@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,242 @@
1
+ import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
2
+ import { dirname } from 'node:path';
3
+ const STORE_VERSION = 1;
4
+ /** JSON 文件写入采用同目录临时文件加 rename,避免崩溃留下半截记录。 */
5
+ export class JsonFileTerminalStorePersistence {
6
+ filename;
7
+ constructor(filename) {
8
+ this.filename = filename;
9
+ }
10
+ async load() {
11
+ try {
12
+ return JSON.parse(await readFile(this.filename, 'utf8'));
13
+ }
14
+ catch (error) {
15
+ if (isMissingFile(error))
16
+ return { version: STORE_VERSION, records: [] };
17
+ throw error;
18
+ }
19
+ }
20
+ async save(document) {
21
+ const directory = dirname(this.filename);
22
+ const temporary = `${this.filename}.${process.pid}.tmp`;
23
+ await mkdir(directory, { recursive: true, mode: 0o700 });
24
+ await writeFile(temporary, `${JSON.stringify(document, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
25
+ await rename(temporary, this.filename);
26
+ }
27
+ }
28
+ /**
29
+ * 持久终端记录表。
30
+ *
31
+ * 所有修改在一条 promise 队列中执行;调用完成代表新状态已经落盘。这样 create、
32
+ * recover 与 close 不会用最后写入者覆盖彼此的结果。
33
+ */
34
+ export class CodingNsTerminalStore {
35
+ persistence;
36
+ records = new Map();
37
+ writeTail = Promise.resolve();
38
+ loaded = false;
39
+ constructor(persistence) {
40
+ this.persistence = persistence;
41
+ }
42
+ async load() {
43
+ if (this.loaded)
44
+ return;
45
+ const document = parseDocument(await this.persistence.load());
46
+ this.records.clear();
47
+ for (const record of document.records)
48
+ this.records.set(recordKey(record), record);
49
+ this.loaded = true;
50
+ }
51
+ list(scope) {
52
+ this.requireLoaded();
53
+ const records = [...this.records.values()]
54
+ .filter((record) => scope === undefined || sameScope(record, scope))
55
+ .sort((left, right) => left.createdAt.localeCompare(right.createdAt));
56
+ return records.map(cloneRecord);
57
+ }
58
+ get(identity) {
59
+ this.requireLoaded();
60
+ const record = this.records.get(recordKey(identity));
61
+ return record === undefined ? undefined : cloneRecord(record);
62
+ }
63
+ put(record) {
64
+ validateRecord(record);
65
+ return this.enqueue(async () => {
66
+ this.records.set(recordKey(record), cloneRecord(record));
67
+ await this.persist();
68
+ });
69
+ }
70
+ patch(identity, patch) {
71
+ return this.enqueue(async () => {
72
+ const key = recordKey(identity);
73
+ const current = this.records.get(key);
74
+ if (current === undefined)
75
+ return undefined;
76
+ const next = {
77
+ ...current,
78
+ ...patch,
79
+ ...(patch.error === undefined ? { error: current.error } : {}),
80
+ };
81
+ validateRecord(next);
82
+ this.records.set(key, next);
83
+ await this.persist();
84
+ return cloneRecord(next);
85
+ });
86
+ }
87
+ remove(identity) {
88
+ return this.enqueue(async () => {
89
+ if (!this.records.delete(recordKey(identity)))
90
+ return false;
91
+ await this.persist();
92
+ return true;
93
+ });
94
+ }
95
+ enqueue(operation) {
96
+ this.requireLoaded();
97
+ const pending = this.writeTail.then(operation, operation);
98
+ this.writeTail = pending.then(() => undefined, () => undefined);
99
+ return pending;
100
+ }
101
+ async persist() {
102
+ await this.persistence.save({ version: STORE_VERSION, records: this.list() });
103
+ }
104
+ requireLoaded() {
105
+ if (!this.loaded)
106
+ throw new Error('终端持久存储尚未加载');
107
+ }
108
+ }
109
+ export class InMemoryTerminalStorePersistence {
110
+ document;
111
+ constructor(initial = { version: STORE_VERSION, records: [] }) {
112
+ this.document = structuredClone(initial);
113
+ }
114
+ async load() {
115
+ return structuredClone(this.document);
116
+ }
117
+ async save(document) {
118
+ this.document = structuredClone(document);
119
+ }
120
+ snapshot() {
121
+ return structuredClone(this.document);
122
+ }
123
+ }
124
+ export function terminalStorePath(settingsDocumentPath) {
125
+ return `${dirname(settingsDocumentPath)}/codingns4dsh/terminals.json`;
126
+ }
127
+ function parseDocument(value) {
128
+ if (!isRecord(value) || value.version !== STORE_VERSION || !Array.isArray(value.records)) {
129
+ throw new TypeError('终端持久存储格式无效');
130
+ }
131
+ const records = value.records.map(parseRecord);
132
+ // 旧版本把 sessionId 放进主键;升级到工作区主键后,重复项保留最后更新的一条。
133
+ const byKey = new Map();
134
+ for (const record of records) {
135
+ const key = recordKey(record);
136
+ const previous = byKey.get(key);
137
+ if (previous === undefined || previous.updatedAt <= record.updatedAt)
138
+ byKey.set(key, record);
139
+ }
140
+ return { version: STORE_VERSION, records: [...byKey.values()] };
141
+ }
142
+ function parseRecord(value) {
143
+ if (!isRecord(value))
144
+ throw new TypeError('终端记录必须是对象');
145
+ const record = value;
146
+ validateRecord(record);
147
+ return cloneRecord(record);
148
+ }
149
+ function validateRecord(record) {
150
+ for (const [name, value] of [
151
+ ['hostId', record.hostId],
152
+ ['workspaceId', record.workspaceId],
153
+ ['terminalId', record.terminalId],
154
+ ['runtimeSessionKey', record.runtimeSessionKey],
155
+ ['shellPath', record.shellPath],
156
+ ['cwd', record.cwd],
157
+ ['title', record.title],
158
+ ['createdAt', record.createdAt],
159
+ ['updatedAt', record.updatedAt],
160
+ ]) {
161
+ if (typeof value !== 'string' || value.trim() === '')
162
+ throw new TypeError(`终端记录字段 ${name} 无效`);
163
+ }
164
+ if (record.dshSessionId !== undefined && (typeof record.dshSessionId !== 'string' || record.dshSessionId.trim() === '')) {
165
+ throw new TypeError('终端记录字段 dshSessionId 无效');
166
+ }
167
+ if (!['local-pty', 'tmux', 'conpty-powershell', 'conpty-cmd', 'conpty-git-bash'].includes(record.runtimeType)) {
168
+ throw new TypeError('终端记录 runtimeType 无效');
169
+ }
170
+ if (!['starting', 'running', 'exited', 'closing', 'lost', 'closed', 'error'].includes(record.state)) {
171
+ throw new TypeError('终端记录 state 无效');
172
+ }
173
+ if (!Number.isSafeInteger(record.cols) || record.cols < 2 || !Number.isSafeInteger(record.rows) || record.rows < 1) {
174
+ throw new TypeError('终端记录尺寸无效');
175
+ }
176
+ if (record.exitCode !== null && !Number.isSafeInteger(record.exitCode))
177
+ throw new TypeError('终端记录 exitCode 无效');
178
+ if (record.error !== undefined && typeof record.error !== 'string')
179
+ throw new TypeError('终端记录 error 无效');
180
+ if (record.shellProfileId !== undefined && !['zsh', 'bash', 'powershell', 'cmd', 'git-bash'].includes(record.shellProfileId)) {
181
+ throw new TypeError('终端记录 shellProfileId 无效');
182
+ }
183
+ if (record.shellName !== undefined && (typeof record.shellName !== 'string' || record.shellName.trim() === '')) {
184
+ throw new TypeError('终端记录 shellName 无效');
185
+ }
186
+ if (record.shellArgs !== undefined && (!Array.isArray(record.shellArgs) || record.shellArgs.some((value) => typeof value !== 'string'))) {
187
+ throw new TypeError('终端记录 shellArgs 无效');
188
+ }
189
+ if (record.commandPath !== undefined && (typeof record.commandPath !== 'string' || record.commandPath.trim() === '')) {
190
+ throw new TypeError('终端记录 commandPath 无效');
191
+ }
192
+ if (record.commandArgs !== undefined && (!Array.isArray(record.commandArgs) || record.commandArgs.some((value) => typeof value !== 'string'))) {
193
+ throw new TypeError('终端记录 commandArgs 无效');
194
+ }
195
+ if (record.commandEnv !== undefined && (!isRecord(record.commandEnv) || Object.values(record.commandEnv).some((value) => typeof value !== 'string'))) {
196
+ throw new TypeError('终端记录 commandEnv 无效');
197
+ }
198
+ if (record.launchProfileId !== undefined && (typeof record.launchProfileId !== 'string' || record.launchProfileId.trim() === '')) {
199
+ throw new TypeError('终端记录 launchProfileId 无效');
200
+ }
201
+ }
202
+ function sameScope(record, scope) {
203
+ return record.hostId === scope.hostId
204
+ && record.workspaceId === scope.workspaceId;
205
+ }
206
+ function recordKey(identity) {
207
+ return JSON.stringify([identity.hostId, identity.workspaceId, identity.terminalId]);
208
+ }
209
+ function cloneRecord(record) {
210
+ return {
211
+ hostId: record.hostId,
212
+ workspaceId: record.workspaceId,
213
+ ...(record.dshSessionId === undefined ? {} : { dshSessionId: record.dshSessionId }),
214
+ terminalId: record.terminalId,
215
+ runtimeSessionKey: record.runtimeSessionKey,
216
+ runtimeType: record.runtimeType,
217
+ shellPath: record.shellPath,
218
+ ...(record.shellProfileId === undefined ? {} : { shellProfileId: record.shellProfileId }),
219
+ ...(record.shellName === undefined ? {} : { shellName: record.shellName }),
220
+ ...(record.shellArgs === undefined ? {} : { shellArgs: [...record.shellArgs] }),
221
+ ...(record.commandPath === undefined ? {} : { commandPath: record.commandPath }),
222
+ ...(record.commandArgs === undefined ? {} : { commandArgs: [...record.commandArgs] }),
223
+ ...(record.commandEnv === undefined ? {} : { commandEnv: { ...record.commandEnv } }),
224
+ ...(record.launchProfileId === undefined ? {} : { launchProfileId: record.launchProfileId }),
225
+ cwd: record.cwd,
226
+ title: record.title,
227
+ cols: record.cols,
228
+ rows: record.rows,
229
+ state: record.state,
230
+ exitCode: record.exitCode,
231
+ ...(record.error === undefined ? {} : { error: record.error }),
232
+ createdAt: record.createdAt,
233
+ updatedAt: record.updatedAt,
234
+ };
235
+ }
236
+ function isRecord(value) {
237
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
238
+ }
239
+ function isMissingFile(error) {
240
+ return isRecord(error) && error.code === 'ENOENT';
241
+ }
242
+ //# sourceMappingURL=terminal-store.js.map
@@ -0,0 +1,37 @@
1
+ /** Host 入口是包根导出;共享契约通过显式子路径另行提供。 */
2
+ import { apply as hostApply } from './host/index.js';
3
+ /** Cordis Bundle 标准插件名称。 */
4
+ export declare const name = "codingns4dsh";
5
+ /** Host Cordis 入口。 */
6
+ export declare const apply: typeof hostApply;
7
+ export default hostApply;
8
+ export { createCodingNsRpcHandler, createCodingNsSettingsRpcHandler, registerCodingNsRpc } from './host/rpc.js';
9
+ export { CodingNsRpcError, CodingNsRpcTable, type CodingNsRpcHandler, type CodingNsRpcTarget, } from './host/rpc-table.js';
10
+ export { HOST_FEATURES, createAuthFeature, createCliAdaptersFeature, createLanAccessDshFeature, } from './host/features/index.js';
11
+ export type { CodingNsHostServices } from './host/features/index.js';
12
+ export { CODINGNS_TUNNEL_DATA_CHANNEL_LABEL, FileHostDtlsIdentityStore, createRegisteredHostSignalingSocket, createWeriftPeerConnectionFactory, ensureHostDtlsIdentity, formatHostDtlsFingerprint, generateHostDtlsIdentity, startHostRelayRuntime, } from './host/relay-tunnel-runtime.js';
13
+ export type { HostDtlsIdentityMaterial, HostDtlsIdentityStore, HostRelayRuntime, HostRelayRuntimeOptions, HostRelaySession, HostSignalingSocket, } from './host/relay-tunnel-runtime.js';
14
+ export { createDshRpcGatewayFeature } from './host/dsh-gateway-feature.js';
15
+ export { createLocalDshWebRuntimeProvider, createRemoteWebRuntimeFeature, type DshWebAsset, type DshWebBoot, type DshWebRuntimeProvider, type DshWebSession, type DshWebSocketLike, type LocalDshWebRuntimeProviderOptions, type RemoteWebRuntimeFeatureOptions, } from './host/remote-web-runtime.js';
16
+ export { RemoteDshWebContext } from './client/remote-web-context.js';
17
+ export type { RemoteDshWebBoot, RemoteDshWebContextOptions } from './client/remote-web-context.js';
18
+ export { createHttpDshH5ControlApi, startDshH5BrowserBootstrap } from './client/dsh-h5-bootstrap.js';
19
+ export type { DshH5BrowserBootstrapOptions, DshH5BrowserBootstrapResult, DshH5BrowserControlApi } from './client/dsh-h5-bootstrap.js';
20
+ export { CODINGNS_RPC_CHANNEL } from './shared/contracts/transport.js';
21
+ export { CODINGNS_CONTROL_BASE_URL_FIELD, CODINGNS_CONTROL_BASE_URLS_FIELD, CODINGNS_LAN_ACCESS_DSH_FIELD, CODINGNS_MODULES_FIELD, CODINGNS_SETTINGS_NAMESPACE, DEFAULT_CODINGNS_CONTROL_BASE_URL, DEFAULT_CODINGNS_CONTROL_BASE_URLS, DEFAULT_CODINGNS_SETTINGS, enabledFeatureNames, isFeatureEnabled, } from './shared/contracts/config.js';
22
+ export type * from './shared/index.js';
23
+ export { FeatureRegistry, FeatureRegistryError, FeatureResourceScopeImpl, } from './features/registry.js';
24
+ export type { FeatureRegistryErrorCode, FeatureSnapshot, } from './features/registry.js';
25
+ export { ResourceScopeManager } from './features/resource-scope/index.js';
26
+ export { CodingNsAuthSession, } from './host/auth-session.js';
27
+ export { CODINGNS_CONTROL_API_PATHS, CodingNsControlApiError, HttpCodingNsControlApiClient, type CodingNsControlApiClient, type CodingNsControlClient, type HttpCodingNsControlApiClientOptions, } from './host/control-api-client.js';
28
+ export { InMemoryCodingNsCredentialStore, type CodingNsCredentialStore, } from './host/credential-store.js';
29
+ export type { HostCredentialRecord } from './host/credential-store.js';
30
+ export { LanAccessDshError, LanAccessDshProxy, createLanAccessDshRpcHandler, createNodeLanAccessDshRuntime, normalizeLanAccessDshConfig, } from './host/lan-access-dsh.js';
31
+ export type { LanAccessDshRuntime, LanAccessDshStream } from './host/lan-access-dsh.js';
32
+ export type { LoginByEmailResponse, RefreshTokenRequest, RefreshTokenResponse, } from './host/control-api-client.js';
33
+ export { DshCodingNsTransport, DshTunnelMultiplexer, DshSession, DshGateway, DSH_GATEWAY_PATH, encodeDshEnvelope, decodeDshEnvelope, validateDshEnvelope, DSH_ENVELOPE_PROTOCOL, DSH_ENVELOPE_VERSION, DEFAULT_MAX_DSH_ENVELOPE_BYTES, DEFAULT_MAX_DSH_META_BYTES, createDataChannelCarrier, createRelayTunnelHostCarrier, TUNNEL_DATA_CHANNEL_LABEL, DATA_CHANNEL_FRAGMENT_PAYLOAD_BYTES, DATA_CHANNEL_FRAGMENT_HEADER_BYTES, DATA_CHANNEL_MAX_REASSEMBLY_BYTES, decodeTunnelFrame, encodeTunnelFrame, TUNNEL_PROTOCOL_VERSION, validateTunnelFrame, tunnelFrameByteLength, DEFAULT_MAX_TUNNEL_FRAME_BYTES, assertDtlsFingerprint, connectWebRtcClient, createSignalingUrl, extractDtlsFingerprint, waitForSignalingRegistered, waitForPeerReady, acceptWebRtcHost, createHostSignalingTicketRequest, requestHostSignalingTicket, createDshTransportDebugLogger, resolveDshTransportDebugEnabled, } from './transport/index.js';
34
+ export { bindDshConnection, bindDshConnectionHooks, createDshClientTransportHooks, createDshGenerationSource, createDshGenerationSourceFromHooks, installDshTransport, SUPPORTED_DSH_CONNECTION_VERSION, } from './bootstrap/index.js';
35
+ export type { DshClientTransportHooks, DshConnectionContext, DshConnectionHandle, DshConnectionRpcFailure, DshConnectionRpcResponse, DshConnectionRpcResult, DshGenerationSource, DshTransportLifecycle, } from './bootstrap/index.js';
36
+ export type { CodingNsCarrier, DataChannelCarrierOptions, DataChannelLike, DshCodingNsTransportOptions, TunnelChannel, TunnelFrame, TunnelFrameKind, PeerConnectionLike, SignalingSocketLike, WebRtcClientConnection, WebRtcClientConnectorOptions, HostPeerConnectionLike, HostSignalingTicketRequest, WebRtcHostAcceptor, WebRtcHostAcceptorOptions, WebRtcHostSession, DshTunnelMultiplexerOptions, TunnelFlowControl, DshSessionOptions, DshSessionRole, DshSessionState, DshGatewayFeature, DshGatewayOptions, DshStreamContext, DshEnvelope, DshEnvelopeCodecOptions, DshEnvelopeFlags, DshHostScope, DshChannel, TunnelFrameCodecOptions, DshTransportDebugLogger, DshTransportDebugOptions, DshTransportDebugSide, } from './transport/index.js';
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,26 @@
1
+ /** Host 入口是包根导出;共享契约通过显式子路径另行提供。 */
2
+ import { apply as hostApply } from './host/index.js';
3
+ /** Cordis Bundle 标准插件名称。 */
4
+ export const name = 'codingns4dsh';
5
+ /** Host Cordis 入口。 */
6
+ export const apply = hostApply;
7
+ export default hostApply;
8
+ export { createCodingNsRpcHandler, createCodingNsSettingsRpcHandler, registerCodingNsRpc } from './host/rpc.js';
9
+ export { CodingNsRpcError, CodingNsRpcTable, } from './host/rpc-table.js';
10
+ export { HOST_FEATURES, createAuthFeature, createCliAdaptersFeature, createLanAccessDshFeature, } from './host/features/index.js';
11
+ export { CODINGNS_TUNNEL_DATA_CHANNEL_LABEL, FileHostDtlsIdentityStore, createRegisteredHostSignalingSocket, createWeriftPeerConnectionFactory, ensureHostDtlsIdentity, formatHostDtlsFingerprint, generateHostDtlsIdentity, startHostRelayRuntime, } from './host/relay-tunnel-runtime.js';
12
+ export { createDshRpcGatewayFeature } from './host/dsh-gateway-feature.js';
13
+ export { createLocalDshWebRuntimeProvider, createRemoteWebRuntimeFeature, } from './host/remote-web-runtime.js';
14
+ export { RemoteDshWebContext } from './client/remote-web-context.js';
15
+ export { createHttpDshH5ControlApi, startDshH5BrowserBootstrap } from './client/dsh-h5-bootstrap.js';
16
+ export { CODINGNS_RPC_CHANNEL } from './shared/contracts/transport.js';
17
+ export { CODINGNS_CONTROL_BASE_URL_FIELD, CODINGNS_CONTROL_BASE_URLS_FIELD, CODINGNS_LAN_ACCESS_DSH_FIELD, CODINGNS_MODULES_FIELD, CODINGNS_SETTINGS_NAMESPACE, DEFAULT_CODINGNS_CONTROL_BASE_URL, DEFAULT_CODINGNS_CONTROL_BASE_URLS, DEFAULT_CODINGNS_SETTINGS, enabledFeatureNames, isFeatureEnabled, } from './shared/contracts/config.js';
18
+ export { FeatureRegistry, FeatureRegistryError, FeatureResourceScopeImpl, } from './features/registry.js';
19
+ export { ResourceScopeManager } from './features/resource-scope/index.js';
20
+ export { CodingNsAuthSession, } from './host/auth-session.js';
21
+ export { CODINGNS_CONTROL_API_PATHS, CodingNsControlApiError, HttpCodingNsControlApiClient, } from './host/control-api-client.js';
22
+ export { InMemoryCodingNsCredentialStore, } from './host/credential-store.js';
23
+ export { LanAccessDshError, LanAccessDshProxy, createLanAccessDshRpcHandler, createNodeLanAccessDshRuntime, normalizeLanAccessDshConfig, } from './host/lan-access-dsh.js';
24
+ export { DshCodingNsTransport, DshTunnelMultiplexer, DshSession, DshGateway, DSH_GATEWAY_PATH, encodeDshEnvelope, decodeDshEnvelope, validateDshEnvelope, DSH_ENVELOPE_PROTOCOL, DSH_ENVELOPE_VERSION, DEFAULT_MAX_DSH_ENVELOPE_BYTES, DEFAULT_MAX_DSH_META_BYTES, createDataChannelCarrier, createRelayTunnelHostCarrier, TUNNEL_DATA_CHANNEL_LABEL, DATA_CHANNEL_FRAGMENT_PAYLOAD_BYTES, DATA_CHANNEL_FRAGMENT_HEADER_BYTES, DATA_CHANNEL_MAX_REASSEMBLY_BYTES, decodeTunnelFrame, encodeTunnelFrame, TUNNEL_PROTOCOL_VERSION, validateTunnelFrame, tunnelFrameByteLength, DEFAULT_MAX_TUNNEL_FRAME_BYTES, assertDtlsFingerprint, connectWebRtcClient, createSignalingUrl, extractDtlsFingerprint, waitForSignalingRegistered, waitForPeerReady, acceptWebRtcHost, createHostSignalingTicketRequest, requestHostSignalingTicket, createDshTransportDebugLogger, resolveDshTransportDebugEnabled, } from './transport/index.js';
25
+ export { bindDshConnection, bindDshConnectionHooks, createDshClientTransportHooks, createDshGenerationSource, createDshGenerationSourceFromHooks, installDshTransport, SUPPORTED_DSH_CONNECTION_VERSION, } from './bootstrap/index.js';
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Codingns4DSH 控制面认证契约。
3
+ *
4
+ * 这些 DTO 与 codingns-proxy/packages/shared-contracts 保持字段兼容。
5
+ * 阶段 2 只定义数据边界,不在插件中发起真实网络请求。
6
+ */
7
+ export type AccountRole = 'user' | 'admin';
8
+ export type AccountStatus = 'pending_verification' | 'active' | 'disabled';
9
+ export interface AccountProfile {
10
+ accountId: string;
11
+ email: string;
12
+ emailVerified: boolean;
13
+ role: AccountRole;
14
+ mustChangePassword: boolean;
15
+ createdAt: string;
16
+ status?: AccountStatus;
17
+ sessionVersion?: number;
18
+ }
19
+ export interface LoginByEmailRequest {
20
+ email: string;
21
+ password: string;
22
+ }
23
+ export type AuthClientType = 'desktop' | 'web' | 'ios' | 'android' | 'unknown';
24
+ export interface AuthDeviceViewDto {
25
+ deviceId: string | null;
26
+ clientType: AuthClientType;
27
+ clientInstanceId: string | null;
28
+ displayName: string | null;
29
+ browserName: string | null;
30
+ browserVersion: string | null;
31
+ osName: string | null;
32
+ osVersion: string | null;
33
+ lastSourceAddress: string | null;
34
+ lastSeenAt: string;
35
+ isPrimary: boolean;
36
+ isCurrent: boolean;
37
+ isLegacy: boolean;
38
+ }
39
+ export interface RecentLoginRecordViewDto {
40
+ id: string;
41
+ deviceId: string | null;
42
+ clientType: AuthClientType;
43
+ displayName: string | null;
44
+ browserName: string | null;
45
+ browserVersion: string | null;
46
+ osName: string | null;
47
+ osVersion: string | null;
48
+ sourceAddress: string | null;
49
+ occurredAt: string;
50
+ isCurrentDevice: boolean;
51
+ isLegacy: boolean;
52
+ }
53
+ export interface AuthDeviceManagementSnapshotDto {
54
+ currentDevice: AuthDeviceViewDto | null;
55
+ otherActiveDevices: AuthDeviceViewDto[];
56
+ recentLoginRecords: RecentLoginRecordViewDto[];
57
+ }
58
+ export interface TunnelBindingSummary {
59
+ bindingId: string;
60
+ tunnelDomain: string;
61
+ hostPublicKey: string;
62
+ hostFingerprint: string;
63
+ relayBaseUrl: string;
64
+ controlBaseUrl: string;
65
+ sessionRateLimitBytesPerSecond: string | null;
66
+ effectiveSessionRateLimitBytesPerSecond: string | null;
67
+ status: 'active' | 'disabled';
68
+ credentialVersion?: number;
69
+ runtime?: {
70
+ online: boolean;
71
+ onlineSince: string | null;
72
+ lastHeartbeatAt: string | null;
73
+ localTargetBaseUrl: string | null;
74
+ candidateEndpoints: Array<{
75
+ endpointId: string;
76
+ kind: 'relay' | 'lan' | 'loopback' | 'tailscale' | 'custom';
77
+ url: string;
78
+ priority: number;
79
+ expiresAt: string | null;
80
+ source: 'host_reported' | 'desktop_scan' | 'user_saved';
81
+ }>;
82
+ } | null;
83
+ }
84
+ export interface HostBindRequest {
85
+ hostLabel: string;
86
+ hostPublicKey: string;
87
+ hostFingerprint: string;
88
+ }
89
+ export interface HostBindResponse {
90
+ binding: TunnelBindingSummary;
91
+ created: boolean;
92
+ }
93
+ export interface HostBindingsResponse {
94
+ bindings: TunnelBindingSummary[];
95
+ }
96
+ export interface HostUnbindResponse {
97
+ released: true;
98
+ binding: TunnelBindingSummary;
99
+ }
100
+ export interface HostLabelAvailabilityResponse {
101
+ hostLabel: string;
102
+ tunnelDomain: string | null;
103
+ available: boolean;
104
+ reason: 'available' | 'occupied' | 'reserved' | 'unavailable';
105
+ }
106
+ export type CodingNsAuthStatus = 'logged_out' | 'logging_in' | 'authenticated' | 'refreshing' | 'revoked' | 'failed';
107
+ /** 不含 access/refresh token,可安全用于 Host 内部状态展示和日志摘要。 */
108
+ export interface CodingNsAuthSessionSnapshot {
109
+ status: CodingNsAuthStatus;
110
+ account: AccountProfile | null;
111
+ currentDevice: AuthDeviceViewDto | null;
112
+ binding: TunnelBindingSummary | null;
113
+ expiresAt: string | null;
114
+ errorCode: string | null;
115
+ }
116
+ export interface CodingNsAuthLoginResult {
117
+ account: AccountProfile;
118
+ expiresAt: string;
119
+ currentDevice: AuthDeviceViewDto | null;
120
+ binding: TunnelBindingSummary | null;
121
+ }
122
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Codingns4DSH 控制面认证契约。
3
+ *
4
+ * 这些 DTO 与 codingns-proxy/packages/shared-contracts 保持字段兼容。
5
+ * 阶段 2 只定义数据边界,不在插件中发起真实网络请求。
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1,192 @@
1
+ /** Codingns4DSH 当前可接入的外部 Agent 标识。内部字段沿用 cli 命名以保持协议兼容。 */
2
+ export type CodingNsCliAdapterId = string;
3
+ /** Host 侧可供 Client 展示的外部 Agent 摘要。 */
4
+ export interface CodingNsCliAdapterDescriptor {
5
+ readonly id: CodingNsCliAdapterId;
6
+ readonly name: string;
7
+ /** 适配器使用的标准运行时协议,供设置页和诊断显示。 */
8
+ readonly protocol?: 'command' | 'stream-json' | 'json-rpc' | 'acp' | 'http-sse';
9
+ /** 适配器已经验证的能力;未声明的能力必须按不支持处理。 */
10
+ readonly capabilities?: readonly CodingNsCliCapability[];
11
+ readonly installed: boolean;
12
+ readonly enabled: boolean;
13
+ readonly version: string | null;
14
+ readonly command: string | null;
15
+ }
16
+ export type CodingNsCliCapability = 'models' | 'stream' | 'resume' | 'interrupt' | 'tool-events' | 'reasoning' | 'usage' | 'permission' | 'questions' | 'steer';
17
+ /** 适配器模型及其可用思考强度。 */
18
+ export interface CodingNsCliModel {
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly description?: string;
22
+ readonly efforts: readonly string[];
23
+ }
24
+ export interface CodingNsCliModelGroup {
25
+ readonly id: string;
26
+ readonly name: string;
27
+ readonly models: readonly CodingNsCliModel[];
28
+ }
29
+ export interface CodingNsCliModelCatalog {
30
+ readonly groups: readonly CodingNsCliModelGroup[];
31
+ readonly currentModel: string | null;
32
+ readonly currentEffort: string | null;
33
+ }
34
+ /** 每个 DSH 会话绑定的 CLI 选择;不包含凭据。 */
35
+ export interface CodingNsCliSessionConfig {
36
+ readonly adapterId: CodingNsCliAdapterId;
37
+ readonly modelId?: string;
38
+ readonly effortId?: string;
39
+ /** 外部运行时会话标识,只保存在 Host 会话表中。 */
40
+ readonly providerSessionId?: string;
41
+ readonly rawStoreRef?: string;
42
+ }
43
+ /** Client 展示会话 Agent 时使用的最小脱敏绑定。 */
44
+ export interface CodingNsSessionAdapterBinding {
45
+ readonly sessionId: string;
46
+ readonly adapterId: CodingNsCliAdapterId;
47
+ }
48
+ /** 外部 Agent 会话在 Host 侧的持久化索引。
49
+ *
50
+ * 这里只保存恢复会话所需的标识和摘要,不保存令牌、原始消息或进程句柄。
51
+ * dshSessionId 仍然是 DSH 的会话主键,providerSessionId 只由 Host 使用。
52
+ */
53
+ export type CodingNsCliSessionStatus = 'active' | 'idle' | 'error' | 'archived';
54
+ /** 外部 Provider 原始会话的可用状态;与 DSH 会话自身的运行状态相互独立。 */
55
+ export type CodingNsCliProviderSessionState = 'unchecked' | 'available' | 'missing' | 'corrupt' | 'unreachable' | 'unknown' | 'ephemeral';
56
+ export interface CodingNsCliSessionRecord extends CodingNsCliSessionConfig {
57
+ readonly dshSessionId: string;
58
+ readonly title?: string;
59
+ readonly cwd?: string;
60
+ readonly status: CodingNsCliSessionStatus;
61
+ /** 未填写表示旧记录尚未检查,语义等同于 unchecked。 */
62
+ readonly providerState?: CodingNsCliProviderSessionState;
63
+ readonly providerCheckedAt?: string;
64
+ readonly providerStateReason?: string;
65
+ readonly createdAt: string;
66
+ readonly updatedAt: string;
67
+ readonly lastError?: string;
68
+ }
69
+ /** 传给 CLI 驱动的一轮完整上下文。 */
70
+ export interface CodingNsCliTurnInput {
71
+ readonly sessionId: string;
72
+ readonly messages: readonly CodingNsCliMessage[];
73
+ readonly prompt: string;
74
+ readonly modelId?: string;
75
+ readonly effortId?: string;
76
+ readonly cwd?: string;
77
+ readonly signal?: AbortSignal;
78
+ readonly providerSessionId?: string;
79
+ readonly rawStoreRef?: string;
80
+ }
81
+ export interface CodingNsAgentPermissionResponse {
82
+ readonly requestId: string;
83
+ readonly approved: boolean;
84
+ readonly reason?: string;
85
+ }
86
+ /** 外部 Agent 请求用户回答的一道结构化问题。 */
87
+ export interface CodingNsAgentQuestion {
88
+ readonly id: string;
89
+ readonly question: string;
90
+ readonly detail?: string;
91
+ readonly header?: string;
92
+ readonly options?: readonly {
93
+ readonly label: string;
94
+ readonly description?: string;
95
+ }[];
96
+ readonly multiSelect?: boolean;
97
+ }
98
+ /** 用户对一组外部 Agent 问题的结构化回答。 */
99
+ export interface CodingNsAgentQuestionResponse {
100
+ readonly requestId: string;
101
+ readonly answers: readonly {
102
+ readonly id: string;
103
+ readonly selected: readonly string[];
104
+ readonly custom?: string;
105
+ }[];
106
+ }
107
+ export interface CodingNsCliMessage {
108
+ readonly id?: string;
109
+ readonly role: 'user' | 'assistant' | 'system';
110
+ readonly content: unknown;
111
+ /** DSH 原生消息来源;插件上下文不能被当成人类输入再次发送给外部 Agent。 */
112
+ readonly source?: {
113
+ readonly kind?: string;
114
+ readonly plugin?: string;
115
+ readonly form?: string;
116
+ };
117
+ }
118
+ /**
119
+ * 外部 CLI 已经执行过的工具观察事件。
120
+ *
121
+ * `status` 表示真实生命周期。该事件只能写入只读历史,不能转换成
122
+ * DSH 的待执行 `tool-call`。
123
+ */
124
+ export interface CodingNsAgentToolEvent {
125
+ readonly type: 'tool-event';
126
+ readonly toolName: string;
127
+ readonly status?: 'started' | 'running' | 'completed' | 'failed';
128
+ readonly callId?: string;
129
+ readonly input?: string;
130
+ readonly output?: string;
131
+ /**
132
+ * output 的线协议语义。delta 表示追加片段,snapshot 表示截至当前的完整快照。
133
+ * 只要提供 output 就必须显式填写。
134
+ */
135
+ readonly outputMode?: 'delta' | 'snapshot';
136
+ readonly error?: string;
137
+ readonly agentId?: string;
138
+ readonly detail?: string;
139
+ }
140
+ /**
141
+ * 所有外部 Agent 必须输出的公共事件契约。
142
+ *
143
+ * Provider 驱动只能理解自己的线协议并生成这些事件;快照去重、交互请求、工具
144
+ * 历史和 DSH 原生消息映射全部由公共消息投影层负责。
145
+ */
146
+ export type CodingNsAgentEvent = {
147
+ readonly type: 'reasoning-delta';
148
+ readonly text: string;
149
+ } | {
150
+ readonly type: 'reasoning-snapshot';
151
+ readonly text: string;
152
+ } | {
153
+ readonly type: 'text-delta';
154
+ readonly text: string;
155
+ } | {
156
+ readonly type: 'text-snapshot';
157
+ readonly text: string;
158
+ } | CodingNsAgentToolEvent | {
159
+ readonly type: 'usage';
160
+ /** Command Code 的 inputTokens 是包含缓存读写的完整输入。 */
161
+ readonly inputTokens: number;
162
+ readonly outputTokens: number;
163
+ readonly cacheReadTokens?: number;
164
+ readonly cacheWriteTokens?: number;
165
+ readonly uncachedInputTokens?: number;
166
+ readonly totalTokens?: number;
167
+ /** 缓存读取 / 完整输入,百分比取值 0 到 100。 */
168
+ readonly cacheHitRate?: number;
169
+ /** Provider 明确报告的上下文窗口及当前占用,用于会话上下文用量展示。 */
170
+ readonly contextWindow?: number;
171
+ readonly contextTokens?: number;
172
+ readonly contextUsageRatio?: number;
173
+ } | {
174
+ readonly type: 'finish';
175
+ readonly reason: 'stop' | 'cancel' | 'error';
176
+ } | {
177
+ readonly type: 'session-binding';
178
+ readonly providerSessionId: string;
179
+ readonly rawStoreRef?: string;
180
+ } | {
181
+ readonly type: 'permission-request';
182
+ readonly requestId: string;
183
+ readonly kind: string;
184
+ readonly toolName?: string;
185
+ readonly callId?: string;
186
+ readonly detail?: string;
187
+ } | {
188
+ readonly type: 'question-request';
189
+ readonly requestId: string;
190
+ readonly questions: readonly CodingNsAgentQuestion[];
191
+ };
192
+ //# sourceMappingURL=cli-adapter.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli-adapter.js.map
@@ -0,0 +1,5 @@
1
+ import type { CliSubscriptionUsage, CliSubscriptionWindow } from './subscription.js';
2
+ /** 兼容旧导出的 Command Code 专用名称,实际结构与所有 Provider 共用。 */
3
+ export type CommandCodeSubscriptionWindow = CliSubscriptionWindow;
4
+ export type CommandCodeSubscriptionUsage = CliSubscriptionUsage;
5
+ //# sourceMappingURL=command-code.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=command-code.js.map