@app-vitals/agent-admin 1.130.0 → 1.132.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.130.0",
3
+ "version": "1.132.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.130.0",
48
+ "@app-vitals/agent-lib": "1.132.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,31 @@
1
+ /**
2
+ * admin/src/admin-ui-info-tip.ts
3
+ *
4
+ * Shared CSS-only info tooltip: a focusable ⓘ button plus a popover that opens
5
+ * on hover and keyboard focus. Styles live in baseStyles() (admin-ui-styles.ts).
6
+ */
7
+
8
+ import { escapeHtml } from "@app-vitals/agent-lib/web/toolbar.ts";
9
+
10
+ /** Base URL for product docs links shown in info tooltips. */
11
+ export const ADMIN_DOCS_BASE_URL = "https://shipwrightharness.com/docs/";
12
+
13
+ export interface InfoTipOptions {
14
+ /** Unique id; becomes the popover element id (aria-describedby target). */
15
+ id: string;
16
+ /** Short subject name, used in the button's aria-label ("About {label}"). */
17
+ label: string;
18
+ /** Plain-text summary shown in the popover (escaped). */
19
+ summary: string;
20
+ /** Absolute URL for the "Learn more →" link. */
21
+ docsHref: string;
22
+ /** "end" opens the popover leftward (anchored to the right edge). */
23
+ align?: "start" | "end";
24
+ }
25
+
26
+ /** Focusable info button + CSS popover with a docs link. */
27
+ export function renderInfoTip(opts: InfoTipOptions): string {
28
+ const id = escapeHtml(opts.id);
29
+ const alignClass = opts.align === "end" ? " info-tip-end" : "";
30
+ return `<span class="info-tip${alignClass}"><button type="button" class="info-tip-btn" onclick="event.preventDefault();event.stopPropagation()" aria-label="About ${escapeHtml(opts.label)}" aria-describedby="${id}">ⓘ</button><span role="tooltip" id="${id}" class="info-tip-pop">${escapeHtml(opts.summary)}<a href="${escapeHtml(opts.docsHref)}" target="_blank" rel="noopener">Learn more →</a></span></span>`;
31
+ }
@@ -0,0 +1,59 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { ADMIN_DOCS_BASE_URL, renderInfoTip } from "./admin-ui-info-tip.ts";
3
+
4
+ const base = {
5
+ id: "tip-1",
6
+ label: "Widgets",
7
+ summary: "Explains widgets.",
8
+ docsHref: `${ADMIN_DOCS_BASE_URL}widgets`,
9
+ };
10
+
11
+ describe("renderInfoTip", () => {
12
+ test("renders a button with aria wiring and a tooltip popover", () => {
13
+ const html = renderInfoTip(base);
14
+ expect(html).toContain('<button type="button" class="info-tip-btn"');
15
+ expect(html).toContain("ⓘ</button>");
16
+ expect(html).toContain('aria-label="About Widgets"');
17
+ expect(html).toContain('aria-describedby="tip-1"');
18
+ expect(html).toContain('role="tooltip" id="tip-1"');
19
+ expect(html).toContain("Explains widgets.");
20
+ });
21
+
22
+ test("link opens a new tab safely", () => {
23
+ const html = renderInfoTip(base);
24
+ expect(html).toContain(
25
+ `<a href="https://shipwrightharness.com/docs/widgets" target="_blank" rel="noopener">Learn more →</a>`,
26
+ );
27
+ });
28
+
29
+ test("activating the button does not trigger its container", () => {
30
+ const html = renderInfoTip(base);
31
+ expect(html).toContain("event.preventDefault()");
32
+ expect(html).toContain("event.stopPropagation()");
33
+ });
34
+
35
+ test("escapes < \" ' in summary, label and id", () => {
36
+ const html = renderInfoTip({
37
+ ...base,
38
+ id: `a"b`,
39
+ label: `<b>"x"</b>'`,
40
+ summary: `<script>alert("x")</script>'`,
41
+ });
42
+ expect(html).not.toContain("<script>");
43
+ expect(html).not.toContain("<b>");
44
+ expect(html).toContain("&lt;script&gt;");
45
+ expect(html).toContain("&quot;");
46
+ expect(html).not.toContain(`id="a"b"`);
47
+ });
48
+
49
+ test("align end adds the leftward modifier; default does not", () => {
50
+ expect(renderInfoTip({ ...base, align: "end" })).toContain(
51
+ 'class="info-tip info-tip-end"',
52
+ );
53
+ expect(renderInfoTip(base)).not.toContain("info-tip-end");
54
+ });
55
+
56
+ test("docs base constant is the product docs URL", () => {
57
+ expect(ADMIN_DOCS_BASE_URL).toBe("https://shipwrightharness.com/docs/");
58
+ });
59
+ });
@@ -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
+ });
@@ -24,6 +24,7 @@ import {
24
24
  renderUncoveredBadge,
25
25
  uncoveredRepos,
26
26
  } from "./admin-ui-installation-repos-pages.ts";
