@app-vitals/agent-admin 1.131.0 → 1.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/admin-ui-help-catalogue.ts +87 -0
- package/src/admin-ui-help-catalogue.unit.test.ts +56 -0
- package/src/admin-ui-new-agent-help.unit.test.ts +25 -0
- package/src/admin-ui-pages.ts +35 -9
- package/src/admin-ui-pages.unit.test.ts +73 -0
- package/src/admin-ui.ts +7 -0
- package/src/cron-help.ts +60 -0
- package/src/cron-help.unit.test.ts +101 -0
- package/src/specialty-defaults.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.133.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"./admin-boot": "./src/admin-boot.ts",
|
|
19
19
|
"./admin-extension": "./src/admin-extension.ts",
|
|
20
20
|
"./admin-spec": "./src/admin-spec.ts",
|
|
21
|
+
"./admin-ui-help-catalogue": "./src/admin-ui-help-catalogue.ts",
|
|
21
22
|
"./main": "./src/main.ts",
|
|
22
23
|
"./openapi-schemas": "./src/openapi-schemas.ts",
|
|
23
24
|
"./platform-routes": "./src/platform-routes.ts",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@anthropic-ai/sdk": "0.137.0",
|
|
47
|
-
"@app-vitals/agent-lib": "1.
|
|
48
|
+
"@app-vitals/agent-lib": "1.133.0",
|
|
48
49
|
"@hono/zod-openapi": "^1.0.0",
|
|
49
50
|
"@prisma/adapter-pg": "^7.10.0",
|
|
50
51
|
"@prisma/client": "^7.10.0",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/admin-ui-help-catalogue.ts
|
|
3
|
+
*
|
|
4
|
+
* Typed catalogue of help-tooltip content for the admin UI, keyed by help id.
|
|
5
|
+
* Each entry has a plain-text summary and a glossary anchor; the docs link is
|
|
6
|
+
* ADMIN_DOCS_BASE_URL + "admin-console-glossary#" + anchor.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ADMIN_DOCS_BASE_URL, renderInfoTip } from "./admin-ui-info-tip.ts";
|
|
10
|
+
|
|
11
|
+
export interface HelpEntry {
|
|
12
|
+
/** Plain-text summary (<= 280 chars). */
|
|
13
|
+
summary: string;
|
|
14
|
+
/** Section anchor in the admin console glossary. */
|
|
15
|
+
anchor: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const HELP_CATALOGUE = {
|
|
19
|
+
specialty: {
|
|
20
|
+
summary:
|
|
21
|
+
"What the agent is meant to be good at. The specialty is added to the agent's instructions.",
|
|
22
|
+
anchor: "specialty",
|
|
23
|
+
},
|
|
24
|
+
runtime: {
|
|
25
|
+
summary:
|
|
26
|
+
"Where the agent's code runs: on the platform cluster or on a machine you manage. This decides how the agent is started, updated and stopped.",
|
|
27
|
+
anchor: "runtime",
|
|
28
|
+
},
|
|
29
|
+
"review-author-allowlist": {
|
|
30
|
+
summary:
|
|
31
|
+
"GitHub usernames whose pull requests the agent reviews automatically. Pull requests from anyone else are skipped.",
|
|
32
|
+
anchor: "review-author-allowlist",
|
|
33
|
+
},
|
|
34
|
+
"patch-author-allowlist": {
|
|
35
|
+
summary:
|
|
36
|
+
"GitHub usernames whose pull requests the agent may push fixes to. Pull requests from anyone else are never patched.",
|
|
37
|
+
anchor: "patch-author-allowlist",
|
|
38
|
+
},
|
|
39
|
+
"github-pat-vs-app": {
|
|
40
|
+
summary:
|
|
41
|
+
"A personal access token acts as one person. A GitHub App has its own identity, scoped to the repositories it is installed on.",
|
|
42
|
+
anchor: "github-pat-vs-app",
|
|
43
|
+
},
|
|
44
|
+
"github-app-id": {
|
|
45
|
+
summary:
|
|
46
|
+
"The numeric ID GitHub assigns to an App. Find it on the App's settings page under About.",
|
|
47
|
+
anchor: "github-app-id",
|
|
48
|
+
},
|
|
49
|
+
"github-installation-id": {
|
|
50
|
+
summary:
|
|
51
|
+
"The numeric ID of one installation of the App on an organization or account. It appears in the installation settings URL.",
|
|
52
|
+
anchor: "github-installation-id",
|
|
53
|
+
},
|
|
54
|
+
} as const satisfies Record<string, HelpEntry>;
|
|
55
|
+
|
|
56
|
+
export type HelpId = keyof typeof HELP_CATALOGUE;
|
|
57
|
+
|
|
58
|
+
/** Look up a catalogue entry; undefined for unknown ids and prototype keys. */
|
|
59
|
+
export function getHelpEntry(id: string): HelpEntry | undefined {
|
|
60
|
+
if (!Object.hasOwn(HELP_CATALOGUE, id)) return undefined;
|
|
61
|
+
return HELP_CATALOGUE[id as HelpId];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Absolute docs URL for a catalogue entry. */
|
|
65
|
+
export function helpDocsHref(entry: HelpEntry): string {
|
|
66
|
+
return `${ADMIN_DOCS_BASE_URL}admin-console-glossary#${entry.anchor}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Render the info tooltip for a catalogue id (popover id `help-${id}`).
|
|
71
|
+
* Returns "" for an unknown id so a stale reference never breaks a page.
|
|
72
|
+
*/
|
|
73
|
+
export function renderHelpTip(
|
|
74
|
+
id: string,
|
|
75
|
+
label: string,
|
|
76
|
+
align?: "start" | "end",
|
|
77
|
+
): string {
|
|
78
|
+
const entry = getHelpEntry(id);
|
|
79
|
+
if (!entry) return "";
|
|
80
|
+
return renderInfoTip({
|
|
81
|
+
id: `help-${id}`,
|
|
82
|
+
label,
|
|
83
|
+
summary: entry.summary,
|
|
84
|
+
docsHref: helpDocsHref(entry),
|
|
85
|
+
align,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
getHelpEntry,
|
|
4
|
+
HELP_CATALOGUE,
|
|
5
|
+
helpDocsHref,
|
|
6
|
+
renderHelpTip,
|
|
7
|
+
} from "./admin-ui-help-catalogue.ts";
|
|
8
|
+
import { ADMIN_DOCS_BASE_URL } from "./admin-ui-info-tip.ts";
|
|
9
|
+
|
|
10
|
+
const ids = Object.keys(HELP_CATALOGUE);
|
|
11
|
+
|
|
12
|
+
describe("help catalogue", () => {
|
|
13
|
+
test("has the seven expected ids", () => {
|
|
14
|
+
expect(ids.sort()).toEqual(
|
|
15
|
+
[
|
|
16
|
+
"github-app-id",
|
|
17
|
+
"github-installation-id",
|
|
18
|
+
"github-pat-vs-app",
|
|
19
|
+
"patch-author-allowlist",
|
|
20
|
+
"review-author-allowlist",
|
|
21
|
+
"runtime",
|
|
22
|
+
"specialty",
|
|
23
|
+
].sort(),
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("every entry is well-formed", () => {
|
|
28
|
+
for (const id of ids) {
|
|
29
|
+
const entry = getHelpEntry(id);
|
|
30
|
+
expect(entry).toBeDefined();
|
|
31
|
+
expect(entry?.summary.length).toBeGreaterThan(0);
|
|
32
|
+
expect(entry?.summary.length).toBeLessThanOrEqual(280);
|
|
33
|
+
expect(entry?.anchor).toBe(id);
|
|
34
|
+
expect(helpDocsHref(entry as NonNullable<typeof entry>)).toBe(
|
|
35
|
+
`${ADMIN_DOCS_BASE_URL}admin-console-glossary#${id}`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("unknown and prototype ids return undefined", () => {
|
|
41
|
+
for (const id of ["nope", "__proto__", "constructor", "toString", ""]) {
|
|
42
|
+
expect(getHelpEntry(id)).toBeUndefined();
|
|
43
|
+
expect(renderHelpTip(id, "X")).toBe("");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("renderHelpTip renders popover id, link and align", () => {
|
|
48
|
+
const html = renderHelpTip("runtime", "Runtime", "end");
|
|
49
|
+
expect(html).toContain('id="help-runtime"');
|
|
50
|
+
expect(html).toContain('aria-label="About Runtime"');
|
|
51
|
+
expect(html).toContain("info-tip-end");
|
|
52
|
+
expect(html).toContain(
|
|
53
|
+
`href="${ADMIN_DOCS_BASE_URL}admin-console-glossary#runtime"`,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { HELP_CATALOGUE } from "./admin-ui-help-catalogue.ts";
|
|
3
|
+
import { renderNewLocalAgentPage } from "./admin-ui-pages.ts";
|
|
4
|
+
|
|
5
|
+
const TYPES = [{ name: "coding", displayName: "Coding Agent" }];
|
|
6
|
+
const count = (html: string, needle: string) => html.split(needle).length - 1;
|
|
7
|
+
|
|
8
|
+
describe("renderNewLocalAgentPage help tooltips", () => {
|
|
9
|
+
const html = renderNewLocalAgentPage("Dan", TYPES);
|
|
10
|
+
|
|
11
|
+
for (const id of Object.keys(HELP_CATALOGUE)) {
|
|
12
|
+
test(`renders help-${id} exactly once`, () => {
|
|
13
|
+
expect(count(html, `id="help-${id}"`)).toBe(1);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
test("selfServe omits the specialty tip but keeps the rest", () => {
|
|
18
|
+
const ss = renderNewLocalAgentPage("Dan", TYPES, {
|
|
19
|
+
selfServe: { remaining: 1, max: 3 },
|
|
20
|
+
});
|
|
21
|
+
expect(count(ss, 'id="help-specialty"')).toBe(0);
|
|
22
|
+
expect(count(ss, 'id="help-runtime"')).toBe(1);
|
|
23
|
+
expect(count(ss, 'id="help-github-app-id"')).toBe(1);
|
|
24
|
+
});
|
|
25
|
+
});
|
package/src/admin-ui-pages.ts
CHANGED
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
renderUncoveredBadge,
|
|
25
25
|
uncoveredRepos,
|
|
26
26
|
} from "./admin-ui-installation-repos-pages.ts";
|
|
27
|
+
import { renderInfoTip } from "./admin-ui-info-tip.ts";
|
|
28
|
+
import { renderHelpTip } from "./admin-ui-help-catalogue.ts";
|
|
27
29
|
import { renderAdminPage } from "./admin-ui-layout.ts";
|
|
28
30
|
import { renderSettingsLayout } from "./admin-ui-settings-layout.ts";
|
|
29
31
|
import {
|
|
@@ -38,6 +40,7 @@ import {
|
|
|
38
40
|
} from "./agent-github-apps.ts";
|
|
39
41
|
import { isAudioFilename } from "./attachment-validation.ts";
|
|
40
42
|
import { parseChatMarkers } from "./chat-markers.ts";
|
|
43
|
+
import type { CronHelpLookup } from "./cron-help.ts";
|
|
41
44
|
import type { GithubAppsState } from "./github-apps-state.ts";
|
|
42
45
|
import type {
|
|
43
46
|
ChatMessage,
|
|
@@ -768,7 +771,7 @@ export function renderNewLocalAgentPage(
|
|
|
768
771
|
const typeFieldHtml = selfServe
|
|
769
772
|
? `<input type="hidden" name="type" value="${escapeHtml(getOwnerAgentSpecialty())}" />`
|
|
770
773
|
: `<div class="form-group">
|
|
771
|
-
<label class="form-label" for="type">Specialty <span style="color:#ef4444">*</span
|
|
774
|
+
<label class="form-label" for="type">Specialty <span style="color:#ef4444">*</span>${renderHelpTip("specialty", "Specialty")}</label>
|
|
772
775
|
<select id="type" name="type" class="form-input" required>
|
|
773
776
|
${typeOptions}
|
|
774
777
|
</select>
|
|
@@ -808,7 +811,7 @@ export function renderNewLocalAgentPage(
|
|
|
808
811
|
${typeFieldHtml}
|
|
809
812
|
${accountFieldHtml}
|
|
810
813
|
<fieldset style="border:1px solid var(--vos-border);border-radius:8px;padding:16px">
|
|
811
|
-
<legend style="font-size:13px;font-weight:600;padding:0 8px">Runtime</legend>
|
|
814
|
+
<legend style="font-size:13px;font-weight:600;padding:0 8px">Runtime${renderHelpTip("runtime", "Runtime")}</legend>
|
|
812
815
|
<div class="form-group" style="margin-bottom:0">
|
|
813
816
|
<label style="display:block;font-size:13px;font-weight:500;margin-bottom:8px">
|
|
814
817
|
<input type="radio" name="runtime" value="in-cluster" ${canProvision ? "checked" : "disabled"}
|
|
@@ -850,7 +853,7 @@ export function renderNewLocalAgentPage(
|
|
|
850
853
|
<p style="font-size:12px;color:var(--vos-text-muted);margin-top:4px">Format: <span class="mono">org/repo</span></p>
|
|
851
854
|
</div>
|
|
852
855
|
<div class="form-group">
|
|
853
|
-
<label class="form-label" for="authorAllowlist">Author allowlist (review) (optional, one GitHub login per line)</label
|
|
856
|
+
<label class="form-label" for="authorAllowlist">Author allowlist (review) (optional, one GitHub login per line)</label>${renderHelpTip("review-author-allowlist", "review author allowlist")}
|
|
854
857
|
<textarea
|
|
855
858
|
id="authorAllowlist"
|
|
856
859
|
name="authorAllowlist"
|
|
@@ -861,7 +864,7 @@ export function renderNewLocalAgentPage(
|
|
|
861
864
|
<p style="font-size:12px;color:var(--vos-text-muted);margin-top:4px">GitHub login, one per line</p>
|
|
862
865
|
</div>
|
|
863
866
|
<div class="form-group">
|
|
864
|
-
<label class="form-label" for="patchAuthorAllowlist">Patch author allowlist (optional, one GitHub login per line)</label
|
|
867
|
+
<label class="form-label" for="patchAuthorAllowlist">Patch author allowlist (optional, one GitHub login per line)</label>${renderHelpTip("patch-author-allowlist", "patch author allowlist")}
|
|
865
868
|
<textarea
|
|
866
869
|
id="patchAuthorAllowlist"
|
|
867
870
|
name="patchAuthorAllowlist"
|
|
@@ -930,7 +933,7 @@ export function renderNewLocalAgentPage(
|
|
|
930
933
|
</div>
|
|
931
934
|
</fieldset>
|
|
932
935
|
<fieldset id="github-section" style="display:${runtimeSectionsDisplay};border:1px solid var(--vos-border);border-radius:8px;padding:16px">
|
|
933
|
-
<legend style="font-size:13px;font-weight:600;padding:0 8px">GitHub Authentication (optional)</legend>
|
|
936
|
+
<legend style="font-size:13px;font-weight:600;padding:0 8px">GitHub Authentication (optional)${renderHelpTip("github-pat-vs-app", "personal access token versus GitHub App")}</legend>
|
|
934
937
|
<!--
|
|
935
938
|
ghAppMode disambiguates the two ghAuthMode="app" radios below
|
|
936
939
|
(Create GitHub App = auto, Use existing GitHub App = manual).
|
|
@@ -985,11 +988,11 @@ export function renderNewLocalAgentPage(
|
|
|
985
988
|
</div>
|
|
986
989
|
<div id="gh-app-manual-fields" style="display:none">
|
|
987
990
|
<div class="form-group">
|
|
988
|
-
<label class="form-label" for="ghAppId">GitHub App ID</label>
|
|
991
|
+
<label class="form-label" for="ghAppId">GitHub App ID${renderHelpTip("github-app-id", "GitHub App ID")}</label>
|
|
989
992
|
<input id="ghAppId" name="ghAppId" type="text" class="form-input" placeholder="App ID" />
|
|
990
993
|
</div>
|
|
991
994
|
<div class="form-group">
|
|
992
|
-
<label class="form-label" for="ghAppInstallationId">Installation ID</label>
|
|
995
|
+
<label class="form-label" for="ghAppInstallationId">Installation ID${renderHelpTip("github-installation-id", "Installation ID")}</label>
|
|
993
996
|
<input id="ghAppInstallationId" name="ghAppInstallationId" type="text" class="form-input" placeholder="Installation ID" />
|
|
994
997
|
</div>
|
|
995
998
|
<div class="form-group">
|
|
@@ -1334,6 +1337,12 @@ export function renderAgentDetailPage(
|
|
|
1334
1337
|
* /admin/agents/:id/queue-activity; absent/false omits the link.
|
|
1335
1338
|
*/
|
|
1336
1339
|
queueActivityLinks?: boolean;
|
|
1340
|
+
/**
|
|
1341
|
+
* Per-cron help for the Cron Jobs card (cron-help.ts): a cron whose name
|
|
1342
|
+
* resolves gets an info tooltip beside its label. Absent, or no entry for
|
|
1343
|
+
* a name, renders that row without one.
|
|
1344
|
+
*/
|
|
1345
|
+
cronHelp?: CronHelpLookup;
|
|
1337
1346
|
/** PMK-1.5: remote AgentMarketplace rows for the Marketplaces card. */
|
|
1338
1347
|
marketplaces?: MarketplaceItem[];
|
|
1339
1348
|
/**
|
|
@@ -1588,6 +1597,23 @@ export function renderAgentDetailPage(
|
|
|
1588
1597
|
}`;
|
|
1589
1598
|
}
|
|
1590
1599
|
|
|
1600
|
+
/**
|
|
1601
|
+
* The info tooltip for a cron that has help (opts.cronHelp), or "". Only
|
|
1602
|
+
* named system crons are looked up: a custom cron that happens to share a
|
|
1603
|
+
* system cron's name must not borrow its explanation.
|
|
1604
|
+
*/
|
|
1605
|
+
function renderCronHelpTip(c: CronJobItem): string {
|
|
1606
|
+
if (!c.system || !c.name) return "";
|
|
1607
|
+
const help = opts?.cronHelp?.(c.name);
|
|
1608
|
+
if (!help) return "";
|
|
1609
|
+
return ` ${renderInfoTip({
|
|
1610
|
+
id: `cron-help-${c.id}`,
|
|
1611
|
+
label: c.name,
|
|
1612
|
+
summary: help.summary,
|
|
1613
|
+
docsHref: help.docsHref,
|
|
1614
|
+
})}`;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1591
1617
|
/**
|
|
1592
1618
|
* Renders the nested "Phases of <parent>" block for a top-level cron's
|
|
1593
1619
|
* children (e.g. shipwright-loop's dev-task/review/patch/deploy phases).
|
|
@@ -1607,7 +1633,7 @@ export function renderAgentDetailPage(
|
|
|
1607
1633
|
? cronRunOutcomeLabel(child.lastRun)
|
|
1608
1634
|
: null;
|
|
1609
1635
|
return `<tr>
|
|
1610
|
-
<td style="padding-left:20px">${escapeHtml(child.name ? `${child.name}: ${child.prompt}` : child.prompt)}</td>
|
|
1636
|
+
<td style="padding-left:20px">${escapeHtml(child.name ? `${child.name}: ${child.prompt}` : child.prompt)}${renderCronHelpTip(child)}</td>
|
|
1611
1637
|
<td class="mono">${escapeHtml(child.schedule)}</td>
|
|
1612
1638
|
<td><span class="badge ${child.enabled ? "badge-green" : "badge-gray"}">${child.enabled ? "enabled" : "disabled"}</span></td>
|
|
1613
1639
|
<td style="font-size:11px">${
|
|
@@ -1676,7 +1702,7 @@ export function renderAgentDetailPage(
|
|
|
1676
1702
|
|
|
1677
1703
|
return `<tr>
|
|
1678
1704
|
<td class="mono">${escapeHtml(c.schedule)}</td>
|
|
1679
|
-
<td style="max-width:280px;overflow
|
|
1705
|
+
<td style="max-width:280px;overflow-wrap:anywhere">${escapeHtml(c.name ? `${c.name}: ${c.prompt}` : c.prompt)}${renderCronHelpTip(c)}${sourceBadge(c.system ? undefined : c.source)}</td>
|
|
1680
1706
|
<td class="mono" style="font-size:11px;color:var(--vos-text-muted);max-width:170px;overflow:hidden;text-overflow:ellipsis">${c.preCheck ? escapeHtml(c.preCheck) : "—"}</td>
|
|
1681
1707
|
<td>${c.channel ? escapeHtml(c.channel) : c.user ? escapeHtml(c.user) : "—"}</td>
|
|
1682
1708
|
<td><span class="badge ${c.enabled ? "badge-green" : "badge-gray"}">${c.enabled ? "enabled" : "disabled"}</span></td>
|
|
@@ -4834,3 +4834,76 @@ describe("deriveAgentSetupSteps with the GitHub App table (multi-github-apps 1.5
|
|
|
4834
4834
|
);
|
|
4835
4835
|
});
|
|
4836
4836
|
});
|
|
4837
|
+
|
|
4838
|
+
// ─── renderAgentDetailPage — per-cron help tooltips ──────────────────────────
|
|
4839
|
+
|
|
4840
|
+
describe("renderAgentDetailPage — cron help tooltips", () => {
|
|
4841
|
+
const HELP = {
|
|
4842
|
+
summary: "Checks health <once> an hour.",
|
|
4843
|
+
docsHref: "https://shipwrightharness.com/docs/widgets#health-check",
|
|
4844
|
+
};
|
|
4845
|
+
const PHASE_HELP = {
|
|
4846
|
+
summary: "Runs the build phase.",
|
|
4847
|
+
docsHref: "https://shipwrightharness.com/docs/widgets#build-phase",
|
|
4848
|
+
};
|
|
4849
|
+
const PHASE: CronJobItem = {
|
|
4850
|
+
...SYSTEM_CRON,
|
|
4851
|
+
id: "cron-phase-1",
|
|
4852
|
+
name: "build-phase",
|
|
4853
|
+
prompt: "/run build",
|
|
4854
|
+
parentCronId: SYSTEM_CRON.id,
|
|
4855
|
+
};
|
|
4856
|
+
const lookup = (name: string) =>
|
|
4857
|
+
({ "health-check": HELP, "build-phase": PHASE_HELP })[name];
|
|
4858
|
+
|
|
4859
|
+
function render(
|
|
4860
|
+
crons: CronJobItem[],
|
|
4861
|
+
cronHelp?: (name: string) => typeof HELP | undefined,
|
|
4862
|
+
): string {
|
|
4863
|
+
return renderAgentDetailSection(
|
|
4864
|
+
AGENT,
|
|
4865
|
+
{},
|
|
4866
|
+
crons,
|
|
4867
|
+
[],
|
|
4868
|
+
[],
|
|
4869
|
+
[],
|
|
4870
|
+
[],
|
|
4871
|
+
USER_NAME,
|
|
4872
|
+
true,
|
|
4873
|
+
{ timezone: "UTC", section: "automation", cronHelp },
|
|
4874
|
+
);
|
|
4875
|
+
}
|
|
4876
|
+
const tipCount = (html: string) =>
|
|
4877
|
+
html.split('class="info-tip-btn"').length - 1;
|
|
4878
|
+
|
|
4879
|
+
test("a system row and a phase row each get exactly one tooltip", () => {
|
|
4880
|
+
const html = render([SYSTEM_CRON, PHASE], lookup);
|
|
4881
|
+
expect(tipCount(html)).toBe(2);
|
|
4882
|
+
expect(html).toContain('aria-label="About health-check"');
|
|
4883
|
+
expect(html).toContain('id="cron-help-cron-sys-1"');
|
|
4884
|
+
expect(html).toContain("Checks health <once> an hour.");
|
|
4885
|
+
expect(html).toContain(
|
|
4886
|
+
`<a href="${HELP.docsHref}" target="_blank" rel="noopener">Learn more →</a>`,
|
|
4887
|
+
);
|
|
4888
|
+
expect(html).toContain('aria-label="About build-phase"');
|
|
4889
|
+
expect(html).toContain('id="cron-help-cron-phase-1"');
|
|
4890
|
+
expect(html).toContain(PHASE_HELP.docsHref);
|
|
4891
|
+
});
|
|
4892
|
+
|
|
4893
|
+
test("no lookup leaves the rows without tooltips", () => {
|
|
4894
|
+
expect(tipCount(render([SYSTEM_CRON, PHASE]))).toBe(0);
|
|
4895
|
+
});
|
|
4896
|
+
|
|
4897
|
+
test("a cron with no entry gets no tooltip", () => {
|
|
4898
|
+
const html = render([{ ...SYSTEM_CRON, name: "other-cron" }], lookup);
|
|
4899
|
+
expect(tipCount(html)).toBe(0);
|
|
4900
|
+
});
|
|
4901
|
+
|
|
4902
|
+
test("a custom cron never borrows a system cron's help", () => {
|
|
4903
|
+
const html = render(
|
|
4904
|
+
[{ ...CUSTOM_CRON, name: "health-check", source: "custom" }],
|
|
4905
|
+
lookup,
|
|
4906
|
+
);
|
|
4907
|
+
expect(tipCount(html)).toBe(0);
|
|
4908
|
+
});
|
|
4909
|
+
});
|
package/src/admin-ui.ts
CHANGED
|
@@ -210,6 +210,7 @@ import {
|
|
|
210
210
|
SlackProvisioningService,
|
|
211
211
|
} from "./slack-provisioning-service.ts";
|
|
212
212
|
import type { SpecialtyDefaultsResolver } from "./specialty-defaults.ts";
|
|
213
|
+
import { buildCronHelpLookup } from "./cron-help.ts";
|
|
213
214
|
import {
|
|
214
215
|
type SpecialtyTypeResolver,
|
|
215
216
|
SpecialtyTypes,
|
|
@@ -2972,6 +2973,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2972
2973
|
extensionCardsHtml: cards.header,
|
|
2973
2974
|
configurationCardsHtml: cards.configuration,
|
|
2974
2975
|
queueActivityLinks: deps.queueActivityLinks,
|
|
2976
|
+
cronHelp: buildCronHelpLookup(
|
|
2977
|
+
specialtyDefaults?.(agentDetail.specialty),
|
|
2978
|
+
),
|
|
2975
2979
|
marketplaces,
|
|
2976
2980
|
...(appsState ? { githubAppsState: appsState } : {}),
|
|
2977
2981
|
slackConfigTokenStored: await hasStoredSlackConfigToken(
|
|
@@ -4008,6 +4012,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
4008
4012
|
extensionCardsHtml: cards.header,
|
|
4009
4013
|
configurationCardsHtml: cards.configuration,
|
|
4010
4014
|
queueActivityLinks: deps.queueActivityLinks,
|
|
4015
|
+
cronHelp: buildCronHelpLookup(
|
|
4016
|
+
specialtyDefaults?.(agentDetail.specialty),
|
|
4017
|
+
),
|
|
4011
4018
|
marketplaces,
|
|
4012
4019
|
...(await githubAppsState(c).then((st) =>
|
|
4013
4020
|
st ? { githubAppsState: st } : {},
|
package/src/cron-help.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/cron-help.ts
|
|
3
|
+
*
|
|
4
|
+
* Per-cron help for the agent detail page's Cron Jobs card. A specialty's
|
|
5
|
+
* default crons (specialty-defaults.ts) may each carry a short summary and a
|
|
6
|
+
* docs link; the card shows them in the shared info tooltip next to the cron's
|
|
7
|
+
* name. The wording belongs to whoever supplies the defaults, never to the
|
|
8
|
+
* platform: a cron with no help entry renders exactly as before.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { ADMIN_DOCS_BASE_URL } from "./admin-ui-info-tip.ts";
|
|
12
|
+
import type { SpecialtyDefaults } from "./specialty-defaults.ts";
|
|
13
|
+
|
|
14
|
+
/** Help shown for one cron: one or two sentences plus a docs link. */
|
|
15
|
+
export interface CronHelp {
|
|
16
|
+
/** Plain-text summary shown in the tooltip. */
|
|
17
|
+
summary: string;
|
|
18
|
+
/** Absolute docs URL; must start with ADMIN_DOCS_BASE_URL. */
|
|
19
|
+
docsHref: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Longest summary a tooltip shows; the same limit the help catalogue uses. */
|
|
23
|
+
export const CRON_HELP_MAX_SUMMARY_LENGTH = 280;
|
|
24
|
+
|
|
25
|
+
/** Resolves a cron's name to its help, or undefined when there is none. */
|
|
26
|
+
export type CronHelpLookup = (cronName: string) => CronHelp | undefined;
|
|
27
|
+
|
|
28
|
+
/** True when the help is safe to show: a real summary and a docs-site link. */
|
|
29
|
+
export function isValidCronHelp(help: unknown): help is CronHelp {
|
|
30
|
+
if (typeof help !== "object" || help === null) return false;
|
|
31
|
+
const { summary, docsHref } = help as Record<string, unknown>;
|
|
32
|
+
if (typeof summary !== "string" || typeof docsHref !== "string") return false;
|
|
33
|
+
const trimmed = summary.trim();
|
|
34
|
+
return (
|
|
35
|
+
trimmed.length > 0 &&
|
|
36
|
+
trimmed.length <= CRON_HELP_MAX_SUMMARY_LENGTH &&
|
|
37
|
+
docsHref.startsWith(ADMIN_DOCS_BASE_URL)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Builds the lookup for one specialty's defaults. Invalid entries (empty or
|
|
43
|
+
* over-long summary, a link outside the docs site) are dropped so a bad entry
|
|
44
|
+
* hides its tooltip instead of rendering a broken one. Names are matched
|
|
45
|
+
* exactly; a Map keeps prototype keys such as "constructor" from resolving.
|
|
46
|
+
*/
|
|
47
|
+
export function buildCronHelpLookup(
|
|
48
|
+
defaults: SpecialtyDefaults | undefined,
|
|
49
|
+
): CronHelpLookup {
|
|
50
|
+
const byName = new Map<string, CronHelp>();
|
|
51
|
+
for (const cron of defaults?.crons ?? []) {
|
|
52
|
+
if (isValidCronHelp(cron.help)) {
|
|
53
|
+
byName.set(cron.name, {
|
|
54
|
+
summary: cron.help.summary.trim(),
|
|
55
|
+
docsHref: cron.help.docsHref,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return (cronName) => byName.get(cronName);
|
|
60
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { ADMIN_DOCS_BASE_URL } from "./admin-ui-info-tip.ts";
|
|
3
|
+
import {
|
|
4
|
+
buildCronHelpLookup,
|
|
5
|
+
CRON_HELP_MAX_SUMMARY_LENGTH,
|
|
6
|
+
isValidCronHelp,
|
|
7
|
+
} from "./cron-help.ts";
|
|
8
|
+
import type { SpecialtyDefaultCron } from "./specialty-defaults.ts";
|
|
9
|
+
|
|
10
|
+
const cron = (
|
|
11
|
+
name: string,
|
|
12
|
+
help?: SpecialtyDefaultCron["help"],
|
|
13
|
+
): SpecialtyDefaultCron => ({
|
|
14
|
+
name,
|
|
15
|
+
schedule: "* * * * *",
|
|
16
|
+
prompt: `/run ${name}`,
|
|
17
|
+
...(help ? { help } : {}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const good = {
|
|
21
|
+
summary: "Builds the selected task.",
|
|
22
|
+
docsHref: `${ADMIN_DOCS_BASE_URL}widgets#build`,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("isValidCronHelp", () => {
|
|
26
|
+
test("accepts a summary with a docs-site link", () => {
|
|
27
|
+
expect(isValidCronHelp(good)).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("rejects a blank or over-long summary", () => {
|
|
31
|
+
expect(isValidCronHelp({ ...good, summary: " " })).toBe(false);
|
|
32
|
+
expect(
|
|
33
|
+
isValidCronHelp({
|
|
34
|
+
...good,
|
|
35
|
+
summary: "x".repeat(CRON_HELP_MAX_SUMMARY_LENGTH + 1),
|
|
36
|
+
}),
|
|
37
|
+
).toBe(false);
|
|
38
|
+
expect(
|
|
39
|
+
isValidCronHelp({
|
|
40
|
+
...good,
|
|
41
|
+
summary: "x".repeat(CRON_HELP_MAX_SUMMARY_LENGTH),
|
|
42
|
+
}),
|
|
43
|
+
).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("rejects a link outside the docs site", () => {
|
|
47
|
+
expect(
|
|
48
|
+
isValidCronHelp({ ...good, docsHref: "https://example.com/docs/x" }),
|
|
49
|
+
).toBe(false);
|
|
50
|
+
expect(isValidCronHelp({ ...good, docsHref: "javascript:alert(1)" })).toBe(
|
|
51
|
+
false,
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("rejects values that are not help objects", () => {
|
|
56
|
+
for (const value of [undefined, null, "text", 3, {}, { summary: "x" }]) {
|
|
57
|
+
expect(isValidCronHelp(value)).toBe(false);
|
|
58
|
+
}
|
|
59
|
+
expect(isValidCronHelp({ summary: 1, docsHref: good.docsHref })).toBe(
|
|
60
|
+
false,
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe("buildCronHelpLookup", () => {
|
|
66
|
+
test("resolves a cron by exact name and trims the summary", () => {
|
|
67
|
+
const lookup = buildCronHelpLookup({
|
|
68
|
+
crons: [cron("build", { ...good, summary: " Builds it. " })],
|
|
69
|
+
});
|
|
70
|
+
expect(lookup("build")).toEqual({
|
|
71
|
+
summary: "Builds it.",
|
|
72
|
+
docsHref: good.docsHref,
|
|
73
|
+
});
|
|
74
|
+
expect(lookup("Build")).toBeUndefined();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("returns nothing for crons without help or with invalid help", () => {
|
|
78
|
+
const lookup = buildCronHelpLookup({
|
|
79
|
+
crons: [
|
|
80
|
+
cron("plain"),
|
|
81
|
+
cron("blank", { ...good, summary: "" }),
|
|
82
|
+
cron("offsite", { ...good, docsHref: "https://example.com/x" }),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
expect(lookup("plain")).toBeUndefined();
|
|
86
|
+
expect(lookup("blank")).toBeUndefined();
|
|
87
|
+
expect(lookup("offsite")).toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("returns nothing for unknown names and prototype keys", () => {
|
|
91
|
+
const lookup = buildCronHelpLookup({ crons: [cron("build", good)] });
|
|
92
|
+
expect(lookup("no-such-cron")).toBeUndefined();
|
|
93
|
+
expect(lookup("constructor")).toBeUndefined();
|
|
94
|
+
expect(lookup("__proto__")).toBeUndefined();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("is empty when the specialty supplies no defaults or no crons", () => {
|
|
98
|
+
expect(buildCronHelpLookup(undefined)("build")).toBeUndefined();
|
|
99
|
+
expect(buildCronHelpLookup({})("build")).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -20,6 +20,11 @@ export interface SpecialtyDefaultCron {
|
|
|
20
20
|
enabled?: boolean;
|
|
21
21
|
/** Name of another cron in this same list. */
|
|
22
22
|
parentCron?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Shown in the info tooltip beside this cron on the agent detail page
|
|
25
|
+
* (cron-help.ts). Display only: never stored on the cron row.
|
|
26
|
+
*/
|
|
27
|
+
help?: { summary: string; docsHref: string };
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/** Any field left undefined falls back to the built-in type for that field. */
|