@app-vitals/agent-lib 1.71.0 → 1.73.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-lib",
3
- "version": "1.71.0",
3
+ "version": "1.73.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
package/web/toolbar.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  /**
7
- * Who is viewing the toolbar. `admin` = admins and owners; `member` = any other
7
+ * Who is viewing the toolbar. `admin` = admins, owners and account members; `member` = any other
8
8
  * signed-in user; `public` = the unauthenticated read-only proof host.
9
9
  */
10
10
  export type ToolbarAudience = "admin" | "member" | "public";
@@ -45,10 +45,10 @@ export const TOOLBAR_NAV_ITEMS: readonly ToolbarNavItem[] = [
45
45
  export interface ShipwrightToolbarOptions {
46
46
  /**
47
47
  * Who is viewing. Nav visibility derives from {@link TOOLBAR_NAV_ITEMS}.
48
- * `public` renders the read-only variant (same as `readOnly`). When omitted,
49
- * the legacy `readOnly` / `showSettings` flags decide.
48
+ * `public` renders the read-only variant (Metrics + public task board, no
49
+ * sign-out).
50
50
  */
51
- audience?: ToolbarAudience;
51
+ audience: ToolbarAudience;
52
52
  userName: string;
53
53
  /** Current request path, used to highlight the active nav link. */
54
54
  activePath: string;
@@ -58,21 +58,8 @@ export interface ShipwrightToolbarOptions {
58
58
  metricsUrl?: string;
59
59
  /** Base URL of the admin service. Defaults to empty string (same origin). */
60
60
  adminBaseUrl?: string;
61
- /**
62
- * Public, unauthenticated variant. When true, render only the read-only
63
- * surfaces (Metrics dashboard + public task board) and no sign-out — the
64
- * authenticated /admin/* links and logout are omitted, since they 404 (and
65
- * aren't reachable) on the public proof host.
66
- */
67
- readOnly?: boolean;
68
- /** Public task board URL, used only in readOnly mode. Defaults to "/public/tasks". */
61
+ /** Public task board URL, used only for the public audience. Defaults to "/public/tasks". */
69
62
  tasksUrl?: string;
70
- /**
71
- * Render the "Settings" nav entry (links to /admin/settings; shown to
72
- * admins and account members). Defaults to false. Legacy: prefer
73
- * `audience`; when both are set, Settings shows if either allows it.
74
- */
75
- showSettings?: boolean;
76
63
  }
77
64
 
78
65
  export function baseStyles(): string {
@@ -251,18 +238,14 @@ export function renderShipwrightToolbar(
251
238
  const isQueueActivity = activePath.includes("/queue-activity");
252
239
 
253
240
  const audience = opts.audience;
254
- const visible = (id: ToolbarNavItemId): boolean => {
255
- if (id === "settings" && opts.showSettings) return true; // legacy flag
256
- const item = TOOLBAR_NAV_ITEMS.find((i) => i.id === id);
257
- // No audience: legacy rendering (everything except Settings, which is flag-gated).
258
- if (!audience) return id !== "settings" && id !== "public-tasks";
259
- return item?.audiences.includes(audience) ?? false;
260
- };
241
+ const visible = (id: ToolbarNavItemId): boolean =>
242
+ TOOLBAR_NAV_ITEMS.find((i) => i.id === id)?.audiences.includes(audience) ??
243
+ false;
261
244
 
262
245
  // Public proof surface: only the read-only Metrics + Tasks views are routed and
263
246
  // reachable, so omit every /admin/* link and the sign-out form (they 404 on the
264
247
  // public host). The wordmark points at the dashboard instead of /admin/agents.
265
- if (opts.readOnly || audience === "public") {
248
+ if (audience === "public") {
266
249
  const tasksUrl = opts.tasksUrl ?? "/public/tasks";
267
250
  return `<input type="checkbox" id="vos-nav-toggle" class="vos-nav-toggle" aria-hidden="true">
268
251
  <nav class="vos-toolbar" aria-label="Site navigation">
@@ -10,11 +10,12 @@ import { describe, expect, test } from "bun:test";
10
10
  import { renderShipwrightToolbar, TOOLBAR_NAV_ITEMS } from "./toolbar.ts";
11
11
 
12
12
  describe("renderShipwrightToolbar", () => {
13
- describe("authenticated mode (readOnly=false)", () => {
13
+ describe("authenticated mode (member)", () => {
14
14
  const html = renderShipwrightToolbar({
15
15
  userName: "Alice",
16
16
  activePath: "/admin/agents",
17
17
  logoutAction: "/auth/logout",
18
+ audience: "member",
18
19
  });
19
20
 
20
21
  test("contains hamburger button with class vos-hamburger", () => {
@@ -99,6 +100,7 @@ describe("renderShipwrightToolbar", () => {
99
100
  const html = renderShipwrightToolbar({
100
101
  userName: "Alice",
101
102
  activePath: "/admin/agents",
103
+ audience: "member",
102
104
  logoutAction: "/auth/logout",
103
105
  });
104
106
  expect(activeHref(html)).toBe("/admin/agents");
@@ -111,6 +113,7 @@ describe("renderShipwrightToolbar", () => {
111
113
  const html = renderShipwrightToolbar({
112
114
  userName: "Alice",
113
115
  activePath: "/admin/agents/agent-123",
116
+ audience: "member",
114
117
  logoutAction: "/auth/logout",
115
118
  });
116
119
  expect(activeHref(html)).toBe("/admin/agents");
@@ -123,6 +126,7 @@ describe("renderShipwrightToolbar", () => {
123
126
  const html = renderShipwrightToolbar({
124
127
  userName: "Alice",
125
128
  activePath: "/admin/agents/agent-123/queue-activity",
129
+ audience: "member",
126
130
  logoutAction: "/auth/logout",
127
131
  });
128
132
  expect(activeHref(html)).toBe("/admin/queue-activity");
@@ -142,6 +146,7 @@ describe("renderShipwrightToolbar", () => {
142
146
  const html = renderShipwrightToolbar({
143
147
  userName: "Alice",
144
148
  activePath: "/admin/sessions",
149
+ audience: "member",
145
150
  logoutAction: "/auth/logout",
146
151
  });
147
152
  expect(activeHref(html)).toBe("/admin/sessions");
@@ -151,18 +156,19 @@ describe("renderShipwrightToolbar", () => {
151
156
  const html = renderShipwrightToolbar({
152
157
  userName: "Alice",
153
158
  activePath: "/admin/sessions/some-slug",
159
+ audience: "member",
154
160
  logoutAction: "/auth/logout",
155
161
  });
156
162
  expect(activeHref(html)).toBe("/admin/sessions");
157
163
  });
158
164
  });
159
165
 
160
- describe("read-only mode (readOnly=true)", () => {
166
+ describe("read-only mode (public)", () => {
161
167
  const html = renderShipwrightToolbar({
162
168
  userName: "",
163
169
  activePath: "/dashboard",
164
170
  logoutAction: "",
165
- readOnly: true,
171
+ audience: "public",
166
172
  });
167
173
 
168
174
  test("contains hamburger button with class vos-hamburger", () => {
@@ -213,45 +219,12 @@ describe("renderShipwrightToolbar Account entry (SGL-2.3)", () => {
213
219
  userName: "Alice",
214
220
  activePath: "/admin/agents",
215
221
  logoutAction: "/auth/logout",
216
- showSettings: true,
222
+ audience: "admin",
217
223
  });
218
224
  expect(html).not.toContain('href="/admin/account"');
219
225
  });
220
226
  });
221
227
 
222
- describe("renderShipwrightToolbar Settings entry (GHE-1.4)", () => {
223
- const base = {
224
- userName: "a@x.com",
225
- activePath: "/admin/settings/github-enterprise",
226
- logoutAction: "/admin/logout",
227
- };
228
- test("omitted by default", () => {
229
- expect(renderShipwrightToolbar(base)).not.toContain("/admin/settings");
230
- });
231
- test("rendered and active when showSettings is true", () => {
232
- const html = renderShipwrightToolbar({ ...base, showSettings: true });
233
- expect(html).toContain(
234
- 'href="/admin/settings" class="vos-nav-link active">Settings</a>',
235
- );
236
- });
237
- test("active on any /admin/settings/* sub-page and links to /admin/settings", () => {
238
- const html = renderShipwrightToolbar({
239
- ...base,
240
- activePath: "/admin/settings/templates",
241
- showSettings: true,
242
- });
243
- expect(html).toContain(
244
- 'href="/admin/settings" class="vos-nav-link active"',
245
- );
246
- expect(html).not.toContain('href="/admin/settings/github-enterprise"');
247
- });
248
- test("readOnly never renders it", () => {
249
- expect(
250
- renderShipwrightToolbar({ ...base, readOnly: true, showSettings: true }),
251
- ).not.toContain("/admin/settings");
252
- });
253
- });
254
-
255
228
  describe("renderShipwrightToolbar audience (MNAV-2.1)", () => {
256
229
  const base = {
257
230
  userName: "a@x.com",
@@ -277,26 +250,6 @@ describe("renderShipwrightToolbar audience (MNAV-2.1)", () => {
277
250
  expect(html).not.toContain("Sign out");
278
251
  expect(html).toContain("/public/tasks");
279
252
  });
280
- test("audience admin output equals legacy showSettings output", () => {
281
- expect(renderShipwrightToolbar({ ...base, audience: "admin" })).toBe(
282
- renderShipwrightToolbar({ ...base, showSettings: true }),
283
- );
284
- });
285
- test("audience member output equals legacy default output", () => {
286
- expect(renderShipwrightToolbar({ ...base, audience: "member" })).toBe(
287
- renderShipwrightToolbar(base),
288
- );
289
- });
290
- test("legacy readOnly still works", () => {
291
- expect(renderShipwrightToolbar({ ...base, readOnly: true })).toBe(
292
- renderShipwrightToolbar({ ...base, audience: "public" }),
293
- );
294
- });
295
- test("legacy showSettings still adds Settings for a member", () => {
296
- expect(
297
- renderShipwrightToolbar({ ...base, audience: "member", showSettings: true }),
298
- ).toContain(settings);
299
- });
300
253
  });
301
254
 
302
255
  describe("TOOLBAR_NAV_ITEMS manifest", () => {