@corbet-labs/ccht 0.2.0 → 0.2.2

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 (382) hide show
  1. package/README.md +194 -212
  2. package/index.d.ts +6 -1
  3. package/index.js +8 -1
  4. package/package.json +12 -26
  5. package/src/auth.ts +149 -0
  6. package/src/components/AccountConnection.svelte +201 -0
  7. package/src/components/Dock.svelte +172 -0
  8. package/src/dock.ts +244 -0
  9. package/wasm/ccht_bg.wasm +0 -0
  10. package/LICENSE +0 -307
  11. package/LICENSE.md +0 -25
  12. package/LICENSES/GPL-3.0-only.txt +0 -232
  13. package/LICENSES/LGPL-3.0-only.txt +0 -304
  14. package/LICENSES/dependencies/agent-client-protocol-2.1.0/LICENSE +0 -191
  15. package/LICENSES/dependencies/agent-client-protocol-derive-2.1.0/LICENSE +0 -191
  16. package/LICENSES/dependencies/agent-client-protocol-schema-1.7.0/LICENSE +0 -190
  17. package/LICENSES/dependencies/android_system_properties-0.1.6/LICENSE-APACHE +0 -13
  18. package/LICENSES/dependencies/android_system_properties-0.1.6/LICENSE-MIT +0 -20
  19. package/LICENSES/dependencies/anyhow-1.0.104/LICENSE-APACHE +0 -176
  20. package/LICENSES/dependencies/anyhow-1.0.104/LICENSE-MIT +0 -23
  21. package/LICENSES/dependencies/async-channel-2.5.0/LICENSE-APACHE +0 -201
  22. package/LICENSES/dependencies/async-channel-2.5.0/LICENSE-MIT +0 -23
  23. package/LICENSES/dependencies/async-io-2.6.0/LICENSE-APACHE +0 -201
  24. package/LICENSES/dependencies/async-io-2.6.0/LICENSE-MIT +0 -23
  25. package/LICENSES/dependencies/async-lock-3.4.2/LICENSE-APACHE +0 -201
  26. package/LICENSES/dependencies/async-lock-3.4.2/LICENSE-MIT +0 -23
  27. package/LICENSES/dependencies/async-process-2.5.0/LICENSE-APACHE +0 -201
  28. package/LICENSES/dependencies/async-process-2.5.0/LICENSE-MIT +0 -23
  29. package/LICENSES/dependencies/async-signal-0.2.14/LICENSE-APACHE +0 -201
  30. package/LICENSES/dependencies/async-signal-0.2.14/LICENSE-MIT +0 -23
  31. package/LICENSES/dependencies/async-task-4.7.1/LICENSE-APACHE +0 -201
  32. package/LICENSES/dependencies/async-task-4.7.1/LICENSE-MIT +0 -23
  33. package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-APACHE +0 -201
  34. package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-MIT +0 -23
  35. package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-THIRD-PARTY +0 -45
  36. package/LICENSES/dependencies/autocfg-1.5.1/LICENSE-APACHE +0 -201
  37. package/LICENSES/dependencies/autocfg-1.5.1/LICENSE-MIT +0 -25
  38. package/LICENSES/dependencies/base64-0.22.1/LICENSE-APACHE +0 -201
  39. package/LICENSES/dependencies/base64-0.22.1/LICENSE-MIT +0 -21
  40. package/LICENSES/dependencies/base64-0.23.1/LICENSE-APACHE +0 -201
  41. package/LICENSES/dependencies/base64-0.23.1/LICENSE-MIT +0 -21
  42. package/LICENSES/dependencies/bitflags-1.3.2/LICENSE-APACHE +0 -201
  43. package/LICENSES/dependencies/bitflags-1.3.2/LICENSE-MIT +0 -25
  44. package/LICENSES/dependencies/bitflags-2.13.2/LICENSE-APACHE +0 -201
  45. package/LICENSES/dependencies/bitflags-2.13.2/LICENSE-MIT +0 -25
  46. package/LICENSES/dependencies/blocking-1.7.0/LICENSE-APACHE +0 -201
  47. package/LICENSES/dependencies/blocking-1.7.0/LICENSE-MIT +0 -23
  48. package/LICENSES/dependencies/bs58-0.5.1/LICENSE-APACHE +0 -201
  49. package/LICENSES/dependencies/bs58-0.5.1/LICENSE-MIT +0 -20
  50. package/LICENSES/dependencies/bumpalo-3.20.3/LICENSE-APACHE +0 -201
  51. package/LICENSES/dependencies/bumpalo-3.20.3/LICENSE-MIT +0 -25
  52. package/LICENSES/dependencies/cc-1.4.5/LICENSE-APACHE +0 -201
  53. package/LICENSES/dependencies/cc-1.4.5/LICENSE-MIT +0 -25
  54. package/LICENSES/dependencies/cfg-if-1.0.4/LICENSE-APACHE +0 -201
  55. package/LICENSES/dependencies/cfg-if-1.0.4/LICENSE-MIT +0 -25
  56. package/LICENSES/dependencies/chrono-0.4.45/LICENSE.txt +0 -240
  57. package/LICENSES/dependencies/concurrent-queue-2.5.0/LICENSE-APACHE +0 -201
  58. package/LICENSES/dependencies/concurrent-queue-2.5.0/LICENSE-MIT +0 -23
  59. package/LICENSES/dependencies/convert_case-0.10.0/LICENSE +0 -21
  60. package/LICENSES/dependencies/core-foundation-sys-0.8.7/LICENSE-APACHE +0 -201
  61. package/LICENSES/dependencies/core-foundation-sys-0.8.7/LICENSE-MIT +0 -25
  62. package/LICENSES/dependencies/crossbeam-deque-0.8.8/LICENSE-APACHE +0 -201
  63. package/LICENSES/dependencies/crossbeam-deque-0.8.8/LICENSE-MIT +0 -27
  64. package/LICENSES/dependencies/crossbeam-epoch-0.9.21/LICENSE-APACHE +0 -201
  65. package/LICENSES/dependencies/crossbeam-epoch-0.9.21/LICENSE-MIT +0 -27
  66. package/LICENSES/dependencies/crossbeam-utils-0.8.23/LICENSE-APACHE +0 -201
  67. package/LICENSES/dependencies/crossbeam-utils-0.8.23/LICENSE-MIT +0 -27
  68. package/LICENSES/dependencies/darling-0.24.1/LICENSE +0 -21
  69. package/LICENSES/dependencies/darling_core-0.24.1/LICENSE +0 -21
  70. package/LICENSES/dependencies/darling_macro-0.24.1/LICENSE +0 -21
  71. package/LICENSES/dependencies/defmt-1.1.1/LICENSE-APACHE +0 -201
  72. package/LICENSES/dependencies/defmt-1.1.1/LICENSE-MIT +0 -25
  73. package/LICENSES/dependencies/defmt-macros-1.1.1/LICENSE-APACHE +0 -201
  74. package/LICENSES/dependencies/defmt-macros-1.1.1/LICENSE-MIT +0 -25
  75. package/LICENSES/dependencies/defmt-parser-1.0.0/LICENSE-APACHE +0 -201
  76. package/LICENSES/dependencies/defmt-parser-1.0.0/LICENSE-MIT +0 -25
  77. package/LICENSES/dependencies/deranged-0.5.8/LICENSE-Apache +0 -202
  78. package/LICENSES/dependencies/deranged-0.5.8/LICENSE-MIT +0 -19
  79. package/LICENSES/dependencies/derive_more-2.1.1/LICENSE +0 -21
  80. package/LICENSES/dependencies/derive_more-impl-2.1.1/LICENSE +0 -21
  81. package/LICENSES/dependencies/dyn-clone-1.0.20/LICENSE-APACHE +0 -176
  82. package/LICENSES/dependencies/dyn-clone-1.0.20/LICENSE-MIT +0 -23
  83. package/LICENSES/dependencies/either-1.18.0/LICENSE-APACHE +0 -201
  84. package/LICENSES/dependencies/either-1.18.0/LICENSE-MIT +0 -25
  85. package/LICENSES/dependencies/equivalent-1.0.2/LICENSE-APACHE +0 -201
  86. package/LICENSES/dependencies/equivalent-1.0.2/LICENSE-MIT +0 -25
  87. package/LICENSES/dependencies/errno-0.3.14/LICENSE-APACHE +0 -201
  88. package/LICENSES/dependencies/errno-0.3.14/LICENSE-MIT +0 -25
  89. package/LICENSES/dependencies/event-listener-5.4.2/LICENSE-APACHE +0 -201
  90. package/LICENSES/dependencies/event-listener-5.4.2/LICENSE-MIT +0 -23
  91. package/LICENSES/dependencies/event-listener-strategy-0.5.4/LICENSE-APACHE +0 -201
  92. package/LICENSES/dependencies/event-listener-strategy-0.5.4/LICENSE-MIT +0 -23
  93. package/LICENSES/dependencies/fallible-iterator-0.3.0/LICENSE-APACHE +0 -202
  94. package/LICENSES/dependencies/fallible-iterator-0.3.0/LICENSE-MIT +0 -19
  95. package/LICENSES/dependencies/fastrand-2.5.0/LICENSE-APACHE +0 -201
  96. package/LICENSES/dependencies/fastrand-2.5.0/LICENSE-MIT +0 -23
  97. package/LICENSES/dependencies/find-msvc-tools-0.1.12/LICENSE-APACHE +0 -201
  98. package/LICENSES/dependencies/find-msvc-tools-0.1.12/LICENSE-MIT +0 -25
  99. package/LICENSES/dependencies/fixedbitset-0.5.7/LICENSE-APACHE +0 -201
  100. package/LICENSES/dependencies/fixedbitset-0.5.7/LICENSE-MIT +0 -25
  101. package/LICENSES/dependencies/foldhash-0.2.0/LICENSE +0 -19
  102. package/LICENSES/dependencies/futures-0.3.34/LICENSE-APACHE +0 -202
  103. package/LICENSES/dependencies/futures-0.3.34/LICENSE-MIT +0 -26
  104. package/LICENSES/dependencies/futures-channel-0.3.34/LICENSE-APACHE +0 -202
  105. package/LICENSES/dependencies/futures-channel-0.3.34/LICENSE-MIT +0 -26
  106. package/LICENSES/dependencies/futures-concurrency-7.7.1/LICENSE-APACHE +0 -190
  107. package/LICENSES/dependencies/futures-concurrency-7.7.1/LICENSE-MIT +0 -21
  108. package/LICENSES/dependencies/futures-core-0.3.34/LICENSE-APACHE +0 -202
  109. package/LICENSES/dependencies/futures-core-0.3.34/LICENSE-MIT +0 -26
  110. package/LICENSES/dependencies/futures-executor-0.3.34/LICENSE-APACHE +0 -202
  111. package/LICENSES/dependencies/futures-executor-0.3.34/LICENSE-MIT +0 -26
  112. package/LICENSES/dependencies/futures-io-0.3.34/LICENSE-APACHE +0 -202
  113. package/LICENSES/dependencies/futures-io-0.3.34/LICENSE-MIT +0 -26
  114. package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-APACHE +0 -201
  115. package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-MIT +0 -23
  116. package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-THIRD-PARTY +0 -45
  117. package/LICENSES/dependencies/futures-macro-0.3.34/LICENSE-APACHE +0 -202
  118. package/LICENSES/dependencies/futures-macro-0.3.34/LICENSE-MIT +0 -26
  119. package/LICENSES/dependencies/futures-sink-0.3.34/LICENSE-APACHE +0 -202
  120. package/LICENSES/dependencies/futures-sink-0.3.34/LICENSE-MIT +0 -26
  121. package/LICENSES/dependencies/futures-task-0.3.34/LICENSE-APACHE +0 -202
  122. package/LICENSES/dependencies/futures-task-0.3.34/LICENSE-MIT +0 -26
  123. package/LICENSES/dependencies/futures-util-0.3.34/LICENSE-APACHE +0 -202
  124. package/LICENSES/dependencies/futures-util-0.3.34/LICENSE-MIT +0 -26
  125. package/LICENSES/dependencies/getrandom-0.4.3/LICENSE-APACHE +0 -201
  126. package/LICENSES/dependencies/getrandom-0.4.3/LICENSE-MIT +0 -26
  127. package/LICENSES/dependencies/gimli-0.32.3/LICENSE-APACHE +0 -201
  128. package/LICENSES/dependencies/gimli-0.32.3/LICENSE-MIT +0 -25
  129. package/LICENSES/dependencies/hashbrown-0.12.3/LICENSE-APACHE +0 -201
  130. package/LICENSES/dependencies/hashbrown-0.12.3/LICENSE-MIT +0 -25
  131. package/LICENSES/dependencies/hashbrown-0.16.1/LICENSE-APACHE +0 -201
  132. package/LICENSES/dependencies/hashbrown-0.16.1/LICENSE-MIT +0 -25
  133. package/LICENSES/dependencies/hashbrown-0.17.1/LICENSE-APACHE +0 -201
  134. package/LICENSES/dependencies/hashbrown-0.17.1/LICENSE-MIT +0 -25
  135. package/LICENSES/dependencies/heck-0.5.0/LICENSE-APACHE +0 -201
  136. package/LICENSES/dependencies/heck-0.5.0/LICENSE-MIT +0 -25
  137. package/LICENSES/dependencies/hermit-abi-0.5.3/LICENSE-APACHE +0 -201
  138. package/LICENSES/dependencies/hermit-abi-0.5.3/LICENSE-MIT +0 -23
  139. package/LICENSES/dependencies/hex-0.4.3/LICENSE-APACHE +0 -202
  140. package/LICENSES/dependencies/hex-0.4.3/LICENSE-MIT +0 -20
  141. package/LICENSES/dependencies/iana-time-zone-0.1.65/LICENSE-APACHE +0 -201
  142. package/LICENSES/dependencies/iana-time-zone-0.1.65/LICENSE-MIT +0 -25
  143. package/LICENSES/dependencies/iana-time-zone-haiku-0.1.2/LICENSE-APACHE +0 -201
  144. package/LICENSES/dependencies/iana-time-zone-haiku-0.1.2/LICENSE-MIT +0 -25
  145. package/LICENSES/dependencies/id-arena-2.3.0/LICENSE-APACHE +0 -201
  146. package/LICENSES/dependencies/id-arena-2.3.0/LICENSE-MIT +0 -25
  147. package/LICENSES/dependencies/ident_case-1.0.1/LICENSE +0 -19
  148. package/LICENSES/dependencies/indexmap-1.9.3/LICENSE-APACHE +0 -201
  149. package/LICENSES/dependencies/indexmap-1.9.3/LICENSE-MIT +0 -25
  150. package/LICENSES/dependencies/indexmap-2.14.2/LICENSE-APACHE +0 -201
  151. package/LICENSES/dependencies/indexmap-2.14.2/LICENSE-MIT +0 -25
  152. package/LICENSES/dependencies/itoa-1.0.18/LICENSE-APACHE +0 -176
  153. package/LICENSES/dependencies/itoa-1.0.18/LICENSE-MIT +0 -23
  154. package/LICENSES/dependencies/jiff-0.2.35/COPYING +0 -3
  155. package/LICENSES/dependencies/jiff-0.2.35/LICENSE-MIT +0 -21
  156. package/LICENSES/dependencies/jiff-0.2.35/UNLICENSE +0 -24
  157. package/LICENSES/dependencies/jiff-core-0.1.0/COPYING +0 -3
  158. package/LICENSES/dependencies/jiff-core-0.1.0/LICENSE-MIT +0 -21
  159. package/LICENSES/dependencies/jiff-core-0.1.0/UNLICENSE +0 -24
  160. package/LICENSES/dependencies/jiff-static-0.2.35/COPYING +0 -3
  161. package/LICENSES/dependencies/jiff-static-0.2.35/LICENSE-MIT +0 -21
  162. package/LICENSES/dependencies/jiff-static-0.2.35/UNLICENSE +0 -24
  163. package/LICENSES/dependencies/jiff-tzdb-0.1.8/COPYING +0 -3
  164. package/LICENSES/dependencies/jiff-tzdb-0.1.8/LICENSE-MIT +0 -21
  165. package/LICENSES/dependencies/jiff-tzdb-0.1.8/UNLICENSE +0 -24
  166. package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/COPYING +0 -3
  167. package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/LICENSE-MIT +0 -21
  168. package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/UNLICENSE +0 -24
  169. package/LICENSES/dependencies/js-sys-0.3.105/LICENSE-APACHE +0 -201
  170. package/LICENSES/dependencies/js-sys-0.3.105/LICENSE-MIT +0 -25
  171. package/LICENSES/dependencies/leb128-0.2.7/LICENSE-APACHE +0 -201
  172. package/LICENSES/dependencies/leb128-0.2.7/LICENSE-MIT +0 -25
  173. package/LICENSES/dependencies/leb128fmt-0.1.0/LICENSE-APACHE +0 -201
  174. package/LICENSES/dependencies/leb128fmt-0.1.0/LICENSE-MIT +0 -23
  175. package/LICENSES/dependencies/libc-0.2.189/LICENSE-APACHE +0 -176
  176. package/LICENSES/dependencies/libc-0.2.189/LICENSE-MIT +0 -25
  177. package/LICENSES/dependencies/linux-raw-sys-0.12.1/COPYRIGHT +0 -29
  178. package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-APACHE +0 -201
  179. package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  180. package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-MIT +0 -23
  181. package/LICENSES/dependencies/log-0.4.34/LICENSE-APACHE +0 -201
  182. package/LICENSES/dependencies/log-0.4.34/LICENSE-MIT +0 -25
  183. package/LICENSES/dependencies/memchr-2.8.3/COPYING +0 -3
  184. package/LICENSES/dependencies/memchr-2.8.3/LICENSE-MIT +0 -21
  185. package/LICENSES/dependencies/memchr-2.8.3/UNLICENSE +0 -24
  186. package/LICENSES/dependencies/mio-1.2.3/LICENSE +0 -19
  187. package/LICENSES/dependencies/num-conv-0.2.2/LICENSE-Apache +0 -177
  188. package/LICENSES/dependencies/num-conv-0.2.2/LICENSE-MIT +0 -19
  189. package/LICENSES/dependencies/num-traits-0.2.19/LICENSE-APACHE +0 -201
  190. package/LICENSES/dependencies/num-traits-0.2.19/LICENSE-MIT +0 -25
  191. package/LICENSES/dependencies/once_cell-1.21.4/LICENSE-APACHE +0 -201
  192. package/LICENSES/dependencies/once_cell-1.21.4/LICENSE-MIT +0 -23
  193. package/LICENSES/dependencies/parking-2.2.1/LICENSE-APACHE +0 -201
  194. package/LICENSES/dependencies/parking-2.2.1/LICENSE-MIT +0 -23
  195. package/LICENSES/dependencies/parking-2.2.1/LICENSE-THIRD-PARTY +0 -9
  196. package/LICENSES/dependencies/pin-project-1.1.13/LICENSE-APACHE +0 -177
  197. package/LICENSES/dependencies/pin-project-1.1.13/LICENSE-MIT +0 -23
  198. package/LICENSES/dependencies/pin-project-internal-1.1.13/LICENSE-APACHE +0 -177
  199. package/LICENSES/dependencies/pin-project-internal-1.1.13/LICENSE-MIT +0 -23
  200. package/LICENSES/dependencies/pin-project-lite-0.2.17/LICENSE-APACHE +0 -177
  201. package/LICENSES/dependencies/pin-project-lite-0.2.17/LICENSE-MIT +0 -23
  202. package/LICENSES/dependencies/piper-0.2.5/LICENSE-APACHE +0 -201
  203. package/LICENSES/dependencies/piper-0.2.5/LICENSE-MIT +0 -23
  204. package/LICENSES/dependencies/polling-3.11.0/LICENSE-APACHE +0 -201
  205. package/LICENSES/dependencies/polling-3.11.0/LICENSE-MIT +0 -23
  206. package/LICENSES/dependencies/portable-atomic-1.15.0/LICENSE-APACHE +0 -177
  207. package/LICENSES/dependencies/portable-atomic-1.15.0/LICENSE-MIT +0 -23
  208. package/LICENSES/dependencies/portable-atomic-util-0.2.8/LICENSE-APACHE +0 -177
  209. package/LICENSES/dependencies/portable-atomic-util-0.2.8/LICENSE-MIT +0 -23
  210. package/LICENSES/dependencies/powerfmt-0.2.0/LICENSE-Apache +0 -202
  211. package/LICENSES/dependencies/powerfmt-0.2.0/LICENSE-MIT +0 -19
  212. package/LICENSES/dependencies/proc-macro2-1.0.107/LICENSE-APACHE +0 -176
  213. package/LICENSES/dependencies/proc-macro2-1.0.107/LICENSE-MIT +0 -23
  214. package/LICENSES/dependencies/quote-1.0.47/LICENSE-APACHE +0 -176
  215. package/LICENSES/dependencies/quote-1.0.47/LICENSE-MIT +0 -23
  216. package/LICENSES/dependencies/r-efi-6.0.0/AUTHORS +0 -75
  217. package/LICENSES/dependencies/rayon-1.12.0/LICENSE-APACHE +0 -201
  218. package/LICENSES/dependencies/rayon-1.12.0/LICENSE-MIT +0 -25
  219. package/LICENSES/dependencies/rayon-core-1.13.0/LICENSE-APACHE +0 -201
  220. package/LICENSES/dependencies/rayon-core-1.13.0/LICENSE-MIT +0 -25
  221. package/LICENSES/dependencies/ref-cast-1.0.27/LICENSE-APACHE +0 -176
  222. package/LICENSES/dependencies/ref-cast-1.0.27/LICENSE-MIT +0 -23
  223. package/LICENSES/dependencies/ref-cast-impl-1.0.27/LICENSE-APACHE +0 -176
  224. package/LICENSES/dependencies/ref-cast-impl-1.0.27/LICENSE-MIT +0 -23
  225. package/LICENSES/dependencies/rustc-demangle-0.1.28/LICENSE-APACHE +0 -201
  226. package/LICENSES/dependencies/rustc-demangle-0.1.28/LICENSE-MIT +0 -25
  227. package/LICENSES/dependencies/rustc-hash-2.1.3/LICENSE-APACHE +0 -176
  228. package/LICENSES/dependencies/rustc-hash-2.1.3/LICENSE-MIT +0 -23
  229. package/LICENSES/dependencies/rustc_version-0.4.1/LICENSE-APACHE +0 -201
  230. package/LICENSES/dependencies/rustc_version-0.4.1/LICENSE-MIT +0 -25
  231. package/LICENSES/dependencies/rustix-1.1.4/COPYRIGHT +0 -29
  232. package/LICENSES/dependencies/rustix-1.1.4/LICENSE-APACHE +0 -201
  233. package/LICENSES/dependencies/rustix-1.1.4/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  234. package/LICENSES/dependencies/rustix-1.1.4/LICENSE-MIT +0 -23
  235. package/LICENSES/dependencies/rustversion-1.0.23/LICENSE-APACHE +0 -176
  236. package/LICENSES/dependencies/rustversion-1.0.23/LICENSE-MIT +0 -23
  237. package/LICENSES/dependencies/schemars-0.9.0/LICENSE +0 -21
  238. package/LICENSES/dependencies/schemars-1.2.2/LICENSE +0 -21
  239. package/LICENSES/dependencies/schemars_derive-1.2.2/LICENSE +0 -21
  240. package/LICENSES/dependencies/semver-1.0.28/LICENSE-APACHE +0 -176
  241. package/LICENSES/dependencies/semver-1.0.28/LICENSE-MIT +0 -23
  242. package/LICENSES/dependencies/serde-1.0.229/LICENSE-APACHE +0 -176
  243. package/LICENSES/dependencies/serde-1.0.229/LICENSE-MIT +0 -23
  244. package/LICENSES/dependencies/serde_core-1.0.229/LICENSE-APACHE +0 -176
  245. package/LICENSES/dependencies/serde_core-1.0.229/LICENSE-MIT +0 -23
  246. package/LICENSES/dependencies/serde_derive-1.0.229/LICENSE-APACHE +0 -176
  247. package/LICENSES/dependencies/serde_derive-1.0.229/LICENSE-MIT +0 -23
  248. package/LICENSES/dependencies/serde_derive_internals-0.30.0/LICENSE-APACHE +0 -176
  249. package/LICENSES/dependencies/serde_derive_internals-0.30.0/LICENSE-MIT +0 -23
  250. package/LICENSES/dependencies/serde_json-1.0.151/LICENSE-APACHE +0 -176
  251. package/LICENSES/dependencies/serde_json-1.0.151/LICENSE-MIT +0 -23
  252. package/LICENSES/dependencies/serde_with-3.23.0/LICENSE-APACHE +0 -201
  253. package/LICENSES/dependencies/serde_with-3.23.0/LICENSE-MIT +0 -25
  254. package/LICENSES/dependencies/serde_with_macros-3.23.0/LICENSE-APACHE +0 -201
  255. package/LICENSES/dependencies/serde_with_macros-3.23.0/LICENSE-MIT +0 -25
  256. package/LICENSES/dependencies/shell-words-1.1.1/LICENSE-APACHE +0 -201
  257. package/LICENSES/dependencies/shell-words-1.1.1/LICENSE-MIT +0 -25
  258. package/LICENSES/dependencies/shlex-2.0.1/LICENSE-APACHE +0 -13
  259. package/LICENSES/dependencies/shlex-2.0.1/LICENSE-MIT +0 -21
  260. package/LICENSES/dependencies/signal-hook-registry-1.4.8/LICENSE-APACHE +0 -201
  261. package/LICENSES/dependencies/signal-hook-registry-1.4.8/LICENSE-MIT +0 -25
  262. package/LICENSES/dependencies/slab-0.4.12/LICENSE +0 -25
  263. package/LICENSES/dependencies/smallvec-1.16.0/LICENSE-APACHE +0 -201
  264. package/LICENSES/dependencies/smallvec-1.16.0/LICENSE-MIT +0 -25
  265. package/LICENSES/dependencies/socket2-0.6.5/LICENSE-APACHE +0 -201
  266. package/LICENSES/dependencies/socket2-0.6.5/LICENSE-MIT +0 -25
  267. package/LICENSES/dependencies/stable_deref_trait-1.2.1/LICENSE-APACHE +0 -201
  268. package/LICENSES/dependencies/stable_deref_trait-1.2.1/LICENSE-MIT +0 -25
  269. package/LICENSES/dependencies/strsim-0.11.1/LICENSE +0 -23
  270. package/LICENSES/dependencies/strum-0.28.0/LICENSE +0 -21
  271. package/LICENSES/dependencies/strum_macros-0.28.0/LICENSE +0 -21
  272. package/LICENSES/dependencies/syn-2.0.119/LICENSE-APACHE +0 -176
  273. package/LICENSES/dependencies/syn-2.0.119/LICENSE-MIT +0 -23
  274. package/LICENSES/dependencies/syn-3.0.5/LICENSE-APACHE +0 -176
  275. package/LICENSES/dependencies/syn-3.0.5/LICENSE-MIT +0 -23
  276. package/LICENSES/dependencies/thiserror-2.0.20/LICENSE-APACHE +0 -176
  277. package/LICENSES/dependencies/thiserror-2.0.20/LICENSE-MIT +0 -23
  278. package/LICENSES/dependencies/thiserror-impl-2.0.20/LICENSE-APACHE +0 -176
  279. package/LICENSES/dependencies/thiserror-impl-2.0.20/LICENSE-MIT +0 -23
  280. package/LICENSES/dependencies/time-0.3.55/LICENSE-Apache +0 -177
  281. package/LICENSES/dependencies/time-0.3.55/LICENSE-MIT +0 -19
  282. package/LICENSES/dependencies/time-core-0.1.9/LICENSE-Apache +0 -177
  283. package/LICENSES/dependencies/time-core-0.1.9/LICENSE-MIT +0 -19
  284. package/LICENSES/dependencies/time-macros-0.2.32/LICENSE-Apache +0 -177
  285. package/LICENSES/dependencies/time-macros-0.2.32/LICENSE-MIT +0 -19
  286. package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-APACHE.md +0 -202
  287. package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-MIT.md +0 -5
  288. package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-ZLIB.md +0 -11
  289. package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-APACHE.md +0 -202
  290. package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-MIT.md +0 -21
  291. package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-ZLIB.md +0 -20
  292. package/LICENSES/dependencies/tokio-1.53.1/LICENSE +0 -21
  293. package/LICENSES/dependencies/tokio-macros-2.7.2/LICENSE +0 -22
  294. package/LICENSES/dependencies/tracing-0.1.44/LICENSE +0 -25
  295. package/LICENSES/dependencies/tracing-attributes-0.1.31/LICENSE +0 -25
  296. package/LICENSES/dependencies/tracing-core-0.1.36/LICENSE +0 -25
  297. package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-APACHE +0 -176
  298. package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-MIT +0 -23
  299. package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-UNICODE +0 -39
  300. package/LICENSES/dependencies/unicode-segmentation-1.13.3/COPYRIGHT +0 -7
  301. package/LICENSES/dependencies/unicode-segmentation-1.13.3/LICENSE-APACHE +0 -201
  302. package/LICENSES/dependencies/unicode-segmentation-1.13.3/LICENSE-MIT +0 -25
  303. package/LICENSES/dependencies/unicode-xid-0.2.6/COPYRIGHT +0 -7
  304. package/LICENSES/dependencies/unicode-xid-0.2.6/LICENSE-APACHE +0 -201
  305. package/LICENSES/dependencies/unicode-xid-0.2.6/LICENSE-MIT +0 -25
  306. package/LICENSES/dependencies/uuid-1.26.1/LICENSE-APACHE +0 -201
  307. package/LICENSES/dependencies/uuid-1.26.1/LICENSE-MIT +0 -26
  308. package/LICENSES/dependencies/walrus-0.26.5/LICENSE-APACHE +0 -201
  309. package/LICENSES/dependencies/walrus-0.26.5/LICENSE-MIT +0 -25
  310. package/LICENSES/dependencies/walrus-macro-0.26.0/LICENSE-APACHE +0 -201
  311. package/LICENSES/dependencies/walrus-macro-0.26.0/LICENSE-MIT +0 -25
  312. package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-APACHE +0 -201
  313. package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  314. package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-MIT +0 -23
  315. package/LICENSES/dependencies/wasm-bindgen-0.2.128/LICENSE-APACHE +0 -201
  316. package/LICENSES/dependencies/wasm-bindgen-0.2.128/LICENSE-MIT +0 -25
  317. package/LICENSES/dependencies/wasm-bindgen-cli-support-0.2.128/LICENSE-APACHE +0 -201
  318. package/LICENSES/dependencies/wasm-bindgen-cli-support-0.2.128/LICENSE-MIT +0 -25
  319. package/LICENSES/dependencies/wasm-bindgen-macro-0.2.128/LICENSE-APACHE +0 -201
  320. package/LICENSES/dependencies/wasm-bindgen-macro-0.2.128/LICENSE-MIT +0 -25
  321. package/LICENSES/dependencies/wasm-bindgen-macro-support-0.2.128/LICENSE-APACHE +0 -201
  322. package/LICENSES/dependencies/wasm-bindgen-macro-support-0.2.128/LICENSE-MIT +0 -25
  323. package/LICENSES/dependencies/wasm-bindgen-shared-0.2.128/LICENSE-APACHE +0 -201
  324. package/LICENSES/dependencies/wasm-bindgen-shared-0.2.128/LICENSE-MIT +0 -25
  325. package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-APACHE +0 -201
  326. package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  327. package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-MIT +0 -23
  328. package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-APACHE +0 -201
  329. package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  330. package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-MIT +0 -23
  331. package/LICENSES/dependencies/windows-core-0.62.2/license-apache-2.0 +0 -201
  332. package/LICENSES/dependencies/windows-core-0.62.2/license-mit +0 -21
  333. package/LICENSES/dependencies/windows-implement-0.60.2/license-apache-2.0 +0 -201
  334. package/LICENSES/dependencies/windows-implement-0.60.2/license-mit +0 -21
  335. package/LICENSES/dependencies/windows-interface-0.59.3/license-apache-2.0 +0 -201
  336. package/LICENSES/dependencies/windows-interface-0.59.3/license-mit +0 -21
  337. package/LICENSES/dependencies/windows-link-0.2.1/license-apache-2.0 +0 -201
  338. package/LICENSES/dependencies/windows-link-0.2.1/license-mit +0 -21
  339. package/LICENSES/dependencies/windows-result-0.4.1/license-apache-2.0 +0 -201
  340. package/LICENSES/dependencies/windows-result-0.4.1/license-mit +0 -21
  341. package/LICENSES/dependencies/windows-strings-0.5.1/license-apache-2.0 +0 -201
  342. package/LICENSES/dependencies/windows-strings-0.5.1/license-mit +0 -21
  343. package/LICENSES/dependencies/windows-sys-0.61.2/license-apache-2.0 +0 -201
  344. package/LICENSES/dependencies/windows-sys-0.61.2/license-mit +0 -21
  345. package/LICENSES/dependencies/zmij-1.0.23/LICENSE-MIT +0 -23
  346. package/THIRD-PARTY.md +0 -45
  347. package/source/.cargo/config.toml +0 -5
  348. package/source/.ci/upstream-notices/PROVENANCE.json +0 -198
  349. package/source/.ci/upstream-notices/agent-client-protocol-2.1.0/LICENSE +0 -191
  350. package/source/.ci/upstream-notices/agent-client-protocol-derive-2.1.0/LICENSE +0 -191
  351. package/source/.ci/upstream-notices/agent-client-protocol-schema-1.7.0/LICENSE +0 -190
  352. package/source/.ci/upstream-notices/defmt-parser-1.0.0/LICENSE-APACHE +0 -201
  353. package/source/.ci/upstream-notices/defmt-parser-1.0.0/LICENSE-MIT +0 -25
  354. package/source/.ci/upstream-notices/r-efi-6.0.0/AUTHORS +0 -75
  355. package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-APACHE +0 -201
  356. package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  357. package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-MIT +0 -23
  358. package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-APACHE +0 -201
  359. package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  360. package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-MIT +0 -23
  361. package/source/.ci/wasm-bundle/Cargo.toml +0 -10
  362. package/source/.ci/wasm-bundle/src/main.rs +0 -17
  363. package/source/CHANGELOG.md +0 -28
  364. package/source/Cargo.lock +0 -1622
  365. package/source/Cargo.toml +0 -48
  366. package/source/LICENSE +0 -307
  367. package/source/LICENSE.md +0 -25
  368. package/source/LICENSES/GPL-3.0-only.txt +0 -232
  369. package/source/LICENSES/LGPL-3.0-only.txt +0 -304
  370. package/source/README.md +0 -234
  371. package/source/THIRD-PARTY.md +0 -45
  372. package/source/dependencies.tar.gz +0 -0
  373. package/source/examples/native.rs +0 -45
  374. package/source/src/configuration.rs +0 -89
  375. package/source/src/conversation.rs +0 -569
  376. package/source/src/lib.rs +0 -30
  377. package/source/src/native/client.rs +0 -395
  378. package/source/src/native/fixture.py +0 -114
  379. package/source/src/native/mod.rs +0 -252
  380. package/source/src/native/session.rs +0 -603
  381. package/source/src/native/tests.rs +0 -463
  382. package/source/src/web.rs +0 -35
