@app-vitals/agent-admin 1.120.1 → 1.121.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/package.json +2 -2
  2. package/src/account-repo-lookup-api.integration.test.ts +1 -1
  3. package/src/admin-boot-config.ts +2 -2
  4. package/src/admin-boot-config.unit.test.ts +1 -1
  5. package/src/admin-boot.ts +1 -1
  6. package/src/admin-ui-account.ts +2 -2
  7. package/src/admin-ui-agent-template.smoke.test.ts +1 -1
  8. package/src/admin-ui-github-identity-pages.ts +2 -2
  9. package/src/admin-ui-push-test.smoke.test.ts +7 -5
  10. package/src/admin-ui-styles.unit.test.ts +3 -1
  11. package/src/admin-ui-templates-pages.ts +5 -5
  12. package/src/agent-cron-run-stats.integration.test.ts +11 -2
  13. package/src/agent-deletion-checklist.unit.test.ts +1 -1
  14. package/src/agent-manifest.unit.test.ts +3 -3
  15. package/src/agent-marketplaces-api.integration.test.ts +22 -1
  16. package/src/agent-members.integration.test.ts +1 -1
  17. package/src/agent-pod-labels.unit.test.ts +2 -2
  18. package/src/agent-provisioner.unit.test.ts +4 -4
  19. package/src/agent-setup.unit.test.ts +14 -3
  20. package/src/agent-template-items.ts +1 -1
  21. package/src/agent-templates.ts +1 -1
  22. package/src/agent-tools-token.integration.test.ts +3 -3
  23. package/src/api-auth.ts +11 -4
  24. package/src/brand-tokens.json +23 -4
  25. package/src/brand-tokens.unit.test.ts +11 -4
  26. package/src/chat-credential-config.unit.test.ts +6 -2
  27. package/src/chat-markers.unit.test.ts +5 -2
  28. package/src/cron-run-now.smoke.test.ts +1 -1
  29. package/src/cron-run-now.ts +1 -1
  30. package/src/errors.unit.test.ts +7 -4
  31. package/src/fixtures/github-agent-installation-cassette.json +35 -5
  32. package/src/github-access-backfill.ts +1 -1
  33. package/src/github-access-backfill.unit.test.ts +1 -1
  34. package/src/github-agent-installation-crawler.integration.test.ts +29 -12
  35. package/src/github-agent-installation-crawler.ts +2 -2
  36. package/src/github-agent-installation-crawler.unit.test.ts +28 -7
  37. package/src/github-app-api.ts +1 -1
  38. package/src/github-app-jwt.unit.test.ts +2 -1
  39. package/src/github-cache-roundtrip.integration.test.ts +4 -4
  40. package/src/github-enterprise-api.integration.test.ts +4 -4
  41. package/src/github-enterprise-api.ts +6 -6
  42. package/src/github-enterprise-client-page.unit.test.ts +18 -6
  43. package/src/github-enterprise-client.integration.test.ts +97 -32
  44. package/src/github-enterprise-client.ts +81 -22
  45. package/src/github-enterprise-client.unit.test.ts +1 -1
  46. package/src/github-enterprise-warnings.unit.test.ts +19 -6
  47. package/src/github-installation-selection.integration.test.ts +4 -1
  48. package/src/github-installation-wiring.unit.test.ts +1 -1
  49. package/src/github-repo-refresh-discovery.unit.test.ts +1 -1
  50. package/src/github-repo-refresher.unit.test.ts +11 -5
  51. package/src/github-sync-cache.integration.test.ts +1 -1
  52. package/src/github-sync-cached-access.ts +1 -1
  53. package/src/github-sync-reverify.unit.test.ts +1 -1
  54. package/src/github-sync-snapshot-refresh.integration.test.ts +1 -1
  55. package/src/github-sync.unit.test.ts +6 -6
  56. package/src/installation-ports-fixture.integration.test.ts +2 -2
  57. package/src/installation-repos-service.ts +5 -5
  58. package/src/kubernetes-client.integration.test.ts +1 -2
  59. package/src/platform-routes.ts +1 -1
  60. package/src/push-content.unit.test.ts +2 -2
  61. package/src/push-sender.unit.test.ts +1 -1
  62. package/src/push-service.integration.test.ts +1 -1
  63. package/src/pwa-icons.unit.test.ts +1 -1
  64. package/src/slack-config-token-resolve.unit.test.ts +25 -7
  65. package/src/slack-provisioning-client.integration.test.ts +10 -8
  66. package/src/slack-provisioning-client.ts +2 -6
  67. package/src/tools-token-policy.integration.test.ts +68 -6
  68. package/src/tools-token-policy.smoke.test.ts +22 -5
  69. package/src/tools-token-policy.ts +100 -8
  70. package/src/tools-token-policy.unit.test.ts +137 -4
  71. package/src/trial-expiry-sweeper.unit.test.ts +1 -1
  72. package/src/user-prefs.integration.test.ts +1 -1
  73. package/src/user-repo-access-resolver.unit.test.ts +1 -1
