An open-source, faster Devin alternative
TypeScript
docs/sdk: GitHub auth as a connection — OC App is v1, BYO/broker coming soon
Igor Zalutski94ff75440b59
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex db169381..f99ee90e 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -73,12 +73,11 @@ Turn = {started_at?, completed_at?}-SessionSource = // a sources[] entry — WIRE shape (SDK is- { repo, ref, sha, name? } // camelCase: brokerUrl, expiresAt)- | { url, ref, sha, name?, auth } // name defaults to the repo name; type defaults "git"-SourceAuth =- { type: "token_broker", broker_url, grant } // grant: a short-lived reference, not a token- | { type: "risky_short_lived_token", token, expires_at } // discouraged; short-lived only+SessionSource = // a sources[] entry (SDK camelCase: expiresAt)+ { repo, ref, sha, name? } // a registered repo id or "owner/repo" — auth via your connection+ | { url, ref, sha, name?, auth } // inline shortcut; name defaults to repo name, type defaults "git"+SourceAuth = // inline path ONLY (connection-backed repos need none)+ { type: "risky_short_lived_token", token, expires_at } // workaround; short-lived; can't refreshSourceSummary = { name, status, path, sha } // sanitized; in the create response + GET …/sources// status: pending | materializing | resolved | failed | unavailable | auth_required```@@ -251,9 +250,11 @@ Create body: `name`, `prompt`, `model`, `runtime?` (`claude` | `codex`), `key?`,Pass `key` **or** `credential` (or neither → org default). The agent's `limits` are the defaults for its sessions; a session's own `limits` override. Each agent has a monotonic `revision` (bumped on PATCH) that sessions pin in `agent_snapshot.revision`, so you can tell which version produced a run.-## Repos+## GitHub connections & Repos-A reusable, owner-scoped connection to a Git repository — referenced from a session's `sources`. See the [Repos guide](/agent-sessions/repos) for the security model.+Auth lives on a **connection** (how OpenComputer mints tokens for your org); a **Repo** is repo identity + policy that references it. See the [Repos guide](/agent-sessions/repos).++**Connect GitHub** by installing the **OpenComputer GitHub App** (recommended, durable; bring-your-own App + broker coming soon). The install captures an owner-scoped connection; OpenComputer then mints short-lived, repo-scoped tokens just in time. **No credential passes through this API.**<Tabs>@@ -261,9 +262,10 @@ A reusable, owner-scoped connection to a Git repository — referenced from a se| Call | Purpose || --- | --- |-| `oc.repos.create(params)` | Register (get-or-create) a repo connection. |+| `oc.repos.create(params)` | Register (get-or-create) a repo. || `oc.repos.get(idOrSlug)` · `oc.repos.list()` | Fetch / list. |-| `oc.repos.update(id, params)` | Update `auth` / policy `defaults`. |+| `oc.repos.update(id, params)` | Update policy `defaults`. |+| `oc.github.connections.list()` | List connected GitHub Apps (installs). |</Tab>@@ -271,35 +273,23 @@ A reusable, owner-scoped connection to a Git repository — referenced from a se| Method · Path | Purpose || --- | --- |-| `POST /repos` | Register (get-or-create) a repo connection. |+| `POST /repos` | Register (get-or-create) a repo. || `GET /repos/:id` · `GET /repos` | Fetch / list. |-| `PATCH /repos/:id` | Update `auth` / policy `defaults`. |+| `PATCH /repos/:id` | Update policy `defaults`. |+| `GET /github/connections` | List connected GitHub Apps (installs). |</Tab></Tabs>-Create body: `owner`, `repo`, `provider?` (`github`, default), `name?` (a handle), `auth`, `defaults?`. **Idempotent by `(provider, owner, repo)`** — a fresh register returns **201**, a repeat returns the existing repo with **200**. Stores **no GitHub token** — only the broker URL, repo identity, and policy.--`auth` — how OpenComputer obtains tokens (no standing credential is stored):-- `{ "type": "token_broker", "broker_url": "https://…" }` — your [broker](/agent-sessions/repos#what-you-provide) endpoint; OpenComputer signs each request to it, verified against its published JWKS.--`defaults` (optional policy): `{ "branch_namespace"?: "oc/{session}/", "allow"?: ["contents:read", "pull_requests:write", …] }` — `allow` is a ceiling on what any request may mint.--```-Repo = { id, provider, owner, repo, name?, broker_url?, defaults?, created_at, updated_at }-```--The response **never** contains a token or secret. (SDK is camelCase: `brokerUrl`, `branchNamespace`.) `defaults.allow` is a **GitHub permission ceiling** (e.g. `contents:read`, `pull_requests:write`) — not a free-form list.--**Broker request** (the contract your `broker_url` implements). At materialization OpenComputer `POST`s your broker a **signed** request (verify against OpenComputer's published JWKS):+Repo create body: `owner`, `repo`, `provider?` (`github`, default), `name?` (a handle), `defaults?`. **No `auth`** — auth comes from your GitHub connection. **Idempotent by `(provider, owner, repo)`** (201 fresh / 200 repeat). `defaults`: `{ branch_namespace?, allow? }` — `allow` is a **GitHub permission ceiling** (e.g. `contents:read`, `pull_requests:write`).```-→ { owner_id, repo, operation, permissions, ref, sha } // signed by OpenComputer-← { token, expires_at, permissions } // a JIT installation token+Repo = { id, provider, owner, repo, name?, connection_id?, defaults?, created_at, updated_at }+Connection = { id, provider, type, status, account_login, created_at } // type: oc_app (byo_* coming soon)```-**Bind `owner_id` to your OpenComputer org** (allowlist or a one-time registration) so a foreign org can't point at your broker URL and mint tokens for your installation. Mint only the intersection of your grant/policy and the requested scope — never broader. See the [Repos guide](/agent-sessions/repos#what-you-provide).+Responses **never** contain a token or secret. (SDK camelCase: `branchNamespace`, `accountLogin`.) Registering a repo is **optional** under the OpenComputer App — a session can reference `"owner/repo"` directly.## Credentialsdiff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdxindex e77f53a0..3d139fd9 100644--- a/docs/agent-sessions/repos.mdx+++ b/docs/agent-sessions/repos.mdx@@ -1,73 +1,71 @@---title: "Repos"-description: "Connect a private repo to your sessions behind a security boundary — the agent works on the code, GitHub access stays isolated"+description: "Connect a private repo behind a security boundary — the agent works on the code, GitHub access stays isolated and durable"---A **Repo** connects a Git repository to your sessions and draws a **security boundary**around it. The agent reads and edits the checked-out code in its own sandbox, but every-authenticated GitHub operation — clone, fetch, push, PR, comment — runs in a-**separate, single-use sandbox the agent can't reach**, with a token minted just in time-and destroyed after. Registering a repo is how you set that boundary up.+authenticated GitHub operation — clone, fetch, push, PR, comment — runs in a **separate,+single-use sandbox the agent can't reach**, with a token minted just in time and+destroyed after.<Note>**Why isolate.** A GitHub token is *authority*, not just a secret — anything holding itcan push, read your other repos, or exfiltrate. So OpenComputer keeps it out of theagent entirely: the agent requests GitHub *outcomes*, and the credential lives only in-the repo's dedicated operation sandbox, one operation at a time.+the isolated operation sandbox, one operation at a time.</Note>-A Repo is to *where* an agent works what an [Agent](/agent-sessions/agents) is to *what*-it runs: a reusable, owner-scoped entity you register once and reference by id.+## Connect GitHub-<Note>**Status — in active rollout.** Today a session accepts inline `sources` at-create (below). Registered **Repos**, the broker drop-in, automatic checkout, and the-GitHub tools are landing now; this page is the target contract.</Note>+Sessions are **durable** — an agent might wait hours for input, then push — so a single+token (GitHub installation tokens last ~1h) isn't enough; OpenComputer needs to mint a+fresh one on demand. You connect GitHub **once**, and OpenComputer mints short-lived,+repo-scoped tokens just in time, for every operation, across the whole session.-## What you provide+| Method | How | Status |+| --- | --- | --- |+| **OpenComputer GitHub App** | install the App on your repos — OpenComputer mints from it | **Recommended** |+| Bring your own App — delegated key | register your App's id + private key | Coming soon |+| Bring your own App — broker | host a small mint endpoint OpenComputer calls | Coming soon |+| Inline short-lived token | pass a token per session (no refresh) | Workaround — see [below](#inline-token-the-no-setup-workaround) |-You own a **GitHub App** (you hold its private key) and host a small **token broker**-endpoint. OpenComputer stores no GitHub credential; at materialization it calls your-broker with a **signed** request, and your broker mints a fresh, repo-scoped,-short-lived installation token for that one operation. Your broker:+### OpenComputer GitHub App (recommended)-1. **Verifies the request is OpenComputer's** — each request is signed; verify it- against OpenComputer's published JWKS (no shared secret for you to store).-2. **Binds it to your org** — the request carries the OpenComputer `owner_id`, the- `repo`, and the `operation`. Confirm the `owner_id` is *your* OpenComputer org (an- allowlist, or a one-time registration handshake) — so another customer can't point- at your broker URL and have it mint tokens for your installation (confused-deputy).-3. **Mints to the policy, never more** — issue an installation token scoped to that- repo and the minimum permissions the operation needs, with a short TTL.+Install the **OpenComputer** GitHub App on your org and the repos you want agents to work+in — you choose the repos and the permissions, and can uninstall anytime. That's the+whole setup: no keys to manage, no endpoint to host. From then on OpenComputer mints a+fresh, narrowly-scoped token for each operation and discards it, so **durable sessions+and recovery just work**.-<Note>A drop-in `ocGithubBroker()` that does all three is **coming soon**. Until then,-implement the contract above — it's a thin wrapper over your existing GitHub App-client. See the [broker contract](/agent-sessions/api-reference#repos) for exact shapes.</Note>+<Note>**Bring your own GitHub App** — so PRs and comments show as *your* App+(branding/audit) — is coming soon, in two flavors: register your App's private key with+OpenComputer, or keep the key and host a tiny mint endpoint OpenComputer calls. Same repo+model and session API; your integration won't change.</Note>## Register a repo+Once GitHub is connected, register a repo — optional: any installed repo can be used in a+session directly; a Repo adds policy and a stable handle.+<CodeGroup>```ts TypeScript SDK-const repo = await oc.repos.create({- owner: "acme",- repo: "web",- auth: { type: "token_broker", brokerUrl: "https://app.example.com/oc/github-token" },-});+const repo = await oc.repos.create({ owner: "acme", repo: "web" });``````http REST APIPOST /v3/reposAuthorization: Bearer $OPENCOMPUTER_API_KEY-{ "provider": "github", "owner": "acme", "repo": "web",- "auth": { "type": "token_broker", "broker_url": "https://app.example.com/oc/github-token" } }+{ "provider": "github", "owner": "acme", "repo": "web" }```</CodeGroup>-Get-or-create, owner-scoped, idempotent by `(provider, owner, repo)`. It stores only the-broker URL, repo identity, and policy defaults — **never a token**. Sessions then-reference the repo with no per-session secret.+Get-or-create, owner-scoped, idempotent by `(provider, owner, repo)`. **No credential is+passed** — auth comes from your GitHub connection. Optional `defaults`:+`{ branchNamespace, allow }` (`allow` is a GitHub permission ceiling).## Use it in a session@@ -84,17 +82,26 @@ const session = await oc.sessions.create({can't be fetched directly.- **`sha`** (required) — the exact commit, pinned and verified after fetch.-A session can list several sources (a PR's base + head). Sources are **immutable**; the-agent pulls more refs mid-session via the `source.fetch_ref` tool.+You can also reference `"owner/repo"` directly instead of a registered id. A session can+list several sources (a PR's base + head); they're **immutable**, and the agent pulls+more refs mid-session via the `source.fetch_ref` tool.-**Inline, without registering** — pass `url` + a per-session `grant` (a short-lived-reference your app mints) instead of a registered `repo`:+## Inline token — the no-setup workaround++Haven't connected the App yet? Pass a real short-lived token inline with the+deliberately-named `risky_short_lived_token` auth:```tssources: [{ url: "https://github.com/acme/web.git", ref: "refs/pull/42/head", sha: "abc123…",- auth: { type: "token_broker", brokerUrl: "…", grant: "<grant>" } }]+ auth: { type: "risky_short_lived_token", token: "ghs_…", expiresAt: "…" } }]```+It works today but **can't refresh** — once the token expires the session can't fetch,+push, or recover (so it's only safe for sessions that finish within the token's life).+OpenComputer rejects a far-future/missing expiry, holds it **encrypted only until the+first checkout, then purges it**. This is a **temporary shortcut until the App-based+methods above land — prefer the GitHub App.**+## What the agent can doLocal Git works normally on the checkout (`status`/`diff`/`log`, edit, test, local@@ -107,25 +114,14 @@ the agent never runs authenticated `git`/`gh` and never sees a token:| `github.publish_branch` / `publish_pull_request` | push changes / open a PR | Coming soon || `github.comment` / `github.set_status` | comment, set a commit status | Coming soon |-Write actions need write scope; if the repo's grant doesn't cover it the action reports-`auth_required` rather than reusing read scope. *(Coming soon.)*-## Guarantees-- **No GitHub token is ever stored** — a repo holds only a broker URL + identity; a- per-session grant is an encrypted *reference*, not a credential.-- **Tokens are minted just in time, per operation** — repo-scoped, short-lived, and- destroyed with the isolated job. None ever reaches the agent's prompt, shell, files,- env, the event log, or telemetry.+- **No GitHub token is ever stored** — OpenComputer mints short-lived, repo-scoped tokens+ just in time and destroys them. None reaches the agent's prompt, shell, files, env, the+ event log, or telemetry.+- The GitHub App's private key lives only in OpenComputer's **control plane**, never in a+ sandbox.- 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 prebuiltcheckouts for large repos ([Workspaces](/agent-sessions/workspaces)) are firming up.--<Note>-**No broker yet?** Pass a real short-lived token inline with the deliberately-named-`risky_short_lived_token` auth. OpenComputer rejects a far-future/missing expiry, stores-it **encrypted** only until the first checkout, then purges it — it never becomes a-durable credential, and the source can't be recovered once the token expires. Prefer the-broker.-</Note>diff --git a/sdks/typescript/src/agents/client.ts b/sdks/typescript/src/agents/client.tsindex d66b00d9..c0c6d118 100644--- a/sdks/typescript/src/agents/client.ts+++ b/sdks/typescript/src/agents/client.ts@@ -2,7 +2,7 @@ import { Http, type HttpOptions } from "./http.js";import { Agents } from "./agents.js";import { Sessions } from "./sessions.js";import { Credentials } from "./credentials.js";-import { Repos } from "./repos.js";+import { Repos, GitHub } from "./repos.js";export interface OpenComputerOptions extends HttpOptions {/** Your OpenComputer org API key (server-side only — never ship it to a browser). */@@ -22,6 +22,8 @@ export class OpenComputer {readonly sessions: Sessions;readonly credentials: Credentials;readonly repos: Repos;+ /** GitHub integration (`oc.github.connections.list()`). Connect via the OpenComputer App. */+ readonly github: GitHub;constructor(opts: OpenComputerOptions) {const http = new Http({ apiKey: opts.apiKey }, opts);@@ -29,5 +31,6 @@ export class OpenComputer {this.sessions = new Sessions(http);this.credentials = new Credentials(http);this.repos = new Repos(http);+ this.github = new GitHub(http);}}diff --git a/sdks/typescript/src/agents/index.ts b/sdks/typescript/src/agents/index.tsindex 4779c7e6..9b3e352f 100644--- a/sdks/typescript/src/agents/index.ts+++ b/sdks/typescript/src/agents/index.ts@@ -8,8 +8,8 @@ export type {} from "./sessions.js";export { Agents } from "./agents.js";export type { CreateAgentParams, UpdateAgentParams, Page } from "./agents.js";-export { Repos } from "./repos.js";-export type { CreateRepoParams, UpdateRepoParams, Repo, RepoAuth, RepoDefaults } from "./repos.js";+export { Repos, GitHub, Connections } from "./repos.js";+export type { CreateRepoParams, UpdateRepoParams, Repo, RepoDefaults, Connection } from "./repos.js";export { Credentials } from "./credentials.js";export type { CreateCredentialParams } from "./credentials.js";export { Destinations, Deliveries } from "./destinations.js";diff --git a/sdks/typescript/src/agents/repos.ts b/sdks/typescript/src/agents/repos.tsindex b8edbe90..cc45de9d 100644--- a/sdks/typescript/src/agents/repos.ts+++ b/sdks/typescript/src/agents/repos.ts@@ -1,27 +1,10 @@import type { Http, Query } from "./http.js";-/**- * How OpenComputer obtains GitHub tokens for a repo. OpenComputer never stores a- * GitHub credential — it calls your **token broker** to mint a short-lived,- * narrowly-scoped installation token just in time for each operation, runs the- * operation in an isolated job, and discards the token.- *- * `token_broker` registers a *connection*: your broker authorizes OpenComputer's- * (signature-verified) requests for this repo, per your broker's own policy. No- * standing GitHub credential is given to OpenComputer; only the broker URL +- * repo identity are recorded.- */-export type RepoAuth = {- type: "token_broker";- /** Your broker endpoint. OpenComputer signs requests to it with its published JWKS. */- brokerUrl: string;-};-export interface RepoDefaults {/** Branch namespace for agent pushes; default `oc/{session}/`. No protected/base push. */branchNamespace?: string;/** GitHub permission ceiling (e.g. `contents:read`, `pull_requests:write`) this repo- * may ever authorize — a ceiling; the broker still decides what to mint per call. */+ * may ever authorize — a ceiling; OpenComputer still mints the minimum per operation. */allow?: string[];}@@ -31,14 +14,15 @@ export interface CreateRepoParams {repo: string;/** Optional handle for your own reference; identity is (provider, owner, repo). */name?: string;- auth: RepoAuth;+ /** Optional explicit GitHub connection id. Defaults to your org's connection. */+ connection?: string;defaults?: RepoDefaults;}export interface UpdateRepoParams {- auth?: RepoAuth;defaults?: RepoDefaults;name?: string;+ connection?: string;}export interface Repo {@@ -47,20 +31,36 @@ export interface Repo {owner: string;repo: string;name?: string;- /** The broker endpoint (not a secret). No GitHub token is ever returned or stored. */- brokerUrl?: string;+ /** The GitHub connection that authorizes this repo (auth lives there, not here). */+ connectionId?: string;defaults?: RepoDefaults;createdAt?: string;updatedAt?: string;}+/**+ * How OpenComputer mints GitHub tokens for your org. Created by **installing the+ * OpenComputer GitHub App** (recommended) — bring-your-own App + broker are coming soon.+ * No GitHub credential is ever returned.+ */+export interface Connection {+ id: string; // conn_…+ provider: string;+ /** `oc_app` today; `byo_app_key` / `byo_broker` coming soon. */+ type: "oc_app" | "byo_app_key" | "byo_broker";+ status: "active" | "suspended" | "revoked";+ /** The GitHub org/user the App is installed on. */+ accountLogin: string;+ createdAt?: string;+}+export interface Page<T> { data: T[]; nextCursor?: string | null; }/**- * Repos — a reusable, registered connection to a repository (the "where" a session- * works), analogous to {@link Agents} (the "what" it runs). Register once; reference- * from many sessions via `sources: [{ repo, ref, sha }]`. Sessions can also use a repo- * inline without registering — see {@link CreateSessionParams.sources}.+ * Repos — repository identity + policy (the "where" a session works), analogous to+ * {@link Agents}. Auth comes from your GitHub {@link Connection}; no credential is passed+ * here. Register once and reference from `sources: [{ repo, ref, sha }]`, or reference+ * `"owner/repo"` directly. See the [Repos guide](https://docs.opencomputer.dev/agent-sessions/repos).*/export class Repos {constructor(private readonly http: Http) {}@@ -79,3 +79,19 @@ export class Repos {return this.http.request("GET", "/repos", { query: params as Query });}}++/** GitHub integration surface (`oc.github`). v1: list your connected installs. */+export class GitHub {+ readonly connections: Connections;+ constructor(http: Http) {+ this.connections = new Connections(http);+ }+}++/** Connected GitHub Apps (installs) for your org. Created via the install flow, not the API. */+export class Connections {+ constructor(private readonly http: Http) {}+ list(): Promise<Page<Connection>> {+ return this.http.request("GET", "/github/connections");+ }+}diff --git a/sdks/typescript/src/agents/sessions.ts b/sdks/typescript/src/agents/sessions.tsindex 6b430615..edcd468d 100644--- a/sdks/typescript/src/agents/sessions.ts+++ b/sdks/typescript/src/agents/sessions.ts@@ -44,7 +44,8 @@ export interface CreateSessionParams {export type SessionSource = RegisteredRepoSource | InlineRepoSource;export interface RegisteredRepoSource {- /** A registered repo id (`repo_…`) or `owner/repo` slug. Auth comes from the repo. */+ /** A registered repo id (`repo_…`) or `owner/repo` slug. Auth comes from your GitHub+ * connection (the installed OpenComputer App) — no per-source credential. */repo: string;/** Required fetch ref (branch or `refs/pull/N/head`). */ref: string;@@ -60,13 +61,17 @@ export interface InlineRepoSource {ref: string;sha: string;name?: string;- /** Per-session auth (the registered-repo path carries auth on the repo instead). */+ /** Inline auth (registered repos use the connection instead — no per-source auth). */auth: SourceAuth;}-/** Per-source auth for the inline path. Prefer a registered repo + broker connection. */+/**+ * Inline-source auth — the **no-setup workaround**. Pass a real short-lived token; it+ * works today but **can't refresh** (once it expires the session can't fetch/push/recover),+ * so it's only for sessions that finish within the token's life. Prefer connecting the+ * OpenComputer GitHub App (durable). Held encrypted, used once, then purged.+ */export type SourceAuth =- | { type: "token_broker"; brokerUrl: string; grant: string }| { type: "risky_short_lived_token"; token: string; expiresAt: string };/** Sanitized per-source status returned on a session (never exposes url/auth). */