@app-vitals/agent-admin 1.87.0 → 1.89.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 (30) hide show
  1. package/openapi.json +253 -0
  2. package/openapi.platform.json +297 -0
  3. package/package.json +2 -2
  4. package/prisma/client/internal/class.ts +4 -4
  5. package/prisma/client/internal/prismaNamespace.ts +1 -0
  6. package/prisma/client/internal/prismaNamespaceBrowser.ts +1 -0
  7. package/prisma/client/models/GitHubRepoSnapshot.ts +33 -1
  8. package/prisma/migrations/20261125000000_add_github_snapshot_repository_selection/migration.sql +2 -0
  9. package/prisma/schema/schema.prisma +2 -0
  10. package/src/admin-boot.ts +11 -0
  11. package/src/agents-api.smoke.test.ts +88 -0
  12. package/src/agents-api.ts +15 -0
  13. package/src/fixtures/github-enterprise-cassette.json +16 -0
  14. package/src/github-agent-installation-crawler.ts +27 -8
  15. package/src/github-agent-installation-crawler.unit.test.ts +76 -1
  16. package/src/github-enterprise-api.integration.test.ts +127 -0
  17. package/src/github-enterprise-api.smoke.test.ts +188 -5
  18. package/src/github-enterprise-api.ts +212 -4
  19. package/src/github-enterprise-client.ts +23 -1
  20. package/src/github-enterprise-client.unit.test.ts +65 -0
  21. package/src/github-installation-selection.integration.test.ts +91 -0
  22. package/src/github-installation-wiring.ts +5 -0
  23. package/src/github-repo-cache.ts +8 -0
  24. package/src/github-sync-switch.integration.test.ts +297 -0
  25. package/src/github-sync-switch.unit.test.ts +467 -0
  26. package/src/github-sync.ts +205 -24
  27. package/src/github-uninstall.ts +70 -0
  28. package/src/github-uninstall.unit.test.ts +78 -0
  29. package/src/installation-ports.ts +43 -0
  30. package/src/installation-repos-service.ts +2 -0
package/openapi.json CHANGED
@@ -3929,6 +3929,69 @@
3929
3929
  "required": [
3930
3930
  "agentId"
3931
3931
  ]
3932
+ },
3933
+ "GithubEnterpriseUninstallResult": {
3934
+ "type": "object",
3935
+ "properties": {
3936
+ "status": {
3937
+ "type": "string",
3938
+ "enum": [
3939
+ "preview",
3940
+ "uninstalled"
3941
+ ]
3942
+ },
3943
+ "org": {
3944
+ "type": "string"
3945
+ },
3946
+ "installationId": {
3947
+ "type": "number"
3948
+ },
3949
+ "repos": {
3950
+ "type": "array",
3951
+ "items": {
3952
+ "type": "string"
3953
+ },
3954
+ "description": "The agent's repos in the org, removed from the agent."
3955
+ },
3956
+ "openWork": {
3957
+ "type": "array",
3958
+ "items": {
3959
+ "type": "object",
3960
+ "properties": {
3961
+ "id": {
3962
+ "type": "string"
3963
+ },
3964
+ "repo": {
3965
+ "type": "string"
3966
+ },
3967
+ "title": {
3968
+ "type": "string"
3969
+ }
3970
+ },
3971
+ "required": [
3972
+ "id",
3973
+ "repo"
3974
+ ]
3975
+ }
3976
+ },
3977
+ "warnings": {
3978
+ "type": "array",
3979
+ "items": {
3980
+ "type": "string"
3981
+ }
3982
+ },
3983
+ "auditId": {
3984
+ "type": "string"
3985
+ }
3986
+ },
3987
+ "required": [
3988
+ "status",
3989
+ "org",
3990
+ "installationId",
3991
+ "repos",
3992
+ "openWork",
3993
+ "warnings"
3994
+ ]
3932
3995
  }
3933
3996
  },
3934
3997
  "parameters": {}
@@ -7761,6 +7824,196 @@
7761
7824
  }
7762
7825
  }
7763
7826
  }
