@corbet-labs/ccht 0.2.2 → 0.2.4

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 (397) hide show
  1. package/LICENSE +307 -0
  2. package/LICENSE.md +30 -0
  3. package/LICENSES/GPL-3.0-only.txt +232 -0
  4. package/LICENSES/LGPL-3.0-linking-exception.txt +16 -0
  5. package/LICENSES/LGPL-3.0-only WITH LGPL-3.0-linking-exception.txt +16 -0
  6. package/LICENSES/LGPL-3.0-only.txt +304 -0
  7. package/LICENSES/dependencies/agent-client-protocol-2.1.0/LICENSE +191 -0
  8. package/LICENSES/dependencies/agent-client-protocol-derive-2.1.0/LICENSE +191 -0
  9. package/LICENSES/dependencies/agent-client-protocol-schema-1.7.0/LICENSE +190 -0
  10. package/LICENSES/dependencies/android_system_properties-0.1.6/LICENSE-APACHE +13 -0
  11. package/LICENSES/dependencies/android_system_properties-0.1.6/LICENSE-MIT +20 -0
  12. package/LICENSES/dependencies/anyhow-1.0.104/LICENSE-APACHE +176 -0
  13. package/LICENSES/dependencies/anyhow-1.0.104/LICENSE-MIT +23 -0
  14. package/LICENSES/dependencies/async-channel-2.5.0/LICENSE-APACHE +201 -0
  15. package/LICENSES/dependencies/async-channel-2.5.0/LICENSE-MIT +23 -0
  16. package/LICENSES/dependencies/async-io-2.6.0/LICENSE-APACHE +201 -0
  17. package/LICENSES/dependencies/async-io-2.6.0/LICENSE-MIT +23 -0
  18. package/LICENSES/dependencies/async-lock-3.4.2/LICENSE-APACHE +201 -0
  19. package/LICENSES/dependencies/async-lock-3.4.2/LICENSE-MIT +23 -0
  20. package/LICENSES/dependencies/async-process-2.5.0/LICENSE-APACHE +201 -0
  21. package/LICENSES/dependencies/async-process-2.5.0/LICENSE-MIT +23 -0
  22. package/LICENSES/dependencies/async-signal-0.2.14/LICENSE-APACHE +201 -0
  23. package/LICENSES/dependencies/async-signal-0.2.14/LICENSE-MIT +23 -0
  24. package/LICENSES/dependencies/async-task-4.7.1/LICENSE-APACHE +201 -0
  25. package/LICENSES/dependencies/async-task-4.7.1/LICENSE-MIT +23 -0
  26. package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-APACHE +201 -0
  27. package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-MIT +23 -0
  28. package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-THIRD-PARTY +45 -0
  29. package/LICENSES/dependencies/autocfg-1.5.1/LICENSE-APACHE +201 -0
  30. package/LICENSES/dependencies/autocfg-1.5.1/LICENSE-MIT +25 -0
  31. package/LICENSES/dependencies/base64-0.22.1/LICENSE-APACHE +201 -0
  32. package/LICENSES/dependencies/base64-0.22.1/LICENSE-MIT +21 -0
  33. package/LICENSES/dependencies/base64-0.23.1/LICENSE-APACHE +201 -0
  34. package/LICENSES/dependencies/base64-0.23.1/LICENSE-MIT +21 -0
  35. package/LICENSES/dependencies/bitflags-1.3.2/LICENSE-APACHE +201 -0
  36. package/LICENSES/dependencies/bitflags-1.3.2/LICENSE-MIT +25 -0
  37. package/LICENSES/dependencies/bitflags-2.13.2/LICENSE-APACHE +201 -0
  38. package/LICENSES/dependencies/bitflags-2.13.2/LICENSE-MIT +25 -0
  39. package/LICENSES/dependencies/blocking-1.7.0/LICENSE-APACHE +201 -0
  40. package/LICENSES/dependencies/blocking-1.7.0/LICENSE-MIT +23 -0
  41. package/LICENSES/dependencies/bs58-0.5.1/LICENSE-APACHE +201 -0
  42. package/LICENSES/dependencies/bs58-0.5.1/LICENSE-MIT +20 -0
  43. package/LICENSES/dependencies/bumpalo-3.20.3/LICENSE-APACHE +201 -0
  44. package/LICENSES/dependencies/bumpalo-3.20.3/LICENSE-MIT +25 -0
  45. package/LICENSES/dependencies/bytes-1.12.1/LICENSE +25 -0
  46. package/LICENSES/dependencies/cc-1.4.5/LICENSE-APACHE +201 -0
  47. package/LICENSES/dependencies/cc-1.4.5/LICENSE-MIT +25 -0
  48. package/LICENSES/dependencies/cfg-if-1.0.4/LICENSE-APACHE +201 -0
  49. package/LICENSES/dependencies/cfg-if-1.0.4/LICENSE-MIT +25 -0
  50. package/LICENSES/dependencies/chrono-0.4.45/LICENSE.txt +240 -0
  51. package/LICENSES/dependencies/concurrent-queue-2.5.0/LICENSE-APACHE +201 -0
  52. package/LICENSES/dependencies/concurrent-queue-2.5.0/LICENSE-MIT +23 -0
  53. package/LICENSES/dependencies/convert_case-0.10.0/LICENSE +21 -0
  54. package/LICENSES/dependencies/core-foundation-sys-0.8.7/LICENSE-APACHE +201 -0
  55. package/LICENSES/dependencies/core-foundation-sys-0.8.7/LICENSE-MIT +25 -0
  56. package/LICENSES/dependencies/crossbeam-deque-0.8.8/LICENSE-APACHE +201 -0
  57. package/LICENSES/dependencies/crossbeam-deque-0.8.8/LICENSE-MIT +27 -0
  58. package/LICENSES/dependencies/crossbeam-epoch-0.9.21/LICENSE-APACHE +201 -0
  59. package/LICENSES/dependencies/crossbeam-epoch-0.9.21/LICENSE-MIT +27 -0
  60. package/LICENSES/dependencies/crossbeam-utils-0.8.23/LICENSE-APACHE +201 -0
  61. package/LICENSES/dependencies/crossbeam-utils-0.8.23/LICENSE-MIT +27 -0
  62. package/LICENSES/dependencies/darling-0.24.1/LICENSE +21 -0
  63. package/LICENSES/dependencies/darling_core-0.24.1/LICENSE +21 -0
  64. package/LICENSES/dependencies/darling_macro-0.24.1/LICENSE +21 -0
  65. package/LICENSES/dependencies/defmt-1.1.1/LICENSE-APACHE +201 -0
  66. package/LICENSES/dependencies/defmt-1.1.1/LICENSE-MIT +25 -0
  67. package/LICENSES/dependencies/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
  68. package/LICENSES/dependencies/defmt-macros-1.1.1/LICENSE-MIT +25 -0
  69. package/LICENSES/dependencies/defmt-parser-1.0.0/LICENSE-APACHE +201 -0
  70. package/LICENSES/dependencies/defmt-parser-1.0.0/LICENSE-MIT +25 -0
  71. package/LICENSES/dependencies/deranged-0.5.8/LICENSE-Apache +202 -0
  72. package/LICENSES/dependencies/deranged-0.5.8/LICENSE-MIT +19 -0
  73. package/LICENSES/dependencies/derive_more-2.1.1/LICENSE +21 -0
  74. package/LICENSES/dependencies/derive_more-impl-2.1.1/LICENSE +21 -0
  75. package/LICENSES/dependencies/dyn-clone-1.0.20/LICENSE-APACHE +176 -0
  76. package/LICENSES/dependencies/dyn-clone-1.0.20/LICENSE-MIT +23 -0
  77. package/LICENSES/dependencies/either-1.18.0/LICENSE-APACHE +201 -0
  78. package/LICENSES/dependencies/either-1.18.0/LICENSE-MIT +25 -0
  79. package/LICENSES/dependencies/equivalent-1.0.2/LICENSE-APACHE +201 -0
  80. package/LICENSES/dependencies/equivalent-1.0.2/LICENSE-MIT +25 -0
  81. package/LICENSES/dependencies/errno-0.3.14/LICENSE-APACHE +201 -0
  82. package/LICENSES/dependencies/errno-0.3.14/LICENSE-MIT +25 -0
  83. package/LICENSES/dependencies/event-listener-5.4.2/LICENSE-APACHE +201 -0
  84. package/LICENSES/dependencies/event-listener-5.4.2/LICENSE-MIT +23 -0
  85. package/LICENSES/dependencies/event-listener-strategy-0.5.4/LICENSE-APACHE +201 -0
  86. package/LICENSES/dependencies/event-listener-strategy-0.5.4/LICENSE-MIT +23 -0
  87. package/LICENSES/dependencies/fallible-iterator-0.3.0/LICENSE-APACHE +202 -0
  88. package/LICENSES/dependencies/fallible-iterator-0.3.0/LICENSE-MIT +19 -0
  89. package/LICENSES/dependencies/fastrand-2.5.0/LICENSE-APACHE +201 -0
  90. package/LICENSES/dependencies/fastrand-2.5.0/LICENSE-MIT +23 -0
  91. package/LICENSES/dependencies/find-msvc-tools-0.1.12/LICENSE-APACHE +201 -0
  92. package/LICENSES/dependencies/find-msvc-tools-0.1.12/LICENSE-MIT +25 -0
  93. package/LICENSES/dependencies/fixedbitset-0.5.7/LICENSE-APACHE +201 -0
  94. package/LICENSES/dependencies/fixedbitset-0.5.7/LICENSE-MIT +25 -0
  95. package/LICENSES/dependencies/foldhash-0.2.0/LICENSE +19 -0
  96. package/LICENSES/dependencies/futures-0.3.34/LICENSE-APACHE +202 -0
  97. package/LICENSES/dependencies/futures-0.3.34/LICENSE-MIT +26 -0
  98. package/LICENSES/dependencies/futures-channel-0.3.34/LICENSE-APACHE +202 -0
  99. package/LICENSES/dependencies/futures-channel-0.3.34/LICENSE-MIT +26 -0
  100. package/LICENSES/dependencies/futures-concurrency-7.7.1/LICENSE-APACHE +190 -0
  101. package/LICENSES/dependencies/futures-concurrency-7.7.1/LICENSE-MIT +21 -0
  102. package/LICENSES/dependencies/futures-core-0.3.34/LICENSE-APACHE +202 -0
  103. package/LICENSES/dependencies/futures-core-0.3.34/LICENSE-MIT +26 -0
  104. package/LICENSES/dependencies/futures-executor-0.3.34/LICENSE-APACHE +202 -0
  105. package/LICENSES/dependencies/futures-executor-0.3.34/LICENSE-MIT +26 -0
  106. package/LICENSES/dependencies/futures-io-0.3.34/LICENSE-APACHE +202 -0
  107. package/LICENSES/dependencies/futures-io-0.3.34/LICENSE-MIT +26 -0
  108. package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-APACHE +201 -0
  109. package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-MIT +23 -0
  110. package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-THIRD-PARTY +45 -0
  111. package/LICENSES/dependencies/futures-macro-0.3.34/LICENSE-APACHE +202 -0
  112. package/LICENSES/dependencies/futures-macro-0.3.34/LICENSE-MIT +26 -0
  113. package/LICENSES/dependencies/futures-sink-0.3.34/LICENSE-APACHE +202 -0
  114. package/LICENSES/dependencies/futures-sink-0.3.34/LICENSE-MIT +26 -0
  115. package/LICENSES/dependencies/futures-task-0.3.34/LICENSE-APACHE +202 -0
  116. package/LICENSES/dependencies/futures-task-0.3.34/LICENSE-MIT +26 -0
  117. package/LICENSES/dependencies/futures-util-0.3.34/LICENSE-APACHE +202 -0
  118. package/LICENSES/dependencies/futures-util-0.3.34/LICENSE-MIT +26 -0
  119. package/LICENSES/dependencies/getrandom-0.4.3/LICENSE-APACHE +201 -0
  120. package/LICENSES/dependencies/getrandom-0.4.3/LICENSE-MIT +26 -0
  121. package/LICENSES/dependencies/gimli-0.32.3/LICENSE-APACHE +201 -0
  122. package/LICENSES/dependencies/gimli-0.32.3/LICENSE-MIT +25 -0
  123. package/LICENSES/dependencies/hashbrown-0.12.3/LICENSE-APACHE +201 -0
  124. package/LICENSES/dependencies/hashbrown-0.12.3/LICENSE-MIT +25 -0
  125. package/LICENSES/dependencies/hashbrown-0.16.1/LICENSE-APACHE +201 -0
  126. package/LICENSES/dependencies/hashbrown-0.16.1/LICENSE-MIT +25 -0
  127. package/LICENSES/dependencies/hashbrown-0.17.1/LICENSE-APACHE +201 -0
  128. package/LICENSES/dependencies/hashbrown-0.17.1/LICENSE-MIT +25 -0
  129. package/LICENSES/dependencies/heck-0.5.0/LICENSE-APACHE +201 -0
  130. package/LICENSES/dependencies/heck-0.5.0/LICENSE-MIT +25 -0
  131. package/LICENSES/dependencies/hermit-abi-0.5.3/LICENSE-APACHE +201 -0
  132. package/LICENSES/dependencies/hermit-abi-0.5.3/LICENSE-MIT +23 -0
  133. package/LICENSES/dependencies/hex-0.4.3/LICENSE-APACHE +202 -0
  134. package/LICENSES/dependencies/hex-0.4.3/LICENSE-MIT +20 -0
  135. package/LICENSES/dependencies/iana-time-zone-0.1.65/LICENSE-APACHE +201 -0
  136. package/LICENSES/dependencies/iana-time-zone-0.1.65/LICENSE-MIT +25 -0
  137. package/LICENSES/dependencies/iana-time-zone-haiku-0.1.2/LICENSE-APACHE +201 -0
  138. package/LICENSES/dependencies/iana-time-zone-haiku-0.1.2/LICENSE-MIT +25 -0
  139. package/LICENSES/dependencies/id-arena-2.3.0/LICENSE-APACHE +201 -0
  140. package/LICENSES/dependencies/id-arena-2.3.0/LICENSE-MIT +25 -0
  141. package/LICENSES/dependencies/ident_case-1.0.1/LICENSE +19 -0
  142. package/LICENSES/dependencies/indexmap-1.9.3/LICENSE-APACHE +201 -0
  143. package/LICENSES/dependencies/indexmap-1.9.3/LICENSE-MIT +25 -0
  144. package/LICENSES/dependencies/indexmap-2.14.2/LICENSE-APACHE +201 -0
  145. package/LICENSES/dependencies/indexmap-2.14.2/LICENSE-MIT +25 -0
  146. package/LICENSES/dependencies/itoa-1.0.18/LICENSE-APACHE +176 -0
  147. package/LICENSES/dependencies/itoa-1.0.18/LICENSE-MIT +23 -0
  148. package/LICENSES/dependencies/jiff-0.2.35/COPYING +3 -0
  149. package/LICENSES/dependencies/jiff-0.2.35/LICENSE-MIT +21 -0
  150. package/LICENSES/dependencies/jiff-0.2.35/UNLICENSE +24 -0
  151. package/LICENSES/dependencies/jiff-core-0.1.0/COPYING +3 -0
  152. package/LICENSES/dependencies/jiff-core-0.1.0/LICENSE-MIT +21 -0
  153. package/LICENSES/dependencies/jiff-core-0.1.0/UNLICENSE +24 -0
  154. package/LICENSES/dependencies/jiff-static-0.2.35/COPYING +3 -0
  155. package/LICENSES/dependencies/jiff-static-0.2.35/LICENSE-MIT +21 -0
  156. package/LICENSES/dependencies/jiff-static-0.2.35/UNLICENSE +24 -0
  157. package/LICENSES/dependencies/jiff-tzdb-0.1.8/COPYING +3 -0
  158. package/LICENSES/dependencies/jiff-tzdb-0.1.8/LICENSE-MIT +21 -0
  159. package/LICENSES/dependencies/jiff-tzdb-0.1.8/UNLICENSE +24 -0
  160. package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/COPYING +3 -0
  161. package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
  162. package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/UNLICENSE +24 -0
  163. package/LICENSES/dependencies/js-sys-0.3.105/LICENSE-APACHE +201 -0
  164. package/LICENSES/dependencies/js-sys-0.3.105/LICENSE-MIT +25 -0
  165. package/LICENSES/dependencies/leb128-0.2.7/LICENSE-APACHE +201 -0
  166. package/LICENSES/dependencies/leb128-0.2.7/LICENSE-MIT +25 -0
  167. package/LICENSES/dependencies/leb128fmt-0.1.0/LICENSE-APACHE +201 -0
  168. package/LICENSES/dependencies/leb128fmt-0.1.0/LICENSE-MIT +23 -0
  169. package/LICENSES/dependencies/libc-0.2.189/LICENSE-APACHE +176 -0
  170. package/LICENSES/dependencies/libc-0.2.189/LICENSE-MIT +25 -0
  171. package/LICENSES/dependencies/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
  172. package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
  173. package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  174. package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
  175. package/LICENSES/dependencies/log-0.4.34/LICENSE-APACHE +201 -0
  176. package/LICENSES/dependencies/log-0.4.34/LICENSE-MIT +25 -0
  177. package/LICENSES/dependencies/memchr-2.8.3/COPYING +3 -0
  178. package/LICENSES/dependencies/memchr-2.8.3/LICENSE-MIT +21 -0
  179. package/LICENSES/dependencies/memchr-2.8.3/UNLICENSE +24 -0
  180. package/LICENSES/dependencies/mio-1.2.3/LICENSE +19 -0
  181. package/LICENSES/dependencies/num-conv-0.2.2/LICENSE-Apache +177 -0
  182. package/LICENSES/dependencies/num-conv-0.2.2/LICENSE-MIT +19 -0
  183. package/LICENSES/dependencies/num-traits-0.2.19/LICENSE-APACHE +201 -0
  184. package/LICENSES/dependencies/num-traits-0.2.19/LICENSE-MIT +25 -0
  185. package/LICENSES/dependencies/once_cell-1.21.4/LICENSE-APACHE +201 -0
  186. package/LICENSES/dependencies/once_cell-1.21.4/LICENSE-MIT +23 -0
  187. package/LICENSES/dependencies/parking-2.2.1/LICENSE-APACHE +201 -0
  188. package/LICENSES/dependencies/parking-2.2.1/LICENSE-MIT +23 -0
  189. package/LICENSES/dependencies/parking-2.2.1/LICENSE-THIRD-PARTY +9 -0
  190. package/LICENSES/dependencies/pin-project-1.1.13/LICENSE-APACHE +177 -0
  191. package/LICENSES/dependencies/pin-project-1.1.13/LICENSE-MIT +23 -0
  192. package/LICENSES/dependencies/pin-project-internal-1.1.13/LICENSE-APACHE +177 -0
  193. package/LICENSES/dependencies/pin-project-internal-1.1.13/LICENSE-MIT +23 -0
  194. package/LICENSES/dependencies/pin-project-lite-0.2.17/LICENSE-APACHE +177 -0
  195. package/LICENSES/dependencies/pin-project-lite-0.2.17/LICENSE-MIT +23 -0
  196. package/LICENSES/dependencies/piper-0.2.5/LICENSE-APACHE +201 -0
  197. package/LICENSES/dependencies/piper-0.2.5/LICENSE-MIT +23 -0
  198. package/LICENSES/dependencies/polling-3.11.0/LICENSE-APACHE +201 -0
  199. package/LICENSES/dependencies/polling-3.11.0/LICENSE-MIT +23 -0
  200. package/LICENSES/dependencies/portable-atomic-1.15.0/LICENSE-APACHE +177 -0
  201. package/LICENSES/dependencies/portable-atomic-1.15.0/LICENSE-MIT +23 -0
  202. package/LICENSES/dependencies/portable-atomic-util-0.2.8/LICENSE-APACHE +177 -0
  203. package/LICENSES/dependencies/portable-atomic-util-0.2.8/LICENSE-MIT +23 -0
  204. package/LICENSES/dependencies/powerfmt-0.2.0/LICENSE-Apache +202 -0
  205. package/LICENSES/dependencies/powerfmt-0.2.0/LICENSE-MIT +19 -0
  206. package/LICENSES/dependencies/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
  207. package/LICENSES/dependencies/proc-macro2-1.0.107/LICENSE-MIT +23 -0
  208. package/LICENSES/dependencies/quote-1.0.47/LICENSE-APACHE +176 -0
  209. package/LICENSES/dependencies/quote-1.0.47/LICENSE-MIT +23 -0
  210. package/LICENSES/dependencies/r-efi-6.0.0/AUTHORS +75 -0
  211. package/LICENSES/dependencies/rayon-1.12.0/LICENSE-APACHE +201 -0
  212. package/LICENSES/dependencies/rayon-1.12.0/LICENSE-MIT +25 -0
  213. package/LICENSES/dependencies/rayon-core-1.13.0/LICENSE-APACHE +201 -0
  214. package/LICENSES/dependencies/rayon-core-1.13.0/LICENSE-MIT +25 -0
  215. package/LICENSES/dependencies/ref-cast-1.0.27/LICENSE-APACHE +176 -0
  216. package/LICENSES/dependencies/ref-cast-1.0.27/LICENSE-MIT +23 -0
  217. package/LICENSES/dependencies/ref-cast-impl-1.0.27/LICENSE-APACHE +176 -0
  218. package/LICENSES/dependencies/ref-cast-impl-1.0.27/LICENSE-MIT +23 -0
  219. package/LICENSES/dependencies/rustc-demangle-0.1.28/LICENSE-APACHE +201 -0
  220. package/LICENSES/dependencies/rustc-demangle-0.1.28/LICENSE-MIT +25 -0
  221. package/LICENSES/dependencies/rustc-hash-2.1.3/LICENSE-APACHE +176 -0
  222. package/LICENSES/dependencies/rustc-hash-2.1.3/LICENSE-MIT +23 -0
  223. package/LICENSES/dependencies/rustc_version-0.4.1/LICENSE-APACHE +201 -0
  224. package/LICENSES/dependencies/rustc_version-0.4.1/LICENSE-MIT +25 -0
  225. package/LICENSES/dependencies/rustix-1.1.4/COPYRIGHT +29 -0
  226. package/LICENSES/dependencies/rustix-1.1.4/LICENSE-APACHE +201 -0
  227. package/LICENSES/dependencies/rustix-1.1.4/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  228. package/LICENSES/dependencies/rustix-1.1.4/LICENSE-MIT +23 -0
  229. package/LICENSES/dependencies/rustversion-1.0.23/LICENSE-APACHE +176 -0
  230. package/LICENSES/dependencies/rustversion-1.0.23/LICENSE-MIT +23 -0
  231. package/LICENSES/dependencies/schemars-0.9.0/LICENSE +21 -0
  232. package/LICENSES/dependencies/schemars-1.2.2/LICENSE +21 -0
  233. package/LICENSES/dependencies/schemars_derive-1.2.2/LICENSE +21 -0
  234. package/LICENSES/dependencies/semver-1.0.28/LICENSE-APACHE +176 -0
  235. package/LICENSES/dependencies/semver-1.0.28/LICENSE-MIT +23 -0
  236. package/LICENSES/dependencies/serde-1.0.229/LICENSE-APACHE +176 -0
  237. package/LICENSES/dependencies/serde-1.0.229/LICENSE-MIT +23 -0
  238. package/LICENSES/dependencies/serde_core-1.0.229/LICENSE-APACHE +176 -0
  239. package/LICENSES/dependencies/serde_core-1.0.229/LICENSE-MIT +23 -0
  240. package/LICENSES/dependencies/serde_derive-1.0.229/LICENSE-APACHE +176 -0
  241. package/LICENSES/dependencies/serde_derive-1.0.229/LICENSE-MIT +23 -0
  242. package/LICENSES/dependencies/serde_derive_internals-0.30.0/LICENSE-APACHE +176 -0
  243. package/LICENSES/dependencies/serde_derive_internals-0.30.0/LICENSE-MIT +23 -0
  244. package/LICENSES/dependencies/serde_json-1.0.151/LICENSE-APACHE +176 -0
  245. package/LICENSES/dependencies/serde_json-1.0.151/LICENSE-MIT +23 -0
  246. package/LICENSES/dependencies/serde_with-3.23.0/LICENSE-APACHE +201 -0
  247. package/LICENSES/dependencies/serde_with-3.23.0/LICENSE-MIT +25 -0
  248. package/LICENSES/dependencies/serde_with_macros-3.23.0/LICENSE-APACHE +201 -0
  249. package/LICENSES/dependencies/serde_with_macros-3.23.0/LICENSE-MIT +25 -0
  250. package/LICENSES/dependencies/shell-words-1.1.1/LICENSE-APACHE +201 -0
  251. package/LICENSES/dependencies/shell-words-1.1.1/LICENSE-MIT +25 -0
  252. package/LICENSES/dependencies/shlex-2.0.1/LICENSE-APACHE +13 -0
  253. package/LICENSES/dependencies/shlex-2.0.1/LICENSE-MIT +21 -0
  254. package/LICENSES/dependencies/signal-hook-registry-1.4.8/LICENSE-APACHE +201 -0
  255. package/LICENSES/dependencies/signal-hook-registry-1.4.8/LICENSE-MIT +25 -0
  256. package/LICENSES/dependencies/slab-0.4.12/LICENSE +25 -0
  257. package/LICENSES/dependencies/smallvec-1.16.0/LICENSE-APACHE +201 -0
  258. package/LICENSES/dependencies/smallvec-1.16.0/LICENSE-MIT +25 -0
  259. package/LICENSES/dependencies/socket2-0.6.5/LICENSE-APACHE +201 -0
  260. package/LICENSES/dependencies/socket2-0.6.5/LICENSE-MIT +25 -0
  261. package/LICENSES/dependencies/stable_deref_trait-1.2.1/LICENSE-APACHE +201 -0
  262. package/LICENSES/dependencies/stable_deref_trait-1.2.1/LICENSE-MIT +25 -0
  263. package/LICENSES/dependencies/strsim-0.11.1/LICENSE +23 -0
  264. package/LICENSES/dependencies/strum-0.28.0/LICENSE +21 -0
  265. package/LICENSES/dependencies/strum_macros-0.28.0/LICENSE +21 -0
  266. package/LICENSES/dependencies/syn-2.0.119/LICENSE-APACHE +176 -0
  267. package/LICENSES/dependencies/syn-2.0.119/LICENSE-MIT +23 -0
  268. package/LICENSES/dependencies/syn-3.0.5/LICENSE-APACHE +176 -0
  269. package/LICENSES/dependencies/syn-3.0.5/LICENSE-MIT +23 -0
  270. package/LICENSES/dependencies/thiserror-2.0.20/LICENSE-APACHE +176 -0
  271. package/LICENSES/dependencies/thiserror-2.0.20/LICENSE-MIT +23 -0
  272. package/LICENSES/dependencies/thiserror-impl-2.0.20/LICENSE-APACHE +176 -0
  273. package/LICENSES/dependencies/thiserror-impl-2.0.20/LICENSE-MIT +23 -0
  274. package/LICENSES/dependencies/time-0.3.55/LICENSE-Apache +177 -0
  275. package/LICENSES/dependencies/time-0.3.55/LICENSE-MIT +19 -0
  276. package/LICENSES/dependencies/time-core-0.1.9/LICENSE-Apache +177 -0
  277. package/LICENSES/dependencies/time-core-0.1.9/LICENSE-MIT +19 -0
  278. package/LICENSES/dependencies/time-macros-0.2.32/LICENSE-Apache +177 -0
  279. package/LICENSES/dependencies/time-macros-0.2.32/LICENSE-MIT +19 -0
  280. package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-APACHE.md +202 -0
  281. package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-MIT.md +5 -0
  282. package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-ZLIB.md +11 -0
  283. package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-APACHE.md +202 -0
  284. package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-MIT.md +21 -0
  285. package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-ZLIB.md +20 -0
  286. package/LICENSES/dependencies/tokio-1.53.1/LICENSE +21 -0
  287. package/LICENSES/dependencies/tokio-macros-2.7.2/LICENSE +22 -0
  288. package/LICENSES/dependencies/tracing-0.1.44/LICENSE +25 -0
  289. package/LICENSES/dependencies/tracing-attributes-0.1.31/LICENSE +25 -0
  290. package/LICENSES/dependencies/tracing-core-0.1.36/LICENSE +25 -0
  291. package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-APACHE +176 -0
  292. package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-MIT +23 -0
  293. package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-UNICODE +39 -0
  294. package/LICENSES/dependencies/unicode-segmentation-1.13.3/COPYRIGHT +7 -0
  295. package/LICENSES/dependencies/unicode-segmentation-1.13.3/LICENSE-APACHE +201 -0
  296. package/LICENSES/dependencies/unicode-segmentation-1.13.3/LICENSE-MIT +25 -0
  297. package/LICENSES/dependencies/unicode-xid-0.2.6/COPYRIGHT +7 -0
  298. package/LICENSES/dependencies/unicode-xid-0.2.6/LICENSE-APACHE +201 -0
  299. package/LICENSES/dependencies/unicode-xid-0.2.6/LICENSE-MIT +25 -0
  300. package/LICENSES/dependencies/uuid-1.26.1/LICENSE-APACHE +201 -0
  301. package/LICENSES/dependencies/uuid-1.26.1/LICENSE-MIT +26 -0
  302. package/LICENSES/dependencies/walrus-0.26.5/LICENSE-APACHE +201 -0
  303. package/LICENSES/dependencies/walrus-0.26.5/LICENSE-MIT +25 -0
  304. package/LICENSES/dependencies/walrus-macro-0.26.0/LICENSE-APACHE +201 -0
  305. package/LICENSES/dependencies/walrus-macro-0.26.0/LICENSE-MIT +25 -0
  306. package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-APACHE +201 -0
  307. package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  308. package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-MIT +23 -0
  309. package/LICENSES/dependencies/wasm-bindgen-0.2.128/LICENSE-APACHE +201 -0
  310. package/LICENSES/dependencies/wasm-bindgen-0.2.128/LICENSE-MIT +25 -0
  311. package/LICENSES/dependencies/wasm-bindgen-cli-support-0.2.128/LICENSE-APACHE +201 -0
  312. package/LICENSES/dependencies/wasm-bindgen-cli-support-0.2.128/LICENSE-MIT +25 -0
  313. package/LICENSES/dependencies/wasm-bindgen-macro-0.2.128/LICENSE-APACHE +201 -0
  314. package/LICENSES/dependencies/wasm-bindgen-macro-0.2.128/LICENSE-MIT +25 -0
  315. package/LICENSES/dependencies/wasm-bindgen-macro-support-0.2.128/LICENSE-APACHE +201 -0
  316. package/LICENSES/dependencies/wasm-bindgen-macro-support-0.2.128/LICENSE-MIT +25 -0
  317. package/LICENSES/dependencies/wasm-bindgen-shared-0.2.128/LICENSE-APACHE +201 -0
  318. package/LICENSES/dependencies/wasm-bindgen-shared-0.2.128/LICENSE-MIT +25 -0
  319. package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-APACHE +201 -0
  320. package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  321. package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-MIT +23 -0
  322. package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-APACHE +201 -0
  323. package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  324. package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-MIT +23 -0
  325. package/LICENSES/dependencies/windows-core-0.62.2/license-apache-2.0 +201 -0
  326. package/LICENSES/dependencies/windows-core-0.62.2/license-mit +21 -0
  327. package/LICENSES/dependencies/windows-implement-0.60.2/license-apache-2.0 +201 -0
  328. package/LICENSES/dependencies/windows-implement-0.60.2/license-mit +21 -0
  329. package/LICENSES/dependencies/windows-interface-0.59.3/license-apache-2.0 +201 -0
  330. package/LICENSES/dependencies/windows-interface-0.59.3/license-mit +21 -0
  331. package/LICENSES/dependencies/windows-link-0.2.1/license-apache-2.0 +201 -0
  332. package/LICENSES/dependencies/windows-link-0.2.1/license-mit +21 -0
  333. package/LICENSES/dependencies/windows-result-0.4.1/license-apache-2.0 +201 -0
  334. package/LICENSES/dependencies/windows-result-0.4.1/license-mit +21 -0
  335. package/LICENSES/dependencies/windows-strings-0.5.1/license-apache-2.0 +201 -0
  336. package/LICENSES/dependencies/windows-strings-0.5.1/license-mit +21 -0
  337. package/LICENSES/dependencies/windows-sys-0.61.2/license-apache-2.0 +201 -0
  338. package/LICENSES/dependencies/windows-sys-0.61.2/license-mit +21 -0
  339. package/LICENSES/dependencies/zmij-1.0.23/LICENSE-MIT +23 -0
  340. package/README.md +70 -0
  341. package/THIRD-PARTY.md +62 -0
  342. package/package.json +48 -9
  343. package/source/.cargo/config.toml +5 -0
  344. package/source/.ci/upstream-notices/PROVENANCE.json +198 -0
  345. package/source/.ci/upstream-notices/agent-client-protocol-2.1.0/LICENSE +191 -0
  346. package/source/.ci/upstream-notices/agent-client-protocol-derive-2.1.0/LICENSE +191 -0
  347. package/source/.ci/upstream-notices/agent-client-protocol-schema-1.7.0/LICENSE +190 -0
  348. package/source/.ci/upstream-notices/defmt-parser-1.0.0/LICENSE-APACHE +201 -0
  349. package/source/.ci/upstream-notices/defmt-parser-1.0.0/LICENSE-MIT +25 -0
  350. package/source/.ci/upstream-notices/r-efi-6.0.0/AUTHORS +75 -0
  351. package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-APACHE +201 -0
  352. package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  353. package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-MIT +23 -0
  354. package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-APACHE +201 -0
  355. package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  356. package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-MIT +23 -0
  357. package/source/.ci/wasm-bundle/Cargo.toml +10 -0
  358. package/source/.ci/wasm-bundle/src/main.rs +17 -0
  359. package/source/CHANGELOG.md +99 -0
  360. package/source/Cargo.lock +1630 -0
  361. package/source/Cargo.toml +48 -0
  362. package/source/LICENSE +307 -0
  363. package/source/LICENSE.md +30 -0
  364. package/source/LICENSES/GPL-3.0-only.txt +232 -0
  365. package/source/LICENSES/LGPL-3.0-linking-exception.txt +16 -0
  366. package/source/LICENSES/LGPL-3.0-only WITH LGPL-3.0-linking-exception.txt +16 -0
  367. package/source/LICENSES/LGPL-3.0-only.txt +304 -0
  368. package/source/README.md +289 -0
  369. package/source/THIRD-PARTY.md +62 -0
  370. package/source/dependencies.tar.gz +0 -0
  371. package/source/examples/native.rs +45 -0
  372. package/source/src/auth.rs +435 -0
  373. package/source/src/configuration.rs +140 -0
  374. package/source/src/conversation.rs +594 -0
  375. package/source/src/dock.rs +564 -0
  376. package/source/src/lib.rs +39 -0
  377. package/source/src/native/client.rs +401 -0
  378. package/source/src/native/drivers/codex.rs +506 -0
  379. package/source/src/native/drivers/mod.rs +305 -0
  380. package/source/src/native/drivers/opencode.rs +531 -0
  381. package/source/src/native/env.rs +264 -0
  382. package/source/src/native/fixture.py +191 -0
  383. package/source/src/native/mod.rs +257 -0
  384. package/source/src/native/pool.rs +440 -0
  385. package/source/src/native/session.rs +609 -0
  386. package/source/src/native/tests.rs +667 -0
  387. package/source/src/transport.rs +330 -0
  388. package/source/src/web.rs +35 -0
  389. package/src/auth.test.ts +115 -0
  390. package/src/components/ChatDock.component.test.ts +213 -0
  391. package/src/components/ChatDock.svelte +422 -0
  392. package/src/components/Dock.component.test.ts +92 -0
  393. package/src/components/Dock.svelte +6 -3
  394. package/src/components/StepConfig.component.test.ts +185 -0
  395. package/src/components/StepConfig.svelte +247 -0
  396. package/src/dock.test.ts +226 -0
  397. package/wasm/ccht_bg.wasm +0 -0
