super-dsh 0.1.6 → 0.1.10

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 (248) hide show
  1. package/README.md +25 -3
  2. package/agent-agy/cordis.patch.yml +7 -4
  3. package/agent-agy/dist/agent.d.ts +12 -11
  4. package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
  5. package/agent-agy/dist/agy-auth-gateway.js +233 -0
  6. package/agent-agy/dist/agy-auth.d.ts +153 -0
  7. package/agent-agy/dist/agy-auth.js +179 -0
  8. package/agent-agy/dist/agy-cli-client.d.ts +39 -9
  9. package/agent-agy/dist/agy-cli-client.js +82 -18
  10. package/agent-agy/dist/agy-store.d.ts +8 -0
  11. package/agent-agy/dist/index.d.ts +46 -16
  12. package/agent-agy/dist/index.js +82 -56
  13. package/agent-agy/dist/models.d.ts +70 -0
  14. package/agent-agy/dist/models.js +102 -3
  15. package/agent-agy/package.json +7 -5
  16. package/agent-agy-sdk/cordis.patch.yml +58 -0
  17. package/agent-agy-sdk/dist/adapter.d.ts +15 -0
  18. package/agent-agy-sdk/dist/adapter.js +42 -0
  19. package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
  20. package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
  21. package/agent-agy-sdk/dist/agent.d.ts +138 -0
  22. package/agent-agy-sdk/dist/agent.js +494 -0
  23. package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
  24. package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
  25. package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
  26. package/agent-agy-sdk/dist/agy-sessions.js +107 -0
  27. package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
  28. package/agent-agy-sdk/dist/agy-store.js +83 -0
  29. package/agent-agy-sdk/dist/inbox.d.ts +26 -0
  30. package/agent-agy-sdk/dist/inbox.js +53 -0
  31. package/agent-agy-sdk/dist/index.d.ts +93 -0
  32. package/agent-agy-sdk/dist/index.js +476 -0
  33. package/agent-agy-sdk/dist/models.d.ts +41 -0
  34. package/agent-agy-sdk/dist/models.js +74 -0
  35. package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
  36. package/agent-agy-sdk/dist/sdk-venv.js +173 -0
  37. package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
  38. package/agent-agy-sdk/dist/world-plugin.js +82 -0
  39. package/agent-agy-sdk/package.json +64 -0
  40. package/agent-codex/README.md +141 -36
  41. package/agent-codex/cordis.patch.yml +14 -10
  42. package/agent-codex/dist/adapter.js +64 -28
  43. package/agent-codex/dist/agent.js +255 -81
  44. package/agent-codex/dist/app-server-approvals.js +165 -0
  45. package/agent-codex/dist/app-server-client.js +723 -0
  46. package/agent-codex/dist/app-server-events.js +432 -0
  47. package/agent-codex/dist/app-server-protocol.js +95 -0
  48. package/agent-codex/dist/app-server-wire.js +299 -0
  49. package/agent-codex/dist/codex-launch.js +78 -0
  50. package/agent-codex/dist/codex-native-config.js +392 -0
  51. package/agent-codex/dist/codex-provider-gateway.js +402 -0
  52. package/agent-codex/dist/codex-providers.js +376 -0
  53. package/agent-codex/dist/codex-route.js +86 -0
  54. package/agent-codex/dist/index.js +256 -115
  55. package/agent-codex/dist/permission.js +75 -1
  56. package/agent-codex/package.json +1 -2
  57. package/agent-codex-sdk/README.md +79 -0
  58. package/agent-codex-sdk/cordis.patch.yml +81 -0
  59. package/agent-codex-sdk/dist/adapter.js +91 -0
  60. package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
  61. package/agent-codex-sdk/dist/agent.js +1085 -0
  62. package/agent-codex-sdk/dist/codex-native-config.js +392 -0
  63. package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
  64. package/agent-codex-sdk/dist/codex-providers.js +376 -0
  65. package/agent-codex-sdk/dist/codex-route.js +86 -0
  66. package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
  67. package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
  68. package/agent-codex-sdk/dist/codex-store.js +180 -0
  69. package/agent-codex-sdk/dist/inbox.js +53 -0
  70. package/agent-codex-sdk/dist/index.js +739 -0
  71. package/agent-codex-sdk/dist/permission.js +71 -0
  72. package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
  73. package/agent-codex-sdk/dist/session-map.js +167 -0
  74. package/agent-codex-sdk/dist/world-plugin.js +93 -0
  75. package/agent-codex-sdk/package.json +79 -0
  76. package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
  77. package/agent-omp/README.md +72 -55
  78. package/agent-omp/dist/agent.js +36 -11
  79. package/agent-omp/dist/index.js +92 -52
  80. package/agent-omp/dist/lazy-rpc.js +11 -4
  81. package/agent-omp/dist/omp-cli.js +114 -97
  82. package/agent-omp/dist/omp-store.js +12 -4
  83. package/agent-omp/dist/permission.js +70 -5
  84. package/agent-omp/dist/rpc-client.js +409 -0
  85. package/agent-omp/dist/world-plugin.js +36 -3
  86. package/agent-omp/package.json +2 -6
  87. package/agent-omp-sdk/README.md +103 -0
  88. package/agent-omp-sdk/cordis.patch.yml +108 -0
  89. package/agent-omp-sdk/dist/adapter.d.ts +21 -0
  90. package/agent-omp-sdk/dist/adapter.js +36 -0
  91. package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
  92. package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
  93. package/agent-omp-sdk/dist/agent.d.ts +64 -0
  94. package/agent-omp-sdk/dist/agent.js +1178 -0
  95. package/agent-omp-sdk/dist/discovery.d.ts +57 -0
  96. package/agent-omp-sdk/dist/discovery.js +116 -0
  97. package/agent-omp-sdk/dist/inbox.d.ts +28 -0
  98. package/agent-omp-sdk/dist/inbox.js +53 -0
  99. package/agent-omp-sdk/dist/index.d.ts +60 -0
  100. package/agent-omp-sdk/dist/index.js +632 -0
  101. package/agent-omp-sdk/dist/knobs.d.ts +34 -0
  102. package/agent-omp-sdk/dist/knobs.js +50 -0
  103. package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
  104. package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
  105. package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
  106. package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
  107. package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
  108. package/agent-omp-sdk/dist/mobile-boot.js +38 -0
  109. package/agent-omp-sdk/dist/models.d.ts +39 -0
  110. package/agent-omp-sdk/dist/models.js +299 -0
  111. package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
  112. package/agent-omp-sdk/dist/omp-cli.js +164 -0
  113. package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
  114. package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
  115. package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
  116. package/agent-omp-sdk/dist/omp-executable.js +30 -0
  117. package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
  118. package/agent-omp-sdk/dist/omp-store.js +526 -0
  119. package/agent-omp-sdk/dist/pairing.d.ts +7 -0
  120. package/agent-omp-sdk/dist/pairing.js +45 -0
  121. package/agent-omp-sdk/dist/permission.d.ts +138 -0
  122. package/agent-omp-sdk/dist/permission.js +161 -0
  123. package/agent-omp-sdk/dist/protocol.d.ts +189 -0
  124. package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
  125. package/agent-omp-sdk/dist/rpc-types.js +1 -0
  126. package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
  127. package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
  128. package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
  129. package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
  130. package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
  131. package/agent-omp-sdk/dist/sidecar-client.js +197 -0
  132. package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
  133. package/agent-omp-sdk/dist/store/adapter.js +47 -0
  134. package/agent-omp-sdk/dist/store/db.d.ts +70 -0
  135. package/agent-omp-sdk/dist/store/db.js +210 -0
  136. package/agent-omp-sdk/dist/store/index.d.ts +23 -0
  137. package/agent-omp-sdk/dist/store/index.js +59 -0
  138. package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
  139. package/agent-omp-sdk/dist/store/reconcile.js +51 -0
  140. package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
  141. package/agent-omp-sdk/dist/store/schema.js +40 -0
  142. package/agent-omp-sdk/dist/transport.d.ts +49 -0
  143. package/agent-omp-sdk/dist/transport.js +35 -0
  144. package/agent-omp-sdk/dist/world-home.d.ts +4 -0
  145. package/agent-omp-sdk/dist/world-home.js +23 -0
  146. package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
  147. package/agent-omp-sdk/dist/world-plugin.js +137 -0
  148. package/agent-omp-sdk/package.json +87 -0
  149. package/client/index.js +1794 -287
  150. package/cordis.patch.yml +80 -0
  151. package/package.json +23 -8
  152. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  153. package/superd-hub/dist/a2a-delivery.js +240 -0
  154. package/superd-hub/dist/a2a-host.d.ts +76 -0
  155. package/superd-hub/dist/a2a-host.js +145 -0
  156. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  157. package/superd-hub/dist/a2a-ingest.js +636 -0
  158. package/superd-hub/dist/a2a-log.d.ts +17 -0
  159. package/superd-hub/dist/a2a-log.js +42 -0
  160. package/superd-hub/dist/a2a-row.d.ts +65 -0
  161. package/superd-hub/dist/a2a-row.js +162 -0
  162. package/superd-hub/dist/a2a-service.d.ts +357 -0
  163. package/superd-hub/dist/a2a-service.js +980 -0
  164. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  165. package/superd-hub/dist/a2a-wire.js +305 -0
  166. package/superd-hub/dist/agent-ids.d.ts +10 -0
  167. package/superd-hub/dist/agent-ids.js +68 -0
  168. package/superd-hub/dist/agent-roster.d.ts +29 -18
  169. package/superd-hub/dist/agent-roster.js +54 -15
  170. package/superd-hub/dist/agent-status.d.ts +119 -0
  171. package/superd-hub/dist/agent-status.js +386 -0
  172. package/superd-hub/dist/client/agent-settings.d.ts +156 -0
  173. package/superd-hub/dist/client/agent-settings.js +229 -0
  174. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  175. package/superd-hub/dist/client/mesh-api.js +219 -0
  176. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  177. package/superd-hub/dist/client/mesh-groups.js +66 -0
  178. package/superd-hub/dist/client/roster.d.ts +48 -0
  179. package/superd-hub/dist/client/roster.js +102 -0
  180. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  181. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  182. package/superd-hub/dist/client/switch.d.ts +165 -0
  183. package/superd-hub/dist/client/switch.js +295 -0
  184. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  185. package/superd-hub/dist/exec-pty-channel.js +162 -0
  186. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  187. package/superd-hub/dist/exec-pty-framing.js +81 -0
  188. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  189. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  190. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  191. package/superd-hub/dist/exec-pty-session.js +234 -0
  192. package/superd-hub/dist/exec.d.ts +56 -0
  193. package/superd-hub/dist/exec.js +225 -0
  194. package/superd-hub/dist/gateway.d.ts +39 -2
  195. package/superd-hub/dist/gateway.js +62 -3
  196. package/superd-hub/dist/hub-tool.d.ts +174 -0
  197. package/superd-hub/dist/hub-tool.js +464 -0
  198. package/superd-hub/dist/index.d.ts +15 -1
  199. package/superd-hub/dist/index.js +16 -0
  200. package/superd-hub/dist/machines.d.ts +45 -0
  201. package/superd-hub/dist/machines.js +125 -0
  202. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  203. package/superd-hub/dist/mesh-federate.js +223 -0
  204. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  205. package/superd-hub/dist/mesh-gateway.js +408 -0
  206. package/superd-hub/dist/mesh-link.d.ts +274 -0
  207. package/superd-hub/dist/mesh-link.js +441 -0
  208. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  209. package/superd-hub/dist/mesh-rpc.js +250 -0
  210. package/superd-hub/dist/mux-client.d.ts +71 -0
  211. package/superd-hub/dist/mux-client.js +281 -0
  212. package/superd-hub/dist/pack-version.d.ts +2 -0
  213. package/superd-hub/dist/pack-version.js +30 -0
  214. package/superd-hub/dist/roster.d.ts +6 -0
  215. package/superd-hub/dist/rpc.d.ts +18 -2
  216. package/superd-hub/dist/rpc.js +34 -4
  217. package/superd-hub/dist/spawn-world.js +3 -1
  218. package/superd-hub/dist/switch-core.d.ts +62 -25
  219. package/superd-hub/dist/switch-core.js +53 -30
  220. package/superd-hub/dist/system-head.d.ts +22 -12
  221. package/superd-hub/dist/system-head.js +100 -84
  222. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  223. package/superd-hub/dist/wire-endpoints.js +180 -0
  224. package/superd-hub/lib/client/index.js +1794 -287
  225. package/superd-hub/package.json +11 -2
  226. package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
  227. package/agent-agy/dist/agent-preset-projection.js +0 -33
  228. package/agent-claude/dist/agent-preset-projection.js +0 -30
  229. package/agent-codex/dist/agent-preset-projection.js +0 -37
  230. package/agent-codex/dist/app-home.js +0 -65
  231. package/agent-codex/dist/models.js +0 -152
  232. package/agent-codex/dist/spike.js +0 -46
  233. package/agent-hermes/dist/agent-preset-projection.js +0 -34
  234. package/agent-omp/dist/agent-preset-projection.js +0 -36
  235. package/agent-omp/dist/app-home.js +0 -86
  236. package/agent-omp/dist/sidecar-client.js +0 -195
  237. package/agent-pi/dist/agent-preset-projection.js +0 -29
  238. package/superd-hub/dist/client-shim.d.ts +0 -28
  239. package/superd-hub/dist/client-shim.js +0 -251
  240. package/superd-hub/dist/index-pass.d.ts +0 -22
  241. package/superd-hub/dist/index-pass.js +0 -47
  242. package/superd-hub/dist/labels.d.ts +0 -45
  243. package/superd-hub/dist/labels.js +0 -83
  244. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  245. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  246. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  247. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  248. /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
package/client/index.js CHANGED
@@ -25,10 +25,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  //#endregion
26
26
  let react = require("react");
27
27
  react = __toESM(react);
28
- let react_jsx_runtime = require("react/jsx-runtime");
29
- react_jsx_runtime = __toESM(react_jsx_runtime);
30
28
  let __deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
