@app-vitals/agent-admin 1.35.1 → 1.36.1

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.
@@ -3305,50 +3305,7 @@
3305
3305
  "orgs"
3306
3306
  ]
3307
3307
  },
3308
- "GithubInstallationReposChange": {
3309
- "type": "object",
3310
- "properties": {
3311
- "status": {
3312
- "type": "string",
3313
- "enum": [
3314
- "applied"
3315
- ]
3316
- },
3317
- "auditId": {
3318
- "type": "string"
3319
- },
3320
- "repos": {
3321
- "type": "array",
3322
- "items": {
3323
- "type": "string"
3324
- }
3325
- }
3326
- },
3327
- "required": [
3328
- "status",
3329
- "auditId",
3330
- "repos"
3331
- ]
3332
- },
3333
- "GithubInstallationReposBody": {
3334
- "type": "object",
3335
- "properties": {
3336
- "repos": {
3337
- "type": "array",
3338
- "items": {
3339
- "type": "string",
3340
- "pattern": "^[^/\\s]+\\/[^/\\s]+$"
3341
- },
3342
- "minItems": 1,
3343
- "maxItems": 100,
3344
- "description": "Repos (owner/repo) to change on the agent App's installation."
3345
- }
3346
- },
3347
- "required": [
3348
- "repos"
3349
- ]
3350
- },
3351
- "GithubLostAccessPreview": {
3308
+ "GithubSyncPreview": {
3352
3309
  "type": "object",
3353
3310
  "properties": {
3354
3311
  "status": {
@@ -3362,24 +3319,26 @@
3362
3319
  "reason": {
3363
3320
  "type": "string"
3364
3321
  },
3365
- "repos": {
3322
+ "appAdds": {
3366
3323
  "type": "array",
3367
3324
  "items": {
3368
3325
  "type": "string"
3369
3326
  },
3370
- "description": "Every repo the bound user can no longer push to that would be removed from the installation or the agent's repos."
3327
+ "description": "Repos the bound user can push to, in orgs the agent App is installed on with a complete access listing, that are not on the installation. No cap."
3371
3328
  },
3372
- "installationRemoves": {
3329
+ "appRemoves": {
3373
3330
  "type": "array",
3374
3331
  "items": {
3375
3332
  "type": "string"
3376
- }
3333
+ },
3334
+ "description": "Installation repos the bound user can no longer push to."
3377
3335
  },
3378
- "configRemoves": {
3336
+ "agentRemoves": {
3379
3337
  "type": "array",
3380
3338
  "items": {
3381
3339
  "type": "string"
3382
- }
3340
+ },
3341
+ "description": "Configured agent repos the bound user can no longer push to. The agent's repos are never added to."
3383
3342
  },
3384
3343
  "skippedOrgs": {
3385
3344
  "type": "array",
@@ -3398,7 +3357,7 @@
3398
3357
  "reason"
3399
3358
  ]
3400
3359
  },
3401
- "description": "Orgs whose access listing is missing, partial or failed, or whose lookup App is installed on selected repositories only; nothing there is removed."
3360
+ "description": "Orgs whose access listing is missing, partial or failed, or whose lookup App is not installed or installed on selected repositories only; nothing there is added or removed."
3402
3361
  },
3403
3362
  "openWork": {
3404
3363
  "type": "array",
@@ -3420,7 +3379,7 @@
3420
3379
  "repo"
3421
3380
  ]
3422
3381
  },
3423
- "description": "The agent's open tasks and PRs on those repos that removing them would block; empty when no open-work port is wired."
3382
+ "description": "The agent's open tasks and PRs on the removed repos that the removals would block; empty when no open-work port is wired."
3424
3383
  },
3425
3384
  "warnings": {
3426
3385
  "type": "array",
@@ -3433,7 +3392,7 @@
3433
3392
  "status"
3434
3393
  ]
3435
3394
  },
