@jingyi0605/codingns4dsh 0.2.0-beta.2 → 0.2.0-rc.3

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 (604) hide show
  1. package/README.en.md +4 -4
  2. package/README.md +18 -7
  3. package/assets/provider-icons/antigravity.svg +39 -0
  4. package/assets/provider-icons/codebuddy.svg +37 -0
  5. package/assets/provider-icons/cursor-cli.svg +1 -0
  6. package/assets/provider-icons/kiro-cli.svg +11 -0
  7. package/assets/provider-icons/minimax-code.svg +4 -0
  8. package/assets/provider-icons/qoder-cn.svg +5 -0
  9. package/assets/provider-icons/qoder.svg +5 -0
  10. package/assets/provider-icons/workbuddy.svg +29 -0
  11. package/assets/provider-icons/zcode.svg +14 -0
  12. package/data/build/dist/bootstrap/dsh-peer-host-preboot-shim.d.ts.map +1 -1
  13. package/data/build/dist/bootstrap/dsh-peer-host-preboot-shim.js +78 -1
  14. package/data/build/dist/bootstrap/dsh-peer-host-preboot-shim.js.map +1 -1
  15. package/data/build/dist/client/account-bar.d.ts +2 -1
  16. package/data/build/dist/client/account-bar.d.ts.map +1 -1
  17. package/data/build/dist/client/account-bar.js +21 -16
  18. package/data/build/dist/client/account-bar.js.map +1 -1
  19. package/data/build/dist/client/bundle.js +8147 -2158
  20. package/data/build/dist/client/bundle.js.map +1 -1
  21. package/data/build/dist/client/cli-catalog.d.ts +1 -1
  22. package/data/build/dist/client/cli-catalog.d.ts.map +1 -1
  23. package/data/build/dist/client/cli-catalog.js +11 -5
  24. package/data/build/dist/client/cli-catalog.js.map +1 -1
  25. package/data/build/dist/client/cli-slots.d.ts.map +1 -1
  26. package/data/build/dist/client/cli-slots.js +127 -21
  27. package/data/build/dist/client/cli-slots.js.map +1 -1
  28. package/data/build/dist/client/debug/ui.d.ts +2 -1
  29. package/data/build/dist/client/debug/ui.d.ts.map +1 -1
  30. package/data/build/dist/client/debug/ui.js +41 -34
  31. package/data/build/dist/client/debug/ui.js.map +1 -1
  32. package/data/build/dist/client/delegate-command.d.ts +17 -0
  33. package/data/build/dist/client/delegate-command.d.ts.map +1 -0
  34. package/data/build/dist/client/delegate-command.js +597 -0
  35. package/data/build/dist/client/delegate-command.js.map +1 -0
  36. package/data/build/dist/client/delegate-plan.d.ts +40 -0
  37. package/data/build/dist/client/delegate-plan.d.ts.map +1 -0
  38. package/data/build/dist/client/delegate-plan.js +63 -0
  39. package/data/build/dist/client/delegate-plan.js.map +1 -0
  40. package/data/build/dist/client/delegate-ui-dom.d.ts +86 -0
  41. package/data/build/dist/client/delegate-ui-dom.d.ts.map +1 -0
  42. package/data/build/dist/client/delegate-ui-dom.js +647 -0
  43. package/data/build/dist/client/delegate-ui-dom.js.map +1 -0
  44. package/data/build/dist/client/external-tool-stream.d.ts.map +1 -1
  45. package/data/build/dist/client/external-tool-stream.js +44 -36
  46. package/data/build/dist/client/external-tool-stream.js.map +1 -1
  47. package/data/build/dist/client/features/cli-adapters.d.ts +7 -2
  48. package/data/build/dist/client/features/cli-adapters.d.ts.map +1 -1
  49. package/data/build/dist/client/features/cli-adapters.js +153 -95
  50. package/data/build/dist/client/features/cli-adapters.js.map +1 -1
  51. package/data/build/dist/client/features/debug.d.ts.map +1 -1
  52. package/data/build/dist/client/features/debug.js +5 -3
  53. package/data/build/dist/client/features/debug.js.map +1 -1
  54. package/data/build/dist/client/features/file-management.d.ts.map +1 -1
  55. package/data/build/dist/client/features/file-management.js +7 -4
  56. package/data/build/dist/client/features/file-management.js.map +1 -1
  57. package/data/build/dist/client/features/lan-access-panel.js +10 -10
  58. package/data/build/dist/client/features/lan-access-panel.js.map +1 -1
  59. package/data/build/dist/client/features/lan-access.d.ts.map +1 -1
  60. package/data/build/dist/client/features/lan-access.js +8 -3
  61. package/data/build/dist/client/features/lan-access.js.map +1 -1
  62. package/data/build/dist/client/features/login-protection-panel.d.ts.map +1 -1
  63. package/data/build/dist/client/features/login-protection-panel.js +9 -7
  64. package/data/build/dist/client/features/login-protection-panel.js.map +1 -1
  65. package/data/build/dist/client/features/login-protection.js +2 -2
  66. package/data/build/dist/client/features/login-protection.js.map +1 -1
  67. package/data/build/dist/client/features/mobile-access-panel.d.ts.map +1 -1
  68. package/data/build/dist/client/features/mobile-access-panel.js +8 -7
  69. package/data/build/dist/client/features/mobile-access-panel.js.map +1 -1
  70. package/data/build/dist/client/features/mobile-access.d.ts.map +1 -1
  71. package/data/build/dist/client/features/mobile-access.js +6 -2
  72. package/data/build/dist/client/features/mobile-access.js.map +1 -1
  73. package/data/build/dist/client/features/peer-host.d.ts +6 -4
  74. package/data/build/dist/client/features/peer-host.d.ts.map +1 -1
  75. package/data/build/dist/client/features/peer-host.js +459 -27
  76. package/data/build/dist/client/features/peer-host.js.map +1 -1
  77. package/data/build/dist/client/features/reverse-proxy.js +2 -2
  78. package/data/build/dist/client/features/reverse-proxy.js.map +1 -1
  79. package/data/build/dist/client/features/terminal-enhancement.js +2 -2
  80. package/data/build/dist/client/features/terminal-enhancement.js.map +1 -1
  81. package/data/build/dist/client/features/workspace-session-enhancement-panel.js +1 -1
  82. package/data/build/dist/client/features/workspace-session-enhancement-panel.js.map +1 -1
  83. package/data/build/dist/client/features/workspace-session-enhancement.d.ts.map +1 -1
  84. package/data/build/dist/client/features/workspace-session-enhancement.js +8 -3
  85. package/data/build/dist/client/features/workspace-session-enhancement.js.map +1 -1
  86. package/data/build/dist/client/file-management-dom.d.ts +3 -0
  87. package/data/build/dist/client/file-management-dom.d.ts.map +1 -1
  88. package/data/build/dist/client/file-management-dom.js +41 -30
  89. package/data/build/dist/client/file-management-dom.js.map +1 -1
  90. package/data/build/dist/client/git-history-graph.d.ts +2 -2
  91. package/data/build/dist/client/git-history-graph.d.ts.map +1 -1
  92. package/data/build/dist/client/git-history-graph.js +2 -2
  93. package/data/build/dist/client/git-history-graph.js.map +1 -1
  94. package/data/build/dist/client/git-management.d.ts +2 -0
  95. package/data/build/dist/client/git-management.d.ts.map +1 -1
  96. package/data/build/dist/client/git-management.js +103 -75
  97. package/data/build/dist/client/git-management.js.map +1 -1
  98. package/data/build/dist/client/git-workspace-events.d.ts +7 -0
  99. package/data/build/dist/client/git-workspace-events.d.ts.map +1 -0
  100. package/data/build/dist/client/git-workspace-events.js +32 -0
  101. package/data/build/dist/client/git-workspace-events.js.map +1 -0
  102. package/data/build/dist/client/index.d.ts +2 -0
  103. package/data/build/dist/client/index.d.ts.map +1 -1
  104. package/data/build/dist/client/index.js +6 -5
  105. package/data/build/dist/client/index.js.map +1 -1
  106. package/data/build/dist/client/locale.d.ts +7 -0
  107. package/data/build/dist/client/locale.d.ts.map +1 -1
  108. package/data/build/dist/client/locale.js +140 -42
  109. package/data/build/dist/client/locale.js.map +1 -1
  110. package/data/build/dist/client/locales/debug.d.ts +9 -0
  111. package/data/build/dist/client/locales/debug.d.ts.map +1 -0
  112. package/data/build/dist/client/locales/debug.js +163 -0
  113. package/data/build/dist/client/locales/debug.js.map +1 -0
  114. package/data/build/dist/client/locales/fileWorkspace.d.ts +9 -0
  115. package/data/build/dist/client/locales/fileWorkspace.d.ts.map +1 -0
  116. package/data/build/dist/client/locales/fileWorkspace.js +139 -0
  117. package/data/build/dist/client/locales/fileWorkspace.js.map +1 -0
  118. package/data/build/dist/client/locales/git.d.ts +9 -0
  119. package/data/build/dist/client/locales/git.d.ts.map +1 -0
  120. package/data/build/dist/client/locales/git.js +223 -0
  121. package/data/build/dist/client/locales/git.js.map +1 -0
  122. package/data/build/dist/client/locales/panels.d.ts +9 -0
  123. package/data/build/dist/client/locales/panels.d.ts.map +1 -0
  124. package/data/build/dist/client/locales/panels.js +33 -0
  125. package/data/build/dist/client/locales/panels.js.map +1 -0
  126. package/data/build/dist/client/locales/peerHost.d.ts +9 -0
  127. package/data/build/dist/client/locales/peerHost.d.ts.map +1 -0
  128. package/data/build/dist/client/locales/peerHost.js +153 -0
  129. package/data/build/dist/client/locales/peerHost.js.map +1 -0
  130. package/data/build/dist/client/locales/peerHostWorkspace.d.ts +9 -0
  131. package/data/build/dist/client/locales/peerHostWorkspace.d.ts.map +1 -0
  132. package/data/build/dist/client/locales/peerHostWorkspace.js +69 -0
  133. package/data/build/dist/client/locales/peerHostWorkspace.js.map +1 -0
  134. package/data/build/dist/client/locales/terminalAuth.d.ts +9 -0
  135. package/data/build/dist/client/locales/terminalAuth.d.ts.map +1 -0
  136. package/data/build/dist/client/locales/terminalAuth.js +71 -0
  137. package/data/build/dist/client/locales/terminalAuth.js.map +1 -0
  138. package/data/build/dist/client/locales/usage.d.ts +9 -0
  139. package/data/build/dist/client/locales/usage.d.ts.map +1 -0
  140. package/data/build/dist/client/locales/usage.js +215 -0
  141. package/data/build/dist/client/locales/usage.js.map +1 -0
  142. package/data/build/dist/client/mobile-session-interaction.d.ts +44 -0
  143. package/data/build/dist/client/mobile-session-interaction.d.ts.map +1 -0
  144. package/data/build/dist/client/mobile-session-interaction.js +308 -0
  145. package/data/build/dist/client/mobile-session-interaction.js.map +1 -0
  146. package/data/build/dist/client/mobile-sidebar-gestures.d.ts +55 -7
  147. package/data/build/dist/client/mobile-sidebar-gestures.d.ts.map +1 -1
  148. package/data/build/dist/client/mobile-sidebar-gestures.js +339 -40
  149. package/data/build/dist/client/mobile-sidebar-gestures.js.map +1 -1
  150. package/data/build/dist/client/mobile-sidebar-rail-dom.d.ts +10 -2
  151. package/data/build/dist/client/mobile-sidebar-rail-dom.d.ts.map +1 -1
  152. package/data/build/dist/client/mobile-sidebar-rail-dom.js +14 -6
  153. package/data/build/dist/client/mobile-sidebar-rail-dom.js.map +1 -1
  154. package/data/build/dist/client/model-catalog-cache.d.ts +5 -0
  155. package/data/build/dist/client/model-catalog-cache.d.ts.map +1 -0
  156. package/data/build/dist/client/model-catalog-cache.js +58 -0
  157. package/data/build/dist/client/model-catalog-cache.js.map +1 -0
  158. package/data/build/dist/client/peer-host-aggregate-refresh.d.ts +7 -0
  159. package/data/build/dist/client/peer-host-aggregate-refresh.d.ts.map +1 -1
  160. package/data/build/dist/client/peer-host-aggregate-refresh.js +13 -1
  161. package/data/build/dist/client/peer-host-aggregate-refresh.js.map +1 -1
  162. package/data/build/dist/client/peer-host-connection-button.d.ts +14 -1
  163. package/data/build/dist/client/peer-host-connection-button.d.ts.map +1 -1
  164. package/data/build/dist/client/peer-host-connection-button.js +12 -4
  165. package/data/build/dist/client/peer-host-connection-button.js.map +1 -1
  166. package/data/build/dist/client/peer-host-management-panel.d.ts +3 -0
  167. package/data/build/dist/client/peer-host-management-panel.d.ts.map +1 -1
  168. package/data/build/dist/client/peer-host-management-panel.js +83 -79
  169. package/data/build/dist/client/peer-host-management-panel.js.map +1 -1
  170. package/data/build/dist/client/peer-host-native-projection.d.ts +17 -1
  171. package/data/build/dist/client/peer-host-native-projection.d.ts.map +1 -1
  172. package/data/build/dist/client/peer-host-native-projection.js +54 -8
  173. package/data/build/dist/client/peer-host-native-projection.js.map +1 -1
  174. package/data/build/dist/client/peer-host-native-store-projection.d.ts +6 -2
  175. package/data/build/dist/client/peer-host-native-store-projection.d.ts.map +1 -1
  176. package/data/build/dist/client/peer-host-native-store-projection.js +308 -10
  177. package/data/build/dist/client/peer-host-native-store-projection.js.map +1 -1
  178. package/data/build/dist/client/peer-host-scoped-client.js +5 -5
  179. package/data/build/dist/client/peer-host-scoped-client.js.map +1 -1
  180. package/data/build/dist/client/peer-host-workspace-tab.d.ts +8 -0
  181. package/data/build/dist/client/peer-host-workspace-tab.d.ts.map +1 -1
  182. package/data/build/dist/client/peer-host-workspace-tab.js +48 -28
  183. package/data/build/dist/client/peer-host-workspace-tab.js.map +1 -1
  184. package/data/build/dist/client/provider-icon-assets.js +18 -0
  185. package/data/build/dist/client/provider-icon-assets.js.map +1 -1
  186. package/data/build/dist/client/provider-icons.d.ts +8 -2
  187. package/data/build/dist/client/provider-icons.d.ts.map +1 -1
  188. package/data/build/dist/client/provider-icons.js +28 -7
  189. package/data/build/dist/client/provider-icons.js.map +1 -1
  190. package/data/build/dist/client/pwa-install-prompt.d.ts +4 -1
  191. package/data/build/dist/client/pwa-install-prompt.d.ts.map +1 -1
  192. package/data/build/dist/client/pwa-install-prompt.js +8 -7
  193. package/data/build/dist/client/pwa-install-prompt.js.map +1 -1
  194. package/data/build/dist/client/quick-phrase-layout.d.ts +11 -0
  195. package/data/build/dist/client/quick-phrase-layout.d.ts.map +1 -1
  196. package/data/build/dist/client/quick-phrase-layout.js +20 -0
  197. package/data/build/dist/client/quick-phrase-layout.js.map +1 -1
  198. package/data/build/dist/client/quick-phrase-slot.d.ts.map +1 -1
  199. package/data/build/dist/client/quick-phrase-slot.js +20 -8
  200. package/data/build/dist/client/quick-phrase-slot.js.map +1 -1
  201. package/data/build/dist/client/remote-web-context.js +10 -6
  202. package/data/build/dist/client/remote-web-context.js.map +1 -1
  203. package/data/build/dist/client/service-tier.d.ts +54 -0
  204. package/data/build/dist/client/service-tier.d.ts.map +1 -0
  205. package/data/build/dist/client/service-tier.js +78 -0
  206. package/data/build/dist/client/service-tier.js.map +1 -0
  207. package/data/build/dist/client/session-changed-files-view.d.ts +8 -1
  208. package/data/build/dist/client/session-changed-files-view.d.ts.map +1 -1
  209. package/data/build/dist/client/session-changed-files-view.js +71 -28
  210. package/data/build/dist/client/session-changed-files-view.js.map +1 -1
  211. package/data/build/dist/client/settings-anchor.d.ts +9 -3
  212. package/data/build/dist/client/settings-anchor.d.ts.map +1 -1
  213. package/data/build/dist/client/settings-anchor.js +8 -2
  214. package/data/build/dist/client/settings-anchor.js.map +1 -1
  215. package/data/build/dist/client/settings-promo-styles.d.ts +28 -0
  216. package/data/build/dist/client/settings-promo-styles.d.ts.map +1 -0
  217. package/data/build/dist/client/settings-promo-styles.js +58 -0
  218. package/data/build/dist/client/settings-promo-styles.js.map +1 -0
  219. package/data/build/dist/client/settings-promo.d.ts +14 -0
  220. package/data/build/dist/client/settings-promo.d.ts.map +1 -0
  221. package/data/build/dist/client/settings-promo.js +68 -0
  222. package/data/build/dist/client/settings-promo.js.map +1 -0
  223. package/data/build/dist/client/settings-section.d.ts +2 -1
  224. package/data/build/dist/client/settings-section.d.ts.map +1 -1
  225. package/data/build/dist/client/settings-section.js +10 -7
  226. package/data/build/dist/client/settings-section.js.map +1 -1
  227. package/data/build/dist/client/subscription-slot.d.ts +4 -1
  228. package/data/build/dist/client/subscription-slot.d.ts.map +1 -1
  229. package/data/build/dist/client/subscription-slot.js +497 -56
  230. package/data/build/dist/client/subscription-slot.js.map +1 -1
  231. package/data/build/dist/client/terminal/model.d.ts +94 -4
  232. package/data/build/dist/client/terminal/model.d.ts.map +1 -1
  233. package/data/build/dist/client/terminal/model.js +392 -33
  234. package/data/build/dist/client/terminal/model.js.map +1 -1
  235. package/data/build/dist/client/terminal/recovery.d.ts +16 -1
  236. package/data/build/dist/client/terminal/recovery.d.ts.map +1 -1
  237. package/data/build/dist/client/terminal/recovery.js +101 -39
  238. package/data/build/dist/client/terminal/recovery.js.map +1 -1
  239. package/data/build/dist/client/terminal/styles.d.ts +10 -0
  240. package/data/build/dist/client/terminal/styles.d.ts.map +1 -1
  241. package/data/build/dist/client/terminal/styles.js +27 -3
  242. package/data/build/dist/client/terminal/styles.js.map +1 -1
  243. package/data/build/dist/client/terminal/ui.d.ts +3 -2
  244. package/data/build/dist/client/terminal/ui.d.ts.map +1 -1
  245. package/data/build/dist/client/terminal/ui.js +216 -103
  246. package/data/build/dist/client/terminal/ui.js.map +1 -1
  247. package/data/build/dist/client/terminal/xterm-view.d.ts +8 -1
  248. package/data/build/dist/client/terminal/xterm-view.d.ts.map +1 -1
  249. package/data/build/dist/client/terminal/xterm-view.js +394 -34
  250. package/data/build/dist/client/terminal/xterm-view.js.map +1 -1
  251. package/data/build/dist/client/workspace-session-archive-dom.d.ts +3 -0
  252. package/data/build/dist/client/workspace-session-archive-dom.d.ts.map +1 -1
  253. package/data/build/dist/client/workspace-session-archive-dom.js +131 -45
  254. package/data/build/dist/client/workspace-session-archive-dom.js.map +1 -1
  255. package/data/build/dist/client/workspace-session-logo-dom.d.ts +3 -0
  256. package/data/build/dist/client/workspace-session-logo-dom.d.ts.map +1 -1
  257. package/data/build/dist/client/workspace-session-logo-dom.js +3 -1
  258. package/data/build/dist/client/workspace-session-logo-dom.js.map +1 -1
  259. package/data/build/dist/client/workspace-session-visibility-dom.d.ts +3 -0
  260. package/data/build/dist/client/workspace-session-visibility-dom.d.ts.map +1 -1
  261. package/data/build/dist/client/workspace-session-visibility-dom.js +46 -17
  262. package/data/build/dist/client/workspace-session-visibility-dom.js.map +1 -1
  263. package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts +10 -0
  264. package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts.map +1 -1
  265. package/data/build/dist/dsh-capabilities/client/primitives-adapter.js +20 -0
  266. package/data/build/dist/dsh-capabilities/client/primitives-adapter.js.map +1 -1
  267. package/data/build/dist/host/browser-text.d.ts +30 -0
  268. package/data/build/dist/host/browser-text.d.ts.map +1 -0
  269. package/data/build/dist/host/browser-text.js +105 -0
  270. package/data/build/dist/host/browser-text.js.map +1 -0
  271. package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts +58 -0
  272. package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts.map +1 -0
  273. package/data/build/dist/host/cli-adapters/acp-cli-driver.js +271 -0
  274. package/data/build/dist/host/cli-adapters/acp-cli-driver.js.map +1 -0
  275. package/data/build/dist/host/cli-adapters/antigravity-driver.d.ts +30 -0
  276. package/data/build/dist/host/cli-adapters/antigravity-driver.d.ts.map +1 -0
  277. package/data/build/dist/host/cli-adapters/antigravity-driver.js +210 -0
  278. package/data/build/dist/host/cli-adapters/antigravity-driver.js.map +1 -0
  279. package/data/build/dist/host/cli-adapters/claude-driver.d.ts +28 -2
  280. package/data/build/dist/host/cli-adapters/claude-driver.d.ts.map +1 -1
  281. package/data/build/dist/host/cli-adapters/claude-driver.js +74 -4
  282. package/data/build/dist/host/cli-adapters/claude-driver.js.map +1 -1
  283. package/data/build/dist/host/cli-adapters/claude-model-options.d.ts.map +1 -1
  284. package/data/build/dist/host/cli-adapters/claude-model-options.js +22 -9
  285. package/data/build/dist/host/cli-adapters/claude-model-options.js.map +1 -1
  286. package/data/build/dist/host/cli-adapters/codebuddy-driver.d.ts +139 -0
  287. package/data/build/dist/host/cli-adapters/codebuddy-driver.d.ts.map +1 -0
  288. package/data/build/dist/host/cli-adapters/codebuddy-driver.js +1721 -0
  289. package/data/build/dist/host/cli-adapters/codebuddy-driver.js.map +1 -0
  290. package/data/build/dist/host/cli-adapters/codebuddy-subscription.d.ts +53 -0
  291. package/data/build/dist/host/cli-adapters/codebuddy-subscription.d.ts.map +1 -0
  292. package/data/build/dist/host/cli-adapters/codebuddy-subscription.js +778 -0
  293. package/data/build/dist/host/cli-adapters/codebuddy-subscription.js.map +1 -0
  294. package/data/build/dist/host/cli-adapters/codex-driver.d.ts +22 -0
  295. package/data/build/dist/host/cli-adapters/codex-driver.d.ts.map +1 -1
  296. package/data/build/dist/host/cli-adapters/codex-driver.js +254 -7
  297. package/data/build/dist/host/cli-adapters/codex-driver.js.map +1 -1
  298. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +43 -3
  299. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts.map +1 -1
  300. package/data/build/dist/host/cli-adapters/command-code-driver.js +681 -74
  301. package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
  302. package/data/build/dist/host/cli-adapters/command-code-history.d.ts +147 -0
  303. package/data/build/dist/host/cli-adapters/command-code-history.d.ts.map +1 -0
  304. package/data/build/dist/host/cli-adapters/command-code-history.js +659 -0
  305. package/data/build/dist/host/cli-adapters/command-code-history.js.map +1 -0
  306. package/data/build/dist/host/cli-adapters/cursor-driver.d.ts +12 -0
  307. package/data/build/dist/host/cli-adapters/cursor-driver.d.ts.map +1 -0
  308. package/data/build/dist/host/cli-adapters/cursor-driver.js +20 -0
  309. package/data/build/dist/host/cli-adapters/cursor-driver.js.map +1 -0
  310. package/data/build/dist/host/cli-adapters/custom-upstream-classifier.d.ts +67 -0
  311. package/data/build/dist/host/cli-adapters/custom-upstream-classifier.d.ts.map +1 -0
  312. package/data/build/dist/host/cli-adapters/custom-upstream-classifier.js +169 -0
  313. package/data/build/dist/host/cli-adapters/custom-upstream-classifier.js.map +1 -0
  314. package/data/build/dist/host/cli-adapters/delegate-dispatch.d.ts +48 -0
  315. package/data/build/dist/host/cli-adapters/delegate-dispatch.d.ts.map +1 -0
  316. package/data/build/dist/host/cli-adapters/delegate-dispatch.js +111 -0
  317. package/data/build/dist/host/cli-adapters/delegate-dispatch.js.map +1 -0
  318. package/data/build/dist/host/cli-adapters/delegation-authorization.d.ts +19 -0
  319. package/data/build/dist/host/cli-adapters/delegation-authorization.d.ts.map +1 -0
  320. package/data/build/dist/host/cli-adapters/delegation-authorization.js +49 -0
  321. package/data/build/dist/host/cli-adapters/delegation-authorization.js.map +1 -0
  322. package/data/build/dist/host/cli-adapters/delegation-mention-rewrite.d.ts +34 -0
  323. package/data/build/dist/host/cli-adapters/delegation-mention-rewrite.d.ts.map +1 -0
  324. package/data/build/dist/host/cli-adapters/delegation-mention-rewrite.js +121 -0
  325. package/data/build/dist/host/cli-adapters/delegation-mention-rewrite.js.map +1 -0
  326. package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts +32 -0
  327. package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts.map +1 -0
  328. package/data/build/dist/host/cli-adapters/desktop-app-runtime.js +121 -0
  329. package/data/build/dist/host/cli-adapters/desktop-app-runtime.js.map +1 -0
  330. package/data/build/dist/host/cli-adapters/driver.d.ts +6 -0
  331. package/data/build/dist/host/cli-adapters/driver.d.ts.map +1 -1
  332. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts.map +1 -1
  333. package/data/build/dist/host/cli-adapters/dsh-message-projector.js +5 -4
  334. package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
  335. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.d.ts +16 -0
  336. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.d.ts.map +1 -0
  337. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js +73 -0
  338. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js.map +1 -0
  339. package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
  340. package/data/build/dist/host/cli-adapters/feature.js +459 -26
  341. package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
  342. package/data/build/dist/host/cli-adapters/gemini-driver.d.ts.map +1 -1
  343. package/data/build/dist/host/cli-adapters/gemini-driver.js +21 -5
  344. package/data/build/dist/host/cli-adapters/gemini-driver.js.map +1 -1
  345. package/data/build/dist/host/cli-adapters/grok-driver.d.ts.map +1 -1
  346. package/data/build/dist/host/cli-adapters/grok-driver.js +24 -7
  347. package/data/build/dist/host/cli-adapters/grok-driver.js.map +1 -1
  348. package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts +22 -6
  349. package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts.map +1 -1
  350. package/data/build/dist/host/cli-adapters/json-rpc-process.js +118 -21
  351. package/data/build/dist/host/cli-adapters/json-rpc-process.js.map +1 -1
  352. package/data/build/dist/host/cli-adapters/kimi-driver.d.ts.map +1 -1
  353. package/data/build/dist/host/cli-adapters/kimi-driver.js +25 -4
  354. package/data/build/dist/host/cli-adapters/kimi-driver.js.map +1 -1
  355. package/data/build/dist/host/cli-adapters/kiro-driver.d.ts +12 -0
  356. package/data/build/dist/host/cli-adapters/kiro-driver.d.ts.map +1 -0
  357. package/data/build/dist/host/cli-adapters/kiro-driver.js +18 -0
  358. package/data/build/dist/host/cli-adapters/kiro-driver.js.map +1 -0
  359. package/data/build/dist/host/cli-adapters/legacy-session-adapter.d.ts +11 -2
  360. package/data/build/dist/host/cli-adapters/legacy-session-adapter.d.ts.map +1 -1
  361. package/data/build/dist/host/cli-adapters/legacy-session-adapter.js +26 -6
  362. package/data/build/dist/host/cli-adapters/legacy-session-adapter.js.map +1 -1
  363. package/data/build/dist/host/cli-adapters/mcode-catalog.d.ts +23 -0
  364. package/data/build/dist/host/cli-adapters/mcode-catalog.d.ts.map +1 -0
  365. package/data/build/dist/host/cli-adapters/mcode-catalog.js +120 -0
  366. package/data/build/dist/host/cli-adapters/mcode-catalog.js.map +1 -0
  367. package/data/build/dist/host/cli-adapters/mcode-driver.d.ts +56 -0
  368. package/data/build/dist/host/cli-adapters/mcode-driver.d.ts.map +1 -0
  369. package/data/build/dist/host/cli-adapters/mcode-driver.js +544 -0
  370. package/data/build/dist/host/cli-adapters/mcode-driver.js.map +1 -0
  371. package/data/build/dist/host/cli-adapters/model-catalog.d.ts +35 -5
  372. package/data/build/dist/host/cli-adapters/model-catalog.d.ts.map +1 -1
  373. package/data/build/dist/host/cli-adapters/model-catalog.js +213 -8
  374. package/data/build/dist/host/cli-adapters/model-catalog.js.map +1 -1
  375. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts +81 -0
  376. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts.map +1 -0
  377. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js +299 -0
  378. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js.map +1 -0
  379. package/data/build/dist/host/cli-adapters/native-subagent-holder.d.ts +4 -0
  380. package/data/build/dist/host/cli-adapters/native-subagent-holder.d.ts.map +1 -0
  381. package/data/build/dist/host/cli-adapters/native-subagent-holder.js +4 -0
  382. package/data/build/dist/host/cli-adapters/native-subagent-holder.js.map +1 -0
  383. package/data/build/dist/host/cli-adapters/native-team-proxy.js +18 -15
  384. package/data/build/dist/host/cli-adapters/native-team-proxy.js.map +1 -1
  385. package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts +57 -0
  386. package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts.map +1 -0
  387. package/data/build/dist/host/cli-adapters/native-team-subagent.js +126 -0
  388. package/data/build/dist/host/cli-adapters/native-team-subagent.js.map +1 -0
  389. package/data/build/dist/host/cli-adapters/new-api-subscription.d.ts +75 -0
  390. package/data/build/dist/host/cli-adapters/new-api-subscription.d.ts.map +1 -0
  391. package/data/build/dist/host/cli-adapters/new-api-subscription.js +959 -0
  392. package/data/build/dist/host/cli-adapters/new-api-subscription.js.map +1 -0
  393. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts.map +1 -1
  394. package/data/build/dist/host/cli-adapters/opencode-driver.js +22 -10
  395. package/data/build/dist/host/cli-adapters/opencode-driver.js.map +1 -1
  396. package/data/build/dist/host/cli-adapters/pi-driver.js +24 -7
  397. package/data/build/dist/host/cli-adapters/pi-driver.js.map +1 -1
  398. package/data/build/dist/host/cli-adapters/provider-subscription.d.ts +41 -4
  399. package/data/build/dist/host/cli-adapters/provider-subscription.d.ts.map +1 -1
  400. package/data/build/dist/host/cli-adapters/provider-subscription.js +254 -40
  401. package/data/build/dist/host/cli-adapters/provider-subscription.js.map +1 -1
  402. package/data/build/dist/host/cli-adapters/qoder-driver.d.ts +71 -0
  403. package/data/build/dist/host/cli-adapters/qoder-driver.d.ts.map +1 -0
  404. package/data/build/dist/host/cli-adapters/qoder-driver.js +553 -0
  405. package/data/build/dist/host/cli-adapters/qoder-driver.js.map +1 -0
  406. package/data/build/dist/host/cli-adapters/qoder-subscription.d.ts +31 -0
  407. package/data/build/dist/host/cli-adapters/qoder-subscription.d.ts.map +1 -0
  408. package/data/build/dist/host/cli-adapters/qoder-subscription.js +178 -0
  409. package/data/build/dist/host/cli-adapters/qoder-subscription.js.map +1 -0
  410. package/data/build/dist/host/cli-adapters/registry-holder.d.ts +4 -0
  411. package/data/build/dist/host/cli-adapters/registry-holder.d.ts.map +1 -0
  412. package/data/build/dist/host/cli-adapters/registry-holder.js +9 -0
  413. package/data/build/dist/host/cli-adapters/registry-holder.js.map +1 -0
  414. package/data/build/dist/host/cli-adapters/registry.d.ts +54 -2
  415. package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
  416. package/data/build/dist/host/cli-adapters/registry.js +224 -18
  417. package/data/build/dist/host/cli-adapters/registry.js.map +1 -1
  418. package/data/build/dist/host/cli-adapters/session-store.d.ts +10 -1
  419. package/data/build/dist/host/cli-adapters/session-store.d.ts.map +1 -1
  420. package/data/build/dist/host/cli-adapters/session-store.js +60 -6
  421. package/data/build/dist/host/cli-adapters/session-store.js.map +1 -1
  422. package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts +16 -1
  423. package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts.map +1 -1
  424. package/data/build/dist/host/cli-adapters/standard-stream-driver.js +150 -26
  425. package/data/build/dist/host/cli-adapters/standard-stream-driver.js.map +1 -1
  426. package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +10 -1
  427. package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts.map +1 -1
  428. package/data/build/dist/host/cli-adapters/stream-normalizer.js +23 -0
  429. package/data/build/dist/host/cli-adapters/stream-normalizer.js.map +1 -1
  430. package/data/build/dist/host/cli-adapters/subagent-tool.d.ts +5 -0
  431. package/data/build/dist/host/cli-adapters/subagent-tool.d.ts.map +1 -0
  432. package/data/build/dist/host/cli-adapters/subagent-tool.js +112 -0
  433. package/data/build/dist/host/cli-adapters/subagent-tool.js.map +1 -0
  434. package/data/build/dist/host/cli-adapters/zcode-driver.d.ts +57 -0
  435. package/data/build/dist/host/cli-adapters/zcode-driver.d.ts.map +1 -0
  436. package/data/build/dist/host/cli-adapters/zcode-driver.js +843 -0
  437. package/data/build/dist/host/cli-adapters/zcode-driver.js.map +1 -0
  438. package/data/build/dist/host/cli-adapters/zcode-subscription.d.ts +28 -0
  439. package/data/build/dist/host/cli-adapters/zcode-subscription.d.ts.map +1 -0
  440. package/data/build/dist/host/cli-adapters/zcode-subscription.js +212 -0
  441. package/data/build/dist/host/cli-adapters/zcode-subscription.js.map +1 -0
  442. package/data/build/dist/host/cli-bridge/bridge-holder.d.ts +27 -0
  443. package/data/build/dist/host/cli-bridge/bridge-holder.d.ts.map +1 -0
  444. package/data/build/dist/host/cli-bridge/bridge-holder.js +51 -0
  445. package/data/build/dist/host/cli-bridge/bridge-holder.js.map +1 -0
  446. package/data/build/dist/host/cli-bridge/bridge-server.d.ts +39 -0
  447. package/data/build/dist/host/cli-bridge/bridge-server.d.ts.map +1 -0
  448. package/data/build/dist/host/cli-bridge/bridge-server.js +140 -0
  449. package/data/build/dist/host/cli-bridge/bridge-server.js.map +1 -0
  450. package/data/build/dist/host/cli-bridge/command-code-mod.d.ts +29 -0
  451. package/data/build/dist/host/cli-bridge/command-code-mod.d.ts.map +1 -0
  452. package/data/build/dist/host/cli-bridge/command-code-mod.js +91 -0
  453. package/data/build/dist/host/cli-bridge/command-code-mod.js.map +1 -0
  454. package/data/build/dist/host/cli-bridge/dispatch.d.ts +19 -0
  455. package/data/build/dist/host/cli-bridge/dispatch.d.ts.map +1 -0
  456. package/data/build/dist/host/cli-bridge/dispatch.js +128 -0
  457. package/data/build/dist/host/cli-bridge/dispatch.js.map +1 -0
  458. package/data/build/dist/host/cli-bridge/injections.d.ts +28 -0
  459. package/data/build/dist/host/cli-bridge/injections.d.ts.map +1 -0
  460. package/data/build/dist/host/cli-bridge/injections.js +131 -0
  461. package/data/build/dist/host/cli-bridge/injections.js.map +1 -0
  462. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.d.ts +8 -0
  463. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.d.ts.map +1 -0
  464. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js +170 -0
  465. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js.map +1 -0
  466. package/data/build/dist/host/features/lan-access-dsh.d.ts.map +1 -1
  467. package/data/build/dist/host/features/lan-access-dsh.js +6 -2
  468. package/data/build/dist/host/features/lan-access-dsh.js.map +1 -1
  469. package/data/build/dist/host/features/peer-host.d.ts +21 -1
  470. package/data/build/dist/host/features/peer-host.d.ts.map +1 -1
  471. package/data/build/dist/host/features/peer-host.js +176 -31
  472. package/data/build/dist/host/features/peer-host.js.map +1 -1
  473. package/data/build/dist/host/features/types.d.ts +2 -0
  474. package/data/build/dist/host/features/types.d.ts.map +1 -1
  475. package/data/build/dist/host/index.d.ts +15 -1
  476. package/data/build/dist/host/index.d.ts.map +1 -1
  477. package/data/build/dist/host/index.js +48 -2
  478. package/data/build/dist/host/index.js.map +1 -1
  479. package/data/build/dist/host/lan-access-dsh.d.ts +7 -1
  480. package/data/build/dist/host/lan-access-dsh.d.ts.map +1 -1
  481. package/data/build/dist/host/lan-access-dsh.js +95 -19
  482. package/data/build/dist/host/lan-access-dsh.js.map +1 -1
  483. package/data/build/dist/host/login-attempt-guard.d.ts +55 -0
  484. package/data/build/dist/host/login-attempt-guard.d.ts.map +1 -0
  485. package/data/build/dist/host/login-attempt-guard.js +201 -0
  486. package/data/build/dist/host/login-attempt-guard.js.map +1 -0
  487. package/data/build/dist/host/modules/peer-host/host-api-proxy-service.d.ts +3 -0
  488. package/data/build/dist/host/modules/peer-host/host-api-proxy-service.d.ts.map +1 -1
  489. package/data/build/dist/host/modules/peer-host/host-api-proxy-service.js +2 -0
  490. package/data/build/dist/host/modules/peer-host/host-api-proxy-service.js.map +1 -1
  491. package/data/build/dist/host/modules/peer-host/peer-host-aggregate-service.d.ts +1 -0
  492. package/data/build/dist/host/modules/peer-host/peer-host-aggregate-service.d.ts.map +1 -1
  493. package/data/build/dist/host/modules/peer-host/peer-host-aggregate-service.js +1 -0
  494. package/data/build/dist/host/modules/peer-host/peer-host-aggregate-service.js.map +1 -1
  495. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.d.ts +1 -1
  496. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.d.ts.map +1 -1
  497. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.js +9 -1
  498. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.js.map +1 -1
  499. package/data/build/dist/host/modules/peer-host/peer-host-native-transport.d.ts +8 -0
  500. package/data/build/dist/host/modules/peer-host/peer-host-native-transport.d.ts.map +1 -1
  501. package/data/build/dist/host/modules/peer-host/peer-host-native-transport.js +9 -0
  502. package/data/build/dist/host/modules/peer-host/peer-host-native-transport.js.map +1 -1
  503. package/data/build/dist/host/modules/peer-host/peer-host-remote-summary-source.d.ts +7 -0
  504. package/data/build/dist/host/modules/peer-host/peer-host-remote-summary-source.d.ts.map +1 -1
  505. package/data/build/dist/host/modules/peer-host/peer-host-remote-summary-source.js +31 -3
  506. package/data/build/dist/host/modules/peer-host/peer-host-remote-summary-source.js.map +1 -1
  507. package/data/build/dist/host/modules/peer-host/peer-host-virtual-registry.d.ts +2 -0
  508. package/data/build/dist/host/modules/peer-host/peer-host-virtual-registry.d.ts.map +1 -1
  509. package/data/build/dist/host/modules/peer-host/peer-host-virtual-registry.js +26 -7
  510. package/data/build/dist/host/modules/peer-host/peer-host-virtual-registry.js.map +1 -1
  511. package/data/build/dist/host/modules/pwa/pwa-assets.d.ts +6 -4
  512. package/data/build/dist/host/modules/pwa/pwa-assets.d.ts.map +1 -1
  513. package/data/build/dist/host/modules/pwa/pwa-assets.js +11 -9
  514. package/data/build/dist/host/modules/pwa/pwa-assets.js.map +1 -1
  515. package/data/build/dist/host/modules/pwa/pwa-session-notifications.d.ts +3 -0
  516. package/data/build/dist/host/modules/pwa/pwa-session-notifications.d.ts.map +1 -1
  517. package/data/build/dist/host/modules/pwa/pwa-session-notifications.js +6 -4
  518. package/data/build/dist/host/modules/pwa/pwa-session-notifications.js.map +1 -1
  519. package/data/build/dist/host/native-session-bridge.d.ts.map +1 -1
  520. package/data/build/dist/host/native-session-bridge.js +106 -59
  521. package/data/build/dist/host/native-session-bridge.js.map +1 -1
  522. package/data/build/dist/host/rpc.js +8 -2
  523. package/data/build/dist/host/rpc.js.map +1 -1
  524. package/data/build/dist/host/settings.d.ts.map +1 -1
  525. package/data/build/dist/host/settings.js +14 -4
  526. package/data/build/dist/host/settings.js.map +1 -1
  527. package/data/build/dist/host/terminal/backends/local-pty-backend.d.ts.map +1 -1
  528. package/data/build/dist/host/terminal/backends/local-pty-backend.js +14 -0
  529. package/data/build/dist/host/terminal/backends/local-pty-backend.js.map +1 -1
  530. package/data/build/dist/host/terminal/backends/tmux-backend.d.ts +40 -1
  531. package/data/build/dist/host/terminal/backends/tmux-backend.d.ts.map +1 -1
  532. package/data/build/dist/host/terminal/backends/tmux-backend.js +291 -18
  533. package/data/build/dist/host/terminal/backends/tmux-backend.js.map +1 -1
  534. package/data/build/dist/host/terminal/runtime-adapter.d.ts +32 -0
  535. package/data/build/dist/host/terminal/runtime-adapter.d.ts.map +1 -1
  536. package/data/build/dist/host/terminal/runtime-adapter.js +8 -0
  537. package/data/build/dist/host/terminal/runtime-adapter.js.map +1 -1
  538. package/data/build/dist/host/terminal/runtime-manager.d.ts +3 -0
  539. package/data/build/dist/host/terminal/runtime-manager.d.ts.map +1 -1
  540. package/data/build/dist/host/terminal/runtime-manager.js +92 -4
  541. package/data/build/dist/host/terminal/runtime-manager.js.map +1 -1
  542. package/data/build/dist/host/terminal/terminal-controller.d.ts.map +1 -1
  543. package/data/build/dist/host/terminal/terminal-controller.js +58 -6
  544. package/data/build/dist/host/terminal/terminal-controller.js.map +1 -1
  545. package/data/build/dist/host/terminal/terminal-process-service.d.ts.map +1 -1
  546. package/data/build/dist/host/terminal/terminal-process-service.js +12 -2
  547. package/data/build/dist/host/terminal/terminal-process-service.js.map +1 -1
  548. package/data/build/dist/host/terminal/terminal-service.d.ts +41 -4
  549. package/data/build/dist/host/terminal/terminal-service.d.ts.map +1 -1
  550. package/data/build/dist/host/terminal/terminal-service.js +551 -61
  551. package/data/build/dist/host/terminal/terminal-service.js.map +1 -1
  552. package/data/build/dist/index.d.ts +2 -2
  553. package/data/build/dist/index.d.ts.map +1 -1
  554. package/data/build/dist/index.js +2 -2
  555. package/data/build/dist/index.js.map +1 -1
  556. package/data/build/dist/shared/contracts/cli-adapter.d.ts +69 -2
  557. package/data/build/dist/shared/contracts/cli-adapter.d.ts.map +1 -1
  558. package/data/build/dist/shared/contracts/config.d.ts +63 -10
  559. package/data/build/dist/shared/contracts/config.d.ts.map +1 -1
  560. package/data/build/dist/shared/contracts/config.js +57 -5
  561. package/data/build/dist/shared/contracts/config.js.map +1 -1
  562. package/data/build/dist/shared/contracts/peer-host.d.ts +2 -0
  563. package/data/build/dist/shared/contracts/peer-host.d.ts.map +1 -1
  564. package/data/build/dist/shared/contracts/peer-host.js.map +1 -1
  565. package/data/build/dist/shared/contracts/subscription.d.ts +20 -1
  566. package/data/build/dist/shared/contracts/subscription.d.ts.map +1 -1
  567. package/data/build/dist/shared/contracts/subscription.js.map +1 -1
  568. package/data/build/dist/shared/contracts/terminal.d.ts +8 -1
  569. package/data/build/dist/shared/contracts/terminal.d.ts.map +1 -1
  570. package/data/build/dist/shared/contracts/version.d.ts +1 -1
  571. package/data/build/dist/shared/contracts/version.d.ts.map +1 -1
  572. package/data/build/dist/shared/contracts/version.js +1 -1
  573. package/data/build/dist/shared/contracts/version.js.map +1 -1
  574. package/data/build/dist/shared/debug.d.ts +8 -0
  575. package/data/build/dist/shared/debug.d.ts.map +1 -1
  576. package/data/build/dist/shared/debug.js +43 -7
  577. package/data/build/dist/shared/debug.js.map +1 -1
  578. package/data/build/dist/shared/delegation-carrier.d.ts +24 -0
  579. package/data/build/dist/shared/delegation-carrier.d.ts.map +1 -0
  580. package/data/build/dist/shared/delegation-carrier.js +111 -0
  581. package/data/build/dist/shared/delegation-carrier.js.map +1 -0
  582. package/data/build/dist/shared/index.d.ts +3 -3
  583. package/data/build/dist/shared/index.d.ts.map +1 -1
  584. package/data/build/dist/shared/index.js +2 -2
  585. package/data/build/dist/shared/index.js.map +1 -1
  586. package/data/build/dist/shared/terminal-input.d.ts +8 -0
  587. package/data/build/dist/shared/terminal-input.d.ts.map +1 -0
  588. package/data/build/dist/shared/terminal-input.js +10 -0
  589. package/data/build/dist/shared/terminal-input.js.map +1 -0
  590. package/data/build/dist/transport/debug.d.ts +7 -0
  591. package/data/build/dist/transport/debug.d.ts.map +1 -1
  592. package/data/build/dist/transport/debug.js +33 -5
  593. package/data/build/dist/transport/debug.js.map +1 -1
  594. package/data/build/dist/transport/index.d.ts +1 -1
  595. package/data/build/dist/transport/index.d.ts.map +1 -1
  596. package/data/build/dist/transport/index.js +1 -1
  597. package/data/build/dist/transport/index.js.map +1 -1
  598. package/data/build/dist/typert.host.js +1 -1
  599. package/data/build/dist/typert.host.js.map +1 -1
  600. package/package.json +3 -1
  601. package/profile/README.md +2 -2
  602. package/profile/package.json +2 -2
  603. package/profile/version.json +1 -1
  604. package/version.json +1 -1
