super-dsh 0.1.9 → 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 (166) 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 +1115 -93
  150. package/cordis.patch.yml +64 -0
  151. package/package.json +17 -7
  152. package/superd-hub/dist/client/agent-settings.d.ts +156 -0
  153. package/superd-hub/dist/client/agent-settings.js +229 -0
  154. package/superd-hub/dist/client/roster.js +6 -0
  155. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  156. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  157. package/superd-hub/dist/client/switch.d.ts +165 -0
  158. package/superd-hub/dist/client/switch.js +295 -0
  159. package/superd-hub/lib/client/index.js +1115 -93
  160. package/agent-codex/dist/models.js +0 -152
  161. package/agent-omp/dist/sidecar-client.js +0 -195
  162. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  163. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  164. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  165. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  166. /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) {
@@ -1446,14 +1450,43 @@ function reportMachineDown(label, row) {
1446
1450
  clearTimeout: (handle) => globalThis.clearTimeout(handle)
1447
1451
  });
1448
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
+ }
1449
1482
  /** The bound `switchAgent`, or `undefined` until the entry binds it. */
1450
1483
  let bound;
1451
1484
  /**
1452
1485
  * Bind the page's switch agent from the client services. Idempotent; a no-op
1453
1486
  * without the page atom (a non-fusion page never has one).
1454
- * @param deps - the `connection`, `uiWorkspace`, `workspaces`, `sessions`
1455
- * and `locale` services (structural; the stock client tree always has all
1456
- * 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).
1457
1490
  */
1458
1491
  function bindSwitchAgent(deps) {
1459
1492
  if (bound !== void 0) return;
@@ -1474,19 +1507,6 @@ function bindSwitchAgent(deps) {
1474
1507
  }
1475
1508
  };
1476
1509
  };