31
29
  __deepseek_ai_dsh_client_ui_primitives = __toESM(__deepseek_ai_dsh_client_ui_primitives);
30
+ let react_jsx_runtime = require("react/jsx-runtime");
31
+ react_jsx_runtime = __toESM(react_jsx_runtime);
32
32
 
33
33
  //#region src/client/glyph.tsx
34
34
  /**
@@ -241,9 +241,10 @@ function imgMark(uri, size) {
241
241
  */
242
242
  function RuntimeMark({ agentKey, size }) {
243
243
  if (agentKey === "native") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DshFish, { size });
244
- const uri = RUNTIME_ICON_URIS[agentKey];
244
+ const base = agentKey.endsWith("-sdk") ? agentKey.slice(0, -4) : agentKey;
245
+ const uri = RUNTIME_ICON_URIS[base];
245
246
  if (uri === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubagentGlyph, { size });
246
- const tile = RUNTIME_TILE_BG[agentKey];
247
+ const tile = RUNTIME_TILE_BG[base];
247
248
  if (tile === void 0) return imgMark(uri, size);
248
249
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
249
250
  "aria-hidden": "true",
@@ -280,7 +281,10 @@ const FALLBACK_LABELS = {
280
281
  claude: "Claude",
281
282
  pi: "Pi",
282
283
  hermes: "Hermes",
283
- agy: "Antigravity"
284
+ agy: "Antigravity",
285
+ "omp-sdk": "OMP (SDK)",
286
+ "agy-sdk": "Antigravity (SDK)",
287
+ "codex-sdk": "Codex (SDK)"
284
288
  };
285
289
  /** Coerce a wire `agents` array into links; undefined when unusable/empty. */
286
290
  function coerceAgents(raw) {
@@ -294,7 +298,7 @@ function coerceAgents(raw) {
294
298
  key,
295
299
  label: typeof label === "string" ? label : FALLBACK_LABELS[key] ?? key,
296
300
  path,
297
- machine: typeof machine === "string" ? machine : "local",
301
+ machine: typeof machine === "string" && machine !== "" ? machine : void 0,
298
302
  ready: entry.ready === true,
299
303
  failed: entry.failed === true
300
304
  });
@@ -308,7 +312,8 @@ function rosterFromGlobal() {
308
312
  }
309
313
  /** Normalize the current mount root: `/omp` and `/omp/` are the same page. */
310
314
  function currentMountPath() {
311
- const pathname = typeof location === "undefined" ? "/" : location.pathname;
315
+ const location$1 = globalThis.location;
316
+ const pathname = location$1 === void 0 ? "/" : location$1.pathname;
312
317
  if (pathname === "" || pathname === "/") return "/";
313
318
  return pathname.endsWith("/") ? pathname : `${pathname}/`;
314
319
  }
@@ -343,78 +348,288 @@ async function fetchRoster() {
343
348
  }
344
349
 
345
350
  //#endregion
346
- //#region src/client/machines-store.ts
347
- /** Storage slot for the ledger (v1 shape; bump the suffix on breaking edits). */
348
- const STORAGE_KEY = "superd-hub.machines.v1";
351
+ //#region src/client/mesh-api.ts
352
+ /**
353
+ * Machine-mesh data access for the Hub machines panel (mesh P1, Task 5):
354
+ * the client half of `/api/superd/machines` (host side: mesh-rpc.ts) —
355
+ * same-origin fetch behind the standard browser-trust + cookie fence, the
356
+ * roster face's house style (`credentials: 'same-origin'`). The localStorage
357
+ * ledger era (machines-store.ts, retired with this module) ended: the hub's
358
+ * registry is the single source of truth, this file only fetches it and
359
+ * coerces the wire answer into row views.
360
+ *
361
+ * Node-safe by construction — no DOM, no react, no @deepseek-ai imports —
362
+ * so the host tsc emits it to `dist/client/mesh-api.js` and
363
+ * test/client-mesh-view.test.mjs runs the pure halves (coercion, token-URL
364
+ * pre-check) under `node --test` without jsdom: the switch-core/toast-core
365
+ * precedent in reverse (pure logic kept beside the fetch wrappers, all under
366
+ * src/client). No fetch happens at import time.
367
+ *
368
+ * @module superd-hub/client/mesh-api
369
+ */
349
370
  /**
350
- * The self row is DERIVED, never stored: this machine's label tracks the
351
- * product copy and its URL tracks the serving origin on every load. Only
352
- * remote machines persist.
371
+ * Base path of the mesh machines API — the client-side spelling of the
372
+ * host's `MESH_API_BASE` (mesh-rpc.ts). Duplicated deliberately: importing
373
+ * the host module would drag its node:fs-backed dependencies into the
374
+ * browser bundle; a path literal cannot drift silently because the mesh-rpc
375
+ * route registration and this file are reviewed together.
353
376
  */
