@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,179 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { TerminalAttachmentRegistry } from './attachment-registry.js';
3
+ /** 统一选择 backend,并确保停用插件时只清理 attach,不结束持久进程。 */
4
+ export class TerminalRuntimeManager {
5
+ adapters = new Map();
6
+ registry = new TerminalAttachmentRegistry();
7
+ monitors = new Map();
8
+ constructor(adapters) {
9
+ for (const adapter of adapters) {
10
+ for (const runtimeType of adapter.runtimeTypes) {
11
+ if (this.adapters.has(runtimeType))
12
+ throw new Error(`终端 backend 重复注册: ${runtimeType}`);
13
+ this.adapters.set(runtimeType, adapter);
14
+ }
15
+ }
16
+ }
17
+ create(record) {
18
+ return this.adapter(record.runtimeType).create({ session: runtimeSession(record), cols: record.cols, rows: record.rows });
19
+ }
20
+ inspect(record) {
21
+ return this.adapter(record.runtimeType).inspect(runtimeSession(record));
22
+ }
23
+ async attach(record, input) {
24
+ const backend = this.adapter(record.runtimeType);
25
+ const subscriptionId = randomUUID();
26
+ let runtimeAttachmentId;
27
+ const earlyData = [];
28
+ let earlyExit;
29
+ const attachment = await backend.attach({
30
+ session: runtimeSession(record),
31
+ cols: input.cols,
32
+ rows: input.rows,
33
+ onData: (data) => {
34
+ if (runtimeAttachmentId === undefined) {
35
+ earlyData.push(data);
36
+ return;
37
+ }
38
+ if (this.registry.isCurrent(subscriptionId, input.generation, runtimeAttachmentId))
39
+ input.onData(data);
40
+ },
41
+ onExit: (exitCode) => {
42
+ if (runtimeAttachmentId === undefined) {
43
+ earlyExit = exitCode;
44
+ return;
45
+ }
46
+ if (this.registry.isCurrent(subscriptionId, input.generation, runtimeAttachmentId))
47
+ input.onExit(exitCode);
48
+ },
49
+ });
50
+ runtimeAttachmentId = attachment.attachmentId;
51
+ const managed = {
52
+ identity: { ...input.identity },
53
+ runtimeType: record.runtimeType,
54
+ terminalId: record.terminalId,
55
+ generation: input.generation,
56
+ streamId: input.streamId,
57
+ subscriptionId,
58
+ runtimeAttachmentId,
59
+ };
60
+ this.registry.add(managed);
61
+ for (const data of earlyData) {
62
+ if (this.registry.isCurrent(subscriptionId, input.generation, runtimeAttachmentId))
63
+ input.onData(data);
64
+ }
65
+ if (earlyExit !== undefined && this.registry.isCurrent(subscriptionId, input.generation, runtimeAttachmentId)) {
66
+ input.onExit(earlyExit);
67
+ }
68
+ return managed;
69
+ }
70
+ async write(subscriptionId, data) {
71
+ const attachment = this.requireAttachment(subscriptionId);
72
+ await this.adapter(attachment.runtimeType).write({ attachmentId: attachment.runtimeAttachmentId, data });
73
+ }
74
+ /**
75
+ * 在不抢占浏览器 attach 控制权的前提下,向持久终端写入一次启动命令。
76
+ * 这是调试快捷启动所需的“先开 Shell、再发送命令”路径。
77
+ */
78
+ async writeSession(record, data) {
79
+ const monitor = this.monitors.get(monitorKey(record));
80
+ const backend = this.adapter(record.runtimeType);
81
+ if (monitor !== undefined) {
82
+ // monitor attach 与持久 Shell 同寿命,不能像临时 attach 一样写完立即销毁。
83
+ await backend.write({ attachmentId: monitor.attachmentId, data });
84
+ return;
85
+ }
86
+ const attachment = await backend.attach({
87
+ session: runtimeSession(record),
88
+ cols: record.cols,
89
+ rows: record.rows,
90
+ onData: () => undefined,
91
+ });
92
+ try {
93
+ await backend.write({ attachmentId: attachment.attachmentId, data });
94
+ }
95
+ finally {
96
+ await backend.detach(attachment.attachmentId);
97
+ }
98
+ }
99
+ async resize(subscriptionId, cols, rows) {
100
+ const attachment = this.requireAttachment(subscriptionId);
101
+ await this.adapter(attachment.runtimeType).resize({ attachmentId: attachment.runtimeAttachmentId, cols, rows });
102
+ }
103
+ async detach(subscriptionId) {
104
+ const attachment = this.registry.remove(subscriptionId);
105
+ if (attachment === undefined)
106
+ return;
107
+ await this.adapter(attachment.runtimeType).detach(attachment.runtimeAttachmentId);
108
+ }
109
+ async detachGeneration(generation) {
110
+ await Promise.all(this.registry.listByGeneration(generation).map((attachment) => this.detach(attachment.subscriptionId)));
111
+ }
112
+ async detachTerminal(identity) {
113
+ await Promise.all(this.registry.listByTerminal(identity).map((attachment) => this.detach(attachment.subscriptionId)));
114
+ }
115
+ /** 为 Host 进程状态提供退出监听,不获取终端输入控制权。 */
116
+ async monitor(record, onExit) {
117
+ const key = monitorKey(record);
118
+ if (this.monitors.has(key))
119
+ return;
120
+ const backend = this.adapter(record.runtimeType);
121
+ const attachment = await backend.attach({
122
+ session: runtimeSession(record),
123
+ cols: record.cols,
124
+ rows: record.rows,
125
+ onData: () => undefined,
126
+ onExit: (exitCode) => {
127
+ this.monitors.delete(key);
128
+ onExit(exitCode);
129
+ },
130
+ });
131
+ this.monitors.set(key, { runtimeType: record.runtimeType, attachmentId: attachment.attachmentId });
132
+ }
133
+ async detachMonitor(record) {
134
+ const key = monitorKey(record);
135
+ const monitor = this.monitors.get(key);
136
+ if (monitor === undefined)
137
+ return;
138
+ this.monitors.delete(key);
139
+ await this.adapter(monitor.runtimeType).detach(monitor.attachmentId);
140
+ }
141
+ async dispose() {
142
+ await Promise.all(this.registry.list().map((attachment) => this.detach(attachment.subscriptionId)));
143
+ await Promise.all([...this.monitors].map(async ([, monitor]) => this.adapter(monitor.runtimeType).detach(monitor.attachmentId)));
144
+ this.monitors.clear();
145
+ await Promise.all([...new Set(this.adapters.values())].map((adapter) => adapter.dispose?.()));
146
+ }
147
+ async terminate(record) {
148
+ await this.detachMonitor(record);
149
+ await this.adapter(record.runtimeType).terminate(runtimeSession(record));
150
+ }
151
+ adapter(runtimeType) {
152
+ const adapter = this.adapters.get(runtimeType);
153
+ if (adapter === undefined)
154
+ throw new Error(`当前 Host 没有终端 backend: ${runtimeType}`);
155
+ return adapter;
156
+ }
157
+ requireAttachment(subscriptionId) {
158
+ const attachment = this.registry.get(subscriptionId);
159
+ if (attachment === undefined)
160
+ throw new Error('终端 attach 不存在或已经释放');
161
+ return attachment;
162
+ }
163
+ }
164
+ function monitorKey(record) {
165
+ return JSON.stringify([record.hostId, record.workspaceId, record.terminalId]);
166
+ }
167
+ function runtimeSession(record) {
168
+ return {
169
+ runtimeSessionKey: record.runtimeSessionKey,
170
+ runtimeType: record.runtimeType,
171
+ shellPath: record.shellPath,
172
+ shellArgs: record.shellArgs ?? [],
173
+ ...(record.commandPath === undefined ? {} : { commandPath: record.commandPath }),
174
+ ...(record.commandArgs === undefined ? {} : { commandArgs: record.commandArgs }),
175
+ ...(record.commandEnv === undefined ? {} : { commandEnv: record.commandEnv }),
176
+ cwd: record.cwd,
177
+ };
178
+ }
179
+ //# sourceMappingURL=runtime-manager.js.map
@@ -0,0 +1,23 @@
1
+ export type TerminalShellProfileId = 'system' | 'zsh' | 'bash' | 'powershell' | 'cmd' | 'git-bash';
2
+ export interface DetectedTerminalShell {
3
+ readonly profileId: Exclude<TerminalShellProfileId, 'system'>;
4
+ readonly displayName: string;
5
+ readonly path: string | null;
6
+ readonly available: boolean;
7
+ readonly unavailableReason?: string;
8
+ }
9
+ export interface ShellDetectionOptions {
10
+ readonly platform?: string;
11
+ readonly env?: Readonly<Record<string, string | undefined>>;
12
+ readonly isExecutable?: (path: string) => boolean;
13
+ }
14
+ export interface ResolvedTerminalShell {
15
+ readonly requestedProfileId: TerminalShellProfileId;
16
+ readonly resolvedProfileId: Exclude<TerminalShellProfileId, 'system'>;
17
+ readonly path: string;
18
+ readonly fallbackReason?: string;
19
+ }
20
+ /** 平台探测只返回白名单 profile,浏览器不能借此提交任意可执行文件。 */
21
+ export declare function detectTerminalShells(options?: ShellDetectionOptions): readonly DetectedTerminalShell[];
22
+ export declare function resolveTerminalShell(requestedProfileId: TerminalShellProfileId, detected: readonly DetectedTerminalShell[], platform?: string): ResolvedTerminalShell;
23
+ //# sourceMappingURL=shell-detection.d.ts.map
@@ -0,0 +1,105 @@
1
+ import { accessSync, constants } from 'node:fs';
2
+ /** 平台探测只返回白名单 profile,浏览器不能借此提交任意可执行文件。 */
3
+ export function detectTerminalShells(options = {}) {
4
+ const platform = options.platform ?? process.platform;
5
+ const env = options.env ?? process.env;
6
+ const executable = options.isExecutable ?? defaultIsExecutable;
7
+ if (platform === 'win32')
8
+ return detectWindowsShells(env, executable);
9
+ if (platform === 'darwin' || platform === 'linux')
10
+ return detectPosixShells(platform, env, executable);
11
+ return [];
12
+ }
13
+ export function resolveTerminalShell(requestedProfileId, detected, platform = process.platform) {
14
+ const requested = requestedProfileId === 'system'
15
+ ? undefined
16
+ : detected.find((shell) => shell.profileId === requestedProfileId);
17
+ if (requested?.available && requested.path !== null) {
18
+ return { requestedProfileId, resolvedProfileId: requested.profileId, path: requested.path };
19
+ }
20
+ const order = platform === 'win32'
21
+ ? ['powershell', 'cmd']
22
+ : ['zsh', 'bash'];
23
+ const fallback = order
24
+ .map((profileId) => detected.find((shell) => shell.profileId === profileId))
25
+ .find((shell) => shell?.available === true && shell.path !== null);
26
+ if (fallback === undefined)
27
+ throw new Error('当前平台没有可用的受支持终端 shell');
28
+ return {
29
+ requestedProfileId,
30
+ resolvedProfileId: fallback.profileId,
31
+ path: fallback.path,
32
+ ...(requestedProfileId === 'system'
33
+ ? {}
34
+ : { fallbackReason: `${requestedProfileId} 当前不可用,已回退到${fallback.displayName}` }),
35
+ };
36
+ }
37
+ function detectPosixShells(platform, env, executable) {
38
+ const envShell = env.SHELL;
39
+ const zsh = firstExecutable([
40
+ ...(envShell?.endsWith('/zsh') ? [envShell] : []),
41
+ '/bin/zsh',
42
+ '/usr/bin/zsh',
43
+ ...(platform === 'darwin' ? ['/opt/homebrew/bin/zsh', '/usr/local/bin/zsh'] : []),
44
+ ], executable, platform);
45
+ const bash = firstExecutable([
46
+ ...(envShell?.endsWith('/bash') ? [envShell] : []),
47
+ '/bin/bash',
48
+ '/usr/bin/bash',
49
+ '/usr/local/bin/bash',
50
+ ], executable, platform);
51
+ return [shellResult('zsh', 'zsh', zsh), shellResult('bash', 'bash', bash)];
52
+ }
53
+ function detectWindowsShells(env, executable) {
54
+ const systemRoot = env.SystemRoot ?? env.WINDIR ?? 'C:\\Windows';
55
+ const programFiles = env.ProgramFiles ?? 'C:\\Program Files';
56
+ const programFilesX86 = env['ProgramFiles(x86)'];
57
+ const localAppData = env.LOCALAPPDATA;
58
+ const pathEntries = (env.Path ?? env.PATH ?? '').split(';').map((value) => value.trim()).filter(Boolean);
59
+ const powershell = firstExecutable(uniqueWindowsPaths([
60
+ `${systemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,
61
+ `${programFiles}\\PowerShell\\7\\pwsh.exe`,
62
+ ...(programFilesX86 ? [`${programFilesX86}\\PowerShell\\7\\pwsh.exe`] : []),
63
+ ...(localAppData ? [`${localAppData}\\Programs\\PowerShell\\7\\pwsh.exe`] : []),
64
+ ...pathCandidates(pathEntries, ['pwsh.exe', 'powershell.exe']),
65
+ ]), executable, 'win32');
66
+ const cmd = firstExecutable([env.ComSpec ?? '', `${systemRoot}\\System32\\cmd.exe`], executable, 'win32');
67
+ const gitBash = firstExecutable(uniqueWindowsPaths([
68
+ `${programFiles}\\Git\\bin\\bash.exe`,
69
+ ...(programFilesX86 ? [`${programFilesX86}\\Git\\bin\\bash.exe`] : []),
70
+ ...(localAppData ? [`${localAppData}\\Programs\\Git\\bin\\bash.exe`] : []),
71
+ ...pathCandidates(pathEntries, ['bash.exe']),
72
+ ]), executable, 'win32');
73
+ return [
74
+ shellResult('powershell', 'PowerShell', powershell),
75
+ shellResult('cmd', '命令提示符', cmd),
76
+ shellResult('git-bash', 'Git Bash', gitBash),
77
+ ];
78
+ }
79
+ function pathCandidates(entries, names) {
80
+ return entries.flatMap((entry) => names.map((name) => `${entry.replace(/[\\/]+$/u, '')}\\${name}`));
81
+ }
82
+ function uniqueWindowsPaths(paths) {
83
+ return [...new Set(paths)];
84
+ }
85
+ function firstExecutable(paths, executable, platform) {
86
+ return paths.find((path) => path !== '' && isAbsoluteForPlatform(path, platform) && executable(path)) ?? null;
87
+ }
88
+ function isAbsoluteForPlatform(path, platform) {
89
+ return platform === 'win32' ? /^[a-zA-Z]:[\\/]/.test(path) || path.startsWith('\\\\') : path.startsWith('/');
90
+ }
91
+ function shellResult(profileId, displayName, path) {
92
+ return path === null
93
+ ? { profileId, displayName, path: null, available: false, unavailableReason: '未找到可执行文件' }
94
+ : { profileId, displayName, path, available: true };
95
+ }
96
+ function defaultIsExecutable(path) {
97
+ try {
98
+ accessSync(path, constants.X_OK);
99
+ return true;
100
+ }
101
+ catch {
102
+ return false;
103
+ }
104
+ }
105
+ //# sourceMappingURL=shell-detection.js.map
@@ -0,0 +1,33 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { SettingsProvider, SettingsScope } from '@deepseek-ai/dsh-settings';
3
+ import type { CodingNsSettings } from '../../shared/contracts/config.js';
4
+ import { createTerminalController, type TerminalControllerFactoryResult } from './controller-factory.js';
5
+ export interface TerminalStartupIdentity {
6
+ readonly hostId: string;
7
+ readonly storeFilename: string;
8
+ readonly hostIdFilename: string;
9
+ }
10
+ export interface InstallTerminalControllerOptions {
11
+ readonly platform?: string;
12
+ readonly createController?: typeof createTerminalController;
13
+ readonly resolveIdentity?: (settingsDocumentPath: string) => Promise<TerminalStartupIdentity>;
14
+ /** 由 Host 解析稳定 Workspace ID 到受信任根目录;不能接收浏览器传来的绝对路径。 */
15
+ readonly resolveWorkspaceRoot?: (workspaceId: string) => string | null;
16
+ }
17
+ /**
18
+ * 从 DSH 设置文档旁边的持久目录读取本机终端身份。
19
+ *
20
+ * hostId 首次生成后独占写入,不依赖 PID、端口或 Bundle 安装路径;同一 Profile
21
+ * 重启后会继续使用同一身份和同一终端映射文件。
22
+ */
23
+ export declare function resolveTerminalStartupIdentity(settingsDocumentPath: string, createId?: () => string): Promise<TerminalStartupIdentity>;
24
+ /** 每个浏览器 attachment 都是一个短命 generation,不能写入持久记录。 */
25
+ export declare function terminalAttachmentGeneration(hostId: string, attachmentId: string): string;
26
+ /** 工作区身份使用规范化绝对路径,避免同一路径的相对写法生成两份映射。 */
27
+ export declare function terminalWorkspaceId(cwd: string): string;
28
+ /**
29
+ * 在 Host 启动时读取一次启用快照并安装唯一 controller。
30
+ * 设置后续变化不会热切同名 Cordis service,必须重启 DSH 才会重新选择模式。
31
+ */
32
+ export declare function installTerminalController(ctx: Context, settings: SettingsScope<CodingNsSettings>, provider: Pick<SettingsProvider, 'documentPath'>, options?: InstallTerminalControllerOptions): Promise<TerminalControllerFactoryResult>;
33
+ //# sourceMappingURL=startup.d.ts.map
@@ -0,0 +1,100 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { dirname, isAbsolute, join } from 'node:path';
4
+ import { createTerminalController, } from './controller-factory.js';
5
+ import { terminalStorePath } from './terminal-store.js';
6
+ const HOST_ID_FILENAME = 'host-id';
7
+ const HOST_ID_PATTERN = /^local-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
8
+ /**
9
+ * 从 DSH 设置文档旁边的持久目录读取本机终端身份。
10
+ *
11
+ * hostId 首次生成后独占写入,不依赖 PID、端口或 Bundle 安装路径;同一 Profile
12
+ * 重启后会继续使用同一身份和同一终端映射文件。
13
+ */
14
+ export async function resolveTerminalStartupIdentity(settingsDocumentPath, createId = () => `local-${randomUUID()}`) {
15
+ if (settingsDocumentPath.trim() === '')
16
+ throw new Error('DSH 设置文档路径为空,无法定位终端持久目录');
17
+ const absoluteSettingsPath = absolutePath(settingsDocumentPath);
18
+ const hostIdFilename = join(dirname(absoluteSettingsPath), 'codingns4dsh', HOST_ID_FILENAME);
19
+ await mkdir(dirname(hostIdFilename), { recursive: true, mode: 0o700 });
20
+ let hostId;
21
+ try {
22
+ hostId = parseHostId(await readFile(hostIdFilename, 'utf8'), hostIdFilename);
23
+ }
24
+ catch (error) {
25
+ if (!isMissingFile(error))
26
+ throw error;
27
+ const candidate = parseHostId(createId(), '新生成的 Host ID');
28
+ try {
29
+ await writeFile(hostIdFilename, `${candidate}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
30
+ hostId = candidate;
31
+ }
32
+ catch (writeError) {
33
+ if (!isExistingFile(writeError))
34
+ throw writeError;
35
+ hostId = parseHostId(await readFile(hostIdFilename, 'utf8'), hostIdFilename);
36
+ }
37
+ }
38
+ return {
39
+ hostId,
40
+ storeFilename: terminalStorePath(absoluteSettingsPath),
41
+ hostIdFilename,
42
+ };
43
+ }
44
+ /** 每个浏览器 attachment 都是一个短命 generation,不能写入持久记录。 */
45
+ export function terminalAttachmentGeneration(hostId, attachmentId) {
46
+ return `${hostId}:terminal-attach:${attachmentId}`;
47
+ }
48
+ /** 工作区身份使用规范化绝对路径,避免同一路径的相对写法生成两份映射。 */
49
+ export function terminalWorkspaceId(cwd) {
50
+ return absolutePath(cwd);
51
+ }
52
+ /**
53
+ * 在 Host 启动时读取一次启用快照并安装唯一 controller。
54
+ * 设置后续变化不会热切同名 Cordis service,必须重启 DSH 才会重新选择模式。
55
+ */
56
+ export async function installTerminalController(ctx, settings, provider, options = {}) {
57
+ const createController = options.createController ?? createTerminalController;
58
+ const current = settings.get();
59
+ const enhancedEnabled = current.modules.terminalEnhancement ?? false;
60
+ const common = {
61
+ settings: () => settings.get().terminalEnhancement,
62
+ ...(options.platform === undefined ? {} : { platform: options.platform }),
63
+ ...(options.resolveWorkspaceRoot === undefined ? {} : { resolveWorkspaceRoot: options.resolveWorkspaceRoot }),
64
+ };
65
+ if (!enhancedEnabled) {
66
+ return createController(ctx, { enhancedEnabled: false, ...common });
67
+ }
68
+ const documentPath = provider.documentPath;
69
+ if (documentPath === undefined) {
70
+ throw new Error('终端强化需要文件型 DSH 设置 Provider,以便持久保存 Host ID 和终端映射');
71
+ }
72
+ const identity = await (options.resolveIdentity ?? resolveTerminalStartupIdentity)(documentPath);
73
+ return createController(ctx, {
74
+ enhancedEnabled: true,
75
+ hostId: identity.hostId,
76
+ storeFilename: identity.storeFilename,
77
+ generation: (_agent, attachmentId) => terminalAttachmentGeneration(identity.hostId, attachmentId),
78
+ workspaceId: (_agent, cwd) => terminalWorkspaceId(cwd),
79
+ ...common,
80
+ });
81
+ }
82
+ function parseHostId(value, source) {
83
+ const normalized = value.trim().toLowerCase();
84
+ if (!HOST_ID_PATTERN.test(normalized))
85
+ throw new Error(`${source} 包含无效的终端 Host ID`);
86
+ return normalized;
87
+ }
88
+ function isMissingFile(error) {
89
+ return isNodeError(error) && error.code === 'ENOENT';
90
+ }
91
+ function isExistingFile(error) {
92
+ return isNodeError(error) && error.code === 'EEXIST';
93
+ }
94
+ function isNodeError(error) {
95
+ return error instanceof Error;
96
+ }
97
+ function absolutePath(path) {
98
+ return isAbsolute(path) ? path : join(process.cwd(), path);
99
+ }
100
+ //# sourceMappingURL=startup.js.map
@@ -0,0 +1,78 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
3
+ import type { TerminalEnhancementSettings } from '../../shared/contracts/config.js';
4
+ import type { CodingNsTerminalCreateRequest, CodingNsTerminalEnvironment, CodingNsTerminalFrame, CodingNsTerminalRetentionFrame, CodingNsTerminalRuntimeType, CodingNsTerminalShellOption, CodingNsWebTerminalInfo } from '../../shared/contracts/terminal.js';
5
+ import { type DetectedTerminalShell, type TerminalShellProfileId } from './shell-detection.js';
6
+ import { CodingNsTerminalService } from './terminal-service.js';
7
+ declare module '@deepseek-ai/dsh-typert-protocol' {
8
+ interface RemoteErrorDetailsMap {
9
+ 'terminal/unavailable': Record<string, never>;
10
+ 'terminal/control-unavailable': {
11
+ readonly reason: 'read-only' | 'not-running';
12
+ };
13
+ 'terminal/limit-reached': {
14
+ readonly limit: number;
15
+ };
16
+ }
17
+ }
18
+ export interface DshTerminalAgent {
19
+ readonly id: string;
20
+ readonly session: {
21
+ readonly header?: {
22
+ readonly cwd?: string;
23
+ };
24
+ };
25
+ }
26
+ export interface CodingNsTerminalControllerOptions {
27
+ readonly hostId: string;
28
+ readonly service: CodingNsTerminalService;
29
+ readonly settings: () => TerminalEnhancementSettings;
30
+ readonly platform?: string;
31
+ readonly generation?: (agent: DshTerminalAgent, attachmentId: string) => string;
32
+ readonly workspaceId?: (agent: DshTerminalAgent, cwd: string) => string;
33
+ /** 基线模式固定使用进程内 PTY;强化模式再按平台选择持久 backend。 */
34
+ readonly runtimeType?: (profileId: Exclude<TerminalShellProfileId, 'system'>, platform: string) => CodingNsTerminalRuntimeType;
35
+ readonly detectShells?: () => readonly DetectedTerminalShell[];
36
+ readonly maxTerminals?: number;
37
+ readonly maxInputBytes?: number;
38
+ readonly maxCols?: number;
39
+ readonly maxRows?: number;
40
+ }
41
+ /** 与 DSH 0.1.6-alpha.2 `remote.terminal` 完全同名、同方法的 Host controller。 */
42
+ export declare class CodingNsTerminalController extends TypertRemoteService {
43
+ private readonly options;
44
+ static inject: string[];
45
+ private readonly platform;
46
+ private readonly detectShells;
47
+ private readonly maxTerminals;
48
+ private readonly maxInputBytes;
49
+ private readonly maxCols;
50
+ private readonly maxRows;
51
+ /** 绑定范围与 controller 一样在 DSH 启动时锁定,避免运行中切换造成终端集合瞬间变化。 */
52
+ private readonly bindingScope;
53
+ /** list/retain 的官方 wire 只有 sessionId;这里把它解析到工作区后再查持久终端。 */
54
+ private readonly sessionWorkspaces;
55
+ constructor(ctx: Context, options: CodingNsTerminalControllerOptions);
56
+ environment(agent: DshTerminalAgent, signal: AbortSignal): CodingNsTerminalEnvironment;
57
+ shells(agent: DshTerminalAgent, signal: AbortSignal): CodingNsTerminalShellOption[];
58
+ list(sessionId: string): CodingNsWebTerminalInfo[];
59
+ create(agent: DshTerminalAgent, request: CodingNsTerminalCreateRequest, signal: AbortSignal): Promise<CodingNsWebTerminalInfo>;
60
+ retain(sessionId: string, id: string, signal: AbortSignal): AsyncIterable<CodingNsTerminalRetentionFrame>;
61
+ follow(agent: DshTerminalAgent, id: string, attachmentId: string, signal: AbortSignal): AsyncIterable<CodingNsTerminalFrame>;
62
+ write(agent: DshTerminalAgent, id: string, attachmentId: string, data: string): Promise<void>;
63
+ resize(agent: DshTerminalAgent, id: string, attachmentId: string, cols: number, rows: number): Promise<void>;
64
+ rename(agent: DshTerminalAgent, id: string, title: string): Promise<void>;
65
+ close(agent: DshTerminalAgent, id: string): Promise<void>;
66
+ private selectShell;
67
+ private cwd;
68
+ private scope;
69
+ private rememberWorkspace;
70
+ /**
71
+ * Workspace Registry 是跨会话的稳定身份。只有找不到正式工作区时才回退到
72
+ * 插件提供的 cwd 规则,避免把同一工作区的不同 Session 拆成多个终端集合。
73
+ */
74
+ private workspaceId;
75
+ private identity;
76
+ private optionalIdentity;
77
+ }
78
+ //# sourceMappingURL=terminal-controller.d.ts.map