@jingyi0605/codingns4dsh 0.2.1-beta.7 → 0.2.1-beta.9

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 (301) hide show
  1. package/README.en.md +3 -3
  2. package/README.md +9 -3
  3. package/data/build/dist/bootstrap/dsh-peer-host-preboot-shim.d.ts.map +1 -1
  4. package/data/build/dist/bootstrap/dsh-peer-host-preboot-shim.js +26 -1
  5. package/data/build/dist/bootstrap/dsh-peer-host-preboot-shim.js.map +1 -1
  6. package/data/build/dist/client/account-bar.d.ts.map +1 -1
  7. package/data/build/dist/client/account-bar.js +33 -21
  8. package/data/build/dist/client/account-bar.js.map +1 -1
  9. package/data/build/dist/client/avatar/desktop-bridge.js +1 -1
  10. package/data/build/dist/client/avatar/desktop-bridge.js.map +1 -1
  11. package/data/build/dist/client/avatar/desktop-view.d.ts +6 -2
  12. package/data/build/dist/client/avatar/desktop-view.d.ts.map +1 -1
  13. package/data/build/dist/client/avatar/desktop-view.js +48 -13
  14. package/data/build/dist/client/avatar/desktop-view.js.map +1 -1
  15. package/data/build/dist/client/avatar/floating.d.ts +5 -2
  16. package/data/build/dist/client/avatar/floating.d.ts.map +1 -1
  17. package/data/build/dist/client/avatar/floating.js +16 -5
  18. package/data/build/dist/client/avatar/floating.js.map +1 -1
  19. package/data/build/dist/client/avatar/notification-bubble.d.ts +24 -5
  20. package/data/build/dist/client/avatar/notification-bubble.d.ts.map +1 -1
  21. package/data/build/dist/client/avatar/notification-bubble.js +253 -66
  22. package/data/build/dist/client/avatar/notification-bubble.js.map +1 -1
  23. package/data/build/dist/client/avatar/notification-surface.d.ts +16 -0
  24. package/data/build/dist/client/avatar/notification-surface.d.ts.map +1 -0
  25. package/data/build/dist/client/avatar/notification-surface.js +54 -0
  26. package/data/build/dist/client/avatar/notification-surface.js.map +1 -0
  27. package/data/build/dist/client/avatar/reaction-badge.d.ts.map +1 -1
  28. package/data/build/dist/client/avatar/reaction-badge.js +11 -2
  29. package/data/build/dist/client/avatar/reaction-badge.js.map +1 -1
  30. package/data/build/dist/client/bundle.js +2628 -566
  31. package/data/build/dist/client/bundle.js.map +1 -1
  32. package/data/build/dist/client/cli-slots.d.ts.map +1 -1
  33. package/data/build/dist/client/cli-slots.js +26 -2
  34. package/data/build/dist/client/cli-slots.js.map +1 -1
  35. package/data/build/dist/client/client.assistant-notifications.js.map +1 -1
  36. package/data/build/dist/client/client.assistant-workbench.js +235 -109
  37. package/data/build/dist/client/client.assistant-workbench.js.map +1 -1
  38. package/data/build/dist/client/client.delegate-command.js +6 -6
  39. package/data/build/dist/client/client.delegate-command.js.map +1 -1
  40. package/data/build/dist/client/client.manager.js +46 -9
  41. package/data/build/dist/client/client.manager.js.map +1 -1
  42. package/data/build/dist/client/client.native-workspace-store.js +39 -3
  43. package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
  44. package/data/build/dist/client/client.session-translation.js +54 -0
  45. package/data/build/dist/client/client.session-translation.js.map +1 -0
  46. package/data/build/dist/client/client.theme.js +2 -0
  47. package/data/build/dist/client/client.theme.js.map +1 -1
  48. package/data/build/dist/client/client.transport.js +123 -11
  49. package/data/build/dist/client/client.transport.js.map +1 -1
  50. package/data/build/dist/client/desktop-assistant.js +57927 -387
  51. package/data/build/dist/client/features/assistant-conversation-message.d.ts +2 -1
  52. package/data/build/dist/client/features/assistant-conversation-message.d.ts.map +1 -1
  53. package/data/build/dist/client/features/assistant-conversation-message.js +59 -24
  54. package/data/build/dist/client/features/assistant-conversation-message.js.map +1 -1
  55. package/data/build/dist/client/features/assistant-notification-store.d.ts +8 -2
  56. package/data/build/dist/client/features/assistant-notification-store.d.ts.map +1 -1
  57. package/data/build/dist/client/features/assistant-notification-store.js +45 -1
  58. package/data/build/dist/client/features/assistant-notification-store.js.map +1 -1
  59. package/data/build/dist/client/features/assistant-record-style.js +11 -4
  60. package/data/build/dist/client/features/assistant-record-style.js.map +1 -1
  61. package/data/build/dist/client/features/assistant-workbench.d.ts +4 -0
  62. package/data/build/dist/client/features/assistant-workbench.d.ts.map +1 -1
  63. package/data/build/dist/client/features/assistant-workbench.js +27 -1
  64. package/data/build/dist/client/features/assistant-workbench.js.map +1 -1
  65. package/data/build/dist/client/features/global-voice-assistant.d.ts.map +1 -1
  66. package/data/build/dist/client/features/global-voice-assistant.js +46 -8
  67. package/data/build/dist/client/features/global-voice-assistant.js.map +1 -1
  68. package/data/build/dist/client/features/index.d.ts +1 -0
  69. package/data/build/dist/client/features/index.d.ts.map +1 -1
  70. package/data/build/dist/client/features/index.js +3 -0
  71. package/data/build/dist/client/features/index.js.map +1 -1
  72. package/data/build/dist/client/features/peer-host.d.ts.map +1 -1
  73. package/data/build/dist/client/features/peer-host.js +130 -17
  74. package/data/build/dist/client/features/peer-host.js.map +1 -1
  75. package/data/build/dist/client/features/session-translation.d.ts +3 -0
  76. package/data/build/dist/client/features/session-translation.d.ts.map +1 -0
  77. package/data/build/dist/client/features/session-translation.js +116 -0
  78. package/data/build/dist/client/features/session-translation.js.map +1 -0
  79. package/data/build/dist/client/index.d.ts.map +1 -1
  80. package/data/build/dist/client/index.js +6 -1
  81. package/data/build/dist/client/index.js.map +1 -1
  82. package/data/build/dist/client/locales/assistantWorkbench.d.ts +17 -3
  83. package/data/build/dist/client/locales/assistantWorkbench.d.ts.map +1 -1
  84. package/data/build/dist/client/locales/assistantWorkbench.js +15 -11
  85. package/data/build/dist/client/locales/assistantWorkbench.js.map +1 -1
  86. package/data/build/dist/client/locales/panels.d.ts.map +1 -1
  87. package/data/build/dist/client/locales/panels.js +62 -0
  88. package/data/build/dist/client/locales/panels.js.map +1 -1
  89. package/data/build/dist/client/peer-host-native-projection.d.ts +4 -0
  90. package/data/build/dist/client/peer-host-native-projection.d.ts.map +1 -1
  91. package/data/build/dist/client/peer-host-native-projection.js +40 -1
  92. package/data/build/dist/client/peer-host-native-projection.js.map +1 -1
  93. package/data/build/dist/client/peer-host-remote-events.d.ts +14 -0
  94. package/data/build/dist/client/peer-host-remote-events.d.ts.map +1 -1
  95. package/data/build/dist/client/peer-host-remote-events.js +92 -3
  96. package/data/build/dist/client/peer-host-remote-events.js.map +1 -1
  97. package/data/build/dist/client/session-file-links.d.ts +11 -0
  98. package/data/build/dist/client/session-file-links.d.ts.map +1 -0
  99. package/data/build/dist/client/{peer-host-file-links.js → session-file-links.js} +13 -3
  100. package/data/build/dist/client/session-file-links.js.map +1 -0
  101. package/data/build/dist/client/session-translation-chat.d.ts +6 -0
  102. package/data/build/dist/client/session-translation-chat.d.ts.map +1 -0
  103. package/data/build/dist/client/session-translation-chat.js +686 -0
  104. package/data/build/dist/client/session-translation-chat.js.map +1 -0
  105. package/data/build/dist/client/style.css +2561 -0
  106. package/data/build/dist/client/subscription-slot.d.ts.map +1 -1
  107. package/data/build/dist/client/subscription-slot.js +5 -1
  108. package/data/build/dist/client/subscription-slot.js.map +1 -1
  109. package/data/build/dist/client/theme.d.ts +2 -0
  110. package/data/build/dist/client/theme.d.ts.map +1 -1
  111. package/data/build/dist/client/theme.js +3 -0
  112. package/data/build/dist/client/theme.js.map +1 -1
  113. package/data/build/dist/client/workspace-session-visibility-dom.d.ts.map +1 -1
  114. package/data/build/dist/client/workspace-session-visibility-dom.js +43 -15
  115. package/data/build/dist/client/workspace-session-visibility-dom.js.map +1 -1
  116. package/data/build/dist/dsh-capabilities/client/assistant-session-navigation-adapter.d.ts +9 -1
  117. package/data/build/dist/dsh-capabilities/client/assistant-session-navigation-adapter.d.ts.map +1 -1
  118. package/data/build/dist/dsh-capabilities/client/assistant-session-navigation-adapter.js +65 -0
  119. package/data/build/dist/dsh-capabilities/client/assistant-session-navigation-adapter.js.map +1 -1
  120. package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts +21 -0
  121. package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts.map +1 -1
  122. package/data/build/dist/host/cli-adapters/acp-cli-driver.js +100 -3
  123. package/data/build/dist/host/cli-adapters/acp-cli-driver.js.map +1 -1
  124. package/data/build/dist/host/cli-adapters/codex-driver.d.ts +11 -1
  125. package/data/build/dist/host/cli-adapters/codex-driver.d.ts.map +1 -1
  126. package/data/build/dist/host/cli-adapters/codex-driver.js +80 -14
  127. package/data/build/dist/host/cli-adapters/codex-driver.js.map +1 -1
  128. package/data/build/dist/host/cli-adapters/codex-file-citations.d.ts +13 -0
  129. package/data/build/dist/host/cli-adapters/codex-file-citations.d.ts.map +1 -0
  130. package/data/build/dist/host/cli-adapters/codex-file-citations.js +271 -0
  131. package/data/build/dist/host/cli-adapters/codex-file-citations.js.map +1 -0
  132. package/data/build/dist/host/cli-adapters/command-code-acp-loader.d.ts +8 -1
  133. package/data/build/dist/host/cli-adapters/command-code-acp-loader.d.ts.map +1 -1
  134. package/data/build/dist/host/cli-adapters/command-code-acp-loader.js +45 -2
  135. package/data/build/dist/host/cli-adapters/command-code-acp-loader.js.map +1 -1
  136. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +8 -2
  137. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts.map +1 -1
  138. package/data/build/dist/host/cli-adapters/command-code-driver.js +32 -3
  139. package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
  140. package/data/build/dist/host/cli-adapters/command-code-history.d.ts +27 -0
  141. package/data/build/dist/host/cli-adapters/command-code-history.d.ts.map +1 -1
  142. package/data/build/dist/host/cli-adapters/command-code-history.js +131 -1
  143. package/data/build/dist/host/cli-adapters/command-code-history.js.map +1 -1
  144. package/data/build/dist/host/cli-adapters/delegation-mention-rewrite.js +9 -9
  145. package/data/build/dist/host/cli-adapters/delegation-mention-rewrite.js.map +1 -1
  146. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +13 -1
  147. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts.map +1 -1
  148. package/data/build/dist/host/cli-adapters/dsh-message-projector.js +95 -12
  149. package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
  150. package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
  151. package/data/build/dist/host/cli-adapters/feature.js +287 -19
  152. package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
  153. package/data/build/dist/host/cli-adapters/grok-driver.d.ts.map +1 -1
  154. package/data/build/dist/host/cli-adapters/grok-driver.js +108 -47
  155. package/data/build/dist/host/cli-adapters/grok-driver.js.map +1 -1
  156. package/data/build/dist/host/cli-adapters/legacy-session-settings.d.ts.map +1 -1
  157. package/data/build/dist/host/cli-adapters/legacy-session-settings.js +7 -2
  158. package/data/build/dist/host/cli-adapters/legacy-session-settings.js.map +1 -1
  159. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +4 -2
  160. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts.map +1 -1
  161. package/data/build/dist/host/cli-adapters/opencode-driver.js +78 -31
  162. package/data/build/dist/host/cli-adapters/opencode-driver.js.map +1 -1
  163. package/data/build/dist/host/cli-adapters/opencode-v2-protocol.d.ts +1 -1
  164. package/data/build/dist/host/cli-adapters/opencode-v2-protocol.d.ts.map +1 -1
  165. package/data/build/dist/host/cli-adapters/opencode-v2-protocol.js +83 -9
  166. package/data/build/dist/host/cli-adapters/opencode-v2-protocol.js.map +1 -1
  167. package/data/build/dist/host/cli-adapters/provider-subscription.d.ts +5 -1
  168. package/data/build/dist/host/cli-adapters/provider-subscription.d.ts.map +1 -1
  169. package/data/build/dist/host/cli-adapters/provider-subscription.js +90 -25
  170. package/data/build/dist/host/cli-adapters/provider-subscription.js.map +1 -1
  171. package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
  172. package/data/build/dist/host/cli-adapters/registry.js +22 -5
  173. package/data/build/dist/host/cli-adapters/registry.js.map +1 -1
  174. package/data/build/dist/host/cli-adapters/session-store.d.ts +1 -0
  175. package/data/build/dist/host/cli-adapters/session-store.d.ts.map +1 -1
  176. package/data/build/dist/host/cli-adapters/session-store.js +3 -0
  177. package/data/build/dist/host/cli-adapters/session-store.js.map +1 -1
  178. package/data/build/dist/host/cli-bridge/bridge-server.js +2 -2
  179. package/data/build/dist/host/cli-bridge/bridge-server.js.map +1 -1
  180. package/data/build/dist/host/cli-bridge/command-code-mod.js +21 -21
  181. package/data/build/dist/host/cli-bridge/command-code-mod.js.map +1 -1
  182. package/data/build/dist/host/cli-bridge/dispatch.js +19 -19
  183. package/data/build/dist/host/cli-bridge/dispatch.js.map +1 -1
  184. package/data/build/dist/host/cli-bridge/injections.d.ts +32 -0
  185. package/data/build/dist/host/cli-bridge/injections.d.ts.map +1 -1
  186. package/data/build/dist/host/cli-bridge/injections.js +137 -1
  187. package/data/build/dist/host/cli-bridge/injections.js.map +1 -1
  188. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js +20 -20
  189. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js.map +1 -1
  190. package/data/build/dist/host/desktop-assistant/controller.d.ts +3 -0
  191. package/data/build/dist/host/desktop-assistant/controller.d.ts.map +1 -1
  192. package/data/build/dist/host/desktop-assistant/controller.js +49 -4
  193. package/data/build/dist/host/desktop-assistant/controller.js.map +1 -1
  194. package/data/build/dist/host/desktop-assistant/mac-agent.d.ts.map +1 -1
  195. package/data/build/dist/host/desktop-assistant/mac-agent.js +15 -3
  196. package/data/build/dist/host/desktop-assistant/mac-agent.js.map +1 -1
  197. package/data/build/dist/host/desktop-assistant/win-agent.d.ts.map +1 -1
  198. package/data/build/dist/host/desktop-assistant/win-agent.js +21 -3
  199. package/data/build/dist/host/desktop-assistant/win-agent.js.map +1 -1
  200. package/data/build/dist/host/features/assistant-management-tools.d.ts +2 -1
  201. package/data/build/dist/host/features/assistant-management-tools.d.ts.map +1 -1
  202. package/data/build/dist/host/features/assistant-management-tools.js +10 -3
  203. package/data/build/dist/host/features/assistant-management-tools.js.map +1 -1
  204. package/data/build/dist/host/features/assistant-notification-events.js +1 -1
  205. package/data/build/dist/host/features/assistant-notification-events.js.map +1 -1
  206. package/data/build/dist/host/features/assistant-notifications.d.ts +8 -1
  207. package/data/build/dist/host/features/assistant-notifications.d.ts.map +1 -1
  208. package/data/build/dist/host/features/assistant-notifications.js +114 -12
  209. package/data/build/dist/host/features/assistant-notifications.js.map +1 -1
  210. package/data/build/dist/host/features/global-voice-rpc.d.ts +2 -2
  211. package/data/build/dist/host/features/global-voice-rpc.d.ts.map +1 -1
  212. package/data/build/dist/host/features/global-voice-rpc.js +89 -2
  213. package/data/build/dist/host/features/global-voice-rpc.js.map +1 -1
  214. package/data/build/dist/host/features/index.d.ts +1 -0
  215. package/data/build/dist/host/features/index.d.ts.map +1 -1
  216. package/data/build/dist/host/features/index.js +3 -0
  217. package/data/build/dist/host/features/index.js.map +1 -1
  218. package/data/build/dist/host/features/peer-host.d.ts.map +1 -1
  219. package/data/build/dist/host/features/peer-host.js +41 -5
  220. package/data/build/dist/host/features/peer-host.js.map +1 -1
  221. package/data/build/dist/host/features/session-translation-service.d.ts +31 -0
  222. package/data/build/dist/host/features/session-translation-service.d.ts.map +1 -0
  223. package/data/build/dist/host/features/session-translation-service.js +451 -0
  224. package/data/build/dist/host/features/session-translation-service.js.map +1 -0
  225. package/data/build/dist/host/features/session-translation.d.ts +5 -0
  226. package/data/build/dist/host/features/session-translation.d.ts.map +1 -0
  227. package/data/build/dist/host/features/session-translation.js +37 -0
  228. package/data/build/dist/host/features/session-translation.js.map +1 -0
  229. package/data/build/dist/host/features/types.d.ts +6 -1
  230. package/data/build/dist/host/features/types.d.ts.map +1 -1
  231. package/data/build/dist/host/image-artifact-store.d.ts +21 -0
  232. package/data/build/dist/host/image-artifact-store.d.ts.map +1 -0
  233. package/data/build/dist/host/image-artifact-store.js +136 -0
  234. package/data/build/dist/host/image-artifact-store.js.map +1 -0
  235. package/data/build/dist/host/index.d.ts.map +1 -1
  236. package/data/build/dist/host/index.js +3 -0
  237. package/data/build/dist/host/index.js.map +1 -1
  238. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts +7 -1
  239. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts.map +1 -1
  240. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js +23 -4
  241. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js.map +1 -1
  242. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.d.ts +1 -1
  243. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.d.ts.map +1 -1
  244. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.js +2 -0
  245. package/data/build/dist/host/modules/peer-host/peer-host-native-protocol.js.map +1 -1
  246. package/data/build/dist/host/native-session-bridge.d.ts +16 -1
  247. package/data/build/dist/host/native-session-bridge.d.ts.map +1 -1
  248. package/data/build/dist/host/native-session-bridge.js +69 -9
  249. package/data/build/dist/host/native-session-bridge.js.map +1 -1
  250. package/data/build/dist/host/rpc.js +4 -4
  251. package/data/build/dist/host/rpc.js.map +1 -1
  252. package/data/build/dist/host/session-changes.d.ts.map +1 -1
  253. package/data/build/dist/host/session-changes.js +196 -13
  254. package/data/build/dist/host/session-changes.js.map +1 -1
  255. package/data/build/dist/host/settings.d.ts.map +1 -1
  256. package/data/build/dist/host/settings.js +8 -0
  257. package/data/build/dist/host/settings.js.map +1 -1
  258. package/data/build/dist/shared/assistant-message-timeline.d.ts +11 -0
  259. package/data/build/dist/shared/assistant-message-timeline.d.ts.map +1 -1
  260. package/data/build/dist/shared/assistant-message-timeline.js +19 -0
  261. package/data/build/dist/shared/assistant-message-timeline.js.map +1 -1
  262. package/data/build/dist/shared/assistant-notifications.d.ts +35 -1
  263. package/data/build/dist/shared/assistant-notifications.d.ts.map +1 -1
  264. package/data/build/dist/shared/assistant-notifications.js +8 -0
  265. package/data/build/dist/shared/assistant-notifications.js.map +1 -1
  266. package/data/build/dist/shared/assistant-session-messages.d.ts +13 -0
  267. package/data/build/dist/shared/assistant-session-messages.d.ts.map +1 -0
  268. package/data/build/dist/shared/assistant-session-messages.js +155 -0
  269. package/data/build/dist/shared/assistant-session-messages.js.map +1 -0
  270. package/data/build/dist/shared/contracts/assistant.d.ts +13 -0
  271. package/data/build/dist/shared/contracts/assistant.d.ts.map +1 -1
  272. package/data/build/dist/shared/contracts/cli-adapter.d.ts +25 -2
  273. package/data/build/dist/shared/contracts/cli-adapter.d.ts.map +1 -1
  274. package/data/build/dist/shared/contracts/config.d.ts +6 -0
  275. package/data/build/dist/shared/contracts/config.d.ts.map +1 -1
  276. package/data/build/dist/shared/contracts/config.js +3 -0
  277. package/data/build/dist/shared/contracts/config.js.map +1 -1
  278. package/data/build/dist/shared/contracts/session-translation.d.ts +58 -0
  279. package/data/build/dist/shared/contracts/session-translation.d.ts.map +1 -0
  280. package/data/build/dist/shared/contracts/session-translation.js +23 -0
  281. package/data/build/dist/shared/contracts/session-translation.js.map +1 -0
  282. package/data/build/dist/shared/contracts/version.d.ts +1 -1
  283. package/data/build/dist/shared/contracts/version.js +1 -1
  284. package/data/build/dist/shared/delegation-carrier.js +6 -6
  285. package/data/build/dist/shared/delegation-carrier.js.map +1 -1
  286. package/data/build/dist/shared/desktop-assistant.d.ts +10 -3
  287. package/data/build/dist/shared/desktop-assistant.d.ts.map +1 -1
  288. package/data/build/dist/shared/desktop-assistant.js +46 -14
  289. package/data/build/dist/shared/desktop-assistant.js.map +1 -1
  290. package/data/build/dist/shared/index.d.ts +2 -1
  291. package/data/build/dist/shared/index.d.ts.map +1 -1
  292. package/data/build/dist/shared/index.js +2 -1
  293. package/data/build/dist/shared/index.js.map +1 -1
  294. package/package.json +17 -15
  295. package/profile/README.md +2 -2
  296. package/profile/package.json +2 -2
  297. package/profile/version.json +1 -1
  298. package/version.json +1 -1
  299. package/data/build/dist/client/peer-host-file-links.d.ts +0 -8
  300. package/data/build/dist/client/peer-host-file-links.d.ts.map +0 -1
  301. package/data/build/dist/client/peer-host-file-links.js.map +0 -1
