@ljwei-stak/dsh-model-route-bot 0.0.0-stage → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/.dsh-plugin/bot-product.mjs +127 -0
  2. package/.dsh-plugin/client.js +35432 -0
  3. package/.dsh-plugin/index.mjs +9 -0
  4. package/.dsh-plugin/official-tools-remote-service.mjs +281 -0
  5. package/.dsh-plugin/router-core.mjs +2779 -0
  6. package/.dsh-plugin/shared/adaptive-feedback.mjs +272 -0
  7. package/.dsh-plugin/shared/assignment-solver.mjs +286 -0
  8. package/.dsh-plugin/shared/attention.mjs +79 -0
  9. package/.dsh-plugin/shared/budget-reservations.mjs +287 -0
  10. package/.dsh-plugin/shared/capability-union.mjs +32 -0
  11. package/.dsh-plugin/shared/cli-profiles.mjs +70 -0
  12. package/.dsh-plugin/shared/cli-terminal-protocol.mjs +152 -0
  13. package/.dsh-plugin/shared/cli-terminal.mjs +697 -0
  14. package/.dsh-plugin/shared/dynamic-data-view.mjs +120 -0
  15. package/.dsh-plugin/shared/dynamic-data.mjs +372 -0
  16. package/.dsh-plugin/shared/execution-accounting.mjs +61 -0
  17. package/.dsh-plugin/shared/execution-lifecycle.mjs +169 -0
  18. package/.dsh-plugin/shared/harness-plan.mjs +199 -0
  19. package/.dsh-plugin/shared/latest-versions.mjs +232 -0
  20. package/.dsh-plugin/shared/ledgers.mjs +87 -0
  21. package/.dsh-plugin/shared/legacy-policy.mjs +56 -0
  22. package/.dsh-plugin/shared/library-tools.mjs +69 -0
  23. package/.dsh-plugin/shared/livebench.mjs +301 -0
  24. package/.dsh-plugin/shared/manual-plan.mjs +143 -0
  25. package/.dsh-plugin/shared/model-profiles.mjs +148 -0
  26. package/.dsh-plugin/shared/npm-attestation.mjs +319 -0
  27. package/.dsh-plugin/shared/official-team-runtime.mjs +623 -0
  28. package/.dsh-plugin/shared/official-tool-executor.mjs +1321 -0
  29. package/.dsh-plugin/shared/official-tool-registry.mjs +577 -0
  30. package/.dsh-plugin/shared/official-tools-remote.mjs +352 -0
  31. package/.dsh-plugin/shared/official-tools-runtime.mjs +1745 -0
  32. package/.dsh-plugin/shared/package-assignments.mjs +71 -0
  33. package/.dsh-plugin/shared/quality-gates.mjs +169 -0
  34. package/.dsh-plugin/shared/read-only-guard.mjs +41 -0
  35. package/.dsh-plugin/shared/reasoning-execution.mjs +92 -0
  36. package/.dsh-plugin/shared/router-state.mjs +431 -0
  37. package/.dsh-plugin/shared/router.mjs +1209 -0
  38. package/.dsh-plugin/shared/routing-evidence.mjs +720 -0
  39. package/.dsh-plugin/shared/routing-presets.mjs +49 -0
  40. package/.dsh-plugin/shared/run-jobs.mjs +169 -0
  41. package/.dsh-plugin/shared/run-ledger.mjs +588 -0
  42. package/.dsh-plugin/shared/security-boundaries.mjs +54 -0
  43. package/.dsh-plugin/shared/subscription-billing.mjs +340 -0
  44. package/.dsh-plugin/shared/subscription-usage.mjs +210 -0
  45. package/.dsh-plugin/shared/task-executors.mjs +1555 -0
  46. package/.dsh-plugin/shared/tool-health.mjs +357 -0
  47. package/.dsh-plugin/shared/tool-install-preferences.mjs +390 -0
  48. package/.dsh-plugin/shared/tool-prerequisites.mjs +70 -0
  49. package/.dsh-plugin/shared/tui-executor.mjs +110 -0
  50. package/.dsh-plugin/shared/vendor-mimo-grok-adapter.mjs +351 -0
  51. package/.dsh-plugin/shared/vendor-minimax-adapter.mjs +247 -0
  52. package/.dsh-plugin/shared/version-order.mjs +30 -0
  53. package/.dsh-plugin/shared/zcode-bundle.mjs +93 -0
  54. package/.dsh-plugin/shared/zcode-installer.mjs +274 -0
  55. package/.dsh-plugin/shared/zcode-npm-shims.mjs +140 -0
  56. package/.dsh-plugin/shared/zcode-npm.mjs +177 -0
  57. package/LICENSE +21 -0
  58. package/README.i18n.yaml +4 -0
  59. package/README.md +363 -2
  60. package/README.zh.md +364 -0
  61. package/apps/integration-client/README.md +30 -0
  62. package/apps/integration-client/api.mjs +24 -0
  63. package/apps/integration-client/binding-editor.jsx +118 -0
  64. package/apps/integration-client/bot-attention.mjs +94 -0
  65. package/apps/integration-client/desktop-bridge.mjs +23 -0
  66. package/apps/integration-client/desktop-pane.jsx +209 -0
  67. package/apps/integration-client/desktop-stream.mjs +88 -0
  68. package/apps/integration-client/index.jsx +56 -0
  69. package/apps/integration-client/library-panel.jsx +139 -0
  70. package/apps/integration-client/pairing.mjs +113 -0
  71. package/apps/integration-client/panels.jsx +955 -0
  72. package/apps/integration-client/product.css +326 -0
  73. package/apps/integration-client/routine-recorder.mjs +97 -0
  74. package/apps/integration-client/routines-panel.jsx +126 -0
  75. package/apps/integration-client/routing-submissions.mjs +68 -0
  76. package/apps/integration-client/task-progress.mjs +46 -0
  77. package/apps/integration-client/tasks-panel.jsx +147 -0
  78. package/apps/integration-client/ui-icons.jsx +32 -0
  79. package/cordis.patch.yml +17 -0
  80. package/deploy/remote-agent/Dockerfile +10 -0
  81. package/deploy/remote-agent/README.md +36 -0
  82. package/deploy/remote-agent/install-linux.sh +22 -0
  83. package/deploy/remote-agent/install-windows.ps1 +43 -0
  84. package/deploy/remote-agent/remote-agent.service.example +22 -0
  85. package/modules/bot-runtime/README.md +123 -0
  86. package/modules/bot-runtime/SOURCE.json +2591 -0
  87. package/modules/bot-runtime/index.mjs +81 -0
  88. package/modules/bot-runtime/policy-scope.mjs +15 -0
  89. package/modules/bot-runtime/product-overlay/OVERLAY.json +58 -0
  90. package/modules/bot-runtime/product-overlay/README.md +55 -0
  91. package/modules/bot-runtime/product-overlay/base/src/client/details-drawer.js +310 -0
  92. package/modules/bot-runtime/product-overlay/base/src/client/index.js +1120 -0
  93. package/modules/bot-runtime/product-overlay/base/src/client/sidebar.js +1130 -0
  94. package/modules/bot-runtime/product-overlay/base/src/host/schedules.js +154 -0
  95. package/modules/bot-runtime/product-overlay/base/src/host/tools.js +1105 -0
  96. package/modules/bot-runtime/product-overlay/files/src/client/desktop-pane.js +181 -0
  97. package/modules/bot-runtime/product-overlay/patches/src/client/details-drawer.js.patch +37 -0
  98. package/modules/bot-runtime/product-overlay/patches/src/client/index.js.patch +11 -0
  99. package/modules/bot-runtime/product-overlay/patches/src/client/sidebar.js.patch +10 -0
  100. package/modules/bot-runtime/product-overlay/patches/src/host/schedules.js.patch +17 -0
  101. package/modules/bot-runtime/product-overlay/patches/src/host/tools.js.patch +11 -0
  102. package/modules/bot-runtime/read-model.mjs +102 -0
  103. package/modules/bot-runtime/schedule-compat.mjs +25 -0
  104. package/modules/bot-runtime/vendor/ds-bot/LICENSE +201 -0
  105. package/modules/bot-runtime/vendor/ds-bot/README.md +258 -0
  106. package/modules/bot-runtime/vendor/ds-bot/UPSTREAM_LICENSE +201 -0
  107. package/modules/bot-runtime/vendor/ds-bot/UPSTREAM_NOTICE +135 -0
  108. package/modules/bot-runtime/vendor/ds-bot/cordis.patch.yml +19 -0
  109. package/modules/bot-runtime/vendor/ds-bot/index.js +82 -0
  110. package/modules/bot-runtime/vendor/ds-bot/office.js +8889 -0
  111. package/modules/bot-runtime/vendor/ds-bot/package.json +73 -0
  112. package/modules/bot-runtime/vendor/ds-bot/src/client/about.js +160 -0
  113. package/modules/bot-runtime/vendor/ds-bot/src/client/activity-row.js +195 -0
  114. package/modules/bot-runtime/vendor/ds-bot/src/client/api.js +42 -0
  115. package/modules/bot-runtime/vendor/ds-bot/src/client/approval-notices.js +36 -0
  116. package/modules/bot-runtime/vendor/ds-bot/src/client/at-menu.js +115 -0
  117. package/modules/bot-runtime/vendor/ds-bot/src/client/avatar-library.js +159 -0
  118. package/modules/bot-runtime/vendor/ds-bot/src/client/bot-browsers.js +642 -0
  119. package/modules/bot-runtime/vendor/ds-bot/src/client/bot-draft.js +25 -0
  120. package/modules/bot-runtime/vendor/ds-bot/src/client/bot-settings.js +294 -0
  121. package/modules/bot-runtime/vendor/ds-bot/src/client/browser-overlap.js +4 -0
  122. package/modules/bot-runtime/vendor/ds-bot/src/client/browser-pane.js +869 -0
  123. package/modules/bot-runtime/vendor/ds-bot/src/client/browser-settings.js +129 -0
  124. package/modules/bot-runtime/vendor/ds-bot/src/client/btw-model.js +266 -0
  125. package/modules/bot-runtime/vendor/ds-bot/src/client/btw.js +105 -0
  126. package/modules/bot-runtime/vendor/ds-bot/src/client/capability-settings.js +166 -0
  127. package/modules/bot-runtime/vendor/ds-bot/src/client/card-hold.js +18 -0
  128. package/modules/bot-runtime/vendor/ds-bot/src/client/cell-empty.js +38 -0
  129. package/modules/bot-runtime/vendor/ds-bot/src/client/cells.js +1149 -0
  130. package/modules/bot-runtime/vendor/ds-bot/src/client/characters.js +136 -0
  131. package/modules/bot-runtime/vendor/ds-bot/src/client/composer.js +218 -0
  132. package/modules/bot-runtime/vendor/ds-bot/src/client/connectors.js +66 -0
  133. package/modules/bot-runtime/vendor/ds-bot/src/client/context-menu.js +97 -0
  134. package/modules/bot-runtime/vendor/ds-bot/src/client/create-bot.js +107 -0
  135. package/modules/bot-runtime/vendor/ds-bot/src/client/desktop-pane.js +181 -0
  136. package/modules/bot-runtime/vendor/ds-bot/src/client/details-drawer.js +312 -0
  137. package/modules/bot-runtime/vendor/ds-bot/src/client/diagnostics.js +93 -0
  138. package/modules/bot-runtime/vendor/ds-bot/src/client/dsh-offer.js +14 -0
  139. package/modules/bot-runtime/vendor/ds-bot/src/client/dsh-primitives.js +3 -0
  140. package/modules/bot-runtime/vendor/ds-bot/src/client/enter-key.js +20 -0
  141. package/modules/bot-runtime/vendor/ds-bot/src/client/enter-steer.js +37 -0
  142. package/modules/bot-runtime/vendor/ds-bot/src/client/exchange.js +75 -0
  143. package/modules/bot-runtime/vendor/ds-bot/src/client/feedback.js +183 -0
  144. package/modules/bot-runtime/vendor/ds-bot/src/client/fold.js +154 -0
  145. package/modules/bot-runtime/vendor/ds-bot/src/client/folder-menu.js +112 -0
  146. package/modules/bot-runtime/vendor/ds-bot/src/client/frame-layout.js +90 -0
  147. package/modules/bot-runtime/vendor/ds-bot/src/client/frame-watch.js +109 -0
  148. package/modules/bot-runtime/vendor/ds-bot/src/client/goal.js +403 -0
  149. package/modules/bot-runtime/vendor/ds-bot/src/client/group-settings.js +180 -0
  150. package/modules/bot-runtime/vendor/ds-bot/src/client/handoff-card.js +132 -0
  151. package/modules/bot-runtime/vendor/ds-bot/src/client/header-navigation.js +36 -0
  152. package/modules/bot-runtime/vendor/ds-bot/src/client/header.js +244 -0
  153. package/modules/bot-runtime/vendor/ds-bot/src/client/i18n.js +1324 -0
  154. package/modules/bot-runtime/vendor/ds-bot/src/client/icons.js +105 -0
  155. package/modules/bot-runtime/vendor/ds-bot/src/client/index.js +1120 -0
  156. package/modules/bot-runtime/vendor/ds-bot/src/client/inks.js +27 -0
  157. package/modules/bot-runtime/vendor/ds-bot/src/client/kept-private.js +26 -0
  158. package/modules/bot-runtime/vendor/ds-bot/src/client/learning-card-model.js +66 -0
  159. package/modules/bot-runtime/vendor/ds-bot/src/client/learning-card.js +202 -0
  160. package/modules/bot-runtime/vendor/ds-bot/src/client/mark.js +170 -0
  161. package/modules/bot-runtime/vendor/ds-bot/src/client/member-status.js +254 -0
  162. package/modules/bot-runtime/vendor/ds-bot/src/client/memory-panel.js +373 -0
  163. package/modules/bot-runtime/vendor/ds-bot/src/client/model-menu.js +371 -0
  164. package/modules/bot-runtime/vendor/ds-bot/src/client/motion.js +245 -0
  165. package/modules/bot-runtime/vendor/ds-bot/src/client/new-chat.js +181 -0
  166. package/modules/bot-runtime/vendor/ds-bot/src/client/open-listed.js +27 -0
  167. package/modules/bot-runtime/vendor/ds-bot/src/client/overlay-hooks.js +31 -0
  168. package/modules/bot-runtime/vendor/ds-bot/src/client/overlays.js +70 -0
  169. package/modules/bot-runtime/vendor/ds-bot/src/client/palette.js +141 -0
  170. package/modules/bot-runtime/vendor/ds-bot/src/client/permission-picker.js +47 -0
  171. package/modules/bot-runtime/vendor/ds-bot/src/client/providers-page.js +196 -0
  172. package/modules/bot-runtime/vendor/ds-bot/src/client/questions.js +233 -0
  173. package/modules/bot-runtime/vendor/ds-bot/src/client/read-page.js +335 -0
  174. package/modules/bot-runtime/vendor/ds-bot/src/client/right-panel.js +49 -0
  175. package/modules/bot-runtime/vendor/ds-bot/src/client/schedules.js +290 -0
  176. package/modules/bot-runtime/vendor/ds-bot/src/client/secret-card.js +363 -0
  177. package/modules/bot-runtime/vendor/ds-bot/src/client/settings.js +310 -0
  178. package/modules/bot-runtime/vendor/ds-bot/src/client/shared-map.js +65 -0
  179. package/modules/bot-runtime/vendor/ds-bot/src/client/side-chat.js +157 -0
  180. package/modules/bot-runtime/vendor/ds-bot/src/client/side-model.js +171 -0
  181. package/modules/bot-runtime/vendor/ds-bot/src/client/sidebar.js +1131 -0
  182. package/modules/bot-runtime/vendor/ds-bot/src/client/sources.js +68 -0
  183. package/modules/bot-runtime/vendor/ds-bot/src/client/speech.js +162 -0
  184. package/modules/bot-runtime/vendor/ds-bot/src/client/storage.js +72 -0
  185. package/modules/bot-runtime/vendor/ds-bot/src/client/styles.js +1324 -0
  186. package/modules/bot-runtime/vendor/ds-bot/src/client/surface.js +94 -0
  187. package/modules/bot-runtime/vendor/ds-bot/src/client/team-actions.js +218 -0
  188. package/modules/bot-runtime/vendor/ds-bot/src/client/text.js +291 -0
  189. package/modules/bot-runtime/vendor/ds-bot/src/client/themes.js +128 -0
  190. package/modules/bot-runtime/vendor/ds-bot/src/client/turn-error.js +260 -0
  191. package/modules/bot-runtime/vendor/ds-bot/src/client/turn-reasoning.js +38 -0
  192. package/modules/bot-runtime/vendor/ds-bot/src/client/usage-data.js +159 -0
  193. package/modules/bot-runtime/vendor/ds-bot/src/client/usage-page.js +760 -0
  194. package/modules/bot-runtime/vendor/ds-bot/src/client/user-message.js +139 -0
  195. package/modules/bot-runtime/vendor/ds-bot/src/client/voice.js +300 -0
  196. package/modules/bot-runtime/vendor/ds-bot/src/client/widget-cell.js +138 -0
  197. package/modules/bot-runtime/vendor/ds-bot/src/host/agents.js +129 -0
  198. package/modules/bot-runtime/vendor/ds-bot/src/host/approvals.js +69 -0
  199. package/modules/bot-runtime/vendor/ds-bot/src/host/avatar-library.js +131 -0
  200. package/modules/bot-runtime/vendor/ds-bot/src/host/avatar.js +107 -0
  201. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/gate.js +3 -0
  202. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/loop.js +95 -0
  203. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/mount.js +177 -0
  204. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/refs.js +151 -0
  205. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/script.js +38 -0
  206. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/session-model.js +205 -0
  207. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/session.js +765 -0
  208. package/modules/bot-runtime/vendor/ds-bot/src/host/browser/task.js +64 -0
  209. package/modules/bot-runtime/vendor/ds-bot/src/host/browser-plugins.js +174 -0
  210. package/modules/bot-runtime/vendor/ds-bot/src/host/browser.js +287 -0
  211. package/modules/bot-runtime/vendor/ds-bot/src/host/btw.js +372 -0
  212. package/modules/bot-runtime/vendor/ds-bot/src/host/capabilities.js +542 -0
  213. package/modules/bot-runtime/vendor/ds-bot/src/host/channel.js +647 -0
  214. package/modules/bot-runtime/vendor/ds-bot/src/host/chat-index.js +293 -0
  215. package/modules/bot-runtime/vendor/ds-bot/src/host/connectors.js +169 -0
  216. package/modules/bot-runtime/vendor/ds-bot/src/host/constants.js +96 -0
  217. package/modules/bot-runtime/vendor/ds-bot/src/host/delivery.js +171 -0
  218. package/modules/bot-runtime/vendor/ds-bot/src/host/diagnostics.js +257 -0
  219. package/modules/bot-runtime/vendor/ds-bot/src/host/dsh-update.js +172 -0
  220. package/modules/bot-runtime/vendor/ds-bot/src/host/feed.js +115 -0
  221. package/modules/bot-runtime/vendor/ds-bot/src/host/files.js +27 -0
  222. package/modules/bot-runtime/vendor/ds-bot/src/host/folders.js +230 -0
  223. package/modules/bot-runtime/vendor/ds-bot/src/host/goal-skills.js +48 -0
  224. package/modules/bot-runtime/vendor/ds-bot/src/host/goals.js +812 -0
  225. package/modules/bot-runtime/vendor/ds-bot/src/host/groups.js +1466 -0
  226. package/modules/bot-runtime/vendor/ds-bot/src/host/handoffs.js +330 -0
  227. package/modules/bot-runtime/vendor/ds-bot/src/host/home-lock.js +98 -0
  228. package/modules/bot-runtime/vendor/ds-bot/src/host/images.js +212 -0
  229. package/modules/bot-runtime/vendor/ds-bot/src/host/learning.js +781 -0
  230. package/modules/bot-runtime/vendor/ds-bot/src/host/links.js +39 -0
  231. package/modules/bot-runtime/vendor/ds-bot/src/host/memory-pending.js +95 -0
  232. package/modules/bot-runtime/vendor/ds-bot/src/host/memory.js +2050 -0
  233. package/modules/bot-runtime/vendor/ds-bot/src/host/models.js +314 -0
  234. package/modules/bot-runtime/vendor/ds-bot/src/host/office-skills.js +78 -0
  235. package/modules/bot-runtime/vendor/ds-bot/src/host/parts.js +1473 -0
  236. package/modules/bot-runtime/vendor/ds-bot/src/host/permissions.js +117 -0
  237. package/modules/bot-runtime/vendor/ds-bot/src/host/privacy.js +368 -0
  238. package/modules/bot-runtime/vendor/ds-bot/src/host/prompt.js +73 -0
  239. package/modules/bot-runtime/vendor/ds-bot/src/host/providers.js +226 -0
  240. package/modules/bot-runtime/vendor/ds-bot/src/host/requests.js +141 -0
  241. package/modules/bot-runtime/vendor/ds-bot/src/host/resume.js +445 -0
  242. package/modules/bot-runtime/vendor/ds-bot/src/host/roster.js +776 -0
  243. package/modules/bot-runtime/vendor/ds-bot/src/host/schedules.js +156 -0
  244. package/modules/bot-runtime/vendor/ds-bot/src/host/secrets.js +586 -0
  245. package/modules/bot-runtime/vendor/ds-bot/src/host/side.js +406 -0
  246. package/modules/bot-runtime/vendor/ds-bot/src/host/skills/goal-grill/SKILL.md +37 -0
  247. package/modules/bot-runtime/vendor/ds-bot/src/host/steer.js +265 -0
  248. package/modules/bot-runtime/vendor/ds-bot/src/host/steward.js +165 -0
  249. package/modules/bot-runtime/vendor/ds-bot/src/host/store.js +512 -0
  250. package/modules/bot-runtime/vendor/ds-bot/src/host/text.js +49 -0
  251. package/modules/bot-runtime/vendor/ds-bot/src/host/thinking.js +55 -0
  252. package/modules/bot-runtime/vendor/ds-bot/src/host/time-context.js +46 -0
  253. package/modules/bot-runtime/vendor/ds-bot/src/host/tools.js +1105 -0
  254. package/modules/bot-runtime/vendor/ds-bot/src/host/turns.js +1126 -0
  255. package/modules/bot-runtime/vendor/ds-bot/src/host/update.js +315 -0
  256. package/modules/bot-runtime/vendor/ds-bot/src/host/usage.js +653 -0
  257. package/modules/bot-runtime/vendor/ds-bot/src/office/check.js +329 -0
  258. package/modules/bot-runtime/vendor/ds-bot/src/office/cli.js +193 -0
  259. package/modules/bot-runtime/vendor/ds-bot/src/office/docx.js +644 -0
  260. package/modules/bot-runtime/vendor/ds-bot/src/office/package.js +238 -0
  261. package/modules/bot-runtime/vendor/ds-bot/src/office/png.js +183 -0
  262. package/modules/bot-runtime/vendor/ds-bot/src/office/pptx.js +408 -0
  263. package/modules/bot-runtime/vendor/ds-bot/src/office/skills/office/SKILL.md +18 -0
  264. package/modules/bot-runtime/vendor/ds-bot/src/office/skills/office-tools/SKILL.md +41 -0
  265. package/modules/bot-runtime/vendor/ds-bot/src/office/xlsx.js +119 -0
  266. package/modules/bot-runtime/vendor/ds-bot/src/office/xml.js +128 -0
  267. package/modules/bot-runtime/vendor/ds-bot/src/office/zip.js +146 -0
  268. package/modules/bot-runtime/vendor/ds-bot/src/shared/group-replies.js +69 -0
  269. package/modules/bot-runtime/vendor/ds-bot/src/shared/mentions.js +72 -0
  270. package/modules/bot-runtime/vendor/ds-bot/test/harness-resolve.mjs +48 -0
  271. package/modules/bot-runtime/vendor/ds-bot/web-search.js +775 -0
  272. package/modules/bot-runtime/web-search.mjs +3 -0
  273. package/modules/independent-runtime/index.mjs +62 -0
  274. package/modules/independent-runtime/remote-tools.mjs +51 -0
  275. package/modules/independent-runtime/workspace-tools.mjs +96 -0
  276. package/native/windows-desktop/DesktopLease.cs +128 -0
  277. package/native/windows-desktop/DesktopStream.cs +161 -0
  278. package/native/windows-desktop/FullDesktop.cs +76 -0
  279. package/native/windows-desktop/ProcessJob.cs +172 -0
  280. package/native/windows-desktop/Program.cs +272 -0
  281. package/native/windows-desktop/README.md +11 -0
  282. package/native/windows-desktop/build.ps1 +22 -0
  283. package/package.json +438 -4
  284. package/packages/capability-broker/README.md +41 -0
  285. package/packages/capability-broker/src/authority.mjs +162 -0
  286. package/packages/capability-broker/src/cli-bootstrap.mjs +122 -0
  287. package/packages/capability-broker/src/cli-stdio-bridge.mjs +69 -0
  288. package/packages/capability-broker/src/managed-bridge.mjs +107 -0
  289. package/packages/capability-broker/src/stdio-bridge.mjs +57 -0
  290. package/packages/cli-runtime/README.md +41 -0
  291. package/packages/cli-runtime/src/agent-codex-runtime.mjs +64 -0
  292. package/packages/cli-runtime/src/codex-runtime.mjs +21 -0
  293. package/packages/cli-runtime/src/codex-session-core.mjs +202 -0
  294. package/packages/cli-runtime/src/contracts.mjs +59 -0
  295. package/packages/cli-runtime/src/native-peer.ps1 +311 -0
  296. package/packages/cli-runtime/src/native-peer.py +222 -0
  297. package/packages/cli-runtime/src/native-process.mjs +117 -0
  298. package/packages/cli-runtime/src/native-terminal-peer.ps1 +267 -0
  299. package/packages/cli-runtime/src/native-terminal.mjs +499 -0
  300. package/packages/cli-runtime/src/profile-policy.mjs +28 -0
  301. package/packages/model-router-plugin/README.md +58 -0
  302. package/packages/model-router-plugin/README.zh.md +58 -0
  303. package/packages/model-router-plugin/cordis.patch.yml +4 -0
  304. package/packages/model-router-plugin/package.json +59 -0
  305. package/packages/orchestration/README.md +146 -0
  306. package/packages/orchestration/src/bot-budget.mjs +100 -0
  307. package/packages/orchestration/src/bot-handoff.mjs +88 -0
  308. package/packages/orchestration/src/bot-library.mjs +195 -0
  309. package/packages/orchestration/src/bot-loop-bridge.mjs +102 -0
  310. package/packages/orchestration/src/bot-loop.mjs +84 -0
  311. package/packages/orchestration/src/bot-policy.mjs +94 -0
  312. package/packages/orchestration/src/bot-roles.mjs +63 -0
  313. package/packages/orchestration/src/bot-routine-store.mjs +194 -0
  314. package/packages/orchestration/src/bot-routine.mjs +195 -0
  315. package/packages/orchestration/src/bot-routing-candidates.mjs +140 -0
  316. package/packages/orchestration/src/bot-routing-dispatch.mjs +402 -0
  317. package/packages/orchestration/src/bot-routing-mode.mjs +108 -0
  318. package/packages/orchestration/src/bot-routing-runtime.mjs +360 -0
  319. package/packages/orchestration/src/bot-routing-service.mjs +257 -0
  320. package/packages/orchestration/src/bot-routing-settings.mjs +34 -0
  321. package/packages/orchestration/src/bot-routing-tools.mjs +89 -0
  322. package/packages/orchestration/src/bot-routing.mjs +108 -0
  323. package/packages/orchestration/src/bot-runtime-assembly.mjs +128 -0
  324. package/packages/orchestration/src/bot-runtime-config.mjs +41 -0
  325. package/packages/orchestration/src/bot-runtime-dispatch.mjs +51 -0
  326. package/packages/orchestration/src/bot-runtime-switch.mjs +97 -0
  327. package/packages/orchestration/src/bot-session-store.mjs +120 -0
  328. package/packages/orchestration/src/bot-settings.mjs +341 -0
  329. package/packages/orchestration/src/cli-execution.mjs +180 -0
  330. package/packages/orchestration/src/deferred-router-state.mjs +19 -0
  331. package/packages/orchestration/src/desktop-actions.mjs +60 -0
  332. package/packages/orchestration/src/desktop-contract.mjs +99 -0
  333. package/packages/orchestration/src/desktop-sessions.mjs +93 -0
  334. package/packages/orchestration/src/ds-lifecycle.mjs +189 -0
  335. package/packages/orchestration/src/ds-workspace-privacy.mjs +21 -0
  336. package/packages/orchestration/src/funded-router-state.mjs +63 -0
  337. package/packages/orchestration/src/funding-accounts.mjs +63 -0
  338. package/packages/orchestration/src/funding-admission.mjs +39 -0
  339. package/packages/orchestration/src/funding-projection.mjs +124 -0
  340. package/packages/orchestration/src/machine-heartbeat.mjs +35 -0
  341. package/packages/orchestration/src/machine-secrets.mjs +37 -0
  342. package/packages/orchestration/src/migration-atomic-rename.mjs +16 -0
  343. package/packages/orchestration/src/migration-attestation-verifier.mjs +621 -0
  344. package/packages/orchestration/src/migration-commit-orchestration.mjs +1193 -0
  345. package/packages/orchestration/src/migration-configuration-commit.mjs +217 -0
  346. package/packages/orchestration/src/migration-data-archive.mjs +128 -0
  347. package/packages/orchestration/src/migration-domain-audit.mjs +245 -0
  348. package/packages/orchestration/src/migration-domain-evidence.mjs +409 -0
  349. package/packages/orchestration/src/migration-domain-inventory.mjs +78 -0
  350. package/packages/orchestration/src/migration-fence.mjs +278 -0
  351. package/packages/orchestration/src/migration-file-stability.mjs +19 -0
  352. package/packages/orchestration/src/migration-financial-audit.mjs +147 -0
  353. package/packages/orchestration/src/migration-ledger-export.mjs +159 -0
  354. package/packages/orchestration/src/migration-linux-quarantine.mjs +83 -0
  355. package/packages/orchestration/src/migration-linux-quarantine.py +184 -0
  356. package/packages/orchestration/src/migration-os-quarantine.mjs +99 -0
  357. package/packages/orchestration/src/migration-private-files.mjs +52 -0
  358. package/packages/orchestration/src/migration-provider-selection.mjs +242 -0
  359. package/packages/orchestration/src/migration-recovery-audit.mjs +359 -0
  360. package/packages/orchestration/src/migration-remote-client-quarantine.mjs +80 -0
  361. package/packages/orchestration/src/migration-remote-file-reconciliation.mjs +72 -0
  362. package/packages/orchestration/src/migration-remote-operation-drain.mjs +35 -0
  363. package/packages/orchestration/src/migration-restore.mjs +146 -0
  364. package/packages/orchestration/src/migration-rollback-readiness.mjs +114 -0
  365. package/packages/orchestration/src/migration-rollback-rehearsal.mjs +135 -0
  366. package/packages/orchestration/src/migration-session-decoder.mjs +108 -0
  367. package/packages/orchestration/src/migration-session-reader.mjs +60 -0
  368. package/packages/orchestration/src/migration-snapshot.mjs +142 -0
  369. package/packages/orchestration/src/migration-startup-gate.mjs +29 -0
  370. package/packages/orchestration/src/migration-supporting-domains.mjs +141 -0
  371. package/packages/orchestration/src/migration-systemd-quarantine.mjs +132 -0
  372. package/packages/orchestration/src/migration-windows-launcher-quarantine.mjs +86 -0
  373. package/packages/orchestration/src/migration-workspace-audit.mjs +69 -0
  374. package/packages/orchestration/src/migration-writer-inventory.mjs +167 -0
  375. package/packages/orchestration/src/model-accounting.mjs +198 -0
  376. package/packages/orchestration/src/model-receipt.mjs +46 -0
  377. package/packages/orchestration/src/mr-read-backend.mjs +110 -0
  378. package/packages/orchestration/src/pair-main-machine.mjs +20 -0
  379. package/packages/orchestration/src/principals.mjs +56 -0
  380. package/packages/orchestration/src/product-composition.mjs +961 -0
  381. package/packages/orchestration/src/product-funding.mjs +13 -0
  382. package/packages/orchestration/src/profile-migration-plan.mjs +521 -0
  383. package/packages/orchestration/src/remote-cli-execution.mjs +187 -0
  384. package/packages/orchestration/src/remote-command-execution.mjs +83 -0
  385. package/packages/orchestration/src/remote-computer-tools.mjs +234 -0
  386. package/packages/orchestration/src/remote-execution.mjs +65 -0
  387. package/packages/orchestration/src/remote-machines.mjs +316 -0
  388. package/packages/orchestration/src/routine-execution.mjs +130 -0
  389. package/packages/orchestration/src/routine-session.mjs +158 -0
  390. package/packages/orchestration/src/sqlite-router-state.mjs +254 -0
  391. package/packages/orchestration/src/task-admission.mjs +39 -0
  392. package/packages/orchestration/src/task-contract.mjs +223 -0
  393. package/packages/orchestration/src/task-journal.mjs +571 -0
  394. package/packages/orchestration/src/task-product.mjs +49 -0
  395. package/packages/orchestration/src/task-service.mjs +266 -0
  396. package/packages/orchestration/src/task-stage.mjs +14 -0
  397. package/packages/orchestration/src/task-tools.mjs +27 -0
  398. package/remote-computer-agent/README.md +29 -0
  399. package/remote-computer-agent/build.mjs +51 -0
  400. package/remote-computer-agent/dist/cli-stdio-bridge.mjs +251 -0
  401. package/remote-computer-agent/dist/cli-stdio-bridge.mjs.map +7 -0
  402. package/remote-computer-agent/dist/cli.mjs +4473 -0
  403. package/remote-computer-agent/dist/cli.mjs.map +7 -0
  404. package/remote-computer-agent/dist/index.mjs +4489 -0
  405. package/remote-computer-agent/dist/index.mjs.map +7 -0
  406. package/remote-computer-agent/dist/native-peer.ps1 +311 -0
  407. package/remote-computer-agent/dist/native-peer.py +222 -0
  408. package/remote-computer-agent/launch-agent.ps1 +9 -0
  409. package/remote-computer-agent/package-lock.json +618 -0
  410. package/remote-computer-agent/package.json +27 -0
  411. package/remote-computer-agent/setup.ps1 +170 -0
  412. package/remote-computer-agent/src/agent.ts +308 -0
  413. package/remote-computer-agent/src/auth-throttle.ts +45 -0
  414. package/remote-computer-agent/src/browser.ts +71 -0
  415. package/remote-computer-agent/src/cli-task.ts +115 -0
  416. package/remote-computer-agent/src/cli.ts +25 -0
  417. package/remote-computer-agent/src/client.ts +11 -0
  418. package/remote-computer-agent/src/container-command.ts +166 -0
  419. package/remote-computer-agent/src/container-supervisor.mjs +32 -0
  420. package/remote-computer-agent/src/container-task-contract.ts +583 -0
  421. package/remote-computer-agent/src/desktop-session.ts +240 -0
  422. package/remote-computer-agent/src/desktop.ts +98 -0
  423. package/remote-computer-agent/src/index.ts +12 -0
  424. package/remote-computer-agent/src/pinned-write.ts +462 -0
  425. package/remote-computer-agent/src/protocol.ts +25 -0
  426. package/remote-computer-agent/src/scope.ts +92 -0
  427. package/remote-computer-agent/src/store.ts +101 -0
  428. package/remote-computer-agent/src/transport.ts +89 -0
  429. package/remote-computer-agent/src/workspace-admission.ts +181 -0
  430. package/remote-computer-agent/src/workspace-generation.ts +51 -0
  431. package/remote-computer-agent/src/workspace-identity.ts +126 -0
  432. package/remote-computer-agent/start.cmd +3 -0
