@sleep2agi/agent-network-dashboard 0.6.3-preview.44 → 0.6.3-preview.45

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.
Files changed (185) hide show
  1. package/.next/BUILD_COMMIT +1 -1
  2. package/.next/BUILD_ID +1 -1
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/diagnostics/route-bundle-stats.json +52 -52
  5. package/.next/fallback-build-manifest.json +3 -3
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +2 -2
  15. package/.next/server/app/_not-found.rsc +12 -12
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +12 -12
  17. package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  18. package/.next/server/app/_not-found.segments/_index.segment.rsc +7 -7
  19. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  21. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  22. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/admin.html +2 -2
  24. package/.next/server/app/admin.rsc +14 -14
  25. package/.next/server/app/admin.segments/_full.segment.rsc +14 -14
  26. package/.next/server/app/admin.segments/_head.segment.rsc +4 -4
  27. package/.next/server/app/admin.segments/_index.segment.rsc +7 -7
  28. package/.next/server/app/admin.segments/_tree.segment.rsc +1 -1
  29. package/.next/server/app/admin.segments/admin/__PAGE__.segment.rsc +4 -4
  30. package/.next/server/app/admin.segments/admin.segment.rsc +3 -3
  31. package/.next/server/app/index.html +2 -2
  32. package/.next/server/app/index.rsc +14 -14
  33. package/.next/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  34. package/.next/server/app/index.segments/_full.segment.rsc +14 -14
  35. package/.next/server/app/index.segments/_head.segment.rsc +4 -4
  36. package/.next/server/app/index.segments/_index.segment.rsc +7 -7
  37. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  38. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  39. package/.next/server/app/login.html +2 -2
  40. package/.next/server/app/login.rsc +14 -14
  41. package/.next/server/app/login.segments/_full.segment.rsc +14 -14
  42. package/.next/server/app/login.segments/_head.segment.rsc +4 -4
  43. package/.next/server/app/login.segments/_index.segment.rsc +7 -7
  44. package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  45. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  46. package/.next/server/app/login.segments/login.segment.rsc +3 -3
  47. package/.next/server/app/logs/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/logs.html +2 -2
  49. package/.next/server/app/logs.rsc +14 -14
  50. package/.next/server/app/logs.segments/_full.segment.rsc +14 -14
  51. package/.next/server/app/logs.segments/_head.segment.rsc +4 -4
  52. package/.next/server/app/logs.segments/_index.segment.rsc +7 -7
  53. package/.next/server/app/logs.segments/_tree.segment.rsc +1 -1
  54. package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +4 -4
  55. package/.next/server/app/logs.segments/logs.segment.rsc +3 -3
  56. package/.next/server/app/messages/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/messages.html +2 -2
  58. package/.next/server/app/messages.rsc +14 -14
  59. package/.next/server/app/messages.segments/_full.segment.rsc +14 -14
  60. package/.next/server/app/messages.segments/_head.segment.rsc +4 -4
  61. package/.next/server/app/messages.segments/_index.segment.rsc +7 -7
  62. package/.next/server/app/messages.segments/_tree.segment.rsc +1 -1
  63. package/.next/server/app/messages.segments/messages/__PAGE__.segment.rsc +4 -4
  64. package/.next/server/app/messages.segments/messages.segment.rsc +3 -3
  65. package/.next/server/app/node/page_client-reference-manifest.js +1 -1
  66. package/.next/server/app/node.html +2 -2
  67. package/.next/server/app/node.rsc +14 -14
  68. package/.next/server/app/node.segments/_full.segment.rsc +14 -14
  69. package/.next/server/app/node.segments/_head.segment.rsc +4 -4
  70. package/.next/server/app/node.segments/_index.segment.rsc +7 -7
  71. package/.next/server/app/node.segments/_tree.segment.rsc +1 -1
  72. package/.next/server/app/node.segments/node/__PAGE__.segment.rsc +4 -4
  73. package/.next/server/app/node.segments/node.segment.rsc +3 -3
  74. package/.next/server/app/nodes/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/nodes.html +2 -2
  76. package/.next/server/app/nodes.rsc +14 -14
  77. package/.next/server/app/nodes.segments/_full.segment.rsc +14 -14
  78. package/.next/server/app/nodes.segments/_head.segment.rsc +4 -4
  79. package/.next/server/app/nodes.segments/_index.segment.rsc +7 -7
  80. package/.next/server/app/nodes.segments/_tree.segment.rsc +1 -1
  81. package/.next/server/app/nodes.segments/nodes/__PAGE__.segment.rsc +4 -4
  82. package/.next/server/app/nodes.segments/nodes.segment.rsc +3 -3
  83. package/.next/server/app/page_client-reference-manifest.js +1 -1
  84. package/.next/server/app/providers/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app/providers.html +2 -2
  86. package/.next/server/app/providers.rsc +14 -14
  87. package/.next/server/app/providers.segments/_full.segment.rsc +14 -14
  88. package/.next/server/app/providers.segments/_head.segment.rsc +4 -4
  89. package/.next/server/app/providers.segments/_index.segment.rsc +7 -7
  90. package/.next/server/app/providers.segments/_tree.segment.rsc +1 -1
  91. package/.next/server/app/providers.segments/providers/__PAGE__.segment.rsc +4 -4
  92. package/.next/server/app/providers.segments/providers.segment.rsc +3 -3
  93. package/.next/server/app/server-logs/page_client-reference-manifest.js +1 -1
  94. package/.next/server/app/server-logs.html +2 -2
  95. package/.next/server/app/server-logs.rsc +14 -14
  96. package/.next/server/app/server-logs.segments/_full.segment.rsc +14 -14
  97. package/.next/server/app/server-logs.segments/_head.segment.rsc +4 -4
  98. package/.next/server/app/server-logs.segments/_index.segment.rsc +7 -7
  99. package/.next/server/app/server-logs.segments/_tree.segment.rsc +1 -1
  100. package/.next/server/app/server-logs.segments/server-logs/__PAGE__.segment.rsc +4 -4
  101. package/.next/server/app/server-logs.segments/server-logs.segment.rsc +3 -3
  102. package/.next/server/app/servers/page_client-reference-manifest.js +1 -1
  103. package/.next/server/app/servers.html +2 -2
  104. package/.next/server/app/servers.rsc +14 -14
  105. package/.next/server/app/servers.segments/_full.segment.rsc +14 -14
  106. package/.next/server/app/servers.segments/_head.segment.rsc +4 -4
  107. package/.next/server/app/servers.segments/_index.segment.rsc +7 -7
  108. package/.next/server/app/servers.segments/_tree.segment.rsc +1 -1
  109. package/.next/server/app/servers.segments/servers/__PAGE__.segment.rsc +4 -4
  110. package/.next/server/app/servers.segments/servers.segment.rsc +3 -3
  111. package/.next/server/app/settings/networks/page_client-reference-manifest.js +1 -1
  112. package/.next/server/app/settings/networks.html +2 -2
  113. package/.next/server/app/settings/networks.rsc +14 -14
  114. package/.next/server/app/settings/networks.segments/_full.segment.rsc +14 -14
  115. package/.next/server/app/settings/networks.segments/_head.segment.rsc +4 -4
  116. package/.next/server/app/settings/networks.segments/_index.segment.rsc +7 -7
  117. package/.next/server/app/settings/networks.segments/_tree.segment.rsc +1 -1
  118. package/.next/server/app/settings/networks.segments/settings/networks/__PAGE__.segment.rsc +4 -4
  119. package/.next/server/app/settings/networks.segments/settings/networks.segment.rsc +3 -3
  120. package/.next/server/app/settings/networks.segments/settings.segment.rsc +3 -3
  121. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  122. package/.next/server/app/settings/tokens/page_client-reference-manifest.js +1 -1
  123. package/.next/server/app/settings/tokens.html +2 -2
  124. package/.next/server/app/settings/tokens.rsc +14 -14
  125. package/.next/server/app/settings/tokens.segments/_full.segment.rsc +14 -14
  126. package/.next/server/app/settings/tokens.segments/_head.segment.rsc +4 -4
  127. package/.next/server/app/settings/tokens.segments/_index.segment.rsc +7 -7
  128. package/.next/server/app/settings/tokens.segments/_tree.segment.rsc +1 -1
  129. package/.next/server/app/settings/tokens.segments/settings/tokens/__PAGE__.segment.rsc +4 -4
  130. package/.next/server/app/settings/tokens.segments/settings/tokens.segment.rsc +3 -3
  131. package/.next/server/app/settings/tokens.segments/settings.segment.rsc +3 -3
  132. package/.next/server/app/settings.html +2 -2
  133. package/.next/server/app/settings.rsc +14 -14
  134. package/.next/server/app/settings.segments/_full.segment.rsc +14 -14
  135. package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
  136. package/.next/server/app/settings.segments/_index.segment.rsc +7 -7
  137. package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  138. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
  139. package/.next/server/app/settings.segments/settings.segment.rsc +3 -3
  140. package/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  141. package/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/tasks.html +2 -2
  143. package/.next/server/app/tasks.rsc +14 -14
  144. package/.next/server/app/tasks.segments/_full.segment.rsc +14 -14
  145. package/.next/server/app/tasks.segments/_head.segment.rsc +4 -4
  146. package/.next/server/app/tasks.segments/_index.segment.rsc +7 -7
  147. package/.next/server/app/tasks.segments/_tree.segment.rsc +1 -1
  148. package/.next/server/app/tasks.segments/tasks/__PAGE__.segment.rsc +4 -4
  149. package/.next/server/app/tasks.segments/tasks.segment.rsc +3 -3
  150. package/.next/server/chunks/ssr/[root-of-the-server]__0z0lvdf._.js +1 -1
  151. package/.next/server/chunks/ssr/[root-of-the-server]__0z0lvdf._.js.map +1 -1
  152. package/.next/server/chunks/ssr/[root-of-the-server]__13svd64._.js +1 -1
  153. package/.next/server/chunks/ssr/[root-of-the-server]__13svd64._.js.map +1 -1
  154. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_0f4savf._.js +2 -2
  155. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_0f4savf._.js.map +1 -1
  156. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_0fv9~x1._.js +1 -1
  157. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_0fv9~x1._.js.map +1 -1
  158. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_10nv4wt._.js +1 -1
  159. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_10nv4wt._.js.map +1 -1
  160. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_components_07gcm8v._.js +1 -1
  161. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_components_07gcm8v._.js.map +1 -1
  162. package/.next/server/middleware-build-manifest.js +3 -3
  163. package/.next/server/pages/404.html +2 -2
  164. package/.next/server/pages/500.html +1 -1
  165. package/.next/static/chunks/{0b3jrmai2phnc.js → 00.lep~gx75xc.js} +1 -1
  166. package/.next/static/chunks/{03kazq4f2o8kc.js → 0gv~xarphwy7~.js} +1 -1
  167. package/.next/static/chunks/{0mqxob_pphde0.js → 0k_3kdj.1c2m5.js} +1 -1
  168. package/.next/static/chunks/0~rml5aiu3yw7.js +7 -0
  169. package/.next/static/chunks/{17bch5v2vnph5.js → 0~v0m8f1.aob5.js} +2 -2
  170. package/.next/static/chunks/16kecv_vyjyyv.js +1 -0
  171. package/.next/trace +2 -2
  172. package/.next/trace-build +1 -1
  173. package/app/components/HealthBanner.tsx +21 -2
  174. package/app/components/Sidebar.tsx +8 -2
  175. package/app/components/StatsBar.tsx +32 -14
  176. package/app/lib/presence.ts +56 -1
  177. package/app/page.tsx +17 -4
  178. package/package.json +1 -1
  179. package/tests/e2e-53-blind-vs-empty.spec.ts +262 -0
  180. package/tests/e2e-53-presence-status.spec.ts +52 -0
  181. package/.next/static/chunks/0adq.v18n1i97.js +0 -7
  182. package/.next/static/chunks/0ws5f9sp.pgiv.js +0 -1
  183. /package/.next/static/{VeCvA8ZJHnHbQwP2X4xfs → EEoQxe-lggOsAx0h8hIFx}/_buildManifest.js +0 -0
  184. /package/.next/static/{VeCvA8ZJHnHbQwP2X4xfs → EEoQxe-lggOsAx0h8hIFx}/_clientMiddlewareManifest.js +0 -0
  185. /package/.next/static/{VeCvA8ZJHnHbQwP2X4xfs → EEoQxe-lggOsAx0h8hIFx}/_ssgManifest.js +0 -0