7827
+ },
7828
+ "delete": {
7829
+ "tags": [
7830
+ "github-enterprise"
7831
+ ],
7832
+ "summary": "Uninstall an agent's App from an organization",
7833
+ "description": "Admin-only. Finds the agent App's installation on the org (client id, slug or app id) and deletes it with the installer App, removes that org's repos from the agent's repos, blocks the agent's open tasks and PRs on them through the open-work port (a port failure is a warning) and writes one audit row (uninstall:org). `preview=true` lists the repos and open work that would be affected and changes nothing. 404 when the App is not installed on the org; 422 when more than 10 repos would be removed without `confirmRemovals=true`; 502 (with a failed audit row) when GitHub refuses.",
7834
+ "parameters": [
7835
+ {
7836
+ "schema": {
7837
+ "type": "string",
7838
+ "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$",
7839
+ "example": "example-org"
7840
+ },
7841
+ "required": true,
7842
+ "name": "org",
7843
+ "in": "path"
7844
+ },
7845
+ {
7846
+ "schema": {
7847
+ "type": "string",
7848
+ "minLength": 1,
7849
+ "description": "Account whose App pair to read/write. Omit for the deployment-wide pair."
7850
+ },
7851
+ "required": false,
7852
+ "description": "Account whose App pair to read/write. Omit for the deployment-wide pair.",
7853
+ "name": "accountId",
7854
+ "in": "query"
7855
+ },
7856
+ {
7857
+ "schema": {
7858
+ "type": "string",
7859
+ "minLength": 1,
7860
+ "example": "agent-id"
7861
+ },
7862
+ "required": true,
7863
+ "name": "agentId",
7864
+ "in": "query"
7865
+ },
7866
+ {
7867
+ "schema": {
7868
+ "type": "string",
7869
+ "enum": [
7870
+ "true",
7871
+ "false"
7872
+ ],
7873
+ "description": "true: list the repos and open work an uninstall would affect and change nothing."
7874
+ },
7875
+ "required": false,
7876
+ "description": "true: list the repos and open work an uninstall would affect and change nothing.",
7877
+ "name": "preview",
7878
+ "in": "query"
7879
+ },
7880
+ {
7881
+ "schema": {
7882
+ "type": "string",
7883
+ "enum": [
7884
+ "true",
7885
+ "false"
7886
+ ],
7887
+ "description": "Required when more than 10 agent repos would be removed."
7888
+ },
7889
+ "required": false,
7890
+ "description": "Required when more than 10 agent repos would be removed.",
7891
+ "name": "confirmRemovals",
7892
+ "in": "query"
7893
+ }
7894
+ ],
7895
+ "responses": {
7896
+ "200": {
7897
+ "description": "Uninstalled, or the preview",
7898
+ "content": {
7899
+ "application/json": {
7900
+ "schema": {
7901
+ "$ref": "#/components/schemas/GithubEnterpriseUninstallResult"
7902
+ }
7903
+ }
7904
+ }
7905
+ },
7906
+ "400": {
7907
+ "description": "Bad request",
7908
+ "content": {
7909
+ "application/json": {
7910
+ "schema": {
7911
+ "$ref": "#/components/schemas/Error"
7912
+ }
7913
+ }
7914
+ }
7915
+ },
7916
+ "401": {
7917
+ "description": "Unauthorized",
7918
+ "content": {
7919
+ "application/json": {
7920
+ "schema": {
7921
+ "$ref": "#/components/schemas/Error"
7922
+ }
7923
+ }
7924
+ }
7925
+ },
7926
+ "403": {
7927
+ "description": "Forbidden (non-admin caller)",
7928
+ "content": {
7929
+ "application/json": {
7930
+ "schema": {
7931
+ "$ref": "#/components/schemas/Error"
7932
+ }
7933
+ }
7934
+ }
7935
+ },
7936
+ "404": {
7937
+ "description": "Not found (or not found at GitHub)",
7938
+ "content": {
7939
+ "application/json": {
7940
+ "schema": {
7941
+ "$ref": "#/components/schemas/Error"
7942
+ }
7943
+ }
7944
+ }
7945
+ },
7946
+ "409": {
7947
+ "description": "Installer App not configured",
7948
+ "content": {
7949
+ "application/json": {
7950
+ "schema": {
7951
+ "$ref": "#/components/schemas/Error"
7952
+ }
7953
+ }
7954
+ }
7955
+ },
7956
+ "422": {
7957
+ "description": "Refused or rejected by GitHub",
7958
+ "content": {
7959
+ "application/json": {
7960
+ "schema": {
7961
+ "$ref": "#/components/schemas/Error"
7962
+ }
7963
+ }
7964
+ }
7965
+ },
7966
+ "424": {
7967
+ "description": "GitHub refused the configured App credentials or permission",
7968
+ "content": {
7969
+ "application/json": {
7970
+ "schema": {
7971
+ "$ref": "#/components/schemas/Error"
7972
+ }
7973
+ }
7974
+ }
7975
+ },
7976
+ "429": {
7977
+ "description": "GitHub rate limit",
7978
+ "content": {
7979
+ "application/json": {
7980
+ "schema": {
7981
+ "$ref": "#/components/schemas/Error"
7982
+ }
7983
+ }
7984
+ }
7985
+ },
7986
+ "502": {
7987
+ "description": "GitHub unavailable or returned an unexpected response",
7988
+ "content": {
7989
+ "application/json": {
7990
+ "schema": {
7991
+ "$ref": "#/components/schemas/Error"
7992
+ }
7993
+ }
7994
+ }
7995
+ },
7996
+ "503": {
7997
+ "description": "Uninstall is not available",
7998
+ "content": {
7999
+ "application/json": {
8000
+ "schema": {
8001
+ "$ref": "#/components/schemas/Error"
8002
+ }
8003
+ }
8004
+ }
8005
+ },
8006
+ "504": {
8007
+ "description": "GitHub unreachable",
8008
+ "content": {
8009
+ "application/json": {
8010
+ "schema": {
8011
+ "$ref": "#/components/schemas/Error"
8012
+ }
8013
+ }
8014
+ }
8015
+ }
8016
+ }
7764
8017
  }
