@app-vitals/agent-admin 1.33.0 → 1.34.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.
@@ -3580,6 +3580,196 @@
3580
3580
  "repos"
3581
3581
  ]
3582
3582
  },
3583
+ "GithubLostAccessPreview": {
3584
+ "type": "object",
3585
+ "properties": {
3586
+ "status": {
3587
+ "type": "string",
3588
+ "enum": [
3589
+ "previewed",
3590
+ "skipped"
3591
+ ],
3592
+ "description": "`skipped` (not an error) when no GitHub username is bound, the user is not found or unverified, the agent has no GH_APP_ID, or the Apps are not configured; `reason` says why."
3593
+ },
3594
+ "reason": {
3595
+ "type": "string"
3596
+ },
3597
+ "repos": {
3598
+ "type": "array",
3599
+ "items": {
3600
+ "type": "string"
3601
+ },
3602
+ "description": "Every repo the bound user can no longer push to that would be removed from the installation or the agent's repos."
3603
+ },
3604
+ "installationRemoves": {
3605
+ "type": "array",
3606
+ "items": {
3607
+ "type": "string"
3608
+ }
3609
+ },
3610
+ "configRemoves": {
3611
+ "type": "array",
3612
+ "items": {
3613
+ "type": "string"
3614
+ }
3615
+ },
3616
+ "skippedOrgs": {
3617
+ "type": "array",
3618
+ "items": {
3619
+ "type": "object",
3620
+ "properties": {
3621
+ "org": {
3622
+ "type": "string"
3623
+ },
3624
+ "reason": {
3625
+ "type": "string"
3626
+ }
3627
+ },
3628
+ "required": [
3629
+ "org",
3630
+ "reason"
3631
+ ]
3632
+ },
3633
+ "description": "Orgs whose access listing is missing, partial or failed, or whose lookup App is installed on selected repositories only; nothing there is removed."
3634
+ },
3635
+ "openWork": {
3636
+ "type": "array",
3637
+ "items": {
3638
+ "type": "object",
3639
+ "properties": {
3640
+ "id": {
3641
+ "type": "string"
3642
+ },
3643
+ "repo": {
3644
+ "type": "string"
3645
+ },
3646
+ "title": {
3647
+ "type": "string"
3648
+ }
3649
+ },
3650
+ "required": [
3651
+ "id",
3652
+ "repo"
3653
+ ]
3654
+ },
3655
+ "description": "The agent's open tasks and PRs on those repos that removing them would block; empty when no open-work port is wired."
3656
+ },
3657
+ "warnings": {
3658
+ "type": "array",
3659
+ "items": {
3660
+ "type": "string"
3661
+ }
3662
+ }
3663
+ },
3664
+ "required": [
3665
+ "status"
3666
+ ]
3667
+ },
3668
+ "GithubLostAccessRemoveResult": {
3669
+ "type": "object",
3670
+ "properties": {
3671
+ "status": {
3672
+ "type": "string",
3673
+ "enum": [
3674
+ "applied",
3675
+ "noop",
3676
+ "skipped"
3677
+ ]
3678
+ },
3679
+ "reason": {
3680
+ "type": "string"
3681
+ },
3682
+ "auditId": {
3683
+ "type": "string"
3684
+ },
3685
+ "repos": {
3686
+ "type": "array",
3687
+ "items": {
3688
+ "type": "string"
3689
+ }
3690
+ },
3691
+ "installationRemoves": {
3692
+ "type": "array",
3693
+ "items": {
3694
+ "type": "string"
3695
+ }
3696
+ },
3697
+ "configRemoves": {
3698
+ "type": "array",
3699
+ "items": {
3700
+ "type": "string"
3701
+ }
3702
+ },
3703
+ "notRemoved": {
3704
+ "type": "array",
3705
+ "items": {
3706
+ "type": "object",
3707
+ "properties": {
3708
+ "repo": {
3709
+ "type": "string"
3710
+ },
3711
+ "reason": {
3712
+ "type": "string"
3713
+ }
3714
+ },
3715
+ "required": [
3716
+ "repo",
3717
+ "reason"
3718
+ ]
3719
+ },
3720
+ "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."
3721
+ },
3722
+ "skippedOrgs": {
3723
+ "type": "array",
3724
+ "items": {
3725
+ "type": "object",
3726
+ "properties": {
3727
+ "org": {
3728
+ "type": "string"
3729
+ },
3730
+ "reason": {
3731
+ "type": "string"
3732
+ }
3733
+ },
3734
+ "required": [
3735
+ "org",
3736
+ "reason"
3737
+ ]
3738
+ }
3739
+ },
3740
+ "warnings": {
3741
+ "type": "array",
3742
+ "items": {
3743
+ "type": "string"
3744
+ }
3745
+ }
3746
+ },
3747
+ "required": [
3748
+ "status"
3749
+ ]
3750
+ },
3751
+ "GithubLostAccessRemoveBody": {
3752
+ "type": "object",
3753
+ "properties": {
3754
+ "repos": {
3755
+ "type": "array",
3756
+ "items": {
3757
+ "type": "string",
3758
+ "pattern": "^[^/\\s]+\\/[^/\\s]+$"
3759
+ },
3760
+ "minItems": 1,
3761
+ "maxItems": 100,
3762
+ "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."
3763
+ },
3764
+ "confirmRemovals": {
3765
+ "type": "boolean",
3766
+ "description": "Required when more than 10 repos would be removed."
3767
+ }
3768
+ },
3769
+ "required": [
3770
+ "repos"
3771
+ ]
3772
+ },
3583
3773
  "AgentConfigResponse": {
3584
3774
  "type": "object",
3585
3775
  "properties": {
@@ -7780,6 +7970,184 @@
7780
7970
  }
7781
7971
  }