@@ -0,0 +1,262 @@
1
+ import { test, expect, Page } from '@playwright/test';
2
+
3
+ const BASE = process.env.TEST_URL || 'http://localhost:3100';
4
+
5
+ // #53 DOM behaviour — the "blind" vs "truly empty" fixtures MUST render
6
+ // distinct UIs. Same-render is exactly the regression #53 was opened
7
+ // for (unified predicate collapses "can't see" and "nothing there" into
8
+ // a confident, consistent, and wrong 0 online).
9
+ //
10
+ // Acceptance criterion from the issue:
11
+ // > 两个 fixture 必须都在,且断言互不相同 —— 否则又回到「两种情形一个画面」
12
+ //
13
+ // PR #54 review round-2 added a third fixture — BLIND (populated fleet)
14
+ // — because /api/hub/status and /health have INDEPENDENT auth gates, so
15
+ // "status returned sessions, health omitted sse_sessions" is a real
16
+ // reachable combination that only the populated-fleet fixture covers.
17
+ //
18
+ // Assertion matrix (each column must have at least one row unique to
19
+ // itself, and each row must be independently red-provable — a targeted
20
+ // mutation of the code that assertion protects should make ONLY that
21
+ // row's test go red, not just the earliest gate in that test):
22
+ //
23
+ // | BLIND(empty) BLIND(populated) EMPTY
24
+ // "? online" strip | ✓ — ✗ (not.toMatch)
25
+ // "0 online" strip | ✗ — ✓
26
+ // "presence unavail" | — ✓ ✗
27
+ // HealthBanner text | ✓ ✓ ✗
28
+ // agent-alpha visible | — ✓ — ← proves the
29
+ // | grid actually
30
+ // | mounted, so
31
+ // | "cell isn't a
32
+ // | number" can't
33
+ // | pass on an
34
+ // | unrendered grid
35
+ // Online cell === '?' | — ✓ —
36
+ // "Spin up..." pitch | ✗ ✗ — (may or may not)
37
+ //
38
+ // Witnessed-red evidence for each fixture:
39
+ // - BLIND(empty) ← mutate presenceStatus → always 'ready': banner
40
+ // gate at "Unable to read presence" fails.
41
+ // - EMPTY ← the "always 'ready'" mutation doesn't red this
42
+ // test because EMPTY *wants* 'ready'. The
43
+ // regression EMPTY protects is the OPPOSITE
44
+ // direction: "someone treats sse_sessions === {}
45
+ // as if the map were missing". Two targeted
46
+ // mutations of presence.ts, each catches EMPTY
47
+ // at a different assertion — the pair is what
48
+ // proves EMPTY isn't relying on one accidental
49
+ // assertion:
50
+ //
51
+ // (a) `if (sseSessions && Object.keys(sseSessions)
52
+ // .length > 0) return 'ready';` (requires
53
+ // non-empty map to be 'ready')
54
+ // → {} + conns=0 falls through to the conns
55
+ // check → returns 'loading' (NOT 'blind',
56
+ // because EMPTY fixture has conns=0).
57
+ // → page.tsx sets presenceUnknown=true.
58
+ // → StatsBar renders '? online' not '0 online'.
59
+ // → RED at L223: expect(bodyText).toMatch(
60
+ // /\b0\s+online\b/i) — Expected pattern
61
+ // /\b0\s+online\b/i, received "agent
62
+ // network..." (the '0 online' text is
63
+ // gone from the strip).
64
+ //
65
+ // (b) `if (sseSessions && Object.keys(sseSessions)
66
+ // .length > 0) return 'ready'; if (sseSessions
67
+ // !== undefined) return 'blind';` (forces
68
+ // empty-map to 'blind' directly)
69
+ // → {} → 'blind' regardless of conns.
70
+ // → HealthBanner fires the red presence-blind
71
+ // banner.
72
+ // → RED at L217: expect(bodyText.toLowerCase())
73
+ // .not.toContain('unable to read presence')
74
+ // — Expected NOT to contain, received
75
+ // "agent network... unable to read presence
76
+ // — hub reports 0 live SSE...".
77
+ //
78
+ // Both mutations are covered by real runs, not
79
+ // code inspection. Together they show EMPTY's
80
+ // assertion set is defended from multiple angles
81
+ // of the "collapse map={} with map=missing"
82
+ // failure mode — the exact regression #53 opened
83
+ // against.
84
+ // - BLIND(populated) ← 🔴 mutate ONLY StatsBar (make onlineDisplay
85
+ // ignore presenceUnknown and always render numeric
86
+ // `online`): L152 fails with
87
+ // `Expected: "?" Received: "0"`. This proves
88
+ // the '?' assertion targets StatsBar's presence-
89
+ // unknown branch specifically, not merely the
90
+ // earlier banner-visible gate.
91
+
92
+ const HUB_STATUS_ANONYMOUS = {
93
+ // Hub server, when called anonymously / with wrong-scope token,
94
+ // returns 0 sessions AND omits sse_sessions on /health.
95
+ sessions: [],
96
+ };
97
+
98
+ // PR #54 review — the two endpoints (/api/hub/status and /health) have
99
+ // independent auth gates, so "status returned sessions, but health's
100
+ // sse_sessions is missing" is a real reachable combination. This
101
+ // fixture exercises the StatCard populated path — a distinct render
102
+ // branch from the empty-fleet strip that the two anonymous fixtures
103
+ // above hit.
104
+ const HUB_STATUS_POPULATED = {
105
+ sessions: [
106
+ { alias: 'agent-alpha', status: 'working', network_id: 'net_x' },
107
+ { alias: 'agent-beta', status: 'idle', network_id: 'net_x' },
108
+ { alias: 'agent-gamma', status: 'idle', network_id: 'net_x' },
109
+ { alias: 'agent-delta', status: 'working', network_id: 'net_x' },
110
+ ],
111
+ };
112
+
113
+ // Health payload for the BLIND fixture — omits `sse_sessions` entirely
114
+ // but reports live connections. That contradiction is the signal.
115
+ const HUB_HEALTH_BLIND = {
116
+ ok: true,
117
+ version: '0.9.0-test',
118
+ sse_connections: 97,
119
+ // Note: sse_sessions deliberately NOT included. That's the whole
120
+ // point of the fixture — the map is missing while conns > 0.
121
+ };
122
+
123
+ // Health payload for the EMPTY fixture — map is present and empty,
124
+ // conns is 0. Truly no nodes connected.
125
+ const HUB_HEALTH_EMPTY = {
126
+ ok: true,
127
+ version: '0.9.0-test',
128
+ sse_connections: 0,
129
+ sse_sessions: {},
130
+ };
131
+
132
+ async function login(context: Page['context'] extends () => infer C ? C : never) {
133
+ const res = await context.request.post(`${BASE}/api/auth/login`, {
134
+ data: { password: process.env.ANET_DASHBOARD_PASSWORD || 'admin123' },
135
+ });
136
+ const setCookie = res.headers()['set-cookie'] || '';
137
+ const match = setCookie.match(/anet_dashboard_session=([^;]+)/);
138
+ if (match) {
139
+ const domain = new URL(BASE).hostname;
140
+ await context.addCookies([{
141
+ name: 'anet_dashboard_session',
142
+ value: decodeURIComponent(match[1]),
143
+ domain,
144
+ path: '/',
145
+ }]);
146
+ }
147
+ }
148
+
149
+ async function mockCommon(page: Page, statusBody: object, healthBody: object) {
150
+ await page.route('**/api/hub/status**', route =>
151
+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(statusBody) }));
152
+ await page.route('**/api/hub/health', route =>
153
+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(healthBody) }));
154
+ // Cheap stubs — HealthBanner also polls /api/hub/stats + /tasks, so
155
+ // return empty happy shapes to keep the amber "N failed" and green
156
+ // "all systems go" branches inert.
157
+ await page.route('**/api/hub/stats**', route =>
158
+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, tasks: { by_status: [] }, nodes: { total: 0 } }) }));
159
+ await page.route('**/api/hub/tasks**', route =>
160
+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ tasks: [], _hint: {} }) }));
161
+ await page.route('**/api/hub/nodes**', route =>
162
+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ nodes: [] }) }));
163
+ await page.route('**/api/hub/messages**', route =>
164
+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ messages: [] }) }));
165
+ }
166
+
167
+ test.describe('#53 blind vs empty — different UIs', () => {
168
+ test('BLIND: sse_sessions absent + conns > 0 → alert + "?" online + NO empty-state pitch', async ({ page, context }) => {
169
+ await login(context);
170
+ await mockCommon(page, HUB_STATUS_ANONYMOUS, HUB_HEALTH_BLIND);
171
+ await page.goto(`${BASE}/`);
172
+ // Wait for the HealthBanner blind message to appear.
173
+ await expect(page.locator('text=/Unable to read presence/i').first()).toBeVisible({ timeout: 15000 });
174
+
175
+ const bodyText = await page.locator('body').innerText();
176
+
177
+ // The "?" online — in the empty-fleet strip (StatsBar renders the
178
+ // strip when total===0). Under blind, the strip reads "? online"
179
+ // instead of "0 online". This is the DOM signal that must NOT
180
+ // match the truly-empty fixture below.
181
+ expect(bodyText).toMatch(/\?\s+online\b/);
182
+ expect(bodyText).not.toMatch(/\b0\s+online\b/);
183
+
184
+ // MUST NOT pitch "Spin up your first agent" in this state.
185
+ expect(bodyText).not.toContain('Spin up your first agent');
186
+
187
+ // Positive: HealthBanner alert copy is present.
188
+ expect(bodyText.toLowerCase()).toContain('unable to read presence');
189
+ // Positive: the alert names the "live SSE" side of the
190
+ // contradiction. Reviewer note: an earlier draft also accepted
191
+ // /97/, but that digit can incidentally match other numbers on
192
+ // the page (versions, other counters) — tightening to the phrase
193
+ // that only the banner uses.
194
+ expect(bodyText).toMatch(/live SSE/i);
195
+
196
+ await page.screenshot({ path: 'test-results/e2e-53-blind.png', fullPage: false });
197
+ });
198
+
199
+ test('BLIND (populated fleet): StatCard grid renders "?" for Online + "presence unavailable" subtitle', async ({ page, context }) => {
200
+ await login(context);
201
+ await mockCommon(page, HUB_STATUS_POPULATED, HUB_HEALTH_BLIND);
202
+ await page.goto(`${BASE}/`);
203
+ await expect(page.locator('text=/Unable to read presence/i').first()).toBeVisible({ timeout: 15000 });
204
+ await page.waitForTimeout(1500);
205
+
206
+ const bodyText = await page.locator('body').innerText();
207
+
208
+ // Positive proof the StatCard grid actually rendered — otherwise
209
+ // "Online cell isn't a number" would spuriously pass just because
210
+ // the whole grid failed to mount. Assert we see at least one of
211
+ // the fixture aliases, which appear in the AgentCard grid below
212
+ // the StatsBar.
213
+ expect(bodyText).toContain('agent-alpha');
214
+
215
+ // The StatCard "Online" cell — under populated + blind, the value
216
+ // is '?' and the subtitle drops to 'presence unavailable' (both
217
+ // set by StatsBar via the presenceUnknown prop). This is the
218
+ // primary reachable path in real traffic: hub returned sessions
219
+ // (status endpoint auth held), health omitted sse_sessions (its
220
+ // own auth gate tripped). Two independent auth gates, one
221
+ // rendering combination.
222
+ const onlineCardValue = await page.getByText('Online', { exact: true }).first()
223
+ .evaluate(el => el.previousElementSibling?.textContent ?? null);
224
+ expect(onlineCardValue?.trim()).toBe('?');
225
+
226
+ // Subtitle underneath the card.
227
+ expect(bodyText.toLowerCase()).toContain('presence unavailable');
228
+
229
+ // Empty-state pitch must NOT appear even though total > 0 (it's
230
+ // gated on sessions.length === 0), but assert it anyway — the
231
+ // gate condition on presenceState covers a different path and we
232
+ // want either coverage to catch a regression.
233
+ expect(bodyText).not.toContain('Spin up your first agent');
234
+
235
+ await page.screenshot({ path: 'test-results/e2e-53-populated-blind.png', fullPage: false });
236
+ });
237
+
238
+ test('EMPTY: sse_sessions = {} + conns = 0 → NO presence-blind alert + numeric 0 online', async ({ page, context }) => {
239
+ await login(context);
240
+ await mockCommon(page, HUB_STATUS_ANONYMOUS, HUB_HEALTH_EMPTY);
241
+ await page.goto(`${BASE}/`);
242
+ // Wait for the page to settle. Something needs to render — pick a
243
+ // stable, non-count anchor.
244
+ await expect(page.locator('h1', { hasText: 'Agent Network' }).first()).toBeVisible({ timeout: 15000 });
245
+ await page.waitForTimeout(1500);
246
+
247
+ const bodyText = await page.locator('body').innerText();
248
+
249
+ // The presence-blind alert MUST NOT fire when the map is truly
250
+ // present-and-empty — that would be a false alarm the other way.
251
+ expect(bodyText.toLowerCase()).not.toContain('unable to read presence');
252
+
253
+ // In truly-empty state, presenceStatus === 'ready', so the online
254
+ // cell is a real number (0). Confirm it's NOT "?".
255
+ // (Empty-fleet path uses a thin strip, not the StatCard grid, so
256
+ // we grep the strip text.)
257
+ expect(bodyText).toMatch(/\b0\s+online\b/i);
258
+ expect(bodyText).not.toContain('presence unavailable');
259
+
260
+ await page.screenshot({ path: 'test-results/e2e-53-empty.png', fullPage: false });
261
+ });
262
+ });
@@ -0,0 +1,52 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { presenceStatus } from '../app/lib/presence';
3
+
4
+ // #53 — three-state ambient presence. Companion to the
5
+ // e2e-53-blind-vs-empty DOM test: this one nails down the predicate
6
+ // contract every consumer inherits from presenceStatus().
7
+ //
8
+ // Two hand-computed fixtures cover the two states that must NEVER
9
+ // collapse to the same UI:
10
+ // - sseSessions === undefined & health.sse_connections > 0 → 'blind'
11
+ // (hub says there are live SSE, but the auth-gated map is missing
12
+ // from THIS response — anonymous / wrong scope; must NOT render 0)
13
+ // - sseSessions === {} & health.sse_connections = 0 → 'ready'
14
+ // (map is present and truly empty; safe to render 0 online)
15
+ //
16
+ // Also:
17
+ // - sseSessions undefined & no health → 'loading' (boot)
18
+ // - sseSessions undefined & health.sse_connections = 0 → 'loading'
19
+ // (conservative — both look identical to us and neither should
20
+ // inflate)
21
+
22
+ test.describe('#53 presenceStatus — undefined vs empty must NOT collapse', () => {
23
+ test('sseSessions absent + hub reports live connections → blind', () => {
24
+ expect(presenceStatus(undefined, { sse_connections: 97 })).toBe('blind');
25
+ expect(presenceStatus(undefined, { sse_connections: 1 })).toBe('blind');
26
+ });
27
+
28
+ test('sseSessions absent + hub reports 0 connections → loading (conservative)', () => {
29
+ // We can't tell "no map + 0 conns" from "hub-connection is stale on
30
+ // its own reporting" — treat as loading and don't render "0 online".
31
+ expect(presenceStatus(undefined, { sse_connections: 0 })).toBe('loading');
32
+ });
33
+
34
+ test('sseSessions absent + no health at all → loading (boot)', () => {
35
+ expect(presenceStatus(undefined, null)).toBe('loading');
36
+ expect(presenceStatus(undefined, undefined)).toBe('loading');
37
+ });
38
+
39
+ test('sseSessions present (even empty) → ready — trust the count', () => {
40
+ // The whole point of #53: "map is {} " means "the caller CAN see
41
+ // presence, and there's nothing to see". That is a DIFFERENT
42
+ // condition from "map is missing entirely" and must render
43
+ // differently.
44
+ expect(presenceStatus({}, { sse_connections: 0 })).toBe('ready');
45
+ expect(presenceStatus({ 'net_a:one': 1 }, { sse_connections: 1 })).toBe('ready');
46
+ // Even a self-contradictory response (map says 0 but conns > 0)
47
+ // is still 'ready' at the map level — the map is authoritative
48
+ // for who's online; the count-vs-map mismatch is a hub-side bug,
49
+ // not a presence-blindness signal.
50
+ expect(presenceStatus({}, { sse_connections: 5 })).toBe('ready');
51
+ });
52
+ });
@@ -1,7 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,16322,e=>{"use strict";var t=e.i(26387),a=e.i(18943),s=e.i(41065),n=e.i(10663),r=e.i(51071),o=e.i(97940),l=e.i(1065),i=e.i(54010),c=e.i(35361);let d=e=>fetch(e).then(e=>e.ok?e.json():{networks:[]}),h=[{href:"/",label:"Overview",icon:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"},{href:"/tasks",label:"Tasks",icon:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},{href:"/nodes",label:"Nodes",icon:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"},{href:"/servers",label:"Servers",icon:"M4 6.5A2.5 2.5 0 016.5 4h11A2.5 2.5 0 0120 6.5v1A2.5 2.5 0 0117.5 10h-11A2.5 2.5 0 014 7.5v-1zM4 16.5A2.5 2.5 0 016.5 14h11a2.5 2.5 0 012.5 2.5v1a2.5 2.5 0 01-2.5 2.5h-11A2.5 2.5 0 014 17.5v-1zM7 7h.01M7 17h.01"},{href:"/providers",label:"Providers",icon:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"},{href:"/admin",label:"Admin",icon:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"},{href:"/settings",label:"Settings",icon:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"}],p={owner:"⭐",admin:"🔧",member:"👤",viewer:"👁"};function m(){let e=(0,a.usePathname)(),[i,c]=(0,r.useState)(!1),m=["cyber","light","slack"],x={cyber:"深色",light:"浅色",slack:"Slack"},[f,v]=(0,r.useState)("cyber");(0,r.useEffect)(()=>{try{let e=localStorage.getItem("anet-theme");e&&x[e]&&v(e)}catch{}},[]);let[b,k]=(0,r.useState)(!1),{networkId:y,setNetworkId:w}=(0,l.useNetworkId)(),{data:j}=(0,o.default)("/api/hub/networks",d,{refreshInterval:15e3,dedupingInterval:1e4}),{data:N}=(0,o.default)("/api/hub/status",u,{refreshInterval:15e3,dedupingInterval:1e4}),M=j?.networks||[],C=(()=>{let e=new Map;for(let t of N?.sessions||[])t.network_id&&e.set(t.network_id,(e.get(t.network_id)||0)+1);let t=new Set(M.map(e=>e.network_id));return[...M,...[...e.keys()].filter(e=>!t.has(e)).map(e=>({network_id:e,network_name:e}))].map(t=>({...t,agentCount:e.get(t.network_id)||0}))})(),E=(0,t.jsx)("nav",{className:"flex flex-col gap-1 px-2 py-4",children:h.map(a=>{var n;return(0,t.jsxs)(s.default,{href:a.href,prefetch:!1,onClick:()=>k(!1),title:i?a.label:void 0,className:`relative flex items-center gap-3 px-3 py-3 rounded-lg text-sm transition-colors active:bg-[#232327] ${("/"===(n=a.href)?"/"===e:"/settings"===n?"/settings"===e:e.startsWith(n))?"bg-cyan-500/10 text-cyan-300 border border-cyan-500/20 anet-nav-active":"text-gray-400 hover:text-gray-200 hover:bg-[#1c1c1f]"} ${i?"justify-center px-0":""}`,children:[(0,t.jsx)("svg",{className:"w-5 h-5 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:a.icon})}),!i&&(0,t.jsx)("span",{children:a.label})]},a.href)})});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:()=>k(!b),className:"fixed top-3 left-3 z-50 lg:hidden bg-[#161618] border border-[#26262b] rounded-lg p-3 min-h-[44px] min-w-[44px] inline-flex items-center justify-center text-gray-400 hover:text-white active:bg-[#232327]","aria-label":"Toggle menu",children:(0,t.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:b?(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"}):(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),b&&(0,t.jsx)("div",{className:"fixed inset-0 bg-black/50 z-30 lg:hidden anet-fade-in",onClick:()=>k(!1)}),(0,t.jsxs)("aside",{"data-anet-sidebar":"true",className:`
2
- fixed top-0 left-0 h-full z-40 bg-[#111113] border-r border-[#26262b]
3
- transition-transform duration-200 ease-out
4
- ${i?"w-16":"w-52"}
5
- ${b?"translate-x-0 shadow-2xl shadow-black/40 lg:shadow-none":"-translate-x-full"}
6
- lg:translate-x-0 lg:static lg:shrink-0 lg:shadow-none
7
- `,children:[(0,t.jsx)(g,{collapsed:i}),(0,t.jsx)("div",{className:"border-b border-[#26262b]"}),!i&&C.length>0&&(0,t.jsxs)("div",{className:"px-2 py-3 border-b border-[#26262b]",children:[(0,t.jsx)("div",{className:"px-3 text-[10px] text-gray-600 uppercase mb-2",children:"Networks"}),(0,t.jsx)("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:C.map(e=>(0,t.jsxs)("button",{onClick:()=>{w(e.network_id),k(!1)},title:e.network_id,className:`w-full flex items-center gap-2 px-3 py-2.5 lg:py-1.5 rounded-md text-xs transition-colors text-left ${y===e.network_id?"bg-cyan-500/10 text-cyan-300":"text-gray-500 hover:text-gray-300 hover:bg-[#1c1c1f]"}`,children:[(0,t.jsx)("span",{children:p[e.role||"member"]||"👤"}),(0,t.jsx)("span",{className:"truncate flex-1",children:e.network_name}),e.agentCount?(0,t.jsx)("span",{className:"shrink-0 tabular-nums text-[10px] text-gray-600",children:e.agentCount}):null]},e.network_id))})]}),(0,t.jsx)("div",{className:"pb-28",children:E}),(0,t.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 border-t border-[#26262b] bg-[#111113]",children:[(0,t.jsxs)("button",{onClick:()=>{let e=m[(m.indexOf(f)+1)%m.length];(0,n.applyTheme)(e);try{localStorage.setItem("anet-theme",e)}catch{}v(e)},title:i?`主题:${x[f]}(点击切换)`:void 0,className:`w-full flex items-center text-[11px] text-gray-600 hover:text-gray-400 hover:bg-[#1c1c1f] transition-colors ${i?"justify-center px-0 py-2.5":"justify-between gap-2 px-5 py-3 lg:py-2"}`,"aria-label":`切换主题(当前:${x[f]})`,children:[(0,t.jsxs)("span",{className:`flex items-center ${i?"":"gap-2"}`,children:[(0,t.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.098 19.902a3.75 3.75 0 005.304 0l6.401-6.402M6.75 21A3.75 3.75 0 013 17.25V4.125C3 3.504 3.504 3 4.125 3h5.25c.621 0 1.125.504 1.125 1.125v4.072M6.75 21a3.75 3.75 0 003.75-3.75V8.197M6.75 21h13.125c.621 0 1.125-.504 1.125-1.125v-5.25c0-.621-.504-1.125-1.125-1.125h-4.072M10.5 8.197l2.88-2.88c.438-.439 1.15-.439 1.59 0l3.712 3.713c.44.44.44 1.152 0 1.59l-2.879 2.88"})}),!i&&"主题"]}),!i&&(0,t.jsx)("span",{className:"text-[10px] border border-current rounded px-1.5 py-0.5 opacity-70",children:x[f]})]}),(0,t.jsxs)("button",{onClick:()=>{window.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,ctrlKey:!0}))},title:i?"Quick search (⌘K)":void 0,className:`w-full flex items-center text-[11px] text-gray-600 hover:text-gray-400 hover:bg-[#1c1c1f] transition-colors ${i?"justify-center px-0 py-2.5":"justify-between gap-2 px-5 py-3 lg:py-2"}`,"aria-label":"Open command palette",children:[(0,t.jsxs)("span",{className:`flex items-center ${i?"":"gap-2"}`,children:[(0,t.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),!i&&"Quick search"]}),!i&&(0,t.jsx)("kbd",{className:"text-[10px] border border-current rounded px-1 py-0.5 opacity-60 font-mono",children:"⌘K"})]}),(0,t.jsxs)("button",{onClick:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),sessionStorage.removeItem("anet_v3_auth"),window.location.assign("/login")},title:i?"Sign out":void 0,className:`w-full flex items-center text-xs text-gray-500 hover:text-red-400 hover:bg-red-500/5 transition-colors ${i?"justify-center px-0 py-2.5":"gap-3 px-5 py-3"}`,children:[(0,t.jsx)("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9"})}),!i&&"Sign out"]}),(0,t.jsx)("div",{className:`flex items-center ${i?"flex-col px-0 py-2":"px-3 py-2 justify-end"}`,children:(0,t.jsx)("button",{onClick:()=>c(!i),title:i?"Expand sidebar":"Collapse sidebar",className:"hidden lg:flex p-1.5 rounded text-gray-600 hover:text-gray-400 transition-colors","aria-label":i?"Expand sidebar":"Collapse sidebar",children:(0,t.jsx)("svg",{className:`w-4 h-4 transition-transform ${i?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})})})]})]})]})}let u=e=>fetch(e).then(e=>e.ok?e.json():{sessions:[]});function g({collapsed:e}){let{data:a}=(0,o.default)("/api/hub/status",u,{refreshInterval:1e4,dedupingInterval:4e3}),{health:n}=(0,c.useHealth)(),r=a?.sessions||[],l=n?.sse_sessions,d=r.filter(e=>!!e.alias&&(0,i.isOnline)({alias:e.alias,network_id:e.network_id},l)).length,h=r.length;return e?(0,t.jsx)(s.default,{href:"/",className:"block px-3 py-4 flex justify-center hover:opacity-80 transition-opacity","aria-label":"Agent Network — home",children:(0,t.jsx)(x,{size:32})}):(0,t.jsxs)(s.default,{href:"/",className:"block px-4 py-4 flex items-center gap-3 hover:bg-[#161618]/40 transition-colors rounded-r-xl","aria-label":"Agent Network — home",children:[(0,t.jsx)(x,{size:32}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-white text-[13px] font-semibold leading-tight",children:"Agent Network"}),(0,t.jsxs)("div",{className:"text-[10px] text-gray-500 flex items-center gap-1.5 mt-0.5",children:[(0,t.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${d>0?"bg-emerald-400 anet-brand-pulse":"bg-gray-600"}`,"aria-hidden":!0}),0===h?(0,t.jsx)("span",{children:"waiting for agents"}):(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"text-gray-300 font-medium tabular-nums",children:d}),(0,t.jsxs)("span",{className:"text-gray-600",children:["/",h]})," online"]})]})]})]})}function x({size:e}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32","aria-hidden":!0,className:"shrink-0",children:[(0,t.jsx)("circle",{cx:"16",cy:"16",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.2",className:"text-cyan-400"}),(0,t.jsx)("line",{x1:"16",y1:"10",x2:"10",y2:"20",stroke:"currentColor",strokeWidth:"1",opacity:"0.45",className:"text-cyan-400"}),(0,t.jsx)("line",{x1:"16",y1:"10",x2:"22",y2:"20",stroke:"currentColor",strokeWidth:"1",opacity:"0.45",className:"text-cyan-400"}),(0,t.jsx)("line",{x1:"10",y1:"20",x2:"22",y2:"20",stroke:"currentColor",strokeWidth:"1",opacity:"0.45",className:"text-cyan-400"}),(0,t.jsx)("circle",{cx:"16",cy:"10",r:"2.5",fill:"currentColor",className:"text-cyan-400"}),(0,t.jsx)("circle",{cx:"10",cy:"20",r:"2.5",fill:"currentColor",className:"text-green-400"}),(0,t.jsx)("circle",{cx:"22",cy:"20",r:"2.5",fill:"currentColor",className:"text-violet-400"})]})}var f=e.i(77535);let v=async e=>{let t=await fetch(e);if(!t.ok)throw Error(String(t.status));return t.json()};function b(){let e,a,{data:n,error:l}=(0,o.default)("/api/hub/stats",v,{refreshInterval:15e3,dedupingInterval:5e3,shouldRetryOnError:!1}),{data:i,error:c}=(0,o.default)("/api/hub/health",v,{refreshInterval:15e3,dedupingInterval:5e3,shouldRetryOnError:!1}),d=n?.tasks?.by_status?.find(e=>"failed"===e.status)?.count||0,{data:h}=(0,o.default)(d>0?"/api/hub/tasks?status=failed&limit=100":null,v,{refreshInterval:6e4,dedupingInterval:3e4,shouldRetryOnError:!1}),[p,m]=(0,r.useState)(()=>"1"===sessionStorage.getItem("anet-hb-dismissed"));if(p)return null;let u=l&&c||i&&!1===i.ok,g=Date.now()-864e5,x=(h?.tasks||[]).filter(e=>{let t=(0,f.parseHubTime)(e.completed_at)??(0,f.parseHubTime)(e.created_at);return null!==t&&t>=g}).length,b=n?.nodes?.total===0,k=null;if(u?(e="red",a="CommHub unreachable — agents may be offline",k={label:"Open Settings",href:"/settings"}):x>0?(e="amber",a=`${x} task${x>1?"s":""} failed in the last 24h`,k={label:"Review failures",href:"/tasks?status=failed"}):(b?(e="green",a="Waiting for first agent"):(e="green",a="All systems go"),k=null),"green"===e&&!n)return null;let y={red:"bg-red-500/8 border-red-500/25 text-red-300",amber:"bg-amber-500/8 border-amber-500/25 text-amber-300",green:"bg-emerald-500/6 border-emerald-500/20 text-emerald-300"}[e],w={red:"bg-red-400",amber:"bg-amber-400 anet-brand-pulse",green:"bg-emerald-400"}[e];return(0,t.jsxs)("div",{role:"status",className:`anet-health-banner sticky top-0 z-30 border-b ${y} pl-14 pr-3 sm:px-6 py-1.5 text-[12px] flex items-center justify-between gap-3 backdrop-blur-sm`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${w}`,"aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:a})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[k&&(0,t.jsxs)(s.default,{href:k.href,className:"text-[11px] font-medium underline-offset-2 hover:underline opacity-90 hover:opacity-100 hidden sm:inline",children:[k.label," →"]}),k&&(0,t.jsx)(s.default,{href:k.href,"aria-label":k.label,className:"sm:hidden text-[13px] font-medium opacity-90 hover:opacity-100 relative leading-none px-1.5 before:absolute before:inset-y-[-10px] before:inset-x-[-8px] before:content-['']",children:"→"}),(0,t.jsx)("button",{onClick:()=>{m(!0);try{sessionStorage.setItem("anet-hb-dismissed","1")}catch{}},"aria-label":"Dismiss banner",className:"opacity-60 hover:opacity-100 leading-none px-1.5 text-base relative rounded-md hover:bg-white/5 before:absolute before:inset-y-[-10px] before:inset-x-[-8px] before:content-['']",children:"×"})]})]})}let k="anet-cmdk-recents";function y(){try{let e=sessionStorage.getItem(k);return e?JSON.parse(e):[]}catch{return[]}}function w(e){try{let t=y().filter(t=>t!==e);t.unshift(e),sessionStorage.setItem(k,JSON.stringify(t.slice(0,4)))}catch{}}function j(e,t){if(!t)return{score:0,indices:[]};let a=e.toLowerCase(),s=t.toLowerCase(),n=0,r=0,o=0,l=0,i=[];for(;n<a.length&&r<s.length;)a[n]===s[r]?(o+=2+l,l++,i.push(n),(0===n||/[\s·:_/-]/.test(a[n-1]))&&(o+=4),r++):l=0,n++;return r<s.length?{score:-1,indices:[]}:{score:o-.05*Math.max(0,a.length-s.length),indices:i}}function N({text:e,indices:a}){if(!a.length)return(0,t.jsx)(t.Fragment,{children:e});let s=new Set(a),n=Array.from(e);return(0,t.jsx)(t.Fragment,{children:n.map((e,a)=>s.has(a)?(0,t.jsx)("mark",{className:"anet-cmdk-mark",children:e},a):(0,t.jsx)("span",{children:e},a))})}function M({d:e}){return(0,t.jsx)("svg",{width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})})}let C=[{id:"go-overview",title:"Go to Overview",hint:"Fleet at a glance",group:"Navigate",icon:(0,t.jsx)(M,{d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3"}),perform:e=>e.push("/")},{id:"go-tasks",title:"Go to Tasks",hint:"All task statuses",group:"Navigate",icon:(0,t.jsx)(M,{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"}),perform:e=>e.push("/tasks")},{id:"go-tasks-failed",title:"Go to Failed tasks",hint:"Filter status=failed",group:"Navigate",icon:(0,t.jsx)(M,{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"}),perform:e=>e.push("/tasks?status=failed")},{id:"go-nodes",title:"Go to Nodes",hint:"Agent fleet",group:"Navigate",icon:(0,t.jsx)(M,{d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"}),perform:e=>e.push("/nodes")},{id:"go-messages",title:"Go to Messages",hint:"Inter-agent chat",group:"Navigate",icon:(0,t.jsx)(M,{d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"}),perform:e=>e.push("/messages")},{id:"go-networks",title:"Go to Networks",hint:"Manage networks",group:"Navigate",icon:(0,t.jsx)(M,{d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"}),perform:e=>e.push("/settings/networks")},{id:"go-logs",title:"Go to Audit Log",hint:"Register / login / actions",group:"Navigate",icon:(0,t.jsx)(M,{d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"}),perform:e=>e.push("/logs")},{id:"go-server-logs",title:"Go to Server Logs",hint:"CommHub stdout/stderr",group:"Navigate",icon:(0,t.jsx)(M,{d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"}),perform:e=>e.push("/server-logs")},{id:"go-admin",title:"Go to Admin",hint:"Server overview + broadcast",group:"Navigate",icon:(0,t.jsx)(M,{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"}),perform:e=>e.push("/admin")},{id:"go-settings",title:"Go to Settings",hint:"Connection / Account / Resources",group:"Navigate",icon:(0,t.jsx)(M,{d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),perform:e=>e.push("/settings")},{id:"act-toggle-theme",title:"Toggle theme",hint:"dark ↔ light",group:"Actions",icon:(0,t.jsx)(M,{d:"M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"}),perform:()=>{let e="cyber"===(document.documentElement.getAttribute("data-theme")||"cyber")?"light":"cyber";(0,n.applyTheme)(e);try{localStorage.setItem("anet-theme",e)}catch{}}},{id:"act-copy-url",title:"Copy current URL",hint:"page link to clipboard",group:"Actions",icon:(0,t.jsx)(M,{d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"}),perform:()=>{try{navigator.clipboard.writeText(window.location.href)}catch{}}},{id:"act-sign-out",title:"Sign out",hint:"clear session",group:"Actions",icon:(0,t.jsx)(M,{d:"M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9"}),perform:()=>{fetch("/api/auth/logout",{method:"POST"}).catch(()=>{});try{sessionStorage.removeItem("anet_v3_auth")}catch{}window.location.assign("/login")}},{id:"act-help",title:"Show keyboard shortcuts",hint:"press ? — works on mobile too",group:"Actions",icon:(0,t.jsx)(M,{d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),perform:()=>{window.dispatchEvent(new KeyboardEvent("keydown",{key:"?"}))}},{id:"act-pin-working",title:"Pin topology filter: working",hint:"highlight working nodes only",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 6h16M4 12h8m-8 6h16"}),perform:()=>{try{sessionStorage.setItem("anet-topo-pinned-status","working")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"status",value:"working"}}))}},{id:"act-pin-idle",title:"Pin topology filter: idle",hint:"highlight idle (online) nodes only",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 6h16M4 12h8m-8 6h16"}),perform:()=>{try{sessionStorage.setItem("anet-topo-pinned-status","idle")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"status",value:"idle"}}))}},{id:"act-pin-offline",title:"Pin topology filter: offline",hint:"highlight offline / no-SSE nodes",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 6h16M4 12h8m-8 6h16"}),perform:()=>{try{sessionStorage.setItem("anet-topo-pinned-status","offline")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"status",value:"offline"}}))}},{id:"act-pin-vendor-A",title:"Pin topology filter: Anthropic",hint:"highlight A vendor only",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 6h16M4 12h8m-8 6h16"}),perform:()=>{try{sessionStorage.setItem("anet-topo-pinned-vendor","A")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"vendor",value:"A"}}))}},{id:"act-pin-vendor-O",title:"Pin topology filter: OpenAI",hint:"highlight O vendor only",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 6h16M4 12h8m-8 6h16"}),perform:()=>{try{sessionStorage.setItem("anet-topo-pinned-vendor","O")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"vendor",value:"O"}}))}},{id:"act-pin-vendor-S",title:"Pin topology filter: 书生",hint:"highlight 书 vendor only",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 6h16M4 12h8m-8 6h16"}),perform:()=>{try{sessionStorage.setItem("anet-topo-pinned-vendor","书")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"vendor",value:"书"}}))}},{id:"act-clear-topo-pins",title:"Clear topology filters",hint:"release pinned status + group + vendor + edge",group:"Actions",icon:(0,t.jsx)(M,{d:"M6 18L18 6M6 6l12 12"}),perform:()=>{try{sessionStorage.removeItem("anet-topo-pinned-status"),sessionStorage.removeItem("anet-topo-pinned-group"),sessionStorage.removeItem("anet-topo-pinned-vendor")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"clear"}}))}},{id:"act-clear-topo-edge",title:"Clear topology edge pin",hint:"release pinned recent-signal row only",group:"Actions",icon:(0,t.jsx)(M,{d:"M6 18L18 6M6 6l12 12"}),perform:()=>{window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"clear-edge"}}))}},{id:"act-clear-topo-vendor",title:"Clear topology vendor filter",hint:"release pinned vendor only",group:"Actions",icon:(0,t.jsx)(M,{d:"M6 18L18 6M6 6l12 12"}),perform:()=>{try{sessionStorage.removeItem("anet-topo-pinned-vendor")}catch{}window.dispatchEvent(new CustomEvent("anet:topo-pin",{detail:{kind:"clear-vendor"}}))}},{id:"act-topo-toggle-layout",title:"Toggle topology layout",hint:"ring ↔ grid (or press `l`)",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 4h6v6H4V4zm10 0h6v6h-6V4zM4 14h6v6H4v-6zm10 0h6v6h-6v-6z"}),perform:()=>{window.dispatchEvent(new CustomEvent("anet:topo-layout",{detail:{kind:"toggle"}}))}},{id:"act-topo-fit",title:"Fit topology to canvas",hint:"auto-zoom to content (or press `f`)",group:"Actions",icon:(0,t.jsx)(M,{d:"M4 8V4h4M16 4h4v4M20 16v4h-4M8 20H4v-4"}),perform:()=>{window.dispatchEvent(new CustomEvent("anet:topo-view",{detail:{kind:"fit"}}))}}];function E(){let e=(0,a.useRouter)(),[s,n]=(0,r.useState)(!1),[o,l]=(0,r.useState)(""),[i,c]=(0,r.useState)(0),d=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()){e.preventDefault(),n(e=>!e);return}if("/"===e.key&&document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&!s){e.preventDefault(),n(!0);return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),(0,r.useEffect)(()=>{s&&(l(""),c(0),setTimeout(()=>d.current?.focus(),50))},[s]);let[h,p]=(0,r.useState)([]);(0,r.useEffect)(()=>{s&&p(y())},[s]);let[m,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!s)return;let e=!1;return(async()=>{try{let[a,s]=await Promise.all([fetch("/api/hub/status").then(e=>e.ok?e.json():{sessions:[]}),fetch("/api/hub/tasks?limit=20").then(e=>e.ok?e.json():{tasks:[]})]);if(e)return;let n=(a.sessions||[]).filter(e=>e.alias).slice(0,20).map(e=>({id:`agent-${e.alias}`,title:`Go to agent ${e.alias}`,hint:`${e.agent||"agent"} \xb7 ${e.status||"unknown"}`,group:"Agents",icon:(0,t.jsx)(M,{d:"M5.121 17.804A13.937 13.937 0 0112 16c2.5 0 4.847.655 6.879 1.804M15 10a3 3 0 11-6 0 3 3 0 016 0zm6 2a9 9 0 11-18 0 9 9 0 0118 0z"}),perform:t=>t.push(`/node?alias=${encodeURIComponent(e.alias)}`)})),r=(s.tasks||[]).filter(e=>e.task_id).slice(0,15).map(e=>({id:`task-${e.task_id}`,title:`Open task: ${(e.content||e.task_id||"").slice(0,50)}`,hint:`${e.from_name||"?"} → ${e.to_name||"?"} \xb7 ${e.status||""}`,group:"Tasks",icon:(0,t.jsx)(M,{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"}),perform:t=>t.push(`/tasks/${encodeURIComponent(e.task_id)}`)}));u([...n,...r])}catch{}})(),()=>{e=!0}},[s]);let g=(0,r.useMemo)(()=>{let e=[...C,...m];if(!o.trim()){let t=h.map(t=>e.find(e=>e.id===t)).filter(e=>!!e).map(e=>({...e,group:"Recents"})),a=new Set(h);return[...t,...C.filter(e=>!a.has(e.id))]}let t=e.map(e=>{let t=j(e.title,o),a=e.hint?j(e.hint,o):{score:-1,indices:[]},s=j(e.id,o);return{c:e,score:Math.max(t.score>=0?+t.score:-1/0,a.score>=0?.6*a.score:-1/0,s.score>=0?.3*s.score:-1/0),_titleHi:t.score>=0?t.indices:[],_hintHi:a.score>=0?a.indices:[]}}).filter(e=>e.score>-1/0);return t.sort((e,t)=>t.score-e.score),t.map(e=>({...e.c,_titleHi:e._titleHi,_hintHi:e._hintHi}))},[o,h,m]);if((0,r.useEffect)(()=>{i>=g.length&&c(0)},[g.length,i]),!s)return null;let x={};for(let e of g)(x[e.group]||=[]).push(e);let f=0;return(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Command palette",className:"anet-cmdk fixed inset-0 z-[100] flex items-start justify-center pt-[10vh] sm:pt-[15vh] px-4",onClick:()=>n(!1),onKeyDown:t=>{if("Escape"===t.key)return void n(!1);if("ArrowDown"===t.key){t.preventDefault(),c(e=>Math.min(e+1,g.length-1));return}if("ArrowUp"===t.key){t.preventDefault(),c(e=>Math.max(e-1,0));return}if("Enter"===t.key){t.preventDefault();let a=g[i];a&&(w(a.id),a.perform(e),n(!1))}},children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm","aria-hidden":!0}),(0,t.jsxs)("div",{className:"relative w-full max-w-xl rounded-xl border border-[#26262b] bg-[#111113] shadow-2xl shadow-black/40 overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b border-[#26262b] px-3 py-2.5",children:[(0,t.jsx)("svg",{width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",className:"text-gray-500 shrink-0",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,t.jsx)("input",{ref:d,value:o,onChange:e=>{l(e.target.value),c(0)},placeholder:"Type a command or search…",className:"flex-1 bg-transparent text-base sm:text-sm text-gray-200 placeholder-gray-600 focus:outline-none"}),(0,t.jsx)("kbd",{className:"text-[10px] text-gray-600 border border-[#26262b] rounded px-1.5 py-0.5 font-mono",children:"esc"})]}),(0,t.jsx)("div",{className:"max-h-[60vh] overflow-y-auto py-2",children:0===g.length?(0,t.jsxs)("div",{className:"px-4 py-8 text-center text-xs text-gray-600",children:['No commands match "',o,'"']}):Object.entries(x).map(([a,s])=>(0,t.jsxs)("div",{className:"mb-2 last:mb-0",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-[0.12em] text-gray-600 px-3 py-1",children:a}),s.map(a=>{let s=f++,r=s===i;return(0,t.jsxs)("button",{onMouseEnter:()=>c(s),onClick:()=>{w(a.id),a.perform(e),n(!1)},className:`anet-cmdk-row w-full flex items-center gap-3 px-3 py-2 text-left text-sm ${r?"bg-cyan-500/10 text-cyan-300":"text-gray-300 hover:bg-[#1c1c1f]/50"}`,children:[(0,t.jsx)("span",{className:r?"text-cyan-400":"text-gray-500",children:a.icon}),(0,t.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"block truncate",children:(0,t.jsx)(N,{text:a.title,indices:a._titleHi||[]})}),a.hint&&(0,t.jsx)("span",{className:"block text-[11px] text-gray-600 truncate",children:(0,t.jsx)(N,{text:a.hint,indices:a._hintHi||[]})})]}),r&&(0,t.jsx)("span",{className:"text-[10px] text-gray-500",children:"↵"})]},a.id)})]},a))}),(0,t.jsxs)("div",{className:"border-t border-[#26262b] px-3 py-1.5 flex items-center justify-between text-[10px] text-gray-600",children:[(0,t.jsxs)("span",{className:"flex items-center gap-3",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("kbd",{className:"font-mono",children:"↑↓"})," navigate"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("kbd",{className:"font-mono",children:"↵"})," select"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("kbd",{className:"font-mono",children:"esc"})," close"]})]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("kbd",{className:"font-mono",children:"⌘K"})," toggle"]})]})]})]})}let A=[{group:"Global",items:[{keys:["⌘","K"],label:"Open command palette (also Ctrl+K)"},{keys:["/"],label:"Open command palette"},{keys:["?"],label:"Toggle this help overlay"},{keys:["Esc"],label:"Close any open modal"}]},{group:"Navigate (vim-style)",items:[{keys:["g","o"],label:"Go to Overview"},{keys:["g","t"],label:"Go to Tasks"},{keys:["g","n"],label:"Go to Nodes"},{keys:["g","a"],label:"Go to Admin"},{keys:["g","s"],label:"Go to Settings"}]},{group:"Command palette",items:[{keys:["↑","↓"],label:"Move selection"},{keys:["↵"],label:"Activate selected command"},{keys:["type"],label:"Filter — searches commands, agents, tasks"}]},{group:"Topology canvas",items:[{keys:["+"],label:"Zoom in (also =)"},{keys:["−"],label:"Zoom out"},{keys:["0"],label:"Reset zoom + pan"},{keys:["f"],label:"Fit topology to canvas"},{keys:["l"],label:"Toggle layout (ring ↔ grid)"},{keys:["⌘","wheel"],label:"Zoom toward cursor (Ctrl on Windows/Linux)"},{keys:["drag"],label:"Pan the canvas (cursor → grabbing)"},{keys:["dbl-click"],label:"Reset zoom + pan (empty canvas only)"},{keys:["click"],label:"Open chat popover on a node (Esc to close)"},{keys:["click hub"],label:"Fit topology to canvas (R52)"},{keys:["hover legend"],label:"Highlight nodes of a status (R55)"},{keys:["hover signal"],label:"Highlight one flow edge (R56)"},{keys:["click chip"],label:"Pin a status filter (R60/R61)"},{keys:["Esc"],label:"Clear pinned filter (R62) — or close chat"},{keys:["click group"],label:"Pin a team focus (R63)"},{keys:["click ×"],label:"Clear one filter (R64) — Esc clears all"},{keys:["⌘","K"],label:'Pin / clear filters via palette → "Pin topology filter…" (R69)'},{keys:["⌘","K"],label:"Toggle layout / Fit canvas via palette (R74)"},{keys:["click pill"],label:"Clear filter — click anywhere on the pill body (R73)"},{keys:["hover chip"],label:'Brighten all active flows — hover "N active links" (R77)'},{keys:["hover N working"],label:"Highlight working nodes — chip-row sibling of legend (R79)"},{keys:["hover vendor"],label:"Highlight one vendor — hover A/O/书/? in the chip row (R80)"},{keys:["hover seg"],label:"Preview a status filter — hover a pressure-bar segment (R83)"},{keys:["hover group"],label:"Preview a team focus — hover a group label (R86)"},{keys:["click vendor"],label:"Pin a vendor filter — click A/O/书/? in the chip row (R88)"},{keys:["⌘","K"],label:'Clear vendor pin only via palette → "Clear topology vendor filter" (R90)'},{keys:["⌘","K"],label:'Pin vendor: Anthropic/OpenAI/书生 via palette → "Pin topology filter…" (R108)'},{keys:["click row"],label:"Pin a flow filter — click a recent-signal row to lock the edge (R116)"},{keys:["⌘","K"],label:'Clear edge pin only via palette → "Clear topology edge pin" (R117)'},{keys:["click badge"],label:"Pin a flow filter from the canvas — click an edge midpoint count badge (R121)"},{keys:["click footer"],label:'See all flows — click "+ N more flows" in the recent-signal panel (R133)'},{keys:["click chip"],label:'See all flows — click the "N active links" chip in the chip row (R136)'},{keys:["click chip"],label:'Pin "working" status — click "N working" in the chip row (R139)'},{keys:["click chip"],label:'Open the agent list — click "N online" in the chip row (R140)'},{keys:["Tab","Enter"],label:"Open chat on a focused node (also Space) — keyboard parallel of click-to-chat (R151)"}]}],S={o:"/",t:"/tasks",n:"/nodes",m:"/messages",w:"/settings/networks",a:"/admin",l:"/logs",s:"/settings"};function R(){let[e,s]=(0,r.useState)(!1),n=(0,a.useRouter)(),o=(0,r.useRef)(0);return((0,r.useEffect)(()=>{let t=t=>{let a=document.activeElement?.tagName,r="INPUT"===a||"TEXTAREA"===a||document.activeElement?.isContentEditable;if("?"===t.key&&!r){t.preventDefault(),s(e=>!e);return}if("Escape"===t.key&&e&&s(!1),!r&&!t.metaKey&&!t.ctrlKey&&!t.altKey){if("g"===t.key){o.current=Date.now();return}if(Date.now()-o.current<1500){let e=S[t.key.toLowerCase()];e&&(t.preventDefault(),o.current=0,n.push(e))}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,n]),e)?(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",className:"anet-help fixed inset-0 z-[101] flex items-center justify-center px-4",onClick:()=>s(!1),children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm","aria-hidden":!0}),(0,t.jsxs)("div",{className:"relative w-full max-w-md rounded-xl border border-[#26262b] bg-[#111113] shadow-2xl shadow-black/40 overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-[#26262b] px-4 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-200",children:[(0,t.jsx)("svg",{width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",className:"text-gray-500",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Keyboard shortcuts"]}),(0,t.jsx)("button",{onClick:()=>s(!1),"aria-label":"Close help",className:"text-gray-500 hover:text-gray-300 text-lg leading-none px-1",children:"×"})]}),(0,t.jsx)("div",{className:"px-4 py-3 max-h-[70vh] overflow-y-auto",children:A.map(e=>(0,t.jsxs)("div",{className:"mb-3 last:mb-0",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-[0.12em] text-gray-600 mb-1.5",children:e.group}),(0,t.jsx)("ul",{className:"space-y-1.5",children:e.items.map((e,a)=>(0,t.jsxs)("li",{className:"flex items-center gap-3 text-xs",children:[(0,t.jsx)("span",{className:"flex items-center gap-1",children:e.keys.map((e,a)=>(0,t.jsx)("kbd",{className:"text-[10px] font-mono border border-[#26262b] rounded px-1.5 py-0.5 text-gray-400 bg-[#1c1c1f]/40",children:e},a))}),(0,t.jsx)("span",{className:"text-gray-400 flex-1",children:e.label})]},a))})]},e.group))}),(0,t.jsxs)("div",{className:"border-t border-[#26262b] px-4 py-1.5 text-[10px] text-gray-600 flex items-center justify-between",children:[(0,t.jsxs)("span",{children:["Press ",(0,t.jsx)("kbd",{className:"font-mono",children:"?"})," to toggle"]}),(0,t.jsxs)("span",{children:["or ",(0,t.jsx)("kbd",{className:"font-mono",children:"esc"})," to close"]})]})]})]}):null}var L=e.i(66369),I=e.i(93950);let z=[{href:"/nodes",label:"Agents",icon:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"},{href:"/",label:"Overview",icon:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"},{href:"/tasks",label:"Tasks",icon:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},{href:"/settings",label:"Settings",icon:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"}];function _(){let e=(0,a.usePathname)(),{totalUnread:n,hasMutedUnread:o}=(0,I.useChatUnread)(),l=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let e=document.querySelector('link[rel="icon"]');if(e||((e=document.createElement("link")).rel="icon",document.head.appendChild(e),e.href="/favicon.svg"),null===l.current&&(l.current=e.href||"/favicon.svg"),n<=0){e.href!==l.current&&(e.href=l.current);return}let t=new Image;t.onload=()=>{let a=document.createElement("canvas");a.width=64,a.height=64;let s=a.getContext("2d");if(s){s.drawImage(t,0,0,64,64),s.beginPath(),s.arc(48,16,13,0,2*Math.PI),s.fillStyle="#ef4444",s.fill(),s.lineWidth=5,s.strokeStyle="#0b0b0d",s.stroke();try{e.href=a.toDataURL("image/png")}catch{}}},t.src=l.current},[n]),(0,r.useEffect)(()=>{let e=document.title.replace(/^\(\d+\+?\)\s/,"");document.title=n>0?`(${(0,I.badgeLabel)(n)}) ${e}`:e},[n]),(0,t.jsx)("nav",{className:"fixed inset-x-0 bottom-0 z-40 border-t border-[#26262b] bg-[#111113]/95 px-1 pb-[calc(env(safe-area-inset-bottom)+0.35rem)] pt-1.5 backdrop-blur lg:hidden",children:(0,t.jsx)("div",{className:"mx-auto grid max-w-md grid-cols-4 gap-1",children:z.map(a=>{var r;let l="/"===(r=a.href)?"/"===e:"/settings"===r?"/settings"===e:e.startsWith(r);return(0,t.jsxs)(s.default,{href:a.href,prefetch:!1,"aria-current":l?"page":void 0,className:`relative flex min-h-12 flex-col items-center justify-center gap-0.5 rounded-xl px-1 text-[10px] transition-colors ${l?"bg-cyan-500/12 text-cyan-300 before:absolute before:top-0 before:left-3 before:right-3 before:h-0.5 before:rounded-full before:bg-cyan-400":"text-gray-500 active:bg-[#232327] active:text-gray-200"}`,children:[(0,t.jsxs)("span",{className:"relative inline-flex",children:[(0,t.jsx)("svg",{className:"h-5 w-5 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:a.icon})}),"/nodes"===a.href&&0===n&&o&&(0,t.jsx)("span",{"aria-label":"有未读(已静音)",className:"absolute -top-0.5 right-1 h-2 w-2 rounded-full bg-red-500/80"}),"/nodes"===a.href&&n>0&&(0,t.jsx)("span",{className:"absolute -top-1 -right-2.5 min-w-[15px] h-[15px] px-1 rounded-full bg-red-500 text-white text-[9px] font-semibold leading-[15px] text-center",children:(0,I.badgeLabel)(n)})]}),(0,t.jsx)("span",{className:"max-w-full truncate",children:a.label})]},a.href)})})})}let P=["/login"];e.s(["AppShell",0,function({children:e}){let s=(0,a.usePathname)();return P.includes(s)?(0,t.jsx)(t.Fragment,{children:e}):(0,t.jsxs)("div",{className:"flex min-h-[100dvh] max-w-full overflow-x-hidden",children:[(0,t.jsx)(m,{}),(0,t.jsxs)("main",{className:"flex-1 min-w-0 max-w-full overflow-x-hidden flex flex-col pt-[env(safe-area-inset-top)]",children:[(0,t.jsx)(b,{}),(0,t.jsx)("div",{className:"flex-1 min-w-0 max-w-full overflow-x-hidden pb-[calc(5rem+env(safe-area-inset-bottom))] lg:pb-0",children:e})]}),(0,t.jsx)(_,{}),(0,t.jsx)(E,{}),(0,t.jsx)(R,{}),(0,t.jsx)(L.ServersDrawer,{})]})}],16322)},91112,e=>{"use strict";var t=e.i(51071);e.s(["PwaInstaller",0,function(){return(0,t.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{})},[]),null}])}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18943,(e,t,r)=>{t.exports=e.r(96868)},54010,14642,93950,e=>{"use strict";function t(e,t){if(!t)return;let r=(e.network_id?t[`${e.network_id}:${e.alias}`]:void 0)??t[e.alias];return"number"==typeof r?r:void 0}e.s(["isOnline",0,function(e,r){let n=t(e,r);return"number"==typeof n&&n>0},"sseCountFor",0,t],54010);var r=e.i(51071),n=e.i(97940),a=e.i(1065);let s="anet_chat_mute_v1",l="anet-chat-mute-updated";function o(){try{let e=JSON.parse(window.localStorage.getItem(s)||"[]");return new Set(Array.isArray(e)?e:[])}catch{return new Set}}function i(e){return!!e&&o().has(e)}let d=0;function c(e){let t=()=>{d++,e()};return window.addEventListener(l,t),window.addEventListener("storage",t),()=>{window.removeEventListener(l,t),window.removeEventListener("storage",t)}}function u(){return(0,r.useSyncExternalStore)(c,()=>d,()=>0)}e.s(["isMuted",0,i,"toggleMute",0,function(e){if(e)try{let t=o();t.has(e)?t.delete(e):t.add(e),window.localStorage.setItem(s,JSON.stringify([...t])),window.dispatchEvent(new Event(l))}catch{}},"useMuteVersion",0,u,"useMuted",0,function(e){return(0,r.useSyncExternalStore)(c,()=>!!e&&i(e),()=>!1)}],14642);let m="anet-chat-read-updated",x=new Set(["","dashboard","admin","api","hub"]),h=e=>x.has((e||"").trim().toLowerCase());function f(e){return`anet_chat_read_v1:${e||"global"}`}function g(e){if(!e)return 0;let t=e.includes("T")?e:e.replace(" ","T"),r=Date.parse(/Z$|[+-]\d{2}:\d{2}$/.test(t)?t:`${t}Z`);return Number.isFinite(r)?r:0}let p="__baseline";function v(e){try{let t=window.localStorage.getItem(f(e));!t&&(t=window.sessionStorage.getItem(f(e)))&&window.localStorage.setItem(f(e),t);let r=t?JSON.parse(t):{},n=r&&"object"==typeof r?r:{};return n[p]||(n[p]=new Date().toISOString(),window.localStorage.setItem(f(e),JSON.stringify(n))),n}catch{return{}}}let b=async e=>{let t=await fetch(e);if(401===t.status)throw window.location.assign("/login"),Error("unauthorized");return t.json()};function w(e,t){if(e){var r={...v(t),[e]:new Date().toISOString()};try{window.localStorage.setItem(f(t),JSON.stringify(r)),window.dispatchEvent(new CustomEvent(m,{detail:{networkId:t}}))}catch{}}}e.s(["badgeLabel",0,function(e){return e<=0?"":e>99?"99+":String(e)},"markChatRead",0,w,"useChatUnread",0,function(){let{networkId:e}=(0,a.useNetworkId)(),{data:t}=(0,n.default)(function(e,t){if(!t)return e;let r=e.includes("?")?"&":"?";return`${e}${r}network_id=${encodeURIComponent(t)}`}("/api/hub/messages?limit=200",e),b,{refreshInterval:5e3,dedupingInterval:3e3}),[s,l]=(0,r.useState)(0);(0,r.useEffect)(()=>{let t=t=>{t.key&&t.key!==f(e)||l(e=>"number"==typeof e?e+1:1)},r=t=>{let r=t.detail;(r?.networkId===void 0||r.networkId===e)&&l(e=>"number"==typeof e?e+1:1)};return window.addEventListener("storage",t),window.addEventListener(m,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(m,r)}},[e,l]);let o=(0,r.useMemo)(()=>v(e),[e,s]),d=(0,r.useMemo)(()=>{let e=new Map,r=new Map,n=new Set(Object.keys(o).filter(e=>e!==p)),a=g(o[p]),s=(t,s)=>{n.has(t)&&s>(r.get(t)||0)&&r.set(t,s),s>Math.max(g(o[t]),a)&&e.set(t,(e.get(t)||0)+1)};for(let e of t?.messages||[]){let t=e.from_alias?.trim();if(!t||h(t)||!h(e.to_alias))continue;let r=g(e.created_at);r&&s(t,r)}return{counts:e,lastActivity:r}},[t,o]),c=(0,r.useCallback)(e=>!!e&&(d.counts.get(e)||0)>0,[d]),x=(0,r.useCallback)(e=>e&&d.counts.get(e)||0,[d]),y=(0,r.useCallback)(e=>e&&d.lastActivity.get(e)||0,[d]),j=u(),{totalUnread:k,hasMutedUnread:_}=(0,r.useMemo)(()=>{let e=0,t=!1;for(let[r,n]of d.counts){if(i(r)){n>0&&(t=!0);continue}e+=n}return{totalUnread:e,hasMutedUnread:t}},[d,j]);return{unreadMap:d,hasUnread:c,unreadCount:x,lastActivityAt:y,totalUnread:k,hasMutedUnread:_,clearUnread:(0,r.useCallback)(t=>{w(t,e)},[e])}}],93950)},10663,e=>{"use strict";var t=e.i(26387),r=e.i(51071);let n=new Set(["cyber","light","slack"]);function a(e){if("u"<typeof document)return;let t=document.documentElement;"slack"===e?(t.setAttribute("data-theme","light"),t.setAttribute("data-skin","slack")):(t.setAttribute("data-theme",e),t.removeAttribute("data-skin"))}e.s(["THEMES",0,n,"ThemeProvider",0,function({children:e}){return(0,r.useEffect)(()=>{if("u"<typeof document)return;let e="cyber";try{let t=localStorage.getItem("anet-theme");t&&n.has(t)&&(e=t)}catch{}a(e)},[]),(0,t.jsx)(t.Fragment,{children:e})},"applyTheme",0,a])},66369,e=>{"use strict";var t=e.i(26387),r=e.i(51071),n=e.i(97940);let a=async e=>{let t=await fetch(e);if(401===t.status)throw window.location.assign("/login"),Error("unauthorized");if(!t.ok)throw Error(`hub ${t.status}`);return t.json()};function s(e){return e>=85?{fill:"#ef4444",track:"rgb(239 68 68 / 0.16)"}:e>=60?{fill:"#f59e0b",track:"rgb(245 158 11 / 0.16)"}:{fill:"#10b981",track:"rgb(16 185 129 / 0.16)"}}function l({pct:e,label:r}){let n=s(e),a=Math.max(0,Math.min(100,e));return(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsxs)("div",{className:"flex justify-between text-[10px] text-[var(--fg-muted)] font-mono",children:[(0,t.jsx)("span",{children:r}),(0,t.jsxs)("span",{className:"tabular-nums",children:[Math.round(a),"%"]})]}),(0,t.jsx)("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:n.track},children:(0,t.jsx)("div",{className:"h-full transition-[width] duration-300 ease-out",style:{width:`${a}%`,background:n.fill}})})]})}function o({values:e,tint:r,label:n}){if(!e||e.length<2)return null;let a=100/Math.max(1,e.length-1),s=e.map((e,t)=>{let r=18-Math.max(0,Math.min(100,e))/100*18;return`${(t*a).toFixed(1)},${r.toFixed(1)}`}),l=s.join(" "),i=`M0,18 L${s.join(" L")} L100,18 Z`;return(0,t.jsxs)("svg",{width:"100%",height:18,viewBox:"0 0 100 18",preserveAspectRatio:"none","aria-label":`${n} 5-min history`,"data-server-sparkline":n,children:[(0,t.jsx)("path",{d:i,fill:r,opacity:"0.18"}),(0,t.jsx)("polyline",{points:l,fill:"none",stroke:r,strokeWidth:"1.2"})]})}function i({cpu:e,mem:r,disk:n}){let a=[e,r,n].filter(e=>"number"==typeof e);if(0===a.length)return null;let l=Math.max(...a),o=s(l);return(0,t.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0",style:{background:o.fill,boxShadow:`0 0 0 2px ${o.track}`},"data-server-health-badge":l>=85?"red":l>=60?"amber":"green",title:`worst: ${Math.round(l)}%`})}function d({agents:e}){return e&&0!==e.length?(0,t.jsx)("ul",{className:"space-y-1","data-server-agent-list":!0,children:e.map(e=>{let r="working"===e.status?"#10b981":"idle"===e.status?"#06b6d4":"#6b7280";return(0,t.jsxs)("li",{className:"flex items-center gap-1.5 text-[10px] font-mono","data-server-agent":e.alias,children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:r}}),(0,t.jsx)("span",{className:"font-semibold truncate",style:{color:"var(--fg)"},children:e.alias}),e.runtime&&(0,t.jsxs)("span",{className:"text-[9px] text-[var(--fg-dim)] shrink-0",children:["· ",e.runtime]}),"number"==typeof e.progress&&e.progress>0&&(0,t.jsxs)("span",{className:"ml-auto text-[9px] tabular-nums text-[var(--fg-muted)]",children:[Math.round(100*e.progress),"%"]})]},e.alias)})}):(0,t.jsx)("div",{className:"text-[9px] text-[var(--fg-dim)] font-mono italic px-1 py-1","data-server-agents-missing":"true",children:"agent rollup not reported by hub"})}function c(e=!0){let{data:t,error:r}=(0,n.default)(e?"/api/hub/servers":null,a,{refreshInterval:5e3,dedupingInterval:3e3}),s=t?.servers??[],l=t?.unavailable===!0,o=s.filter(e=>"online"===e.status).length,i=e&&!t&&!r;return{data:t,error:r,servers:s,unavailable:l,onlineCount:o,loading:i}}function u({enabled:e=!0,className:n=""}){let[a,s]=(0,r.useState)(new Set);(0,r.useEffect)(()=>{try{let e=localStorage.getItem("anet-servers-drawer-expanded");e&&s(new Set(JSON.parse(e)))}catch{}},[]);let{data:m,error:x,servers:h,unavailable:f,loading:g}=c(e);return(0,t.jsxs)("div",{className:`min-h-0 overflow-y-auto px-2 py-2 space-y-2 ${n}`,"data-servers-body":!0,children:[g&&(0,t.jsx)("div",{className:"text-[10px] text-[var(--fg-muted)] font-mono text-center py-4",children:"loading servers…"}),x&&!m&&(0,t.jsx)("div",{className:"rounded-md border px-2.5 py-2 text-[10px] font-mono",style:{background:"rgb(239 68 68 / 0.06)",borderColor:"rgb(239 68 68 / 0.25)",color:"#ef4444"},children:"hub unreachable · retrying every 5s"}),f&&(0,t.jsxs)("div",{className:"text-[10px] text-[var(--fg-muted)] font-mono text-center py-3 leading-relaxed",children:["host telemetry not available",(0,t.jsx)("br",{}),(0,t.jsx)("span",{className:"text-[var(--fg-dim)]",children:"upgrade commhub-server ≥ 0.8.1-preview.2"})]}),!g&&!x&&!f&&0===h.length&&(0,t.jsx)("div",{className:"text-[10px] text-[var(--fg-muted)] font-mono text-center py-4",children:"no servers reporting yet"}),h.map(e=>{let r="offline"===e.status,n=null!=e.cpu_load_1min&&e.cpu_cores>0?e.cpu_load_1min/e.cpu_cores*100:null,c=null!=e.mem_used_gb&&null!=e.mem_total_gb&&e.mem_total_gb>0?e.mem_used_gb/e.mem_total_gb*100:null,u=null!=e.disk_used_gb&&null!=e.disk_total_gb&&e.disk_total_gb>0?e.disk_used_gb/e.disk_total_gb*100:null,m=a.has(e.hostname);return(0,t.jsxs)("div",{className:"rounded-lg border px-2.5 py-2 space-y-1.5",style:{background:"var(--bg)",borderColor:"var(--border)",opacity:r?.55:1},"data-server-card":e.hostname,"data-server-expanded":m?"true":"false",title:e.ip?`${e.hostname} \xb7 ${e.ip}`:e.hostname,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{let t;return t=e.hostname,s(e=>{let r=new Set(e);r.has(t)?r.delete(t):r.add(t);try{localStorage.setItem("anet-servers-drawer-expanded",JSON.stringify([...r]))}catch{}return r})},"aria-expanded":m,className:"w-full flex items-center justify-between gap-2 text-left","data-server-card-toggle":e.hostname,children:[(0,t.jsxs)("div",{className:"min-w-0 flex items-center gap-1.5",children:[!r&&(0,t.jsx)(i,{cpu:n,mem:c,disk:u}),(0,t.jsx)("span",{className:"font-mono text-[12px] font-semibold truncate",style:{color:"var(--fg)"},children:e.hostname}),e.note&&(0,t.jsxs)("span",{className:"text-[9px] text-[var(--fg-dim)]",children:["(",e.note,")"]})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsxs)("span",{className:"text-[10px] text-[var(--fg-muted)] font-mono tabular-nums",children:[e.agent_count," agent",1===e.agent_count?"":"s"]}),(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:m?"rotate(90deg)":"rotate(0deg)",transition:"transform 150ms ease-out"},"aria-hidden":!0,children:(0,t.jsx)("path",{d:"M3 1.5L7 5L3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]}),!r&&null!=n&&(0,t.jsx)(l,{pct:n,label:`CPU ${e.cpu_load_1min.toFixed(2)}/${e.cpu_cores}`}),!r&&null!=c&&(0,t.jsx)(l,{pct:c,label:`RAM ${e.mem_used_gb.toFixed(1)}/${e.mem_total_gb.toFixed(1)}G`}),r&&(0,t.jsx)("div",{className:"text-[10px] text-[var(--fg-dim)] font-mono italic",children:"CPU n/a · RAM n/a · offline"}),m&&!r&&(0,t.jsxs)("div",{className:"pt-1 mt-1 border-t space-y-1.5",style:{borderColor:"var(--border)"},children:[null!=u?(0,t.jsx)(l,{pct:u,label:`DISK ${e.disk_used_gb.toFixed(1)}/${e.disk_total_gb.toFixed(1)}G`}):(0,t.jsx)("div",{className:"text-[9px] text-[var(--fg-dim)] font-mono italic","data-server-disk-missing":"true",children:"disk metric not reported by hub"}),e.cpu_history&&e.cpu_history.length>=2&&(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("div",{className:"text-[9px] text-[var(--fg-muted)] font-mono",children:"CPU · 5-min"}),(0,t.jsx)(o,{values:e.cpu_history,tint:"#10b981",label:"CPU"})]}),e.mem_history&&e.mem_history.length>=2&&(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("div",{className:"text-[9px] text-[var(--fg-muted)] font-mono",children:"RAM · 5-min"}),(0,t.jsx)(o,{values:e.mem_history,tint:"#06b6d4",label:"MEM"})]}),e.disk_history&&e.disk_history.length>=2&&(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("div",{className:"text-[9px] text-[var(--fg-muted)] font-mono",children:"DISK · 5-min"}),(0,t.jsx)(o,{values:e.disk_history,tint:"#f59e0b",label:"DISK"})]}),(0,t.jsxs)("div",{className:"pt-1",children:[(0,t.jsx)("div",{className:"text-[9px] text-[var(--fg-muted)] font-mono mb-0.5",children:"agents"}),(0,t.jsx)(d,{agents:e.agents})]})]})]},e.hostname)}),h.length>0&&(0,t.jsx)("div",{className:"pt-1 text-[9px] text-[var(--fg-dim)] font-mono text-center",children:"live · refreshing every 5s"})]})}e.s(["ServersDrawer",0,function(){let[e,n]=(0,r.useState)(!1);(0,r.useEffect)(()=>{try{"1"===localStorage.getItem("anet-servers-drawer")&&n(!0)}catch{}},[]);let{servers:a,onlineCount:s}=c(e);return(0,t.jsxs)("aside",{className:"fixed right-0 top-20 z-40 hidden lg:flex flex-col rounded-l-xl border border-r-0 shadow-xl shadow-black/30 anet-fade-in",style:{background:"var(--bg-secondary)",borderColor:"var(--border)",width:e?296:40,maxHeight:"calc(100vh - 6rem)",transition:"width 200ms ease-out"},"aria-label":"Servers panel",children:[(0,t.jsxs)("button",{onClick:()=>n(e=>{let t=!e;try{localStorage.setItem("anet-servers-drawer",t?"1":"0")}catch{}return t}),"aria-expanded":e,"aria-label":e?"Collapse servers panel":"Expand servers panel",className:"flex items-center gap-2 px-2.5 py-2 border-b text-[11px] font-semibold tracking-wide select-none",style:{color:"var(--fg)",borderColor:"var(--border)"},children:[(0,t.jsxs)("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),(0,t.jsx)("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),(0,t.jsx)("circle",{cx:"7",cy:"7",r:"0.7",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"7",cy:"17",r:"0.7",fill:"currentColor"})]}),e&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex-1 text-left",children:"Servers"}),(0,t.jsxs)("span",{className:"text-[10px] text-[var(--fg-muted)] font-mono",children:[s,"/",a.length]})]})]}),e&&(0,t.jsx)(u,{enabled:e,className:"flex-1"})]})},"ServersPanel",0,u])}]);