7765
8018
  }
7766
8019
  },
@@ -3712,6 +3712,28 @@
3712
3712
  },
3713
3713
  "description": "Configured agent repos the bound user can no longer push to. The agent's repos are never added to."
3714
3714
  },
3715
+ "selectionSwitches": {
3716
+ "type": "array",
3717
+ "items": {
3718
+ "type": "object",
3719
+ "properties": {
3720
+ "org": {
3721
+ "type": "string"
3722
+ },
3723
+ "repos": {
3724
+ "type": "array",
3725
+ "items": {
3726
+ "type": "string"
3727
+ }
3728
+ }
3729
+ },
3730
+ "required": [
3731
+ "org",
3732
+ "repos"
3733
+ ]
3734
+ },
3735
+ "description": "Orgs whose agent App installation is on All repositories. Sync switches each to Selected repositories (first 50 repos in the switch, the rest added in batches) before any add or remove; `repos` is the resulting list: the installed repos minus the org's confirmed removals. An org the bound user can push to nothing in is skipped (see `skippedOrgs`) and stays on All repositories."
3736
+ },
3715
3737
  "skippedOrgs": {
3716
3738
  "type": "array",
3717
3739
  "items": {
@@ -3875,6 +3897,28 @@
3875
3897
  "type": "string"
3876
3898
  }
3877
3899
  },
3900
+ "selectionSwitches": {
3901
+ "type": "array",
3902
+ "items": {
3903
+ "type": "object",
3904
+ "properties": {
3905
+ "org": {
3906
+ "type": "string"
3907
+ },
3908
+ "repos": {
3909
+ "type": "array",
3910
+ "items": {
3911
+ "type": "string"
3912
+ }
3913
+ }
3914
+ },
3915
+ "required": [
3916
+ "org",
3917
+ "repos"
3918
+ ]
3919
+ },
3920
+ "description": "Orgs whose agent App installation is on All repositories. Sync switches each to Selected repositories (first 50 repos in the switch, the rest added in batches) before any add or remove; `repos` is the resulting list: the installed repos minus the org's confirmed removals. An org the bound user can push to nothing in is skipped (see `skippedOrgs`) and stays on All repositories."
3921
+ },
3878
3922
  "notApplied": {
3879
3923
  "type": "array",
3880
3924
  "items": {
@@ -4521,6 +4565,69 @@
4521
4565
  "agentId"
4522
4566
  ]
4523
4567
  },