@@ -0,0 +1,609 @@
1
+ //! Native conversation session with one ordered event stream.
2
+ //!
3
+ //! The worker owns prompt routing, permission validation, and timeout handling.
4
+ //! Applications consume events through the single receiver and control the turn
5
+ //! through [`SessionHandle`]; dropping an active prompt closes the connection.
6
+
7
+ use std::collections::BTreeMap;
8
+ use std::sync::atomic::{AtomicU64, Ordering};
9
+ use std::sync::{Arc, Mutex};
10
+
11
+ use agent_client_protocol::util::MatchDispatch;
12
+ use agent_client_protocol::{ActiveSession, Agent, Dispatch, Responder, SessionMessage};
13
+ use tokio::sync::{mpsc, oneshot, watch};
14
+ use tokio::task::JoinHandle;
15
+ use tokio::time::{Instant, interval, timeout};
16
+
17
+ use crate::acp::{
18
+ CancelNotification, CloseSessionRequest, ContentBlock, PromptRequest, PromptResponse,
19
+ RequestPermissionOutcome, RequestPermissionRequest, RequestPermissionResponse, SessionId,
20
+ SessionNotification, StopReason,
21
+ };
22
+ use crate::{Event, Prompt, SessionConfiguration, SessionEvent};
23
+
24
+ use super::client::{ClientLease, ClientState};
25
+ use super::{NativeError, PermissionDecision, PermissionPolicy, Result, lock};
26
+
27
+ static NEXT_PERMISSION: AtomicU64 = AtomicU64::new(1);
28
+
29
+ /// A native session and its single ordered event stream.
30
+ ///
31
+ /// Take the receiver once, then retain a handle while consuming it. A cloned
32
+ /// handle keeps the session alive independently of this value.
33
+ pub struct NativeSession {
34
+ handle: SessionHandle,
35
+ events: Option<mpsc::Receiver<SessionEvent>>,
36
+ }
37
+
38
+ /// Cloneable, thread-safe control of a native conversation.
39
+ #[derive(Clone)]
40
+ pub struct SessionHandle {
41
+ lease: Arc<SessionLease>,
42
+ }
43
+
44
+ struct SessionLease {
45
+ state: Arc<SessionState>,
46
+ commands: mpsc::Sender<PromptCommand>,
47
+ client: Arc<ClientLease>,
48
+ }
49
+
50
+ struct SessionState {
51
+ id: SessionId,
52
+ client: Arc<ClientState>,
53
+ connection: agent_client_protocol::ConnectionTo<Agent>,
54
+ turn: Mutex<TurnState>,
55
+ activity: watch::Sender<bool>,
56
+ closed: watch::Sender<bool>,
57
+ failure: Mutex<Option<NativeError>>,
58
+ events: Mutex<Option<mpsc::Sender<SessionEvent>>>,
59
+ permissions: Mutex<BTreeMap<String, PendingPermission>>,
60
+ configuration: Mutex<SessionConfiguration>,
61
+ configuring: tokio::sync::Mutex<()>,
62
+ task: Mutex<Option<JoinHandle<()>>>,
63
+ }
64
+
65
+ #[derive(Default)]
66
+ struct TurnState {
67
+ reserved: Option<String>,
68
+ current: Option<String>,
69
+ cancelled: bool,
70
+ }
71
+
72
+ struct PendingPermission {
73
+ request: RequestPermissionRequest,
74
+ responder: Responder<RequestPermissionResponse>,
75
+ expires: Instant,
76
+ }
77
+
78
+ struct PromptCommand {
79
+ prompt: Prompt,
80
+ result: oneshot::Sender<Result<StopReason>>,
81
+ }
82
+
83
+ struct PromptGuard(Option<(Arc<SessionState>, String)>);
84
+
85
+ impl Drop for PromptGuard {
86
+ fn drop(&mut self) {
87
+ let Some((state, request_id)) = &self.0 else {
88
+ return;
89
+ };
90
+ // Release the turn lock before cleanup takes it again.
91
+ let active = lock(&state.turn).reserved.as_ref() == Some(request_id);
92
+ if active {
93
+ // Abandoning a prompt cannot leave unattended agent work running.
94
+ state.close(NativeError::Closed, true);
95
+ }
96
+ }
97
+ }
98
+
99
+ impl Drop for SessionLease {
100
+ fn drop(&mut self) {
101
+ let active = lock(&self.state.turn).reserved.is_some();
102
+ self.state.close(NativeError::Closed, active);
103
+ }
104
+ }
105
+
106
+ impl SessionState {
107
+ fn is_closed(&self) -> bool {
108
+ *self.closed.borrow() || self.client.is_closed()
109
+ }
110
+
111
+ fn error(&self) -> NativeError {
112
+ lock(&self.failure)
113
+ .clone()
114
+ .unwrap_or_else(|| self.client.error())
115
+ }
116
+
117
+ fn emit(&self, event: Event) -> Result<()> {
118
+ if let Event::Update { update } = &event {
119
+ lock(&self.configuration).apply(update);
120
+ }
121
+ let request_id = lock(&self.turn).current.clone();
122
+ let result = lock(&self.events)
123
+ .as_ref()
124
+ .ok_or(NativeError::Closed)?
125
+ .try_send(SessionEvent { request_id, event });
126
+ match result {
127
+ Ok(()) => Ok(()),
128
+ Err(mpsc::error::TrySendError::Full(_)) => {
129
+ self.close(NativeError::EventBufferFull, true);
130
+ Err(NativeError::EventBufferFull)
131
+ }
132
+ Err(mpsc::error::TrySendError::Closed(_)) => {
133
+ self.close(NativeError::Closed, true);
134
+ Err(NativeError::Closed)
135
+ }
136
+ }
137
+ }
138
+
139
+ fn deny_permissions(&self) {
140
+ for (_, pending) in std::mem::take(&mut *lock(&self.permissions)) {
141
+ let _ = pending.responder.respond(RequestPermissionResponse::new(
142
+ RequestPermissionOutcome::Cancelled,
143
+ ));
144
+ }
145
+ }
146
+
147
+ fn close(&self, error: NativeError, stop_connection: bool) {
148
+ if !*self.closed.borrow() {
149
+ *lock(&self.failure) = Some(error.clone());
150
+ let _ = self
151
+ .connection
152
+ .send_notification(CancelNotification::new(self.id.clone()));
153
+ self.deny_permissions();
154
+ let request_id = lock(&self.turn).current.clone();
155
+ if let Some(events) = lock(&self.events).take()
156
+ && (request_id.is_some() || error != NativeError::Closed)
157
+ {
158
+ let _ = events.try_send(SessionEvent {
159
+ request_id,
160
+ event: Event::Error {
161
+ code: error.code().into(),
162
+ message: error.to_string(),
163
+ },
164
+ });
165
+ }
166
+ self.closed.send_replace(true);
167
+ self.activity.send_replace(false);
168
+ if let Some(task) = lock(&self.task).as_ref() {
169
+ task.abort();
170
+ }
171
+ }
172
+ if stop_connection {
173
+ self.client.abort();
174
+ }
175
+ }
176
+
177
+ fn finish(&self, outcome: &Result<StopReason>) -> Result<()> {
178
+ self.deny_permissions();
179
+ let event = match outcome {
180
+ Ok(stop_reason) => Event::Completed {
181
+ stop_reason: *stop_reason,
182
+ },
183
+ Err(error) => Event::Error {
184
+ code: error.code().into(),
185
+ message: error.to_string(),
186
+ },
187
+ };
188
+ self.emit(event)?;
189
+ *lock(&self.turn) = TurnState::default();
190
+ self.activity.send_replace(false);
191
+ Ok(())
192
+ }
193
+ }
194
+
195
+ impl NativeSession {
196
+ pub(super) fn start(
197
+ client: Arc<ClientLease>,
198
+ session: ActiveSession<'static, Agent>,
199
+ ) -> Result<Self> {
200
+ let (events_tx, events_rx) = mpsc::channel(client.options.event_capacity);
201
+ let (commands_tx, commands_rx) = mpsc::channel(1);
202
+ let (activity, _) = watch::channel(false);
203
+ let (closed, _) = watch::channel(false);
204
+ let state = Arc::new(SessionState {
205
+ id: session.session_id().clone(),
206
+ client: client.state.clone(),
207
+ connection: session.connection().clone(),
208
+ turn: Mutex::new(TurnState::default()),
209
+ activity,
210
+ closed,
211
+ failure: Mutex::new(None),
212
+ events: Mutex::new(Some(events_tx)),
213
+ permissions: Mutex::new(BTreeMap::new()),
214
+ configuration: Mutex::new(SessionConfiguration {
215
+ options: session.config_options().unwrap_or_default().to_vec(),
216
+ modes: session.modes().cloned(),
217
+ }),
218
+ configuring: tokio::sync::Mutex::new(()),
219
+ task: Mutex::new(None),
220
+ });
221
+ let worker_state = state.clone();
222
+ let options = client.options.clone();
223
+ let task = tokio::spawn(async move {
224
+ if let Err(error) =
225
+ run_session(session, commands_rx, worker_state.clone(), options).await
226
+ {
227
+ worker_state.close(error, true);
228
+ }
229
+ });
230
+ *lock(&state.task) = Some(task);
231
+ Ok(Self {
232
+ handle: SessionHandle {
233
+ lease: Arc::new(SessionLease {
234
+ state,
235
+ commands: commands_tx,
236
+ client,
237
+ }),
238
+ },
239
+ events: Some(events_rx),
240
+ })
241
+ }
242
+
243
+ /// Clone the control handle; it can be used while the receiver is polled elsewhere.
244
+ pub fn handle(&self) -> SessionHandle {
245
+ self.handle.clone()
246
+ }
247
+
248
+ /// Take the sole stream, including any history queued during session restoration.
249
+ pub fn take_events(&mut self) -> Result<mpsc::Receiver<SessionEvent>> {
250
+ self.events.take().ok_or(NativeError::EventsTaken)
251
+ }
252
+ }
253
+
254
+ impl SessionHandle {
255
+ /// Latest agent-advertised controls, including dependent changes and notifications.
256
+ pub fn configuration(&self) -> SessionConfiguration {
257
+ lock(&self.lease.state.configuration).clone()
258
+ }
259
+
260
+ /// Select an exact model advertised by this session, without any fallback.
261
+ pub async fn set_model(&self, model: &str) -> Result<SessionConfiguration> {
262
+ let id = self
263
+ .configuration()
264
+ .model_option()
265
+ .map(|option| option.id.to_string())
266
+ .ok_or(NativeError::Unsupported("model selection"))?;
267
+ self.set_config_option(&id, model.into()).await
268
+ }
269
+
270
+ /// Change an advertised select or boolean control and retain the full response.
271
+ /// Unknown controls and values fail before sending a request to the agent.
272
+ pub async fn set_config_option(
273
+ &self,
274
+ id: &str,
275
+ value: crate::acp::SessionConfigOptionValue,
276
+ ) -> Result<SessionConfiguration> {
277
+ let state = &self.lease.state;
278
+ let _serial = state.configuring.lock().await;
279
+ if state.is_closed() {
280
+ return Err(state.error());
281
+ }
282
+ if !self.configuration().accepts(id, &value) {
283
+ return Err(NativeError::Unsupported("the selected configuration value"));
284
+ }
285
+ let request =
286
+ crate::acp::SetSessionConfigOptionRequest::new(state.id.clone(), id.to_owned(), value);
287
+ let response = match timeout(
288
+ self.lease.client.options.operation_timeout,
289
+ state.connection.send_request(request).block_task(),
290
+ )
291
+ .await
292
+ {
293
+ Ok(result) => result?,
294
+ Err(_) => {
295
+ state.close(NativeError::Timeout, true);
296
+ return Err(NativeError::Timeout);
297
+ }
298
+ };
299
+ state.emit(Event::Update {
300
+ update: crate::acp::SessionUpdate::ConfigOptionUpdate(
301
+ crate::acp::ConfigOptionUpdate::new(response.config_options),
302
+ ),
303
+ })?;
304
+ Ok(self.configuration())
305
+ }
306
+
307
+ /// The agent-owned session identifier, suitable for explicit load or resume.
308
+ pub fn id(&self) -> &str {
309
+ self.lease.state.id.0.as_ref()
310
+ }
311
+
312
+ /// Send one prompt and await its terminal result while events stream independently.
313
+ ///
314
+ /// A concurrent prompt fails with `Busy`. Dropping this future after submission
315
+ /// closes the connection, ensuring the abandoned turn cannot keep running.
316
+ pub async fn prompt(&self, prompt: Prompt) -> Result<StopReason> {
317
+ let state = &self.lease.state;
318
+ if state.is_closed() {
319
+ return Err(state.error());
320
+ }
321
+ if prompt.request_id.is_empty() || prompt.content.is_empty() {
322
+ return Err(NativeError::InvalidOptions(
323
+ "a prompt needs a request id and content",
324
+ ));
325
+ }
326
+ let capabilities = &self
327
+ .lease
328
+ .client
329
+ .info
330
+ .agent_capabilities
331
+ .prompt_capabilities;
332
+ for content in &prompt.content {
333
+ match content {
334
+ ContentBlock::Text(_) | ContentBlock::ResourceLink(_) => {}
335
+ ContentBlock::Image(_) if capabilities.image => {}
336
+ ContentBlock::Audio(_) if capabilities.audio => {}
337
+ ContentBlock::Resource(_) if capabilities.embedded_context => {}
338
+ _ => return Err(NativeError::Unsupported("the requested prompt content")),
339
+ }
340
+ }
341
+ {
342
+ let mut turn = lock(&state.turn);
343
+ if turn.reserved.is_some() {
344
+ return Err(NativeError::Busy);
345
+ }
346
+ turn.reserved = Some(prompt.request_id.clone());
347
+ turn.cancelled = false;
348
+ state.activity.send_replace(true);
349
+ }
350
+ let mut guard = PromptGuard(Some((state.clone(), prompt.request_id.clone())));
351
+ let (result_tx, result_rx) = oneshot::channel();
352
+ self.lease
353
+ .commands
354
+ .send(PromptCommand {
355
+ prompt,
356
+ result: result_tx,
357
+ })
358
+ .await
359
+ .map_err(|_| state.error())?;
360
+ let mut closed = state.closed.subscribe();
361
+ let mut connection_closed = state.client.closed.subscribe();
362
+ let result = timeout(self.lease.client.options.prompt_timeout, async {
363
+ if state.is_closed() {
364
+ return Err(state.error());
365
+ }
366
+ tokio::select! {
367
+ result = result_rx => result.unwrap_or_else(|_| Err(state.error())),
368
+ _ = closed.changed() => Err(state.error()),
369
+ _ = connection_closed.changed() => Err(state.error()),
370
+ }
371
+ })
372
+ .await;
373
+ match result {
374
+ Ok(outcome) => {
375
+ guard.0 = None;
376
+ outcome
377
+ }
378
+ Err(_) => {
379
+ state.close(NativeError::Timeout, true);
380
+ guard.0 = None;
381
+ Err(NativeError::Timeout)
382
+ }
383
+ }
384
+ }
385
+
386
+ /// Request cancellation and wait a bounded time for the active turn to finish.
387
+ ///
388
+ /// If the agent ignores cancellation, the SDK connection is closed. This also
389
+ /// closes other sessions sharing that agent process.
390
+ pub async fn cancel(&self) -> Result<()> {
391
+ let state = &self.lease.state;
392
+ if state.is_closed() {
393
+ return Err(state.error());
394
+ }
395
+ {
396
+ let mut turn = lock(&state.turn);
397
+ if turn.reserved.is_none() {
398
+ return Ok(());
399
+ }
400
+ turn.cancelled = true;
401
+ }
402
+ state.deny_permissions();
403
+ state
404
+ .connection
405
+ .send_notification(CancelNotification::new(state.id.clone()))?;
406
+ let mut activity = state.activity.subscribe();
407
+ if timeout(self.lease.client.options.shutdown_timeout, async {
408
+ while *activity.borrow_and_update() {
409
+ if activity.changed().await.is_err() {
410
+ break;
411
+ }
412
+ }
413
+ })
414
+ .await
415
+ .is_err()
416
+ {
417
+ state.close(NativeError::Timeout, true);
418
+ return Err(NativeError::Timeout);
419
+ }
420
+ if state.is_closed() {
421
+ Err(state.error())
422
+ } else {
423
+ Ok(())
424
+ }
425
+ }
426
+
427
+ /// Answer one pending permission request using an option the agent offered.
428
+ ///
429
+ /// Invalid selections leave the request pending so the application can correct
430
+ /// its response. Expired or previously answered requests fail explicitly.
431
+ pub async fn respond_permission(
432
+ &self,
433
+ request_id: &str,
434
+ decision: PermissionDecision,
435
+ ) -> Result<()> {
436
+ let state = &self.lease.state;
437
+ if state.is_closed() {
438
+ return Err(state.error());
439
+ }
440
+ let pending = {
441
+ let mut permissions = lock(&state.permissions);
442
+ let pending = permissions
443
+ .get(request_id)
444
+ .ok_or(NativeError::UnknownPermission)?;
445
+ if pending.expires <= Instant::now() || pending.responder.cancellation().is_cancelled()
446
+ {
447
+ return Err(NativeError::UnknownPermission);
448
+ }
449
+ match &decision {
450
+ RequestPermissionOutcome::Cancelled => {}
451
+ RequestPermissionOutcome::Selected(selected)
452
+ if pending
453
+ .request
454
+ .options
455
+ .iter()
456
+ .any(|option| option.option_id == selected.option_id) => {}
457
+ _ => return Err(NativeError::InvalidPermissionOption),
458
+ }
459
+ permissions
460
+ .remove(request_id)
461
+ .ok_or(NativeError::UnknownPermission)?
462
+ };
463
+ pending
464
+ .responder
465
+ .respond(RequestPermissionResponse::new(decision))?;
466
+ Ok(())
467
+ }
468
+
469
+ /// Cancel work, detach local routing, and close the remote session when supported.
470
+ ///
471
+ /// Without `session/close`, persisted agent history remains available for an
472
+ /// explicit future load; this method never claims to delete remote history.
473
+ pub async fn close(&self) -> Result<()> {
474
+ let state = &self.lease.state;
475
+ if state.is_closed() {
476
+ return Ok(());
477
+ }
478
+ self.cancel().await?;
479
+ if self
480
+ .lease
481
+ .client
482
+ .info
483
+ .agent_capabilities
484
+ .session_capabilities
485
+ .close
486
+ .is_some()
487
+ {
488
+ let response = timeout(
489
+ self.lease.client.options.shutdown_timeout,
490
+ state
491
+ .connection
492
+ .send_request(CloseSessionRequest::new(state.id.clone()))
493
+ .block_task(),
494
+ )
495
+ .await;
496
+ match response {
497
+ Ok(Ok(_)) => {}
498
+ Ok(Err(error)) => {
499
+ state.close(error.clone().into(), false);
500
+ return Err(error.into());
501
+ }
502
+ Err(_) => {
503
+ state.close(NativeError::Timeout, true);
504
+ return Err(NativeError::Timeout);
505
+ }
506
+ }
507
+ }
508
+ state.close(NativeError::Closed, false);
509
+ Ok(())
510
+ }
511
+ }
512
+
513
+ async fn run_session(
514
+ mut session: ActiveSession<'static, Agent>,
515
+ mut commands: mpsc::Receiver<PromptCommand>,
516
+ state: Arc<SessionState>,
517
+ options: super::NativeOptions,
518
+ ) -> Result<()> {
519
+ let (completion_tx, mut completion_rx) = mpsc::unbounded_channel::<Result<StopReason>>();
520
+ let mut active: Option<oneshot::Sender<Result<StopReason>>> = None;
521
+ let mut closed = state.closed.subscribe();
522
+ let mut connection_closed = state.client.closed.subscribe();
523
+ let mut expiry = interval(
524
+ options
525
+ .permission_timeout
526
+ .min(std::time::Duration::from_secs(1)),
527
+ );
528
+ loop {
529
+ if state.is_closed() {
530
+ return Err(state.error());
531
+ }
532
+ tokio::select! {
533
+ biased;
534
+ _ = closed.changed() => return Ok(()),
535
+ _ = connection_closed.changed() => return Err(state.client.error()),
536
+ message = session.read_update() => {
537
+ match message? {
538
+ SessionMessage::SessionMessage(dispatch) => {
539
+ MatchDispatch::new(dispatch)
540
+ .if_notification(async |notification: SessionNotification| {
541
+ state.emit(Event::Update { update: notification.update })
542
+ .map_err(|_| agent_client_protocol::Error::internal_error())
543
+ }).await
544
+ .if_request(async |request: RequestPermissionRequest, responder| {
545
+ if options.permissions == PermissionPolicy::Deny
546
+ || lock(&state.turn).cancelled
547
+ || lock(&state.permissions).len() >= options.event_capacity
548
+ {
549
+ return responder.respond(RequestPermissionResponse::new(RequestPermissionOutcome::Cancelled));
550
+ }
551
+ let request_id = format!("permission-{}", NEXT_PERMISSION.fetch_add(1, Ordering::Relaxed));
552
+ lock(&state.permissions).insert(request_id.clone(), PendingPermission {
553
+ request: request.clone(), responder,
554
+ expires: Instant::now() + options.permission_timeout,
555
+ });
556
+ state.emit(Event::Permission { request_id, request })
557
+ .map_err(|_| agent_client_protocol::Error::internal_error())
558
+ }).await
559
+ .otherwise(async |dispatch| {
560
+ match dispatch {
561
+ Dispatch::Request(_, responder) => responder.respond_with_result(Err(agent_client_protocol::Error::method_not_found())),
562
+ _ => Ok(()),
563
+ }
564
+ }).await?;
565
+ }
566
+ SessionMessage::StopReason(stop_reason) => {
567
+ let _ = completion_tx.send(Ok(stop_reason));
568
+ }
569
+ _ => return Err(NativeError::Unsupported("the received SDK session event")),
570
+ }
571
+ }
572
+ Some(outcome) = completion_rx.recv(), if active.is_some() => {
573
+ state.finish(&outcome)?;
574
+ if let Some(result) = active.take() { let _ = result.send(outcome); }
575
+ }
576
+ Some(command) = commands.recv(), if active.is_none() => {
577
+ {
578
+ let mut turn = lock(&state.turn);
579
+ turn.current = Some(command.prompt.request_id.clone());
580
+ }
581
+ if lock(&state.turn).cancelled || command.result.is_closed() {
582
+ let outcome = Ok(StopReason::Cancelled);
583
+ state.finish(&outcome)?;
584
+ let _ = command.result.send(outcome);
585
+ continue;
586
+ }
587
+ active = Some(command.result);
588
+ let tx = completion_tx.clone();
589
+ session.connection().send_request(PromptRequest::new(state.id.clone(), command.prompt.content))
590
+ .on_receiving_result(async move |result: std::result::Result<PromptResponse, agent_client_protocol::Error>| {
591
+ // Earlier notifications are already on ActiveSession's queue.
592
+ // The biased reader drains them before publishing completion.
593
+ let _ = tx.send(result.map(|response| response.stop_reason).map_err(NativeError::from));
594
+ Ok(())
595
+ })?;
596
+ }
597
+ _ = expiry.tick() => {
598
+ let expired: Vec<_> = lock(&state.permissions).iter()
599
+ .filter(|(_, pending)| pending.expires <= Instant::now() || pending.responder.cancellation().is_cancelled())
600
+ .map(|(id, _)| id.clone()).collect();
601
+ for id in expired {
602
+ if let Some(pending) = lock(&state.permissions).remove(&id) {
603
+ let _ = pending.responder.respond(RequestPermissionResponse::new(RequestPermissionOutcome::Cancelled));
604
+ }
605
+ }
606
+ }
607
+ }
608
+ }
609
+ }