@app-vitals/agent-admin 1.54.0 → 1.54.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.54.
|
|
3
|
+
"version": "1.54.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.137.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.54.
|
|
45
|
+
"@app-vitals/agent-lib": "1.54.1",
|
|
46
46
|
"@hono/zod-openapi": "^1.0.0",
|
|
47
47
|
"@prisma/adapter-pg": "^7.10.0",
|
|
48
48
|
"@prisma/client": "^7.10.0",
|
|
@@ -67,8 +67,6 @@ export interface GithubEnterpriseSettingsPageOpts {
|
|
|
67
67
|
orgs?: GheOrgs;
|
|
68
68
|
/** Readable message when the org list could not be loaded. */
|
|
69
69
|
orgsError?: string;
|
|
70
|
-
/** Agent whose App the install actions target (carried via ?agentId=). */
|
|
71
|
-
agentId?: string;
|
|
72
70
|
error?: string;
|
|
73
71
|
notice?: string;
|
|
74
72
|
/** Warning codes from the last validate (carried via ?warn=); unknown codes are ignored. */
|
|
@@ -204,14 +202,8 @@ function installedCell(v: boolean | null): string {
|
|
|
204
202
|
function orgsCard(opts: GithubEnterpriseSettingsPageOpts): string {
|
|
205
203
|
const { status } = opts;
|
|
206
204
|
if (!status.installer) return "";
|
|
207
|
-
const agentId = opts.agentId ?? "";
|
|
208
205
|
const lookupSlug = status.lookup?.slug;
|
|
209
206
|
|
|
210
|
-
const filter = `<form method="GET" action="${BASE}" style="display:flex;gap:8px;margin:8px 0">
|
|
211
|
-
<input name="agentId" class="form-input" placeholder="Agent ID (to check its App)" value="${escapeHtml(agentId)}" style="max-width:280px" />
|
|
212
|
-
<button type="submit" class="btn btn-secondary">Check agent</button>
|
|
213
|
-
</form>`;
|
|
214
|
-
|
|
215
207
|
let body: string;
|
|
216
208
|
if (opts.orgsError) {
|
|
217
209
|
body = `<div class="alert alert-error">${escapeHtml(opts.orgsError)}</div>`;
|
|
@@ -219,38 +211,27 @@ function orgsCard(opts: GithubEnterpriseSettingsPageOpts): string {
|
|
|
219
211
|
const orgs = opts.orgs?.orgs ?? [];
|
|
220
212
|
const rows =
|
|
221
213
|
orgs.length === 0
|
|
222
|
-
? `<tr><td colspan="
|
|
214
|
+
? `<tr><td colspan="3" class="empty-state">No installable organizations.</td></tr>`
|
|
223
215
|
: orgs
|
|
224
216
|
.map((o) => {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
? ""
|
|
228
|
-
: o.lookupAppInstalled
|
|
217
|
+
const lookupAction =
|
|
218
|
+
!lookupSlug || o.lookupAppInstalled
|
|
229
219
|
? ""
|
|
230
220
|
: `<a class="btn btn-secondary" style="font-size:12px;padding:4px 10px" href="https://github.com/apps/${escapeHtml(lookupSlug)}/installations/new" target="_blank" rel="noopener noreferrer">Install lookup app</a>`;
|
|
231
|
-
const agentAction = `<form method="POST" action="${BASE}/orgs/${encodeURIComponent(o.login)}/install" style="display:inline-flex;gap:4px;margin:0">
|
|
232
|
-
<input name="agentId" class="form-input" required placeholder="Agent ID" value="${escapeHtml(agentId)}" style="max-width:160px;padding:4px 8px" />
|
|
233
|
-
<button type="submit" class="btn btn-primary" style="font-size:12px;padding:4px 10px">Install agent app</button>
|
|
234
|
-
</form>`;
|
|
235
221
|
return `<tr>
|
|
236
|
-
<td>${login}</td>
|
|
222
|
+
<td>${escapeHtml(o.login)}</td>
|
|
237
223
|
<td>${installedCell(o.lookupAppInstalled)}</td>
|
|
238
|
-
<td>${
|
|
239
|
-
<td style="text-align:right">${lookupAction} ${agentAction}</td>
|
|
224
|
+
<td style="text-align:right">${lookupAction}</td>
|
|
240
225
|
</tr>`;
|
|
241
226
|
})
|
|
242
227
|
.join("\n");
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
: "";
|
|
246
|
-
body = `${reason}<table class="data-table">
|
|
247
|
-
<thead><tr><th>Organization</th><th>Lookup app</th><th>Agent app</th><th></th></tr></thead>
|
|
228
|
+
body = `<table class="data-table">
|
|
229
|
+
<thead><tr><th>Organization</th><th>Lookup app</th><th></th></tr></thead>
|
|
248
230
|
<tbody>${rows}</tbody>
|
|
249
231
|
</table>`;
|
|
250
232
|
}
|
|
251
233
|
return `<div class="card">
|
|
252
234
|
<div class="card-title">Organizations</div>
|
|
253
|
-
${filter}
|
|
254
235
|
${body}
|
|
255
236
|
</div>`;
|
|
256
237
|
}
|
|
@@ -175,10 +175,9 @@ describe("renderGithubEnterpriseSettingsPage", () => {
|
|
|
175
175
|
expect(html).toContain("Key not set");
|
|
176
176
|
});
|
|
177
177
|
|
|
178
|
-
test("org list
|
|
178
|
+
test("org list shows only org, lookup state and the lookup install link", () => {
|
|
179
179
|
const html = renderGithubEnterpriseSettingsPage({
|
|
180
180
|
...base,
|
|
181
|
-
agentId: "agent-1",
|
|
182
181
|
status: {
|
|
183
182
|
configured: true,
|
|
184
183
|
installer: app(),
|
|
@@ -190,7 +189,6 @@ describe("renderGithubEnterpriseSettingsPage", () => {
|
|
|
190
189
|
},
|
|
191
190
|
orgs: {
|
|
192
191
|
configured: true,
|
|
193
|
-
agentAppSlug: "agent-app",
|
|
194
192
|
orgs: [
|
|
195
193
|
{
|
|
196
194
|
id: 1,
|
|
@@ -212,35 +210,12 @@ describe("renderGithubEnterpriseSettingsPage", () => {
|
|
|
212
210
|
expect(html).toContain(
|
|
213
211
|
"https://github.com/apps/acme-lookup/installations/new",
|
|
214
212
|
);
|
|
215
|
-
expect(html).toContain(
|
|
216
|
-
'action="/admin/settings/github-enterprise/orgs/org-a/install"',
|
|
217
|
-
);
|
|
218
|
-
expect(html).toContain('value="agent-1"');
|
|
219
|
-
expect(html).toContain("Install agent app");
|
|
220
213
|
expect(html).toContain("Installed");
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
agentId: "agent-1",
|
|
227
|
-
status: { configured: true, installer: app(), lookup: null },
|
|
228
|
-
orgs: {
|
|
229
|
-
configured: true,
|
|
230
|
-
agentAppSlug: "agent-app",
|
|
231
|
-
agentAppReason: "the agent's App 'agent-app' is private <b>",
|
|
232
|
-
orgs: [
|
|
233
|
-
{
|
|
234
|
-
id: 1,
|
|
235
|
-
login: "org-a",
|
|
236
|
-
lookupAppInstalled: null,
|
|
237
|
-
agentAppInstalled: false,
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
expect(html).toContain("is private <b>");
|
|
243
|
-
expect(html).not.toContain("private <b>");
|
|
214
|
+
expect(html).not.toContain('name="agentId"');
|
|
215
|
+
expect(html).not.toContain("Install agent app");
|
|
216
|
+
expect(html).not.toContain("Agent app");
|
|
217
|
+
expect(html).not.toContain("Check agent");
|
|
218
|
+
expect(html).not.toContain("/orgs/org-a/install");
|
|
244
219
|
});
|
|
245
220
|
|
|
246
221
|
test("org list failure and top-level error/notice are escaped messages", () => {
|
|
@@ -338,21 +338,13 @@ describe("form posts", () => {
|
|
|
338
338
|
);
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
-
it("
|
|
341
|
+
it("the per-org agent install UI route is gone", async () => {
|
|
342
342
|
const { app } = setup();
|
|
343
343
|
const res = await app.request(
|
|
344
344
|
`${BASE}/orgs/org-a/install`,
|
|
345
345
|
form({ agentId: "agent-1" }),
|
|
346
346
|
);
|
|
347
|
-
expect(res.status).toBe(
|
|
348
|
-
expect(await res.text()).toContain("the installer App is not configured");
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it("install with an empty agent id is a readable 400", async () => {
|
|
352
|
-
const { app } = setup();
|
|
353
|
-
const res = await app.request(`${BASE}/orgs/org-a/install`, form({}));
|
|
354
|
-
expect(res.status).toBe(400);
|
|
355
|
-
expect(await res.text()).toContain("Agent ID is required");
|
|
347
|
+
expect(res.status).toBe(404);
|
|
356
348
|
});
|
|
357
349
|
|
|
358
350
|
it("org list failure from GitHub renders a message, not a 500", async () => {
|
|
@@ -32,8 +32,6 @@ const NOTICES: Record<string, string> = {
|
|
|
32
32
|
saved: "Credentials saved. Validate the app to check its permissions.",
|
|
33
33
|
deleted: "App removed.",
|
|
34
34
|
validated: "Validation finished; see the status below.",
|
|
35
|
-
installed: "Agent app installed.",
|
|
36
|
-
already: "The agent app was already installed on that organization.",
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
// Deliberately not imported from the enterprise credential service: that
|
|
@@ -96,7 +94,6 @@ export function registerAdminGithubEnterpriseRoutes(
|
|
|
96
94
|
c: Context<AdminUIEnv>,
|
|
97
95
|
flash: { error?: string; notice?: string; status?: number } = {},
|
|
98
96
|
): Promise<Response> {
|
|
99
|
-
const agentId = c.req.query("agentId")?.trim() || undefined;
|
|
100
97
|
const statusRes = await call<GheStatus>(
|
|
101
98
|
c,
|
|
102
99
|
"GET",
|
|
@@ -118,8 +115,7 @@ export function registerAdminGithubEnterpriseRoutes(
|
|
|
118
115
|
let orgs: GheOrgs | undefined;
|
|
119
116
|
let orgsError: string | undefined;
|
|
120
117
|
if (status.installer) {
|
|
121
|
-
const
|
|
122
|
-
const r = await call<GheOrgs>(c, "GET", `/github-enterprise/orgs${qs}`);
|
|
118
|
+
const r = await call<GheOrgs>(c, "GET", "/github-enterprise/orgs");
|
|
123
119
|
if (r.ok) orgs = r.data;
|
|
124
120
|
else orgsError = r.error;
|
|
125
121
|
}
|
|
@@ -133,7 +129,6 @@ export function registerAdminGithubEnterpriseRoutes(
|
|
|
133
129
|
status,
|
|
134
130
|
orgs,
|
|
135
131
|
orgsError,
|
|
136
|
-
agentId,
|
|
137
132
|
error: flash.error,
|
|
138
133
|
notice,
|
|
139
134
|
warnings: c.req.query("warn")?.split(",").filter(Boolean),
|
|
@@ -151,11 +146,8 @@ export function registerAdminGithubEnterpriseRoutes(
|
|
|
151
146
|
return new FormData();
|
|
152
147
|
}
|
|
153
148
|
}
|
|
154
|
-
const back = (c: Context<AdminUIEnv>, notice: string
|
|
155
|
-
c.redirect(
|
|
156
|
-
`${BASE}?notice=${notice}${agentId ? `&agentId=${encodeURIComponent(agentId)}` : ""}`,
|
|
157
|
-
302,
|
|
158
|
-
);
|
|
149
|
+
const back = (c: Context<AdminUIEnv>, notice: string) =>
|
|
150
|
+
c.redirect(`${BASE}?notice=${notice}`, 302);
|
|
159
151
|
const fail = (c: Context<AdminUIEnv>, r: ApiResult<unknown>) =>
|
|
160
152
|
renderPage(c, { error: r.error, status: r.status >= 400 ? r.status : 400 });
|
|
161
153
|
|
|
@@ -213,29 +205,4 @@ export function registerAdminGithubEnterpriseRoutes(
|
|
|
213
205
|
return r.ok ? back(c, "deleted") : fail(c, r);
|
|
214
206
|
},
|
|
215
207
|
);
|
|
216
|
-
|
|
217
|
-
app.post(
|
|
218
|
-
`${BASE}/orgs/:org/install`,
|
|
219
|
-
deps.requireAuth,
|
|
220
|
-
requireAdmin,
|
|
221
|
-
async (c) => {
|
|
222
|
-
const org = c.req.param("org");
|
|
223
|
-
const agentId = field(await readForm(c), "agentId");
|
|
224
|
-
if (!agentId) {
|
|
225
|
-
return renderPage(c, { error: "Agent ID is required.", status: 400 });
|
|
226
|
-
}
|
|
227
|
-
const r = await call<{ created: boolean }>(
|
|
228
|
-
c,
|
|
229
|
-
"POST",
|
|
230
|
-
`/github-enterprise/orgs/${encodeURIComponent(org)}/install`,
|
|
231
|
-
{ agentId },
|
|
232
|
-
);
|
|
233
|
-
if (!r.ok) return fail(c, r);
|
|
234
|
-
return back(
|
|
235
|
-
c,
|
|
236
|
-
r.data?.created === false ? "already" : "installed",
|
|
237
|
-
agentId,
|
|
238
|
-
);
|
|
239
|
-
},
|
|
240
|
-
);
|
|
241
208
|
}
|