4568
+ "GithubEnterpriseUninstallResult": {
4569
+ "type": "object",
4570
+ "properties": {
4571
+ "status": {
4572
+ "type": "string",
4573
+ "enum": [
4574
+ "preview",
4575
+ "uninstalled"
4576
+ ]
4577
+ },
4578
+ "org": {
4579
+ "type": "string"
4580
+ },
4581
+ "installationId": {
4582
+ "type": "number"
4583
+ },
4584
+ "repos": {
4585
+ "type": "array",
4586
+ "items": {
4587
+ "type": "string"
4588
+ },
4589
+ "description": "The agent's repos in the org, removed from the agent."
4590
+ },
4591
+ "openWork": {
4592
+ "type": "array",
4593
+ "items": {
4594
+ "type": "object",
4595
+ "properties": {
4596
+ "id": {
4597
+ "type": "string"
4598
+ },
4599
+ "repo": {
4600
+ "type": "string"
4601
+ },
4602
+ "title": {
4603
+ "type": "string"
4604
+ }
4605
+ },
4606
+ "required": [
4607
+ "id",
4608
+ "repo"
4609
+ ]
4610
+ }
4611
+ },
4612
+ "warnings": {
4613
+ "type": "array",
4614
+ "items": {
4615
+ "type": "string"
4616
+ }
4617
+ },
4618
+ "auditId": {
4619
+ "type": "string"
4620
+ }
4621
+ },
4622
+ "required": [
4623
+ "status",
4624
+ "org",
4625
+ "installationId",
4626
+ "repos",
4627
+ "openWork",
4628
+ "warnings"
4629
+ ]
4630
+ },
4524
4631
  "AgentTemplatesList": {
4525
4632
  "type": "object",
4526
4633
  "properties": {
@@ -9018,6 +9125,196 @@
9018
9125
  }
9019
9126
  }
9020
9127
  }