@@ -1,569 +0,0 @@
1
- //! Platform-independent conversation events and rendering state.
2
-
3
- use std::collections::BTreeMap;
4
-
5
- use serde::{Deserialize, Serialize};
6
- use thiserror::Error;
7
-
8
- use crate::acp;
9
-
10
- /// Version of the application-facing event envelope.
11
- pub const WIRE_VERSION: u16 = 1;
12
- /// Maximum accepted serialized event size.
13
- pub const MAX_EVENT_BYTES: usize = 1024 * 1024;
14
- const MAX_TURNS: usize = 256;
15
- const MAX_TURN_BYTES: usize = 8 * 1024 * 1024;
16
-
17
- /// A prompt whose correlation identity is assigned by the application.
18
- #[derive(Clone, Debug, Serialize, Deserialize)]
19
- pub struct Prompt {
20
- /// Unique identity for this delivery attempt. Never reuse it to retry an uncertain delivery.
21
- pub request_id: String,
22
- /// Official ACP content blocks, including any application-owned context.
23
- pub content: Vec<acp::ContentBlock>,
24
- }
25
-
26
- impl Prompt {
27
- /// Construct a plain-text prompt.
28
- pub fn text(request_id: impl Into<String>, text: impl Into<String>) -> Self {
29
- Self {
30
- request_id: request_id.into(),
31
- content: vec![acp::ContentBlock::from(text.into())],
32
- }
33
- }
34
- }
35
-
36
- /// A native session event. Events during history loading have no active request.
37
- #[derive(Clone, Debug, Serialize, Deserialize)]
38
- pub struct SessionEvent {
39
- /// Application request identity, when a prompt is active.
40
- pub request_id: Option<String>,
41
- /// Structured event payload.
42
- pub event: Event,
43
- }
44
-
45
- /// Shared event payload. Upstream ACP types preserve tool and capability details.
46
- #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
47
- #[serde(tag = "kind", rename_all = "snake_case")]
48
- pub enum Event {
49
- /// Agent output, tools, plans, usage, or session configuration.
50
- Update {
51
- /// Original typed ACP update.
52
- update: acp::SessionUpdate,
53
- },
54
- /// A permission decision is required from the application's authority.
55
- Permission {
56
- /// Identity of the pending permission request, not the prompt identity.
57
- request_id: String,
58
- /// The options and tool activity reported by the agent.
59
- request: acp::RequestPermissionRequest,
60
- },
61
- /// The prompt finished. Cancellation and refusal remain distinct reasons.
62
- Completed {
63
- /// Agent-reported terminal reason.
64
- stop_reason: acp::StopReason,
65
- },
66
- /// A terminal failure with a safe, application-facing description.
67
- Error {
68
- /// Stable failure category.
69
- code: String,
70
- /// Sanitized description; never raw credentials or process output.
71
- message: String,
72
- },
73
- }
74
-
75
- /// An application-authorized event suitable for persistence, SSE or other transports.
76
- ///
77
- /// Sequence numbers start at one and increase within each request. They are not
78
- /// a database cursor. Applications authenticate/authorize the conversation before
79
- /// handing events to a consumer; this envelope is not an authorization mechanism.
80
- #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
81
- pub struct WireEvent {
82
- /// Protocol version, currently one.
83
- pub version: u16,
84
- /// Application-owned conversation identity, including role isolation where needed.
85
- pub conversation_id: String,
86
- /// Application-owned prompt/delivery identity.
87
- pub request_id: String,
88
- /// Contiguous sequence number within the request, starting at one.
89
- pub sequence: u64,
90
- /// Shared structured event.
91
- pub event: Event,
92
- }
93
-
94
- impl WireEvent {
95
- /// Wrap an event with its application-owned routing and ordering identity.
96
- pub fn new(
97
- conversation_id: impl Into<String>,
98
- request_id: impl Into<String>,
99
- sequence: u64,
100
- event: Event,
101
- ) -> Self {
102
- Self {
103
- version: WIRE_VERSION,
104
- conversation_id: conversation_id.into(),
105
- request_id: request_id.into(),
106
- sequence,
107
- event,
108
- }
109
- }
110
- }
111
-
112
- /// An unresolved permission prompt. Rendering this does not authorize the action.
113
- #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
114
- pub struct PendingPermission {
115
- /// Native permission-request identity.
116
- pub request_id: String,
117
- /// Original request and the allowed response options.
118
- pub request: acp::RequestPermissionRequest,
119
- }
120
-
121
- /// Conversation processing failure. Rejected events do not mutate the snapshot.
122
- #[derive(Clone, Debug, Error, PartialEq, Eq)]
123
- pub enum ConversationError {
124
- /// The producer speaks an unsupported envelope version.
125
- #[error("unsupported ccht event version")]
126
- Version,
127
- /// The event belongs to a different conversation.
128
- #[error("event belongs to another conversation")]
129
- Scope,
130
- /// A request identifier or sequence is invalid.
131
- #[error("request identity and positive sequence are required")]
132
- Identity,
133
- /// A cursor skipped an event. The application must replay the missing event.
134
- #[error("event sequence has a gap; replay the missing events")]
135
- Gap,
136
- /// An event arrived after the request was terminal.
137
- #[error("request is already terminal")]
138
- Terminal,
139
- /// A bounded event or conversation exceeded its capacity.
140
- #[error("conversation capacity exceeded")]
141
- Capacity,
142
- /// The event is not valid ccht JSON.
143
- #[error("invalid ccht event JSON")]
144
- Json,
145
- }
146
-
147
- /// Renderable state for one prompt, shared between web and native consumers.
148
- #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
149
- pub struct TurnState {
150
- /// Application-owned request identity.
151
- pub request_id: String,
152
- /// Last applied event sequence.
153
- pub last_sequence: u64,
154
- /// Accumulated assistant text.
155
- pub text: String,
156
- /// User text supplied by upstream history replay, if any.
157
- pub user_text: String,
158
- /// Non-text user content from history replay, preserved separately by role.
159
- pub user_content: Vec<acp::ContentBlock>,
160
- /// Separately reported thought text; applications choose whether to display it.
161
- pub thought_text: String,
162
- /// Non-text thought content, preserved separately from visible assistant output.
163
- pub thought_content: Vec<acp::ContentBlock>,
164
- /// Non-text assistant content, preserved without flattening.
165
- pub content: Vec<acp::ContentBlock>,
166
- /// Current tool calls, including updates to their content and status.
167
- pub tools: BTreeMap<String, acp::ToolCall>,
168
- /// Unresolved permission requests.
169
- pub permissions: Vec<PendingPermission>,
170
- /// Latest other update of each ACP type, preserving plans/configuration/usage.
171
- pub updates: BTreeMap<String, serde_json::Value>,
172
- /// `streaming`, `awaiting_permission`, `completed`, `cancelled`, `refused`, or `failed`.
173
- pub status: String,
174
- /// Exact upstream terminal reason.
175
- pub stop_reason: Option<acp::StopReason>,
176
- /// Safe terminal error details.
177
- pub error: Option<serde_json::Value>,
178
- }
179
-
180
- impl TurnState {
181
- fn new(request_id: String) -> Self {
182
- Self {
183
- request_id,
184
- last_sequence: 0,
185
- text: String::new(),
186
- user_text: String::new(),
187
- user_content: Vec::new(),
188
- thought_text: String::new(),
189
- thought_content: Vec::new(),
190
- content: Vec::new(),
191
- tools: BTreeMap::new(),
192
- permissions: Vec::new(),
193
- updates: BTreeMap::new(),
194
- status: "streaming".into(),
195
- stop_reason: None,
196
- error: None,
197
- }
198
- }
199
-
200
- fn update(&mut self, update: acp::SessionUpdate) -> Result<(), ConversationError> {
201
- match update {
202
- acp::SessionUpdate::AgentMessageChunk(chunk) => match chunk.content {
203
- acp::ContentBlock::Text(text) => self.text.push_str(&text.text),
204
- other => self.content.push(other),
205
- },
206
- acp::SessionUpdate::UserMessageChunk(chunk) => match chunk.content {
207
- acp::ContentBlock::Text(text) => self.user_text.push_str(&text.text),
208
- other => self.user_content.push(other),
209
- },
210
- acp::SessionUpdate::AgentThoughtChunk(chunk) => match chunk.content {
211
- acp::ContentBlock::Text(text) => self.thought_text.push_str(&text.text),
212
- other => self.thought_content.push(other),
213
- },
214
- acp::SessionUpdate::ToolCall(call) => {
215
- self.tools.insert(call.tool_call_id.to_string(), call);
216
- }
217
- acp::SessionUpdate::ToolCallUpdate(update) => {
218
- let id = update.tool_call_id.to_string();
219
- let call = self.tools.entry(id).or_insert_with(|| {
220
- acp::ToolCall::new(update.tool_call_id.clone(), "Tool activity")
221
- });
222
- let fields = update.fields;
223
- if let Some(v) = fields.title {
224
- call.title = v;
225
- }
226
- if let Some(v) = fields.kind {
227
- call.kind = v;
228
- }
229
- if let Some(v) = fields.status {
230
- call.status = v;
231
- }
232
- if let Some(v) = fields.content {
233
- call.content = v;
234
- }
235
- if let Some(v) = fields.locations {
236
- call.locations = v;
237
- }
238
- if let Some(v) = fields.raw_input {
239
- call.raw_input = Some(v);
240
- }
241
- if let Some(v) = fields.raw_output {
242
- call.raw_output = Some(v);
243
- }
244
- if matches!(
245
- call.status,
246
- acp::ToolCallStatus::Completed | acp::ToolCallStatus::Failed
247
- ) {
248
- self.permissions
249
- .retain(|p| p.request.tool_call.tool_call_id != call.tool_call_id);
250
- }
251
- }
252
- other => {
253
- let value = serde_json::to_value(other).map_err(|_| ConversationError::Json)?;
254
- let key = value
255
- .get("sessionUpdate")
256
- .and_then(|v| v.as_str())
257
- .unwrap_or("unknown")
258
- .to_owned();
259
- self.updates.insert(key, value);
260
- }
261
- }
262
- self.status = if self.permissions.is_empty() {
263
- "streaming"
264
- } else {
265
- "awaiting_permission"
266
- }
267
- .into();
268
- Ok(())
269
- }
270
- }
271
-
272
- /// Bounded, deterministic conversation state. It owns no network, database or UI.
273
- #[derive(Clone, Debug, PartialEq, Serialize)]
274
- pub struct Conversation {
275
- conversation_id: String,
276
- turns: Vec<TurnState>,
277
- configuration: crate::SessionConfiguration,
278
- }
279
-
280
- impl Conversation {
281
- /// Create an empty conversation for one application-owned identity.
282
- pub fn new(conversation_id: impl Into<String>) -> Self {
283
- Self {
284
- conversation_id: conversation_id.into(),
285
- turns: Vec::new(),
286
- configuration: crate::SessionConfiguration::default(),
287
- }
288
- }
289
-
290
- /// Application-owned identity of this conversation.
291
- pub fn id(&self) -> &str {
292
- &self.conversation_id
293
- }
294
-
295
- /// Ordered render state, independent of any frontend framework.
296
- pub fn turns(&self) -> &[TurnState] {
297
- &self.turns
298
- }
299
-
300
- /// Latest session controls observed in the ordered event stream.
301
- pub fn configuration(&self) -> &crate::SessionConfiguration {
302
- &self.configuration
303
- }
304
-
305
- /// Serialize the render state for a browser or another transport.
306
- pub fn snapshot_json(&self) -> Result<String, ConversationError> {
307
- serde_json::to_string(self).map_err(|_| ConversationError::Json)
308
- }
309
-
310
- /// Parse and apply a bounded JSON envelope. Duplicate events return false.
311
- pub fn apply_json(&mut self, json: &str) -> Result<bool, ConversationError> {
312
- if json.len() > MAX_EVENT_BYTES {
313
- return Err(ConversationError::Capacity);
314
- }
315
- self.apply(serde_json::from_str(json).map_err(|_| ConversationError::Json)?)
316
- }
317
-
318
- /// Apply exactly one ordered event. Duplicate/replayed events return false.
319
- ///
320
- /// Gaps, scope mismatches and new events after completion fail explicitly.
321
- /// Applications retain the source event log and replay it on reconnection.
322
- pub fn apply(&mut self, wire: WireEvent) -> Result<bool, ConversationError> {
323
- if wire.version != WIRE_VERSION {
324
- return Err(ConversationError::Version);
325
- }
326
- if self.conversation_id.is_empty() || wire.conversation_id != self.conversation_id {
327
- return Err(ConversationError::Scope);
328
- }
329
- if wire.request_id.is_empty() || wire.sequence == 0 {
330
- return Err(ConversationError::Identity);
331
- }
332
- let index = self
333
- .turns
334
- .iter()
335
- .position(|t| t.request_id == wire.request_id);
336
- if let Some(i) = index {
337
- if wire.sequence <= self.turns[i].last_sequence {
338
- return Ok(false);
339
- }
340
- if self.turns[i].stop_reason.is_some() || self.turns[i].error.is_some() {
341
- return Err(ConversationError::Terminal);
342
- }
343
- } else if self.turns.len() >= MAX_TURNS {
344
- return Err(ConversationError::Capacity);
345
- }
346
- let mut turn = index
347
- .map(|i| self.turns[i].clone())
348
- .unwrap_or_else(|| TurnState::new(wire.request_id));
349
- if wire.sequence != turn.last_sequence + 1 {
350
- return Err(ConversationError::Gap);
351
- }
352
- if serde_json::to_vec(&wire.event)
353
- .map_err(|_| ConversationError::Json)?
354
- .len()
355
- > MAX_EVENT_BYTES
356
- {
357
- return Err(ConversationError::Capacity);
358
- }
359
- let mut configuration = self.configuration.clone();
360
- if let Event::Update { update } = &wire.event {
361
- configuration.apply(update);
362
- }
363
- match wire.event {
364
- Event::Update { update } => turn.update(update)?,
365
- Event::Permission {
366
- request_id,
367
- request,
368
- } => {
369
- if !turn.permissions.iter().any(|p| p.request_id == request_id) {
370
- turn.permissions.push(PendingPermission {
371
- request_id,
372
- request,
373
- });
374
- }
375
- turn.status = "awaiting_permission".into();
376
- }
377
- Event::Completed { stop_reason } => {
378
- turn.status = match stop_reason {
379
- acp::StopReason::Cancelled => "cancelled",
380
- acp::StopReason::Refusal => "refused",
381
- _ => "completed",
382
- }
383
- .into();
384
- turn.stop_reason = Some(stop_reason);
385
- turn.permissions.clear();
386
- }
387
- Event::Error { code, message } => {
388
- turn.status = "failed".into();
389
- turn.error = Some(serde_json::json!({"code":code,"message":message}));
390
- turn.permissions.clear();
391
- }
392
- }
393
- turn.last_sequence = wire.sequence;
394
- if serde_json::to_vec(&turn)
395
- .map_err(|_| ConversationError::Json)?
396
- .len()
397
- > MAX_TURN_BYTES
398
- {
399
- return Err(ConversationError::Capacity);
400
- }
401
- self.configuration = configuration;
402
- match index {
403
- Some(i) => self.turns[i] = turn,
404
- None => self.turns.push(turn),
405
- }
406
- Ok(true)
407
- }
408
- }
409
-
410
- #[cfg(test)]
411
- mod tests {
412
- use super::*;
413
-
414
- fn delta(conversation: &str, request: &str, sequence: u64, text: &str) -> WireEvent {
415
- WireEvent::new(
416
- conversation,
417
- request,
418
- sequence,
419
- Event::Update {
420
- update: acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(text.into())),
421
- },
422
- )
423
- }
424
-
425
- #[test]
426
- fn isolated_conversations_and_idempotent_replay() {
427
- let mut creator = Conversation::new("creator");
428
- let mut critic = Conversation::new("critic");
429
- let first = delta("creator", "r1", 1, "Hello");
430
- assert!(creator.apply(first.clone()).unwrap());
431
- assert!(!creator.apply(first.clone()).unwrap());
432
- assert_eq!(critic.apply(first), Err(ConversationError::Scope));
433
- assert!(critic.turns().is_empty());
434
- creator.apply(delta("creator", "r1", 2, " world")).unwrap();
435
- assert_eq!(creator.turns()[0].text, "Hello world");
436
- }
437
-
438
- #[test]
439
- fn gaps_and_late_updates_do_not_mutate_state() {
440
- let mut conversation = Conversation::new("c");
441
- assert_eq!(
442
- conversation.apply(delta("c", "r", 2, "lost")),
443
- Err(ConversationError::Gap)
444
- );
445
- assert!(conversation.turns().is_empty());
446
- conversation.apply(delta("c", "r", 1, "partial")).unwrap();
447
- conversation
448
- .apply(WireEvent::new(
449
- "c",
450
- "r",
451
- 2,
452
- Event::Completed {
453
- stop_reason: acp::StopReason::Cancelled,
454
- },
455
- ))
456
- .unwrap();
457
- let before = conversation.snapshot_json().unwrap();
458
- assert_eq!(
459
- conversation.apply(delta("c", "r", 3, "late")),
460
- Err(ConversationError::Terminal)
461
- );
462
- assert_eq!(before, conversation.snapshot_json().unwrap());
463
- assert_eq!(conversation.turns()[0].status, "cancelled");
464
- }
465
-
466
- #[test]
467
- fn non_text_content_preserves_user_assistant_and_thought_roles() {
468
- let mut conversation = Conversation::new("c");
469
- let image: acp::ContentBlock = serde_json::from_value(serde_json::json!({
470
- "type": "image", "data": "aW1hZ2U=", "mimeType": "image/png"
471
- }))
472
- .unwrap();
473
- for (sequence, update) in [
474
- (
475
- 1,
476
- acp::SessionUpdate::UserMessageChunk(acp::ContentChunk::new(image.clone())),
477
- ),
478
- (
479
- 2,
480
- acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new(image.clone())),
481
- ),
482
- (
483
- 3,
484
- acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new(image.clone())),
485
- ),
486
- ] {
487
- conversation
488
- .apply(WireEvent::new("c", "r", sequence, Event::Update { update }))
489
- .unwrap();
490
- }
491
- let turn = &conversation.turns()[0];
492
- assert_eq!(turn.user_content.as_slice(), std::slice::from_ref(&image));
493
- assert_eq!(turn.content.as_slice(), std::slice::from_ref(&image));
494
- assert_eq!(turn.thought_content, [image]);
495
- assert!(turn.text.is_empty());
496
- assert!(turn.user_text.is_empty());
497
- assert!(turn.thought_text.is_empty());
498
- }
499
-
500
- #[test]
501
- fn tool_updates_preserve_structure_and_resolve_permissions() {
502
- let mut conversation = Conversation::new("c");
503
- let call = acp::ToolCall::new("tool-1", "Edit document");
504
- conversation
505
- .apply(WireEvent::new(
506
- "c",
507
- "r",
508
- 1,
509
- Event::Update {
510
- update: acp::SessionUpdate::ToolCall(call),
511
- },
512
- ))
513
- .unwrap();
514
- let permission = acp::RequestPermissionRequest::new(
515
- "native",
516
- acp::ToolCallUpdate::new("tool-1", acp::ToolCallUpdateFields::new()),
517
- vec![acp::PermissionOption::new(
518
- "deny",
519
- "Deny",
520
- acp::PermissionOptionKind::RejectOnce,
521
- )],
522
- );
523
- conversation
524
- .apply(WireEvent::new(
525
- "c",
526
- "r",
527
- 2,
528
- Event::Permission {
529
- request_id: "p1".into(),
530
- request: permission,
531
- },
532
- ))
533
- .unwrap();
534
- assert_eq!(conversation.turns()[0].status, "awaiting_permission");
535
- let fields = acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Failed);
536
- conversation
537
- .apply(WireEvent::new(
538
- "c",
539
- "r",
540
- 3,
541
- Event::Update {
542
- update: acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new(
543
- "tool-1", fields,
544
- )),
545
- },
546
- ))
547
- .unwrap();
548
- assert!(conversation.turns()[0].permissions.is_empty());
549
- assert_eq!(
550
- conversation.turns()[0].tools["tool-1"].status,
551
- acp::ToolCallStatus::Failed
552
- );
553
- }
554
-
555
- #[test]
556
- fn invalid_json_versions_and_capacity_fail_without_mutation() {
557
- let mut conversation = Conversation::new("c");
558
- assert_eq!(conversation.apply_json("{"), Err(ConversationError::Json));
559
- let mut event = delta("c", "r", 1, "text");
560
- event.version = 2;
561
- assert_eq!(conversation.apply(event), Err(ConversationError::Version));
562
- let oversized = "x".repeat(MAX_EVENT_BYTES + 1);
563
- assert_eq!(
564
- conversation.apply_json(&oversized),
565
- Err(ConversationError::Capacity)
566
- );
567
- assert!(conversation.turns().is_empty());
568
- }
569
- }
package/source/src/lib.rs DELETED
@@ -1,30 +0,0 @@
1
- //! Reusable conversations for native applications and the web.
2
- //!
3
- //! The conversation model and event contract compile to native Rust and Wasm.
4
- //! Native connections use the official ACP SDK; applications own their UI,
5
- //! persistence, prompts and authorization decisions.
6
- //!
7
- //! ```
8
- //! use ccht::{Conversation, Event, WireEvent, acp};
9
- //! let mut conversation = Conversation::new("creator");
10
- //! let event = WireEvent::new("creator", "turn-1", 1,
11
- //! Event::Update { update: acp::SessionUpdate::AgentMessageChunk(
12
- //! acp::ContentChunk::new("Hello".into())) });
13
- //! conversation.apply(event).unwrap();
14
- //! assert_eq!(conversation.turns()[0].text, "Hello");
15
- //! ```
16
-
17
- /// The official platform-independent ACP version 1 schema.
18
- pub use agent_client_protocol_schema::v1 as acp;
19
-
20
- mod configuration;
21
- pub use configuration::*;
22
-
23
- mod conversation;
24
- pub use conversation::*;
25
-
26
- #[cfg(all(feature = "native", not(target_family = "wasm")))]
27
- pub mod native;
28
-
29
- #[cfg(feature = "web")]
30
- mod web;