1477
- const openDefaultWorkspace = () => {
1478
- const language = deps.locale.getSnapshot().active.toLowerCase().split("-")[0];
1479
- const title = language === "zh" ? "默认工作区" : "Default workspace";
1480
- const directoryName = language === "zh" || language === "en" ? title : "default-workspace";
1481
- deps.workspaces.initializeDefault({
1482
- directoryName,
1483
- title
1484
- }).then((prepared) => {
1485
- if (prepared !== void 0) deps.uiWorkspace.openWorkspace(prepared.workspaceId);
1486
- }).catch(() => {
1487
- showToast("Super D: unable to create the default workspace.");
1488
- });
1489
- };
1490
1510
  const controller = createSwitchController({
1491
1511
  setAgent(label) {
1492
1512
  state.setAgent(label);
@@ -1501,7 +1521,7 @@ function bindSwitchAgent(deps) {
1501
1521
  startSession(workspaceId) {
1502
1522
  deps.uiWorkspace.startSession(workspaceId);
1503
1523
  },
1504
- openDefaultWorkspace,
1524
+ openDefaultWorkspace: openDefaultWorkspaceFor(deps, showToast),
1505
1525
  readRestoreCaches,
1506
1526
  onCachesRefreshed(listener, gate) {
1507
1527
  return observeCachesRefreshed(deps.workspaces.list, {
@@ -1619,16 +1639,292 @@ function attemptSwitch(label) {
1619
1639
  return true;
1620
1640
  }
1621
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
+
1622
1922
  //#endregion
1623
1923
  //#region src/client/HubPage.tsx
1624
1924
  const EMPTY_DRAFT = {
1625
1925
  name: "",
1626
1926
  tokenUrl: ""
1627
1927
  };
1628
- /** Chip text: drop the trailing slash for concision ('/claude/' → '/claude'). */
1629
- function displayPath(path) {
1630
- return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
1631
- }
1632
1928
  /** Shared chip look (status pills, path tags). */
1633
1929
  const chip = {
1634
1930
  fontSize: 10,
@@ -1679,17 +1975,29 @@ const originStyle = {
1679
1975
  fontSize: 12,
1680
1976
  color: "var(--dsw-alias-label-secondary)"
1681
1977
  };
1682
- /** The quiet text action (reprobe) — the switch link's look. */
1683
- const textActionStyle = {
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 = {
1684
1984
  border: "none",
1685
1985
  background: "transparent",
1686
1986
  padding: 0,
1687
1987
  font: "inherit",
1688
1988
  fontSize: 12.5,
1689
1989
  color: "var(--dsw-alias-label-secondary)",
1690
- cursor: "pointer",
1691
1990
  whiteSpace: "nowrap"
1692
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
+ };
1693
2001
  /** The icon action (remove ✕) seat. */
1694
2002
  const iconActionStyle = {
1695
2003
  display: "inline-flex",
@@ -1704,6 +2012,39 @@ const iconActionStyle = {
1704
2012
  font: "inherit",
1705
2013
  cursor: "pointer"
1706
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
+ };
1707
2048
  /** The status dot's color: reachable green, pending grey, unreachable amber, auth-expired red. */
1708
2049
  function statusDotColor(status) {
1709
2050
  if (status === "reachable") return "var(--dsw-alias-state-success-primary)";
@@ -1775,11 +2116,18 @@ const sectionHeadStyle = {
1775
2116
  whiteSpace: "nowrap",
1776
2117
  listStyle: "none"
1777
2118
  };
1778
- /** A row that lights its surface on hover (inline styles have no :hover). */
1779
- function HoverRow({ children, onClick, clickable }) {
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 }) {
1780
2127
  const [hover, setHover] = react.useState(false);
1781
2128
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
1782
2129
  onClick,
2130
+ "aria-expanded": expanded,
1783
2131
  onMouseEnter: () => {
1784
2132
  setHover(true);
1785
2133
  },
@@ -1794,7 +2142,7 @@ function HoverRow({ children, onClick, clickable }) {
1794
2142
  padding: "9px 8px",
1795
2143
  borderRadius: 12,
1796
2144
  listStyle: "none",
1797
- background: hover ? "var(--dsw-alias-interactive-bg-hover)" : "transparent",
2145
+ background: hover || expanded ? "var(--dsw-alias-interactive-bg-hover)" : "transparent",
1798
2146
  cursor: clickable ? "pointer" : void 0
1799
2147
  },
1800
2148
  children
@@ -1831,6 +2179,671 @@ function GroupHead({ title, count, action }) {
1831
2179
  ]
1832
2180
  });
1833
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";
1834
2847
  function HubPage() {
1835
2848
  const [mesh, setMesh] = react.useState({ machines: [] });
1836
2849
  const [meshLoaded, setMeshLoaded] = react.useState(false);
@@ -1845,6 +2858,11 @@ function HubPage() {
1845
2858
  const fusion = fusionPage();
1846
2859
  const switchUi = switchAffordance(fusion);
1847
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);
1848
2866
  react.useEffect(() => {
1849
2867
  let cancelled = false;
1850
2868
  fetchRoster().then((list) => {
@@ -1917,66 +2935,71 @@ function HubPage() {
1917
2935
  /**
1918
2936
  * One Agent Runtimes row — the SAME row in both shapes; `showMachine`
1919
2937
  * keeps the flat fallback's per-row machine text (the grouped shape moves
1920
- * it onto the section head). The click contract is untouched: every row
1921
- * still runs the `seatClickDecision` table.
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).
1922
2945
  */
1923
- const renderRow = (agent, showMachine) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HoverRow, {
1924
- clickable: switchUi.available,
1925
- onClick: switchUi.available ? (event) => {
1926
- rowDecision(agent, event);
1927
- } : void 0,
1928
- children: [
1929
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeMark, {
1930
- agentKey: agent.key,
1931
- size: 20
1932
- }),
1933
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1934
- style: {
1935
- fontWeight: 500,
1936
- whiteSpace: "nowrap"
1937
- },
1938
- children: agent.label
1939
- }),
1940
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1941
- style: {
1942
- flex: 1,
1943
- minWidth: 0,
1944
- overflow: "hidden",
1945
- textOverflow: "ellipsis",
1946
- whiteSpace: "nowrap",
1947
- fontSize: 12.5,
1948
- color: "var(--dsw-alias-label-tertiary)"
1949
- },
1950
- children: showMachine ? agent.machine : null
1951
- }),
1952
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1953
- style: {
1954
- ...chip,
1955
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
1956
- fontSize: 10.5
1957
- },
1958
- children: displayPath(agent.path)
1959
- }),
1960
- isActive(agent) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1961
- style: chipSelf,
1962
- children: "current"
1963
- }),
1964
- switchUi.available && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1965
- "aria-current": isActive(agent) ? "page" : void 0,
1966
- style: {
1967
- fontSize: 12.5,
1968
- color: "var(--dsh-alias-label-secondary)",
1969
- textDecoration: "none",
1970
- cursor: "pointer"
1971
- },
1972
- onClick: (event) => {
1973
- event.stopPropagation();
1974
- rowDecision(agent, event);
1975
- },
1976
- children: "switch"
1977
- })
1978
- ]
1979
- }, agent.key);
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
+ };
1980
3003
  /** Bump the reload sequence — every mutating op refreshes through the API. */
1981
3004
  const reloadMachines = () => {
1982
3005
  setMeshReloads((n) => n + 1);
@@ -2738,8 +3761,7 @@ function apply(ctx) {
2738
3761
  "connection",
2739
3762
  "uiWorkspace",
2740
3763
  "workspaces",
2741
- "sessions",
2742
- "locale"
3764
+ "sessions"
2743
3765
  ], (raw) => {
2744
3766
  bindSwitchAgent(raw);
2745
3767
  });