@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,324 @@
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5
+ }
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
31
+ }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
35
+ import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
36
+ import { detectTerminalShells, resolveTerminalShell, } from './shell-detection.js';
37
+ import { CodingNsTerminalService, TerminalServiceError } from './terminal-service.js';
38
+ /** 与 DSH 0.1.6-alpha.2 `remote.terminal` 完全同名、同方法的 Host controller。 */
39
+ let CodingNsTerminalController = (() => {
40
+ let _classSuper = TypertRemoteService;
41
+ let _instanceExtraInitializers = [];
42
+ let _environment_decorators;
43
+ let _shells_decorators;
44
+ let _list_decorators;
45
+ let _create_decorators;
46
+ let _retain_decorators;
47
+ let _follow_decorators;
48
+ let _write_decorators;
49
+ let _resize_decorators;
50
+ let _rename_decorators;
51
+ let _close_decorators;
52
+ return class CodingNsTerminalController extends _classSuper {
53
+ static {
54
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
55
+ _environment_decorators = [Remote];
56
+ _shells_decorators = [Remote];
57
+ _list_decorators = [Remote];
58
+ _create_decorators = [Remote];
59
+ _retain_decorators = [Remote({ mode: 'stream' })];
60
+ _follow_decorators = [Remote({ mode: 'stream' })];
61
+ _write_decorators = [Remote];
62
+ _resize_decorators = [Remote];
63
+ _rename_decorators = [Remote];
64
+ _close_decorators = [Remote];
65
+ __esDecorate(this, null, _environment_decorators, { kind: "method", name: "environment", static: false, private: false, access: { has: obj => "environment" in obj, get: obj => obj.environment }, metadata: _metadata }, null, _instanceExtraInitializers);
66
+ __esDecorate(this, null, _shells_decorators, { kind: "method", name: "shells", static: false, private: false, access: { has: obj => "shells" in obj, get: obj => obj.shells }, metadata: _metadata }, null, _instanceExtraInitializers);
67
+ __esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
68
+ __esDecorate(this, null, _create_decorators, { kind: "method", name: "create", static: false, private: false, access: { has: obj => "create" in obj, get: obj => obj.create }, metadata: _metadata }, null, _instanceExtraInitializers);
69
+ __esDecorate(this, null, _retain_decorators, { kind: "method", name: "retain", static: false, private: false, access: { has: obj => "retain" in obj, get: obj => obj.retain }, metadata: _metadata }, null, _instanceExtraInitializers);
70
+ __esDecorate(this, null, _follow_decorators, { kind: "method", name: "follow", static: false, private: false, access: { has: obj => "follow" in obj, get: obj => obj.follow }, metadata: _metadata }, null, _instanceExtraInitializers);
71
+ __esDecorate(this, null, _write_decorators, { kind: "method", name: "write", static: false, private: false, access: { has: obj => "write" in obj, get: obj => obj.write }, metadata: _metadata }, null, _instanceExtraInitializers);
72
+ __esDecorate(this, null, _resize_decorators, { kind: "method", name: "resize", static: false, private: false, access: { has: obj => "resize" in obj, get: obj => obj.resize }, metadata: _metadata }, null, _instanceExtraInitializers);
73
+ __esDecorate(this, null, _rename_decorators, { kind: "method", name: "rename", static: false, private: false, access: { has: obj => "rename" in obj, get: obj => obj.rename }, metadata: _metadata }, null, _instanceExtraInitializers);
74
+ __esDecorate(this, null, _close_decorators, { kind: "method", name: "close", static: false, private: false, access: { has: obj => "close" in obj, get: obj => obj.close }, metadata: _metadata }, null, _instanceExtraInitializers);
75
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
76
+ }
77
+ options = __runInitializers(this, _instanceExtraInitializers);
78
+ static inject = ['typert'];
79
+ platform;
80
+ detectShells;
81
+ maxTerminals;
82
+ maxInputBytes;
83
+ maxCols;
84
+ maxRows;
85
+ /** 绑定范围与 controller 一样在 DSH 启动时锁定,避免运行中切换造成终端集合瞬间变化。 */
86
+ bindingScope;
87
+ /** list/retain 的官方 wire 只有 sessionId;这里把它解析到工作区后再查持久终端。 */
88
+ sessionWorkspaces = new Map();
89
+ constructor(ctx, options) {
90
+ super(ctx, 'terminalController', { namespace: 'terminal' });
91
+ this.options = options;
92
+ this.platform = options.platform ?? process.platform;
93
+ this.detectShells = options.detectShells ?? (() => detectTerminalShells({ platform: this.platform }));
94
+ this.maxTerminals = options.maxTerminals ?? 8;
95
+ this.maxInputBytes = options.maxInputBytes ?? 64 * 1024;
96
+ this.maxCols = options.maxCols ?? 500;
97
+ this.maxRows = options.maxRows ?? 200;
98
+ this.bindingScope = options.settings().bindingScope ?? 'workspace';
99
+ }
100
+ environment(agent, signal) {
101
+ signal.throwIfAborted();
102
+ const workspaceId = this.rememberWorkspace(agent);
103
+ return {
104
+ cwd: this.cwd(agent),
105
+ workspaceId,
106
+ maxInputBytes: this.maxInputBytes,
107
+ maxCols: this.maxCols,
108
+ maxRows: this.maxRows,
109
+ scrollback: this.options.settings().appearance.scrollback ?? 1000,
110
+ };
111
+ }
112
+ shells(agent, signal) {
113
+ signal.throwIfAborted();
114
+ const detected = this.detectShells();
115
+ const preferred = resolveTerminalShell(this.options.settings().defaultProfile, detected, this.platform);
116
+ const available = detected.filter((shell) => shell.available && shell.path !== null);
117
+ const ordered = [
118
+ ...available.filter((shell) => shell.path === preferred.path),
119
+ ...available.filter((shell) => shell.path !== preferred.path),
120
+ ];
121
+ if (ordered.length === 0)
122
+ throw new Error('当前平台没有可用的受支持终端 shell');
123
+ return ordered.map(shellOption);
124
+ }
125
+ list(sessionId) {
126
+ const workspaceId = this.sessionWorkspaces.get(sessionId);
127
+ return [...this.options.service.listSession(this.options.hostId, sessionId, workspaceId)];
128
+ }
129
+ async create(agent, request, signal) {
130
+ signal.throwIfAborted();
131
+ const scope = this.scope(agent);
132
+ this.rememberWorkspace(agent);
133
+ const existing = this.options.service.list(scope).find((terminal) => terminal.id === request.id);
134
+ if (existing !== undefined)
135
+ return existing;
136
+ if (this.options.service.list(scope).length >= this.maxTerminals) {
137
+ throw new RemoteError('terminal/limit-reached', '当前 DSH 会话的终端数量已达到上限', { limit: this.maxTerminals });
138
+ }
139
+ const selected = this.selectShell(request.shellPath);
140
+ try {
141
+ return await this.options.service.create({
142
+ scope,
143
+ terminalId: request.id,
144
+ runtimeType: this.options.runtimeType?.(selected.profileId, this.platform)
145
+ ?? runtimeType(this.platform, selected.profileId),
146
+ shell: shellProfile(selected),
147
+ cwd: this.cwd(agent),
148
+ cols: request.cols,
149
+ rows: request.rows,
150
+ });
151
+ }
152
+ catch (error) {
153
+ throw remoteTerminalError(error);
154
+ }
155
+ }
156
+ retain(sessionId, id, signal) {
157
+ try {
158
+ const identity = this.options.service.findIdentity(this.options.hostId, sessionId, id, this.sessionWorkspaces.get(sessionId));
159
+ return translateTerminalStream(this.options.service.retain(identity, signal));
160
+ }
161
+ catch (error) {
162
+ throw remoteTerminalError(error);
163
+ }
164
+ }
165
+ follow(agent, id, attachmentId, signal) {
166
+ if (!/^[\w-]{1,128}$/u.test(attachmentId))
167
+ throw new TypeError('终端 attach 标识无效');
168
+ try {
169
+ return translateTerminalStream(this.options.service.follow({
170
+ identity: this.identity(agent, id),
171
+ attachmentId,
172
+ // attachmentId 由原生 Client 每次物理 attach 重新生成,正好作为短命
173
+ // generation;它不会进入持久记录,也不会让旧 attach 的回调控制新流。
174
+ generation: this.options.generation?.(agent, attachmentId) ?? `terminal-attach:${attachmentId}`,
175
+ signal,
176
+ }));
177
+ }
178
+ catch (error) {
179
+ throw remoteTerminalError(error);
180
+ }
181
+ }
182
+ async write(agent, id, attachmentId, data) {
183
+ if (new TextEncoder().encode(data).byteLength > this.maxInputBytes)
184
+ throw new TypeError('终端输入超过允许上限');
185
+ try {
186
+ await this.options.service.write(this.identity(agent, id), attachmentId, data);
187
+ }
188
+ catch (error) {
189
+ throw remoteTerminalError(error);
190
+ }
191
+ }
192
+ async resize(agent, id, attachmentId, cols, rows) {
193
+ try {
194
+ await this.options.service.resize(this.identity(agent, id), attachmentId, cols, rows);
195
+ }
196
+ catch (error) {
197
+ throw remoteTerminalError(error);
198
+ }
199
+ }
200
+ async rename(agent, id, title) {
201
+ try {
202
+ await this.options.service.rename(this.identity(agent, id), title);
203
+ }
204
+ catch (error) {
205
+ throw remoteTerminalError(error);
206
+ }
207
+ }
208
+ async close(agent, id) {
209
+ try {
210
+ const identity = this.optionalIdentity(agent, id);
211
+ if (identity !== undefined)
212
+ await this.options.service.close(identity);
213
+ }
214
+ catch (error) {
215
+ throw remoteTerminalError(error);
216
+ }
217
+ }
218
+ selectShell(shellPath) {
219
+ const detected = this.detectShells();
220
+ if (shellPath !== undefined) {
221
+ const selected = detected.find((shell) => shell.available && shell.path === shellPath);
222
+ if (selected?.path !== null && selected?.path !== undefined)
223
+ return selected;
224
+ throw new TypeError('所选 shell 不在 Host 白名单或当前不可用');
225
+ }
226
+ const resolved = resolveTerminalShell(this.options.settings().defaultProfile, detected, this.platform);
227
+ const selected = detected.find((shell) => shell.available && shell.path === resolved.path);
228
+ if (selected?.path === null || selected?.path === undefined)
229
+ throw new Error('默认 shell 解析结果无效');
230
+ return selected;
231
+ }
232
+ cwd(agent) {
233
+ return agent.session.header?.cwd ?? process.cwd();
234
+ }
235
+ scope(agent) {
236
+ const cwd = this.cwd(agent);
237
+ return {
238
+ hostId: this.options.hostId,
239
+ workspaceId: this.workspaceId(agent, cwd),
240
+ dshSessionId: agent.id,
241
+ };
242
+ }
243
+ rememberWorkspace(agent) {
244
+ const workspaceId = this.workspaceId(agent, this.cwd(agent));
245
+ this.sessionWorkspaces.set(agent.id, workspaceId);
246
+ return workspaceId;
247
+ }
248
+ /**
249
+ * Workspace Registry 是跨会话的稳定身份。只有找不到正式工作区时才回退到
250
+ * 插件提供的 cwd 规则,避免把同一工作区的不同 Session 拆成多个终端集合。
251
+ */
252
+ workspaceId(agent, cwd) {
253
+ if (this.bindingScope === 'session')
254
+ return `session:${agent.id}`;
255
+ // Cordis 未注入可选服务时直接读 ctx.workspaceRegistry 会抛出 "without inject";
256
+ // 通过 get 探测是官方允许的可选服务读取方式。
257
+ const registry = this.ctx.get('workspaceRegistry');
258
+ if (registry !== undefined) {
259
+ try {
260
+ const workspace = registry.list().find((entry) => entry.sessionIds.includes(agent.id));
261
+ if (workspace !== undefined)
262
+ return workspace.id;
263
+ }
264
+ catch {
265
+ // Workspace Registry 尚未完成启动时继续使用兼容回退,不能让终端功能阻塞 DSH。
266
+ }
267
+ }
268
+ return this.options.workspaceId?.(agent, cwd) ?? cwd;
269
+ }
270
+ identity(agent, terminalId) {
271
+ return { ...this.scope(agent), terminalId };
272
+ }
273
+ optionalIdentity(agent, terminalId) {
274
+ try {
275
+ return this.options.service.findIdentity(this.options.hostId, agent.id, terminalId, this.rememberWorkspace(agent));
276
+ }
277
+ catch (error) {
278
+ if (!(error instanceof TerminalServiceError) || error.code !== 'TERMINAL_UNAVAILABLE')
279
+ throw error;
280
+ return undefined;
281
+ }
282
+ }
283
+ };
284
+ })();
285
+ export { CodingNsTerminalController };
286
+ function shellOption(shell) {
287
+ return { path: shell.path, name: shell.displayName, args: shellArgs(shell.profileId) };
288
+ }
289
+ function shellProfile(shell) {
290
+ return { profileId: shell.profileId, path: shell.path, name: shell.displayName, args: shellArgs(shell.profileId) };
291
+ }
292
+ function shellArgs(profileId) {
293
+ if (profileId === 'cmd')
294
+ return [];
295
+ if (profileId === 'powershell')
296
+ return ['-NoLogo'];
297
+ return ['-i'];
298
+ }
299
+ function runtimeType(platform, profileId) {
300
+ if (platform !== 'win32')
301
+ return 'tmux';
302
+ if (profileId === 'cmd')
303
+ return 'conpty-cmd';
304
+ if (profileId === 'git-bash')
305
+ return 'conpty-git-bash';
306
+ return 'conpty-powershell';
307
+ }
308
+ function remoteTerminalError(error) {
309
+ if (!(error instanceof TerminalServiceError))
310
+ return error;
311
+ if (error.code === 'TERMINAL_CONTROL_UNAVAILABLE') {
312
+ return new RemoteError('terminal/control-unavailable', error.message, { reason: 'read-only' });
313
+ }
314
+ return new RemoteError('terminal/unavailable', error.message, {});
315
+ }
316
+ async function* translateTerminalStream(stream) {
317
+ try {
318
+ yield* stream;
319
+ }
320
+ catch (error) {
321
+ throw remoteTerminalError(error);
322
+ }
323
+ }
324
+ //# sourceMappingURL=terminal-controller.js.map
@@ -0,0 +1,30 @@
1
+ import type { TerminalLaunchProfile, TerminalLaunchProfileInput, TerminalProcessInstance, TerminalProcessLaunchRequest, TerminalProcessLaunchResult } from '../../shared/contracts/terminal-process.js';
2
+ import { CodingNsTerminalService } from './terminal-service.js';
3
+ import { TerminalProcessStore } from './terminal-process-store.js';
4
+ export interface TerminalProcessServiceOptions {
5
+ readonly hostId: string;
6
+ readonly terminalService: CodingNsTerminalService;
7
+ readonly resolveWorkspaceRoot: (workspaceId: string) => string | null;
8
+ readonly now?: () => Date;
9
+ }
10
+ /** 终端侧最小启动器:Host 先创建 PTY 命令,再让现有终端 controller attach。 */
11
+ export declare class TerminalProcessService {
12
+ private readonly store;
13
+ private readonly options;
14
+ private readonly now;
15
+ constructor(store: TerminalProcessStore, options: TerminalProcessServiceOptions);
16
+ initialize(): Promise<void>;
17
+ listProfiles(workspaceId?: string): readonly TerminalLaunchProfile[];
18
+ createProfile(input: TerminalLaunchProfileInput): Promise<TerminalLaunchProfile>;
19
+ deleteProfile(workspaceId: string, profileId: string): Promise<boolean>;
20
+ getInstance(instanceId: string): TerminalProcessInstance | undefined;
21
+ listInstances(workspaceId?: string): readonly TerminalProcessInstance[];
22
+ launch(request: TerminalProcessLaunchRequest): Promise<TerminalProcessLaunchResult>;
23
+ stop(instanceId: string): Promise<TerminalProcessInstance>;
24
+ recover(): Promise<void>;
25
+ private handleExit;
26
+ private resolveCwd;
27
+ }
28
+ /** 与 Spec003 约定的名称;当前只承载 runtimeMode=pty 的终端进程。 */
29
+ export { TerminalProcessService as ProcessRuntimeService };
30
+ //# sourceMappingURL=terminal-process-service.d.ts.map
@@ -0,0 +1,194 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { isAbsolute, join, normalize, relative, sep } from 'node:path';
3
+ import { CodingNsTerminalService } from './terminal-service.js';
4
+ import { TerminalProcessStore, validateProfile } from './terminal-process-store.js';
5
+ /** 终端侧最小启动器:Host 先创建 PTY 命令,再让现有终端 controller attach。 */
6
+ export class TerminalProcessService {
7
+ store;
8
+ options;
9
+ now;
10
+ constructor(store, options) {
11
+ this.store = store;
12
+ this.options = options;
13
+ this.now = options.now ?? (() => new Date());
14
+ }
15
+ async initialize() { await this.store.load(); }
16
+ listProfiles(workspaceId) { return this.store.listProfiles(workspaceId); }
17
+ async createProfile(input) {
18
+ const current = this.store.getProfile(input.workspaceId, input.id);
19
+ const timestamp = this.now().toISOString();
20
+ const profile = {
21
+ id: input.id,
22
+ workspaceId: input.workspaceId,
23
+ name: input.name,
24
+ cwdRelative: input.cwdRelative,
25
+ command: input.command,
26
+ args: [...(input.args ?? [])],
27
+ env: { ...(input.env ?? {}) },
28
+ shell: { ...input.shell, args: [...input.shell.args] },
29
+ runtimeType: input.runtimeType,
30
+ runtimeMode: 'pty',
31
+ revision: (current?.revision ?? 0) + 1,
32
+ createdAt: current?.createdAt ?? timestamp,
33
+ updatedAt: timestamp,
34
+ };
35
+ validateProfile(profile);
36
+ await this.store.putProfile(profile);
37
+ return profile;
38
+ }
39
+ async deleteProfile(workspaceId, profileId) {
40
+ if (this.store.listInstances(workspaceId).some((instance) => instance.profileId === profileId && isActive(instance.state))) {
41
+ throw new Error('终端启动项仍有活动进程,不能删除');
42
+ }
43
+ return this.store.deleteProfile(workspaceId, profileId);
44
+ }
45
+ getInstance(instanceId) { return this.store.getInstance(instanceId); }
46
+ listInstances(workspaceId) { return this.store.listInstances(workspaceId); }
47
+ async launch(request) {
48
+ const profile = this.store.getProfile(request.workspaceId, request.profileId);
49
+ if (profile === undefined)
50
+ throw new Error('终端启动项不存在');
51
+ const cwd = this.resolveCwd(profile);
52
+ const terminalId = request.terminalId ?? `process-${randomUUID()}`;
53
+ const instanceId = `instance-${randomUUID()}`;
54
+ const startedAt = this.now().toISOString();
55
+ let instance = {
56
+ id: instanceId,
57
+ workspaceId: request.workspaceId,
58
+ profileId: profile.id,
59
+ terminalId,
60
+ runtimeSessionKey: null,
61
+ state: 'starting',
62
+ pid: null,
63
+ resolvedCommand: { command: profile.command, args: [...profile.args], cwd },
64
+ exitCode: null,
65
+ startedAt,
66
+ stoppedAt: null,
67
+ };
68
+ await this.store.putInstance(instance);
69
+ const scope = {
70
+ hostId: this.options.hostId,
71
+ workspaceId: request.workspaceId,
72
+ ...(request.dshSessionId === undefined ? {} : { dshSessionId: request.dshSessionId }),
73
+ };
74
+ const identity = { ...scope, terminalId };
75
+ try {
76
+ if (this.options.terminalService.getRecord(identity) !== undefined)
77
+ throw new Error('指定 terminalId 已经存在,不能覆盖已有终端');
78
+ const terminal = await this.options.terminalService.create({
79
+ scope,
80
+ terminalId,
81
+ runtimeType: profile.runtimeType,
82
+ shell: profile.shell,
83
+ ...(request.commandMode === 'shell-input' ? { title: `${profile.name}(${profile.shell.name})` } : {}),
84
+ ...(request.commandMode === 'shell-input' ? {} : { commandPath: profile.command, commandArgs: profile.args }),
85
+ commandEnv: profile.env,
86
+ launchProfileId: profile.id,
87
+ cwd,
88
+ cols: request.cols,
89
+ rows: request.rows,
90
+ onExit: (exitCode) => { void this.handleExit(instanceId, exitCode); },
91
+ });
92
+ if (request.commandMode === 'shell-input') {
93
+ await this.options.terminalService.writeInitialInput(identity, buildShellInput(profile));
94
+ }
95
+ const record = this.options.terminalService.getRecord(identity);
96
+ const runtime = await this.options.terminalService.inspect(identity);
97
+ if (record === undefined)
98
+ throw new Error('终端启动后记录丢失');
99
+ instance = {
100
+ ...instance,
101
+ runtimeSessionKey: record.runtimeSessionKey,
102
+ state: 'running',
103
+ // Shell-input 模式的 runtime PID 是交互 Shell,不是实际监听端口的业务进程。
104
+ // 业务进程身份由 DebugWorkspaceService 的端口快照单独确认。
105
+ pid: request.commandMode === 'shell-input' ? null : runtime.runtimePid,
106
+ };
107
+ await this.store.putInstance(instance);
108
+ return { instance, terminal };
109
+ }
110
+ catch (error) {
111
+ await this.store.putInstance({ ...instance, state: 'failed', error: errorMessage(error), stoppedAt: this.now().toISOString() });
112
+ try {
113
+ await this.options.terminalService.close(identity);
114
+ }
115
+ catch { /* 创建失败时可能尚未有终端记录 */ }
116
+ throw error;
117
+ }
118
+ }
119
+ async stop(instanceId) {
120
+ const instance = this.store.getInstance(instanceId);
121
+ if (instance === undefined)
122
+ throw new Error('终端进程实例不存在');
123
+ if (!isActive(instance.state))
124
+ return instance;
125
+ await this.store.putInstance({ ...instance, state: 'stopping' });
126
+ try {
127
+ await this.options.terminalService.close({
128
+ hostId: this.options.hostId,
129
+ workspaceId: instance.workspaceId,
130
+ terminalId: instance.terminalId,
131
+ });
132
+ const latest = this.store.getInstance(instanceId) ?? instance;
133
+ const stopped = { ...latest, state: 'exited', stoppedAt: this.now().toISOString() };
134
+ await this.store.putInstance(stopped);
135
+ return stopped;
136
+ }
137
+ catch (error) {
138
+ const failed = { ...instance, state: 'failed', error: errorMessage(error), stoppedAt: this.now().toISOString() };
139
+ await this.store.putInstance(failed);
140
+ throw error;
141
+ }
142
+ }
143
+ async recover() {
144
+ for (const instance of this.store.listInstances()) {
145
+ if (!isActive(instance.state))
146
+ continue;
147
+ const identity = { hostId: this.options.hostId, workspaceId: instance.workspaceId, terminalId: instance.terminalId };
148
+ try {
149
+ const runtime = await this.options.terminalService.inspect(identity);
150
+ await this.store.putInstance({ ...instance, state: runtime.alive ? 'running' : 'lost', pid: runtime.runtimePid, ...(runtime.alive ? {} : { error: runtime.detail ?? '终端运行时不存在' }) });
151
+ }
152
+ catch (error) {
153
+ await this.store.putInstance({ ...instance, state: 'lost', error: errorMessage(error) });
154
+ }
155
+ }
156
+ }
157
+ async handleExit(instanceId, exitCode) {
158
+ const current = this.store.getInstance(instanceId);
159
+ if (current === undefined || !isActive(current.state))
160
+ return;
161
+ await this.store.putInstance({ ...current, state: 'exited', exitCode, stoppedAt: this.now().toISOString() });
162
+ }
163
+ resolveCwd(profile) {
164
+ const root = this.options.resolveWorkspaceRoot(profile.workspaceId);
165
+ if (root === null || !isAbsolute(root))
166
+ throw new Error('Workspace 根目录不可用');
167
+ const cwd = normalize(join(root, profile.cwdRelative));
168
+ const escaped = relative(root, cwd);
169
+ if (escaped === '..' || escaped.startsWith(`..${sep}`) || isAbsolute(escaped))
170
+ throw new Error('终端启动项工作目录越出 Workspace');
171
+ return cwd;
172
+ }
173
+ }
174
+ /** 与 Spec003 约定的名称;当前只承载 runtimeMode=pty 的终端进程。 */
175
+ export { TerminalProcessService as ProcessRuntimeService };
176
+ function isActive(state) { return state === 'starting' || state === 'running' || state === 'stopping'; }
177
+ function errorMessage(error) { return error instanceof Error ? error.message : String(error); }
178
+ /** 按目标 Shell 的语法编码命令参数,避免把参数中的空格重新拆开。 */
179
+ function buildShellInput(profile) {
180
+ const command = [profile.command, ...profile.args];
181
+ const shellType = profile.shell.profileId === 'cmd'
182
+ ? 'cmd'
183
+ : profile.shell.profileId === 'powershell'
184
+ ? 'powershell'
185
+ : 'posix';
186
+ const line = shellType === 'powershell'
187
+ ? `& ${command.map(powerShellQuote).join(' ')}`
188
+ : command.map(shellType === 'cmd' ? cmdQuote : posixQuote).join(' ');
189
+ return `${line}${shellType === 'posix' ? '\n' : '\r'}`;
190
+ }
191
+ function posixQuote(value) { return `'${value.replaceAll("'", "'\\''")}'`; }
192
+ function powerShellQuote(value) { return `'${value.replaceAll("'", "''")}'`; }
193
+ function cmdQuote(value) { return `"${value.replaceAll('"', '""')}"`; }
194
+ //# sourceMappingURL=terminal-process-service.js.map
@@ -0,0 +1,45 @@
1
+ import type { TerminalLaunchProfile, TerminalProcessInstance } from '../../shared/contracts/terminal-process.js';
2
+ declare const STORE_VERSION = 1;
3
+ interface TerminalProcessDocument {
4
+ readonly version: typeof STORE_VERSION;
5
+ readonly profiles: readonly TerminalLaunchProfile[];
6
+ readonly instances: readonly TerminalProcessInstance[];
7
+ }
8
+ export interface TerminalProcessStorePersistence {
9
+ load(): Promise<unknown>;
10
+ save(document: TerminalProcessDocument): Promise<void>;
11
+ }
12
+ export declare class JsonFileTerminalProcessStorePersistence implements TerminalProcessStorePersistence {
13
+ private readonly filename;
14
+ constructor(filename: string);
15
+ load(): Promise<unknown>;
16
+ save(document: TerminalProcessDocument): Promise<void>;
17
+ }
18
+ export declare class InMemoryTerminalProcessStorePersistence implements TerminalProcessStorePersistence {
19
+ private document;
20
+ constructor(initial?: unknown);
21
+ load(): Promise<unknown>;
22
+ save(document: TerminalProcessDocument): Promise<void>;
23
+ }
24
+ export declare class TerminalProcessStore {
25
+ private readonly persistence;
26
+ private profiles;
27
+ private instances;
28
+ private writeTail;
29
+ private loaded;
30
+ constructor(persistence: TerminalProcessStorePersistence);
31
+ load(): Promise<void>;
32
+ getProfile(workspaceId: string, profileId: string): TerminalLaunchProfile | undefined;
33
+ listProfiles(workspaceId?: string): readonly TerminalLaunchProfile[];
34
+ putProfile(profile: TerminalLaunchProfile): Promise<void>;
35
+ deleteProfile(workspaceId: string, profileId: string): Promise<boolean>;
36
+ getInstance(instanceId: string): TerminalProcessInstance | undefined;
37
+ listInstances(workspaceId?: string): readonly TerminalProcessInstance[];
38
+ putInstance(instance: TerminalProcessInstance): Promise<void>;
39
+ private enqueue;
40
+ private persist;
41
+ private requireLoaded;
42
+ }
43
+ export declare function validateProfile(profile: TerminalLaunchProfile): void;
44
+ export {};
45
+ //# sourceMappingURL=terminal-process-store.d.ts.map