@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,659 @@
1
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from 'node:fs';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { homedir } from 'node:os';
4
+ import { basename, dirname, join, relative, resolve } from 'node:path';
5
+ import { knownCommandCodeContextWindow } from './model-catalog.js';
6
+ const COMMAND_CODE_MAX_TITLE_LENGTH = 48;
7
+ const COMMAND_CODE_HISTORY_CACHE_MAX_ENTRIES = 64;
8
+ const COMMAND_CODE_HISTORY_CACHE_MAX_BYTES = 32 * 1024 * 1024;
9
+ const COMMAND_CODE_HISTORY_FALLBACK_INTERVAL_MS = 5_000;
10
+ /**
11
+ * Command Code 原生 JSONL 的只读历史层。
12
+ *
13
+ * 运行层负责启动 CLI;本类只操作 Provider canonical transcript,避免把 DSH
14
+ * 会话索引误当成 Provider 历史。方法名与父仓库 Provider Adapter 保持一致,
15
+ * 供 Host RPC 或后续原生历史投影按需接入。
16
+ */
17
+ export class CommandCodeHistory {
18
+ homeDirectory;
19
+ readStatus;
20
+ cache = new Map();
21
+ cacheBytes = 0;
22
+ constructor(homeDirectory = join(homedir(), '.commandcode'), options = {}) {
23
+ this.homeDirectory = homeDirectory;
24
+ this.readStatus = options.readStatus;
25
+ }
26
+ async detectSessions(workspacePath) {
27
+ return (await this.detectSessionsDetailed(workspacePath)).sessions;
28
+ }
29
+ async detectSessionsDetailed(workspacePath) {
30
+ const target = normalizeWorkspace(workspacePath);
31
+ const projectsRoot = join(this.homeDirectory, 'projects');
32
+ const sessions = [];
33
+ let invalidLineCount = 0;
34
+ let incompleteTailCount = 0;
35
+ for (const path of walkJsonlFiles(projectsRoot)) {
36
+ const parsed = readTranscript(path);
37
+ invalidLineCount += parsed.invalidLineCount;
38
+ incompleteTailCount += parsed.incompleteTailCount;
39
+ const session = parsed.records.find((record) => record.type === 'session') ?? parsed.records[0];
40
+ const cwd = text(session?.cwd);
41
+ if (cwd === '' || normalizeWorkspace(cwd) !== target)
42
+ continue;
43
+ const providerSessionId = text(session?.id ?? session?.sessionId) || basename(path, '.jsonl');
44
+ const messages = this.parseMessages(path, providerSessionId, parsed.records, parsed.lineNumbers);
45
+ const stats = statSafe(path);
46
+ if (stats === null)
47
+ continue;
48
+ sessions.push({
49
+ provider: 'command-code',
50
+ providerSessionId,
51
+ title: transcriptTitle(parsed.records, messages, path),
52
+ workspacePath,
53
+ rawStoreRef: path,
54
+ isArchived: readArchived(path),
55
+ lastMessageAt: messages.at(-1)?.timestamp ?? (text(parsed.records.at(-1)?.timestamp) || null),
56
+ messageCount: messages.length,
57
+ sourceMtimeMs: stats.mtimeMs,
58
+ sourceSizeBytes: stats.size,
59
+ });
60
+ }
61
+ sessions.sort((left, right) => (right.lastMessageAt ?? '').localeCompare(left.lastMessageAt ?? ''));
62
+ return { sessions, isComplete: invalidLineCount === 0 && incompleteTailCount === 0, invalidLineCount, incompleteTailCount };
63
+ }
64
+ async startSession(workspacePath, options = {}) {
65
+ const providerSessionId = randomUUID();
66
+ const directory = join(this.homeDirectory, 'projects', workspaceSlug(workspacePath));
67
+ const filePath = join(directory, `${providerSessionId}.jsonl`);
68
+ mkdirSync(directory, { recursive: true });
69
+ const timestamp = new Date().toISOString();
70
+ const initialPrompt = options.initialPrompt?.trim() ?? '';
71
+ const lines = [{ type: 'session', version: 3, id: providerSessionId, timestamp, cwd: workspacePath }];
72
+ if (initialPrompt !== '')
73
+ lines.push({ type: 'message', id: randomUUID(), parentId: null, timestamp, sessionId: providerSessionId, message: { role: 'user', content: [{ type: 'text', text: initialPrompt }], meta: { source: 'user', createdAt: Date.parse(timestamp) } } });
74
+ writeFileSync(filePath, `${lines.map((line) => JSON.stringify(line)).join('\n')}\n`, 'utf8');
75
+ const stats = statSafe(filePath);
76
+ const messages = this.getMessages(filePath, providerSessionId);
77
+ return { session: { provider: 'command-code', providerSessionId, title: normalizeTitle(initialPrompt) || 'New Command Code session', workspacePath, rawStoreRef: filePath, isArchived: false, lastMessageAt: timestamp, messageCount: messages.length, sourceMtimeMs: stats.mtimeMs, sourceSizeBytes: stats.size }, initialCursor: encodeCursor(messages.length) };
78
+ }
79
+ async resumeSession(providerSessionId, rawStoreRef) {
80
+ const filePath = this.requireSessionFilePath(providerSessionId, rawStoreRef);
81
+ return { provider: 'command-code', providerSessionId, resumedAt: new Date().toISOString(), rawStoreRef: filePath };
82
+ }
83
+ async sendMessage(providerSessionId, rawStoreRef, content) {
84
+ const filePath = this.requireSessionFilePath(providerSessionId, rawStoreRef);
85
+ const acceptedAt = new Date().toISOString();
86
+ const textContent = content;
87
+ if (textContent.trim() === '')
88
+ throw new Error('content 不能为空');
89
+ const recordId = randomUUID();
90
+ appendFileSync(filePath, `${JSON.stringify({ type: 'message', id: recordId, parentId: null, timestamp: acceptedAt, sessionId: providerSessionId, message: { role: 'user', content: [{ type: 'text', text: textContent }], meta: { source: 'user', createdAt: Date.parse(acceptedAt) } } })}\n`, 'utf8');
91
+ this.deleteCached(filePath);
92
+ const message = this.getMessages(filePath, providerSessionId).at(-1);
93
+ if (message === undefined)
94
+ throw new Error('PROVIDER_HISTORY_WRITE_FAILED');
95
+ return { acceptedAt, message };
96
+ }
97
+ async readSessionHistory(providerSessionId, rawStoreRef, cursor, limit, direction = 'forward') {
98
+ const filePath = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
99
+ if (filePath === null)
100
+ return { messages: [], cursor, nextCursor: null, total: 0 };
101
+ const messages = this.getMessages(filePath, providerSessionId);
102
+ return sliceHistory(messages, cursor, limit, direction);
103
+ }
104
+ async readSessionHistoryDelta(providerSessionId, rawStoreRef, cursor, limit, direction = 'forward') {
105
+ const filePath = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
106
+ if (filePath === null)
107
+ return { messages: [], cursor, nextCursor: null, total: 0, mode: 'reset_required', bytesRead: 0, recordsParsed: 0 };
108
+ const previous = this.cache.get(filePath);
109
+ const stats = statSafe(filePath);
110
+ if (stats === null)
111
+ return { messages: [], cursor, nextCursor: null, total: 0, mode: 'reset_required', bytesRead: 0, recordsParsed: 0 };
112
+ const messages = this.getMessages(filePath, providerSessionId);
113
+ const current = this.cache.get(filePath);
114
+ const mode = previous === undefined
115
+ ? 'seed'
116
+ : previous.identity !== current.identity || stats.size < previous.size
117
+ ? 'reset_required'
118
+ : stats.size === previous.size ? 'unchanged' : 'append';
119
+ const page = sliceHistory(messages, cursor, limit, direction);
120
+ return { ...page, mode, bytesRead: mode === 'unchanged' ? 0 : Math.max(0, stats.size - (previous?.size ?? 0)), recordsParsed: mode === 'unchanged' ? 0 : Math.max(0, current.recordCount - (previous?.recordCount ?? 0)) };
121
+ }
122
+ subscribeSession(providerSessionId, rawStoreRef, cursor, limit, onEvent) {
123
+ const filePath = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
124
+ if (filePath === null)
125
+ return { close() { } };
126
+ let closed = false;
127
+ let currentCursor = cursor;
128
+ let watcher;
129
+ const fallbackTimer = setInterval(() => { ensureWatcher(); void refresh(); }, COMMAND_CODE_HISTORY_FALLBACK_INTERVAL_MS);
130
+ fallbackTimer.unref?.();
131
+ let running = false;
132
+ const refresh = async () => {
133
+ if (closed || running)
134
+ return;
135
+ running = true;
136
+ try {
137
+ const delta = await this.readSessionHistoryDelta(providerSessionId, filePath, currentCursor, limit);
138
+ if (!closed && delta.mode !== 'unchanged' && delta.messages.length > 0) {
139
+ currentCursor = delta.cursor;
140
+ await onEvent({ messages: delta.messages, cursor: delta.cursor });
141
+ }
142
+ }
143
+ finally {
144
+ running = false;
145
+ }
146
+ };
147
+ const ensureWatcher = () => {
148
+ if (closed || watcher !== undefined || !existsSync(filePath))
149
+ return;
150
+ try {
151
+ watcher = watch(filePath, (eventType) => {
152
+ if (eventType === 'rename') {
153
+ watcher?.close();
154
+ watcher = undefined;
155
+ }
156
+ void refresh();
157
+ });
158
+ }
159
+ catch {
160
+ watcher = undefined;
161
+ }
162
+ };
163
+ ensureWatcher();
164
+ return {
165
+ close: () => {
166
+ if (closed)
167
+ return;
168
+ closed = true;
169
+ watcher?.close();
170
+ watcher = undefined;
171
+ clearInterval(fallbackTimer);
172
+ },
173
+ };
174
+ }
175
+ async readSessionTitle(providerSessionId, rawStoreRef) {
176
+ const filePath = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
177
+ if (filePath === null)
178
+ return '';
179
+ const parsed = readTranscript(filePath);
180
+ return transcriptTitle(parsed.records, this.getMessages(filePath, providerSessionId), filePath);
181
+ }
182
+ async renameSessionTitle(providerSessionId, rawStoreRef, title) {
183
+ const filePath = this.requireSessionFilePath(providerSessionId, rawStoreRef);
184
+ const normalized = title.trim().replace(/[\r\n]+/gu, ' ').replace(/\s+/gu, ' ').slice(0, COMMAND_CODE_MAX_TITLE_LENGTH);
185
+ appendFileSync(filePath, `${JSON.stringify({ type: 'title', sessionId: providerSessionId, title: normalized })}\n`, 'utf8');
186
+ this.deleteCached(filePath);
187
+ return normalized;
188
+ }
189
+ async updateSessionArchiveState(providerSessionId, rawStoreRef, isArchived) {
190
+ const filePath = this.requireSessionFilePath(providerSessionId, rawStoreRef);
191
+ const metadataPath = join(dirname(filePath), '.meta.json');
192
+ let metadata = {};
193
+ try {
194
+ metadata = JSON.parse(readFileSync(metadataPath, 'utf8'));
195
+ }
196
+ catch { /* 缺少或损坏的 meta 视为默认空对象 */ }
197
+ metadata.archived = isArchived;
198
+ mkdirSync(dirname(metadataPath), { recursive: true });
199
+ writeFileSync(metadataPath, `${JSON.stringify(metadata)}\n`, 'utf8');
200
+ return { rawStoreRef: filePath, isArchived };
201
+ }
202
+ async deleteSession(providerSessionId, rawStoreRef) {
203
+ const filePath = this.requireSessionFilePath(providerSessionId, rawStoreRef);
204
+ rmSync(filePath, { force: true });
205
+ this.deleteCached(filePath);
206
+ }
207
+ async readContextUsage(providerSessionId, rawStoreRef) {
208
+ const filePath = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
209
+ if (filePath === null)
210
+ return null;
211
+ const parsed = readTranscript(filePath);
212
+ const usage = parsed.records.map((record, index) => readUsage(record, index)).filter((value) => value !== null).at(-1);
213
+ if (usage === undefined)
214
+ return null;
215
+ const session = parsed.records.find((record) => record.type === 'session');
216
+ const modelId = usage.model || text(session?.model) || null;
217
+ const status = this.readStatus === undefined
218
+ ? null
219
+ : await this.readStatus(text(session?.cwd) || dirname(filePath)).catch(() => null);
220
+ const statusModel = text(status?.model).trim().toLowerCase();
221
+ const statusWindow = readNumber(status?.contextWindow ?? status?.context_window);
222
+ const runtimeWindow = statusWindow > 0 && modelId !== null && statusModel === modelId.trim().toLowerCase()
223
+ ? statusWindow
224
+ : null;
225
+ const contextWindow = usage.contextWindow ?? runtimeWindow ?? knownCommandCodeContextWindow(modelId === null ? undefined : modelId) ?? null;
226
+ return {
227
+ provider: 'command-code',
228
+ promptTokens: usage.inputTokens,
229
+ outputTokens: usage.outputTokens,
230
+ cacheReadTokens: usage.cacheReadTokens,
231
+ cacheWriteTokens: usage.cacheWriteTokens,
232
+ contextWindow,
233
+ usageRatio: contextWindow === null || contextWindow <= 0 ? null : Math.min(1, Math.max(0, usage.inputTokens / contextWindow)),
234
+ modelId,
235
+ capturedAt: usage.timestamp || null,
236
+ };
237
+ }
238
+ async readSessionStats(providerSessionId, rawStoreRef) {
239
+ const filePath = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
240
+ if (filePath === null)
241
+ return null;
242
+ const records = readTranscript(filePath).records;
243
+ const byMessageId = new Map();
244
+ for (const usage of records.map((record, index) => readUsage(record, index)).filter((value) => value !== null)) {
245
+ byMessageId.set(usage.messageId, usage);
246
+ }
247
+ const usages = [...byMessageId.values()];
248
+ if (usages.length === 0)
249
+ return null;
250
+ const inputTokens = usages.reduce((sum, value) => sum + value.inputTokens, 0);
251
+ const outputTokens = usages.reduce((sum, value) => sum + value.outputTokens, 0);
252
+ return {
253
+ provider: 'command-code',
254
+ inputTokens,
255
+ outputTokens,
256
+ cacheReadTokens: usages.reduce((sum, value) => sum + value.cacheReadTokens, 0),
257
+ cacheWriteTokens: usages.reduce((sum, value) => sum + value.cacheWriteTokens, 0),
258
+ totalTokens: inputTokens + outputTokens,
259
+ turns: countTurns(records),
260
+ steps: usages.length,
261
+ capturedAt: usages.at(-1)?.timestamp || null,
262
+ };
263
+ }
264
+ async forkSession(providerSessionId, workspacePath, options) {
265
+ const sourcePath = this.requireSessionFilePath(providerSessionId, options.rawStoreRef);
266
+ const sourceMessages = this.getMessages(sourcePath, providerSessionId).filter((message) => (message.role === 'user' || message.role === 'assistant') && message.kind === 'text' && message.content.trim() !== '');
267
+ const sourceIndex = options.sourceType === 'message' && options.sourceMessageId
268
+ ? sourceMessages.findIndex((message) => message.messageId === options.sourceMessageId)
269
+ : -1;
270
+ const inherited = sourceIndex >= 0 ? sourceMessages.slice(0, sourceIndex + 1) : sourceMessages;
271
+ const forkedId = randomUUID();
272
+ const directory = join(this.homeDirectory, 'projects', workspaceSlug(workspacePath));
273
+ const targetPath = join(directory, `${forkedId}.jsonl`);
274
+ mkdirSync(directory, { recursive: true });
275
+ const timestamp = new Date().toISOString();
276
+ const lines = [{ type: 'session', version: 3, id: forkedId, timestamp, cwd: workspacePath }, ...inherited.map((message) => ({ type: 'message', id: randomUUID(), parentId: null, timestamp: message.timestamp, message: { role: message.role, content: [{ type: 'text', text: message.content }] } }))];
277
+ writeFileSync(targetPath, `${lines.map((line) => JSON.stringify(line)).join('\n')}\n`, 'utf8');
278
+ const stats = statSafe(targetPath);
279
+ const session = {
280
+ provider: 'command-code', providerSessionId: forkedId, title: transcriptTitle([], inherited, targetPath), workspacePath,
281
+ rawStoreRef: targetPath, isArchived: false, lastMessageAt: inherited.at(-1)?.timestamp ?? timestamp,
282
+ messageCount: inherited.length, sourceMtimeMs: stats.mtimeMs, sourceSizeBytes: stats.size,
283
+ };
284
+ return { session, inheritedPrefixMessageCount: inherited.length, forkSourceType: options.sourceType, providerSourceMessageId: options.sourceMessageId ?? null };
285
+ }
286
+ getMessages(filePath, providerSessionId) {
287
+ const stats = statSafe(filePath);
288
+ if (stats === null)
289
+ return [];
290
+ const identity = `${stats.dev}:${stats.ino}`;
291
+ const cached = this.cache.get(filePath);
292
+ if (cached?.identity === identity && cached.providerSessionId === providerSessionId && cached.size === stats.size)
293
+ return cached.messages;
294
+ const parsed = readTranscript(filePath);
295
+ const messages = this.parseMessages(filePath, providerSessionId, parsed.records, parsed.lineNumbers);
296
+ this.setCached(filePath, { filePath, providerSessionId, identity, size: stats.size, mtimeMs: stats.mtimeMs, messages, recordCount: parsed.records.length });
297
+ return messages;
298
+ }
299
+ setCached(filePath, value) {
300
+ const previous = this.cache.get(filePath);
301
+ if (previous !== undefined)
302
+ this.cacheBytes -= previous.size;
303
+ this.cache.set(filePath, value);
304
+ this.cacheBytes += value.size;
305
+ while (this.cache.size > COMMAND_CODE_HISTORY_CACHE_MAX_ENTRIES || this.cacheBytes > COMMAND_CODE_HISTORY_CACHE_MAX_BYTES) {
306
+ const oldest = this.cache.keys().next().value;
307
+ if (oldest === undefined)
308
+ break;
309
+ this.deleteCached(oldest);
310
+ }
311
+ }
312
+ deleteCached(filePath) {
313
+ const cached = this.cache.get(filePath);
314
+ if (cached === undefined)
315
+ return;
316
+ this.cache.delete(filePath);
317
+ this.cacheBytes = Math.max(0, this.cacheBytes - cached.size);
318
+ }
319
+ parseMessages(filePath, providerSessionId, records, lineNumbers) {
320
+ const result = [];
321
+ const positions = new Map();
322
+ records.forEach((record, recordIndex) => {
323
+ if (record.type !== 'message')
324
+ return;
325
+ const message = asRecord(record.message);
326
+ const role = normalizeRole(message?.role);
327
+ const content = Array.isArray(message?.content) ? message.content : [message?.content];
328
+ content.forEach((part, partIndex) => {
329
+ const block = asRecord(part);
330
+ if (block === null)
331
+ return;
332
+ const type = text(block.type).toLowerCase();
333
+ const callId = text(block.id ?? block.tool_use_id ?? block.toolCallId ?? block.callId);
334
+ const messageId = `${text(record.id) || text(message?.id) || recordIndex}:${partIndex}:${type}:${callId}`;
335
+ const rawRef = `${filePath}#${lineNumbers?.get(record) ?? recordIndex + 1}:${partIndex}`;
336
+ const timestamp = text(record.timestamp) || new Date().toISOString();
337
+ const push = (entry) => {
338
+ const normalized = { ...entry, messageId, providerSessionId, timestamp, sequence: 0, rawRef };
339
+ const existing = positions.get(messageId);
340
+ if (existing === undefined) {
341
+ positions.set(messageId, result.length);
342
+ result.push(normalized);
343
+ }
344
+ else {
345
+ result[existing] = normalized;
346
+ }
347
+ };
348
+ if (type === 'thinking' || type === 'reasoning') {
349
+ push({ role: 'assistant', kind: 'thinking', content: text(block.thinking ?? block.text ?? block.content), toolCall: null });
350
+ }
351
+ else if (type === 'text' || type === 'output_text' || type === 'markdown') {
352
+ push({ role, kind: 'text', content: text(block.text ?? block.content), toolCall: null });
353
+ }
354
+ else if (type === 'tool_use' || type === 'tool_call' || type === 'function_call') {
355
+ const fn = asRecord(block.function);
356
+ const name = text(block.name ?? block.tool ?? fn?.name) || 'tool';
357
+ push({ role: 'assistant', kind: 'tool_call', content: '', toolCall: { callId: callId || messageId, name, input: stringify(block.input ?? fn?.arguments ?? {}), output: null, error: null, status: 'running' } });
358
+ }
359
+ else if (type === 'tool_result' || type === 'tool_return' || type === 'function_result') {
360
+ const error = block.error !== undefined || block.is_error === true;
361
+ const output = extractTextBlocks(block.content ?? block.output ?? block.result);
362
+ push({ role: 'tool', kind: 'tool_result', content: output, toolCall: { callId: callId || messageId, name: text(block.name) || 'tool', input: '', output: error ? null : output, error: error ? output : null, status: error ? 'failed' : 'completed' } });
363
+ }
364
+ else if (role === 'user' || role === 'assistant' || role === 'system') {
365
+ const value = extractTextBlocks(part);
366
+ if (value.trim() !== '')
367
+ push({ role, kind: 'text', content: value, toolCall: null });
368
+ }
369
+ });
370
+ });
371
+ return result.map((message, index) => ({ ...message, sequence: index + 1 }));
372
+ }
373
+ resolveSessionFilePath(providerSessionId, rawStoreRef) {
374
+ const candidate = rawStoreRef.trim();
375
+ if (isSafeTranscriptPath(candidate, this.homeDirectory) && existsSync(candidate)) {
376
+ const filenameId = basename(candidate, '.jsonl');
377
+ const first = readTranscript(candidate).records.find((record) => record.type === 'session');
378
+ const recordedId = text(first?.id ?? first?.sessionId).trim();
379
+ if (filenameId === providerSessionId || recordedId === providerSessionId)
380
+ return candidate;
381
+ }
382
+ return this.findSessionFile(providerSessionId);
383
+ }
384
+ requireSessionFilePath(providerSessionId, rawStoreRef) {
385
+ const path = this.resolveSessionFilePath(providerSessionId, rawStoreRef);
386
+ if (path === null)
387
+ throw new Error('PROVIDER_SESSION_NOT_FOUND');
388
+ return path;
389
+ }
390
+ findSessionFile(providerSessionId) {
391
+ const root = resolve(join(this.homeDirectory, 'projects'));
392
+ for (const filePath of walkJsonlFiles(root)) {
393
+ if (basename(filePath, '.jsonl') === providerSessionId)
394
+ return filePath;
395
+ const first = readTranscript(filePath).records.find((record) => record.type === 'session');
396
+ if (text(first?.id ?? first?.sessionId).trim() === providerSessionId)
397
+ return filePath;
398
+ }
399
+ return null;
400
+ }
401
+ }
402
+ function readUsage(record, recordIndex = 0) {
403
+ const usage = asRecord(record.usage) ?? asRecord(asRecord(record.event)?.usage) ?? asRecord(asRecord(record.result)?.usage);
404
+ if (usage === null)
405
+ return null;
406
+ const number = (...keys) => {
407
+ for (const key of keys) {
408
+ const value = usage[key];
409
+ if (typeof value === 'number' && Number.isFinite(value))
410
+ return Math.max(0, value);
411
+ }
412
+ return 0;
413
+ };
414
+ const inputTokens = number('inputTokens', 'input_tokens', 'promptTokens', 'prompt_tokens');
415
+ const outputTokens = number('outputTokens', 'output_tokens', 'completionTokens', 'completion_tokens');
416
+ if (inputTokens === 0 && outputTokens === 0 && number('totalTokens', 'total_tokens') === 0)
417
+ return null;
418
+ const contextWindow = number('contextWindow', 'context_window') || readNumber(record.contextWindow ?? record.context_window);
419
+ return {
420
+ messageId: text(record.id ?? asRecord(record.message)?.id ?? asRecord(record.meta)?.messageId) || `record:${recordIndex}`,
421
+ inputTokens,
422
+ outputTokens,
423
+ cacheReadTokens: number('cacheReadTokens', 'cache_read_tokens', 'cachedInputTokens'),
424
+ cacheWriteTokens: number('cacheWriteTokens', 'cache_write_tokens'),
425
+ ...(contextWindow > 0 ? { contextWindow } : {}),
426
+ model: text(usage.model ?? record.model),
427
+ timestamp: text(record.timestamp ?? asRecord(record.event)?.timestamp),
428
+ };
429
+ }
430
+ function readNumber(value) {
431
+ const parsed = typeof value === 'number' ? value : Number(value);
432
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;
433
+ }
434
+ /** 工具结果也会以 user 角色写回,但它不代表新的真实用户轮次。 */
435
+ function countTurns(records) {
436
+ return records.reduce((count, record) => {
437
+ if (record.type !== 'message')
438
+ return count;
439
+ const message = asRecord(record.message);
440
+ if (text(message?.role).trim().toLowerCase() !== 'user')
441
+ return count;
442
+ const parts = Array.isArray(message?.content) ? message.content : [];
443
+ if (parts.length === 0)
444
+ return count;
445
+ const isToolResult = parts.some((part) => {
446
+ const type = text(asRecord(part)?.type).trim().toLowerCase();
447
+ return type === 'tool_result' || type === 'tool_return' || type === 'function_result';
448
+ });
449
+ return isToolResult ? count : count + 1;
450
+ }, 0);
451
+ }
452
+ function sliceHistory(messages, cursor, limit, direction) {
453
+ const size = Math.max(1, Math.min(100, Math.floor(limit) || 50));
454
+ const offset = cursor === null
455
+ ? (direction === 'backward' ? messages.length : 0)
456
+ : decodeCursor(cursor);
457
+ if (direction === 'backward') {
458
+ const start = Math.max(0, offset - size);
459
+ return { messages: messages.slice(start, offset), cursor: encodeCursor(offset), nextCursor: start > 0 ? encodeCursor(start) : null, total: messages.length };
460
+ }
461
+ const end = Math.min(messages.length, offset + size);
462
+ return { messages: messages.slice(offset, end), cursor: encodeCursor(end), nextCursor: end < messages.length ? encodeCursor(end) : null, total: messages.length };
463
+ }
464
+ function encodeCursor(index) {
465
+ return Buffer.from(JSON.stringify({ index: Math.max(0, Math.trunc(index)) }), 'utf8').toString('base64url');
466
+ }
467
+ function decodeCursor(cursor) {
468
+ try {
469
+ const value = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
470
+ const index = Number(value.index);
471
+ if (!Number.isFinite(index) || index < 0)
472
+ throw new Error('CURSOR_INVALID');
473
+ return Math.trunc(index);
474
+ }
475
+ catch {
476
+ // 兼容旧版本曾经暴露的十进制游标,已存在的分页链接不应突然失效。
477
+ const legacy = Number.parseInt(cursor, 10);
478
+ if (Number.isFinite(legacy) && legacy >= 0)
479
+ return legacy;
480
+ throw new Error('CURSOR_INVALID');
481
+ }
482
+ }
483
+ function readTranscript(path) {
484
+ let content = '';
485
+ try {
486
+ content = readFileSync(path, 'utf8');
487
+ }
488
+ catch {
489
+ return { records: [], invalidLineCount: 1, incompleteTailCount: 0, lineNumbers: new Map() };
490
+ }
491
+ const lines = content.split(/\r?\n/u);
492
+ const completeFinalLine = /\r?\n$/u.test(content);
493
+ const records = [];
494
+ const lineNumbers = new Map();
495
+ let invalidLineCount = 0;
496
+ let incompleteTailCount = 0;
497
+ lines.forEach((line, index) => {
498
+ if (line.trim() === '')
499
+ return;
500
+ try {
501
+ const value = JSON.parse(line);
502
+ if (asRecord(value) === null)
503
+ invalidLineCount += 1;
504
+ else {
505
+ const record = value;
506
+ records.push(record);
507
+ lineNumbers.set(record, index + 1);
508
+ }
509
+ }
510
+ catch {
511
+ // 末尾半行是 CLI 正在写入的正常瞬态;中间损坏行仍计入诊断。
512
+ if (index !== lines.length - 1 || completeFinalLine)
513
+ invalidLineCount += 1;
514
+ else if (looksLikeIncompleteJson(line))
515
+ incompleteTailCount += 1;
516
+ }
517
+ });
518
+ return { records, invalidLineCount, incompleteTailCount, lineNumbers };
519
+ }
520
+ function looksLikeIncompleteJson(value) {
521
+ const trimmed = value.trim();
522
+ if (!trimmed.startsWith('{') && !trimmed.startsWith('['))
523
+ return false;
524
+ let depth = 0;
525
+ let inString = false;
526
+ let escaping = false;
527
+ for (const char of trimmed) {
528
+ if (inString) {
529
+ if (escaping)
530
+ escaping = false;
531
+ else if (char === '\\')
532
+ escaping = true;
533
+ else if (char === '"')
534
+ inString = false;
535
+ continue;
536
+ }
537
+ if (char === '"')
538
+ inString = true;
539
+ else if (char === '{' || char === '[')
540
+ depth += 1;
541
+ else if (char === '}' || char === ']')
542
+ depth -= 1;
543
+ }
544
+ return depth > 0 || inString || escaping;
545
+ }
546
+ function extractTextBlocks(value) {
547
+ if (typeof value === 'string')
548
+ return value;
549
+ if (value === undefined || value === null)
550
+ return '';
551
+ if (Array.isArray(value)) {
552
+ const combined = value.map((item) => extractTextBlocks(item).trim()).filter(Boolean).join('\n');
553
+ return combined || stringify(value);
554
+ }
555
+ if (typeof value === 'object') {
556
+ const record = value;
557
+ for (const key of ['text', 'thinking', 'output', 'content', 'message']) {
558
+ const nested = extractTextBlocks(record[key]).trim();
559
+ if (nested)
560
+ return nested;
561
+ }
562
+ return stringify(value);
563
+ }
564
+ return text(value);
565
+ }
566
+ function transcriptTitle(records, messages, path) {
567
+ for (let index = records.length - 1; index >= 0; index -= 1) {
568
+ const record = records[index];
569
+ const metadata = asRecord(record?.meta);
570
+ const title = text(record?.title ?? record?.aiTitle ?? metadata?.title).trim();
571
+ if (title !== '')
572
+ return normalizeTitle(title);
573
+ }
574
+ return normalizeTitle(messages.find((message) => message.role === 'user' && message.kind === 'text' && message.content.trim() !== '')?.content ?? '')
575
+ || basename(path, '.jsonl');
576
+ }
577
+ function normalizeTitle(value) {
578
+ return value.trim().replace(/[\r\n]+/gu, ' ').replace(/\s+/gu, ' ').slice(0, COMMAND_CODE_MAX_TITLE_LENGTH);
579
+ }
580
+ function readArchived(path) {
581
+ try {
582
+ const value = JSON.parse(readFileSync(join(dirname(path), '.meta.json'), 'utf8'));
583
+ return value.archived === true || value.isArchived === true;
584
+ }
585
+ catch {
586
+ return false;
587
+ }
588
+ }
589
+ function isSafeTranscriptPath(candidate, homeDirectory) {
590
+ const rootPath = resolve(join(homeDirectory, 'projects'));
591
+ let root = rootPath;
592
+ try {
593
+ if (existsSync(rootPath))
594
+ root = realpathSync(rootPath);
595
+ }
596
+ catch {
597
+ return false;
598
+ }
599
+ const value = resolve(candidate);
600
+ let actualValue = value;
601
+ try {
602
+ if (existsSync(value))
603
+ actualValue = realpathSync(value);
604
+ }
605
+ catch {
606
+ return false;
607
+ }
608
+ const relativePath = relative(root, actualValue);
609
+ return relativePath !== '' && !relativePath.startsWith('..') && actualValue.endsWith('.jsonl');
610
+ }
611
+ function walkJsonlFiles(root) {
612
+ const files = [];
613
+ const visit = (directory) => {
614
+ let entries;
615
+ try {
616
+ entries = readdirSync(directory);
617
+ }
618
+ catch {
619
+ return;
620
+ }
621
+ for (const entry of entries) {
622
+ const path = join(directory, entry);
623
+ try {
624
+ const stats = statSync(path);
625
+ if (stats.isDirectory())
626
+ visit(path);
627
+ else if (stats.isFile() && entry.endsWith('.jsonl') && !entry.endsWith('.checkpoints.jsonl'))
628
+ files.push(path);
629
+ }
630
+ catch { /* 文件在扫描期间消失,跳过即可 */ }
631
+ }
632
+ };
633
+ visit(root);
634
+ return files;
635
+ }
636
+ function normalizeWorkspace(value) { return resolve(value).replace(/[\\/]+$/u, '').toLowerCase(); }
637
+ function workspaceSlug(value) {
638
+ return value.replace(/[\\/]+$/u, '').replace(/([a-z0-9])([A-Z])/g, '$1-$2').replaceAll(':', '-').replaceAll('\\', '-').replaceAll('/', '-').replace(/[^a-zA-Z0-9_-]+/gu, '-').replace(/-+/g, '-').replace(/^-+|-+$/g, '').toLowerCase();
639
+ }
640
+ function statSafe(path) {
641
+ try {
642
+ const stats = statSync(path);
643
+ return { size: stats.size, mtimeMs: stats.mtimeMs, dev: stats.dev, ino: stats.ino };
644
+ }
645
+ catch {
646
+ return null;
647
+ }
648
+ }
649
+ function asRecord(value) { return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null; }
650
+ function text(value) { return typeof value === 'string' ? value : value === undefined || value === null ? '' : stringify(value); }
651
+ function stringify(value) { if (typeof value === 'string')
652
+ return value; try {
653
+ return JSON.stringify(value) ?? '';
654
+ }
655
+ catch {
656
+ return String(value);
657
+ } }
658
+ function normalizeRole(value) { return value === 'assistant' || value === 'tool' || value === 'system' ? value : 'user'; }
659
+ //# sourceMappingURL=command-code-history.js.map