@app-vitals/agent-admin 1.31.0 → 1.32.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.
@@ -3492,6 +3492,94 @@
3492
3492
  "planHash"
3493
3493
  ]
3494
3494
  },
3495
+ "GithubInstallationReposList": {
3496
+ "type": "object",
3497
+ "properties": {
3498
+ "appId": {
3499
+ "type": "integer"
3500
+ },
3501
+ "orgs": {
3502
+ "type": "array",
3503
+ "items": {
3504
+ "type": "object",
3505
+ "properties": {
3506
+ "org": {
3507
+ "type": "string"
3508
+ },
3509
+ "repos": {
3510
+ "type": "array",
3511
+ "items": {
3512
+ "type": "object",
3513
+ "properties": {
3514
+ "fullName": {
3515
+ "type": "string"
3516
+ },
3517
+ "userCanPush": {
3518
+ "type": "boolean",
3519
+ "description": "Whether the agent's bound GitHub user can push. Omitted when no username is bound or the org's access lookup is incomplete; never reported as false for unknown."
3520
+ }
3521
+ },
3522
+ "required": [
3523
+ "fullName"
3524
+ ]
3525
+ }
3526
+ }
3527
+ },
3528
+ "required": [
3529
+ "org",
3530
+ "repos"
3531
+ ]
3532
+ }
3533
+ }
3534
+ },
3535
+ "required": [
3536
+ "appId",
3537
+ "orgs"
3538
+ ]
3539
+ },
3540
+ "GithubInstallationReposChange": {
3541
+ "type": "object",
3542
+ "properties": {
3543
+ "status": {
3544
+ "type": "string",
3545
+ "enum": [
3546
+ "applied"
3547
+ ]
3548
+ },
3549
+ "auditId": {
3550
+ "type": "string"
3551
+ },
3552
+ "repos": {
3553
+ "type": "array",
3554
+ "items": {
3555
+ "type": "string"
3556
+ }
3557
+ }
3558
+ },
3559
+ "required": [
3560
+ "status",
3561
+ "auditId",
3562
+ "repos"
3563
+ ]
3564
+ },
3565
+ "GithubInstallationReposBody": {
3566
+ "type": "object",
3567
+ "properties": {
3568
+ "repos": {
3569
+ "type": "array",
3570
+ "items": {
3571
+ "type": "string",
3572
+ "pattern": "^[^/\\s]+\\/[^/\\s]+$"
3573
+ },
3574
+ "minItems": 1,
3575
+ "maxItems": 100,
3576
+ "description": "Repos (owner/repo) to change on the agent App's installation."
3577
+ }
3578
+ },
3579
+ "required": [
3580
+ "repos"
3581
+ ]
3582
+ },
3495
3583
  "AgentConfigResponse": {
3496
3584
  "type": "object",
3497
3585
  "properties": {
@@ -7283,6 +7371,311 @@
7283
7371
  }
7284
7372
  }
7285
7373
  },
