@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-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,
|
|
@@ -128,6 +129,8 @@ export interface AgentDetail {
|
|
|
128
129
|
* state.
|
|
129
130
|
*/
|
|
130
131
|
bakedMarketplaces?: string[];
|
|
132
|
+
/** ATP-2.4: the agent no longer follows its template. */
|
|
133
|
+
templateDetached?: boolean;
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
export interface CronJobItem {
|
|
@@ -141,6 +144,8 @@ export interface CronJobItem {
|
|
|
141
144
|
system: boolean;
|
|
142
145
|
parentCronId: string | null;
|
|
143
146
|
preCheck?: string | null;
|
|
147
|
+
/** ATP-2.4: `template` (inherited) or `custom`. */
|
|
148
|
+
source?: string;
|
|
144
149
|
lastRun?: {
|
|
145
150
|
startedAt: Date;
|
|
146
151
|
completedAt: Date | null;
|
|
@@ -179,6 +184,8 @@ export interface ToolItem {
|
|
|
179
184
|
id: string;
|
|
180
185
|
pattern: string;
|
|
181
186
|
enabled: boolean;
|
|
187
|
+
/** ATP-2.4: `template` (inherited) or `custom`. */
|
|
188
|
+
source?: string;
|
|
182
189
|
createdAt: Date;
|
|
183
190
|
}
|
|
184
191
|
|
|
@@ -194,6 +201,8 @@ export interface PluginItem {
|
|
|
194
201
|
name: string;
|
|
195
202
|
version: string | null;
|
|
196
203
|
enabled: boolean;
|
|
204
|
+
/** ATP-2.4: `template` (inherited) or `custom`. */
|
|
205
|
+
source?: string;
|
|
197
206
|
createdAt: Date;
|
|
198
207
|
}
|
|
199
208
|
|
|
@@ -502,6 +511,16 @@ function runtimeSectionsOnchange(display: "" | "none"): string {
|
|
|
502
511
|
.join(";");
|
|
503
512
|
}
|
|
504
513
|
|
|
514
|
+
/** ATP-2.4: one template-provided default on the provisioning form. */
|
|
515
|
+
export interface NewAgentTemplateItem {
|
|
516
|
+
kind: string;
|
|
517
|
+
key: string;
|
|
518
|
+
/** Display value (env only; secrets already masked). */
|
|
519
|
+
value?: string;
|
|
520
|
+
/** Human label of the template scope. */
|
|
521
|
+
scope: string;
|
|
522
|
+
}
|
|
523
|
+
|
|
505
524
|
export function renderNewLocalAgentPage(
|
|
506
525
|
userName: string,
|
|
507
526
|
types: SpecialtyOption[],
|
|
@@ -516,6 +535,12 @@ export function renderNewLocalAgentPage(
|
|
|
516
535
|
* the self-serve specialty (the server forces it regardless).
|
|
517
536
|
*/
|
|
518
537
|
selfServe?: { remaining: number; max: number; contactEmail: string };
|
|
538
|
+
/**
|
|
539
|
+
* ATP-2.4: present when agent templates are available. Lists the
|
|
540
|
+
* template-provided defaults and adds the opt-out checkbox; `allowEnv`
|
|
541
|
+
* (platform admins) adds the explicit env override box.
|
|
542
|
+
*/
|
|
543
|
+
template?: { items: NewAgentTemplateItem[]; allowEnv: boolean };
|
|
519
544
|
},
|
|
520
545
|
): string {
|
|
521
546
|
const error = opts?.error;
|
|
@@ -591,6 +616,46 @@ export function renderNewLocalAgentPage(
|
|
|
591
616
|
</ul>
|
|
592
617
|
</div>`
|
|
593
618
|
: "";
|
|
619
|
+
const tplOpts = opts?.template;
|
|
620
|
+
const templateFieldsetHtml = tplOpts
|
|
621
|
+
? `<fieldset id="template-section" style="border:1px solid #e8e8ee;border-radius:8px;padding:16px">
|
|
622
|
+
<legend style="font-size:13px;font-weight:600;padding:0 8px">Agent template</legend>
|
|
623
|
+
${
|
|
624
|
+
tplOpts.items.length === 0
|
|
625
|
+
? `<p style="font-size:13px;color:#6b7280;margin-bottom:12px">No template items apply to new agents.</p>`
|
|
626
|
+
: `<p style="font-size:13px;color:#6b7280;margin-bottom:8px">New agents start with these template defaults${tplOpts.allowEnv ? "; anything you enter below overrides them" : ""}:</p>
|
|
627
|
+
<table class="data-table" style="margin-bottom:12px">
|
|
628
|
+
<thead><tr><th>Kind</th><th>Key</th><th>Default</th><th>Applies to</th></tr></thead>
|
|
629
|
+
<tbody>${tplOpts.items
|
|
630
|
+
.map(
|
|
631
|
+
(i) =>
|
|
632
|
+
`<tr><td>${escapeHtml(i.kind)}</td><td class="mono">${escapeHtml(i.key)}</td><td class="mono">${i.value === undefined ? "—" : escapeHtml(i.value)}</td><td>${escapeHtml(i.scope)}</td></tr>`,
|
|
633
|
+
)
|
|
634
|
+
.join("")}</tbody>
|
|
635
|
+
</table>`
|
|
636
|
+
}
|
|
637
|
+
${
|
|
638
|
+
tplOpts.allowEnv
|
|
639
|
+
? `<div class="form-group">
|
|
640
|
+
<label class="form-label" for="env">Env overrides (optional)</label>
|
|
641
|
+
<textarea id="env" name="env" class="form-input mono" rows="3" placeholder="KEY=value (one per line)"></textarea>
|
|
642
|
+
<p style="font-size:12px;color:#6b7280;margin-top:4px">
|
|
643
|
+
Values entered here win over the template defaults above and stay fixed when the template changes.
|
|
644
|
+
</p>
|
|
645
|
+
</div>`
|
|
646
|
+
: ""
|
|
647
|
+
}
|
|
648
|
+
<div class="form-group" style="margin-bottom:0">
|
|
649
|
+
<label style="font-size:13px">
|
|
650
|
+
<input type="checkbox" name="templateDetached" value="true" />
|
|
651
|
+
Start without the template (opt out)
|
|
652
|
+
</label>
|
|
653
|
+
<p style="font-size:12px;color:#6b7280;margin-top:4px">
|
|
654
|
+
The agent gets only its built-in defaults and ignores later template changes until you reattach it.
|
|
655
|
+
</p>
|
|
656
|
+
</div>
|
|
657
|
+
</fieldset>`
|
|
658
|
+
: "";
|
|
594
659
|
const typeFieldHtml = selfServe
|
|
595
660
|
? `<input type="hidden" name="type" value="${escapeHtml(getSelfServeSpecialty())}" />`
|
|
596
661
|
: `<div class="form-group">
|
|
@@ -826,6 +891,7 @@ export function renderNewLocalAgentPage(
|
|
|
826
891
|
</div>
|
|
827
892
|
</div>
|
|
828
893
|
</fieldset>
|
|
894
|
+
${templateFieldsetHtml}
|
|
829
895
|
<div>
|
|
830
896
|
<button type="submit" class="btn btn-primary">Create agent →</button>
|
|
831
897
|
<a href="/admin/agents" class="btn btn-secondary" style="margin-left:8px">Cancel</a>
|
|
@@ -908,37 +974,110 @@ function renderConnectAction(
|
|
|
908
974
|
</details>`;
|
|
909
975
|
}
|
|
910
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
|
+
|
|
911
998
|
/**
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
*
|
|
916
|
-
* auto-open behavior for any group.
|
|
917
|
-
*
|
|
918
|
-
* `stat` is a short, pre-formatted, trusted (non-user-controlled) string
|
|
919
|
-
* (e.g. "5 system · 7 custom") rendered flush-right in the summary row.
|
|
920
|
-
* `name` (also trusted/static) is the group title, rendered flush-left.
|
|
921
|
-
* The toggle indicator (▸/▾) is a `::before` on the `.group-title` span
|
|
922
|
-
* itself — NOT on the flex `.group-summary` — so it stays part of that one
|
|
923
|
-
* flex child instead of becoming its own third flex item, which would break
|
|
924
|
-
* 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.
|
|
925
1003
|
*/
|
|
926
|
-
function
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
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";
|
|
936
1070
|
}
|
|
937
1071
|
|
|
938
1072
|
export function renderAgentDetailPage(
|
|
939
1073
|
agent: AgentDetail,
|
|
940
1074
|
envResult:
|
|
941
|
-
| {
|
|
1075
|
+
| {
|
|
1076
|
+
env: Record<string, string>;
|
|
1077
|
+
secretKeys: string[];
|
|
1078
|
+
/** ATP-2.4: row source per key. */
|
|
1079
|
+
sources?: Record<string, string>;
|
|
1080
|
+
}
|
|
942
1081
|
| Record<string, string>,
|
|
943
1082
|
crons: CronJobItem[],
|
|
944
1083
|
tools: ToolItem[],
|
|
@@ -948,6 +1087,8 @@ export function renderAgentDetailPage(
|
|
|
948
1087
|
userName: string,
|
|
949
1088
|
isAdmin: boolean,
|
|
950
1089
|
opts?: {
|
|
1090
|
+
/** Section to render (SGL-1.2). Defaults to "general". */
|
|
1091
|
+
section?: AgentSection;
|
|
951
1092
|
/**
|
|
952
1093
|
* SSP-4.3: render the Members / Slack access / Danger Zone cards. Defaults
|
|
953
1094
|
* to isAdmin; the caller passes true for agent-access holders when
|
|
@@ -995,6 +1136,12 @@ export function renderAgentDetailPage(
|
|
|
995
1136
|
* could be listed. Absent means unknown: no coverage warning is shown.
|
|
996
1137
|
*/
|
|
997
1138
|
installationRepos?: readonly string[];
|
|
1139
|
+
/**
|
|
1140
|
+
* ATP-2.4: present when agent templates are available. Turns on the
|
|
1141
|
+
* inherited/custom badges, the detach/reattach toggle and the per-item
|
|
1142
|
+
* reset controls.
|
|
1143
|
+
*/
|
|
1144
|
+
template?: { detached: boolean };
|
|
998
1145
|
},
|
|
999
1146
|
): string {
|
|
1000
1147
|
// Reference time for relative timestamps — injected by tests for determinism,
|
|
@@ -1016,19 +1163,66 @@ export function renderAgentDetailPage(
|
|
|
1016
1163
|
: [],
|
|
1017
1164
|
);
|
|
1018
1165
|
|
|
1166
|
+
// ATP-2.4: inherited/custom badge, per-item reset and agent-wide controls.
|
|
1167
|
+
const tpl = opts?.template;
|
|
1168
|
+
const agentPath = `/admin/agents/${escapeHtml(agent.id)}`;
|
|
1169
|
+
const sourceBadge = (source: string | undefined): string =>
|
|
1170
|
+
!tpl || (source !== "template" && source !== "custom")
|
|
1171
|
+
? ""
|
|
1172
|
+
: source === "template"
|
|
1173
|
+
? ` <span class="badge badge-template" data-source="template" title="Inherited from the agent template">template</span>`
|
|
1174
|
+
: ` <span class="badge badge-custom" data-source="custom" title="Set on this agent; overrides the template">custom</span>`;
|
|
1175
|
+
const resetForm = (
|
|
1176
|
+
source: string | undefined,
|
|
1177
|
+
kind: string,
|
|
1178
|
+
key: string | null | undefined,
|
|
1179
|
+
): string =>
|
|
1180
|
+
!tpl || tpl.detached || source !== "custom" || !key
|
|
1181
|
+
? ""
|
|
1182
|
+
: `<form method="POST" action="${agentPath}/template/reset" style="display:inline;margin-left:4px">
|
|
1183
|
+
<input type="hidden" name="kind" value="${kind}" />
|
|
1184
|
+
<input type="hidden" name="key" value="${escapeHtml(key)}" />
|
|
1185
|
+
<button type="submit" class="btn btn-secondary" style="font-size:11px;padding:3px 8px" title="Drop this agent's override and restore the template value">Reset to template</button>
|
|
1186
|
+
</form>`;
|
|
1187
|
+
const envSources =
|
|
1188
|
+
envResult && "sources" in envResult
|
|
1189
|
+
? ((envResult as { sources?: Record<string, string> }).sources ?? {})
|
|
1190
|
+
: {};
|
|
1191
|
+
const templateCard = tpl
|
|
1192
|
+
? `<div class="card" id="template">
|
|
1193
|
+
<div class="card-title">Agent template</div>
|
|
1194
|
+
${
|
|
1195
|
+
tpl.detached
|
|
1196
|
+
? `<p style="font-size:13px;margin-bottom:12px"><span class="badge badge-gray">Detached from template</span>
|
|
1197
|
+
Template changes no longer reach this agent. Reattaching reconciles it against the template now; your custom rows are kept.</p>
|
|
1198
|
+
<form method="POST" action="${agentPath}/template/reattach">
|
|
1199
|
+
<button type="submit" class="btn btn-primary">Reattach to template</button>
|
|
1200
|
+
</form>`
|
|
1201
|
+
: `<p style="font-size:13px;margin-bottom:12px"><span class="badge badge-template">Following template</span>
|
|
1202
|
+
Rows marked <em>template</em> are managed from Settings > Templates; editing one makes it <em>custom</em>.</p>
|
|
1203
|
+
<form method="POST" action="${agentPath}/template/detach" style="display:inline">
|
|
1204
|
+
<button type="submit" class="btn btn-secondary">Detach from template</button>
|
|
1205
|
+
</form>
|
|
1206
|
+
<form method="POST" action="${agentPath}/template/reset" style="display:inline;margin-left:8px">
|
|
1207
|
+
<button type="submit" class="btn btn-secondary" title="Drop every override of a key the template defines">Reset all to template</button>
|
|
1208
|
+
</form>`
|
|
1209
|
+
}
|
|
1210
|
+
</div>`
|
|
1211
|
+
: "";
|
|
1212
|
+
|
|
1019
1213
|
const envRows =
|
|
1020
1214
|
Object.keys(envVars).length === 0
|
|
1021
1215
|
? `<tr><td colspan="3" class="empty-state">No env vars set.</td></tr>`
|
|
1022
1216
|
: Object.entries(envVars)
|
|
1023
1217
|
.map(
|
|
1024
1218
|
([k]) => `<tr>
|
|
1025
|
-
<td class="mono">${escapeHtml(k)}${secretKeySet.has(k) ? ' <span title="Secret">🔒</span>' : ""}</td>
|
|
1219
|
+
<td class="mono">${escapeHtml(k)}${secretKeySet.has(k) ? ' <span title="Secret">🔒</span>' : ""}${sourceBadge(envSources[k])}</td>
|
|
1026
1220
|
<td class="mono" style="color:#6b7280">••••••••</td>
|
|
1027
1221
|
<td>
|
|
1028
1222
|
<form method="POST" action="/admin/agents/${escapeHtml(agent.id)}/envs/delete" style="display:inline">
|
|
1029
1223
|
<input type="hidden" name="key" value="${escapeHtml(k)}" />
|
|
1030
1224
|
<button type="submit" class="btn btn-danger" style="font-size:11px;padding:3px 8px">Delete</button>
|
|
1031
|
-
</form
|
|
1225
|
+
</form>${resetForm(envSources[k], "env", k)}
|
|
1032
1226
|
</td>
|
|
1033
1227
|
</tr>`,
|
|
1034
1228
|
)
|
|
@@ -1232,13 +1426,13 @@ export function renderAgentDetailPage(
|
|
|
1232
1426
|
|
|
1233
1427
|
return `<tr>
|
|
1234
1428
|
<td class="mono">${escapeHtml(c.schedule)}</td>
|
|
1235
|
-
<td style="max-width:280px;overflow:hidden;text-overflow:ellipsis">${escapeHtml(c.name ? `${c.name}: ${c.prompt}` : c.prompt)}</td>
|
|
1429
|
+
<td style="max-width:280px;overflow:hidden;text-overflow:ellipsis">${escapeHtml(c.name ? `${c.name}: ${c.prompt}` : c.prompt)}${sourceBadge(c.system ? undefined : c.source)}</td>
|
|
1236
1430
|
<td class="mono" style="font-size:11px;color:#6b7280;max-width:170px;overflow:hidden;text-overflow:ellipsis">${c.preCheck ? escapeHtml(c.preCheck) : "—"}</td>
|
|
1237
1431
|
<td>${c.channel ? escapeHtml(c.channel) : c.user ? escapeHtml(c.user) : "—"}</td>
|
|
1238
1432
|
<td><span class="badge ${c.enabled ? "badge-green" : "badge-gray"}">${c.enabled ? "enabled" : "disabled"}</span></td>
|
|
1239
1433
|
<td style="font-size:11px">${lastRunHtml}</td>
|
|
1240
1434
|
<td class="col-created">${escapeHtml(new Date(c.createdAt).toLocaleDateString("en-US", { timeZone: timezone }))}</td>
|
|
1241
|
-
<td style="white-space:nowrap">${actions}${editForm}</td>
|
|
1435
|
+
<td style="white-space:nowrap">${actions}${resetForm(c.system ? undefined : c.source, "cron", c.name)}${editForm}</td>
|
|
1242
1436
|
</tr>
|
|
1243
1437
|
${nestedPhasesRow}`;
|
|
1244
1438
|
}
|
|
@@ -1259,7 +1453,7 @@ export function renderAgentDetailPage(
|
|
|
1259
1453
|
: tools
|
|
1260
1454
|
.map(
|
|
1261
1455
|
(t) => `<tr>
|
|
1262
|
-
<td class="mono">${escapeHtml(t.pattern)}</td>
|
|
1456
|
+
<td class="mono">${escapeHtml(t.pattern)}${sourceBadge(t.source)}</td>
|
|
1263
1457
|
<td><span class="badge ${t.enabled ? "badge-green" : "badge-gray"}">${t.enabled ? "enabled" : "disabled"}</span></td>
|
|
1264
1458
|
<td>${escapeHtml(new Date(t.createdAt).toLocaleDateString("en-US", { timeZone: timezone }))}</td>
|
|
1265
1459
|
<td style="white-space:nowrap">
|
|
@@ -1269,7 +1463,7 @@ export function renderAgentDetailPage(
|
|
|
1269
1463
|
</form>
|
|
1270
1464
|
<form method="POST" action="/admin/agents/${escapeHtml(agent.id)}/tools/${escapeHtml(t.id)}/delete" style="display:inline;margin-left:4px">
|
|
1271
1465
|
<button type="submit" class="btn btn-danger" style="font-size:11px;padding:3px 8px">Delete</button>
|
|
1272
|
-
</form
|
|
1466
|
+
</form>${resetForm(t.source, "tool", t.pattern)}
|
|
1273
1467
|
</td>
|
|
1274
1468
|
</tr>`,
|
|
1275
1469
|
)
|
|
@@ -1301,7 +1495,7 @@ export function renderAgentDetailPage(
|
|
|
1301
1495
|
: plugins
|
|
1302
1496
|
.map(
|
|
1303
1497
|
(p) => `<tr>
|
|
1304
|
-
<td class="mono">${escapeHtml(p.name)}</td>
|
|
1498
|
+
<td class="mono">${escapeHtml(p.name)}${sourceBadge(p.source)}</td>
|
|
1305
1499
|
<td class="mono">${p.version ? escapeHtml(p.version) : "latest"}</td>
|
|
1306
1500
|
<td><span class="badge ${p.enabled ? "badge-green" : "badge-gray"}">${p.enabled ? "enabled" : "disabled"}</span></td>
|
|
1307
1501
|
<td>${escapeHtml(new Date(p.createdAt).toLocaleDateString("en-US", { timeZone: timezone }))}</td>
|
|
@@ -1309,7 +1503,7 @@ export function renderAgentDetailPage(
|
|
|
1309
1503
|
<form method="POST" action="/admin/agents/${escapeHtml(agent.id)}/plugins/delete" style="display:inline">
|
|
1310
1504
|
<input type="hidden" name="pluginId" value="${escapeHtml(p.id)}" />
|
|
1311
1505
|
<button type="submit" class="btn btn-danger" style="font-size:11px;padding:3px 8px">Remove</button>
|
|
1312
|
-
</form
|
|
1506
|
+
</form>${resetForm(p.source, "plugin", p.name)}
|
|
1313
1507
|
</td>
|
|
1314
1508
|
</tr>`,
|
|
1315
1509
|
)
|
|
@@ -1947,8 +2141,8 @@ export function renderAgentDetailPage(
|
|
|
1947
2141
|
|
|
1948
2142
|
const dangerZoneSection = canManage
|
|
1949
2143
|
? `<!-- Danger Zone -->
|
|
1950
|
-
<div class="
|
|
1951
|
-
<div class="
|
|
2144
|
+
<div class="settings-danger-zone">
|
|
2145
|
+
<div class="settings-section-title">Danger Zone</div>
|
|
1952
2146
|
<p style="font-size:13px;color:#6b7280;margin-bottom:16px">
|
|
1953
2147
|
Deleting this agent permanently removes all its data (env vars, crons, tools, tokens, plugins, members)
|
|
1954
2148
|
and terminates its pod. This action cannot be undone.
|
|
@@ -1968,24 +2162,8 @@ export function renderAgentDetailPage(
|
|
|
1968
2162
|
</div>`
|
|
1969
2163
|
: "";
|
|
1970
2164
|
|
|
1971
|
-
// ─── Accordion groups (AGA-1.1) ────────────────────────────────────────
|
|
1972
|
-
// The cards below are grouped into 4 collapsed-by-default
|
|
1973
|
-
// <details class="group"> sections. Grouping is purely presentational —
|
|
1974
|
-
// every card's internal markup/ids/form actions are unchanged, they're
|
|
1975
|
-
// just composed into a new order. Agent Policy (added after this task was
|
|
1976
|
-
// originally scoped) lands in Configuration alongside Env Vars/Repos since
|
|
1977
|
-
// it is agent-level configuration, as do extension cards placed there
|
|
1978
|
-
// (the coding extension's Phase Methodology card) — this keeps every card
|
|
1979
|
-
// inside exactly one of the 4 groups, with no stray bare cards besides
|
|
1980
|
-
// Danger Zone.
|
|
1981
|
-
const automationStat = `${systemCrons.length} system · ${customCrons.length} custom`;
|
|
1982
|
-
const configurationStat = `${Object.keys(envVars).length} env vars · ${agent.repos.length} repos`;
|
|
1983
|
-
const activeTokenCount = tokens.filter((t) => !t.revokedAt).length;
|
|
1984
|
-
const accessStat = `${members.length} members · ${activeTokenCount} active tokens`;
|
|
1985
|
-
const pluginsToolsStat = `${tools.length} tools · ${plugins.length} plugins`;
|
|
1986
|
-
|
|
1987
2165
|
// ─── Stat strip (AGA-1.2) ──────────────────────────────────────────────
|
|
1988
|
-
// 4-tile stat strip rendered
|
|
2166
|
+
// 4-tile stat strip rendered on the General section. Each tile
|
|
1989
2167
|
// derives its count from parameters already passed into this function.
|
|
1990
2168
|
const cronsActiveCount = topLevelCrons.filter((c) => c.enabled).length;
|
|
1991
2169
|
const missingEnvVarsCount = agent.missingRequiredEnv.length;
|
|
@@ -2011,64 +2189,15 @@ export function renderAgentDetailPage(
|
|
|
2011
2189
|
</div>
|
|
2012
2190
|
</div>`;
|
|
2013
2191
|
|
|
2014
|
-
const
|
|
2015
|
-
"Automation",
|
|
2016
|
-
automationStat,
|
|
2017
|
-
cronJobsSection,
|
|
2018
|
-
);
|
|
2019
|
-
const configurationGroup = renderGroup(
|
|
2020
|
-
"Configuration",
|
|
2021
|
-
configurationStat,
|
|
2022
|
-
`${envVarsSection}${reposSection}${(opts?.configurationCardsHtml ?? []).join("")}${agentPolicySection}`,
|
|
2023
|
-
);
|
|
2024
|
-
const accessGroup = renderGroup(
|
|
2025
|
-
"Access",
|
|
2026
|
-
accessStat,
|
|
2027
|
-
`${identitySection}${canManage ? membersSection : ""}${authorAllowlistReviewSection}${authorAllowlistPatchSection}${slackAccessSection}${tokensSection}`,
|
|
2028
|
-
);
|
|
2029
|
-
const pluginsToolsGroup = renderGroup(
|
|
2030
|
-
"Plugins & Tools",
|
|
2031
|
-
pluginsToolsStat,
|
|
2032
|
-
`${toolsSection}${pluginsSection}${marketplacesSection}`,
|
|
2033
|
-
);
|
|
2192
|
+
const section = opts?.section ?? "general";
|
|
2034
2193
|
|
|
2035
|
-
const
|
|
2036
|
-
<div style="display:flex;gap:8px;margin-bottom:16px">
|
|
2037
|
-
<button type="button" class="btn btn-secondary" id="expand-all-btn">Expand all</button>
|
|
2038
|
-
<button type="button" class="btn btn-secondary" id="collapse-all-btn">Collapse all</button>
|
|
2039
|
-
</div>
|
|
2040
|
-
<script>
|
|
2041
|
-
(function() {
|
|
2042
|
-
var expandBtn = document.getElementById('expand-all-btn');
|
|
2043
|
-
var collapseBtn = document.getElementById('collapse-all-btn');
|
|
2044
|
-
if (expandBtn) {
|
|
2045
|
-
expandBtn.addEventListener('click', function() {
|
|
2046
|
-
document.querySelectorAll('.group').forEach(function(el) {
|
|
2047
|
-
el.open = true;
|
|
2048
|
-
});
|
|
2049
|
-
});
|
|
2050
|
-
}
|
|
2051
|
-
if (collapseBtn) {
|
|
2052
|
-
collapseBtn.addEventListener('click', function() {
|
|
2053
|
-
document.querySelectorAll('.group').forEach(function(el) {
|
|
2054
|
-
el.open = false;
|
|
2055
|
-
});
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
})();
|
|
2059
|
-
</script>
|
|
2060
|
-
`;
|
|
2061
|
-
|
|
2062
|
-
return renderAdminPage({
|
|
2063
|
-
title: `${agent.name} — Shipwright Admin`,
|
|
2064
|
-
body: `${renderAdminToolbar(userName, "/admin/agents")}
|
|
2065
|
-
<div class="vos-page">
|
|
2066
|
-
<div class="page-header">
|
|
2194
|
+
const headerInfoHtml = `<div class="page-header">
|
|
2067
2195
|
<div>
|
|
2068
2196
|
<a href="/admin/agents" style="font-size:13px;color:#6b7280;text-decoration:none">← Agents</a>
|
|
2069
|
-
<
|
|
2070
|
-
|
|
2071
|
-
|
|
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>
|
|
2072
2201
|
</div>
|
|
2073
2202
|
${
|
|
2074
2203
|
agent.slackId
|
|
@@ -2093,24 +2222,45 @@ export function renderAgentDetailPage(
|
|
|
2093
2222
|
</div>`
|
|
2094
2223
|
: ""
|
|
2095
2224
|
}
|
|
2096
|
-
</div
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
${newTokenHtml}
|
|
2225
|
+
</div>`;
|
|
2226
|
+
|
|
2227
|
+
const sectionBodies: Record<AgentSection, string> = {
|
|
2228
|
+
general: `${headerInfoHtml}
|
|
2101
2229
|
${(opts?.extensionCardsHtml ?? []).join("\n ")}
|
|
2102
2230
|
|
|
2103
2231
|
${statStripHtml}
|
|
2104
2232
|
|
|
2105
|
-
${
|
|
2106
|
-
|
|
2107
|
-
${
|
|
2108
|
-
${
|
|
2109
|
-
${
|
|
2110
|
-
|
|
2111
|
-
${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
|
+
};
|
|
2112
2239
|
|
|
2113
|
-
|
|
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
|
+
}),
|
|
2114
2264
|
});
|
|
2115
2265
|
}
|
|
2116
2266
|
|