An open-source, faster Devin alternative
TypeScript
docs/sdk: make github app the repo auth seam
Igor Zalutskie88422a4d40c
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex 101c44a7..9d7d6c7f 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -255,11 +255,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.-## GitHub App installations & Repos+## GitHub Apps & Repos-Install the **OpenComputer GitHub App** to let OpenComputer mint short-lived, repo-scoped tokens for the GitHub accounts and repositories you select. 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 guide](/agent-sessions/repos).-The OC-owned App is installed from the dashboard or GitHub, not by minting an install URL through the SDK. Bring-your-own GitHub App support will add a separate GitHub App entity later; repo and session shapes stay the same. **No credential passes through this API.**+The OpenComputer-owned App is the current simplest path and is installed from the dashboard or GitHub, 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.**<Tabs>@@ -267,7 +267,8 @@ The OC-owned App is installed from the dashboard or GitHub, not by minting an in| Call | Purpose || --- | --- |-| `oc.github.installations.list()` | List OpenComputer GitHub App installations available to your org. |+| `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.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`. |@@ -278,7 +279,8 @@ The OC-owned App is installed from the dashboard or GitHub, not by minting an in| Method · Path | Purpose || --- | --- |-| `GET /github/installations` | List OpenComputer GitHub App installations available to your org. |+| `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. || `POST /repos` | Register (get-or-create) a repo. || `GET /repos/:id` · `GET /repos` | Fetch / list. || `PATCH /repos/:id` | Update policy `defaults`. |@@ -287,14 +289,15 @@ The OC-owned App is installed from the dashboard or GitHub, not by minting an in</Tabs>-Repo create body: `owner`, `repo`, `provider?` (`github`, default), `name?` (a handle), `installation_id?`, `defaults?`. **No `auth`** — auth comes from the GitHub App installation. **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`).+Repo create body: `owner`, `repo`, `provider?` (`github`, default), `name?` (a handle), `app_id?`, `defaults?`. **No `auth`** — auth resolves through the GitHub App. **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`).```-Repo = { id, provider, owner, repo, name?, installation_id?, defaults?, created_at, updated_at }-GitHubInstallation = { id, account_login, status, repository_selection?, created_at }+Repo = { id, provider, owner, repo, name?, app_id?, defaults?, created_at, updated_at }+GitHubApp = { id, provider, mode, status, app_slug?, app_name?, is_default?, created_at }+GitHubInstallation = { id, app_id, account_login, status, repository_selection?, created_at }```-Responses **never** contain a token or secret. (SDK camelCase: `branchNamespace`, `installationId`, `accountLogin`.) 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: 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.## Credentialsdiff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdxindex 833748c2..0a6e5a73 100644--- a/docs/agent-sessions/repos.mdx+++ b/docs/agent-sessions/repos.mdx@@ -10,14 +10,14 @@ holds a GitHub credential.<Note>**Preview** — APIs may change before general availability.</Note>-## Connect GitHub+## Connect a GitHub App-Connect once; OpenComputer mints 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.+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.-### OpenComputer GitHub App (recommended)+### OpenComputer GitHub App (current simplest path)Install the **OpenComputer** GitHub App and select the repositories agents may work in —you choose the repos, and can change the selection or uninstall anytime. No keys to@@ -34,11 +34,14 @@ publish/comment action.Start the install from your dashboard (**Integrations → GitHub**) or from the publicOpenComputer GitHub App page. No API call is needed to install the OC-owned App.-After installation, you can verify which GitHub accounts are available:+After installation, you can verify the App and visible installs:```ts-const installs = await oc.github.installations.list();-// [{ id: "ghi_...", accountLogin: "acme", status: "active" }]+const apps = await oc.github.apps.list();+// [{ id: "gha_oc", appName: "OpenComputer", mode: "oc_app", status: "active" }]++const installs = await oc.github.installations.list({ appId: "gha_oc" });+// [{ id: "ghi_...", appId: "gha_oc", accountLogin: "acme", status: "active" }]```### Inline short-lived token@@ -81,7 +84,7 @@ The inline token **can't refresh** — once it expires the session can't fetch,recover, so use it only for sessions that finish within the token's life. OpenComputerrejects a far-future or missing expiry and holds it encrypted only until the firstcheckout, then purges it. It's a temporary shortcut for environments that have not-installed the App yet — **prefer the GitHub App.**+connected a GitHub App yet.</Warning>### Bring your own GitHub App (not yet available)@@ -89,8 +92,9 @@ installed the App yet — **prefer the GitHub App.**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. That App will then have its own installations. The repo and session-shape below stay the same.+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 repo@@ -103,6 +107,7 @@ used in a session directly; a Repo adds policy and a stable handle.const repo = await oc.repos.create({owner: "acme",repo: "web",+ // appId: "gha_...", // optional: org default, then OC Appdefaults: { allow: ["contents:read"] },});```@@ -117,9 +122,11 @@ Authorization: Bearer $OPENCOMPUTER_API_KEY</CodeGroup>Get-or-create, owner-scoped, idempotent by `(provider, owner, repo)`. **No credential is-passed** — auth comes from the GitHub App installation. Optional `defaults`:+passed** — auth resolves through the GitHub App. Optional `appId` pins a repo to a+specific App; otherwise OpenComputer uses your org default App, then the OpenComputer App.+Optional `defaults`:`{ branchNamespace, allow }` (`allow` is a GitHub permission ceiling; OpenComputer still-mints the minimum token per operation).+requests the minimum token per operation).## Use it in a session@@ -198,12 +205,13 @@ git-ops sandbox — the agent never runs authenticated `git`/`gh` and never sees## Guarantees-- **GitHub App-backed tokens are never stored** — OpenComputer mints short-lived,+- **GitHub App-backed tokens are never stored** — OpenComputer obtains 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 one exception is the inline-tokenworkaround, held encrypted only until the first checkout, then purged.)-- The GitHub App's private key lives only in OpenComputer's **control plane**, never in a- sandbox.+- 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.- 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/sdks/typescript/src/agents/client.ts b/sdks/typescript/src/agents/client.tsindex 008613f8..52ff9fe8 100644--- a/sdks/typescript/src/agents/client.ts+++ b/sdks/typescript/src/agents/client.ts@@ -22,7 +22,7 @@ export class OpenComputer {readonly sessions: Sessions;readonly credentials: Credentials;readonly repos: Repos;- /** GitHub integration (`oc.github.installations.list()`). Connect via the OpenComputer App. */+ /** GitHub integration (`oc.github.apps.list()`). Connect via a GitHub App. */readonly github: GitHub;constructor(opts: OpenComputerOptions) {diff --git a/sdks/typescript/src/agents/index.ts b/sdks/typescript/src/agents/index.tsindex 6f29e844..fc59213e 100644--- a/sdks/typescript/src/agents/index.ts+++ b/sdks/typescript/src/agents/index.ts@@ -9,10 +9,11 @@ export type {} from "./sessions.js";export { Agents } from "./agents.js";export type { CreateAgentParams, UpdateAgentParams, Page } from "./agents.js";-export { Repos, GitHub, GitHubInstallations } from "./repos.js";+export { Repos, GitHub, GitHubApps, GitHubInstallations } from "./repos.js";export type {CreateRepoParams, UpdateRepoParams, Repo, RepoDefaults, GitHubPermission,- GitHubInstallation,+ GitHubApp, GitHubAppMode, GitHubAppStatus, GitHubInstallation,+ ListGitHubInstallationsParams,} from "./repos.js";export { Credentials } from "./credentials.js";export type { CreateCredentialParams } from "./credentials.js";diff --git a/sdks/typescript/src/agents/repos.ts b/sdks/typescript/src/agents/repos.tsindex 9fc2f912..0278f48b 100644--- a/sdks/typescript/src/agents/repos.ts+++ b/sdks/typescript/src/agents/repos.ts@@ -12,7 +12,7 @@ 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; OpenComputer still mints the minimum per operation. */+ * may ever authorize — a ceiling; each operation still requests the minimum token. */allow?: GitHubPermission[];}@@ -22,15 +22,15 @@ export interface CreateRepoParams {repo: string;/** Optional handle for your own reference; identity is (provider, owner, repo). */name?: string;- /** Optional explicit GitHub App installation id. Usually resolved from owner/repo. */- installationId?: string;+ /** Optional explicit GitHub App id. Defaults to your org's default app, then the OC App. */+ appId?: string;defaults?: RepoDefaults;}export interface UpdateRepoParams {defaults?: RepoDefaults;name?: string;- installationId?: string;+ appId?: string;}export interface Repo {@@ -39,20 +39,40 @@ export interface Repo {owner: string;repo: string;name?: string;- /** The GitHub App installation that authorizes this repo (auth lives there, not here). */- installationId?: string;+ /** The GitHub App that authorizes this repo (auth lives there, not here). */+ appId?: string;defaults?: RepoDefaults;createdAt?: string;updatedAt?: string;}+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.+ */+export interface GitHubApp {+ id: string; // gha_…+ provider: "github" | (string & {});+ mode: GitHubAppMode;+ status: GitHubAppStatus;+ appSlug?: string;+ appName?: string;+ isDefault?: boolean;+ createdAt?: string;+}+/**- * An installation of the OpenComputer GitHub App on a GitHub user/org. OpenComputer uses- * this to mint short-lived, repo-scoped tokens just in time; no token is ever returned.+ * 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.*/export interface GitHubInstallation {id: string; // ghi_…- status: "active" | "suspended" | "revoked";+ appId: string; // gha_…+ status: GitHubAppStatus;/** The GitHub org/user the App is installed on. */accountLogin: string;/** GitHub's raw installation id, when exposed for audit/debug. */@@ -63,9 +83,15 @@ export interface GitHubInstallation {export interface Page<T> { data: T[]; nextCursor?: string | null; }+export interface ListGitHubInstallationsParams {+ appId?: string;+ limit?: number;+ cursor?: string;+}+/*** Repos — repository identity + policy (the "where" a session works), analogous to- * {@link Agents}. Auth comes from a GitHub App installation; no credential is passed here.+ * {@link Agents}. Auth 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).@@ -88,18 +114,28 @@ export class Repos {}}-/** GitHub integration surface (`oc.github`). v1: list OpenComputer App installations. */+/** GitHub integration surface (`oc.github`). */export class GitHub {+ readonly apps: GitHubApps;readonly installations: GitHubInstallations;constructor(http: Http) {+ this.apps = new GitHubApps(http);this.installations = new GitHubInstallations(http);}}-/** OpenComputer GitHub App installations available to your org. */+/** GitHub Apps available to your org. BYO App registration methods are additive later. */+export class GitHubApps {+ constructor(private readonly http: Http) {}+ list(params: { limit?: number; cursor?: string } = {}): Promise<Page<GitHubApp>> {+ return this.http.request("GET", "/github/apps", { query: params as Query });+ }+}++/** GitHub App installations visible to OpenComputer; optional for broker-mode Apps. */export class GitHubInstallations {constructor(private readonly http: Http) {}- list(): Promise<Page<GitHubInstallation>> {- return this.http.request("GET", "/github/installations");+ list(params: ListGitHubInstallationsParams = {}): Promise<Page<GitHubInstallation>> {+ return this.http.request("GET", "/github/installations", { query: params as Query });}}diff --git a/sdks/typescript/src/agents/sessions.ts b/sdks/typescript/src/agents/sessions.tsindex b5c599b0..0fa9e80e 100644--- a/sdks/typescript/src/agents/sessions.ts+++ b/sdks/typescript/src/agents/sessions.ts@@ -45,7 +45,7 @@ export type SessionSource = RegisteredRepoSource | InlineRepoSource;export interface RegisteredRepoSource {/** A registered repo id (`repo_…`) or `owner/repo` slug. Auth comes from your GitHub- * App installation — no per-source credential. */+ * App — no per-source credential. */repo: string;url?: never;auth?: never;@@ -64,15 +64,15 @@ export interface InlineRepoSource {ref: string;sha: string;name?: string;- /** Inline auth (registered repos use the GitHub App installation instead). */+ /** Inline auth (registered repos use the resolved GitHub App instead). */auth: SourceAuth;}/*** 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.+ * so it's only for sessions that finish within the token's life. Prefer connecting a+ * GitHub App (durable). Held encrypted, used once, then purged.*/export type SourceAuth =| { type: "risky_short_lived_token"; token: string; expiresAt: string };@@ -83,8 +83,8 @@ export type SourceStatus =export type SourceErrorCode =| "source.auth_required"| "source.auth_ambiguous"- | "source.installation_suspended"- | "source.installation_revoked"+ | "source.app_suspended"+ | "source.app_revoked"| "source.repo_not_selected"| "source.permission_missing"| "source.mint_failed"