@jingyi0605/codingns4dsh 0.1.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 (312) hide show
  1. package/README.md +1114 -0
  2. package/assets/provider-icons/claude-code.png +0 -0
  3. package/assets/provider-icons/codex.png +0 -0
  4. package/assets/provider-icons/command-code.svg +5 -0
  5. package/assets/provider-icons/deepseek-harness.svg +9 -0
  6. package/assets/provider-icons/gemini.png +0 -0
  7. package/assets/provider-icons/grok.png +0 -0
  8. package/assets/provider-icons/kimi.png +0 -0
  9. package/assets/provider-icons/opencode.png +0 -0
  10. package/assets/provider-icons/pi.svg +7 -0
  11. package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +97 -0
  12. package/data/build/dist/bootstrap/dsh-connection-adapter.js +169 -0
  13. package/data/build/dist/bootstrap/index.d.ts +38 -0
  14. package/data/build/dist/bootstrap/index.js +44 -0
  15. package/data/build/dist/client/account-bar.d.ts +9 -0
  16. package/data/build/dist/client/account-bar.js +398 -0
  17. package/data/build/dist/client/bundle.js +26167 -0
  18. package/data/build/dist/client/cli-catalog.d.ts +24 -0
  19. package/data/build/dist/client/cli-catalog.js +108 -0
  20. package/data/build/dist/client/cli-slots.d.ts +38 -0
  21. package/data/build/dist/client/cli-slots.js +297 -0
  22. package/data/build/dist/client/debug/ui.d.ts +12 -0
  23. package/data/build/dist/client/debug/ui.js +451 -0
  24. package/data/build/dist/client/dsh-h5-bootstrap.d.ts +64 -0
  25. package/data/build/dist/client/dsh-h5-bootstrap.js +293 -0
  26. package/data/build/dist/client/dsh-runtime-version.d.ts +3 -0
  27. package/data/build/dist/client/dsh-runtime-version.js +11 -0
  28. package/data/build/dist/client/external-tool-stream.d.ts +24 -0
  29. package/data/build/dist/client/external-tool-stream.js +114 -0
  30. package/data/build/dist/client/features/cli-adapters.d.ts +7 -0
  31. package/data/build/dist/client/features/cli-adapters.js +215 -0
  32. package/data/build/dist/client/features/debug.d.ts +4 -0
  33. package/data/build/dist/client/features/debug.js +24 -0
  34. package/data/build/dist/client/features/index.d.ts +33 -0
  35. package/data/build/dist/client/features/index.js +44 -0
  36. package/data/build/dist/client/features/lan-access-panel.d.ts +5 -0
  37. package/data/build/dist/client/features/lan-access-panel.js +146 -0
  38. package/data/build/dist/client/features/lan-access.d.ts +9 -0
  39. package/data/build/dist/client/features/lan-access.js +30 -0
  40. package/data/build/dist/client/features/login-protection-panel.d.ts +5 -0
  41. package/data/build/dist/client/features/login-protection-panel.js +91 -0
  42. package/data/build/dist/client/features/login-protection-session.d.ts +6 -0
  43. package/data/build/dist/client/features/login-protection-session.js +25 -0
  44. package/data/build/dist/client/features/login-protection.d.ts +4 -0
  45. package/data/build/dist/client/features/login-protection.js +23 -0
  46. package/data/build/dist/client/features/reverse-proxy-panel.d.ts +9 -0
  47. package/data/build/dist/client/features/reverse-proxy-panel.js +159 -0
  48. package/data/build/dist/client/features/reverse-proxy.d.ts +12 -0
  49. package/data/build/dist/client/features/reverse-proxy.js +112 -0
  50. package/data/build/dist/client/features/terminal-enhancement-panel.d.ts +5 -0
  51. package/data/build/dist/client/features/terminal-enhancement-panel.js +160 -0
  52. package/data/build/dist/client/features/terminal-enhancement.d.ts +4 -0
  53. package/data/build/dist/client/features/terminal-enhancement.js +24 -0
  54. package/data/build/dist/client/features/types.d.ts +58 -0
  55. package/data/build/dist/client/features/types.js +2 -0
  56. package/data/build/dist/client/features/workspace-session-enhancement-panel.d.ts +5 -0
  57. package/data/build/dist/client/features/workspace-session-enhancement-panel.js +66 -0
  58. package/data/build/dist/client/features/workspace-session-enhancement.d.ts +4 -0
  59. package/data/build/dist/client/features/workspace-session-enhancement.js +101 -0
  60. package/data/build/dist/client/h5-bootstrap-entry.d.ts +2 -0
  61. package/data/build/dist/client/h5-bootstrap-entry.js +17 -0
  62. package/data/build/dist/client/index.d.ts +31 -0
  63. package/data/build/dist/client/index.js +98 -0
  64. package/data/build/dist/client/lan-access.d.ts +28 -0
  65. package/data/build/dist/client/lan-access.js +68 -0
  66. package/data/build/dist/client/locale.d.ts +20 -0
  67. package/data/build/dist/client/locale.js +393 -0
  68. package/data/build/dist/client/provider-icon-assets.d.ts +2 -0
  69. package/data/build/dist/client/provider-icon-assets.js +23 -0
  70. package/data/build/dist/client/provider-icons.d.ts +19 -0
  71. package/data/build/dist/client/provider-icons.js +39 -0
  72. package/data/build/dist/client/remote-web-context.d.ts +57 -0
  73. package/data/build/dist/client/remote-web-context.js +939 -0
  74. package/data/build/dist/client/session-adapter-cache.d.ts +18 -0
  75. package/data/build/dist/client/session-adapter-cache.js +84 -0
  76. package/data/build/dist/client/settings-bridge.d.ts +32 -0
  77. package/data/build/dist/client/settings-bridge.js +126 -0
  78. package/data/build/dist/client/settings-section.d.ts +30 -0
  79. package/data/build/dist/client/settings-section.js +93 -0
  80. package/data/build/dist/client/subscription-slot.d.ts +18 -0
  81. package/data/build/dist/client/subscription-slot.js +223 -0
  82. package/data/build/dist/client/terminal/index.d.ts +4 -0
  83. package/data/build/dist/client/terminal/index.js +3 -0
  84. package/data/build/dist/client/terminal/model.d.ts +116 -0
  85. package/data/build/dist/client/terminal/model.js +435 -0
  86. package/data/build/dist/client/terminal/styles.d.ts +21 -0
  87. package/data/build/dist/client/terminal/styles.js +51 -0
  88. package/data/build/dist/client/terminal/ui.d.ts +19 -0
  89. package/data/build/dist/client/terminal/ui.js +257 -0
  90. package/data/build/dist/client/terminal/xterm-view.d.ts +13 -0
  91. package/data/build/dist/client/terminal/xterm-view.js +213 -0
  92. package/data/build/dist/client/theme.d.ts +56 -0
  93. package/data/build/dist/client/theme.js +186 -0
  94. package/data/build/dist/client/workspace-session-archive-dom.d.ts +29 -0
  95. package/data/build/dist/client/workspace-session-archive-dom.js +525 -0
  96. package/data/build/dist/client/workspace-session-fiber.d.ts +3 -0
  97. package/data/build/dist/client/workspace-session-fiber.js +33 -0
  98. package/data/build/dist/client/workspace-session-logo-dom.d.ts +26 -0
  99. package/data/build/dist/client/workspace-session-logo-dom.js +128 -0
  100. package/data/build/dist/features/index.d.ts +3 -0
  101. package/data/build/dist/features/index.js +2 -0
  102. package/data/build/dist/features/registry.d.ts +74 -0
  103. package/data/build/dist/features/registry.js +382 -0
  104. package/data/build/dist/features/resource-scope/index.d.ts +39 -0
  105. package/data/build/dist/features/resource-scope/index.js +161 -0
  106. package/data/build/dist/host/auth-session.d.ts +42 -0
  107. package/data/build/dist/host/auth-session.js +186 -0
  108. package/data/build/dist/host/cli-adapters/claude-driver.d.ts +14 -0
  109. package/data/build/dist/host/cli-adapters/claude-driver.js +103 -0
  110. package/data/build/dist/host/cli-adapters/codex-driver.d.ts +45 -0
  111. package/data/build/dist/host/cli-adapters/codex-driver.js +534 -0
  112. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +38 -0
  113. package/data/build/dist/host/cli-adapters/command-code-driver.js +394 -0
  114. package/data/build/dist/host/cli-adapters/command-code-subscription.d.ts +19 -0
  115. package/data/build/dist/host/cli-adapters/command-code-subscription.js +126 -0
  116. package/data/build/dist/host/cli-adapters/driver.d.ts +41 -0
  117. package/data/build/dist/host/cli-adapters/driver.js +2 -0
  118. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +37 -0
  119. package/data/build/dist/host/cli-adapters/dsh-message-projector.js +180 -0
  120. package/data/build/dist/host/cli-adapters/dsh-tool-history.d.ts +48 -0
  121. package/data/build/dist/host/cli-adapters/dsh-tool-history.js +373 -0
  122. package/data/build/dist/host/cli-adapters/feature.d.ts +7 -0
  123. package/data/build/dist/host/cli-adapters/feature.js +335 -0
  124. package/data/build/dist/host/cli-adapters/gemini-driver.d.ts +24 -0
  125. package/data/build/dist/host/cli-adapters/gemini-driver.js +427 -0
  126. package/data/build/dist/host/cli-adapters/grok-driver.d.ts +38 -0
  127. package/data/build/dist/host/cli-adapters/grok-driver.js +372 -0
  128. package/data/build/dist/host/cli-adapters/http-sse-client.d.ts +22 -0
  129. package/data/build/dist/host/cli-adapters/http-sse-client.js +99 -0
  130. package/data/build/dist/host/cli-adapters/interaction-events.d.ts +11 -0
  131. package/data/build/dist/host/cli-adapters/interaction-events.js +80 -0
  132. package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts +65 -0
  133. package/data/build/dist/host/cli-adapters/json-rpc-process.js +256 -0
  134. package/data/build/dist/host/cli-adapters/kimi-driver.d.ts +21 -0
  135. package/data/build/dist/host/cli-adapters/kimi-driver.js +382 -0
  136. package/data/build/dist/host/cli-adapters/model-catalog.d.ts +22 -0
  137. package/data/build/dist/host/cli-adapters/model-catalog.js +89 -0
  138. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +55 -0
  139. package/data/build/dist/host/cli-adapters/opencode-driver.js +728 -0
  140. package/data/build/dist/host/cli-adapters/pi-driver.d.ts +43 -0
  141. package/data/build/dist/host/cli-adapters/pi-driver.js +312 -0
  142. package/data/build/dist/host/cli-adapters/process-utils.d.ts +16 -0
  143. package/data/build/dist/host/cli-adapters/process-utils.js +27 -0
  144. package/data/build/dist/host/cli-adapters/provider-subscription.d.ts +82 -0
  145. package/data/build/dist/host/cli-adapters/provider-subscription.js +610 -0
  146. package/data/build/dist/host/cli-adapters/registry.d.ts +95 -0
  147. package/data/build/dist/host/cli-adapters/registry.js +659 -0
  148. package/data/build/dist/host/cli-adapters/rpc-driver-utils.d.ts +24 -0
  149. package/data/build/dist/host/cli-adapters/rpc-driver-utils.js +119 -0
  150. package/data/build/dist/host/cli-adapters/session-probe.d.ts +20 -0
  151. package/data/build/dist/host/cli-adapters/session-probe.js +139 -0
  152. package/data/build/dist/host/cli-adapters/session-store.d.ts +68 -0
  153. package/data/build/dist/host/cli-adapters/session-store.js +180 -0
  154. package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts +45 -0
  155. package/data/build/dist/host/cli-adapters/standard-stream-driver.js +205 -0
  156. package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +25 -0
  157. package/data/build/dist/host/cli-adapters/stream-normalizer.js +83 -0
  158. package/data/build/dist/host/cli-adapters/tool-observation.d.ts +9 -0
  159. package/data/build/dist/host/cli-adapters/tool-observation.js +39 -0
  160. package/data/build/dist/host/control-api-client.d.ts +84 -0
  161. package/data/build/dist/host/control-api-client.js +130 -0
  162. package/data/build/dist/host/credential-store.d.ts +54 -0
  163. package/data/build/dist/host/credential-store.js +114 -0
  164. package/data/build/dist/host/debug.d.ts +79 -0
  165. package/data/build/dist/host/debug.js +295 -0
  166. package/data/build/dist/host/dsh-device-runtime.d.ts +39 -0
  167. package/data/build/dist/host/dsh-device-runtime.js +118 -0
  168. package/data/build/dist/host/dsh-gateway-feature.d.ts +5 -0
  169. package/data/build/dist/host/dsh-gateway-feature.js +55 -0
  170. package/data/build/dist/host/dsh-runtime-version.d.ts +12 -0
  171. package/data/build/dist/host/dsh-runtime-version.js +69 -0
  172. package/data/build/dist/host/features/auth.d.ts +11 -0
  173. package/data/build/dist/host/features/auth.js +273 -0
  174. package/data/build/dist/host/features/debug.d.ts +5 -0
  175. package/data/build/dist/host/features/debug.js +90 -0
  176. package/data/build/dist/host/features/host-status.d.ts +12 -0
  177. package/data/build/dist/host/features/host-status.js +54 -0
  178. package/data/build/dist/host/features/index.d.ts +19 -0
  179. package/data/build/dist/host/features/index.js +29 -0
  180. package/data/build/dist/host/features/lan-access-dsh.d.ts +8 -0
  181. package/data/build/dist/host/features/lan-access-dsh.js +45 -0
  182. package/data/build/dist/host/features/terminal-process.d.ts +5 -0
  183. package/data/build/dist/host/features/terminal-process.js +110 -0
  184. package/data/build/dist/host/features/terminal-status.d.ts +18 -0
  185. package/data/build/dist/host/features/terminal-status.js +56 -0
  186. package/data/build/dist/host/features/types.d.ts +41 -0
  187. package/data/build/dist/host/features/types.js +2 -0
  188. package/data/build/dist/host/index.d.ts +43 -0
  189. package/data/build/dist/host/index.js +135 -0
  190. package/data/build/dist/host/lan-access-dsh.d.ts +83 -0
  191. package/data/build/dist/host/lan-access-dsh.js +831 -0
  192. package/data/build/dist/host/native-session-bridge.d.ts +130 -0
  193. package/data/build/dist/host/native-session-bridge.js +317 -0
  194. package/data/build/dist/host/relay-tunnel-runtime.d.ts +97 -0
  195. package/data/build/dist/host/relay-tunnel-runtime.js +361 -0
  196. package/data/build/dist/host/remote-web-runtime.d.ts +78 -0
  197. package/data/build/dist/host/remote-web-runtime.js +559 -0
  198. package/data/build/dist/host/rpc-table.d.ts +32 -0
  199. package/data/build/dist/host/rpc-table.js +47 -0
  200. package/data/build/dist/host/rpc.d.ts +18 -0
  201. package/data/build/dist/host/rpc.js +248 -0
  202. package/data/build/dist/host/settings.d.ts +19 -0
  203. package/data/build/dist/host/settings.js +80 -0
  204. package/data/build/dist/host/terminal/attachment-registry.d.ts +17 -0
  205. package/data/build/dist/host/terminal/attachment-registry.js +49 -0
  206. package/data/build/dist/host/terminal/backends/conpty-backend.d.ts +39 -0
  207. package/data/build/dist/host/terminal/backends/conpty-backend.js +160 -0
  208. package/data/build/dist/host/terminal/backends/local-pty-backend.d.ts +36 -0
  209. package/data/build/dist/host/terminal/backends/local-pty-backend.js +178 -0
  210. package/data/build/dist/host/terminal/backends/tmux-backend.d.ts +40 -0
  211. package/data/build/dist/host/terminal/backends/tmux-backend.js +191 -0
  212. package/data/build/dist/host/terminal/broker/conpty-broker-client.d.ts +27 -0
  213. package/data/build/dist/host/terminal/broker/conpty-broker-client.js +154 -0
  214. package/data/build/dist/host/terminal/broker/conpty-broker-process.d.ts +10 -0
  215. package/data/build/dist/host/terminal/broker/conpty-broker-process.js +147 -0
  216. package/data/build/dist/host/terminal/broker/conpty-broker-protocol.d.ts +92 -0
  217. package/data/build/dist/host/terminal/broker/conpty-broker-protocol.js +134 -0
  218. package/data/build/dist/host/terminal/controller-factory.d.ts +37 -0
  219. package/data/build/dist/host/terminal/controller-factory.js +82 -0
  220. package/data/build/dist/host/terminal/index.d.ts +17 -0
  221. package/data/build/dist/host/terminal/index.js +17 -0
  222. package/data/build/dist/host/terminal/runtime-adapter.d.ts +77 -0
  223. package/data/build/dist/host/terminal/runtime-adapter.js +18 -0
  224. package/data/build/dist/host/terminal/runtime-manager.d.ts +41 -0
  225. package/data/build/dist/host/terminal/runtime-manager.js +179 -0
  226. package/data/build/dist/host/terminal/shell-detection.d.ts +23 -0
  227. package/data/build/dist/host/terminal/shell-detection.js +105 -0
  228. package/data/build/dist/host/terminal/startup.d.ts +33 -0
  229. package/data/build/dist/host/terminal/startup.js +100 -0
  230. package/data/build/dist/host/terminal/terminal-controller.d.ts +78 -0
  231. package/data/build/dist/host/terminal/terminal-controller.js +324 -0
  232. package/data/build/dist/host/terminal/terminal-process-service.d.ts +30 -0
  233. package/data/build/dist/host/terminal/terminal-process-service.js +194 -0
  234. package/data/build/dist/host/terminal/terminal-process-store.d.ts +45 -0
  235. package/data/build/dist/host/terminal/terminal-process-store.js +183 -0
  236. package/data/build/dist/host/terminal/terminal-service.d.ts +87 -0
  237. package/data/build/dist/host/terminal/terminal-service.js +528 -0
  238. package/data/build/dist/host/terminal/terminal-store.d.ts +49 -0
  239. package/data/build/dist/host/terminal/terminal-store.js +242 -0
  240. package/data/build/dist/index.d.ts +37 -0
  241. package/data/build/dist/index.js +26 -0
  242. package/data/build/dist/shared/contracts/auth.d.ts +122 -0
  243. package/data/build/dist/shared/contracts/auth.js +8 -0
  244. package/data/build/dist/shared/contracts/cli-adapter.d.ts +192 -0
  245. package/data/build/dist/shared/contracts/cli-adapter.js +2 -0
  246. package/data/build/dist/shared/contracts/command-code.d.ts +5 -0
  247. package/data/build/dist/shared/contracts/command-code.js +2 -0
  248. package/data/build/dist/shared/contracts/config.d.ts +113 -0
  249. package/data/build/dist/shared/contracts/config.js +86 -0
  250. package/data/build/dist/shared/contracts/debug-config.d.ts +28 -0
  251. package/data/build/dist/shared/contracts/debug-config.js +78 -0
  252. package/data/build/dist/shared/contracts/debug.d.ts +75 -0
  253. package/data/build/dist/shared/contracts/debug.js +121 -0
  254. package/data/build/dist/shared/contracts/dsh-device.d.ts +72 -0
  255. package/data/build/dist/shared/contracts/dsh-device.js +2 -0
  256. package/data/build/dist/shared/contracts/errors.d.ts +33 -0
  257. package/data/build/dist/shared/contracts/errors.js +41 -0
  258. package/data/build/dist/shared/contracts/feature.d.ts +71 -0
  259. package/data/build/dist/shared/contracts/feature.js +2 -0
  260. package/data/build/dist/shared/contracts/host-status.d.ts +14 -0
  261. package/data/build/dist/shared/contracts/host-status.js +2 -0
  262. package/data/build/dist/shared/contracts/lan-access-dsh.d.ts +30 -0
  263. package/data/build/dist/shared/contracts/lan-access-dsh.js +2 -0
  264. package/data/build/dist/shared/contracts/peer-host.d.ts +37 -0
  265. package/data/build/dist/shared/contracts/peer-host.js +9 -0
  266. package/data/build/dist/shared/contracts/signaling.d.ts +67 -0
  267. package/data/build/dist/shared/contracts/signaling.js +2 -0
  268. package/data/build/dist/shared/contracts/subscription.d.ts +69 -0
  269. package/data/build/dist/shared/contracts/subscription.js +2 -0
  270. package/data/build/dist/shared/contracts/terminal-process.d.ts +65 -0
  271. package/data/build/dist/shared/contracts/terminal-process.js +2 -0
  272. package/data/build/dist/shared/contracts/terminal.d.ts +127 -0
  273. package/data/build/dist/shared/contracts/terminal.js +2 -0
  274. package/data/build/dist/shared/contracts/transport.d.ts +45 -0
  275. package/data/build/dist/shared/contracts/transport.js +3 -0
  276. package/data/build/dist/shared/contracts/version.d.ts +19 -0
  277. package/data/build/dist/shared/contracts/version.js +74 -0
  278. package/data/build/dist/shared/index.d.ts +22 -0
  279. package/data/build/dist/shared/index.js +9 -0
  280. package/data/build/dist/transport/carrier.d.ts +38 -0
  281. package/data/build/dist/transport/carrier.js +268 -0
  282. package/data/build/dist/transport/debug.d.ts +22 -0
  283. package/data/build/dist/transport/debug.js +57 -0
  284. package/data/build/dist/transport/dsh-envelope.d.ts +41 -0
  285. package/data/build/dist/transport/dsh-envelope.js +107 -0
  286. package/data/build/dist/transport/dsh-gateway.d.ts +64 -0
  287. package/data/build/dist/transport/dsh-gateway.js +254 -0
  288. package/data/build/dist/transport/dsh-session.d.ts +55 -0
  289. package/data/build/dist/transport/dsh-session.js +256 -0
  290. package/data/build/dist/transport/dsh-transport.d.ts +57 -0
  291. package/data/build/dist/transport/dsh-transport.js +125 -0
  292. package/data/build/dist/transport/frame.d.ts +132 -0
  293. package/data/build/dist/transport/frame.js +168 -0
  294. package/data/build/dist/transport/index.d.ts +11 -0
  295. package/data/build/dist/transport/index.js +11 -0
  296. package/data/build/dist/transport/multiplexer.d.ts +63 -0
  297. package/data/build/dist/transport/multiplexer.js +323 -0
  298. package/data/build/dist/transport/webrtc-client.d.ts +65 -0
  299. package/data/build/dist/transport/webrtc-client.js +255 -0
  300. package/data/build/dist/transport/webrtc-host.d.ts +58 -0
  301. package/data/build/dist/transport/webrtc-host.js +252 -0
  302. package/data/build/dist/typert.host.d.ts +25 -0
  303. package/data/build/dist/typert.host.js +150 -0
  304. package/dsh.bundle.patch +12 -0
  305. package/package.json +135 -0
  306. package/profile/README.md +27 -0
  307. package/profile/cordis.patch.yml +2 -0
  308. package/profile/package.json +20 -0
  309. package/profile/scripts/check-dsh-install.mjs +71 -0
  310. package/profile/version.json +5 -0
  311. package/scripts/check-dsh-install.mjs +88 -0
  312. package/version.json +6 -0