9128
+ },
9129
+ "delete": {
9130
+ "tags": [
9131
+ "github-enterprise"
9132
+ ],
9133
+ "summary": "Uninstall an agent's App from an organization",
9134
+ "description": "Admin-only. Finds the agent App's installation on the org (client id, slug or app id) and deletes it with the installer App, removes that org's repos from the agent's repos, blocks the agent's open tasks and PRs on them through the open-work port (a port failure is a warning) and writes one audit row (uninstall:org). `preview=true` lists the repos and open work that would be affected and changes nothing. 404 when the App is not installed on the org; 422 when more than 10 repos would be removed without `confirmRemovals=true`; 502 (with a failed audit row) when GitHub refuses.",
9135
+ "parameters": [
9136
+ {
9137
+ "schema": {
9138
+ "type": "string",
9139
+ "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$",
9140
+ "example": "example-org"
9141
+ },
9142
+ "required": true,
9143
+ "name": "org",
9144
+ "in": "path"
9145
+ },
9146
+ {
9147
+ "schema": {
9148
+ "type": "string",
9149
+ "minLength": 1,
9150
+ "description": "Account whose App pair to read/write. Omit for the deployment-wide pair."
9151
+ },
9152
+ "required": false,
9153
+ "description": "Account whose App pair to read/write. Omit for the deployment-wide pair.",
9154
+ "name": "accountId",
9155
+ "in": "query"
9156
+ },
9157
+ {
9158
+ "schema": {
9159
+ "type": "string",
9160
+ "minLength": 1,
9161
+ "example": "agent-id"
9162
+ },
9163
+ "required": true,
9164
+ "name": "agentId",
9165
+ "in": "query"
9166
+ },
9167
+ {
9168
+ "schema": {
9169
+ "type": "string",
9170
+ "enum": [
9171
+ "true",
9172
+ "false"
9173
+ ],
9174
+ "description": "true: list the repos and open work an uninstall would affect and change nothing."
9175
+ },
9176
+ "required": false,
9177
+ "description": "true: list the repos and open work an uninstall would affect and change nothing.",
9178
+ "name": "preview",
9179
+ "in": "query"
9180
+ },
9181
+ {
9182
+ "schema": {
9183
+ "type": "string",
9184
+ "enum": [
9185
+ "true",
9186
+ "false"
9187
+ ],
9188
+ "description": "Required when more than 10 agent repos would be removed."
9189
+ },
9190
+ "required": false,
9191
+ "description": "Required when more than 10 agent repos would be removed.",
9192
+ "name": "confirmRemovals",
9193
+ "in": "query"
9194
+ }
9195
+ ],
9196
+ "responses": {
9197
+ "200": {
9198
+ "description": "Uninstalled, or the preview",
9199
+ "content": {
9200
+ "application/json": {
9201
+ "schema": {
9202
+ "$ref": "#/components/schemas/GithubEnterpriseUninstallResult"
9203
+ }
9204
+ }
9205
+ }
9206
+ },
9207
+ "400": {
9208
+ "description": "Bad request",
9209
+ "content": {
9210
+ "application/json": {
9211
+ "schema": {
9212
+ "$ref": "#/components/schemas/Error"
9213
+ }
9214
+ }
9215
+ }
9216
+ },
9217
+ "401": {
9218
+ "description": "Unauthorized",
9219
+ "content": {
9220
+ "application/json": {
9221
+ "schema": {
9222
+ "$ref": "#/components/schemas/Error"
9223
+ }
9224
+ }
9225
+ }
9226
+ },
9227
+ "403": {
9228
+ "description": "Forbidden (non-admin caller)",
9229
+ "content": {
9230
+ "application/json": {
9231
+ "schema": {
9232
+ "$ref": "#/components/schemas/Error"
9233
+ }
9234
+ }
9235
+ }
9236
+ },
9237
+ "404": {
9238
+ "description": "Not found (or not found at GitHub)",
9239
+ "content": {
9240
+ "application/json": {
9241
+ "schema": {
9242
+ "$ref": "#/components/schemas/Error"
9243
+ }
9244
+ }
9245
+ }
9246
+ },
9247
+ "409": {
9248
+ "description": "Installer App not configured",
9249
+ "content": {
9250
+ "application/json": {
9251
+ "schema": {
9252
+ "$ref": "#/components/schemas/Error"
9253
+ }
9254
+ }
9255
+ }
9256
+ },
9257
+ "422": {
9258
+ "description": "Refused or rejected by GitHub",
9259
+ "content": {
9260
+ "application/json": {
9261
+ "schema": {
9262
+ "$ref": "#/components/schemas/Error"
9263
+ }
9264
+ }
9265
+ }
9266
+ },
9267
+ "424": {
9268
+ "description": "GitHub refused the configured App credentials or permission",
9269
+ "content": {
9270
+ "application/json": {
9271
+ "schema": {
9272
+ "$ref": "#/components/schemas/Error"
9273
+ }
9274
+ }
9275
+ }
9276
+ },
9277
+ "429": {
9278
+ "description": "GitHub rate limit",
9279
+ "content": {
9280
+ "application/json": {
9281
+ "schema": {
9282
+ "$ref": "#/components/schemas/Error"
9283
+ }
9284
+ }
9285
+ }
9286
+ },
9287
+ "502": {
9288
+ "description": "GitHub unavailable or returned an unexpected response",
9289
+ "content": {
9290
+ "application/json": {
9291
+ "schema": {
9292
+ "$ref": "#/components/schemas/Error"
9293
+ }
9294
+ }
9295
+ }
9296
+ },
9297
+ "503": {
9298
+ "description": "Uninstall is not available",
9299
+ "content": {
9300
+ "application/json": {
9301
+ "schema": {
9302
+ "$ref": "#/components/schemas/Error"
9303
+ }
9304
+ }
9305
+ }
9306
+ },
9307
+ "504": {
9308
+ "description": "GitHub unreachable",
9309
+ "content": {
9310
+ "application/json": {
9311
+ "schema": {
9312
+ "$ref": "#/components/schemas/Error"
9313
+ }
9314
+ }
9315
+ }
9316
+ }
9317
+ }
9021
9318
  }
9022
9319
  },
9023
9320
  "/templates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.87.0",
3
+ "version": "1.89.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@anthropic-ai/sdk": "0.137.0",
47
- "@app-vitals/agent-lib": "1.87.0",
47
+ "@app-vitals/agent-lib": "1.89.0",
48
48
  "@hono/zod-openapi": "^1.0.0",
49
49
  "@prisma/adapter-pg": "^7.10.0",
50
50
  "@prisma/client": "^7.10.0",