27
+ import { renderHelpTip } from "./admin-ui-help-catalogue.ts";
27
28
  import { renderAdminPage } from "./admin-ui-layout.ts";
28
29
  import { renderSettingsLayout } from "./admin-ui-settings-layout.ts";
29
30
  import {
@@ -768,7 +769,7 @@ export function renderNewLocalAgentPage(
768
769
  const typeFieldHtml = selfServe
769
770
  ? `<input type="hidden" name="type" value="${escapeHtml(getOwnerAgentSpecialty())}" />`
770
771
  : `<div class="form-group">
771
- <label class="form-label" for="type">Specialty <span style="color:#ef4444">*</span></label>
772
+ <label class="form-label" for="type">Specialty <span style="color:#ef4444">*</span>${renderHelpTip("specialty", "Specialty")}</label>
772
773
  <select id="type" name="type" class="form-input" required>
773
774
  ${typeOptions}
774
775
  </select>
@@ -808,7 +809,7 @@ export function renderNewLocalAgentPage(
808
809
  ${typeFieldHtml}
809
810
  ${accountFieldHtml}
810
811
  <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>
812
+ <legend style="font-size:13px;font-weight:600;padding:0 8px">Runtime${renderHelpTip("runtime", "Runtime")}</legend>
812
813
  <div class="form-group" style="margin-bottom:0">
813
814
  <label style="display:block;font-size:13px;font-weight:500;margin-bottom:8px">
814
815
  <input type="radio" name="runtime" value="in-cluster" ${canProvision ? "checked" : "disabled"}
@@ -850,7 +851,7 @@ export function renderNewLocalAgentPage(
850
851
  <p style="font-size:12px;color:var(--vos-text-muted);margin-top:4px">Format: <span class="mono">org/repo</span></p>
851
852
  </div>
852
853
  <div class="form-group">
853
- <label class="form-label" for="authorAllowlist">Author allowlist (review) (optional, one GitHub login per line)</label>
854
+ <label class="form-label" for="authorAllowlist">Author allowlist (review) (optional, one GitHub login per line)</label>${renderHelpTip("review-author-allowlist", "review author allowlist")}
854
855
  <textarea
855
856
  id="authorAllowlist"
856
857
  name="authorAllowlist"
@@ -861,7 +862,7 @@ export function renderNewLocalAgentPage(
861
862
  <p style="font-size:12px;color:var(--vos-text-muted);margin-top:4px">GitHub login, one per line</p>
862
863
  </div>
863
864
  <div class="form-group">
864
- <label class="form-label" for="patchAuthorAllowlist">Patch author allowlist (optional, one GitHub login per line)</label>
865
+ <label class="form-label" for="patchAuthorAllowlist">Patch author allowlist (optional, one GitHub login per line)</label>${renderHelpTip("patch-author-allowlist", "patch author allowlist")}
865
866
  <textarea
866
867
  id="patchAuthorAllowlist"
867
868
  name="patchAuthorAllowlist"
@@ -930,7 +931,7 @@ export function renderNewLocalAgentPage(
930
931
  </div>
931
932
  </fieldset>
932
933
  <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>
934
+ <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
935
  <!--
935
936
  ghAppMode disambiguates the two ghAuthMode="app" radios below
936
937
  (Create GitHub App = auto, Use existing GitHub App = manual).
@@ -985,11 +986,11 @@ export function renderNewLocalAgentPage(
985
986
  </div>
986
987
  <div id="gh-app-manual-fields" style="display:none">
987
988
  <div class="form-group">
988
- <label class="form-label" for="ghAppId">GitHub App ID</label>
989
+ <label class="form-label" for="ghAppId">GitHub App ID${renderHelpTip("github-app-id", "GitHub App ID")}</label>
989
990
  <input id="ghAppId" name="ghAppId" type="text" class="form-input" placeholder="App ID" />
990
991
  </div>
991
992
  <div class="form-group">
992
- <label class="form-label" for="ghAppInstallationId">Installation ID</label>
993
+ <label class="form-label" for="ghAppInstallationId">Installation ID${renderHelpTip("github-installation-id", "Installation ID")}</label>
993
994
  <input id="ghAppInstallationId" name="ghAppInstallationId" type="text" class="form-input" placeholder="Installation ID" />
994
995
  </div>
995
996
  <div class="form-group">
@@ -397,6 +397,40 @@ export function baseStyles(): string {
397
397
  pointer-events: none;
398
398
  }
399
399
 
400
+ /* ─── Info tip (ⓘ button + CSS popover; hover and focus-within) ─── */
401
+ .info-tip { position: relative; display: inline-block; vertical-align: middle; }
402
+ .info-tip-btn {
403
+ border: 0;
404
+ background: none;
405
+ padding: 0 4px;
406
+ cursor: pointer;
407
+ font-size: 14px;
408
+ line-height: 1;
409
+ color: var(--vos-text-muted);
410
+ }
411
+ .info-tip-pop {
412
+ display: none;
413
+ position: absolute;
414
+ left: 0;
415
+ top: 100%;
416
+ z-index: 10;
417
+ width: 260px;
418
+ padding: 10px 12px;
419
+ border: 1px solid var(--vos-border);
420
+ border-radius: 6px;
421
+ background: var(--vos-surface);
422
+ color: var(--vos-text);
423
+ font-size: 12px;
424
+ font-weight: normal;
425
+ line-height: 1.4;
426
+ text-align: left;
427
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
428
+ }
429
+ .info-tip-end .info-tip-pop { left: auto; right: 0; }
430
+ .info-tip:hover .info-tip-pop,
431
+ .info-tip:focus-within .info-tip-pop { display: block; }
432
+ .info-tip-pop a { display: block; margin-top: 6px; }
433
+
400
434
  /* ─── Heartbeat status dots (fresh/aging/stale) ─────── */
401
435
  .heartbeat-dot {
402
436
  display: inline-block;
@@ -148,3 +148,19 @@ describe("baseStyles — SGL-1.1 settings layout", () => {
148
148
  expect(block).toContain("var(--vos-");
149
149
  });
150
150
  });
151
+
152
+ describe("baseStyles — info tip", () => {
153
+ const css = baseStyles();
154
+ test("contains the info tip rules with hover and focus-within reveal", () => {
155
+ expect(css).toContain(".info-tip-pop");
156
+ expect(css).toContain(".info-tip:hover .info-tip-pop");
157
+ expect(css).toContain(".info-tip:focus-within .info-tip-pop");
158
+ expect(css).toContain(".info-tip-end .info-tip-pop");
159
+ });
160
+ test("uses theme variables, and the old header tooltip is unchanged", () => {
161
+ expect(css).toContain("background: var(--vos-surface)");
162
+ expect(css).toContain("color: var(--vos-text)");
163
+ expect(css).toContain(".header-tooltip[data-tip]:hover::after");
164
+ expect(css).toContain("content: attr(data-tip)");
165
+ });
166
+ });