@jingyi0605/codingns4dsh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/README.md +1114 -0
  2. package/assets/provider-icons/claude-code.png +0 -0
  3. package/assets/provider-icons/codex.png +0 -0
  4. package/assets/provider-icons/command-code.svg +5 -0
  5. package/assets/provider-icons/deepseek-harness.svg +9 -0
  6. package/assets/provider-icons/gemini.png +0 -0
  7. package/assets/provider-icons/grok.png +0 -0
  8. package/assets/provider-icons/kimi.png +0 -0
  9. package/assets/provider-icons/opencode.png +0 -0
  10. package/assets/provider-icons/pi.svg +7 -0
  11. package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +97 -0
  12. package/data/build/dist/bootstrap/dsh-connection-adapter.js +169 -0
  13. package/data/build/dist/bootstrap/index.d.ts +38 -0
  14. package/data/build/dist/bootstrap/index.js +44 -0
  15. package/data/build/dist/client/account-bar.d.ts +9 -0
  16. package/data/build/dist/client/account-bar.js +398 -0
  17. package/data/build/dist/client/bundle.js +26167 -0
  18. package/data/build/dist/client/cli-catalog.d.ts +24 -0
  19. package/data/build/dist/client/cli-catalog.js +108 -0
  20. package/data/build/dist/client/cli-slots.d.ts +38 -0
  21. package/data/build/dist/client/cli-slots.js +297 -0
  22. package/data/build/dist/client/debug/ui.d.ts +12 -0
  23. package/data/build/dist/client/debug/ui.js +451 -0
  24. package/data/build/dist/client/dsh-h5-bootstrap.d.ts +64 -0
  25. package/data/build/dist/client/dsh-h5-bootstrap.js +293 -0
  26. package/data/build/dist/client/dsh-runtime-version.d.ts +3 -0
  27. package/data/build/dist/client/dsh-runtime-version.js +11 -0
  28. package/data/build/dist/client/external-tool-stream.d.ts +24 -0
  29. package/data/build/dist/client/external-tool-stream.js +114 -0
  30. package/data/build/dist/client/features/cli-adapters.d.ts +7 -0
  31. package/data/build/dist/client/features/cli-adapters.js +215 -0
  32. package/data/build/dist/client/features/debug.d.ts +4 -0
  33. package/data/build/dist/client/features/debug.js +24 -0
  34. package/data/build/dist/client/features/index.d.ts +33 -0
  35. package/data/build/dist/client/features/index.js +44 -0
  36. package/data/build/dist/client/features/lan-access-panel.d.ts +5 -0
  37. package/data/build/dist/client/features/lan-access-panel.js +146 -0
  38. package/data/build/dist/client/features/lan-access.d.ts +9 -0
  39. package/data/build/dist/client/features/lan-access.js +30 -0
  40. package/data/build/dist/client/features/login-protection-panel.d.ts +5 -0
  41. package/data/build/dist/client/features/login-protection-panel.js +91 -0
  42. package/data/build/dist/client/features/login-protection-session.d.ts +6 -0
  43. package/data/build/dist/client/features/login-protection-session.js +25 -0
  44. package/data/build/dist/client/features/login-protection.d.ts +4 -0
  45. package/data/build/dist/client/features/login-protection.js +23 -0
  46. package/data/build/dist/client/features/reverse-proxy-panel.d.ts +9 -0
  47. package/data/build/dist/client/features/reverse-proxy-panel.js +159 -0
  48. package/data/build/dist/client/features/reverse-proxy.d.ts +12 -0
  49. package/data/build/dist/client/features/reverse-proxy.js +112 -0
  50. package/data/build/dist/client/features/terminal-enhancement-panel.d.ts +5 -0
  51. package/data/build/dist/client/features/terminal-enhancement-panel.js +160 -0
  52. package/data/build/dist/client/features/terminal-enhancement.d.ts +4 -0
  53. package/data/build/dist/client/features/terminal-enhancement.js +24 -0
  54. package/data/build/dist/client/features/types.d.ts +58 -0
  55. package/data/build/dist/client/features/types.js +2 -0
  56. package/data/build/dist/client/features/workspace-session-enhancement-panel.d.ts +5 -0
  57. package/data/build/dist/client/features/workspace-session-enhancement-panel.js +66 -0
  58. package/data/build/dist/client/features/workspace-session-enhancement.d.ts +4 -0
  59. package/data/build/dist/client/features/workspace-session-enhancement.js +101 -0
  60. package/data/build/dist/client/h5-bootstrap-entry.d.ts +2 -0
  61. package/data/build/dist/client/h5-bootstrap-entry.js +17 -0
  62. package/data/build/dist/client/index.d.ts +31 -0
  63. package/data/build/dist/client/index.js +98 -0
  64. package/data/build/dist/client/lan-access.d.ts +28 -0
  65. package/data/build/dist/client/lan-access.js +68 -0
  66. package/data/build/dist/client/locale.d.ts +20 -0
  67. package/data/build/dist/client/locale.js +393 -0
  68. package/data/build/dist/client/provider-icon-assets.d.ts +2 -0
  69. package/data/build/dist/client/provider-icon-assets.js +23 -0
  70. package/data/build/dist/client/provider-icons.d.ts +19 -0
  71. package/data/build/dist/client/provider-icons.js +39 -0
  72. package/data/build/dist/client/remote-web-context.d.ts +57 -0
  73. package/data/build/dist/client/remote-web-context.js +939 -0
  74. package/data/build/dist/client/session-adapter-cache.d.ts +18 -0
  75. package/data/build/dist/client/session-adapter-cache.js +84 -0
  76. package/data/build/dist/client/settings-bridge.d.ts +32 -0
  77. package/data/build/dist/client/settings-bridge.js +126 -0
  78. package/data/build/dist/client/settings-section.d.ts +30 -0
  79. package/data/build/dist/client/settings-section.js +93 -0
  80. package/data/build/dist/client/subscription-slot.d.ts +18 -0
  81. package/data/build/dist/client/subscription-slot.js +223 -0
  82. package/data/build/dist/client/terminal/index.d.ts +4 -0
  83. package/data/build/dist/client/terminal/index.js +3 -0
  84. package/data/build/dist/client/terminal/model.d.ts +116 -0
  85. package/data/build/dist/client/terminal/model.js +435 -0
  86. package/data/build/dist/client/terminal/styles.d.ts +21 -0
  87. package/data/build/dist/client/terminal/styles.js +51 -0
  88. package/data/build/dist/client/terminal/ui.d.ts +19 -0
  89. package/data/build/dist/client/terminal/ui.js +257 -0
  90. package/data/build/dist/client/terminal/xterm-view.d.ts +13 -0
  91. package/data/build/dist/client/terminal/xterm-view.js +213 -0
  92. package/data/build/dist/client/theme.d.ts +56 -0
  93. package/data/build/dist/client/theme.js +186 -0
  94. package/data/build/dist/client/workspace-session-archive-dom.d.ts +29 -0
  95. package/data/build/dist/client/workspace-session-archive-dom.js +525 -0
  96. package/data/build/dist/client/workspace-session-fiber.d.ts +3 -0
  97. package/data/build/dist/client/workspace-session-fiber.js +33 -0
  98. package/data/build/dist/client/workspace-session-logo-dom.d.ts +26 -0
  99. package/data/build/dist/client/workspace-session-logo-dom.js +128 -0
  100. package/data/build/dist/features/index.d.ts +3 -0
  101. package/data/build/dist/features/index.js +2 -0
  102. package/data/build/dist/features/registry.d.ts +74 -0
  103. package/data/build/dist/features/registry.js +382 -0
  104. package/data/build/dist/features/resource-scope/index.d.ts +39 -0
  105. package/data/build/dist/features/resource-scope/index.js +161 -0
  106. package/data/build/dist/host/auth-session.d.ts +42 -0
  107. package/data/build/dist/host/auth-session.js +186 -0
  108. package/data/build/dist/host/cli-adapters/claude-driver.d.ts +14 -0
  109. package/data/build/dist/host/cli-adapters/claude-driver.js +103 -0
  110. package/data/build/dist/host/cli-adapters/codex-driver.d.ts +45 -0
  111. package/data/build/dist/host/cli-adapters/codex-driver.js +534 -0
  112. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +38 -0
  113. package/data/build/dist/host/cli-adapters/command-code-driver.js +394 -0
  114. package/data/build/dist/host/cli-adapters/command-code-subscription.d.ts +19 -0
  115. package/data/build/dist/host/cli-adapters/command-code-subscription.js +126 -0
  116. package/data/build/dist/host/cli-adapters/driver.d.ts +41 -0
  117. package/data/build/dist/host/cli-adapters/driver.js +2 -0
  118. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +37 -0
  119. package/data/build/dist/host/cli-adapters/dsh-message-projector.js +180 -0
  120. package/data/build/dist/host/cli-adapters/dsh-tool-history.d.ts +48 -0
  121. package/data/build/dist/host/cli-adapters/dsh-tool-history.js +373 -0
  122. package/data/build/dist/host/cli-adapters/feature.d.ts +7 -0
  123. package/data/build/dist/host/cli-adapters/feature.js +335 -0
  124. package/data/build/dist/host/cli-adapters/gemini-driver.d.ts +24 -0
  125. package/data/build/dist/host/cli-adapters/gemini-driver.js +427 -0
  126. package/data/build/dist/host/cli-adapters/grok-driver.d.ts +38 -0
  127. package/data/build/dist/host/cli-adapters/grok-driver.js +372 -0
  128. package/data/build/dist/host/cli-adapters/http-sse-client.d.ts +22 -0
  129. package/data/build/dist/host/cli-adapters/http-sse-client.js +99 -0
  130. package/data/build/dist/host/cli-adapters/interaction-events.d.ts +11 -0
  131. package/data/build/dist/host/cli-adapters/interaction-events.js +80 -0
  132. package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts +65 -0
  133. package/data/build/dist/host/cli-adapters/json-rpc-process.js +256 -0
  134. package/data/build/dist/host/cli-adapters/kimi-driver.d.ts +21 -0
  135. package/data/build/dist/host/cli-adapters/kimi-driver.js +382 -0
  136. package/data/build/dist/host/cli-adapters/model-catalog.d.ts +22 -0
  137. package/data/build/dist/host/cli-adapters/model-catalog.js +89 -0
  138. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +55 -0
  139. package/data/build/dist/host/cli-adapters/opencode-driver.js +728 -0
  140. package/data/build/dist/host/cli-adapters/pi-driver.d.ts +43 -0
  141. package/data/build/dist/host/cli-adapters/pi-driver.js +312 -0
  142. package/data/build/dist/host/cli-adapters/process-utils.d.ts +16 -0
  143. package/data/build/dist/host/cli-adapters/process-utils.js +27 -0
  144. package/data/build/dist/host/cli-adapters/provider-subscription.d.ts +82 -0
  145. package/data/build/dist/host/cli-adapters/provider-subscription.js +610 -0
  146. package/data/build/dist/host/cli-adapters/registry.d.ts +95 -0
  147. package/data/build/dist/host/cli-adapters/registry.js +659 -0
  148. package/data/build/dist/host/cli-adapters/rpc-driver-utils.d.ts +24 -0
  149. package/data/build/dist/host/cli-adapters/rpc-driver-utils.js +119 -0
  150. package/data/build/dist/host/cli-adapters/session-probe.d.ts +20 -0
  151. package/data/build/dist/host/cli-adapters/session-probe.js +139 -0
  152. package/data/build/dist/host/cli-adapters/session-store.d.ts +68 -0
  153. package/data/build/dist/host/cli-adapters/session-store.js +180 -0
  154. package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts +45 -0
  155. package/data/build/dist/host/cli-adapters/standard-stream-driver.js +205 -0
  156. package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +25 -0
  157. package/data/build/dist/host/cli-adapters/stream-normalizer.js +83 -0
  158. package/data/build/dist/host/cli-adapters/tool-observation.d.ts +9 -0
  159. package/data/build/dist/host/cli-adapters/tool-observation.js +39 -0
  160. package/data/build/dist/host/control-api-client.d.ts +84 -0
  161. package/data/build/dist/host/control-api-client.js +130 -0
  162. package/data/build/dist/host/credential-store.d.ts +54 -0
  163. package/data/build/dist/host/credential-store.js +114 -0
  164. package/data/build/dist/host/debug.d.ts +79 -0
  165. package/data/build/dist/host/debug.js +295 -0
  166. package/data/build/dist/host/dsh-device-runtime.d.ts +39 -0
  167. package/data/build/dist/host/dsh-device-runtime.js +118 -0
  168. package/data/build/dist/host/dsh-gateway-feature.d.ts +5 -0
  169. package/data/build/dist/host/dsh-gateway-feature.js +55 -0
  170. package/data/build/dist/host/dsh-runtime-version.d.ts +12 -0
  171. package/data/build/dist/host/dsh-runtime-version.js +69 -0
  172. package/data/build/dist/host/features/auth.d.ts +11 -0
  173. package/data/build/dist/host/features/auth.js +273 -0
  174. package/data/build/dist/host/features/debug.d.ts +5 -0
  175. package/data/build/dist/host/features/debug.js +90 -0
  176. package/data/build/dist/host/features/host-status.d.ts +12 -0
  177. package/data/build/dist/host/features/host-status.js +54 -0
  178. package/data/build/dist/host/features/index.d.ts +19 -0
  179. package/data/build/dist/host/features/index.js +29 -0
  180. package/data/build/dist/host/features/lan-access-dsh.d.ts +8 -0
  181. package/data/build/dist/host/features/lan-access-dsh.js +45 -0
  182. package/data/build/dist/host/features/terminal-process.d.ts +5 -0
  183. package/data/build/dist/host/features/terminal-process.js +110 -0
  184. package/data/build/dist/host/features/terminal-status.d.ts +18 -0
  185. package/data/build/dist/host/features/terminal-status.js +56 -0
  186. package/data/build/dist/host/features/types.d.ts +41 -0
  187. package/data/build/dist/host/features/types.js +2 -0
  188. package/data/build/dist/host/index.d.ts +43 -0
  189. package/data/build/dist/host/index.js +135 -0
  190. package/data/build/dist/host/lan-access-dsh.d.ts +83 -0
  191. package/data/build/dist/host/lan-access-dsh.js +831 -0
  192. package/data/build/dist/host/native-session-bridge.d.ts +130 -0
  193. package/data/build/dist/host/native-session-bridge.js +317 -0
  194. package/data/build/dist/host/relay-tunnel-runtime.d.ts +97 -0
  195. package/data/build/dist/host/relay-tunnel-runtime.js +361 -0
  196. package/data/build/dist/host/remote-web-runtime.d.ts +78 -0
  197. package/data/build/dist/host/remote-web-runtime.js +559 -0
  198. package/data/build/dist/host/rpc-table.d.ts +32 -0
  199. package/data/build/dist/host/rpc-table.js +47 -0
  200. package/data/build/dist/host/rpc.d.ts +18 -0
  201. package/data/build/dist/host/rpc.js +248 -0
  202. package/data/build/dist/host/settings.d.ts +19 -0
  203. package/data/build/dist/host/settings.js +80 -0
  204. package/data/build/dist/host/terminal/attachment-registry.d.ts +17 -0
  205. package/data/build/dist/host/terminal/attachment-registry.js +49 -0
  206. package/data/build/dist/host/terminal/backends/conpty-backend.d.ts +39 -0
  207. package/data/build/dist/host/terminal/backends/conpty-backend.js +160 -0
  208. package/data/build/dist/host/terminal/backends/local-pty-backend.d.ts +36 -0
  209. package/data/build/dist/host/terminal/backends/local-pty-backend.js +178 -0
  210. package/data/build/dist/host/terminal/backends/tmux-backend.d.ts +40 -0
  211. package/data/build/dist/host/terminal/backends/tmux-backend.js +191 -0
  212. package/data/build/dist/host/terminal/broker/conpty-broker-client.d.ts +27 -0
  213. package/data/build/dist/host/terminal/broker/conpty-broker-client.js +154 -0
  214. package/data/build/dist/host/terminal/broker/conpty-broker-process.d.ts +10 -0
  215. package/data/build/dist/host/terminal/broker/conpty-broker-process.js +147 -0
  216. package/data/build/dist/host/terminal/broker/conpty-broker-protocol.d.ts +92 -0
  217. package/data/build/dist/host/terminal/broker/conpty-broker-protocol.js +134 -0
  218. package/data/build/dist/host/terminal/controller-factory.d.ts +37 -0
  219. package/data/build/dist/host/terminal/controller-factory.js +82 -0
  220. package/data/build/dist/host/terminal/index.d.ts +17 -0
  221. package/data/build/dist/host/terminal/index.js +17 -0
  222. package/data/build/dist/host/terminal/runtime-adapter.d.ts +77 -0
  223. package/data/build/dist/host/terminal/runtime-adapter.js +18 -0
  224. package/data/build/dist/host/terminal/runtime-manager.d.ts +41 -0
  225. package/data/build/dist/host/terminal/runtime-manager.js +179 -0
  226. package/data/build/dist/host/terminal/shell-detection.d.ts +23 -0
  227. package/data/build/dist/host/terminal/shell-detection.js +105 -0
  228. package/data/build/dist/host/terminal/startup.d.ts +33 -0
  229. package/data/build/dist/host/terminal/startup.js +100 -0
  230. package/data/build/dist/host/terminal/terminal-controller.d.ts +78 -0
  231. package/data/build/dist/host/terminal/terminal-controller.js +324 -0
  232. package/data/build/dist/host/terminal/terminal-process-service.d.ts +30 -0
  233. package/data/build/dist/host/terminal/terminal-process-service.js +194 -0
  234. package/data/build/dist/host/terminal/terminal-process-store.d.ts +45 -0
  235. package/data/build/dist/host/terminal/terminal-process-store.js +183 -0
  236. package/data/build/dist/host/terminal/terminal-service.d.ts +87 -0
  237. package/data/build/dist/host/terminal/terminal-service.js +528 -0
  238. package/data/build/dist/host/terminal/terminal-store.d.ts +49 -0
  239. package/data/build/dist/host/terminal/terminal-store.js +242 -0
  240. package/data/build/dist/index.d.ts +37 -0
  241. package/data/build/dist/index.js +26 -0
  242. package/data/build/dist/shared/contracts/auth.d.ts +122 -0
  243. package/data/build/dist/shared/contracts/auth.js +8 -0
  244. package/data/build/dist/shared/contracts/cli-adapter.d.ts +192 -0
  245. package/data/build/dist/shared/contracts/cli-adapter.js +2 -0
  246. package/data/build/dist/shared/contracts/command-code.d.ts +5 -0
  247. package/data/build/dist/shared/contracts/command-code.js +2 -0
  248. package/data/build/dist/shared/contracts/config.d.ts +113 -0
  249. package/data/build/dist/shared/contracts/config.js +86 -0
  250. package/data/build/dist/shared/contracts/debug-config.d.ts +28 -0
  251. package/data/build/dist/shared/contracts/debug-config.js +78 -0
  252. package/data/build/dist/shared/contracts/debug.d.ts +75 -0
  253. package/data/build/dist/shared/contracts/debug.js +121 -0
  254. package/data/build/dist/shared/contracts/dsh-device.d.ts +72 -0
  255. package/data/build/dist/shared/contracts/dsh-device.js +2 -0
  256. package/data/build/dist/shared/contracts/errors.d.ts +33 -0
  257. package/data/build/dist/shared/contracts/errors.js +41 -0
  258. package/data/build/dist/shared/contracts/feature.d.ts +71 -0
  259. package/data/build/dist/shared/contracts/feature.js +2 -0
  260. package/data/build/dist/shared/contracts/host-status.d.ts +14 -0
  261. package/data/build/dist/shared/contracts/host-status.js +2 -0
  262. package/data/build/dist/shared/contracts/lan-access-dsh.d.ts +30 -0
  263. package/data/build/dist/shared/contracts/lan-access-dsh.js +2 -0
  264. package/data/build/dist/shared/contracts/peer-host.d.ts +37 -0
  265. package/data/build/dist/shared/contracts/peer-host.js +9 -0
  266. package/data/build/dist/shared/contracts/signaling.d.ts +67 -0
  267. package/data/build/dist/shared/contracts/signaling.js +2 -0
  268. package/data/build/dist/shared/contracts/subscription.d.ts +69 -0
  269. package/data/build/dist/shared/contracts/subscription.js +2 -0
  270. package/data/build/dist/shared/contracts/terminal-process.d.ts +65 -0
  271. package/data/build/dist/shared/contracts/terminal-process.js +2 -0
  272. package/data/build/dist/shared/contracts/terminal.d.ts +127 -0
  273. package/data/build/dist/shared/contracts/terminal.js +2 -0
  274. package/data/build/dist/shared/contracts/transport.d.ts +45 -0
  275. package/data/build/dist/shared/contracts/transport.js +3 -0
  276. package/data/build/dist/shared/contracts/version.d.ts +19 -0
  277. package/data/build/dist/shared/contracts/version.js +74 -0
  278. package/data/build/dist/shared/index.d.ts +22 -0
  279. package/data/build/dist/shared/index.js +9 -0
  280. package/data/build/dist/transport/carrier.d.ts +38 -0
  281. package/data/build/dist/transport/carrier.js +268 -0
  282. package/data/build/dist/transport/debug.d.ts +22 -0
  283. package/data/build/dist/transport/debug.js +57 -0
  284. package/data/build/dist/transport/dsh-envelope.d.ts +41 -0
  285. package/data/build/dist/transport/dsh-envelope.js +107 -0
  286. package/data/build/dist/transport/dsh-gateway.d.ts +64 -0
  287. package/data/build/dist/transport/dsh-gateway.js +254 -0
  288. package/data/build/dist/transport/dsh-session.d.ts +55 -0
  289. package/data/build/dist/transport/dsh-session.js +256 -0
  290. package/data/build/dist/transport/dsh-transport.d.ts +57 -0
  291. package/data/build/dist/transport/dsh-transport.js +125 -0
  292. package/data/build/dist/transport/frame.d.ts +132 -0
  293. package/data/build/dist/transport/frame.js +168 -0
  294. package/data/build/dist/transport/index.d.ts +11 -0
  295. package/data/build/dist/transport/index.js +11 -0
  296. package/data/build/dist/transport/multiplexer.d.ts +63 -0
  297. package/data/build/dist/transport/multiplexer.js +323 -0
  298. package/data/build/dist/transport/webrtc-client.d.ts +65 -0
  299. package/data/build/dist/transport/webrtc-client.js +255 -0
  300. package/data/build/dist/transport/webrtc-host.d.ts +58 -0
  301. package/data/build/dist/transport/webrtc-host.js +252 -0
  302. package/data/build/dist/typert.host.d.ts +25 -0
  303. package/data/build/dist/typert.host.js +150 -0
  304. package/dsh.bundle.patch +12 -0
  305. package/package.json +135 -0
  306. package/profile/README.md +27 -0
  307. package/profile/cordis.patch.yml +2 -0
  308. package/profile/package.json +20 -0
  309. package/profile/scripts/check-dsh-install.mjs +71 -0
  310. package/profile/version.json +5 -0
  311. package/scripts/check-dsh-install.mjs +88 -0
  312. package/version.json +6 -0