@@ -0,0 +1,215 @@
1
+ import { createElement, useEffect, useState } from 'react';
2
+ import { archiveCliSession, callCliRpc, errorMessage, listCliSessions, restoreCliSession } from '../cli-catalog.js';
3
+ import { dshFormRootStyle, dshPopupSurfaceStyle, dshSettingsButtonStyle, dshSettingsListRowStyle, dshThemeColor } from '../theme.js';
4
+ import { useCodingNsTranslator } from '../locale.js';
5
+ import { registerExternalToolStreamUi } from '../external-tool-stream.js';
6
+ /** 外部 Agent 集成模块。Agent 进程在 Host 运行,浏览器只读取目录和状态。 */
7
+ export const cliAdaptersFeature = {
8
+ descriptor: {
9
+ name: 'cliAdapters',
10
+ version: '0.1.0',
11
+ enabledByDefault: true,
12
+ dependencies: [],
13
+ runtime: 'client',
14
+ ui: {
15
+ label: '外部Agent集成',
16
+ description: '查看外部 Agent 的安装状态、版本、命令路径和可用模型,并单独启用或停用。',
17
+ labelKey: 'feature.cliAdapters.label',
18
+ descriptionKey: 'feature.cliAdapters.description',
19
+ order: 30,
20
+ defaultOpen: true,
21
+ },
22
+ },
23
+ start: async (context) => {
24
+ const slots = context.services.slots;
25
+ if (slots === undefined)
26
+ return;
27
+ context.resources.add(registerExternalToolStreamUi(context.services));
28
+ // CLI Slot 带有浏览器图片资源,启用模块时再加载,避免 Node 侧读取 Client 元数据时解析图片。
29
+ const { registerCliConversationSlots } = await import('../cli-slots.js');
30
+ const disposeSlots = registerCliConversationSlots(slots, context.services.rpc, context.services.locale);
31
+ context.resources.add(disposeSlots);
32
+ },
33
+ settingsPanel: CliAdaptersPanel,
34
+ };
35
+ /** 设置页中的 Agent 列表和详情模态框。 */
36
+ export function CliAdaptersPanel({ services, enabled }) {
37
+ const t = useCodingNsTranslator(services.locale);
38
+ const [catalog, setCatalog] = useState([]);
39
+ const [selected, setSelected] = useState(null);
40
+ const [models, setModels] = useState(null);
41
+ const [loading, setLoading] = useState(false);
42
+ const [busyAdapterId, setBusyAdapterId] = useState(null);
43
+ const [sessions, setSessions] = useState([]);
44
+ const [sessionsLoading, setSessionsLoading] = useState(false);
45
+ const [restoringSessionId, setRestoringSessionId] = useState(null);
46
+ const [archivingSessionId, setArchivingSessionId] = useState(null);
47
+ const [message, setMessage] = useState('');
48
+ const disabled = !enabled;
49
+ useEffect(() => {
50
+ if (disabled)
51
+ return;
52
+ let active = true;
53
+ setLoading(true);
54
+ void callCliRpc(services.rpc, 'catalog', {})
55
+ .then((value) => { if (active)
56
+ setCatalog(value); })
57
+ .catch((error) => { if (active)
58
+ setMessage(errorMessage(error)); })
59
+ .finally(() => { if (active)
60
+ setLoading(false); });
61
+ return () => { active = false; };
62
+ }, [disabled, services.rpc]);
63
+ useEffect(() => {
64
+ if (disabled) {
65
+ setSessions([]);
66
+ return;
67
+ }
68
+ let active = true;
69
+ setSessionsLoading(true);
70
+ void listCliSessions(services.rpc)
71
+ .then((value) => { if (active)
72
+ setSessions(value); })
73
+ .catch((error) => { if (active)
74
+ setMessage(errorMessage(error)); })
75
+ .finally(() => { if (active)
76
+ setSessionsLoading(false); });
77
+ return () => { active = false; };
78
+ }, [disabled, services.rpc]);
79
+ useEffect(() => {
80
+ if (selected === null || disabled || !selected.installed || !selected.enabled) {
81
+ setModels(null);
82
+ return;
83
+ }
84
+ let active = true;
85
+ setModels(null);
86
+ setMessage('');
87
+ void callCliRpc(services.rpc, 'models', { adapterId: selected.id })
88
+ .then((value) => { if (active)
89
+ setModels(value); })
90
+ .catch((error) => { if (active)
91
+ setMessage(errorMessage(error)); });
92
+ return () => { active = false; };
93
+ }, [disabled, selected, services.rpc]);
94
+ const rowStyle = dshSettingsListRowStyle;
95
+ const buttonStyle = { ...dshSettingsButtonStyle, cursor: disabled ? 'not-allowed' : 'pointer' };
96
+ const toggleAdapter = async (adapter, next) => {
97
+ setBusyAdapterId(adapter.id);
98
+ setMessage('');
99
+ try {
100
+ await callCliRpc(services.rpc, 'adapter/set', { adapterId: adapter.id, enabled: next });
101
+ const refreshed = await callCliRpc(services.rpc, 'catalog', {});
102
+ setCatalog(refreshed);
103
+ }
104
+ catch (error) {
105
+ setMessage(errorMessage(error));
106
+ }
107
+ finally {
108
+ setBusyAdapterId(null);
109
+ }
110
+ };
111
+ const restoreSession = async (record) => {
112
+ setRestoringSessionId(record.dshSessionId);
113
+ setMessage('');
114
+ try {
115
+ await restoreCliSession(services.rpc, record);
116
+ }
117
+ catch (error) {
118
+ setMessage(errorMessage(error));
119
+ }
120
+ finally {
121
+ setRestoringSessionId(null);
122
+ }
123
+ };
124
+ const archiveSession = async (record) => {
125
+ setArchivingSessionId(record.dshSessionId);
126
+ setMessage('');
127
+ try {
128
+ await archiveCliSession(services.rpc, record.dshSessionId);
129
+ setSessions((current) => current.filter((item) => item.dshSessionId !== record.dshSessionId));
130
+ }
131
+ catch (error) {
132
+ setMessage(errorMessage(error));
133
+ }
134
+ finally {
135
+ setArchivingSessionId(null);
136
+ }
137
+ };
138
+ return createElement('div', { 'aria-disabled': disabled, style: { ...dshFormRootStyle, opacity: disabled ? 0.5 : 1, pointerEvents: disabled ? 'none' : 'auto' } }, loading && createElement('div', { role: 'status' }, t('cli.readingAgents')), !loading && catalog.length === 0 && createElement('div', { role: 'status', style: { opacity: 0.7 } }, t('cli.noAgents')), createElement('div', undefined, ...catalog.map((adapter) => createElement('div', { key: adapter.id, style: rowStyle }, createElement('button', {
139
+ type: 'button',
140
+ onClick: () => setSelected(adapter),
141
+ style: { flex: '1 1 auto', minWidth: 0, display: 'flex', alignItems: 'center', gap: 12, padding: 0, border: 0, color: 'inherit', textAlign: 'left', background: 'transparent', cursor: 'pointer' },
142
+ 'aria-label': t('cli.viewDetails', { name: adapter.name }),
143
+ }, createElement('span', { style: { flex: '1 1 auto', minWidth: 0, fontWeight: 600 } }, adapter.name), createElement('span', { style: { color: adapter.installed ? dshThemeColor.success : dshThemeColor.labelTertiary } }, adapter.installed ? t('cli.installed') : t('cli.notInstalled')), createElement('span', { style: { minWidth: 70, color: dshThemeColor.labelTertiary } }, adapter.version ?? t('cli.notDetectedVersion'))), createElement('label', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, flex: '0 0 auto' } }, createElement('input', { type: 'checkbox', role: 'switch', 'aria-label': t('cli.adapterToggle', { name: adapter.name }), checked: adapter.enabled, disabled: !adapter.installed || busyAdapterId === adapter.id, onChange: (event) => { void toggleAdapter(adapter, event.currentTarget.checked); }, style: { accentColor: dshThemeColor.accent } }), createElement('span', undefined, adapter.enabled ? t('cli.enabled') : t('cli.disabled')))))), createElement(CliSessionList, {
144
+ sessions,
145
+ loading: sessionsLoading,
146
+ restoringSessionId,
147
+ archivingSessionId,
148
+ onRestore: (record) => { void restoreSession(record); },
149
+ onArchive: (record) => { void archiveSession(record); },
150
+ t,
151
+ }), message && createElement('div', { role: 'alert', style: { marginTop: 10, color: dshThemeColor.error } }, message), selected !== null && createElement(AdapterDetailsDialog, {
152
+ adapter: selected,
153
+ models,
154
+ loading: selected.installed && selected.enabled && models === null && !message,
155
+ onClose: () => setSelected(null),
156
+ buttonStyle,
157
+ t,
158
+ }));
159
+ }
160
+ /** 外部会话索引入口;打开后交给 DSH 原生会话页面渲染消息。 */
161
+ function CliSessionList({ sessions, loading, restoringSessionId, archivingSessionId, onRestore, onArchive, t }) {
162
+ return createElement('section', { 'aria-labelledby': 'codingns-cli-session-title', style: { marginTop: 20 } }, createElement('h4', { id: 'codingns-cli-session-title', style: { margin: '0 0 8px' } }, t('cli.sessions')), loading && createElement('div', { role: 'status' }, t('cli.readingSessions')), !loading && sessions.length === 0 && createElement('div', { style: { opacity: 0.7 } }, t('cli.noSessions')), !loading && sessions.length > 0 && createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, ...sessions.map((record) => createElement('div', {
163
+ key: record.dshSessionId,
164
+ style: { display: 'flex', alignItems: 'center', gap: 10, padding: '8px 0', borderTop: `1px solid ${dshThemeColor.border}` },
165
+ }, createElement('div', { style: { flex: '1 1 auto', minWidth: 0 } }, createElement('div', { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', fontWeight: 600 } }, record.title ?? t('cli.session', { id: record.adapterId })), createElement('div', {
166
+ title: record.providerStateReason,
167
+ style: { marginTop: 2, color: record.providerState === 'missing' ? dshThemeColor.error : dshThemeColor.labelTertiary, fontSize: 12 },
168
+ }, `${record.adapterId} · ${sessionStatusLabel(record, t)}`)), createElement('button', {
169
+ type: 'button',
170
+ onClick: () => onRestore(record),
171
+ disabled: restoringSessionId !== null,
172
+ 'aria-label': `${t('cli.open')} ${record.title ?? t('cli.session', { id: record.adapterId })}`,
173
+ style: { ...dshSettingsButtonStyle, flex: '0 0 auto', cursor: restoringSessionId === null ? 'pointer' : 'not-allowed' },
174
+ }, restoringSessionId === record.dshSessionId ? t('cli.opening') : t('cli.open')), record.providerState === 'missing' && createElement('button', {
175
+ type: 'button',
176
+ onClick: () => onArchive(record),
177
+ disabled: archivingSessionId !== null,
178
+ 'aria-label': t('cli.removeFromSidebar', { name: record.title ?? t('cli.session', { id: record.adapterId }) }),
179
+ style: { ...dshSettingsButtonStyle, flex: '0 0 auto', color: dshThemeColor.error, cursor: archivingSessionId === null ? 'pointer' : 'not-allowed' },
180
+ }, archivingSessionId === record.dshSessionId ? t('cli.removing') : t('cli.remove'))))));
181
+ }
182
+ function sessionStatusLabel(record, t) {
183
+ if (record.providerState === 'missing')
184
+ return t('cli.statusMissing');
185
+ if (record.providerState === 'corrupt')
186
+ return t('cli.statusCorrupt');
187
+ if (record.providerState === 'unreachable')
188
+ return t('cli.statusUnreachable');
189
+ if (record.providerState === 'ephemeral')
190
+ return t('cli.statusEphemeral');
191
+ if (record.status === 'active')
192
+ return t('cli.statusActive');
193
+ if (record.status === 'error')
194
+ return t('cli.statusError');
195
+ if (record.status === 'archived')
196
+ return t('cli.statusArchived');
197
+ return t('cli.statusPaused');
198
+ }
199
+ function AdapterDetailsDialog({ adapter, models, loading, onClose, buttonStyle, t }) {
200
+ return createElement('div', {
201
+ role: 'dialog',
202
+ 'aria-modal': true,
203
+ 'aria-labelledby': 'codingns-cli-adapter-title',
204
+ style: { position: 'fixed', inset: 0, zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 24, background: dshThemeColor.overlay },
205
+ }, createElement('div', { style: { ...dshPopupSurfaceStyle, width: 'min(100%, 620px)', maxHeight: 'min(720px, 90vh)', overflow: 'auto', boxSizing: 'border-box', padding: 24, borderRadius: 8 } }, createElement('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 } }, createElement('h3', { id: 'codingns-cli-adapter-title', style: { margin: 0, fontSize: 18 } }, adapter.name), createElement('button', { type: 'button', onClick: onClose, style: buttonStyle, 'aria-label': t('cli.closeDetails') }, t('cli.closeDetails'))), createElement('dl', { style: { display: 'grid', gridTemplateColumns: 'max-content 1fr', gap: '8px 16px', margin: '20px 0' } }, createElement('dt', undefined, t('cli.installStatus')), createElement('dd', { style: { margin: 0 } }, adapter.installed ? t('cli.installed') : t('cli.notInstalled')), createElement('dt', undefined, t('cli.enabledStatus')), createElement('dd', { style: { margin: 0 } }, adapter.enabled ? t('cli.enabled') : t('cli.disabled')), createElement('dt', undefined, t('cli.version')), createElement('dd', { style: { margin: 0 } }, adapter.version ?? t('cli.notDetectedVersion')), createElement('dt', undefined, t('cli.commandPath')), createElement('dd', { style: { margin: 0, overflowWrap: 'anywhere' } }, adapter.command ?? t('cli.notDetectedCommand')), createElement('dt', undefined, t('cli.protocol')), createElement('dd', { style: { margin: 0 } }, adapter.protocol ?? t('cli.undeclared')), createElement('dt', undefined, t('cli.capabilities')), createElement('dd', { style: { margin: 0, overflowWrap: 'anywhere' } }, adapter.capabilities?.join('、') ?? t('cli.undeclared'))), createElement('h4', { style: { margin: '16px 0 8px' } }, t('cli.modelCatalog')), !adapter.installed && createElement('div', { style: { opacity: 0.7 } }, t('cli.agentNotInstalled')), adapter.installed && !adapter.enabled && createElement('div', { style: { opacity: 0.7 } }, t('cli.agentDisabled')), adapter.installed && loading && createElement('div', { role: 'status' }, t('cli.readingModels')), adapter.installed && !loading && models !== null && createElement(ModelCatalog, { catalog: models, t }), createElement('div', { style: { display: 'flex', justifyContent: 'flex-end', marginTop: 20 } }, createElement('button', { type: 'button', onClick: onClose, style: buttonStyle }, t('cli.done')))));
206
+ }
207
+ function ModelCatalog({ catalog, t }) {
208
+ if (catalog.groups.length === 0)
209
+ return createElement('div', { style: { opacity: 0.7 } }, t('cli.noModels'));
210
+ return createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 14 } }, ...catalog.groups.map((group) => createElement('section', { key: group.id }, createElement('strong', undefined, group.name), createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, marginTop: 6 } }, ...group.models.map((model) => createElement(ModelRow, { key: model.id, model, t }))))));
211
+ }
212
+ function ModelRow({ model, t }) {
213
+ return createElement('div', { style: { padding: '8px 10px', border: `1px solid ${dshThemeColor.border}`, borderRadius: 6 } }, createElement('div', { style: { fontWeight: 600 } }, model.name), model.description && createElement('div', { style: { marginTop: 3, opacity: 0.7, fontSize: 13 } }, model.description), createElement('div', { style: { marginTop: 5, opacity: 0.7, fontSize: 13 } }, t('cli.thinkingLevel', { value: model.efforts.length > 0 ? model.efforts.join('、') : t('cli.defaultEffort') })));
214
+ }
215
+ //# sourceMappingURL=cli-adapters.js.map
@@ -0,0 +1,4 @@
1
+ import type { CodingNsClientFeatureModule } from './types.js';
2
+ /** 工作区调试面板模块;开关关闭时同时移除 Sidebar 标签和注入内容。 */
3
+ export declare const debugFeature: CodingNsClientFeatureModule;
4
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { registerDebugUi } from '../debug/ui.js';
2
+ /** 工作区调试面板模块;开关关闭时同时移除 Sidebar 标签和注入内容。 */
3
+ export const debugFeature = {
4
+ descriptor: {
5
+ name: 'debug',
6
+ version: '0.1.0',
7
+ enabledByDefault: true,
8
+ dependencies: [],
9
+ runtime: 'client',
10
+ ui: {
11
+ label: '工作区调试',
12
+ description: '按 Workspace 配置启动终端、检查端口并访问指定服务。',
13
+ order: 35,
14
+ defaultOpen: true,
15
+ },
16
+ },
17
+ start(context) {
18
+ const uiContext = context.services.uiContext;
19
+ if (uiContext === undefined)
20
+ throw new Error('工作区调试模块缺少 DSH UI 上下文');
21
+ context.resources.add(registerDebugUi(uiContext, context.services.rpc, context.services.remote));
22
+ },
23
+ };
24
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1,33 @@
1
+ import type { FeatureRegistry } from '../../features/registry.js';
2
+ import type { FeatureUiDescriptor } from '../../shared/contracts/feature.js';
3
+ import { lanAccessFeature } from './lan-access.js';
4
+ import { reverseProxyFeature } from './reverse-proxy.js';
5
+ import { loginProtectionFeature } from './login-protection.js';
6
+ import { cliAdaptersFeature } from './cli-adapters.js';
7
+ import { terminalEnhancementFeature } from './terminal-enhancement.js';
8
+ import { workspaceSessionEnhancementFeature } from './workspace-session-enhancement.js';
9
+ import { debugFeature } from './debug.js';
10
+ import type { CodingNsClientFeatureModule, CodingNsClientServices } from './types.js';
11
+ /** Client 侧功能模块清单:新增模块在这里登记一行,不需要改动设置页和入口。 */
12
+ export declare const CLIENT_FEATURES: readonly CodingNsClientFeatureModule[];
13
+ /** 设置页要显示的一个模块及其界面描述。 */
14
+ export interface CodingNsSettingsModule {
15
+ readonly module: CodingNsClientFeatureModule;
16
+ readonly ui: FeatureUiDescriptor;
17
+ }
18
+ /**
19
+ * 汇总需要在设置页显示的模块,按 ui.order 升序。
20
+ *
21
+ * 归属 Host 的模块由 Host 侧配置承载,这里跳过;没有 ui 描述的模块不显示。
22
+ */
23
+ export declare function settingsModules(registry: FeatureRegistry<CodingNsClientServices, CodingNsClientFeatureModule>): readonly CodingNsSettingsModule[];
24
+ export { lanAccessFeature, loginProtectionFeature, reverseProxyFeature, cliAdaptersFeature, workspaceSessionEnhancementFeature, terminalEnhancementFeature, debugFeature };
25
+ export { startBrowserRelayConnection } from './reverse-proxy.js';
26
+ export { LanAccessPanel } from './lan-access-panel.js';
27
+ export { LoginProtectionPanel } from './login-protection-panel.js';
28
+ export { ReverseProxyPanel } from './reverse-proxy-panel.js';
29
+ export { CliAdaptersPanel } from './cli-adapters.js';
30
+ export { TerminalEnhancementPanel } from './terminal-enhancement-panel.js';
31
+ export { WorkspaceSessionEnhancementPanel } from './workspace-session-enhancement-panel.js';
32
+ export type { CodingNsClientFeatureModule, CodingNsClientServices, CodingNsRpcClient, CodingNsRpcResult, FeaturePanelProps, } from './types.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { lanAccessFeature } from './lan-access.js';
2
+ import { reverseProxyFeature } from './reverse-proxy.js';
3
+ import { loginProtectionFeature } from './login-protection.js';
4
+ import { cliAdaptersFeature } from './cli-adapters.js';
5
+ import { terminalEnhancementFeature } from './terminal-enhancement.js';
6
+ import { workspaceSessionEnhancementFeature } from './workspace-session-enhancement.js';
7
+ import { debugFeature } from './debug.js';
8
+ /** Client 侧功能模块清单:新增模块在这里登记一行,不需要改动设置页和入口。 */
9
+ export const CLIENT_FEATURES = [
10
+ lanAccessFeature,
11
+ loginProtectionFeature,
12
+ reverseProxyFeature,
13
+ cliAdaptersFeature,
14
+ workspaceSessionEnhancementFeature,
15
+ terminalEnhancementFeature,
16
+ debugFeature,
17
+ ];
18
+ /**
19
+ * 汇总需要在设置页显示的模块,按 ui.order 升序。
20
+ *
21
+ * 归属 Host 的模块由 Host 侧配置承载,这里跳过;没有 ui 描述的模块不显示。
22
+ */
23
+ export function settingsModules(registry) {
24
+ const entries = [];
25
+ for (const module of registry.modules()) {
26
+ if (module.descriptor.runtime === 'host')
27
+ continue;
28
+ const ui = module.descriptor.ui;
29
+ if (ui === undefined)
30
+ continue;
31
+ entries.push({ module, ui });
32
+ }
33
+ entries.sort((left, right) => (left.ui.order ?? 0) - (right.ui.order ?? 0));
34
+ return entries;
35
+ }
36
+ export { lanAccessFeature, loginProtectionFeature, reverseProxyFeature, cliAdaptersFeature, workspaceSessionEnhancementFeature, terminalEnhancementFeature, debugFeature };
37
+ export { startBrowserRelayConnection } from './reverse-proxy.js';
38
+ export { LanAccessPanel } from './lan-access-panel.js';
39
+ export { LoginProtectionPanel } from './login-protection-panel.js';
40
+ export { ReverseProxyPanel } from './reverse-proxy-panel.js';
41
+ export { CliAdaptersPanel } from './cli-adapters.js';
42
+ export { TerminalEnhancementPanel } from './terminal-enhancement-panel.js';
43
+ export { WorkspaceSessionEnhancementPanel } from './workspace-session-enhancement-panel.js';
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { FeaturePanelProps } from './types.js';
3
+ /** “局域网访问DSH”设置卡片:只配置一条监听并转发到当前 DSH Web。 */
4
+ export declare function LanAccessPanel({ services, enabled, snapshot: settingsSnapshot }: FeaturePanelProps): ReactElement;
5
+ //# sourceMappingURL=lan-access-panel.d.ts.map
@@ -0,0 +1,146 @@
1
+ import { createElement, useEffect, useState } from 'react';
2
+ import { CODINGNS_RPC_CHANNEL } from '../../shared/contracts/transport.js';
3
+ import { dshFormRootStyle, dshSettingsButtonStyle, dshSettingsFieldLabelStyle, dshSettingsFieldStyle, dshSettingsNoteStyle, dshSettingsPrimaryButtonStyle, dshSettingsRowStyle, dshThemeColor, } from '../theme.js';
4
+ import { useCodingNsTranslator } from '../locale.js';
5
+ /** “局域网访问DSH”设置卡片:只配置一条监听并转发到当前 DSH Web。 */
6
+ export function LanAccessPanel({ services, enabled, snapshot: settingsSnapshot }) {
7
+ const { rpc, settings } = services;
8
+ const t = useCodingNsTranslator(services.locale);
9
+ const [savedSettings, setSavedSettings] = useState();
10
+ const disabled = !enabled;
11
+ const controlsDisabled = disabled || settingsSnapshot.status === 'loading' || !settingsSnapshot.writable;
12
+ const [listenHosts, setListenHosts] = useState(['0.0.0.0']);
13
+ const [listenHost, setListenHost] = useState('0.0.0.0');
14
+ const [listenPort, setListenPort] = useState('13080');
15
+ const [dshPort, setDshPort] = useState('');
16
+ const [autoStart, setAutoStart] = useState(false);
17
+ const [detectedDshPorts, setDetectedDshPorts] = useState([]);
18
+ const [snapshot, setSnapshot] = useState(null);
19
+ const [busy, setBusy] = useState(false);
20
+ const [message, setMessage] = useState('');
21
+ useEffect(() => {
22
+ if (disabled)
23
+ return;
24
+ void callRpc(rpc, 'lanAccessDsh/addresses', {})
25
+ .then((addresses) => {
26
+ setListenHosts(addresses);
27
+ if (!addresses.includes(listenHost))
28
+ setListenHost(addresses[0] ?? '0.0.0.0');
29
+ })
30
+ .catch(() => undefined);
31
+ void callRpc(rpc, 'lanAccessDsh/get', {})
32
+ .then((current) => {
33
+ if (!current)
34
+ return;
35
+ setSnapshot(current);
36
+ })
37
+ .catch(() => undefined);
38
+ void callRpc(rpc, 'lanAccessDsh/settings/get', {})
39
+ .then(setSavedSettings)
40
+ .catch(() => {
41
+ const fallback = settings.getSnapshot().value?.lanAccessDsh;
42
+ if (fallback !== undefined)
43
+ setSavedSettings(fallback);
44
+ });
45
+ }, [disabled, rpc, settings]);
46
+ useEffect(() => {
47
+ if (savedSettings === undefined)
48
+ return;
49
+ setAutoStart(savedSettings.autoStart);
50
+ setListenHost(savedSettings.listenHost);
51
+ setListenPort(String(savedSettings.listenPort));
52
+ setDshPort(savedSettings.dshPort > 0 ? String(savedSettings.dshPort) : '');
53
+ }, [savedSettings]);
54
+ const run = async (operation) => {
55
+ setBusy(true);
56
+ setMessage('');
57
+ try {
58
+ await operation();
59
+ }
60
+ catch (error) {
61
+ setMessage(error instanceof Error ? error.message : String(error));
62
+ }
63
+ finally {
64
+ setBusy(false);
65
+ }
66
+ };
67
+ const detect = () => run(async () => {
68
+ const result = await callRpc(rpc, 'lanAccessDsh/detect', {});
69
+ setDetectedDshPorts(result.ports);
70
+ if (result.ports.length === 1)
71
+ setDshPort(String(result.ports[0]));
72
+ setMessage(result.ports.length === 0 ? t('lan.detectNone') : t('lan.detected', { ports: result.ports.join('、') }));
73
+ });
74
+ const saveMapping = async (nextAutoStart = autoStart) => {
75
+ const saved = await callRpc(rpc, 'lanAccessDsh/settings/set', readMapping(listenHost, listenPort, dshPort, nextAutoStart));
76
+ setSavedSettings(saved);
77
+ };
78
+ const saveMappingOnBlur = () => {
79
+ if (!autoStart)
80
+ return;
81
+ void saveMapping().catch((error) => {
82
+ setMessage(error instanceof Error ? error.message : String(error));
83
+ });
84
+ };
85
+ const start = () => run(async () => {
86
+ const saved = readMapping(listenHost, listenPort, dshPort, autoStart);
87
+ await saveMapping();
88
+ const payload = {
89
+ listenHost: saved.listenHost,
90
+ listenPort: saved.listenPort,
91
+ ...(saved.dshPort > 0 ? { dshPort: saved.dshPort } : {}),
92
+ };
93
+ const current = await callRpc(rpc, 'lanAccessDsh/start', payload);
94
+ setSnapshot(current);
95
+ setDshPort(String(current.dshPort));
96
+ setListenPort(String(current.listenPort));
97
+ setMessage(t('lan.started', { host: current.listenHost, port: current.actualListenPort ?? current.listenPort, dshPort: current.dshPort }));
98
+ });
99
+ const stop = () => run(async () => {
100
+ await callRpc(rpc, 'lanAccessDsh/stop', {});
101
+ setSnapshot(null);
102
+ setMessage(t('lan.stopped'));
103
+ });
104
+ const toggleAutoStart = () => run(async () => {
105
+ const next = !autoStart;
106
+ await saveMapping(next);
107
+ setAutoStart(next);
108
+ setMessage(next ? t('lan.autoStartOn') : t('lan.autoStartOff'));
109
+ });
110
+ const fieldStyle = dshSettingsFieldStyle;
111
+ const buttonStyle = dshSettingsButtonStyle;
112
+ return createElement('div', { 'aria-disabled': controlsDisabled, style: { ...dshFormRootStyle, display: 'flex', flexDirection: 'column', gap: 14, opacity: controlsDisabled ? 0.5 : 1, pointerEvents: controlsDisabled ? 'none' : 'auto' } }, createElement('p', { style: { margin: 0, color: dshThemeColor.labelSecondary, fontSize: 13, lineHeight: 1.5 } }, t('lan.description')), createElement('label', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, createElement('span', { style: dshSettingsFieldLabelStyle }, t('lan.listenHost')), createElement('select', { value: listenHost, disabled: controlsDisabled || busy, onChange: (event) => setListenHost(event.currentTarget.value), onBlur: saveMappingOnBlur, style: fieldStyle }, ...listenHosts.map((host) => createElement('option', { key: host, value: host }, host === '0.0.0.0' ? t('lan.allInterfaces') : host)))), createElement('label', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, createElement('span', { style: dshSettingsFieldLabelStyle }, t('lan.listenPort')), createElement('input', { type: 'number', min: 0, max: 65535, placeholder: t('lan.listenPort'), value: listenPort, disabled: controlsDisabled || busy, onChange: (event) => setListenPort(event.currentTarget.value), onBlur: saveMappingOnBlur, style: fieldStyle })), createElement('label', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, createElement('span', { style: dshSettingsFieldLabelStyle }, t('lan.dshPort')), createElement('div', { style: dshSettingsRowStyle }, createElement('input', { type: 'number', min: 1, max: 65535, placeholder: t('lan.dshPort'), value: dshPort, disabled: controlsDisabled || busy, onChange: (event) => setDshPort(event.currentTarget.value), onBlur: saveMappingOnBlur, style: { ...fieldStyle, flex: 1, minWidth: 0 } }), createElement('button', { type: 'button', disabled: controlsDisabled || busy, onClick: () => void detect(), style: buttonStyle }, t('lan.detect')))), detectedDshPorts.length > 1 && createElement('div', { style: dshSettingsNoteStyle }, t('lan.detectMultiple', { ports: detectedDshPorts.join('、') })), createElement('label', { style: { display: 'flex', alignItems: 'center', gap: 8, cursor: controlsDisabled || busy ? 'not-allowed' : 'pointer', color: dshThemeColor.labelSecondary, fontSize: 13 } }, createElement('input', { type: 'checkbox', checked: autoStart, disabled: controlsDisabled || busy, onChange: () => void toggleAutoStart(), style: { accentColor: dshThemeColor.accent } }), createElement('span', undefined, t('lan.autoStart'))), createElement('div', { style: dshSettingsRowStyle }, createElement('button', { type: 'button', disabled: controlsDisabled || busy || !listenPort, onClick: () => void start(), style: { ...dshSettingsPrimaryButtonStyle, flex: 1 } }, busy ? t('lan.processing') : snapshot ? t('lan.update') : t('lan.start')), snapshot && createElement('button', { type: 'button', disabled: controlsDisabled || busy, onClick: () => void stop(), style: buttonStyle }, t('lan.stop'))), snapshot && createElement('div', { role: 'status', style: dshSettingsNoteStyle }, t('lan.forwarding', { host: snapshot.listenHost, port: snapshot.actualListenPort ?? snapshot.listenPort, dshPort: snapshot.dshPort })), message && createElement('div', { role: 'status', style: { color: message.includes('已') ? dshThemeColor.success : dshThemeColor.error } }, message));
113
+ }
114
+ function readMapping(listenHost, listenPort, dshPort, autoStart) {
115
+ return {
116
+ autoStart,
117
+ listenHost,
118
+ listenPort: parsePort(listenPort, '监听端口', true),
119
+ dshPort: dshPort.trim() === '' ? 0 : parsePort(dshPort, 'DSH 本地端口', false),
120
+ };
121
+ }
122
+ function parsePort(value, field, allowZero) {
123
+ if (!/^\d+$/u.test(value))
124
+ throw new Error(`${field} 必须是数字`);
125
+ const port = Number(value);
126
+ const minimum = allowZero ? 0 : 1;
127
+ if (!Number.isInteger(port) || port < minimum || port > 65535)
128
+ throw new Error(`${field} 必须是 ${minimum} 到 65535 的整数`);
129
+ return port;
130
+ }
131
+ async function callRpc(rpc, endpoint, payload) {
132
+ let response;
133
+ try {
134
+ response = await rpc.call(CODINGNS_RPC_CHANNEL, endpoint, payload);
135
+ }
136
+ catch (error) {
137
+ const message = error instanceof Error ? error.message : String(error);
138
+ if (!/HTTP (?:404|405)\b/u.test(message))
139
+ throw error;
140
+ response = await rpc.call('/api', `codingns/${endpoint}`, payload);
141
+ }
142
+ if (!response.ok)
143
+ throw new Error(response.error.message);
144
+ return response.value;
145
+ }
146
+ //# sourceMappingURL=lan-access-panel.js.map
@@ -0,0 +1,9 @@
1
+ import type { CodingNsClientFeatureModule } from './types.js';
2
+ /**
3
+ * 局域网访问DSH模块。
4
+ *
5
+ * 入口加载时会补齐 `crypto.randomUUID`(见 client/index.ts);设置面板另外承载
6
+ * 监听转发配置。它的 start 是幂等的,重复执行不会覆盖浏览器原生实现。
7
+ */
8
+ export declare const lanAccessFeature: CodingNsClientFeatureModule;
9
+ //# sourceMappingURL=lan-access.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { ensureCryptoRandomUUID } from '../lan-access.js';
2
+ import { LanAccessPanel } from './lan-access-panel.js';
3
+ /**
4
+ * 局域网访问DSH模块。
5
+ *
6
+ * 入口加载时会补齐 `crypto.randomUUID`(见 client/index.ts);设置面板另外承载
7
+ * 监听转发配置。它的 start 是幂等的,重复执行不会覆盖浏览器原生实现。
8
+ */
9
+ export const lanAccessFeature = {
10
+ descriptor: {
11
+ name: 'lanAccess',
12
+ version: '0.1.0',
13
+ enabledByDefault: true,
14
+ dependencies: [],
15
+ runtime: 'client',
16
+ ui: {
17
+ label: '局域网访问DSH',
18
+ description: '通过局域网 IP 访问 DSH,自动补齐 crypto.randomUUID,并将监听端口转发到当前 DSH Web。',
19
+ labelKey: 'feature.lanAccess.label',
20
+ descriptionKey: 'feature.lanAccess.description',
21
+ order: 10,
22
+ alwaysEnabled: true,
23
+ },
24
+ },
25
+ start: () => {
26
+ ensureCryptoRandomUUID();
27
+ },
28
+ settingsPanel: LanAccessPanel,
29
+ };
30
+ //# sourceMappingURL=lan-access.js.map
@@ -0,0 +1,5 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { FeaturePanelProps } from './types.js';
3
+ /** 独立的登录保护设置卡片,凭据实际由 Host 保存和校验。 */
4
+ export declare function LoginProtectionPanel({ services, enabled, snapshot }: FeaturePanelProps): ReactElement;
5
+ //# sourceMappingURL=login-protection-panel.d.ts.map
@@ -0,0 +1,91 @@
1
+ import { createElement, useEffect, useState } from 'react';
2
+ import { CODINGNS_RPC_CHANNEL } from '../../shared/contracts/transport.js';
3
+ import { dshFormRootStyle, dshSettingsButtonStyle, dshSettingsFieldLabelStyle, dshSettingsFieldStyle, dshSettingsNoteStyle, dshSettingsPrimaryButtonStyle, dshThemeColor, } from '../theme.js';
4
+ import { writeLoginProtectionSession } from './login-protection-session.js';
5
+ const DEFAULT_SCOPES = { lan: true, relay: true };
6
+ /** 独立的登录保护设置卡片,凭据实际由 Host 保存和校验。 */
7
+ export function LoginProtectionPanel({ services, enabled, snapshot }) {
8
+ const { rpc } = services;
9
+ const controlsDisabled = !enabled || snapshot.status === 'loading' || !snapshot.writable;
10
+ const [saved, setSaved] = useState({ enabled: false, username: '', passwordConfigured: false, timeoutSeconds: 1800, scopes: DEFAULT_SCOPES });
11
+ const [active, setActive] = useState(false);
12
+ const [username, setUsername] = useState('');
13
+ const [password, setPassword] = useState('');
14
+ const [timeoutSeconds, setTimeoutSeconds] = useState('1800');
15
+ const [scopes, setScopes] = useState(DEFAULT_SCOPES);
16
+ const [busy, setBusy] = useState(false);
17
+ const [message, setMessage] = useState('');
18
+ useEffect(() => {
19
+ if (!enabled)
20
+ return;
21
+ void callRpc(rpc, 'lanAccessDsh/login/get', {})
22
+ .then((value) => {
23
+ setSaved(value);
24
+ setActive(value.enabled);
25
+ setUsername(value.username);
26
+ setTimeoutSeconds(String(value.timeoutSeconds));
27
+ setScopes(value.scopes ?? DEFAULT_SCOPES);
28
+ })
29
+ .catch((error) => setMessage(error instanceof Error ? error.message : String(error)));
30
+ }, [enabled, rpc]);
31
+ const save = async () => {
32
+ setBusy(true);
33
+ setMessage('');
34
+ try {
35
+ const parsedTimeout = Number(timeoutSeconds);
36
+ if (!Number.isInteger(parsedTimeout) || parsedTimeout < 60 || parsedTimeout > 604800)
37
+ throw new Error('会话超时时间必须是 60 到 604800 秒');
38
+ if (active && !Object.values(scopes).some(Boolean))
39
+ throw new Error('至少选择一个应用范围');
40
+ const value = await callRpc(rpc, 'lanAccessDsh/login/set', {
41
+ enabled: active,
42
+ username,
43
+ password,
44
+ timeoutSeconds: parsedTimeout,
45
+ scopes,
46
+ });
47
+ setSaved(value);
48
+ setActive(value.enabled);
49
+ if (value.relaySession?.token !== undefined) {
50
+ writeLoginProtectionSession(value.relaySession.token);
51
+ }
52
+ else if (!value.enabled || !value.scopes.relay) {
53
+ writeLoginProtectionSession(undefined);
54
+ }
55
+ setPassword('');
56
+ setMessage(value.enabled && value.scopes.relay && password === '' ? '设置已保存;中继访问需要重新输入密码以建立当前标签页会话' : '登录保护设置已保存');
57
+ }
58
+ catch (error) {
59
+ setMessage(error instanceof Error ? error.message : String(error));
60
+ }
61
+ finally {
62
+ setBusy(false);
63
+ }
64
+ };
65
+ const toggleScope = (scope) => setScopes((current) => ({ ...current, [scope]: !current[scope] }));
66
+ const field = dshSettingsFieldStyle;
67
+ const button = dshSettingsButtonStyle;
68
+ return createElement('div', {
69
+ style: { ...dshFormRootStyle, display: 'flex', flexDirection: 'column', gap: 14, opacity: controlsDisabled ? 0.5 : 1 },
70
+ 'aria-disabled': controlsDisabled,
71
+ }, createElement('p', { style: { margin: 0, color: dshThemeColor.labelSecondary, fontSize: 13, lineHeight: 1.5 } }, '为局域网和中继访问统一增加本地账号验证。本机 127.0.0.1 / ::1 永远不受此保护。密码只在 Host 侧验证,不会进入浏览器设置或 URL。'), createElement('label', { style: { display: 'flex', alignItems: 'center', gap: 8, color: dshThemeColor.labelSecondary, fontSize: 13 } }, createElement('input', { type: 'checkbox', checked: active, disabled: controlsDisabled || busy, onChange: (event) => setActive(event.currentTarget.checked), style: { accentColor: dshThemeColor.accent } }), createElement('span', undefined, '启用登录保护')), createElement('label', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, createElement('span', { style: dshSettingsFieldLabelStyle }, '本地用户名'), createElement('input', { value: username, disabled: controlsDisabled || busy || !active, autoComplete: 'username', onChange: (event) => setUsername(event.currentTarget.value), style: field })), createElement('label', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, createElement('span', { style: dshSettingsFieldLabelStyle }, saved.passwordConfigured ? '新密码(留空保持不变)' : '密码(至少 8 位)'), createElement('input', { type: 'password', value: password, disabled: controlsDisabled || busy || !active, autoComplete: 'new-password', onChange: (event) => setPassword(event.currentTarget.value), style: field })), createElement('label', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, createElement('span', { style: dshSettingsFieldLabelStyle }, '会话超时(秒)'), createElement('input', { type: 'number', min: 60, max: 604800, value: timeoutSeconds, disabled: controlsDisabled || busy || !active, onChange: (event) => setTimeoutSeconds(event.currentTarget.value), style: field })), createElement('fieldset', { disabled: controlsDisabled || busy || !active, style: { display: 'flex', flexDirection: 'column', gap: 8, margin: 0, padding: 12, border: `1px solid ${dshThemeColor.border}`, borderRadius: 6 } }, createElement('legend', { style: dshSettingsFieldLabelStyle }, '应用范围'), ...[
72
+ ['lan', '局域网访问', '局域网网卡入口'],
73
+ ['relay', '中继访问', 'DSH-Codingns4DSH 中继'],
74
+ ].map(([key, label, hint]) => createElement('label', { key, style: { display: 'flex', alignItems: 'center', gap: 8, color: dshThemeColor.labelSecondary, fontSize: 13 } }, createElement('input', { type: 'checkbox', checked: scopes[key], onChange: () => toggleScope(key), style: { accentColor: dshThemeColor.accent } }), createElement('span', undefined, `${label}(${hint})`)))), createElement('button', { type: 'button', disabled: controlsDisabled || busy, onClick: () => void save(), style: dshSettingsPrimaryButtonStyle }, busy ? '保存中…' : '保存登录保护'), message && createElement('div', { role: 'status', style: message.includes('已') ? { color: dshThemeColor.success } : { ...dshSettingsNoteStyle, color: dshThemeColor.error } }, message));
75
+ }
76
+ async function callRpc(rpc, endpoint, payload) {
77
+ let response;
78
+ try {
79
+ response = await rpc.call(CODINGNS_RPC_CHANNEL, endpoint, payload);
80
+ }
81
+ catch (error) {
82
+ const message = error instanceof Error ? error.message : String(error);
83
+ if (!/HTTP (?:404|405)\b/u.test(message))
84
+ throw error;
85
+ response = await rpc.call('/api', `codingns/${endpoint}`, payload);
86
+ }
87
+ if (!response.ok)
88
+ throw new Error(response.error.message);
89
+ return response.value;
90
+ }
91
+ //# sourceMappingURL=login-protection-panel.js.map
@@ -0,0 +1,6 @@
1
+ /** 登录保护会话只放在当前浏览器标签页,关闭标签页即失效。 */
2
+ export declare const LOGIN_PROTECTION_SESSION_KEY = "codingns4dsh.login-protection.relay-token";
3
+ export declare const LOGIN_PROTECTION_SESSION_EVENT = "codingns4dsh-login-protection-session";
4
+ export declare function readLoginProtectionSession(): string | undefined;
5
+ export declare function writeLoginProtectionSession(token: string | undefined): void;
6
+ //# sourceMappingURL=login-protection-session.d.ts.map