@app-vitals/agent-admin 1.49.0 → 1.51.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/e2e/agents-page.e2e.ts +61 -21
- package/e2e/marketplaces-section.e2e.ts +5 -24
- package/e2e/plugins-section.e2e.ts +6 -27
- package/package.json +2 -2
- package/src/admin-ui-account-nav.ts +3 -14
- package/src/admin-ui-account-nav.unit.test.ts +5 -14
- package/src/admin-ui-account-pages.ts +21 -10
- package/src/admin-ui-account-pages.unit.test.ts +12 -12
- package/src/admin-ui-account.smoke.test.ts +4 -0
- package/src/admin-ui-account.ts +5 -0
- package/src/admin-ui-accounts-pages.ts +36 -16
- package/src/admin-ui-accounts-pages.unit.test.ts +29 -0
- package/src/admin-ui-accounts.smoke.test.ts +2 -0
- package/src/admin-ui-accounts.ts +10 -1
- package/src/admin-ui-agent-sections.unit.test.ts +95 -0
- package/src/admin-ui-agent-template.smoke.test.ts +22 -16
- package/src/admin-ui-github-identity-pages.unit.test.ts +22 -1
- package/src/admin-ui-github-identity.smoke.test.ts +1 -1
- package/src/admin-ui-installation-repos.smoke.test.ts +7 -7
- package/src/admin-ui-pages.ts +137 -110
- package/src/admin-ui-pages.unit.test.ts +166 -225
- package/src/admin-ui-settings-layout.ts +24 -6
- package/src/admin-ui-settings.smoke.test.ts +28 -0
- package/src/admin-ui-styles.ts +1 -70
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +211 -131
package/src/admin-ui.ts
CHANGED
|
@@ -46,15 +46,13 @@ import {
|
|
|
46
46
|
renderAgentDetailCardSlots,
|
|
47
47
|
} from "./admin-extension.ts";
|
|
48
48
|
import { registerAccountRoutes } from "./admin-ui-account.ts";
|
|
49
|
-
import {
|
|
50
|
-
runWithAccountNav,
|
|
51
|
-
runWithSettingsNav,
|
|
52
|
-
} from "./admin-ui-account-nav.ts";
|
|
49
|
+
import { runWithSettingsNav } from "./admin-ui-account-nav.ts";
|
|
53
50
|
import { renderZeroQuotaNotice } from "./admin-ui-account-pages.ts";
|
|
54
51
|
import { registerAdminAccountsRoutes } from "./admin-ui-accounts.ts";
|
|
55
52
|
import {
|
|
56
53
|
buildSettingsNav,
|
|
57
54
|
firstVisibleSettingsItem,
|
|
55
|
+
SETTINGS_ACCOUNT_PATH,
|
|
58
56
|
} from "./admin-ui-settings-layout.ts";
|
|
59
57
|
import { registerAdminGithubEnterpriseRoutes } from "./admin-ui-github-enterprise.ts";
|
|
60
58
|
import { registerAdminTemplatesRoutes } from "./admin-ui-templates.ts";
|
|
@@ -74,14 +72,19 @@ import {
|
|
|
74
72
|
type RepoRemovalPreviewView,
|
|
75
73
|
renderInstallationReposBody,
|
|
76
74
|
renderInstallationReposError,
|
|
77
|
-
renderSyncConfirm,
|
|
78
|
-
renderSyncResult,
|
|
79
75
|
renderRepoRemovalConfirm,
|
|
80
76
|
renderRepoRemovalResult,
|
|
77
|
+
renderSyncConfirm,
|
|
78
|
+
renderSyncResult,
|
|
81
79
|
} from "./admin-ui-installation-repos-pages.ts";
|
|
82
80
|
import {
|
|
81
|
+
AGENT_SECTIONS,
|
|
83
82
|
type AgentDetail,
|
|
84
83
|
type AgentOption,
|
|
84
|
+
type AgentSection,
|
|
85
|
+
agentSectionPath,
|
|
86
|
+
isAgentSection,
|
|
87
|
+
settingsRedirectSection,
|
|
85
88
|
renderAgentDetailPage,
|
|
86
89
|
renderAgentsPage,
|
|
87
90
|
renderChatMessageBubble,
|
|
@@ -739,17 +742,20 @@ async function redirectWithMembersWarning(
|
|
|
739
742
|
agentMemberService: Pick<AgentMemberService, "listByAgentId">,
|
|
740
743
|
agentId: string,
|
|
741
744
|
restrictSlackToMembers: boolean,
|
|
745
|
+
section: AgentSection,
|
|
742
746
|
) {
|
|
743
747
|
if (restrictSlackToMembers) {
|
|
744
748
|
const members = await agentMemberService.listByAgentId(agentId);
|
|
745
749
|
if (members.length === 0) {
|
|
746
750
|
return c.redirect(
|
|
747
|
-
|
|
751
|
+
agentSectionPath(agentId, section, {
|
|
752
|
+
warning: "restrict_slack_no_members",
|
|
753
|
+
}),
|
|
748
754
|
302,
|
|
749
755
|
);
|
|
750
756
|
}
|
|
751
757
|
}
|
|
752
|
-
return c.redirect(
|
|
758
|
+
return c.redirect(agentSectionPath(agentId, section), 302);
|
|
753
759
|
}
|
|
754
760
|
|
|
755
761
|
// ─── HTML helper ──────────────────────────────────────────────────────────────
|
|
@@ -941,10 +947,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
941
947
|
devAuthEnabled,
|
|
942
948
|
});
|
|
943
949
|
|
|
944
|
-
|
|
945
|
-
|
|
950
|
+
const accountNavEnabled = Boolean(selfServe?.enabled && accountServices);
|
|
951
|
+
|
|
952
|
+
// GHE-1.4: the admin-only "Settings" toolbar entry.
|
|
946
953
|
// SGL-2.2: shown to admins and to account members.
|
|
947
|
-
if (githubEnterpriseApi || templateService) {
|
|
954
|
+
if (githubEnterpriseApi || templateService || accountNavEnabled) {
|
|
948
955
|
app.use("/admin/*", async (c, next) => {
|
|
949
956
|
const token = getCookie(c, SESSION_COOKIE);
|
|
950
957
|
const user = token ? await getSessionUser(token, sessionSecret) : null;
|
|
@@ -962,28 +969,6 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
962
969
|
});
|
|
963
970
|
}
|
|
964
971
|
|
|
965
|
-
// SSP-3.2: show the toolbar's "Account" entry only for signed-in users who
|
|
966
|
-
// belong to an account, and only while self-serve is on. The flag is carried
|
|
967
|
-
// in AsyncLocalStorage so renderAdminToolbar() needs no extra parameter.
|
|
968
|
-
const accountNavEnabled = Boolean(selfServe?.enabled && accountServices);
|
|
969
|
-
if (accountNavEnabled && accountServices) {
|
|
970
|
-
app.use("/admin/*", async (c, next) => {
|
|
971
|
-
const token = getCookie(c, SESSION_COOKIE);
|
|
972
|
-
const user = token ? await getSessionUser(token, sessionSecret) : null;
|
|
973
|
-
let showAccount = false;
|
|
974
|
-
if (user) {
|
|
975
|
-
try {
|
|
976
|
-
showAccount =
|
|
977
|
-
(await accountServices.accounts.getByMemberEmail(user.email)) !==
|
|
978
|
-
null;
|
|
979
|
-
} catch {
|
|
980
|
-
// nav is cosmetic — never fail the page over the lookup
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
return runWithAccountNav(showAccount, () => next());
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
|
|
987
972
|
// Extracted Slack app-manifest-creation/OAuth/app-token orchestration
|
|
988
973
|
// (UAP-1.1) — shared by the legacy /admin/provision/* wizard's Slack
|
|
989
974
|
// branch and the new per-agent /admin/agents/:id/connect-slack routes so
|
|
@@ -1609,10 +1594,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1609
1594
|
...(templateService
|
|
1610
1595
|
? {
|
|
1611
1596
|
template: {
|
|
1612
|
-
items: await templateDefaultItems(
|
|
1613
|
-
c.var.isAdmin,
|
|
1614
|
-
accountId,
|
|
1615
|
-
),
|
|
1597
|
+
items: await templateDefaultItems(c.var.isAdmin, accountId),
|
|
1616
1598
|
allowEnv: c.var.isAdmin === true,
|
|
1617
1599
|
},
|
|
1618
1600
|
}
|
|
@@ -1916,6 +1898,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1916
1898
|
agentMemberService,
|
|
1917
1899
|
agent.id,
|
|
1918
1900
|
restrictSlackToMembers,
|
|
1901
|
+
"general",
|
|
1919
1902
|
);
|
|
1920
1903
|
});
|
|
1921
1904
|
|
|
@@ -1995,7 +1978,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1995
1978
|
}),
|
|
1996
1979
|
},
|
|
1997
1980
|
);
|
|
1998
|
-
const base =
|
|
1981
|
+
const base = agentSectionPath(agentId, "access");
|
|
1999
1982
|
if (res?.ok) {
|
|
2000
1983
|
return c.redirect(
|
|
2001
1984
|
`${base}?success=${username === "" ? "github_username_cleared" : "github_username_saved"}`,
|
|
@@ -2009,7 +1992,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2009
1992
|
} catch {
|
|
2010
1993
|
// keep the generic message
|
|
2011
1994
|
}
|
|
2012
|
-
return c.redirect(
|
|
1995
|
+
return c.redirect(
|
|
1996
|
+
agentSectionPath(agentId, "access", { error: message }),
|
|
1997
|
+
302,
|
|
1998
|
+
);
|
|
2013
1999
|
});
|
|
2014
2000
|
|
|
2015
2001
|
app.get("/admin/agents/:id/github-access", requireAuth, async (c) => {
|
|
@@ -2272,8 +2258,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2272
2258
|
},
|
|
2273
2259
|
);
|
|
2274
2260
|
|
|
2275
|
-
|
|
2276
|
-
const agentId = c.req.param("id");
|
|
2261
|
+
const agentDetailHandler = async (c: Context<AdminUIEnv, any>) => {
|
|
2262
|
+
const agentId = c.req.param("id") ?? "";
|
|
2263
|
+
const sectionParam = c.req.param("section") ?? "general";
|
|
2264
|
+
if (!isAgentSection(sectionParam)) {
|
|
2265
|
+
return new Response("Not found", { status: 404 });
|
|
2266
|
+
}
|
|
2267
|
+
const section: AgentSection = sectionParam;
|
|
2277
2268
|
const agent = await agentService.getDetail(agentId);
|
|
2278
2269
|
if (!agent) {
|
|
2279
2270
|
return new Response("Agent not found", { status: 404 });
|
|
@@ -2397,6 +2388,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2397
2388
|
c.var.userEmail,
|
|
2398
2389
|
c.var.isAdmin,
|
|
2399
2390
|
{
|
|
2391
|
+
section,
|
|
2400
2392
|
canManage: canManageAgents(c.var.isAdmin),
|
|
2401
2393
|
error,
|
|
2402
2394
|
newToken,
|
|
@@ -2415,7 +2407,16 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2415
2407
|
},
|
|
2416
2408
|
),
|
|
2417
2409
|
);
|
|
2418
|
-
}
|
|
2410
|
+
};
|
|
2411
|
+
app.get("/admin/agents/:id", requireAuth, agentDetailHandler);
|
|
2412
|
+
// Constrained to the known sections so other /admin/agents/:id/<x> GET routes
|
|
2413
|
+
// (extension-mounted pages) still match; an unknown section falls through to
|
|
2414
|
+
// the default 404.
|
|
2415
|
+
app.get(
|
|
2416
|
+
`/admin/agents/:id/:section{${AGENT_SECTIONS.join("|")}}`,
|
|
2417
|
+
requireAuth,
|
|
2418
|
+
agentDetailHandler,
|
|
2419
|
+
);
|
|
2419
2420
|
|
|
2420
2421
|
// ─── Env var mutations ────────────────────────────────────────────────────
|
|
2421
2422
|
|
|
@@ -2433,7 +2434,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2433
2434
|
value = formData.get("value")?.toString();
|
|
2434
2435
|
secretStr = formData.get("secret")?.toString();
|
|
2435
2436
|
} catch {
|
|
2436
|
-
return c.redirect(
|
|
2437
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2437
2438
|
}
|
|
2438
2439
|
if (key && value !== undefined) {
|
|
2439
2440
|
const isSecret = secretStr === "true";
|
|
@@ -2448,14 +2449,14 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2448
2449
|
// value) on the agent page instead of a 500.
|
|
2449
2450
|
if (err instanceof AnthropicCredentialsBlockedError) {
|
|
2450
2451
|
return c.redirect(
|
|
2451
|
-
|
|
2452
|
+
agentSectionPath(agentId, "configuration", { error: err.message }),
|
|
2452
2453
|
302,
|
|
2453
2454
|
);
|
|
2454
2455
|
}
|
|
2455
2456
|
throw err;
|
|
2456
2457
|
}
|
|
2457
2458
|
}
|
|
2458
|
-
return c.redirect(
|
|
2459
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2459
2460
|
});
|
|
2460
2461
|
|
|
2461
2462
|
app.post("/admin/agents/:id/envs/delete", requireAuth, async (c) => {
|
|
@@ -2468,31 +2469,38 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2468
2469
|
const formData = await c.req.formData();
|
|
2469
2470
|
key = formData.get("key")?.toString();
|
|
2470
2471
|
} catch {
|
|
2471
|
-
return c.redirect(
|
|
2472
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2472
2473
|
}
|
|
2473
2474
|
if (key) {
|
|
2474
2475
|
await agentEnvService.deleteKey(agentId, key);
|
|
2475
2476
|
}
|
|
2476
|
-
return c.redirect(
|
|
2477
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2477
2478
|
});
|
|
2478
2479
|
|
|
2479
2480
|
// ─── Agent template (ATP-2.4) ─────────────────────────────────────────────
|
|
2480
2481
|
// Thin forwards to the ATP-2.2 endpoints through the agents API seam, with
|
|
2481
2482
|
// the caller's session cookie, so its own auth and 409 rules apply.
|
|
2482
2483
|
|
|
2483
|
-
|
|
2484
|
+
// A per-item reset lands on the section whose row it was clicked from.
|
|
2485
|
+
const TEMPLATE_KIND_SECTIONS: Record<string, AgentSection> = {
|
|
2486
|
+
env: "configuration",
|
|
2487
|
+
tool: "extensions",
|
|
2488
|
+
plugin: "extensions",
|
|
2489
|
+
cron: "automation",
|
|
2490
|
+
};
|
|
2491
|
+
const TEMPLATE_KINDS = Object.keys(TEMPLATE_KIND_SECTIONS);
|
|
2484
2492
|
|
|
2485
2493
|
async function templateAction(
|
|
2486
2494
|
c: Context<AdminUIEnv>,
|
|
2487
2495
|
action: "detach" | "reattach" | "reset",
|
|
2488
2496
|
body?: Record<string, string>,
|
|
2497
|
+
section: AgentSection = "configuration",
|
|
2489
2498
|
): Promise<Response> {
|
|
2490
2499
|
const agentId = c.req.param("id") ?? "";
|
|
2491
2500
|
if (!agentsApi) return new Response("Not found", { status: 404 });
|
|
2492
2501
|
if (!(await assertAgentAccess(agentId, c.var.userEmail, c.var.isAdmin))) {
|
|
2493
2502
|
return new Response("Forbidden", { status: 403 });
|
|
2494
2503
|
}
|
|
2495
|
-
const base = `/admin/agents/${agentId}`;
|
|
2496
2504
|
const res = await callApi(
|
|
2497
2505
|
c,
|
|
2498
2506
|
agentsApi,
|
|
@@ -2507,7 +2515,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2507
2515
|
: {}),
|
|
2508
2516
|
},
|
|
2509
2517
|
);
|
|
2510
|
-
if (res?.ok) return c.redirect(
|
|
2518
|
+
if (res?.ok) return c.redirect(agentSectionPath(agentId, section), 302);
|
|
2511
2519
|
let message = "Could not update the agent template.";
|
|
2512
2520
|
try {
|
|
2513
2521
|
const j = (await res?.json()) as { error?: unknown };
|
|
@@ -2515,7 +2523,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2515
2523
|
} catch {
|
|
2516
2524
|
// keep the generic message
|
|
2517
2525
|
}
|
|
2518
|
-
return c.redirect(
|
|
2526
|
+
return c.redirect(
|
|
2527
|
+
agentSectionPath(agentId, section, { error: message }),
|
|
2528
|
+
302,
|
|
2529
|
+
);
|
|
2519
2530
|
}
|
|
2520
2531
|
|
|
2521
2532
|
app.post("/admin/agents/:id/template/detach", requireAuth, (c) =>
|
|
@@ -2538,11 +2549,18 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2538
2549
|
}
|
|
2539
2550
|
if (kind !== "" && (!TEMPLATE_KINDS.includes(kind) || key === "")) {
|
|
2540
2551
|
return c.redirect(
|
|
2541
|
-
|
|
2552
|
+
agentSectionPath(c.req.param("id"), "configuration", {
|
|
2553
|
+
error: "Unknown template item to reset.",
|
|
2554
|
+
}),
|
|
2542
2555
|
302,
|
|
2543
2556
|
);
|
|
2544
2557
|
}
|
|
2545
|
-
return templateAction(
|
|
2558
|
+
return templateAction(
|
|
2559
|
+
c,
|
|
2560
|
+
"reset",
|
|
2561
|
+
kind === "" ? {} : { kind, key },
|
|
2562
|
+
TEMPLATE_KIND_SECTIONS[kind] ?? "configuration",
|
|
2563
|
+
);
|
|
2546
2564
|
});
|
|
2547
2565
|
|
|
2548
2566
|
// ─── Repo mutations ───────────────────────────────────────────────────────
|
|
@@ -2557,11 +2575,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2557
2575
|
const formData = await c.req.formData();
|
|
2558
2576
|
repo = formData.get("repo")?.toString()?.trim();
|
|
2559
2577
|
} catch {
|
|
2560
|
-
return c.redirect(
|
|
2578
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2561
2579
|
}
|
|
2562
2580
|
if (!repo || !isOrgRepo(repo)) {
|
|
2563
2581
|
return c.redirect(
|
|
2564
|
-
|
|
2582
|
+
agentSectionPath(agentId, "configuration", {
|
|
2583
|
+
error: "invalid_repo_format",
|
|
2584
|
+
}),
|
|
2565
2585
|
302,
|
|
2566
2586
|
);
|
|
2567
2587
|
}
|
|
@@ -2574,12 +2594,12 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2574
2594
|
const collision = describeRepoNameCollision(deduped);
|
|
2575
2595
|
if (collision) {
|
|
2576
2596
|
return c.redirect(
|
|
2577
|
-
|
|
2597
|
+
agentSectionPath(agentId, "configuration", { error: collision }),
|
|
2578
2598
|
302,
|
|
2579
2599
|
);
|
|
2580
2600
|
}
|
|
2581
2601
|
await agentService.updateFields(agentId, { repos: deduped });
|
|
2582
|
-
return c.redirect(
|
|
2602
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2583
2603
|
});
|
|
2584
2604
|
|
|
2585
2605
|
app.post("/admin/agents/:id/repos/delete", requireAuth, async (c) => {
|
|
@@ -2592,7 +2612,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2592
2612
|
const formData = await c.req.formData();
|
|
2593
2613
|
repo = formData.get("repo")?.toString()?.trim();
|
|
2594
2614
|
} catch {
|
|
2595
|
-
return c.redirect(
|
|
2615
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2596
2616
|
}
|
|
2597
2617
|
if (repo) {
|
|
2598
2618
|
const agent = await agentService.getDetail(agentId);
|
|
@@ -2602,7 +2622,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2602
2622
|
const updated = (agent.repos ?? []).filter((r) => r !== repo);
|
|
2603
2623
|
await agentService.updateFields(agentId, { repos: updated });
|
|
2604
2624
|
}
|
|
2605
|
-
return c.redirect(
|
|
2625
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2606
2626
|
});
|
|
2607
2627
|
|
|
2608
2628
|
// ─── Author allowlist (review) mutations ───────────────────────────────────
|
|
@@ -2620,11 +2640,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2620
2640
|
const formData = await c.req.formData();
|
|
2621
2641
|
login = formData.get("login")?.toString()?.trim();
|
|
2622
2642
|
} catch {
|
|
2623
|
-
return c.redirect(
|
|
2643
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2624
2644
|
}
|
|
2625
2645
|
if (!login || !isGithubLogin(login)) {
|
|
2626
2646
|
return c.redirect(
|
|
2627
|
-
|
|
2647
|
+
agentSectionPath(agentId, "access", {
|
|
2648
|
+
error: "invalid_author_allowlist_format",
|
|
2649
|
+
}),
|
|
2628
2650
|
302,
|
|
2629
2651
|
);
|
|
2630
2652
|
}
|
|
@@ -2639,7 +2661,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2639
2661
|
await agentService.updateFields(agentId, {
|
|
2640
2662
|
reviewAuthorAllowlist: deduped,
|
|
2641
2663
|
});
|
|
2642
|
-
return c.redirect(
|
|
2664
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2643
2665
|
},
|
|
2644
2666
|
);
|
|
2645
2667
|
|
|
@@ -2656,7 +2678,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2656
2678
|
const formData = await c.req.formData();
|
|
2657
2679
|
login = formData.get("login")?.toString()?.trim();
|
|
2658
2680
|
} catch {
|
|
2659
|
-
return c.redirect(
|
|
2681
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2660
2682
|
}
|
|
2661
2683
|
if (login) {
|
|
2662
2684
|
const agent = await agentService.getDetail(agentId);
|
|
@@ -2670,7 +2692,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2670
2692
|
reviewAuthorAllowlist: updated,
|
|
2671
2693
|
});
|
|
2672
2694
|
}
|
|
2673
|
-
return c.redirect(
|
|
2695
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2674
2696
|
},
|
|
2675
2697
|
);
|
|
2676
2698
|
|
|
@@ -2689,11 +2711,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2689
2711
|
const formData = await c.req.formData();
|
|
2690
2712
|
login = formData.get("login")?.toString()?.trim();
|
|
2691
2713
|
} catch {
|
|
2692
|
-
return c.redirect(
|
|
2714
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2693
2715
|
}
|
|
2694
2716
|
if (!login || !isGithubLogin(login)) {
|
|
2695
2717
|
return c.redirect(
|
|
2696
|
-
|
|
2718
|
+
agentSectionPath(agentId, "access", {
|
|
2719
|
+
error: "invalid_author_allowlist_format",
|
|
2720
|
+
}),
|
|
2697
2721
|
302,
|
|
2698
2722
|
);
|
|
2699
2723
|
}
|
|
@@ -2708,7 +2732,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2708
2732
|
await agentService.updateFields(agentId, {
|
|
2709
2733
|
patchAuthorAllowlist: deduped,
|
|
2710
2734
|
});
|
|
2711
|
-
return c.redirect(
|
|
2735
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2712
2736
|
},
|
|
2713
2737
|
);
|
|
2714
2738
|
|
|
@@ -2725,7 +2749,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2725
2749
|
const formData = await c.req.formData();
|
|
2726
2750
|
login = formData.get("login")?.toString()?.trim();
|
|
2727
2751
|
} catch {
|
|
2728
|
-
return c.redirect(
|
|
2752
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2729
2753
|
}
|
|
2730
2754
|
if (login) {
|
|
2731
2755
|
const agent = await agentService.getDetail(agentId);
|
|
@@ -2739,7 +2763,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2739
2763
|
patchAuthorAllowlist: updated,
|
|
2740
2764
|
});
|
|
2741
2765
|
}
|
|
2742
|
-
return c.redirect(
|
|
2766
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2743
2767
|
},
|
|
2744
2768
|
);
|
|
2745
2769
|
|
|
@@ -2769,7 +2793,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2769
2793
|
try {
|
|
2770
2794
|
formData = await c.req.formData();
|
|
2771
2795
|
} catch {
|
|
2772
|
-
return c.redirect(
|
|
2796
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2773
2797
|
}
|
|
2774
2798
|
|
|
2775
2799
|
const readBool = (name: string): boolean | undefined => {
|
|
@@ -2821,6 +2845,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2821
2845
|
agentMemberService,
|
|
2822
2846
|
agent.id,
|
|
2823
2847
|
agent.restrictSlackToMembers,
|
|
2848
|
+
settingsRedirectSection(formData),
|
|
2824
2849
|
);
|
|
2825
2850
|
});
|
|
2826
2851
|
|
|
@@ -2852,10 +2877,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2852
2877
|
enabled = enabledVal === "on" || enabledVal === "true";
|
|
2853
2878
|
name = formData.get("name")?.toString() || null;
|
|
2854
2879
|
} catch {
|
|
2855
|
-
return c.redirect(
|
|
2880
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2856
2881
|
}
|
|
2857
2882
|
if (!schedule || !prompt) {
|
|
2858
|
-
return c.redirect(
|
|
2883
|
+
return c.redirect(
|
|
2884
|
+
agentSectionPath(agentId, "automation", { error: "missing_fields" }),
|
|
2885
|
+
302,
|
|
2886
|
+
);
|
|
2859
2887
|
}
|
|
2860
2888
|
try {
|
|
2861
2889
|
await agentCronJobService.create(agentId, {
|
|
@@ -2872,7 +2900,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2872
2900
|
const msg = err.message.toLowerCase();
|
|
2873
2901
|
if (msg.includes("invalid cron")) {
|
|
2874
2902
|
return c.redirect(
|
|
2875
|
-
|
|
2903
|
+
agentSectionPath(agentId, "automation", {
|
|
2904
|
+
error: "invalid_schedule",
|
|
2905
|
+
}),
|
|
2876
2906
|
302,
|
|
2877
2907
|
);
|
|
2878
2908
|
}
|
|
@@ -2882,14 +2912,19 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2882
2912
|
msg.includes("target")
|
|
2883
2913
|
) {
|
|
2884
2914
|
return c.redirect(
|
|
2885
|
-
|
|
2915
|
+
agentSectionPath(agentId, "automation", {
|
|
2916
|
+
error: "invalid_target",
|
|
2917
|
+
}),
|
|
2886
2918
|
302,
|
|
2887
2919
|
);
|
|
2888
2920
|
}
|
|
2889
2921
|
}
|
|
2890
|
-
return c.redirect(
|
|
2922
|
+
return c.redirect(
|
|
2923
|
+
agentSectionPath(agentId, "automation", { error: "create_failed" }),
|
|
2924
|
+
302,
|
|
2925
|
+
);
|
|
2891
2926
|
}
|
|
2892
|
-
return c.redirect(
|
|
2927
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2893
2928
|
});
|
|
2894
2929
|
|
|
2895
2930
|
app.post("/admin/agents/:id/crons/:cronId/toggle", requireAuth, async (c) => {
|
|
@@ -2910,7 +2945,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2910
2945
|
} catch {
|
|
2911
2946
|
// ignore errors — redirect back regardless
|
|
2912
2947
|
}
|
|
2913
|
-
return c.redirect(
|
|
2948
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2914
2949
|
});
|
|
2915
2950
|
|
|
2916
2951
|
app.post("/admin/agents/:id/crons/:cronId/update", requireAuth, async (c) => {
|
|
@@ -2936,7 +2971,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2936
2971
|
}
|
|
2937
2972
|
if (!schedule || !prompt) {
|
|
2938
2973
|
return c.redirect(
|
|
2939
|
-
|
|
2974
|
+
agentSectionPath(agentId, "automation", {
|
|
2975
|
+
error: "schedule and prompt are required",
|
|
2976
|
+
}),
|
|
2940
2977
|
302,
|
|
2941
2978
|
);
|
|
2942
2979
|
}
|
|
@@ -2948,7 +2985,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2948
2985
|
const existing = await agentCronJobService.get(agentId, cronId);
|
|
2949
2986
|
if (existing.system) {
|
|
2950
2987
|
return c.redirect(
|
|
2951
|
-
|
|
2988
|
+
agentSectionPath(agentId, "automation", {
|
|
2989
|
+
error: "system crons cannot be edited",
|
|
2990
|
+
}),
|
|
2952
2991
|
302,
|
|
2953
2992
|
);
|
|
2954
2993
|
}
|
|
@@ -2963,13 +3002,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2963
3002
|
} catch (err) {
|
|
2964
3003
|
// Surface validation errors (e.g. invalid cron expression) back to the page.
|
|
2965
3004
|
return c.redirect(
|
|
2966
|
-
|
|
2967
|
-
err instanceof Error ? err.message : "cron update failed",
|
|
2968
|
-
)
|
|
3005
|
+
agentSectionPath(agentId, "automation", {
|
|
3006
|
+
error: err instanceof Error ? err.message : "cron update failed",
|
|
3007
|
+
}),
|
|
2969
3008
|
302,
|
|
2970
3009
|
);
|
|
2971
3010
|
}
|
|
2972
|
-
return c.redirect(
|
|
3011
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2973
3012
|
});
|
|
2974
3013
|
|
|
2975
3014
|
app.post("/admin/agents/:id/crons/:cronId/delete", requireAuth, async (c) => {
|
|
@@ -2987,13 +3026,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2987
3026
|
} catch (err) {
|
|
2988
3027
|
if (err instanceof ForbiddenError) {
|
|
2989
3028
|
return c.redirect(
|
|
2990
|
-
|
|
3029
|
+
agentSectionPath(agentId, "automation", { error: err.message }),
|
|
2991
3030
|
302,
|
|
2992
3031
|
);
|
|
2993
3032
|
}
|
|
2994
3033
|
// other errors (NotFoundError, etc.) — redirect back silently
|
|
2995
3034
|
}
|
|
2996
|
-
return c.redirect(
|
|
3035
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2997
3036
|
});
|
|
2998
3037
|
|
|
2999
3038
|
// ─── Tool mutations ───────────────────────────────────────────────────────
|
|
@@ -3008,17 +3047,20 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3008
3047
|
const formData = await c.req.formData();
|
|
3009
3048
|
pattern = formData.get("pattern")?.toString();
|
|
3010
3049
|
} catch {
|
|
3011
|
-
return c.redirect(
|
|
3050
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3012
3051
|
}
|
|
3013
3052
|
if (!pattern) {
|
|
3014
|
-
return c.redirect(
|
|
3053
|
+
return c.redirect(
|
|
3054
|
+
agentSectionPath(agentId, "extensions", { error: "missing_fields" }),
|
|
3055
|
+
302,
|
|
3056
|
+
);
|
|
3015
3057
|
}
|
|
3016
3058
|
try {
|
|
3017
3059
|
await agentToolService.add(agentId, pattern);
|
|
3018
3060
|
} catch {
|
|
3019
3061
|
// ignore errors — redirect back regardless
|
|
3020
3062
|
}
|
|
3021
|
-
return c.redirect(
|
|
3063
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3022
3064
|
});
|
|
3023
3065
|
|
|
3024
3066
|
app.post("/admin/agents/:id/tools/:toolId/toggle", requireAuth, async (c) => {
|
|
@@ -3039,7 +3081,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3039
3081
|
} catch {
|
|
3040
3082
|
// ignore errors — redirect back regardless
|
|
3041
3083
|
}
|
|
3042
|
-
return c.redirect(
|
|
3084
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3043
3085
|
});
|
|
3044
3086
|
|
|
3045
3087
|
app.post("/admin/agents/:id/tools/:toolId/delete", requireAuth, async (c) => {
|
|
@@ -3053,7 +3095,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3053
3095
|
} catch {
|
|
3054
3096
|
// ignore errors — redirect back regardless
|
|
3055
3097
|
}
|
|
3056
|
-
return c.redirect(
|
|
3098
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3057
3099
|
});
|
|
3058
3100
|
|
|
3059
3101
|
// ─── Marketplace mutations (PMK-1.5) ──────────────────────────────────────
|
|
@@ -3074,23 +3116,26 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3074
3116
|
source = formData.get("source")?.toString().trim();
|
|
3075
3117
|
ref = formData.get("ref")?.toString().trim() || undefined;
|
|
3076
3118
|
} catch {
|
|
3077
|
-
return c.redirect(
|
|
3119
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3078
3120
|
}
|
|
3079
3121
|
if (!name || !source) {
|
|
3080
|
-
return c.redirect(
|
|
3122
|
+
return c.redirect(
|
|
3123
|
+
agentSectionPath(agentId, "extensions", { error: "missing_fields" }),
|
|
3124
|
+
302,
|
|
3125
|
+
);
|
|
3081
3126
|
}
|
|
3082
3127
|
try {
|
|
3083
3128
|
await agentMarketplaceService?.upsert(agentId, { name, source, ref });
|
|
3084
3129
|
} catch (err) {
|
|
3085
3130
|
if (err instanceof UnprocessableEntityError) {
|
|
3086
3131
|
return c.redirect(
|
|
3087
|
-
|
|
3132
|
+
agentSectionPath(agentId, "extensions", { error: err.message }),
|
|
3088
3133
|
302,
|
|
3089
3134
|
);
|
|
3090
3135
|
}
|
|
3091
3136
|
// other errors — redirect back silently, like the tool routes
|
|
3092
3137
|
}
|
|
3093
|
-
return c.redirect(
|
|
3138
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3094
3139
|
});
|
|
3095
3140
|
|
|
3096
3141
|
app.post("/admin/agents/:id/marketplaces/delete", requireAuth, async (c) => {
|
|
@@ -3103,7 +3148,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3103
3148
|
const formData = await c.req.formData();
|
|
3104
3149
|
marketplaceId = formData.get("marketplaceId")?.toString();
|
|
3105
3150
|
} catch {
|
|
3106
|
-
return c.redirect(
|
|
3151
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3107
3152
|
}
|
|
3108
3153
|
if (marketplaceId) {
|
|
3109
3154
|
try {
|
|
@@ -3112,7 +3157,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3112
3157
|
// already gone, ignore
|
|
3113
3158
|
}
|
|
3114
3159
|
}
|
|
3115
|
-
return c.redirect(
|
|
3160
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3116
3161
|
});
|
|
3117
3162
|
|
|
3118
3163
|
// ─── Plugin mutations (PUI-1.2) ───────────────────────────────────────────
|
|
@@ -3130,11 +3175,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3130
3175
|
const formData = await c.req.formData();
|
|
3131
3176
|
raw = formData.get("spec")?.toString().trim();
|
|
3132
3177
|
} catch {
|
|
3133
|
-
return c.redirect(
|
|
3178
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3134
3179
|
}
|
|
3135
3180
|
const redirectError = (message: string) =>
|
|
3136
3181
|
c.redirect(
|
|
3137
|
-
|
|
3182
|
+
agentSectionPath(agentId, "extensions", { error: message }),
|
|
3138
3183
|
302,
|
|
3139
3184
|
);
|
|
3140
3185
|
if (!raw) return redirectError("missing_fields");
|
|
@@ -3146,7 +3191,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3146
3191
|
}
|
|
3147
3192
|
// other errors — redirect back silently, like the tool routes
|
|
3148
3193
|
}
|
|
3149
|
-
return c.redirect(
|
|
3194
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3150
3195
|
});
|
|
3151
3196
|
|
|
3152
3197
|
app.post("/admin/agents/:id/plugins/delete", requireAuth, async (c) => {
|
|
@@ -3159,7 +3204,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3159
3204
|
const formData = await c.req.formData();
|
|
3160
3205
|
pluginId = formData.get("pluginId")?.toString();
|
|
3161
3206
|
} catch {
|
|
3162
|
-
return c.redirect(
|
|
3207
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3163
3208
|
}
|
|
3164
3209
|
if (pluginId) {
|
|
3165
3210
|
try {
|
|
@@ -3168,7 +3213,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3168
3213
|
// already gone, ignore
|
|
3169
3214
|
}
|
|
3170
3215
|
}
|
|
3171
|
-
return c.redirect(
|
|
3216
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3172
3217
|
});
|
|
3173
3218
|
|
|
3174
3219
|
// ─── Token mutations ──────────────────────────────────────────────────────
|
|
@@ -3183,7 +3228,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3183
3228
|
const formData = await c.req.formData();
|
|
3184
3229
|
label = formData.get("label")?.toString() || undefined;
|
|
3185
3230
|
} catch {
|
|
3186
|
-
return c.redirect(
|
|
3231
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3187
3232
|
}
|
|
3188
3233
|
const agent = await agentService.getDetail(agentId);
|
|
3189
3234
|
if (!agent) {
|
|
@@ -3258,6 +3303,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3258
3303
|
c.var.userEmail,
|
|
3259
3304
|
c.var.isAdmin,
|
|
3260
3305
|
{
|
|
3306
|
+
section: "access",
|
|
3261
3307
|
canManage: canManageAgents(c.var.isAdmin),
|
|
3262
3308
|
newToken: rawToken,
|
|
3263
3309
|
timezone,
|
|
@@ -3273,7 +3319,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3273
3319
|
),
|
|
3274
3320
|
);
|
|
3275
3321
|
} catch {
|
|
3276
|
-
return c.redirect(
|
|
3322
|
+
return c.redirect(
|
|
3323
|
+
agentSectionPath(agentId, "access", { error: "create_failed" }),
|
|
3324
|
+
302,
|
|
3325
|
+
);
|
|
3277
3326
|
}
|
|
3278
3327
|
});
|
|
3279
3328
|
|
|
@@ -3291,7 +3340,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3291
3340
|
} catch {
|
|
3292
3341
|
// ignore errors — redirect back regardless
|
|
3293
3342
|
}
|
|
3294
|
-
return c.redirect(
|
|
3343
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3295
3344
|
},
|
|
3296
3345
|
);
|
|
3297
3346
|
|
|
@@ -3317,12 +3366,17 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3317
3366
|
const formData = await c.req.formData();
|
|
3318
3367
|
xoxpToken = formData.get("xoxpToken")?.toString();
|
|
3319
3368
|
} catch {
|
|
3320
|
-
return c.redirect(
|
|
3369
|
+
return c.redirect(
|
|
3370
|
+
agentSectionPath(agentId, "general", { error: "missing_fields" }),
|
|
3371
|
+
302,
|
|
3372
|
+
);
|
|
3321
3373
|
}
|
|
3322
3374
|
|
|
3323
3375
|
if (!xoxpToken?.startsWith("xoxe.xoxp-")) {
|
|
3324
3376
|
return c.redirect(
|
|
3325
|
-
|
|
3377
|
+
agentSectionPath(agentId, "general", {
|
|
3378
|
+
error: "Slack app configuration token must start with xoxe.xoxp-",
|
|
3379
|
+
}),
|
|
3326
3380
|
302,
|
|
3327
3381
|
);
|
|
3328
3382
|
}
|
|
@@ -3331,7 +3385,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3331
3385
|
const appId = envBundle?.env.SLACK_APP_ID;
|
|
3332
3386
|
if (!appId) {
|
|
3333
3387
|
return c.redirect(
|
|
3334
|
-
|
|
3388
|
+
agentSectionPath(agentId, "general", {
|
|
3389
|
+
error: "SLACK_APP_ID is not set — provision the agent first.",
|
|
3390
|
+
}),
|
|
3335
3391
|
302,
|
|
3336
3392
|
);
|
|
3337
3393
|
}
|
|
@@ -3344,7 +3400,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3344
3400
|
const msg =
|
|
3345
3401
|
err instanceof Error ? err.message : "Unknown error syncing manifest.";
|
|
3346
3402
|
return c.redirect(
|
|
3347
|
-
|
|
3403
|
+
agentSectionPath(agentId, "general", { error: msg }),
|
|
3348
3404
|
302,
|
|
3349
3405
|
);
|
|
3350
3406
|
}
|
|
@@ -3394,7 +3450,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3394
3450
|
);
|
|
3395
3451
|
}
|
|
3396
3452
|
|
|
3397
|
-
return c.redirect(
|
|
3453
|
+
return c.redirect(
|
|
3454
|
+
agentSectionPath(agentId, "general", { success: "manifest_synced" }),
|
|
3455
|
+
302,
|
|
3456
|
+
);
|
|
3398
3457
|
});
|
|
3399
3458
|
|
|
3400
3459
|
// ─── connect-slack (UAP-1.1) ───────────────────────────────────────────────
|
|
@@ -3414,7 +3473,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3414
3473
|
const formData = await c.req.formData();
|
|
3415
3474
|
xoxpToken = formData.get("xoxpToken")?.toString();
|
|
3416
3475
|
} catch {
|
|
3417
|
-
return c.redirect(
|
|
3476
|
+
return c.redirect(
|
|
3477
|
+
agentSectionPath(agentId, "access", { error: "missing_fields" }),
|
|
3478
|
+
302,
|
|
3479
|
+
);
|
|
3418
3480
|
}
|
|
3419
3481
|
|
|
3420
3482
|
const result = await slackProvisioningService.startConnect(
|
|
@@ -3425,7 +3487,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3425
3487
|
|
|
3426
3488
|
if (!result.ok) {
|
|
3427
3489
|
return c.redirect(
|
|
3428
|
-
|
|
3490
|
+
agentSectionPath(agentId, "access", { error: result.error }),
|
|
3429
3491
|
302,
|
|
3430
3492
|
);
|
|
3431
3493
|
}
|
|
@@ -3503,7 +3565,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3503
3565
|
const query = ghConnectWarning
|
|
3504
3566
|
? `?success=reinstalled&warning=${encodeURIComponent(ghConnectWarning)}`
|
|
3505
3567
|
: "?success=reinstalled";
|
|
3506
|
-
return c.redirect(
|
|
3568
|
+
return c.redirect(
|
|
3569
|
+
`${agentSectionPath(result.agentId, "access")}${query}`,
|
|
3570
|
+
302,
|
|
3571
|
+
);
|
|
3507
3572
|
}
|
|
3508
3573
|
|
|
3509
3574
|
// result.outcome === "needs_app_token"
|
|
@@ -3822,7 +3887,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3822
3887
|
const result = await githubProvisioningService.getAddOrgUrl(agentId);
|
|
3823
3888
|
if (!result.ok) {
|
|
3824
3889
|
return c.redirect(
|
|
3825
|
-
|
|
3890
|
+
agentSectionPath(agentId, "access", { error: result.error }),
|
|
3826
3891
|
302,
|
|
3827
3892
|
);
|
|
3828
3893
|
}
|
|
@@ -3848,7 +3913,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3848
3913
|
const formData = await c.req.formData();
|
|
3849
3914
|
email = formData.get("email")?.toString()?.toLowerCase();
|
|
3850
3915
|
} catch {
|
|
3851
|
-
return c.redirect(
|
|
3916
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3852
3917
|
}
|
|
3853
3918
|
if (email) {
|
|
3854
3919
|
try {
|
|
@@ -3857,7 +3922,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3857
3922
|
// unique constraint violation — already a member, ignore
|
|
3858
3923
|
}
|
|
3859
3924
|
}
|
|
3860
|
-
return c.redirect(
|
|
3925
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3861
3926
|
});
|
|
3862
3927
|
|
|
3863
3928
|
app.post("/admin/agents/:id/members/delete", requireAuth, async (c) => {
|
|
@@ -3872,7 +3937,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3872
3937
|
const formData = await c.req.formData();
|
|
3873
3938
|
memberId = formData.get("memberId")?.toString();
|
|
3874
3939
|
} catch {
|
|
3875
|
-
return c.redirect(
|
|
3940
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3876
3941
|
}
|
|
3877
3942
|
if (memberId) {
|
|
3878
3943
|
try {
|
|
@@ -3881,7 +3946,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3881
3946
|
// already gone, ignore
|
|
3882
3947
|
}
|
|
3883
3948
|
}
|
|
3884
|
-
return c.redirect(
|
|
3949
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3885
3950
|
});
|
|
3886
3951
|
|
|
3887
3952
|
// ─── Enterprise GitHub apps settings (GHE-1.4) ───────────────────────────
|
|
@@ -3889,16 +3954,29 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3889
3954
|
const settingsNav = buildSettingsNav({
|
|
3890
3955
|
githubEnterprise: Boolean(githubEnterpriseApi),
|
|
3891
3956
|
templates: Boolean(templateService),
|
|
3957
|
+
accounts: accountNavEnabled,
|
|
3892
3958
|
extraItems: deps.settingsNavItems ?? [],
|
|
3893
3959
|
});
|
|
3894
3960
|
|
|
3895
3961
|
// SGL-2.2: /admin/settings lands on the first nav item the viewer can see.
|
|
3896
|
-
if (githubEnterpriseApi || templateService) {
|
|
3897
|
-
app.get("/admin/settings", requireAuth, (c) => {
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3962
|
+
if (githubEnterpriseApi || templateService || accountNavEnabled) {
|
|
3963
|
+
app.get("/admin/settings", requireAuth, async (c) => {
|
|
3964
|
+
// Admins without an account would 404 on the Account item; skip it.
|
|
3965
|
+
let nav = settingsNav;
|
|
3966
|
+
if (accountNavEnabled && accountServices) {
|
|
3967
|
+
const account = await accountServices.accounts
|
|
3968
|
+
.getByMemberEmail(c.var.userEmail)
|
|
3969
|
+
.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
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
const first = firstVisibleSettingsItem(nav, c.var.isAdmin === true);
|
|
3902
3980
|
if (!first) {
|
|
3903
3981
|
return new Response("No settings are available for your account.", {
|
|
3904
3982
|
status: 404,
|
|
@@ -3937,12 +4015,14 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3937
4015
|
registerAccountRoutes(app, {
|
|
3938
4016
|
enabled: accountNavEnabled,
|
|
3939
4017
|
requireAuth,
|
|
4018
|
+
settingsNav,
|
|
3940
4019
|
...accountServices,
|
|
3941
4020
|
html,
|
|
3942
4021
|
});
|
|
3943
4022
|
registerAdminAccountsRoutes(app, {
|
|
3944
4023
|
enabled: accountNavEnabled,
|
|
3945
4024
|
requireAuth,
|
|
4025
|
+
settingsNav,
|
|
3946
4026
|
...accountServices,
|
|
3947
4027
|
agents: agentService,
|
|
3948
4028
|
provisioner,
|
|
@@ -4752,9 +4832,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
4752
4832
|
// steps still need a retry.
|
|
4753
4833
|
const failedSteps = result.failed.map((f) => f.step).join(", ");
|
|
4754
4834
|
return c.redirect(
|
|
4755
|
-
|
|
4756
|
-
`Cleanup incomplete — retry. Failed steps: ${failedSteps}`,
|
|
4757
|
-
)
|
|
4835
|
+
agentSectionPath(agentId, "general", {
|
|
4836
|
+
error: `Cleanup incomplete — retry. Failed steps: ${failedSteps}`,
|
|
4837
|
+
}),
|
|
4758
4838
|
302,
|
|
4759
4839
|
);
|
|
4760
4840
|
}
|
|
@@ -4769,11 +4849,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
4769
4849
|
302,
|
|
4770
4850
|
);
|
|
4771
4851
|
} catch (err) {
|
|
4772
|
-
const msg =
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4852
|
+
const msg = err instanceof Error ? err.message : "delete_failed";
|
|
4853
|
+
return c.redirect(
|
|
4854
|
+
agentSectionPath(agentId, "general", { error: msg }),
|
|
4855
|
+
302,
|
|
4856
|
+
);
|
|
4777
4857
|
}
|
|
4778
4858
|
});
|
|
4779
4859
|
|