@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
@@ -0,0 +1,778 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
5
+ import { createConnection } from 'node:net';
6
+ const INTERNAL_DOMAINS = new Set([
7
+ 'copilot.tencent.com', 'staging-copilot.tencent.com', 'www.codebuddy.cn', 'staging.codebuddy.cn',
8
+ 'www.workbuddy.cn', 'staging.workbuddy.cn',
9
+ ]);
10
+ const EXTERNAL_DOMAINS = new Set([
11
+ 'www.codebuddy.ai', 'codebuddy.ai', 'staging-codebuddy.tencent.com',
12
+ 'www.workbuddy.ai', 'workbuddy.ai', 'staging.workbuddy.ai',
13
+ ]);
14
+ const DEFAULT_ORIGINS = {
15
+ cn: ['https://copilot.tencent.com', 'https://www.codebuddy.cn'],
16
+ international: ['https://www.codebuddy.ai', 'https://staging-codebuddy.tencent.com'],
17
+ };
18
+ /** WorkBuddy 使用独立产品域名,不能回退到 CodeBuddy 计费域名。 */
19
+ const WORKBUDDY_ORIGINS = {
20
+ cn: ['https://www.workbuddy.cn'],
21
+ international: ['https://www.workbuddy.ai'],
22
+ };
23
+ const ACCOUNT_STATUS_VALID = 0;
24
+ const ACCOUNT_STATUS_USED_UP = 3;
25
+ /**
26
+ * 读取 CodeBuddy/WorkBuddy 官方计费摘要。
27
+ *
28
+ * ACP 的 `usage_update` 只描述当前会话 token 消耗,不能代替套餐余额。
29
+ * 这里直接调用官方只读 billing API,并且把接口不稳定视为“暂无用量”,不影响会话。
30
+ */
31
+ export class CodeBuddySubscriptionService {
32
+ request;
33
+ timeoutMs;
34
+ homeDirectory;
35
+ authFiles;
36
+ origins;
37
+ constructor(options = {}) {
38
+ this.request = options.fetch ?? fetch;
39
+ this.timeoutMs = options.timeoutMs ?? 8_000;
40
+ this.homeDirectory = options.homeDirectory?.trim() || process.env.HOME?.trim() || homedir();
41
+ this.authFiles = options.authFiles;
42
+ this.origins = options.origins ?? {};
43
+ }
44
+ async read(adapterId) {
45
+ if (adapterId === 'workbuddy' && this.authFiles === undefined) {
46
+ const viaIpc = await this.readWorkBuddyViaIpc();
47
+ if (viaIpc !== null)
48
+ return viaIpc;
49
+ }
50
+ return this.readWithRequest(adapterId, this.request);
51
+ }
52
+ async readWithRequest(adapterId, request, overrideAuth) {
53
+ const authFiles = this.authFiles ?? defaultAuthFiles(this.homeDirectory, adapterId);
54
+ const regions = overrideAuth === undefined
55
+ ? orderRegions(regionsForAdapter(adapterId), authFiles)
56
+ : regionsForAdapter(adapterId).filter((region) => matchesRegion(overrideAuth.domain, region));
57
+ if (regions.length === 0)
58
+ return null;
59
+ for (const region of regions) {
60
+ const auth = overrideAuth ?? readCodeBuddyAuth(authFiles, region);
61
+ if (auth === null)
62
+ continue;
63
+ const defaultOrigins = adapterId === 'workbuddy' ? WORKBUDDY_ORIGINS : DEFAULT_ORIGINS;
64
+ const origins = uniqueOrigins(this.origins[region] ?? defaultOrigins[region]);
65
+ for (const origin of origins) {
66
+ if (auth.enterpriseId !== null) {
67
+ const enterprise = normalizeEnterpriseUsage(await this.post(origin, '/billing/meter/get-enterprise-user-usage', auth, region, {}, adapterId, request));
68
+ if (enterprise !== null)
69
+ return buildUsage(origin, enterprise.summary, enterprise.resources, adapterId);
70
+ }
71
+ const summaryResponse = await this.post(origin, '/billing/meter/get-user-resource-summary', auth, region, {}, adapterId, request);
72
+ const summary = normalizeSummary(summaryResponse);
73
+ if (summary === null)
74
+ continue;
75
+ const packageCodes = summary.resources.map((resource) => resource.packageCode).filter(Boolean);
76
+ const [paid, free] = await Promise.all([
77
+ this.post(origin, '/billing/meter/get-user-resource-paid-packages', auth, region, {
78
+ PageNumber: 1,
79
+ PageSize: 200,
80
+ PackageCodes: packageCodes,
81
+ Status: [ACCOUNT_STATUS_VALID, ACCOUNT_STATUS_USED_UP],
82
+ NeedRenewInfo: true,
83
+ }, adapterId, request),
84
+ this.post(origin, '/billing/meter/get-user-resource-free-packages', auth, region, {
85
+ PageNumber: 1,
86
+ PageSize: 200,
87
+ PackageCodes: packageCodes,
88
+ Status: [ACCOUNT_STATUS_VALID, ACCOUNT_STATUS_USED_UP],
89
+ ...slicePeriodRange(),
90
+ }, adapterId, request),
91
+ ]);
92
+ const resources = mergeResources(summary.resources, normalizePackageAccounts(paid), normalizePackageAccounts(free));
93
+ return buildUsage(origin, summary, resources, adapterId);
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ /** WorkBuddy 的认证文件是字段加密格式,必须让 daemon 通过 WBIPC 注入认证头。 */
99
+ async readWorkBuddyViaIpc() {
100
+ const authFiles = defaultAuthFiles(this.homeDirectory, 'workbuddy');
101
+ const auth = readWorkBuddyAuthMetadata(authFiles);
102
+ if (auth === null)
103
+ return null;
104
+ const ipc = await connectWorkBuddyRequestPipe(this.homeDirectory);
105
+ if (ipc === null)
106
+ return null;
107
+ try {
108
+ return await this.readWithRequest('workbuddy', ipc.fetch, auth);
109
+ }
110
+ finally {
111
+ ipc.close();
112
+ }
113
+ }
114
+ async post(origin, path, auth, region, body, adapterId, request) {
115
+ const controller = new AbortController();
116
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
117
+ const normalizedOrigin = normalizeOrigin(origin);
118
+ if (normalizedOrigin === '') {
119
+ clearTimeout(timer);
120
+ return null;
121
+ }
122
+ try {
123
+ const response = await request(`${normalizedOrigin}${path}`, {
124
+ method: 'POST',
125
+ headers: requestHeaders(normalizedOrigin, auth, region, adapterId),
126
+ body: JSON.stringify(body),
127
+ signal: controller.signal,
128
+ });
129
+ if (!response.ok)
130
+ return null;
131
+ return recordValue(await response.json());
132
+ }
133
+ catch {
134
+ return null;
135
+ }
136
+ finally {
137
+ clearTimeout(timer);
138
+ }
139
+ }
140
+ }
141
+ function regionsForAdapter(adapterId) {
142
+ // 兼容旧版持久化调用;统一适配器只向外暴露 codebuddy。
143
+ if (adapterId === 'codebuddy-cn')
144
+ adapterId = 'codebuddy';
145
+ // WorkBuddy 的国内版和国际版共用一个适配器,按认证文件 domain 选择计费区域。
146
+ if (adapterId === 'codebuddy' || adapterId === 'workbuddy')
147
+ return ['cn', 'international'];
148
+ return [];
149
+ }
150
+ function defaultAuthFiles(home, adapterId) {
151
+ if (adapterId === 'workbuddy')
152
+ return [workBuddyAuthFileForHome(home)];
153
+ return [
154
+ authFileForHome(home),
155
+ authFileForHome(join(home, '.codebuddy-cn-home')),
156
+ authFileForHome(join(home, '.codebuddy-international-home')),
157
+ authFileForHome(join(home, '.workbuddy')),
158
+ ];
159
+ }
160
+ function workBuddyAuthFileForHome(home) {
161
+ if (process.platform === 'win32')
162
+ return join(home, 'AppData/Local/CodeBuddyExtension/Data/Public/auth/workbuddy-desktop.info');
163
+ if (process.platform === 'darwin')
164
+ return join(home, 'Library/Application Support/CodeBuddyExtension/Data/Public/auth/workbuddy-desktop.info');
165
+ return join(home, '.local/share/CodeBuddyExtension/Data/Public/auth/workbuddy-desktop.info');
166
+ }
167
+ function readWorkBuddyAuthMetadata(files) {
168
+ for (const path of files) {
169
+ try {
170
+ const value = recordValue(JSON.parse(readFileSync(path, 'utf8')));
171
+ if (value === null)
172
+ continue;
173
+ const auth = recordValue(value.auth);
174
+ const account = recordValue(value.account);
175
+ const uid = textValue(account?.uid ?? value.uid);
176
+ const domain = (textValue(auth?.domain ?? account?.domain) ?? '').toLowerCase();
177
+ const encryptedToken = recordValue(auth?.accessToken ?? auth?.access_token);
178
+ if (uid === null || domain === '' || encryptedToken === null)
179
+ continue;
180
+ const enterpriseId = textValue(account?.enterpriseId ?? account?.enterprise_id ?? value.enterpriseId ?? value.enterprise_id);
181
+ // 令牌只作为类型占位;实际请求由 WorkBuddy daemon 通过 WBIPC 注入。
182
+ return { accessToken: '', uid, domain, enterpriseId };
183
+ }
184
+ catch {
185
+ // 认证文件缺失或损坏时继续检查其他候选文件。
186
+ }
187
+ }
188
+ return null;
189
+ }
190
+ function authFileForHome(home) {
191
+ if (process.platform === 'win32')
192
+ return join(home, 'AppData/Local/CodeBuddyExtension/Data/Public/auth/Tencent-Cloud.coding-copilot.info');
193
+ if (process.platform === 'darwin')
194
+ return join(home, 'Library/Application Support/CodeBuddyExtension/Data/Public/auth/Tencent-Cloud.coding-copilot.info');
195
+ return join(home, '.local/share/CodeBuddyExtension/Data/Public/auth/Tencent-Cloud.coding-copilot.info');
196
+ }
197
+ function orderRegions(regions, authFiles) {
198
+ if (regions.length < 2)
199
+ return regions;
200
+ const configured = `${process.env.CODEBUDDY_INTERNET_ENVIRONMENT ?? process.env.CODEBUDDY_COPILOT_INTERNET_ENVIRONMENT ?? ''}`.trim().toLowerCase();
201
+ const preferred = configured === 'internal' || configured === 'cn' || configured === 'china' || configured === 'ioa'
202
+ ? 'cn'
203
+ : configured === 'external' || configured === 'international' || configured === 'overseas'
204
+ ? 'international'
205
+ : regionFromAuthFile(authFiles[0]);
206
+ if (preferred === undefined || !regions.includes(preferred))
207
+ return regions;
208
+ return [preferred, ...regions.filter((region) => region !== preferred)];
209
+ }
210
+ function regionFromAuthFile(path) {
211
+ if (path === undefined)
212
+ return undefined;
213
+ try {
214
+ const value = recordValue(JSON.parse(readFileSync(path, 'utf8')));
215
+ const auth = recordValue(value?.auth);
216
+ const domain = (textValue(auth?.domain) ?? '').toLowerCase();
217
+ if (INTERNAL_DOMAINS.has(domain))
218
+ return 'cn';
219
+ if (EXTERNAL_DOMAINS.has(domain))
220
+ return 'international';
221
+ }
222
+ catch {
223
+ // 缺少或损坏的主认证文件时,继续按候选文件逐区查询。
224
+ }
225
+ return undefined;
226
+ }
227
+ function readCodeBuddyAuth(files, region) {
228
+ for (const path of files) {
229
+ try {
230
+ const value = recordValue(JSON.parse(readFileSync(path, 'utf8')));
231
+ if (value === null)
232
+ continue;
233
+ const auth = recordValue(value.auth);
234
+ const account = recordValue(value.account);
235
+ const accessToken = textValue(auth?.accessToken ?? auth?.access_token);
236
+ const uid = textValue(account?.uid ?? value.uid);
237
+ if (accessToken === null || uid === null)
238
+ continue;
239
+ const domain = (textValue(auth?.domain ?? account?.domain) ?? '').toLowerCase();
240
+ if (!matchesRegion(domain, region))
241
+ continue;
242
+ const enterpriseId = textValue(account?.enterpriseId ?? account?.enterprise_id ?? value.enterpriseId ?? value.enterprise_id);
243
+ return { accessToken, uid, domain, enterpriseId };
244
+ }
245
+ catch {
246
+ // 认证文件缺失或损坏时继续检查其他隔离根。
247
+ }
248
+ }
249
+ return null;
250
+ }
251
+ function matchesRegion(domain, region) {
252
+ if (domain === '')
253
+ return false;
254
+ const hostname = domain.replace(/^https?:\/\//u, '').split('/')[0]?.toLowerCase() ?? '';
255
+ return (region === 'cn' ? INTERNAL_DOMAINS : EXTERNAL_DOMAINS).has(hostname);
256
+ }
257
+ function requestHeaders(origin, auth, region, adapterId) {
258
+ return {
259
+ Authorization: `Bearer ${auth.accessToken}`,
260
+ 'X-User-Id': auth.uid,
261
+ 'X-Trace-ID': randomUUID(),
262
+ 'X-Request-ID': randomUUID(),
263
+ 'Accept-Language': region === 'cn' ? 'zh' : 'en',
264
+ Accept: 'application/json',
265
+ 'Content-Type': 'application/json',
266
+ Origin: origin,
267
+ Referer: `${origin}/`,
268
+ 'User-Agent': `CodingNS4DSH ${adapterId === 'workbuddy' ? 'WorkBuddy' : 'CodeBuddy'} subscription reader`,
269
+ ...(adapterId === 'workbuddy' ? {
270
+ 'X-Domain': auth.domain,
271
+ 'X-Product': 'WorkBuddy',
272
+ 'X-IDE-Type': 'WorkBuddy',
273
+ 'X-IDE-Name': 'WorkBuddy',
274
+ } : {}),
275
+ ...(auth.enterpriseId === null ? {} : { 'X-Enterprise-Id': auth.enterpriseId }),
276
+ };
277
+ }
278
+ function normalizeSummary(value) {
279
+ const data = unwrapData(value);
280
+ if (data === null)
281
+ return null;
282
+ const resources = arrayValue(data.Packages ?? data.packages).map(normalizeSummaryResource).filter((item) => item !== null);
283
+ const planCode = textValue(data.SubscriptionPackageCode ?? data.subscriptionPackageCode) ?? '';
284
+ const planName = textValue(data.SubscriptionPackageName ?? data.subscriptionPackageName ?? data.PackageName ?? data.packageName) ?? '';
285
+ const isPaid = booleanValue(data.IsPaidUser ?? data.isPaidUser);
286
+ if (resources.length === 0 && planCode === '' && planName === '')
287
+ return null;
288
+ return { planCode, planName, isPaid, resources };
289
+ }
290
+ /** 导出给 fixture/诊断使用的容错 summary 解析器,不暴露任何认证字段。 */
291
+ export function normalizeCodeBuddySummary(value) {
292
+ return normalizeSummary(recordValue(value));
293
+ }
294
+ function normalizeSummaryResource(value) {
295
+ const record = recordValue(value);
296
+ if (record === null)
297
+ return null;
298
+ const packageCode = textValue(record.PackageCode ?? record.packageCode ?? record.Code ?? record.code);
299
+ if (packageCode === null)
300
+ return null;
301
+ const total = numberValue(record.CycleTotalCapacity ?? record.cycleTotalCapacity ?? record.TotalCapacity ?? record.totalCapacity);
302
+ const remaining = numberValue(record.CycleRemainCapacity ?? record.cycleRemainCapacity ?? record.RemainCapacity ?? record.remainCapacity);
303
+ const used = numberValue(record.CycleUsedCapacity ?? record.cycleUsedCapacity ?? record.UsedCapacity ?? record.usedCapacity)
304
+ ?? (total !== null && remaining !== null ? Math.max(0, total - remaining) : null);
305
+ return {
306
+ packageCode,
307
+ packageName: textValue(record.PackageName ?? record.packageName) ?? packageCode,
308
+ total,
309
+ used,
310
+ remaining,
311
+ expiresAt: timestampValue(record.DeductionEndTime ?? record.ExpiredTime ?? record.CycleEndTime ?? record.expireAt),
312
+ refreshAt: timestampValue(record.CycleEndTime ?? record.refreshAt),
313
+ };
314
+ }
315
+ function normalizePackageAccounts(value) {
316
+ const data = unwrapData(value);
317
+ if (data === null)
318
+ return [];
319
+ const entries = arrayValue(data.Accounts ?? data.accounts ?? data.Resources ?? data.resources);
320
+ return entries.flatMap((entry) => {
321
+ const record = recordValue(entry);
322
+ if (record === null)
323
+ return [];
324
+ const resource = normalizeSummaryResource(record);
325
+ if (resource === null)
326
+ return [];
327
+ const capacityType = numberValue(record.CapacityType ?? record.capacityType);
328
+ const slices = arrayValue(record.SlicePeriodUsageDetails ?? record.slicePeriodUsageDetails);
329
+ if (capacityType !== 4 || slices.length === 0)
330
+ return [resource];
331
+ const slice = recordValue(slices[0]);
332
+ if (slice === null)
333
+ return [resource];
334
+ const total = numberValue(slice.CycleCapacitySizePrecise ?? slice.cycleCapacitySizePrecise) ?? resource.total;
335
+ const remaining = numberValue(slice.CycleCapacityRemainPrecise ?? slice.cycleCapacityRemainPrecise) ?? resource.remaining;
336
+ const used = numberValue(slice.CycleCapacityUsedPrecise ?? slice.cycleCapacityUsedPrecise) ?? (total !== null && remaining !== null ? Math.max(0, total - remaining) : resource.used);
337
+ return [{ ...resource, total, remaining, used, expiresAt: timestampValue(slice.CycleEndTime ?? slice.endTime) ?? resource.expiresAt, refreshAt: timestampValue(slice.CycleEndTime ?? slice.endTime) ?? resource.refreshAt }];
338
+ });
339
+ }
340
+ function mergeResources(...lists) {
341
+ const merged = new Map();
342
+ for (const list of lists) {
343
+ for (const resource of list) {
344
+ const current = merged.get(resource.packageCode);
345
+ merged.set(resource.packageCode, current === undefined ? resource : {
346
+ packageCode: resource.packageCode,
347
+ packageName: resource.packageName && resource.packageName !== resource.packageCode ? resource.packageName : current.packageName,
348
+ total: resource.total ?? current.total,
349
+ used: resource.used ?? current.used,
350
+ remaining: resource.remaining ?? current.remaining,
351
+ expiresAt: resource.expiresAt ?? current.expiresAt,
352
+ refreshAt: resource.refreshAt ?? current.refreshAt,
353
+ });
354
+ }
355
+ }
356
+ return [...merged.values()];
357
+ }
358
+ function buildUsage(origin, summary, resources, adapterId) {
359
+ const total = sumNumbers(resources.map((resource) => resource.total));
360
+ const remaining = sumNumbers(resources.map((resource) => resource.remaining));
361
+ const used = sumNumbers(resources.map((resource) => resource.used)) ?? (total !== null && remaining !== null ? Math.max(0, total - remaining) : null);
362
+ const details = [
363
+ ...(summary.isPaid === null ? [] : [{ label: '付费用户', value: summary.isPaid ? '是' : '否' }]),
364
+ ];
365
+ for (const resource of resources) {
366
+ const label = resource.packageName || resource.packageCode;
367
+ if (resource.total !== null)
368
+ details.push({ label: `${label} 总量`, value: resource.total });
369
+ if (resource.used !== null)
370
+ details.push({ label: `${label} 已用`, value: resource.used });
371
+ if (resource.remaining !== null)
372
+ details.push({ label: `${label} 剩余`, value: resource.remaining });
373
+ if (resource.expiresAt !== null)
374
+ details.push({ label: `${label} 周期结束`, value: new Date(resource.expiresAt).toISOString() });
375
+ }
376
+ const providerBalance = {
377
+ upstreamUrl: normalizeOrigin(origin),
378
+ currency: null,
379
+ unit: 'credits',
380
+ balance: remaining,
381
+ remaining,
382
+ used,
383
+ total,
384
+ requests: null,
385
+ inputTokens: null,
386
+ outputTokens: null,
387
+ planName: summary.planName || null,
388
+ details,
389
+ };
390
+ return {
391
+ authenticated: true,
392
+ planType: summary.planName || null,
393
+ primary: null,
394
+ secondary: null,
395
+ monthly: null,
396
+ rateLimitReachedType: null,
397
+ resetCredits: null,
398
+ capturedAt: new Date().toISOString(),
399
+ provider: {
400
+ id: adapterId,
401
+ displayName: adapterId === 'workbuddy' ? 'WorkBuddy' : 'CodeBuddy',
402
+ baseUrl: normalizeOrigin(origin),
403
+ capability: 'official-balance',
404
+ logoUrl: '',
405
+ },
406
+ providerBalance,
407
+ };
408
+ }
409
+ function normalizeEnterpriseUsage(value) {
410
+ const data = unwrapData(value);
411
+ if (data === null)
412
+ return null;
413
+ const total = numberValue(data.limitNum ?? data.limit_num ?? data.total);
414
+ const used = numberValue(data.credit ?? data.used ?? data.usedNum);
415
+ if (total === null && used === null)
416
+ return null;
417
+ const remaining = total !== null && used !== null ? Math.max(0, total - used) : null;
418
+ const resource = {
419
+ packageCode: 'enterprise',
420
+ packageName: '企业额度',
421
+ total,
422
+ used,
423
+ remaining,
424
+ expiresAt: timestampValue(data.cycleResetTime ?? data.cycle_reset_time),
425
+ refreshAt: timestampValue(data.cycleResetTime ?? data.cycle_reset_time),
426
+ };
427
+ return {
428
+ summary: { planCode: 'enterprise', planName: '企业版', isPaid: true, resources: [resource] },
429
+ resources: [resource],
430
+ };
431
+ }
432
+ function slicePeriodRange() {
433
+ const now = new Date();
434
+ const year = now.getFullYear();
435
+ const month = String(now.getMonth() + 1).padStart(2, '0');
436
+ const day = String(now.getDate()).padStart(2, '0');
437
+ return {
438
+ SlicePeriodStartTime: `${year}-${month}-${day} 00:00:00`,
439
+ SlicePeriodEndTime: `${year}-${month}-${day} 23:59:59`,
440
+ };
441
+ }
442
+ function unwrapData(value) {
443
+ let current = value;
444
+ for (let i = 0; i < 3 && current !== null; i += 1) {
445
+ const nested = recordValue(current.data ?? current.Data);
446
+ if (nested === null)
447
+ break;
448
+ current = nested;
449
+ }
450
+ return current;
451
+ }
452
+ function arrayValue(value) { return Array.isArray(value) ? value : []; }
453
+ function uniqueOrigins(values) {
454
+ return [...new Set(values.map(normalizeOrigin).filter((value) => value !== ''))];
455
+ }
456
+ function normalizeOrigin(value) {
457
+ try {
458
+ const url = new URL(value);
459
+ if (url.protocol !== 'http:' && url.protocol !== 'https:')
460
+ return '';
461
+ url.pathname = '';
462
+ url.search = '';
463
+ url.hash = '';
464
+ return url.toString().replace(/\/$/u, '');
465
+ }
466
+ catch {
467
+ return '';
468
+ }
469
+ }
470
+ function recordValue(value) { return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null; }
471
+ function textValue(value) { return typeof value === 'string' && value.trim() !== '' ? value.trim() : null; }
472
+ function numberValue(value) {
473
+ const number = typeof value === 'number' ? value : Number(value);
474
+ return Number.isFinite(number) ? number : null;
475
+ }
476
+ function booleanValue(value) { return typeof value === 'boolean' ? value : value === 1 || value === '1' ? true : value === 0 || value === '0' ? false : null; }
477
+ function timestampValue(value) {
478
+ if (value instanceof Date)
479
+ return value.getTime();
480
+ if (typeof value === 'number' || typeof value === 'string' && /^\d+(?:\.\d+)?$/u.test(value.trim())) {
481
+ const number = numberValue(value);
482
+ if (number === null || number <= 0)
483
+ return null;
484
+ return number < 100_000_000_000 ? Math.round(number * 1_000) : Math.round(number);
485
+ }
486
+ if (typeof value === 'string') {
487
+ const parsed = Date.parse(value);
488
+ return Number.isNaN(parsed) ? null : parsed;
489
+ }
490
+ return null;
491
+ }
492
+ function sumNumbers(values) {
493
+ const present = values.filter((value) => value !== null && Number.isFinite(value));
494
+ return present.length === 0 ? null : present.reduce((sum, value) => sum + value, 0);
495
+ }
496
+ const WORKBUDDY_IPC_PROTOCOL = 1;
497
+ const WORKBUDDY_IPC_MAX_FRAME_BYTES = 1024 * 1024;
498
+ const WORKBUDDY_IPC_HANDSHAKE_TIMEOUT_MS = 5_000;
499
+ const WORKBUDDY_IPC_CALL_TIMEOUT_MS = 12_000;
500
+ /**
501
+ * 连接 WorkBuddy daemon 的官方 WBIPC 请求通道。
502
+ *
503
+ * WorkBuddy 的认证文件只保存了桌面端可解密的字段,DSH 不能自行解密;
504
+ * 通过 wb.request/http.fetch 请求时由 daemon 注入当前登录态,避免串用 CodeBuddy token。
505
+ */
506
+ async function connectWorkBuddyRequestPipe(home) {
507
+ const discovery = readWorkBuddyIpcDiscovery(home);
508
+ if (discovery === null)
509
+ return null;
510
+ const socket = await connectWorkBuddyIpcSocket(discovery);
511
+ if (socket === null)
512
+ return null;
513
+ try {
514
+ const rpc = await handshakeWorkBuddyIpc(socket, discovery);
515
+ const pipe = await rpc.call('broker/GetPipe', { pipe: 'wb.request' });
516
+ const pipeRecord = recordValue(pipe);
517
+ const channel = textValue(pipeRecord?.channel);
518
+ if (channel === null)
519
+ throw new Error('WorkBuddy wb.request pipe unavailable');
520
+ return {
521
+ fetch: createWorkBuddyIpcFetch(rpc, channel),
522
+ close: rpc.close,
523
+ };
524
+ }
525
+ catch {
526
+ socket.destroy();
527
+ return null;
528
+ }
529
+ }
530
+ function readWorkBuddyIpcDiscovery(home) {
531
+ const configured = process.env.WORKBUDDY_CONFIG_DIR?.trim();
532
+ const configDirectory = configured || join(home, '.workbuddy');
533
+ try {
534
+ const value = recordValue(JSON.parse(readFileSync(join(configDirectory, 'wbipc/endpoint.json'), 'utf8')));
535
+ const endpoint = textValue(value?.endpoint);
536
+ const ticket = textValue(value?.ticket);
537
+ return endpoint === null || ticket === null ? null : { endpoint, ticket };
538
+ }
539
+ catch {
540
+ return null;
541
+ }
542
+ }
543
+ function connectWorkBuddyIpcSocket(discovery) {
544
+ return new Promise((resolve) => {
545
+ const endpoint = discovery.endpoint.startsWith('unix:') ? discovery.endpoint.slice('unix:'.length) : discovery.endpoint;
546
+ const socket = createConnection({ path: endpoint });
547
+ let settled = false;
548
+ const timer = setTimeout(() => finish(null), WORKBUDDY_IPC_HANDSHAKE_TIMEOUT_MS);
549
+ const finish = (result) => {
550
+ if (settled)
551
+ return;
552
+ settled = true;
553
+ clearTimeout(timer);
554
+ if (result === null)
555
+ socket.destroy();
556
+ resolve(result);
557
+ };
558
+ socket.once('connect', () => finish(socket));
559
+ socket.once('error', () => finish(null));
560
+ });
561
+ }
562
+ async function handshakeWorkBuddyIpc(socket, discovery) {
563
+ let buffer = Buffer.alloc(0);
564
+ let frameHandler = null;
565
+ const queuedFrames = [];
566
+ let failed = null;
567
+ const readFrame = () => new Promise((resolve, reject) => {
568
+ const queued = queuedFrames.shift();
569
+ if (queued !== undefined) {
570
+ resolve(queued);
571
+ return;
572
+ }
573
+ frameHandler = (frame) => {
574
+ frameHandler = null;
575
+ resolve(frame);
576
+ };
577
+ failed = reject;
578
+ });
579
+ const handleData = (chunk) => {
580
+ buffer = buffer.length === 0 ? chunk : Buffer.concat([buffer, chunk]);
581
+ for (;;) {
582
+ const newline = buffer.indexOf(0x0a);
583
+ if (newline < 0) {
584
+ if (buffer.length > WORKBUDDY_IPC_MAX_FRAME_BYTES) {
585
+ failed?.(new Error('WorkBuddy WBIPC frame exceeds limit'));
586
+ failed = null;
587
+ }
588
+ return;
589
+ }
590
+ if (newline > WORKBUDDY_IPC_MAX_FRAME_BYTES) {
591
+ failed?.(new Error('WorkBuddy WBIPC frame exceeds limit'));
592
+ failed = null;
593
+ return;
594
+ }
595
+ const line = buffer.subarray(0, newline);
596
+ buffer = buffer.subarray(newline + 1);
597
+ if (line.length === 0)
598
+ continue;
599
+ try {
600
+ const frame = recordValue(JSON.parse(line.toString('utf8')));
601
+ if (frame === null)
602
+ throw new Error('invalid WorkBuddy WBIPC frame');
603
+ if (frameHandler === null)
604
+ queuedFrames.push(frame);
605
+ else
606
+ frameHandler(frame);
607
+ }
608
+ catch (error) {
609
+ failed?.(error instanceof Error ? error : new Error(String(error)));
610
+ failed = null;
611
+ return;
612
+ }
613
+ }
614
+ };
615
+ socket.on('data', handleData);
616
+ const write = (frame) => {
617
+ const payload = `${JSON.stringify(frame)}\n`;
618
+ if (Buffer.byteLength(payload) > WORKBUDDY_IPC_MAX_FRAME_BYTES)
619
+ throw new Error('WorkBuddy WBIPC request exceeds limit');
620
+ socket.write(payload);
621
+ };
622
+ const rejectSocket = (error) => {
623
+ failed?.(error);
624
+ failed = null;
625
+ };
626
+ socket.once('error', () => rejectSocket(new Error('WorkBuddy WBIPC socket error')));
627
+ socket.once('close', () => rejectSocket(new Error('WorkBuddy WBIPC socket closed')));
628
+ const withTimeout = async (promise, message) => {
629
+ let timer;
630
+ try {
631
+ return await Promise.race([
632
+ promise,
633
+ new Promise((_, reject) => {
634
+ timer = setTimeout(() => reject(new Error(message)), WORKBUDDY_IPC_HANDSHAKE_TIMEOUT_MS);
635
+ }),
636
+ ]);
637
+ }
638
+ finally {
639
+ if (timer !== undefined)
640
+ clearTimeout(timer);
641
+ }
642
+ };
643
+ const clientNonce = randomBytes(16).toString('base64url');
644
+ const ticketId = createHash('sha256').update(discovery.ticket, 'utf8').digest('hex').slice(0, 16);
645
+ write({
646
+ type: 'session_hello',
647
+ protocol_min: WORKBUDDY_IPC_PROTOCOL,
648
+ protocol_max: WORKBUDDY_IPC_PROTOCOL,
649
+ client_nonce: clientNonce,
650
+ ticket_id: ticketId,
651
+ client: { kind: 'plugin', id: 'codingns-subscription' },
652
+ });
653
+ const challenge = await withTimeout(readFrame(), 'WorkBuddy WBIPC handshake timeout');
654
+ if (challenge.type === 'session_hello_error')
655
+ throw new Error(`WorkBuddy WBIPC handshake rejected: ${String(challenge.code ?? '?')}`);
656
+ if (challenge.type !== 'session_challenge')
657
+ throw new Error('unexpected WorkBuddy WBIPC handshake frame');
658
+ const serverNonce = textValue(challenge.server_nonce);
659
+ if (serverNonce === null)
660
+ throw new Error('WorkBuddy WBIPC server nonce missing');
661
+ const transcript = { protocol: WORKBUDDY_IPC_PROTOCOL, endpoint: discovery.endpoint, clientNonce, serverNonce };
662
+ const proof = (role) => createHmac('sha256', Buffer.from(discovery.ticket, 'utf8'))
663
+ .update(encodeWorkBuddyTranscript(role, transcript)).digest('base64url');
664
+ const serverProof = textValue(challenge.server_proof);
665
+ if (serverProof === null || !safeWorkBuddyEqual(proof('server'), serverProof))
666
+ throw new Error('WorkBuddy WBIPC endpoint proof failed');
667
+ write({ type: 'session_prove', client_proof: proof('client') });
668
+ const ack = await withTimeout(readFrame(), 'WorkBuddy WBIPC handshake acknowledgement timeout');
669
+ if (ack.type !== 'session_hello_ack')
670
+ throw new Error(`WorkBuddy WBIPC handshake rejected: ${String(ack.code ?? '?')}`);
671
+ const pending = new Map();
672
+ let nextId = 1;
673
+ const onRpcFrame = (frame) => {
674
+ const id = numberValue(frame.id);
675
+ if (id === null)
676
+ return;
677
+ const entry = pending.get(id);
678
+ if (entry === undefined)
679
+ return;
680
+ pending.delete(id);
681
+ clearTimeout(entry.timer);
682
+ const error = recordValue(frame.error);
683
+ if (error !== null) {
684
+ entry.reject(new Error(String(error.message ?? 'WorkBuddy WBIPC request failed')));
685
+ return;
686
+ }
687
+ entry.resolve(frame.result);
688
+ };
689
+ frameHandler = onRpcFrame;
690
+ while (queuedFrames.length > 0) {
691
+ const frame = queuedFrames.shift();
692
+ if (frame !== undefined)
693
+ onRpcFrame(frame);
694
+ }
695
+ const close = () => {
696
+ for (const entry of pending.values()) {
697
+ clearTimeout(entry.timer);
698
+ entry.reject(new Error('WorkBuddy WBIPC connection closed'));
699
+ }
700
+ pending.clear();
701
+ socket.destroy();
702
+ };
703
+ return {
704
+ call(method, params) {
705
+ const id = nextId++;
706
+ return new Promise((resolve, reject) => {
707
+ const timer = setTimeout(() => {
708
+ if (!pending.delete(id))
709
+ return;
710
+ reject(new Error(`WorkBuddy WBIPC call timeout: ${method}`));
711
+ }, WORKBUDDY_IPC_CALL_TIMEOUT_MS);
712
+ pending.set(id, { resolve, reject, timer });
713
+ try {
714
+ write({ jsonrpc: '2.0', id, method, params, mode: 'call' });
715
+ }
716
+ catch (error) {
717
+ clearTimeout(timer);
718
+ pending.delete(id);
719
+ reject(error);
720
+ }
721
+ });
722
+ },
723
+ close,
724
+ };
725
+ }
726
+ function encodeWorkBuddyTranscript(role, transcript) {
727
+ const parts = [role === 'server' ? 'wbipc-s' : 'wbipc-c', String(transcript.protocol), transcript.endpoint, transcript.clientNonce, transcript.serverNonce];
728
+ return Buffer.concat(parts.map((part) => {
729
+ const value = Buffer.from(part, 'utf8');
730
+ const length = Buffer.alloc(4);
731
+ length.writeUInt32BE(value.length, 0);
732
+ return Buffer.concat([length, value]);
733
+ }));
734
+ }
735
+ function safeWorkBuddyEqual(left, right) {
736
+ const a = Buffer.from(left, 'utf8');
737
+ const b = Buffer.from(right, 'utf8');
738
+ return a.length > 0 && a.length === b.length && timingSafeEqual(a, b);
739
+ }
740
+ function createWorkBuddyIpcFetch(rpc, channel) {
741
+ return async (input, init) => {
742
+ const url = typeof input === 'string' || input instanceof URL ? new URL(String(input)) : new URL(input.url);
743
+ const sourceHeaders = new Headers(init?.headers);
744
+ // WorkBuddy daemon 只允许这两个业务头,其余身份、Origin、追踪头由宿主裁决。
745
+ const headers = new Headers();
746
+ for (const name of ['accept', 'content-type']) {
747
+ const value = sourceHeaders.get(name);
748
+ if (value !== null)
749
+ headers.set(name, value);
750
+ }
751
+ const body = init?.body === undefined || init.body === null
752
+ ? undefined
753
+ : Buffer.from(await new Response(init.body).arrayBuffer()).toString('base64');
754
+ const result = recordValue(await rpc.call(`${channel}/http.fetch`, {
755
+ method: (init?.method ?? 'GET').toUpperCase(),
756
+ path: `${url.pathname}${url.search}`,
757
+ headers: Object.fromEntries(headers.entries()),
758
+ ...(body === undefined ? {} : { body_b64: body }),
759
+ }));
760
+ const status = numberValue(result?.status);
761
+ const responseHeaders = recordValue(result?.headers);
762
+ const normalizedHeaders = {};
763
+ if (responseHeaders !== null) {
764
+ for (const [key, value] of Object.entries(responseHeaders)) {
765
+ const text = textValue(value);
766
+ if (text !== null)
767
+ normalizedHeaders[key] = text;
768
+ }
769
+ }
770
+ const bodyValue = typeof result?.body_b64 === 'string' ? Buffer.from(result.body_b64, 'base64') : Buffer.alloc(0);
771
+ return new Response(bodyValue, {
772
+ status: status !== null && status >= 200 && status <= 599 ? status : 500,
773
+ headers: normalizedHeaders,
774
+ });
775
+ };
776
+ }
777
+ export { DEFAULT_ORIGINS as CODEBUDDY_BILLING_ORIGINS };
778
+ //# sourceMappingURL=codebuddy-subscription.js.map