An open-source, faster Devin alternative
TypeScript
docs: clarify repo github auth model
Igor Zalutski51c2f45d970a
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex 5bc4309c..32205fa9 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -55,7 +55,7 @@ const session = await oc.sessions.get("ses_..."); // server, org key</Tabs>-`agent` is **required** (create a saved [agent](#agents) first); a resolvable model [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. `metadata` is opaque **application routing state** — a JSON object (≤ 16 KB) stored on the session, returned by get/list, and delivered **verbatim in webhooks** so a callback handler can route to the right external record without a lookup; it is **never** shown to the model, **not** indexed/queryable, and distinct from `key` (get-or-create) and `Idempotency-Key` (dedupe). `input` is the task — a string or a full [envelope](/agent-sessions/messaging#message-input). For the managed runtimes (`claude`, `codex`), put all task-critical context in the task text. There's no fixed byte cap on `input`, but it counts against the model's context window — **truncate large inputs** (e.g. a PR diff) and have the agent pull the rest through its [sandbox tools](/agent-sessions/runtime-tools) (clone the repo, read files) rather than inlining it. `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). `sources` checks out one or more repositories for the agent **before the first turn**; the checkout credential never enters the agent's sandbox (see [Repos](#repos)). Each entry references a registered [repo](#repos) — `{ repo, ref, sha, name? }` — or is inline — `{ url, ref, sha, name?, auth }`. `ref` (the fetch ref, e.g. `refs/pull/N/head`) and `sha` are both **required**: the ref is fetched and the exact `sha` is pinned and verified. The create response echoes sanitized `sources`; poll `GET /sessions/:id/sources` for live status and `error_code` details.+`agent` is **required** (create a saved [agent](#agents) first); a resolvable model [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. `metadata` is opaque **application routing state** — a JSON object (≤ 16 KB) stored on the session, returned by get/list, and delivered **verbatim in webhooks** so a callback handler can route to the right external record without a lookup; it is **never** shown to the model, **not** indexed/queryable, and distinct from `key` (get-or-create) and `Idempotency-Key` (dedupe). `input` is the task — a string or a full [envelope](/agent-sessions/messaging#message-input). For the managed runtimes (`claude`, `codex`), put all task-critical context in the task text. There's no fixed byte cap on `input`, but it counts against the model's context window — **truncate large inputs** (e.g. a PR diff) and have the agent pull the rest through its [sandbox tools](/agent-sessions/runtime-tools) (clone the repo, read files) rather than inlining it. `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). `sources` checks out one or more repositories for the agent **before the first turn**; the checkout credential never enters the agent's sandbox (see [Repos & GitHub](#github-apps--repos)). Each entry references a registered [repo](#github-apps--repos) — `{ repo, ref, sha, name? }` — or is inline — `{ url, ref, sha, name?, auth }`. `ref` (the fetch ref, e.g. `refs/pull/N/head`) and `sha` are both **required**: the ref is fetched and the exact `sha` is pinned and verified. The create response echoes sanitized `sources`; poll `GET /sessions/:id/sources` for live status and `error_code` details.Client tokens accept `scopes?` (subset of `read`, `steer`) and `ttl?` seconds, clamped to 60–86400 (SDK: `ttlSeconds`).@@ -257,10 +257,14 @@ Pass `key` **or** `credential` (or neither → org default). The agent's `limits## GitHub Apps & Repos-Connect a GitHub App to let OpenComputer obtain short-lived, repo-scoped tokens for the repositories agents may work in. A **Repo** is repository identity + policy. See the [Repos guide](/agent-sessions/repos).+Connect a GitHub App to let OpenComputer obtain short-lived, repo-scoped tokens for the repositories agents may work in. A **Repo** is repository identity + policy. See the [Repos & GitHub guide](/agent-sessions/repos).The OpenComputer-owned App is the current simplest path and is installed from its GitHub App install URL, not by minting an install URL through the SDK. Bring-your-own GitHub App support adds more App records later; repo and session shapes stay the same. **No credential passes through this API.**+GitHub App `mode` values: `oc_app` (OpenComputer owns and mints), `byo_stored_key` (your+App key is encrypted in OpenComputer; OpenComputer mints), and `byo_broker` (your backend+owns the App key and returns operation-scoped short-lived tokens).+<Tabs><Tab title="TypeScript SDK">@@ -268,7 +272,7 @@ The OpenComputer-owned App is the current simplest path and is installed from it| Call | Purpose || --- | --- || `oc.github.apps.list()` | List GitHub Apps available to your org. |-| `oc.github.installations.list(params?)` | List known installations for App-key modes; optional for setup/status. |+| `oc.github.installations.list(params?)` | List known installations for `oc_app` / `byo_stored_key`; optional for setup/status. || `oc.repos.create(params)` | Register (get-or-create) a repo. || `oc.repos.get(id)` · `oc.repos.list()` | Fetch / list. || `oc.repos.update(id, params)` | Update policy `defaults`. |@@ -280,7 +284,7 @@ The OpenComputer-owned App is the current simplest path and is installed from it| Method · Path | Purpose || --- | --- || `GET /github/apps` | List GitHub Apps available to your org. |-| `GET /github/installations?app_id=...` | List known installations for App-key modes; optional for setup/status. |+| `GET /github/installations?app_id=...` | List known installations for `oc_app` / `byo_stored_key`; optional for setup/status. || `POST /repos` | Register (get-or-create) a repo. || `GET /repos/:id` · `GET /repos` | Fetch / list. || `PATCH /repos/:id` | Update policy `defaults`. |@@ -297,7 +301,7 @@ GitHubApp = { id, provider, mode, status, app_slug?, app_name?, is_defaGitHubInstallation = { id, app_id, account_login, status, repository_selection?, created_at }```-Responses **never** contain a token or secret. (SDK camelCase: `branchNamespace`, `appId`, `appSlug`, `accountLogin`.) Installations are a status/preflight surface: App-key modes can list them, while broker-mode Apps may have none because your broker owns that lifecycle. Registering a repo is **optional** under the OpenComputer App — a session can reference `"owner/repo"` directly.+Responses **never** contain a token or secret. (SDK camelCase: `branchNamespace`, `appId`, `appSlug`, `accountLogin`.) Installations are a status/preflight surface: `oc_app` and `byo_stored_key` Apps can list them, while `byo_broker` Apps may have none because your backend owns that lifecycle. Registering a repo is **optional** under the OpenComputer App — a session can reference `"owner/repo"` directly.## Credentialsdiff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdxindex 3a38a2ee..d3d0df9b 100644--- a/docs/agent-sessions/overview.mdx+++ b/docs/agent-sessions/overview.mdx@@ -69,7 +69,7 @@ Use sessions for long-running or interactive agents. For a one-shot command in a<Card title="Session lifecycle" icon="book" href="/agent-sessions/sessions">Statuses, events, results, and limits.</Card>- <Card title="Repos" icon="github" href="/agent-sessions/repos">+ <Card title="Repos & GitHub" icon="github" href="/agent-sessions/repos">Private repo checkout with GitHub access kept outside the agent sandbox.</Card><Card title="Example apps" icon="github" href="https://github.com/diggerhq/oc-sessions-demos">diff --git a/docs/agent-sessions/quickstart.mdx b/docs/agent-sessions/quickstart.mdxindex c8692a03..5cbd4580 100644--- a/docs/agent-sessions/quickstart.mdx+++ b/docs/agent-sessions/quickstart.mdx@@ -204,7 +204,7 @@ Response:<Card title="Events" icon="timeline" href="/agent-sessions/events">Event shape, levels, cursors, and resume behavior.</Card>- <Card title="Repos" icon="github" href="/agent-sessions/repos">+ <Card title="Repos & GitHub" icon="github" href="/agent-sessions/repos">Check out private repositories without putting GitHub tokens in the sandbox.</Card><Card title="Example app" icon="github" href="https://github.com/diggerhq/oc-sessions-demos">diff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdxindex 994e3add..c5f351d3 100644--- a/docs/agent-sessions/repos.mdx+++ b/docs/agent-sessions/repos.mdx@@ -1,21 +1,45 @@----title: "Repos"-description: "Connect a Git repository to your sessions — the agent works on the code, GitHub access stays isolated"+title: "Repos & GitHub"+description: "Use GitHub Apps to authorize private repo work while keeping credentials out of agent sandboxes"----A **Repo** connects a Git repository to your sessions. The agent reads and edits the-checked-out code in its sandbox; authenticated GitHub operations (clone, fetch, push, PR,-comment) run outside it, with a short-lived token minted just in time — the agent never-holds a GitHub credential.+A **Repo** is repository identity plus policy. A **GitHub App** is the authority+OpenComputer uses to obtain short-lived GitHub tokens. Sessions point at repos and+sources; GitHub credentials stay behind that boundary and never enter the agent sandbox.<Note>**Preview** — APIs may change before general availability.</Note>-## Connect a GitHub App+## Model-Connect a GitHub App once; OpenComputer uses that App to obtain short-lived, repo-scoped-tokens just in time for each operation. Launch scope is source checkout before the first-turn; additional remote GitHub actions (`source.fetch_ref`, PR publish, comments,-statuses) use the same boundary and are coming next.+| Concept | Role | Boundary |+| --- | --- | --- |+| GitHub App | Token authority for GitHub operations. | Does not define repo policy or session refs. |+| Installation | GitHub account and repo selection for an App. | `byo_broker` can keep this state inside your backend. |+| Repo | Provider, owner, repo name, optional App pin, and permission ceiling. | Stores no tokens, private keys, or session refs. |+| Source | Per-session checkout: repo/url, `ref`, `sha`, and local name. | Auth comes from the repo's App unless using inline auth. |++Launch scope is source checkout before the first turn. Remote GitHub actions+(`source.fetch_ref`, PR publish, comments, statuses) use the same boundary and are coming+next.++<Note>+The Repo/Source shape is provider-neutral: `provider`, `owner`, `repo`, `ref`, `sha`.+GitHub uses GitHub Apps as its auth surface. A future GitLab integration should add a+provider-specific auth surface, but sessions should still reference repos and sources the+same way.+</Note>++## GitHub App modes++| Mode | Who owns the App key | Who mints tokens | Status |+| --- | --- | --- | --- |+| `oc_app` | OpenComputer | OpenComputer | Current simplest path. |+| `byo_stored_key` | You; encrypted in OpenComputer | OpenComputer | Coming next. |+| `byo_broker` | You; kept in your backend | Your broker endpoint | Coming next. |++In all modes, each operation asks for the minimum GitHub permission it needs. Checkout+needs read-only contents access; future publish/comment/status tools ask for write access+only for that operation.### OpenComputer GitHub App (current simplest path)@@ -44,6 +68,21 @@ const installs = await oc.github.installations.list({ appId: "gha_oc" });// [{ id: "ghi_...", appId: "gha_oc", accountLogin: "acme", status: "active" }]```+### Bring your own GitHub App (coming next)++Use a bring-your-own App when you want GitHub audit logs, PRs, comments, and statuses to+come from your own App instead of OpenComputer's.++`byo_stored_key` means OpenComputer stores your App private key encrypted and mints+operation-scoped installation tokens on demand. This keeps setup simple, but OpenComputer+is still the token authority.++`byo_broker` means your backend keeps the App key and owns the full GitHub lifecycle. When+OpenComputer needs a GitHub operation, it sends a signed request with the repo, operation,+ref/sha, and requested permissions; your broker returns a short-lived installation token+or denies the request. OpenComputer may not be able to list installations for `byo_broker`+Apps, because your backend owns that state.+### Inline short-lived tokenThe no-setup workaround is to pass a real short-lived token inline on the source, using the@@ -87,15 +126,6 @@ checkout, then purges it. It's a temporary shortcut for environments that have nconnected a GitHub App yet.</Warning>-### Bring your own GitHub App (not yet available)--Not built yet — here's how we expect it to work. To have PRs and comments appear as-*your own* App (branding, audit), you'll register a GitHub App entity with OpenComputer:-either store its App id + private key in OpenComputer, or keep the key and host a small-token-broker endpoint. Stored-key Apps can expose installations for setup status; broker-Apps can own the full GitHub lifecycle on your side, with your broker as the authority.-The repo and session shape below stays the same.-## Register a repoOnce the GitHub App is installed, register a repo — optional: any installed repo can be@@ -210,8 +240,8 @@ git-ops sandbox — the agent never runs authenticated `git`/`gh` and never seesshell, files, env, the event log, or telemetry. (The one exception is the inline-tokenworkaround, held encrypted only until the first checkout, then purged.)- App private keys for the OpenComputer App and stored-key Apps live only in- OpenComputer's **control plane**, never in a sandbox. Broker-mode App keys stay in- your backend.+ OpenComputer's **control plane**, never in a sandbox. `byo_broker` App keys stay in your+ backend.- Agent pushes go to an `oc/<session>/…` branch namespace — **no protected-branch push,no force-push.**- Submodules and Git LFS aren't supported yet. Lost-sandbox recovery and prebuiltdiff --git a/docs/agent-sessions/workspaces.mdx b/docs/agent-sessions/workspaces.mdxindex bd80a93e..06233d23 100644--- a/docs/agent-sessions/workspaces.mdx+++ b/docs/agent-sessions/workspaces.mdx@@ -4,7 +4,7 @@ title: "Workspaces"description: "Prepared repo environments, rebuilt on push (coming soon)"----<Note>**Planned.** This page describes planned API shape, not shipped behavior. Today a session works in its [sandbox](/agent-sessions/runtime-tools); for a public repo the agent clones on demand, and for a private repo OpenComputer checks it out before the first turn (see [Repos](/agent-sessions/repos)).</Note>+<Note>**Planned.** This page describes planned API shape, not shipped behavior. Today a session works in its [sandbox](/agent-sessions/runtime-tools); for a public repo the agent clones on demand, and for a private repo OpenComputer checks it out before the first turn (see [Repos & GitHub](/agent-sessions/repos)).</Note>Cloning, installing, and building take minutes. A **workspace** does that work ahead of time — on every push — and snapshots the result, so a session boots into a ready machine in seconds. It is a first-class resource (not an agent attribute), shared by every session that lands on its repo(s).diff --git a/sdks/typescript/src/agents/repos.ts b/sdks/typescript/src/agents/repos.tsindex 0278f48b..960c8f6e 100644--- a/sdks/typescript/src/agents/repos.ts+++ b/sdks/typescript/src/agents/repos.ts@@ -46,12 +46,18 @@ export interface Repo {updatedAt?: string;}+/**+ * How a GitHub App mints operation-scoped tokens:+ * - `oc_app`: OpenComputer owns the App key and mints.+ * - `byo_stored_key`: you own the App; OpenComputer stores the key encrypted and mints.+ * - `byo_broker`: your backend owns the App key/lifecycle and returns short-lived tokens.+ */export type GitHubAppMode = "oc_app" | "byo_stored_key" | "byo_broker" | (string & {});export type GitHubAppStatus = "active" | "suspended" | "revoked" | (string & {});/**- * A GitHub App OpenComputer can use to mint short-lived, repo-scoped tokens. The built-in- * OpenComputer App is `oc_app`; user-owned App modes are additive.+ * A GitHub App authority for repo operations. The built-in OpenComputer App is `oc_app`;+ * user-owned App modes are additive and keep the Repo/Source shape unchanged.*/export interface GitHubApp {id: string; // gha_…@@ -66,8 +72,8 @@ export interface GitHubApp {/*** A GitHub App installation visible to OpenComputer. Installations are useful for setup- * status and preflight; auth resolves through the App, and broker-mode Apps may have no- * OpenComputer-visible installations.+ * status and preflight. `byo_broker` Apps may have no OpenComputer-visible installations+ * because your backend owns that lifecycle.*/export interface GitHubInstallation {id: string; // ghi_…@@ -90,11 +96,11 @@ export interface ListGitHubInstallationsParams {}/**- * Repos — repository identity + policy (the "where" a session works), analogous to- * {@link Agents}. Auth resolves through a GitHub App; no credential is passed here.+ * Repos — provider-neutral repository identity + policy (the "where" a session works).+ * Auth for GitHub repos resolves through a GitHub App; no credential is passed here.* Register once and reference from `sources: [{ repo, ref, sha }]`. A session can also* reference `"owner/repo"` directly without creating a Repo handle. See the- * [Repos guide](https://docs.opencomputer.dev/agent-sessions/repos).+ * [Repos & GitHub guide](https://docs.opencomputer.dev/agent-sessions/repos).*/export class Repos {constructor(private readonly http: Http) {}@@ -132,7 +138,7 @@ export class GitHubApps {}}-/** GitHub App installations visible to OpenComputer; optional for broker-mode Apps. */+/** GitHub App installations visible to OpenComputer; optional for `byo_broker` Apps. */export class GitHubInstallations {constructor(private readonly http: Http) {}list(params: ListGitHubInstallationsParams = {}): Promise<Page<GitHubInstallation>> {