@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,335 @@
1
+ import { CommandCodeDriver } from './command-code-driver.js';
2
+ import { ClaudeCodeDriver } from './claude-driver.js';
3
+ import { GeminiCliDriver } from './gemini-driver.js';
4
+ import { KimiCliDriver } from './kimi-driver.js';
5
+ import { PiAgentDriver } from './pi-driver.js';
6
+ import { CodexAppServerDriver } from './codex-driver.js';
7
+ import { GrokBuildDriver } from './grok-driver.js';
8
+ import { OpenCodeDriver } from './opencode-driver.js';
9
+ import { CodingNsCliAdapterRegistry } from './registry.js';
10
+ import { CodingNsCliSessionStore } from './session-store.js';
11
+ import { CodingNsDshMessageProjector } from './dsh-message-projector.js';
12
+ import { CommandCodeSubscriptionService } from './command-code-subscription.js';
13
+ import { ProviderSubscriptionService } from './provider-subscription.js';
14
+ export function createCliAdaptersFeature(options = {}) {
15
+ return {
16
+ descriptor: {
17
+ name: 'cliAdapters',
18
+ version: '0.1.0',
19
+ enabledByDefault: true,
20
+ dependencies: [],
21
+ runtime: 'host',
22
+ },
23
+ start(context) {
24
+ const commandCodeSubscription = new CommandCodeSubscriptionService();
25
+ const subscriptions = new ProviderSubscriptionService({ commandCode: commandCodeSubscription });
26
+ const sessionStore = new CodingNsCliSessionStore(context.services.settings === undefined ? {} : { settings: context.services.settings });
27
+ const registry = options.registry ?? new CodingNsCliAdapterRegistry([
28
+ new CommandCodeDriver(),
29
+ new ClaudeCodeDriver(),
30
+ new KimiCliDriver(),
31
+ new GeminiCliDriver(),
32
+ new PiAgentDriver(),
33
+ new CodexAppServerDriver(),
34
+ new OpenCodeDriver(),
35
+ new GrokBuildDriver(),
36
+ ], context.services.settings?.get().agentAdapters, {
37
+ sessionStore,
38
+ ...(context.services.settings === undefined ? {} : { settings: context.services.settings }),
39
+ ...(context.services.nativeSessions === undefined ? {} : { nativeSessions: context.services.nativeSessions }),
40
+ });
41
+ registry.applyEnabledSettings(context.services.settings?.get().agentAdapters);
42
+ registry.warmCatalog();
43
+ const nativeSessions = context.services.nativeSessions;
44
+ if (nativeSessions !== undefined) {
45
+ const disposeNativeEvents = nativeSessions.subscribe({
46
+ onEvent: (session, event) => {
47
+ const sessionId = nativeSessionId(session);
48
+ const eventType = nativeEventType(event);
49
+ if (sessionId === undefined || eventType === undefined)
50
+ return;
51
+ const current = sessionStore.get(sessionId);
52
+ if (current === undefined || current.status === 'archived')
53
+ return;
54
+ if (eventType === 'turn/start') {
55
+ sessionStore.upsert(sessionId, { ...current, status: 'active' });
56
+ }
57
+ else if (eventType === 'turn/end') {
58
+ sessionStore.upsert(sessionId, { ...current, status: 'idle' });
59
+ }
60
+ },
61
+ });
62
+ context.resources.add(disposeNativeEvents);
63
+ }
64
+ context.resources.add(context.services.rpc.register('cli', (action, payload) => {
65
+ switch (action) {
66
+ case 'catalog': return registry.catalog();
67
+ case 'models': return registry.models(readAdapterId(payload));
68
+ case 'adapter/set': return setAdapterEnabled(context.services.settings, registry, payload);
69
+ case 'session/get': return registry.getSession(readSessionId(payload));
70
+ case 'session/set': return registry.setSession(readSessionId(payload), readSessionConfig(payload));
71
+ case 'session/list': return registry.listSessions(readSessionListOptions(payload));
72
+ case 'session/adapter-map': return sessionStore.adapterBindings();
73
+ case 'session/archive': return registry.archiveSession(readSessionId(payload));
74
+ case 'session/steer': return registry.steer(readSessionId(payload), readPrompt(payload), false);
75
+ case 'session/follow-up': return registry.steer(readSessionId(payload), readPrompt(payload), true);
76
+ case 'session/interrupt': return registry.interrupt(readSessionId(payload));
77
+ case 'subscription': return subscriptions.read(readSubscriptionAdapterId(payload));
78
+ default: throw new Error(`未知 CLI RPC: cli/${action}`);
79
+ }
80
+ }));
81
+ const settings = context.services.settings;
82
+ if (settings !== undefined) {
83
+ context.resources.add(settings.watch((next) => {
84
+ registry.applyEnabledSettings(next.agentAdapters);
85
+ registry.syncPreferences(next.agentAdapterPreferences);
86
+ sessionStore.sync(next.cliSessions);
87
+ }));
88
+ }
89
+ const events = context.services.events;
90
+ if (events !== undefined) {
91
+ const dispose = events.on('llm/stream', async function* (options, next) {
92
+ const value = asRecord(options);
93
+ const sessionId = typeof value?.sessionId === 'string' ? value.sessionId : '';
94
+ const config = sessionId ? registry.getSession(sessionId) : { adapterId: 'dsh' };
95
+ if (config.adapterId === 'dsh') {
96
+ const selection = readDshSelection(value);
97
+ if (sessionId !== '' && (selection.modelId !== undefined || selection.effortId !== undefined)) {
98
+ registry.setSession(sessionId, { adapterId: 'dsh', ...selection });
99
+ }
100
+ yield* next();
101
+ return;
102
+ }
103
+ if (value?.purpose === 'session-title' || value?.purpose === 'compaction') {
104
+ yield* next();
105
+ return;
106
+ }
107
+ const messages = Array.isArray(value?.messages) ? value.messages.filter(isMessage) : [];
108
+ const cwd = resolveSessionCwd(context.services.nativeSessions, sessionId, value);
109
+ const input = {
110
+ sessionId,
111
+ messages,
112
+ prompt: extractPrompt(messages),
113
+ ...(config.modelId ? { modelId: config.modelId } : {}),
114
+ ...(config.effortId ? { effortId: config.effortId } : {}),
115
+ ...(config.providerSessionId ? { providerSessionId: config.providerSessionId } : {}),
116
+ ...(config.rawStoreRef ? { rawStoreRef: config.rawStoreRef } : {}),
117
+ ...(cwd === undefined ? {} : { cwd }),
118
+ ...(isAbortSignal(value?.signal) ? { signal: value.signal } : {}),
119
+ };
120
+ const projector = new CodingNsDshMessageProjector({
121
+ adapterId: config.adapterId,
122
+ sessionId,
123
+ ...(config.modelId === undefined ? {} : { modelId: config.modelId }),
124
+ ...(nativeSessions === undefined ? {} : { nativeSessions }),
125
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
126
+ respondPermission: (response) => registry.respondPermission(sessionId, response),
127
+ respondQuestion: (response) => registry.respondQuestion(sessionId, response),
128
+ });
129
+ try {
130
+ for await (const chunk of registry.execute({ ...input, adapterId: config.adapterId })) {
131
+ for (const dshChunk of await projector.push(chunk))
132
+ yield dshChunk;
133
+ // DSH 要求 finish 是唯一且最后一个 chunk。这里 return 也会关闭上游迭代器。
134
+ if (projector.isFinished)
135
+ return;
136
+ }
137
+ const reason = input.signal?.aborted ? 'cancel' : 'stop';
138
+ for (const dshChunk of await projector.complete(reason))
139
+ yield dshChunk;
140
+ }
141
+ catch (error) {
142
+ const message = safeError(error);
143
+ for (const dshChunk of await projector.fail(message, input.signal?.aborted ?? false))
144
+ yield dshChunk;
145
+ }
146
+ });
147
+ if (typeof dispose === 'function')
148
+ context.resources.add(() => { dispose(); });
149
+ }
150
+ context.resources.add(async () => { await registry.dispose(); await sessionStore.flush(); });
151
+ },
152
+ };
153
+ }
154
+ function readAdapterId(value) {
155
+ const record = asRecord(value);
156
+ if (typeof record?.adapterId !== 'string' || record.adapterId.trim() === '')
157
+ throw new Error('adapterId 不能为空');
158
+ return record.adapterId.trim();
159
+ }
160
+ function readSubscriptionAdapterId(value) {
161
+ const record = asRecord(value);
162
+ if (record === null || record.adapterId === undefined)
163
+ return 'command-code';
164
+ return readAdapterId(value);
165
+ }
166
+ function readSessionId(value) {
167
+ const record = asRecord(value);
168
+ if (typeof record?.sessionId !== 'string' || record.sessionId.trim() === '')
169
+ throw new Error('sessionId 不能为空');
170
+ return record.sessionId.trim();
171
+ }
172
+ function readSessionConfig(value) {
173
+ const record = asRecord(value);
174
+ const adapterId = readAdapterId(record);
175
+ return {
176
+ adapterId,
177
+ ...(typeof record?.modelId === 'string' && record.modelId.trim() ? { modelId: record.modelId.trim() } : {}),
178
+ ...(typeof record?.effortId === 'string' && record.effortId.trim() ? { effortId: record.effortId.trim() } : {}),
179
+ ...(typeof record?.providerSessionId === 'string' && record.providerSessionId.trim() ? { providerSessionId: record.providerSessionId.trim() } : {}),
180
+ };
181
+ }
182
+ function readSessionListOptions(value) {
183
+ const record = asRecord(value);
184
+ const adapterId = typeof record?.adapterId === 'string' && record.adapterId.trim() ? record.adapterId.trim() : undefined;
185
+ const includeArchived = record?.includeArchived === true ? true : undefined;
186
+ return {
187
+ ...(adapterId ? { adapterId } : {}),
188
+ ...(includeArchived === true ? { includeArchived: true } : {}),
189
+ };
190
+ }
191
+ function readPrompt(value) {
192
+ const record = asRecord(value);
193
+ if (typeof record?.prompt !== 'string' || record.prompt.trim() === '')
194
+ throw new Error('prompt 不能为空');
195
+ return record.prompt.trim();
196
+ }
197
+ /** 从 DSH 原生 llm/stream 请求头捕获当前模型和思考强度。 */
198
+ function readDshSelection(value) {
199
+ const candidates = [
200
+ value,
201
+ asRecord(value?.request),
202
+ asRecord(value?.config),
203
+ asRecord(value?.header),
204
+ ...readModelSelectionCandidates(value),
205
+ ];
206
+ const read = (keys) => {
207
+ for (const candidate of candidates) {
208
+ for (const key of keys) {
209
+ const result = candidate?.[key];
210
+ if (typeof result === 'string' && result.trim() !== '')
211
+ return result.trim();
212
+ }
213
+ }
214
+ return undefined;
215
+ };
216
+ const modelId = read(['model', 'modelId']);
217
+ const effortId = read(['reasoningEffort', 'effortId', 'thinking']);
218
+ return {
219
+ ...(modelId === undefined ? {} : { modelId }),
220
+ ...(effortId === undefined ? {} : { effortId }),
221
+ };
222
+ }
223
+ /** DSH Session 快照把最近选择放在 modelSelection.lastUsed/next。 */
224
+ function readModelSelectionCandidates(value) {
225
+ const result = [];
226
+ for (const candidate of [value, asRecord(value?.request), asRecord(value?.config), asRecord(value?.header)]) {
227
+ const selection = asRecord(candidate?.modelSelection);
228
+ const lastUsed = asRecord(selection?.lastUsed);
229
+ const next = asRecord(selection?.next);
230
+ if (lastUsed !== null)
231
+ result.push(lastUsed);
232
+ if (next !== null)
233
+ result.push(next);
234
+ }
235
+ return result;
236
+ }
237
+ async function setAdapterEnabled(settings, registry, value) {
238
+ const record = asRecord(value);
239
+ const adapterId = readAdapterId(record);
240
+ if (typeof record?.enabled !== 'boolean')
241
+ throw new Error('enabled 必须是布尔值');
242
+ const enabled = registry.setEnabled(adapterId, record.enabled);
243
+ if (settings !== undefined)
244
+ await settings.update({ agentAdapters: registry.enabledSnapshot() });
245
+ return { adapterId, enabled };
246
+ }
247
+ function extractPrompt(messages) {
248
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
249
+ const message = messages[index];
250
+ if (message !== undefined && isHumanUserMessage(message))
251
+ return extractText(message.content);
252
+ }
253
+ return '';
254
+ }
255
+ function isHumanUserMessage(message) {
256
+ if (message.role !== 'user')
257
+ return false;
258
+ // 旧测试和旧调用方没有 source,保留其兼容语义;有 source 时只接受真实用户消息。
259
+ if (message.source === undefined)
260
+ return true;
261
+ if (!isRecord(message.source))
262
+ return false;
263
+ return message.source.kind === undefined || message.source.kind === 'user';
264
+ }
265
+ function extractText(content) {
266
+ if (typeof content === 'string')
267
+ return content;
268
+ if (!Array.isArray(content))
269
+ return '';
270
+ return content.filter(isRecord).map((part) => typeof part.text === 'string' ? part.text : '').join('\n').trim();
271
+ }
272
+ function resolveSessionCwd(nativeSessions, sessionId, value) {
273
+ const direct = typeof value?.cwd === 'string' && value.cwd.trim() ? value.cwd.trim() : undefined;
274
+ if (direct !== undefined)
275
+ return direct;
276
+ if (nativeSessions === undefined || sessionId.trim() === '')
277
+ return undefined;
278
+ const session = nativeSessions.get(sessionId);
279
+ const record = asRecord(session);
280
+ const header = asRecord(record?.header);
281
+ const meta = asRecord(record?.meta);
282
+ const directCwd = [header?.cwd, meta?.cwd, record?.cwd].find((item) => typeof item === 'string' && item.trim() !== '');
283
+ if (directCwd !== undefined)
284
+ return directCwd.trim();
285
+ const snapshot = record?.snapshotEvents;
286
+ if (typeof snapshot === 'function') {
287
+ try {
288
+ const events = snapshot.call(session);
289
+ const eventCwd = findCwdInValue(events, 0);
290
+ if (eventCwd !== undefined)
291
+ return eventCwd;
292
+ }
293
+ catch { /* 原生会话快照不可读时继续使用未解析状态。 */ }
294
+ }
295
+ return findCwdInValue(record, 0);
296
+ }
297
+ /** DSH 的 cwd 可能只存在 request/header.data.header 或事件 data.cwd 中。 */
298
+ function findCwdInValue(value, depth) {
299
+ if (depth > 6 || value === null || typeof value !== 'object')
300
+ return undefined;
301
+ if (Array.isArray(value)) {
302
+ for (const item of value) {
303
+ const found = findCwdInValue(item, depth + 1);
304
+ if (found !== undefined)
305
+ return found;
306
+ }
307
+ return undefined;
308
+ }
309
+ const record = value;
310
+ for (const key of ['cwd', 'workingDirectory']) {
311
+ const candidate = record[key];
312
+ if (typeof candidate === 'string' && candidate.trim() !== '')
313
+ return candidate.trim();
314
+ }
315
+ for (const key of ['header', 'request', 'context', 'data', 'meta', 'session']) {
316
+ const found = findCwdInValue(record[key], depth + 1);
317
+ if (found !== undefined)
318
+ return found;
319
+ }
320
+ return undefined;
321
+ }
322
+ function asRecord(value) { return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null; }
323
+ function isRecord(value) { return asRecord(value) !== null; }
324
+ function nativeSessionId(value) {
325
+ const record = asRecord(value);
326
+ return typeof record?.id === 'string' && record.id.trim() ? record.id.trim() : typeof record?.sessionId === 'string' && record.sessionId.trim() ? record.sessionId.trim() : undefined;
327
+ }
328
+ function nativeEventType(value) {
329
+ const record = asRecord(value);
330
+ return typeof record?.type === 'string' ? record.type : undefined;
331
+ }
332
+ function isMessage(value) { const record = asRecord(value); return (record?.role === 'user' || record?.role === 'assistant' || record?.role === 'system') && 'content' in record; }
333
+ function isAbortSignal(value) { return asRecord(value)?.aborted === true || (asRecord(value)?.addEventListener instanceof Function); }
334
+ function safeError(error) { return error instanceof Error ? error.message.slice(0, 512) : String(error).slice(0, 512); }
335
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1,24 @@
1
+ import type { CodingNsAgentEvent, CodingNsCliModelCatalog, CodingNsAgentPermissionResponse, CodingNsCliTurnInput } from '../../shared/contracts/cli-adapter.js';
2
+ import type { CodingNsCliSessionProbeInput, CodingNsCliSessionProbeResult } from './driver.js';
3
+ import { StandardStreamDriver, type StandardStreamDriverOptions } from './standard-stream-driver.js';
4
+ /** Gemini 官方 ACP 优先;不支持 ACP 的旧 CLI 自动回退 headless stream-json。 */
5
+ export declare class GeminiCliDriver extends StandardStreamDriver {
6
+ private readonly sessionRoots;
7
+ private readonly interactions;
8
+ constructor(options?: StandardStreamDriverOptions);
9
+ listModels(): Promise<CodingNsCliModelCatalog>;
10
+ probeSession(input: CodingNsCliSessionProbeInput): Promise<CodingNsCliSessionProbeResult>;
11
+ protected buildArgs(input: CodingNsCliTurnInput): readonly string[];
12
+ /**
13
+ * Gemini 的旧版 stream-json 会先回放一条 role=user 的消息。
14
+ * 这条记录只是输入回显,不能投影成 DSH 的 assistant 正文;result 还要按
15
+ * Gemini 自己的 status 和 stats 字段生成正确的终态与用量。
16
+ */
17
+ protected parseEvent(value: Record<string, unknown>, input: CodingNsCliTurnInput): readonly CodingNsAgentEvent[];
18
+ respondPermission(sessionId: string, response: CodingNsAgentPermissionResponse): void;
19
+ dispose(): void;
20
+ executeTurn(input: CodingNsCliTurnInput): AsyncIterable<CodingNsAgentEvent>;
21
+ private executeAcpTurn;
22
+ }
23
+ export { GeminiCliDriver as GeminiDriver };
24
+ //# sourceMappingURL=gemini-driver.d.ts.map