@app-vitals/agent-admin 1.35.0 → 1.36.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.
- package/openapi.platform.json +136 -766
- package/package.json +2 -2
- package/src/admin-boot.ts +4 -15
- package/src/admin-extension.ts +3 -3
- package/src/admin-ui-github-identity.smoke.test.ts +24 -116
- package/src/admin-ui-installation-repos-pages.ts +198 -231
- package/src/admin-ui-installation-repos-pages.unit.test.ts +199 -0
- package/src/admin-ui-installation-repos.smoke.test.ts +166 -173
- package/src/admin-ui-pages.ts +2 -2
- package/src/admin-ui.ts +103 -171
- package/src/agents-api.smoke.test.ts +195 -642
- package/src/agents-api.ts +86 -477
- package/src/github-enterprise-isolation.unit.test.ts +4 -4
- package/src/{github-reconcile-wiring.ts → github-installation-wiring.ts} +24 -46
- package/src/github-installation-wiring.unit.test.ts +115 -0
- package/src/github-installation.fixtures.ts +76 -0
- package/src/github-sync.ts +407 -0
- package/src/{lost-access-removal.unit.test.ts → github-sync.unit.test.ts} +220 -115
- package/src/installation-ports.integration.test.ts +89 -0
- package/src/installation-ports.ts +207 -0
- package/src/installation-ports.unit.test.ts +51 -0
- package/src/installation-repos-service.ts +10 -105
- package/src/installation-repos-service.unit.test.ts +5 -90
- package/src/reconcile-open-work.ts +5 -7
- package/src/repo-access-rules.ts +58 -0
- package/src/repo-access-rules.unit.test.ts +98 -0
- package/src/admin-ui-github-reconcile-pages.ts +0 -208
- package/src/admin-ui-github-reconcile-pages.unit.test.ts +0 -226
- package/src/github-reconcile-routes.integration.test.ts +0 -206
- package/src/github-reconcile-wiring.unit.test.ts +0 -170
- package/src/lost-access-removal.ts +0 -333
- package/src/reconcile-apply-service.integration.test.ts +0 -271
- package/src/reconcile-apply-service.ts +0 -439
- package/src/reconcile-apply-service.unit.test.ts +0 -279
- package/src/reconcile-planner.ts +0 -264
- package/src/reconcile-planner.unit.test.ts +0 -274
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.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.
|
|
45
|
+
"@app-vitals/agent-lib": "1.36.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,9 +107,8 @@ import {
|
|
|
107
107
|
import { GitHubEnterpriseAppService } from "./github-enterprise-apps.ts";
|
|
108
108
|
import {
|
|
109
109
|
createGithubInstallationRepos,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} from "./github-reconcile-wiring.ts";
|
|
110
|
+
createGithubSync,
|
|
111
|
+
} from "./github-installation-wiring.ts";
|
|
113
112
|
import { HttpGoogleAuthClient } from "./google-auth-client.ts";
|
|
114
113
|
import { HttpChatClient } from "./http-chat-client.ts";
|
|
115
114
|
import { HttpOktaAuthClient } from "./okta-auth-client.ts";
|
|
@@ -474,22 +473,13 @@ export async function startAdmin(
|
|
|
474
473
|
const githubAccessPreview = createGithubAccessPreview({
|
|
475
474
|
appService: githubEnterpriseAppService,
|
|
476
475
|
});
|
|
477
|
-
// GHE-3.9: the reconcile routes' service, with the extension's optional
|
|
478
|
-
// open-work port. Each agent's App id is read from its own stored GH_APP_ID.
|
|
479
|
-
const githubReconcile = createGithubReconcile({
|
|
480
|
-
prisma,
|
|
481
|
-
appService: githubEnterpriseAppService,
|
|
482
|
-
access: githubAccessPreview,
|
|
483
|
-
agentEnv: agentEnvService,
|
|
484
|
-
openWork: resolvedExtensions.openWork,
|
|
485
|
-
});
|
|
486
476
|
const githubInstallationRepos = createGithubInstallationRepos({
|
|
487
477
|
prisma,
|
|
488
478
|
appService: githubEnterpriseAppService,
|
|
489
479
|
access: githubAccessPreview,
|
|
490
480
|
agentEnv: agentEnvService,
|
|
491
481
|
});
|
|
492
|
-
const
|
|
482
|
+
const githubSync = createGithubSync({
|
|
493
483
|
prisma,
|
|
494
484
|
appService: githubEnterpriseAppService,
|
|
495
485
|
access: githubAccessPreview,
|
|
@@ -498,12 +488,11 @@ export async function startAdmin(
|
|
|
498
488
|
});
|
|
499
489
|
const adminApiApp = createAdminApp({
|
|
500
490
|
githubAccessPreview,
|
|
501
|
-
githubReconcile,
|
|
502
491
|
...(resolvedExtensions.openWork
|
|
503
492
|
? { openWork: resolvedExtensions.openWork }
|
|
504
493
|
: {}),
|
|
505
494
|
githubInstallationRepos,
|
|
506
|
-
|
|
495
|
+
githubSync,
|
|
507
496
|
agentService,
|
|
508
497
|
agentEnvService,
|
|
509
498
|
agentCronJobService,
|
package/src/admin-extension.ts
CHANGED
|
@@ -130,9 +130,9 @@ export interface AdminExtensionServices {
|
|
|
130
130
|
*/
|
|
131
131
|
agentPhaseMethodologyService?: AgentPhaseMethodologyServiceLike;
|
|
132
132
|
/**
|
|
133
|
-
* Supplies the
|
|
134
|
-
*
|
|
135
|
-
* extension → nothing is listed or blocked.
|
|
133
|
+
* Supplies the open-work port: removing a repo from an agent (or the
|
|
134
|
+
* GitHub Sync) previews and blocks the open work on it. Absent from
|
|
135
|
+
* every extension → nothing is listed or blocked.
|
|
136
136
|
*/
|
|
137
137
|
openWork?: OpenWorkPort;
|
|
138
138
|
}
|
|
@@ -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: () =>
|
|
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();
|
|
@@ -202,118 +224,4 @@ describe("admin UI — GitHub identity (GHE-2.5)", () => {
|
|
|
202
224
|
expect(res.status).toBe(403);
|
|
203
225
|
expect(calls.length).toBe(0);
|
|
204
226
|
});
|
|
205
|
-
|
|
206
|
-
it("IRM-1.4: the Reconcile card is replaced on the page by the installation repos card", async () => {
|
|
207
|
-
const { app } = setup({});
|
|
208
|
-
const html = await (await get(app, admin)).text();
|
|
209
|
-
expect(html).not.toContain('id="github-reconcile-card"');
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("GHE-3.5: hides the Reconcile card when the apps are unconfigured", async () => {
|
|
213
|
-
const { app } = setup({ configured: false });
|
|
214
|
-
const html = await (await get(app, admin)).text();
|
|
215
|
-
expect(html).not.toContain("github-reconcile-card");
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("GHE-3.5: hides the Reconcile card from a non-admin", async () => {
|
|
219
|
-
const { app } = setup({});
|
|
220
|
-
const html = await (await get(app, member)).text();
|
|
221
|
-
expect(html).not.toContain("github-reconcile-card");
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it("GHE-3.5: plan route proxies the API and renders the diff", async () => {
|
|
225
|
-
const { app, calls } = setup({
|
|
226
|
-
agentsApi: () =>
|
|
227
|
-
json({
|
|
228
|
-
status: "planned",
|
|
229
|
-
planHash: "h1",
|
|
230
|
-
empty: false,
|
|
231
|
-
diff: {
|
|
232
|
-
installationAdds: [],
|
|
233
|
-
installationRemoves: [],
|
|
234
|
-
configAdds: ["acme/new"],
|
|
235
|
-
configRemoves: [],
|
|
236
|
-
},
|
|
237
|
-
}),
|
|
238
|
-
});
|
|
239
|
-
const res = await app.request(
|
|
240
|
-
`/admin/agents/${AGENT_ID}/github-reconcile/plan`,
|
|
241
|
-
{
|
|
242
|
-
method: "POST",
|
|
243
|
-
headers: {
|
|
244
|
-
Cookie: `admin_session=${admin}`,
|
|
245
|
-
"Content-Type": "application/json",
|
|
246
|
-
},
|
|
247
|
-
body: JSON.stringify({ addRepos: ["acme/new"] }),
|
|
248
|
-
},
|
|
249
|
-
);
|
|
250
|
-
expect(res.status).toBe(200);
|
|
251
|
-
const html = await res.text();
|
|
252
|
-
expect(calls.at(-1)?.path).toBe(
|
|
253
|
-
`/agents/${AGENT_ID}/github-reconcile/plan`,
|
|
254
|
-
);
|
|
255
|
-
expect(JSON.parse(String(calls.at(-1)?.init?.body))).toEqual({
|
|
256
|
-
addRepos: ["acme/new"],
|
|
257
|
-
});
|
|
258
|
-
expect(html).toContain('data-plan-hash="h1"');
|
|
259
|
-
expect(html).toContain('data-add-repos="acme/new"');
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it("GHE-3.5: apply route forwards the confirmation and renders the result", async () => {
|
|
263
|
-
const { app, calls } = setup({
|
|
264
|
-
agentsApi: () => json({ status: "applied", auditId: "aud-9" }),
|
|
265
|
-
});
|
|
266
|
-
const payload = { planHash: "h1", addRepos: [], confirmRemovals: true };
|
|
267
|
-
const res = await app.request(
|
|
268
|
-
`/admin/agents/${AGENT_ID}/github-reconcile/apply`,
|
|
269
|
-
{
|
|
270
|
-
method: "POST",
|
|
271
|
-
headers: {
|
|
272
|
-
Cookie: `admin_session=${admin}`,
|
|
273
|
-
"Content-Type": "application/json",
|
|
274
|
-
},
|
|
275
|
-
body: JSON.stringify(payload),
|
|
276
|
-
},
|
|
277
|
-
);
|
|
278
|
-
expect(await res.text()).toContain("aud-9");
|
|
279
|
-
expect(JSON.parse(String(calls.at(-1)?.init?.body))).toEqual(payload);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("GHE-3.5: apply surfaces a 409 stale plan error", async () => {
|
|
283
|
-
const { app } = setup({
|
|
284
|
-
agentsApi: () => json({ error: "the plan changed" }, 409),
|
|
285
|
-
});
|
|
286
|
-
const res = await app.request(
|
|
287
|
-
`/admin/agents/${AGENT_ID}/github-reconcile/apply`,
|
|
288
|
-
{
|
|
289
|
-
method: "POST",
|
|
290
|
-
headers: {
|
|
291
|
-
Cookie: `admin_session=${admin}`,
|
|
292
|
-
"Content-Type": "application/json",
|
|
293
|
-
},
|
|
294
|
-
body: JSON.stringify({ planHash: "old" }),
|
|
295
|
-
},
|
|
296
|
-
);
|
|
297
|
-
expect(res.status).toBe(409);
|
|
298
|
-
expect(await res.text()).toContain("the plan changed");
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it("GHE-3.5: plan and apply routes are forbidden for a non-admin", async () => {
|
|
302
|
-
const { app, calls } = setup({});
|
|
303
|
-
for (const step of ["plan", "apply"]) {
|
|
304
|
-
const res = await app.request(
|
|
305
|
-
`/admin/agents/${AGENT_ID}/github-reconcile/${step}`,
|
|
306
|
-
{
|
|
307
|
-
method: "POST",
|
|
308
|
-
headers: {
|
|
309
|
-
Cookie: `admin_session=${member}`,
|
|
310
|
-
"Content-Type": "application/json",
|
|
311
|
-
},
|
|
312
|
-
body: "{}",
|
|
313
|
-
},
|
|
314
|
-
);
|
|
315
|
-
expect(res.status).toBe(403);
|
|
316
|
-
}
|
|
317
|
-
expect(calls.length).toBe(0);
|
|
318
|
-
});
|
|
319
227
|
});
|