354
- function selfMachine() {
377
+ const MESH_API_BASE = "/api/superd/machines";
378
+ /** The statuses the wire may carry; anything else coerces to `'pending'`. */
379
+ const STATUSES = [
380
+ "pending",
381
+ "reachable",
382
+ "unreachable",
383
+ "auth-expired"
384
+ ];
385
+ /** Coerce the self block; a shape without a non-empty string id + string label is simply absent. */
386
+ function coerceSelf(raw) {
387
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return void 0;
388
+ const { id, label } = raw;
389
+ if (typeof id !== "string" || id === "" || typeof label !== "string") return void 0;
355
390
  return {
356
- id: "self",
357
- name: "local",
358
- label: "This machine",
359
- url: typeof location === "undefined" ? "" : location.origin,
360
- self: true,
361
- addedAt: 0
391
+ id,
392
+ label
362
393
  };
363
394
  }
364
395
  /**
365
- * Read the ledger; a missing or unreadable store resets to the self row.
396
+ * Coerce a raw GET body into the panel's view list. Any bad shape degrades
397
+ * to the empty list (rows dropped individually, self dropped as a block) —
398
+ * the UI never crashes on a malformed answer.
366
399
  *
367
- * @returns the machines: the derived self row first, then the stored remotes.
400
+ * @param raw - the parsed JSON body (or anything else the wire produced).
401
+ * @returns self (when usable) + the coerced remote rows.
368
402
  */
369
- function loadMachines() {
370
- const remotes = readStoredRemotes();
371
- return [selfMachine(), ...remotes];
403
+ function coerceMachineList(raw) {
404
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return { machines: [] };
405
+ const record = raw;
406
+ const self = coerceSelf(record.self);
407
+ const machines = [];
408
+ if (Array.isArray(record.machines)) for (const entry of record.machines) {
409
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
410
+ const row = entry;
411
+ if (typeof row.id !== "string" || row.id === "") continue;
412
+ if (typeof row.name !== "string" || row.name === "") continue;
413
+ if (typeof row.origin !== "string" || row.origin === "") continue;
414
+ const status = typeof row.status === "string" && STATUSES.includes(row.status) ? row.status : "pending";
415
+ const base = {
416
+ id: row.id,
417
+ name: row.name,
418
+ label: typeof row.label === "string" && row.label !== "" ? row.label : row.name,
419
+ origin: row.origin,
420
+ status,
421
+ self: self !== void 0 && row.id === self.id
422
+ };
423
+ const withProbe = typeof row.lastProbeAt === "number" ? {
424
+ ...base,
425
+ lastProbeAt: row.lastProbeAt
426
+ } : base;
427
+ machines.push(typeof row.versionWarning === "string" && row.versionWarning !== "" ? {
428
+ ...withProbe,
429
+ versionWarning: row.versionWarning
430
+ } : withProbe);
431
+ }
432
+ return self === void 0 ? { machines } : {
433
+ self,
434
+ machines
435
+ };
372
436
  }
373
- /** Parse the stored remote machines; storage failures degrade to none. */
374
- function readStoredRemotes() {
375
- if (typeof localStorage === "undefined") return [];
376
- let parsed;
437
+ /**
438
+ * The version-warning chip for one machine row (I2): present EXACTLY when the
439
+ * coerced row carries a `versionWarning` — the Hub machines panel renders
440
+ * the chip iff this returns a value. Kept here beside the coercion so the
441
+ * presence contract stays unit-testable without jsdom (the HubPage seat is
442
+ * a one-line consumer following the existing chip patterns).
443
+ */
444
+ function machineVersionChip(machine) {
445
+ return machine.versionWarning === void 0 ? void 0 : { text: machine.versionWarning };
446
+ }
447
+ /** Read a non-2xx body's `{error}` message; degrade to the bare status line. */
448
+ async function errorText(response) {
377
449
  try {
378
- const raw = localStorage.getItem(STORAGE_KEY);
379
- if (raw === null) return [];
380
- parsed = JSON.parse(raw);
450
+ const body = await response.json();
451
+ if (typeof body?.error === "string" && body.error !== "") return body.error;
452
+ } catch {}
453
+ return `HTTP ${response.status}`;
454
+ }
455
+ /**
456
+ * GET the machine list (self + remotes).
457
+ *
458
+ * @returns the coerced list — a malformed body degrades to the empty list, never a throw.
459
+ * @throws when the request fails or the face answers non-2xx.
460
+ */
461
+ async function fetchMachines() {
462
+ const response = await fetch(MESH_API_BASE, { credentials: "same-origin" });
463
+ if (!response.ok) throw new Error(await errorText(response));
464
+ return coerceMachineList(await response.json().catch(() => void 0));
465
+ }
466
+ /**
467
+ * POST a pairing `{name, label?, tokenUrl}` (label omitted → the server
468
+ * collapses it to the name).
469
+ *
470
+ * @throws Error(body.error) when the face answers non-2xx — the message is
471
+ * mesh-link's own, already token-redacted.
472
+ */
473
+ async function addMachine(input) {
474
+ const body = {
475
+ name: input.name,
476
+ tokenUrl: input.tokenUrl
477
+ };
478
+ if (typeof input.label === "string" && input.label !== "") body.label = input.label;
479
+ const response = await fetch(MESH_API_BASE, {
480
+ credentials: "same-origin",
481
+ method: "POST",
482
+ headers: { "content-type": "application/json" },
483
+ body: JSON.stringify(body)
484
+ });
485
+ if (!response.ok) throw new Error(await errorText(response));
486
+ }
487
+ /**
488
+ * DELETE one remote row by id (`{removed: boolean}` answers even for
489
+ * unknown ids — a false removal is a reload, not an error).
490
+ *
491
+ * @throws Error(body.error) on a non-2xx answer.
492
+ */
493
+ async function removeMachine(id) {
494
+ const response = await fetch(`${MESH_API_BASE}?id=${encodeURIComponent(id)}`, {
495
+ credentials: "same-origin",
496
+ method: "DELETE"
497
+ });
498
+ if (!response.ok) throw new Error(await errorText(response));
499
+ }
500
+ /**
501
+ * POST `{op: 'reprobe', id}` — a fresh probe of one remote; the outcome
502
+ * (even unreachable/auth-expired) lands in the status table server-side, so
503
+ * the caller reloads rather than interpreting the probe body.
504
+ *
505
+ * @throws Error(body.error) on a non-2xx answer (the op itself failed).
506
+ */
507
+ async function reprobeMachine(id) {
508
+ const response = await fetch(MESH_API_BASE, {
509
+ credentials: "same-origin",
510
+ method: "POST",
511
+ headers: { "content-type": "application/json" },
512
+ body: JSON.stringify({
513
+ op: "reprobe",
514
+ id
515
+ })
516
+ });
517
+ if (!response.ok) throw new Error(await errorText(response));
518
+ }
519
+ /**
520
+ * The standing cadence note (D18): machine status refresh rides the hub's
521
+ * 5-minute sweep — the panel renders this verbatim beside its live-fetch
522
+ * control. English copy to match the DSH UI.
523
+ */
524
+ const AUTO_REFRESH_NOTE = "auto-refreshes every 5 min";
525
+ /**
526
+ * The per-machine last-fetch line, shaped from the row's `lastProbeAt`
527
+ * (the hub's status table stamp — mesh-rpc joins it on every GET).
528
+ * Pure by design (the UI passes its own `now`): headless-testable without
529
+ * jsdom, same presence contract as {@link machineVersionChip} — absent or
530
+ * non-finite stamp means "never probed" and the panel omits the line.
531
+ *
532
+ * @param lastProbeAt - epoch ms of the machine's last recorded probe.
533
+ * @param now - epoch ms the panel renders at.
534
+ * @returns "Updated 2m ago" / "Updated just now" / … , or undefined.
535
+ */
536
+ function lastFetchLabel(lastProbeAt, now) {
537
+ if (typeof lastProbeAt !== "number" || !Number.isFinite(lastProbeAt)) return void 0;
538
+ const seconds = Math.max(0, Math.floor((now - lastProbeAt) / 1e3));
539
+ if (seconds < 60) return "Updated just now";
540
+ if (seconds < 3600) return `Updated ${Math.floor(seconds / 60)}m ago`;
541
+ if (seconds < 86400) return `Updated ${Math.floor(seconds / 3600)}h ago`;
542
+ return `Updated ${Math.floor(seconds / 86400)}d ago`;
543
+ }
544
+ /**
545
+ * Client-side pre-check before a pairing submit: a parseable absolute
546
+ * http(s) URL carrying a non-empty `token` query param. The server re-parses
547
+ * authoritatively (mesh-link's parseTokenUrl); this only keeps obviously
548
+ * dead drafts off the wire.
549
+ *
550
+ * @param input - the raw token-URL draft (trim before calling).
551
+ * @returns whether the draft is submit-shaped.
552
+ */
553
+ function validTokenUrl(input) {
554
+ if (typeof input !== "string" || input === "") return false;
555
+ let url;
556
+ try {
557
+ url = new URL(input);
381
558
  } catch {
382
- return [];
383
- }
384
- if (!Array.isArray(parsed)) return [];
385
- const list = [];
386
- for (const entry of parsed) {
387
- if (typeof entry !== "object" || entry === null) continue;
388
- const { id, name, label, url, self, addedAt } = entry;
389
- if (self === true) continue;
390
- if (typeof id !== "string" || typeof name !== "string" || typeof url !== "string") continue;
391
- list.push({
392
- id,
393
- name,
394
- label: typeof label === "string" ? label : name,
395
- url,
396
- self: false,
397
- addedAt: typeof addedAt === "number" ? addedAt : 0
398
- });
559
+ return false;
399
560
  }
400
- return list;
561
+ if (url.protocol !== "http:" && url.protocol !== "https:") return false;
562
+ const token = url.searchParams.get("token");
563
+ return token !== null && token !== "";
564
+ }
565
+
566
+ //#endregion
567
+ //#region src/client/mesh-groups.ts
568
+ /** The machine key every LOCAL roster row carries (older host shapes may omit the field — grouping treats absent as local). */
569
+ const LOCAL_MACHINE_KEY = "local";
570
+ /** The LOCAL section's fixed display label — this machine needs no registry row to be named. */
571
+ const LOCAL_MACHINE_LABEL = "This machine";
572
+ /** Whether a row's machine field parks it in the local section: `'local'` or absent (the coercion drops unknown values). */
573
+ function isLocalMachine(machine) {
574
+ return machine === void 0 || machine === LOCAL_MACHINE_KEY;
401
575
  }
402
576
  /**
403
- * Persist the ledger; storage failures degrade silently to in-memory state.
577
+ * Group a roster into machine sections for the switch menu and the Hub
578
+ * roster rows: the LOCAL group first (label {@link LOCAL_MACHINE_LABEL};
579
+ * rows whose `machine` is `'local'` or absent), then one group per remote
580
+ * machine sorted by display label (code-unit order) with the machine key as
581
+ * the tiebreak. Members keep the roster's given order inside their group;
582
+ * groups only exist for machines actually present in the roster (no empty
583
+ * local section when every row is federated). An unknown label map entry —
584
+ * missing, or an empty string — falls back to the raw machine key.
404
585
  *
405
- * @param list - the machines to store (self row included).
586
+ * @param links - the roster rows (any order; the section order is derived, not inherited).
587
+ * @param machineLabels - machine key (m4) → display label; the machines API answer via {@link machineLabelsFrom}.
588
+ * @returns the sections, local first.
406
589
  */
407
- function saveMachines(list) {
408
- if (typeof localStorage === "undefined") return;
409
- try {
410
- localStorage.setItem(STORAGE_KEY, JSON.stringify(list));
411
- } catch {}
590
+ function groupByMachine(links, machineLabels) {
591
+ const local = [];
592
+ const byKey = /* @__PURE__ */ new Map();
593
+ for (const link of links) {
594
+ if (isLocalMachine(link.machine)) {
595
+ local.push(link);
596
+ continue;
597
+ }
598
+ const machine = link.machine;
599
+ const bucket = byKey.get(machine);
600
+ if (bucket === void 0) byKey.set(machine, [link]);
601
+ else bucket.push(link);
602
+ }
603
+ const labelOf = (key) => {
604
+ const label = machineLabels[key];
605
+ return typeof label === "string" && label !== "" ? label : key;
606
+ };
607
+ const remote = [...byKey.entries()].map(([key, agents]) => ({
608
+ key,
609
+ label: labelOf(key),
610
+ agents
611
+ })).sort((a, b) => a.label !== b.label ? a.label < b.label ? -1 : 1 : a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
612
+ return local.length > 0 ? [{
613
+ key: LOCAL_MACHINE_KEY,
614
+ label: LOCAL_MACHINE_LABEL,
615
+ agents: local
616
+ }, ...remote] : remote;
412
617
  }
413
- /** A fresh row id (UUID when available, time+random otherwise). */
414
- function freshMachineId() {
415
- const cryptoRef = globalThis.crypto;
416
- if (typeof cryptoRef?.randomUUID === "function") return cryptoRef.randomUUID();
417
- return `m-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
618
+ /**
619
+ * The machines API answer → the grouping label map: every remote row's
620
+ * `id → label` (mesh-api's coercion already collapsed an empty label to the
621
+ * machine name) plus the self block's own `m4 → label`. An absent list is
622
+ * the empty map — the caller's degrade-to-flat trigger, never a throw.
623
+ *
624
+ * @param list - the coerced `fetchMachines()` answer, when it succeeded.
625
+ * @returns machine key → display label (the raw key stays absent, not mapped).
626
+ */
627
+ function machineLabelsFrom(list) {
628
+ const labels = {};
629
+ if (list === void 0) return labels;
630
+ for (const machine of list.machines) labels[machine.id] = machine.label !== "" ? machine.label : machine.name;
631
+ if (list.self !== void 0) labels[list.self.id] = list.self.label;
632
+ return labels;
418
633
  }
419
634
 
420
635
  //#endregion
@@ -888,37 +1103,6 @@ function activeAgentName(activeAgent, roster) {
888
1103
  if (activeAgent === void 0 || activeAgent === "") return void 0;
889
1104
  return roster.find((row) => row.key === activeAgent)?.label ?? activeAgent;
890
1105
  }
891
- /** Which machine one roster row groups under: the row's own machine (parser-guaranteed). */
892
- function machineGroup(row) {
893
- return row.machine;
894
- }
895
- /**
896
- * Group a roster by machine for the HubPanelIcon chevron menu's native
897
- * workspace-list look: one group per distinct `machineGroup` key, groups in
898
- * first-appearance order, members keeping the roster's order inside their
899
- * group. A single-group roster (today's local-only shape) renders exactly
900
- * like the old flat list minus the card border.
901
- *
902
- * Host-half pure logic so `test/client-switch.test.mjs` pins it from `dist/`.
903
- */
904
- function machineGroups(rows) {
905
- const groups = [];
906
- const byMachine = /* @__PURE__ */ new Map();
907
- for (const row of rows) {
908
- const machine = machineGroup(row);
909
- let group = byMachine.get(machine);
910
- if (group === void 0) {
911
- group = {
912
- machine,
913
- agents: []
914
- };
915
- byMachine.set(machine, group);
916
- groups.push(group);
917
- }
918
- group.agents.push(row);
919
- }
920
- return groups;
921
- }
922
1106
  /**
923
1107
  * Build the switch machine over an injected {@link SwitchHost}.
924
1108
  *
@@ -1064,15 +1248,63 @@ function createSwitchController(host, options = {}) {
1064
1248
  /**
1065
1249
  * The pure pre-flight decision. `native` always runs; an absent row (roster
1066
1250
  * fetch failed, or the key is not listed) also runs — the machine's roster
1067
- * probe is the authority on unknown targets, exactly as before C1.
1251
+ * probe is the authority on unknown targets, exactly as before C1. A
1252
+ * not-ready FEDERATED row (`machine` set and not `'local'`) decides
1253
+ * `'machine-down'` — an immediate actionable failure, never a wait loop
1254
+ * (the hub's probe already knows the machine is unreachable or its auth
1255
+ * expired); `failed` keeps precedence everywhere (a peer-reported spawn
1256
+ * rejection still reports as failed).
1068
1257
  */
1069
1258
  function decidePreFlight(label, row) {
1070
1259
  if (label === NATIVE_AGENT) return "run";
1071
1260
  if (row === void 0) return "run";
1072
1261
  if (row.failed === true) return "failed";
1073
- if (row.ready !== true) return "wait";
1262
+ if (row.ready !== true) {
1263
+ if (row.machine !== void 0 && row.machine !== "local") return "machine-down";
1264
+ return "wait";
1265
+ }
1074
1266
  return "run";
1075
1267
  }
1268
+ /** Bound on the machine-down branch's enrichment fetch (mesh P3 Task 5a:
1269
+ * the parked P2 minor — an unbounded `fetchMachines` await — folds here; a
1270
+ * hung hub answer must never swallow the toast). */
1271
+ const MACHINE_DOWN_ENRICH_MS = 3e3;
1272
+ /**
1273
+ * The machine-down branch's pure half (I1(c) feedback + I1(b) light probe,
1274
+ * mesh P3 Task 5a): enrich the toast through the machines face — BOUNDED at
1275
+ * {@link MACHINE_DOWN_ENRICH_MS} — then, after toasting, fire ONE reprobe
1276
+ * for the row's machine and forget it: a stale-unreachable machine gets a
1277
+ * fresh attempt per failed click, so the NEXT click can succeed without
1278
+ * waiting for the hub's 5-minute sweep. Never blocks the UI path (the whole
1279
+ * body is detached), never surfaces a reprobe failure (the sweep retries).
1280
+ */
1281
+ function runMachineDownFeedback(label, row, faces) {
1282
+ (async () => {
1283
+ let machineName = row.machine;
1284
+ let status;
1285
+ const enriched = await new Promise((resolve) => {
1286
+ const bound$1 = faces.setTimeout(() => resolve(void 0), MACHINE_DOWN_ENRICH_MS);
1287
+ faces.fetchMachines().then((list) => {
1288
+ faces.clearTimeout(bound$1);
1289
+ resolve(list);
1290
+ }, () => {
1291
+ faces.clearTimeout(bound$1);
1292
+ resolve(void 0);
1293
+ });
1294
+ });
1295
+ if (enriched !== void 0) {
1296
+ const found = enriched.machines.find((entry) => entry.id === row.machine);
1297
+ if (found !== void 0) {
1298
+ machineName = found.label;
1299
+ if (found.status === "unreachable" || found.status === "auth-expired") status = found.status;
1300
+ }
1301
+ }
1302
+ const who = row.label ?? label;
1303
+ const machine = machineName ?? "its machine";
1304
+ faces.toast(status === void 0 ? `Super D: ${who} is unavailable — machine ${machine} is not ready. Reprobe or re-add it in the Hub machines panel.` : `Super D: ${who} is unavailable — machine ${machine} reports ${status}. Reprobe or re-add it in the Hub machines panel.`);
1305
+ if (row.machine !== void 0) faces.reprobe(row.machine).catch(() => {});
1306
+ })();
1307
+ }
1076
1308
  /** Default bound on one readiness wait (the page never locks behind a stuck world). */
1077
1309
  const WAIT_BOUND_MS = 12e4;
1078
1310
  /** Default poll interval for one readiness wait. */
@@ -1200,14 +1432,61 @@ function uiState() {
1200
1432
  function showToast(message) {
1201
1433
  showSuperdToast(message);
1202
1434
  }
1435
+ /**
1436
+ * I1(c) feedback + I1(b) light probe (mesh P3 Task 5a): the machine-down
1437
+ * branch delegates to the pure {@link runMachineDownFeedback} — the
1438
+ * machines face (already part of the client half — the Hub machines panel's
1439
+ * own cheap same-origin GET) enriches the toast, bounded at 3s; after
1440
+ * toasting, ONE fire-and-forget reprobe POST per failed click refreshes the
1441
+ * hub's status table so the NEXT click can succeed without waiting for the
1442
+ * 5-minute sweep. Nothing here blocks the UI path.
1443
+ */
1444
+ function reportMachineDown(label, row) {
1445
+ runMachineDownFeedback(label, row, {
1446
+ fetchMachines,
1447
+ reprobe: reprobeMachine,
1448
+ toast: showToast,
1449
+ setTimeout: (fn, ms) => globalThis.setTimeout(fn, ms),
1450
+ clearTimeout: (handle) => globalThis.clearTimeout(handle)
1451
+ });
1452
+ }
1453
+ /**
1454
+ * Build the `SwitchHost.openDefaultWorkspace` action.
1455
+ *
1456
+ * dsh 0.2.0-rc.2 removed the request object from the Host's
1457
+ * `workspaces.initializeDefault` Remote: the first-use directory and stored
1458
+ * title are fixed and language-neutral (`default-workspace` under
1459
+ * `<Documents>/deepseek-harness`), so the caller passes only its own lifetime
1460
+ * signal. This module shipped the pre-0.2 `{ directoryName, title }` shape for
1461
+ * a release cycle; the Host then received a plain object where it feeds
1462
+ * `AbortSignal.any(...)`, EVERY empty-plane landing rejected, and the browser
1463
+ * surfaced "Unable to create default workspace". Root-caused 2026-10-02 on
1464
+ * the Hermes world — the only world whose registry was still empty after the
1465
+ * 0.2.0-rc.2 upgrade, hence the only one that took the default-workspace
1466
+ * branch. Exported so the call shape is unit-testable without the
1467
+ * module-level single-bind guard.
1468
+ *
1469
+ * @param deps - the workspace projection and the navigation face.
1470
+ * @param toast - the feedback sink; a refusal is feedback, never a revert.
1471
+ * @returns the host action.
1472
+ */
1473
+ function openDefaultWorkspaceFor(deps, toast) {
1474
+ return () => {
1475
+ deps.workspaces.initializeDefault().then((prepared) => {
1476
+ if (prepared !== void 0) deps.uiWorkspace.openWorkspace(prepared.workspaceId);
1477
+ }).catch(() => {
1478
+ toast("Super D: unable to create the default workspace.");
1479
+ });
1480
+ };
1481
+ }
1203
1482
  /** The bound `switchAgent`, or `undefined` until the entry binds it. */
1204
1483
  let bound;
1205
1484
  /**
1206
1485
  * Bind the page's switch agent from the client services. Idempotent; a no-op
1207
1486
  * without the page atom (a non-fusion page never has one).
1208
- * @param deps - the `connection`, `uiWorkspace`, `workspaces`, `sessions`
1209
- * and `locale` services (structural; the stock client tree always has all
1210
- * five — upstream's ui-workspace injects the same set).
1487
+ * @param deps - the `connection`, `uiWorkspace`, `workspaces` and `sessions`
1488
+ * services (structural; the stock client tree always has all four —
1489
+ * upstream's ui-workspace injects the same set).
1211
1490
  */
1212
1491
  function bindSwitchAgent(deps) {
1213
1492
  if (bound !== void 0) return;
@@ -1228,19 +1507,6 @@ function bindSwitchAgent(deps) {
1228
1507
  }
1229
1508
  };
1230
1509
  };
1231
- const openDefaultWorkspace = () => {
1232
- const language = deps.locale.getSnapshot().active.toLowerCase().split("-")[0];
1233
- const title = language === "zh" ? "默认工作区" : "Default workspace";
1234
- const directoryName = language === "zh" || language === "en" ? title : "default-workspace";
1235
- deps.workspaces.initializeDefault({
1236
- directoryName,
1237
- title
1238
- }).then((prepared) => {
1239
- if (prepared !== void 0) deps.uiWorkspace.openWorkspace(prepared.workspaceId);
1240
- }).catch(() => {
1241
- showToast("Super D: unable to create the default workspace.");
1242
- });
1243
- };
1244
1510
  const controller = createSwitchController({
1245
1511
  setAgent(label) {
1246
1512
  state.setAgent(label);
@@ -1255,7 +1521,7 @@ function bindSwitchAgent(deps) {
1255
1521
  startSession(workspaceId) {
1256
1522
  deps.uiWorkspace.startSession(workspaceId);
1257
1523
  },
1258
- openDefaultWorkspace,
1524
+ openDefaultWorkspace: openDefaultWorkspaceFor(deps, showToast),
1259
1525
  readRestoreCaches,
1260
1526
  onCachesRefreshed(listener, gate) {
1261
1527
  return observeCachesRefreshed(deps.workspaces.list, {
@@ -1312,7 +1578,10 @@ let pendingWait;
1312
1578
  * `label`, gated on the target world's readiness (C1): a not-ready world
1313
1579
  * holds the UI on native with starting feedback and a bounded poll; a
1314
1580
  * failed world reports and never switches; a ready/native/unknown target
1315
- * runs the machine (whose roster probe stays the fallback).
1581
+ * runs the machine (whose roster probe stays the fallback). A not-ready
1582
+ * FEDERATED row skips all of that — an immediate machine-error toast
1583
+ * (I1(c), `machine-down`), never a wait loop.
1584
+ *
1316
1585
  * @returns `true` when the fusion switch took the click over; `false` when
1317
1586
  * this page is not a fusion page or the orchestration is unbound.
1318
1587
  * Informational only — the interception contract (`seatClickDecision`)
@@ -1337,6 +1606,10 @@ function attemptSwitch(label) {
1337
1606
  showToast(`Super D: ${label} failed to start — see the service log.`);
1338
1607
  return;
1339
1608
  }
1609
+ if (decision === "machine-down") {
1610
+ if (row !== void 0) reportMachineDown(label, row);
1611
+ return;
1612
+ }
1340
1613
  if (decision === "wait") {
1341
1614
  showToast(`Super D: ${label} is starting…`);
1342
1615
  const waiter = createReadinessWaiter({
@@ -1366,16 +1639,292 @@ function attemptSwitch(label) {
1366
1639
  return true;
1367
1640
  }
1368
1641
 
1642
+ //#endregion
1643
+ //#region src/client/agent-settings.ts
1644
+ const SETTINGS_PANELS = {
1645
+ agy: {
1646
+ namespace: "agyAuth",
1647
+ kind: "auth"
1648
+ },
1649
+ codex: {
1650
+ namespace: "codexProviders",
1651
+ kind: "providers"
1652
+ },
1653
+ "codex-sdk": {
1654
+ namespace: "codexProviders",
1655
+ kind: "providers"
1656
+ }
1657
+ };
1658
+ /** The panel spec for a runtime, or `undefined` when it has none yet. */
1659
+ function settingsPanelFor(agentKey) {
1660
+ return SETTINGS_PANELS[agentKey];
1661
+ }
1662
+ /**
1663
+ * Accordion transition: at most one row open. Clicking the open row closes it;
1664
+ * clicking another moves the panel there in one click.
1665
+ */
1666
+ function toggleExpanded(current$1, key) {
1667
+ return current$1 === key ? null : key;
1668
+ }
1669
+ function str(value) {
1670
+ return typeof value === "string" && value !== "" ? value : void 0;
1671
+ }
1672
+ function methodOption(raw) {
1673
+ if (typeof raw !== "object" || raw === null) return void 0;
1674
+ const record = raw;
1675
+ const key = str(record.key);
1676
+ const label = str(record.label);
1677
+ if (key === void 0 || label === void 0) return void 0;
1678
+ return {
1679
+ key,
1680
+ label,
1681
+ available: record.available === true,
1682
+ placeholder: record.placeholder === true,
1683
+ hint: str(record.hint) ?? ""
1684
+ };
1685
+ }
1686
+ /**
1687
+ * Defensive parse of the RPC answer. Returns `undefined` for anything that is
1688
+ * not a usable view (no methods, wrong shape, adapter absent) so the panel can
1689
+ * render an explicit failure instead of an empty list that looks like success.
1690
+ */
1691
+ function parseAuthView(raw) {
1692
+ if (typeof raw !== "object" || raw === null) return void 0;
1693
+ const record = raw;
1694
+ if (!Array.isArray(record.methods)) return void 0;
1695
+ const methods = record.methods.map(methodOption).filter((m) => m !== void 0);
1696
+ if (methods.length === 0) return void 0;
1697
+ const settingsPath = str(record.settingsPath);
1698
+ const note = str(record.note);
1699
+ return {
1700
+ methods,
1701
+ selected: str(record.selected) ?? null,
1702
+ effective: str(record.effective) ?? null,
1703
+ ...settingsPath === void 0 ? {} : { settingsPath },
1704
+ ...note === void 0 ? {} : { note }
1705
+ };
1706
+ }
1707
+ /**
1708
+ * The option the panel marks as in force: the effective one when the adapter
1709
+ * named it, else the explicit selection. `undefined` when neither is known —
1710
+ * the panel then marks nothing rather than guessing.
1711
+ */
1712
+ function activeMethod(view) {
1713
+ const wanted = view.effective ?? view.selected;
1714
+ if (wanted === null) return void 0;
1715
+ return view.methods.find((method) => method.key === wanted);
1716
+ }
1717
+ /** Whether an option may be picked (placeholders are rendered, never selected). */
1718
+ function selectable(option) {
1719
+ return !option.placeholder;
1720
+ }
1721
+ function nonEmpty(value) {
1722
+ return typeof value === "string" && value !== "" ? value : void 0;
1723
+ }
1724
+ function modelOption(raw) {
1725
+ if (typeof raw !== "object" || raw === null) return void 0;
1726
+ const record = raw;
1727
+ const id = nonEmpty(record.id);
1728
+ if (id === void 0) return void 0;
1729
+ const contextWindow = record.contextWindow;
1730
+ return {
1731
+ id,
1732
+ label: nonEmpty(record.displayName) ?? id,
1733
+ ...typeof contextWindow === "number" && Number.isSafeInteger(contextWindow) && contextWindow > 0 ? { contextWindow } : {}
1734
+ };
1735
+ }
1736
+ function providerOption(raw) {
1737
+ if (typeof raw !== "object" || raw === null) return void 0;
1738
+ const record = raw;
1739
+ const id = nonEmpty(record.id);
1740
+ const label = nonEmpty(record.label);
1741
+ const baseUrl = nonEmpty(record.baseUrl);
1742
+ if (id === void 0 || label === void 0 || baseUrl === void 0) return void 0;
1743
+ const models = Array.isArray(record.models) ? record.models.map(modelOption).filter((entry) => entry !== void 0) : [];
1744
+ const envName = nonEmpty(record.envName);
1745
+ return {
1746
+ id,
1747
+ label,
1748
+ baseUrl,
1749
+ protocol: record.protocol === "chat" ? "chat" : "responses",
1750
+ models,
1751
+ authKind: record.authKind === "env" ? "env" : "apiKey",
1752
+ ...envName === void 0 ? {} : { envName },
1753
+ hasKey: record.hasKey === true
1754
+ };
1755
+ }
1756
+ function protocolOption(raw) {
1757
+ if (typeof raw !== "object" || raw === null) return void 0;
1758
+ const record = raw;
1759
+ const value = nonEmpty(record.value);
1760
+ const label = nonEmpty(record.label);
1761
+ if (value === void 0 || label === void 0) return void 0;
1762
+ return {
1763
+ value,
1764
+ label,
1765
+ available: record.available === true,
1766
+ hint: nonEmpty(record.hint) ?? ""
1767
+ };
1768
+ }
1769
+ function providerPaths(raw) {
1770
+ if (typeof raw !== "object" || raw === null) return void 0;
1771
+ const record = raw;
1772
+ const store = nonEmpty(record.store);
1773
+ const config = nonEmpty(record.config);
1774
+ const auth = nonEmpty(record.auth);
1775
+ const catalogs = nonEmpty(record.catalogs);
1776
+ if (store === void 0 || config === void 0 || auth === void 0 || catalogs === void 0) return void 0;
1777
+ return {
1778
+ store,
1779
+ config,
1780
+ auth,
1781
+ catalogs
1782
+ };
1783
+ }
1784
+ /**
1785
+ * Defensive parse of the adapter's providers answer.
1786
+ *
1787
+ * `undefined` for anything that is not a usable view — but an empty `providers`
1788
+ * array WITH a usable protocol list is valid (a fresh install), and so is a
1789
+ * provider whose `models` array is empty.
1790
+ */
1791
+ function parseProvidersView(raw) {
1792
+ if (typeof raw !== "object" || raw === null) return void 0;
1793
+ const record = raw;
1794
+ if (!Array.isArray(record.providers)) return void 0;
1795
+ if (!Array.isArray(record.protocols)) return void 0;
1796
+ const protocols = record.protocols.map(protocolOption).filter((entry) => entry !== void 0);
1797
+ if (protocols.length === 0) return void 0;
1798
+ const paths = providerPaths(record.paths);
1799
+ if (paths === void 0) return void 0;
1800
+ const providers = record.providers.map(providerOption).filter((entry) => entry !== void 0);
1801
+ const syncedAt = record.syncedAt;
1802
+ const note = nonEmpty(record.note);
1803
+ return {
1804
+ providers,
1805
+ native: nativeConfig(record.native),
1806
+ protocols,
1807
+ paths,
1808
+ ...typeof syncedAt === "number" && Number.isFinite(syncedAt) ? { syncedAt } : {},
1809
+ ...note === void 0 ? {} : { note }
1810
+ };
1811
+ }
1812
+ /**
1813
+ * The user's own config.toml as the adapter last read it. `null` when the
1814
+ * adapter said nothing; otherwise an object carrying whichever halves were
1815
+ * named (an empty one is still news — the panel says the file names nothing).
1816
+ */
1817
+ function nativeConfig(raw) {
1818
+ if (typeof raw !== "object" || raw === null) return null;
1819
+ const record = raw;
1820
+ const providerId = nonEmpty(record.providerId);
1821
+ const model = nonEmpty(record.model);
1822
+ return {
1823
+ ...providerId === void 0 ? {} : { providerId },
1824
+ ...model === void 0 ? {} : { model }
1825
+ };
1826
+ }
1827
+
1828
+ //#endregion
1829
+ //#region src/client/runtime-settings-api.ts
1830
+ /** One rpcId for request/response correlation. `randomUUID` needs a secure context. */
1831
+ function mintRpcId() {
1832
+ const webCrypto = globalThis.crypto;
1833
+ if (webCrypto !== void 0 && typeof webCrypto.randomUUID === "function") return webCrypto.randomUUID();
1834
+ if (webCrypto !== void 0 && typeof webCrypto.getRandomValues === "function") return [...webCrypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, "0")).join("");
1835
+ return `rpc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
1836
+ }
1837
+ function settingsEnvelope(namespace, op, args) {
1838
+ return {
1839
+ type: "client-request",
1840
+ rpcId: mintRpcId(),
1841
+ method: `${namespace}/${op}`,
1842
+ payload: { args }
1843
+ };
1844
+ }
1845
+ /** What a caller can do with a failed panel call — kept structural for the tests. */
1846
+ function messageOf(error) {
1847
+ if (error !== null && typeof error === "object" && typeof error.message === "string") return error.message;
1848
+ return String(error);
1849
+ }
1850
+ /**
1851
+ * One unary call at a runtime's world, unwrapped to the RPC's value.
1852
+ *
1853
+ * Every failure mode is reported as a thrown `Error` carrying the adapter's own
1854
+ * message where one exists: a transport failure, a malformed answer, and the
1855
+ * gateway's business error (`{ok:false,error}`) must not look alike to the panel.
1856
+ *
1857
+ * @param agentKey - roster key addressing the world (`?agent=`).
1858
+ * @param namespace - the adapter's Remote namespace (`agyAuth`).
1859
+ * @param op - the Remote method.
1860
+ * @param args - exact named wire arguments.
1861
+ * @param doFetch - fetch implementation (tests inject).
1862
+ * @returns the raw RPC value.
1863
+ * @throws {Error} on transport, framing, or gateway failure.
1864
+ */
1865
+ async function callRuntimeSettings(agentKey, namespace, op, args, doFetch) {
1866
+ const send = doFetch ?? ((input, init) => fetch(input, init));
1867
+ const envelope = settingsEnvelope(namespace, op, args);
1868
+ const response = await send(`/hub/api?agent=${encodeURIComponent(agentKey)}`, {
1869
+ method: "POST",
1870
+ credentials: "same-origin",
1871
+ headers: { "content-type": "application/json" },
1872
+ body: JSON.stringify(envelope)
1873
+ });
1874
+ const text = await response.text();
1875
+ let body;
1876
+ try {
1877
+ body = JSON.parse(text);
1878
+ } catch {
1879
+ throw new Error(`settings ${envelope.method}: unreadable answer (HTTP ${response.status})`);
1880
+ }
1881
+ const result = body?.result;
1882
+ if (result === null || typeof result !== "object") throw new Error(`settings ${envelope.method}: malformed answer (HTTP ${response.status})`);
1883
+ const record = result;
1884
+ if (record.ok === true) return record.value;
1885
+ const error = record.error;
1886
+ if (error !== void 0 && typeof error.message === "string") throw new Error(error.message);
1887
+ throw new Error(`settings ${envelope.method}: failed (HTTP ${response.status})`);
1888
+ }
1889
+ /** Read one runtime's panel state, parsed. */
1890
+ async function fetchAuthView(agentKey, namespace, doFetch) {
1891
+ const view = parseAuthView(await callRuntimeSettings(agentKey, namespace, "get", {}, doFetch));
1892
+ if (view === void 0) throw new Error("settings: the runtime returned no usable auth options");
1893
+ return view;
1894
+ }
1895
+ /** Adopt one auth form (`null` clears the explicit choice). */
1896
+ async function setAuthMode(agentKey, namespace, mode, doFetch) {
1897
+ const view = parseAuthView(await callRuntimeSettings(agentKey, namespace, "set", { request: { mode } }, doFetch));
1898
+ if (view === void 0) throw new Error("settings: the runtime returned no usable auth options");
1899
+ return view;
1900
+ }
1901
+ function requireProvidersView(value) {
1902
+ const view = parseProvidersView(value);
1903
+ if (view === void 0) throw new Error("settings: the runtime returned no usable provider list");
1904
+ return view;
1905
+ }
1906
+ /** Read the multi-provider state of one runtime. */
1907
+ async function fetchProvidersView(agentKey, namespace, doFetch) {
1908
+ return requireProvidersView(await callRuntimeSettings(agentKey, namespace, "get", {}, doFetch));
1909
+ }
1910
+ /**
1911
+ * Add or edit one provider in the adapter's list. Which provider a session runs
1912
+ * on is DSH's own per-session model selection, so this touches no active half.
1913
+ */
1914
+ async function saveProvider(agentKey, namespace, provider, doFetch) {
1915
+ return requireProvidersView(await callRuntimeSettings(agentKey, namespace, "save", { request: { provider } }, doFetch));
1916
+ }
1917
+ /** Drop one provider from the list. Does not rewrite the runtime's own config. */
1918
+ async function removeProvider(agentKey, namespace, id, doFetch) {
1919
+ return requireProvidersView(await callRuntimeSettings(agentKey, namespace, "remove", { request: { id } }, doFetch));
1920
+ }
1921
+
1369
1922
  //#endregion
1370
1923
  //#region src/client/HubPage.tsx
1371
1924
  const EMPTY_DRAFT = {
1372
1925
  name: "",
1373
- url: ""
1926
+ tokenUrl: ""
1374
1927
  };
1375
- /** Chip text: drop the trailing slash for concision ('/claude/' → '/claude'). */
1376
- function displayPath(path) {
1377
- return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
1378
- }
1379
1928
  /** Shared chip look (status pills, path tags). */
1380
1929
  const chip = {
1381
1930
  fontSize: 10,
@@ -1394,6 +1943,144 @@ const chipPending = {
1394
1943
  ...chip,
1395
1944
  color: "var(--dsw-alias-label-caption)"
1396
1945
  };
1946
+ const chipWarn = {
1947
+ ...chip,
1948
+ color: "var(--dsw-alias-state-warn-primary)"
1949
+ };
1950
+ const chipError = {
1951
+ ...chip,
1952
+ color: "var(--dsw-alias-state-error-primary)"
1953
+ };
1954
+ /** Machine id chip (the m4): the monospace chip look the roster's path tags use. */
1955
+ const chipMonoId = {
1956
+ ...chip,
1957
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
1958
+ fontSize: 10.5
1959
+ };
1960
+ /** The status dot's fixed part (the color is decided per row). */
1961
+ const dotStyle = {
1962
+ width: 8,
1963
+ height: 8,
1964
+ borderRadius: "50%",
1965
+ flex: "none"
1966
+ };
1967
+ /** The machine origin column: monospace, eats the leftover row width. */
1968
+ const originStyle = {
1969
+ flex: 1,
1970
+ minWidth: 0,
1971
+ overflow: "hidden",
1972
+ textOverflow: "ellipsis",
1973
+ whiteSpace: "nowrap",
1974
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
1975
+ fontSize: 12,
1976
+ color: "var(--dsw-alias-label-secondary)"
1977
+ };
1978
+ /**
1979
+ * The row's switch control (P3: the `switch` word is a real BUTTON now — the
1980
+ * row body toggles the settings panel instead, so the switch needs its own
1981
+ * hit target that stops propagation).
1982
+ */
1983
+ const switchButtonStyle = {
1984
+ border: "none",
1985
+ background: "transparent",
1986
+ padding: 0,
1987
+ font: "inherit",
1988
+ fontSize: 12.5,
1989
+ color: "var(--dsw-alias-label-secondary)",
1990
+ whiteSpace: "nowrap"
1991
+ };
1992
+ /** The inline settings panel a row body expands into (P3 accordion). */
1993
+ const panelStyle = {
1994
+ listStyle: "none",
1995
+ margin: "0 -8px 4px",
1996
+ padding: "10px 12px 12px 42px",
1997
+ borderRadius: 12,
1998
+ background: "var(--dsw-alias-interactive-bg-hover)",
1999
+ fontSize: 12.5
2000
+ };
2001
+ /** The icon action (remove ✕) seat. */
2002
+ const iconActionStyle = {
2003
+ display: "inline-flex",
2004
+ alignItems: "center",
2005
+ justifyContent: "center",
2006
+ width: 22,
2007
+ height: 22,
2008
+ borderRadius: 6,
2009
+ border: "none",
2010
+ background: "transparent",
2011
+ color: "var(--dsw-alias-label-caption)",
2012
+ font: "inherit",
2013
+ cursor: "pointer"
2014
+ };
2015
+ /** The quiet text action (reprobe) — the switch/row-action look. */
2016
+ const textActionStyle = {
2017
+ border: "none",
2018
+ background: "transparent",
2019
+ padding: 0,
2020
+ font: "inherit",
2021
+ fontSize: 12.5,
2022
+ color: "var(--dsw-alias-label-secondary)",
2023
+ cursor: "pointer",
2024
+ whiteSpace: "nowrap"
2025
+ };
2026
+ /** The row's settings panel heading. */
2027
+ const panelHeadStyle = {
2028
+ margin: "0 0 6px",
2029
+ fontSize: 12,
2030
+ fontWeight: 500,
2031
+ color: "var(--dsw-alias-label-secondary)"
2032
+ };
2033
+ /** One auth-method option's row in the panel. */
2034
+ const optionStyle = {
2035
+ display: "flex",
2036
+ alignItems: "baseline",
2037
+ gap: 8,
2038
+ width: "100%",
2039
+ textAlign: "left",
2040
+ border: "none",
2041
+ background: "transparent",
2042
+ padding: "5px 6px",
2043
+ borderRadius: 8,
2044
+ font: "inherit",
2045
+ fontSize: 12.5,
2046
+ color: "var(--dsw-alias-label-primary)"
2047
+ };
2048
+ /** The status dot's color: reachable green, pending grey, unreachable amber, auth-expired red. */
2049
+ function statusDotColor(status) {
2050
+ if (status === "reachable") return "var(--dsw-alias-state-success-primary)";
2051
+ if (status === "auth-expired") return "var(--dsw-alias-state-error-primary)";
2052
+ if (status === "unreachable") return "var(--dsw-alias-state-warn-primary)";
2053
+ return "var(--dsw-alias-label-caption)";
2054
+ }
2055
+ /** The last-fetch caption's style (R7): quiet tertiary text beside the status chip. */
2056
+ const ageStyle = {
2057
+ fontSize: 11.5,
2058
+ color: "var(--dsw-alias-label-tertiary)",
2059
+ whiteSpace: "nowrap"
2060
+ };
2061
+ /** The status chip (style + text) for one remote row. */
2062
+ function statusChip(machine) {
2063
+ if (machine.status === "reachable") return {
2064
+ style: chipSelf,
2065
+ text: "reachable"
2066
+ };
2067
+ if (machine.status === "auth-expired") return {
2068
+ style: chipError,
2069
+ text: "auth expired"
2070
+ };
2071
+ if (machine.status === "unreachable") return {
2072
+ style: chipWarn,
2073
+ text: "unreachable"
2074
+ };
2075
+ return {
2076
+ style: chipPending,
2077
+ text: "pending"
2078
+ };
2079
+ }
2080
+ /** One line of error text for the panel's inline error line. */
2081
+ function errText(err) {
2082
+ return err instanceof Error ? err.message : String(err);
2083
+ }
1397
2084
  const inputStyle = {
1398
2085
  boxSizing: "border-box",
1399
2086
  width: "100%",
@@ -1420,11 +2107,27 @@ const listStyle = {
1420
2107
  flexDirection: "column",
1421
2108
  gap: 2
1422
2109
  };
1423
- /** A row that lights its surface on hover (inline styles have no :hover). */
1424
- function HoverRow({ children, onClick, clickable }) {
2110
+ /** The machine section head inside the roster list (the grouped shape's caption row). */
2111
+ const sectionHeadStyle = {
2112
+ padding: "8px 8px 2px",
2113
+ fontSize: 11,
2114
+ lineHeight: "16px",
2115
+ color: "var(--dsw-alias-label-caption)",
2116
+ whiteSpace: "nowrap",
2117
+ listStyle: "none"
2118
+ };
2119
+ /**
2120
+ * A row that lights its surface on hover (inline styles have no :hover).
2121
+ *
2122
+ * P3: the row BODY is the settings-panel toggle, not the switch — `expanded`
2123
+ * keeps the surface lit while its panel is open, so the open row stays
2124
+ * identifiable after the pointer leaves. The switch lives in the row's button.
2125
+ */
2126
+ function HoverRow({ children, onClick, clickable, expanded }) {
1425
2127
  const [hover, setHover] = react.useState(false);
1426
2128
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1427
2129
  onClick,
2130
+ "aria-expanded": expanded,
1428
2131
  onMouseEnter: () => {
1429
2132
  setHover(true);
1430
2133
  },
@@ -1439,7 +2142,7 @@ function HoverRow({ children, onClick, clickable }) {
1439
2142
  padding: "9px 8px",
1440
2143
  borderRadius: 12,
1441
2144
  listStyle: "none",
1442
- background: hover ? "var(--dsw-alias-interactive-bg-hover)" : "transparent",
2145
+ background: hover || expanded ? "var(--dsw-alias-interactive-bg-hover)" : "transparent",
1443
2146
  cursor: clickable ? "pointer" : void 0
1444
2147
  },
1445
2148
  children
@@ -1476,8 +2179,677 @@ function GroupHead({ title, count, action }) {
1476
2179
  ]
1477
2180
  });
1478
2181
  }
2182
+ /**
2183
+ * One runtime's settings, rendered inside its expanded row (P3/P4).
2184
+ *
2185
+ * The adapter owns the config, so this component owns no config knowledge: each
2186
+ * body asks the adapter's Remote and renders what comes back. The round trip
2187
+ * after a change is authoritative — the adapter re-reads the machine and
2188
+ * answers with the new state, which is why nothing is optimistically patched
2189
+ * here (a selection can fall through a ladder, or a switch can leave a provider
2190
+ * the runtime is still running).
2191
+ *
2192
+ * Mounted only while its row is open, so expanding always re-reads the
2193
+ * machine rather than replaying a stale first read.
2194
+ */
2195
+ function RuntimeSettingsPanel({ agent }) {
2196
+ const panel = settingsPanelFor(agent.key);
2197
+ if (panel === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2198
+ style: {
2199
+ margin: 0,
2200
+ color: "var(--dsw-alias-label-tertiary)"
2201
+ },
2202
+ children: "No settings for this runtime yet."
2203
+ });
2204
+ return panel.kind === "providers" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProvidersPanel, {
2205
+ agent,
2206
+ namespace: panel.namespace
2207
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AuthSettingsPanel, {
2208
+ agent,
2209
+ namespace: panel.namespace
2210
+ });
2211
+ }
2212
+ /**
2213
+ * The sign-in-form body (Antigravity): one form picked from the adapter's
2214
+ * ladder. `namespace` always resolves — the row would not mount this body
2215
+ * otherwise.
2216
+ */
2217
+ function AuthSettingsPanel({ agent, namespace }) {
2218
+ const [view, setView] = react.useState(void 0);
2219
+ const [error, setError] = react.useState(null);
2220
+ const [busy, setBusy] = react.useState(null);
2221
+ const [loading, setLoading] = react.useState(true);
2222
+ react.useEffect(() => {
2223
+ let live = true;
2224
+ setLoading(true);
2225
+ fetchAuthView(agent.key, namespace).then((next) => {
2226
+ if (live) {
2227
+ setView(next);
2228
+ setError(null);
2229
+ }
2230
+ }).catch((err) => {
2231
+ if (live) {
2232
+ setView(void 0);
2233
+ setError(messageOf(err));
2234
+ }
2235
+ }).finally(() => {
2236
+ if (live) setLoading(false);
2237
+ });
2238
+ return () => {
2239
+ live = false;
2240
+ };
2241
+ }, [agent.key, namespace]);
2242
+ const choose = (mode) => {
2243
+ if (busy !== null) return;
2244
+ setBusy(mode);
2245
+ setAuthMode(agent.key, namespace, mode).then((next) => {
2246
+ setView(next);
2247
+ setError(null);
2248
+ }).catch((err) => {
2249
+ setError(messageOf(err));
2250
+ }).finally(() => {
2251
+ setBusy(null);
2252
+ });
2253
+ };
2254
+ if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2255
+ style: {
2256
+ margin: 0,
2257
+ color: "var(--dsw-alias-label-tertiary)"
2258
+ },
2259
+ children: "Loading settings…"
2260
+ });
2261
+ if (view === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2262
+ style: {
2263
+ margin: 0,
2264
+ color: "var(--dsw-alias-state-warn-label, var(--dsw-alias-label-secondary))"
2265
+ },
2266
+ children: error ?? "Settings are unavailable for this runtime."
2267
+ });
2268
+ const current$1 = activeMethod(view);
2269
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2270
+ style: {
2271
+ display: "flex",
2272
+ flexDirection: "column",
2273
+ gap: 4
2274
+ },
2275
+ children: [
2276
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2277
+ style: panelHeadStyle,
2278
+ children: "Sign-in method"
2279
+ }),
2280
+ view.methods.map((option) => {
2281
+ const isCurrent = current$1?.key === option.key;
2282
+ const disabled = !selectable(option) || busy !== null;
2283
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2284
+ type: "button",
2285
+ role: "radio",
2286
+ "aria-checked": isCurrent,
2287
+ disabled,
2288
+ onClick: () => {
2289
+ choose(option.key);
2290
+ },
2291
+ style: {
2292
+ ...optionStyle,
2293
+ color: disabled ? "var(--dsw-alias-label-tertiary)" : "var(--dsw-alias-label-primary)",
2294
+ cursor: disabled ? "default" : "pointer",
2295
+ background: isCurrent ? "var(--dsw-alias-bg-elevated, transparent)" : "transparent"
2296
+ },
2297
+ children: [
2298
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2299
+ "aria-hidden": true,
2300
+ style: {
2301
+ width: 12,
2302
+ flex: "0 0 12px"
2303
+ },
2304
+ children: isCurrent ? "●" : "○"
2305
+ }),
2306
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2307
+ style: {
2308
+ fontWeight: 500,
2309
+ whiteSpace: "nowrap"
2310
+ },
2311
+ children: option.label
2312
+ }),
2313
+ isCurrent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2314
+ style: chipSelf,
2315
+ children: "in force"
2316
+ }),
2317
+ !option.available && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2318
+ style: chip,
2319
+ children: "not detected"
2320
+ }),
2321
+ option.placeholder && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2322
+ style: chip,
2323
+ children: "placeholder"
2324
+ }),
2325
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2326
+ style: {
2327
+ flex: 1,
2328
+ minWidth: 0,
2329
+ color: "var(--dsw-alias-label-tertiary)"
2330
+ },
2331
+ children: option.hint
2332
+ }),
2333
+ busy === option.key && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2334
+ style: chip,
2335
+ children: "applying…"
2336
+ })
2337
+ ]
2338
+ }, option.key);
2339
+ }),
2340
+ view.note !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2341
+ style: {
2342
+ margin: "2px 0 0",
2343
+ color: "var(--dsw-alias-label-tertiary)"
2344
+ },
2345
+ children: view.note
2346
+ }),
2347
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2348
+ style: {
2349
+ margin: "2px 0 0",
2350
+ color: "var(--dsw-alias-state-error-primary)"
2351
+ },
2352
+ children: error
2353
+ }),
2354
+ view.settingsPath !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2355
+ style: {
2356
+ margin: "4px 0 0",
2357
+ color: "var(--dsw-alias-label-caption)",
2358
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
2359
+ fontSize: 11
2360
+ },
2361
+ children: ["writes ", view.settingsPath]
2362
+ })
2363
+ ]
2364
+ });
2365
+ }
2366
+ /** Field and control styling for the providers body — same visual language as the auth list. */
2367
+ const fieldStyle = {
2368
+ display: "flex",
2369
+ flexDirection: "column",
2370
+ gap: 3,
2371
+ fontSize: 12.5,
2372
+ color: "var(--dsw-alias-label-secondary)"
2373
+ };
2374
+ const buttonStyle = {
2375
+ font: "inherit",
2376
+ fontSize: 12.5,
2377
+ padding: "5px 10px",
2378
+ borderRadius: 6,
2379
+ border: "1px solid var(--dsw-alias-border-secondary, rgba(127,127,127,0.3))",
2380
+ background: "transparent",
2381
+ color: "var(--dsw-alias-label-primary)",
2382
+ cursor: "pointer"
2383
+ };
2384
+ const primaryButtonStyle = {
2385
+ ...buttonStyle,
2386
+ border: "none",
2387
+ background: "var(--dsw-alias-label-primary)",
2388
+ color: "var(--dsw-alias-bg-base, #fff)",
2389
+ fontWeight: 500
2390
+ };
2391
+ /** The blank draft the Add form starts from. */
2392
+ const EMPTY_PROVIDER_DRAFT = {
2393
+ id: "",
2394
+ label: "",
2395
+ baseUrl: "",
2396
+ protocol: "responses",
2397
+ apiKey: "",
2398
+ envName: "",
2399
+ modelIds: "",
2400
+ contextWindow: ""
2401
+ };
2402
+ /** `a, b c` → `['a','b','c']` — the model field takes whatever separator is natural. */
2403
+ function parseModelIds(text) {
2404
+ return text.split(/[\s,]+/).map((part) => part.trim()).filter((part) => part !== "");
2405
+ }
2406
+ /** `provider / model`, whichever halves the user's config.toml actually names. */
2407
+ function nativeDescription(native) {
2408
+ const parts = [native.providerId, native.model].filter((part) => part !== void 0);
2409
+ return parts.length === 0 ? "no provider" : parts.join(" / ");
2410
+ }
2411
+ /**
2412
+ * The multi-provider body (Codex, 2026-10-03 ruling).
2413
+ *
2414
+ * Super D hosts the list cc-switch otherwise holds: add, edit and remove only.
2415
+ * The active/select half is gone — which provider a Codex session runs on is
2416
+ * DSH's own per-session model selection, so no row is marked "in force". What
2417
+ * the user's OWN config.toml names is rendered as a passive fact (the adapter
2418
+ * reconciles the list against that file), and the files it touches are named so
2419
+ * an edit is never a surprise.
2420
+ *
2421
+ * Keys are write-only by construction: the adapter answers `hasKey`, never a
2422
+ * value, so the field is blank on every open and blank means "leave whatever is
2423
+ * already there".
2424
+ */
2425
+ function ProvidersPanel({ agent, namespace }) {
2426
+ const [view, setView] = react.useState(void 0);
2427
+ const [error, setError] = react.useState(null);
2428
+ const [busy, setBusy] = react.useState(null);
2429
+ const [loading, setLoading] = react.useState(true);
2430
+ /** The id being edited, `NEW_PROVIDER` for the add form, `null` when closed. */
2431
+ const [editing, setEditing] = react.useState(null);
2432
+ const [draft, setDraft] = react.useState(EMPTY_PROVIDER_DRAFT);
2433
+ react.useEffect(() => {
2434
+ let live = true;
2435
+ setLoading(true);
2436
+ fetchProvidersView(agent.key, namespace).then((next) => {
2437
+ if (live) {
2438
+ setView(next);
2439
+ setError(null);
2440
+ }
2441
+ }).catch((err) => {
2442
+ if (live) {
2443
+ setView(void 0);
2444
+ setError(messageOf(err));
2445
+ }
2446
+ }).finally(() => {
2447
+ if (live) setLoading(false);
2448
+ });
2449
+ return () => {
2450
+ live = false;
2451
+ };
2452
+ }, [agent.key, namespace]);
2453
+ /** One mutation, one authoritative re-read; `key` drives the busy chip. */
2454
+ const run = (key, call) => {
2455
+ if (busy !== null) return;
2456
+ setBusy(key);
2457
+ call().then((next) => {
2458
+ setView(next);
2459
+ setError(null);
2460
+ setEditing(null);
2461
+ setDraft(EMPTY_PROVIDER_DRAFT);
2462
+ }).catch((err) => {
2463
+ setError(messageOf(err));
2464
+ }).finally(() => {
2465
+ setBusy(null);
2466
+ });
2467
+ };
2468
+ const openNew = () => {
2469
+ setEditing(NEW_PROVIDER);
2470
+ setDraft(EMPTY_PROVIDER_DRAFT);
2471
+ setError(null);
2472
+ };
2473
+ const openEdit = (provider) => {
2474
+ setEditing(provider.id);
2475
+ setDraft({
2476
+ id: provider.id,
2477
+ label: provider.label,
2478
+ baseUrl: provider.baseUrl,
2479
+ protocol: provider.protocol,
2480
+ apiKey: "",
2481
+ envName: provider.envName ?? "",
2482
+ modelIds: provider.models.map((model) => model.id).join(", "),
2483
+ contextWindow: provider.models[0]?.contextWindow === void 0 ? "" : String(provider.models[0].contextWindow)
2484
+ });
2485
+ setError(null);
2486
+ };
2487
+ const submit = () => {
2488
+ const ids = parseModelIds(draft.modelIds);
2489
+ const window$1 = draft.contextWindow.trim() === "" ? void 0 : Number(draft.contextWindow);
2490
+ const provider = {
2491
+ id: draft.id.trim(),
2492
+ label: draft.label.trim(),
2493
+ baseUrl: draft.baseUrl.trim(),
2494
+ protocol: draft.protocol,
2495
+ auth: draft.envName.trim() === "" ? {
2496
+ kind: "apiKey",
2497
+ value: draft.apiKey
2498
+ } : {
2499
+ kind: "env",
2500
+ name: draft.envName.trim()
2501
+ },
2502
+ models: ids.map((id) => ({
2503
+ id,
2504
+ ...window$1 !== void 0 && Number.isSafeInteger(window$1) && window$1 > 0 ? { contextWindow: window$1 } : {}
2505
+ }))
2506
+ };
2507
+ run("save", () => saveProvider(agent.key, namespace, provider));
2508
+ };
2509
+ if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2510
+ style: {
2511
+ margin: 0,
2512
+ color: "var(--dsw-alias-label-tertiary)"
2513
+ },
2514
+ children: "Loading providers…"
2515
+ });
2516
+ if (view === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2517
+ style: {
2518
+ margin: 0,
2519
+ color: "var(--dsw-alias-state-warn-label, var(--dsw-alias-label-secondary))"
2520
+ },
2521
+ children: error ?? "Providers are unavailable for this runtime."
2522
+ });
2523
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2524
+ style: {
2525
+ display: "flex",
2526
+ flexDirection: "column",
2527
+ gap: 6
2528
+ },
2529
+ children: [
2530
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2531
+ style: panelHeadStyle,
2532
+ children: "Model provider"
2533
+ }),
2534
+ view.native !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2535
+ style: {
2536
+ margin: 0,
2537
+ color: "var(--dsw-alias-label-tertiary)"
2538
+ },
2539
+ children: [
2540
+ "Your own Codex config.toml currently names ",
2541
+ nativeDescription(view.native),
2542
+ "."
2543
+ ]
2544
+ }),
2545
+ view.syncedAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2546
+ style: {
2547
+ margin: 0,
2548
+ color: "var(--dsw-alias-label-caption)",
2549
+ fontSize: 11
2550
+ },
2551
+ children: ["synced from config.toml ", new Date(view.syncedAt).toLocaleString()]
2552
+ }),
2553
+ view.providers.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2554
+ style: {
2555
+ margin: 0,
2556
+ color: "var(--dsw-alias-label-tertiary)"
2557
+ },
2558
+ children: "No providers yet — add one to pin a model and endpoint."
2559
+ }),
2560
+ view.providers.map((provider) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2561
+ style: optionStyle,
2562
+ children: [
2563
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2564
+ style: {
2565
+ fontWeight: 500,
2566
+ whiteSpace: "nowrap"
2567
+ },
2568
+ children: provider.label
2569
+ }),
2570
+ provider.authKind === "env" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2571
+ style: chip,
2572
+ children: ["env ", provider.envName]
2573
+ }),
2574
+ !provider.hasKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2575
+ style: chip,
2576
+ children: "no key"
2577
+ }),
2578
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2579
+ style: {
2580
+ flex: 1,
2581
+ minWidth: 0,
2582
+ overflow: "hidden",
2583
+ textOverflow: "ellipsis",
2584
+ whiteSpace: "nowrap",
2585
+ fontSize: 12,
2586
+ color: "var(--dsw-alias-label-tertiary)"
2587
+ },
2588
+ children: [provider.baseUrl, provider.models.length === 0 ? "" : ` · ${provider.models.map((model) => model.id).join(", ")}`]
2589
+ }),
2590
+ provider.models.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2591
+ style: chipWarn,
2592
+ children: "no models yet — add one"
2593
+ }),
2594
+ busy === `remove:${provider.id}` && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2595
+ style: chip,
2596
+ children: "removing…"
2597
+ }),
2598
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2599
+ type: "button",
2600
+ style: buttonStyle,
2601
+ disabled: busy !== null,
2602
+ onClick: () => {
2603
+ openEdit(provider);
2604
+ },
2605
+ children: "Edit"
2606
+ }),
2607
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2608
+ type: "button",
2609
+ style: {
2610
+ ...buttonStyle,
2611
+ color: "var(--dsw-alias-state-error-primary, #c66)"
2612
+ },
2613
+ disabled: busy !== null,
2614
+ "aria-label": `Delete ${provider.label}`,
2615
+ onClick: () => {
2616
+ run(`remove:${provider.id}`, () => removeProvider(agent.key, namespace, provider.id));
2617
+ },
2618
+ children: "Delete"
2619
+ })
2620
+ ]
2621
+ }, provider.id)),
2622
+ editing === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2623
+ type: "button",
2624
+ style: buttonStyle,
2625
+ disabled: busy !== null,
2626
+ onClick: openNew,
2627
+ children: "+ Add provider"
2628
+ }) }),
2629
+ editing !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2630
+ style: {
2631
+ display: "flex",
2632
+ flexDirection: "column",
2633
+ gap: 8,
2634
+ maxWidth: 520
2635
+ },
2636
+ children: [
2637
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2638
+ style: panelHeadStyle,
2639
+ children: editing === NEW_PROVIDER ? "Add provider" : `Edit ${editing}`
2640
+ }),
2641
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2642
+ style: fieldStyle,
2643
+ children: ["Provider id", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2644
+ style: inputStyle,
2645
+ value: draft.id,
2646
+ disabled: editing !== NEW_PROVIDER,
2647
+ placeholder: "zai-plan",
2648
+ onChange: (event) => {
2649
+ setDraft({
2650
+ ...draft,
2651
+ id: event.target.value
2652
+ });
2653
+ }
2654
+ })]
2655
+ }),
2656
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2657
+ style: fieldStyle,
2658
+ children: ["Display name", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2659
+ style: inputStyle,
2660
+ value: draft.label,
2661
+ placeholder: "Z.ai Plan",
2662
+ onChange: (event) => {
2663
+ setDraft({
2664
+ ...draft,
2665
+ label: event.target.value
2666
+ });
2667
+ }
2668
+ })]
2669
+ }),
2670
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2671
+ style: fieldStyle,
2672
+ children: ["Base URL", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2673
+ style: inputStyle,
2674
+ value: draft.baseUrl,
2675
+ placeholder: "https://api.z.ai/api/coding/paas/v4",
2676
+ onChange: (event) => {
2677
+ setDraft({
2678
+ ...draft,
2679
+ baseUrl: event.target.value
2680
+ });
2681
+ }
2682
+ })]
2683
+ }),
2684
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2685
+ style: fieldStyle,
2686
+ children: ["API protocol", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
2687
+ style: inputStyle,
2688
+ value: draft.protocol,
2689
+ onChange: (event) => {
2690
+ setDraft({
2691
+ ...draft,
2692
+ protocol: event.target.value
2693
+ });
2694
+ },
2695
+ children: view.protocols.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
2696
+ value: option.value,
2697
+ disabled: !option.available,
2698
+ title: option.hint,
2699
+ children: [option.label, option.available ? "" : " — unsupported"]
2700
+ }, option.value))
2701
+ })]
2702
+ }),
2703
+ (() => {
2704
+ const option = view.protocols.find((candidate) => candidate.value === draft.protocol);
2705
+ return option === void 0 || option.available ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2706
+ style: {
2707
+ margin: 0,
2708
+ color: "var(--dsw-alias-state-error-primary, #c66)",
2709
+ fontSize: 12
2710
+ },
2711
+ children: option.hint
2712
+ });
2713
+ })(),
2714
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2715
+ style: fieldStyle,
2716
+ children: ["Model IDs", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2717
+ style: inputStyle,
2718
+ value: draft.modelIds,
2719
+ placeholder: "glm-5.2, glm-5.2-air",
2720
+ onChange: (event) => {
2721
+ setDraft({
2722
+ ...draft,
2723
+ modelIds: event.target.value
2724
+ });
2725
+ }
2726
+ })]
2727
+ }),
2728
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2729
+ style: fieldStyle,
2730
+ children: ["Context window (tokens, optional)", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2731
+ style: inputStyle,
2732
+ value: draft.contextWindow,
2733
+ inputMode: "numeric",
2734
+ placeholder: "1000000",
2735
+ onChange: (event) => {
2736
+ setDraft({
2737
+ ...draft,
2738
+ contextWindow: event.target.value
2739
+ });
2740
+ }
2741
+ })]
2742
+ }),
2743
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2744
+ style: fieldStyle,
2745
+ children: [
2746
+ "API key ",
2747
+ editing !== NEW_PROVIDER && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2748
+ style: { color: "var(--dsw-alias-label-caption)" },
2749
+ children: "(leave blank to keep the saved one)"
2750
+ }),
2751
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2752
+ style: inputStyle,
2753
+ type: "password",
2754
+ value: draft.apiKey,
2755
+ autoComplete: "off",
2756
+ onChange: (event) => {
2757
+ setDraft({
2758
+ ...draft,
2759
+ apiKey: event.target.value
2760
+ });
2761
+ }
2762
+ })
2763
+ ]
2764
+ }),
2765
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2766
+ style: fieldStyle,
2767
+ children: ["…or read the key from an environment variable", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2768
+ style: inputStyle,
2769
+ value: draft.envName,
2770
+ placeholder: "DEEPSEEK_API_KEY",
2771
+ onChange: (event) => {
2772
+ setDraft({
2773
+ ...draft,
2774
+ envName: event.target.value
2775
+ });
2776
+ }
2777
+ })]
2778
+ }),
2779
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2780
+ style: {
2781
+ display: "flex",
2782
+ gap: 6
2783
+ },
2784
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2785
+ type: "button",
2786
+ style: primaryButtonStyle,
2787
+ disabled: busy !== null,
2788
+ onClick: submit,
2789
+ children: busy === "save" ? "Saving…" : "Save"
2790
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2791
+ type: "button",
2792
+ style: buttonStyle,
2793
+ disabled: busy !== null,
2794
+ onClick: () => {
2795
+ setEditing(null);
2796
+ setDraft(EMPTY_PROVIDER_DRAFT);
2797
+ },
2798
+ children: "Cancel"
2799
+ })]
2800
+ })
2801
+ ]
2802
+ }),
2803
+ view.note !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2804
+ style: {
2805
+ margin: "2px 0 0",
2806
+ color: "var(--dsw-alias-label-tertiary)"
2807
+ },
2808
+ children: view.note
2809
+ }),
2810
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2811
+ style: {
2812
+ margin: "2px 0 0",
2813
+ color: "var(--dsw-alias-state-error-primary)"
2814
+ },
2815
+ children: error
2816
+ }),
2817
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2818
+ style: {
2819
+ margin: "4px 0 0",
2820
+ color: "var(--dsw-alias-label-caption)",
2821
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
2822
+ fontSize: 11
2823
+ },
2824
+ children: ["list ", view.paths.store]
2825
+ }),
2826
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2827
+ style: {
2828
+ margin: 0,
2829
+ color: "var(--dsw-alias-label-caption)",
2830
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
2831
+ fontSize: 11
2832
+ },
2833
+ children: [
2834
+ "native ",
2835
+ view.paths.config,
2836
+ " · ",
2837
+ view.paths.auth,
2838
+ " · ",
2839
+ view.paths.catalogs
2840
+ ]
2841
+ })
2842
+ ]
2843
+ });
2844
+ }
2845
+ /** Sentinel for "the add form", distinct from any real provider id. */
2846
+ const NEW_PROVIDER = "\0new";
1479
2847
  function HubPage() {
1480
- const [machines, setMachines] = react.useState(() => loadMachines());
2848
+ const [mesh, setMesh] = react.useState({ machines: [] });
2849
+ const [meshLoaded, setMeshLoaded] = react.useState(false);
2850
+ const [meshError, setMeshError] = react.useState(null);
2851
+ const [meshBusy, setMeshBusy] = react.useState(false);
2852
+ const [meshReloads, setMeshReloads] = react.useState(0);
1481
2853
  const [showAdd, setShowAdd] = react.useState(false);
1482
2854
  const [draft, setDraft] = react.useState(EMPTY_DRAFT);
1483
2855
  const [agents, setAgents] = react.useState(() => rosterFromGlobal() ?? null);
@@ -1486,6 +2858,11 @@ function HubPage() {
1486
2858
  const fusion = fusionPage();
1487
2859
  const switchUi = switchAffordance(fusion);
1488
2860
  const [activeKey, setActiveKey] = react.useState(() => fusion ? uiState()?.activeAgent : void 0);
2861
+ /**
2862
+ * The open settings panel (P3 accordion): one runtime key at a time, or
2863
+ * `null` when every row is collapsed. `toggleExpanded` owns the transition.
2864
+ */
2865
+ const [expandedKey, setExpandedKey] = react.useState(null);
1489
2866
  react.useEffect(() => {
1490
2867
  let cancelled = false;
1491
2868
  fetchRoster().then((list) => {
@@ -1503,6 +2880,24 @@ function HubPage() {
1503
2880
  cancelled = true;
1504
2881
  };
1505
2882
  }, []);
2883
+ react.useEffect(() => {
2884
+ let cancelled = false;
2885
+ fetchMachines().then((list) => {
2886
+ if (!cancelled) {
2887
+ setMesh(list);
2888
+ setMeshError(null);
2889
+ setMeshLoaded(true);
2890
+ }
2891
+ }).catch((err) => {
2892
+ if (!cancelled) {
2893
+ setMeshError(errText(err));
2894
+ setMeshLoaded(true);
2895
+ }
2896
+ });
2897
+ return () => {
2898
+ cancelled = true;
2899
+ };
2900
+ }, [meshReloads]);
1506
2901
  react.useEffect(() => {
1507
2902
  if (!fusion) return;
1508
2903
  const state = uiState();
@@ -1512,6 +2907,7 @@ function HubPage() {
1512
2907
  });
1513
2908
  }, [fusion]);
1514
2909
  const here = currentMountPath();
2910
+ const hereOrigin = typeof location === "undefined" ? "" : location.origin;
1515
2911
  const isActive = (agent) => hubRowActive({
1516
2912
  fusion,
1517
2913
  agentKey: agent.key,
@@ -1534,30 +2930,116 @@ function HubPage() {
1534
2930
  attempt: () => attemptSwitch(agent.key)
1535
2931
  }).preventDefault) event.preventDefault();
1536
2932
  };
1537
- const persist = (next) => {
1538
- const list = [...next];
1539
- setMachines(list);
1540
- saveMachines(list);
2933
+ const machineLabels = meshLoaded && meshError === null ? machineLabelsFrom(mesh) : void 0;
2934
+ const groups = agents !== null && machineLabels !== void 0 ? groupByMachine(agents, machineLabels) : void 0;
2935
+ /**
2936
+ * One Agent Runtimes row — the SAME row in both shapes; `showMachine`
2937
+ * keeps the flat fallback's per-row machine text (the grouped shape moves
2938
+ * it onto the section head).
2939
+ *
2940
+ * P3 interaction (2026-10-02 user ruling): the ROW BODY expands this
2941
+ * runtime's OWN settings inline (accordion — one panel at a time), and the
2942
+ * right-hand `switch` is the row's ONLY switch, now a real button. The two
2943
+ * are separate controls on purpose: expanding is navigation of config, the
2944
+ * button performs `seatClickDecision` (intercept + in-place switchAgent).
2945
+ */
2946
+ const renderRow = (agent, showMachine) => {
2947
+ const expanded = expandedKey === agent.key;
2948
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HoverRow, {
2949
+ clickable: true,
2950
+ expanded,
2951
+ onClick: () => {
2952
+ setExpandedKey((current$1) => toggleExpanded(current$1, agent.key));
2953
+ },
2954
+ children: [
2955
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeMark, {
2956
+ agentKey: agent.key,
2957
+ size: 20
2958
+ }),
2959
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2960
+ style: {
2961
+ fontWeight: 500,
2962
+ whiteSpace: "nowrap"
2963
+ },
2964
+ children: agent.label
2965
+ }),
2966
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2967
+ style: {
2968
+ flex: 1,
2969
+ minWidth: 0,
2970
+ overflow: "hidden",
2971
+ textOverflow: "ellipsis",
2972
+ whiteSpace: "nowrap",
2973
+ fontSize: 12.5,
2974
+ color: "var(--dsw-alias-label-tertiary)"
2975
+ },
2976
+ children: showMachine ? agent.machine : null
2977
+ }),
2978
+ isActive(agent) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2979
+ style: chipSelf,
2980
+ children: "current"
2981
+ }),
2982
+ switchUi.available && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2983
+ type: "button",
2984
+ "aria-current": isActive(agent) ? "page" : void 0,
2985
+ "aria-label": isActive(agent) ? `${agent.label} is current` : `Switch to ${agent.label}`,
2986
+ style: {
2987
+ ...switchButtonStyle,
2988
+ color: isActive(agent) ? "var(--dsw-alias-label-tertiary)" : "var(--dsw-alias-label-secondary)",
2989
+ cursor: "pointer"
2990
+ },
2991
+ onClick: (event) => {
2992
+ event.stopPropagation();
2993
+ rowDecision(agent, event);
2994
+ },
2995
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.IconPlayOutlineRegular, { size: 16 })
2996
+ })
2997
+ ]
2998
+ }), expanded && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
2999
+ style: panelStyle,
3000
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeSettingsPanel, { agent })
3001
+ })] }, agent.key);
3002
+ };
3003
+ /** Bump the reload sequence — every mutating op refreshes through the API. */
3004
+ const reloadMachines = () => {
3005
+ setMeshReloads((n) => n + 1);
1541
3006
  };