@@ -1,11 +1,17 @@
1
1
  import { spawn, spawnSync } from 'node:child_process';
2
2
  import type { CodingNsAgentEvent, CodingNsAgentQuestionResponse, CodingNsCliModelCatalog, CodingNsAgentPermissionResponse, CodingNsCliTurnInput, CodingNsCliSkillDescriptor, CodingNsCliSkillListInput } from '../../shared/contracts/cli-adapter.js';
3
3
  import type { CodingNsCliDriver, CodingNsCliSessionProbeInput, CodingNsCliSessionProbeResult } from './driver.js';
4
+ import { type CodexComputerUseMode, type CodexComputerUseServerConfig } from '../cli-bridge/injections.js';
4
5
  export interface CodexAppServerDriverOptions {
5
6
  readonly binaries?: readonly string[];
6
7
  readonly sessionRoots?: readonly string[];
7
8
  readonly spawnSync?: typeof spawnSync;
8
9
  readonly spawn?: typeof spawn;
10
+ /** Computer Use 运行时策略;生产 Feature 使用 auto,受限部署可显式关闭。 */
11
+ readonly computerUse?: CodexComputerUseMode;
12
+ /** 注入测试或受控部署提供的官方 cua_repl 配置。 */
13
+ readonly computerUseConfig?: CodexComputerUseServerConfig;
14
+ readonly codexHome?: string;
9
15
  }