7782
7972
  },
7973
+ "/agents/{id}/github-lost-access/preview": {
7974
+ "get": {
7975
+ "summary": "Preview removing the repos the bound user can no longer push to",
7976
+ "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.",
7977
+ "parameters": [
7978
+ {
7979
+ "schema": {
7980
+ "type": "string",
7981
+ "example": "clx1234567890"
7982
+ },
7983
+ "required": true,
7984
+ "name": "id",
7985
+ "in": "path"
7986
+ }
7987
+ ],
7988
+ "responses": {
7989
+ "200": {
7990
+ "description": "Lost-access removal preview",
7991
+ "content": {
7992
+ "application/json": {
7993
+ "schema": {
7994
+ "$ref": "#/components/schemas/GithubLostAccessPreview"
7995
+ }
7996
+ }
7997
+ }
7998
+ },
7999
+ "401": {
8000
+ "description": "Unauthorized",
8001
+ "content": {
8002
+ "application/json": {
8003
+ "schema": {
8004
+ "$ref": "#/components/schemas/Error"
8005
+ }
8006
+ }
8007
+ }
8008
+ },
8009
+ "403": {
8010
+ "description": "Platform admin required",
8011
+ "content": {
8012
+ "application/json": {
8013
+ "schema": {
8014
+ "$ref": "#/components/schemas/Error"
8015
+ }
8016
+ }
8017
+ }
8018
+ },
8019
+ "404": {
8020
+ "description": "Agent not found",
8021
+ "content": {
8022
+ "application/json": {
8023
+ "schema": {
8024
+ "$ref": "#/components/schemas/Error"
8025
+ }
8026
+ }
8027
+ }
8028
+ },
8029
+ "502": {
8030
+ "description": "GitHub unavailable or refused",
8031
+ "content": {
8032
+ "application/json": {
8033
+ "schema": {
8034
+ "$ref": "#/components/schemas/Error"
8035
+ }
8036
+ }
8037
+ }
8038
+ },
8039
+ "503": {
8040
+ "description": "GitHub Apps are not configured",
8041
+ "content": {
8042
+ "application/json": {
8043
+ "schema": {
8044
+ "$ref": "#/components/schemas/Error"
8045
+ }
8046
+ }
8047
+ }
8048
+ }
8049
+ }
8050
+ }
8051
+ },
8052
+ "/agents/{id}/github-lost-access/remove": {
8053
+ "post": {
8054
+ "summary": "Remove the confirmed repos the bound user can no longer push to",
8055
+ "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).",
8056
+ "parameters": [
8057
+ {
8058
+ "schema": {
8059
+ "type": "string",
8060
+ "example": "clx1234567890"
8061
+ },
8062
+ "required": true,
8063
+ "name": "id",
8064
+ "in": "path"
8065
+ }
8066
+ ],
8067
+ "requestBody": {
8068
+ "required": true,
8069
+ "content": {
8070
+ "application/json": {
8071
+ "schema": {
8072
+ "$ref": "#/components/schemas/GithubLostAccessRemoveBody"
8073
+ }
8074
+ }
8075
+ }
8076
+ },
8077
+ "responses": {
8078
+ "200": {
8079
+ "description": "Removal result",
8080
+ "content": {
8081
+ "application/json": {
8082
+ "schema": {
8083
+ "$ref": "#/components/schemas/GithubLostAccessRemoveResult"
8084
+ }
8085
+ }
8086
+ }
8087
+ },
8088
+ "401": {
8089
+ "description": "Unauthorized",
8090
+ "content": {
8091
+ "application/json": {
8092
+ "schema": {
8093
+ "$ref": "#/components/schemas/Error"
8094
+ }
8095
+ }
8096
+ }
8097
+ },
8098
+ "403": {
8099
+ "description": "Platform admin required",
8100
+ "content": {
8101
+ "application/json": {
8102
+ "schema": {
8103
+ "$ref": "#/components/schemas/Error"
8104
+ }
8105
+ }
8106
+ }
8107
+ },
8108
+ "404": {
8109
+ "description": "Agent not found",
8110
+ "content": {
8111
+ "application/json": {
8112
+ "schema": {
8113
+ "$ref": "#/components/schemas/Error"
8114
+ }
8115
+ }
8116
+ }
8117
+ },
8118
+ "422": {
8119
+ "description": "Removal cap needs confirmRemovals",
8120
+ "content": {
8121
+ "application/json": {
8122
+ "schema": {
8123
+ "$ref": "#/components/schemas/Error"
8124
+ }
8125
+ }
8126
+ }
8127
+ },
8128
+ "502": {
8129
+ "description": "GitHub unavailable or refused",
8130
+ "content": {
8131
+ "application/json": {
8132
+ "schema": {
8133
+ "$ref": "#/components/schemas/Error"
8134
+ }
8135
+ }
8136
+ }
8137
+ },
8138
+ "503": {
8139
+ "description": "GitHub Apps are not configured",
8140
+ "content": {
8141
+ "application/json": {
8142
+ "schema": {
8143
+ "$ref": "#/components/schemas/Error"
8144
+ }
8145
+ }
8146
+ }
8147
+ }
8148
+ }
8149
+ }
8150
+ },
7783
8151
  "/agents/{id}/config": {
7784
8152
  "get": {
7785
8153
  "tags": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.33.0",
3
+ "version": "1.34.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.33.0",
45
+ "@app-vitals/agent-lib": "1.34.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
@@ -107,6 +107,7 @@ import {
107
107
  import { GitHubEnterpriseAppService } from "./github-enterprise-apps.ts";
108
108
  import {
109
109
  createGithubInstallationRepos,
110
+ createGithubLostAccessRemoval,
110
111
  createGithubReconcile,
111
112
  } from "./github-reconcile-wiring.ts";
112
113
  import { HttpGoogleAuthClient } from "./google-auth-client.ts";
@@ -488,6 +489,13 @@ export async function startAdmin(
488
489
  access: githubAccessPreview,
489
490
  agentEnv: agentEnvService,
490
491
  });
492
+ const githubLostAccessRemoval = createGithubLostAccessRemoval({
493
+ prisma,
494
+ appService: githubEnterpriseAppService,
495
+ access: githubAccessPreview,
496
+ agentEnv: agentEnvService,
497
+ openWork: resolvedExtensions.openWork,
498
+ });
491
499
  const adminApiApp = createAdminApp({
492
500
  githubAccessPreview,
493
501
  githubReconcile,
@@ -495,6 +503,7 @@ export async function startAdmin(
495
503
  ? { openWork: resolvedExtensions.openWork }
496
504
  : {}),
497
505
  githubInstallationRepos,
506
+ githubLostAccessRemoval,
498
507
  agentService,
499
508
  agentEnvService,
500
509
  agentCronJobService,