@@ -9,8 +9,8 @@
9
9
  */
10
10
 
11
11
  import { describe, expect, it } from "bun:test";
12
- import { readFileSync } from "node:fs";
13
12
  import { generateKeyPairSync } from "node:crypto";
13
+ import { readFileSync } from "node:fs";
14
14
  import {
15
15
  GithubEnterpriseClient,
16
16
  type GithubEnterpriseErrorKind,
@@ -24,7 +24,8 @@ interface CassetteEntry {
24
24
 
25
25
  const cassette: Record<string, CassetteEntry> = JSON.parse(
26
26
  readFileSync(
27
- new URL("./fixtures/github-enterprise-cassette.json", import.meta.url).pathname,
27
+ new URL("./fixtures/github-enterprise-cassette.json", import.meta.url)
28
+ .pathname,
28
29
  "utf-8",
29
30
  ),
30
31
  );
@@ -41,11 +42,14 @@ const ENT = "GET /enterprises/acme/installation";
41
42
  const MINT = "POST /app/installations/4242/access_tokens";
42
43
  const ORGS = "GET /enterprises/acme/apps/installable_organizations";
43
44
  const INSTS = "GET /enterprises/acme/apps/organizations/acme-eng/installations";
44
- const REPOS = "GET /enterprises/acme/apps/organizations/acme-eng/installations/501/repositories";
45
- const SELECTION = "PATCH /enterprises/acme/apps/organizations/acme-eng/installations/501/repositories";
45
+ const REPOS =
46
+ "GET /enterprises/acme/apps/organizations/acme-eng/installations/501/repositories";
47
+ const SELECTION =
48
+ "PATCH /enterprises/acme/apps/organizations/acme-eng/installations/501/repositories";
46
49
  const ADD = `${SELECTION}/add`;
47
50
  const REMOVE = `${SELECTION}/remove`;
48
- const INSTALL = "POST /enterprises/acme/apps/organizations/acme-eng/installations";
51
+ const INSTALL =
52
+ "POST /enterprises/acme/apps/organizations/acme-eng/installations";
49
53
 
50
54
  interface Recorded {
51
55
  method: string;
@@ -84,7 +88,10 @@ function replay(routes: Record<string, string | string[]>) {
84
88
  return { fetchFn, calls };
85
89
  }
86
90
 
87
- const OK = { [ENT]: "enterprise_installation_success", [MINT]: "access_token_success" };
91
+ const OK = {
92
+ [ENT]: "enterprise_installation_success",
93
+ [MINT]: "access_token_success",
94
+ };
88
95
 
89
96
  function makeClient(routes: Record<string, string | string[]>) {
90
97
  const { fetchFn, calls } = replay({ ...OK, ...routes });
@@ -146,11 +153,16 @@ describe("getInstallationToken", () => {
146
153
  token: "ghs_cassetteInstallationToken0000000000",
147
154
  expiresAt: "2026-11-09T13:00:00Z",
148
155
  installationId: 4242,
149
- permissions: { enterprise_organization_installations: "write", metadata: "read" },
156
+ permissions: {
157
+ enterprise_organization_installations: "write",
158
+ metadata: "read",
159
+ },
150
160
  });
151
161
  expect(calls.map((c) => `${c.method} ${c.path}`)).toEqual([ENT, MINT]);
152
162
  for (const c of calls) {
153
- expect(c.headers.get("authorization")).toMatch(/^Bearer [\w-]+\.[\w-]+\.[\w-]+$/);
163
+ expect(c.headers.get("authorization")).toMatch(
164
+ /^Bearer [\w-]+\.[\w-]+\.[\w-]+$/,
165
+ );
154
166
  expect(c.headers.get("accept")).toBe("application/vnd.github+json");
155
167
  }
156
168
  });
@@ -164,7 +176,9 @@ describe("getInstallationToken", () => {
164
176
 
165
177
  for (const [suffix, kind, status] of ERRORS) {
166
178
  it(`lookup ${suffix} -> ${kind}`, async () => {
167
- const { client } = makeClient({ [ENT]: `enterprise_installation_${suffix}` });
179
+ const { client } = makeClient({
180
+ [ENT]: `enterprise_installation_${suffix}`,
181
+ });
168
182
  const e = await errOf(client.getInstallationToken());
169
183
  expect(e.kind).toBe(kind);
170
184
  expect(e.status).toBe(status);
@@ -197,7 +211,9 @@ describe("getInstallationToken", () => {
197
211
 
198
212
  describe("listInstallableOrganizations", () => {
199
213
  it("returns orgs using the installation token", async () => {
200
- const { client, calls } = makeClient({ [ORGS]: "installable_orgs_success" });
214
+ const { client, calls } = makeClient({
215
+ [ORGS]: "installable_orgs_success",
216
+ });
201
217
  expect(await client.listInstallableOrganizations()).toEqual([
202
218
  { id: 1, login: "org-1" },
203
219
  { id: 2, login: "org-2" },
@@ -218,7 +234,9 @@ describe("listInstallableOrganizations", () => {
218
234
  });
219
235
  const orgs = await client.listInstallableOrganizations();
220
236
  expect(orgs.map((o) => o.login)).toEqual(["org-1", "org-2", "org-3"]);
221
- expect(calls.filter((c) => c.path.includes("installable_organizations"))).toHaveLength(2);
237
+ expect(
238
+ calls.filter((c) => c.path.includes("installable_organizations")),
239
+ ).toHaveLength(2);
222
240
  });
223
241
 
224
242
  it("returns an empty list", async () => {
@@ -299,14 +317,18 @@ describe("installOnOrg", () => {
299
317
  });
300
318
 
301
319
  it("sends repositories for selected", async () => {
302
- const { client, calls } = makeClient({ [INSTALL]: "install_selected_created" });
320
+ const { client, calls } = makeClient({
321
+ [INSTALL]: "install_selected_created",
322
+ });
303
323
  const r = await client.installOnOrg("acme-eng", {
304
324
  clientId: "Iv1.targetapp0001",
305
325
  repositorySelection: "selected",
306
326
  repositories: ["hello-world"],
307
327
  });
308
328
  expect(r.installation.repositorySelection).toBe("selected");
309
- expect(JSON.parse((calls[calls.length - 1] as Recorded).body ?? "")).toEqual({
329
+ expect(
330
+ JSON.parse((calls[calls.length - 1] as Recorded).body ?? ""),
331
+ ).toEqual({
310
332
  client_id: "Iv1.targetapp0001",
311
333
  repository_selection: "selected",
312
334
  repositories: ["hello-world"],
@@ -320,7 +342,9 @@ describe("installOnOrg", () => {
320
342
  repositorySelection: "none",
321
343
  repositories: ["ignored"],
322
344
  });
323
- expect(JSON.parse((calls[calls.length - 1] as Recorded).body ?? "")).toEqual({
345
+ expect(
346
+ JSON.parse((calls[calls.length - 1] as Recorded).body ?? ""),
347
+ ).toEqual({
324
348
  client_id: "Iv1.x",
325
349
  repository_selection: "none",
326
350
  });
@@ -330,7 +354,10 @@ describe("installOnOrg", () => {
330
354
  it(`${suffix} -> ${kind}`, async () => {
331
355
  const { client } = makeClient({ [INSTALL]: `install_${suffix}` });
332
356
  const e = await errOf(
333
- client.installOnOrg("acme-eng", { clientId: "Iv1.x", repositorySelection: "all" }),
357
+ client.installOnOrg("acme-eng", {
358
+ clientId: "Iv1.x",
359
+ repositorySelection: "all",
360
+ }),
334
361
  );
335
362
  expect(e.kind).toBe(kind);
336
363
  expect(e.status).toBe(status);
@@ -369,13 +396,17 @@ describe("listInstallationRepositories", () => {
369
396
 
370
397
  it("returns an empty list", async () => {
371
398
  const { client } = makeClient({ [REPOS]: "install_repos_empty" });
372
- expect(await client.listInstallationRepositories("acme-eng", 501)).toEqual([]);
399
+ expect(await client.listInstallationRepositories("acme-eng", 501)).toEqual(
400
+ [],
401
+ );
373
402
  });
374
403
 
375
404
  for (const [suffix, kind, status] of ERRORS) {
376
405
  it(`${suffix} -> ${kind}`, async () => {
377
406
  const { client } = makeClient({ [REPOS]: `install_repos_${suffix}` });
378
- const e = await errOf(client.listInstallationRepositories("acme-eng", 501));
407
+ const e = await errOf(
408
+ client.listInstallationRepositories("acme-eng", 501),
409
+ );
379
410
  expect(e.kind).toBe(kind);
380
411
  expect(e.status).toBe(status);
381
412
  expectNoSecrets(e);
@@ -385,12 +416,22 @@ describe("listInstallationRepositories", () => {
385
416
 
386
417
  describe("addRepositories", () => {
387
418
  it("patches repository names and maps the result", async () => {
388
- const { client, calls } = makeClient({ [ADD]: "install_repos_add_success" });
389
- const r = await client.addRepositories("acme-eng", 501, ["repo-1", "repo-2"]);
390
- expect(r.map((x) => x.fullName)).toEqual(["acme-eng/repo-1", "acme-eng/repo-2"]);
419
+ const { client, calls } = makeClient({
420
+ [ADD]: "install_repos_add_success",
421
+ });
422
+ const r = await client.addRepositories("acme-eng", 501, [
423
+ "repo-1",
424
+ "repo-2",
425
+ ]);
426
+ expect(r.map((x) => x.fullName)).toEqual([
427
+ "acme-eng/repo-1",
428
+ "acme-eng/repo-2",
429
+ ]);
391
430
  const last = calls[calls.length - 1] as Recorded;
392
431
  expect(last.method).toBe("PATCH");
393
- expect(JSON.parse(last.body ?? "")).toEqual({ repositories: ["repo-1", "repo-2"] });
432
+ expect(JSON.parse(last.body ?? "")).toEqual({
433
+ repositories: ["repo-1", "repo-2"],
434
+ });
394
435
  });
395
436
 
396
437
  it("splits 51 repositories into batches of 50 and 1", async () => {
@@ -400,8 +441,12 @@ describe("addRepositories", () => {
400
441
  const r = await client.addRepositories("acme-eng", 501, names(1, 51));
401
442
  expect(r).toHaveLength(51);
402
443
  const patches = calls.filter((c) => c.method === "PATCH");
403
- expect(patches.map((c) => JSON.parse(c.body ?? "").repositories.length)).toEqual([50, 1]);
404
- expect(patches.every((c) => c.path.endsWith("/repositories/add"))).toBe(true);
444
+ expect(
445
+ patches.map((c) => JSON.parse(c.body ?? "").repositories.length),
446
+ ).toEqual([50, 1]);
447
+ expect(patches.every((c) => c.path.endsWith("/repositories/add"))).toBe(
448
+ true,
449
+ );
405
450
  });
406
451
 
407
452
  it("makes no request for an empty list", async () => {
@@ -413,7 +458,9 @@ describe("addRepositories", () => {
413
458
  for (const [suffix, kind, status] of ERRORS) {
414
459
  it(`${suffix} -> ${kind}`, async () => {
415
460
  const { client } = makeClient({ [ADD]: `install_repos_add_${suffix}` });
416
- const e = await errOf(client.addRepositories("acme-eng", 501, ["repo-1"]));
461
+ const e = await errOf(
462
+ client.addRepositories("acme-eng", 501, ["repo-1"]),
463
+ );
417
464
  expect(e.kind).toBe(kind);
418
465
  expect(e.status).toBe(status);
419
466
  expectNoSecrets(e);
@@ -423,38 +470,56 @@ describe("addRepositories", () => {
423
470
 
424
471
  describe("removeRepositories", () => {
425
472
  it("patches repository names to /remove", async () => {
426
- const { client, calls } = makeClient({ [REMOVE]: "install_repos_remove_success" });
427
- const r = await client.removeRepositories("acme-eng", 501, ["repo-1", "repo-2"]);
473
+ const { client, calls } = makeClient({
474
+ [REMOVE]: "install_repos_remove_success",
475
+ });
476
+ const r = await client.removeRepositories("acme-eng", 501, [
477
+ "repo-1",
478
+ "repo-2",
479
+ ]);
428
480
  expect(r).toHaveLength(2);
429
481
  const last = calls[calls.length - 1] as Recorded;
430
482
  expect(last.method).toBe("PATCH");
431
483
  expect(last.path).toEndWith("/installations/501/repositories/remove");
432
- expect(JSON.parse(last.body ?? "")).toEqual({ repositories: ["repo-1", "repo-2"] });
484
+ expect(JSON.parse(last.body ?? "")).toEqual({
485
+ repositories: ["repo-1", "repo-2"],
486
+ });
433
487
  });
434
488
 
435
489
  it("splits 51 repositories into batches of 50 and 1", async () => {
436
490
  const { client, calls } = makeClient({
437
- [REMOVE]: ["install_repos_remove_batch_1", "install_repos_remove_batch_2"],
491
+ [REMOVE]: [
492
+ "install_repos_remove_batch_1",
493
+ "install_repos_remove_batch_2",
494
+ ],
438
495
  });
439
496
  const r = await client.removeRepositories("acme-eng", 501, names(1, 51));
440
497
  expect(r).toHaveLength(51);
441
498
  const patches = calls.filter((c) => c.method === "PATCH");
442
- expect(patches.map((c) => JSON.parse(c.body ?? "").repositories.length)).toEqual([50, 1]);
499
+ expect(
500
+ patches.map((c) => JSON.parse(c.body ?? "").repositories.length),
501
+ ).toEqual([50, 1]);
443
502
  });
444
503
 
445
504
  it("stops at the first failing batch", async () => {
446
505
  const { client, calls } = makeClient({
447
506
  [REMOVE]: ["install_repos_remove_batch_1", "install_repos_remove_422"],
448
507
  });
449
- const e = await errOf(client.removeRepositories("acme-eng", 501, names(1, 101)));
508
+ const e = await errOf(
509
+ client.removeRepositories("acme-eng", 501, names(1, 101)),
510
+ );
450
511
  expect(e.kind).toBe("validation");
451
512
  expect(calls.filter((c) => c.method === "PATCH")).toHaveLength(2);
452
513
  });
453
514
 
454
515
  for (const [suffix, kind, status] of ERRORS) {
455
516
  it(`${suffix} -> ${kind}`, async () => {
456
- const { client } = makeClient({ [REMOVE]: `install_repos_remove_${suffix}` });
457
- const e = await errOf(client.removeRepositories("acme-eng", 501, ["repo-1"]));
517
+ const { client } = makeClient({
518
+ [REMOVE]: `install_repos_remove_${suffix}`,
519
+ });
520
+ const e = await errOf(
521
+ client.removeRepositories("acme-eng", 501, ["repo-1"]),
522
+ );
458
523
  expect(e.kind).toBe(kind);
459
524
  expect(e.status).toBe(status);
460
525
  expectNoSecrets(e);
@@ -82,7 +82,11 @@ export class GithubEnterpriseError extends Error {
82
82
  constructor(
83
83
  kind: GithubEnterpriseErrorKind,
84
84
  message: string,
85
- opts?: { status?: number; retryAfterSeconds?: number; step?: "installation_lookup" },
85
+ opts?: {
86
+ status?: number;
87
+ retryAfterSeconds?: number;
88
+ step?: "installation_lookup";
89
+ },
86
90
  ) {
87
91
  super(message);
88
92
  this.name = "GithubEnterpriseError";
@@ -105,7 +109,9 @@ export function mapGithubEnterpriseError(
105
109
  secrets: readonly string[] = [],
106
110
  ): GithubEnterpriseError {
107
111
  let detail =
108
- body && typeof body === "object" && typeof (body as { message?: unknown }).message === "string"
112
+ body &&
113
+ typeof body === "object" &&
114
+ typeof (body as { message?: unknown }).message === "string"
109
115
  ? (body as { message: string }).message
110
116
  : "";
111
117
  for (const s of secrets) if (s) detail = detail.split(s).join("[redacted]");
@@ -116,17 +122,25 @@ export function mapGithubEnterpriseError(
116
122
  const retryAfterSeconds = Number.isFinite(ra) && ra > 0 ? ra : undefined;
117
123
  const opts = { status, retryAfterSeconds };
118
124
 
119
- if (status === 429) return new GithubEnterpriseError("rate_limit", message, opts);
125
+ if (status === 429)
126
+ return new GithubEnterpriseError("rate_limit", message, opts);
120
127
  if (status === 403) {
121
128
  const limited =
122
129
  headers.get("retry-after") !== null ||
123
130
  headers.get("x-ratelimit-remaining") === "0" ||
124
131
  /rate limit/i.test(detail);
125
- return new GithubEnterpriseError(limited ? "rate_limit" : "permission", message, opts);
132
+ return new GithubEnterpriseError(
133
+ limited ? "rate_limit" : "permission",
134
+ message,
135
+ opts,
136
+ );
126
137
  }
127
- if (status === 401) return new GithubEnterpriseError("unauthorized", message, opts);
128
- if (status === 404) return new GithubEnterpriseError("not_found", message, opts);
129
- if (status === 422) return new GithubEnterpriseError("validation", message, opts);
138
+ if (status === 401)
139
+ return new GithubEnterpriseError("unauthorized", message, opts);
140
+ if (status === 404)
141
+ return new GithubEnterpriseError("not_found", message, opts);
142
+ if (status === 422)
143
+ return new GithubEnterpriseError("validation", message, opts);
130
144
  if (status >= 500) return new GithubEnterpriseError("server", message, opts);
131
145
  return new GithubEnterpriseError("unexpected", message, opts);
132
146
  }
@@ -248,7 +262,8 @@ export class GithubEnterpriseClient {
248
262
  async getInstallationToken(): Promise<EnterpriseInstallationToken> {
249
263
  if (
250
264
  this.cached &&
251
- Date.parse(this.cached.expiresAt) - this.now().getTime() > TOKEN_REFRESH_SKEW_MS
265
+ Date.parse(this.cached.expiresAt) - this.now().getTime() >
266
+ TOKEN_REFRESH_SKEW_MS
252
267
  ) {
253
268
  return this.cached;
254
269
  }
@@ -330,12 +345,21 @@ export class GithubEnterpriseClient {
330
345
  }
331
346
 
332
347
  /** Install an App on an enterprise-owned org. */
333
- async installOnOrg(org: string, input: InstallOnOrgInput): Promise<InstallOnOrgResult> {
348
+ async installOnOrg(
349
+ org: string,
350
+ input: InstallOnOrgInput,
351
+ ): Promise<InstallOnOrgResult> {
334
352
  if (!input.clientId) {
335
- throw new GithubEnterpriseError("validation", "installOnOrg: clientId is required");
353
+ throw new GithubEnterpriseError(
354
+ "validation",
355
+ "installOnOrg: clientId is required",
356
+ );
336
357
  }
337
358
  const repos = input.repositories ?? [];
338
- if (input.repositorySelection === "selected" && (repos.length === 0 || repos.length > MAX_REPOSITORIES)) {
359
+ if (
360
+ input.repositorySelection === "selected" &&
361
+ (repos.length === 0 || repos.length > MAX_REPOSITORIES)
362
+ ) {
339
363
  throw new GithubEnterpriseError(
340
364
  "validation",
341
365
  `installOnOrg: repositories must list 1-${MAX_REPOSITORIES} names when repositorySelection is "selected"`,
@@ -356,9 +380,15 @@ export class GithubEnterpriseClient {
356
380
  body,
357
381
  );
358
382
  if (typeof res.data?.id !== "number") {
359
- throw new GithubEnterpriseError("unexpected", "GitHub install App on org: response missing id");
383
+ throw new GithubEnterpriseError(
384
+ "unexpected",
385
+ "GitHub install App on org: response missing id",
386
+ );
360
387
  }
361
- return { installation: toInstallation(res.data), created: res.status === 201 };
388
+ return {
389
+ installation: toInstallation(res.data),
390
+ created: res.status === 201,
391
+ };
362
392
  }
363
393
 
364
394
  /**
@@ -406,7 +436,10 @@ export class GithubEnterpriseClient {
406
436
  page: number,
407
437
  ): Promise<InstallationRepositoriesPage> {
408
438
  if (!Number.isInteger(page) || page < 1) {
409
- throw new GithubEnterpriseError("validation", "page must be a positive integer");
439
+ throw new GithubEnterpriseError(
440
+ "validation",
441
+ "page must be a positive integer",
442
+ );
410
443
  }
411
444
  const context = "GitHub installation repositories";
412
445
  const path = this.repositoriesPath(org, installationId);
@@ -418,10 +451,14 @@ export class GithubEnterpriseClient {
418
451
  context,
419
452
  );
420
453
  if (!Array.isArray(res.data)) {
421
- throw new GithubEnterpriseError("unexpected", `${context}: response is not a list`);
454
+ throw new GithubEnterpriseError(
455
+ "unexpected",
456
+ `${context}: response is not a list`,
457
+ );
422
458
  }
423
459
  const link = res.headers.get("link");
424
- const hasNext = link !== null ? /rel="next"/.test(link) : res.data.length >= PER_PAGE;
460
+ const hasNext =
461
+ link !== null ? /rel="next"/.test(link) : res.data.length >= PER_PAGE;
425
462
  return {
426
463
  repos: res.data.map((r) => ({
427
464
  ...toRepository(r),
@@ -438,7 +475,13 @@ export class GithubEnterpriseClient {
438
475
  installationId: number,
439
476
  names: readonly string[],
440
477
  ): Promise<AccessibleRepository[]> {
441
- return this.patchRepositories(org, installationId, "add", names, "GitHub add installation repositories");
478
+ return this.patchRepositories(
479
+ org,
480
+ installationId,
481
+ "add",
482
+ names,
483
+ "GitHub add installation repositories",
484
+ );
442
485
  }
443
486
 
444
487
  /** Remove repository access from an installation, in batches of at most 50. */
@@ -460,7 +503,10 @@ export class GithubEnterpriseClient {
460
503
 
461
504
  private repositoriesPath(org: string, installationId: number): string {
462
505
  if (!Number.isInteger(installationId) || installationId <= 0) {
463
- throw new GithubEnterpriseError("validation", "installationId must be a positive integer");
506
+ throw new GithubEnterpriseError(
507
+ "validation",
508
+ "installationId must be a positive integer",
509
+ );
464
510
  }
465
511
  const ent = encodeURIComponent(this.enterprise);
466
512
  return `/enterprises/${ent}/apps/organizations/${encodeURIComponent(org)}/installations/${installationId}/repositories`;
@@ -480,9 +526,18 @@ export class GithubEnterpriseClient {
480
526
  const { token } = await this.getInstallationToken();
481
527
  const out: AccessibleRepository[] = [];
482
528
  for (const repositories of batches) {
483
- const res = await this.request<RawRepository[]>("PATCH", path, token, context, { repositories });
529
+ const res = await this.request<RawRepository[]>(
530
+ "PATCH",
531
+ path,
532
+ token,
533
+ context,
534
+ { repositories },
535
+ );
484
536
  if (!Array.isArray(res.data)) {
485
- throw new GithubEnterpriseError("unexpected", `${context}: response is not a list`);
537
+ throw new GithubEnterpriseError(
538
+ "unexpected",
539
+ `${context}: response is not a list`,
540
+ );
486
541
  }
487
542
  out.push(...res.data.map(toRepository));
488
543
  }
@@ -500,11 +555,15 @@ export class GithubEnterpriseClient {
500
555
  context,
501
556
  );
502
557
  if (!Array.isArray(res.data)) {
503
- throw new GithubEnterpriseError("unexpected", `${context}: response is not a list`);
558
+ throw new GithubEnterpriseError(
559
+ "unexpected",
560
+ `${context}: response is not a list`,
561
+ );
504
562
  }
505
563
  all.push(...res.data);
506
564
  const link = res.headers.get("link");
507
- const hasNext = link !== null ? /rel="next"/.test(link) : res.data.length >= PER_PAGE;
565
+ const hasNext =
566
+ link !== null ? /rel="next"/.test(link) : res.data.length >= PER_PAGE;
508
567
  if (!hasNext) break;
509
568
  }
510
569
  return all;
@@ -5,10 +5,10 @@
5
5
 
6
6
  import { describe, expect, it } from "bun:test";
7
7
  import {
8
+ batchRepositoryNames,
8
9
  GithubEnterpriseClient,
9
10
  GithubEnterpriseError,
10
11
  type GithubEnterpriseErrorKind,
11
- batchRepositoryNames,
12
12
  mapGithubEnterpriseError,
13
13
  } from "./github-enterprise-client.ts";
14
14
 
@@ -11,31 +11,44 @@ import {
11
11
 
12
12
  describe("permissionWarnings", () => {
13
13
  it("installer: warns unless the repositories permission is write", () => {
14
- expect(permissionWarnings("installer", {})).toEqual([GHE_WARNINGS.installer_repositories_write]);
14
+ expect(permissionWarnings("installer", {})).toEqual([
15
+ GHE_WARNINGS.installer_repositories_write,
16
+ ]);
15
17
  expect(
16
- permissionWarnings("installer", { enterprise_organization_installation_repositories: "read" }),
18
+ permissionWarnings("installer", {
19
+ enterprise_organization_installation_repositories: "read",
20
+ }),
17
21
  ).toHaveLength(1);
18
22
  expect(
19
- permissionWarnings("installer", { enterprise_organization_installation_repositories: "write" }),
23
+ permissionWarnings("installer", {
24
+ enterprise_organization_installation_repositories: "write",
25
+ }),
20
26
  ).toEqual([]);
21
27
  });
22
28
 
23
29
  it("installer warning says the repositories permission is needed for Sync", () => {
24
30
  const msg = GHE_WARNINGS.installer_repositories_write;
25
- expect(msg).toContain("enterprise_organization_installation_repositories (write)");
31
+ expect(msg).toContain(
32
+ "enterprise_organization_installation_repositories (write)",
33
+ );
26
34
  expect(msg).toContain("Sync");
27
35
  expect(msg).not.toContain("not needed yet");
28
36
  });
29
37
 
30
38
  it("lookup: warns unless members is read or write", () => {
31
- expect(permissionWarnings("lookup", { metadata: "read" })).toEqual([GHE_WARNINGS.lookup_members_read]);
39
+ expect(permissionWarnings("lookup", { metadata: "read" })).toEqual([
40
+ GHE_WARNINGS.lookup_members_read,
41
+ ]);
32
42
  expect(permissionWarnings("lookup", { members: "read" })).toEqual([]);
33
43
  expect(permissionWarnings("lookup", { members: "write" })).toEqual([]);
34
44
  });
35
45
  });
36
46
 
37
47
  describe("resolveValidation", () => {
38
- const installer = { name: "enterprise_organization_installations", levels: ["write"] };
48
+ const installer = {
49
+ name: "enterprise_organization_installations",
50
+ levels: ["write"],
51
+ };
39
52
 
40
53
  it("a warning never turns a valid result invalid", () => {
41
54
  const r = resolveValidation("installer", installer, {
@@ -60,7 +60,10 @@ describeOrSkip("agent installation repository selection (integration)", () => {
60
60
  });
61
61
  const stored = async () =>
62
62
  (
63
- await cache.listAgentSnapshots(DEPLOYMENT_WIDE_ACCOUNT_KEY, String(APP_ID))
63
+ await cache.listAgentSnapshots(
64
+ DEPLOYMENT_WIDE_ACCOUNT_KEY,
65
+ String(APP_ID),
66
+ )
64
67
  )[0]?.repositorySelection;
65
68
 
66
69
  beforeEach(async () => {
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from "bun:test";
2
+ import type { GitHubEnterpriseAppMetadata } from "./github-enterprise-apps.ts";
2
3
  import {
3
4
  accessFor,
4
5
  envWith,
@@ -12,7 +13,6 @@ import {
12
13
  createGithubInstallationRepos,
13
14
  createGithubSync,
14
15
  } from "./github-installation-wiring.ts";
15
- import type { GitHubEnterpriseAppMetadata } from "./github-enterprise-apps.ts";
16
16
  import type { InstallationReposPort } from "./installation-repos-service.ts";
17
17
 
18
18
  const noApp = { get: async () => null, getPrivateKey: async () => null };
@@ -7,13 +7,13 @@
7
7
 
8
8
  import { describe, expect, it } from "bun:test";
9
9
  import { GithubEnterpriseError } from "./github-enterprise-client.ts";
10
+ import type { PageSource } from "./github-repo-crawler.ts";
10
11
  import {
11
12
  createRefreshDiscovery,
12
13
  type DiscoveryPorts,
13
14
  type LookupAppClient,
14
15
  notFoundAsEmpty,
15
16
  } from "./github-repo-refresh-discovery.ts";
16
- import type { PageSource } from "./github-repo-crawler.ts";
17
17
  import type { InstallationAgentRecord } from "./installation-ports.ts";
18
18
 
19
19
  const clock = { now: () => new Date("2026-11-20T12:00:00Z") };
@@ -474,13 +474,19 @@ describe("GithubRepoRefresher access backfill and archived repos", () => {
474
474
  org: "acme",
475
475
  };
476
476
  const t = target("acme", { users: [{ username: "octocat" }] });
477
- t.access = { ...(t.access as NonNullable<typeof t.access>), installationKeys: [agentKey] };
477
+ t.access = {
478
+ ...(t.access as NonNullable<typeof t.access>),
479
+ installationKeys: [agentKey],
480
+ };
478
481
  await seedCrawl(t.key, ["acme/a", "acme/b", "acme/c"], T0);
479
482
  await seedCrawl(agentKey, ["acme/c"], T0);
480
483
  store.archived = new Set(["acme/b", "acme/c"]);
481
484
  await refresher([t]).tick();
482
485
  // Installed archived acme/c is probed; the other archived acme/b is not.
483
- expect(events.sort()).toEqual(["probe:acme/a@octocat", "probe:acme/c@octocat"]);
486
+ expect(events.sort()).toEqual([
487
+ "probe:acme/a@octocat",
488
+ "probe:acme/c@octocat",
489
+ ]);
484
490
  });
485
491
  });
486
492
 
@@ -571,9 +577,9 @@ describe("GithubRepoRefresher.tick", () => {
571
577
  clock.advance(MIN);
572
578
  const second = await r.tick();
573
579
  expect(events[0]).toBe("crawl:capped");
574
- expect(
575
- second.targets.find((s) => s.key.org === "capped")?.steps,
576
- ).toEqual(["crawl:stale_cap"]);
580
+ expect(second.targets.find((s) => s.key.org === "capped")?.steps).toEqual([
581
+ "crawl:stale_cap",
582
+ ]);
577
583
  });
578
584
 
579
585
  it("skips an org whose lease another worker holds", async () => {
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from "bun:test";
2
+ import type { GitHubEnterpriseAppMetadata } from "./github-enterprise-apps.ts";
2
3
  import {
3
4
  accessFor,
4
5
  envWith,
@@ -10,7 +11,6 @@ import {
10
11
  createGithubInstallationRepos,
11
12
  createGithubSync,
12
13
  } from "./github-installation-wiring.ts";
13
- import type { GitHubEnterpriseAppMetadata } from "./github-enterprise-apps.ts";
14
14
  import type { InstallationReposPort } from "./installation-repos-service.ts";
15
15
 
16
16
  // Sync preview over the real cache service (fake prisma): complete, partial, stale.
@@ -13,6 +13,7 @@
13
13
  * over stale data when both apply.
14
14
  */
15
15
 
16
+ import type { RepoRole } from "./github-lookup-client.ts";
16
17
  import type { CachedAccessRow } from "./installation-repos-service.ts";
17
18
  import {
18
19
  INCOMPLETE_ACCESS_REASON,
@@ -25,7 +26,6 @@ import {
25
26
  type ResolvedRepoAccess,
26
27
  type UserRepoAccessResult,
27
28
  } from "./user-repo-access-resolver.ts";
28
- import type { RepoRole } from "./github-lookup-client.ts";
29
29
 
30
30
  export interface CachedOrgInput {
31
31
  org: string;
@@ -4,8 +4,8 @@ import {
4
4
  REVERIFY_FAILED_REASON,
5
5
  STILL_PUSHABLE_REASON,
6
6
  } from "./github-sync.ts";
7
- import type { InstallationCachePort } from "./installation-repos-service.ts";
8
7
  import { MAX_UNCONFIRMED_REMOVALS } from "./installation-ports.ts";
8
+ import type { InstallationCachePort } from "./installation-repos-service.ts";
9
9
 
10
10
  const NOW = new Date("2026-11-21T00:00:00.000Z");
11
11
  const names = (n: number) => Array.from({ length: n }, (_, i) => `acme/r${i}`);