An open-source, faster Devin alternative
TypeScript
Work API: list the repositories the organization's GitHub installations grant
Igor Zalutski via Computer713bc776a2ff
diff --git a/services/managed-agents/src/computer/api-http.ts b/services/managed-agents/src/computer/api-http.tsindex cdc620f1..643f1857 100644--- a/services/managed-agents/src/computer/api-http.ts+++ b/services/managed-agents/src/computer/api-http.ts@@ -68,6 +68,7 @@ export function matchApiRoute(method: string, suffix: string): Route | null {// The Work API (work tracking 3.10): the organization's items, read from its knowledge repository.if (p[0] === "work") {if (p[1] === "repository" && p.length === 2) return method === "GET" ? { op: "work.repository.get" } : method === "PUT" ? { op: "work.repository.put" } : null;+ if (p[1] === "repositories") return is("GET", 2) ? { op: "work.repositories" } : null;if (p[1] !== "items") return null;if (is("GET", 2)) return { op: "work.items" };if (is("GET", 3)) return { op: "work.item", sub: p[2] };@@ -271,7 +272,7 @@ const OPS = new Set(["sessions.interrupt", "sessions.compact", "sessions.suspend", "sessions.resume","turns.send", "turns.list", "turns.get", "turns.cancel", "events.list","asks.list", "asks.get", "asks.answer", "asks.dismiss", "subagents.list", "subagents.get", "subagents.stop",- "work.repository.get", "work.repository.put", "work.items", "work.item", "work.history",+ "work.repository.get", "work.repository.put", "work.repositories", "work.items", "work.item", "work.history",]);/** The request's one `httpapi.request`; never throws, never awaited. */diff --git a/services/managed-agents/src/computer/work/api.ts b/services/managed-agents/src/computer/work/api.tsindex f186408e..f9201d1c 100644--- a/services/managed-agents/src/computer/work/api.ts+++ b/services/managed-agents/src/computer/work/api.ts@@ -53,7 +53,7 @@ export interface Item {closedBy: string | null;}-export type WorkRouteOp = "work.repository.get" | "work.repository.put" | "work.items" | "work.item" | "work.history";+export type WorkRouteOp = "work.repository.get" | "work.repository.put" | "work.repositories" | "work.items" | "work.item" | "work.history";export interface WorkRoute {op: WorkRouteOp;@@ -77,6 +77,7 @@ export interface WorkDeps {const PARAMS: Record<WorkRouteOp, readonly string[]> = {"work.repository.get": [],"work.repository.put": [],+ "work.repositories": [],"work.items": ["stage", "cursor", "limit"],"work.item": [],"work.history": ["cursor"],@@ -115,6 +116,13 @@ export async function workApi(deps: WorkDeps, route: WorkRoute, query: URLSearchreturn { status: 200, body: { repository: result.value } };}+ case "work.repositories": {+ // What the organization's installations grant, for the picker; the index reads GitHub.+ const result = await index.repositories(deps.accountId);+ if (!result.ok) return { ...UNAVAILABLE, error: { ...UNAVAILABLE.error!, retryAfterMs: result.retryAfterMs } };+ return { status: 200, body: { installations: result.installations } };+ }+case "work.items": {const stage = query.get("stage");if (stage !== "open" && stage !== "closed") return invalid("stage is open or closed.", "stage");diff --git a/services/managed-agents/src/computer/work/github.ts b/services/managed-agents/src/computer/work/github.tsindex 2d56decb..5e9624b0 100644--- a/services/managed-agents/src/computer/work/github.ts+++ b/services/managed-agents/src/computer/work/github.ts@@ -5,8 +5,9 @@// token narrowed to the knowledge repository and `contents: read`. Pull request state is read// with `pull_requests: read` narrowed to the repositories of the batch asked, and only for// repositories of the installation's own account (other links are `unreadable`). Finding a-// renamed repository by its id uses `metadata: read`. Each token is held in memory until five-// minutes before it expires.+// renamed repository by its id, and listing the repositories an installation grants (the+// repository picker), use `metadata: read`. Each token is held in memory until five minutes+// before it expires.// - Every request is aborted after REQUEST_TIMEOUT_MS, the body included.// - Quota: the installation's limit is shared with the organization's agents. Every response's// rate-limit headers are kept per resource (`core`, `graphql`); `spare()` is false under a fifth@@ -77,6 +78,31 @@ export interface TokenMinter {}): Promise<GitHubTokenMint>;/** The installation's GitHub account (`accountLogin`), or null when it is not connected. */getGitHubInstallation(installationId: string): Promise<{ accountLogin: string } | null> | { accountLogin: string } | null;+ /** The organization's installations (the repository picker lists the active ones). */+ listGitHubInstallations(): Promise<AccountInstallation[]> | AccountInstallation[];+}++/** An installation as the Account object holds it, the fields the Work index reads. */+export interface AccountInstallation {+ /** The Account object's id for it. */+ id: string;+ /** GitHub's id for it, which its settings page is named by. */+ githubInstallationId: number;+ accountLogin: string;+ /** GitHub's `Organization` or `User`. */+ accountType: string;+ state: string;+}++/** A repository an installation grants, as the picker lists it. */+export interface GrantedRepository {+ id: number;+ owner: string;+ name: string;+ private: boolean;+ defaultBranch: string;+ /** The last push, ISO; null for a repository never pushed to. */+ pushedAt: string | null;}export interface WorkRepo {@@ -335,6 +361,27 @@ export class WorkGitHub {// ---------------------------------------------------------------- calls+ /**+ * The repositories the installation grants, PER_PAGE_MAX a page, at most `max` (in GitHub's+ * order). The one call that reads the installation, not `repo`. `truncated` when it grants more.+ */+ async grantedRepositories(max: number): Promise<{ repositories: GrantedRepository[]; truncated: boolean }> {+ const repositories: GrantedRepository[] = [];+ let total: number | null = null;+ let full = false;+ for (let page = 1; repositories.length < max; page++) {+ const answer = await this.request(`/installation/repositories?per_page=${PER_PAGE_MAX}&page=${page}`, { token: { kind: "metadata" } });+ if (answer.status === 404) throw new GitHubGone("installation_removed", "The GitHub installation is not connected to this organization.");+ const body = this.json<{ total_count?: unknown; repositories?: unknown }>(answer);+ const list = Array.isArray(body.repositories) ? body.repositories : [];+ if (typeof body.total_count === "number") total = body.total_count;+ repositories.push(...list.map(grantedOf).filter((r): r is GrantedRepository => r !== null));+ full = list.length >= PER_PAGE_MAX;+ if (!full) break;+ }+ return { repositories: repositories.slice(0, max), truncated: total !== null ? total > max : full && repositories.length >= max };+ }+/** The repository as GitHub names it now, its id and default branch (setRepository's check). */async repository(): Promise<{ id: number | null; owner: string; name: string; defaultBranch: string }> {const answer = await this.request(this.repoPath(""));@@ -507,6 +554,19 @@ function repositoryOf(raw: unknown): { id: number | null; owner: string; name: s};}+function grantedOf(raw: unknown): GrantedRepository | null {+ const r = raw as { id?: unknown; name?: unknown; owner?: { login?: unknown }; private?: unknown; default_branch?: unknown; pushed_at?: unknown };+ if (typeof r?.id !== "number" || typeof r.name !== "string" || typeof r.owner?.login !== "string") return null;+ return {+ id: r.id,+ owner: r.owner.login,+ name: r.name,+ private: r.private === true,+ defaultBranch: typeof r.default_branch === "string" ? r.default_branch : "main",+ pushedAt: typeof r.pushed_at === "string" && Number.isFinite(Date.parse(r.pushed_at)) ? r.pushed_at : null,+ };+}+function commitOf(raw: unknown): CommitInfo | null {const c = raw as { sha?: unknown; commit?: { message?: unknown; author?: { name?: unknown; email?: unknown; date?: unknown } } };if (typeof c?.sha !== "string" || typeof c.commit?.message !== "string") return null;diff --git a/services/managed-agents/src/computer/work/index-contract.ts b/services/managed-agents/src/computer/work/index-contract.tsindex 2361f74f..9e66ae49 100644--- a/services/managed-agents/src/computer/work/index-contract.ts+++ b/services/managed-agents/src/computer/work/index-contract.ts@@ -6,10 +6,10 @@// Close and Reopen (3.9, build step 5) slot in beside `setRepository`: writes that run inside the// index's one-at-a-time chain and answer a `WorkWrite`.-import type { RepositoryProblem } from "./github.js";+import type { GrantedRepository, RepositoryProblem } from "./github.js";import type { Stage } from "./item.js";-export type { RepositoryProblem } from "./github.js";+export type { GrantedRepository, RepositoryProblem } from "./github.js";/** The knowledge repository setting, as the API shows it. */export interface Repository {@@ -32,6 +32,26 @@ export interface RepositoryChoice {branch?: string;}+/** One of the organization's active GitHub installations, with what it grants, for the picker. */+export interface GrantingInstallation {+ /** The Account object's id for it: a `RepositoryChoice`'s `installationId`. */+ id: string;+ accountLogin: string;+ /** GitHub's `Organization` or `User`. */+ accountType: string;+ /** The installation's page on GitHub, where a person grants it more repositories. */+ settingsUrl: string;+ /** Most recently pushed first; never pushed last. */+ repositories: GrantedRepository[];+ /** True when the installation grants more than the list holds. */+ truncated: boolean;+ /** Set when GitHub would not list them (the repositories are then empty). A stable code. */+ problem: RepositoryProblem | null;+ problemMessage: string | null;+}++export type RepositoriesResult = { ok: true; installations: GrantingInstallation[] } | { ok: false; error: "unavailable"; retryAfterMs: number };+/** Who made a write, from the identity the edge asserted. */export interface WorkActor {member: string;@@ -123,6 +143,7 @@ export type WorkWrite<T> = { ok: true; value: T } | { ok: false; status: number;export interface WorkIndexRpc {repository(accountId: string): Promise<Repository | null>;setRepository(accountId: string, choice: RepositoryChoice, by: WorkActor): Promise<WorkWrite<Repository>>;+ repositories(accountId: string): Promise<RepositoriesResult>;items(accountId: string, query: ItemsQuery): Promise<ItemsResult>;item(accountId: string, number: number): Promise<ItemResult>;history(accountId: string, number: number, cursor?: string): Promise<HistoryResult>;diff --git a/services/managed-agents/src/computer/work/index-do.ts b/services/managed-agents/src/computer/work/index-do.tsindex 341ac6ce..6ba8ff7f 100644--- a/services/managed-agents/src/computer/work/index-do.ts+++ b/services/managed-agents/src/computer/work/index-do.ts@@ -54,6 +54,10 @@ export class WorkIndexDurableObject extends DurableObject<WorkIndexEnv> implemenreturn this.index.setRepository(accountId, choice, by);}+ repositories(accountId: string) {+ return this.index.repositories(accountId);+ }+items(accountId: string, query: ItemsQuery) {return this.index.items(accountId, query);}diff --git a/services/managed-agents/src/computer/work/index.ts b/services/managed-agents/src/computer/work/index.tsindex 0c9c5c25..e66c13fc 100644--- a/services/managed-agents/src/computer/work/index.ts+++ b/services/managed-agents/src/computer/work/index.ts@@ -28,6 +28,7 @@// Reads never wait on it: they are SQL, and the two that may need GitHub (an item or a page of// closed items not read yet, history while the walk is not done) wait at most READ_WAIT_MS. Every// GitHub request is aborted after 10 s, so a hung one holds the chain no longer than that.+// Listing what the installations grant (the repository picker) stores nothing and is outside it.// - A permanent failure is stored as `problem` (a code) and `problemMessage`; it is retried from// the alarm with a backoff from PROBLEM_RETRY_MS to PROBLEM_RETRY_MAX_MS and cleared on success.//@@ -43,6 +44,7 @@ import {WorkGitHub,type CommitInfo,type FileChange,+ type GrantedRepository,type RepositoryProblem,type TokenMinter,type WorkRepo,@@ -54,7 +56,9 @@ import type {ItemsQuery,ItemsResult,OpenStamp,+ GrantingInstallation,ReadState,+ RepositoriesResult,Repository,RepositoryChoice,Revision,@@ -93,6 +97,8 @@ const HISTORY_PAGE = 30;const CLOSED_LIMIT_DEFAULT = 50;const CLOSED_LIMIT_MAX = 100;const FETCH_PARALLEL = 6;+/** The picker lists at most this many repositories per installation (five pages). */+export const GRANTED_MAX = 500;/** Durable Object SQL binds at most 100 parameters per statement. */const BIND_MAX = 90;/** Stored bodies re-parsed per step after PARSER_VERSION changes. */@@ -190,6 +196,8 @@ export class WorkIndex {private tail: Promise<unknown> = Promise.resolve();private looking: Promise<void> | null = null;private readonly filling = new Map<number, Promise<void>>();+ /** The picker's clients, one per installation, so a refresh reuses the token. */+ private readonly listers = new Map<string, WorkGitHub>();constructor(private readonly deps: WorkIndexDeps) {this.store = deps.store;@@ -391,6 +399,49 @@ export class WorkIndex {});}+ /**+ * The organization's active installations, each with the repositories it grants, read from+ * GitHub on every call: the picker asks again when the person comes back from granting access.+ * An installation GitHub will not list carries its problem; any other failure answers unavailable.+ */+ async repositories(accountId: string): Promise<RepositoriesResult> {+ this.bind(accountId);+ const account = this.deps.account(accountId);+ const active = (await account.listGitHubInstallations()).filter((i) => i.state === "active");+ try {+ const installations = await Promise.all(+ active.map(async (i): Promise<GrantingInstallation> => {+ const organization = i.accountType.toLowerCase() === "organization";+ const shown = {+ id: String(i.id),+ accountLogin: i.accountLogin,+ accountType: organization ? "Organization" : "User",+ settingsUrl: organization+ ? `https://github.com/organizations/${encodeURIComponent(i.accountLogin)}/settings/installations/${i.githubInstallationId}`+ : `https://github.com/settings/installations/${i.githubInstallationId}`,+ };+ let lister = this.listers.get(shown.id);+ if (!lister) {+ // A client for the installation alone: listing reads no repository.+ lister = this.newClient({ installationId: shown.id, owner: i.accountLogin, name: "", branch: "" }, accountId);+ this.listers.set(shown.id, lister);+ }+ try {+ const { repositories, truncated } = await lister.grantedRepositories(GRANTED_MAX);+ return { ...shown, repositories: repositories.sort(byPushed), truncated, problem: null, problemMessage: null };+ } catch (error) {+ if (!(error instanceof GitHubGone)) throw error;+ return { ...shown, repositories: [], truncated: false, problem: error.problem, problemMessage: error.message };+ }+ }),+ );+ return { ok: true, installations };+ } catch (error) {+ const retryAfterMs = error instanceof GitHubPaused ? Math.max(1000, error.until - this.now()) : 5_000;+ return { ok: false, error: "unavailable", retryAfterMs };+ }+ }+async items(accountId: string, query: ItemsQuery): Promise<ItemsResult> {this.bind(accountId);this.noteRead();@@ -1253,3 +1304,13 @@ async function parallel<T>(items: T[], fn: (item: T) => Promise<void>): Promise<});await Promise.all(lanes);}++/** Most recently pushed first, never pushed last, then by name. */+function byPushed(a: GrantedRepository, b: GrantedRepository): number {+ if (a.pushedAt !== b.pushedAt) {+ if (a.pushedAt === null) return 1;+ if (b.pushedAt === null) return -1;+ return Date.parse(b.pushedAt) - Date.parse(a.pushedAt);+ }+ return a.name.localeCompare(b.name);+}diff --git a/services/managed-agents/test/fixtures/fake-github-repo.ts b/services/managed-agents/test/fixtures/fake-github-repo.tsindex 66b728d1..2d4ba77f 100644--- a/services/managed-agents/test/fixtures/fake-github-repo.ts+++ b/services/managed-agents/test/fixtures/fake-github-repo.ts@@ -3,8 +3,8 @@ import { createHash } from "node:crypto";/*** A knowledge repository on a fake GitHub, as much of the REST API as the Work index uses: the* branch ref (with ETag), compare (with rename detection), commits (one, and filtered by path),- * trees (a commit's root, then one directory), blobs, the repository (by name and by id), and the- * pull request GraphQL query. History is a list of commits with whole-tree snapshots; `forcePush`+ * trees (a commit's root, then one directory), blobs, the repository (by name and by id), the+ * installation's repositories, and the pull request GraphQL query. History is a list of commits with whole-tree snapshots; `forcePush`* rewrites it.** GitHub's limits hold: compare lists at most 300 files and a page of commits; lists take@@ -54,6 +54,8 @@ export class FakeRepo {limit = 5000;deleted = false;pulls = new Map<string, FakePull>();+ /** The other repositories the installation grants, besides this one, as GitHub lists them. */+ granted: { id: number; name: string; private?: boolean; pushedAt?: string | null }[] = [];private clock = Date.parse("2026-11-01T00:00:00Z");constructor(initial: Record<string, string> = {}) {@@ -184,6 +186,15 @@ export class FakeRepo {return json(200, { data });}const about = () => ({ id: this.id, name: this.name, owner: { login: this.owner }, default_branch: this.defaultBranch });+ if (url.pathname === "/installation/repositories") {+ const all = [+ ...(this.deleted ? [] : [{ ...about(), private: true, pushed_at: this.commits.get(this.head!)?.at ?? null }]),+ ...this.granted.map((g) => ({ id: g.id, name: g.name, owner: { login: this.owner }, default_branch: "main", private: g.private ?? false, pushed_at: g.pushedAt ?? null })),+ ];+ const perPage = Math.min(Number(url.searchParams.get("per_page") ?? "30"), 100);+ const page = Number(url.searchParams.get("page") ?? "1");+ return json(200, { total_count: all.length, repositories: all.slice((page - 1) * perPage, page * perPage) });+ }if (url.pathname === `/repositories/${this.id}`) return this.deleted ? json(404, { message: "Not Found" }) : json(200, about());// GitHub's owner and repository names are case-insensitive; a former name redirects.const lower = url.pathname.toLowerCase();diff --git a/services/managed-agents/test/work-api.test.ts b/services/managed-agents/test/work-api.test.tsindex 2c47be6a..34b1a274 100644--- a/services/managed-agents/test/work-api.test.ts+++ b/services/managed-agents/test/work-api.test.ts@@ -70,17 +70,20 @@ function computer(sessions: FakeSession[]) {}/** A Work index over a fake GitHub, as the binding answers it. */-async function workIndex(repo: FakeRepo) {+async function workIndex(repo: FakeRepo, over: Partial<TokenMinter> = {}) {const pending: Promise<unknown>[] = [];const account: TokenMinter = {mintGitHubInstallationToken: async () => ({ outcome: "minted", token: "ghs_test", expiresAt: "2099-01-01T00:00:00Z" }),getGitHubInstallation: () => ({ accountLogin: "acme" }),+ listGitHubInstallations: () => [{ id: "12", githubInstallationId: 9012, accountLogin: "acme", accountType: "Organization", state: "active" }],+ ...over,};const clock = new FakeClock();const index = new WorkIndex({ store: indexStore(), clock, scheduler: { arm: async () => {}, waitUntil: (p) => void pending.push(p) }, account: () => account, fetch: repo.fetch });const rpc: WorkIndexRpc = {repository: (a) => index.getRepository(a),setRepository: (a, c, by) => index.setRepository(a, c, by),+ repositories: (a) => index.repositories(a),items: (a, q) => index.items(a, q),item: (a, n) => index.item(a, n),history: (a, n, c) => index.history(a, n, c),@@ -133,7 +136,7 @@ async function board() {}describe("Work API scopes", () => {- const env = { WORK_INDEX: { getByName: () => ({ repository: async () => null, setRepository: async () => ({ ok: true, value: null }) }) } };+ const env = { WORK_INDEX: { getByName: () => ({ repository: async () => null, setRepository: async () => ({ ok: true, value: null }), repositories: async () => ({ ok: true, installations: [] }) }) } };const stub: ComputerApiStub = { computerApi: vi.fn() };const status = async (identity: RequestIdentity, method = "GET", path = "/work/repository", body?: string) => {const res = await call(env, stub, identity, method, path, body ? { body } : {});@@ -147,6 +150,8 @@ describe("Work API scopes", () => {expect((await status(withKey(["work:read"]))).status).toBe(200);expect(await status(withKey(["work:read"]), "PUT", "/work/repository", choice)).toMatchObject({ status: 403, error: { scope: "work:write" } });expect((await status(withKey(["work:write"]), "PUT", "/work/repository", choice)).status).toBe(200);+ expect(await status(withKey(["sessions:read"]), "GET", "/work/repositories")).toMatchObject({ status: 403, error: { scope: "work:read" } });+ expect((await status(withKey(["work:read"]), "GET", "/work/repositories")).status).toBe(200);});it("lets the dashboard read and write", async () => {@@ -172,6 +177,8 @@ describe("Work API scopes", () => {expect((await call(env, stub, person, "DELETE", "/work/repository")).status).toBe(404);expect((await call(env, stub, person, "POST", "/work/items/1/close")).status).toBe(404);expect((await call(env, stub, person, "GET", "/work/files")).status).toBe(404);+ expect((await call(env, stub, person, "POST", "/work/repositories")).status).toBe(404);+ expect((await call(env, stub, person, "GET", "/work/repositories/1")).status).toBe(404);});});@@ -354,6 +361,62 @@ describe("Work API composition", () => {});});+describe("Work API repositories", () => {+ const installations = [+ { id: "12", githubInstallationId: 9012, accountLogin: "acme", accountType: "Organization", state: "active" },+ { id: "13", githubInstallationId: 9013, accountLogin: "ana", accountType: "User", state: "active" },+ { id: "14", githubInstallationId: 9014, accountLogin: "old", accountType: "Organization", state: "suspended" },+ ];++ it("lists each active installation's repositories, most recently pushed first, with its settings page", async () => {+ const repo = new FakeRepo({ "work/1-a.md": doc(1, "A") });+ repo.granted = [+ { id: 1, name: "app", pushedAt: "2026-11-18T00:00:00Z" },+ { id: 2, name: "empty", pushedAt: null },+ { id: 3, name: "site", private: true, pushedAt: "2026-10-01T00:00:00Z" },+ ];+ const w = await workIndex(repo, { listGitHubInstallations: () => installations });+ const res = await call(w.env, computer([]).stub, person, "GET", "/work/repositories");+ expect(res.status).toBe(200);+ const body = await json(res);+ expect(body.installations.map((i: { id: string }) => i.id)).toEqual(["12", "13"]);+ const [acme, ana] = body.installations;+ expect(acme).toMatchObject({ accountLogin: "acme", accountType: "Organization", settingsUrl: "https://github.com/organizations/acme/settings/installations/9012", truncated: false, problem: null });+ expect(ana.settingsUrl).toBe("https://github.com/settings/installations/9013");+ expect(acme.repositories.map((r: { name: string }) => r.name)).toEqual(["app", "knowledge", "site", "empty"]);+ expect(acme.repositories[2]).toEqual({ id: 3, owner: "acme", name: "site", private: true, defaultBranch: "main", pushedAt: "2026-10-01T00:00:00Z" });+ expect(repo.log).toContain("GET /installation/repositories?per_page=100&page=1");+ });++ it("stops at 500 repositories and says so", async () => {+ const repo = new FakeRepo({});+ repo.granted = Array.from({ length: 520 }, (_, i) => ({ id: i + 1, name: `r${i}`, pushedAt: "2026-11-01T00:00:00Z" }));+ const w = await workIndex(repo);+ const body = await json(await call(w.env, computer([]).stub, person, "GET", "/work/repositories"));+ expect(body.installations[0].repositories).toHaveLength(500);+ expect(body.installations[0].truncated).toBe(true);+ expect(repo.log.filter((l) => l.startsWith("GET /installation/repositories"))).toHaveLength(5);+ });++ it("names the problem of an installation GitHub will not list, and answers 503 when GitHub is down", async () => {+ const w = await workIndex(new FakeRepo({}), { mintGitHubInstallationToken: async () => ({ outcome: "failed", code: "installation_suspended", message: "The installation is suspended." }) as never });+ const body = await json(await call(w.env, computer([]).stub, person, "GET", "/work/repositories"));+ expect(body.installations[0]).toMatchObject({ repositories: [], problem: "installation_suspended", problemMessage: "The installation is suspended." });++ const down = new FakeRepo({});+ down.failNext = [{ status: 502, match: /^\/installation\// }];+ const w2 = await workIndex(down);+ const res = await call(w2.env, computer([]).stub, person, "GET", "/work/repositories");+ expect(res.status).toBe(503);+ expect((await json(res)).error).toMatchObject({ code: "unavailable", retryAfterMs: 5_000 });+ });++ it("answers no installations when GitHub is not connected", async () => {+ const w = await workIndex(new FakeRepo({}), { listGitHubInstallations: () => [] });+ expect(await json(await call(w.env, computer([]).stub, person, "GET", "/work/repositories"))).toEqual({ installations: [] });+ });+});+describe("branchName", () => {it("follows git check-ref-format for a branch", () => {for (const ok of ["main", "trunk", "feat/work-index", "release-1.2", "a_b", "x@y", "ü"]) expect(branchName(ok), ok).toBe(true);diff --git a/services/managed-agents/test/work-index.test.ts b/services/managed-agents/test/work-index.test.tsindex c74b792a..d480ec59 100644--- a/services/managed-agents/test/work-index.test.ts+++ b/services/managed-agents/test/work-index.test.ts@@ -39,6 +39,7 @@ function setup(repo: FakeRepo, options: { sql?: SqlStorage; mint?: Partial<Tokenreturn { outcome: "minted", token: "ghs_test", expiresAt: new Date(clock.now() + 3_600_000).toISOString() };},getGitHubInstallation: () => ({ accountLogin: "acme" }),+ listGitHubInstallations: () => [{ id: "12", githubInstallationId: 9012, accountLogin: "acme", accountType: "Organization", state: "active" }],...options.mint,};const fetches: string[] = [];