@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.
- package/LICENSE +307 -0
- package/LICENSE.md +30 -0
- package/LICENSES/GPL-3.0-only.txt +232 -0
- package/LICENSES/LGPL-3.0-linking-exception.txt +16 -0
- package/LICENSES/LGPL-3.0-only WITH LGPL-3.0-linking-exception.txt +16 -0
- package/LICENSES/LGPL-3.0-only.txt +304 -0
- package/LICENSES/dependencies/agent-client-protocol-2.1.0/LICENSE +191 -0
- package/LICENSES/dependencies/agent-client-protocol-derive-2.1.0/LICENSE +191 -0
- package/LICENSES/dependencies/agent-client-protocol-schema-1.7.0/LICENSE +190 -0
- package/LICENSES/dependencies/android_system_properties-0.1.6/LICENSE-APACHE +13 -0
- package/LICENSES/dependencies/android_system_properties-0.1.6/LICENSE-MIT +20 -0
- package/LICENSES/dependencies/anyhow-1.0.104/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/anyhow-1.0.104/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/async-channel-2.5.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/async-channel-2.5.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/async-io-2.6.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/async-io-2.6.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/async-lock-3.4.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/async-lock-3.4.2/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/async-process-2.5.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/async-process-2.5.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/async-signal-0.2.14/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/async-signal-0.2.14/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/async-task-4.7.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/async-task-4.7.1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/atomic-waker-1.1.2/LICENSE-THIRD-PARTY +45 -0
- package/LICENSES/dependencies/autocfg-1.5.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/autocfg-1.5.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/base64-0.22.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/base64-0.22.1/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/base64-0.23.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/base64-0.23.1/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/bitflags-1.3.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/bitflags-1.3.2/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/bitflags-2.13.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/bitflags-2.13.2/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/blocking-1.7.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/blocking-1.7.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/bs58-0.5.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/bs58-0.5.1/LICENSE-MIT +20 -0
- package/LICENSES/dependencies/bumpalo-3.20.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/bumpalo-3.20.3/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/bytes-1.12.1/LICENSE +25 -0
- package/LICENSES/dependencies/cc-1.4.5/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/cc-1.4.5/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/cfg-if-1.0.4/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/cfg-if-1.0.4/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/chrono-0.4.45/LICENSE.txt +240 -0
- package/LICENSES/dependencies/concurrent-queue-2.5.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/concurrent-queue-2.5.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/convert_case-0.10.0/LICENSE +21 -0
- package/LICENSES/dependencies/core-foundation-sys-0.8.7/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/core-foundation-sys-0.8.7/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/crossbeam-deque-0.8.8/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/crossbeam-deque-0.8.8/LICENSE-MIT +27 -0
- package/LICENSES/dependencies/crossbeam-epoch-0.9.21/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/crossbeam-epoch-0.9.21/LICENSE-MIT +27 -0
- package/LICENSES/dependencies/crossbeam-utils-0.8.23/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/crossbeam-utils-0.8.23/LICENSE-MIT +27 -0
- package/LICENSES/dependencies/darling-0.24.1/LICENSE +21 -0
- package/LICENSES/dependencies/darling_core-0.24.1/LICENSE +21 -0
- package/LICENSES/dependencies/darling_macro-0.24.1/LICENSE +21 -0
- package/LICENSES/dependencies/defmt-1.1.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/defmt-1.1.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/defmt-macros-1.1.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/defmt-parser-1.0.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/defmt-parser-1.0.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/deranged-0.5.8/LICENSE-Apache +202 -0
- package/LICENSES/dependencies/deranged-0.5.8/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/derive_more-2.1.1/LICENSE +21 -0
- package/LICENSES/dependencies/derive_more-impl-2.1.1/LICENSE +21 -0
- package/LICENSES/dependencies/dyn-clone-1.0.20/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/dyn-clone-1.0.20/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/either-1.18.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/either-1.18.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/equivalent-1.0.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/equivalent-1.0.2/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/errno-0.3.14/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/errno-0.3.14/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/event-listener-5.4.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/event-listener-5.4.2/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/event-listener-strategy-0.5.4/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/event-listener-strategy-0.5.4/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/fallible-iterator-0.3.0/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/fallible-iterator-0.3.0/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/fastrand-2.5.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/fastrand-2.5.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/find-msvc-tools-0.1.12/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/find-msvc-tools-0.1.12/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/fixedbitset-0.5.7/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/fixedbitset-0.5.7/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/foldhash-0.2.0/LICENSE +19 -0
- package/LICENSES/dependencies/futures-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-channel-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-channel-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-concurrency-7.7.1/LICENSE-APACHE +190 -0
- package/LICENSES/dependencies/futures-concurrency-7.7.1/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/futures-core-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-core-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-executor-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-executor-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-io-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-io-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/futures-lite-2.6.1/LICENSE-THIRD-PARTY +45 -0
- package/LICENSES/dependencies/futures-macro-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-macro-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-sink-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-sink-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-task-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-task-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/futures-util-0.3.34/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/futures-util-0.3.34/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/getrandom-0.4.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/getrandom-0.4.3/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/gimli-0.32.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/gimli-0.32.3/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/hashbrown-0.12.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/hashbrown-0.12.3/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/hashbrown-0.16.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/hashbrown-0.16.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/hashbrown-0.17.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/hashbrown-0.17.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/heck-0.5.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/heck-0.5.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/hermit-abi-0.5.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/hermit-abi-0.5.3/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/hex-0.4.3/LICENSE-APACHE +202 -0
- package/LICENSES/dependencies/hex-0.4.3/LICENSE-MIT +20 -0
- package/LICENSES/dependencies/iana-time-zone-0.1.65/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/iana-time-zone-0.1.65/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/iana-time-zone-haiku-0.1.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/iana-time-zone-haiku-0.1.2/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/id-arena-2.3.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/id-arena-2.3.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/ident_case-1.0.1/LICENSE +19 -0
- package/LICENSES/dependencies/indexmap-1.9.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/indexmap-1.9.3/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/indexmap-2.14.2/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/indexmap-2.14.2/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/itoa-1.0.18/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/itoa-1.0.18/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/jiff-0.2.35/COPYING +3 -0
- package/LICENSES/dependencies/jiff-0.2.35/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/jiff-0.2.35/UNLICENSE +24 -0
- package/LICENSES/dependencies/jiff-core-0.1.0/COPYING +3 -0
- package/LICENSES/dependencies/jiff-core-0.1.0/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/jiff-core-0.1.0/UNLICENSE +24 -0
- package/LICENSES/dependencies/jiff-static-0.2.35/COPYING +3 -0
- package/LICENSES/dependencies/jiff-static-0.2.35/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/jiff-static-0.2.35/UNLICENSE +24 -0
- package/LICENSES/dependencies/jiff-tzdb-0.1.8/COPYING +3 -0
- package/LICENSES/dependencies/jiff-tzdb-0.1.8/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/jiff-tzdb-0.1.8/UNLICENSE +24 -0
- package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/COPYING +3 -0
- package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/jiff-tzdb-platform-0.1.3/UNLICENSE +24 -0
- package/LICENSES/dependencies/js-sys-0.3.105/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/js-sys-0.3.105/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/leb128-0.2.7/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/leb128-0.2.7/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/leb128fmt-0.1.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/leb128fmt-0.1.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/libc-0.2.189/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/libc-0.2.189/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
- package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/LICENSES/dependencies/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/log-0.4.34/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/log-0.4.34/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/memchr-2.8.3/COPYING +3 -0
- package/LICENSES/dependencies/memchr-2.8.3/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/memchr-2.8.3/UNLICENSE +24 -0
- package/LICENSES/dependencies/mio-1.2.3/LICENSE +19 -0
- package/LICENSES/dependencies/num-conv-0.2.2/LICENSE-Apache +177 -0
- package/LICENSES/dependencies/num-conv-0.2.2/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/num-traits-0.2.19/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/num-traits-0.2.19/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/once_cell-1.21.4/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/once_cell-1.21.4/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/parking-2.2.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/parking-2.2.1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/parking-2.2.1/LICENSE-THIRD-PARTY +9 -0
- package/LICENSES/dependencies/pin-project-1.1.13/LICENSE-APACHE +177 -0
- package/LICENSES/dependencies/pin-project-1.1.13/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/pin-project-internal-1.1.13/LICENSE-APACHE +177 -0
- package/LICENSES/dependencies/pin-project-internal-1.1.13/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/pin-project-lite-0.2.17/LICENSE-APACHE +177 -0
- package/LICENSES/dependencies/pin-project-lite-0.2.17/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/piper-0.2.5/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/piper-0.2.5/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/polling-3.11.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/polling-3.11.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/portable-atomic-1.15.0/LICENSE-APACHE +177 -0
- package/LICENSES/dependencies/portable-atomic-1.15.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/portable-atomic-util-0.2.8/LICENSE-APACHE +177 -0
- package/LICENSES/dependencies/portable-atomic-util-0.2.8/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/powerfmt-0.2.0/LICENSE-Apache +202 -0
- package/LICENSES/dependencies/powerfmt-0.2.0/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/proc-macro2-1.0.107/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/quote-1.0.47/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/quote-1.0.47/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/r-efi-6.0.0/AUTHORS +75 -0
- package/LICENSES/dependencies/rayon-1.12.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/rayon-1.12.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/rayon-core-1.13.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/rayon-core-1.13.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/ref-cast-1.0.27/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/ref-cast-1.0.27/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/ref-cast-impl-1.0.27/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/ref-cast-impl-1.0.27/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/rustc-demangle-0.1.28/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/rustc-demangle-0.1.28/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/rustc-hash-2.1.3/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/rustc-hash-2.1.3/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/rustc_version-0.4.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/rustc_version-0.4.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/rustix-1.1.4/COPYRIGHT +29 -0
- package/LICENSES/dependencies/rustix-1.1.4/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/rustix-1.1.4/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/LICENSES/dependencies/rustix-1.1.4/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/rustversion-1.0.23/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/rustversion-1.0.23/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/schemars-0.9.0/LICENSE +21 -0
- package/LICENSES/dependencies/schemars-1.2.2/LICENSE +21 -0
- package/LICENSES/dependencies/schemars_derive-1.2.2/LICENSE +21 -0
- package/LICENSES/dependencies/semver-1.0.28/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/semver-1.0.28/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/serde-1.0.229/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/serde-1.0.229/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/serde_core-1.0.229/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/serde_core-1.0.229/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/serde_derive-1.0.229/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/serde_derive-1.0.229/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/serde_derive_internals-0.30.0/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/serde_derive_internals-0.30.0/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/serde_json-1.0.151/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/serde_json-1.0.151/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/serde_with-3.23.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/serde_with-3.23.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/serde_with_macros-3.23.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/serde_with_macros-3.23.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/shell-words-1.1.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/shell-words-1.1.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/shlex-2.0.1/LICENSE-APACHE +13 -0
- package/LICENSES/dependencies/shlex-2.0.1/LICENSE-MIT +21 -0
- package/LICENSES/dependencies/signal-hook-registry-1.4.8/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/signal-hook-registry-1.4.8/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/slab-0.4.12/LICENSE +25 -0
- package/LICENSES/dependencies/smallvec-1.16.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/smallvec-1.16.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/socket2-0.6.5/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/socket2-0.6.5/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/stable_deref_trait-1.2.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/stable_deref_trait-1.2.1/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/strsim-0.11.1/LICENSE +23 -0
- package/LICENSES/dependencies/strum-0.28.0/LICENSE +21 -0
- package/LICENSES/dependencies/strum_macros-0.28.0/LICENSE +21 -0
- package/LICENSES/dependencies/syn-2.0.119/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/syn-2.0.119/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/syn-3.0.5/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/syn-3.0.5/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/thiserror-2.0.20/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/thiserror-2.0.20/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/thiserror-impl-2.0.20/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/thiserror-impl-2.0.20/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/time-0.3.55/LICENSE-Apache +177 -0
- package/LICENSES/dependencies/time-0.3.55/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/time-core-0.1.9/LICENSE-Apache +177 -0
- package/LICENSES/dependencies/time-core-0.1.9/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/time-macros-0.2.32/LICENSE-Apache +177 -0
- package/LICENSES/dependencies/time-macros-0.2.32/LICENSE-MIT +19 -0
- package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-APACHE.md +202 -0
- package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-MIT.md +5 -0
- package/LICENSES/dependencies/tinyvec-1.13.2/LICENSE-ZLIB.md +11 -0
- package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-APACHE.md +202 -0
- package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-MIT.md +21 -0
- package/LICENSES/dependencies/tinyvec_macros-0.1.1/LICENSE-ZLIB.md +20 -0
- package/LICENSES/dependencies/tokio-1.53.1/LICENSE +21 -0
- package/LICENSES/dependencies/tokio-macros-2.7.2/LICENSE +22 -0
- package/LICENSES/dependencies/tracing-0.1.44/LICENSE +25 -0
- package/LICENSES/dependencies/tracing-attributes-0.1.31/LICENSE +25 -0
- package/LICENSES/dependencies/tracing-core-0.1.36/LICENSE +25 -0
- package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-APACHE +176 -0
- package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/unicode-ident-1.0.24/LICENSE-UNICODE +39 -0
- package/LICENSES/dependencies/unicode-segmentation-1.13.3/COPYRIGHT +7 -0
- package/LICENSES/dependencies/unicode-segmentation-1.13.3/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/unicode-segmentation-1.13.3/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/unicode-xid-0.2.6/COPYRIGHT +7 -0
- package/LICENSES/dependencies/unicode-xid-0.2.6/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/unicode-xid-0.2.6/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/uuid-1.26.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/uuid-1.26.1/LICENSE-MIT +26 -0
- package/LICENSES/dependencies/walrus-0.26.5/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/walrus-0.26.5/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/walrus-macro-0.26.0/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/walrus-macro-0.26.0/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/LICENSES/dependencies/wasi-0.11.1+wasi-snapshot-preview1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/wasm-bindgen-0.2.128/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasm-bindgen-0.2.128/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/wasm-bindgen-cli-support-0.2.128/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasm-bindgen-cli-support-0.2.128/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/wasm-bindgen-macro-0.2.128/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasm-bindgen-macro-0.2.128/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/wasm-bindgen-macro-support-0.2.128/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasm-bindgen-macro-support-0.2.128/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/wasm-bindgen-shared-0.2.128/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasm-bindgen-shared-0.2.128/LICENSE-MIT +25 -0
- package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/LICENSES/dependencies/wasm-encoder-0.245.1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-APACHE +201 -0
- package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/LICENSES/dependencies/wasmparser-0.245.1/LICENSE-MIT +23 -0
- package/LICENSES/dependencies/windows-core-0.62.2/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-core-0.62.2/license-mit +21 -0
- package/LICENSES/dependencies/windows-implement-0.60.2/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-implement-0.60.2/license-mit +21 -0
- package/LICENSES/dependencies/windows-interface-0.59.3/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-interface-0.59.3/license-mit +21 -0
- package/LICENSES/dependencies/windows-link-0.2.1/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-link-0.2.1/license-mit +21 -0
- package/LICENSES/dependencies/windows-result-0.4.1/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-result-0.4.1/license-mit +21 -0
- package/LICENSES/dependencies/windows-strings-0.5.1/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-strings-0.5.1/license-mit +21 -0
- package/LICENSES/dependencies/windows-sys-0.61.2/license-apache-2.0 +201 -0
- package/LICENSES/dependencies/windows-sys-0.61.2/license-mit +21 -0
- package/LICENSES/dependencies/zmij-1.0.23/LICENSE-MIT +23 -0
- package/README.md +70 -0
- package/THIRD-PARTY.md +62 -0
- package/package.json +48 -9
- package/source/.cargo/config.toml +5 -0
- package/source/.ci/upstream-notices/PROVENANCE.json +198 -0
- package/source/.ci/upstream-notices/agent-client-protocol-2.1.0/LICENSE +191 -0
- package/source/.ci/upstream-notices/agent-client-protocol-derive-2.1.0/LICENSE +191 -0
- package/source/.ci/upstream-notices/agent-client-protocol-schema-1.7.0/LICENSE +190 -0
- package/source/.ci/upstream-notices/defmt-parser-1.0.0/LICENSE-APACHE +201 -0
- package/source/.ci/upstream-notices/defmt-parser-1.0.0/LICENSE-MIT +25 -0
- package/source/.ci/upstream-notices/r-efi-6.0.0/AUTHORS +75 -0
- package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-APACHE +201 -0
- package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/source/.ci/upstream-notices/wasm-encoder-0.245.1/LICENSE-MIT +23 -0
- package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-APACHE +201 -0
- package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/source/.ci/upstream-notices/wasmparser-0.245.1/LICENSE-MIT +23 -0
- package/source/.ci/wasm-bundle/Cargo.toml +10 -0
- package/source/.ci/wasm-bundle/src/main.rs +17 -0
- package/source/CHANGELOG.md +99 -0
- package/source/Cargo.lock +1630 -0
- package/source/Cargo.toml +48 -0
- package/source/LICENSE +307 -0
- package/source/LICENSE.md +30 -0
- package/source/LICENSES/GPL-3.0-only.txt +232 -0
- package/source/LICENSES/LGPL-3.0-linking-exception.txt +16 -0
- package/source/LICENSES/LGPL-3.0-only WITH LGPL-3.0-linking-exception.txt +16 -0
- package/source/LICENSES/LGPL-3.0-only.txt +304 -0
- package/source/README.md +289 -0
- package/source/THIRD-PARTY.md +62 -0
- package/source/dependencies.tar.gz +0 -0
- package/source/examples/native.rs +45 -0
- package/source/src/auth.rs +435 -0
- package/source/src/configuration.rs +140 -0
- package/source/src/conversation.rs +594 -0
- package/source/src/dock.rs +564 -0
- package/source/src/lib.rs +39 -0
- package/source/src/native/client.rs +401 -0
- package/source/src/native/drivers/codex.rs +506 -0
- package/source/src/native/drivers/mod.rs +305 -0
- package/source/src/native/drivers/opencode.rs +531 -0
- package/source/src/native/env.rs +264 -0
- package/source/src/native/fixture.py +191 -0
- package/source/src/native/mod.rs +257 -0
- package/source/src/native/pool.rs +440 -0
- package/source/src/native/session.rs +609 -0
- package/source/src/native/tests.rs +667 -0
- package/source/src/transport.rs +330 -0
- package/source/src/web.rs +35 -0
- package/src/auth.test.ts +115 -0
- package/src/components/ChatDock.component.test.ts +213 -0
- package/src/components/ChatDock.svelte +422 -0
- package/src/components/Dock.component.test.ts +92 -0
- package/src/components/Dock.svelte +6 -3
- package/src/components/StepConfig.component.test.ts +185 -0
- package/src/components/StepConfig.svelte +247 -0
- package/src/dock.test.ts +226 -0
- 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
|
+
}
|