7374
+ "/agents/{id}/github-installation/repos": {
7375
+ "get": {
7376
+ "summary": "List the repos on the agent App's installation",
7377
+ "description": "Platform-admin only (session members, ops keys and agent keys get 403). Per org the agent's own GitHub App (its GH_APP_ID) is installed on, lists the installation's repos. When the agent has a bound githubUsername, each repo carries `userCanPush` from the access lookup only when that org's lookup result is complete; otherwise the field is omitted (never false). 404 for an unknown agent; 422 when the agent has no GH_APP_ID.",
7378
+ "parameters": [
7379
+ {
7380
+ "schema": {
7381
+ "type": "string",
7382
+ "example": "clx1234567890"
7383
+ },
7384
+ "required": true,
7385
+ "name": "id",
7386
+ "in": "path"
7387
+ }
7388
+ ],
7389
+ "responses": {
7390
+ "200": {
7391
+ "description": "Installation repos",
7392
+ "content": {
7393
+ "application/json": {
7394
+ "schema": {
7395
+ "$ref": "#/components/schemas/GithubInstallationReposList"
7396
+ }
7397
+ }
7398
+ }
7399
+ },
7400
+ "401": {
7401
+ "description": "Unauthorized",
7402
+ "content": {
7403
+ "application/json": {
7404
+ "schema": {
7405
+ "$ref": "#/components/schemas/Error"
7406
+ }
7407
+ }
7408
+ }
7409
+ },
7410
+ "403": {
7411
+ "description": "Platform admin required",
7412
+ "content": {
7413
+ "application/json": {
7414
+ "schema": {
7415
+ "$ref": "#/components/schemas/Error"
7416
+ }
7417
+ }
7418
+ }
7419
+ },
7420
+ "404": {
7421
+ "description": "Agent not found",
7422
+ "content": {
7423
+ "application/json": {
7424
+ "schema": {
7425
+ "$ref": "#/components/schemas/Error"
7426
+ }
7427
+ }
7428
+ }
7429
+ },
7430
+ "422": {
7431
+ "description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
7432
+ "content": {
7433
+ "application/json": {
7434
+ "schema": {
7435
+ "$ref": "#/components/schemas/Error"
7436
+ }
7437
+ }
7438
+ }
7439
+ },
7440
+ "502": {
7441
+ "description": "GitHub unavailable or refused",
7442
+ "content": {
7443
+ "application/json": {
7444
+ "schema": {
7445
+ "$ref": "#/components/schemas/Error"
7446
+ }
7447
+ }
7448
+ }
7449
+ },
7450
+ "503": {
7451
+ "description": "GitHub Apps are not configured",
7452
+ "content": {
7453
+ "application/json": {
7454
+ "schema": {
7455
+ "$ref": "#/components/schemas/Error"
7456
+ }
7457
+ }
7458
+ }
7459
+ }
7460
+ }
7461
+ },
7462
+ "post": {
7463
+ "summary": "Add repos to the agent App's installation",
7464
+ "description": "Platform-admin only. Grants the agent's own GitHub App installation access to the named repos, with no plan step; 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).",
7465
+ "parameters": [
7466
+ {
7467
+ "schema": {
7468
+ "type": "string",
7469
+ "example": "clx1234567890"
7470
+ },
7471
+ "required": true,
7472
+ "name": "id",
7473
+ "in": "path"
7474
+ }
7475
+ ],
7476
+ "requestBody": {
7477
+ "required": true,
7478
+ "content": {
7479
+ "application/json": {
7480
+ "schema": {
7481
+ "$ref": "#/components/schemas/GithubInstallationReposBody"
7482
+ }
7483
+ }
7484
+ }
7485
+ },
7486
+ "responses": {
7487
+ "200": {
7488
+ "description": "Repos added",
7489
+ "content": {
7490
+ "application/json": {
7491
+ "schema": {
7492
+ "$ref": "#/components/schemas/GithubInstallationReposChange"
7493
+ }
7494
+ }
7495
+ }
7496
+ },
7497
+ "401": {
7498
+ "description": "Unauthorized",
7499
+ "content": {
7500
+ "application/json": {
7501
+ "schema": {
7502
+ "$ref": "#/components/schemas/Error"
7503
+ }
7504
+ }
7505
+ }
7506
+ },
7507
+ "403": {
7508
+ "description": "Platform admin required",
7509
+ "content": {
7510
+ "application/json": {
7511
+ "schema": {
7512
+ "$ref": "#/components/schemas/Error"
7513
+ }
7514
+ }
7515
+ }
7516
+ },
7517
+ "404": {
7518
+ "description": "Agent not found",
7519
+ "content": {
7520
+ "application/json": {
7521
+ "schema": {
7522
+ "$ref": "#/components/schemas/Error"
7523
+ }
7524
+ }
7525
+ }
7526
+ },
7527
+ "409": {
7528
+ "description": "Agent App not installed on the org",
7529
+ "content": {
7530
+ "application/json": {
7531
+ "schema": {
7532
+ "$ref": "#/components/schemas/Error"
7533
+ }
7534
+ }
7535
+ }
7536
+ },
7537
+ "422": {
7538
+ "description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
7539
+ "content": {
7540
+ "application/json": {
7541
+ "schema": {
7542
+ "$ref": "#/components/schemas/Error"
7543
+ }
7544
+ }
7545
+ }
7546
+ },
7547
+ "502": {
7548
+ "description": "GitHub unavailable or refused",
7549
+ "content": {
7550
+ "application/json": {
7551
+ "schema": {
7552
+ "$ref": "#/components/schemas/Error"
7553
+ }
7554
+ }
7555
+ }
7556
+ },
7557
+ "503": {
7558
+ "description": "GitHub Apps are not configured",
7559
+ "content": {
7560
+ "application/json": {
7561
+ "schema": {
7562
+ "$ref": "#/components/schemas/Error"
7563
+ }
7564
+ }
7565
+ }
7566
+ }
7567
+ }
7568
+ }
7569
+ },
7570
+ "/agents/{id}/github-installation/repos/remove": {
7571
+ "post": {
7572
+ "summary": "Remove repos from the agent App's installation",
7573
+ "description": "Platform-admin only. Revokes the agent's own GitHub App installation access to the named repos, with no plan step; 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.",
7574
+ "parameters": [
7575
+ {
7576
+ "schema": {
7577
+ "type": "string",
7578
+ "example": "clx1234567890"
7579
+ },
7580
+ "required": true,
7581
+ "name": "id",
7582
+ "in": "path"
7583
+ }
7584
+ ],
7585
+ "requestBody": {
7586
+ "required": true,
7587
+ "content": {
7588
+ "application/json": {
7589
+ "schema": {
7590
+ "$ref": "#/components/schemas/GithubInstallationReposBody"
7591
+ }
7592
+ }
7593
+ }
7594
+ },
7595
+ "responses": {
7596
+ "200": {
7597
+ "description": "Repos removed",
7598
+ "content": {
7599
+ "application/json": {
7600
+ "schema": {
7601
+ "$ref": "#/components/schemas/GithubInstallationReposChange"
7602
+ }
7603
+ }
7604
+ }
7605
+ },
7606
+ "401": {
7607
+ "description": "Unauthorized",
7608
+ "content": {
7609
+ "application/json": {
7610
+ "schema": {
7611
+ "$ref": "#/components/schemas/Error"
7612
+ }
7613
+ }
7614
+ }
7615
+ },
7616
+ "403": {
7617
+ "description": "Platform admin required",
7618
+ "content": {
7619
+ "application/json": {
7620
+ "schema": {
7621
+ "$ref": "#/components/schemas/Error"
7622
+ }
7623
+ }
7624
+ }
7625
+ },
7626
+ "404": {
7627
+ "description": "Agent not found",
7628
+ "content": {
7629
+ "application/json": {
7630
+ "schema": {
7631
+ "$ref": "#/components/schemas/Error"
7632
+ }
7633
+ }
7634
+ }
7635
+ },
7636
+ "409": {
7637
+ "description": "Agent App not installed on the org",
7638
+ "content": {
7639
+ "application/json": {
7640
+ "schema": {
7641
+ "$ref": "#/components/schemas/Error"
7642
+ }
7643
+ }
7644
+ }
7645
+ },
7646
+ "422": {
7647
+ "description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
7648
+ "content": {
7649
+ "application/json": {
7650
+ "schema": {
7651
+ "$ref": "#/components/schemas/Error"
7652
+ }
7653
+ }
7654
+ }
7655
+ },
7656
+ "502": {
7657
+ "description": "GitHub unavailable or refused",
7658
+ "content": {
7659
+ "application/json": {
7660
+ "schema": {
7661
+ "$ref": "#/components/schemas/Error"
7662
+ }
7663
+ }
7664
+ }
7665
+ },
7666
+ "503": {
7667
+ "description": "GitHub Apps are not configured",
7668
+ "content": {
7669
+ "application/json": {
7670
+ "schema": {
7671
+ "$ref": "#/components/schemas/Error"
7672
+ }
7673
+ }
7674
+ }
7675
+ }
7676
+ }
7677
+ }
7678
+ },
7286
7679
  "/agents/{id}/config": {
7287
7680
  "get": {
7288
7681
  "tags": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
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.31.0",
45
+ "@app-vitals/agent-lib": "1.32.0",
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
@@ -106,8 +106,8 @@ import {
106
106
  } from "./github-enterprise-api.ts";
107
107
  import { GitHubEnterpriseAppService } from "./github-enterprise-apps.ts";
108
108
  import {
109
+ createGithubInstallationRepos,
109
110
  createGithubReconcile,
110
- parseAgentAppId,
111
111
  } from "./github-reconcile-wiring.ts";
112
112
  import { HttpGoogleAuthClient } from "./google-auth-client.ts";
113
113
  import { HttpChatClient } from "./http-chat-client.ts";
@@ -474,17 +474,24 @@ export async function startAdmin(
474
474
  appService: githubEnterpriseAppService,
475
475
  });
476
476
  // GHE-3.9: the reconcile routes' service, with the extension's optional
477
- // open-work port. Unwired (routes report `skipped`) without an agent App id.
477
+ // open-work port. Each agent's App id is read from its own stored GH_APP_ID.
478
478
  const githubReconcile = createGithubReconcile({
479
479
  prisma,
480
480
  appService: githubEnterpriseAppService,
481
481
  access: githubAccessPreview,
482
- agentAppId: parseAgentAppId(process.env.SHIPWRIGHT_GITHUB_AGENT_APP_ID),
482
+ agentEnv: agentEnvService,
483
483
  openWork: resolvedExtensions.openWork,
484
484
  });
485
+ const githubInstallationRepos = createGithubInstallationRepos({
486
+ prisma,
487
+ appService: githubEnterpriseAppService,
488
+ access: githubAccessPreview,
489
+ agentEnv: agentEnvService,
490
+ });
485
491
  const adminApiApp = createAdminApp({
486
492
  githubAccessPreview,
487
- ...(githubReconcile ? { githubReconcile } : {}),
493
+ githubReconcile,
494
+ githubInstallationRepos,
488
495
  agentService,
489
496
  agentEnvService,
490
497
  agentCronJobService,