@app-vitals/agent-admin 1.132.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.132.0",
3
+ "version": "1.133.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@anthropic-ai/sdk": "0.137.0",
48
- "@app-vitals/agent-lib": "1.132.0",
48
+ "@app-vitals/agent-lib": "1.133.0",
49
49
  "@hono/zod-openapi": "^1.0.0",
50
50
  "@prisma/adapter-pg": "^7.10.0",
51
51
  "@prisma/client": "^7.10.0",
@@ -24,6 +24,7 @@ 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";
27
28
  import { renderHelpTip } from "./admin-ui-help-catalogue.ts";
28
29
  import { renderAdminPage } from "./admin-ui-layout.ts";
29
30
  import { renderSettingsLayout } from "./admin-ui-settings-layout.ts";
@@ -39,6 +40,7 @@ import {
39
40
  } from "./agent-github-apps.ts";
40
41
  import { isAudioFilename } from "./attachment-validation.ts";
41
42
  import { parseChatMarkers } from "./chat-markers.ts";
43
+ import type { CronHelpLookup } from "./cron-help.ts";
42
44
  import type { GithubAppsState } from "./github-apps-state.ts";
43
45
  import type {
44
46
  ChatMessage,
@@ -1335,6 +1337,12 @@ export function renderAgentDetailPage(
1335
1337
  * /admin/agents/:id/queue-activity; absent/false omits the link.
1336
1338
  */
1337
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;
1338
1346
  /** PMK-1.5: remote AgentMarketplace rows for the Marketplaces card. */
1339
1347
  marketplaces?: MarketplaceItem[];
1340
1348
  /**
@@ -1589,6 +1597,23 @@ export function renderAgentDetailPage(
1589
1597
  }`;
1590
1598
  }
1591
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
+
1592
1617
  /**
1593
1618
  * Renders the nested "Phases of <parent>" block for a top-level cron's
1594
1619
  * children (e.g. shipwright-loop's dev-task/review/patch/deploy phases).
@@ -1608,7 +1633,7 @@ export function renderAgentDetailPage(
1608
1633
  ? cronRunOutcomeLabel(child.lastRun)
1609
1634
  : null;
1610
1635
  return `<tr>
1611
- <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>
1612
1637
  <td class="mono">${escapeHtml(child.schedule)}</td>
1613
1638
  <td><span class="badge ${child.enabled ? "badge-green" : "badge-gray"}">${child.enabled ? "enabled" : "disabled"}</span></td>
1614
1639
  <td style="font-size:11px">${
@@ -1677,7 +1702,7 @@ export function renderAgentDetailPage(
1677
1702
 
1678
1703
  return `<tr>
1679
1704
  <td class="mono">${escapeHtml(c.schedule)}</td>
1680
- <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>
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>
1681
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>
1682
1707
  <td>${c.channel ? escapeHtml(c.channel) : c.user ? escapeHtml(c.user) : "—"}</td>
1683
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 &lt;once&gt; 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 } : {},
@@ -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. */