1542
- const addMachine = () => {
3007
+ const addRemote = () => {
1543
3008
  const name = draft.name.trim();
1544
- const url = draft.url.trim();
1545
- if (name === "" || url === "") return;
1546
- persist([...machines, {
1547
- id: freshMachineId(),
3009
+ const tokenUrl = draft.tokenUrl.trim();
3010
+ if (name === "" || !validTokenUrl(tokenUrl)) return;
3011
+ setMeshBusy(true);
3012
+ addMachine({
1548
3013
  name,
1549
- label: name,
1550
- url,
1551
- self: false,
1552
- addedAt: Date.now()
1553
- }]);
1554
- setDraft(EMPTY_DRAFT);
1555
- setShowAdd(false);
3014
+ tokenUrl
3015
+ }).then(() => {
3016
+ setDraft(EMPTY_DRAFT);
3017
+ setShowAdd(false);
3018
+ setMeshError(null);
3019
+ reloadMachines();
3020
+ }).catch((err) => {
3021
+ setMeshError(errText(err));
3022
+ }).finally(() => {
3023
+ setMeshBusy(false);
3024
+ });
3025
+ };
3026
+ const removeRemote = (id) => {
3027
+ removeMachine(id).then(() => {
3028
+ setMeshError(null);
3029
+ reloadMachines();
3030
+ }).catch((err) => {
3031
+ setMeshError(errText(err));
3032
+ });
1556
3033
  };
1557
- const removeMachine = (id) => {
1558
- persist(machines.filter((machine) => machine.id !== id));
3034
+ const reprobeRemote = (id) => {
3035
+ reprobeMachine(id).then(() => {
3036
+ setMeshError(null);
3037
+ reloadMachines();
3038
+ }).catch((err) => {
3039
+ setMeshError(errText(err));
3040
+ });
1559
3041
  };
1560
- const draftValid = draft.name.trim() !== "" && draft.url.trim() !== "";
3042
+ const draftValid = draft.name.trim() !== "" && validTokenUrl(draft.tokenUrl.trim());
1561
3043
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1562
3044
  style: {
1563
3045
  display: "flex",
@@ -1685,7 +3167,7 @@ function HubPage() {
1685
3167
  children: [
1686
3168
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupHead, {
1687
3169
  title: "Machines",
1688
- count: machines.length,
3170
+ count: (mesh.self !== void 0 ? 1 : 0) + mesh.machines.length,
1689
3171
  action: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1690
3172
  type: "button",
1691
3173
  onClick: () => {
@@ -1719,90 +3201,152 @@ function HubPage() {
1719
3201
  }), "Add machine"]
1720
3202
  })
1721
3203
  }),
1722
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3204
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1723
3205
  style: {
1724
3206
  margin: 0,
1725
3207
  fontSize: 13,
1726
3208
  lineHeight: "20px",
1727
3209
  color: "var(--dsw-alias-label-tertiary)"
1728
3210
  },
1729
- children: "Add another DSH from remote machines, provide the token URL."
3211
+ children: [
3212
+ "Add another DSH from remote machines, provide the token URL. Status ",
3213
+ AUTO_REFRESH_NOTE,
3214
+ "."
3215
+ ]
1730
3216
  }),
