@app-vitals/agent-admin 1.49.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 +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-styles.ts +0 -65
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +184 -96
package/src/admin-ui-pages.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
uncoveredRepos,
|
|
23
23
|
} from "./admin-ui-installation-repos-pages.ts";
|
|
24
24
|
import { renderAdminPage } from "./admin-ui-layout.ts";
|
|
25
|
+
import { renderSettingsLayout } from "./admin-ui-settings-layout.ts";
|
|
25
26
|
import {
|
|
26
27
|
BREAKPOINT_MOBILE_MAX,
|
|
27
28
|
escapeHtml,
|
|
@@ -973,31 +974,99 @@ function renderConnectAction(
|
|
|
973
974
|
</details>`;
|
|
974
975
|
}
|
|
975
976
|
|
|
977
|
+
export const AGENT_SECTIONS = [
|
|
978
|
+
"general",
|
|
979
|
+
"automation",
|
|
980
|
+
"configuration",
|
|
981
|
+
"access",
|
|
982
|
+
"extensions",
|
|
983
|
+
] as const;
|
|
984
|
+
export type AgentSection = (typeof AGENT_SECTIONS)[number];
|
|
985
|
+
|
|
986
|
+
export function isAgentSection(value: string): value is AgentSection {
|
|
987
|
+
return (AGENT_SECTIONS as readonly string[]).includes(value);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
const AGENT_SECTION_LABELS: Record<AgentSection, string> = {
|
|
991
|
+
general: "General",
|
|
992
|
+
automation: "Automation",
|
|
993
|
+
configuration: "Configuration",
|
|
994
|
+
access: "Access",
|
|
995
|
+
extensions: "Extensions",
|
|
996
|
+
};
|
|
997
|
+
|
|
976
998
|
/**
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
*
|
|
981
|
-
* auto-open behavior for any group.
|
|
982
|
-
*
|
|
983
|
-
* `stat` is a short, pre-formatted, trusted (non-user-controlled) string
|
|
984
|
-
* (e.g. "5 system · 7 custom") rendered flush-right in the summary row.
|
|
985
|
-
* `name` (also trusted/static) is the group title, rendered flush-left.
|
|
986
|
-
* The toggle indicator (▸/▾) is a `::before` on the `.group-title` span
|
|
987
|
-
* itself — NOT on the flex `.group-summary` — so it stays part of that one
|
|
988
|
-
* flex child instead of becoming its own third flex item, which would break
|
|
989
|
-
* the flush-left/flush-right 2-sided layout into an uneven 3-way split.
|
|
999
|
+
* Path of one agent detail section (SGL-1.2). General is the bare agent path,
|
|
1000
|
+
* so existing links and redirects to /admin/agents/:id keep landing there.
|
|
1001
|
+
* `query` params (e.g. error / success / warning) are URL-encoded and appended
|
|
1002
|
+
* so post-action redirects keep their banner on the section that owns the card.
|
|
990
1003
|
*/
|
|
991
|
-
function
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1004
|
+
export function agentSectionPath(
|
|
1005
|
+
agentId: string,
|
|
1006
|
+
section: AgentSection = "general",
|
|
1007
|
+
query?: Record<string, string | undefined>,
|
|
1008
|
+
): string {
|
|
1009
|
+
const base = `/admin/agents/${encodeURIComponent(agentId)}`;
|
|
1010
|
+
const path = section === "general" ? base : `${base}/${section}`;
|
|
1011
|
+
const qs = Object.entries(query ?? {})
|
|
1012
|
+
.filter((e): e is [string, string] => e[1] !== undefined)
|
|
1013
|
+
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
|
1014
|
+
.join("&");
|
|
1015
|
+
return qs ? `${path}?${qs}` : path;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Section each POST /admin/agents/:id/* handler redirects back to (SGL-1.3):
|
|
1020
|
+
* the section whose card renders the handler's form. Keys are the route path
|
|
1021
|
+
* after `/admin/agents/:id`. A unit test scans admin-ui.ts so a new handler
|
|
1022
|
+
* cannot be added without an entry here.
|
|
1023
|
+
*/
|
|
1024
|
+
export const AGENT_POST_SECTIONS: Readonly<Record<string, AgentSection>> = {
|
|
1025
|
+
"/github-username": "access",
|
|
1026
|
+
"/github-sync/apply-confirmed": "access",
|
|
1027
|
+
"/repos/remove-confirmed": "configuration",
|
|
1028
|
+
"/envs": "configuration",
|
|
1029
|
+
"/template/detach": "configuration",
|
|
1030
|
+
"/template/reattach": "configuration",
|
|
1031
|
+
"/template/reset": "configuration",
|
|
1032
|
+
"/envs/delete": "configuration",
|
|
1033
|
+
"/repos/add": "configuration",
|
|
1034
|
+
"/repos/delete": "configuration",
|
|
1035
|
+
"/review-author-allowlist/add": "access",
|
|
1036
|
+
"/review-author-allowlist/delete": "access",
|
|
1037
|
+
"/patch-author-allowlist/add": "access",
|
|
1038
|
+
"/patch-author-allowlist/delete": "access",
|
|
1039
|
+
// Shared by the Slack access card (access) and the Agent Policy card
|
|
1040
|
+
// (configuration); see settingsRedirectSection.
|
|
1041
|
+
"/settings": "configuration",
|
|
1042
|
+
"/crons": "automation",
|
|
1043
|
+
"/crons/:cronId/toggle": "automation",
|
|
1044
|
+
"/crons/:cronId/update": "automation",
|
|
1045
|
+
"/crons/:cronId/delete": "automation",
|
|
1046
|
+
"/tools": "extensions",
|
|
1047
|
+
"/tools/:toolId/toggle": "extensions",
|
|
1048
|
+
"/tools/:toolId/delete": "extensions",
|
|
1049
|
+
"/marketplaces": "extensions",
|
|
1050
|
+
"/marketplaces/delete": "extensions",
|
|
1051
|
+
"/plugins": "extensions",
|
|
1052
|
+
"/plugins/delete": "extensions",
|
|
1053
|
+
"/tokens": "access",
|
|
1054
|
+
"/tokens/:tokenId/revoke": "access",
|
|
1055
|
+
"/sync-manifest": "general",
|
|
1056
|
+
"/connect-slack": "access",
|
|
1057
|
+
"/connect-slack/app-token": "access",
|
|
1058
|
+
"/connect-github": "access",
|
|
1059
|
+
"/members": "access",
|
|
1060
|
+
"/members/delete": "access",
|
|
1061
|
+
"/delete": "general",
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* POST /settings serves two forms: Slack access (access section, carries
|
|
1066
|
+
* restrictSlackToMembers) and Agent Policy (configuration section).
|
|
1067
|
+
*/
|
|
1068
|
+
export function settingsRedirectSection(formData: FormData): AgentSection {
|
|
1069
|
+
return formData.has("restrictSlackToMembers") ? "access" : "configuration";
|
|
1001
1070
|
}
|
|
1002
1071
|
|
|
1003
1072
|
export function renderAgentDetailPage(
|
|
@@ -1018,6 +1087,8 @@ export function renderAgentDetailPage(
|
|
|
1018
1087
|
userName: string,
|
|
1019
1088
|
isAdmin: boolean,
|
|
1020
1089
|
opts?: {
|
|
1090
|
+
/** Section to render (SGL-1.2). Defaults to "general". */
|
|
1091
|
+
section?: AgentSection;
|
|
1021
1092
|
/**
|
|
1022
1093
|
* SSP-4.3: render the Members / Slack access / Danger Zone cards. Defaults
|
|
1023
1094
|
* to isAdmin; the caller passes true for agent-access holders when
|
|
@@ -2070,8 +2141,8 @@ export function renderAgentDetailPage(
|
|
|
2070
2141
|
|
|
2071
2142
|
const dangerZoneSection = canManage
|
|
2072
2143
|
? `<!-- Danger Zone -->
|
|
2073
|
-
<div class="
|
|
2074
|
-
<div class="
|
|
2144
|
+
<div class="settings-danger-zone">
|
|
2145
|
+
<div class="settings-section-title">Danger Zone</div>
|
|
2075
2146
|
<p style="font-size:13px;color:#6b7280;margin-bottom:16px">
|
|
2076
2147
|
Deleting this agent permanently removes all its data (env vars, crons, tools, tokens, plugins, members)
|
|
2077
2148
|
and terminates its pod. This action cannot be undone.
|
|
@@ -2091,24 +2162,8 @@ export function renderAgentDetailPage(
|
|
|
2091
2162
|
</div>`
|
|
2092
2163
|
: "";
|
|
2093
2164
|
|
|
2094
|
-
// ─── Accordion groups (AGA-1.1) ────────────────────────────────────────
|
|
2095
|
-
// The cards below are grouped into 4 collapsed-by-default
|
|
2096
|
-
// <details class="group"> sections. Grouping is purely presentational —
|
|
2097
|
-
// every card's internal markup/ids/form actions are unchanged, they're
|
|
2098
|
-
// just composed into a new order. Agent Policy (added after this task was
|
|
2099
|
-
// originally scoped) lands in Configuration alongside Env Vars/Repos since
|
|
2100
|
-
// it is agent-level configuration, as do extension cards placed there
|
|
2101
|
-
// (the coding extension's Phase Methodology card) — this keeps every card
|
|
2102
|
-
// inside exactly one of the 4 groups, with no stray bare cards besides
|
|
2103
|
-
// Danger Zone.
|
|
2104
|
-
const automationStat = `${systemCrons.length} system · ${customCrons.length} custom`;
|
|
2105
|
-
const configurationStat = `${Object.keys(envVars).length} env vars · ${agent.repos.length} repos`;
|
|
2106
|
-
const activeTokenCount = tokens.filter((t) => !t.revokedAt).length;
|
|
2107
|
-
const accessStat = `${members.length} members · ${activeTokenCount} active tokens`;
|
|
2108
|
-
const pluginsToolsStat = `${tools.length} tools · ${plugins.length} plugins`;
|
|
2109
|
-
|
|
2110
2165
|
// ─── Stat strip (AGA-1.2) ──────────────────────────────────────────────
|
|
2111
|
-
// 4-tile stat strip rendered
|
|
2166
|
+
// 4-tile stat strip rendered on the General section. Each tile
|
|
2112
2167
|
// derives its count from parameters already passed into this function.
|
|
2113
2168
|
const cronsActiveCount = topLevelCrons.filter((c) => c.enabled).length;
|
|
2114
2169
|
const missingEnvVarsCount = agent.missingRequiredEnv.length;
|
|
@@ -2134,64 +2189,15 @@ export function renderAgentDetailPage(
|
|
|
2134
2189
|
</div>
|
|
2135
2190
|
</div>`;
|
|
2136
2191
|
|
|
2137
|
-
const
|
|
2138
|
-
"Automation",
|
|
2139
|
-
automationStat,
|
|
2140
|
-
cronJobsSection,
|
|
2141
|
-
);
|
|
2142
|
-
const configurationGroup = renderGroup(
|
|
2143
|
-
"Configuration",
|
|
2144
|
-
configurationStat,
|
|
2145
|
-
`${templateCard}${envVarsSection}${reposSection}${(opts?.configurationCardsHtml ?? []).join("")}${agentPolicySection}`,
|
|
2146
|
-
);
|
|
2147
|
-
const accessGroup = renderGroup(
|
|
2148
|
-
"Access",
|
|
2149
|
-
accessStat,
|
|
2150
|
-
`${identitySection}${canManage ? membersSection : ""}${authorAllowlistReviewSection}${authorAllowlistPatchSection}${slackAccessSection}${tokensSection}`,
|
|
2151
|
-
);
|
|
2152
|
-
const pluginsToolsGroup = renderGroup(
|
|
2153
|
-
"Plugins & Tools",
|
|
2154
|
-
pluginsToolsStat,
|
|
2155
|
-
`${toolsSection}${pluginsSection}${marketplacesSection}`,
|
|
2156
|
-
);
|
|
2157
|
-
|
|
2158
|
-
const expandCollapseControls = `
|
|
2159
|
-
<div style="display:flex;gap:8px;margin-bottom:16px">
|
|
2160
|
-
<button type="button" class="btn btn-secondary" id="expand-all-btn">Expand all</button>
|
|
2161
|
-
<button type="button" class="btn btn-secondary" id="collapse-all-btn">Collapse all</button>
|
|
2162
|
-
</div>
|
|
2163
|
-
<script>
|
|
2164
|
-
(function() {
|
|
2165
|
-
var expandBtn = document.getElementById('expand-all-btn');
|
|
2166
|
-
var collapseBtn = document.getElementById('collapse-all-btn');
|
|
2167
|
-
if (expandBtn) {
|
|
2168
|
-
expandBtn.addEventListener('click', function() {
|
|
2169
|
-
document.querySelectorAll('.group').forEach(function(el) {
|
|
2170
|
-
el.open = true;
|
|
2171
|
-
});
|
|
2172
|
-
});
|
|
2173
|
-
}
|
|
2174
|
-
if (collapseBtn) {
|
|
2175
|
-
collapseBtn.addEventListener('click', function() {
|
|
2176
|
-
document.querySelectorAll('.group').forEach(function(el) {
|
|
2177
|
-
el.open = false;
|
|
2178
|
-
});
|
|
2179
|
-
});
|
|
2180
|
-
}
|
|
2181
|
-
})();
|
|
2182
|
-
</script>
|
|
2183
|
-
`;
|
|
2192
|
+
const section = opts?.section ?? "general";
|
|
2184
2193
|
|
|
2185
|
-
|
|
2186
|
-
title: `${agent.name} — Shipwright Admin`,
|
|
2187
|
-
body: `${renderAdminToolbar(userName, "/admin/agents")}
|
|
2188
|
-
<div class="vos-page">
|
|
2189
|
-
<div class="page-header">
|
|
2194
|
+
const headerInfoHtml = `<div class="page-header">
|
|
2190
2195
|
<div>
|
|
2191
2196
|
<a href="/admin/agents" style="font-size:13px;color:#6b7280;text-decoration:none">← Agents</a>
|
|
2192
|
-
<
|
|
2193
|
-
|
|
2194
|
-
|
|
2197
|
+
<div style="margin-top:4px">
|
|
2198
|
+
<span style="font-size:13px;color:#6b7280">Type: <span class="mono">${escapeHtml(agent.specialty)}</span></span>
|
|
2199
|
+
${agent.slackId ? `<span style="font-size:13px;color:#6b7280">Slack ID: <span class="mono">${escapeHtml(agent.slackId)}</span></span>` : ""}
|
|
2200
|
+
</div>
|
|
2195
2201
|
</div>
|
|
2196
2202
|
${
|
|
2197
2203
|
agent.slackId
|
|
@@ -2216,24 +2222,45 @@ export function renderAgentDetailPage(
|
|
|
2216
2222
|
</div>`
|
|
2217
2223
|
: ""
|
|
2218
2224
|
}
|
|
2219
|
-
</div
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
${newTokenHtml}
|
|
2225
|
+
</div>`;
|
|
2226
|
+
|
|
2227
|
+
const sectionBodies: Record<AgentSection, string> = {
|
|
2228
|
+
general: `${headerInfoHtml}
|
|
2224
2229
|
${(opts?.extensionCardsHtml ?? []).join("\n ")}
|
|
2225
2230
|
|
|
2226
2231
|
${statStripHtml}
|
|
2227
2232
|
|
|
2228
|
-
${
|
|
2229
|
-
|
|
2230
|
-
${
|
|
2231
|
-
${
|
|
2232
|
-
${
|
|
2233
|
-
|
|
2234
|
-
${dangerZoneSection}
|
|
2233
|
+
${dangerZoneSection}`,
|
|
2234
|
+
automation: cronJobsSection,
|
|
2235
|
+
configuration: `${templateCard}${envVarsSection}${reposSection}${(opts?.configurationCardsHtml ?? []).join("")}${agentPolicySection}`,
|
|
2236
|
+
access: `${identitySection}${canManage ? membersSection : ""}${authorAllowlistReviewSection}${authorAllowlistPatchSection}${slackAccessSection}${tokensSection}`,
|
|
2237
|
+
extensions: `${toolsSection}${pluginsSection}${marketplacesSection}`,
|
|
2238
|
+
};
|
|
2235
2239
|
|
|
2236
|
-
|
|
2240
|
+
return renderAdminPage({
|
|
2241
|
+
title: `${agent.name} — Shipwright Admin`,
|
|
2242
|
+
body: renderSettingsLayout({
|
|
2243
|
+
userName,
|
|
2244
|
+
title: agent.name,
|
|
2245
|
+
nav: {
|
|
2246
|
+
sections: [
|
|
2247
|
+
{
|
|
2248
|
+
label: "Agent",
|
|
2249
|
+
items: AGENT_SECTIONS.map((k) => ({
|
|
2250
|
+
label: AGENT_SECTION_LABELS[k],
|
|
2251
|
+
path: agentSectionPath(agent.id, k),
|
|
2252
|
+
})),
|
|
2253
|
+
},
|
|
2254
|
+
],
|
|
2255
|
+
},
|
|
2256
|
+
active: agentSectionPath(agent.id, section),
|
|
2257
|
+
toolbarPath: "/admin/agents",
|
|
2258
|
+
body: `${errorHtml}
|
|
2259
|
+
${successHtml}
|
|
2260
|
+
${warningHtml}
|
|
2261
|
+
${newTokenHtml}
|
|
2262
|
+
${sectionBodies[section]}`,
|
|
2263
|
+
}),
|
|
2237
2264
|
});
|
|
2238
2265
|
}
|
|
2239
2266
|
|