@@ -1,12 +1,15 @@
1
1
  import { spawn, spawnSync } from 'node:child_process';
2
- import { copyFileSync, existsSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
3
- import { homedir, tmpdir } from 'node:os';
4
- import { basename, dirname, join } from 'node:path';
2
+ import { closeSync, copyFileSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, readSync, realpathSync, statSync, writeFileSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { basename, dirname, join, relative, resolve } from 'node:path';
5
5
  import readline from 'node:readline';
6
6
  import { firstToolText, serializeToolValue } from './tool-observation.js';
7
7
  import { usageChunk } from './rpc-driver-utils.js';
8
8
  import { commandEnvironment, resolveCommandPath, terminateChildProcess } from './process-utils.js';
9
9
  import { promptWithAttachmentPaths } from './attachment-utils.js';
10
+ import { commandCodeBridgeArgs, commandCodeBridgeEnvironment } from '../cli-bridge/injections.js';
11
+ import { getSubagentBridge } from '../cli-bridge/bridge-holder.js';
12
+ import { CommandCodeHistory, } from './command-code-history.js';
10
13
  const WINDOWS = process.platform === 'win32';
11
14
  const COMMAND_CODE_BINARIES = WINDOWS
12
15
  ? ['command-code', 'commandcode', 'cmdc']
@@ -91,6 +94,60 @@ const CATALOG_EFFORTS = new Map([
91
94
  ['xai/grok-4.5', ['low', 'medium', 'high']],
92
95
  ['xai/grok-4.7', ['low', 'medium', 'high', 'xhigh']],
93
96
  ]);
97
+ /**
98
+ * 按模型名的最后一段回退查找思考强度。
99
+ *
100
+ * BYOK 提供者的模型 id 带自定义前缀(如 `mcgrox/deepseek-v4.1-flash`),
101
+ * 而 CATALOG_EFFORTS 的键是 Command Code 内置目录 id(`deepseek/deepseek-v4.1-flash`),
102
+ * 直接查表会落空,导致菜单只剩 Default。表内 77 个键的最后一段互不重复,
103
+ * 因此可以安全地按末段匹配;命中多个时按歧义处理并返回空,避免误判。
104
+ */
105
+ function catalogEffortsFor(id) {
106
+ const key = id.toLowerCase();
107
+ const direct = CATALOG_EFFORTS.get(key);
108
+ if (direct !== undefined)
109
+ return direct;
110
+ const bare = key.includes('/') ? key.slice(key.lastIndexOf('/') + 1) : key;
111
+ if (bare === key)
112
+ return [];
113
+ let matched;
114
+ for (const [candidate, efforts] of CATALOG_EFFORTS) {
115
+ if (!candidate.endsWith(`/${bare}`))
116
+ continue;
117
+ if (matched !== undefined)
118
+ return []; // 末段歧义,宁可不给强度也不猜
119
+ matched = efforts;
120
+ }
121
+ return matched ?? [];
122
+ }
123
+ /**
124
+ * 读取 BYOK 提供者在 `~/.commandcode/providers.json` 里声明的思考强度。
125
+ *
126
+ * 这是 BYOK 模型强度的权威来源:用户在 providers.json 的模型条目上写
127
+ * `reasoningEfforts: [...]`,Command Code 据此校验 `--effort`。内置目录查不到
128
+ * 的自定义模型只能从这里拿到强度。键为 `提供者/模型` 小写形式,空 Map 表示无声明。
129
+ */
130
+ function readDeclaredEfforts(homeDirectory) {
131
+ const declared = new Map();
132
+ const config = readJson(join(homeDirectory, 'providers.json'));
133
+ if (config === null)
134
+ return declared;
135
+ const providers = isRecord(config.provider) ? config.provider : isRecord(config.providers) ? config.providers : null;
136
+ if (providers === null)
137
+ return declared;
138
+ for (const [providerId, provider] of Object.entries(providers)) {
139
+ if (!isRecord(provider) || !isRecord(provider.models))
140
+ continue;
141
+ for (const [modelName, entry] of Object.entries(provider.models)) {
142
+ if (!isRecord(entry) || !Array.isArray(entry.reasoningEfforts))
143
+ continue;
144
+ const efforts = entry.reasoningEfforts.filter((value) => typeof value === 'string' && VALID_EFFORTS.has(value));
145
+ if (efforts.length > 0)
146
+ declared.set(`${providerId}/${modelName}`.toLowerCase(), efforts);
147
+ }
148
+ }
149
+ return declared;
150
+ }
94
151
  /**
95
152
  * CLI 的 `--max-turns` 默认只有 100,复杂任务经常在半途被截断。
96
153
  *
@@ -101,8 +158,22 @@ const DEFAULT_AUTO_CONTINUE_ATTEMPTS = 3;
101
158
  const AUTO_CONTINUE_PROMPT = '继续';
102
159
  /** CLI 在 -p 模式撞到 --max-turns 时的退出码(MAX_TURNS_REACHED)。 */
103
160
  const COMMAND_CODE_MAX_TURNS_EXIT_CODE = 8;
161
+ /** 发送 SIGINT 后等待 CLI 自己收尾的时间;超时再强制清理进程树。 */
162
+ const COMMAND_CODE_INTERRUPT_GRACE_MS = 1_500;
163
+ /** 将 DSH 权限状态映射为 Command Code 参数;未知状态保持 CLI 默认审批。 */
164
+ function commandCodePermissionArgs(permission) {
165
+ if (permission?.sandboxMode === 'danger-full-access' && permission.approvalPolicy === 'never')
166
+ return ['--yolo'];
167
+ if (permission?.sandboxMode === 'workspace-write' && permission.approvalPolicy === 'never')
168
+ return ['--permission-mode', 'accept-edits'];
169
+ if (permission?.sandboxMode === 'read-only')
170
+ return ['--plan'];
171
+ return [];
172
+ }
104
173
  /**
105
- * Command Code 驱动:沿用 `--session + -p + --output-format json` 的 NDJSON 事件流。
174
+ * Command Code 驱动:使用 `--session` 建立首轮输入,随后绑定 Provider 原生会话并用
175
+ * `--resume + -p + --output-format json` 续接。首轮历史只作为 CLI 的输入快照,不能替代
176
+ * Provider 自己维护的 canonical transcript。
106
177
  *
107
178
  * 与 Codex 驱动保持同一套消息优化:正文/推理增量携带 assistant 消息身份,工具完成后
108
179
  * 的下一条 assistant 消息之前结束当前 DSH step,因此一个 Provider 运行会被切成多个
@@ -114,7 +185,7 @@ export class CommandCodeDriver {
114
185
  id: 'command-code',
115
186
  name: 'Command Code',
116
187
  protocol: 'command',
117
- capabilities: ['models', 'stream', 'resume', 'interrupt', 'tool-events', 'reasoning', 'usage'],
188
+ capabilities: ['models', 'stream', 'resume', 'interrupt', 'tool-events', 'reasoning', 'usage', 'history'],
118
189
  };
119
190
  /** 驱动自己维护 Provider turn 边界,Host 可以把工具边界映射为 DSH step。 */
120
191
  supportsSegmentedTurns = true;
@@ -125,6 +196,7 @@ export class CommandCodeDriver {
125
196
  maxTurns;
126
197
  autoContinueMaxAttempts;
127
198
  autoContinuePrompt;
199
+ history;
128
200
  cachedBinary = null;
129
201
  cachedEnvironment;
130
202
  processes = new Set();
@@ -137,6 +209,54 @@ export class CommandCodeDriver {
137
209
  this.maxTurns = normalizePositiveInteger(options.maxTurns ?? readOptionalIntegerEnv('CODINGNS_COMMAND_CODE_MAX_TURNS'), DEFAULT_MAX_TURNS);
138
210
  this.autoContinueMaxAttempts = normalizeNonNegativeInteger(options.autoContinueMaxAttempts ?? readOptionalIntegerEnv('CODINGNS_COMMAND_CODE_AUTO_CONTINUE_ATTEMPTS'), DEFAULT_AUTO_CONTINUE_ATTEMPTS);
139
211
  this.autoContinuePrompt = options.autoContinuePrompt?.trim() || AUTO_CONTINUE_PROMPT;
212
+ const readStatus = options.readStatus ?? ((workspacePath) => this.readCommandCodeStatus(workspacePath));
213
+ this.history = new CommandCodeHistory(this.homeDirectory, { readStatus });
214
+ }
215
+ /** 读取 Command Code 原生会话目录,供 Provider History 层使用。 */
216
+ detectSessions(workspacePath) {
217
+ return this.history.detectSessions(workspacePath);
218
+ }
219
+ detectSessionsDetailed(workspacePath) {
220
+ return this.history.detectSessionsDetailed(workspacePath);
221
+ }
222
+ startSession(workspacePath, options = {}) {
223
+ return this.history.startSession(workspacePath, options);
224
+ }
225
+ resumeSession(providerSessionId, rawStoreRef) {
226
+ return this.history.resumeSession(providerSessionId, rawStoreRef);
227
+ }
228
+ sendMessage(providerSessionId, rawStoreRef, content) {
229
+ return this.history.sendMessage(providerSessionId, rawStoreRef, content);
230
+ }
231
+ readSessionHistory(providerSessionId, rawStoreRef, cursor, limit, direction = 'forward') {
232
+ return this.history.readSessionHistory(providerSessionId, rawStoreRef, cursor, limit, direction);
233
+ }
234
+ readSessionHistoryDelta(providerSessionId, rawStoreRef, cursor, limit, direction = 'forward') {
235
+ return this.history.readSessionHistoryDelta(providerSessionId, rawStoreRef, cursor, limit, direction);
236
+ }
237
+ subscribeSession(providerSessionId, rawStoreRef, cursor, limit, onEvent) {
238
+ return this.history.subscribeSession(providerSessionId, rawStoreRef, cursor, limit, onEvent);
239
+ }
240
+ readSessionTitle(providerSessionId, rawStoreRef) {
241
+ return this.history.readSessionTitle(providerSessionId, rawStoreRef);
242
+ }
243
+ renameSessionTitle(providerSessionId, rawStoreRef, title) {
244
+ return this.history.renameSessionTitle(providerSessionId, rawStoreRef, title);
245
+ }
246
+ updateSessionArchiveState(providerSessionId, rawStoreRef, isArchived) {
247
+ return this.history.updateSessionArchiveState(providerSessionId, rawStoreRef, isArchived);
248
+ }
249
+ deleteSession(providerSessionId, rawStoreRef) {
250
+ return this.history.deleteSession(providerSessionId, rawStoreRef);
251
+ }
252
+ readContextUsage(providerSessionId, rawStoreRef) {
253
+ return this.history.readContextUsage(providerSessionId, rawStoreRef);
254
+ }
255
+ readSessionStats(providerSessionId, rawStoreRef) {
256
+ return this.history.readSessionStats(providerSessionId, rawStoreRef);
257
+ }
258
+ forkSession(providerSessionId, workspacePath, options) {
259
+ return this.history.forkSession(providerSessionId, workspacePath, options);
140
260
  }
141
261
  async detect() {
142
262
  for (const command of this.binaries) {
@@ -187,6 +307,7 @@ export class CommandCodeDriver {
187
307
  return emptyCatalog();
188
308
  }
189
309
  const groups = [];
310
+ const declared = readDeclaredEfforts(this.homeDirectory);
190
311
  let currentGroup;
191
312
  for (const rawLine of stdout.split(/\r?\n/u)) {
192
313
  const line = rawLine.trim();
@@ -202,20 +323,101 @@ export class CommandCodeDriver {
202
323
  continue;
203
324
  const id = match[1];
204
325
  const description = match[2].trim();
205
- currentGroup.models.push({ id, name: id, ...(description ? { description } : {}), efforts: CATALOG_EFFORTS.get(id.toLowerCase()) ?? [] });
326
+ // BYOK 模型以 providers.json 的声明为准,内置目录作为回退;
327
+ // 目录回退按末段匹配,使 `mcgrox/deepseek-v4.1-flash` 也能拿到内置强度。
328
+ const efforts = declared.get(id.toLowerCase()) ?? catalogEffortsFor(id);
329
+ currentGroup.models.push({ id, name: id, ...(description ? { description } : {}), efforts });
206
330
  }
207
331
  const config = readJson(join(this.homeDirectory, 'config.json'));
208
- const currentModel = typeof config?.model === 'string' ? config.model : null;
332
+ // status --json 反映 CLI 当前真实模型;配置文件可能仍是旧值,优先使用运行时状态。
333
+ let statusModel = null;
334
+ try {
335
+ const status = this.runSpawnSync(detection.command, ['status', '--json'], { encoding: 'utf8', timeout: 5_000, windowsHide: true, shell: WINDOWS, ...(this.cachedEnvironment === undefined ? {} : { env: this.cachedEnvironment }) });
336
+ const parsed = parseJson(status.stdout ?? '');
337
+ statusModel = typeof parsed?.model === 'string' && parsed.model.trim() !== '' ? parsed.model.trim() : null;
338
+ }
339
+ catch { /* 状态读取失败时回退配置文件 */ }
340
+ const currentModel = statusModel ?? (typeof config?.model === 'string' ? config.model : null);
209
341
  const configuredEffort = currentModel !== null && isRecord(config?.reasoningEffort) ? config.reasoningEffort[currentModel] : undefined;
210
342
  const currentEffort = typeof configuredEffort === 'string' && VALID_EFFORTS.has(configuredEffort) ? configuredEffort : null;
211
343
  const result = { groups, currentModel, currentEffort };
212
344
  return result;
213
345
  }
214
- async probeSession(_input) {
215
- return {
216
- state: 'ephemeral',
217
- reason: 'Command Code 当前使用单轮临时 transcript,不存在可恢复的 Provider 原始会话',
218
- };
346
+ /** 读取 Provider 当前 status;历史层只在模型一致时使用其中的上下文窗口。 */
347
+ async readCommandCodeStatus(workspacePath) {
348
+ const command = this.cachedBinary ?? this.binaries[0];
349
+ if (command === undefined)
350
+ return null;
351
+ try {
352
+ const result = this.runSpawnSync(command, ['status', '--json'], {
353
+ cwd: workspacePath,
354
+ encoding: 'utf8',
355
+ timeout: 5_000,
356
+ windowsHide: true,
357
+ shell: WINDOWS,
358
+ env: this.cachedEnvironment ?? commandEnvironment(command),
359
+ });
360
+ return parseJson(result.stdout ?? '');
361
+ }
362
+ catch {
363
+ return null;
364
+ }
365
+ }
366
+ async probeSession(input) {
367
+ throwIfCommandCodeProbeAborted(input.signal);
368
+ const providerSessionId = input.providerSessionId?.trim();
369
+ if (!providerSessionId)
370
+ return { state: 'unknown', reason: '缺少 Provider 会话标识' };
371
+ const candidates = new Set();
372
+ const rawStoreRef = input.rawStoreRef?.trim();
373
+ const safeRawStoreRef = rawStoreRef !== undefined && isSafeCommandCodeTranscriptPath(rawStoreRef, this.homeDirectory)
374
+ ? rawStoreRef
375
+ : undefined;
376
+ if (safeRawStoreRef !== undefined)
377
+ candidates.add(safeRawStoreRef);
378
+ const discovered = resolveCanonicalTranscriptPath(join(this.homeDirectory, 'projects', `${providerSessionId}.jsonl`), this.homeDirectory, input.cwd);
379
+ if (discovered !== null)
380
+ candidates.add(discovered);
381
+ const checkpoint = resolveCommandCodeCheckpointPath(this.homeDirectory, input.cwd ?? process.cwd(), providerSessionId);
382
+ if (checkpoint !== null)
383
+ candidates.add(checkpoint);
384
+ if (candidates.size === 0)
385
+ return { state: 'missing', reason: 'Command Code 原生会话文件不存在' };
386
+ let lastFailure;
387
+ for (const candidate of candidates) {
388
+ throwIfCommandCodeProbeAborted(input.signal);
389
+ if (!existsSync(candidate))
390
+ continue;
391
+ try {
392
+ if (!statSync(candidate).isFile()) {
393
+ lastFailure = { state: 'missing', reason: 'Command Code 原生会话路径不是文件', rawStoreRef: candidate };
394
+ continue;
395
+ }
396
+ // 探测只需验证首条记录;CLI 正在追加时末尾可能存在半行,不能因此拒绝
397
+ // 一个仍可由 --resume 找到的会话。完整历史解析由独立的读取入口负责。
398
+ const firstRecord = readFirstJsonRecord(candidate);
399
+ if (firstRecord === null) {
400
+ lastFailure = { state: 'corrupt', reason: 'Command Code 原生会话首条记录不是有效 JSONL', rawStoreRef: candidate };
401
+ continue;
402
+ }
403
+ if (candidate.endsWith('.checkpoints.jsonl')) {
404
+ // checkpoint 只保存回退点,Command Code 的 --resume 索引仍要求同名
405
+ // `.jsonl` transcript。仅有 checkpoint 的旧会话不能宣称可恢复。
406
+ lastFailure = { state: 'missing', reason: 'Command Code 只有 checkpoint,没有可恢复 transcript', rawStoreRef: candidate };
407
+ continue;
408
+ }
409
+ const recordedId = textValue(firstRecord.id ?? firstRecord.sessionId).trim();
410
+ if (recordedId !== '' && recordedId !== providerSessionId) {
411
+ lastFailure = { state: 'corrupt', reason: 'Command Code 原生会话标识与绑定不一致', rawStoreRef: candidate };
412
+ continue;
413
+ }
414
+ return { state: 'available', reason: 'Command Code 原生会话可用', rawStoreRef: candidate };
415
+ }
416
+ catch (error) {
417
+ lastFailure = { state: 'unreachable', reason: `无法读取 Command Code 原生会话:${error instanceof Error ? error.message : String(error)}`, rawStoreRef: candidate };
418
+ }
419
+ }
420
+ return lastFailure ?? { state: 'missing', reason: 'Command Code 原生会话文件不存在', ...(safeRawStoreRef ? { rawStoreRef: safeRawStoreRef } : {}) };
219
421
  }
220
422
  async *executeTurn(input) {
221
423
  const binary = this.cachedBinary ?? (await this.detect()).command;
@@ -224,7 +426,7 @@ export class CommandCodeDriver {
224
426
  const segmented = input.splitToolSteps === true;
225
427
  const turn = segmented ? this.acquireTurn(input, binary) : this.startTurn(input, binary);
226
428
  let suspended = false;
227
- const onAbort = () => { turn.aborted = true; this.disposeTurn(turn); };
429
+ const onAbort = () => { this.requestGracefulStop(turn); };
228
430
  input.signal?.addEventListener('abort', onAbort, { once: true });
229
431
  if (input.signal?.aborted)
230
432
  onAbort();
@@ -267,12 +469,35 @@ export class CommandCodeDriver {
267
469
  return turn;
268
470
  }
269
471
  startTurn(input, binary) {
270
- const transcriptPath = join(tmpdir(), `codingns4dsh-cc-${safeId(input.sessionId)}.jsonl`);
271
- writeTranscript(transcriptPath, input);
472
+ const cwd = input.cwd ?? process.cwd();
473
+ const requestedProviderSessionId = input.providerSessionId?.trim() || undefined;
474
+ // 旧 synthetic ID 可能只对应 checkpoint;回退时必须以当前 DSH 会话 ID
475
+ // 作为文件名,保证后续 session-binding、索引和 --resume 使用同一个标识。
476
+ const canonicalKey = requestedProviderSessionId !== undefined
477
+ && !isLegacySyntheticSessionId(requestedProviderSessionId)
478
+ ? requestedProviderSessionId
479
+ : input.sessionId;
480
+ const canonicalPath = resolveCommandCodeTranscriptPath(this.homeDirectory, cwd, canonicalKey);
481
+ const hasCanonicalTranscript = existsSync(canonicalPath) && isSafeCommandCodeTranscriptPath(canonicalPath, this.homeDirectory);
482
+ const hasRequestedRawTranscript = input.rawStoreRef?.trim() !== undefined
483
+ && existsSync(input.rawStoreRef.trim())
484
+ && isSafeCommandCodeTranscriptPath(input.rawStoreRef.trim(), this.homeDirectory);
485
+ // 旧版本会把只有 checkpoint 的外部路径登记成 synthetic session ID;该 ID
486
+ // 无法被 Command Code 的 --resume 索引解析。没有可读 JSONL 时重新从 DSH
487
+ // 历史建立 canonical transcript,避免把坏绑定继续传给 Provider。
488
+ const canResume = requestedProviderSessionId !== undefined
489
+ && (hasCanonicalTranscript || hasRequestedRawTranscript || !isLegacySyntheticSessionId(requestedProviderSessionId));
490
+ const providerSessionId = canResume ? requestedProviderSessionId : input.sessionId;
491
+ const transcriptPath = canResume ? undefined : canonicalPath;
492
+ if (transcriptPath !== undefined)
493
+ writeTranscript(transcriptPath, input);
272
494
  const turn = {
273
495
  sessionId: input.sessionId,
274
496
  child: undefined,
275
497
  transcriptPath,
498
+ providerSessionId,
499
+ rawStoreRef: canResume ? input.rawStoreRef?.trim() || undefined : transcriptPath,
500
+ cwd,
276
501
  queue: createEventQueue(),
277
502
  currentMessageId: undefined,
278
503
  sawCompletedTool: false,
@@ -285,7 +510,15 @@ export class CommandCodeDriver {
285
510
  attempt: 0,
286
511
  maxTurnsReached: false,
287
512
  messageSequence: 0,
513
+ stderrTail: '',
288
514
  };
515
+ // 首轮固定使用 canonical transcript;CLI 事件里的 checkpoint ID 不可用于
516
+ // --resume,因此先登记稳定的 DSH 会话 ID,后续回合沿用同一路径恢复。
517
+ if (!canResume && transcriptPath !== undefined) {
518
+ turn.queue.push({ type: 'session-binding', providerSessionId: providerSessionId, rawStoreRef: transcriptPath });
519
+ }
520
+ // 普通回合也登记活动 turn;Registry 的 interrupt 不应只对分段回合生效。
521
+ this.turns.set(input.sessionId, turn);
289
522
  void this.runTurnAttempts(turn, input, binary);
290
523
  return turn;
291
524
  }
@@ -302,22 +535,28 @@ export class CommandCodeDriver {
302
535
  try {
303
536
  while (true) {
304
537
  turn.attempt += 1;
538
+ turn.stderrTail = '';
305
539
  // 自动续跑是同一个 DSH 运行里的下一段;消息序号必须跨尝试连续,
306
540
  // 否则新进程会从 command-code-message-1 重新编号,公共投影层会把它
307
541
  // 当成同一条消息继续追加,而不是开启新段。
308
- const state = createStreamState(() => turn.aborted, turn.messageSequence);
542
+ const state = createStreamState(() => turn.aborted, turn.messageSequence, turn.providerSessionId ?? null, turn.sessionId);
309
543
  const child = this.spawnAttempt(turn, input, binary);
310
544
  const code = await this.readAttempt(turn, child, state);
311
545
  turn.messageSequence = state.messageSequence;
546
+ // 首轮使用临时 `--session` 文件。Provider 会话 ID 在流中确认后,必须在
547
+ // 本次尝试结束时把临时 transcript 提升到 canonical 路径;否则下一轮拿着
548
+ // 已登记的 ID 执行 `--resume` 时,Command Code 找不到对应原生会话。
549
+ if (turn.transcriptPath !== undefined && turn.providerSessionId !== undefined) {
550
+ syncCommandCodeTranscript(turn.transcriptPath, this.homeDirectory, input.cwd, turn.providerSessionId);
551
+ }
312
552
  if (turn.disposed || turn.finished)
313
553
  return;
314
554
  const capped = state.maxTurnsReached || code === COMMAND_CODE_MAX_TURNS_EXIT_CODE;
315
555
  const autoContinueUsed = turn.attempt - 1;
316
- if (capped && !turn.aborted && !turn.terminal && autoContinueUsed < this.autoContinueMaxAttempts) {
556
+ if (capped && !turn.aborted && !turn.terminal && turn.providerSessionId !== undefined && autoContinueUsed < this.autoContinueMaxAttempts) {
317
557
  // 续跑必须落在同一个会话上。CLI 可能把 transcript 写回会话文件、也可能
318
558
  // 写进按 cwd 归档的 canonical 目录;两种落点都要先归位到同一个文件,
319
559
  // 否则“继续”会开出一个没有上文的新会话,等于白跑一轮预算。
320
- syncCommandCodeTranscript(turn.transcriptPath, this.homeDirectory, input.cwd);
321
560
  continue;
322
561
  }
323
562
  if (capped && !turn.aborted && !turn.terminal) {
@@ -338,29 +577,81 @@ export class CommandCodeDriver {
338
577
  /** 启动一次 CLI 尝试;首次写入 transcript,续跑沿用同一会话文件。 */
339
578
  spawnAttempt(turn, input, binary) {
340
579
  const args = this.buildTurnArgs(input, turn);
341
- const child = this.runSpawn(binary, args, { cwd: input.cwd ?? process.cwd(), env: this.cachedEnvironment ?? commandEnvironment(binary), stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true, shell: WINDOWS });
580
+ const bridgeEnvironment = commandCodeBridgeEnvironment(input.sessionId, this.descriptor.id);
581
+ const child = this.runSpawn(binary, args, {
582
+ cwd: input.cwd ?? process.cwd(),
583
+ env: { ...(this.cachedEnvironment ?? commandEnvironment(binary)), ...(input.runtimeEnv ?? {}), ...bridgeEnvironment },
584
+ stdio: ['ignore', 'pipe', 'pipe'],
585
+ windowsHide: true,
586
+ shell: WINDOWS,
587
+ });
342
588
  // 自动续跑会替换活动进程;已退出的旧尝试不能继续留在进程表里等待 terminate。
343
589
  if (turn.child !== undefined)
344
590
  this.processes.delete(turn.child);
345
591
  this.processes.add(child);
346
- // 必须消费 stderr,错误内容不能回传给 DSH,避免泄露命令参数或文件片段。
347
- child.stderr?.on('data', () => undefined);
592
+ // 必须消费 stderr,错误内容只保留尾部用于诊断,避免泄露整段命令输出。
593
+ child.stderr?.on('data', (chunk) => {
594
+ turn.stderrTail = `${turn.stderrTail}${chunk.toString()}`.slice(-512);
595
+ });
348
596
  turn.child = child;
349
597
  return child;
350
598
  }
351
599
  buildTurnArgs(input, turn) {
352
- // 续跑沿用同一个 transcript 文件,只把输入换成续跑提示;不能再次写入历史,
600
+ // 续跑沿用同一个 Provider 会话,只把输入换成续跑提示;不能再次写入历史,
353
601
  // 否则会把 CLI 已经落盘的进度覆盖成空会话。
354
602
  const prompt = turn.attempt > 1 ? this.autoContinuePrompt : promptWithAttachmentPaths(input.prompt, input.attachments ?? []);
355
- const args = ['--session', turn.transcriptPath, '-p', prompt, '--output-format', 'json', '--tools-all', '--yolo', '--max-turns', String(this.maxTurns)];
603
+ const args = turn.transcriptPath !== undefined && turn.attempt === 1
604
+ ? ['--session', turn.transcriptPath, '-p', prompt, '--output-format', 'json', '--skip-onboarding', '--max-turns', String(this.maxTurns)]
605
+ : turn.providerSessionId !== undefined
606
+ ? ['-p', prompt, '--output-format', 'json', '--skip-onboarding', '--max-turns', String(this.maxTurns), '--resume', turn.providerSessionId]
607
+ : ['--session', turn.transcriptPath, '-p', prompt, '--output-format', 'json', '--skip-onboarding', '--max-turns', String(this.maxTurns)];
608
+ // 只有 Host 明确确认“完全访问且永不询问”时才允许 --yolo。
609
+ // 权限状态缺省表示尚未读取,必须保持 CLI 的保守默认,不能把未知状态升级为完全访问。
610
+ args.push(...commandCodePermissionArgs(input.permission));
611
+ if (input.plan === true && !args.includes('--plan'))
612
+ args.push('--plan');
613
+ // Command Code 只允许从已有 --resume 会话分叉;首轮临时 transcript 不能带该参数。
614
+ if (input.forkSession === true && turn.providerSessionId !== undefined)
615
+ args.push('--fork-session');
616
+ if (input.enableAskUserQuestion === true || input.runtimeEnv?.CMD_TOOLS_ASK_USER_QUESTION_ENABLE === 'true') {
617
+ args.push('--tools-enable', 'ask_user_question');
618
+ }
619
+ // 子代理托管开启时加载桥接 mod:内建 agent 调用会被转投成 DSH 原生子会话。
620
+ args.push(...commandCodeBridgeArgs(input.sessionId));
356
621
  for (const directory of new Set((input.attachments ?? []).map((attachment) => dirname(attachment.path))))
357
622
  args.push('--add-dir', directory);
358
- if (input.modelId)
359
- args.push('-m', input.modelId);
360
- if (input.effortId && input.effortId !== 'default' && input.effortId !== 'Default')
361
- args.push('--effort', input.effortId);
623
+ if (input.modelId && input.modelId !== 'provider-default')
624
+ args.push('--model', input.modelId);
625
+ const effort = input.effortId?.trim().toLowerCase();
626
+ if (effort !== undefined && VALID_EFFORTS.has(effort))
627
+ args.push('--effort', effort);
362
628
  return args;
363
629
  }
630
+ /** 中断当前会话并清理 CLI 进程;不存在活动运行时视为幂等成功。 */
631
+ async interrupt(sessionId) {
632
+ const turn = this.turns.get(sessionId);
633
+ if (turn === undefined)
634
+ return;
635
+ this.requestGracefulStop(turn);
636
+ }
637
+ /** 先让 CLI 保存检查点并自行退出,超时后才清理进程树。 */
638
+ requestGracefulStop(turn) {
639
+ turn.aborted = true;
640
+ const child = turn.child;
641
+ if (child === undefined) {
642
+ this.disposeTurn(turn);
643
+ return;
644
+ }
645
+ try {
646
+ child.kill('SIGINT');
647
+ }
648
+ catch { /* 进程可能已经退出 */ }
649
+ const timer = setTimeout(() => {
650
+ if (!turn.disposed)
651
+ this.disposeTurn(turn);
652
+ }, COMMAND_CODE_INTERRUPT_GRACE_MS);
653
+ timer.unref?.();
654
+ }
364
655
  /** 读取一次尝试的 stdout,直到进程结束;队列在整个运行结束前保持打开。 */
365
656
  async readAttempt(turn, child, state) {
366
657
  // 测试替身可能只提供 stdout/kill,没有 ChildProcess 的事件接口。
@@ -368,6 +659,7 @@ export class CommandCodeDriver {
368
659
  ? child
369
660
  : null;
370
661
  let exitCode = null;
662
+ let exitSignal = null;
371
663
  let resolveClose = null;
372
664
  const closed = new Promise((resolve) => { resolveClose = resolve; });
373
665
  if (emitter !== null) {
@@ -378,8 +670,9 @@ export class CommandCodeDriver {
378
670
  turn.failure ??= error;
379
671
  resolveClose?.();
380
672
  });
381
- emitter.on('close', (code) => {
673
+ emitter.on('close', (code, signal) => {
382
674
  exitCode = code;
675
+ exitSignal = signal ?? null;
383
676
  if (state.maxTurnsReached)
384
677
  turn.maxTurnsReached = true;
385
678
  resolveClose?.();
@@ -387,15 +680,32 @@ export class CommandCodeDriver {
387
680
  }
388
681
  try {
389
682
  const lines = readline.createInterface({ input: child.stdout });
683
+ let lineNumber = 0;
390
684
  try {
391
685
  for await (const line of lines) {
392
686
  if (!line.trim())
393
687
  continue;
688
+ lineNumber += 1;
394
689
  const item = parseJson(line);
395
- if (item === null)
690
+ if (item === null) {
691
+ // CLI 升级后可能输出非对象或损坏的 NDJSON;保留行号诊断,不能静默吞掉。
692
+ console.warn(`[codingns4dsh] Command Code 忽略非法 NDJSON(第 ${lineNumber} 行)`);
396
693
  continue;
694
+ }
397
695
  const event = item.type === 'event' && isRecord(item.event) ? item.event : item;
398
- for (const chunk of commandCodeEventChunks(event, state)) {
696
+ for (const rawChunk of commandCodeEventChunks(event, state)) {
697
+ let chunk = rawChunk;
698
+ if (rawChunk.type === 'session-binding') {
699
+ // `--session <path>` 模式下 CLI 发出的 sessionId 是 checkpoint
700
+ // 内部 ID,不是可供 --resume 查找的 transcript ID;保持 Host 绑定。
701
+ if (turn.transcriptPath !== undefined)
702
+ continue;
703
+ turn.providerSessionId = rawChunk.providerSessionId;
704
+ turn.rawStoreRef = resolveCommandCodeTranscriptPath(this.homeDirectory, turn.cwd, rawChunk.providerSessionId);
705
+ // Provider ID 一旦确认就立即暴露 canonical 路径;文件可能稍后才落盘,
706
+ // 但 Registry 必须先保存稳定绑定,冷恢复时才能直接定位原生会话。
707
+ chunk = { ...rawChunk, rawStoreRef: turn.rawStoreRef };
708
+ }
399
709
  if (chunk.type === 'finish')
400
710
  turn.terminal = true;
401
711
  turn.queue.push(chunk);
@@ -417,6 +727,23 @@ export class CommandCodeDriver {
417
727
  else {
418
728
  await closed;
419
729
  }
730
+ if (!turn.terminal && !state.maxTurnsReached) {
731
+ if (turn.aborted || exitSignal === 'SIGINT' || exitSignal === 'SIGTERM') {
732
+ turn.terminal = true;
733
+ turn.queue.push({ type: 'finish', reason: 'cancel' });
734
+ }
735
+ else if (turn.failure !== null || (exitCode !== null && exitCode !== 0) || exitSignal !== null) {
736
+ const message = turn.failure?.message
737
+ || (turn.stderrTail.trim() !== '' ? `Command Code 执行失败:${turn.stderrTail.trim()}` : `Command Code 进程退出(代码 ${exitCode ?? exitSignal ?? 'unknown'})`);
738
+ turn.failure = null;
739
+ turn.terminal = true;
740
+ turn.queue.push({
741
+ type: 'finish',
742
+ reason: 'error',
743
+ failure: { message, code: exitCode === null ? 'COMMAND_CODE_SPAWN_ERROR' : `COMMAND_CODE_EXIT_${exitCode}` },
744
+ });
745
+ }
746
+ }
420
747
  return exitCode;
421
748
  }
422
749
  async *consumeTurn(turn, input, segmented, suspend) {
@@ -479,13 +806,10 @@ export class CommandCodeDriver {
479
806
  this.processes.delete(child);
480
807
  terminateChildProcess(child);
481
808
  }
482
- try {
483
- rmSync(turn.transcriptPath, { force: true });
484
- }
485
- catch { /* 临时文件清理尽力而为 */ }
809
+ // 首轮 transcript 已经是 canonical 文件,必须保留给下一轮 --resume 及冷恢复。
486
810
  }
487
811
  }
488
- function createStreamState(aborted, messageSequence = 0) {
812
+ function createStreamState(aborted, messageSequence = 0, sessionId = null, bridgeSessionId = '') {
489
813
  return {
490
814
  messageSequence,
491
815
  messageId: null,
@@ -494,9 +818,11 @@ function createStreamState(aborted, messageSequence = 0) {
494
818
  sawText: false,
495
819
  perRequestUsageSeen: false,
496
820
  turnUsageSeen: false,
497
- sessionId: null,
821
+ sessionId,
822
+ bridgeSessionId,
498
823
  aborted,
499
824
  maxTurnsReached: false,
825
+ terminalEmitted: false,
500
826
  };
501
827
  }
502
828
  function createEventQueue() {
@@ -550,6 +876,16 @@ function commandCodeEventChunks(event, state) {
550
876
  chunks.push({ type: 'session-binding', providerSessionId: sessionId });
551
877
  }
552
878
  switch (type) {
879
+ case 'run_start':
880
+ case 'run-start':
881
+ case 'session_created':
882
+ case 'session-created':
883
+ case 'model_request_start':
884
+ case 'model-request-start':
885
+ case 'model_trace':
886
+ case 'model-trace':
887
+ // 这些事件只标记 Provider 生命周期,不应制造正文或终态。
888
+ break;
553
889
  case 'turn_start':
554
890
  case 'turn-start':
555
891
  beginMessage(state);
@@ -614,19 +950,36 @@ function commandCodeEventChunks(event, state) {
614
950
  }
615
951
  case 'run_end':
616
952
  case 'run-end':
617
- // run_end 只是“CLI 侧整个 run 收尾了”,最终结算仍以紧随其后的 result 行为准。
618
- // 这里只识别轮次上限:上限不是终态,等进程退出后决定续跑还是报错。
619
- if (isMaxTurnsOutcome(event))
953
+ if (!state.sawText) {
954
+ const finalText = readFinalText(event);
955
+ if (finalText) {
956
+ ensureMessage(state);
957
+ state.sawText = true;
958
+ state.emittedText = finalText;
959
+ chunks.push(textDelta(finalText, state));
960
+ }
961
+ }
962
+ if (isMaxTurnsOutcome(event)) {
963
+ // 撞到 CLI 的轮次上限不是终态,但 run_end 可能同时携带本次已生成的
964
+ // 最后一段正文。正文必须先投影出去,续跑只负责继续执行,不能吞掉这段结果。
620
965
  state.maxTurnsReached = true;
966
+ break;
967
+ }
968
+ if (!state.terminalEmitted) {
969
+ state.terminalEmitted = true;
970
+ chunks.push({ type: 'finish', reason: state.aborted() ? 'cancel' : resultReason(event) });
971
+ }
621
972
  break;
622
973
  case 'result': {
974
+ if (state.terminalEmitted)
975
+ break;
623
976
  if (!state.perRequestUsageSeen) {
624
977
  const usage = usageChunk(recordValue(event.usage));
625
978
  if (usage !== null)
626
979
  chunks.push(usage);
627
980
  }
628
981
  if (!state.sawText) {
629
- const finalText = textValue(event.finalText ?? recordValue(event.result)?.finalText ?? (typeof event.result === 'string' ? event.result : undefined));
982
+ const finalText = readFinalText(event);
630
983
  if (finalText) {
631
984
  ensureMessage(state);
632
985
  state.sawText = true;
@@ -640,10 +993,28 @@ function commandCodeEventChunks(event, state) {
640
993
  state.maxTurnsReached = true;
641
994
  break;
642
995
  }
643
- chunks.push({ type: 'finish', reason: state.aborted() ? 'cancel' : resultReason(event) });
996
+ const reason = state.aborted() ? 'cancel' : resultReason(event);
997
+ state.terminalEmitted = true;
998
+ chunks.push({
999
+ type: 'finish',
1000
+ reason,
1001
+ ...(reason === 'error' ? { failure: commandCodeFailure(event) } : {}),
1002
+ });
644
1003
  break;
645
1004
  }
1005
+ case 'error':
1006
+ case 'fatal_error':
1007
+ case 'run_error':
1008
+ if (!state.terminalEmitted) {
1009
+ state.terminalEmitted = true;
1010
+ chunks.push({ type: 'finish', reason: state.aborted() ? 'cancel' : 'error', ...(state.aborted() ? {} : { failure: commandCodeFailure(event) }) });
1011
+ }
1012
+ break;
646
1013
  default:
1014
+ if (type !== '' && !isToolStart(type) && !isToolResult(type)) {
1015
+ // 未知事件不应改变正常流,但必须留下可定位的升级诊断。
1016
+ console.warn(`[codingns4dsh] Command Code 忽略未知事件:${type}`);
1017
+ }
647
1018
  break;
648
1019
  }
649
1020
  if (isToolStart(type)) {
@@ -652,7 +1023,10 @@ function commandCodeEventChunks(event, state) {
652
1023
  chunks.push(tool);
653
1024
  }
654
1025
  else if (isToolResult(type)) {
655
- const failed = type.includes('error') || type.includes('fail') || type.includes('denied') || type.includes('blocked');
1026
+ // 子代理托管命中时,mod 用 block 结束内建 agent 调用,真正的执行已经发生在
1027
+ // DSH 原生子会话里;这里必须投影成完成态,而不是普通 hook 拦截的失败态。
1028
+ const redirected = type.includes('blocked') && consumeBridgeRedirect(state, event);
1029
+ const failed = !redirected && (type.includes('error') || type.includes('fail') || type.includes('denied') || type.includes('blocked'));
656
1030
  const tool = readToolChunk(event, failed ? 'failed' : 'completed');
657
1031
  if (tool !== null) {
658
1032
  chunks.push(tool);
@@ -664,6 +1038,30 @@ function commandCodeEventChunks(event, state) {
664
1038
  }
665
1039
  return chunks;
666
1040
  }
1041
+ function readFinalText(event) {
1042
+ const result = recordValue(event.result);
1043
+ return textValue(event.finalText
1044
+ ?? result?.finalText
1045
+ ?? result?.output
1046
+ ?? result?.text
1047
+ ?? (typeof event.result === 'string' ? event.result : undefined)
1048
+ ?? event.output
1049
+ ?? event.text);
1050
+ }
1051
+ /** 该 blocked 事件是否来自桥接转投;命中后消费一次记录,避免重复投影。 */
1052
+ function consumeBridgeRedirect(state, event) {
1053
+ if (state.bridgeSessionId === '')
1054
+ return false;
1055
+ const callId = firstToolText(event.callId, event.call_id, event.toolCallId, event.tool_call_id, event.toolUseId, event.tool_use_id, event.id);
1056
+ if (callId === undefined || callId === '')
1057
+ return false;
1058
+ try {
1059
+ return getSubagentBridge()?.consumeRedirect(state.bridgeSessionId, callId) !== undefined;
1060
+ }
1061
+ catch {
1062
+ return false;
1063
+ }
1064
+ }
667
1065
  function beginMessage(state) {
668
1066
  state.messageSequence += 1;
669
1067
  state.messageId = `command-code-message-${state.messageSequence}`;
@@ -691,8 +1089,17 @@ function reasoningDelta(text, state) {
691
1089
  function appendContentFallback(chunks, content, state) {
692
1090
  if (!Array.isArray(content))
693
1091
  return;
694
- let text = '';
695
- let reasoning = '';
1092
+ let snapshotText = '';
1093
+ let snapshotReasoning = '';
1094
+ let pendingKind = null;
1095
+ let pendingDelta = '';
1096
+ const flushPending = () => {
1097
+ if (pendingKind === null || pendingDelta === '')
1098
+ return;
1099
+ chunks.push(pendingKind === 'text' ? textDelta(pendingDelta, state) : reasoningDelta(pendingDelta, state));
1100
+ pendingKind = null;
1101
+ pendingDelta = '';
1102
+ };
696
1103
  for (const block of content) {
697
1104
  const value = recordValue(block);
698
1105
  if (value === null)
@@ -700,31 +1107,43 @@ function appendContentFallback(chunks, content, state) {
700
1107
  const blockType = textValue(value.type).toLowerCase();
701
1108
  const isReasoning = blockType.includes('thinking') || blockType.includes('reasoning')
702
1109
  || typeof value.thinking === 'string' || typeof value.reasoning === 'string';
703
- if (isReasoning)
704
- reasoning += textValue(value.thinking ?? value.reasoning ?? value.text ?? value.content);
705
- else
706
- text += textValue(value.text ?? value.content);
707
- }
708
- if (text.length > state.emittedText.length) {
709
- const delta = text.slice(state.emittedText.length);
710
- ensureMessage(state);
711
- state.emittedText = text;
712
- state.sawText = true;
713
- chunks.push(textDelta(delta, state));
714
- }
715
- if (reasoning.length > state.emittedReasoning.length) {
716
- const delta = reasoning.slice(state.emittedReasoning.length);
717
- ensureMessage(state);
718
- state.emittedReasoning = reasoning;
719
- chunks.push(reasoningDelta(delta, state));
1110
+ const blockText = textValue(isReasoning
1111
+ ? value.thinking ?? value.reasoning ?? value.text ?? value.content
1112
+ : value.text ?? value.content);
1113
+ if (isReasoning) {
1114
+ snapshotReasoning += blockText;
1115
+ if (snapshotReasoning.length > state.emittedReasoning.length) {
1116
+ const delta = snapshotReasoning.slice(state.emittedReasoning.length);
1117
+ ensureMessage(state);
1118
+ state.emittedReasoning = snapshotReasoning;
1119
+ if (pendingKind !== 'reasoning')
1120
+ flushPending();
1121
+ pendingKind = 'reasoning';
1122
+ pendingDelta += delta;
1123
+ }
1124
+ }
1125
+ else {
1126
+ snapshotText += blockText;
1127
+ if (snapshotText.length > state.emittedText.length) {
1128
+ const delta = snapshotText.slice(state.emittedText.length);
1129
+ ensureMessage(state);
1130
+ state.emittedText = snapshotText;
1131
+ state.sawText = true;
1132
+ if (pendingKind !== 'text')
1133
+ flushPending();
1134
+ pendingKind = 'text';
1135
+ pendingDelta += delta;
1136
+ }
1137
+ }
720
1138
  }
1139
+ flushPending();
721
1140
  }
722
1141
  function readToolChunk(event, status) {
723
1142
  const callId = firstToolText(event.callId, event.call_id, event.toolCallId, event.tool_call_id, event.toolUseId, event.tool_use_id, event.id);
724
1143
  const fn = recordValue(event.function);
725
1144
  const toolName = textValue(event.name ?? event.toolName ?? event.tool_name ?? event.tool ?? fn?.name) || 'tool';
726
1145
  const error = textValue(event.error ?? event.reason ?? event.message);
727
- const output = textValue(event.output ?? event.result ?? event.content);
1146
+ const output = textValue(event.output ?? event.result ?? event.content ?? event.hookOutput);
728
1147
  const input = event.input ?? fn?.arguments ?? event.arguments;
729
1148
  const agentId = firstToolText(event.agentId, event.agent_id);
730
1149
  const detail = serializeToolValue(event.detail ?? event.metadata ?? event.description);
@@ -759,6 +1178,15 @@ function resultReason(event) {
759
1178
  return 'cancel';
760
1179
  return 'stop';
761
1180
  }
1181
+ function commandCodeFailure(event) {
1182
+ const result = recordValue(event.result);
1183
+ const candidate = event.error ?? event.errorMessage ?? event.error_message ?? result?.error ?? result?.errorMessage ?? result?.message ?? event.message;
1184
+ const message = textValue(candidate) ?? (typeof candidate === 'string' ? candidate.trim() : '');
1185
+ const codeValue = result?.code ?? result?.errorCode ?? event.code ?? event.errorCode;
1186
+ const code = typeof codeValue === 'string' && codeValue.trim() !== '' ? codeValue.trim() : undefined;
1187
+ const actual = message.trim() || 'Command Code Provider 未返回具体失败信息。';
1188
+ return code === undefined ? { message: actual } : { message: actual, code };
1189
+ }
762
1190
  /**
763
1191
  * 读取 CLI 的结束原因。
764
1192
  *
@@ -783,20 +1211,36 @@ function isMaxTurnsOutcome(event) {
783
1211
  *
784
1212
  * 实测 CLI 的落盘位置取决于会话文件里是否已有历史:空会话(只有 session 头)时
785
1213
  * 会把消息写进 `~/.commandcode/projects/<slug>/<id>.jsonl`,带上历史时则写回
786
- * `--session` 指定的文件。两种落点都要先归位,否则自动续跑的“继续”会落在一个
787
- * 没有上文的会话上。归位只做“canonical 比本地新”的单向复制,不覆盖更新的本地文件。
1214
+ * `--session` 指定的文件。两种落点都要统一,否则下一轮恢复会落在一个没有上文的
1215
+ * 会话上。两边都存在时按修改时间同步最新内容,首轮则创建 canonical 文件。
788
1216
  */
789
- function syncCommandCodeTranscript(transcriptPath, homeDirectory, cwd) {
790
- const canonicalPath = resolveCanonicalTranscriptPath(transcriptPath, homeDirectory, cwd);
1217
+ function syncCommandCodeTranscript(transcriptPath, homeDirectory, cwd, providerSessionId) {
1218
+ const canonicalPath = providerSessionId === undefined
1219
+ ? resolveCanonicalTranscriptPath(transcriptPath, homeDirectory, cwd)
1220
+ : resolveCommandCodeTranscriptPath(homeDirectory, cwd ?? process.cwd(), providerSessionId);
791
1221
  if (canonicalPath === null)
792
1222
  return;
1223
+ if (providerSessionId !== undefined && !isSafeCommandCodeTranscriptTarget(canonicalPath, homeDirectory))
1224
+ return;
793
1225
  try {
794
- if (statSync(canonicalPath).mtimeMs <= statSync(transcriptPath).mtimeMs)
1226
+ if (!existsSync(transcriptPath) || !statSync(transcriptPath).isFile())
1227
+ return;
1228
+ const sourceMtime = statSync(transcriptPath).mtimeMs;
1229
+ if (!existsSync(canonicalPath)) {
1230
+ mkdirSync(dirname(canonicalPath), { recursive: true });
1231
+ copyFileSync(transcriptPath, canonicalPath);
1232
+ return;
1233
+ }
1234
+ if (!statSync(canonicalPath).isFile())
795
1235
  return;
796
- copyFileSync(canonicalPath, transcriptPath);
1236
+ const canonicalMtime = statSync(canonicalPath).mtimeMs;
1237
+ if (sourceMtime > canonicalMtime)
1238
+ copyFileSync(transcriptPath, canonicalPath);
1239
+ else if (canonicalMtime > sourceMtime)
1240
+ copyFileSync(canonicalPath, transcriptPath);
797
1241
  }
798
1242
  catch {
799
- // transcript 归位是续跑优化;文件缺失或不可读时保持现状即可。
1243
+ // transcript 归位是恢复前的必要同步;文件竞态或不可读时保持当前运行结果。
800
1244
  }
801
1245
  }
802
1246
  /** 按 CLI 的 `<cwd slug>/<session id>` 规则定位 canonical transcript。 */
@@ -826,6 +1270,86 @@ function resolveCanonicalTranscriptPath(transcriptPath, homeDirectory, cwd) {
826
1270
  }
827
1271
  return null;
828
1272
  }
1273
+ /** 按 Provider 会话 ID 计算 Command Code 的 canonical transcript 路径。 */
1274
+ function resolveCommandCodeTranscriptPath(homeDirectory, cwd, providerSessionId) {
1275
+ return join(homeDirectory, 'projects', workspaceSlug(cwd), `${safeId(providerSessionId)}.jsonl`);
1276
+ }
1277
+ /** Provider 索引只能指向 Command Code 项目目录中的 JSONL,避免旧配置污染探测边界。 */
1278
+ function isSafeCommandCodeTranscriptPath(candidate, homeDirectory) {
1279
+ const projectsRootPath = resolve(join(homeDirectory, 'projects'));
1280
+ let projectsRoot = projectsRootPath;
1281
+ try {
1282
+ if (existsSync(projectsRootPath))
1283
+ projectsRoot = realpathSync(projectsRootPath);
1284
+ }
1285
+ catch {
1286
+ return false;
1287
+ }
1288
+ const resolvedCandidate = resolve(candidate);
1289
+ let actualCandidate = resolvedCandidate;
1290
+ try {
1291
+ if (existsSync(resolvedCandidate))
1292
+ actualCandidate = realpathSync(resolvedCandidate);
1293
+ }
1294
+ catch {
1295
+ return false;
1296
+ }
1297
+ const relativePath = relative(projectsRoot, actualCandidate);
1298
+ const segments = relativePath.split(/[\\/]+/u).filter(Boolean);
1299
+ return relativePath !== ''
1300
+ && !relativePath.startsWith('..')
1301
+ && segments.length === 2
1302
+ && actualCandidate.endsWith('.jsonl')
1303
+ // checkpoint 不是 --resume 使用的 transcript,即使扩展名同为 .jsonl
1304
+ // 也不能把它当作可恢复会话绑定。
1305
+ && !actualCandidate.endsWith('.checkpoints.jsonl');
1306
+ }
1307
+ /** 允许同步创建的 canonical transcript 目标,路径必须严格位于 projects/<slug>/*.jsonl。 */
1308
+ function isSafeCommandCodeTranscriptTarget(candidate, homeDirectory) {
1309
+ const projectsRoot = resolve(join(homeDirectory, 'projects'));
1310
+ const resolvedCandidate = resolve(candidate);
1311
+ const relativePath = relative(projectsRoot, resolvedCandidate);
1312
+ const segments = relativePath.split(/[\\/]+/u).filter(Boolean);
1313
+ return relativePath !== ''
1314
+ && !relativePath.startsWith('..')
1315
+ && segments.length === 2
1316
+ && resolvedCandidate.endsWith('.jsonl')
1317
+ && !resolvedCandidate.endsWith('.checkpoints.jsonl');
1318
+ }
1319
+ /** 只读 JSONL 首条记录,避免探测大 transcript 时把整份文件载入内存。 */
1320
+ function readFirstJsonRecord(path) {
1321
+ const descriptor = openSync(path, 'r');
1322
+ try {
1323
+ const buffer = Buffer.allocUnsafe(64 * 1024);
1324
+ const bytes = readSync(descriptor, buffer, 0, buffer.length, 0);
1325
+ const firstLine = buffer.subarray(0, bytes).toString('utf8').split(/\r?\n/u).find((line) => line.trim() !== '');
1326
+ return firstLine === undefined ? null : parseJson(firstLine);
1327
+ }
1328
+ finally {
1329
+ closeSync(descriptor);
1330
+ }
1331
+ }
1332
+ /**
1333
+ * Command Code 的 `--session <临时路径>` 在部分版本只落检查点文件,不创建主 transcript。
1334
+ * 检查点足以证明会话仍可被 `--resume` 找到,但不包含完整消息历史,因此只用于探测回退。
1335
+ */
1336
+ function resolveCommandCodeCheckpointPath(homeDirectory, cwd, providerSessionId) {
1337
+ const expected = join(homeDirectory, 'projects', workspaceSlug(cwd), `${providerSessionId}.checkpoints.jsonl`);
1338
+ if (existsSync(expected))
1339
+ return expected;
1340
+ const projectsRoot = join(homeDirectory, 'projects');
1341
+ try {
1342
+ for (const entry of readdirSync(projectsRoot)) {
1343
+ const candidate = join(projectsRoot, entry, `${providerSessionId}.checkpoints.jsonl`);
1344
+ if (existsSync(candidate))
1345
+ return candidate;
1346
+ }
1347
+ }
1348
+ catch {
1349
+ // projects 目录不存在说明 CLI 还没写过检查点。
1350
+ }
1351
+ return null;
1352
+ }
829
1353
  /** CLI 的 canonical 目录名:绝对路径去掉前导分隔符,非字母数字统一换成连字符并转小写。 */
830
1354
  function workspaceSlug(workspacePath) {
831
1355
  return workspacePath.replace(/[\\/]+$/, '')
@@ -864,6 +1388,14 @@ function readSessionId(event) {
864
1388
  const value = textValue(event.sessionId ?? event.session_id ?? recordValue(event.session)?.id ?? recordValue(event.result)?.sessionId).trim();
865
1389
  return value === '' ? null : value;
866
1390
  }
1391
+ /** 会话探测由 Registry 控制超时;文件扫描期间也必须尊重取消信号。 */
1392
+ function throwIfCommandCodeProbeAborted(signal) {
1393
+ if (signal?.aborted !== true)
1394
+ return;
1395
+ const error = new Error('Command Code 会话探测已取消');
1396
+ error.name = 'AbortError';
1397
+ throw error;
1398
+ }
867
1399
  function textValue(value) {
868
1400
  return typeof value === 'string' ? value : value === undefined || value === null ? '' : structuredText(value);
869
1401
  }
@@ -881,22 +1413,97 @@ function recordValue(value) {
881
1413
  return isRecord(value) ? value : null;
882
1414
  }
883
1415
  function writeTranscript(path, input) {
1416
+ mkdirSync(dirname(path), { recursive: true });
884
1417
  const history = input.messages.length > 0 ? input.messages.slice(0, -1) : [];
885
1418
  let parentId = null;
886
1419
  const lines = [JSON.stringify({ type: 'session', version: 3, id: input.sessionId, timestamp: new Date().toISOString(), cwd: input.cwd ?? process.cwd() })];
887
1420
  history.forEach((message, index) => {
888
- if (message.role !== 'user' && message.role !== 'assistant')
1421
+ if (message.role !== 'user' && message.role !== 'assistant' && message.role !== 'tool')
1422
+ return;
1423
+ const content = extractText(message.content, message);
1424
+ if (content.length === 0)
889
1425
  return;
890
1426
  const id = message.id ?? `message-${index}`;
891
- lines.push(JSON.stringify({ type: 'message', id, parentId, timestamp: new Date().toISOString(), message: { role: message.role, content: [{ type: 'text', text: extractText(message.content) }] } }));
1427
+ const role = message.role === 'tool' ? 'user' : message.role;
1428
+ lines.push(JSON.stringify({ type: 'message', id, parentId, timestamp: new Date().toISOString(), message: { role, content } }));
892
1429
  parentId = id;
893
1430
  });
894
1431
  writeFileSync(path, `${lines.join('\n')}\n`, 'utf8');
895
1432
  }
896
- function extractText(content) { if (typeof content === 'string')
897
- return content; if (!Array.isArray(content))
898
- return ''; return content.filter(isRecord).map((part) => typeof part.text === 'string' ? part.text : '').join('\n').trim(); }
1433
+ /** 把 DSH 消息块转换为 Command Code 原生 transcript 块,保留工具和推理语义。 */
1434
+ function extractText(content, message) {
1435
+ if (message.role === 'tool') {
1436
+ const toolCallId = message.toolCallId ?? message.source?.callId;
1437
+ if (toolCallId === undefined || toolCallId.trim() === '')
1438
+ return [];
1439
+ return [{ type: 'tool_result', tool_use_id: toolCallId, content: extractToolResultContent(content) }];
1440
+ }
1441
+ if (typeof content === 'string')
1442
+ return content === '' ? [] : [{ type: 'text', text: content }];
1443
+ if (!Array.isArray(content))
1444
+ return [];
1445
+ const blocks = [];
1446
+ for (const part of content) {
1447
+ if (!isRecord(part))
1448
+ continue;
1449
+ if (part.type === 'tool-call') {
1450
+ const id = typeof part.id === 'string' ? part.id.trim() : '';
1451
+ const name = typeof part.name === 'string' ? part.name.trim() : '';
1452
+ if (id === '' || name === '')
1453
+ continue;
1454
+ blocks.push({ type: 'tool_use', id, name, input: parseToolInput(part.arguments ?? part.input) });
1455
+ continue;
1456
+ }
1457
+ if (part.type === 'tool-result') {
1458
+ const toolUseId = firstText(part.toolCallId, part.tool_use_id, part.toolUseId);
1459
+ if (toolUseId !== '')
1460
+ blocks.push({ type: 'tool_result', tool_use_id: toolUseId, content: extractToolResultContent(part.content ?? part.output ?? part.result) });
1461
+ continue;
1462
+ }
1463
+ if (part.type === 'thinking' || part.type === 'reasoning') {
1464
+ const thinking = firstText(part.thinking, part.reasoning, part.text, part.content);
1465
+ if (thinking !== '')
1466
+ blocks.push({ type: 'thinking', thinking });
1467
+ continue;
1468
+ }
1469
+ const text = typeof part.text === 'string' ? part.text : '';
1470
+ if (text !== '')
1471
+ blocks.push({ type: 'text', text });
1472
+ }
1473
+ return blocks;
1474
+ }
1475
+ function extractToolResultContent(content) {
1476
+ if (typeof content === 'string')
1477
+ return [{ type: 'text', text: content }];
1478
+ if (Array.isArray(content)) {
1479
+ const parts = content.filter(isRecord).map((part) => {
1480
+ if (typeof part.text === 'string')
1481
+ return { type: 'text', text: part.text };
1482
+ return null;
1483
+ }).filter((part) => part !== null);
1484
+ if (parts.length > 0)
1485
+ return parts;
1486
+ }
1487
+ return [{ type: 'text', text: structuredText(content) }];
1488
+ }
1489
+ function parseToolInput(value) {
1490
+ if (typeof value !== 'string')
1491
+ return value ?? {};
1492
+ try {
1493
+ return JSON.parse(value);
1494
+ }
1495
+ catch {
1496
+ return value;
1497
+ }
1498
+ }
1499
+ function firstText(...values) {
1500
+ return values.find((value) => typeof value === 'string' && value !== '') ?? '';
1501
+ }
899
1502
  function safeId(value) { return value.replace(/[^a-zA-Z0-9._-]+/gu, '_').slice(0, 96) || 'default'; }
1503
+ /** 旧驱动生成的 Host synthetic ID;没有 canonical transcript 时必须放弃 --resume。 */
1504
+ function isLegacySyntheticSessionId(value) {
1505
+ return value.startsWith('codingns4dsh-cc-session-') || value.startsWith('dsh-codingns-cc-session-');
1506
+ }
900
1507
  function parseJson(value) { try {
901
1508
  const parsed = JSON.parse(value);
902
1509
  return isRecord(parsed) ? parsed : null;