1731
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
3217
+ meshError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3218
+ style: {
3219
+ margin: 0,
3220
+ fontSize: 12.5,
3221
+ lineHeight: "20px",
3222
+ color: "var(--dsw-alias-state-error-primary)"
3223
+ },
3224
+ children: meshError
3225
+ }),
3226
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
1732
3227
  style: listStyle,
1733
- children: machines.map((machine) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HoverRow, { children: [
1734
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1735
- "aria-hidden": true,
1736
- style: {
1737
- width: 8,
1738
- height: 8,
1739
- borderRadius: "50%",
1740
- flex: "none",
1741
- background: machine.self ? "var(--dsw-alias-state-success-primary)" : "var(--dsw-alias-label-caption)"
1742
- }
1743
- }),
1744
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3228
+ children: [
3229
+ !meshLoaded && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1745
3230
  style: {
1746
- fontWeight: 500,
1747
- whiteSpace: "nowrap"
3231
+ padding: "9px 8px",
3232
+ fontSize: 13,
3233
+ color: "var(--dsw-alias-label-tertiary)",
3234
+ listStyle: "none"
1748
3235
  },
1749
- children: machine.name
1750
- }),
1751
- machine.label !== machine.name && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1752
- style: chip,
1753
- children: machine.label
3236
+ children: "Loading machines…"
1754
3237
  }),