@@ -0,0 +1,180 @@
1
+ import { CodingNsDshToolHistoryProjector } from './dsh-tool-history.js';
2
+ import { CodingNsAgentEventNormalizer, } from './stream-normalizer.js';
3
+ /**
4
+ * 所有外部 Agent 共用的 DSH 消息投影器。
5
+ *
6
+ * 驱动只产生 CodingNsAgentEvent。本类统一完成快照去重、通道索引、工具历史、
7
+ * 原生权限/问题交互、usage 和终态映射,调用方不再按 Provider 或消息类型分支。
8
+ */
9
+ export class CodingNsDshMessageProjector {
10
+ options;
11
+ normalizer = new CodingNsAgentEventNormalizer();
12
+ toolHistory;
13
+ finished = false;
14
+ constructor(options) {
15
+ this.options = options;
16
+ this.toolHistory = new CodingNsDshToolHistoryProjector(options.nativeSessions, options.sessionId);
17
+ }
18
+ get isFinished() {
19
+ return this.finished;
20
+ }
21
+ async push(event) {
22
+ if (this.finished)
23
+ return [];
24
+ const projected = [];
25
+ for (const normalized of this.normalizer.push(event)) {
26
+ projected.push(...await this.project(normalized));
27
+ if (this.finished)
28
+ break;
29
+ }
30
+ return projected;
31
+ }
32
+ /** Provider 未发送 finish 时补齐 usage 和正常终态。 */
33
+ async complete(reason = 'stop') {
34
+ if (this.finished)
35
+ return [];
36
+ const projected = await this.flushUsage();
37
+ projected.push(...await this.project({ type: 'finish', reason }));
38
+ return projected;
39
+ }
40
+ /** 把执行异常也交给同一投影层,确保错误正文和终态结构一致。 */
41
+ async fail(message, cancelled = false) {
42
+ if (this.finished)
43
+ return [];
44
+ const projected = await this.flushUsage();
45
+ const reason = cancelled ? 'cancel' : 'error';
46
+ if (!cancelled) {
47
+ projected.push({ type: 'text-delta', index: 1, text: formatExecutionFailure(this.options.adapterId, message) });
48
+ }
49
+ projected.push(...await this.project({ type: 'finish', reason }, message));
50
+ return projected;
51
+ }
52
+ async flushUsage() {
53
+ const projected = [];
54
+ for (const event of this.normalizer.flush())
55
+ projected.push(...await this.project(event));
56
+ return projected;
57
+ }
58
+ async project(event, failureMessage) {
59
+ switch (event.type) {
60
+ case 'reasoning-delta':
61
+ return event.text === '' ? [] : [{ type: 'reasoning-delta', index: 0, text: event.text }];
62
+ case 'text-delta':
63
+ return event.text === '' ? [] : [{ type: 'text-delta', index: 1, text: event.text }];
64
+ case 'tool-event':
65
+ return externalToolChunk(this.toolHistory.observe(event));
66
+ case 'permission-request':
67
+ await this.requestPermission(event);
68
+ return [];
69
+ case 'question-request':
70
+ await this.requestQuestions(event);
71
+ return [];
72
+ case 'usage':
73
+ if (event.contextWindow !== undefined) {
74
+ this.options.nativeSessions?.appendRequestContext?.(this.options.sessionId, {
75
+ provider: this.options.adapterId,
76
+ model: this.options.modelId ?? this.options.adapterId,
77
+ contextWindow: event.contextWindow,
78
+ });
79
+ }
80
+ return [{
81
+ type: 'usage',
82
+ usage: {
83
+ inputTokens: event.inputTokens,
84
+ outputTokens: event.outputTokens,
85
+ ...(event.cacheReadTokens === undefined ? {} : { cacheReadTokens: event.cacheReadTokens }),
86
+ ...(event.cacheWriteTokens === undefined ? {} : { cacheWriteTokens: event.cacheWriteTokens }),
87
+ ...(event.uncachedInputTokens === undefined ? {} : { uncachedInputTokens: event.uncachedInputTokens }),
88
+ ...(event.totalTokens === undefined ? {} : { totalTokens: event.totalTokens }),
89
+ ...(event.cacheHitRate === undefined ? {} : { cacheHitRate: event.cacheHitRate }),
90
+ ...(event.contextWindow === undefined ? {} : { contextWindow: event.contextWindow }),
91
+ ...(event.contextTokens === undefined ? {} : { contextTokens: event.contextTokens }),
92
+ ...(event.contextUsageRatio === undefined ? {} : { contextUsageRatio: event.contextUsageRatio }),
93
+ },
94
+ }];
95
+ case 'session-binding':
96
+ return [];
97
+ case 'finish':
98
+ this.finished = true;
99
+ this.toolHistory.finalize(event.reason, failureMessage);
100
+ return [{ type: 'finish', reason: toDshFinishReason(event.reason, failureMessage) }];
101
+ }
102
+ }
103
+ async requestPermission(event) {
104
+ const responder = this.options.respondPermission;
105
+ if (responder === undefined)
106
+ throw new Error('外部 Agent 发送了权限请求,但适配器没有权限回复接口');
107
+ const outcome = await this.options.nativeSessions?.requestApproval?.(this.options.sessionId, {
108
+ requestId: event.requestId,
109
+ toolName: event.toolName ?? (event.kind || 'external-agent'),
110
+ ...(event.callId ? { callId: event.callId } : {}),
111
+ ...(event.detail ? { reason: event.detail } : {}),
112
+ ...(this.options.signal === undefined ? {} : { signal: this.options.signal }),
113
+ }) ?? 'unavailable';
114
+ const approved = outcome === 'allowed-once';
115
+ const reason = approvalReason(outcome);
116
+ await responder({ requestId: event.requestId, approved, ...(reason === undefined ? {} : { reason }) });
117
+ }
118
+ async requestQuestions(event) {
119
+ const responder = this.options.respondQuestion;
120
+ if (responder === undefined)
121
+ throw new Error('外部 Agent 发送了问题请求,但适配器没有问题回复接口');
122
+ const response = await this.options.nativeSessions?.askQuestions?.(this.options.sessionId, {
123
+ requestId: event.requestId,
124
+ questions: event.questions,
125
+ ...(this.options.signal === undefined ? {} : { signal: this.options.signal }),
126
+ }) ?? null;
127
+ if (response === null)
128
+ throw new Error('DSH 原生问题组件不可用或问题已取消');
129
+ await responder(response);
130
+ }
131
+ }
132
+ /**
133
+ * 没有 DSH 原生 Session 时的工具展示回退:使用空白 reasoning chunk 携带私有标记,
134
+ * 只让 Client 的实时 Conversation 投影读取,不会再次执行工具。完整 Host 直接使用
135
+ * 原生 tool/call 与 tool/result,不经过这里。
136
+ */
137
+ function externalToolChunk(marker) {
138
+ if (marker === null)
139
+ return [];
140
+ return [{
141
+ type: 'reasoning-delta',
142
+ index: 0,
143
+ // 空 delta 会被 DSH 的流式聚合器丢弃,空格能保留 live-chunk 但不会显示思考正文。
144
+ text: ' ',
145
+ codingnsExternalTool: marker,
146
+ }];
147
+ }
148
+ function toDshFinishReason(reason, failureMessage) {
149
+ if (reason === 'cancel') {
150
+ return { kind: 'aborted', failure: { message: failureMessage ?? '外部 Agent 执行已取消', code: 'ABORTED' } };
151
+ }
152
+ if (reason === 'error') {
153
+ return { kind: 'error', failure: { message: failureMessage ?? '外部 Agent 执行失败', code: 'PROVIDER_ERROR' } };
154
+ }
155
+ return { kind: 'stop' };
156
+ }
157
+ function approvalReason(outcome) {
158
+ if (outcome === 'rejected')
159
+ return '用户拒绝了权限请求';
160
+ if (outcome === 'cancelled')
161
+ return '权限请求已取消';
162
+ if (outcome === 'unavailable')
163
+ return 'DSH 原生权限组件不可用';
164
+ return undefined;
165
+ }
166
+ function formatExecutionFailure(adapterId, message) {
167
+ const content = `[${adapterId}] ${message}`;
168
+ const fence = '~'.repeat(Math.max(3, longestCharacterRun(content, '~') + 1));
169
+ return `\n\n**外部 Agent 执行失败**\n\n${fence}text\n${content}\n${fence}\n`;
170
+ }
171
+ function longestCharacterRun(value, character) {
172
+ let longest = 0;
173
+ let current = 0;
174
+ for (const item of value) {
175
+ current = item === character ? current + 1 : 0;
176
+ longest = Math.max(longest, current);
177
+ }
178
+ return longest;
179
+ }
180
+ //# sourceMappingURL=dsh-message-projector.js.map
@@ -0,0 +1,48 @@
1
+ import type { CodingNsAgentToolEvent } from '../../shared/contracts/cli-adapter.js';
2
+ import type { CodingNsNativeSessionBridge } from '../native-session-bridge.js';
3
+ /** 外部工具的实时回退标记;正常 Host 会优先写入 Session 持久时间线。 */
4
+ export interface CodingNsDshExternalToolMarker {
5
+ readonly source: 'codingns-external-tool';
6
+ readonly phase: 'start' | 'update';
7
+ readonly callId: string;
8
+ readonly name: string;
9
+ readonly arguments: string;
10
+ readonly status: 'running' | 'completed' | 'failed';
11
+ readonly output?: string;
12
+ readonly error?: string;
13
+ }
14
+ /**
15
+ * 所有外部 Agent 共用的 DSH 工具历史投影器。
16
+ *
17
+ * 驱动只需要产出统一的 tool-event 观察事件;这里负责生命周期聚合、工具别名、
18
+ * 参数修正、结果文本和 diff 元数据,最后经唯一的原生 Session 桥接落盘。
19
+ */
20
+ export declare class CodingNsDshToolHistoryProjector {
21
+ private readonly nativeSessions;
22
+ private readonly sessionId;
23
+ private readonly records;
24
+ private readonly deferNativeAppend;
25
+ private readonly removeNativeEventListener;
26
+ private anonymousSequence;
27
+ private turnChars;
28
+ private observedCalls;
29
+ private finalized;
30
+ private flushScheduled;
31
+ constructor(nativeSessions: CodingNsNativeSessionBridge | undefined, sessionId: string);
32
+ observe(event: CodingNsAgentToolEvent): CodingNsDshExternalToolMarker | null;
33
+ /** 流结束时补齐 Provider 遗漏的终态,避免原生组件永久停留在运行中。 */
34
+ finalize(reason: 'stop' | 'cancel' | 'error', failure?: string): void;
35
+ private assign;
36
+ private settle;
37
+ /** 按 Provider 到达顺序把工具调用和结果写入当前 DSH step。 */
38
+ private flushNativeRecords;
39
+ private persistNativeRecord;
40
+ private scheduleFlush;
41
+ /** 活动 step 晚于首个工具通知时,补写尚未进入 Session 的工具标记。 */
42
+ private flushExternalMarkers;
43
+ /** 先补齐同一调用的 start,再追加当前 update,保持 Conversation 生命周期合法。 */
44
+ private persistExternalMarker;
45
+ private appendCall;
46
+ private nextAnonymousCallId;
47
+ }
48
+ //# sourceMappingURL=dsh-tool-history.d.ts.map
@@ -0,0 +1,373 @@
1
+ const FIELD_LIMIT = 64 * 1024;
2
+ const CALL_LIMIT = 192 * 1024;
3
+ const TURN_LIMIT = 768 * 1024;
4
+ const CALL_COUNT_LIMIT = 256;
5
+ const TRUNCATION_MARKER = '\n...[内容因长度限制已截断]';
6
+ /**
7
+ * 所有外部 Agent 共用的 DSH 工具历史投影器。
8
+ *
9
+ * 驱动只需要产出统一的 tool-event 观察事件;这里负责生命周期聚合、工具别名、
10
+ * 参数修正、结果文本和 diff 元数据,最后经唯一的原生 Session 桥接落盘。
11
+ */
12
+ export class CodingNsDshToolHistoryProjector {
13
+ nativeSessions;
14
+ sessionId;
15
+ records = new Map();
16
+ deferNativeAppend;
17
+ removeNativeEventListener;
18
+ anonymousSequence = 0;
19
+ turnChars = 0;
20
+ observedCalls = 0;
21
+ finalized = false;
22
+ flushScheduled = false;
23
+ constructor(nativeSessions, sessionId) {
24
+ this.nativeSessions = nativeSessions;
25
+ this.sessionId = sessionId;
26
+ // 工具事件必须尽早进入当前 step。新桥接优先写入原生 tool/call 与 tool/result;
27
+ // 自定义标记只负责把这次通知立即送进实时 Conversation。不能把工具伪装成
28
+ // assistant/attempt,因为 DSH 会把后者当成模型结算,天然排到正文之后。
29
+ const subscribe = nativeSessions?.supportsEvents === true ? nativeSessions.subscribe : undefined;
30
+ this.deferNativeAppend = nativeSessions?.appendToolCall === undefined && nativeSessions?.appendExternalToolEvent === undefined && subscribe !== undefined;
31
+ this.removeNativeEventListener = subscribe?.call(nativeSessions, {
32
+ onEvent: (session, event) => {
33
+ if (session !== nativeSessions?.get(sessionId))
34
+ return;
35
+ if (!isNativeStepStart(event) || this.flushScheduled)
36
+ return;
37
+ this.flushScheduled = true;
38
+ queueMicrotask(() => {
39
+ this.flushScheduled = false;
40
+ if (nativeSessions?.appendToolCall !== undefined)
41
+ this.flushNativeRecords();
42
+ else
43
+ this.flushExternalMarkers();
44
+ });
45
+ },
46
+ });
47
+ }
48
+ observe(event) {
49
+ const explicitCallId = event.callId?.trim();
50
+ const callId = explicitCallId || this.nextAnonymousCallId();
51
+ const key = explicitCallId ? `id:${explicitCallId}` : `anonymous:${callId}`;
52
+ const current = this.records.get(key);
53
+ if (current === undefined && this.observedCalls >= CALL_COUNT_LIMIT)
54
+ return null;
55
+ const toolName = meaningfulToolName(event.toolName, current?.toolName);
56
+ const input = event.input ?? current?.input;
57
+ const record = current ?? {
58
+ callId,
59
+ toolName,
60
+ handle: null,
61
+ failed: false,
62
+ settled: false,
63
+ resultAppended: false,
64
+ externalPersisted: false,
65
+ externalMarkerPersisted: false,
66
+ };
67
+ if (current === undefined)
68
+ this.observedCalls += 1;
69
+ record.toolName = toolName;
70
+ this.assign(record, 'input', input, 'snapshot');
71
+ if (event.output !== undefined) {
72
+ if (event.outputMode === undefined)
73
+ throw new Error('工具输出事件缺少 outputMode');
74
+ this.assign(record, 'output', event.output, event.outputMode);
75
+ }
76
+ this.assign(record, 'error', event.error, 'snapshot');
77
+ if (event.status === 'failed' || event.error !== undefined)
78
+ record.failed = true;
79
+ this.records.set(key, record);
80
+ if (event.status === 'completed' || event.status === 'failed') {
81
+ this.settle(record, record.failed);
82
+ }
83
+ const normalized = normalizeToolCall(record.toolName, record.input);
84
+ const status = record.failed
85
+ ? 'failed'
86
+ : record.settled
87
+ ? 'completed'
88
+ : 'running';
89
+ const marker = {
90
+ source: 'codingns-external-tool',
91
+ phase: current === undefined ? 'start' : 'update',
92
+ callId: record.callId,
93
+ name: normalized.name,
94
+ arguments: normalized.arguments,
95
+ status,
96
+ ...(record.output === undefined ? {} : { output: record.output }),
97
+ ...(record.error === undefined ? {} : { error: record.error }),
98
+ };
99
+ record.externalMarker = marker;
100
+ record.externalMarkerPersisted = false;
101
+ if (this.nativeSessions?.appendToolCall !== undefined && this.sessionId.trim() !== '') {
102
+ // DSH Chat 原生识别 tool/call 为运行中的工具节点,tool/result 负责更新它。
103
+ // 不再额外伪造 reasoning-delta,否则每个工具通知都会触发 assistant 正文刷新。
104
+ const persisted = this.persistNativeRecord(record);
105
+ if (!persisted && this.nativeSessions.supportsEvents)
106
+ this.scheduleFlush();
107
+ return null;
108
+ }
109
+ const hasExternalAppender = this.nativeSessions?.appendExternalToolEvent !== undefined && this.sessionId.trim() !== '';
110
+ if (hasExternalAppender)
111
+ this.persistExternalMarker(record);
112
+ if (!hasExternalAppender && !this.deferNativeAppend)
113
+ this.flushNativeRecords();
114
+ return marker;
115
+ }
116
+ /** 流结束时补齐 Provider 遗漏的终态,避免原生组件永久停留在运行中。 */
117
+ finalize(reason, failure) {
118
+ this.finalized = true;
119
+ for (const record of this.records.values()) {
120
+ if (record.settled)
121
+ continue;
122
+ if (failure !== undefined && record.error === undefined)
123
+ this.assign(record, 'error', failure, 'snapshot');
124
+ this.settle(record, record.failed || reason !== 'stop');
125
+ }
126
+ if (this.nativeSessions?.appendToolCall !== undefined) {
127
+ this.flushNativeRecords();
128
+ this.removeNativeEventListener?.();
129
+ }
130
+ else if (this.nativeSessions?.appendExternalToolEvent !== undefined) {
131
+ this.flushExternalMarkers();
132
+ this.removeNativeEventListener?.();
133
+ }
134
+ else if (!this.deferNativeAppend)
135
+ this.flushNativeRecords();
136
+ }
137
+ assign(record, field, incoming, mode) {
138
+ if (incoming === undefined)
139
+ return;
140
+ const current = record[field] ?? '';
141
+ const callChars = (record.input?.length ?? 0) + (record.output?.length ?? 0) + (record.error?.length ?? 0);
142
+ const available = Math.max(0, Math.min(FIELD_LIMIT, current.length + CALL_LIMIT - callChars, current.length + TURN_LIMIT - this.turnChars));
143
+ const next = mode === 'snapshot'
144
+ ? bounded(incoming, available)
145
+ : bounded(`${current}${incoming}`, available);
146
+ if (next === current)
147
+ return;
148
+ record[field] = next;
149
+ this.turnChars += next.length - current.length;
150
+ }
151
+ settle(record, isError) {
152
+ if (record.settled)
153
+ return;
154
+ record.settled = true;
155
+ record.failed = isError;
156
+ }
157
+ /** 按 Provider 到达顺序把工具调用和结果写入当前 DSH step。 */
158
+ flushNativeRecords() {
159
+ if (this.nativeSessions?.appendToolCall === undefined || this.sessionId.trim() === '')
160
+ return;
161
+ for (const record of this.records.values())
162
+ this.persistNativeRecord(record);
163
+ if (this.finalized)
164
+ this.removeNativeEventListener?.();
165
+ }
166
+ persistNativeRecord(record) {
167
+ const append = this.nativeSessions?.appendToolCall;
168
+ if (append === undefined || this.sessionId.trim() === '')
169
+ return false;
170
+ if (record.handle === null)
171
+ record.handle = this.appendCall(record, append);
172
+ if (!record.settled || record.resultAppended || record.handle === null)
173
+ return record.handle !== null;
174
+ const appendResult = this.nativeSessions?.appendToolResult;
175
+ if (appendResult === undefined)
176
+ return false;
177
+ const normalized = normalizeToolCall(record.toolName, record.input);
178
+ const error = record.error?.trim();
179
+ const output = normalizeToolOutput(record.output ?? error ?? '');
180
+ try {
181
+ record.resultAppended = appendResult.call(this.nativeSessions, record.handle, {
182
+ output,
183
+ isError: record.failed,
184
+ ...(error ? { error } : {}),
185
+ ...toolResultMeta(normalized.name, normalized.arguments),
186
+ });
187
+ }
188
+ catch {
189
+ record.resultAppended = false;
190
+ }
191
+ return record.resultAppended;
192
+ }
193
+ scheduleFlush() {
194
+ if (this.flushScheduled)
195
+ return;
196
+ this.flushScheduled = true;
197
+ queueMicrotask(() => {
198
+ this.flushScheduled = false;
199
+ if (this.nativeSessions?.appendToolCall !== undefined)
200
+ this.flushNativeRecords();
201
+ else
202
+ this.flushExternalMarkers();
203
+ });
204
+ }
205
+ /** 活动 step 晚于首个工具通知时,补写尚未进入 Session 的工具标记。 */
206
+ flushExternalMarkers() {
207
+ if (this.nativeSessions?.appendExternalToolEvent === undefined || this.sessionId.trim() === '')
208
+ return;
209
+ for (const record of this.records.values()) {
210
+ if (record.externalMarker === undefined || record.externalMarkerPersisted)
211
+ continue;
212
+ this.persistExternalMarker(record);
213
+ }
214
+ }
215
+ /** 先补齐同一调用的 start,再追加当前 update,保持 Conversation 生命周期合法。 */
216
+ persistExternalMarker(record) {
217
+ const append = this.nativeSessions?.appendExternalToolEvent;
218
+ const marker = record.externalMarker;
219
+ if (append === undefined || marker === undefined || this.sessionId.trim() === '')
220
+ return false;
221
+ if (!record.externalPersisted) {
222
+ const start = marker.phase === 'start'
223
+ ? marker
224
+ : { source: marker.source, phase: 'start', callId: marker.callId, name: marker.name, arguments: marker.arguments, status: 'running' };
225
+ try {
226
+ if (!append.call(this.nativeSessions, this.sessionId, start))
227
+ return false;
228
+ record.externalPersisted = true;
229
+ }
230
+ catch {
231
+ return false;
232
+ }
233
+ if (marker.phase === 'start') {
234
+ record.externalMarkerPersisted = true;
235
+ return true;
236
+ }
237
+ }
238
+ try {
239
+ record.externalMarkerPersisted = append.call(this.nativeSessions, this.sessionId, marker);
240
+ return record.externalMarkerPersisted;
241
+ }
242
+ catch {
243
+ return false;
244
+ }
245
+ }
246
+ appendCall(record, append) {
247
+ const normalized = normalizeToolCall(record.toolName, record.input);
248
+ try {
249
+ return append.call(this.nativeSessions, this.sessionId, {
250
+ callId: record.callId,
251
+ name: normalized.name,
252
+ arguments: normalized.arguments,
253
+ });
254
+ }
255
+ catch {
256
+ // 原生展示失败不能中断外部 Agent 的真实执行。
257
+ return null;
258
+ }
259
+ }
260
+ nextAnonymousCallId() {
261
+ this.anonymousSequence += 1;
262
+ return `external-tool-${this.anonymousSequence}`;
263
+ }
264
+ }
265
+ function normalizeToolCall(toolName, input) {
266
+ const name = canonicalToolName(toolName);
267
+ const parsed = parseRecord(input);
268
+ const args = parsed ?? (input === undefined || input === ''
269
+ ? {}
270
+ : name === 'bash'
271
+ ? { command: input }
272
+ : { input });
273
+ if (name === 'read' || name === 'write' || name === 'edit') {
274
+ rename(args, 'path', 'file_path');
275
+ rename(args, 'filePath', 'file_path');
276
+ }
277
+ if (name === 'edit') {
278
+ rename(args, 'oldString', 'old_string');
279
+ rename(args, 'newString', 'new_string');
280
+ rename(args, 'replaceAll', 'replace_all');
281
+ }
282
+ return { name, arguments: JSON.stringify(args) };
283
+ }
284
+ function canonicalToolName(value) {
285
+ const original = value.trim() || 'tool';
286
+ const key = original.toLowerCase().replace(/[\s-]+/gu, '_');
287
+ if (['read', 'read_file'].includes(key))
288
+ return 'read';
289
+ if (['write', 'write_file'].includes(key))
290
+ return 'write';
291
+ if (['edit', 'edit_file'].includes(key))
292
+ return 'edit';
293
+ if (['bash', 'shell', 'shell_command', 'run_shell_command', 'command_execution'].includes(key))
294
+ return 'bash';
295
+ return original;
296
+ }
297
+ function toolResultMeta(name, argumentsJson) {
298
+ if (name !== 'edit' && name !== 'write')
299
+ return {};
300
+ const args = parseRecord(argumentsJson);
301
+ const path = stringValue(args?.file_path);
302
+ const newText = stringValue(name === 'edit' ? args?.new_string : args?.content);
303
+ if (path === null || newText === null)
304
+ return {};
305
+ const oldText = name === 'edit' ? stringValue(args?.old_string) : null;
306
+ return {
307
+ meta: {
308
+ diffs: [{ path, oldText, newText }],
309
+ },
310
+ };
311
+ }
312
+ /** Command Code 等 Provider 会把文本块包成 JSON;原生结果只展示真正文本。 */
313
+ function normalizeToolOutput(value) {
314
+ if (value === '')
315
+ return '';
316
+ try {
317
+ const parsed = JSON.parse(value);
318
+ const texts = collectTextBlocks(parsed);
319
+ return texts.length > 0 ? texts.join('\n') : value;
320
+ }
321
+ catch {
322
+ return value;
323
+ }
324
+ }
325
+ function collectTextBlocks(value) {
326
+ if (Array.isArray(value))
327
+ return value.flatMap(collectTextBlocks);
328
+ if (!isRecord(value))
329
+ return [];
330
+ if (value.type === 'text' && typeof value.text === 'string')
331
+ return [value.text];
332
+ if (Array.isArray(value.content))
333
+ return value.content.flatMap(collectTextBlocks);
334
+ return [];
335
+ }
336
+ function meaningfulToolName(incoming, previous) {
337
+ const normalized = incoming.trim() || 'tool';
338
+ return normalized === 'tool' && previous !== undefined ? previous : normalized;
339
+ }
340
+ function isNativeStepStart(value) {
341
+ return isRecord(value) && value.type === 'step/start';
342
+ }
343
+ function parseRecord(value) {
344
+ if (value === undefined || value.trim() === '')
345
+ return null;
346
+ try {
347
+ const parsed = JSON.parse(value);
348
+ return isRecord(parsed) ? { ...parsed } : null;
349
+ }
350
+ catch {
351
+ return null;
352
+ }
353
+ }
354
+ function rename(record, source, target) {
355
+ if (record[target] === undefined && record[source] !== undefined)
356
+ record[target] = record[source];
357
+ if (source !== target)
358
+ delete record[source];
359
+ }
360
+ function stringValue(value) {
361
+ return typeof value === 'string' ? value : null;
362
+ }
363
+ function bounded(value, limit = FIELD_LIMIT) {
364
+ if (value.length <= limit)
365
+ return value;
366
+ if (limit <= TRUNCATION_MARKER.length)
367
+ return TRUNCATION_MARKER.slice(0, limit);
368
+ return `${value.slice(0, limit - TRUNCATION_MARKER.length)}${TRUNCATION_MARKER}`;
369
+ }
370
+ function isRecord(value) {
371
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
372
+ }
373
+ //# sourceMappingURL=dsh-tool-history.js.map
@@ -0,0 +1,7 @@
1
+ import type { FeatureModule } from '../../shared/contracts/feature.js';
2
+ import { CodingNsCliAdapterRegistry } from './registry.js';
3
+ import type { CodingNsHostServices } from '../features/types.js';
4
+ export declare function createCliAdaptersFeature(options?: {
5
+ registry?: CodingNsCliAdapterRegistry;
6
+ }): FeatureModule<CodingNsHostServices>;
7
+ //# sourceMappingURL=feature.d.ts.map