An open-source, faster Devin alternative
TypeScript
docs+sdk: hosted one-click manifest flow (open a link) for BYO App
Igor Zalutskieec804f3e80d
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex 06126300..194d29df 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -272,7 +272,8 @@ During preview, **install the [OpenComputer GitHub App](https://github.com/apps/| `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.createManifestUrl(params)` | One-click: get a link to open; OpenComputer hosts the GitHub flow + key capture. |+| `oc.github.apps.createManifest(params)` · `completeManifest(params)` | Developer-driven manifest flow (you host the redirect). || `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. |@@ -288,7 +289,9 @@ During preview, **install the [OpenComputer GitHub App](https://github.com/apps/| `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). |+| `POST /github/apps/manifest` | Start the manifest flow → `{ start_url }` (hosted) or `{ manifest, … }` (with `redirect_url`). |+| `GET /github/apps/manifest/start` · `…/callback` | Hosted pages OpenComputer serves (browser, not called directly). |+| `POST /github/apps/manifest/conversions` | Developer-driven: exchange the code for a registered App. || `GET /github/installations` | List GitHub App installations visible to OpenComputer. |</Tab>@@ -303,7 +306,7 @@ Repo = { id, provider, owner, repo, name?, created_at, updated_atResponses **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 — 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.+`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: `POST /github/apps/manifest` returns a `start_url` to open and OpenComputer hosts the GitHub redirect + key capture (creating an App is a GitHub-UI flow, so it's a link to open, not a fully programmatic call). 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.## Credentialsdiff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdxindex 830fb87f..12efc728 100644--- a/docs/agent-sessions/repos.mdx+++ b/docs/agent-sessions/repos.mdx@@ -139,28 +139,56 @@ identity instead of OpenComputer's. Nothing else changes — OpenComputer stillper-operation, repo-scoped tokens; it just signs them with your App's key, which it storesencrypted and never returns.-There are two ways to set one up.+Creating a GitHub App is, by GitHub's design, a **user-facing flow through GitHub's UI** —+GitHub authenticates the person who creates and owns the App, so there's no API that mints one+on your behalf. OpenComputer hosts that flow behind a single link. (If you already have an App,+skip to [registering it directly](#already-have-an-app).)-**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.+**One-click — open a link (recommended).** Ask OpenComputer for a setup link and open it.+GitHub walks the user through creating the App; OpenComputer's callback captures the key,+encrypts it, and registers the App as `byo_stored_key`. You never render a form or touch the+private key.<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",+const { startUrl } = await oc.github.apps.createManifestUrl({name: "Acme Agents",+ isDefault: true,// organization: "acme", // omit for a user-owned App});+// Open startUrl in a browser (or print it in your CLI). After the user clicks+// "Create" on GitHub, OpenComputer registers the App — nothing else to call.+```-// 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=…+```http REST API+POST /v3/github/apps/manifest+Authorization: Bearer $OPENCOMPUTER_API_KEY++{ "name": "Acme Agents", "is_default": true }+// → { "start_url": "https://api.opencomputer.dev/v3/github/apps/manifest/start?token=…",+// "expires_at": "…" }+// Open start_url in a browser; OpenComputer hosts the GitHub redirect + key capture.+```++</CodeGroup>-// 3. In your redirect handler, exchange the code — registers a byo_stored_key App.+**Embed it in your own product (developer-driven).** If you want the GitHub redirect to land in+*your* app (e.g. to attach the new App to your own user), host the redirect yourself: build the+manifest, render a top-level form that POSTs it to GitHub, then exchange the `code` GitHub+returns. (The form must be a top-level navigation, not fetch/XHR — GitHub shows the user its+App-creation screen.)++<CodeGroup>++```ts TypeScript SDK+// 1. Build the manifest + the GitHub URL to submit it to.+const m = await oc.github.apps.createManifest({+ redirectUrl: "https://your.app/github/callback",+ name: "Acme Agents",+});+// 2. Render a form that POSTs m.manifest (JSON) as field m.field to m.postUrl.+// 3. In your redirect handler, exchange the code GitHub appended:const app = await oc.github.apps.completeManifest({ code, isDefault: true });```@@ -172,16 +200,15 @@ Authorization: Bearer $OPENCOMPUTER_API_KEY// → { "manifest": { … }, "post_url": "https://github.com/settings/apps/new?state=…",// "field": "manifest", "state": "…" }-// After GitHub redirects back to your redirect_url with ?code=…+// 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", … }+// → { "id": "gha_…", "mode": "byo_stored_key", … }```</CodeGroup>+<a id="already-have-an-app" />**Already have an App?** Register it directly with its numeric App id and private key.<CodeGroup>@@ -209,10 +236,10 @@ Authorization: Bearer $OPENCOMPUTER_API_KEY</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+However you set it up, 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>diff --git a/sdks/typescript/src/agents/repos.ts b/sdks/typescript/src/agents/repos.tsindex 4845ca2e..53bcabdc 100644--- a/sdks/typescript/src/agents/repos.ts+++ b/sdks/typescript/src/agents/repos.ts@@ -86,7 +86,27 @@ export interface UpdateGitHubAppParams {brokerSecret?: string;}-/** Parameters for building a GitHub App-creation manifest. */+/** Parameters for the hosted one-click flow (OpenComputer hosts the start page + callback). */+export interface CreateAppManifestUrlParams {+ /** Suggested App name (GitHub requires global uniqueness; the user can change it). */+ name?: string;+ /** Org login to create an org-owned App; omit for a user-owned App. */+ organization?: string;+ /** Make the new App your org's default. */+ isDefault?: boolean;+}++/** A short-lived link to open in a browser to create + connect a GitHub App. */+export interface AppManifestUrl {+ /** Open this in a browser: it sends the user to GitHub, and OpenComputer's callback captures+ * the key and registers the App. No form to render, no code to handle. */+ startUrl: string;+ expiresAt: string;+}++/** Parameters for building a GitHub App-creation manifest (developer-driven; you host the+ * redirect and exchange the code yourself). For the one-click path use+ * {@link GitHubApps.createManifestUrl} instead. */export interface CreateAppManifestParams {/** Where GitHub returns `?code=&state=` after the App is created (must be https). */redirectUrl: string;@@ -177,8 +197,8 @@ export class GitHub {/*** 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}.+ * identity. Easiest is {@link createManifestUrl} (one link, OpenComputer hosts the rest); if+ * you already have an App, {@link register} it directly.*/export class GitHubApps {constructor(private readonly http: Http) {}@@ -204,19 +224,32 @@ export class GitHubApps {}/**- * 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`.+ * **One-click (recommended).** Returns a `startUrl` to open in a browser. It sends the user+ * to GitHub to create the App, and OpenComputer's hosted callback captures the key and+ * registers it as `byo_stored_key` — you don't render a form or handle the redirect code.+ * Creating an App from a manifest is inherently a GitHub-UI flow, so this is a link to open,+ * not a fully programmatic call. The link is short-lived.+ */+ createManifestUrl(params: CreateAppManifestUrlParams = {}): Promise<AppManifestUrl> {+ return this.http.request("POST", "/github/apps/manifest", { body: params });+ }++ /**+ * Developer-driven manifest flow (use {@link createManifestUrl} unless you need to host the+ * redirect yourself — e.g. to attach the App to your own user in your UI). Builds a manifest+ * pre-scoped to what OpenComputer needs; render a form that POSTs `result.manifest` (JSON) as+ * field `result.field` to `result.postUrl`. GitHub redirects to your `redirectUrl` with a+ * `code` — finish with {@link completeManifest}.*/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.+ * Finish the developer-driven 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. (Not needed for+ * {@link createManifestUrl}, whose callback does this for you.)*/completeManifest(params: CompleteAppManifestParams): Promise<GitHubApp> {return this.http.request("POST", "/github/apps/manifest/conversions", { body: params });