@@ -0,0 +1,1130 @@
1
+ import { createElement as h, Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
2
+ import { createPortal } from 'react-dom'
3
+ import { FishLogo } from './dsh-primitives.js'
4
+ import { isMainOf } from './sources.js'
5
+ import { currentPart, previewOf, relativeShort } from './text.js'
6
+ import { PlusIcon, SearchIcon, SidebarIcon, GaugeIcon, ClockIcon, GearIcon, PinMarkIcon, ConnectorIcon, SwitchIcon, CloudDownloadIcon, SignInIcon, SignOutIcon, SlidersIcon } from './icons.js'
7
+ import { lookOf, MAIN_LOOK } from './characters.js'
8
+ import { botState, BotMark, BotAvatar, RoomAvatar } from './mark.js'
9
+ import { reducedMotion } from './activity-row.js'
10
+ import { Shimmer, workPhrase } from './cells.js'
11
+ import { springEasing, SPRING_POP, SPRING_SHAPE, useLinger, useViewport, viewBottom } from './motion.js'
12
+ import { hostText, t } from './i18n.js'
13
+ import { clientErrors } from './diagnostics.js'
14
+ import { showsDshRow } from './dsh-offer.js'
15
+ import { quietly } from './diagnostics.js'
16
+ import { frameLayout, dragColumn, RAIL_WIDTH, FALLBACK_SIDEBAR_WIDTH, userSidebarToggle } from './frame-layout.js'
17
+ import { chatRoom, dshCollapsed } from './frame-watch.js'
18
+
19
+ // -------------------------------------------------------------------------
20
+ // Sidebar
21
+
22
+ // Manual "Mark as Unread" lasts until the conversation is opened again.
23
+ function useMarkedUnread(id, active, marked, actions) {
24
+ useEffect(() => {
25
+ if (active && marked) actions.clearUnread(id)
26
+ }, [active, marked])
27
+ }
28
+
29
+ const PinMark = () => h('span', { className: 'bt-pin', 'aria-hidden': true }, h(PinMarkIcon))
30
+
31
+ // The rail shows a row's name only on hover; the wide list does so when the name is
32
+ // cut, which only the laid-out row can tell, so it is measured as the pointer enters.
33
+ const nameIfCut = (event) => {
34
+ const row = event.currentTarget
35
+ const name = row.querySelector('.bt-row-title')
36
+ if (name && name.scrollWidth > name.clientWidth) row.title = name.textContent
37
+ else row.removeAttribute('title')
38
+ }
39
+
40
+ // Whether an approval waits for the user: for a Bot, in any of its Sessions; for a group,
41
+ // from any of its members there.
42
+ const useApproval = (useWork, match) => (useWork ? useWork(work => (work.approvals ?? []).some(match)) : false)
43
+
44
+ // Work running in group Sessions, as "botId|tool" keys so a row redraws only when it
45
+ // changes: the groups one Bot works in, or the members at work in one group.
46
+ // Picked as text, so a row redraws only when what it shows changes.
47
+ const useGroupWork = (useWork, pick) => (useWork ? useWork(work => JSON.stringify(pick(work.rooms ?? {}))) : '[]')
48
+ const workKeys = text => JSON.parse(text)
49
+ const doingOf = ({ tool, said, note, target, switching }) => ({ tool, said, note, target, switching })
50
+ const workLine = (lead, doing, more) => h(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ''}`)
51
+ // The row already names the Bot; its own-chat preview is just what it is doing.
52
+ const doingLine = doing => h(Shimmer, null, `${workPhrase(doing)}…`)
53
+ // The Bots and groups a Bot waits for (handoffs.js), by the names they have now.
54
+ const waitingFor = (roster, waits) => {
55
+ const names = [...(waits?.bots ?? []).map(id => roster.byId[id]?.name), ...(waits?.rooms ?? []).map(id => roster.roomsById[id]?.name)].filter(Boolean)
56
+ return names.length === 0 ? '' : t('Waiting for {names}', { names: names.join(t(' and ')) })
57
+ }
58
+
59
+ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, useWork, wide, marked }) {
60
+ const id = bot.id
61
+ const part = currentPart(bot)
62
+ const preview = useSessions(list => previewOf(list, part, roster.exchangeTurns[part]))
63
+ const running = useSessionStatus(map => map.get(part)?.running === true)
64
+ const active = useSessionRetainInfo(part, info => (info?.retainedBy?.mainView ?? 0) > 0)
65
+ const unread = useSessionStatus(map => map.get(part)?.completionUnread === true || map.get(part)?.pendingInteraction !== undefined) || (marked && !active)
66
+ useMarkedUnread(id, active, marked, actions)
67
+ const main = isMainOf(roster, id)
68
+ const tile = roster.mainBotId === id
69
+ const approval = useApproval(useWork, entry => entry.botId === id)
70
+ const alert = roster.questions?.[part] !== undefined || approval
71
+ const doing = useActivity(map => map[id])
72
+ // Work in a group runs in a Session of its own, so the Bot's chat stays idle meanwhile.
73
+ const groups = workKeys(useGroupWork(useWork, rooms => Object.entries(rooms).flatMap(([roomId, entries]) => entries.filter(entry => entry.botId === id).map(entry => ({ id: roomId, ...doingOf(entry) })))))
74
+ const away = !running && groups.length > 0
75
+ const state = botState(running || away, doing, alert)
76
+ // A Bot running in its own chat previews what it is doing, like a group's row.
77
+ const runningLine = running && doing ? doingLine(doing) : null
78
+ const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t('a group chat'), groups[0], groups.length - 1) : null
79
+ const waits = workKeys(useWork ? useWork(work => JSON.stringify(work.waiting?.[id] ?? null)) : 'null')
80
+ const waitsFor = state === 'waiting' ? waitingFor(roster, waits) : ''
81
+ if (bot.hidden && !active && !main) return null
82
+ const onContextMenu = (event) => {
83
+ event.preventDefault()
84
+ actions.openMenu({ kind: 'bot', id, x: event.clientX, y: event.clientY })
85
+ }
86
+ const pinned = bot.pinned === true && !tile
87
+ const label = [bot.name, main ? t('Main Bot') : '', pinned ? t('Pinned') : '', running || away ? t('Working') : '', waitsFor, approval ? t('Waiting for your approval') : alert ? t('Waiting for your answer') : '', unread ? t('Unread activity') : ''].filter(Boolean).join(', ')
88
+ if (tile && wide) {
89
+ return h('div', { className: 'bt-tile-wrap' }, h('button', {
90
+ type: 'button', className: 'bt-tile', 'aria-label': label, 'aria-current': active ? 'page' : undefined,
91
+ 'data-bot-id': id, title: preview || bot.name, onClick: () => actions.openSession(id), onContextMenu,
92
+ },
93
+ h(BotAvatar, { bot, size: 60, state, main: true }),
94
+ h('span', { className: 'bt-tile-name' }, bot.name),
95
+ bot.role ? h('span', { className: 'bt-chip' }, bot.role) : null))
96
+ }
97
+ return h('button', {
98
+ type: 'button', className: 'bt-row', 'aria-label': label, 'aria-current': active ? 'page' : undefined,
99
+ 'data-bot-id': id, title: wide ? undefined : bot.name, onMouseEnter: wide ? nameIfCut : undefined, onClick: () => actions.openSession(id), onContextMenu,
100
+ },
101
+ h(BotAvatar, { bot, size: wide ? 36 : 44, state, main }),
102
+ pinned && !wide ? h(PinMark) : null,
103
+ wide ? h('span', { className: 'bt-row-body' },
104
+ h('span', { className: 'bt-row-name' }, h('span', { className: 'bt-row-title' }, bot.name), pinned ? h(PinMark) : null),
105
+ runningLine ? h('span', { className: 'bt-row-preview' }, runningLine)
106
+ : awayLine ? h('span', { className: 'bt-row-preview' }, awayLine)
107
+ : waitsFor ? h('span', { className: 'bt-row-preview' }, waitsFor)
108
+ : preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,
109
+ wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true })
110
+ : !wide && !active && (alert || unread) ? h('span', { className: `bt-dot${alert ? ' bt-dot-wait' : ''}`, 'aria-hidden': true }) : null)
111
+ }
112
+
113
+ function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useWork, wide, marked }) {
114
+ const id = room.id
115
+ // The group's own Session is a chain of parts; the row shows the current one.
116
+ const sessionId = room.sessionId ?? id
117
+ const fallback = useSessions(list => previewOf(list, sessionId))
118
+ const preview = room.preview?.replace(/\s+/g, ' ').trim() || fallback
119
+ const active = useSessionRetainInfo(sessionId, info => (info?.retainedBy?.mainView ?? 0) > 0)
120
+ const unread = useSessionStatus(map => map.get(sessionId)?.completionUnread === true) || (marked && !active)
121
+ useMarkedUnread(id, active, marked, actions)
122
+ const approval = useApproval(useWork, entry => entry.roomId === id)
123
+ const members = workKeys(useGroupWork(useWork, rooms => (rooms[id] ?? []).filter(entry => entry.botId !== undefined).map(entry => ({ id: entry.botId, ...doingOf(entry) }))))
124
+ const first = roster.byId[members[0]?.id]
125
+ const workingLine = first ? workLine(first.name, members[0], members.length - 1) : null
126
+ if (room.hidden && !active) return null
127
+ const pinned = room.pinned === true
128
+ const label = [room.name, pinned ? t('Pinned') : '', members.length > 0 ? t('Working') : '', approval ? t('Waiting for your approval') : ''].filter(Boolean).join(', ')
129
+ return h('button', {
130
+ type: 'button', className: 'bt-row', 'aria-label': label, 'aria-current': active ? 'page' : undefined,
131
+ 'data-room-id': id, title: wide ? undefined : room.name, onMouseEnter: wide ? nameIfCut : undefined, onClick: () => actions.openSession(id),
132
+ onContextMenu: (event) => { event.preventDefault(); actions.openMenu({ kind: 'room', id, x: event.clientX, y: event.clientY }) },
133
+ },
134
+ h(RoomAvatar, { room, roster, size: wide ? 36 : 44 }),
135
+ pinned && !wide ? h(PinMark) : null,
136
+ wide ? h('span', { className: 'bt-row-body' },
137
+ h('span', { className: 'bt-row-name' }, h('span', { className: 'bt-row-title' }, room.name), pinned ? h(PinMark) : null),
138
+ workingLine ? h('span', { className: 'bt-row-preview' }, workingLine) : preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,
139
+ wide && approval && !active ? h('span', { className: 'bt-unread bt-unread-wait', 'aria-hidden': true })
140
+ : wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true })
141
+ : !wide && !active && (approval || unread) ? h('span', { className: `bt-dot${approval ? ' bt-dot-wait' : ''}`, 'aria-hidden': true }) : null)
142
+ }
143
+
144
+ // One expanded DSH Agent Session row: title, relative stamp, rename field, and a
145
+ // context menu for rename/archive.
146
+ function AgentSessionRow({ session, agent, actions, renaming, index }) {
147
+ const input = useRef(null)
148
+ useLayoutEffect(() => {
149
+ if (!renaming) return
150
+ input.current?.focus()
151
+ input.current?.select()
152
+ }, [renaming])
153
+ if (renaming) {
154
+ const commit = (keep) => {
155
+ const value = input.current?.value ?? ''
156
+ if (!keep || value.trim() === '' || value.trim() === session.title) { actions.endAgentRename(); return }
157
+ // The editor closes only after the rename landed; a failure keeps it open.
158
+ void (async () => {
159
+ try {
160
+ await actions.renameAgentSession(agent.id, session.id, value)
161
+ actions.endAgentRename()
162
+ } catch (error) {
163
+ actions.reportError(error, 'agent-rename')
164
+ }
165
+ })()
166
+ }
167
+ return h('div', { className: 'bt-agent-sub-row bt-agent-edit', style: { '--i': index } },
168
+ h('input', {
169
+ ref: input, defaultValue: session.title, 'aria-label': t('Rename'),
170
+ onKeyDown: (event) => {
171
+ if (event.nativeEvent.isComposing) return
172
+ if (event.key === 'Enter') commit(true)
173
+ else if (event.key === 'Escape') commit(false)
174
+ },
175
+ onBlur: () => commit(true),
176
+ }))
177
+ }
178
+ return h('button', {
179
+ type: 'button', className: 'bt-agent-sub-row', 'aria-current': session.active ? 'page' : undefined, style: { '--i': index },
180
+ onClick: () => actions.openAgentSession(session.id),
181
+ onContextMenu: (event) => {
182
+ event.preventDefault()
183
+ event.stopPropagation()
184
+ actions.openMenu({ kind: 'agent-session', id: session.id, agentId: agent.id, x: event.clientX, y: event.clientY })
185
+ },
186
+ },
187
+ h('span', { className: 'bt-agent-sub-title' }, session.title),
188
+ h('span', { className: 'bt-agent-sub-time' }, session.at > 0 ? relativeShort(session.at) : ''))
189
+ }
190
+
191
+ // The DSH Agent row: a plain dsh Session list lives in the Bot workspace, so it
192
+ // sits among the Bots with the harness's own whale mark.
193
+ function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide, marked }) {
194
+ const info = useSessions(list => JSON.stringify(agent.sessions.map((id) => {
195
+ const row = list.byId[id]
196
+ return {
197
+ id,
198
+ // A blank Session's title is the workspace folder name; show the label instead.
199
+ title: row?.blank === true ? '' : (row?.displayTitle ?? row?.title ?? ''),
200
+ at: row?.updatedAt ?? 0,
201
+ running: row?.running === true,
202
+ active: (row?.retainedBy?.mainView ?? 0) > 0,
203
+ }
204
+ }).sort((a, b) => b.at - a.at)))
205
+ const statusInfo = useSessionStatus(map => JSON.stringify(agent.sessions.map(id => ({
206
+ id, running: map.get(id)?.running === true, unread: map.get(id)?.completionUnread === true,
207
+ }))))
208
+ const statuses = Object.fromEntries(JSON.parse(statusInfo).map(entry => [entry.id, entry]))
209
+ const sessions = JSON.parse(info).map(session => ({
210
+ ...session,
211
+ running: statuses[session.id]?.running ?? session.running,
212
+ unread: statuses[session.id]?.unread ?? false,
213
+ title: session.title === '' ? t('New session') : session.title,
214
+ }))
215
+ const renaming = useUi(value => value.renameAgent)
216
+ const active = sessions.some(session => session.active)
217
+ const running = sessions.some(session => session.running)
218
+ const unread = sessions.some(session => session.unread) || (marked && !active)
219
+ useMarkedUnread(agent.id, active, marked, actions)
220
+ const preview = sessions[0]?.title ?? t('New session')
221
+ const label = ['DSH Agent', running ? t('Working') : '', unread ? t('Unread activity') : ''].filter(Boolean).join(', ')
222
+ const open = active && wide
223
+ return h('div', { className: 'bt-agent' },
224
+ h('button', {
225
+ type: 'button', className: 'bt-row', 'aria-label': label, 'aria-current': active ? 'page' : undefined,
226
+ 'data-agent-id': agent.id, title: wide ? undefined : 'DSH Agent', onClick: () => actions.openAgent(agent.id),
227
+ onContextMenu: (event) => { event.preventDefault(); actions.openMenu({ kind: 'agent', id: agent.id, x: event.clientX, y: event.clientY }) },
228
+ },
229
+ h('span', { className: `bt-agent-ava${running ? ' bt-run' : ''}` }, h(FishLogo, { size: wide ? 22 : 24 })),
230
+ wide ? h('span', { className: 'bt-row-body' },
231
+ h('span', { className: 'bt-row-name' }, 'DSH Agent'),
232
+ preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,
233
+ wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true })
234
+ : !wide && unread && !active ? h('span', { className: 'bt-dot', 'aria-hidden': true }) : null),
235
+ h('div', { className: 'bt-agent-sub', 'data-open': open || undefined },
236
+ h('div', { className: 'bt-agent-sub-in' },
237
+ h('button', { type: 'button', className: 'bt-agent-sub-row bt-agent-new', style: { '--i': 0 }, onClick: () => { void actions.newAgentSession(agent.id).catch(error => actions.reportError(error, 'agent-session')) } },
238
+ h(PlusIcon), h('span', { className: 'bt-agent-sub-title' }, t('New session'))),
239
+ sessions.map((session, index) => h(AgentSessionRow, {
240
+ key: session.id, session, agent, actions, index: index + 1,
241
+ renaming: renaming === session.id,
242
+ })))))
243
+ }
244
+
245
+ // List rows glide to new places on a spring.
246
+ const GLIDE = springEasing(1000, 63)
247
+
248
+ function useListGlide(listRef, layout, key) {
249
+ const tops = useRef({ layout, map: new Map() })
250
+ useLayoutEffect(() => {
251
+ const list = listRef.current
252
+ if (!list) return
253
+ const next = new Map()
254
+ const still = reducedMotion() || tops.current.layout !== layout
255
+ for (const row of list.querySelectorAll('[data-bot-id],[data-room-id],[data-agent-id]')) {
256
+ const id = row.dataset.botId ?? row.dataset.roomId ?? row.dataset.agentId
257
+ // offsetTop ignores transforms, so a glide in flight does not skew the next one.
258
+ const top = row.offsetTop
259
+ next.set(id, top)
260
+ const before = tops.current.map.get(id)
261
+ if (!still && before !== undefined && Math.abs(before - top) > 0.5) {
262
+ row.animate([{ transform: `translateY(${before - top}px)` }, { transform: 'none' }], GLIDE)
263
+ }
264
+ }
265
+ tops.current = { layout, map: next }
266
+ }, [layout, key])
267
+ }
268
+
269
+ // In the Bot view the left column is ours, drawn on <body> over the shell's
270
+ // collapsed sidebar: the open column or the avatar rail push the conversation
271
+ // over, the drawer floats above it. Its right edge drags the open width, and
272
+ // down to the rail.
273
+ function LeftColumn({ mode, width, onGrip, leaving, children }) {
274
+ return createPortal(h('div', { className: 'bt-leftcol', 'data-left': mode, 'data-leaving': leaving || undefined, 'aria-hidden': leaving || undefined, style: { width: `${width}px` } },
275
+ children,
276
+ h('div', { className: 'bt-leftcol-grip', role: 'separator', 'aria-orientation': 'vertical', 'aria-label': t('Resize sidebar'), title: t('Resize sidebar'), onPointerDown: onGrip })), document.body)
277
+ }
278
+
279
+ // The top-left switch hides the whole column and brings it back. Under a
280
+ // Windows title bar it takes the shell's own place in the title band; elsewhere
281
+ // it shows only while the column is hidden, since the column's own top row
282
+ // carries it otherwise.
283
+ function TitleToggle({ hidden, onToggle }) {
284
+ if (typeof document === 'undefined') return null
285
+ const titlebar = document.documentElement.hasAttribute('data-windows-titlebar')
286
+ if (!titlebar && !hidden) return null
287
+ const label = t(hidden ? 'Expand sidebar' : 'Collapse sidebar')
288
+ return createPortal(h('button', {
289
+ type: 'button', className: titlebar ? 'bt-title-toggle' : 'bt-round bt-title-toggle', 'aria-label': label, title: label, onClick: onToggle,
290
+ }, h(SidebarIcon)), document.body)
291
+ }
292
+
293
+ // The Bot-API-down hint cannot send the user to Settings → Feedback: its
294
+ // diagnostics request needs the same API. What still works in this state is
295
+ // the last error this window recorded, and the engine's own startup output —
296
+ // its console, or the app's startup error box (#516).
297
+ const bootHint = () => {
298
+ const last = clientErrors().at(-1)?.text
299
+ return last === undefined
300
+ ? t('The Bot team could not start. The engine’s startup output — its console, or the app’s startup error box — has the cause.')
301
+ : t('The Bot team could not start. {error}. The engine’s startup output — its console, or the app’s startup error box — has the cause.', { error: last })
302
+ }
303
+
304
+ export function TeamSidebar(props) {
305
+ const { wide, useRoster, useUi, useSessions, actions } = props
306
+ const listRef = useRef(null)
307
+ const roster = useRoster(value => value)
308
+ const markedUnread = useUi(value => value.unread)
309
+ const uiNow = useUi(value => value)
310
+ props.useRegistry(value => value)
311
+ const frameSnap = props.useFrame ? props.useFrame(value => value) : { viewport: typeof window === 'undefined' ? 0 : window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0 }
312
+ const pref = props.useSidebarPref ? props.useSidebarPref(value => value) : 'open'
313
+ const layout = frameLayout({
314
+ viewport: frameSnap.viewport, sidebarWidth: frameSnap.sidebarWidth,
315
+ pref, drawer: uiNow.leftDrawer === true,
316
+ panel: uiNow.details ? { view: uiNow.view, yielded: uiNow.panelYield === true } : null,
317
+ })
318
+ // A drag of the column's edge shows where it would land, live.
319
+ const [drag, setDrag] = useState(null)
320
+ const mode = drag?.left ?? layout.left
321
+ // A hidden column stays mounted for its slide out; `shown` is the mode it last had.
322
+ const [held, leaving] = useLinger(mode === 'hidden' ? null : mode, SPRING_SHAPE.duration)
323
+ const shown = held ?? mode
324
+ const wideContent = shown !== 'rail'
325
+ const updated = useSessions(list => {
326
+ const stamps = {}
327
+ for (const id of list.ids) stamps[id] = list.byId[id]?.updatedAt ?? 0
328
+ return JSON.stringify(stamps)
329
+ })
330
+ const order = useMemo(() => {
331
+ const stamps = JSON.parse(updated)
332
+ const entries = [
333
+ ...roster.bots.filter(bot => bot.id !== roster.mainBotId).map(bot => ({ kind: 'bot', item: bot, at: stamps[currentPart(bot)] ?? bot.createdAt })),
334
+ ...roster.rooms.map(room => ({ kind: 'room', item: room, at: stamps[room.id] ?? room.createdAt })),
335
+ // The Agent sorts by its most recent Session, falling back to when it was added.
336
+ ...(roster.agents ?? []).map(agent => ({ kind: 'agent', item: agent, at: Math.max(0, ...agent.sessions.map(id => stamps[id] ?? 0)) || agent.createdAt })),
337
+ ]
338
+ return entries.sort((a, b) => Number(Boolean(b.item.pinned)) - Number(Boolean(a.item.pinned)) || b.at - a.at)
339
+ }, [roster, updated])
340
+ const main = roster.byId[roster.mainBotId]
341
+ useListGlide(listRef, wideContent, order.map(entry => entry.item.id).join(','))
342
+ useLandOnMainBot(roster, useSessions, actions)
343
+ useReportReady(roster.ready, roster)
344
+
345
+ // Our column pushes the conversation over by what it takes beyond the shell's
346
+ // collapsed track; a drawer floats over the rail's place, so it pushes as much
347
+ // as the rail and the chat stays put when it opens or closes.
348
+ const openWidth = drag?.width ?? frameSnap.sidebarWidth
349
+ const ourWidth = shown === 'rail' ? RAIL_WIDTH : openWidth
350
+ const pushed = mode === 'open' ? openWidth : mode === 'hidden' ? 0 : RAIL_WIDTH
351
+ useLayoutEffect(() => {
352
+ if (typeof document === 'undefined') return
353
+ chatRoom.setLeft(Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)))
354
+ }, [pushed, frameSnap.collapsedWidth])
355
+ useEffect(() => () => { if (typeof document !== 'undefined') chatRoom.setLeft(null) }, [])
356
+
357
+ // The edge drag: live while the pointer moves, the column's new state on release.
358
+ // Per frame the drag writes the column's own inline style and each conversation
359
+ // column's inline margin — the same path the panel's resize takes — so nothing
360
+ // re-renders or restyles the chat while the pointer moves. A render only happens
361
+ // when the drag crosses the rail's snap line, and the spring (`data-folding`)
362
+ // rides that switch alone: it comes off when the switch settles, so a drag that
363
+ // keeps going afterwards follows the cursor frame by frame again.
364
+ const settleTimer = useRef(0)
365
+ const springTimer = useRef(0)
366
+ const startDrag = (event) => {
367
+ if (event.button !== 0) return
368
+ event.preventDefault()
369
+ clearTimeout(settleTimer.current)
370
+ clearTimeout(springTimer.current)
371
+ const grip = event.currentTarget
372
+ const column = grip.parentElement
373
+ // A re-grab can land while a previous spring still stands: the new drag owns
374
+ // the column from here, so its fold state starts clean.
375
+ delete column.dataset.folding
376
+ grip.setPointerCapture?.(event.pointerId)
377
+ chatRoom.hold(true)
378
+ const columns = chatRoom.columns()
379
+ for (const col of columns) col.style.setProperty('transition', 'none', 'important')
380
+ const offLeft = frameSnap.collapsedWidth ?? 0
381
+ let last = null
382
+ let liveLeft = mode
383
+ let done = false
384
+ const write = (at) => {
385
+ const width = at.left === 'rail' ? RAIL_WIDTH : at.width
386
+ column.style.width = `${width}px`
387
+ column.style.setProperty('--bt-lc-w', `${width}px`)
388
+ const push = Math.max(0, (at.left === 'open' ? width : RAIL_WIDTH) - offLeft)
389
+ for (const col of columns) col.style.setProperty('margin-left', `${push}px`, 'important')
390
+ }
391
+ // A snap crossing arms the spring for the switch's glide; the timer takes it
392
+ // back off once the switch has had its duration.
393
+ let springUntil = 0
394
+ const springOff = () => {
395
+ springUntil = 0
396
+ delete column.dataset.folding
397
+ for (const col of columns) col.style.setProperty('transition', 'none', 'important')
398
+ }
399
+ const springOn = () => {
400
+ column.dataset.folding = ''
401
+ for (const col of columns) col.style.setProperty('transition', `margin-left ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}`, 'important')
402
+ springUntil = performance.now() + SPRING_SHAPE.duration
403
+ clearTimeout(springTimer.current)
404
+ springTimer.current = setTimeout(springOff, SPRING_SHAPE.duration)
405
+ }
406
+ const track = (x) => {
407
+ last = dragColumn(x, window.innerWidth)
408
+ if (last.left !== liveLeft) {
409
+ liveLeft = last.left
410
+ if (!reducedMotion()) springOn()
411
+ setDrag(last)
412
+ }
413
+ write(last)
414
+ }
415
+ const onMove = (move) => track(move.clientX)
416
+ // The rules and props take the landed geometry back over; while the fold's
417
+ // spring still runs this waits it out so the landing does not snap. The
418
+ // inline `width` stays: it is the landed geometry, and React writes its width
419
+ // prop only when the value changes, so removing it would leave the edge at
420
+ // its CSS fallback (57px on the rail).
421
+ const finish = () => {
422
+ clearTimeout(springTimer.current)
423
+ if (column.isConnected && last !== null) chatRoom.setLeft(Math.max(0, (last.left === 'open' ? last.width : RAIL_WIDTH) - offLeft))
424
+ for (const col of columns) { col.style.removeProperty('margin-left'); col.style.removeProperty('transition') }
425
+ column.style.removeProperty('--bt-lc-w')
426
+ delete column.dataset.folding
427
+ chatRoom.hold(false)
428
+ }
429
+ const ends = ['pointerup', 'pointercancel', 'lostpointercapture']
430
+ const onEnd = (end) => {
431
+ if (done) return
432
+ done = true
433
+ if (end.type === 'pointerup') track(end.clientX)
434
+ grip.removeEventListener('pointermove', onMove)
435
+ for (const name of ends) grip.removeEventListener(name, onEnd)
436
+ setDrag(null)
437
+ if (last === null) { finish(); return }
438
+ // The drag is the latest explicit gesture: it takes back a yielded panel's room.
439
+ actions.setPanelYield?.(false)
440
+ if (last.left === 'rail') { actions.setLeftDrawer?.(false); actions.setSidebarPref?.('rail') }
441
+ else {
442
+ actions.setSidebarWidth?.(last.width)
443
+ actions.setSidebarPref?.('open')
444
+ actions.setLeftDrawer?.(last.left === 'drawer')
445
+ }
446
+ if (springUntil === 0) finish()
447
+ else settleTimer.current = setTimeout(finish, Math.max(0, springUntil - performance.now()) + 60)
448
+ }
449
+ grip.addEventListener('pointermove', onMove)
450
+ for (const name of ends) grip.addEventListener(name, onEnd)
451
+ }
452
+
453
+ // In the Bot view the shell's own sidebar stays collapsed under our column. A
454
+ // flip we did not ask for is the user's own switch gesture (the shell's button
455
+ // or shortcut where it still reaches), unless the width just crossed the
456
+ // shell's auto-collapse line, which re-applies the shell's own rule.
457
+ const dsh = useRef(null)
458
+ const requested = useRef(false)
459
+ // The request mark always lapses on its own: a re-render before the shell's
460
+ // flip must not leave it set, or the user's next switch would read as ours.
461
+ // A lapse checks the shell again, since our flip and another one landing in
462
+ // the same frame cancel out and no flip arrives to settle it.
463
+ const requestLapse = useRef(0)
464
+ const [lapsed, setLapsed] = useState(0)
465
+ useEffect(() => () => clearTimeout(requestLapse.current), [])
466
+ // The window's own resize event lands before the shell's next-frame measure,
467
+ // so it dates a width change even while our frame source still holds the old one.
468
+ const resizedAt = useRef(0)
469
+ useEffect(() => {
470
+ const onResize = () => { resizedAt.current = performance.now() }
471
+ window.addEventListener('resize', onResize)
472
+ return () => window.removeEventListener('resize', onResize)
473
+ }, [])
474
+ const quiet = (on) => {
475
+ // Our own collapse of the shell's sidebar lands at once: its slide would drag
476
+ // the conversation across under our column.
477
+ if (on) document.documentElement.setAttribute('data-bt-collapsing', '')
478
+ else document.documentElement.removeAttribute('data-bt-collapsing')
479
+ }
480
+ useEffect(() => () => quiet(false), [])
481
+ useLayoutEffect(() => {
482
+ if (typeof document === 'undefined' || typeof actions.toggleSidebar !== 'function') return undefined
483
+ const collapsed = dshCollapsed() ?? !wide
484
+ const prev = dsh.current
485
+ const viewport = window.innerWidth
486
+ dsh.current = { collapsed, viewport }
487
+ if (prev !== null && collapsed !== prev.collapsed) {
488
+ if (requested.current) requested.current = false
489
+ else if (!collapsed && userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {
490
+ toggleRef.current()
491
+ }
492
+ }
493
+ if (collapsed) { requested.current = false; quiet(false); return undefined }
494
+ if (requested.current) return undefined
495
+ requested.current = true
496
+ quiet(true)
497
+ actions.toggleSidebar()
498
+ clearTimeout(requestLapse.current)
499
+ requestLapse.current = setTimeout(() => { requested.current = false; quiet(false); setLapsed(value => value + 1) }, 300)
500
+ return undefined
501
+ }, [wide, frameSnap.viewport, lapsed])
502
+
503
+ // The drawer closes on a row pick, on Escape and on a press outside it.
504
+ useEffect(() => {
505
+ if (mode !== 'drawer') return undefined
506
+ const onDown = (event) => {
507
+ if (event.target instanceof Element && event.target.closest('.bt-leftcol')) return
508
+ actions.setLeftDrawer?.(false)
509
+ }
510
+ const onKey = (event) => {
511
+ if (event.key !== 'Escape') return
512
+ event.stopPropagation()
513
+ actions.setLeftDrawer?.(false)
514
+ }
515
+ window.addEventListener('mousedown', onDown)
516
+ window.addEventListener('keydown', onKey, true)
517
+ return () => { window.removeEventListener('mousedown', onDown); window.removeEventListener('keydown', onKey, true) }
518
+ }, [mode])
519
+
520
+ const navigate = (open, id) => {
521
+ const result = open(id)
522
+ if (uiNow.leftDrawer === true) actions.setLeftDrawer?.(false)
523
+ return result
524
+ }
525
+ const rowActions = {
526
+ ...actions,
527
+ openSession: id => navigate(actions.openSession, id),
528
+ openAgent: id => navigate(actions.openAgent, id),
529
+ openAgentSession: id => navigate(actions.openAgentSession, id),
530
+ newAgentSession: id => navigate(actions.newAgentSession, id),
531
+ }
532
+ const rowProps = { roster, actions: rowActions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide: wideContent }
533
+ // Typing while the sidebar has focus starts a search.
534
+ const typeToSearch = (event) => {
535
+ if (event.defaultPrevented || event.key.length !== 1 || event.key === ' ' || event.metaKey || event.ctrlKey || event.altKey || event.nativeEvent.isComposing) return
536
+ if (event.target instanceof Element && event.target.closest('input,textarea,[contenteditable]')) return
537
+ event.preventDefault()
538
+ actions.openPalette(event.key)
539
+ }
540
+ // The switch (top-left button, the shortcut) hides the whole column or brings
541
+ // back the one it hid.
542
+ const onToggle = () => actions.toggleLeftHidden?.()
543
+ // The shell's sidebar shortcut is caught on its way down, before the shell's
544
+ // own listener on window sees it: left to the shell, it would expand the shell's
545
+ // sidebar first and our sync would pull it back, a visible flash.
546
+ const toggleRef = useRef(onToggle)
547
+ toggleRef.current = onToggle
548
+ useEffect(() => {
549
+ const onKey = (event) => {
550
+ if (event.defaultPrevented || event.isComposing || !pressesShellShortcut(event, 'sidebar.left.toggle')) return
551
+ if (event.target instanceof Element && event.target.closest('.xterm')) return
552
+ if (document.querySelector('[aria-modal="true"]')) return
553
+ event.preventDefault()
554
+ event.stopPropagation()
555
+ toggleRef.current()
556
+ }
557
+ document.addEventListener('keydown', onKey, true)
558
+ return () => document.removeEventListener('keydown', onKey, true)
559
+ }, [])
560
+ const top = wideContent
561
+ ? h('div', { className: 'bt-side-top' },
562
+ h('span', { className: 'bt-brand' }, h(BrandName)),
563
+ h(UpdateButton, { useUpdate: props.useUpdate, actions }),
564
+ h('button', { type: 'button', className: 'bt-round', 'aria-label': t('Search'), title: t('Search'), onClick: () => actions.openPalette() }, h(SearchIcon)),
565
+ h('button', { type: 'button', className: 'bt-round', 'aria-label': t('New…'), title: t('New…'), onClick: () => actions.openNewChat('new') }, h(PlusIcon)),
566
+ h('button', { type: 'button', className: 'bt-round bt-side-collapse', 'aria-label': t('Collapse sidebar'), title: t('Collapse sidebar'), onClick: onToggle }, h(SidebarIcon)))
567
+ : h('div', { className: 'bt-rail-top' },
568
+ h(UpdateButton, { useUpdate: props.useUpdate, actions }),
569
+ h('button', { type: 'button', className: 'bt-round bt-side-collapse', 'aria-label': t('Collapse sidebar'), title: t('Collapse sidebar'), onClick: onToggle }, h(SidebarIcon)),
570
+ main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, uiNow.bootFailed ? bootHint() : t('Setting up your Main Bot…')),
571
+ h('span', { className: 'bt-rail-sep', 'aria-hidden': true }))
572
+ // The foot stands in for the shell's hidden footer: the account avatar, and on
573
+ // the rail the new-chat button above it.
574
+ const foot = wideContent
575
+ ? h('div', { className: 'bt-leftcol-foot' }, h(AccountLauncher, { seat: false, actions }))
576
+ : h('div', { className: 'bt-leftcol-foot bt-leftcol-foot-rail' },
577
+ h('button', { type: 'button', className: 'bt-round', 'aria-label': t('New…'), title: t('New…'), onClick: () => actions.openNewChat('new') }, h(PlusIcon)),
578
+ h(AccountLauncher, { seat: false, actions }))
579
+ const content = h('div', { className: wideContent ? 'bt-side' : 'bt-side bt-rail', onKeyDown: typeToSearch },
580
+ top,
581
+ wideContent && roster.readOnly ? h('div', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,
582
+ h('div', { ref: listRef, className: 'bt-list', role: 'region', 'aria-label': t('Bot list') },
583
+ wideContent ? (main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, uiNow.bootFailed ? bootHint() : t('Setting up your Main Bot…'))) : null,
584
+ order.map(entry => (entry.kind === 'bot'
585
+ ? h(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true })
586
+ : entry.kind === 'room'
587
+ ? h(RoomRow, { key: entry.item.id, ...rowProps, room: entry.item, marked: markedUnread[entry.item.id] === true })
588
+ : h(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true })))),
589
+ foot)
590
+ return h(Fragment, null,
591
+ h(TitleToggle, { hidden: mode === 'hidden', onToggle }),
592
+ shown === 'hidden' ? null : h(LeftColumn, { mode: shown, width: ourWidth, onGrip: startDrag, leaving }, content))
593
+ }
594
+
595
+ // The update button at the sidebar's top right: a cloud while a newer DS Bot —
596
+ // or a newer verified DSH — is available, then the install's progress and
597
+ // result. Its card has one row each for the bot and DSH, with their versions,
598
+ // the release notes link, and each row's own button.
599
+ function UpdateButton({ useUpdate, actions }) {
600
+ const update = useUpdate(value => value)
601
+ const [open, setOpen] = useState(false)
602
+ const [box, setBox] = useState(null)
603
+ const [error, setError] = useState('')
604
+ const [dshError, setDshError] = useState('')
605
+ const button = useRef(null)
606
+ useEffect(() => {
607
+ if (!open) return undefined
608
+ const onDown = (event) => {
609
+ if (event.target instanceof Element && (event.target.closest('.bt-update-pop') || button.current?.contains(event.target))) return
610
+ setOpen(false)
611
+ }
612
+ const onKey = (event) => { if (event.key === 'Escape') { event.stopPropagation(); setOpen(false); button.current?.focus() } }
613
+ window.addEventListener('mousedown', onDown)
614
+ window.addEventListener('keydown', onKey, true)
615
+ return () => { window.removeEventListener('mousedown', onDown); window.removeEventListener('keydown', onKey, true) }
616
+ }, [open])
617
+ const phase = update?.phase ?? 'idle'
618
+ const dsh = update?.dsh
619
+ const dshPhase = dsh?.phase ?? 'idle'
620
+ const dshRow = showsDshRow(dsh, update?.app)
621
+ // Hooks first: an update that turns visible after the sidebar mounted would
622
+ // otherwise add hooks on a later render and crash the slot.
623
+ const tick = useViewport()
624
+ useLayoutEffect(() => {
625
+ if (!open) return
626
+ const rect = button.current?.getBoundingClientRect()
627
+ if (rect) setBox({ left: Math.max(8, Math.min(rect.left, window.innerWidth - 288)), top: rect.bottom + 6 })
628
+ }, [open, tick])
629
+ if (!update?.available && !dshRow && phase === 'idle' && dshPhase === 'idle') return null
630
+ const cloudPhase = phase === 'installing' || dshPhase === 'installing' ? 'installing' : phase !== 'idle' ? phase : dshPhase
631
+ const toggle = () => setOpen(value => !value)
632
+ const start = () => {
633
+ setError('')
634
+ void actions.installUpdate().catch(failure => setError(hostText(failure?.message ?? String(failure))))
635
+ }
636
+ const startDsh = () => {
637
+ setDshError('')
638
+ void actions.installDshUpdate().catch(failure => setDshError(hostText(failure?.message ?? String(failure))))
639
+ }
640
+ const label = phase === 'installing' ? t('Updating DS Bot…')
641
+ : dshPhase === 'installing' ? t('Updating DSH…')
642
+ : phase === 'installed' ? t('DS Bot {version} is installed. Restart DSH to use it.', { version: update.installed ?? update.latest })
643
+ : phase === 'updated' ? t('DS Bot {version} is installed.', { version: update.installed ?? update.latest })
644
+ : dshPhase === 'installed' ? t('Restart DSH to start using DSH {version}.', { version: dsh.installed ?? dsh.verified })
645
+ : update?.available ? t('DS Bot {version} is available', { version: update.latest })
646
+ : t('DSH {version} is available', { version: dsh?.verified })
647
+ const message = error || (phase === 'failed' ? update.error : '')
648
+ const dshMessage = dshError || (dshPhase === 'failed' ? dsh?.error : '')
649
+ const dshText = dshPhase === 'installed'
650
+ ? t('Restart DSH to start using DSH {version}.', { version: dsh.installed ?? dsh.verified })
651
+ : dsh?.available === false && dsh?.blockedBy
652
+ ? t('Update DS Bot {version} first.', { version: dsh.blockedBy })
653
+ : t('You have {version}.', { version: dsh?.current })
654
+ return h(Fragment, null,
655
+ h('button', {
656
+ ref: button, type: 'button', className: 'bt-round bt-update', 'data-phase': cloudPhase, 'aria-label': label, title: label,
657
+ 'aria-haspopup': 'dialog', 'aria-expanded': open, onClick: toggle,
658
+ }, h(CloudDownloadIcon, { done: phase === 'installed' || phase === 'updated' }), phase === 'failed' || dshPhase === 'failed' ? h('span', { className: 'bt-update-dot', 'aria-hidden': true }) : null),
659
+ open && box ? createPortal(h('div', { className: 'bt-update-pop', role: 'dialog', 'aria-label': update?.available || phase !== 'idle' ? t('DS Bot update') : t('DSH update'), style: box },
660
+ update?.available || phase !== 'idle' ? h(Fragment, null,
661
+ h('div', { className: 'bt-update-title' }, phase === 'installed' || phase === 'updated' ? t('Update installed') : t('DS Bot {version}', { version: update.latest })),
662
+ h('div', { className: 'bt-update-text' }, phase === 'installed'
663
+ ? t('Restart DSH to start using DS Bot {version}.', { version: update.installed ?? update.latest })
664
+ : phase === 'updated' ? t('DS Bot {version} is installed.', { version: update.installed ?? update.latest })
665
+ : t('You have {version}.', { version: update.current })),
666
+ message ? h('div', { className: 'bt-update-error', role: 'alert' }, t('The update did not finish: {reason}', { reason: message })) : null,
667
+ h('div', { className: 'bt-update-actions' },
668
+ update.notesUrl ? h('a', { className: 'bt-update-notes', href: update.notesUrl, target: '_blank', rel: 'noopener noreferrer' }, t("What's new")) : null,
669
+ phase === 'installed' || phase === 'updated' ? null : h('button', {
670
+ type: 'button', className: 'bt-update-go', disabled: phase === 'installing', onClick: start,
671
+ }, phase === 'installing' ? t('Updating…') : phase === 'failed' ? t('Try again') : t('Update')))) : null,
672
+ dshRow ? h('div', { className: 'bt-update-dsh' },
673
+ h('div', { className: 'bt-update-title' }, t('DSH {version}', { version: dsh.verified })),
674
+ h('div', { className: 'bt-update-text' }, dshText),
675
+ dshMessage ? h('div', { className: 'bt-update-error', role: 'alert' }, t('The update did not finish: {reason}', { reason: dshMessage })) : null,
676
+ h('div', { className: 'bt-update-actions' },
677
+ dsh.kind === 'app' ? (dsh.available
678
+ ? h('button', { type: 'button', className: 'bt-update-go', onClick: () => void actions.openAppUpdates(dsh.verified).catch(() => {}) }, t('Open updates'))
679
+ : null)
680
+ : !dsh.available && dshPhase === 'idle' ? null
681
+ : dshPhase === 'installed' ? null
682
+ : h('button', {
683
+ type: 'button', className: 'bt-update-go', disabled: dshPhase === 'installing', onClick: startDsh,
684
+ }, dshPhase === 'installing' ? t('Updating…') : dshPhase === 'failed' ? t('Try again') : t('Update')))) : null), document.body) : null)
685
+ }
686
+
687
+ // Account seat of the Settings trigger: the visible label stays for assistive tech only.
688
+ export function YouAvatar() {
689
+ return h('span', { className: 'bt-you-wrap' },
690
+ h('span', { className: 'bt-you', 'aria-hidden': true }, h(GearIcon)),
691
+ h('span', { style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden', clip: 'rect(0 0 0 0)' } }, t('Settings')))
692
+ }
693
+
694
+ let openShellSettings = null
695
+ let openShellOnboarding = null
696
+ let shellShortcuts = null
697
+
698
+ export function holdShellShortcuts(shortcuts) {
699
+ shellShortcuts = shortcuts
700
+ return () => { if (shellShortcuts === shortcuts) shellShortcuts = null }
701
+ }
702
+
703
+ // DeepSeek Harness hands its settings opener only to the settings.launcher seat. When
704
+ // the Desktop's account menu holds that seat, its first item (Settings) is the way in;
705
+ // the Desktop on Windows and macOS takes shortcuts natively, so a synthetic key press
706
+ // reaches the shell only where the page delivers them (the Web, Linux).
707
+ export function openHarnessSettings() {
708
+ // A frame first, so a Bot dialog that closes on this click leaves the modal stack.
709
+ requestAnimationFrame(() => {
710
+ if (openShellSettings) { openShellSettings(); return }
711
+ const desktop = document.querySelector('button[aria-haspopup="menu"][data-signed-out]')
712
+ if (desktop) openThroughMenu(desktop)
713
+ else pressSettingsShortcut()
714
+ })
715
+ }
716
+
717
+ // Opens one of the shell's own onboarding editors, such as the DeepSeek API key form.
718
+ export function openHarnessOnboarding(id) {
719
+ requestAnimationFrame(() => {
720
+ if (openShellOnboarding) openShellOnboarding(id)
721
+ else openHarnessSettings()
722
+ })
723
+ }
724
+
725
+ // The launcher seat can only open DSH's settings on their first section. This onboarding
726
+ // step of DS Bot's own, opened by id, hands the shell's openSection the Models page; the
727
+ // first-run pass meets it last and it steps aside at once.
728
+ export const MODELS_STEP = 'ds-bot-models'
729
+ export const MODELS_STEP_ORDER = 1000
730
+
731
+ export function OpenModelsStep({ explicit, complete, openSection }) {
732
+ useEffect(() => {
733
+ if (explicit) {
734
+ if (typeof openSection === 'function') openSection('models')
735
+ else openHarnessSettings()
736
+ }
737
+ complete()
738
+ }, [explicit])
739
+ return null
740
+ }
741
+
742
+ function openThroughMenu(trigger) {
743
+ const before = new Set(document.querySelectorAll('[role="menu"]'))
744
+ trigger.click()
745
+ let frames = 0
746
+ const look = () => {
747
+ const menu = [...document.querySelectorAll('[role="menu"]')].find(node => !before.has(node))
748
+ const item = menu?.querySelector('button[role="menuitem"]')
749
+ if (item) item.click()
750
+ else if (++frames < 30) requestAnimationFrame(look)
751
+ else pressSettingsShortcut()
752
+ }
753
+ requestAnimationFrame(look)
754
+ }
755
+
756
+ function pressSettingsShortcut() {
757
+ const binding = shellShortcuts?.catalog.getSnapshot().find(row => row.id === 'settings.open')?.binding
758
+ if (!binding) return
759
+ const held = new Set(binding.modifiers)
760
+ window.dispatchEvent(new KeyboardEvent('keydown', {
761
+ code: binding.code, key: binding.code === 'Comma' ? ',' : '', bubbles: true, cancelable: true,
762
+ ctrlKey: held.has('control'), altKey: held.has('alt'), shiftKey: held.has('shift'), metaKey: held.has('meta'),
763
+ }))
764
+ }
765
+
766
+ // Whether a key press is the shell's current binding for one of its shortcuts.
767
+ function pressesShellShortcut(event, id) {
768
+ const binding = shellShortcuts?.catalog.getSnapshot().find(row => row.id === id)?.binding
769
+ if (!binding) return false
770
+ const held = new Set(binding.modifiers)
771
+ return event.code === binding.code && event.ctrlKey === held.has('control') && event.altKey === held.has('alt')
772
+ && event.shiftKey === held.has('shift') && event.metaKey === held.has('meta')
773
+ }
774
+
775
+ const NO_SUBSCRIBE = () => () => {}
776
+ const NO_SNAPSHOT = () => null
777
+
778
+ // The footer avatar opens an account menu above itself, with Bot settings as one
779
+ // entry. Shell panels hidden from the Bot sidebar (plugins, automation) live here too.
780
+ // `seat` is the shell's settings.launcher seat: at priority -10 the whale wins it
781
+ // over a shell account plugin's own launcher (the Desktop's "··· More"), which comes
782
+ // back in Agent mode; FooterAccount stands in while no seat exists at all.
783
+ export function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboarding, actions }) {
784
+ const [open, setOpen] = useState(false)
785
+ useLayoutEffect(() => {
786
+ if (!seat) return undefined
787
+ actions.seatAccount(true)
788
+ return () => actions.seatAccount(false)
789
+ }, [seat])
790
+ const [box, setBox] = useState(null)
791
+ const button = useRef(null)
792
+ useEffect(() => { if (settingsOpen) setOpen(false) }, [settingsOpen])
793
+ // The settings dialog links back to the shell's own settings (models, providers).
794
+ useEffect(() => {
795
+ if (!openSettings) return undefined
796
+ openShellSettings = openSettings
797
+ return () => { if (openShellSettings === openSettings) openShellSettings = null }
798
+ }, [openSettings])
799
+ useEffect(() => {
800
+ if (!openOnboarding) return undefined
801
+ openShellOnboarding = openOnboarding
802
+ return () => { if (openShellOnboarding === openOnboarding) openShellOnboarding = null }
803
+ }, [openOnboarding])
804
+ useEffect(() => {
805
+ if (!open) return undefined
806
+ const onDown = (event) => {
807
+ if (event.target instanceof Element && (event.target.closest('.bt-account-menu') || button.current?.contains(event.target))) return
808
+ setOpen(false)
809
+ }
810
+ const onKey = (event) => { if (event.key === 'Escape') { event.stopPropagation(); setOpen(false); button.current?.focus() } }
811
+ window.addEventListener('mousedown', onDown)
812
+ window.addEventListener('keydown', onKey, true)
813
+ return () => { window.removeEventListener('mousedown', onDown); window.removeEventListener('keydown', onKey, true) }
814
+ }, [open])
815
+ // The shell's account plugin lends its sign-out operation; the item shows only
816
+ // when the plugin's entry is there and its account snapshot says signed in. The
817
+ // entry can arrive after this mounts, so its operations follow the entry.
818
+ const signIn = actions.signInEntry?.() ?? null
819
+ const ops = useMemo(() => signIn?.inject?.() ?? {}, [signIn])
820
+ const accountSource = ops.hooks?.account
821
+ const account = useSyncExternalStore(accountSource?.subscribe ?? NO_SUBSCRIBE, accountSource ? () => accountSource.getSnapshot() : NO_SNAPSHOT)
822
+ const signedIn = signIn !== null && typeof ops.signOut === 'function' && account?.view?.status === 'credential-stored'
823
+ const signedOut = signIn !== null && typeof actions.signIn === 'function' && account?.view?.status === 'signed-out'
824
+ const accountT = actions.accountT?.() ?? (key => key)
825
+ const [confirm, setConfirm] = useState(null)
826
+ const [busy, setBusy] = useState(false)
827
+ const [signOutError, setSignOutError] = useState('')
828
+ const askSignOut = async () => {
829
+ setSignOutError('')
830
+ let state = 'none'
831
+ try {
832
+ if (await ops.hasRunningAccountTasks?.()) state = 'running'
833
+ } catch { state = 'unknown' }
834
+ setConfirm(state)
835
+ }
836
+ const cancelSignOut = () => { setConfirm(null); setSignOutError('') }
837
+ const runSignOut = async () => {
838
+ setBusy(true)
839
+ setSignOutError('')
840
+ try {
841
+ await ops.signOut()
842
+ setConfirm(null)
843
+ setOpen(false)
844
+ } catch (error) {
845
+ setSignOutError(String(error?.message ?? error))
846
+ } finally {
847
+ setBusy(false)
848
+ }
849
+ }
850
+ const tick = useViewport()
851
+ const anchor = () => {
852
+ const rect = button.current?.getBoundingClientRect()
853
+ if (rect) setBox({ left: rect.left, bottom: viewBottom() - rect.top + 5 })
854
+ }
855
+ useLayoutEffect(() => { if (open) anchor() }, [open, tick])
856
+ const toggle = () => { if (!open) anchor(); setOpen(value => !value) }
857
+ // Closing the menu drops a half-finished sign-out confirm with it.
858
+ useEffect(() => {
859
+ if (open) return
860
+ setConfirm(null)
861
+ setSignOutError('')
862
+ setBusy(false)
863
+ }, [open])
864
+ // DS Bot's Models page where the host serves the providers, else DSH's own.
865
+ const openModels = actions.providers ? actions.openModels : actions.openHarnessModels
866
+ const groups = [
867
+ [
868
+ [t('Usage'), GaugeIcon, () => actions.openSettings('usage')],
869
+ openModels ? [t('Models and API keys'), SlidersIcon, () => openModels()] : null,
870
+ [t('Connectors'), ConnectorIcon, () => actions.openConnectors()],
871
+ [t('Automation tasks'), ClockIcon, () => actions.selectPanel('schedules')],
872
+ [t('Bot settings'), GearIcon, () => actions.openSettings('general')],
873
+ ].filter(Boolean),
874
+ [
875
+ [t('Switch to classic Agent mode'), SwitchIcon, () => actions.setSurface('agent')],
876
+ ],
877
+ ]
878
+ if (signedIn) groups.push([[accountT('signOut'), SignOutIcon, askSignOut, undefined, true]])
879
+ else if (signedOut) groups.push([[t('Sign in to DeepSeek'), SignInIcon, () => actions.signIn()]])
880
+ return h(Fragment, null,
881
+ h('button', { ref: button, type: 'button', className: 'bt-account', 'aria-label': t('Account'), 'aria-haspopup': 'menu', 'aria-expanded': open, onClick: toggle },
882
+ h('span', { className: 'bt-you', 'aria-hidden': true }, h(GearIcon))),
883
+ open && box ? createPortal(h('div', { className: 'bt-menu bt-menu-up bt-account-menu', role: 'menu', 'aria-label': t('Account'), style: box },
884
+ confirm !== null ? h('div', { className: 'bt-confirm', role: 'alertdialog', 'aria-label': accountT('signOut') },
885
+ h('p', { className: 'bt-confirm-text' }, accountT(confirm === 'running' ? 'signOutRunningDescription' : confirm === 'unknown' ? 'signOutUnknownDescription' : 'signOutDescription')),
886
+ signOutError !== '' ? h('p', { className: 'bt-confirm-error', role: 'alert' }, signOutError) : null,
887
+ h('div', { className: 'bt-confirm-row' },
888
+ h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: cancelSignOut }, t('Cancel')),
889
+ h('button', { type: 'button', className: 'bt-confirm-go', disabled: busy, onClick: () => { void runSignOut() } }, accountT('signOut'))))
890
+ : groups.map((group, index) => h(Fragment, { key: index },
891
+ index > 0 ? h('div', { className: 'bt-menu-sep', role: 'separator' }) : null,
892
+ group.map(([label, Icon, run, hint, stay]) => h('button', {
893
+ key: label, type: 'button', role: 'menuitem',
894
+ onClick: () => { if (stay !== true) setOpen(false); void Promise.resolve(run()).catch(error => actions.reportError(error, 'menu')) },
895
+ }, h(Icon), h('span', { className: 'bt-menu-label' }, label), hint ? h('span', { className: 'bt-menu-hint' }, hint) : null))))), document.body) : null)
896
+ }
897
+
898
+ // The desktop app keeps its main window hidden until the team interface has drawn
899
+ // the first state, and shows its failure page when that never comes. The report
900
+ // says where the Main Bot's avatar is when it wears the start window's whale: the
901
+ // start window hands that whale over at the top of its jump, and it glides onto
902
+ // the avatar here.
903
+ let readyReported = false
904
+ function useReportReady(drawn, roster) {
905
+ useEffect(() => {
906
+ if (!drawn || readyReported) return
907
+ readyReported = true
908
+ void Promise.resolve().then(() => {
909
+ const app = globalThis.dsBotApp
910
+ if (typeof app?.ready !== 'function') return undefined
911
+ // The place is a nicety: whatever goes wrong measuring it, the report still goes.
912
+ let place
913
+ try { place = mainAvatarPlace(roster) } catch { place = undefined }
914
+ if (place === undefined) return app.ready()
915
+ const mainId = roster.mainBotId
916
+ app.onHandoff?.((from) => { try { glideOnto(mainMarkOf(mainId), from) } catch (error) { quietly('handoff')(error) } })
917
+ return app.ready(place)
918
+ }).catch(quietly('app ready'))
919
+ }, [drawn])
920
+ }
921
+
922
+ function mainMarkOf(id) {
923
+ if (typeof document === 'undefined') return null
924
+ const key = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(id) : id
925
+ return document.querySelector(`.bt-side [data-bot-id="${key}"] .bt-mark`)
926
+ }
927
+
928
+ // The Main Bot's avatar in the team column, in CSS px of the page, with the page's size.
929
+ // Only the default look: a photo or another character would not match the start window's whale.
930
+ function mainAvatarPlace(roster) {
931
+ const main = roster?.byId?.[roster.mainBotId]
932
+ if (main === undefined || main.avatar?.image || typeof document === 'undefined') return undefined
933
+ const look = lookOf(main)
934
+ if (look.shape !== MAIN_LOOK.shape || look.color !== MAIN_LOOK.color) return undefined
935
+ const mark = mainMarkOf(main.id)
936
+ // Not the opacity: the column fades in as it first draws, which is when this is measured.
937
+ if (!mark || mark.checkVisibility?.({ visibilityProperty: true }) === false) return undefined
938
+ const box = mark.getBoundingClientRect()
939
+ const view = document.documentElement
940
+ return { x: box.left, y: box.top, width: box.width, height: box.height, viewportWidth: globalThis.innerWidth ?? view.clientWidth, viewportHeight: globalThis.innerHeight ?? view.clientHeight }
941
+ }
942
+
943
+ // The whale the start window hands over (app/src/start-window.mjs): `from` is where it is on
944
+ // this page at the top of its jump. A copy of the avatar waits there for `hold` ms, while the two
945
+ // windows cross-fade, then glides onto the avatar in one compositor animation, so the jump does
946
+ // not stutter the way a window that resizes under it would. x and y ease differently, so the path
947
+ // bows upward; the avatar itself is hidden until the copy is on it, then gives a small bounce.
948
+ // Hidden by opacity, not visibility: the copy draws through the avatar's own masks (same ids),
949
+ // which a hidden avatar would stop drawing.
950
+ const GLIDE_MS = 460
951
+ function glideOnto(mark, from) {
952
+ if (!mark || reducedMotion()) return
953
+ const box = mark.getBoundingClientRect()
954
+ if (!box.width) return
955
+ const outer = document.createElement('div')
956
+ const inner = document.createElement('div')
957
+ const copy = mark.cloneNode(true)
958
+ copy.removeAttribute('data-live')
959
+ Object.assign(outer.style, { position: 'fixed', left: `${box.left}px`, top: `${box.top}px`, width: `${box.width}px`, height: `${box.height}px`, zIndex: '2147483647', pointerEvents: 'none' })
960
+ Object.assign(inner.style, { width: '100%', height: '100%', transformOrigin: '0 0' })
961
+ Object.assign(copy.style, { width: '100%', height: '100%' })
962
+ copy.style.setProperty('--bt-ink-deepseek', getComputedStyle(mark).getPropertyValue('--bt-ink-deepseek'))
963
+ inner.append(copy)
964
+ outer.append(inner)
965
+ outer.setAttribute('aria-hidden', 'true')
966
+ document.body.append(outer)
967
+ mark.style.opacity = '0'
968
+ const timing = { delay: Math.max(0, Number(from.hold) || 0), duration: GLIDE_MS, fill: 'both' }
969
+ outer.animate([{ transform: `translateX(${from.x - box.left}px)` }, { transform: 'none' }], { ...timing, easing: 'cubic-bezier(.45,0,.25,1)' })
970
+ const glide = inner.animate([{ transform: `translateY(${from.y - box.top}px) scale(${from.size / box.width})` }, { transform: 'none' }], { ...timing, easing: 'cubic-bezier(.2,.65,.3,1)' })
971
+ let landed = false
972
+ const land = () => {
973
+ if (landed) return
974
+ landed = true
975
+ outer.remove()
976
+ mark.style.opacity = ''
977
+ mark.animate([{ transform: 'scale(1.08, .92)' }, { transform: 'none' }], { duration: SPRING_POP.duration, easing: SPRING_POP.easing })
978
+ }
979
+ glide.finished.then(land, land)
980
+ // A hidden page stops ticking animations: the avatar comes back regardless.
981
+ setTimeout(land, timing.delay + GLIDE_MS + 500)
982
+ }
983
+
984
+ // Opens the Main Bot whenever the main view holds no Bot conversation, the way
985
+ // The view always lands on a Bot rather than an empty New Session page.
986
+ // When a Bot's chat moves on to a fresh part, the shell clears the view of the part
987
+ // it archived; the chat then goes on in the Bot's current part instead.
988
+ function useLandOnMainBot(roster, useSessions, actions) {
989
+ const mainView = useSessions((list) => {
990
+ const row = Object.values(list.byId).find(session => (session?.retainedBy?.mainView ?? 0) > 0)
991
+ return row ? `${row.id}|${row.blank ? 1 : 0}` : ''
992
+ })
993
+ const lastBot = useRef(null)
994
+ useEffect(() => {
995
+ if (!roster.ready || !roster.mainBotId) return undefined
996
+ const [id, blank] = mainView.split('|')
997
+ const bot = id === '' ? undefined : roster.byId[id]
998
+ if (bot !== undefined) {
999
+ lastBot.current = { botId: bot.id, sessionId: id }
1000
+ if (currentPart(bot) !== id) actions.landOn(bot.id)
1001
+ return undefined
1002
+ }
1003
+ // The group's own Session moves on like a Bot's chat does: the part it archived
1004
+ // is cleared, and the view goes on in the fresh one.
1005
+ const room = id === '' ? undefined : roster.roomsById[id]
1006
+ if (room !== undefined) {
1007
+ lastBot.current = null
1008
+ if ((room.sessionId ?? room.id) !== id) actions.openSession(room.id)
1009
+ return undefined
1010
+ }
1011
+ // A DSH Agent Session, blank or not, is a real destination: it stays.
1012
+ if (id !== '' && ((actions.isAgentSession?.(id) ?? roster.agentOf[id] !== undefined) || blank !== '1')) {
1013
+ lastBot.current = null
1014
+ return undefined
1015
+ }
1016
+ const last = lastBot.current
1017
+ const timer = setTimeout(() => actions.landOn(roster.mainBotId, last), last ? 0 : 400)
1018
+ return () => clearTimeout(timer)
1019
+ }, [mainView, roster])
1020
+ }
1021
+
1022
+ export function FooterAccount(props) {
1023
+ const seated = props.useUi(value => value.accountSeated === true)
1024
+ if (seated) return null
1025
+ return h('span', { className: 'bt-foot-account' }, h(AccountLauncher, { ...props, seat: false }))
1026
+ }
1027
+
1028
+ // The only entry registered in every mode: in Agent mode the whole Bot surface is
1029
+ // withdrawn, and this button in the shell's own footer is the way back.
1030
+ export function BotReturn({ wide, useSurface, useRoster, actions }) {
1031
+ const mode = useSurface(value => value.mode)
1032
+ const ready = useRoster(value => value.ready)
1033
+ // Agent mode draws no team sidebar; there this button is the team interface.
1034
+ useReportReady(mode === 'agent' && ready)
1035
+ if (mode !== 'agent') return null
1036
+ return h('button', { type: 'button', className: 'bt-return', 'aria-label': t('DS Bot'), title: t('DS Bot'), onClick: () => actions.setSurface('bot') },
1037
+ h(BotMark, { look: MAIN_LOOK, size: 20 }),
1038
+ wide ? h('span', { className: 'bt-return-name' }, t('DS Bot')) : null)
1039
+ }
1040
+
1041
+ // Agent mode has none of the shell-group styles, so the return button carries its own.
1042
+ export const RETURN_CSS = `
1043
+ .bt-return{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:36px;padding:0 14px;border:0;border-radius:999px;background:none;color:inherit;font:inherit;font-size:14px;line-height:20px;cursor:pointer;transition:background-color .12s ease}
1044
+ .bt-return:hover{background:rgba(127,127,127,.14)}
1045
+ .bt-return:active{transform:scale(.96)}
1046
+ .bt-return .bt-mark{display:inline-flex;flex:none;line-height:0}
1047
+ .bt-return .bt-mark svg{width:100%;height:100%;overflow:visible}
1048
+ /* Shell styles carry --bt-ink-deepseek and Agent mode withdraws them; pin it here. */
1049
+ .bt-return .bt-mark{--bt-ink-deepseek:#4D6BFE}
1050
+ .bt-return-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1051
+ `
1052
+
1053
+ export function BrandMark({ size = 24 }) {
1054
+ return h('span', { className: 'bt-brand-whale' }, h(BotMark, { look: MAIN_LOOK, size }))
1055
+ }
1056
+ export function BrandName() {
1057
+ return h('span', { style: { fontWeight: 600, fontSize: 14 } }, 'DS Bot')
1058
+ }
1059
+
1060
+ // With the whale holding the settings seat, the Bot row is just the account menu;
1061
+ // FooterAccount only shows when the seat went to no one. The shell's footer classes
1062
+ // are CSS-module names, so they match on their stems.
1063
+ export const SIDEBAR_CSS = `
1064
+ .bt-confirm{width:260px;max-width:72vw;padding:10px 12px 12px;display:flex;flex-direction:column;gap:10px}
1065
+ .bt-confirm-text{margin:0;font-size:13px;line-height:19px;color:var(--bt-ink-2)}
1066
+ .bt-confirm-error{margin:0;font-size:12px;line-height:17px;color:var(--bt-danger);overflow-wrap:anywhere}
1067
+ .bt-confirm-row{display:flex;justify-content:flex-end;gap:8px}
1068
+ .bt-menu .bt-confirm button{width:auto;min-height:0}
1069
+ .bt-confirm-go{height:28px;padding:0 14px;border:0;border-radius:999px;background:var(--bt-accent);color:var(--bt-accent-ink);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:opacity .12s ease}
1070
+ .bt-confirm-go:hover:not(:disabled){opacity:.9}
1071
+ .bt-confirm-go:disabled{opacity:.6;cursor:default}
1072
+ .bt-side-top .bt-brand{cursor:default;padding-left:6px}
1073
+ .bt-side-top .bt-brand:hover{background:none}
1074
+ .bt-brand .bt-mark{flex:none}
1075
+ .bt-pin{flex:none;display:inline-flex;color:var(--bt-ink-3)}
1076
+ .bt-rail .bt-row{position:relative}
1077
+ .bt-rail .bt-pin{position:absolute;top:1px;left:calc(50% + 14px)}
1078
+ .bt-side .bt-read-only{margin:4px 8px 6px;padding:8px 10px;border-radius:10px;background:var(--bt-hover);font-size:12px;line-height:1.45;text-align:left}
1079
+ [class*="_footArea"]:has(.bt-foot-account){grid-template-columns:auto minmax(0,1fr) auto;column-gap:6px}
1080
+ [class*="_footArea"]>[class*="_footerActions"]>div>.bt-foot-account{grid-column:1;order:1;display:inline-flex}
1081
+ [class*="_footArea"]:has(.bt-foot-account)>[class*="_settingsArea"]{grid-column:3}
1082
+ [class*="_footArea"]:has(.bt-foot-account)>[class*="_settingsArea"] button[class*="_trigger"] [class*="_label"]{display:none!important}
1083
+
1084
+ /* The update cloud springs in when a newer DS Bot shows up; its arrow drops in a
1085
+ loop while the install runs. */
1086
+ .bt-round.bt-update{position:relative;color:var(--bt-accent,#4D6BFE);animation:bt-update-in ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}
1087
+ .bt-round.bt-update svg{width:17px;height:17px}
1088
+ .bt-round.bt-update[data-phase=installed]{color:var(--bt-ink-2)}
1089
+ @keyframes bt-update-in{from{opacity:0;transform:scale(.6);filter:blur(4px)}}
1090
+ .bt-update[data-phase=installing] .bt-cloud-arrow{animation:bt-cloud-drop 1.1s cubic-bezier(.45,0,.55,1) infinite}
1091
+ @keyframes bt-cloud-drop{0%{transform:translateY(-3px);opacity:0}35%{opacity:1}70%{transform:translateY(1px);opacity:1}100%{transform:translateY(2px);opacity:0}}
1092
+ .bt-update-dot{position:absolute;top:6px;right:6px;width:7px;height:7px;border-radius:50%;background:#E5484D;box-shadow:0 0 0 1.5px var(--bt-sidebar)}
1093
+ .bt-update-pop{position:fixed;z-index:60;width:280px;padding:14px 14px 12px;border-radius:14px;background:var(--bt-main);border:.5px solid var(--bt-line-2);box-shadow:0 10px 20px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);color:var(--bt-ink);box-sizing:border-box;transform-origin:top left;font-family:var(--bt-font);animation:bt-update-pop ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}
1094
+ @keyframes bt-update-pop{from{opacity:0;transform:scale(.96);filter:blur(4px)}}
1095
+ .bt-update-title{font-size:14px;line-height:20px;font-weight:600}
1096
+ .bt-update-text{margin-top:2px;font-size:12.5px;line-height:18px;color:var(--bt-ink-2)}
1097
+ .bt-update-error{margin-top:8px;font-size:12px;line-height:17px;color:var(--bt-danger);overflow-wrap:anywhere;max-height:90px;overflow:auto}
1098
+ .bt-update-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:12px}
1099
+ .bt-update-notes{margin-right:auto;font-size:12.5px;color:var(--bt-ink-2);text-decoration:none}
1100
+ .bt-update-notes:hover{color:var(--bt-ink);text-decoration:underline}
1101
+ .bt-update-go{height:30px;padding:0 14px;border:0;border-radius:999px;background:var(--bt-accent,#4D6BFE);color:var(--bt-accent-ink,#fff);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:opacity .12s ease,transform .12s ease}
1102
+ .bt-update-go:hover:not(:disabled){opacity:.9}
1103
+ .bt-update-go:active:not(:disabled){transform:scale(.96)}
1104
+ .bt-update-go:disabled{opacity:.6;cursor:default}
1105
+ .bt-update-dsh:not(:first-child){margin-top:12px;padding-top:12px;border-top:.5px solid var(--bt-line-2)}
1106
+ @media (prefers-reduced-motion:reduce){.bt-round.bt-update,.bt-update-pop,.bt-update .bt-cloud-arrow{animation:none}}
1107
+
1108
+ /* The DSH Agent row and its expanding Session list. The black whale is the
1109
+ harness's own mark, so the row reads as "plain dsh" next to the Bot marks. */
1110
+ .bt-agent-ava{flex:none;width:36px;height:36px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:var(--bt-hover);color:var(--bt-ink)}
1111
+ .bt-agent-ava.bt-run{animation:bt-agent-pulse 1.4s ease-in-out infinite}
1112
+ @keyframes bt-agent-pulse{0%,100%{opacity:1}50%{opacity:.55}}
1113
+ .bt-agent-sub{display:grid;grid-template-rows:0fr;transition:grid-template-rows ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}
1114
+ .bt-agent-sub[data-open]{grid-template-rows:1fr}
1115
+ .bt-agent-sub-in{overflow:hidden;min-height:0;margin-left:44px}
1116
+ .bt-agent-sub-row{display:flex;align-items:center;gap:8px;width:100%;padding:5px 10px 5px 8px;border:0;border-radius:8px;background:none;color:var(--bt-ink-2);font:inherit;font-size:13px;line-height:20px;text-align:left;cursor:pointer}
1117
+ .bt-agent-sub-row:hover{background:var(--bt-hover);color:var(--bt-ink)}
1118
+ .bt-agent-sub-row[aria-current=page]{background:var(--bt-hover);color:var(--bt-ink);font-weight:500}
1119
+ /* .bt-agent-sub-in clips for the expand animation and the rows touch its edges, so the ring goes inside. */
1120
+ .bt-agent-sub-row:focus-visible{outline:2px solid var(--bt-accent);outline-offset:-2px}
1121
+ .bt-agent-sub-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1122
+ .bt-agent-sub-time{flex:none;font-size:11px;color:var(--bt-ink-3)}
1123
+ .bt-agent-new{color:var(--bt-ink-3)}
1124
+ .bt-agent-new svg{width:14px;height:14px;flex:none}
1125
+ .bt-agent-edit{padding:3px 10px 3px 4px}
1126
+ .bt-agent-edit input{width:100%;border:0;border-radius:6px;background:var(--bt-hover);color:var(--bt-ink);font:inherit;font-size:13px;line-height:20px;padding:2px 8px;outline:none;box-shadow:inset 0 0 0 .5px var(--bt-line-2)}
1127
+ .bt-agent-sub[data-open] .bt-agent-sub-row{animation:bt-agent-row-in .24s ease both;animation-delay:calc(var(--i, 0)*30ms)}
1128
+ @keyframes bt-agent-row-in{from{opacity:0;filter:blur(4px)}to{opacity:1;filter:blur(0)}}
1129
+ @media (prefers-reduced-motion:reduce){.bt-agent-sub{transition:none}.bt-agent-sub .bt-agent-sub-row{animation:none}}
1130
+ `