1755
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3238
+ meshLoaded && meshError === null && mesh.machines.length === 0 && mesh.self === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1756
3239
  style: {
1757
- flex: 1,
1758
- minWidth: 0,
1759
- overflow: "hidden",
1760
- textOverflow: "ellipsis",
1761
- whiteSpace: "nowrap",
1762
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
1763
- fontSize: 12,
1764
- color: "var(--dsw-alias-label-secondary)"
3240
+ padding: "9px 8px",
3241
+ fontSize: 13,
3242
+ color: "var(--dsw-alias-label-tertiary)",
3243
+ listStyle: "none"
1765
3244
  },
1766
- children: machine.url
3245
+ children: "No machines yet — add the first one with its token URL."
1767
3246
  }),
1768
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1769
- style: machine.self ? chipSelf : chipPending,
1770
- children: machine.self ? "self" : "link pending"
1771
- }),
1772
- !machine.self && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1773
- type: "button",
1774
- "aria-label": `Remove ${machine.name}`,
1775
- onClick: () => {
1776
- removeMachine(machine.id);
1777
- },
1778
- style: {
1779
- display: "inline-flex",
1780
- alignItems: "center",
1781
- justifyContent: "center",
1782
- width: 22,
1783
- height: 22,
1784
- borderRadius: 6,
1785
- border: "none",
1786
- background: "transparent",
1787
- color: "var(--dsw-alias-label-caption)",
1788
- font: "inherit",
1789
- cursor: "pointer"
1790
- },
1791
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1792
- width: "11",
1793
- height: "11",
1794
- viewBox: "0 0 11 11",
1795
- fill: "none",
1796
- "aria-hidden": "true",
1797
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1798
- d: "M2.5 2.5L8.5 8.5M8.5 2.5L2.5 8.5",
1799
- stroke: "currentColor",
1800
- strokeWidth: "1.4",
1801
- strokeLinecap: "round"
1802
- })
3247
+ mesh.self !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HoverRow, { children: [
3248
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3249
+ "aria-hidden": true,
3250
+ style: {
3251
+ ...dotStyle,
3252
+ background: "var(--dsw-alias-state-success-primary)"
3253
+ }
3254
+ }),
3255
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3256
+ style: {
3257
+ fontWeight: 500,
3258
+ whiteSpace: "nowrap"
3259
+ },
3260
+ children: mesh.self.label
3261
+ }),
3262
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3263
+ style: originStyle,
3264
+ children: hereOrigin
3265
+ }),
3266
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3267
+ style: chipMonoId,
3268
+ children: mesh.self.id
3269
+ }),
3270
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3271
+ style: chipSelf,
3272
+ children: "self"
1803
3273
  })
