Skip to content

An open-source, faster Devin alternative

TypeScript

docs/sdk: tighten private repo sources

Igor Zalutskib43a4c712976
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdx
index 8fe39b5e..228245c7 100644
--- a/docs/agent-sessions/api-reference.mdx
+++ b/docs/agent-sessions/api-reference.mdx
@@ -15,7 +15,7 @@ const session = await oc.sessions.get("ses_..."); // server, org key
// or, in a browser: await connectSession({ sessionId, clientToken })
```
-<Note>The SDK returns the same objects with **camelCase** fields (`client_token` → `session.clientToken`, `created_at` → `createdAt`, `last_turn` → `lastTurn`, `yield_reason` → `yieldReason`, `turn_seconds` → `turnSeconds`, …) and takes camelCase params (`idempotency_key` → `idempotencyKey`). The wire shapes below are the raw JSON. Truly opaque blobs — your session `metadata` and an event's `raw` field — pass through **verbatim** (keys untouched) in both directions; everything else, **including event `body` and `refs`**, is camelCased like the rest.</Note>
+<Note>The SDK returns the same objects with **camelCase** fields (`client_token` → `session.clientToken`, `created_at` → `createdAt`, `last_turn` → `lastTurn`, `yield_reason` → `yieldReason`, `turn_seconds` → `turnSeconds`, …) and takes camelCase params (`idempotency_key` → `idempotencyKey`). The wire shapes below are the raw JSON. Truly opaque blobs — your session `metadata`, event `refs`, and event `raw` — pass through **verbatim** (keys untouched) in both directions; everything else, including event `body`, is camelCased like the rest.</Note>
## Sessions
@@ -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: [{ name, status, path, sha }]`.
+`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.
Client tokens accept `scopes?` (subset of `read`, `steer`) and `ttl?` seconds, clamped to 60–86400 (SDK: `ttlSeconds`).
@@ -79,8 +79,12 @@ SessionSource = // a sources[] entry — WIRE
SourceAuth = // inline path ONLY (connection-backed repos need none)
{ type: "risky_short_lived_token", token, expires_at } // workaround; short-lived; can't refresh
// SDK is camelCase: expiresAt (wire expires_at).
-SourceSummary = { name, status, path, sha } // sanitized; in the create response + GET …/sources
+SourceSummary = { name, status, path, sha, resolved_sha?,
+ error_code?, error_message?, retryable? }
+// sanitized; in the create response + GET …/sources
// status: pending | materializing | resolved | failed | unavailable | auth_required
+// error_code examples: source.auth_required, source.auth_ambiguous,
+// source.permission_missing, source.sha_mismatch, source.timeout
```
`yield_reason` (`completed | needs_input | error | budget_exceeded | deadline_exceeded | max_turns | canceled`; `requires_action` is reserved, not emitted yet) is the machine-readable "why the turn ended" — `needs_input` means the agent asked a question; answer it by [steering](#steer).
@@ -263,8 +267,9 @@ Auth lives on a **connection** (how OpenComputer mints tokens for your org); a *
| Call | Purpose |
| --- | --- |
+| `oc.github.connections.installUrl(params?)` | Create a GitHub App installation URL. |
| `oc.repos.create(params)` | Register (get-or-create) a repo. |
-| `oc.repos.get(idOrSlug)` · `oc.repos.list()` | Fetch / list. |
+| `oc.repos.get(id)` · `oc.repos.list()` | Fetch / list. |
| `oc.repos.update(id, params)` | Update policy `defaults`. |
| `oc.github.connections.list()` | List connected GitHub Apps (installs). |
@@ -274,6 +279,7 @@ Auth lives on a **connection** (how OpenComputer mints tokens for your org); a *
| Method · Path | Purpose |
| --- | --- |
+| `POST /github/connections/install-url` | Create a GitHub App installation URL. |
| `POST /repos` | Register (get-or-create) a repo. |
| `GET /repos/:id` · `GET /repos` | Fetch / list. |
| `PATCH /repos/:id` | Update policy `defaults`. |
@@ -283,14 +289,16 @@ Auth lives on a **connection** (how OpenComputer mints tokens for your org); a *
</Tabs>
-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`).
+Install URL body: `account?`, `redirect_url?`; response `{ url }`. Redirect the user to `url`, then list connections after GitHub returns to your app.
+
+Repo create body: `owner`, `repo`, `provider?` (`github`, default), `name?` (a handle), `connection_id?`, `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`).
```
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)
```
-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.
+Responses **never** contain a token or secret. (SDK camelCase: `branchNamespace`, `connectionId`, `accountLogin`.) Registering a repo is **optional** under the OpenComputer App — a session can reference `"owner/repo"` directly.
## Credentials
diff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdx
index 85d99d8b..3a38a2ee 100644
--- a/docs/agent-sessions/overview.mdx
+++ b/docs/agent-sessions/overview.mdx
@@ -69,6 +69,9 @@ 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">
+ 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">
A repo of examples built on this API.
</Card>
diff --git a/docs/agent-sessions/quickstart.mdx b/docs/agent-sessions/quickstart.mdx
index 9e947f3c..c8692a03 100644
--- a/docs/agent-sessions/quickstart.mdx
+++ b/docs/agent-sessions/quickstart.mdx
@@ -204,8 +204,8 @@ Response:
<Card title="Events" icon="timeline" href="/agent-sessions/events">
Event shape, levels, cursors, and resume behavior.
</Card>
- <Card title="Runtime tools" icon="toolbox" href="/agent-sessions/runtime-tools">
- The tools a runtime can use in the sandbox.
+ <Card title="Repos" 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">
Fork a complete app-builder implementation.
diff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdx
index 45a849fb..39bf63ba 100644
--- a/docs/agent-sessions/repos.mdx
+++ b/docs/agent-sessions/repos.mdx
@@ -13,7 +13,9 @@ holds a GitHub credential.
## Connect GitHub
Connect once; OpenComputer mints short-lived, repo-scoped tokens just in time for each
-operation. There are three ways to connect — one available today.
+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)
@@ -22,10 +24,43 @@ you choose the repos, and can change the selection or uninstall anytime. No keys
manage, no endpoint to host. OpenComputer mints a fresh, narrowly-scoped token for each
operation, so durable sessions and recovery work with nothing else from you.
+<Warning>
+The App may request write-capable GitHub permissions on the repos you select. OpenComputer
+does **not** hand that broad authority to the agent: each operation gets a fresh token with
+the minimum permission it needs, such as read-only for checkout and write only for a future
+publish/comment action.
+</Warning>
+
+Start the install from your dashboard (**Integrations → GitHub**) or create an install URL
+from your backend:
+
+<CodeGroup>
+
+```ts TypeScript SDK
+const url = await oc.github.connections.installUrl({ account: "acme" });
+redirectUserTo(url);
+```
+
+```http REST API
+POST /v3/github/connections/install-url
+Authorization: Bearer $OPENCOMPUTER_API_KEY
+
+{ "account": "acme" }
+```
+
+</CodeGroup>
+
+After GitHub returns to your app, verify the connection:
+
+```ts
+const connections = await oc.github.connections.list();
+// [{ id: "conn_...", accountLogin: "acme", status: "active" }]
+```
+
### Inline short-lived token
-Haven't connected the App yet? Pass a real short-lived token inline on the source, using
-the deliberately-named `risky_short_lived_token` auth:
+The no-setup workaround is to pass a real short-lived token inline on the source, using the
+deliberately-named `risky_short_lived_token` auth:
<CodeGroup>
@@ -34,7 +69,11 @@ sources: [{
url: "https://github.com/acme/web.git",
ref: "refs/pull/42/head",
sha: "abc123…",
- auth: { type: "risky_short_lived_token", token: "ghs_…", expiresAt: "…" },
+ auth: {
+ type: "risky_short_lived_token",
+ token: "ghs_…",
+ expiresAt: "…",
+ },
}]
```
@@ -43,7 +82,11 @@ sources: [{
"url": "https://github.com/acme/web.git",
"ref": "refs/pull/42/head",
"sha": "abc123...",
- "auth": { "type": "risky_short_lived_token", "token": "ghs_...", "expires_at": "..." }
+ "auth": {
+ "type": "risky_short_lived_token",
+ "token": "ghs_...",
+ "expires_at": "..."
+ }
}]
```
@@ -53,8 +96,8 @@ sources: [{
The inline token **can't refresh** — once it expires the session can't fetch, push, or
recover, so use it only for sessions that finish within the token's life. OpenComputer
rejects a far-future or missing expiry and holds it encrypted only until the first
-checkout, then purges it. It's a temporary shortcut until the App-based methods land —
-**prefer the GitHub App.**
+checkout, then purges it. It's a temporary shortcut for environments that have not
+installed the App yet — **prefer the GitHub App.**
</Warning>
### Bring your own GitHub App (not yet available)
@@ -73,7 +116,11 @@ session directly; a Repo adds policy and a stable handle.
<CodeGroup>
```ts TypeScript SDK
-const repo = await oc.repos.create({ owner: "acme", repo: "web" });
+const repo = await oc.repos.create({
+ owner: "acme",
+ repo: "web",
+ defaults: { allow: ["contents:read"] },
+});
```
```http REST API
@@ -87,7 +134,8 @@ Authorization: Bearer $OPENCOMPUTER_API_KEY
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).
+`{ branchNamespace, allow }` (`allow` is a GitHub permission ceiling; OpenComputer still
+mints the minimum token per operation).
## Use it in a session
@@ -97,7 +145,12 @@ passed** — auth comes from your GitHub connection. Optional `defaults`:
const session = await oc.sessions.create({
agent: agent.id,
input: "Review this pull request.",
- sources: [{ repo: repo.id, ref: "refs/pull/42/head", sha: "abc123…", name: "head" }],
+ sources: [{
+ repo: repo.id,
+ ref: "refs/pull/42/head",
+ sha: "abc123…",
+ name: "head",
+ }],
});
// checked out at /workspace/sources/head before the first turn
```
@@ -109,7 +162,12 @@ Authorization: Bearer $OPENCOMPUTER_API_KEY
{
"agent": "agt_...",
"input": "Review this pull request.",
- "sources": [{ "repo": "repo_...", "ref": "refs/pull/42/head", "sha": "abc123...", "name": "head" }]
+ "sources": [{
+ "repo": "repo_...",
+ "ref": "refs/pull/42/head",
+ "sha": "abc123...",
+ "name": "head"
+ }]
}
```
@@ -120,14 +178,33 @@ Authorization: Bearer $OPENCOMPUTER_API_KEY
- **`sha`** (required) — the exact commit, pinned and verified after fetch.
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.
+list several immutable sources, such as a PR's base and head. Fetching more refs
+mid-session will use the `source.fetch_ref` tool once remote actions land.
+
+## Check source status
+
+The create response includes a sanitized source snapshot. Poll `session.listSources()` for
+live materialization status:
+
+```ts
+const sources = await session.listSources();
+
+for (const source of sources) {
+ if (source.status === "auth_required" || source.status === "failed") {
+ showSourceError(source.errorCode, source.errorMessage);
+ }
+}
+```
+
+Common `errorCode` values: `source.auth_required`, `source.auth_ambiguous`,
+`source.repo_not_selected`, `source.permission_missing`, `source.sha_mismatch`, and
+`source.timeout`.
## What the agent can do
Local Git works normally on the checkout (`status`/`diff`/`log`, edit, test, local
-commits). Anything needing the network is a **typed tool** run in the isolated sandbox —
-the agent never runs authenticated `git`/`gh` and never sees a token:
+commits). Anything needing GitHub credentials is a **typed tool** run in a separate
+git-ops sandbox — the agent never runs authenticated `git`/`gh` and never sees a token:
| Tool | Does | Status |
| --- | --- | --- |
diff --git a/sdks/typescript/src/agents/index.ts b/sdks/typescript/src/agents/index.ts
index 9b3e352f..75f055b9 100644
--- a/sdks/typescript/src/agents/index.ts
+++ b/sdks/typescript/src/agents/index.ts
@@ -4,12 +4,16 @@ export { connectSession, type ConnectSessionOptions } from "./connect.js";
export { Sessions, Session, ClientSession } from "./sessions.js";
export type {
CreateSessionParams, StreamOptions, Envelope, ListPage,
- SessionSource, RegisteredRepoSource, InlineRepoSource, SourceAuth, SourceSummary,
+ SessionSource, RegisteredRepoSource, InlineRepoSource, SourceAuth, SourceStatus,
+ SourceErrorCode, SourceSummary,
} from "./sessions.js";
export { Agents } from "./agents.js";
export type { CreateAgentParams, UpdateAgentParams, Page } from "./agents.js";
export { Repos, GitHub, Connections } from "./repos.js";
-export type { CreateRepoParams, UpdateRepoParams, Repo, RepoDefaults, Connection } from "./repos.js";
+export type {
+ CreateRepoParams, UpdateRepoParams, Repo, RepoDefaults, GitHubPermission,
+ Connection, ConnectionInstallUrlParams,
+} 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/normalize.test.ts b/sdks/typescript/src/agents/normalize.test.ts
index 96e48d98..bcadbe24 100644
--- a/sdks/typescript/src/agents/normalize.test.ts
+++ b/sdks/typescript/src/agents/normalize.test.ts
@@ -24,6 +24,13 @@ describe("normalize (API response → idiomatic TS)", () => {
// Caller's routing JSON must round-trip exactly as set (no snake→camel mangling).
expect(out.metadata).toEqual({ pull_number: 42, owner_repo: "acme/widgets", nested: { keep_me: true } });
});
+
+ it("passes event refs through verbatim — opaque, inner keys untouched", () => {
+ const out = normalize<{ refs?: Record<string, unknown> }>({
+ refs: { pull_number: 42, owner_repo: "acme/widgets", nested: { keep_me: true } },
+ });
+ expect(out.refs).toEqual({ pull_number: 42, owner_repo: "acme/widgets", nested: { keep_me: true } });
+ });
});
describe("serialize (request body → snake_case)", () => {
@@ -32,4 +39,9 @@ describe("serialize (request body → snake_case)", () => {
expect(out.idempotency_key).toBe("k1");
expect(out.metadata).toEqual({ pullNumber: 42 }); // verbatim
});
+
+ it("leaves refs opaque on request bodies", () => {
+ const out = serialize({ refs: { pullNumber: 42, owner_repo: "acme/widgets" } }) as Record<string, unknown>;
+ expect(out.refs).toEqual({ pullNumber: 42, owner_repo: "acme/widgets" });
+ });
});
diff --git a/sdks/typescript/src/agents/normalize.ts b/sdks/typescript/src/agents/normalize.ts
index 7a8a1edf..23cb8fbb 100644
--- a/sdks/typescript/src/agents/normalize.ts
+++ b/sdks/typescript/src/agents/normalize.ts
@@ -1,7 +1,8 @@
// Normalize API responses to idiomatic TS: snake_case keys → camelCase, and a known set
// of numeric fields that the API serializes as strings (bigints) → numbers. Opaque
-// subtrees are passed through untouched: `raw` (source-specific adapter data) and
-// `metadata` (the caller's own routing JSON — must round-trip verbatim, keys included).
+// subtrees are passed through untouched: `raw` (source-specific adapter data),
+// `metadata`, and `refs` (caller-owned routing JSON — must round-trip verbatim,
+// keys included).
const NUMERIC = new Set([
"seq", "head", "inputCursor", "inputFromSeq", "inputToSeq", "exitCode", "bytes", "port",
@@ -17,7 +18,7 @@ export function normalize<T = any>(value: unknown): T {
const out: Record<string, unknown> = {};
for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
const ck = camel(k);
- if (ck === "raw" || ck === "metadata") { out[ck] = v; continue; } // opaque: verbatim, keys untouched
+ if (ck === "raw" || ck === "metadata" || ck === "refs") { out[ck] = v; continue; } // opaque: verbatim, keys untouched
let nv: unknown = normalize(v);
if (NUMERIC.has(ck) && typeof nv === "string" && nv !== "" && !Number.isNaN(Number(nv))) {
nv = Number(nv);
diff --git a/sdks/typescript/src/agents/repos.ts b/sdks/typescript/src/agents/repos.ts
index cc45de9d..cc51577e 100644
--- a/sdks/typescript/src/agents/repos.ts
+++ b/sdks/typescript/src/agents/repos.ts
@@ -1,11 +1,19 @@
import type { Http, Query } from "./http.js";
+export type GitHubPermission =
+ | "contents:read" | "contents:write"
+ | "pull_requests:read" | "pull_requests:write"
+ | "issues:read" | "issues:write"
+ | "statuses:read" | "statuses:write"
+ | "checks:read" | "checks:write"
+ | (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; OpenComputer still mints the minimum per operation. */
- allow?: string[];
+ allow?: GitHubPermission[];
}
export interface CreateRepoParams {
@@ -15,14 +23,14 @@ export interface CreateRepoParams {
/** Optional handle for your own reference; identity is (provider, owner, repo). */
name?: string;
/** Optional explicit GitHub connection id. Defaults to your org's connection. */
- connection?: string;
+ connectionId?: string;
defaults?: RepoDefaults;
}
export interface UpdateRepoParams {
defaults?: RepoDefaults;
name?: string;
- connection?: string;
+ connectionId?: string;
}
export interface Repo {
@@ -56,11 +64,19 @@ export interface Connection {
export interface Page<T> { data: T[]; nextCursor?: string | null; }
+export interface ConnectionInstallUrlParams {
+ /** Optional GitHub org/user login to preselect when GitHub supports it. */
+ account?: string;
+ /** Optional app URL to return to after setup completes. */
+ redirectUrl?: string;
+}
+
/**
* 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).
+ * 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).
*/
export class Repos {
constructor(private readonly http: Http) {}
@@ -69,8 +85,8 @@ export class Repos {
create(params: CreateRepoParams): Promise<Repo> {
return this.http.request("POST", "/repos", { body: params, idempotent: true });
}
- get(idOrSlug: string): Promise<Repo> {
- return this.http.request("GET", `/repos/${encodeURIComponent(idOrSlug)}`);
+ get(id: string): Promise<Repo> {
+ return this.http.request("GET", `/repos/${encodeURIComponent(id)}`);
}
update(id: string, params: UpdateRepoParams): Promise<Repo> {
return this.http.request("PATCH", `/repos/${id}`, { body: params });
@@ -91,6 +107,14 @@ export class GitHub {
/** Connected GitHub Apps (installs) for your org. Created via the install flow, not the API. */
export class Connections {
constructor(private readonly http: Http) {}
+ /** Create a GitHub App installation URL. Redirect your user to this URL, then poll/list. */
+ async installUrl(params: ConnectionInstallUrlParams = {}): Promise<string> {
+ const r = await this.http.request<{ url: string }>(
+ "POST", "/github/connections/install-url",
+ { body: params },
+ );
+ return r.url;
+ }
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.ts
index 449ce499..e16b10e0 100644
--- a/sdks/typescript/src/agents/sessions.ts
+++ b/sdks/typescript/src/agents/sessions.ts
@@ -47,6 +47,8 @@ export interface RegisteredRepoSource {
/** 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;
+ url?: never;
+ auth?: never;
/** Required fetch ref (branch or `refs/pull/N/head`). */
ref: string;
/** Required exact commit; fetched, then pinned + verified. */
@@ -56,6 +58,7 @@ export interface RegisteredRepoSource {
}
export interface InlineRepoSource {
+ repo?: never;
/** Clone URL (https, no embedded credentials). */
url: string;
ref: string;
@@ -74,12 +77,40 @@ export interface InlineRepoSource {
export type SourceAuth =
| { type: "risky_short_lived_token"; token: string; expiresAt: string };
+export type SourceStatus =
+ | "pending" | "materializing" | "resolved" | "failed" | "unavailable" | "auth_required";
+
+export type SourceErrorCode =
+ | "source.auth_required"
+ | "source.auth_ambiguous"
+ | "source.connection_suspended"
+ | "source.connection_revoked"
+ | "source.repo_not_selected"
+ | "source.permission_missing"
+ | "source.mint_failed"
+ | "source.mint_rate_limited"
+ | "source.ref_not_found"
+ | "source.sha_mismatch"
+ | "source.unsupported_submodule"
+ | "source.unsupported_lfs"
+ | "source.too_large"
+ | "source.timeout"
+ | (string & {});
+
/** Sanitized per-source status returned on a session (never exposes url/auth). */
export interface SourceSummary {
name: string;
- status: "pending" | "materializing" | "resolved" | "failed" | "unavailable" | "auth_required";
+ status: SourceStatus;
path: string;
+ /** Requested commit from create; kept for correlation while materialization is pending. */
sha: string;
+ /** Actual checked-out commit after materialization succeeds. Usually equals `sha`. */
+ resolvedSha?: string;
+ /** Machine-readable reason when status is `failed` / `unavailable` / `auth_required`. */
+ errorCode?: SourceErrorCode;
+ /** Human-readable diagnostic safe to show in operator/debug UI. */
+ errorMessage?: string;
+ retryable?: boolean;
}
export interface StreamOptions {
@@ -208,7 +239,7 @@ export class Session extends ClientSession {
get status(): SessionStatus { return this.data.status; }
get lastTurn(): LastTurn | undefined { return this.data.lastTurn; }
- /** Source checkout status from the create response — `{ name, status, path, sha }[]`
+ /** Source checkout status from the create response — `{ name, status, path, sha, ... }[]`
* (empty when none). For **live** status, call {@link Session.listSources}. */
get sources(): SourceSummary[] { return this._sources; }
/** Fetch live source checkout status — poll this to watch materialization