Skip to content

An open-source, faster Devin alternative

TypeScript

docs+sdk: bring-your-own GitHub App — register + one-click manifest flow

Igor Zalutski078c749b55dd
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdx
index 2951d43a..06126300 100644
--- a/docs/agent-sessions/api-reference.mdx
+++ b/docs/agent-sessions/api-reference.mdx
@@ -259,7 +259,7 @@ Pass `key` **or** `credential` (or neither → org default). The agent's `limits
The OpenComputer GitHub App lets OpenComputer obtain short-lived, repo-scoped tokens for the repositories agents may work in. A **Repo** is a stable repository handle that resolves to the OpenComputer App. See the [Repos & GitHub guide](/agent-sessions/repos).
-During preview, **install the [OpenComputer GitHub App](https://github.com/apps/opencomputerdev/installations/new)** on the repos you want OpenComputer to work with (you pick the exact repos); there is no SDK method to mint an install URL. **No credential passes through this API.** Bring-your-own GitHub App modes (`byo_stored_key`, `byo_broker`) are **coming later — not yet available**; in preview only `oc_app` (OpenComputer owns and mints) works.
+During preview, **install the [OpenComputer GitHub App](https://github.com/apps/opencomputerdev/installations/new)** on the repos you want OpenComputer to work with (you pick the exact repos). **No credential passes through this API for the OpenComputer App.** You can also **bring your own GitHub App** (`byo_stored_key`) — register an existing App, or create one in one click via the [manifest flow](/agent-sessions/repos#bring-your-own-github-app); the App key is encrypted at rest and never returned. `byo_broker` is registrable but not yet used for minting.
<Tabs>
@@ -271,6 +271,9 @@ During preview, **install the [OpenComputer GitHub App](https://github.com/apps/
| `oc.repos.get(id)` · `oc.repos.list()` | Fetch / list. |
| `oc.repos.update(id, params)` | Update `name`. |
| `oc.github.apps.list()` | List GitHub Apps available to your org. |
+| `oc.github.apps.register(params)` | Register your own App (`byo_stored_key` / `byo_broker`). |
+| `oc.github.apps.createManifest(params)` · `completeManifest(params)` | One-click App creation via GitHub's manifest flow. |
+| `oc.github.apps.update(id, params)` · `delete(id)` | Update / rotate / remove a registered App. |
| `oc.github.installations.list()` | List GitHub App installations visible to OpenComputer. |
</Tab>
@@ -283,6 +286,9 @@ During preview, **install the [OpenComputer GitHub App](https://github.com/apps/
| `GET /repos/:id` · `GET /repos` | Fetch / list. |
| `PATCH /repos/:id` | Update `name`. |
| `GET /github/apps` | List GitHub Apps available to your org. |
+| `POST /github/apps` | Register your own App (`byo_stored_key` / `byo_broker`). |
+| `PATCH /github/apps/:id` · `DELETE /github/apps/:id` | Update / rotate / remove a registered App. |
+| `POST /github/apps/manifest` · `POST /github/apps/manifest/conversions` | One-click App creation (build manifest → exchange code). |
| `GET /github/installations` | List GitHub App installations visible to OpenComputer. |
</Tab>
@@ -297,7 +303,7 @@ Repo = { id, provider, owner, repo, name?, created_at, updated_at
Responses **never** contain a token or secret. Registering a repo is **optional** under the OpenComputer App — a session can reference `"owner/repo"` directly.
-`GET /github/apps` lists the GitHub Apps available to your org (in preview, the OpenComputer App). `GET /github/installations` lists the App installations visible to OpenComputer — it may be **empty** for orgs using only the OpenComputer App (it surfaces bring-your-own installations once those modes are available).
+`GET /github/apps` lists the GitHub Apps available to your org — the built-in OpenComputer App plus any you register. Register your own with `POST /github/apps` (`byo_stored_key`: `github_app_id` + `private_key`; `byo_broker`: `broker_url` + `broker_secret`), or one-click via `POST /github/apps/manifest` → `POST /github/apps/manifest/conversions`. App responses carry `id`, `mode`, `status`, `github_app_id?`, `app_name?`, `is_default?` — **never** a key or secret. `GET /github/installations` lists installations visible to OpenComputer; it may be **empty** for orgs using only the OpenComputer App. See the [Repos & GitHub guide](/agent-sessions/repos#bring-your-own-github-app) for the full flow.
## Credentials
diff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdx
index 03edd52e..830fb87f 100644
--- a/docs/agent-sessions/repos.mdx
+++ b/docs/agent-sessions/repos.mdx
@@ -132,13 +132,94 @@ the minimum permission it needs, such as read-only for checkout and write only f
publish/comment action.
</Warning>
-### Bring your own GitHub App (coming later)
+### Bring your own GitHub App
+
+Register your own GitHub App so pull requests, comments, and statuses come from **your** App
+identity instead of OpenComputer's. Nothing else changes — OpenComputer still mints the same
+per-operation, repo-scoped tokens; it just signs them with your App's key, which it stores
+encrypted and never returns.
+
+There are two ways to set one up.
+
+**One-click — create an App from a manifest.** OpenComputer hands you a manifest already scoped
+to the permissions it needs; GitHub creates the App and returns a one-time code; OpenComputer
+exchanges it and captures the key. You never handle the private key yourself.
+
+<CodeGroup>
+
+```ts TypeScript SDK
+// 1. Build the manifest + the GitHub URL to submit it to.
+const manifest = await oc.github.apps.createManifest({
+ redirectUrl: "https://your.app/github/callback",
+ name: "Acme Agents",
+ // organization: "acme", // omit for a user-owned App
+});
+
+// 2. Render a form that POSTs manifest.manifest (JSON) as field manifest.field
+// to manifest.postUrl. It must be a top-level navigation, not fetch/XHR —
+// GitHub shows the user its App-creation screen, then redirects to
+// redirectUrl?code=…&state=…
+
+// 3. In your redirect handler, exchange the code — registers a byo_stored_key App.
+const app = await oc.github.apps.completeManifest({ code, isDefault: true });
+```
+
+```http REST API
+POST /v3/github/apps/manifest
+Authorization: Bearer $OPENCOMPUTER_API_KEY
+
+{ "redirect_url": "https://your.app/github/callback", "name": "Acme Agents" }
+// → { "manifest": { … }, "post_url": "https://github.com/settings/apps/new?state=…",
+// "field": "manifest", "state": "…" }
+
+// After GitHub redirects back to your redirect_url with ?code=…
+POST /v3/github/apps/manifest/conversions
+Authorization: Bearer $OPENCOMPUTER_API_KEY
+
+{ "code": "…", "is_default": true }
+// → { "id": "gha_…", "mode": "byo_stored_key", "app_name": "Acme Agents", … }
+```
+
+</CodeGroup>
+
+**Already have an App?** Register it directly with its numeric App id and private key.
+
+<CodeGroup>
+
+```ts TypeScript SDK
+const app = await oc.github.apps.register({
+ mode: "byo_stored_key",
+ githubAppId: "123456",
+ privateKey: pem, // PKCS#1 or PKCS#8 PEM; encrypted at rest, never returned
+ isDefault: true,
+});
+```
+
+```http REST API
+POST /v3/github/apps
+Authorization: Bearer $OPENCOMPUTER_API_KEY
+
+{
+ "mode": "byo_stored_key",
+ "github_app_id": "123456",
+ "private_key": "-----BEGIN RSA PRIVATE KEY-----\n…",
+ "is_default": true
+}
+```
+
+</CodeGroup>
+
+Either way, the last step is to **install the App on the repos you want** (from its GitHub
+settings page) and reference those repos in `sources` exactly as with the OpenComputer App —
+OpenComputer resolves your App and mints per operation. Rotate the key or change the default
+with `oc.github.apps.update(id, { … })`; remove it (and its encrypted key) with
+`oc.github.apps.delete(id)`.
<Note>
-**Not yet available.** Bring-your-own GitHub App modes — `byo_stored_key` (OpenComputer
-stores your App key encrypted and mints) and `byo_broker` (your backend owns the App key and
-returns short-lived tokens) — are planned so that GitHub PRs, comments, and statuses can come
-from your own App. In preview, only the OpenComputer App is available.
+**`byo_broker` is registrable but not yet used for operations.** You can register a broker App
+(`mode: "byo_broker"` with `brokerUrl` + `brokerSecret`) so it shows up in your apps list, but
+minting through a broker is still coming — checkout and publish keep using the OpenComputer App
+until it lands. `byo_stored_key` above is the supported way to use your own App today.
</Note>
### Inline short-lived token
diff --git a/sdks/typescript/package-lock.json b/sdks/typescript/package-lock.json
index 42cbd54d..cd0658a6 100644
--- a/sdks/typescript/package-lock.json
+++ b/sdks/typescript/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@opencomputer/sdk",
- "version": "0.8.1",
+ "version": "0.9.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/sdk",
- "version": "0.8.1",
+ "version": "0.9.0",
"license": "MIT",
"devDependencies": {
"@types/node": "^25.3.0",
diff --git a/sdks/typescript/package.json b/sdks/typescript/package.json
index bac1d998..da4b9bf9 100644
--- a/sdks/typescript/package.json
+++ b/sdks/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/sdk",
- "version": "0.8.1",
+ "version": "0.9.0",
"description": "TypeScript SDK for OpenComputer - cloud sandbox platform",
"type": "module",
"main": "dist/index.js",
diff --git a/sdks/typescript/src/agents/repos.ts b/sdks/typescript/src/agents/repos.ts
index 33dcf3c7..4845ca2e 100644
--- a/sdks/typescript/src/agents/repos.ts
+++ b/sdks/typescript/src/agents/repos.ts
@@ -23,30 +23,97 @@ export interface Repo {
}
/**
- * How a GitHub App mints operation-scoped tokens. In preview, only `oc_app` is available:
- * - `oc_app`: OpenComputer owns the App key and mints (the only mode that works today).
- * - `byo_stored_key`, `byo_broker`: bring-your-own App modes — coming later, not yet
- * available. Left as open string values so future values don't break clients.
+ * How a GitHub App mints operation-scoped tokens:
+ * - `oc_app`: the built-in OpenComputer App owns the key and mints. Default if you register
+ * nothing.
+ * - `byo_stored_key`: your own GitHub App; OpenComputer stores the App private key encrypted
+ * and mints with it. Register it directly ({@link GitHubApps.register}) or one-click via the
+ * manifest flow ({@link GitHubApps.createManifest} / {@link GitHubApps.completeManifest}).
+ * - `byo_broker`: your backend owns the key and returns short-lived tokens — registrable now,
+ * but token minting through a broker is still coming, so it is not yet used for operations.
+ * Left as an open string so future modes don't break clients.
*/
export type GitHubAppMode = "oc_app" | "byo_stored_key" | "byo_broker" | (string & {});
export type GitHubAppStatus = "active" | "suspended" | "revoked" | (string & {});
/**
- * A GitHub App authority for repo operations. In preview the only App is the built-in
- * OpenComputer App (`oc_app`); user-owned App modes are planned and would keep the
- * Repo/Source shape unchanged.
+ * A GitHub App authority for repo operations. The built-in OpenComputer App (`oc_app`) is
+ * always present; registering your own adds `byo_stored_key` / `byo_broker` apps. The Repo and
+ * Source shapes are identical regardless of which App authorizes them.
*/
export interface GitHubApp {
id: string; // gha_…
provider: "github" | (string & {});
mode: GitHubAppMode;
status: GitHubAppStatus;
+ /** The GitHub numeric App id (App-key modes). Not a secret. */
+ githubAppId?: string;
appSlug?: string;
appName?: string;
isDefault?: boolean;
createdAt?: string;
}
+/**
+ * Register your own GitHub App. `byo_stored_key` needs the GitHub numeric App id + the App
+ * private key (PEM) — OpenComputer encrypts the key at rest and never returns it. `byo_broker`
+ * needs your HTTPS mint endpoint + a shared secret. Set `isDefault` to make it the App used
+ * when a repo doesn't pin one.
+ */
+export interface RegisterGitHubAppParams {
+ mode: "byo_stored_key" | "byo_broker";
+ /** byo_stored_key: the GitHub numeric App id. */
+ githubAppId?: string;
+ /** byo_stored_key: the App private key, PEM (PKCS#1 or PKCS#8). Encrypted at rest. */
+ privateKey?: string;
+ /** byo_broker: your HTTPS token-mint endpoint. */
+ brokerUrl?: string;
+ /** byo_broker: shared secret OpenComputer presents to your broker. Encrypted at rest. */
+ brokerSecret?: string;
+ appName?: string;
+ appSlug?: string;
+ isDefault?: boolean;
+}
+
+/** Update a registered App. Setting `privateKey` / `brokerSecret` rotates that secret in place. */
+export interface UpdateGitHubAppParams {
+ status?: GitHubAppStatus;
+ appName?: string;
+ appSlug?: string;
+ isDefault?: boolean;
+ privateKey?: string;
+ brokerUrl?: string;
+ brokerSecret?: string;
+}
+
+/** Parameters for building a GitHub App-creation manifest. */
+export interface CreateAppManifestParams {
+ /** Where GitHub returns `?code=&state=` after the App is created (must be https). */
+ redirectUrl: string;
+ /** Suggested App name (GitHub requires global uniqueness; the user can change it). */
+ name?: string;
+ /** App homepage URL; defaults to the redirect URL's origin. */
+ url?: string;
+ /** Org login to create an org-owned App; omit for a user-owned App. */
+ organization?: string;
+}
+
+/** The manifest + where to submit it. POST `manifest` (JSON) as form field `field` to `postUrl`. */
+export interface AppManifest {
+ manifest: Record<string, unknown>;
+ postUrl: string;
+ field: "manifest";
+ /** CSRF/correlation token — echo it from your redirect handler and verify it matches. */
+ state: string;
+}
+
+/** Complete the manifest flow: exchange the `code` GitHub returned for a registered App. */
+export interface CompleteAppManifestParams {
+ /** The one-time `code` GitHub appended to your redirect URL (~1h TTL, single use). */
+ code: string;
+ isDefault?: boolean;
+}
+
/**
* A GitHub App installation visible to OpenComputer. Installations are useful for setup
* status and preflight. In preview this may be empty for orgs using only the OpenComputer
@@ -107,13 +174,53 @@ export class GitHub {
}
}
-/** GitHub Apps available to your org. In preview this lists the OpenComputer App; BYO App
- * registration methods are planned for later. */
+/**
+ * GitHub Apps available to your org — the built-in OpenComputer App plus any you register.
+ * Use your own App (`byo_stored_key`) so PRs, comments, and statuses come from your App
+ * identity; register it directly with {@link register}, or one-click with {@link createManifest}
+ * + {@link completeManifest}.
+ */
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 });
}
+
+ /** Register your own GitHub App (`byo_stored_key` or `byo_broker`). Secrets are encrypted at
+ * rest and never returned. */
+ register(params: RegisterGitHubAppParams): Promise<GitHubApp> {
+ return this.http.request("POST", "/github/apps", { body: params });
+ }
+
+ /** Update an App: rename, change status, set as default, or rotate the key/secret. */
+ update(id: string, params: UpdateGitHubAppParams): Promise<GitHubApp> {
+ return this.http.request("PATCH", `/github/apps/${encodeURIComponent(id)}`, { body: params });
+ }
+
+ /** Remove a registered App, its installations, and its encrypted secrets. */
+ delete(id: string): Promise<{ id: string; deleted: boolean }> {
+ return this.http.request("DELETE", `/github/apps/${encodeURIComponent(id)}`);
+ }
+
+ /**
+ * Step 1 of the one-click flow: build a GitHub App-creation manifest pre-scoped to what
+ * OpenComputer needs. Render a form that POSTs `result.manifest` (JSON) as field
+ * `result.field` to `result.postUrl`; GitHub creates the App and redirects to your
+ * `redirectUrl` with a `code`.
+ */
+ createManifest(params: CreateAppManifestParams): Promise<AppManifest> {
+ return this.http.request("POST", "/github/apps/manifest", { body: params });
+ }
+
+ /**
+ * Step 2 of the one-click flow: exchange the `code` GitHub returned for a registered App.
+ * OpenComputer captures the new App's private key server-side, encrypts it, and registers
+ * the App as `byo_stored_key`. The key is never exposed to your code.
+ */
+ completeManifest(params: CompleteAppManifestParams): Promise<GitHubApp> {
+ return this.http.request("POST", "/github/apps/manifest/conversions", { body: params });
+ }
}
/** GitHub App installations visible to OpenComputer. In preview this may be empty for orgs