10
16
  /** Codex app-server 的 JSON-RPC 驱动,Host 只暴露统一文本流,不暴露线程和 token。 */
11
17
  export declare class CodexAppServerDriver implements CodingNsCliDriver {
@@ -13,7 +19,7 @@ export declare class CodexAppServerDriver implements CodingNsCliDriver {
13
19
  readonly id: "codex";
14
20
  readonly name: "Codex";
15
21
  readonly protocol: "json-rpc";
16
- readonly capabilities: readonly ["models", "skills", "stream", "resume", "interrupt", "tool-events", "reasoning", "usage", "permission", "questions", "steer"];
22
+ readonly capabilities: readonly ["models", "skills", "stream", "resume", "interrupt", "tool-events", "reasoning", "usage", "permission", "questions", "steer", "computer-use"];
17
23
  };
18
24
  readonly supportsSegmentedTurns = true;
19
25
  private readonly binaries;
@@ -22,6 +28,8 @@ export declare class CodexAppServerDriver implements CodingNsCliDriver {
22
28
  private readonly sessionRoots;
23
29
  /** Codex 配置根目录;`config.toml` 与 `auth.json` 都位于这里。 */
24
30
  private readonly codexHome;
31
+ private readonly computerUseMode;
32
+ private readonly computerUseConfig;
25
33
  private cachedBinary;
26
34
  private readonly processes;
27
35
  private readonly sessions;
@@ -55,6 +63,7 @@ export declare class CodexAppServerDriver implements CodingNsCliDriver {
55
63
  */
56
64
  listSkills(input: CodingNsCliSkillListInput): Promise<readonly CodingNsCliSkillDescriptor[]>;
57
65
  executeTurn(input: CodingNsCliTurnInput): AsyncIterable<CodingNsAgentEvent>;
66
+ private executeRawTurn;
58
67
  /**
59
68
  * 将一个 Codex turn 按 assistant item 切成多个 DSH step。
60
69
  *
@@ -111,6 +120,7 @@ export declare class CodexAppServerDriver implements CodingNsCliDriver {
111
120
  /** 回传 requestUserInput 的结构化回答。 */
112
121
  respondQuestion(sessionId: string, response: CodingNsAgentQuestionResponse): void;
113
122
  dispose(): void;
123
+ private appServerArgs;
114
124
  private getSession;
115
125
  }
116
126
  //# sourceMappingURL=codex-driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-driver.d.ts","sourceRoot":"","sources":["../../../../../src/host/cli-adapters/codex-driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAKrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,uBAAuB,EAA0B,+BAA+B,EAA0B,oBAAoB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACrS,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AASjH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,SAAS,CAAA;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CAC9B;AAoID,iEAAiE;AACjE,qBAAa,oBAAqB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,UAAU;;;;;MAAuN;IAG1O,QAAQ,CAAC,sBAAsB,QAAO;IACtC,OAAO,C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AK,EAAE,oBAAoB,GAAG,aAAa,CAAC,kBAAkB,CAAC;YAMnE,cAAc;IAiI7B;;;;;OAKG;YACY,oBAAoB;YAuDrB,kBAAkB;YA0EjB,cAAc;IAoE7B,OAAO,CAAC,kBAAkB;IAQ1B;;;;;;;;OAQG;YACW,gBAAgB;IAmB9B;;;;;;;;;;OAUG;YACW,sBAAsB;IAoBpC,2CAA2C;YAC7B,qBAAqB;IAQnC,qDAAqD;YACvC,SAAS;IAWvB,uEAAuE;YACzD,kBAAkB;YAiBlB,mBAAmB;IAiBjC,sEAAsE;YACxD,aAAa;YAgBb,iBAAiB;IAyF/B,iCAAiC;IAC3B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe7D,yCAAyC;IACnC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjD;;;OAGG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAM7C,iCAAiC;IACjC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,+BAA+B,GAAG,IAAI;IAuBrF,kCAAkC;IAClC,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,6BAA6B,GAAG,IAAI;IAQjF,OAAO,IAAI,IAAI;IAcf,OAAO,CAAC,aAAa;YAeP,UAAU;CAuEzB"}
@@ -9,20 +9,18 @@ import { CODEX_CATALOG, isProviderDefaultModel } from './model-catalog.js';
9
9
  import { probeStoredSession, readFirstJsonRecord } from './session-probe.js';
10
10
  import { firstToolText, normalizeToolStatus, serializeToolValue } from './tool-observation.js';
11
11
  import { isQuestionEvent, questionAnswersRecord, readAgentQuestions } from './interaction-events.js';
12
- import { codexBridgeArgs, codexBridgeDeveloperInstructions } from '../cli-bridge/injections.js';
12
+ import { codexBridgeArgs, codexBridgeDeveloperInstructions, codexComputerUseLaunchSettings } from '../cli-bridge/injections.js';
13
+ import { CodexFileCitationNormalizer } from './codex-file-citations.js';
13
14
  // 只有 Provider 已明确报告超过窗口时才主动压缩;接近上限仍交给 Codex
14
15
  // 自身的 auto-compact,避免对正常的高占用回合重复发起压缩。
15
16
  const CODEX_COMPACTION_THRESHOLD = 1;
16
17
  const CODEX_COMPACTION_TIMEOUT_MS = 60_000;
17
- // Codex CLI 默认会启用 computer_use;DSH 没有对应的桌面控制宿主,必须在
18
- // app-server 进程启动时关闭该 feature,避免模型进入无法完成的控制回合。
19
- const CODEX_APP_SERVER_ARGS = [
18
+ const CODEX_APP_SERVER_BASE_ARGS = [
20
19
  // 原生 request_permissions 默认关闭。必须在插件进程内启用,模型才能主动
21
20
  // 发出 item/permissions/requestApproval,而不是靠试写文件碰沙箱边界。
22
21
  // 用配置覆盖而非 --enable:旧版会忽略未知 feature 配置,保留原命令审批通道。
23
22
  '-c', 'features.request_permissions_tool=true',
24
23
  'app-server',
25
- '--disable', 'computer_use',
26
24
  // Codex 默认关闭 request_user_input;不开启时模型只能把“提问”写成普通文本,
27
25
  // app-server 不会发出 item/tool/requestUserInput,DSH 也就没有问题事件可投影。
28
26
  '--enable', 'default_mode_request_user_input',
@@ -49,6 +47,7 @@ const CODEX_QUESTION_DEVELOPER_INSTRUCTIONS = [
49
47
  */
50
48
  const CODEX_PERMISSION_DEVELOPER_INSTRUCTIONS = [
51
49
  'CodingNS 通过 DSH 原生审批面板处理权限申请,权限边界和审批策略以当前回合的运行时上下文为准。',
50
+ 'Computer Use 只在 macOS 官方 cua_repl 运行时可用,需要系统为运行时授予屏幕录制和辅助功能权限;权限不足时如实报告失败,不要反复重试或改用命令工具绕过拒绝。',
52
51
  '操作需要额外权限且当前审批策略允许交互时,优先调用原生 request_permissions 工具,申请完成任务所需的最小文件或网络权限,并等待结构化审批结果。',
53
52
  '用户要求主动触发或验证权限申请时,应自行选择当前允许范围之外的最小权限并调用 request_permissions;工作区、/tmp、/private/tmp 和 TMPDIR 可能已可写,在这些目录执行普通写入不等于发起审批。',
54
53
  '只有当前工具列表没有 request_permissions 时,才使用原生命令工具的 require_escalated 审批通道;工具参数和目标路径由你确定,不要要求用户编写提权命令。',
@@ -58,7 +57,7 @@ const CODEX_PERMISSION_DEVELOPER_INSTRUCTIONS = [
58
57
  ].join('\n');
59
58
  /** Codex app-server 的 JSON-RPC 驱动,Host 只暴露统一文本流,不暴露线程和 token。 */
60
59
  export class CodexAppServerDriver {
61
- descriptor = { id: 'codex', name: 'Codex', protocol: 'json-rpc', capabilities: ['models', 'skills', 'stream', 'resume', 'interrupt', 'tool-events', 'reasoning', 'usage', 'permission', 'questions', 'steer'] };
60
+ descriptor = { id: 'codex', name: 'Codex', protocol: 'json-rpc', capabilities: ['models', 'skills', 'stream', 'resume', 'interrupt', 'tool-events', 'reasoning', 'usage', 'permission', 'questions', 'steer', 'computer-use'] };
62
61
  // Codex 一个 Provider turn 可能同时包含多个工具调用。只有 assistant item
63
62
  // 切换后才分段,不能在每个工具完成后注入下一 step。
64
63
  supportsSegmentedTurns = true;
@@ -68,6 +67,8 @@ export class CodexAppServerDriver {
68
67
  sessionRoots;
69
68
  /** Codex 配置根目录;`config.toml` 与 `auth.json` 都位于这里。 */
70
69
  codexHome;
70
+ computerUseMode;
71
+ computerUseConfig;
71
72
  cachedBinary = null;
72
73
  processes = new Set();
73
74
  sessions = new Map();
@@ -75,8 +76,12 @@ export class CodexAppServerDriver {
75
76
  this.binaries = options.binaries ?? ['codex'];
76
77
  this.runSpawnSync = options.spawnSync ?? spawnSync;
77
78
  this.runSpawn = options.spawn ?? spawn;
78
- const codexHome = process.env.CODEX_HOME ?? join(homedir(), '.codex');
79
+ const codexHome = options.codexHome ?? process.env.CODEX_HOME ?? join(homedir(), '.codex');
79
80
  this.codexHome = codexHome;
81
+ // 直接构造驱动时保持旧的安全默认值;正式 Feature 显式传入 auto,避免测试
82
+ // 或第三方嵌入在没有桌面宿主时意外启动 CUA 运行时。
83
+ this.computerUseMode = options.computerUse ?? 'disabled';
84
+ this.computerUseConfig = options.computerUseConfig;
80
85
  this.sessionRoots = options.sessionRoots ?? [join(codexHome, 'sessions'), join(codexHome, 'archived_sessions')];
81
86
  }
82
87
  /**
@@ -113,7 +118,9 @@ export class CodexAppServerDriver {
113
118
  const command = this.cachedBinary ?? (await this.detect()).command;
114
119
  if (command === null)
115
120
  return emptyCatalog();
116
- const rpc = new JsonRpcProcess({ command, args: CODEX_APP_SERVER_ARGS, explicitWindowsShell: true, spawn: this.runSpawn });
121
+ // 模型目录查询不需要启动桌面运行时;否则每次刷新模型都会唤起 CUA 服务,
122
+ // 还可能在没有系统权限时把一个与模型无关的失败带进目录查询。
123
+ const rpc = new JsonRpcProcess({ command, args: this.appServerArgs(false), explicitWindowsShell: true, spawn: this.runSpawn });
117
124
  const controller = new AbortController();
118
125
  const timer = setTimeout(() => controller.abort(), 12_000);
119
126
  try {
@@ -181,6 +188,12 @@ export class CodexAppServerDriver {
181
188
  return [...session.skills.values()].map(({ path: _path, ...descriptor }) => descriptor);
182
189
  }
183
190
  async *executeTurn(input) {
191
+ const citations = new CodexFileCitationNormalizer();
192
+ for await (const chunk of this.executeRawTurn(input))
193
+ yield* citations.push(chunk);
194
+ yield* citations.flush();
195
+ }
196
+ async *executeRawTurn(input) {
184
197
  const command = this.cachedBinary ?? (await this.detect()).command;
185
198
  if (command === null)
186
199
  throw new Error('Codex 未安装');
@@ -285,7 +298,7 @@ export class CodexAppServerDriver {
285
298
  if (responseTerminal !== null)
286
299
  onNotification(responseTerminal);
287
300
  for await (const message of eventQueue.iterable) {
288
- const rawChunk = codexMessageToChunk(message);
301
+ const rawChunk = codexMessageToChunk(message, input.cwd);
289
302
  if (rawChunk === null)
290
303
  continue;
291
304
  for (const chunk of expandCodexCompactionChunk(session, rawChunk)) {
@@ -502,7 +515,7 @@ export class CodexAppServerDriver {
502
515
  }
503
516
  if (input.signal?.aborted)
504
517
  throw new Error('请求已取消');
505
- chunk = codexMessageToChunk(next.value);
518
+ chunk = codexMessageToChunk(next.value, input.cwd);
506
519
  }
507
520
  if (chunk === null)
508
521
  continue;
@@ -873,6 +886,16 @@ export class CodexAppServerDriver {
873
886
  this.processes.clear();
874
887
  this.cachedBinary = null;
875
888
  }
889
+ appServerArgs(includeComputerUse = true) {
890
+ const computerUse = codexComputerUseLaunchSettings(includeComputerUse ? this.computerUseMode : 'disabled', includeComputerUse ? this.computerUseConfig : undefined, this.codexHome);
891
+ return [
892
+ ...CODEX_APP_SERVER_BASE_ARGS.slice(0, 2),
893
+ ...computerUse.args,
894
+ ...CODEX_APP_SERVER_BASE_ARGS.slice(2, 3),
895
+ ...(computerUse.enabled ? ['--enable', 'computer_use'] : ['--disable', 'computer_use']),
896
+ ...CODEX_APP_SERVER_BASE_ARGS.slice(3),
897
+ ];
898
+ }
876
899
  async getSession(input, command) {
877
900
  const previous = this.sessions.get(input.sessionId);
878
901
  if (previous !== undefined && previous.cwd === input.cwd)
@@ -884,7 +907,7 @@ export class CodexAppServerDriver {
884
907
  const bridgeArgs = codexBridgeArgs(input.sessionId, this.descriptor.id);
885
908
  // Codex 的 `-c` 覆盖项必须与 app-server 的其余启动参数放在同一侧;
886
909
  // 统一置于子命令前,避免不同版本对全局/子命令参数的解析差异。
887
- const rpc = new JsonRpcProcess({ command, args: [...bridgeArgs, ...CODEX_APP_SERVER_ARGS], cwd: input.cwd, explicitWindowsShell: true, spawn: this.runSpawn });
910
+ const rpc = new JsonRpcProcess({ command, args: [...bridgeArgs, ...this.appServerArgs()], cwd: input.cwd, explicitWindowsShell: true, spawn: this.runSpawn });
888
911
  const session = {
889
912
  rpc,
890
913
  cwd: input.cwd,
@@ -1174,7 +1197,7 @@ function summarizeCodexAuth(auth) {
1174
1197
  const accountId = tokens !== undefined && typeof tokens.account_id === 'string' ? tokens.account_id : '';
1175
1198
  return `${mode}|apiKey=${hasApiKey}|tokens=${hasTokens}|account=${accountId}`;
1176
1199
  }
1177
- function codexMessageToChunk(message) {
1200
+ function codexMessageToChunk(message, cwd) {
1178
1201
  const params = isRecord(message.params) ? message.params : message;
1179
1202
  const item = isRecord(params.item) ? params.item : params;
1180
1203
  const method = typeof message.method === 'string' ? message.method : '';
@@ -1213,6 +1236,9 @@ function codexMessageToChunk(message) {
1213
1236
  const compactionId = readTurnId(message);
1214
1237
  return { type: 'context-compaction', phase: 'end', ...(compactionId === null ? {} : { compactionId }) };
1215
1238
  }
1239
+ const imageArtifact = codexImageArtifact(method, type, params, item, cwd);
1240
+ if (imageArtifact !== null)
1241
+ return imageArtifact;
1216
1242
  if (isQuestionEvent(`${method} ${type}`)) {
1217
1243
  const requestId = readRequestId(message) ?? readRequestId(params);
1218
1244
  const questions = readAgentQuestions(params.questions ?? item.questions ?? params);
@@ -1248,7 +1274,12 @@ function codexMessageToChunk(message) {
1248
1274
  return text ? { type: 'reasoning-delta', text, ...(messageId === undefined ? {} : { messageId }) } : null;
1249
1275
  }
1250
1276
  if (isCodexToolEvent(method, type)) {
1251
- const name = firstToolText(isFileChangeType(type) ? 'edit_file' : undefined, item.name, item.toolName, item.tool, item.command !== undefined ? 'command_execution' : undefined, type);
1277
+ const mcpToolName = type.replace(/[_-]/gu, '').toLowerCase() === 'mcptoolcall'
1278
+ ? firstToolText(item.server, item.tool) === undefined
1279
+ ? undefined
1280
+ : `${firstToolText(item.server) ?? 'mcp'}.${firstToolText(item.tool) ?? 'tool'}`
1281
+ : undefined;
1282
+ const name = firstToolText(isFileChangeType(type) ? 'edit_file' : undefined, mcpToolName, item.name, item.toolName, item.tool, item.command !== undefined ? 'command_execution' : undefined, type);
1252
1283
  const callId = firstToolText(item.callId, item.call_id, item.toolCallId, item.id, params.itemId);
1253
1284
  const agentId = firstToolText(item.agentId, item.agent_id, type.includes('agent') || type.includes('collab') ? item.id : undefined);
1254
1285
  const input = serializeToolValue(isFileChangeType(type) ? fileChangeToolInput(item) : item.arguments ?? item.input ?? item.command);
@@ -1266,7 +1297,7 @@ function codexMessageToChunk(message) {
1266
1297
  ...(callId ? { callId } : {}),
1267
1298
  ...(input !== undefined ? { input } : {}),
1268
1299
  ...(failed
1269
- ? { error: explicitError ?? output ?? `exit code ${String(item.exitCode ?? item.exit_code)}` }
1300
+ ? { error: explicitError ?? output ?? '工具执行失败' }
1270
1301
  : output === undefined ? {} : { output }),
1271
1302
  ...(!failed && output !== undefined ? { outputMode: 'snapshot' } : {}),
1272
1303
  ...(agentId ? { agentId } : {}),
@@ -1275,6 +1306,41 @@ function codexMessageToChunk(message) {
1275
1306
  }
1276
1307
  return codexUsageChunk(params);
1277
1308
  }
1309
+ /**
1310
+ * Codex image_gen 在不同版本有两种结果:旧版提供 saved_path,新版扩展可能只
1311
+ * 提供 image_generation_end.result 的 base64 PNG。两者都在 Host 内转成附件,不能
1312
+ * 把 result 放进普通工具文本,也不能让 Client 读取 Provider 的原始路径。
1313
+ */
1314
+ function codexImageArtifact(method, type, params, item, cwd) {
1315
+ const marker = `${method} ${type} ${firstToolText(item.name, item.toolName, item.tool) ?? ''}`.toLowerCase();
1316
+ if (!/(?:image[_/-]?generation|image[_/-]?gen|imagegeneration)/u.test(marker))
1317
+ return null;
1318
+ const rawPath = firstToolText(item.saved_path, item.savedPath, item.output_path, item.outputPath, item.image_path, item.imagePath, params.saved_path, params.savedPath);
1319
+ const path = rawPath === undefined ? undefined : resolve(cwd ?? process.cwd(), rawPath);
1320
+ const data = codexImageData(item.result ?? params.result ?? item.image ?? params.image);
1321
+ if (path === undefined && data === undefined)
1322
+ return null;
1323
+ return {
1324
+ type: 'image-artifact',
1325
+ ...(path === undefined ? {} : { path }),
1326
+ ...(data === undefined ? {} : { data }),
1327
+ ...(data === undefined ? {} : { mediaType: 'image/png' }),
1328
+ ...(path === undefined ? {} : { name: basename(path) }),
1329
+ };
1330
+ }
1331
+ function codexImageData(value) {
1332
+ if (typeof value === 'string') {
1333
+ const candidate = value.trim();
1334
+ if (/^data:image\/[A-Za-z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/u.test(candidate))
1335
+ return candidate;
1336
+ if (candidate.length >= 128 && candidate.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/u.test(candidate))
1337
+ return candidate;
1338
+ return undefined;
1339
+ }
1340
+ if (!isRecord(value))
1341
+ return undefined;
1342
+ return codexImageData(value.b64_json ?? value.base64 ?? value.data ?? value.image_url ?? value.url);
1343
+ }
1278
1344
  /** 判断分段续流是否带来了新的真实用户插话。 */
1279
1345
  function isCodexSteeringInput(input) {
1280
1346
  if (input.resumeSegmentedTurn !== true || input.prompt.trim() === '')