@app-vitals/agent-admin 1.52.2 → 1.54.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/package.json +2 -2
- package/src/admin-extension.ts +2 -0
- package/src/admin-ui-github-identity-pages.ts +60 -3
- package/src/admin-ui-github-identity-pages.unit.test.ts +71 -0
- package/src/admin-ui-github-identity.smoke.test.ts +110 -3
- package/src/admin-ui-installation-repos-pages.ts +3 -3
- package/src/admin-ui-pages.ts +41 -18
- package/src/admin-ui-pages.unit.test.ts +34 -5
- package/src/admin-ui-settings-layout.ts +26 -0
- package/src/admin-ui-settings-nav-context.smoke.test.ts +166 -0
- package/src/admin-ui.smoke.test.ts +19 -4
- package/src/admin-ui.ts +128 -28
- package/src/server.ts +41 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.54.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.137.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.
|
|
45
|
+
"@app-vitals/agent-lib": "1.54.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-extension.ts
CHANGED
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
* (the composition root) is the only file that wires a concrete extension in.
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
|
+
export { getSettingsNav } from "./admin-ui-settings-layout.ts";
|
|
54
|
+
|
|
53
55
|
import type { PoolLike } from "@app-vitals/agent-lib/pool-observability";
|
|
54
56
|
import type { ErrorCapturingClient } from "@app-vitals/agent-lib/sentry";
|
|
55
57
|
import type { Hono } from "hono";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* repo names and levels only (no token or key ever reaches this module).
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import type { GheOrgs } from "./admin-ui-github-enterprise-pages.ts";
|
|
10
11
|
import { escapeHtml } from "./admin-ui-styles.ts";
|
|
11
12
|
|
|
12
13
|
export interface GithubAccessRepo {
|
|
@@ -84,11 +85,11 @@ export function renderGithubUsernameRow(
|
|
|
84
85
|
</td></tr>`;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
/** The "Preview access" card; the button loads the fragment from the UI route. */
|
|
88
|
+
/** The "Preview access" fragment (rendered inside the GitHub card); the button loads the fragment from the UI route. */
|
|
88
89
|
export function renderGithubAccessCard(agentId: string): string {
|
|
89
90
|
const url = `/admin/agents/${escapeHtml(agentId)}/github-access`;
|
|
90
|
-
return `<div
|
|
91
|
-
<div class="
|
|
91
|
+
return `<div id="github-access-card" style="margin-top:20px">
|
|
92
|
+
<div class="form-label" style="font-weight:600;margin-bottom:6px">Preview access</div>
|
|
92
93
|
<p style="color:#6b7280;font-size:12px;margin:0 0 12px">Shows the repos this agent's GitHub user can reach. Read-only; nothing is stored.</p>
|
|
93
94
|
<button type="button" class="btn btn-primary" id="github-access-btn" data-url="${url}">Preview access</button>
|
|
94
95
|
<div id="github-access-result" style="margin-top:12px"></div>
|
|
@@ -167,3 +168,59 @@ export function renderGithubAccessResult(
|
|
|
167
168
|
export function renderGithubAccessError(message: string): string {
|
|
168
169
|
return `<div class="alert alert-error">${escapeHtml(message)}</div>`;
|
|
169
170
|
}
|
|
171
|
+
|
|
172
|
+
/** "Install on org" block (GHC-1.2); lazy-loads the org list fragment on page load. */
|
|
173
|
+
export function renderGithubInstallCard(agentId: string): string {
|
|
174
|
+
const url = `/admin/agents/${escapeHtml(agentId)}/github-orgs`;
|
|
175
|
+
return `<div id="github-install-card" style="margin-top:20px">
|
|
176
|
+
<div class="form-label" style="font-weight:600;margin-bottom:6px">Install on org</div>
|
|
177
|
+
<p style="color:#6b7280;font-size:12px;margin:0 0 12px">Installs this agent's GitHub App on an organization.</p>
|
|
178
|
+
<div id="github-install-result" data-url="${url}">Loading...</div>
|
|
179
|
+
<script>
|
|
180
|
+
(function() {
|
|
181
|
+
var out = document.getElementById('github-install-result');
|
|
182
|
+
if (!out) return;
|
|
183
|
+
fetch(out.getAttribute('data-url'), { credentials: 'same-origin' })
|
|
184
|
+
.then(function(r) { return r.text(); })
|
|
185
|
+
.then(function(t) { out.innerHTML = t; })
|
|
186
|
+
.catch(function() { out.textContent = 'The request failed.'; });
|
|
187
|
+
})();
|
|
188
|
+
</script>
|
|
189
|
+
</div>`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function installedBadge(v: boolean | null): string {
|
|
193
|
+
if (v === null) return "—";
|
|
194
|
+
return v
|
|
195
|
+
? `<span class="badge badge-green">Installed</span>`
|
|
196
|
+
: `<span class="badge badge-gray">Not installed</span>`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Fragment for the Install on org block: org list with app status and Install buttons. */
|
|
200
|
+
export function renderGithubOrgsFragment(
|
|
201
|
+
agentId: string,
|
|
202
|
+
data: GheOrgs,
|
|
203
|
+
): string {
|
|
204
|
+
if (!data.configured) {
|
|
205
|
+
return `<div class="alert alert-warning">The installer GitHub App is not configured.</div>`;
|
|
206
|
+
}
|
|
207
|
+
const reason = data.agentAppReason
|
|
208
|
+
? `<div class="alert alert-error">${escapeHtml(data.agentAppReason)}</div>`
|
|
209
|
+
: "";
|
|
210
|
+
if (data.orgs.length === 0) {
|
|
211
|
+
return `${reason}<p class="empty-state">No installable organizations.</p>`;
|
|
212
|
+
}
|
|
213
|
+
const disabled = data.agentAppReason ? " disabled" : "";
|
|
214
|
+
const rows = data.orgs
|
|
215
|
+
.map((o) => {
|
|
216
|
+
const action = o.agentAppInstalled
|
|
217
|
+
? ""
|
|
218
|
+
: `<form method="POST" action="/admin/agents/${escapeHtml(agentId)}/github-orgs/${escapeHtml(encodeURIComponent(o.login))}/install" style="display:inline;margin:0"><button type="submit" class="btn btn-primary" style="font-size:12px;padding:4px 10px"${disabled}>Install</button></form>`;
|
|
219
|
+
return `<tr><td>${escapeHtml(o.login)}</td><td>${installedBadge(o.lookupAppInstalled)}</td><td>${installedBadge(o.agentAppInstalled)}</td><td style="text-align:right">${action}</td></tr>`;
|
|
220
|
+
})
|
|
221
|
+
.join("");
|
|
222
|
+
return `${reason}<table class="data-table">
|
|
223
|
+
<thead><tr><th>Organization</th><th>Lookup app</th><th>Agent app</th><th></th></tr></thead>
|
|
224
|
+
<tbody>${rows}</tbody>
|
|
225
|
+
</table>`;
|
|
226
|
+
}
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
type GithubAccessPreviewView,
|
|
10
10
|
renderGithubAccessCard,
|
|
11
11
|
renderGithubAccessResult,
|
|
12
|
+
renderGithubInstallCard,
|
|
13
|
+
renderGithubOrgsFragment,
|
|
12
14
|
renderGithubUsernameRow,
|
|
13
15
|
} from "./admin-ui-github-identity-pages.ts";
|
|
14
16
|
import {
|
|
@@ -259,3 +261,72 @@ describe("renderGithubAccessResult", () => {
|
|
|
259
261
|
expect(html).not.toContain("<i>r</i>");
|
|
260
262
|
});
|
|
261
263
|
});
|
|
264
|
+
|
|
265
|
+
describe("Install on org block (GHC-1.2)", () => {
|
|
266
|
+
const orgs = (over: Record<string, unknown> = {}) => ({
|
|
267
|
+
configured: true,
|
|
268
|
+
agentAppSlug: "agent-app",
|
|
269
|
+
agentAppReason: null,
|
|
270
|
+
orgs: [
|
|
271
|
+
{
|
|
272
|
+
id: 1,
|
|
273
|
+
login: "acme",
|
|
274
|
+
lookupAppInstalled: true,
|
|
275
|
+
agentAppInstalled: false,
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
id: 2,
|
|
279
|
+
login: "<b>x</b>",
|
|
280
|
+
lookupAppInstalled: false,
|
|
281
|
+
agentAppInstalled: true,
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
...over,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("card lazy-loads the fragment and is gated like the sync card", () => {
|
|
288
|
+
expect(renderGithubInstallCard("agent-123")).toContain(
|
|
289
|
+
"/admin/agents/agent-123/github-orgs",
|
|
290
|
+
);
|
|
291
|
+
expect(page(true, true)).toContain("Install on org");
|
|
292
|
+
expect(page(true, false)).not.toContain("Install on org");
|
|
293
|
+
expect(page(false, true)).not.toContain("Install on org");
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test("lists orgs with status; not installed gets an enabled Install form", () => {
|
|
297
|
+
const html = renderGithubOrgsFragment("agent-123", orgs());
|
|
298
|
+
expect(html).toContain("acme");
|
|
299
|
+
expect(html).toContain(
|
|
300
|
+
'action="/admin/agents/agent-123/github-orgs/acme/install"',
|
|
301
|
+
);
|
|
302
|
+
expect(html).toContain("Installed");
|
|
303
|
+
expect(html).toContain("Not installed");
|
|
304
|
+
expect(html).not.toContain("disabled");
|
|
305
|
+
expect(html).not.toContain('name="agentId"');
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
test("installed org has no Install button; names are escaped", () => {
|
|
309
|
+
const html = renderGithubOrgsFragment("agent-123", orgs());
|
|
310
|
+
expect(html).not.toContain("<b>x</b>");
|
|
311
|
+
expect(html).toContain("<b>x</b>");
|
|
312
|
+
expect(html.match(/>Install<\/button>/g)?.length).toBe(1);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
test("agentAppReason is shown and disables Install", () => {
|
|
316
|
+
const html = renderGithubOrgsFragment(
|
|
317
|
+
"agent-123",
|
|
318
|
+
orgs({ agentAppReason: "App <private>" }),
|
|
319
|
+
);
|
|
320
|
+
expect(html).toContain("App <private>");
|
|
321
|
+
expect(html).toContain("disabled");
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test("unconfigured and empty states", () => {
|
|
325
|
+
expect(
|
|
326
|
+
renderGithubOrgsFragment("a", { configured: false, orgs: [] }),
|
|
327
|
+
).toContain("not configured");
|
|
328
|
+
expect(renderGithubOrgsFragment("a", orgs({ orgs: [] }))).toContain(
|
|
329
|
+
"No installable organizations",
|
|
330
|
+
);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
@@ -23,6 +23,7 @@ const json = (b: unknown, status = 200) =>
|
|
|
23
23
|
function setup(opts: {
|
|
24
24
|
configured?: boolean | "installer-only";
|
|
25
25
|
agentsApi?: (path: string, init?: RequestInit) => Response;
|
|
26
|
+
enterpriseApi?: (path: string, init?: RequestInit) => Response;
|
|
26
27
|
}) {
|
|
27
28
|
const calls: { path: string; init?: RequestInit }[] = [];
|
|
28
29
|
const base = makeMockDeps();
|
|
@@ -45,8 +46,12 @@ function setup(opts: {
|
|
|
45
46
|
githubUsername: "octo",
|
|
46
47
|
}),
|
|
47
48
|
},
|
|
48
|
-
githubEnterpriseApi: () =>
|
|
49
|
-
|
|
49
|
+
githubEnterpriseApi: (path: string, init?: RequestInit) => {
|
|
50
|
+
if (path !== "/github-enterprise/apps" && opts.enterpriseApi) {
|
|
51
|
+
calls.push({ path, init });
|
|
52
|
+
return opts.enterpriseApi(path, init);
|
|
53
|
+
}
|
|
54
|
+
return json(
|
|
50
55
|
opts.configured === false
|
|
51
56
|
? { configured: false, installer: null, lookup: null }
|
|
52
57
|
: opts.configured === "installer-only"
|
|
@@ -60,7 +65,8 @@ function setup(opts: {
|
|
|
60
65
|
installer: { role: "installer" },
|
|
61
66
|
lookup: { role: "lookup" },
|
|
62
67
|
},
|
|
63
|
-
)
|
|
68
|
+
);
|
|
69
|
+
},
|
|
64
70
|
agentsApi: (path: string, init?: RequestInit) => {
|
|
65
71
|
calls.push({ path, init });
|
|
66
72
|
return opts.agentsApi ? opts.agentsApi(path, init) : json({});
|
|
@@ -224,4 +230,105 @@ describe("admin UI — GitHub identity (GHE-2.5)", () => {
|
|
|
224
230
|
expect(res.status).toBe(403);
|
|
225
231
|
expect(calls.length).toBe(0);
|
|
226
232
|
});
|
|
233
|
+
|
|
234
|
+
describe("Install on org (GHC-1.2)", () => {
|
|
235
|
+
const orgsUrl = `/admin/agents/${AGENT_ID}/github-orgs`;
|
|
236
|
+
const installUrl = `${orgsUrl}/acme/install`;
|
|
237
|
+
const opts = (cookie: string, method = "GET") => ({
|
|
238
|
+
method,
|
|
239
|
+
headers: { Cookie: `admin_session=${cookie}` },
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("fragment route calls the orgs API for the agent and renders", async () => {
|
|
243
|
+
const { app, calls } = setup({
|
|
244
|
+
enterpriseApi: () =>
|
|
245
|
+
json({
|
|
246
|
+
configured: true,
|
|
247
|
+
agentAppReason: null,
|
|
248
|
+
orgs: [
|
|
249
|
+
{
|
|
250
|
+
id: 1,
|
|
251
|
+
login: "acme",
|
|
252
|
+
lookupAppInstalled: true,
|
|
253
|
+
agentAppInstalled: false,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
}),
|
|
257
|
+
});
|
|
258
|
+
const res = await app.request(orgsUrl, opts(admin));
|
|
259
|
+
expect(res.status).toBe(200);
|
|
260
|
+
expect(calls.at(-1)?.path).toBe(
|
|
261
|
+
`/github-enterprise/orgs?agentId=${AGENT_ID}`,
|
|
262
|
+
);
|
|
263
|
+
expect(await res.text()).toContain(`${orgsUrl}/acme/install`);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it("fragment route surfaces an upstream error", async () => {
|
|
267
|
+
const { app } = setup({
|
|
268
|
+
enterpriseApi: () => json({ error: "boom" }, 502),
|
|
269
|
+
});
|
|
270
|
+
const res = await app.request(orgsUrl, opts(admin));
|
|
271
|
+
expect(res.status).toBe(502);
|
|
272
|
+
expect(await res.text()).toContain("boom");
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("fragment route is forbidden for a non-admin", async () => {
|
|
276
|
+
const { app, calls } = setup({});
|
|
277
|
+
const res = await app.request(orgsUrl, opts(member));
|
|
278
|
+
expect(res.status).toBe(403);
|
|
279
|
+
expect(calls.length).toBe(0);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it("install: created redirects to the Access tab with a banner", async () => {
|
|
283
|
+
const { app, calls } = setup({
|
|
284
|
+
enterpriseApi: () => json({ created: true }),
|
|
285
|
+
});
|
|
286
|
+
const res = await app.request(installUrl, opts(admin, "POST"));
|
|
287
|
+
expect(res.status).toBe(302);
|
|
288
|
+
expect(res.headers.get("location")).toBe(
|
|
289
|
+
`/admin/agents/${AGENT_ID}/access?success=github_app_installed`,
|
|
290
|
+
);
|
|
291
|
+
const c = calls.at(-1);
|
|
292
|
+
expect(c?.path).toBe("/github-enterprise/orgs/acme/install");
|
|
293
|
+
expect(c?.init?.method).toBe("POST");
|
|
294
|
+
expect(JSON.parse(String(c?.init?.body))).toEqual({ agentId: AGENT_ID });
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("install: already installed", async () => {
|
|
298
|
+
const { app } = setup({
|
|
299
|
+
enterpriseApi: () => json({ created: false }),
|
|
300
|
+
});
|
|
301
|
+
const res = await app.request(installUrl, opts(admin, "POST"));
|
|
302
|
+
expect(res.headers.get("location")).toContain(
|
|
303
|
+
"success=github_app_already_installed",
|
|
304
|
+
);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("install: upstream error redirects with the message", async () => {
|
|
308
|
+
const { app } = setup({
|
|
309
|
+
enterpriseApi: () => json({ error: "no client id" }, 422),
|
|
310
|
+
});
|
|
311
|
+
const res = await app.request(installUrl, opts(admin, "POST"));
|
|
312
|
+
expect(res.status).toBe(302);
|
|
313
|
+
expect(res.headers.get("location")).toContain(
|
|
314
|
+
encodeURIComponent("no client id"),
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it("install is forbidden for a non-admin and makes no call", async () => {
|
|
319
|
+
const { app, calls } = setup({});
|
|
320
|
+
const res = await app.request(installUrl, opts(member, "POST"));
|
|
321
|
+
expect(res.status).toBe(403);
|
|
322
|
+
expect(calls.length).toBe(0);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("banners render on the Access tab", async () => {
|
|
326
|
+
const { app } = setup({});
|
|
327
|
+
const res = await app.request(
|
|
328
|
+
`/admin/agents/${AGENT_ID}/access?success=github_app_installed`,
|
|
329
|
+
opts(admin),
|
|
330
|
+
);
|
|
331
|
+
expect(await res.text()).toContain("Agent app installed");
|
|
332
|
+
});
|
|
333
|
+
});
|
|
227
334
|
});
|
|
@@ -121,7 +121,7 @@ export interface GithubSyncCardState {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* The
|
|
124
|
+
* The GitHub sync fragment (rendered inside the GitHub card); it loads its repos body from the UI route on page load.
|
|
125
125
|
* Without a GH_APP_ID or a bound username the button is replaced by the
|
|
126
126
|
* reason (missing App id first).
|
|
127
127
|
*/
|
|
@@ -142,8 +142,8 @@ export function renderGithubSyncCard(
|
|
|
142
142
|
const loader = state.hasAppId
|
|
143
143
|
? `<div id="github-installation-body">Loading...</div>`
|
|
144
144
|
: "";
|
|
145
|
-
return `<div
|
|
146
|
-
<div class="
|
|
145
|
+
return `<div id="github-installation-card" data-base-url="${base}" style="margin-top:20px">
|
|
146
|
+
<div class="form-label" style="font-weight:600;margin-bottom:6px">GitHub sync</div>
|
|
147
147
|
<p style="color:#6b7280;font-size:12px;margin:0 0 12px">Brings this agent's App installation and its repos in line with what the bound GitHub user can push to.</p>
|
|
148
148
|
${action}
|
|
149
149
|
${loader}
|
package/src/admin-ui-pages.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { PROGRESS_LABELS } from "@app-vitals/agent-lib/progress-phases";
|
|
|
14
14
|
import { getSelfServeSpecialty } from "./account-agent-create.ts";
|
|
15
15
|
import {
|
|
16
16
|
renderGithubAccessCard,
|
|
17
|
+
renderGithubInstallCard,
|
|
17
18
|
renderGithubUsernameRow,
|
|
18
19
|
} from "./admin-ui-github-identity-pages.ts";
|
|
19
20
|
import {
|
|
@@ -1024,6 +1025,7 @@ export function agentSectionPath(
|
|
|
1024
1025
|
export const AGENT_POST_SECTIONS: Readonly<Record<string, AgentSection>> = {
|
|
1025
1026
|
"/github-username": "access",
|
|
1026
1027
|
"/github-sync/apply-confirmed": "access",
|
|
1028
|
+
"/github-orgs/:org/install": "access",
|
|
1027
1029
|
"/repos/remove-confirmed": "configuration",
|
|
1028
1030
|
"/envs": "configuration",
|
|
1029
1031
|
"/template/detach": "configuration",
|
|
@@ -1036,7 +1038,7 @@ export const AGENT_POST_SECTIONS: Readonly<Record<string, AgentSection>> = {
|
|
|
1036
1038
|
"/review-author-allowlist/delete": "access",
|
|
1037
1039
|
"/patch-author-allowlist/add": "access",
|
|
1038
1040
|
"/patch-author-allowlist/delete": "access",
|
|
1039
|
-
// Shared by the Slack
|
|
1041
|
+
// Shared by the Slack card (access) and the Agent Policy card
|
|
1040
1042
|
// (configuration); see settingsRedirectSection.
|
|
1041
1043
|
"/settings": "configuration",
|
|
1042
1044
|
"/crons": "automation",
|
|
@@ -1062,7 +1064,7 @@ export const AGENT_POST_SECTIONS: Readonly<Record<string, AgentSection>> = {
|
|
|
1062
1064
|
};
|
|
1063
1065
|
|
|
1064
1066
|
/**
|
|
1065
|
-
* POST /settings serves two forms: Slack
|
|
1067
|
+
* POST /settings serves two forms: Slack (access section, carries
|
|
1066
1068
|
* restrictSlackToMembers) and Agent Policy (configuration section).
|
|
1067
1069
|
*/
|
|
1068
1070
|
export function settingsRedirectSection(formData: FormData): AgentSection {
|
|
@@ -1090,7 +1092,7 @@ export function renderAgentDetailPage(
|
|
|
1090
1092
|
/** Section to render (SGL-1.2). Defaults to "general". */
|
|
1091
1093
|
section?: AgentSection;
|
|
1092
1094
|
/**
|
|
1093
|
-
* SSP-4.3: render the Members / Slack
|
|
1095
|
+
* SSP-4.3: render the Members / Slack / GitHub / Danger Zone cards. Defaults
|
|
1094
1096
|
* to isAdmin; the caller passes true for agent-access holders when
|
|
1095
1097
|
* self-serve is enabled.
|
|
1096
1098
|
*/
|
|
@@ -1230,7 +1232,7 @@ export function renderAgentDetailPage(
|
|
|
1230
1232
|
|
|
1231
1233
|
// "Connect later" actions (UAP-2.3) — each hidden once its AgentEnv key is
|
|
1232
1234
|
// already set, mirroring the "Sync Manifest" visibility pattern.
|
|
1233
|
-
const
|
|
1235
|
+
const slackConnectActionConfigs: ConnectActionConfig[] = [
|
|
1234
1236
|
{
|
|
1235
1237
|
envKey: "SLACK_APP_TOKEN",
|
|
1236
1238
|
label: "Connect Slack",
|
|
@@ -1245,6 +1247,8 @@ export function renderAgentDetailPage(
|
|
|
1245
1247
|
},
|
|
1246
1248
|
],
|
|
1247
1249
|
},
|
|
1250
|
+
];
|
|
1251
|
+
const githubConnectActionConfigs: ConnectActionConfig[] = [
|
|
1248
1252
|
{
|
|
1249
1253
|
envKey: "GH_APP_ID",
|
|
1250
1254
|
label: "Set up GitHub App",
|
|
@@ -1296,17 +1300,25 @@ export function renderAgentDetailPage(
|
|
|
1296
1300
|
],
|
|
1297
1301
|
},
|
|
1298
1302
|
];
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
renderAddAnotherOrgAction(agent.id, envVars),
|
|
1302
|
-
].filter(Boolean);
|
|
1303
|
-
|
|
1304
|
-
const connectActionsHtml =
|
|
1305
|
-
connectActions.length === 0
|
|
1303
|
+
const connectActionsDiv = (items: string[]): string =>
|
|
1304
|
+
items.length === 0
|
|
1306
1305
|
? ""
|
|
1307
1306
|
: `<div style="display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px">
|
|
1308
|
-
${
|
|
1307
|
+
${items.join("\n ")}
|
|
1309
1308
|
</div>`;
|
|
1309
|
+
const slackConnectActionsHtml = connectActionsDiv(
|
|
1310
|
+
slackConnectActionConfigs
|
|
1311
|
+
.map((cfg) => renderConnectAction(envVars, cfg))
|
|
1312
|
+
.filter(Boolean),
|
|
1313
|
+
);
|
|
1314
|
+
const githubConnectActionsHtml = connectActionsDiv(
|
|
1315
|
+
[
|
|
1316
|
+
...githubConnectActionConfigs.map((cfg) =>
|
|
1317
|
+
renderConnectAction(envVars, cfg),
|
|
1318
|
+
),
|
|
1319
|
+
renderAddAnotherOrgAction(agent.id, envVars),
|
|
1320
|
+
].filter(Boolean),
|
|
1321
|
+
);
|
|
1310
1322
|
|
|
1311
1323
|
// Top-level rows exclude any cron parented under another (e.g. shipwright-loop's
|
|
1312
1324
|
// dev-task/review/patch/deploy phases) — those render nested beneath their
|
|
@@ -1816,10 +1828,10 @@ export function renderAgentDetailPage(
|
|
|
1816
1828
|
|
|
1817
1829
|
const canManage = opts?.canManage ?? isAdmin;
|
|
1818
1830
|
|
|
1819
|
-
const
|
|
1831
|
+
const slackSection = canManage
|
|
1820
1832
|
? `<div class="card">
|
|
1821
|
-
<div class="card-title">Slack
|
|
1822
|
-
${
|
|
1833
|
+
<div class="card-title">Slack</div>
|
|
1834
|
+
${slackConnectActionsHtml}
|
|
1823
1835
|
<form method="POST" action="/admin/agents/${escapeHtml(agent.id)}/settings">
|
|
1824
1836
|
<div class="form-group" style="display:flex;align-items:center;gap:6px">
|
|
1825
1837
|
<input
|
|
@@ -2049,7 +2061,18 @@ export function renderAgentDetailPage(
|
|
|
2049
2061
|
${identityRow("Federation rule ID", agent.anthropicFederationRuleId, true)}
|
|
2050
2062
|
${showGithubIdentity ? renderGithubUsernameRow(agent.id, agent.githubUsername) : ""}
|
|
2051
2063
|
</tbody></table>
|
|
2052
|
-
</div
|
|
2064
|
+
</div>`;
|
|
2065
|
+
|
|
2066
|
+
// One GitHub card: connect actions plus (admin + enterprise GitHub) the
|
|
2067
|
+
// Preview access and GitHub sync fragments.
|
|
2068
|
+
const githubCardBody = `${githubConnectActionsHtml}${showGithubIdentity ? renderGithubAccessCard(agent.id) : ""}${showGithubIdentity ? renderGithubSyncCard(agent.id, { hasAppId: "GH_APP_ID" in envVars, githubUsername: agent.githubUsername }) : ""}${showGithubIdentity ? renderGithubInstallCard(agent.id) : ""}`;
|
|
2069
|
+
const githubSection =
|
|
2070
|
+
canManage && githubCardBody.trim() !== ""
|
|
2071
|
+
? `<div class="card">
|
|
2072
|
+
<div class="card-title">GitHub</div>
|
|
2073
|
+
${githubCardBody}
|
|
2074
|
+
</div>`
|
|
2075
|
+
: "";
|
|
2053
2076
|
|
|
2054
2077
|
// Only agents with a GitHub App can make API-signed commits. Checked state
|
|
2055
2078
|
// is the SHIPWRIGHT_SIGNED_COMMITS env row; when the box is hidden the field
|
|
@@ -2084,7 +2107,7 @@ export function renderAgentDetailPage(
|
|
|
2084
2107
|
${agent.autoPostReviews ? "checked" : ""}
|
|
2085
2108
|
/>
|
|
2086
2109
|
<!-- Hidden "false" fallback so an unchecked box still submits a
|
|
2087
|
-
value (see the Slack
|
|
2110
|
+
value (see the Slack card's checkbox above for why). -->
|
|
2088
2111
|
<input type="hidden" name="autoPostReviews" value="false" />
|
|
2089
2112
|
<label class="form-label" for="autoPostReviews" style="margin-bottom:0">Auto-post reviews</label>
|
|
2090
2113
|
</div>
|
|
@@ -2233,7 +2256,7 @@ export function renderAgentDetailPage(
|
|
|
2233
2256
|
${dangerZoneSection}`,
|
|
2234
2257
|
automation: cronJobsSection,
|
|
2235
2258
|
configuration: `${templateCard}${envVarsSection}${reposSection}${(opts?.configurationCardsHtml ?? []).join("")}${agentPolicySection}`,
|
|
2236
|
-
access: `${identitySection}${canManage ? membersSection : ""}${authorAllowlistReviewSection}${authorAllowlistPatchSection}${
|
|
2259
|
+
access: `${identitySection}${canManage ? membersSection : ""}${authorAllowlistReviewSection}${authorAllowlistPatchSection}${slackSection}${githubSection}${tokensSection}`,
|
|
2237
2260
|
extensions: `${toolsSection}${pluginsSection}${marketplacesSection}`,
|
|
2238
2261
|
};
|
|
2239
2262
|
|
|
@@ -1176,6 +1176,31 @@ describe("renderAgentDetailPage — connect-later actions", () => {
|
|
|
1176
1176
|
expect(html).not.toContain("Connect Slack<");
|
|
1177
1177
|
});
|
|
1178
1178
|
|
|
1179
|
+
test("GitHub card holds the connect-github forms; Slack card holds connect-slack and the restrict form but no GitHub actions", () => {
|
|
1180
|
+
const html = render({});
|
|
1181
|
+
const slackStart = html.indexOf('<div class="card-title">Slack</div>');
|
|
1182
|
+
const githubStart = html.indexOf('<div class="card-title">GitHub</div>');
|
|
1183
|
+
expect(slackStart).toBeGreaterThan(-1);
|
|
1184
|
+
expect(githubStart).toBeGreaterThan(-1);
|
|
1185
|
+
const cardEnd = (from: number) => {
|
|
1186
|
+
const next = html.indexOf('<div class="card">', from);
|
|
1187
|
+
return next === -1 ? html.length : next;
|
|
1188
|
+
};
|
|
1189
|
+
const slackCard = html.slice(slackStart, cardEnd(slackStart));
|
|
1190
|
+
const githubCard = html.slice(githubStart, cardEnd(githubStart));
|
|
1191
|
+
expect(slackCard).toContain("/connect-slack");
|
|
1192
|
+
expect(slackCard).toContain("Restrict Slack to members");
|
|
1193
|
+
expect(slackCard).not.toContain("connect-github");
|
|
1194
|
+
expect(slackCard).not.toContain("Set up GitHub App");
|
|
1195
|
+
expect(githubCard).toContain("Set up GitHub App");
|
|
1196
|
+
expect(githubCard).toContain("Use existing GitHub App");
|
|
1197
|
+
expect(githubCard).toContain("Add GitHub PAT");
|
|
1198
|
+
expect(githubCard).toContain("/connect-github");
|
|
1199
|
+
expect(githubCard).not.toContain("connect-slack");
|
|
1200
|
+
expect(githubCard).not.toContain("Restrict Slack");
|
|
1201
|
+
expect(html).not.toContain('<div class="card-title">Slack access</div>');
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1179
1204
|
test("Set up GitHub App (auto) action renders githubOrg plus the public-App checkbox", () => {
|
|
1180
1205
|
const html = render({});
|
|
1181
1206
|
const forms = html.match(
|
|
@@ -2291,7 +2316,7 @@ describe("renderAgentDetailPage — sections", () => {
|
|
|
2291
2316
|
expect(html).not.toContain('id="ext-header"');
|
|
2292
2317
|
});
|
|
2293
2318
|
|
|
2294
|
-
test("Access renders identity, members, allowlists,
|
|
2319
|
+
test("Access renders identity, members, allowlists, Slack, GitHub and tokens", () => {
|
|
2295
2320
|
const html = render("access");
|
|
2296
2321
|
expect(html).toContain("Owner & identities");
|
|
2297
2322
|
expect(html).toContain("member@example.com");
|
|
@@ -2302,7 +2327,9 @@ describe("renderAgentDetailPage — sections", () => {
|
|
|
2302
2327
|
expect(html).toContain(
|
|
2303
2328
|
'action="/admin/agents/agent-123/patch-author-allowlist/add"',
|
|
2304
2329
|
);
|
|
2305
|
-
expect(html).toContain('<div class="card-title">Slack
|
|
2330
|
+
expect(html).toContain('<div class="card-title">Slack</div>');
|
|
2331
|
+
expect(html).toContain('<div class="card-title">GitHub</div>');
|
|
2332
|
+
expect(html).not.toContain('<div class="card-title">Slack access</div>');
|
|
2306
2333
|
expect(html).toContain("Task Store Tokens");
|
|
2307
2334
|
expect(html).toContain('action="/admin/agents/agent-123/tokens"');
|
|
2308
2335
|
expect(html).not.toContain('<div class="card-title">Tools</div>');
|
|
@@ -2312,7 +2339,9 @@ describe("renderAgentDetailPage — sections", () => {
|
|
|
2312
2339
|
test("Access hides members and Slack access when canManage is false", () => {
|
|
2313
2340
|
const html = render("access", { canManage: false }, false);
|
|
2314
2341
|
expect(html).not.toContain('action="/admin/agents/agent-123/members"');
|
|
2315
|
-
expect(html).not.toContain('<div class="card-title">Slack
|
|
2342
|
+
expect(html).not.toContain('<div class="card-title">Slack</div>');
|
|
2343
|
+
expect(html).not.toContain('<div class="card-title">GitHub</div>');
|
|
2344
|
+
expect(html).not.toContain("connect-github");
|
|
2316
2345
|
expect(html).toContain("Task Store Tokens");
|
|
2317
2346
|
});
|
|
2318
2347
|
|
|
@@ -4170,14 +4199,14 @@ describe("renderAgentDetailPage — canManage gating (SSP-4.3)", () => {
|
|
|
4170
4199
|
test("non-admin without canManage: no Danger Zone / Slack access / Members cards", () => {
|
|
4171
4200
|
const html = render(false);
|
|
4172
4201
|
expect(html).not.toContain("Danger Zone");
|
|
4173
|
-
expect(html).not.toContain('<div class="card-title">Slack
|
|
4202
|
+
expect(html).not.toContain('<div class="card-title">Slack</div>');
|
|
4174
4203
|
expect(html).not.toContain("/members");
|
|
4175
4204
|
});
|
|
4176
4205
|
|
|
4177
4206
|
test("non-admin with canManage: all three cards render", () => {
|
|
4178
4207
|
const html = render(false, { canManage: true });
|
|
4179
4208
|
expect(html).toContain("Danger Zone");
|
|
4180
|
-
expect(html).toContain('<div class="card-title">Slack
|
|
4209
|
+
expect(html).toContain('<div class="card-title">Slack</div>');
|
|
4181
4210
|
expect(html).toContain(`/admin/agents/${AGENT.id}/members`);
|
|
4182
4211
|
});
|
|
4183
4212
|
|
|
@@ -155,6 +155,32 @@ export function buildSettingsNav(
|
|
|
155
155
|
return mergeSettingsNavItems(base, [...(opts.extraItems ?? [])]);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/** The nav minus the Account item, for a viewer who has no account. */
|
|
159
|
+
export function withoutAccountItem(nav: SettingsNav): SettingsNav {
|
|
160
|
+
return {
|
|
161
|
+
sections: nav.sections.map((sec) => ({
|
|
162
|
+
...sec,
|
|
163
|
+
items: sec.items.filter((i) => i.path !== SETTINGS_ACCOUNT_PATH),
|
|
164
|
+
})),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Request-context key under which the viewer-resolved nav is stored. */
|
|
169
|
+
export const SETTINGS_NAV_CONTEXT_KEY = "settingsNav";
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The viewer-resolved settings nav for the current /admin/* request: every
|
|
173
|
+
* platform item whose route is registered plus all extension-contributed
|
|
174
|
+
* items, with the Account item omitted for a viewer without an account.
|
|
175
|
+
* Lets extension adminUiRoutes handlers render renderSettingsLayout without
|
|
176
|
+
* rebuilding a partial copy of the nav. Undefined outside the admin UI.
|
|
177
|
+
*/
|
|
178
|
+
export function getSettingsNav(c: {
|
|
179
|
+
get(key: string): unknown;
|
|
180
|
+
}): SettingsNav | undefined {
|
|
181
|
+
return c.get(SETTINGS_NAV_CONTEXT_KEY) as SettingsNav | undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
158
184
|
/** First nav item visible to the viewer, or undefined. */
|
|
159
185
|
export function firstVisibleSettingsItem(
|
|
160
186
|
nav: SettingsNav,
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/admin-ui-settings-nav-context.smoke.test.ts
|
|
3
|
+
* An extension adminUiRoutes handler receives the viewer-resolved settings nav
|
|
4
|
+
* via getSettingsNav(c), mounted exactly as admin-boot does (after the UI app).
|
|
5
|
+
* Contract: each flag-gated platform item is present iff its route is
|
|
6
|
+
* registered.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, expect, it } from "bun:test";
|
|
10
|
+
import { Hono } from "hono";
|
|
11
|
+
import { mountRouteContributions } from "./admin-extension.ts";
|
|
12
|
+
import { makeMockDeps, makeSessionCookie } from "./admin-ui.fixtures.ts";
|
|
13
|
+
import { createAdminUIApp } from "./admin-ui.ts";
|
|
14
|
+
import {
|
|
15
|
+
getSettingsNav,
|
|
16
|
+
SETTINGS_ACCOUNT_PATH,
|
|
17
|
+
SETTINGS_ACCOUNTS_PATH,
|
|
18
|
+
SETTINGS_GHE_PATH,
|
|
19
|
+
SETTINGS_TEMPLATES_PATH,
|
|
20
|
+
type SettingsNav,
|
|
21
|
+
} from "./admin-ui-settings-layout.ts";
|
|
22
|
+
|
|
23
|
+
const ghe = async () =>
|
|
24
|
+
new Response(
|
|
25
|
+
JSON.stringify({ configured: false, installer: null, lookup: null }),
|
|
26
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
27
|
+
);
|
|
28
|
+
const templateService = {
|
|
29
|
+
list: async () => [],
|
|
30
|
+
replace: async () => {
|
|
31
|
+
throw new Error("unused");
|
|
32
|
+
},
|
|
33
|
+
putItem: async () => {
|
|
34
|
+
throw new Error("unused");
|
|
35
|
+
},
|
|
36
|
+
deleteItem: async () => {},
|
|
37
|
+
delete: async () => {},
|
|
38
|
+
} as never;
|
|
39
|
+
const accountServices = (member: string | null) =>
|
|
40
|
+
({
|
|
41
|
+
accounts: {
|
|
42
|
+
getByMemberEmail: async (e: string) =>
|
|
43
|
+
e === member ? ({ id: "acct-1", name: "Acme" } as never) : null,
|
|
44
|
+
listWithCounts: async () => [],
|
|
45
|
+
getWithCounts: async (id: string) => ({ id, name: "Acme" }),
|
|
46
|
+
},
|
|
47
|
+
members: {},
|
|
48
|
+
}) as never;
|
|
49
|
+
const selfServe = {
|
|
50
|
+
enabled: true,
|
|
51
|
+
contactEmail: "c@x.com",
|
|
52
|
+
defaultMaxAgents: 1,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const adminCookie = async () => `admin_session=${await makeSessionCookie()}`;
|
|
56
|
+
|
|
57
|
+
/** Reads the nav from inside an extension route; returns it as JSON. */
|
|
58
|
+
async function navSeenByExtension(
|
|
59
|
+
deps: Parameters<typeof makeMockDeps>[0],
|
|
60
|
+
cookie: string,
|
|
61
|
+
): Promise<SettingsNav | undefined> {
|
|
62
|
+
const root = new Hono();
|
|
63
|
+
root.route("/", createAdminUIApp(makeMockDeps(deps)));
|
|
64
|
+
const ext = new Hono();
|
|
65
|
+
ext.get("/", (c) => c.json(getSettingsNav(c) ?? null));
|
|
66
|
+
mountRouteContributions(root, [{ path: "/admin/ext-page", app: ext }]);
|
|
67
|
+
const res = await root.request("/admin/ext-page", { headers: { cookie } });
|
|
68
|
+
expect(res.status).toBe(200);
|
|
69
|
+
return ((await res.json()) as SettingsNav | null) ?? undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const paths = (nav: SettingsNav | undefined) =>
|
|
73
|
+
(nav?.sections ?? []).flatMap((s) => s.items.map((i) => i.path));
|
|
74
|
+
|
|
75
|
+
describe("getSettingsNav in extension adminUiRoutes", () => {
|
|
76
|
+
it("hands the extension the full nav incl. extension-contributed items", async () => {
|
|
77
|
+
const nav = await navSeenByExtension(
|
|
78
|
+
{
|
|
79
|
+
githubEnterpriseApi: ghe,
|
|
80
|
+
templateService,
|
|
81
|
+
selfServe,
|
|
82
|
+
accountServices: accountServices("admin@example.com"),
|
|
83
|
+
settingsNavItems: [
|
|
84
|
+
{ section: "Platform", label: "Ext", path: "/admin/ext-page" },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
await adminCookie(),
|
|
88
|
+
);
|
|
89
|
+
expect(paths(nav)).toEqual([
|
|
90
|
+
SETTINGS_ACCOUNT_PATH,
|
|
91
|
+
SETTINGS_GHE_PATH,
|
|
92
|
+
SETTINGS_TEMPLATES_PATH,
|
|
93
|
+
SETTINGS_ACCOUNTS_PATH,
|
|
94
|
+
"/admin/ext-page",
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("omits the Account item for a viewer with no account", async () => {
|
|
99
|
+
const nav = await navSeenByExtension(
|
|
100
|
+
{ templateService, selfServe, accountServices: accountServices(null) },
|
|
101
|
+
await adminCookie(),
|
|
102
|
+
);
|
|
103
|
+
expect(paths(nav)).not.toContain(SETTINGS_ACCOUNT_PATH);
|
|
104
|
+
expect(paths(nav)).toContain(SETTINGS_ACCOUNTS_PATH);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("is undefined outside the admin UI app", async () => {
|
|
108
|
+
const app = new Hono();
|
|
109
|
+
app.get("/", (c) => c.json(getSettingsNav(c) ?? null));
|
|
110
|
+
expect(await (await app.request("/")).json()).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("contract: nav item present iff its route is registered", () => {
|
|
115
|
+
const cases: Array<{
|
|
116
|
+
name: string;
|
|
117
|
+
deps: Parameters<typeof makeMockDeps>[0];
|
|
118
|
+
path: string;
|
|
119
|
+
present: boolean;
|
|
120
|
+
}> = [
|
|
121
|
+
{
|
|
122
|
+
name: "GHE on",
|
|
123
|
+
deps: { githubEnterpriseApi: ghe },
|
|
124
|
+
path: SETTINGS_GHE_PATH,
|
|
125
|
+
present: true,
|
|
126
|
+
},
|
|
127
|
+
{ name: "GHE off", deps: {}, path: SETTINGS_GHE_PATH, present: false },
|
|
128
|
+
{
|
|
129
|
+
name: "Templates on",
|
|
130
|
+
deps: { templateService },
|
|
131
|
+
path: SETTINGS_TEMPLATES_PATH,
|
|
132
|
+
present: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "Templates off",
|
|
136
|
+
deps: {},
|
|
137
|
+
path: SETTINGS_TEMPLATES_PATH,
|
|
138
|
+
present: false,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "Accounts on",
|
|
142
|
+
deps: {
|
|
143
|
+
selfServe,
|
|
144
|
+
accountServices: accountServices("admin@example.com"),
|
|
145
|
+
},
|
|
146
|
+
path: SETTINGS_ACCOUNTS_PATH,
|
|
147
|
+
present: true,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "Accounts off",
|
|
151
|
+
deps: {},
|
|
152
|
+
path: SETTINGS_ACCOUNTS_PATH,
|
|
153
|
+
present: false,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
for (const { name, deps, path, present } of cases) {
|
|
157
|
+
it(`${name}: ${path} ${present ? "present" : "absent"} and route ${present ? "registered" : "404"}`, async () => {
|
|
158
|
+
const cookie = await adminCookie();
|
|
159
|
+
const nav = await navSeenByExtension(deps, cookie);
|
|
160
|
+
expect(paths(nav).includes(path)).toBe(present);
|
|
161
|
+
const app = createAdminUIApp(makeMockDeps(deps));
|
|
162
|
+
const res = await app.request(path, { headers: { cookie } });
|
|
163
|
+
expect(res.status === 404).toBe(!present);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
@@ -1044,6 +1044,21 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1044
1044
|
expect(
|
|
1045
1045
|
html.split(`/admin/agents/${AGENT_ID}/connect-github`).length - 1,
|
|
1046
1046
|
).toBeGreaterThanOrEqual(2);
|
|
1047
|
+
|
|
1048
|
+
// Slack and GitHub connect actions live in separate cards.
|
|
1049
|
+
const slackStart = html.indexOf('<div class="card-title">Slack</div>');
|
|
1050
|
+
const githubStart = html.indexOf('<div class="card-title">GitHub</div>');
|
|
1051
|
+
expect(slackStart).toBeGreaterThan(-1);
|
|
1052
|
+
expect(githubStart).toBeGreaterThan(-1);
|
|
1053
|
+
expect(html).not.toContain('<div class="card-title">Slack access</div>');
|
|
1054
|
+
const slackEnd = html.indexOf('<div class="card">', slackStart);
|
|
1055
|
+
const slackCard = html.slice(
|
|
1056
|
+
slackStart,
|
|
1057
|
+
slackEnd === -1 ? html.length : slackEnd,
|
|
1058
|
+
);
|
|
1059
|
+
expect(slackCard).toContain("/connect-slack");
|
|
1060
|
+
expect(slackCard).not.toContain("/connect-github");
|
|
1061
|
+
expect(html.indexOf("/connect-github", githubStart)).toBeGreaterThan(-1);
|
|
1047
1062
|
});
|
|
1048
1063
|
|
|
1049
1064
|
it("SLACK_APP_TOKEN present: hides Connect Slack but still shows the GitHub actions", async () => {
|
|
@@ -1262,7 +1277,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1262
1277
|
expect(slackBlock).toContain('name="xoxpToken"');
|
|
1263
1278
|
});
|
|
1264
1279
|
|
|
1265
|
-
it("non-admin member viewer does not see the connect-later actions (Slack
|
|
1280
|
+
it("non-admin member viewer does not see the connect-later actions (Slack and GitHub cards are admin-only)", async () => {
|
|
1266
1281
|
const MEMBER_EMAIL = "member@example.com";
|
|
1267
1282
|
const memberCookie = await makeSessionCookie(
|
|
1268
1283
|
SESSION_SECRET,
|
|
@@ -2557,7 +2572,7 @@ describe("admin UI — agent policy fields", () => {
|
|
|
2557
2572
|
);
|
|
2558
2573
|
// Mirrors the Agent Policy card's <form> — it has no
|
|
2559
2574
|
// restrictSlackToMembers input at all (that field lives in the separate
|
|
2560
|
-
// Slack
|
|
2575
|
+
// Slack card/form).
|
|
2561
2576
|
const body = new URLSearchParams({
|
|
2562
2577
|
autoPostReviews: "true",
|
|
2563
2578
|
minConfidence: "80",
|
|
@@ -7787,7 +7802,7 @@ describe("admin UI — self-serve agent management (SSP-4.3)", () => {
|
|
|
7787
7802
|
[true, true],
|
|
7788
7803
|
[false, false],
|
|
7789
7804
|
] as const) {
|
|
7790
|
-
it(`agent detail for an access holder ${shown ? "renders" : "hides"} Danger Zone / Slack
|
|
7805
|
+
it(`agent detail for an access holder ${shown ? "renders" : "hides"} Danger Zone / Slack / Members cards when flag is ${enabled ? "on" : "off"}`, async () => {
|
|
7791
7806
|
const cookie = await holderCookie();
|
|
7792
7807
|
const app = createAdminUIApp(
|
|
7793
7808
|
makeMockDeps({
|
|
@@ -7804,7 +7819,7 @@ describe("admin UI — self-serve agent management (SSP-4.3)", () => {
|
|
|
7804
7819
|
expect(accessRes.status).toBe(200);
|
|
7805
7820
|
const html = `${await res.text()}${await accessRes.text()}`;
|
|
7806
7821
|
expect(html.includes("Danger Zone")).toBe(shown);
|
|
7807
|
-
expect(html.includes('<div class="card-title">Slack
|
|
7822
|
+
expect(html.includes('<div class="card-title">Slack</div>')).toBe(
|
|
7808
7823
|
shown,
|
|
7809
7824
|
);
|
|
7810
7825
|
expect(html.includes(`/admin/agents/${AGENT_ID}/members`)).toBe(shown);
|
package/src/admin-ui.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* Allowed users are controlled by the adminAllowedEmails allowlist in deps.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import type { GheOrgs } from "./admin-ui-github-enterprise-pages.ts";
|
|
25
26
|
import { join } from "node:path";
|
|
26
27
|
import { isGithubLogin } from "@app-vitals/agent-lib/github-login";
|
|
27
28
|
import { isOrgRepo } from "@app-vitals/agent-lib/org-repo";
|
|
@@ -42,26 +43,19 @@ import type { AccountOnboardingService } from "./account-onboarding.ts";
|
|
|
42
43
|
import type { AccountService } from "./accounts.ts";
|
|
43
44
|
import {
|
|
44
45
|
type AgentDetailCardSlot,
|
|
45
|
-
type SettingsNavContribution,
|
|
46
46
|
renderAgentDetailCardSlots,
|
|
47
|
+
type SettingsNavContribution,
|
|
47
48
|
} from "./admin-extension.ts";
|
|
48
49
|
import { registerAccountRoutes } from "./admin-ui-account.ts";
|
|
49
50
|
import { runWithSettingsNav } from "./admin-ui-account-nav.ts";
|
|
50
51
|
import { renderZeroQuotaNotice } from "./admin-ui-account-pages.ts";
|
|
51
52
|
import { registerAdminAccountsRoutes } from "./admin-ui-accounts.ts";
|
|
52
|
-
import {
|
|
53
|
-
buildSettingsNav,
|
|
54
|
-
firstVisibleSettingsItem,
|
|
55
|
-
SETTINGS_ACCOUNT_PATH,
|
|
56
|
-
} from "./admin-ui-settings-layout.ts";
|
|
57
53
|
import { registerAdminGithubEnterpriseRoutes } from "./admin-ui-github-enterprise.ts";
|
|
58
|
-
import { registerAdminTemplatesRoutes } from "./admin-ui-templates.ts";
|
|
59
|
-
import type { AgentTemplateReconcileService } from "./agent-template-reconcile.ts";
|
|
60
|
-
import type { AgentTemplateService } from "./agent-templates.ts";
|
|
61
54
|
import {
|
|
62
55
|
type GithubAccessPreviewView,
|
|
63
56
|
renderGithubAccessError,
|
|
64
57
|
renderGithubAccessResult,
|
|
58
|
+
renderGithubOrgsFragment,
|
|
65
59
|
} from "./admin-ui-github-identity-pages.ts";
|
|
66
60
|
import {
|
|
67
61
|
actuallyBlockedWork,
|
|
@@ -84,7 +78,7 @@ import {
|
|
|
84
78
|
type AgentSection,
|
|
85
79
|
agentSectionPath,
|
|
86
80
|
isAgentSection,
|
|
87
|
-
|
|
81
|
+
type NewAgentTemplateItem,
|
|
88
82
|
renderAgentDetailPage,
|
|
89
83
|
renderAgentsPage,
|
|
90
84
|
renderChatMessageBubble,
|
|
@@ -94,11 +88,19 @@ import {
|
|
|
94
88
|
renderGithubAppInstallPage,
|
|
95
89
|
renderGithubAppManifestRedirectPage,
|
|
96
90
|
renderLoginPage,
|
|
97
|
-
type NewAgentTemplateItem,
|
|
98
91
|
renderNewLocalAgentPage,
|
|
99
92
|
renderProvisionCompletePage,
|
|
100
93
|
renderProvisionXappTokenPage,
|
|
94
|
+
settingsRedirectSection,
|
|
101
95
|
} from "./admin-ui-pages.ts";
|
|
96
|
+
import {
|
|
97
|
+
buildSettingsNav,
|
|
98
|
+
firstVisibleSettingsItem,
|
|
99
|
+
SETTINGS_NAV_CONTEXT_KEY,
|
|
100
|
+
type SettingsNav,
|
|
101
|
+
withoutAccountItem,
|
|
102
|
+
} from "./admin-ui-settings-layout.ts";
|
|
103
|
+
import { registerAdminTemplatesRoutes } from "./admin-ui-templates.ts";
|
|
102
104
|
import type { AgentCronJobService } from "./agent-cron-jobs.ts";
|
|
103
105
|
import type { DeleteAgentFullyDeps } from "./agent-deletion.ts";
|
|
104
106
|
import { deleteAgentFully } from "./agent-deletion.ts";
|
|
@@ -108,6 +110,8 @@ import type { AgentMarketplaceService } from "./agent-marketplaces.ts";
|
|
|
108
110
|
import type { AgentMemberService } from "./agent-members.ts";
|
|
109
111
|
import type { AgentPluginService } from "./agent-plugins.ts";
|
|
110
112
|
import type { AgentProvisioner } from "./agent-provisioner.ts";
|
|
113
|
+
import type { AgentTemplateReconcileService } from "./agent-template-reconcile.ts";
|
|
114
|
+
import type { AgentTemplateService } from "./agent-templates.ts";
|
|
111
115
|
import type { AgentTokenService } from "./agent-tokens.ts";
|
|
112
116
|
import type { AgentToolService } from "./agent-tools.ts";
|
|
113
117
|
import type { AgentService } from "./agents.ts";
|
|
@@ -169,7 +173,13 @@ import {
|
|
|
169
173
|
SpecialtyTypes,
|
|
170
174
|
} from "./specialty-types.ts";
|
|
171
175
|
|
|
172
|
-
export type AdminUIEnv = {
|
|
176
|
+
export type AdminUIEnv = {
|
|
177
|
+
Variables: {
|
|
178
|
+
userEmail: string;
|
|
179
|
+
isAdmin: boolean;
|
|
180
|
+
settingsNav?: SettingsNav;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
173
183
|
|
|
174
184
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
175
185
|
|
|
@@ -949,6 +959,31 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
949
959
|
|
|
950
960
|
const accountNavEnabled = Boolean(selfServe?.enabled && accountServices);
|
|
951
961
|
|
|
962
|
+
const settingsNav = buildSettingsNav({
|
|
963
|
+
githubEnterprise: Boolean(githubEnterpriseApi),
|
|
964
|
+
templates: Boolean(templateService),
|
|
965
|
+
accounts: accountNavEnabled,
|
|
966
|
+
extraItems: deps.settingsNavItems ?? [],
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
// Expose the viewer-resolved nav to every /admin/* handler registered after
|
|
970
|
+
// this point, including extension adminUiRoutes (mounted after this app).
|
|
971
|
+
app.use("/admin/*", async (c, next) => {
|
|
972
|
+
let nav = settingsNav;
|
|
973
|
+
if (accountNavEnabled && accountServices) {
|
|
974
|
+
const token = getCookie(c, SESSION_COOKIE);
|
|
975
|
+
const user = token ? await getSessionUser(token, sessionSecret) : null;
|
|
976
|
+
if (user) {
|
|
977
|
+
const account = await accountServices.accounts
|
|
978
|
+
.getByMemberEmail(user.email)
|
|
979
|
+
.catch(() => null);
|
|
980
|
+
if (!account) nav = withoutAccountItem(settingsNav);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
c.set(SETTINGS_NAV_CONTEXT_KEY, nav);
|
|
984
|
+
await next();
|
|
985
|
+
});
|
|
986
|
+
|
|
952
987
|
// GHE-1.4: the admin-only "Settings" toolbar entry.
|
|
953
988
|
// SGL-2.2: shown to admins and to account members.
|
|
954
989
|
if (githubEnterpriseApi || templateService || accountNavEnabled) {
|
|
@@ -2025,6 +2060,81 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2025
2060
|
);
|
|
2026
2061
|
});
|
|
2027
2062
|
|
|
2063
|
+
// GHC-1.2: Install on org block on the agent's GitHub card. Both routes
|
|
2064
|
+
// call the GHE-1.3 API with the agent implicit (the route's :id).
|
|
2065
|
+
const gheError = async (res: Response | null, fallback: string) => {
|
|
2066
|
+
try {
|
|
2067
|
+
const j = (await res?.json()) as { error?: unknown };
|
|
2068
|
+
if (typeof j.error === "string" && j.error) return j.error;
|
|
2069
|
+
} catch {
|
|
2070
|
+
// keep the fallback
|
|
2071
|
+
}
|
|
2072
|
+
return fallback;
|
|
2073
|
+
};
|
|
2074
|
+
|
|
2075
|
+
app.get("/admin/agents/:id/github-orgs", requireAuth, async (c) => {
|
|
2076
|
+
const agentId = c.req.param("id");
|
|
2077
|
+
if (!c.var.isAdmin || !githubEnterpriseApi) {
|
|
2078
|
+
return new Response("Forbidden", { status: 403 });
|
|
2079
|
+
}
|
|
2080
|
+
const res = await callApi(
|
|
2081
|
+
c,
|
|
2082
|
+
githubEnterpriseApi,
|
|
2083
|
+
`/github-enterprise/orgs?agentId=${encodeURIComponent(agentId)}`,
|
|
2084
|
+
);
|
|
2085
|
+
if (!res?.ok) {
|
|
2086
|
+
return html(
|
|
2087
|
+
renderGithubAccessError(
|
|
2088
|
+
await gheError(res, "Could not load the organizations."),
|
|
2089
|
+
),
|
|
2090
|
+
{ status: res && res.status >= 400 ? res.status : 502 },
|
|
2091
|
+
);
|
|
2092
|
+
}
|
|
2093
|
+
return html(
|
|
2094
|
+
renderGithubOrgsFragment(agentId, (await res.json()) as GheOrgs),
|
|
2095
|
+
);
|
|
2096
|
+
});
|
|
2097
|
+
|
|
2098
|
+
app.post(
|
|
2099
|
+
"/admin/agents/:id/github-orgs/:org/install",
|
|
2100
|
+
requireAuth,
|
|
2101
|
+
async (c) => {
|
|
2102
|
+
const agentId = c.req.param("id");
|
|
2103
|
+
if (!c.var.isAdmin || !githubEnterpriseApi) {
|
|
2104
|
+
return new Response("Forbidden", { status: 403 });
|
|
2105
|
+
}
|
|
2106
|
+
const res = await callApi(
|
|
2107
|
+
c,
|
|
2108
|
+
githubEnterpriseApi,
|
|
2109
|
+
`/github-enterprise/orgs/${encodeURIComponent(c.req.param("org"))}/install`,
|
|
2110
|
+
{
|
|
2111
|
+
method: "POST",
|
|
2112
|
+
headers: { "content-type": "application/json" },
|
|
2113
|
+
body: JSON.stringify({ agentId }),
|
|
2114
|
+
},
|
|
2115
|
+
);
|
|
2116
|
+
if (!res?.ok) {
|
|
2117
|
+
return c.redirect(
|
|
2118
|
+
agentSectionPath(agentId, "access", {
|
|
2119
|
+
error: await gheError(res, "Could not install the agent app."),
|
|
2120
|
+
}),
|
|
2121
|
+
302,
|
|
2122
|
+
);
|
|
2123
|
+
}
|
|
2124
|
+
let created = true;
|
|
2125
|
+
try {
|
|
2126
|
+
created =
|
|
2127
|
+
((await res.json()) as { created?: boolean }).created !== false;
|
|
2128
|
+
} catch {
|
|
2129
|
+
// treat as created
|
|
2130
|
+
}
|
|
2131
|
+
return c.redirect(
|
|
2132
|
+
`${agentSectionPath(agentId, "access")}?success=${created ? "github_app_installed" : "github_app_already_installed"}`,
|
|
2133
|
+
302,
|
|
2134
|
+
);
|
|
2135
|
+
},
|
|
2136
|
+
);
|
|
2137
|
+
|
|
2028
2138
|
// IRM-1.4: thin proxies over the installation repos list (IRM-1.2) and
|
|
2029
2139
|
// the repo-removal preview (IRM-1.7).
|
|
2030
2140
|
// They return HTML fragments for the Installation repos card and the agent's
|
|
@@ -2313,7 +2423,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2313
2423
|
? "GitHub username saved."
|
|
2314
2424
|
: successParam === "github_username_cleared"
|
|
2315
2425
|
? "GitHub username cleared."
|
|
2316
|
-
:
|
|
2426
|
+
: successParam === "github_app_installed"
|
|
2427
|
+
? "Agent app installed."
|
|
2428
|
+
: successParam === "github_app_already_installed"
|
|
2429
|
+
? "The agent app was already installed on that organization."
|
|
2430
|
+
: undefined;
|
|
2317
2431
|
const warningParam = c.req.query("warning");
|
|
2318
2432
|
const warning =
|
|
2319
2433
|
warningParam === "restrict_slack_no_members"
|
|
@@ -3951,13 +4065,6 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3951
4065
|
|
|
3952
4066
|
// ─── Enterprise GitHub apps settings (GHE-1.4) ───────────────────────────
|
|
3953
4067
|
|
|
3954
|
-
const settingsNav = buildSettingsNav({
|
|
3955
|
-
githubEnterprise: Boolean(githubEnterpriseApi),
|
|
3956
|
-
templates: Boolean(templateService),
|
|
3957
|
-
accounts: accountNavEnabled,
|
|
3958
|
-
extraItems: deps.settingsNavItems ?? [],
|
|
3959
|
-
});
|
|
3960
|
-
|
|
3961
4068
|
// SGL-2.2: /admin/settings lands on the first nav item the viewer can see.
|
|
3962
4069
|
if (githubEnterpriseApi || templateService || accountNavEnabled) {
|
|
3963
4070
|
app.get("/admin/settings", requireAuth, async (c) => {
|
|
@@ -3967,14 +4074,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3967
4074
|
const account = await accountServices.accounts
|
|
3968
4075
|
.getByMemberEmail(c.var.userEmail)
|
|
3969
4076
|
.catch(() => null);
|
|
3970
|
-
if (!account)
|
|
3971
|
-
nav = {
|
|
3972
|
-
sections: settingsNav.sections.map((sec) => ({
|
|
3973
|
-
...sec,
|
|
3974
|
-
items: sec.items.filter((i) => i.path !== SETTINGS_ACCOUNT_PATH),
|
|
3975
|
-
})),
|
|
3976
|
-
};
|
|
3977
|
-
}
|
|
4077
|
+
if (!account) nav = withoutAccountItem(settingsNav);
|
|
3978
4078
|
}
|
|
3979
4079
|
const first = firstVisibleSettingsItem(nav, c.var.isAdmin === true);
|
|
3980
4080
|
if (!first) {
|
package/src/server.ts
CHANGED
|
@@ -8,58 +8,59 @@
|
|
|
8
8
|
* - Agent runtime API at /agents/* (JSON, internal)
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { PrismaClient } from "../prisma/client/client.ts";
|
|
12
|
+
export type {
|
|
13
|
+
AdminExtension,
|
|
14
|
+
AdminExtensionContext,
|
|
15
|
+
SettingsNavContribution,
|
|
16
|
+
} from "./admin-extension.ts";
|
|
12
17
|
export type { AdminUIDeps } from "./admin-ui.ts";
|
|
13
|
-
export {
|
|
14
|
-
export type { AdminDeps } from "./agents-api.ts";
|
|
15
|
-
export { createAgentRuntimeApp } from "./api.ts";
|
|
18
|
+
export { createAdminUIApp } from "./admin-ui.ts";
|
|
16
19
|
export type {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
20
|
+
RenderSettingsLayoutOptions,
|
|
21
|
+
SettingsNav,
|
|
22
|
+
SettingsNavItem,
|
|
23
|
+
SettingsNavSection,
|
|
24
|
+
} from "./admin-ui-settings-layout.ts";
|
|
25
|
+
export {
|
|
26
|
+
getSettingsNav,
|
|
27
|
+
mergeSettingsNavItems,
|
|
28
|
+
renderSettingsLayout,
|
|
29
|
+
} from "./admin-ui-settings-layout.ts";
|
|
24
30
|
export type {
|
|
25
31
|
AgentCronJob,
|
|
26
32
|
CreateAgentCronJobInput,
|
|
27
33
|
} from "./agent-cron-jobs.ts";
|
|
28
|
-
export {
|
|
29
|
-
export type {
|
|
30
|
-
export {
|
|
31
|
-
export type { AgentToken, AgentTokenValidated } from "./agent-tokens.ts";
|
|
32
|
-
export { AgentPluginService } from "./agent-plugins.ts";
|
|
34
|
+
export { AgentCronJobService } from "./agent-cron-jobs.ts";
|
|
35
|
+
export type { AgentEnvBundle, AgentEnvEntry } from "./agent-envs.ts";
|
|
36
|
+
export { AgentEnvService } from "./agent-envs.ts";
|
|
33
37
|
export type { AgentPlugin as AgentPluginRecord } from "./agent-plugins.ts";
|
|
34
|
-
export {
|
|
35
|
-
export type {
|
|
38
|
+
export { AgentPluginService } from "./agent-plugins.ts";
|
|
39
|
+
export type { AgentToken, AgentTokenValidated } from "./agent-tokens.ts";
|
|
40
|
+
export { AgentTokenService } from "./agent-tokens.ts";
|
|
41
|
+
export type { AgentTool } from "./agent-tools.ts";
|
|
42
|
+
export { AgentToolService } from "./agent-tools.ts";
|
|
43
|
+
export type { AdminDeps } from "./agents-api.ts";
|
|
44
|
+
export { createAdminApp } from "./agents-api.ts";
|
|
45
|
+
export type {
|
|
46
|
+
AgentConfigResponse,
|
|
47
|
+
AgentPlugin,
|
|
48
|
+
AgentRuntimeDeps,
|
|
49
|
+
} from "./api.ts";
|
|
50
|
+
export { createAgentRuntimeApp } from "./api.ts";
|
|
36
51
|
export {
|
|
37
52
|
ApiError,
|
|
38
|
-
|
|
39
|
-
ConflictError,
|
|
53
|
+
BadGatewayError,
|
|
40
54
|
BadRequestError,
|
|
55
|
+
ConflictError,
|
|
41
56
|
ForbiddenError,
|
|
57
|
+
NotFoundError,
|
|
42
58
|
UnprocessableEntityError,
|
|
43
|
-
BadGatewayError,
|
|
44
59
|
} from "./errors.ts";
|
|
45
|
-
export { HttpSlackProvisioningClient } from "./slack-provisioning-client.ts";
|
|
46
|
-
export type { SlackProvisioningClient } from "./slack-provisioning-client.ts";
|
|
47
|
-
export { HttpGoogleAuthClient } from "./google-auth-client.ts";
|
|
48
60
|
export type { GoogleAuthClient } from "./google-auth-client.ts";
|
|
49
|
-
export {
|
|
61
|
+
export { HttpGoogleAuthClient } from "./google-auth-client.ts";
|
|
50
62
|
export { createAdminPrismaClient } from "./prisma-client.ts";
|
|
51
|
-
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} from "./
|
|
55
|
-
export type {
|
|
56
|
-
SettingsNav,
|
|
57
|
-
SettingsNavItem,
|
|
58
|
-
SettingsNavSection,
|
|
59
|
-
RenderSettingsLayoutOptions,
|
|
60
|
-
} from "./admin-ui-settings-layout.ts";
|
|
61
|
-
export type {
|
|
62
|
-
AdminExtension,
|
|
63
|
-
AdminExtensionContext,
|
|
64
|
-
SettingsNavContribution,
|
|
65
|
-
} from "./admin-extension.ts";
|
|
63
|
+
export type { SlackProvisioningClient } from "./slack-provisioning-client.ts";
|
|
64
|
+
export { HttpSlackProvisioningClient } from "./slack-provisioning-client.ts";
|
|
65
|
+
export type { TokenCrypto } from "./token-crypto.ts";
|
|
66
|
+
export { identityCrypto, makeTokenCrypto } from "./token-crypto.ts";
|