3436
- "GithubLostAccessRemoveResult": {
3395
+ "GithubSyncApplyResult": {
3437
3396
  "type": "object",
3438
3397
  "properties": {
3439
3398
  "status": {
@@ -3450,25 +3409,25 @@
3450
3409
  "auditId": {
3451
3410
  "type": "string"
3452
3411
  },
3453
- "repos": {
3412
+ "appAdds": {
3454
3413
  "type": "array",
3455
3414
  "items": {
3456
3415
  "type": "string"
3457
3416
  }
3458
3417
  },
3459
- "installationRemoves": {
3418
+ "appRemoves": {
3460
3419
  "type": "array",
3461
3420
  "items": {
3462
3421
  "type": "string"
3463
3422
  }
3464
3423
  },
3465
- "configRemoves": {
3424
+ "agentRemoves": {
3466
3425
  "type": "array",
3467
3426
  "items": {
3468
3427
  "type": "string"
3469
3428
  }
3470
3429
  },
3471
- "notRemoved": {
3430
+ "notApplied": {
3472
3431
  "type": "array",
3473
3432
  "items": {
3474
3433
  "type": "object",
@@ -3485,7 +3444,7 @@
3485
3444
  "reason"
3486
3445
  ]
3487
3446
  },
3488
- "description": "Named repos left alone: the user can still push, the org was skipped, or the repo is on neither the installation nor the agent."
3447
+ "description": "Confirmed repos left alone: access changed since the preview, the org was skipped, or the repo is not where the change expected it."
3489
3448
  },
3490
3449
  "skippedOrgs": {
3491
3450
  "type": "array",
@@ -3516,27 +3475,44 @@
3516
3475
  "status"
3517
3476
  ]
3518
3477
  },
3519
- "GithubLostAccessRemoveBody": {
3478
+ "GithubSyncApplyBody": {
3520
3479
  "type": "object",
3521
3480
  "properties": {
3522
- "repos": {
3481
+ "appAdds": {
3523
3482
  "type": "array",
3524
3483
  "items": {
3525
3484
  "type": "string",
3526
3485
  "pattern": "^[^/\\s]+\\/[^/\\s]+$"
3527
3486
  },
3528
- "minItems": 1,
3529
- "maxItems": 100,
3530
- "description": "The repos (owner/repo) the admin confirmed from the preview. Each is re-checked; only those the user still cannot push to are removed."
3487
+ "maxItems": 500,
3488
+ "default": [],
3489
+ "description": "Repos (owner/repo) the admin confirmed to add to the agent App's installation."
3490
+ },
3491
+ "appRemoves": {
3492
+ "type": "array",
3493
+ "items": {
3494
+ "type": "string",
3495
+ "pattern": "^[^/\\s]+\\/[^/\\s]+$"
3496
+ },
3497
+ "maxItems": 500,
3498
+ "default": [],
3499
+ "description": "Repos the admin confirmed to remove from the agent App's installation."
3500
+ },
3501
+ "agentRemoves": {
3502
+ "type": "array",
3503
+ "items": {
3504
+ "type": "string",
3505
+ "pattern": "^[^/\\s]+\\/[^/\\s]+$"
3506
+ },
3507
+ "maxItems": 500,
3508
+ "default": [],
3509
+ "description": "Repos the admin confirmed to remove from the agent's repos."
3531
3510
  },
3532
3511
  "confirmRemovals": {
3533
3512
  "type": "boolean",
3534
- "description": "Required when more than 10 repos would be removed."
3513
+ "description": "Required when more than 10 distinct repos would be removed."
3535
3514
  }
3536
- },
3537
- "required": [
3538
- "repos"
3539
- ]
3515
+ }
3540
3516
  },
3541
3517
  "AgentConfigResponse": {
3542
3518
  "type": "object",
@@ -7362,228 +7338,12 @@
7362
7338
  }
7363
7339
  }
7364
7340
  }
7365
- },
7366
- "post": {
7367
- "summary": "Add repos to the agent App's installation",
7368
- "description": "Platform-admin only. Grants the agent's own GitHub App installation access to the named repos; the agent's configured repos are not changed. Writes one audit entry (GitHubReconcileAudit, planHash `direct:add`) recording the caller and repos. 404 unknown agent; 422 no GH_APP_ID; 409 when the App is not installed on a repo's org (nothing is changed or audited); 502 when GitHub refuses (a failed audit entry is written).",
7369
- "parameters": [
7370
- {
7371
- "schema": {
7372
- "type": "string",
7373
- "example": "clx1234567890"
7374
- },
7375
- "required": true,
7376
- "name": "id",
7377
- "in": "path"
7378
- }
7379
- ],
7380
- "requestBody": {
7381
- "required": true,
7382
- "content": {
7383
- "application/json": {
7384
- "schema": {
7385
- "$ref": "#/components/schemas/GithubInstallationReposBody"
7386
- }
7387
- }
7388
- }
7389
- },
7390
- "responses": {
7391
- "200": {
7392
- "description": "Repos added",
7393
- "content": {
7394
- "application/json": {
7395
- "schema": {
7396
- "$ref": "#/components/schemas/GithubInstallationReposChange"
7397
- }
7398
- }
7399
- }
7400
- },
7401
- "401": {
7402
- "description": "Unauthorized",
7403
- "content": {
7404
- "application/json": {
7405
- "schema": {
7406
- "$ref": "#/components/schemas/Error"
7407
- }
7408
- }
7409
- }
7410
- },
7411
- "403": {
7412
- "description": "Platform admin required",
7413
- "content": {
7414
- "application/json": {
7415
- "schema": {
7416
- "$ref": "#/components/schemas/Error"
7417
- }
7418
- }
7419
- }
7420
- },
7421
- "404": {
7422
- "description": "Agent not found",
7423
- "content": {
7424
- "application/json": {
7425
- "schema": {
7426
- "$ref": "#/components/schemas/Error"
7427
- }
7428
- }
7429
- }
7430
- },
7431
- "409": {
7432
- "description": "Agent App not installed on the org",
7433
- "content": {
7434
- "application/json": {
7435
- "schema": {
7436
- "$ref": "#/components/schemas/Error"
7437
- }
7438
- }
7439
- }
7440
- },
7441
- "422": {
7442
- "description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
7443
- "content": {
7444
- "application/json": {
7445
- "schema": {
7446
- "$ref": "#/components/schemas/Error"
7447
- }
7448
- }
7449
- }
7450
- },
7451
- "502": {
7452
- "description": "GitHub unavailable or refused",
7453
- "content": {
7454
- "application/json": {
7455
- "schema": {
7456
- "$ref": "#/components/schemas/Error"
7457
- }
7458
- }
7459
- }
7460
- },
7461
- "503": {
7462
- "description": "GitHub Apps are not configured",
7463
- "content": {
7464
- "application/json": {
7465
- "schema": {
7466
- "$ref": "#/components/schemas/Error"
7467
- }
7468
- }
7469
- }
7470
- }
7471
- }
7472
- }
7473
- },
7474
- "/agents/{id}/github-installation/repos/remove": {
7475
- "post": {
7476
- "summary": "Remove repos from the agent App's installation",
7477
- "description": "Platform-admin only. Revokes the agent's own GitHub App installation access to the named repos; the agent's configured repos are not changed. Writes one audit entry (GitHubReconcileAudit, planHash `direct:remove`) recording the caller and repos. Same errors as the add route.",
7478
- "parameters": [
7479
- {
7480
- "schema": {
7481
- "type": "string",
7482
- "example": "clx1234567890"
7483
- },
7484
- "required": true,
7485
- "name": "id",
7486
- "in": "path"
7487
- }
7488
- ],
7489
- "requestBody": {
7490
- "required": true,
7491
- "content": {
7492
- "application/json": {
7493
- "schema": {
7494
- "$ref": "#/components/schemas/GithubInstallationReposBody"
7495
- }
7496
- }
7497
- }
7498
- },
7499
- "responses": {
7500
- "200": {
7501
- "description": "Repos removed",
7502
- "content": {
7503
- "application/json": {
7504
- "schema": {
7505
- "$ref": "#/components/schemas/GithubInstallationReposChange"
7506
- }
7507
- }
7508
- }
7509
- },
7510
- "401": {
7511
- "description": "Unauthorized",
7512
- "content": {
7513
- "application/json": {
7514
- "schema": {
7515
- "$ref": "#/components/schemas/Error"
7516
- }
7517
- }
7518
- }
7519
- },
7520
- "403": {
7521
- "description": "Platform admin required",
7522
- "content": {
7523
- "application/json": {
7524
- "schema": {
7525
- "$ref": "#/components/schemas/Error"
7526
- }
7527
- }
7528
- }
7529
- },
7530
- "404": {
7531
- "description": "Agent not found",
7532
- "content": {
7533
- "application/json": {
7534
- "schema": {
7535
- "$ref": "#/components/schemas/Error"
7536
- }
7537
- }
7538
- }
7539
- },
7540
- "409": {
7541
- "description": "Agent App not installed on the org",
7542
- "content": {
7543
- "application/json": {
7544
- "schema": {
7545
- "$ref": "#/components/schemas/Error"
7546
- }
7547
- }
7548
- }
7549
- },
7550
- "422": {
7551
- "description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
7552
- "content": {
7553
- "application/json": {
7554
- "schema": {
7555
- "$ref": "#/components/schemas/Error"
7556
- }
7557
- }
7558
- }
7559
- },
7560
- "502": {
7561
- "description": "GitHub unavailable or refused",
7562
- "content": {
7563
- "application/json": {
7564
- "schema": {
7565
- "$ref": "#/components/schemas/Error"
7566
- }
7567
- }
7568
- }
7569
- },
7570
- "503": {
7571
- "description": "GitHub Apps are not configured",
7572
- "content": {
7573
- "application/json": {
7574
- "schema": {
7575
- "$ref": "#/components/schemas/Error"
7576
- }
7577
- }
7578
- }
7579
- }
7580
- }
7581
7341
  }
7582
7342
  },
7583
- "/agents/{id}/github-lost-access/preview": {
7343
+ "/agents/{id}/github-sync/preview": {
7584
7344
  "get": {
7585
- "summary": "Preview removing the repos the bound user can no longer push to",
7586
- "description": "Platform-admin only (session members, ops keys and agent keys get 403). Read-only: nothing is changed or audited. Lists the repos on the agent App's installation or in the agent's repos that the bound githubUsername can no longer push to, and the agent's open tasks and PRs on them (via the optional open-work port; a port failure is a warning). Orgs whose access listing is missing, partial or failed, or whose lookup App is installed on selected repositories only, are skipped and reported. 200 with `status: skipped` when the user is unbound, not found or unverified, the agent has no GH_APP_ID, or the Apps are not configured.",
7345
+ "summary": "Preview syncing the agent's GitHub access with its bound user",
7346
+ "description": "Platform-admin only (session members, ops keys and agent keys get 403). Read-only: nothing is changed or audited. Lists (1) repos to add to the agent App's installation, (2) installation repos to remove and (3) agent repos to remove, based on what the bound githubUsername can push to, plus the agent's open tasks and PRs the removals would block (via the optional open-work port; a port failure is a warning). The agent's repos are never added to. Orgs whose access listing is missing, partial or failed, or whose lookup App is not installed or installed on selected repositories only, are skipped (adds included) and reported. 200 with `status: skipped` when the user is unbound, not found or unverified, the agent has no GH_APP_ID, or the Apps are not configured.",
7587
7347
  "parameters": [
7588
7348
  {
7589
7349
  "schema": {
@@ -7597,11 +7357,11 @@
7597
7357
  ],
7598
7358
  "responses": {
7599
7359
  "200": {
7600
- "description": "Lost-access removal preview",
7360
+ "description": "Sync preview",
7601
7361
  "content": {
7602
7362
  "application/json": {
7603
7363
  "schema": {
7604
- "$ref": "#/components/schemas/GithubLostAccessPreview"
7364
+ "$ref": "#/components/schemas/GithubSyncPreview"
7605
7365
  }
7606
7366
  }
7607
7367
  }
@@ -7659,10 +7419,10 @@
7659
7419
  }
7660
7420
  }
7661
7421
  },
7662
- "/agents/{id}/github-lost-access/remove": {
7422
+ "/agents/{id}/github-sync/apply": {
7663
7423
  "post": {
7664
- "summary": "Remove the confirmed repos the bound user can no longer push to",
7665
- "description": "Platform-admin only. Never adds repos. Takes the repos the admin confirmed from the preview, re-checks each against the bound user's current access, and removes only those still without push access: first from the agent App's installation, then from the agent's repos; then writes one audit entry (GitHubReconcileAudit, planHash `lost-access:remove`) and blocks the agent's open work on the removed repos through the optional open-work port (a failure there is a warning). Named repos left alone are reported in `notRemoved`. Same skip rules as the preview: a skipped call (200 `status: skipped`) changes and audits nothing; `noop` when nothing named still lacks access. 422 when more than 10 repos would be removed without `confirmRemovals: true`. 502 when GitHub refuses (a failed audit entry records only what landed).",
7424
+ "summary": "Apply the confirmed sync changes",
7425
+ "description": "Platform-admin only. Takes the exact lists the admin confirmed from the preview, re-checks each against the bound user's current access, and applies only what still qualifies: installation adds, installation removes, then agent-repo removes. Writes one audit entry (GitHubReconcileAudit, planHash `sync:apply`) and blocks the agent's open work on the removed repos through the optional open-work port (a failure there is a warning). Confirmed repos left alone are reported in `notApplied`. Same skip rules as the preview: a skipped call (200 `status: skipped`) changes and audits nothing; `noop` when nothing confirmed still applies. 422 when more than 10 repos would be removed without `confirmRemovals: true`. 502 when GitHub refuses (a failed audit entry records only what landed).",
7666
7426
  "parameters": [
7667
7427
  {
7668
7428
  "schema": {
@@ -7679,18 +7439,18 @@
7679
7439
  "content": {
7680
7440
  "application/json": {
7681
7441
  "schema": {
7682
- "$ref": "#/components/schemas/GithubLostAccessRemoveBody"
7442
+ "$ref": "#/components/schemas/GithubSyncApplyBody"
7683
7443
  }
7684
7444
  }
7685
7445
  }
7686
7446
  },
7687
7447
  "responses": {
7688
7448
  "200": {
7689
- "description": "Removal result",
7449
+ "description": "Sync result",
7690
7450
  "content": {
7691
7451
  "application/json": {
7692
7452
  "schema": {
7693
- "$ref": "#/components/schemas/GithubLostAccessRemoveResult"
7453
+ "$ref": "#/components/schemas/GithubSyncApplyResult"
7694
7454
  }
7695
7455
  }
7696
7456
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.35.1",
3
+ "version": "1.36.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@anthropic-ai/sdk": "0.135.0",
45
- "@app-vitals/agent-lib": "1.35.1",
45
+ "@app-vitals/agent-lib": "1.36.1",
46
46
  "@hono/zod-openapi": "^1.0.0",
47
47
  "@prisma/adapter-pg": "^7.10.0",
48
48
  "@prisma/client": "^7.10.0",
package/src/admin-boot.ts CHANGED
@@ -107,7 +107,7 @@ import {
107
107
  import { GitHubEnterpriseAppService } from "./github-enterprise-apps.ts";
108
108
  import {
109
109
  createGithubInstallationRepos,
110
- createGithubLostAccessRemoval,
110
+ createGithubSync,
111
111
  } from "./github-installation-wiring.ts";
112
112
  import { HttpGoogleAuthClient } from "./google-auth-client.ts";
113
113
  import { HttpChatClient } from "./http-chat-client.ts";
@@ -479,7 +479,7 @@ export async function startAdmin(
479
479
  access: githubAccessPreview,
480
480
  agentEnv: agentEnvService,
481
481
  });
482
- const githubLostAccessRemoval = createGithubLostAccessRemoval({
482
+ const githubSync = createGithubSync({
483
483
  prisma,
484
484
  appService: githubEnterpriseAppService,
485
485
  access: githubAccessPreview,
@@ -492,7 +492,7 @@ export async function startAdmin(
492
492
  ? { openWork: resolvedExtensions.openWork }
493
493
  : {}),
494
494
  githubInstallationRepos,
495
- githubLostAccessRemoval,
495
+ githubSync,
496
496
  agentService,
497
497
  agentEnvService,
498
498
  agentCronJobService,
@@ -131,7 +131,7 @@ export interface AdminExtensionServices {
131
131
  agentPhaseMethodologyService?: AgentPhaseMethodologyServiceLike;
132
132
  /**
133
133
  * Supplies the open-work port: removing a repo from an agent (or the
134
- * lost-access removal) previews and blocks the open work on it. Absent from
134
+ * GitHub Sync) previews and blocks the open work on it. Absent from
135
135
  * every extension → nothing is listed or blocked.
136
136
  */
137
137
  openWork?: OpenWorkPort;
@@ -21,7 +21,7 @@ const json = (b: unknown, status = 200) =>
21
21
  });
22
22
 
23
23
  function setup(opts: {
24
- configured?: boolean;
24
+ configured?: boolean | "installer-only";
25
25
  agentsApi?: (path: string, init?: RequestInit) => Response;
26
26
  }) {
27
27
  const calls: { path: string; init?: RequestInit }[] = [];
@@ -45,7 +45,22 @@ function setup(opts: {
45
45
  githubUsername: "octo",
46
46
  }),
47
47
  },
48
- githubEnterpriseApi: () => json({ configured: opts.configured ?? true }),
48
+ githubEnterpriseApi: () =>
49
+ json(
50
+ opts.configured === false
51
+ ? { configured: false, installer: null, lookup: null }
52
+ : opts.configured === "installer-only"
53
+ ? {
54
+ configured: true,
55
+ installer: { role: "installer" },
56
+ lookup: null,
57
+ }
58
+ : {
59
+ configured: true,
60
+ installer: { role: "installer" },
61
+ lookup: { role: "lookup" },
62
+ },
63
+ ),
49
64
  agentsApi: (path: string, init?: RequestInit) => {
50
65
  calls.push({ path, init });
51
66
  return opts.agentsApi ? opts.agentsApi(path, init) : json({});
@@ -99,6 +114,13 @@ describe("admin UI — GitHub identity (GHE-2.5)", () => {
99
114
  expect(html).not.toContain("github-access-btn");
100
115
  });
101
116
 
117
+ it("hides both when only one App role is configured", async () => {
118
+ const { app } = setup({ configured: "installer-only" });
119
+ const html = await (await get(app, admin)).text();
120
+ expect(html).not.toContain("GitHub username");
121
+ expect(html).not.toContain("github-access-btn");
122
+ });
123
+
102
124
  it("hides both from a non-admin", async () => {
103
125
  const { app } = setup({});
104
126
  const html = await (await get(app, member)).text();