@app-vitals/agent-admin 1.48.0 → 1.50.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-agent-sections.unit.test.ts +95 -0
- package/src/admin-ui-agent-template.smoke.test.ts +421 -0
- 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 +269 -119
- package/src/admin-ui-pages.unit.test.ts +166 -225
- package/src/admin-ui-styles.ts +8 -65
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +325 -86
- package/src/agent-envs.ts +5 -1
- package/src/agents.ts +3 -0
package/src/admin-ui.ts
CHANGED
|
@@ -74,14 +74,19 @@ import {
|
|
|
74
74
|
type RepoRemovalPreviewView,
|
|
75
75
|
renderInstallationReposBody,
|
|
76
76
|
renderInstallationReposError,
|
|
77
|
-
renderSyncConfirm,
|
|
78
|
-
renderSyncResult,
|
|
79
77
|
renderRepoRemovalConfirm,
|
|
80
78
|
renderRepoRemovalResult,
|
|
79
|
+
renderSyncConfirm,
|
|
80
|
+
renderSyncResult,
|
|
81
81
|
} from "./admin-ui-installation-repos-pages.ts";
|
|
82
82
|
import {
|
|
83
|
+
AGENT_SECTIONS,
|
|
83
84
|
type AgentDetail,
|
|
84
85
|
type AgentOption,
|
|
86
|
+
type AgentSection,
|
|
87
|
+
agentSectionPath,
|
|
88
|
+
isAgentSection,
|
|
89
|
+
settingsRedirectSection,
|
|
85
90
|
renderAgentDetailPage,
|
|
86
91
|
renderAgentsPage,
|
|
87
92
|
renderChatMessageBubble,
|
|
@@ -91,6 +96,7 @@ import {
|
|
|
91
96
|
renderGithubAppInstallPage,
|
|
92
97
|
renderGithubAppManifestRedirectPage,
|
|
93
98
|
renderLoginPage,
|
|
99
|
+
type NewAgentTemplateItem,
|
|
94
100
|
renderNewLocalAgentPage,
|
|
95
101
|
renderProvisionCompletePage,
|
|
96
102
|
renderProvisionXappTokenPage,
|
|
@@ -738,17 +744,20 @@ async function redirectWithMembersWarning(
|
|
|
738
744
|
agentMemberService: Pick<AgentMemberService, "listByAgentId">,
|
|
739
745
|
agentId: string,
|
|
740
746
|
restrictSlackToMembers: boolean,
|
|
747
|
+
section: AgentSection,
|
|
741
748
|
) {
|
|
742
749
|
if (restrictSlackToMembers) {
|
|
743
750
|
const members = await agentMemberService.listByAgentId(agentId);
|
|
744
751
|
if (members.length === 0) {
|
|
745
752
|
return c.redirect(
|
|
746
|
-
|
|
753
|
+
agentSectionPath(agentId, section, {
|
|
754
|
+
warning: "restrict_slack_no_members",
|
|
755
|
+
}),
|
|
747
756
|
302,
|
|
748
757
|
);
|
|
749
758
|
}
|
|
750
759
|
}
|
|
751
|
-
return c.redirect(
|
|
760
|
+
return c.redirect(agentSectionPath(agentId, section), 302);
|
|
752
761
|
}
|
|
753
762
|
|
|
754
763
|
// ─── HTML helper ──────────────────────────────────────────────────────────────
|
|
@@ -847,6 +856,23 @@ export function createAgentAccessChecks(deps: {
|
|
|
847
856
|
/** Marketplace a bare plugin spec resolves to (the bundled one). */
|
|
848
857
|
const DEFAULT_PLUGIN_MARKETPLACE = "shipwright";
|
|
849
858
|
|
|
859
|
+
/**
|
|
860
|
+
* ATP-2.4: parse the create form's `KEY=value` lines (blank lines and `#`
|
|
861
|
+
* comments skipped). Null when a line is malformed.
|
|
862
|
+
*/
|
|
863
|
+
function parseEnvLines(raw: string | undefined): Record<string, string> | null {
|
|
864
|
+
const env: Record<string, string> = {};
|
|
865
|
+
for (const line of (raw ?? "").split(/\r?\n/)) {
|
|
866
|
+
const t = line.trim();
|
|
867
|
+
if (t === "" || t.startsWith("#")) continue;
|
|
868
|
+
const eq = t.indexOf("=");
|
|
869
|
+
const key = eq < 0 ? "" : t.slice(0, eq).trim();
|
|
870
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) return null;
|
|
871
|
+
env[key] = t.slice(eq + 1).trim();
|
|
872
|
+
}
|
|
873
|
+
return env;
|
|
874
|
+
}
|
|
875
|
+
|
|
850
876
|
/**
|
|
851
877
|
* Validate a plugin install spec and return its canonical
|
|
852
878
|
* "<plugin>@<marketplace>" form. Throws UnprocessableEntityError if malformed.
|
|
@@ -1524,6 +1550,38 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1524
1550
|
return accountIdFromScope(await callerScopeResolver(userEmail, false));
|
|
1525
1551
|
}
|
|
1526
1552
|
|
|
1553
|
+
// ATP-2.4: the template items a new agent in this scope would inherit,
|
|
1554
|
+
// flattened for display. Best effort: a failing lookup shows none.
|
|
1555
|
+
async function templateDefaultItems(
|
|
1556
|
+
isAdmin: boolean,
|
|
1557
|
+
accountId: string | null,
|
|
1558
|
+
): Promise<NewAgentTemplateItem[]> {
|
|
1559
|
+
if (!templateService) return [];
|
|
1560
|
+
try {
|
|
1561
|
+
const templates = await templateService.list(
|
|
1562
|
+
isAdmin || accountId === null
|
|
1563
|
+
? { kind: "admin" }
|
|
1564
|
+
: { kind: "account", accountId },
|
|
1565
|
+
);
|
|
1566
|
+
return templates.flatMap((t) => {
|
|
1567
|
+
const scope = `${t.accountId ? "account" : "all accounts"}, ${t.specialty ?? "all types"}`;
|
|
1568
|
+
return t.items.map((i): NewAgentTemplateItem => {
|
|
1569
|
+
const secret = i.payload.secret === true;
|
|
1570
|
+
return {
|
|
1571
|
+
kind: i.kind,
|
|
1572
|
+
key: i.key,
|
|
1573
|
+
...(i.kind === "env" && typeof i.payload.value === "string"
|
|
1574
|
+
? { value: secret ? "***" : i.payload.value }
|
|
1575
|
+
: {}),
|
|
1576
|
+
scope,
|
|
1577
|
+
};
|
|
1578
|
+
});
|
|
1579
|
+
});
|
|
1580
|
+
} catch {
|
|
1581
|
+
return [];
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1527
1585
|
app.get("/admin/agents/new", requireAuth, async (c) => {
|
|
1528
1586
|
const accountId = await resolveCreateAccountId(
|
|
1529
1587
|
c.var.userEmail,
|
|
@@ -1556,6 +1614,14 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1556
1614
|
canProvision: provisioner.canProvision,
|
|
1557
1615
|
anthropicFederationEnabled: deps.anthropicFederationEnabled,
|
|
1558
1616
|
...(selfServeOpts ? { selfServe: selfServeOpts } : {}),
|
|
1617
|
+
...(templateService
|
|
1618
|
+
? {
|
|
1619
|
+
template: {
|
|
1620
|
+
items: await templateDefaultItems(c.var.isAdmin, accountId),
|
|
1621
|
+
allowEnv: c.var.isAdmin === true,
|
|
1622
|
+
},
|
|
1623
|
+
}
|
|
1624
|
+
: {}),
|
|
1559
1625
|
}),
|
|
1560
1626
|
);
|
|
1561
1627
|
});
|
|
@@ -1589,8 +1655,12 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1589
1655
|
let ghAppId: string | undefined;
|
|
1590
1656
|
let ghAppInstallationId: string | undefined;
|
|
1591
1657
|
let ghAppPrivateKey: string | undefined;
|
|
1658
|
+
let templateDetachedRaw: string | undefined;
|
|
1659
|
+
let envRaw: string | undefined;
|
|
1592
1660
|
try {
|
|
1593
1661
|
const formData = await c.req.formData();
|
|
1662
|
+
templateDetachedRaw = formData.get("templateDetached")?.toString();
|
|
1663
|
+
envRaw = formData.get("env")?.toString();
|
|
1594
1664
|
name = formData.get("name")?.toString()?.trim();
|
|
1595
1665
|
specialty = formData.get("type")?.toString()?.trim();
|
|
1596
1666
|
reposRaw = formData.get("repos")?.toString()?.trim();
|
|
@@ -1628,6 +1698,15 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1628
1698
|
} catch {
|
|
1629
1699
|
return c.redirect("/admin/agents/new", 302);
|
|
1630
1700
|
}
|
|
1701
|
+
// ATP-2.4: explicit env entries (platform admins only) override template
|
|
1702
|
+
// defaults per key; the opt-out checkbox starts the agent detached.
|
|
1703
|
+
const explicitEnv = c.var.isAdmin ? parseEnvLines(envRaw) : {};
|
|
1704
|
+
if (explicitEnv === null) {
|
|
1705
|
+
return c.redirect(
|
|
1706
|
+
`/admin/agents/new?error=${encodeURIComponent("Env overrides must be KEY=value lines.")}`,
|
|
1707
|
+
302,
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1631
1710
|
const connectSlack = connectSlackRaw === "true";
|
|
1632
1711
|
// SSP-4.2: account users always create self-serve-specialty agents in their own
|
|
1633
1712
|
// account — any submitted type/accountId is ignored.
|
|
@@ -1695,6 +1774,8 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1695
1774
|
claudeCodeOauthToken,
|
|
1696
1775
|
anthropicApiKey,
|
|
1697
1776
|
...(accountId !== null ? { accountId } : {}),
|
|
1777
|
+
...(templateDetachedRaw === "true" ? { templateDetached: true } : {}),
|
|
1778
|
+
...(Object.keys(explicitEnv).length > 0 ? { env: explicitEnv } : {}),
|
|
1698
1779
|
// PAI-1.2: owner is the authenticated session user, never form data.
|
|
1699
1780
|
ownerEmail: c.var.userEmail,
|
|
1700
1781
|
},
|
|
@@ -1840,6 +1921,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1840
1921
|
agentMemberService,
|
|
1841
1922
|
agent.id,
|
|
1842
1923
|
restrictSlackToMembers,
|
|
1924
|
+
"general",
|
|
1843
1925
|
);
|
|
1844
1926
|
});
|
|
1845
1927
|
|
|
@@ -1919,7 +2001,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1919
2001
|
}),
|
|
1920
2002
|
},
|
|
1921
2003
|
);
|
|
1922
|
-
const base =
|
|
2004
|
+
const base = agentSectionPath(agentId, "access");
|
|
1923
2005
|
if (res?.ok) {
|
|
1924
2006
|
return c.redirect(
|
|
1925
2007
|
`${base}?success=${username === "" ? "github_username_cleared" : "github_username_saved"}`,
|
|
@@ -1933,7 +2015,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1933
2015
|
} catch {
|
|
1934
2016
|
// keep the generic message
|
|
1935
2017
|
}
|
|
1936
|
-
return c.redirect(
|
|
2018
|
+
return c.redirect(
|
|
2019
|
+
agentSectionPath(agentId, "access", { error: message }),
|
|
2020
|
+
302,
|
|
2021
|
+
);
|
|
1937
2022
|
});
|
|
1938
2023
|
|
|
1939
2024
|
app.get("/admin/agents/:id/github-access", requireAuth, async (c) => {
|
|
@@ -2196,8 +2281,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2196
2281
|
},
|
|
2197
2282
|
);
|
|
2198
2283
|
|
|
2199
|
-
|
|
2200
|
-
const agentId = c.req.param("id");
|
|
2284
|
+
const agentDetailHandler = async (c: Context<AdminUIEnv, any>) => {
|
|
2285
|
+
const agentId = c.req.param("id") ?? "";
|
|
2286
|
+
const sectionParam = c.req.param("section") ?? "general";
|
|
2287
|
+
if (!isAgentSection(sectionParam)) {
|
|
2288
|
+
return new Response("Not found", { status: 404 });
|
|
2289
|
+
}
|
|
2290
|
+
const section: AgentSection = sectionParam;
|
|
2201
2291
|
const agent = await agentService.getDetail(agentId);
|
|
2202
2292
|
if (!agent) {
|
|
2203
2293
|
return new Response("Agent not found", { status: 404 });
|
|
@@ -2321,6 +2411,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2321
2411
|
c.var.userEmail,
|
|
2322
2412
|
c.var.isAdmin,
|
|
2323
2413
|
{
|
|
2414
|
+
section,
|
|
2324
2415
|
canManage: canManageAgents(c.var.isAdmin),
|
|
2325
2416
|
error,
|
|
2326
2417
|
newToken,
|
|
@@ -2333,10 +2424,22 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2333
2424
|
marketplaces,
|
|
2334
2425
|
githubEnterpriseConfigured: enterpriseConfigured,
|
|
2335
2426
|
...(installationRepos ? { installationRepos } : {}),
|
|
2427
|
+
...(agentsApi
|
|
2428
|
+
? { template: { detached: agent.templateDetached === true } }
|
|
2429
|
+
: {}),
|
|
2336
2430
|
},
|
|
2337
2431
|
),
|
|
2338
2432
|
);
|
|
2339
|
-
}
|
|
2433
|
+
};
|
|
2434
|
+
app.get("/admin/agents/:id", requireAuth, agentDetailHandler);
|
|
2435
|
+
// Constrained to the known sections so other /admin/agents/:id/<x> GET routes
|
|
2436
|
+
// (extension-mounted pages) still match; an unknown section falls through to
|
|
2437
|
+
// the default 404.
|
|
2438
|
+
app.get(
|
|
2439
|
+
`/admin/agents/:id/:section{${AGENT_SECTIONS.join("|")}}`,
|
|
2440
|
+
requireAuth,
|
|
2441
|
+
agentDetailHandler,
|
|
2442
|
+
);
|
|
2340
2443
|
|
|
2341
2444
|
// ─── Env var mutations ────────────────────────────────────────────────────
|
|
2342
2445
|
|
|
@@ -2354,7 +2457,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2354
2457
|
value = formData.get("value")?.toString();
|
|
2355
2458
|
secretStr = formData.get("secret")?.toString();
|
|
2356
2459
|
} catch {
|
|
2357
|
-
return c.redirect(
|
|
2460
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2358
2461
|
}
|
|
2359
2462
|
if (key && value !== undefined) {
|
|
2360
2463
|
const isSecret = secretStr === "true";
|
|
@@ -2369,14 +2472,14 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2369
2472
|
// value) on the agent page instead of a 500.
|
|
2370
2473
|
if (err instanceof AnthropicCredentialsBlockedError) {
|
|
2371
2474
|
return c.redirect(
|
|
2372
|
-
|
|
2475
|
+
agentSectionPath(agentId, "configuration", { error: err.message }),
|
|
2373
2476
|
302,
|
|
2374
2477
|
);
|
|
2375
2478
|
}
|
|
2376
2479
|
throw err;
|
|
2377
2480
|
}
|
|
2378
2481
|
}
|
|
2379
|
-
return c.redirect(
|
|
2482
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2380
2483
|
});
|
|
2381
2484
|
|
|
2382
2485
|
app.post("/admin/agents/:id/envs/delete", requireAuth, async (c) => {
|
|
@@ -2389,12 +2492,98 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2389
2492
|
const formData = await c.req.formData();
|
|
2390
2493
|
key = formData.get("key")?.toString();
|
|
2391
2494
|
} catch {
|
|
2392
|
-
return c.redirect(
|
|
2495
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2393
2496
|
}
|
|
2394
2497
|
if (key) {
|
|
2395
2498
|
await agentEnvService.deleteKey(agentId, key);
|
|
2396
2499
|
}
|
|
2397
|
-
return c.redirect(
|
|
2500
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2501
|
+
});
|
|
2502
|
+
|
|
2503
|
+
// ─── Agent template (ATP-2.4) ─────────────────────────────────────────────
|
|
2504
|
+
// Thin forwards to the ATP-2.2 endpoints through the agents API seam, with
|
|
2505
|
+
// the caller's session cookie, so its own auth and 409 rules apply.
|
|
2506
|
+
|
|
2507
|
+
// A per-item reset lands on the section whose row it was clicked from.
|
|
2508
|
+
const TEMPLATE_KIND_SECTIONS: Record<string, AgentSection> = {
|
|
2509
|
+
env: "configuration",
|
|
2510
|
+
tool: "extensions",
|
|
2511
|
+
plugin: "extensions",
|
|
2512
|
+
cron: "automation",
|
|
2513
|
+
};
|
|
2514
|
+
const TEMPLATE_KINDS = Object.keys(TEMPLATE_KIND_SECTIONS);
|
|
2515
|
+
|
|
2516
|
+
async function templateAction(
|
|
2517
|
+
c: Context<AdminUIEnv>,
|
|
2518
|
+
action: "detach" | "reattach" | "reset",
|
|
2519
|
+
body?: Record<string, string>,
|
|
2520
|
+
section: AgentSection = "configuration",
|
|
2521
|
+
): Promise<Response> {
|
|
2522
|
+
const agentId = c.req.param("id") ?? "";
|
|
2523
|
+
if (!agentsApi) return new Response("Not found", { status: 404 });
|
|
2524
|
+
if (!(await assertAgentAccess(agentId, c.var.userEmail, c.var.isAdmin))) {
|
|
2525
|
+
return new Response("Forbidden", { status: 403 });
|
|
2526
|
+
}
|
|
2527
|
+
const res = await callApi(
|
|
2528
|
+
c,
|
|
2529
|
+
agentsApi,
|
|
2530
|
+
`/agents/${encodeURIComponent(agentId)}/template/${action}`,
|
|
2531
|
+
{
|
|
2532
|
+
method: "POST",
|
|
2533
|
+
...(body
|
|
2534
|
+
? {
|
|
2535
|
+
headers: { "content-type": "application/json" },
|
|
2536
|
+
body: JSON.stringify(body),
|
|
2537
|
+
}
|
|
2538
|
+
: {}),
|
|
2539
|
+
},
|
|
2540
|
+
);
|
|
2541
|
+
if (res?.ok) return c.redirect(agentSectionPath(agentId, section), 302);
|
|
2542
|
+
let message = "Could not update the agent template.";
|
|
2543
|
+
try {
|
|
2544
|
+
const j = (await res?.json()) as { error?: unknown };
|
|
2545
|
+
if (typeof j.error === "string" && j.error) message = j.error;
|
|
2546
|
+
} catch {
|
|
2547
|
+
// keep the generic message
|
|
2548
|
+
}
|
|
2549
|
+
return c.redirect(
|
|
2550
|
+
agentSectionPath(agentId, section, { error: message }),
|
|
2551
|
+
302,
|
|
2552
|
+
);
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
app.post("/admin/agents/:id/template/detach", requireAuth, (c) =>
|
|
2556
|
+
templateAction(c, "detach"),
|
|
2557
|
+
);
|
|
2558
|
+
|
|
2559
|
+
app.post("/admin/agents/:id/template/reattach", requireAuth, (c) =>
|
|
2560
|
+
templateAction(c, "reattach"),
|
|
2561
|
+
);
|
|
2562
|
+
|
|
2563
|
+
app.post("/admin/agents/:id/template/reset", requireAuth, async (c) => {
|
|
2564
|
+
let kind = "";
|
|
2565
|
+
let key = "";
|
|
2566
|
+
try {
|
|
2567
|
+
const form = await c.req.formData();
|
|
2568
|
+
kind = form.get("kind")?.toString() ?? "";
|
|
2569
|
+
key = form.get("key")?.toString() ?? "";
|
|
2570
|
+
} catch {
|
|
2571
|
+
// no body: reset everything
|
|
2572
|
+
}
|
|
2573
|
+
if (kind !== "" && (!TEMPLATE_KINDS.includes(kind) || key === "")) {
|
|
2574
|
+
return c.redirect(
|
|
2575
|
+
agentSectionPath(c.req.param("id"), "configuration", {
|
|
2576
|
+
error: "Unknown template item to reset.",
|
|
2577
|
+
}),
|
|
2578
|
+
302,
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
return templateAction(
|
|
2582
|
+
c,
|
|
2583
|
+
"reset",
|
|
2584
|
+
kind === "" ? {} : { kind, key },
|
|
2585
|
+
TEMPLATE_KIND_SECTIONS[kind] ?? "configuration",
|
|
2586
|
+
);
|
|
2398
2587
|
});
|
|
2399
2588
|
|
|
2400
2589
|
// ─── Repo mutations ───────────────────────────────────────────────────────
|
|
@@ -2409,11 +2598,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2409
2598
|
const formData = await c.req.formData();
|
|
2410
2599
|
repo = formData.get("repo")?.toString()?.trim();
|
|
2411
2600
|
} catch {
|
|
2412
|
-
return c.redirect(
|
|
2601
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2413
2602
|
}
|
|
2414
2603
|
if (!repo || !isOrgRepo(repo)) {
|
|
2415
2604
|
return c.redirect(
|
|
2416
|
-
|
|
2605
|
+
agentSectionPath(agentId, "configuration", {
|
|
2606
|
+
error: "invalid_repo_format",
|
|
2607
|
+
}),
|
|
2417
2608
|
302,
|
|
2418
2609
|
);
|
|
2419
2610
|
}
|
|
@@ -2426,12 +2617,12 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2426
2617
|
const collision = describeRepoNameCollision(deduped);
|
|
2427
2618
|
if (collision) {
|
|
2428
2619
|
return c.redirect(
|
|
2429
|
-
|
|
2620
|
+
agentSectionPath(agentId, "configuration", { error: collision }),
|
|
2430
2621
|
302,
|
|
2431
2622
|
);
|
|
2432
2623
|
}
|
|
2433
2624
|
await agentService.updateFields(agentId, { repos: deduped });
|
|
2434
|
-
return c.redirect(
|
|
2625
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2435
2626
|
});
|
|
2436
2627
|
|
|
2437
2628
|
app.post("/admin/agents/:id/repos/delete", requireAuth, async (c) => {
|
|
@@ -2444,7 +2635,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2444
2635
|
const formData = await c.req.formData();
|
|
2445
2636
|
repo = formData.get("repo")?.toString()?.trim();
|
|
2446
2637
|
} catch {
|
|
2447
|
-
return c.redirect(
|
|
2638
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2448
2639
|
}
|
|
2449
2640
|
if (repo) {
|
|
2450
2641
|
const agent = await agentService.getDetail(agentId);
|
|
@@ -2454,7 +2645,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2454
2645
|
const updated = (agent.repos ?? []).filter((r) => r !== repo);
|
|
2455
2646
|
await agentService.updateFields(agentId, { repos: updated });
|
|
2456
2647
|
}
|
|
2457
|
-
return c.redirect(
|
|
2648
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2458
2649
|
});
|
|
2459
2650
|
|
|
2460
2651
|
// ─── Author allowlist (review) mutations ───────────────────────────────────
|
|
@@ -2472,11 +2663,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2472
2663
|
const formData = await c.req.formData();
|
|
2473
2664
|
login = formData.get("login")?.toString()?.trim();
|
|
2474
2665
|
} catch {
|
|
2475
|
-
return c.redirect(
|
|
2666
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2476
2667
|
}
|
|
2477
2668
|
if (!login || !isGithubLogin(login)) {
|
|
2478
2669
|
return c.redirect(
|
|
2479
|
-
|
|
2670
|
+
agentSectionPath(agentId, "access", {
|
|
2671
|
+
error: "invalid_author_allowlist_format",
|
|
2672
|
+
}),
|
|
2480
2673
|
302,
|
|
2481
2674
|
);
|
|
2482
2675
|
}
|
|
@@ -2491,7 +2684,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2491
2684
|
await agentService.updateFields(agentId, {
|
|
2492
2685
|
reviewAuthorAllowlist: deduped,
|
|
2493
2686
|
});
|
|
2494
|
-
return c.redirect(
|
|
2687
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2495
2688
|
},
|
|
2496
2689
|
);
|
|
2497
2690
|
|
|
@@ -2508,7 +2701,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2508
2701
|
const formData = await c.req.formData();
|
|
2509
2702
|
login = formData.get("login")?.toString()?.trim();
|
|
2510
2703
|
} catch {
|
|
2511
|
-
return c.redirect(
|
|
2704
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2512
2705
|
}
|
|
2513
2706
|
if (login) {
|
|
2514
2707
|
const agent = await agentService.getDetail(agentId);
|
|
@@ -2522,7 +2715,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2522
2715
|
reviewAuthorAllowlist: updated,
|
|
2523
2716
|
});
|
|
2524
2717
|
}
|
|
2525
|
-
return c.redirect(
|
|
2718
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2526
2719
|
},
|
|
2527
2720
|
);
|
|
2528
2721
|
|
|
@@ -2541,11 +2734,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2541
2734
|
const formData = await c.req.formData();
|
|
2542
2735
|
login = formData.get("login")?.toString()?.trim();
|
|
2543
2736
|
} catch {
|
|
2544
|
-
return c.redirect(
|
|
2737
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2545
2738
|
}
|
|
2546
2739
|
if (!login || !isGithubLogin(login)) {
|
|
2547
2740
|
return c.redirect(
|
|
2548
|
-
|
|
2741
|
+
agentSectionPath(agentId, "access", {
|
|
2742
|
+
error: "invalid_author_allowlist_format",
|
|
2743
|
+
}),
|
|
2549
2744
|
302,
|
|
2550
2745
|
);
|
|
2551
2746
|
}
|
|
@@ -2560,7 +2755,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2560
2755
|
await agentService.updateFields(agentId, {
|
|
2561
2756
|
patchAuthorAllowlist: deduped,
|
|
2562
2757
|
});
|
|
2563
|
-
return c.redirect(
|
|
2758
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2564
2759
|
},
|
|
2565
2760
|
);
|
|
2566
2761
|
|
|
@@ -2577,7 +2772,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2577
2772
|
const formData = await c.req.formData();
|
|
2578
2773
|
login = formData.get("login")?.toString()?.trim();
|
|
2579
2774
|
} catch {
|
|
2580
|
-
return c.redirect(
|
|
2775
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2581
2776
|
}
|
|
2582
2777
|
if (login) {
|
|
2583
2778
|
const agent = await agentService.getDetail(agentId);
|
|
@@ -2591,7 +2786,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2591
2786
|
patchAuthorAllowlist: updated,
|
|
2592
2787
|
});
|
|
2593
2788
|
}
|
|
2594
|
-
return c.redirect(
|
|
2789
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
2595
2790
|
},
|
|
2596
2791
|
);
|
|
2597
2792
|
|
|
@@ -2621,7 +2816,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2621
2816
|
try {
|
|
2622
2817
|
formData = await c.req.formData();
|
|
2623
2818
|
} catch {
|
|
2624
|
-
return c.redirect(
|
|
2819
|
+
return c.redirect(agentSectionPath(agentId, "configuration"), 302);
|
|
2625
2820
|
}
|
|
2626
2821
|
|
|
2627
2822
|
const readBool = (name: string): boolean | undefined => {
|
|
@@ -2673,6 +2868,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2673
2868
|
agentMemberService,
|
|
2674
2869
|
agent.id,
|
|
2675
2870
|
agent.restrictSlackToMembers,
|
|
2871
|
+
settingsRedirectSection(formData),
|
|
2676
2872
|
);
|
|
2677
2873
|
});
|
|
2678
2874
|
|
|
@@ -2704,10 +2900,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2704
2900
|
enabled = enabledVal === "on" || enabledVal === "true";
|
|
2705
2901
|
name = formData.get("name")?.toString() || null;
|
|
2706
2902
|
} catch {
|
|
2707
|
-
return c.redirect(
|
|
2903
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2708
2904
|
}
|
|
2709
2905
|
if (!schedule || !prompt) {
|
|
2710
|
-
return c.redirect(
|
|
2906
|
+
return c.redirect(
|
|
2907
|
+
agentSectionPath(agentId, "automation", { error: "missing_fields" }),
|
|
2908
|
+
302,
|
|
2909
|
+
);
|
|
2711
2910
|
}
|
|
2712
2911
|
try {
|
|
2713
2912
|
await agentCronJobService.create(agentId, {
|
|
@@ -2724,7 +2923,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2724
2923
|
const msg = err.message.toLowerCase();
|
|
2725
2924
|
if (msg.includes("invalid cron")) {
|
|
2726
2925
|
return c.redirect(
|
|
2727
|
-
|
|
2926
|
+
agentSectionPath(agentId, "automation", {
|
|
2927
|
+
error: "invalid_schedule",
|
|
2928
|
+
}),
|
|
2728
2929
|
302,
|
|
2729
2930
|
);
|
|
2730
2931
|
}
|
|
@@ -2734,14 +2935,19 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2734
2935
|
msg.includes("target")
|
|
2735
2936
|
) {
|
|
2736
2937
|
return c.redirect(
|
|
2737
|
-
|
|
2938
|
+
agentSectionPath(agentId, "automation", {
|
|
2939
|
+
error: "invalid_target",
|
|
2940
|
+
}),
|
|
2738
2941
|
302,
|
|
2739
2942
|
);
|
|
2740
2943
|
}
|
|
2741
2944
|
}
|
|
2742
|
-
return c.redirect(
|
|
2945
|
+
return c.redirect(
|
|
2946
|
+
agentSectionPath(agentId, "automation", { error: "create_failed" }),
|
|
2947
|
+
302,
|
|
2948
|
+
);
|
|
2743
2949
|
}
|
|
2744
|
-
return c.redirect(
|
|
2950
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2745
2951
|
});
|
|
2746
2952
|
|
|
2747
2953
|
app.post("/admin/agents/:id/crons/:cronId/toggle", requireAuth, async (c) => {
|
|
@@ -2762,7 +2968,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2762
2968
|
} catch {
|
|
2763
2969
|
// ignore errors — redirect back regardless
|
|
2764
2970
|
}
|
|
2765
|
-
return c.redirect(
|
|
2971
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2766
2972
|
});
|
|
2767
2973
|
|
|
2768
2974
|
app.post("/admin/agents/:id/crons/:cronId/update", requireAuth, async (c) => {
|
|
@@ -2788,7 +2994,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2788
2994
|
}
|
|
2789
2995
|
if (!schedule || !prompt) {
|
|
2790
2996
|
return c.redirect(
|
|
2791
|
-
|
|
2997
|
+
agentSectionPath(agentId, "automation", {
|
|
2998
|
+
error: "schedule and prompt are required",
|
|
2999
|
+
}),
|
|
2792
3000
|
302,
|
|
2793
3001
|
);
|
|
2794
3002
|
}
|
|
@@ -2800,7 +3008,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2800
3008
|
const existing = await agentCronJobService.get(agentId, cronId);
|
|
2801
3009
|
if (existing.system) {
|
|
2802
3010
|
return c.redirect(
|
|
2803
|
-
|
|
3011
|
+
agentSectionPath(agentId, "automation", {
|
|
3012
|
+
error: "system crons cannot be edited",
|
|
3013
|
+
}),
|
|
2804
3014
|
302,
|
|
2805
3015
|
);
|
|
2806
3016
|
}
|
|
@@ -2815,13 +3025,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2815
3025
|
} catch (err) {
|
|
2816
3026
|
// Surface validation errors (e.g. invalid cron expression) back to the page.
|
|
2817
3027
|
return c.redirect(
|
|
2818
|
-
|
|
2819
|
-
err instanceof Error ? err.message : "cron update failed",
|
|
2820
|
-
)
|
|
3028
|
+
agentSectionPath(agentId, "automation", {
|
|
3029
|
+
error: err instanceof Error ? err.message : "cron update failed",
|
|
3030
|
+
}),
|
|
2821
3031
|
302,
|
|
2822
3032
|
);
|
|
2823
3033
|
}
|
|
2824
|
-
return c.redirect(
|
|
3034
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2825
3035
|
});
|
|
2826
3036
|
|
|
2827
3037
|
app.post("/admin/agents/:id/crons/:cronId/delete", requireAuth, async (c) => {
|
|
@@ -2839,13 +3049,13 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2839
3049
|
} catch (err) {
|
|
2840
3050
|
if (err instanceof ForbiddenError) {
|
|
2841
3051
|
return c.redirect(
|
|
2842
|
-
|
|
3052
|
+
agentSectionPath(agentId, "automation", { error: err.message }),
|
|
2843
3053
|
302,
|
|
2844
3054
|
);
|
|
2845
3055
|
}
|
|
2846
3056
|
// other errors (NotFoundError, etc.) — redirect back silently
|
|
2847
3057
|
}
|
|
2848
|
-
return c.redirect(
|
|
3058
|
+
return c.redirect(agentSectionPath(agentId, "automation"), 302);
|
|
2849
3059
|
});
|
|
2850
3060
|
|
|
2851
3061
|
// ─── Tool mutations ───────────────────────────────────────────────────────
|
|
@@ -2860,17 +3070,20 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2860
3070
|
const formData = await c.req.formData();
|
|
2861
3071
|
pattern = formData.get("pattern")?.toString();
|
|
2862
3072
|
} catch {
|
|
2863
|
-
return c.redirect(
|
|
3073
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2864
3074
|
}
|
|
2865
3075
|
if (!pattern) {
|
|
2866
|
-
return c.redirect(
|
|
3076
|
+
return c.redirect(
|
|
3077
|
+
agentSectionPath(agentId, "extensions", { error: "missing_fields" }),
|
|
3078
|
+
302,
|
|
3079
|
+
);
|
|
2867
3080
|
}
|
|
2868
3081
|
try {
|
|
2869
3082
|
await agentToolService.add(agentId, pattern);
|
|
2870
3083
|
} catch {
|
|
2871
3084
|
// ignore errors — redirect back regardless
|
|
2872
3085
|
}
|
|
2873
|
-
return c.redirect(
|
|
3086
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2874
3087
|
});
|
|
2875
3088
|
|
|
2876
3089
|
app.post("/admin/agents/:id/tools/:toolId/toggle", requireAuth, async (c) => {
|
|
@@ -2891,7 +3104,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2891
3104
|
} catch {
|
|
2892
3105
|
// ignore errors — redirect back regardless
|
|
2893
3106
|
}
|
|
2894
|
-
return c.redirect(
|
|
3107
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2895
3108
|
});
|
|
2896
3109
|
|
|
2897
3110
|
app.post("/admin/agents/:id/tools/:toolId/delete", requireAuth, async (c) => {
|
|
@@ -2905,7 +3118,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2905
3118
|
} catch {
|
|
2906
3119
|
// ignore errors — redirect back regardless
|
|
2907
3120
|
}
|
|
2908
|
-
return c.redirect(
|
|
3121
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2909
3122
|
});
|
|
2910
3123
|
|
|
2911
3124
|
// ─── Marketplace mutations (PMK-1.5) ──────────────────────────────────────
|
|
@@ -2926,23 +3139,26 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2926
3139
|
source = formData.get("source")?.toString().trim();
|
|
2927
3140
|
ref = formData.get("ref")?.toString().trim() || undefined;
|
|
2928
3141
|
} catch {
|
|
2929
|
-
return c.redirect(
|
|
3142
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2930
3143
|
}
|
|
2931
3144
|
if (!name || !source) {
|
|
2932
|
-
return c.redirect(
|
|
3145
|
+
return c.redirect(
|
|
3146
|
+
agentSectionPath(agentId, "extensions", { error: "missing_fields" }),
|
|
3147
|
+
302,
|
|
3148
|
+
);
|
|
2933
3149
|
}
|
|
2934
3150
|
try {
|
|
2935
3151
|
await agentMarketplaceService?.upsert(agentId, { name, source, ref });
|
|
2936
3152
|
} catch (err) {
|
|
2937
3153
|
if (err instanceof UnprocessableEntityError) {
|
|
2938
3154
|
return c.redirect(
|
|
2939
|
-
|
|
3155
|
+
agentSectionPath(agentId, "extensions", { error: err.message }),
|
|
2940
3156
|
302,
|
|
2941
3157
|
);
|
|
2942
3158
|
}
|
|
2943
3159
|
// other errors — redirect back silently, like the tool routes
|
|
2944
3160
|
}
|
|
2945
|
-
return c.redirect(
|
|
3161
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2946
3162
|
});
|
|
2947
3163
|
|
|
2948
3164
|
app.post("/admin/agents/:id/marketplaces/delete", requireAuth, async (c) => {
|
|
@@ -2955,7 +3171,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2955
3171
|
const formData = await c.req.formData();
|
|
2956
3172
|
marketplaceId = formData.get("marketplaceId")?.toString();
|
|
2957
3173
|
} catch {
|
|
2958
|
-
return c.redirect(
|
|
3174
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2959
3175
|
}
|
|
2960
3176
|
if (marketplaceId) {
|
|
2961
3177
|
try {
|
|
@@ -2964,7 +3180,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2964
3180
|
// already gone, ignore
|
|
2965
3181
|
}
|
|
2966
3182
|
}
|
|
2967
|
-
return c.redirect(
|
|
3183
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2968
3184
|
});
|
|
2969
3185
|
|
|
2970
3186
|
// ─── Plugin mutations (PUI-1.2) ───────────────────────────────────────────
|
|
@@ -2982,11 +3198,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2982
3198
|
const formData = await c.req.formData();
|
|
2983
3199
|
raw = formData.get("spec")?.toString().trim();
|
|
2984
3200
|
} catch {
|
|
2985
|
-
return c.redirect(
|
|
3201
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
2986
3202
|
}
|
|
2987
3203
|
const redirectError = (message: string) =>
|
|
2988
3204
|
c.redirect(
|
|
2989
|
-
|
|
3205
|
+
agentSectionPath(agentId, "extensions", { error: message }),
|
|
2990
3206
|
302,
|
|
2991
3207
|
);
|
|
2992
3208
|
if (!raw) return redirectError("missing_fields");
|
|
@@ -2998,7 +3214,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2998
3214
|
}
|
|
2999
3215
|
// other errors — redirect back silently, like the tool routes
|
|
3000
3216
|
}
|
|
3001
|
-
return c.redirect(
|
|
3217
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3002
3218
|
});
|
|
3003
3219
|
|
|
3004
3220
|
app.post("/admin/agents/:id/plugins/delete", requireAuth, async (c) => {
|
|
@@ -3011,7 +3227,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3011
3227
|
const formData = await c.req.formData();
|
|
3012
3228
|
pluginId = formData.get("pluginId")?.toString();
|
|
3013
3229
|
} catch {
|
|
3014
|
-
return c.redirect(
|
|
3230
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3015
3231
|
}
|
|
3016
3232
|
if (pluginId) {
|
|
3017
3233
|
try {
|
|
@@ -3020,7 +3236,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3020
3236
|
// already gone, ignore
|
|
3021
3237
|
}
|
|
3022
3238
|
}
|
|
3023
|
-
return c.redirect(
|
|
3239
|
+
return c.redirect(agentSectionPath(agentId, "extensions"), 302);
|
|
3024
3240
|
});
|
|
3025
3241
|
|
|
3026
3242
|
// ─── Token mutations ──────────────────────────────────────────────────────
|
|
@@ -3035,7 +3251,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3035
3251
|
const formData = await c.req.formData();
|
|
3036
3252
|
label = formData.get("label")?.toString() || undefined;
|
|
3037
3253
|
} catch {
|
|
3038
|
-
return c.redirect(
|
|
3254
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3039
3255
|
}
|
|
3040
3256
|
const agent = await agentService.getDetail(agentId);
|
|
3041
3257
|
if (!agent) {
|
|
@@ -3110,6 +3326,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3110
3326
|
c.var.userEmail,
|
|
3111
3327
|
c.var.isAdmin,
|
|
3112
3328
|
{
|
|
3329
|
+
section: "access",
|
|
3113
3330
|
canManage: canManageAgents(c.var.isAdmin),
|
|
3114
3331
|
newToken: rawToken,
|
|
3115
3332
|
timezone,
|
|
@@ -3118,11 +3335,17 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3118
3335
|
queueActivityLinks: deps.queueActivityLinks,
|
|
3119
3336
|
marketplaces,
|
|
3120
3337
|
githubEnterpriseConfigured: await githubEnterpriseConfigured(c),
|
|
3338
|
+
...(agentsApi
|
|
3339
|
+
? { template: { detached: agent.templateDetached === true } }
|
|
3340
|
+
: {}),
|
|
3121
3341
|
},
|
|
3122
3342
|
),
|
|
3123
3343
|
);
|
|
3124
3344
|
} catch {
|
|
3125
|
-
return c.redirect(
|
|
3345
|
+
return c.redirect(
|
|
3346
|
+
agentSectionPath(agentId, "access", { error: "create_failed" }),
|
|
3347
|
+
302,
|
|
3348
|
+
);
|
|
3126
3349
|
}
|
|
3127
3350
|
});
|
|
3128
3351
|
|
|
@@ -3140,7 +3363,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3140
3363
|
} catch {
|
|
3141
3364
|
// ignore errors — redirect back regardless
|
|
3142
3365
|
}
|
|
3143
|
-
return c.redirect(
|
|
3366
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3144
3367
|
},
|
|
3145
3368
|
);
|
|
3146
3369
|
|
|
@@ -3166,12 +3389,17 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3166
3389
|
const formData = await c.req.formData();
|
|
3167
3390
|
xoxpToken = formData.get("xoxpToken")?.toString();
|
|
3168
3391
|
} catch {
|
|
3169
|
-
return c.redirect(
|
|
3392
|
+
return c.redirect(
|
|
3393
|
+
agentSectionPath(agentId, "general", { error: "missing_fields" }),
|
|
3394
|
+
302,
|
|
3395
|
+
);
|
|
3170
3396
|
}
|
|
3171
3397
|
|
|
3172
3398
|
if (!xoxpToken?.startsWith("xoxe.xoxp-")) {
|
|
3173
3399
|
return c.redirect(
|
|
3174
|
-
|
|
3400
|
+
agentSectionPath(agentId, "general", {
|
|
3401
|
+
error: "Slack app configuration token must start with xoxe.xoxp-",
|
|
3402
|
+
}),
|
|
3175
3403
|
302,
|
|
3176
3404
|
);
|
|
3177
3405
|
}
|
|
@@ -3180,7 +3408,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3180
3408
|
const appId = envBundle?.env.SLACK_APP_ID;
|
|
3181
3409
|
if (!appId) {
|
|
3182
3410
|
return c.redirect(
|
|
3183
|
-
|
|
3411
|
+
agentSectionPath(agentId, "general", {
|
|
3412
|
+
error: "SLACK_APP_ID is not set — provision the agent first.",
|
|
3413
|
+
}),
|
|
3184
3414
|
302,
|
|
3185
3415
|
);
|
|
3186
3416
|
}
|
|
@@ -3193,7 +3423,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3193
3423
|
const msg =
|
|
3194
3424
|
err instanceof Error ? err.message : "Unknown error syncing manifest.";
|
|
3195
3425
|
return c.redirect(
|
|
3196
|
-
|
|
3426
|
+
agentSectionPath(agentId, "general", { error: msg }),
|
|
3197
3427
|
302,
|
|
3198
3428
|
);
|
|
3199
3429
|
}
|
|
@@ -3243,7 +3473,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3243
3473
|
);
|
|
3244
3474
|
}
|
|
3245
3475
|
|
|
3246
|
-
return c.redirect(
|
|
3476
|
+
return c.redirect(
|
|
3477
|
+
agentSectionPath(agentId, "general", { success: "manifest_synced" }),
|
|
3478
|
+
302,
|
|
3479
|
+
);
|
|
3247
3480
|
});
|
|
3248
3481
|
|
|
3249
3482
|
// ─── connect-slack (UAP-1.1) ───────────────────────────────────────────────
|
|
@@ -3263,7 +3496,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3263
3496
|
const formData = await c.req.formData();
|
|
3264
3497
|
xoxpToken = formData.get("xoxpToken")?.toString();
|
|
3265
3498
|
} catch {
|
|
3266
|
-
return c.redirect(
|
|
3499
|
+
return c.redirect(
|
|
3500
|
+
agentSectionPath(agentId, "access", { error: "missing_fields" }),
|
|
3501
|
+
302,
|
|
3502
|
+
);
|
|
3267
3503
|
}
|
|
3268
3504
|
|
|
3269
3505
|
const result = await slackProvisioningService.startConnect(
|
|
@@ -3274,7 +3510,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3274
3510
|
|
|
3275
3511
|
if (!result.ok) {
|
|
3276
3512
|
return c.redirect(
|
|
3277
|
-
|
|
3513
|
+
agentSectionPath(agentId, "access", { error: result.error }),
|
|
3278
3514
|
302,
|
|
3279
3515
|
);
|
|
3280
3516
|
}
|
|
@@ -3352,7 +3588,10 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3352
3588
|
const query = ghConnectWarning
|
|
3353
3589
|
? `?success=reinstalled&warning=${encodeURIComponent(ghConnectWarning)}`
|
|
3354
3590
|
: "?success=reinstalled";
|
|
3355
|
-
return c.redirect(
|
|
3591
|
+
return c.redirect(
|
|
3592
|
+
`${agentSectionPath(result.agentId, "access")}${query}`,
|
|
3593
|
+
302,
|
|
3594
|
+
);
|
|
3356
3595
|
}
|
|
3357
3596
|
|
|
3358
3597
|
// result.outcome === "needs_app_token"
|
|
@@ -3671,7 +3910,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3671
3910
|
const result = await githubProvisioningService.getAddOrgUrl(agentId);
|
|
3672
3911
|
if (!result.ok) {
|
|
3673
3912
|
return c.redirect(
|
|
3674
|
-
|
|
3913
|
+
agentSectionPath(agentId, "access", { error: result.error }),
|
|
3675
3914
|
302,
|
|
3676
3915
|
);
|
|
3677
3916
|
}
|
|
@@ -3697,7 +3936,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3697
3936
|
const formData = await c.req.formData();
|
|
3698
3937
|
email = formData.get("email")?.toString()?.toLowerCase();
|
|
3699
3938
|
} catch {
|
|
3700
|
-
return c.redirect(
|
|
3939
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3701
3940
|
}
|
|
3702
3941
|
if (email) {
|
|
3703
3942
|
try {
|
|
@@ -3706,7 +3945,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3706
3945
|
// unique constraint violation — already a member, ignore
|
|
3707
3946
|
}
|
|
3708
3947
|
}
|
|
3709
|
-
return c.redirect(
|
|
3948
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3710
3949
|
});
|
|
3711
3950
|
|
|
3712
3951
|
app.post("/admin/agents/:id/members/delete", requireAuth, async (c) => {
|
|
@@ -3721,7 +3960,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3721
3960
|
const formData = await c.req.formData();
|
|
3722
3961
|
memberId = formData.get("memberId")?.toString();
|
|
3723
3962
|
} catch {
|
|
3724
|
-
return c.redirect(
|
|
3963
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3725
3964
|
}
|
|
3726
3965
|
if (memberId) {
|
|
3727
3966
|
try {
|
|
@@ -3730,7 +3969,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
3730
3969
|
// already gone, ignore
|
|
3731
3970
|
}
|
|
3732
3971
|
}
|
|
3733
|
-
return c.redirect(
|
|
3972
|
+
return c.redirect(agentSectionPath(agentId, "access"), 302);
|
|
3734
3973
|
});
|
|
3735
3974
|
|
|
3736
3975
|
// ─── Enterprise GitHub apps settings (GHE-1.4) ───────────────────────────
|
|
@@ -4601,9 +4840,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
4601
4840
|
// steps still need a retry.
|
|
4602
4841
|
const failedSteps = result.failed.map((f) => f.step).join(", ");
|
|
4603
4842
|
return c.redirect(
|
|
4604
|
-
|
|
4605
|
-
`Cleanup incomplete — retry. Failed steps: ${failedSteps}`,
|
|
4606
|
-
)
|
|
4843
|
+
agentSectionPath(agentId, "general", {
|
|
4844
|
+
error: `Cleanup incomplete — retry. Failed steps: ${failedSteps}`,
|
|
4845
|
+
}),
|
|
4607
4846
|
302,
|
|
4608
4847
|
);
|
|
4609
4848
|
}
|
|
@@ -4618,11 +4857,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
4618
4857
|
302,
|
|
4619
4858
|
);
|
|
4620
4859
|
} catch (err) {
|
|
4621
|
-
const msg =
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4860
|
+
const msg = err instanceof Error ? err.message : "delete_failed";
|
|
4861
|
+
return c.redirect(
|
|
4862
|
+
agentSectionPath(agentId, "general", { error: msg }),
|
|
4863
|
+
302,
|
|
4864
|
+
);
|
|
4626
4865
|
}
|
|
4627
4866
|
});
|
|
4628
4867
|
|