3274
+ ] }),
3275
+ mesh.machines.map((machine) => {
3276
+ const status = statusChip(machine);
3277
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HoverRow, { children: [
3278
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3279
+ "aria-hidden": true,
3280
+ style: {
3281
+ ...dotStyle,
3282
+ background: statusDotColor(machine.status)
3283
+ }
3284
+ }),
3285
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3286
+ style: {
3287
+ fontWeight: 500,
3288
+ whiteSpace: "nowrap"
3289
+ },
3290
+ children: machine.name
3291
+ }),
3292
+ machine.label !== machine.name && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3293
+ style: chip,
3294
+ children: machine.label
3295
+ }),
3296
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3297
+ style: originStyle,
3298
+ children: machine.origin
3299
+ }),
3300
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3301
+ style: chipMonoId,
3302
+ children: machine.id
3303
+ }),
3304
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3305
+ style: status.style,
3306
+ children: status.text
3307
+ }),
3308
+ lastFetchLabel(machine.lastProbeAt, Date.now()) !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3309
+ style: ageStyle,
3310
+ children: lastFetchLabel(machine.lastProbeAt, Date.now())
3311
+ }),
3312
+ machineVersionChip(machine) !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3313
+ style: chipWarn,
3314
+ title: `machine ${machine.id}`,
3315
+ children: machine.versionWarning
3316
+ }),
3317
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3318
+ type: "button",
3319
+ "aria-label": `Refresh ${machine.name}`,
3320
+ onClick: () => {
3321
+ reprobeRemote(machine.id);
3322
+ },
3323
+ style: textActionStyle,
3324
+ children: "refresh"
3325
+ }),
3326
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3327
+ type: "button",
3328
+ "aria-label": `Remove ${machine.name}`,
3329
+ onClick: () => {
3330
+ removeRemote(machine.id);
3331
+ },
3332
+ style: iconActionStyle,
3333
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
3334
+ width: "11",
3335
+ height: "11",
3336
+ viewBox: "0 0 11 11",
3337
+ fill: "none",
3338
+ "aria-hidden": "true",
3339
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3340
+ d: "M2.5 2.5L8.5 8.5M8.5 2.5L2.5 8.5",
3341
+ stroke: "currentColor",
3342
+ strokeWidth: "1.4",
3343
+ strokeLinecap: "round"
3344
+ })
3345
+ })
3346
+ })
3347
+ ] }, machine.id);
1804
3348
  })
1805
- ] }, machine.id))
3349
+ ]
1806
3350
  }),
1807
3351
  showAdd && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1808
3352
  style: {
@@ -1831,15 +3375,15 @@ function HubPage() {
1831
3375
  })] }),
1832
3376
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1833
3377
  style: fieldLabel,
1834
- children: "URL"
3378
+ children: "Token URL"
1835
3379
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1836
3380
  style: inputStyle,
1837
- value: draft.url,
1838
- placeholder: "http://192.168.31.130:4999",
3381
+ value: draft.tokenUrl,
3382
+ placeholder: "https://192.168.31.130:4999/?token=…",
1839
3383
  onChange: (event) => {
1840
3384
  setDraft({
1841
3385
  ...draft,
1842
- url: event.target.value
3386
+ tokenUrl: event.target.value
1843
3387
  });
1844
3388
  }
1845
3389
  })] }),
@@ -1869,9 +3413,9 @@ function HubPage() {
1869
3413
  children: "Cancel"
1870
3414
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1871
3415
  type: "button",
1872
- disabled: !draftValid,
3416
+ disabled: !draftValid || meshBusy,
1873
3417
  onClick: () => {
1874
- addMachine();
3418
+ addRemote();
1875
3419
  },
1876
3420
  style: {
1877
3421
  padding: "7px 14px",
@@ -1922,71 +3466,23 @@ function HubPage() {
1922
3466
  }),
1923
3467
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
1924
3468
  style: listStyle,
1925
- children: [agents === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1926
- style: {
1927
- padding: "9px 8px",
1928
- fontSize: 13,
1929
- color: "var(--dsw-alias-label-tertiary)",
1930
- listStyle: "none"
1931
- },
1932
- children: "Loading roster…"
1933
- }), agents?.map((agent) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HoverRow, {
1934
- clickable: switchUi.available,
1935
- onClick: switchUi.available ? (event) => {
1936
- rowDecision(agent, event);
1937
- } : void 0,
1938
- children: [
1939
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeMark, {
1940
- agentKey: agent.key,
1941
- size: 20
1942
- }),
1943
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1944
- style: {
1945
- fontWeight: 500,
1946
- whiteSpace: "nowrap"
1947
- },
1948
- children: agent.label
1949
- }),
1950
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1951
- style: {
1952
- flex: 1,
1953
- minWidth: 0,
1954
- overflow: "hidden",
1955
- textOverflow: "ellipsis",
1956
- whiteSpace: "nowrap",
1957
- fontSize: 12.5,
1958
- color: "var(--dsw-alias-label-tertiary)"
1959
- },
1960
- children: agent.machine
1961
- }),
1962
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1963
- style: {
1964
- ...chip,
1965
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
1966
- fontSize: 10.5
1967
- },
1968
- children: displayPath(agent.path)
1969
- }),
1970
- isActive(agent) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1971
- style: chipSelf,
1972
- children: "current"
1973
- }),
1974
- switchUi.available && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1975
- "aria-current": isActive(agent) ? "page" : void 0,
1976
- style: {
1977
- fontSize: 12.5,
1978
- color: "var(--dsw-alias-label-secondary)",
1979
- textDecoration: "none",
1980
- cursor: "pointer"
1981
- },
1982
- onClick: (event) => {
1983
- event.stopPropagation();
1984
- rowDecision(agent, event);
1985
- },
1986
- children: "switch"
1987
- })
1988
- ]
1989
- }, agent.key))]
3469
+ children: [
3470
+ agents === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
3471
+ style: {
3472
+ padding: "9px 8px",
3473
+ fontSize: 13,
3474
+ color: "var(--dsw-alias-label-tertiary)",
3475
+ listStyle: "none"
3476
+ },
3477
+ children: "Loading roster…"
3478
+ }),
3479
+ groups !== void 0 && groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
3480
+ "aria-hidden": true,
3481
+ style: sectionHeadStyle,
3482
+ children: group.label
3483
+ }), group.agents.map((agent) => renderRow(agent, false))] }, group.key)),
3484
+ groups === void 0 && agents?.map((agent) => renderRow(agent, true))
3485
+ ]
1990
3486
  })
1991
3487
  ]
1992
3488
  })] })
@@ -2046,6 +3542,7 @@ function HubPanelIcon({ size }) {
2046
3542
  const [hover, setHover] = react.useState(false);
2047
3543
  const [box, setBox] = react.useState(null);
2048
3544
  const [agents, setAgents] = react.useState(() => rosterFromGlobal() ?? [NATIVE_LINK]);
3545
+ const [machineLabels, setMachineLabels] = react.useState(void 0);
2049
3546
  const fusion = fusionPage();
2050
3547
  const switchUi = switchAffordance(fusion);
2051
3548
  const [activeKey, setActiveKey] = react.useState(() => fusion ? uiState()?.activeAgent : void 0);
@@ -2097,6 +3594,9 @@ function HubPanelIcon({ size }) {
2097
3594
  fetchRoster().then((list) => {
2098
3595
  if (!cancelled) setAgents(list);
2099
3596
  }).catch(() => {});
3597
+ fetchMachines().then((list) => {
3598
+ if (!cancelled) setMachineLabels(machineLabelsFrom(list));
3599
+ }).catch(() => {});
2100
3600
  return () => {
2101
3601
  cancelled = true;
2102
3602
  };
@@ -2119,15 +3619,15 @@ function HubPanelIcon({ size }) {
2119
3619
  setOpen((value) => !value);
2120
3620
  };
2121
3621
  const items = [];
2122
- machineGroups(agents).forEach((group, groupIndex) => {
3622
+ if (machineLabels !== void 0) groupByMachine(agents, machineLabels).forEach((group, groupIndex) => {
2123
3623
  if (groupIndex > 0) items.push({
2124
3624
  type: "separator",
2125
- id: `machine-divider:${group.machine}`
3625
+ id: `machine-divider:${group.key}`
2126
3626
  });
2127
3627
  items.push({
2128
3628
  type: "label",
2129
- id: `machine:${group.machine}`,
2130
- text: group.machine
3629
+ id: `machine:${group.key}`,
3630
+ text: group.label
2131
3631
  });
2132
3632
  for (const agent of group.agents) items.push({
2133
3633
  id: agent.key,
@@ -2138,6 +3638,14 @@ function HubPanelIcon({ size }) {
2138
3638
  })
2139
3639
  });
2140
3640
  });
3641
+ else for (const agent of agents) items.push({
3642
+ id: agent.key,
3643
+ label: agent.label,
3644
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeMark, {
3645
+ agentKey: agent.key,
3646
+ size: 14
3647
+ })
3648
+ });
2141
3649
  /**
2142
3650
  * A menu pick. The row is a `menuitem` button — there is no anchor default
2143
3651
  * to cancel — but the shared table still owns whether the attempt runs
@@ -2253,8 +3761,7 @@ function apply(ctx) {
2253
3761
  "connection",
2254
3762
  "uiWorkspace",
2255
3763
  "workspaces",
2256
- "sessions",
2257
- "locale"
3764
+ "sessions"
2258
3765
  ], (raw) => {
2259
3766
  bindSwitchAgent(raw);
2260
3767
  });