diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index adbe3152..0cfd2d5b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -134,6 +134,51 @@ jobs: tar -xf /tmp/zig.tar.xz -C /opt/zig --strip-components=1 echo "/opt/zig" >> "$GITHUB_PATH" fi + # Provide a C/C++ compiler for the musl target. ring's build script + # (cc-rs) looks for `-gcc`, which no longer exists since we + # dropped musl-tools. Point it at zig cc via a wrapper so the same zig + # toolchain compiles the C sources for the musl target. + CC_WRAPPER="/usr/local/bin/${TARGET_TRIPLE}-gcc" + CXX_WRAPPER="/usr/local/bin/${TARGET_TRIPLE}-g++" + # Zig uses its own triple format without the `unknown` vendor + # (x86_64-linux-musl); it rejects the Rust triple's + # x86_64-unknown-linux-musl ("UnknownOperatingSystem"). + ZIG_TRIPLE=$(printf '%s' "$TARGET_TRIPLE" | sed 's/-unknown-/-/') + cat > "$CC_WRAPPER" < for clang-family compilers; + # zig cannot parse that triple, so drop it here and pass the + # zig-native target explicitly. + new="" + for a in "\$@"; do + case "\$a" in + --target=*) continue ;; + esac + new="\$new \$a" + done + exec zig cc -target ${ZIG_TRIPLE} \$new + EOF + cat > "$CXX_WRAPPER" <, pass zig triple. + new="" + for a in "\$@"; do + case "\$a" in + --target=*) continue ;; + esac + new="\$new \$a" + done + exec zig c++ -target ${ZIG_TRIPLE} \$new + EOF + chmod +x "$CC_WRAPPER" "$CXX_WRAPPER" + # cc-rs reads CC_ in lowercase, checking both the dash form + # (exact triple) and the underscore form. Export both to be safe + # across cc crate versions. + ENV_KEY_UNDER=$(echo "$TARGET_TRIPLE" | tr '-' '_') + echo "CC_${TARGET_TRIPLE}=${CC_WRAPPER}" >> "$GITHUB_ENV" + echo "CC_${ENV_KEY_UNDER}=${CC_WRAPPER}" >> "$GITHUB_ENV" + echo "CXX_${TARGET_TRIPLE}=${CXX_WRAPPER}" >> "$GITHUB_ENV" + echo "CXX_${ENV_KEY_UNDER}=${CXX_WRAPPER}" >> "$GITHUB_ENV" - name: Build release run: | @@ -141,7 +186,10 @@ jobs: --target ${{ matrix.label }}-unknown-linux-musl env: APP: ${{ inputs.app || 'elph' }} - RUSTC_WRAPPER: sccache + # sccache does not support zig as a compiler family, so it cannot wrap + # the zig cc C compiler above. Disable the wrapper for this cross-build; + # target/ is still cached on the Namespace cache volume. + RUSTC_WRAPPER: "" - name: Package shell: bash diff --git a/Cargo.lock b/Cargo.lock index ef78b551..b04530ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,15 +8,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "415ed64958754dbe991900f3940677e6a7eefb4d7367afd70d642677b0c7d19d" -[[package]] -name = "addr2line" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59317f77929f0e679d39364702289274de2f0f0b22cbf50b2b8cff2169a0b27a" -dependencies = [ - "gimli", -] - [[package]] name = "adler2" version = "2.0.1" @@ -100,16 +91,16 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdf011db2e21ce0d575593d749db5554b47fed37aff429e4dc50bc91ac93a028" +checksum = "7f2b8006a0c83f52b62ba44a97b58bf76fe2f70a329e588f67f89691d93d498f" dependencies = [ "aead 0.6.1", "aes 0.9.2", "cipher 0.5.2", "ctr 0.10.1", + "ctutils", "ghash 0.6.0", - "subtle", ] [[package]] @@ -407,12 +398,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - [[package]] name = "arrayvec" version = "0.7.8" @@ -714,9 +699,9 @@ dependencies = [ [[package]] name = "aws-config" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b180a3c8b55960db3426d8964b8745e652466a1a49fe1a2eda828046d30b5e4" +checksum = "a767267da9e2c2e189b2f9df8b5657e850ecf5352644734ba130d4a57095cf1b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -806,9 +791,9 @@ dependencies = [ [[package]] name = "aws-sdk-bedrockruntime" -version = "1.139.0" +version = "1.141.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dffe4bd3da45048fa0d30b50febaedf093e93a25d832cc21f2845a6e0c72616" +checksum = "6418b1f5feb3a8cc0fa10fb9af5693c88135ee03bae3ff48c8cdbf6a918daa07" dependencies = [ "arc-swap", "aws-credential-types", @@ -835,9 +820,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.105.0" +version = "1.107.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ffd0fbe7873cb548a7aa60f9573c268fff94155397fd4f14dc9f1ecaaab8516" +checksum = "769b0abd0f89cfe11da5099986dd493e4f94347ce9a4562cb86ddecfe926b6c0" dependencies = [ "arc-swap", "aws-credential-types", @@ -861,9 +846,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.107.0" +version = "1.109.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175763eb222a46377df7aa257a3bca980ab3e96703fefc8f4d0b8da6ad2e254c" +checksum = "f4075b8a2c8cda4076a3dcc43b9d6dabd93e0c2502abeaaf7e14aaead9bb312b" dependencies = [ "arc-swap", "aws-credential-types", @@ -887,9 +872,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.110.0" +version = "1.112.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b14781dfbff48984017d57167b6ea0b6471c6920ec52b44a2677c7feb3c13" +checksum = "3f582002918346a3e685be1b391c7bea155073088cea6bd4e4b7663df9e43b6c" dependencies = [ "arc-swap", "aws-credential-types", @@ -948,9 +933,9 @@ dependencies = [ [[package]] name = "aws-smithy-eventstream" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9381123ab62d20c13082b151f30f962a3b112b727345394536dfa39a482944" +checksum = "6de526c7b567420a31bc283657a7921b45c4cafe0827fdf2490713dcc770c28f" dependencies = [ "aws-smithy-types", "bytes", @@ -981,15 +966,15 @@ dependencies = [ [[package]] name = "aws-smithy-http-client" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "635d23afda0a6ab48d666c4d447c4873e8d1e83518a2be2093122397e50b838e" +checksum = "ebfd138fac0337cee7516c352757ea73b9f2266e57d0bcb5bc70e9547e45aef1" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", "aws-smithy-types", "h2 0.3.27", - "h2 0.4.15", + "h2 0.4.18", "http 0.2.12", "http 1.5.0", "http-body 0.4.6", @@ -1044,9 +1029,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.12.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07505b34e8f4b3591a4fa69e9792b52289b95488dbbc68c3c0075b7bedb245e1" +checksum = "b82e438d30e02a825d363bd639a9efaed68a8089d86101054b0081e7e0d3e606" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1070,9 +1055,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b98f2e1fd67ec06618f9c291e5e495a468e60519e44c9c1979cd0521f3affdb" +checksum = "954c563ce84507722d2679f07a35d21b9c6466b3872d513020d0281fc8112ac9" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api-macros", @@ -1394,11 +1379,10 @@ dependencies = [ [[package]] name = "blake3" -version = "1.8.6" +version = "1.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ae7bad254120e9e4c63bafc385310756f90c484eac0e36b8317cf09cb92a77" +checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae" dependencies = [ - "arrayref", "arrayvec", "cc", "cfg-if 1.0.4", @@ -1518,9 +1502,9 @@ dependencies = [ [[package]] name = "branches" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fba76cd916045514e3064707df9ed5282b94419444c2753a6c62ecaf458e56" +checksum = "7436b21fd6195415058eb41c9090e156b556bc7e0377bb57c5c026a421521525" dependencies = [ "rustc_version", ] @@ -1577,9 +1561,6 @@ name = "bumpalo" version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" -dependencies = [ - "allocator-api2 0.2.21", -] [[package]] name = "bytecount" @@ -1769,9 +1750,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.4.2" +version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d262e149917187838d5b42777c8253bcb64500067342904e7d429499a6f277e" +checksum = "0ad534f4357a5264cce5019c989cf66a4f0dc4e0d1b1d15f8aacec0ff7360273" dependencies = [ "find-msvc-tools", "jobserver", @@ -1978,15 +1959,6 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" -[[package]] -name = "cobs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" -dependencies = [ - "thiserror 2.0.20", -] - [[package]] name = "color_quant" version = "1.1.0" @@ -2112,9 +2084,9 @@ checksum = "18f12cc9948ed9604230cdddc7c86e270f9401ccbe3c2e98a4378c5e7632212f" [[package]] name = "const_panic" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e262cdaac42494e3ae34c43969f9cdeb7da178bdb4b66fa6a1ea2edb4c8ae652" +checksum = "9603f79528ece8163c496f8932121cb36cfe46259e9c907bb3d8205139d7caa3" dependencies = [ "typewit", ] @@ -2195,15 +2167,6 @@ dependencies = [ "futures-io", ] -[[package]] -name = "cpp_demangle" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0667304c32ea56cb4cd6d2d7c0cfe9a2f8041229db8c033af7f8d69492429def" -dependencies = [ - "cfg-if 1.0.4", -] - [[package]] name = "cpubits" version = "0.1.1" @@ -2228,152 +2191,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cranelift-assembler-x64" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d552bd33b7a56dc70aeb1e1c960e51a218fa0db50f23873b500a310379450b2d" -dependencies = [ - "cranelift-assembler-x64-meta", -] - -[[package]] -name = "cranelift-assembler-x64-meta" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e80e4c222279e3330f6aa1a256ca77ddf156d4453166a9f09defedc4594dd" -dependencies = [ - "cranelift-srcgen", -] - -[[package]] -name = "cranelift-bforest" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820ce15d4ad3562d613c31a67b6d0434d403e7091a68d1349903842f7d31737e" -dependencies = [ - "cranelift-entity", - "wasmtime-internal-core", -] - -[[package]] -name = "cranelift-bitset" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61bca563d4b86d285928d9e27f97f27039bb33a0fc524fa130d7d0c106bf8ab3" -dependencies = [ - "serde", - "serde_derive", - "wasmtime-internal-core", -] - -[[package]] -name = "cranelift-codegen" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "709f4b7c0fb57d952658d5b5c07fbdc4149acd7b7f0de9678ae754b9c981949a" -dependencies = [ - "bumpalo", - "cranelift-assembler-x64", - "cranelift-bforest", - "cranelift-bitset", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-control", - "cranelift-entity", - "cranelift-isle", - "gimli", - "hashbrown 0.17.1", - "libm", - "log", - "postcard", - "pulley-interpreter", - "regalloc2", - "rustc-hash 2.1.3", - "serde", - "serde_derive", - "sha2 0.10.9", - "smallvec 1.15.2", - "target-lexicon", - "wasmtime-internal-core", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903dc8915af62aad1d9d0f39a5968d33fa80b9aa899ed6f56e47f40ca4512e1e" -dependencies = [ - "cranelift-assembler-x64-meta", - "cranelift-codegen-shared", - "cranelift-srcgen", - "heck", - "pulley-interpreter", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0522d74c227e49f3fd49ab055311486ae4f09083262b66705bed676952491469" - -[[package]] -name = "cranelift-control" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66560ea1c5cef72e170b18e46d263dba2d3169c9d39e8cafdab2173c6362cc1a" -dependencies = [ - "arbitrary", -] - -[[package]] -name = "cranelift-entity" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ef5b17cc814d27e96b66a5b46da0e4ce2b8ac55a6d478048bb99d04b05526" -dependencies = [ - "cranelift-bitset", - "serde", - "serde_derive", - "wasmtime-internal-core", -] - -[[package]] -name = "cranelift-frontend" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a87e0aaa39dbf70693b348a221e45904111704ee8f9fef140498471005f9842d" -dependencies = [ - "cranelift-codegen", - "hashbrown 0.17.1", - "log", - "smallvec 1.15.2", - "target-lexicon", -] - -[[package]] -name = "cranelift-isle" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf79003ebfa1eed5e87f3b84446ad5236f540268289960e14f387dc9b28e40b7" - -[[package]] -name = "cranelift-native" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bf4f235743c81e67ee4db617c5a4a0b65d58d3f0cfc575ee0f1a4e0cd58273" -dependencies = [ - "cranelift-codegen", - "libc", - "target-lexicon", -] - -[[package]] -name = "cranelift-srcgen" -version = "0.134.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6977c2a71ab1e0d1e62f966b411a498aa04c4dce47d93d52f8a360a06058922" - [[package]] name = "crc32c" version = "0.6.8" @@ -2596,12 +2413,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88490bf1b990d87eaaa7ac8aa887f629a08e7359765b4911faf63c3763347d23" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" dependencies = [ - "darling_core 0.24.0", - "darling_macro 0.24.0", + "darling_core 0.24.1", + "darling_macro 0.24.1", ] [[package]] @@ -2633,9 +2450,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084e274f91c482280130e1e34e0b8d6e66776a060d7b6de7b84289ca778868c4" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" dependencies = [ "ident_case", "proc-macro2", @@ -2668,11 +2485,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5792fa0d41cd2325ce0ffa64f0a340eaebd4971a3a0c5e1ffd2cc488a355e" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" dependencies = [ - "darling_core 0.24.0", + "darling_core 0.24.1", "quote", "syn 3.0.3", ] @@ -3048,13 +2865,13 @@ dependencies = [ [[package]] name = "either" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" +checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" [[package]] name = "elph" -version = "0.0.1" +version = "0.0.0" dependencies = [ "agent-client-protocol", "anstyle", @@ -3093,7 +2910,7 @@ dependencies = [ name = "elph-agent" version = "0.0.28" dependencies = [ - "aes-gcm 0.11.0", + "aes-gcm 0.11.1", "anyhow", "ast-grep-core", "ast-grep-language", @@ -3140,7 +2957,8 @@ dependencies = [ "url", "urlencoding", "walkdir", - "wasmtime", + "wasmi", + "wat", "yaml_serde", ] @@ -3208,7 +3026,7 @@ dependencies = [ "reqwest 0.13.4", "serde", "serde_json", - "similar 3.1.2", + "similar 3.2.0", "smol", "smol-macros", "textwrap", @@ -3267,18 +3085,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "embedded-io" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" - -[[package]] -name = "embedded-io" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" - [[package]] name = "encode_unicode" version = "1.0.0" @@ -3381,9 +3187,9 @@ dependencies = [ [[package]] name = "error-code" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" [[package]] name = "esaxx-rs" @@ -3692,9 +3498,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b73573e6edcd2af0cdf47bd6cb58f0b3839491263c314eaad1ccf24430e1de" +checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890" [[package]] name = "fixedbitset" @@ -3822,12 +3628,12 @@ dependencies = [ [[package]] name = "fraction" -version = "0.15.4" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076045bb43dac435333ed5f04caf35c7463631d0dae2deb2638d94dd0a5b872" +checksum = "33fee0259ffdc3d7bd64438b6b08437884d4df5700f9cb8a23b079c3958ae578" dependencies = [ - "lazy_static", "num", + "num-bigint", ] [[package]] @@ -4388,18 +4194,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "gimli" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7f043f89559805f8c7cacc432749b2fa0d0a0a9ee46ce47164ed5ba7f126c" -dependencies = [ - "fnv", - "hashbrown 0.16.1", - "indexmap 2.14.0", - "stable_deref_trait", -] - [[package]] name = "git-version" version = "0.3.9" @@ -4520,9 +4314,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.15" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155" +checksum = "839c0e8a181239723652be9062bb56ca5bf5f64011f73b623f6f4fc59086a228" dependencies = [ "atomic-waker", "bytes", @@ -4620,8 +4414,6 @@ dependencies = [ "allocator-api2 0.2.21", "equivalent", "foldhash 0.2.0", - "serde", - "serde_core", ] [[package]] @@ -4912,9 +4704,9 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f41fd6a08e4d4ec69df65976da761afd5ad5e58a9d4acb46bd1c953a9e3ff2" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" dependencies = [ "bytes", "futures-core", @@ -5018,7 +4810,7 @@ dependencies = [ "bytes", "futures-channel", "futures-core", - "h2 0.4.15", + "h2 0.4.18", "http 1.5.0", "http-body 1.1.0", "httparse", @@ -5113,28 +4905,28 @@ dependencies = [ [[package]] name = "icu_collator" -version = "2.2.1" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bbdf98e5e0aa827770acee171ebb568aaab975a36b56afdb5fd0e2f525750bb" +checksum = "08984ed58ac439ebf3e13d2cf26b0c46a60afcd21721c1d14087c0b240344dda" dependencies = [ "icu_collator_data", - "icu_collections 2.2.0", - "icu_locale", + "icu_collections 2.3.0", "icu_locale_core", + "icu_locale_fallback", "icu_normalizer", "icu_properties", - "icu_provider 2.2.0", + "icu_provider 2.3.1", "smallvec 1.15.2", "utf16_iter", "utf8_iter", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] name = "icu_collator_data" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038ed8e5817f2059c2f3efb0945ba78d060d3d25e8f1a1bea5139f821a21a2f0" +checksum = "f7d7e54efdddeb1208c08dd5d32b53a879ac00d2d3d051b2255fd26821d16368" [[package]] name = "icu_collections" @@ -5150,52 +4942,72 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" dependencies = [ "displaydoc", "potential_utf", "utf8_iter", "yoke 0.8.3", "zerofrom", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] name = "icu_locale" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5a396343c7208121dc86e35623d3dfe19814a7613cfd14964994cdc9c9a2e26" +checksum = "785f595c61ef57169a467eeed7b4b6936a66f6cacbb116a96ee86da983251bf4" dependencies = [ - "icu_collections 2.2.0", + "icu_collections 2.3.0", "icu_locale_core", "icu_locale_data", - "icu_provider 2.2.0", - "potential_utf", - "tinystr 0.8.3", - "zerovec 0.11.6", + "icu_locale_fallback", + "icu_provider 2.3.1", + "tinystr 0.8.4", + "zerovec 0.11.8", ] [[package]] name = "icu_locale_core" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" dependencies = [ "displaydoc", - "litemap 0.8.2", + "litemap 0.8.3", "serde", - "tinystr 0.8.3", - "writeable 0.6.3", - "zerovec 0.11.6", + "tinystr 0.8.4", + "writeable 0.6.4", + "zerovec 0.11.8", ] [[package]] name = "icu_locale_data" -version = "2.2.0" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37d91460e362a5cf58907cd7ce871411775ee6294e49a5cc8e6cec16dfa75ea" + +[[package]] +name = "icu_locale_fallback" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "251af8e57c9400e3eb58242fe5b8b1152b2a64fdf4cf632f923c38ccee6f2fa9" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider 2.3.1", + "potential_utf", + "tinystr 0.8.4", + "zerovec 0.11.8", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fdcc9ac77c6d74ff5cf6e65ef3181d6af32003b16fce3a77fb451d2f695993" +checksum = "decf2a22ec8fa68f1a0c1129a3f8583f8f8bc24e8b9ccbe98ead99f62a4dc3a8" [[package]] name = "icu_locid" @@ -5211,46 +5023,47 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" dependencies = [ - "icu_collections 2.2.0", + "icu_collections 2.3.0", "icu_normalizer_data", "icu_properties", - "icu_provider 2.2.0", + "icu_provider 2.3.1", "smallvec 1.15.2", "utf16_iter", "utf8_iter", "write16", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] name = "icu_normalizer_data" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" [[package]] name = "icu_properties" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" dependencies = [ - "icu_collections 2.2.0", + "displaydoc", + "icu_collections 2.3.0", "icu_locale_core", "icu_properties_data", - "icu_provider 2.2.0", + "icu_provider 2.3.1", "zerotrie", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] name = "icu_properties_data" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" [[package]] name = "icu_provider" @@ -5271,19 +5084,19 @@ dependencies = [ [[package]] name = "icu_provider" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" dependencies = [ "displaydoc", "icu_locale_core", "serde", "stable_deref_trait", - "writeable 0.6.3", + "writeable 0.6.4", "yoke 0.8.3", "zerofrom", "zerotrie", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] @@ -5315,18 +5128,19 @@ dependencies = [ [[package]] name = "icu_segmenter" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0794db0b1a86193ac9c48768d0e6c52c54448e0870ad87907d456ee0dac964" +checksum = "82d07aafccd67af15d02512a6adf5896fbc5ed00f2e99b471d2efa14016db3db" dependencies = [ "core_maths", - "icu_collections 2.2.0", - "icu_locale", - "icu_provider 2.2.0", - "icu_segmenter_data 2.2.0", + "icu_collections 2.3.0", + "icu_locale_fallback", + "icu_provider 2.3.1", + "icu_segmenter_data 2.3.0", "potential_utf", + "smallvec 1.15.2", "utf8_iter", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] @@ -5337,15 +5151,9 @@ checksum = "a1e52775179941363cc594e49ce99284d13d6948928d8e72c755f55e98caa1eb" [[package]] name = "icu_segmenter_data" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a2c462a4d927d512f5f882a033ddd62f33a05bb9f230d98f736ac3dc85938f" - -[[package]] -name = "id-arena" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" +checksum = "ae293c039020f9ec10710af98d29ce6aa2051486638b49c9a6409f3b4a9e98ad" [[package]] name = "ident_case" @@ -5481,9 +5289,9 @@ dependencies = [ [[package]] name = "inotify" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "153be1941a183ec9ccd095ddbe17a8b8d435ef6c76e9e02451b933c3999af2c8" +checksum = "4cc00ea907cab49550b7da656f80ebb97be1b997d931fbcd28d39734e17ce592" dependencies = [ "bitflags 2.13.1", "inotify-sys", @@ -5801,9 +5609,9 @@ dependencies = [ [[package]] name = "jsonschema" -version = "0.49.9" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ec8a241beed129f06114aa68007e905ca350e7baeb6e17a7631bb7978d91b2" +checksum = "7bd2225bc56c338f18465ce618e5e56fff1295fcb0a0cb338b28010193f26949" dependencies = [ "ahash", "bytecount", @@ -5832,18 +5640,18 @@ dependencies = [ [[package]] name = "jsonschema-regex" -version = "0.49.9" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91994f45017ed5e66aa8e59b8415f4cb033a6380d7200387b7cf117595fbdf85" +checksum = "b11520e5257651f31068fa2c959ce28b09d8a217ffe42338bc27d690f06c0f8c" dependencies = [ "regex-syntax", ] [[package]] name = "jsonschema-value" -version = "0.49.9" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec7637f83e510868ae6ed625f7ebfbbde4554ee8ce49854caa5126a8b9b9ecb" +checksum = "ccefde026ba6e6e23002c4e1e087b5f411ef5bc90f3e7febb7cf3c498ca8b169" dependencies = [ "ahash", "bytecount", @@ -5950,9 +5758,9 @@ dependencies = [ [[package]] name = "libgit2-sys" -version = "0.18.7+1.9.6" +version = "0.18.8+1.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c7391e4b9f4ffab1a624223cc1d7385ff9a678f490768add717de7ea2f4d89" +checksum = "7f7c568b25d7489bc3fb2988ed69ab111d2944d2f5fec3d5c987fe545ea97b50" dependencies = [ "cc", "libc", @@ -5988,9 +5796,9 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2026a5056764a10b2bf5d56488cba40da507f5493a6a429340e2004d9ed085fa" +checksum = "28d0a00925a9f930d679b6789b721e3a7f9ed110f41b86d2497caa780c3a070a" dependencies = [ "libc", ] @@ -6084,9 +5892,9 @@ checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "litemap" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "litrs" @@ -6309,12 +6117,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" -[[package]] -name = "mach2" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dae608c151f68243f2b000364e1f7b186d9c29845f7d2d85bd31b9ad77ad552b" - [[package]] name = "macro_rules_attribute" version = "0.2.3" @@ -6449,15 +6251,6 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" -[[package]] -name = "memfd" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad38eb12aea514a0466ea40a80fd8cc83637065948eb4a426e4aa46261175227" -dependencies = [ - "rustix 1.1.4", -] - [[package]] name = "memmap2" version = "0.9.11" @@ -7264,18 +7057,6 @@ dependencies = [ "objc2-foundation", ] -[[package]] -name = "object" -version = "0.39.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" -dependencies = [ - "crc32fast", - "hashbrown 0.17.1", - "indexmap 2.14.0", - "memchr", -] - [[package]] name = "oci-spec" version = "0.6.7" @@ -7421,9 +7202,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "5.3.0" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7d950ca161dc355eaf28f82b11345ed76c6e1f6eb1f4f4479e0323b9e2fbd0e" +checksum = "8c7c9e0d9b23589f26070720bac724174bfec1083e82f7854cdd0267518343c0" dependencies = [ "num-traits", ] @@ -7781,9 +7562,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "plist" @@ -7890,18 +7671,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "postcard" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" -dependencies = [ - "cobs", - "embedded-io 0.4.0", - "embedded-io 0.6.1", - "serde", -] - [[package]] name = "postscript" version = "0.14.1" @@ -7910,13 +7679,13 @@ checksum = "78451badbdaebaf17f053fd9152b3ffb33b516104eacb45e7864aaa9c712f306" [[package]] name = "potential_utf" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ "serde_core", - "writeable 0.6.3", - "zerovec 0.11.6", + "writeable 0.6.4", + "zerovec 0.11.8", ] [[package]] @@ -8062,29 +7831,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" -[[package]] -name = "pulley-interpreter" -version = "47.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5c8c21ea032e4efbdf2d067dc45171779dbe0c8ecf20ef4a57efa7474f2b0a" -dependencies = [ - "cranelift-bitset", - "log", - "pulley-macros", - "wasmtime-internal-core", -] - -[[package]] -name = "pulley-macros" -version = "47.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f10925455d5dde962e3604eade797ba5488644c8ee14a44191e2f2b58980574" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "pulp" version = "0.21.5" @@ -8199,9 +7945,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.16" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4bfc015262b9df63c8845072ce59068853ff5872180c2ce2f13038b970e560" +checksum = "04759210543be93709136e28212294a659ef5001836ff4eab4d663e4529bba83" dependencies = [ "aws-lc-rs", "bytes", @@ -8367,9 +8113,9 @@ dependencies = [ [[package]] name = "rangemap" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "973443cf09a9c8656b574a866ab68dfa19f0867d0340648c7d2f6a71b8a8ea68" +checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" [[package]] name = "rapidhash" @@ -8524,18 +8270,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216e8f773d7923bcba9ceb86a86c93cabb3903a11872fc3f138c49630e50b96d" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9283685feec7d69af75fb0e858d5e7378f33fe4fc699383b2916ab9273e03c" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" dependencies = [ "proc-macro2", "quote", @@ -8544,9 +8290,9 @@ dependencies = [ [[package]] name = "referencing" -version = "0.49.9" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6efa2154ea6f5ce0fdecdd2a8d18f2fa1a39a8fbba91564f555a592e4dce8278" +checksum = "3b228fc6035ae00a9008ba156c0dfc98f0b6ebc5f3c8db7ac7006dcf8e56f15a" dependencies = [ "ahash", "fluent-uri", @@ -8559,21 +8305,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "regalloc2" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757712e8e61590d6d4f5d563483755538b5aa13467837a3b41cd9832509a7f85" -dependencies = [ - "allocator-api2 0.2.21", - "bumpalo", - "hashbrown 0.17.1", - "log", - "rustc-hash 2.1.3", - "serde", - "smallvec 1.15.2", -] - [[package]] name = "regex" version = "1.13.1" @@ -8684,7 +8415,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.4.15", + "h2 0.4.18", "http 1.5.0", "http-body 1.1.0", "http-body-util", @@ -8754,9 +8485,9 @@ dependencies = [ [[package]] name = "rmcp" -version = "3.1.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8dddc5b1924b9a59fba420166160ca2c4663a4e01803e52eda33070f56d63c8" +checksum = "1a15bc53261a9dc37e105df006e4656c598379a8f9581f8950debb130f27a7cf" dependencies = [ "async-trait", "base64 0.23.1", @@ -8764,6 +8495,7 @@ dependencies = [ "chrono", "futures", "http 1.5.0", + "indexmap 2.14.0", "oauth2", "pastey 0.2.3", "pin-project-lite", @@ -8785,11 +8517,11 @@ dependencies = [ [[package]] name = "rmcp-macros" -version = "3.1.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6898e24cd16342b59bfa8a53c2c04b9cf62fc8a2cfea57b9c038b09984bfc521" +checksum = "a85d45508e9b4ba024fe996c2638799635d75b6dd0ba8f32ccf08f8026f0c780" dependencies = [ - "darling 0.24.0", + "darling 0.24.1", "proc-macro2", "quote", "serde_json", @@ -8798,9 +8530,9 @@ dependencies = [ [[package]] name = "roaring" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dedc5658c6ecb3bdb5ef5f3295bb9253f42dcf3fd1402c03f6b1f7659c3c4a9" +checksum = "18bd8a37d17a58532776dcdf6041ce64929adca78e8489d5cacbafe99229d3e1" dependencies = [ "bytemuck", "byteorder", @@ -8808,9 +8540,9 @@ dependencies = [ [[package]] name = "rtrb" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ade083ccbb4bf536df69d1f6432cc23deb7acccff86b183f3923a6fd56a1153" +checksum = "fae8ee26b0371a29a77d2b2d6b3ae13aa81def6f9bf1b1b92a32d279a5e709b7" [[package]] name = "rust-stemmers" @@ -8822,12 +8554,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "rustc-demangle" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -8919,7 +8645,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.14", + "rustls-webpki 0.103.15", "subtle", "zeroize", ] @@ -8960,7 +8686,7 @@ dependencies = [ "rustls 0.23.43", "rustls-native-certs", "rustls-platform-verifier-android", - "rustls-webpki 0.103.14", + "rustls-webpki 0.103.15", "security-framework", "security-framework-sys", "webpki-root-certs", @@ -8985,9 +8711,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.14" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0527518605e68109d875e248ea259b6758801cf165e4b2c2733ae3b51f12535a" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ "aws-lc-rs", "ring", @@ -9152,10 +8878,6 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" -dependencies = [ - "serde", - "serde_core", -] [[package]] name = "seq-macro" @@ -9565,9 +9287,9 @@ checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" [[package]] name = "similar" -version = "3.1.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85ee016af5d736b69fc89e19254540fa4b5f5492853fb5503920f084011c78b6" +checksum = "4f66ca1f7aca2474dc10c942eb22feffc897735f54cd1db90138c2fddb490987" dependencies = [ "bstr", "unicode-segmentation", @@ -9623,9 +9345,6 @@ name = "smallvec" version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" -dependencies = [ - "serde", -] [[package]] name = "smallvec" @@ -9706,6 +9425,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e14297decde697ddf377c25752aead0927d5cfc89c2684d2af96901a4ceeea" +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" + [[package]] name = "spinning_top" version = "0.3.0" @@ -9768,6 +9493,16 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" +[[package]] +name = "string-interner" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23de088478b31c349c9ba67816fa55d9355232d63c3afea8bf513e31f0f1d2c0" +dependencies = [ + "hashbrown 0.15.5", + "serde", +] + [[package]] name = "string_cache" version = "0.8.9" @@ -10244,12 +9979,6 @@ dependencies = [ "xattr", ] -[[package]] -name = "target-lexicon" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" - [[package]] name = "tempfile" version = "3.27.0" @@ -10283,15 +10012,6 @@ dependencies = [ "new_debug_unreachable", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "text-splitter" version = "0.25.1" @@ -10320,8 +10040,8 @@ dependencies = [ "ahash", "auto_enums", "either", - "icu_provider 2.2.0", - "icu_segmenter 2.2.0", + "icu_provider 2.3.1", + "icu_segmenter 2.3.0", "itertools 0.14.0", "memchr", "pulldown-cmark", @@ -10445,13 +10165,13 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", "serde_core", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] @@ -11067,9 +10787,9 @@ dependencies = [ [[package]] name = "turso" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f9d85f8ae2bf9397e50e505b5d4b3c517c96687bc8a34d9927db739e23b967" +checksum = "f9491d7a80312c5abe66a4409e4dce02065503a235453c94b9e4133877e39ffc" dependencies = [ "thiserror 2.0.20", "tracing", @@ -11081,9 +10801,9 @@ dependencies = [ [[package]] name = "turso_core" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d21d176e7cc7dc607778f33b186ad981003969451ca0e3dca7494ea5ebb08a" +checksum = "7a833cc3bf8d4e6c101c504fa470f8ab4270c2202ff2591b61b2e373b4f20d9b" dependencies = [ "aegis", "aes 0.8.4", @@ -11106,8 +10826,6 @@ dependencies = [ "either", "fallible-iterator", "fastbloom", - "getrandom 0.2.17", - "getrandom 0.3.4", "hex", "icu_collator", "icu_locale", @@ -11134,7 +10852,6 @@ dependencies = [ "ryu", "serde_json", "shuttle", - "simdutf8", "simsimd", "smallvec 1.15.2", "strum 0.26.3", @@ -11155,9 +10872,9 @@ dependencies = [ [[package]] name = "turso_ext" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c1d40548fd1ddfa1e9486b864de3e625658a9c9013031a0d7f69ffbcab2773" +checksum = "e7452fe676450b6840e9eb80e512d14293265221154eba66aba3845dfc0d659f" dependencies = [ "chrono", "getrandom 0.4.3", @@ -11166,9 +10883,9 @@ dependencies = [ [[package]] name = "turso_macros" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20622919c832ac37fb4f784e450f5dfe10598ffbd42c735aa9b2e756c4044137" +checksum = "b2825eaa6b7b893693636947f988e252c1196393fa54d4b85637c70d616d92fa" dependencies = [ "proc-macro2", "quote", @@ -11177,9 +10894,9 @@ dependencies = [ [[package]] name = "turso_parser" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aad14b801fcb7ec1970f51c135e9ddcbbd79d7bce99b16eeb6a2213e536d478" +checksum = "f0e58d029f02e442df4be0b5036ce520b49c553505d9d52ef5a98fc4056e95b7" dependencies = [ "bitflags 2.13.1", "memchr", @@ -11192,9 +10909,9 @@ dependencies = [ [[package]] name = "turso_sdk_kit" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5ea9b302726356d3acefea2bcf9d82a2a02699d2dd02c9af374d63262b7d0e" +checksum = "18c1dc1c0304348c39b97bc6b27cdcb1d7292454ebd0de0f30b5ee3a4c61f9bb" dependencies = [ "bindgen", "env_logger", @@ -11209,9 +10926,9 @@ dependencies = [ [[package]] name = "turso_sdk_kit_macros" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eeffe0b97d9634278423c015635552d1985a875eb008efd19e7f063a985dc6e" +checksum = "c4708b5fe678b8730c85964e3d378f75e18c23c4409971360b2209f4e53e4956" dependencies = [ "proc-macro2", "quote", @@ -11220,9 +10937,9 @@ dependencies = [ [[package]] name = "turso_sync_engine" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dbcab3b5478ca099f4caec6fa1e01097fc44a2e9542748d4b330005397b8074" +checksum = "ce8f03e430240d590d209ac874db52773b7382c627cd604a685affde77622b09" dependencies = [ "base64 0.22.1", "bytes", @@ -11243,9 +10960,9 @@ dependencies = [ [[package]] name = "turso_sync_sdk_kit" -version = "0.8.0-pre.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93641c07b2f6b3b89e57e4ca815d6f31eb7913336923ccc358078d9c6313cde3" +checksum = "d48cb47d056c3ec567745761fa6f832358ca30ef9eb0435fdcfb77c558e70089" dependencies = [ "bindgen", "env_logger", @@ -11616,9 +11333,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.24.0" +version = "1.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3923a6f5c4c6382e0b653c4117f48d631ea17f38ed86e2a828e6f7412f5239" +checksum = "2cefc03fd367c0c6d4305de1b312cf00248c4114f4a0418ce6a6af769e3b0bd9" dependencies = [ "getrandom 0.4.3", "js-sys", @@ -11795,12 +11512,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.252.0" +version = "0.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8185ae345fa5687c054626ff9a50e7089797a343d9904d1dc9820eb4c4d3196f" +checksum = "7d8ad9f0a39050867bda22e6486c316e2e52d20a42154d5bc433934bf738d085" dependencies = [ "leb128fmt", - "wasmparser", + "wasmparser 0.257.1", ] [[package]] @@ -11830,240 +11547,94 @@ dependencies = [ ] [[package]] -name = "wasmparser" -version = "0.252.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3eb099dcadcde5be9eef55e3a337128efd4e44b4c93122487e4d2e4e1c6627c" -dependencies = [ - "bitflags 2.13.1", - "hashbrown 0.17.1", - "indexmap 2.14.0", - "semver", - "serde", -] - -[[package]] -name = "wasmprinter" -version = "0.252.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7142797de29b35ab8dbf15c00f55fda75d409da4c423a8ab8bd6b667a785824b" -dependencies = [ - "anyhow", - "termcolor", - "wasmparser", -] - -[[package]] -name = "wasmtime" -version = "47.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80ca6098e0d4d06886d91d7f2cc3cb6623eb583c4c0ab3c89cbfb6098c8586c" -dependencies = [ - "addr2line", - "async-trait", - "bitflags 2.13.1", - "bumpalo", - "cc", - "cfg-if 1.0.4", - "encoding_rs", - "futures", - "libc", - "log", - "mach2", - "memfd", - "object", - "once_cell", - "postcard", - "pulley-interpreter", - "rustix 1.1.4", - "semver", - "serde", - "serde_derive", - "smallvec 1.15.2", - "target-lexicon", - "wasmparser", - "wasmtime-environ", - "wasmtime-internal-component-macro", - "wasmtime-internal-component-util", - "wasmtime-internal-core", - "wasmtime-internal-cranelift", - "wasmtime-internal-fiber", - "wasmtime-internal-jit-debug", - "wasmtime-internal-jit-icache-coherence", - "wasmtime-internal-unwinder", - "wasmtime-internal-versioned-export-macros", - "windows-sys 0.61.2", -] - -[[package]] -name = "wasmtime-environ" -version = "47.0.3" +name = "wasmi" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134f9d136d29c76f6c1b4c9b468e97a2efc38c7d49fd188e39b64870b2fea701" +checksum = "2300d0f78cba12f14e29e8dd157ea64050c0a688179aefdb2050105805594a0c" dependencies = [ - "anyhow", - "cpp_demangle", - "cranelift-bforest", - "cranelift-bitset", - "cranelift-entity", - "gimli", - "hashbrown 0.17.1", - "indexmap 2.14.0", - "log", - "object", - "postcard", - "rustc-demangle", - "semver", - "serde", - "serde_derive", - "sha2 0.10.9", - "smallvec 1.15.2", - "target-lexicon", - "wasm-encoder", - "wasmparser", - "wasmprinter", - "wasmtime-internal-component-util", - "wasmtime-internal-core", + "spin", + "wasmi_collections", + "wasmi_core", + "wasmi_ir", + "wasmparser 0.239.0", + "wat", ] [[package]] -name = "wasmtime-internal-component-macro" -version = "47.0.3" +name = "wasmi_collections" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf7b91fed3fc34781d57f9c6654ea2513bf0a99f7b0b0523c00de1e6efebe1c" +checksum = "f8a8c42a2a76148d43097b1d7cc2a5bf33d5c23bd4dd69015fc887e311767884" dependencies = [ - "anyhow", - "proc-macro2", - "quote", - "syn 2.0.119", - "wasmtime-internal-component-util", - "wasmtime-internal-wit-bindgen", - "wit-parser", + "string-interner", ] [[package]] -name = "wasmtime-internal-component-util" -version = "47.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc8a678149885cae00289f806fbe74c7863084cf74cace0b8dc73602279400e1" - -[[package]] -name = "wasmtime-internal-core" -version = "47.0.3" +name = "wasmi_core" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0092c4b9d070ac5e278b6d0db10f5e71214190f0347ca57502b4692f796321" +checksum = "9013136083d988725953390bf668b64b7a218fabf26f8b913bbc59546b97ee27" dependencies = [ - "hashbrown 0.17.1", "libm", - "serde", -] - -[[package]] -name = "wasmtime-internal-cranelift" -version = "47.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6851ebc9e03cab23d9821d2b2505d380bdfe38f35ccec945247b05274d85c98b" -dependencies = [ - "cfg-if 1.0.4", - "cranelift-codegen", - "cranelift-control", - "cranelift-entity", - "cranelift-frontend", - "cranelift-native", - "gimli", - "itertools 0.14.0", - "log", - "object", - "pulley-interpreter", - "smallvec 1.15.2", - "target-lexicon", - "thiserror 2.0.20", - "wasmparser", - "wasmtime-environ", - "wasmtime-internal-core", - "wasmtime-internal-unwinder", - "wasmtime-internal-versioned-export-macros", ] [[package]] -name = "wasmtime-internal-fiber" -version = "47.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b26da6d5f60d4c438da70bba3553fe810a840533a64156be287dca2081c6991" -dependencies = [ - "cc", - "cfg-if 1.0.4", - "libc", - "rustix 1.1.4", - "wasmtime-environ", - "wasmtime-internal-versioned-export-macros", - "windows-sys 0.61.2", -] - -[[package]] -name = "wasmtime-internal-jit-debug" -version = "47.0.3" +name = "wasmi_ir" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed621ba25d7bf78b7edd7b4749abbb27c2e5cdba836c9504a424ee74b6c23149" +checksum = "ba1fa003f79156f406d62ef0e1464dc03e11ace37170e9fa7524299a75ad8f68" dependencies = [ - "cc", - "wasmtime-internal-versioned-export-macros", + "wasmi_core", ] [[package]] -name = "wasmtime-internal-jit-icache-coherence" -version = "47.0.3" +name = "wasmparser" +version = "0.239.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5684ba160951baad06a725696f3c590e2fb0e8067c2aebee27bf7f9259058e85" +checksum = "8c9d90bb93e764f6beabf1d02028c70a2156a6583e63ac4218dd07ef733368b0" dependencies = [ - "cfg-if 1.0.4", - "libc", - "wasmtime-internal-core", - "windows-sys 0.61.2", + "bitflags 2.13.1", + "indexmap 2.14.0", ] [[package]] -name = "wasmtime-internal-unwinder" -version = "47.0.3" +name = "wasmparser" +version = "0.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112eead527bffa8ff0646a11fb4339a9d52ddd1da2b9a6fce4aff84c815dd94f" +checksum = "d92fc335fb6d48f46bda1d8b26b69e28320c15ac3272208333833d6e217e2b4a" dependencies = [ - "cfg-if 1.0.4", - "cranelift-codegen", - "log", - "object", - "wasmtime-environ", + "bitflags 2.13.1", + "indexmap 2.14.0", + "semver", ] [[package]] -name = "wasmtime-internal-versioned-export-macros" -version = "47.0.3" +name = "wast" +version = "257.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "153592e0bed824fc13c6696203fa1bd7bd20eb355316475e39a55f081ef80eca" +checksum = "3c416ee8044cf88c5280e3d87c322b009525eb25142cf7428f0a90ea88febc3b" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", + "bumpalo", + "leb128fmt", + "memchr", + "unicode-width 0.2.2", + "wasm-encoder", ] [[package]] -name = "wasmtime-internal-wit-bindgen" -version = "47.0.3" +name = "wat" +version = "1.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c456ad6e81e0f46abfeca43687d18ea15e289c395b262ea6e0023e2682e088be" +checksum = "672e5495f00c5fc6c6b502205bae4708aa4dd13d969754438743afe0a8af0f1d" dependencies = [ - "anyhow", - "bitflags 2.13.1", - "heck", - "indexmap 2.14.0", - "wit-parser", + "wast", ] [[package]] name = "wayland-backend" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016ccf01d1c58b6f8999612813e17c9b2390f7d70671428869913310f83f54b8" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" dependencies = [ "cc", "downcast-rs 1.2.1", @@ -12720,25 +12291,6 @@ version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" -[[package]] -name = "wit-parser" -version = "0.252.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4266bea110371c620ccf3201c5023676046bc4556e5c7cfb5d500bda5ebc162d" -dependencies = [ - "anyhow", - "hashbrown 0.17.1", - "id-arena", - "indexmap 2.14.0", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-ident", - "wasmparser", -] - [[package]] name = "wl-clipboard-rs" version = "0.9.3" @@ -12771,9 +12323,9 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "writeable" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "wyz" @@ -12993,9 +12545,9 @@ checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" [[package]] name = "yaml_serde" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad7a8266fc7ce9d77db272ca5b40b704a1753e2a2e2ab7b1f2da22672941bf93" +checksum = "33b729a08a9a6be689bbad3e2bf8015926db54b6622cc89c3a5f7dc174b9e918" dependencies = [ "indexmap 2.14.0", "itoa", @@ -13100,14 +12652,14 @@ checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" [[package]] name = "zerotrie" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" dependencies = [ "displaydoc", "yoke 0.8.3", "zerofrom", - "zerovec 0.11.6", + "zerovec 0.11.8", ] [[package]] @@ -13118,26 +12670,26 @@ checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" dependencies = [ "yoke 0.7.5", "zerofrom", - "zerovec-derive 0.10.3", + "zerovec-derive 0.10.4", ] [[package]] name = "zerovec" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" dependencies = [ "serde", "yoke 0.8.3", "zerofrom", - "zerovec-derive 0.11.3", + "zerovec-derive 0.11.6", ] [[package]] name = "zerovec-derive" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +checksum = "3e3c6377872d72510393f688a555d7097b0f741995c7a00f0407f786dd486b2d" dependencies = [ "proc-macro2", "quote", @@ -13146,13 +12698,13 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0f7b1956..a216d0c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,14 @@ [workspace] resolver = "2" members = ["crates/coding-agent", "crates/elph-agent", "crates/elph-ai", "crates/floppy", "crates/rendown"] -exclude = ["crates/control-plane", "crates/elph-cron", "crates/elph-sandbox", "crates/ext-hello", "vendor/iocraft"] +exclude = [ + "crates/control-plane", + "crates/elph-cron", + "crates/elph-sandbox", + "crates/ext-hello", + "crates/elph-extension-pdk", + "vendor/iocraft", +] [workspace.package] homepage = "https://elph.space" @@ -13,7 +20,7 @@ edition = "2024" linker_messages = "allow" [workspace.dependencies] -aes-gcm = "0.11.0" +aes-gcm = "0.11.1" agent-client-protocol = { version = "2.0.0", features = [ "unstable_protocol_v2", "unstable_elicitation", @@ -22,12 +29,12 @@ agent-client-protocol = { version = "2.0.0", features = [ anstyle = "1.0.14" anstyle-syntect = "1.0.5" anyhow = "1.0.104" -aws-config = "1.10.1" -aws-sdk-bedrockruntime = "1.139.0" -aws-smithy-runtime-api = "1.14.0" +aws-config = "1.11.0" +aws-sdk-bedrockruntime = "1.141.0" +aws-smithy-runtime-api = "1.15.0" aws-smithy-types = "1.6.2" -ast-grep-core = "0.45.0" -ast-grep-language = { version = "0.45.0", default-features = false, features = [ +ast-grep-core = "0.45.1" +ast-grep-language = { version = "0.45.1", default-features = false, features = [ "tree-sitter-c", "tree-sitter-cpp", "tree-sitter-c-sharp", @@ -40,7 +47,7 @@ ast-grep-language = { version = "0.45.0", default-features = false, features = [ "tree-sitter-typescript", ] } astral-tl = "0.7.11" -async-trait = "0.1" +async-trait = "0.1.92" axum = { version = "0.8.9", default-features = false, features = ["http1", "json", "matched-path", "tokio"] } backon = "1.6.0" base64 = "0.23.1" @@ -61,7 +68,7 @@ fastrace-reqwest = "0.3.0" fff-search = "0.10.5" figlet-rs = "1.0.0" floppy = { path = "crates/floppy", version = "0.0.1" } -futures = "0.3.33" +futures = "0.3.34" git2 = { version = "0.21.0", features = ["cred"] } governor = "0.10.4" html-escape = "0.2.15" @@ -72,7 +79,7 @@ ignore = "0.4.33" image = "0.25.10" inquire = "0.9.4" iocraft = "0.8.4" -jsonschema = "0.49.7" +jsonschema = "0.50.0" kalid = "0.1.0" hkdf = "0.13.0" libc = "0.2.189" @@ -88,7 +95,7 @@ logforth = { version = "0.30.1", features = [ "layout-text", "starter-log", ] } -macro_rules_attribute = "0.2.0" +macro_rules_attribute = "0.2.3" memchr = "2.8.3" mermaid-text = "0.57.0" memorable-ids = "0.1.1" @@ -101,7 +108,7 @@ quick-xml = { version = "0.41.0", features = ["serialize"] } rand = "0.10.2" regex = "1.13.1" reqwest = { version = "0.13.4", default-features = false, features = ["json", "rustls", "stream"] } -rmcp = { version = "3.1.0", features = [ +rmcp = { version = "3.1.4", features = [ "auth", "client", "transport-child-process", @@ -120,9 +127,9 @@ rendown = { path = "crates/rendown", version = "0.0.1" } shell-use = { version = "0.0.1-beta.6" } smol = "2.0.2" smol-macros = "0.1.1" -yaml_serde = "0.10.6" +yaml_serde = "0.10.7" sha2 = "0.11.0" -similar = { version = "3.1.2", features = ["inline", "unicode"] } +similar = { version = "3.2.0", features = ["inline", "unicode"] } supports-color = "3.0.2" syntect = { version = "5.3.0", default-features = false, features = [ "default-syntaxes", @@ -138,15 +145,16 @@ tokio-tungstenite = { version = "0.30.0", default-features = false, features = [ tokio-util = "0.7.19" toml = "1.1.4" toon-format = { version = "0.5.0", default-features = false } -turso = { version = "0.8.0-pre.4", default-features = false, features = ["fts"] } -two-face = { version = "0.5.1", default-features = false, features = ["syntect-fancy"] } +turso = { version = "0.7.2", default-features = false, features = ["fts"] } +two-face = { version = "0.5.2", default-features = false, features = ["syntect-fancy"] } unicode-linebreak = "0.1.5" unicode-segmentation = "1.13.3" unicode-width = "0.2.2" url = "2.5.8" urlencoding = "2.1.3" walkdir = "2.5.0" -wasmtime = { version = "47.0.3", default-features = false, features = ["component-model", "async", "cranelift", "std"] } +wasmi = "1.1.0" +wat = "1.257.1" webpki-roots = "1.0.9" zstd = "0.13.3" diff --git a/Makefile b/Makefile index d3f61c2c..bed699cb 100644 --- a/Makefile +++ b/Makefile @@ -238,6 +238,7 @@ clean: ## Clean build artifacts and caches @find crates -type f -name '*_gen.rs' -delete @rm -fr crates/elph-ai/models/.cache @$(CARGO) clean + @rm -f Cargo.lock # ─── Space reclamation ────────────────────────────────────────────────────────── # diff --git a/crates/coding-agent/Cargo.toml b/crates/coding-agent/Cargo.toml index d40aff21..f17b6484 100644 --- a/crates/coding-agent/Cargo.toml +++ b/crates/coding-agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "elph" -version = "0.0.1" +version = "0.0.0" license = "Apache-2.0" description = "Minimalist AI agent companion for coding" keywords = ["ai", "agent", "cli", "coding", "llm"] diff --git a/crates/coding-agent/src/agent/run_mode.rs b/crates/coding-agent/src/agent/run_mode.rs index e3c85dd8..c840602c 100644 --- a/crates/coding-agent/src/agent/run_mode.rs +++ b/crates/coding-agent/src/agent/run_mode.rs @@ -116,6 +116,7 @@ pub async fn run_non_interactive(options: RunModeOptions<'_>) -> Result result, diff --git a/crates/coding-agent/src/agent/runtime.rs b/crates/coding-agent/src/agent/runtime.rs index 985fbe54..6cc129fb 100644 --- a/crates/coding-agent/src/agent/runtime.rs +++ b/crates/coding-agent/src/agent/runtime.rs @@ -52,6 +52,8 @@ pub struct CreateSessionOptions<'a> { /// Whether the session runs in headless mode (`elph run`). Relaxes some tool /// defaults (e.g. no background-task timeout by default). pub headless: bool, + /// WASM extension host; bound to the harness after restore when present. + pub extension_host: Option<&'a crate::extensions::ExtensionHost>, } pub async fn create_coding_session_with_events( @@ -522,6 +524,10 @@ pub async fn create_coding_session_with_events( log::warn!("automatic memory hooks: {err:#}"); } + if let Some(host) = options.extension_host { + host.bind_to_harness(&harness).await; + } + // Wire the work tracker: increment on every successful mutating tool call so // `todo_write` can enforce that `completed` items actually did real work. let work_tracker_for_hook = work_tracker.clone(); diff --git a/crates/coding-agent/src/cli/extensions.rs b/crates/coding-agent/src/cli/extensions.rs index 40bc2538..b231d262 100644 --- a/crates/coding-agent/src/cli/extensions.rs +++ b/crates/coding-agent/src/cli/extensions.rs @@ -10,7 +10,7 @@ use crate::platform::{AppPaths, EXIT_ERROR, EXIT_SUCCESS, ExitCode, Paths}; #[derive(Parser, Default)] #[command( name = "extensions", - about = "Manage WASM extensions (wasmtime + Component Model)", + about = "Manage WASM extensions (wasmi core Wasm)", color = clap::ColorChoice::Auto )] pub struct ExtensionsArgs { @@ -22,7 +22,7 @@ pub struct ExtensionsArgs { pub enum ExtensionsCommands { /// List installed extensions List, - /// Install an extension bundle from a local directory (contains extension.toml + component wasm) + /// Install an extension bundle from a local directory (extension.toml + plugin.wasm) Install { /// Local path to extension bundle directory source: String, @@ -91,7 +91,7 @@ fn list_extensions(host: &ExtensionHost) -> ExitCode { } }; let settings = ExtensionHost::load_settings(&paths); - let manifests = host.registry().read().extensions(); + let manifests = host.registry().extensions(); let mut out = String::new(); if manifests.is_empty() { @@ -128,7 +128,6 @@ fn list_extensions(host: &ExtensionHost) -> ExitCode { for cmd in host .registry() - .read() .commands() .iter() .filter(|cmd| cmd.extension == manifest.name) diff --git a/crates/coding-agent/src/extensions/mod.rs b/crates/coding-agent/src/extensions/mod.rs index 63f39d10..ff9fc978 100644 --- a/crates/coding-agent/src/extensions/mod.rs +++ b/crates/coding-agent/src/extensions/mod.rs @@ -1,11 +1,13 @@ -//! Extension host wiring for the Elph CLI (wasmtime + Component Model). +//! Extension host wiring for the Elph CLI (wasmi core Wasm). use std::path::Path; use std::sync::Arc; use anyhow::Result; +use elph_agent::harness::AgentHarness; use elph_agent::plugins::global_extensions_dir; use elph_agent::plugins::{ExtensionCommand, ExtensionRegistry, ExtensionSlashResult, ExtensionsSettings}; +use elph_agent::session::types::{HasSessionId, SessionStorage}; use parking_lot::RwLock; use crate::platform::{AppPaths, Paths}; @@ -13,17 +15,23 @@ use crate::platform::{AppPaths, Paths}; /// Shared extension registry for slash dispatch and `/reload`. #[derive(Clone, Default)] pub struct ExtensionHost { - registry: Arc>, + registry: Arc, settings: Arc>, } +impl std::fmt::Debug for ExtensionHost { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ExtensionHost").finish_non_exhaustive() + } +} + impl ExtensionHost { pub fn new() -> Self { Self::default() } - pub fn registry(&self) -> Arc> { - self.registry.clone() + pub fn registry(&self) -> Arc { + Arc::clone(&self.registry) } pub fn load_settings(paths: &Paths) -> ExtensionsSettings { @@ -47,7 +55,7 @@ impl ExtensionHost { pub fn reload(&self, paths: &Paths, host_settings: &crate::platform::Settings) -> Result<()> { let settings = host_settings.extensions_settings(); *self.settings.write() = settings.clone(); - self.registry.read().load( + self.registry.load( paths.config_dir(), &paths.project_elph_dir(), &settings, @@ -56,11 +64,19 @@ impl ExtensionHost { } pub fn commands(&self) -> Vec { - self.registry.read().commands() + self.registry.commands() } pub fn dispatch_slash(&self, name: &str, args: &str) -> Option> { - self.registry.read().dispatch_slash(name, args) + self.registry.dispatch_slash(name, args) + } + + pub async fn bind_to_harness(&self, harness: &AgentHarness) + where + S: SessionStorage + Clone + Send + Sync + 'static, + S::Metadata: HasSessionId + Send + Sync, + { + self.registry.bind_to_harness(harness).await; } pub fn ensure_dirs(paths: &Paths) -> Result<()> { @@ -69,7 +85,7 @@ impl ExtensionHost { } pub fn install_bundle(&self, source: &Path, paths: &Paths, force: bool) -> Result { - let dest = self.registry.read().install_bundle(source, paths.config_dir(), force)?; + let dest = self.registry.install_bundle(source, paths.config_dir(), force)?; let host = crate::platform::Settings::load(paths).unwrap_or_else(|_| crate::platform::Settings::defaults()); self.reload(paths, &host)?; Ok(dest) diff --git a/crates/coding-agent/src/platform/acp/session.rs b/crates/coding-agent/src/platform/acp/session.rs index ceb32fb7..1ff866e5 100644 --- a/crates/coding-agent/src/platform/acp/session.rs +++ b/crates/coding-agent/src/platform/acp/session.rs @@ -289,6 +289,7 @@ pub(super) async fn open_or_create( preloaded_resources: None, defer_mcp_load: true, headless: true, + extension_host: None, }), ) .await diff --git a/crates/coding-agent/src/tui/mod.rs b/crates/coding-agent/src/tui/mod.rs index 9f5dce20..df847abb 100644 --- a/crates/coding-agent/src/tui/mod.rs +++ b/crates/coding-agent/src/tui/mod.rs @@ -118,7 +118,7 @@ pub async fn run_tui(options: TuiOptions) -> Result<()> { let prompt_templates = bootstrap_resources.resources.prompt_templates.clone(); let skills = bootstrap_resources.resources.skills.clone(); let slash_commands = slash_commands_for_palette_with( - Some(&extension_host.registry().read()), + Some(extension_host.registry().as_ref()), Some(&prompt_templates), Some(&skills), settings.resources.enable_skill_commands, @@ -146,6 +146,7 @@ pub async fn run_tui(options: TuiOptions) -> Result<()> { .is_none() .then(|| format!("{boot_provider}/{boot_model_id}")), preloaded_resources: bootstrap_resources, + extension_host: extension_host.clone(), }; let model_label = model_footer_label(Some(&boot_provider), Some(&boot_model_id)); diff --git a/crates/coding-agent/src/tui/shell/keys.rs b/crates/coding-agent/src/tui/shell/keys.rs index d8dfa6e0..e80ead6b 100644 --- a/crates/coding-agent/src/tui/shell/keys.rs +++ b/crates/coding-agent/src/tui/shell/keys.rs @@ -3279,8 +3279,7 @@ pub(crate) fn handle_shell_key(ctx: ShellCtx, event: TerminalEvent) { } }; - let extension_registry = extension_host_for_keys.registry(); - let ext_registry = extension_registry.read(); + let ext_registry = extension_host_for_keys.registry(); let templates = prompt_templates.read().clone(); let loaded_skills = skills.read().clone(); @@ -3290,7 +3289,7 @@ pub(crate) fn handle_shell_key(ctx: ShellCtx, event: TerminalEvent) { let outcome = handle_slash_submit(SlashContext { input: &slash_input, - extensions: Some(&ext_registry), + extensions: Some(ext_registry.as_ref()), prompt_templates: Some(&templates), skills: Some(&loaded_skills), agent_session: agent_session.clone(), diff --git a/crates/coding-agent/src/tui/shell/tick.rs b/crates/coding-agent/src/tui/shell/tick.rs index 1d7f0ed3..063857ef 100644 --- a/crates/coding-agent/src/tui/shell/tick.rs +++ b/crates/coding-agent/src/tui/shell/tick.rs @@ -230,9 +230,8 @@ pub(crate) async fn shell_tick_loop(ctx: ShellCtx) { skills.set(new_skills); { let ext_registry = extension_host_for_loop.registry(); - let reg = ext_registry.read(); slash_commands.set(slash_commands_for_palette_with( - Some(®), + Some(ext_registry.as_ref()), Some(&prompt_templates.read()), Some(&skills.read()), settings.resources.enable_skill_commands, @@ -248,6 +247,7 @@ pub(crate) async fn shell_tick_loop(ctx: ShellCtx) { resume_id: resume_id_req, model_override: boot.ok().map(|(provider, model_id)| format!("{provider}/{model_id}")), preloaded_resources: loaded, + extension_host: extension_host_for_loop.clone(), }; bootstrap_config.set(Some(new_config)); } @@ -294,7 +294,7 @@ pub(crate) async fn shell_tick_loop(ctx: ShellCtx) { .map(|s| s.resources.enable_skill_commands) .unwrap_or(true); slash_commands.set(slash_commands_for_palette_with( - Some(&extension_host_for_palette.registry().read()), + Some(extension_host_for_palette.registry().as_ref()), Some(&templates), Some(&loaded_skills), enable_skill_commands, diff --git a/crates/coding-agent/src/tui/shell/view.rs b/crates/coding-agent/src/tui/shell/view.rs index ef17411f..d5740bde 100644 --- a/crates/coding-agent/src/tui/shell/view.rs +++ b/crates/coding-agent/src/tui/shell/view.rs @@ -1508,8 +1508,7 @@ pub(crate) fn build_shell_view( }; let is_slash = prefix_kind == InputPrefixKind::Slash; - let extension_registry = extension_host.registry(); - let ext_registry = extension_registry.read(); + let ext_registry = extension_host.registry(); let templates = prompt_templates.read().clone(); let loaded_skills = skills.read().clone(); let paths_snapshot = paths.read().clone(); @@ -1520,7 +1519,7 @@ pub(crate) fn build_shell_view( let outcome = handle_slash_submit(SlashContext { input: &slash_input, - extensions: Some(&ext_registry), + extensions: Some(ext_registry.as_ref()), prompt_templates: Some(&templates), skills: Some(&loaded_skills), agent_session: agent_session.clone(), diff --git a/crates/coding-agent/src/tui/startup.rs b/crates/coding-agent/src/tui/startup.rs index 88dffb1e..11caf274 100644 --- a/crates/coding-agent/src/tui/startup.rs +++ b/crates/coding-agent/src/tui/startup.rs @@ -44,6 +44,7 @@ pub struct TuiBootstrapConfig { /// the session restores its own model from the tree. pub model_override: Option, pub preloaded_resources: LoadResourcesResult, + pub extension_host: crate::extensions::ExtensionHost, } /// Bootstrap phases surfaced in the status row and transcript. @@ -347,6 +348,7 @@ pub async fn bootstrap_agent_session(config: &TuiBootstrapConfig) -> Result(caller: &Caller<'_, T>) -> Result { + caller + .get_export("memory") + .and_then(|export| export.into_memory()) + .context("guest did not export memory") +} + +pub fn read_blob(caller: &Caller<'_, T>, ptr: i32, len: i32) -> Result> { + ensure!(ptr >= 0 && len >= 0, "negative pointer or length"); + let len = len as usize; + ensure!(len <= MAX_BLOB, "blob exceeds {MAX_BLOB} bytes"); + let memory = memory_from_caller(caller)?; + let mut buf = vec![0u8; len]; + memory + .read(caller, ptr as usize, &mut buf) + .map_err(|error| anyhow::anyhow!("read guest memory: {error}"))?; + Ok(buf) +} + +pub fn read_utf8(caller: &Caller<'_, T>, ptr: i32, len: i32) -> Result { + let bytes = read_blob(caller, ptr, len)?; + String::from_utf8(bytes).context("guest string is not UTF-8") +} + +pub fn read_len_prefixed(store: C, memory: Memory, ptr: i32) -> Result> { + ensure!(ptr > 0, "null guest pointer"); + let mut header = [0u8; 4]; + memory + .read(&store, ptr as usize, &mut header) + .map_err(|error| anyhow::anyhow!("read length prefix: {error}"))?; + let len = u32::from_le_bytes(header) as usize; + ensure!(len <= MAX_BLOB, "blob exceeds {MAX_BLOB} bytes"); + let mut buf = vec![0u8; len]; + memory + .read(&store, ptr as usize + 4, &mut buf) + .map_err(|error| anyhow::anyhow!("read payload: {error}"))?; + Ok(buf) +} + +pub fn write_guest_bytes( + store: &mut impl AsContextMut, + memory: Memory, + alloc: &wasmi::TypedFunc, + bytes: &[u8], +) -> Result { + ensure!(bytes.len() <= MAX_BLOB, "blob exceeds {MAX_BLOB} bytes"); + let ptr = alloc + .call(&mut *store, bytes.len() as i32) + .map_err(|error| anyhow::anyhow!("elph_alloc: {error}"))?; + if ptr == 0 { + bail!("elph_alloc returned null"); + } + memory + .write(&mut *store, ptr as usize, bytes) + .map_err(|error| anyhow::anyhow!("write guest memory: {error}"))?; + Ok(ptr) +} diff --git a/crates/elph-agent/src/plugins/host.rs b/crates/elph-agent/src/plugins/host.rs index 2ed7b651..1318b556 100644 --- a/crates/elph-agent/src/plugins/host.rs +++ b/crates/elph-agent/src/plugins/host.rs @@ -1,101 +1,315 @@ -//! wasmtime Component Model host for extension guests. +//! wasmi core-Wasm host for extension guests. -use std::path::Path; +use std::sync::Arc; -use anyhow::Result; -use anyhow::{anyhow, ensure}; -use wasmtime::component::{Component, HasSelf, Linker}; -use wasmtime::error::Context; -use wasmtime::{Config, Engine, Store}; +use anyhow::{Context, Result, anyhow, bail, ensure}; +use parking_lot::Mutex; +use serde_json::Value; +use wasmi::{Caller, Config, Engine, Linker, Module, Store}; -use super::types::{ExtensionCommand, ExtensionManifest, ExtensionSlashResult}; +use super::abi::{read_len_prefixed, read_utf8, write_guest_bytes}; +use super::types::{ExtensionCommand, ExtensionManifest, ExtensionSlashResult, ExtensionToolSpec}; +use super::ui::{DenyUi, ExtensionUi}; -wasmtime::component::bindgen!({ - path: "wit", - world: "guest", -}); +const FUEL_PER_CALL: u64 = 10_000_000; -struct ExtensionState; +pub struct PluginState { + pub ui: Arc, + pub commands: Vec, + pub tools: Vec, + pub events: Vec, + pub extension_name: String, +} -impl elph::extension::types::Host for ExtensionState {} +struct InstanceState { + store: Store, + instance: wasmi::Instance, +} pub struct LoadedExtension { pub manifest: ExtensionManifest, #[allow(dead_code)] pub root: std::path::PathBuf, - engine: Engine, - component: Component, - linker: Linker, + inner: Mutex, } impl LoadedExtension { - pub fn load(root: &Path, manifest: ExtensionManifest) -> Result { - let wasm_path = manifest.component_path(root); - ensure!(wasm_path.is_file(), "component not found: {}", wasm_path.display()); + pub fn load( + engine: &Engine, + root: &std::path::Path, + manifest: ExtensionManifest, + ui: Arc, + ) -> Result { + let wasm_path = manifest.wasm_path(root); + ensure!(wasm_path.is_file(), "wasm not found: {}", wasm_path.display()); + let bytes = std::fs::read(&wasm_path).with_context(|| format!("read {}", wasm_path.display()))?; + Self::load_bytes(engine, root.to_path_buf(), manifest, ui, &bytes) + } - let mut config = Config::new(); - config.wasm_component_model(true); - let engine = Engine::new(&config) - .context("create wasmtime engine") - .map_err(|e| anyhow!("{e}"))?; + pub fn load_bytes( + engine: &Engine, + root: std::path::PathBuf, + manifest: ExtensionManifest, + ui: Arc, + bytes: &[u8], + ) -> Result { + if looks_like_wasi_module(bytes) { + bail!( + "extension '{}' imports WASI; Elph guests must target wasm32-unknown-unknown without WASI", + manifest.name + ); + } - let component = Component::from_file(&engine, &wasm_path) - .with_context(|| format!("load component {}", wasm_path.display())) - .map_err(|e| anyhow!("{e}"))?; + let module = Module::new(engine, bytes).map_err(|error| anyhow!("parse wasm: {error}"))?; + let mut linker = Linker::new(engine); + define_host_imports(&mut linker)?; - let mut linker = Linker::new(&engine); - Guest::add_to_linker::<_, HasSelf<_>>(&mut linker, |state| state) - .context("link extension world") - .map_err(|e| anyhow!("{e}"))?; + let state = PluginState { + ui, + commands: Vec::new(), + tools: Vec::new(), + events: Vec::new(), + extension_name: manifest.name.clone(), + }; + let mut store = Store::new(engine, state); + if store.set_fuel(FUEL_PER_CALL).is_err() { + log::debug!("wasmi fuel metering unavailable"); + } + + let instance = linker + .instantiate_and_start(&mut store, &module) + .map_err(|error| anyhow!("instantiate: {error}"))?; + + let init = instance + .get_typed_func::<(), ()>(&store, "elph_init") + .map_err(|error| anyhow!("missing elph_init: {error}"))?; + let _ = store.set_fuel(FUEL_PER_CALL); + init.call(&mut store, ()) + .map_err(|error| anyhow!("elph_init: {error}"))?; Ok(Self { manifest, - root: root.to_path_buf(), - engine, - component, - linker, + root, + inner: Mutex::new(InstanceState { store, instance }), }) } - pub fn list_commands(&self) -> Result> { - let mut store = Store::new(&self.engine, ExtensionState); - let bindings = Guest::instantiate(&mut store, &self.component, &self.linker) - .context("instantiate extension component") - .map_err(|e| anyhow!("{e}"))?; - let instance = bindings.elph_extension_extension(); - let commands = instance - .call_list_commands(&mut store) - .context("extension list-commands") - .map_err(|e| anyhow!("{e}"))?; - Ok(commands - .into_iter() - .map(|cmd| ExtensionCommand { - extension: self.manifest.name.clone(), - name: cmd.name, - description: cmd.description, - }) - .collect()) + pub fn commands(&self) -> Vec { + self.inner.lock().store.data().commands.clone() + } + + pub fn tools(&self) -> Vec { + self.inner.lock().store.data().tools.clone() + } + + pub fn subscribed(&self, event: &str) -> bool { + self.inner.lock().store.data().events.iter().any(|name| name == event) } pub fn execute_command(&self, name: &str, args: &str) -> Result { - let mut store = Store::new(&self.engine, ExtensionState); - let bindings = Guest::instantiate(&mut store, &self.component, &self.linker) - .context("instantiate extension component") - .map_err(|e| anyhow!("{e}"))?; - let instance = bindings.elph_extension_extension(); - match instance - .call_execute_command(&mut store, name, args) - .context("extension execute-command") - .map_err(|e| anyhow!("{e}"))? - { - Ok(result) => Ok(ExtensionSlashResult { - message: result.message, - is_error: result.is_error, - }), - Err(message) => Ok(ExtensionSlashResult { - message, + let mut inner = self.inner.lock(); + let _ = inner.store.set_fuel(FUEL_PER_CALL); + let memory = inner + .instance + .get_memory(&inner.store, "memory") + .context("guest memory")?; + let alloc = inner + .instance + .get_typed_func::(&inner.store, "elph_alloc") + .map_err(|error| anyhow!("elph_alloc: {error}"))?; + let execute = inner + .instance + .get_typed_func::<(i32, i32, i32, i32), i32>(&inner.store, "elph_execute_command") + .map_err(|error| anyhow!("elph_execute_command: {error}"))?; + + let name_ptr = write_guest_bytes(&mut inner.store, memory, &alloc, name.as_bytes())?; + let args_ptr = write_guest_bytes(&mut inner.store, memory, &alloc, args.as_bytes())?; + let result_ptr = execute + .call(&mut inner.store, (name_ptr, name.len() as i32, args_ptr, args.len() as i32)) + .map_err(|error| anyhow!("execute_command: {error}"))?; + if result_ptr == 0 { + return Ok(ExtensionSlashResult { + message: "extension returned null".into(), is_error: true, - }), + }); + } + let payload = read_len_prefixed(&inner.store, memory, result_ptr)?; + serde_json::from_slice(&payload).context("parse slash result") + } + + pub fn execute_tool(&self, name: &str, tool_call_id: &str, input: &Value) -> Result { + let mut inner = self.inner.lock(); + let _ = inner.store.set_fuel(FUEL_PER_CALL); + let memory = inner + .instance + .get_memory(&inner.store, "memory") + .context("guest memory")?; + let alloc = inner + .instance + .get_typed_func::(&inner.store, "elph_alloc") + .map_err(|error| anyhow!("elph_alloc: {error}"))?; + let execute = inner + .instance + .get_typed_func::<(i32, i32), i32>(&inner.store, "elph_execute_tool") + .map_err(|error| anyhow!("elph_execute_tool: {error}"))?; + let body = serde_json::json!({ + "name": name, + "tool_call_id": tool_call_id, + "input": input, + }); + let bytes = serde_json::to_vec(&body)?; + let ptr = write_guest_bytes(&mut inner.store, memory, &alloc, &bytes)?; + let result_ptr = execute + .call(&mut inner.store, (ptr, bytes.len() as i32)) + .map_err(|error| anyhow!("execute_tool: {error}"))?; + if result_ptr == 0 { + bail!("elph_execute_tool returned null"); + } + let payload = read_len_prefixed(&inner.store, memory, result_ptr)?; + serde_json::from_slice(&payload).context("parse tool result") + } + + pub fn on_event(&self, event: &str, payload: &Value) -> Result> { + if !self.subscribed(event) { + return Ok(None); } + let mut inner = self.inner.lock(); + let _ = inner.store.set_fuel(FUEL_PER_CALL); + let memory = inner + .instance + .get_memory(&inner.store, "memory") + .context("guest memory")?; + let alloc = inner + .instance + .get_typed_func::(&inner.store, "elph_alloc") + .map_err(|error| anyhow!("elph_alloc: {error}"))?; + let on_event = inner + .instance + .get_typed_func::<(i32, i32), i32>(&inner.store, "elph_on_event") + .map_err(|error| anyhow!("elph_on_event: {error}"))?; + let body = serde_json::json!({ "event": event, "payload": payload }); + let bytes = serde_json::to_vec(&body)?; + let ptr = write_guest_bytes(&mut inner.store, memory, &alloc, &bytes)?; + let result_ptr = on_event + .call(&mut inner.store, (ptr, bytes.len() as i32)) + .map_err(|error| anyhow!("on_event: {error}"))?; + if result_ptr == 0 { + return Ok(None); + } + let payload = read_len_prefixed(&inner.store, memory, result_ptr)?; + if payload.is_empty() || payload == b"null" { + return Ok(None); + } + let value: Value = serde_json::from_slice(&payload).context("parse event result")?; + if value.is_null() { Ok(None) } else { Ok(Some(value)) } + } +} + +pub fn new_engine() -> Result { + let mut config = Config::default(); + config.consume_fuel(true); + Ok(Engine::new(&config)) +} + +pub fn default_ui() -> Arc { + Arc::new(DenyUi) +} + +fn define_host_imports(linker: &mut Linker) -> Result<()> { + linker + .func_wrap( + "elph", + "register_command", + |mut caller: Caller<'_, PluginState>, ptr: i32, len: i32| { + if let Ok(raw) = read_utf8(&caller, ptr, len) + && let Ok(value) = serde_json::from_str::(&raw) + { + let name = value.get("name").and_then(Value::as_str).unwrap_or("").to_string(); + let description = value + .get("description") + .and_then(Value::as_str) + .unwrap_or("") + .to_string(); + if !name.is_empty() { + let extension = caller.data().extension_name.clone(); + caller.data_mut().commands.push(ExtensionCommand { + extension, + name, + description, + }); + } + } + }, + ) + .map_err(|error| anyhow!("link register_command: {error}"))?; + + linker + .func_wrap( + "elph", + "register_tool", + |mut caller: Caller<'_, PluginState>, ptr: i32, len: i32| { + if let Ok(raw) = read_utf8(&caller, ptr, len) + && let Ok(spec) = serde_json::from_str::(&raw) + && !spec.name.is_empty() + { + caller.data_mut().tools.push(spec); + } + }, + ) + .map_err(|error| anyhow!("link register_tool: {error}"))?; + + linker + .func_wrap( + "elph", + "subscribe", + |mut caller: Caller<'_, PluginState>, ptr: i32, len: i32| { + if let Ok(raw) = read_utf8(&caller, ptr, len) + && let Ok(events) = serde_json::from_str::>(&raw) + { + caller.data_mut().events.extend(events); + } + }, + ) + .map_err(|error| anyhow!("link subscribe: {error}"))?; + + linker + .func_wrap("elph", "notify", |caller: Caller<'_, PluginState>, ptr: i32, len: i32| { + if let Ok(raw) = read_utf8(&caller, ptr, len) + && let Ok(value) = serde_json::from_str::(&raw) + { + let message = value.get("message").and_then(Value::as_str).unwrap_or(""); + let level = value.get("level").and_then(Value::as_str).unwrap_or("info"); + caller.data().ui.notify(message, level); + } + }) + .map_err(|error| anyhow!("link notify: {error}"))?; + + linker + .func_wrap( + "elph", + "confirm", + |caller: Caller<'_, PluginState>, ptr: i32, len: i32| -> i32 { + let Ok(raw) = read_utf8(&caller, ptr, len) else { + return 0; + }; + let Ok(value) = serde_json::from_str::(&raw) else { + return 0; + }; + let title = value.get("title").and_then(Value::as_str).unwrap_or(""); + let body = value.get("body").and_then(Value::as_str).unwrap_or(""); + i32::from(caller.data().ui.confirm(title, body)) + }, + ) + .map_err(|error| anyhow!("link confirm: {error}"))?; + + Ok(()) +} + +fn looks_like_wasi_module(bytes: &[u8]) -> bool { + // Cheap scan: WASI preview1 modules import from `wasi_snapshot_preview1`. + let hay = b"wasi_snapshot_preview1"; + bytes.windows(hay.len()).any(|window| window == hay) || { + let hay2 = b"wasi:"; + bytes.windows(hay2.len()).any(|window| window == hay2) } } diff --git a/crates/elph-agent/src/plugins/mod.rs b/crates/elph-agent/src/plugins/mod.rs index c79086e5..89333cf4 100644 --- a/crates/elph-agent/src/plugins/mod.rs +++ b/crates/elph-agent/src/plugins/mod.rs @@ -1,16 +1,19 @@ -//! WASM extension host (wasmtime + Component Model). +//! WASM extension host (wasmi interpreter, core Wasm ABI). //! //! Pi-compatible discovery: -//! - `~/.elph/extensions//extension.toml` + component wasm +//! - `~/.elph/extensions//extension.toml` + core wasm //! - `/.elph/extensions//...` (after project trust) +mod abi; mod discovery; mod host; mod registry; mod types; +mod ui; pub use discovery::{ discover_manifests, extension_roots, global_extensions_dir, load_manifest, project_extensions_dir, }; pub use registry::ExtensionRegistry; -pub use types::{ExtensionCommand, ExtensionManifest, ExtensionSlashResult, ExtensionsSettings}; +pub use types::{ExtensionCommand, ExtensionManifest, ExtensionSlashResult, ExtensionToolSpec, ExtensionsSettings}; +pub use ui::{DenyUi, ExtensionUi}; diff --git a/crates/elph-agent/src/plugins/registry.rs b/crates/elph-agent/src/plugins/registry.rs index 532a377c..c602202e 100644 --- a/crates/elph-agent/src/plugins/registry.rs +++ b/crates/elph-agent/src/plugins/registry.rs @@ -1,28 +1,58 @@ -//! Extension registry — discovery, load, slash dispatch. +//! Extension registry — discovery, load, slash dispatch, harness bind. use std::path::{Path, PathBuf}; +use std::sync::Arc; use anyhow::{Context, Result}; use parking_lot::RwLock; +use serde_json::Value; +use wasmi::Engine; use super::discovery::{discover_manifests, extension_roots}; -use super::host::LoadedExtension; -use super::types::{ExtensionCommand, ExtensionManifest, ExtensionSlashResult, ExtensionsSettings}; +use super::host::{LoadedExtension, default_ui, new_engine}; +use super::types::{ExtensionCommand, ExtensionManifest, ExtensionSlashResult, ExtensionToolSpec, ExtensionsSettings}; +use super::ui::ExtensionUi; +use crate::agent::harness::AgentHarness; +use crate::session::types::{HasSessionId, SessionStorage}; +use crate::tools::simple_tool; +use crate::tools::types::{AgentTool, AgentToolResult}; +use elph_ai::Tool; + +struct RegistryState { + engine: Engine, + ui: Arc, + extensions: Vec>, + commands: Vec, +} -#[derive(Default)] pub struct ExtensionRegistry { inner: RwLock, } -#[derive(Default)] -struct RegistryState { - extensions: Vec, - commands: Vec, +impl Default for ExtensionRegistry { + fn default() -> Self { + Self::new() + } } impl ExtensionRegistry { pub fn new() -> Self { - Self::default() + let engine = new_engine().unwrap_or_else(|error| { + log::error!("wasmi engine: {error:#}"); + Engine::default() + }); + Self { + inner: RwLock::new(RegistryState { + engine, + ui: default_ui(), + extensions: Vec::new(), + commands: Vec::new(), + }), + } + } + + pub fn set_ui(&self, ui: Arc) { + self.inner.write().ui = ui; } pub fn load( @@ -34,6 +64,10 @@ impl ExtensionRegistry { ) -> Result<()> { let roots = extension_roots(config_dir, project_elph_dir, settings, include_project); let manifests = discover_manifests(&roots)?; + let (engine, ui) = { + let state = self.inner.read(); + (state.engine.clone(), Arc::clone(&state.ui)) + }; let mut extensions = Vec::new(); let mut commands = Vec::new(); @@ -42,25 +76,17 @@ impl ExtensionRegistry { log::debug!("extension skipped name={}", manifest.name); continue; } - let loaded = match LoadedExtension::load(&root, manifest) - .with_context(|| format!("load extension {}", root.display())) - { - Ok(loaded) => loaded, - Err(error) => { - log::warn!("extension load failed root={}: {error:#}", root.display()); - return Err(error); - } - }; - let mut ext_commands = loaded - .list_commands() - .with_context(|| format!("list commands for extension {}", loaded.manifest.name))?; - commands.append(&mut ext_commands); - extensions.push(loaded); + let loaded = LoadedExtension::load(&engine, &root, manifest, Arc::clone(&ui)) + .with_context(|| format!("load extension {}", root.display()))?; + commands.extend(loaded.commands()); + extensions.push(Arc::new(loaded)); } commands.sort_by(|a, b| a.name.cmp(&b.name)); log::info!("extensions loaded count={} commands={}", extensions.len(), commands.len()); - *self.inner.write() = RegistryState { extensions, commands }; + let mut state = self.inner.write(); + state.extensions = extensions; + state.commands = commands; Ok(()) } @@ -73,7 +99,16 @@ impl ExtensionRegistry { .read() .extensions .iter() - .map(|e| e.manifest.clone()) + .map(|ext| ext.manifest.clone()) + .collect() + } + + pub fn tool_specs(&self) -> Vec<(String, ExtensionToolSpec)> { + self.inner + .read() + .extensions + .iter() + .flat_map(|ext| ext.tools().into_iter().map(|spec| (ext.manifest.name.clone(), spec))) .collect() } @@ -84,13 +119,196 @@ impl ExtensionRegistry { .extensions .iter() .find(|ext| ext.manifest.name == owner.extension)?; + let extension = Arc::clone(extension); + let command = owner.name.clone(); + drop(state); Some( extension - .execute_command(&owner.name, args) - .with_context(|| format!("extension /{} from {}", name, owner.extension)), + .execute_command(&command, args) + .with_context(|| format!("extension /{name}")), ) } + pub fn dispatch_event(&self, event: &str, payload: &Value) -> Option { + let extensions: Vec> = self.inner.read().extensions.clone(); + let mut last = None; + for ext in extensions { + if !ext.subscribed(event) { + continue; + } + match ext.on_event(event, payload) { + Ok(Some(value)) => last = Some(value), + Ok(None) => {} + Err(error) => log::warn!("extension event {event} failed: {error:#}"), + } + } + last + } + + pub fn execute_tool(&self, extension: &str, name: &str, tool_call_id: &str, input: &Value) -> Result { + let loaded = { + let state = self.inner.read(); + state + .extensions + .iter() + .find(|ext| ext.manifest.name == extension) + .cloned() + .with_context(|| format!("extension not loaded: {extension}"))? + }; + loaded.execute_tool(name, tool_call_id, input) + } + + pub fn agent_tools(&self) -> Vec { + let loaded = self.inner.read().extensions.clone(); + let mut tools = Vec::new(); + for ext in loaded { + for spec in ext.tools() { + let label = if spec.label.is_empty() { + spec.name.clone() + } else { + spec.label.clone() + }; + let parameters = if spec.parameters.is_null() { + serde_json::json!({ "type": "object", "properties": {} }) + } else { + spec.parameters.clone() + }; + let tool_name = spec.name.clone(); + let ext = Arc::clone(&ext); + tools.push(simple_tool( + Tool { + name: spec.name.clone(), + constrained_sampling: None, + description: spec.description, + parameters, + }, + label, + move |id, args| { + let ext = Arc::clone(&ext); + let tool_name = tool_name.clone(); + Box::pin(async move { + let value = tokio::task::spawn_blocking(move || ext.execute_tool(&tool_name, &id, &args)) + .await + .map_err(|error| anyhow::anyhow!("join: {error}"))??; + Ok(tool_result_from_json(value)) + }) + }, + )); + } + } + tools + } + + pub async fn bind_to_harness(&self, harness: &AgentHarness) + where + S: SessionStorage + Clone + Send + Sync + 'static, + S::Metadata: HasSessionId + Send + Sync, + { + let extra = self.agent_tools(); + if !extra.is_empty() { + let mut tools = harness.get_tools().await; + let mut active = harness + .get_active_tools() + .await + .into_iter() + .map(|t| t.name().to_string()) + .collect::>(); + for tool in extra { + if !active.iter().any(|n| n == tool.name()) { + active.push(tool.name().to_string()); + } + tools.push(tool); + } + if let Err(error) = harness.set_tools(tools, Some(active)).await { + log::warn!("extension tools: {error:#}"); + } + } + + let guests = self.inner.read().extensions.clone(); + + harness + .on_tool_call({ + let guests = guests.clone(); + move |event| { + let guests = guests.clone(); + let payload = serde_json::json!({ + "tool_name": event.tool_name, + "tool_call_id": event.tool_call_id, + "input": event.input, + }); + async move { + let result = tokio::task::spawn_blocking(move || fanout_event(&guests, "tool_call", &payload)) + .await + .ok() + .flatten(); + result.and_then(|value| { + let block = value.get("block").and_then(Value::as_bool).unwrap_or(false); + if !block { + return None; + } + Some(crate::agent::harness::types::ToolCallHookResult { + block: true, + reason: value.get("reason").and_then(Value::as_str).map(str::to_string), + }) + }) + } + } + }) + .await; + + harness + .on_tool_result({ + let guests = guests.clone(); + move |event| { + let guests = guests.clone(); + let payload = serde_json::json!({ + "tool_name": event.tool_name, + "tool_call_id": event.tool_call_id, + "input": event.input, + "is_error": event.is_error, + }); + async move { + let result = + tokio::task::spawn_blocking(move || fanout_event(&guests, "tool_result", &payload)) + .await + .ok() + .flatten(); + result.map(|value| crate::agent::harness::types::ToolResultPatch { + is_error: value.get("is_error").and_then(Value::as_bool), + ..Default::default() + }) + } + } + }) + .await; + + harness + .on_before_agent_start({ + let guests = guests.clone(); + move |event| { + let guests = guests.clone(); + let payload = serde_json::json!({ + "prompt": event.prompt, + "system_prompt": event.system_prompt, + }); + async move { + let result = + tokio::task::spawn_blocking(move || fanout_event(&guests, "before_agent_start", &payload)) + .await + .ok() + .flatten(); + result.map(|value| crate::agent::harness::types::BeforeAgentStartResult { + messages: None, + system_prompt: value.get("system_prompt").and_then(Value::as_str).map(str::to_string), + }) + } + } + }) + .await; + + let _ = self.dispatch_event("session_start", &serde_json::json!({})); + } + pub fn install_bundle(&self, source_dir: &Path, config_dir: &Path, force: bool) -> Result { let manifest_path = source_dir.join("extension.toml"); let manifest = super::discovery::load_manifest(&manifest_path)?; @@ -107,6 +325,37 @@ impl ExtensionRegistry { } } +fn fanout_event(extensions: &[Arc], event: &str, payload: &Value) -> Option { + let mut last = None; + for ext in extensions { + if !ext.subscribed(event) { + continue; + } + match ext.on_event(event, payload) { + Ok(Some(value)) => last = Some(value), + Ok(None) => {} + Err(error) => log::warn!("extension event {event} failed: {error:#}"), + } + } + last +} + +fn tool_result_from_json(value: Value) -> AgentToolResult { + if let Some(message) = value.get("message").and_then(Value::as_str) { + return AgentToolResult::text(message); + } + if let Some(text) = value + .get("content") + .and_then(Value::as_array) + .and_then(|arr| arr.first()) + .and_then(|item| item.get("text")) + .and_then(Value::as_str) + { + return AgentToolResult::text(text); + } + AgentToolResult::text(value.to_string()) +} + fn copy_dir_recursive(src: &Path, dst: &Path) -> Result<()> { std::fs::create_dir_all(dst)?; for entry in std::fs::read_dir(src).with_context(|| format!("read dir {}", src.display()))? { diff --git a/crates/elph-agent/src/plugins/types.rs b/crates/elph-agent/src/plugins/types.rs index 15397acf..702c8c70 100644 --- a/crates/elph-agent/src/plugins/types.rs +++ b/crates/elph-agent/src/plugins/types.rs @@ -1,10 +1,11 @@ -//! Extension manifest and command descriptors. +//! Extension manifest, command descriptors, and JSON ABI payloads. use std::path::PathBuf; use serde::{Deserialize, Serialize}; +use serde_json::Value; -/// On-disk manifest for a WASM component extension (`extension.toml`). +/// On-disk manifest for a core Wasm extension (`extension.toml`). #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct ExtensionManifest { pub name: String, @@ -12,8 +13,8 @@ pub struct ExtensionManifest { pub version: String, #[serde(default)] pub description: String, - /// Path to the component `.wasm` file, relative to the manifest directory. - pub component: String, + /// Path to the core `.wasm` file, relative to the manifest directory. + pub wasm: String, #[serde(default = "default_true")] pub enabled: bool, #[serde(default)] @@ -25,13 +26,13 @@ fn default_true() -> bool { } impl ExtensionManifest { - pub fn component_path(&self, root: &std::path::Path) -> PathBuf { - root.join(&self.component) + pub fn wasm_path(&self, root: &std::path::Path) -> PathBuf { + root.join(&self.wasm) } } /// A slash command contributed by an extension. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ExtensionCommand { pub extension: String, pub name: String, @@ -39,13 +40,25 @@ pub struct ExtensionCommand { } /// Result of executing an extension slash command. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ExtensionSlashResult { pub message: String, pub is_error: bool, } -/// Persisted enable/disable state (`~/.elph/extensions.json`). +/// Tool advertised during `elph_init`. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ExtensionToolSpec { + pub name: String, + #[serde(default)] + pub label: String, + #[serde(default)] + pub description: String, + #[serde(default)] + pub parameters: Value, +} + +/// Persisted enable/disable state (`~/.elph/extensions.json` / settings). #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct ExtensionsSettings { diff --git a/crates/elph-agent/src/plugins/ui.rs b/crates/elph-agent/src/plugins/ui.rs new file mode 100644 index 00000000..65f5a43c --- /dev/null +++ b/crates/elph-agent/src/plugins/ui.rs @@ -0,0 +1,25 @@ +//! UI hooks the host injects into extension guests (`notify` / `confirm`). + +/// Callbacks from Wasm host functions into the product UI. +/// +/// Headless / print / JSON modes should deny `confirm` and treat `notify` as a log line. +pub trait ExtensionUi: Send + Sync { + fn notify(&self, message: &str, level: &str); + /// Return `true` if the user approved. Default implementations must deny. + fn confirm(&self, title: &str, body: &str) -> bool; +} + +/// Safe default: log notifications, deny confirmations. +#[derive(Debug, Default, Clone, Copy)] +pub struct DenyUi; + +impl ExtensionUi for DenyUi { + fn notify(&self, message: &str, level: &str) { + log::info!("extension notify level={level} {message}"); + } + + fn confirm(&self, title: &str, body: &str) -> bool { + log::info!("extension confirm denied (no UI) title={title} body={body}"); + false + } +} diff --git a/crates/elph-agent/tests/plugins.rs b/crates/elph-agent/tests/plugins.rs index 6ee4b078..a75e9490 100644 --- a/crates/elph-agent/tests/plugins.rs +++ b/crates/elph-agent/tests/plugins.rs @@ -1,7 +1,6 @@ -//! Extension discovery and manifest parsing. +//! Extension discovery, ABI, and event dispatch. -use elph_agent::plugins::{ExtensionRegistry, ExtensionsSettings}; -use elph_agent::plugins::{discover_manifests, load_manifest}; +use elph_agent::plugins::{ExtensionRegistry, ExtensionsSettings, load_manifest}; use std::path::PathBuf; #[test] @@ -14,13 +13,13 @@ fn parses_extension_manifest() { name = "demo" version = "1.0.0" description = "Demo extension" -component = "component.wasm" +wasm = "plugin.wasm" "#, ) .expect("write manifest"); let manifest = load_manifest(&manifest_path).expect("parse manifest"); assert_eq!(manifest.name, "demo"); - assert_eq!(manifest.component, "component.wasm"); + assert_eq!(manifest.wasm, "plugin.wasm"); } #[test] @@ -28,14 +27,14 @@ fn discovers_manifests_under_extension_roots() { let root = tempfile::tempdir().expect("tempdir"); let ext_dir = root.path().join("demo"); std::fs::create_dir_all(&ext_dir).expect("mkdir"); - std::fs::write(ext_dir.join("extension.toml"), "name = \"demo\"\ncomponent = \"c.wasm\"\n").expect("write"); - let found = discover_manifests(&[PathBuf::from(root.path())]).expect("discover"); + std::fs::write(ext_dir.join("extension.toml"), "name = \"demo\"\nwasm = \"p.wasm\"\n").expect("write"); + let found = elph_agent::plugins::discover_manifests(&[PathBuf::from(root.path())]).expect("discover"); assert_eq!(found.len(), 1); assert_eq!(found[0].1.name, "demo"); } #[test] -fn registry_loads_without_wasm_components() { +fn registry_loads_without_wasm() { let root = tempfile::tempdir().expect("tempdir"); let config = root.path().join("config"); let project = root.path().join("project"); @@ -47,3 +46,126 @@ fn registry_loads_without_wasm_components() { .expect("load empty registry"); assert!(registry.commands().is_empty()); } + +#[test] +fn rejects_wasi_import_module() { + let wasm = wat::parse_str( + r#"(module + (import "wasi_snapshot_preview1" "fd_write" (func (param i32 i32 i32 i32) (result i32))) + (memory (export "memory") 1) + )"#, + ) + .expect("wat"); + let dir = tempfile::tempdir().expect("tempdir"); + let config = dir.path().join("config"); + let dest = config.join("extensions/wasi-ext"); + std::fs::create_dir_all(&dest).expect("dest"); + std::fs::write(dest.join("plugin.wasm"), wasm).expect("write wasm"); + std::fs::write(dest.join("extension.toml"), "name = \"wasi-ext\"\nwasm = \"plugin.wasm\"\n").expect("toml"); + let project = dir.path().join("project/.elph"); + std::fs::create_dir_all(&project).expect("project"); + + let registry = ExtensionRegistry::new(); + let err = registry + .load(&config, &project, &ExtensionsSettings::default(), false) + .expect_err("wasi module must fail"); + let msg = format!("{err:#}"); + assert!(msg.contains("WASI") || msg.contains("wasi"), "{msg}"); +} + +#[test] +fn wat_guest_registers_command_and_blocks_tool() { + let cmd_json = r#"{"name":"hello","description":"Greet"}"#; + let sub_json = r#"["tool_call"]"#; + let slash_json = r#"{"message":"Hello, Ada!","is_error":false}"#; + let block_json = r#"{"block":true,"reason":"blocked"}"#; + + let wat = format!( + r#" +(module + (import "elph" "register_command" (func $register_command (param i32 i32))) + (import "elph" "subscribe" (func $subscribe (param i32 i32))) + (memory (export "memory") 1) + (global $heap (mut i32) (i32.const 1024)) + + (data (i32.const 16) "{cmd}") + (data (i32.const 80) "{sub}") + (data (i32.const 128) "{slash}") + (data (i32.const 256) "{block}") + + (func $alloc (export "elph_alloc") (param $n i32) (result i32) + (local $p i32) + (local.set $p (global.get $heap)) + (global.set $heap (i32.add (local.get $p) (local.get $n))) + (local.get $p) + ) + (func (export "elph_dealloc") (param i32 i32)) + + (func (export "elph_init") + (call $register_command (i32.const 16) (i32.const {cmd_len})) + (call $subscribe (i32.const 80) (i32.const {sub_len})) + ) + + (func $lenpref (param $src i32) (param $n i32) (result i32) + (local $p i32) + (local.set $p (call $alloc (i32.add (local.get $n) (i32.const 4)))) + (i32.store (local.get $p) (local.get $n)) + (memory.copy (i32.add (local.get $p) (i32.const 4)) (local.get $src) (local.get $n)) + (local.get $p) + ) + + (func (export "elph_execute_command") (param i32 i32 i32 i32) (result i32) + (call $lenpref (i32.const 128) (i32.const {slash_len})) + ) + + (func (export "elph_on_event") (param i32 i32) (result i32) + (call $lenpref (i32.const 256) (i32.const {block_len})) + ) + + (func (export "elph_execute_tool") (param i32 i32) (result i32) + (i32.const 0) + ) +) +"#, + cmd = cmd_json.replace('"', "\\\""), + sub = sub_json.replace('"', "\\\""), + slash = slash_json.replace('"', "\\\""), + block = block_json.replace('"', "\\\""), + cmd_len = cmd_json.len(), + sub_len = sub_json.len(), + slash_len = slash_json.len(), + block_len = block_json.len(), + ); + + let wasm = wat::parse_str(&wat).expect("wat"); + let dir = tempfile::tempdir().expect("tempdir"); + let config = dir.path().join("config"); + let dest = config.join("extensions/demo"); + std::fs::create_dir_all(&dest).expect("dest"); + std::fs::write(dest.join("plugin.wasm"), wasm).expect("wasm"); + std::fs::write( + dest.join("extension.toml"), + "name = \"demo\"\nversion = \"1\"\ndescription = \"fixture\"\nwasm = \"plugin.wasm\"\n", + ) + .expect("toml"); + let project = dir.path().join("project/.elph"); + std::fs::create_dir_all(&project).expect("project"); + + let registry = ExtensionRegistry::new(); + registry + .load(&config, &project, &ExtensionsSettings::default(), false) + .expect("load"); + let commands = registry.commands(); + assert_eq!(commands.len(), 1); + assert_eq!(commands[0].name, "hello"); + + let result = registry.dispatch_slash("hello", "Ada").expect("dispatch").expect("ok"); + assert!(!result.is_error); + assert!(result.message.contains("Ada"), "{}", result.message); + + let blocked = registry.dispatch_event( + "tool_call", + &serde_json::json!({ "tool_name": "shell_exec", "input": { "command": "rm -rf /" } }), + ); + assert_eq!(blocked.and_then(|v| v.get("block").cloned()), Some(serde_json::json!(true))); +} diff --git a/crates/elph-agent/wit/extension.wit b/crates/elph-agent/wit/extension.wit deleted file mode 100644 index d8a9cbc5..00000000 --- a/crates/elph-agent/wit/extension.wit +++ /dev/null @@ -1,29 +0,0 @@ -package elph:extension@0.1.0; - -/// Shared types between host and guest extensions. -interface types { - record command-desc { - name: string, - description: string, - } - - record slash-result { - message: string, - is-error: bool, - } -} - -/// Minimal Pi-compatible surface: slash commands (registerCommand). -interface extension { - use types.{command-desc, slash-result}; - - /// Return all slash commands contributed by this component. - list-commands: func() -> list; - - /// Execute a registered slash command. `name` is without leading `/`. - execute-command: func(name: string, args: string) -> result; -} - -world guest { - export extension; -} \ No newline at end of file diff --git a/crates/elph-extension-pdk/Cargo.toml b/crates/elph-extension-pdk/Cargo.toml new file mode 100644 index 00000000..a0dbb87e --- /dev/null +++ b/crates/elph-extension-pdk/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "elph-extension-pdk" +version = "0.1.0" +edition = "2024" +publish = false +description = "Guest helpers for Elph wasmi extensions (wasm32-unknown-unknown)" + +[dependencies] +serde = { version = "1", features = ["derive"] } +serde_json = "1" diff --git a/crates/elph-extension-pdk/src/lib.rs b/crates/elph-extension-pdk/src/lib.rs new file mode 100644 index 00000000..e7cead2e --- /dev/null +++ b/crates/elph-extension-pdk/src/lib.rs @@ -0,0 +1,99 @@ +//! Guest-side helpers for Elph core-Wasm extensions. + +use std::alloc::{Layout, alloc, dealloc}; +use std::slice; + +#[link(wasm_import_module = "elph")] +unsafe extern "C" { + #[link_name = "register_command"] + fn host_register_command(ptr: i32, len: i32); + #[link_name = "register_tool"] + fn host_register_tool(ptr: i32, len: i32); + #[link_name = "subscribe"] + fn host_subscribe(ptr: i32, len: i32); + #[link_name = "notify"] + fn host_notify(ptr: i32, len: i32); + #[link_name = "confirm"] + fn host_confirm(ptr: i32, len: i32) -> i32; +} + +#[unsafe(no_mangle)] +pub extern "C" fn elph_alloc(size: i32) -> i32 { + if size <= 0 { + return 0; + } + let Ok(layout) = Layout::from_size_align(size as usize, 8) else { + return 0; + }; + let ptr = unsafe { alloc(layout) }; + ptr as i32 +} + +#[unsafe(no_mangle)] +pub extern "C" fn elph_dealloc(ptr: i32, size: i32) { + if ptr == 0 || size <= 0 { + return; + } + if let Ok(layout) = Layout::from_size_align(size as usize, 8) { + unsafe { dealloc(ptr as *mut u8, layout) }; + } +} + +fn call_host(f: unsafe extern "C" fn(i32, i32), json: &str) { + unsafe { f(json.as_ptr() as i32, json.len() as i32) }; +} + +pub fn register_command(name: &str, description: &str) { + let body = serde_json::json!({ "name": name, "description": description }).to_string(); + call_host(host_register_command, &body); +} + +pub fn register_tool(name: &str, label: &str, description: &str, parameters: serde_json::Value) { + let body = serde_json::json!({ + "name": name, + "label": label, + "description": description, + "parameters": parameters, + }) + .to_string(); + call_host(host_register_tool, &body); +} + +pub fn subscribe(events: &[&str]) { + let body = serde_json::to_string(events).unwrap_or_else(|_| "[]".into()); + call_host(host_subscribe, &body); +} + +pub fn notify(message: &str, level: &str) { + let body = serde_json::json!({ "message": message, "level": level }).to_string(); + call_host(host_notify, &body); +} + +pub fn confirm(title: &str, body: &str) -> bool { + let json = serde_json::json!({ "title": title, "body": body }).to_string(); + unsafe { host_confirm(json.as_ptr() as i32, json.len() as i32) != 0 } +} + +/// Encode a JSON value as length-prefixed bytes in guest memory; returns pointer. +pub fn return_json(value: &serde_json::Value) -> i32 { + let bytes = serde_json::to_vec(value).unwrap_or_else(|_| b"null".to_vec()); + let total = bytes.len() + 4; + let ptr = elph_alloc(total as i32); + if ptr == 0 { + return 0; + } + unsafe { + let dest = slice::from_raw_parts_mut(ptr as *mut u8, total); + dest[..4].copy_from_slice(&(bytes.len() as u32).to_le_bytes()); + dest[4..].copy_from_slice(&bytes); + } + ptr +} + +pub fn read_utf8(ptr: i32, len: i32) -> String { + if ptr == 0 || len <= 0 { + return String::new(); + } + let bytes = unsafe { slice::from_raw_parts(ptr as *const u8, len as usize) }; + String::from_utf8_lossy(bytes).into_owned() +} diff --git a/crates/ext-hello/Cargo.toml b/crates/ext-hello/Cargo.toml index fa89d333..998f03ac 100644 --- a/crates/ext-hello/Cargo.toml +++ b/crates/ext-hello/Cargo.toml @@ -8,11 +8,5 @@ publish = false crate-type = ["cdylib"] [dependencies] -wit-bindgen = "0.36.0" - -[package.metadata.component] -package = "elph:extension-say-hello" - -[package.metadata.component.target] -path = "../elph-agent/wit/extension.wit" -world = "guest" +elph-extension-pdk = { path = "../elph-extension-pdk" } +serde_json = "1" diff --git a/crates/ext-hello/README.md b/crates/ext-hello/README.md index 3b403700..ace57a41 100644 --- a/crates/ext-hello/README.md +++ b/crates/ext-hello/README.md @@ -1,23 +1,20 @@ # Elph Example Extension -WASM component extension (wasmtime + Component Model) that adds `/say-hello `. +Core Wasm extension (wasmi) that adds `/say-hello ` and can block `shell_exec` commands containing `rm -rf` (confirm defaults to deny without a TUI). ## Build -Requires the [cargo-component](https://github.com/bytecodealliance/cargo-component) subcommand: - ```sh -cargo install cargo-component -rustup target add wasm32-wasip2 -cd extensions/say-hello -cargo component build --release -cp target/wasm32-wasip2/release/elph_extension_say_hello.wasm component.wasm +rustup target add wasm32-unknown-unknown +cd crates/ext-hello +cargo build --release --target wasm32-unknown-unknown +cp target/wasm32-unknown-unknown/release/elph_extension_say_hello.wasm plugin.wasm ``` ## Install ```sh -elph plugin install extensions/say-hello --force +elph extensions install crates/ext-hello --force ``` ## Usage diff --git a/crates/ext-hello/extension.toml b/crates/ext-hello/extension.toml index 55a5a84f..79d71441 100644 --- a/crates/ext-hello/extension.toml +++ b/crates/ext-hello/extension.toml @@ -1,6 +1,6 @@ name = "say-hello" version = "0.1.0" -description = "Adds /say-hello slash command" -component = "component.wasm" +description = "Adds /say-hello and a shell_exec rm -rf confirm gate" +wasm = "plugin.wasm" enabled = true trusted = true diff --git a/crates/ext-hello/src/bindings.rs b/crates/ext-hello/src/bindings.rs deleted file mode 100644 index a5e0e58d..00000000 --- a/crates/ext-hello/src/bindings.rs +++ /dev/null @@ -1,357 +0,0 @@ -// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT! -// Options used: -// * runtime_path: "wit_bindgen_rt" -#[rustfmt::skip] -#[allow(dead_code, clippy::all)] -pub mod elph { - pub mod extension { - /// Shared types between host and guest extensions. - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - #[derive(Clone)] - pub struct CommandDesc { - pub name: _rt::String, - pub description: _rt::String, - } - impl ::core::fmt::Debug for CommandDesc { - fn fmt( - &self, - f: &mut ::core::fmt::Formatter<'_>, - ) -> ::core::fmt::Result { - f.debug_struct("CommandDesc") - .field("name", &self.name) - .field("description", &self.description) - .finish() - } - } - #[derive(Clone)] - pub struct SlashResult { - pub message: _rt::String, - pub is_error: bool, - } - impl ::core::fmt::Debug for SlashResult { - fn fmt( - &self, - f: &mut ::core::fmt::Formatter<'_>, - ) -> ::core::fmt::Result { - f.debug_struct("SlashResult") - .field("message", &self.message) - .field("is-error", &self.is_error) - .finish() - } - } - } - } -} -#[rustfmt::skip] -#[allow(dead_code, clippy::all)] -pub mod exports { - pub mod elph { - pub mod extension { - /// Minimal Pi-compatible surface: slash commands (registerCommand). - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod extension { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type CommandDesc = super::super::super::super::elph::extension::types::CommandDesc; - pub type SlashResult = super::super::super::super::elph::extension::types::SlashResult; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_list_commands_cabi() -> *mut u8 { - #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - let result0 = T::list_commands(); - let ptr1 = (&raw mut _RET_AREA.0).cast::(); - let vec5 = result0; - let len5 = vec5.len(); - let layout5 = _rt::alloc::Layout::from_size_align_unchecked( - vec5.len() * (4 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); - let result5 = if layout5.size() != 0 { - let ptr = _rt::alloc::alloc(layout5).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout5); - } - ptr - } else { - ::core::ptr::null_mut() - }; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 - .add(i * (4 * ::core::mem::size_of::<*const u8>())); - { - let super::super::super::super::elph::extension::types::CommandDesc { - name: name2, - description: description2, - } = e; - let vec3 = (name2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - ::core::mem::forget(vec3); - *base - .add(::core::mem::size_of::<*const u8>()) - .cast::() = len3; - *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); - let vec4 = (description2.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - ::core::mem::forget(vec4); - *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::() = len4; - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>() = ptr4.cast_mut(); - } - } - *ptr1.add(::core::mem::size_of::<*const u8>()).cast::() = len5; - *ptr1.add(0).cast::<*mut u8>() = result5; - ptr1 - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_list_commands(arg0: *mut u8) { - let l0 = *arg0.add(0).cast::<*mut u8>(); - let l1 = *arg0 - .add(::core::mem::size_of::<*const u8>()) - .cast::(); - let base6 = l0; - let len6 = l1; - for i in 0..len6 { - let base = base6 - .add(i * (4 * ::core::mem::size_of::<*const u8>())); - { - let l2 = *base.add(0).cast::<*mut u8>(); - let l3 = *base - .add(::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l2, l3, 1); - let l4 = *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l5 = *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l4, l5, 1); - } - } - _rt::cabi_dealloc( - base6, - len6 * (4 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_execute_command_cabi( - arg0: *mut u8, - arg1: usize, - arg2: *mut u8, - arg3: usize, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); - let len0 = arg1; - let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); - let len1 = arg3; - let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); - let result2 = T::execute_command( - _rt::string_lift(bytes0), - _rt::string_lift(bytes1), - ); - let ptr3 = (&raw mut _RET_AREA.0).cast::(); - match result2 { - Ok(e) => { - *ptr3.add(0).cast::() = (0i32) as u8; - let super::super::super::super::elph::extension::types::SlashResult { - message: message4, - is_error: is_error4, - } = e; - let vec5 = (message4.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr().cast::(); - let len5 = vec5.len(); - ::core::mem::forget(vec5); - *ptr3 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = len5; - *ptr3 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>() = ptr5.cast_mut(); - *ptr3 - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::() = (match is_error4 { - true => 1, - false => 0, - }) as u8; - } - Err(e) => { - *ptr3.add(0).cast::() = (1i32) as u8; - let vec6 = (e.into_bytes()).into_boxed_slice(); - let ptr6 = vec6.as_ptr().cast::(); - let len6 = vec6.len(); - ::core::mem::forget(vec6); - *ptr3 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = len6; - *ptr3 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>() = ptr6.cast_mut(); - } - }; - ptr3 - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_execute_command(arg0: *mut u8) { - let l0 = i32::from(*arg0.add(0).cast::()); - match l0 { - 0 => { - let l1 = *arg0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l2 = *arg0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l1, l2, 1); - } - _ => { - let l3 = *arg0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l4 = *arg0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l3, l4, 1); - } - } - } - pub trait Guest { - /// Return all slash commands contributed by this component. - fn list_commands() -> _rt::Vec; - /// Execute a registered slash command. `name` is without leading `/`. - fn execute_command( - name: _rt::String, - args: _rt::String, - ) -> Result; - } - #[doc(hidden)] - macro_rules! __export_elph_extension_extension_0_1_0_cabi { - ($ty:ident with_types_in $($path_to_types:tt)*) => { - const _ : () = { #[unsafe (export_name = - "elph:extension/extension@0.1.0#list-commands")] unsafe extern - "C" fn export_list_commands() -> * mut u8 { unsafe { - $($path_to_types)*:: _export_list_commands_cabi::<$ty > () } } - #[unsafe (export_name = - "cabi_post_elph:extension/extension@0.1.0#list-commands")] unsafe - extern "C" fn _post_return_list_commands(arg0 : * mut u8,) { - unsafe { $($path_to_types)*:: __post_return_list_commands::<$ty > - (arg0) } } #[unsafe (export_name = - "elph:extension/extension@0.1.0#execute-command")] unsafe extern - "C" fn export_execute_command(arg0 : * mut u8, arg1 : usize, arg2 - : * mut u8, arg3 : usize,) -> * mut u8 { unsafe { - $($path_to_types)*:: _export_execute_command_cabi::<$ty > (arg0, - arg1, arg2, arg3) } } #[unsafe (export_name = - "cabi_post_elph:extension/extension@0.1.0#execute-command")] - unsafe extern "C" fn _post_return_execute_command(arg0 : * mut - u8,) { unsafe { $($path_to_types)*:: - __post_return_execute_command::<$ty > (arg0) } } }; - }; - } - #[doc(hidden)] - pub(crate) use __export_elph_extension_extension_0_1_0_cabi; - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct _RetArea( - [::core::mem::MaybeUninit< - u8, - >; 4 * ::core::mem::size_of::<*const u8>()], - ); - static mut _RET_AREA: _RetArea = _RetArea( - [::core::mem::MaybeUninit::uninit(); 4 - * ::core::mem::size_of::<*const u8>()], - ); - } - } - } -} -#[rustfmt::skip] -mod _rt { - #![allow(dead_code, clippy::all)] - pub use alloc_crate::string::String; - #[cfg(target_arch = "wasm32")] - pub fn run_ctors_once() { - wit_bindgen_rt::run_ctors_once(); - } - pub use alloc_crate::alloc; - pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { - if size == 0 { - return; - } - let layout = alloc::Layout::from_size_align_unchecked(size, align); - alloc::dealloc(ptr, layout); - } - pub use alloc_crate::vec::Vec; - pub unsafe fn string_lift(bytes: Vec) -> String { - if cfg!(debug_assertions) { - String::from_utf8(bytes).unwrap() - } else { - String::from_utf8_unchecked(bytes) - } - } - extern crate alloc as alloc_crate; -} -/// Generates `#[unsafe(no_mangle)]` functions to export the specified type as -/// the root implementation of all generated traits. -/// -/// For more information see the documentation of `wit_bindgen::generate!`. -/// -/// ```rust -/// # macro_rules! export{ ($($t:tt)*) => (); } -/// # trait Guest {} -/// struct MyType; -/// -/// impl Guest for MyType { -/// // ... -/// } -/// -/// export!(MyType); -/// ``` -#[allow(unused_macros)] -#[doc(hidden)] -macro_rules! __export_guest_impl { - ($ty:ident) => { - self::export!($ty with_types_in self); - }; - ($ty:ident with_types_in $($path_to_types_root:tt)*) => { - $($path_to_types_root)*:: - exports::elph::extension::extension::__export_elph_extension_extension_0_1_0_cabi!($ty - with_types_in $($path_to_types_root)*:: exports::elph::extension::extension); - }; -} -#[doc(inline)] -pub(crate) use __export_guest_impl as export; -#[cfg(target_arch = "wasm32")] -#[unsafe(link_section = "component-type:wit-bindgen:0.41.0:elph:extension@0.1.0:guest:encoded world")] -#[doc(hidden)] -#[allow(clippy::octal_escapes)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 462] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xd2\x02\x01A\x02\x01\ -A\x06\x01B\x04\x01r\x02\x04names\x0bdescriptions\x04\0\x0ccommand-desc\x03\0\0\x01\ -r\x02\x07messages\x08is-error\x7f\x04\0\x0cslash-result\x03\0\x02\x03\0\x1aelph:\ -extension/types@0.1.0\x05\0\x02\x03\0\0\x0ccommand-desc\x02\x03\0\0\x0cslash-res\ -ult\x01B\x0a\x02\x03\x02\x01\x01\x04\0\x0ccommand-desc\x03\0\0\x02\x03\x02\x01\x02\ -\x04\0\x0cslash-result\x03\0\x02\x01p\x01\x01@\0\0\x04\x04\0\x0dlist-commands\x01\ -\x05\x01j\x01\x03\x01s\x01@\x02\x04names\x04argss\0\x06\x04\0\x0fexecute-command\ -\x01\x07\x04\0\x1eelph:extension/extension@0.1.0\x05\x03\x04\0\x1aelph:extension\ -/guest@0.1.0\x04\0\x0b\x0b\x01\0\x05guest\x03\0\0\0G\x09producers\x01\x0cprocess\ -ed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\x060.41.0"; -#[inline(never)] -#[doc(hidden)] -pub fn __link_custom_section_describing_imports() { - wit_bindgen_rt::maybe_link_cabi_realloc(); -} diff --git a/crates/ext-hello/src/lib.rs b/crates/ext-hello/src/lib.rs index d7b820e3..b351934d 100644 --- a/crates/ext-hello/src/lib.rs +++ b/crates/ext-hello/src/lib.rs @@ -1,33 +1,64 @@ -wit_bindgen::generate!({ - path: "../elph-agent/wit/extension.wit", - world: "guest", -}); +//! Example extension: `/say-hello` plus a `tool_call` gate for `rm -rf`. -struct SayHello; +use elph_extension_pdk as pdk; +use serde_json::Value; -impl Guest for SayHello { - fn list_commands() -> Vec { - vec![CommandDesc { - name: "say-hello".into(), - description: "Greet someone by name".into(), - }] +#[unsafe(no_mangle)] +pub extern "C" fn elph_init() { + pdk::register_command("say-hello", "Greet someone by name"); + pdk::subscribe(&["tool_call"]); + pdk::notify("say-hello extension loaded", "info"); +} + +#[unsafe(no_mangle)] +pub extern "C" fn elph_execute_command(name_ptr: i32, name_len: i32, args_ptr: i32, args_len: i32) -> i32 { + let name = pdk::read_utf8(name_ptr, name_len); + if name != "say-hello" { + return pdk::return_json(&serde_json::json!({ + "message": format!("unknown command: {name}"), + "is_error": true, + })); } + let args = pdk::read_utf8(args_ptr, args_len); + let target = args.trim(); + let message = if target.is_empty() { + "Hello, world!".to_string() + } else { + format!("Hello, {target}!") + }; + pdk::return_json(&serde_json::json!({ "message": message, "is_error": false })) +} - fn execute_command(name: String, args: String) -> Result { - if name != "say-hello" { - return Err(format!("unknown command: {name}")); +#[unsafe(no_mangle)] +pub extern "C" fn elph_on_event(ptr: i32, len: i32) -> i32 { + let raw = pdk::read_utf8(ptr, len); + let Ok(value) = serde_json::from_str::(&raw) else { + return 0; + }; + let event = value.get("event").and_then(Value::as_str).unwrap_or(""); + if event != "tool_call" { + return 0; + } + let payload = value.get("payload").cloned().unwrap_or(Value::Null); + let tool = payload.get("tool_name").and_then(Value::as_str).unwrap_or(""); + let command = payload + .get("input") + .and_then(|input| input.get("command")) + .and_then(Value::as_str) + .unwrap_or(""); + if tool == "shell_exec" && command.contains("rm -rf") { + let ok = pdk::confirm("Dangerous command", "Allow rm -rf?"); + if !ok { + return pdk::return_json(&serde_json::json!({ + "block": true, + "reason": "Blocked by extension", + })); } - let target = args.trim(); - let message = if target.is_empty() { - "Hello, world!".to_string() - } else { - format!("Hello, {target}!") - }; - Ok(SlashResult { - message, - is_error: false, - }) } + 0 } -export!(SayHello); +#[unsafe(no_mangle)] +pub extern "C" fn elph_execute_tool(_ptr: i32, _len: i32) -> i32 { + 0 +} diff --git a/docs/archive/README.md b/docs/archive/README.md index 523a8c37..dcda1915 100644 --- a/docs/archive/README.md +++ b/docs/archive/README.md @@ -57,7 +57,7 @@ Living **gap logs** for the TypeScript → Rust port (timestamps, pi vs elph mat | Agent loop + tools | Done | `elph-agent` harness; `builtin-tools` feature | | Goals + nested subagents | Done | Codex-style goals, depth-3 subagents | | MCP → agent loop | Done | `mcp_{server}__{tool}` registry | -| WASM extensions (phase 1) | In progress | Slash commands; wasmtime Component Model | +| WASM extensions (phase 1) | In progress | Slash/tools/events via wasmi core Wasm | | `elph` crate layout | Done | `agent/`, `cli/`, `platform/`, `shell/` | | Elph TUI + coding agent | In progress | Shell wired; overlays partially stubbed | | Elph slash commands | In progress | Built-ins + `/goal`; extension commands | diff --git a/docs/archive/agent-runtime.md b/docs/archive/agent-runtime.md index f72db3a4..ea355533 100644 --- a/docs/archive/agent-runtime.md +++ b/docs/archive/agent-runtime.md @@ -174,7 +174,7 @@ TUI shows `agent_id` + `agent_path` in subagent status lines. ### Extensions (WASM) -Pi-compatible extension bundles discovered from `CONFIG_DIR/extensions/` (default `~/.config/elph/extensions/`) and `/.elph/extensions/`. Phase 1: slash commands via wasmtime Component Model. `/reload` refreshes registry. See [extensions.md](./extensions.md). +Pi-compatible extension bundles discovered from `CONFIG_DIR/extensions/` (default `~/.elph/extensions/`) and `/.elph/extensions/`. Slash commands, tools, and selected harness events via wasmi. `/reload` refreshes registry. See [../extensions.md](../extensions.md). ## Thinking levels diff --git a/docs/archive/cli.md b/docs/archive/cli.md index 776b6796..f9d3051a 100644 --- a/docs/archive/cli.md +++ b/docs/archive/cli.md @@ -156,7 +156,7 @@ Subcommands: `list`, `add`, `remove`, `doctor`, `auth`, `logout`. ### `plugin` -Manage WASM extension bundles (wasmtime + Component Model). See [extensions.md](./extensions.md). +Manage WASM extension bundles (wasmi). See [extensions.md](./extensions.md) and [../extensions.md](../extensions.md). | Subcommand | Flags | Design behavior | | ---------------- | ----------------- | ------------------------------------------------- | diff --git a/docs/archive/configuration.md b/docs/archive/configuration.md index 22d16e4e..132b8b4e 100644 --- a/docs/archive/configuration.md +++ b/docs/archive/configuration.md @@ -23,7 +23,7 @@ Override with `ELPH_HOME` (config) and `ELPH_DATA_DIR` (data). ├── extensions/ # Global WASM extension bundles (placeholder / installed) │ └── / │ ├── extension.toml -│ └── component.wasm +│ └── plugin.wasm ├── hooks/ # User hooks ├── prompts/ │ └── *.md # Global templates → /name diff --git a/docs/archive/development.md b/docs/archive/development.md index 4e0e02e6..84adbe49 100644 --- a/docs/archive/development.md +++ b/docs/archive/development.md @@ -67,8 +67,8 @@ All share the same config/data layout (`CONFIG_DIR` / `APP_DATA`); override with ## Extension development loop -1. Build guest WASM: see [extensions.md](./extensions.md) and `crates/ext-hello/README.md`. -2. Install: `elph plugin install crates/ext-hello --force` +1. Build guest WASM: see [../extensions.md](../extensions.md) and `crates/ext-hello/README.md`. +2. Install: `elph extensions install crates/ext-hello --force` 3. Verify: `elph plugin list` 4. In TUI: `/say-hello World` or `/reload` after changes. diff --git a/docs/archive/extensions.md b/docs/archive/extensions.md index cac4e1b1..5102ce22 100644 --- a/docs/archive/extensions.md +++ b/docs/archive/extensions.md @@ -2,14 +2,14 @@ Design for Pi-compatible WASM extensions — sandboxed plugins that contribute slash commands, tools, and lifecycle hooks without running arbitrary native code in the host process. -Inspired by [Pi extensions](https://pi.dev/docs/latest/extensions); Elph uses **wasmtime + WebAssembly Component Model** instead of TypeScript/jiti. +Inspired by [Pi extensions](https://pi.dev/docs/latest/extensions); Elph uses **wasmi + core Wasm** (JSON ABI, host imports) instead of TypeScript/jiti. Current spec: [../extensions.md](../extensions.md). ## Goals - **Safe by default** — extensions run in a WASM sandbox; host APIs are explicit imports. - **Hot reload** — `/reload` rediscovers extensions without restarting the TUI. - **Pi-compatible layout** — global + project-local discovery, built-in commands win over extension commands. -- **Incremental surface** — phase 1: slash commands; later: tools, hooks, custom UI. +- **Incremental surface** — slash commands, tools, and selected harness events; custom TUI later. ## Discovery layout @@ -23,8 +23,8 @@ Each extension bundle: ``` / -├── extension.toml # manifest (name, version, component path, enabled) -└── component.wasm # WASM Component (guest world) +├── extension.toml # manifest (name, version, wasm path, enabled) +└── plugin.wasm # core Wasm guest ``` ### `extension.toml` (manifest) @@ -34,7 +34,7 @@ Each extension bundle: | `name` | yes | Stable id; install directory name | | `version` | no | Semver string for display | | `description` | no | Human-readable summary | -| `component` | yes | Path to `.wasm`, relative to bundle root | +| `wasm` | yes | Path to `.wasm`, relative to bundle root | | `enabled` | no | Default `true` | | `trusted` | no | Skip trust prompt when installing (future) | @@ -51,24 +51,19 @@ Path: `~/.elph/extensions.json` Merge order for slash dispatch: **built-in commands → extension commands → prompt templates**. -## WASM guest contract (phase 1) +## WASM guest contract -Guest exports a single component interface: +See [../extensions.md](../extensions.md) for the current ABI (`elph_init`, host imports, JSON blobs). -| Export | Description | -| ----------------- | ------------------------------------------------- | -| `list-commands` | Return slash commands (`name`, `description`) | -| `execute-command` | Run `/ `; return message + error flag | - -Future phases add tool registration, lifecycle events (`session_start`, `tool_call`, …), and TUI widgets — aligned with Pi's `ExtensionAPI` event map. +Tools and lifecycle events (`session_start`, `tool_call`, …) are on the host ABI in [../extensions.md](../extensions.md). Custom TUI widgets remain later. ### Build toolchain -- Guest: Rust + `wit-bindgen`, built with `cargo component` → `wasm32-wasip2`. -- Host: `wasmtime` with component model enabled. -- Example bundle: `crates/ext-hello/say-hello/` in the repository (reference only). +- Guest: Rust + `elph-extension-pdk`, `wasm32-unknown-unknown`. +- Host: `wasmi` interpreter (no WASI). +- Example bundle: `crates/ext-hello/`. -## CLI: `elph plugin` +## CLI: `elph extensions` | Subcommand | Design behavior | | -------------------- | --------------------------------------------------------------- | diff --git a/docs/ci.md b/docs/ci.md index 59044185..d6105bdd 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -27,7 +27,7 @@ Create these runner profiles in the [Namespace dashboard](https://cloud.namespac Connect the GitHub org to Namespace before the first run. Lightweight jobs (version gate, publish, sync) stay on GitHub `ubuntu-slim`. -`.cargo/config.toml` uses zig as the linker for musl targets (`x86_64-unknown-linux-musl`, `aarch64-unknown-linux-musl`). Linux AMD64 jobs download zig from ziglang.org in `setup-rust` for musl builds; the default glibc target uses the system linker. +`.cargo/config.toml` uses zig as the linker for musl targets (`x86_64-unknown-linux-musl`, `aarch64-unknown-linux-musl`). Linux AMD64 jobs download zig from ziglang.org in `setup-rust` for musl builds; the default glibc target uses the system linker. The musl cross-build also points `CC_*`/`CXX_*` at a `zig cc` wrapper (ring's build script needs a C compiler for the target) and disables `RUSTC_WRAPPER` for that step — sccache does not support zig as a compiler family, so it cannot wrap the zig cc C compiler. ## Test (debug) @@ -40,7 +40,7 @@ Triggers: Both use path filters on the elph workspace, lockfile, toolchain, Makefile, and `.github/`. -On Linux and macOS the job runs, in order: `cargo fmt --check`, `make check`, `make lint`, `make lint/test -p elph-agent --features full`, `make test`, then `make build`. Windows (`avrea-windows-2025-4-vcpu`, 90 min) runs fmt + check + lint + `make test` only: compiling wasmtime (`elph-agent` `full`) and a second debug build routinely exceed the gap between `main` pushes and get `The operation was canceled`. Workflow concurrency cancels in-progress runs on pull requests only, not on `main`. Shell exec locates Git Bash (`where.exe` / `Git\\bin\\bash.exe`); abort/timeout uses `taskkill /T`. Auth store locking uses a sibling `.flock` file (NTFS mandatory locks cannot sit on `auth.json`). Home directories fall back to `USERPROFILE` when `HOME` is unset. With `CI=true` (or profiling flags like `make build -- --ci`), those targets use Cargo profile `ci` (`target/ci/`: `opt-level=0`, no debuginfo, no incremental — sccache is the cache). Local `make` stays on `dev`. Profiles: `--debug`, `--release`, `--dist`, `--ci` (last flag wins). `PROFILE=dist` / `--dist` is unchanged (`opt-level=3`, thin LTO, `codegen-units=1`). +On Linux and macOS the job runs, in order: `cargo fmt --check`, `make check`, `make lint`, `make lint/test -p elph-agent --features full`, `make test`, then `make build`. Windows (`avrea-windows-2025-4-vcpu`, 90 min) runs fmt + check + lint + `make test` (and `make build` when the workflow mode is `full`). Extensions use the wasmi interpreter. Workflow concurrency cancels in-progress runs on pull requests only, not on `main`. Shell exec locates Git Bash (`where.exe` / `Git\\bin\\bash.exe`); abort/timeout uses `taskkill /T`. Auth store locking uses a sibling `.flock` file (NTFS mandatory locks cannot sit on `auth.json`). Home directories fall back to `USERPROFILE` when `HOME` is unset. With `CI=true` (or profiling flags like `make build -- --ci`), those targets use Cargo profile `ci` (`target/ci/`: `opt-level=0`, no debuginfo, no incremental — sccache is the cache). Local `make` stays on `dev`. Profiles: `--debug`, `--release`, `--dist`, `--ci` (last flag wins). `PROFILE=dist` / `--dist` is unchanged (`opt-level=3`, thin LTO, `codegen-units=1`). ## Release diff --git a/docs/elph-agent.md b/docs/elph-agent.md index aca8e716..e7aa28ac 100644 --- a/docs/elph-agent.md +++ b/docs/elph-agent.md @@ -37,7 +37,7 @@ Default prefix is `ELPH`. Logging uses [`AgentBuilder::env_prefix`] / [`AgentBui ## Features -`default = []`. Enable `mcp`, `builtin-tools`, `extensions`, `prompt-templates`, `tracing`, `backend-turso`, or `full`. +`default = []`. Enable `mcp`, `builtin-tools`, `extensions` (wasmi core-Wasm plugins), `prompt-templates`, `tracing`, `backend-turso`, or `full`. See [extensions.md](./extensions.md). `backend-turso` enables Turso/SQLite session storage (`TursoSessionStorage`, `TursoSessionRepo`), the `datastore` helpers, and Turso-backed stores (turns, todos, goals, workers, session summaries, subagent graph). Without it, use `InMemorySessionStorage`, `JsonlSessionStorage`, or `SessionDirStorage`. diff --git a/docs/extensions.md b/docs/extensions.md new file mode 100644 index 00000000..a77045a0 --- /dev/null +++ b/docs/extensions.md @@ -0,0 +1,55 @@ +# Extensions + +Sandboxed Wasm plugins that customize Elph: slash commands, LLM tools, and agent-loop events. Runtime is **wasmi** (core Wasm). Guests are `wasm32-unknown-unknown` (no WASI, no Node/jiti). + +Pi’s `registerCommand` / `registerTool` / `pi.on` / `ctx.ui.confirm` map to **host imports** with the same names. Pi `.ts` files are not source-compatible. + +## Discovery + +| Location | When loaded | +| --- | --- | +| `~/.elph/extensions//` | Always | +| `/.elph/extensions//` | After project trust | +| Extra paths in settings `resources.extensions` | Always | + +Each bundle: + +``` +/ +├── extension.toml +└── plugin.wasm +``` + +### `extension.toml` + +Required: `name`, `wasm` (path relative to the bundle). Optional: `version`, `description`, `enabled` (default true). + +## ABI + +Linear memory: UTF-8 JSON. Return values are **u32 LE length + bytes**. Max blob 64 KiB. Fuel ~10M instructions per call. Memory grow is not WASI; keep guests small. Guest must **not** import WASI. + +Guest exports: `memory`, `elph_alloc`, `elph_dealloc`, `elph_init`, `elph_on_event`, `elph_execute_command`, `elph_execute_tool`. + +Host imports (`elph` module): `register_command`, `register_tool`, `subscribe`, `notify`, `confirm` (false when no TUI). + +Events in this release: `session_start`, `before_agent_start`, `tool_call`, `tool_result`. Payloads are small JSON (tool name + args, not the full transcript). + +`/reload` rediscovers bundles. Built-in slash commands win over extension commands. + +## Authoring + +Use `crates/elph-extension-pdk` (excluded from the host workspace). Example: `crates/ext-hello`. + +```sh +rustup target add wasm32-unknown-unknown +cargo build --release --target wasm32-unknown-unknown --manifest-path crates/ext-hello/Cargo.toml +elph extensions install crates/ext-hello --force +``` + +## CLI + +`elph extensions list | install | remove | enable | disable` + +## Related + +Harness hooks used by native Elph code stay in `AgentHarness`; Wasm guests attach through the same hook points after session restore. diff --git a/docs/porting/feature-comparison.md b/docs/porting/feature-comparison.md index f23c5dd5..e24975ee 100644 --- a/docs/porting/feature-comparison.md +++ b/docs/porting/feature-comparison.md @@ -267,7 +267,7 @@ Mapping: `@earendil-works/pi-ai` → `crates/elph-ai`, `@earendil-works/pi-agent | ------------------------ | ----------------------------------- | ------------------------------------------------------------- | | Goals | `src/goals/` | Goal tracking with progress, budget, and completion criteria | | Subagent | `src/agent/subagent/` | Subagent spawning and coordination | -| Plugins (WASM) | `src/plugins/` | WASM-based plugin loading with `extensions` feature flag | +| Plugins (WASM) | `src/plugins/` | wasmi core-Wasm plugins (`extensions` feature) | | MCP client | `src/tools/mcp/` | Full MCP integration: stdio/SSE/HTTP transports, auth, crypto | | Collaboration modes | `src/collaboration/` | Plan mode, default mode, tool blocking | | Datastore | `src/datastore/` | Turso database management and migrations | diff --git a/docs/porting/pi-coding-agent.md b/docs/porting/pi-coding-agent.md index 6433aa8a..cf98e38e 100644 --- a/docs/porting/pi-coding-agent.md +++ b/docs/porting/pi-coding-agent.md @@ -31,7 +31,7 @@ Elph deliberately **diverges** in product design (memory, ACP, WASM extensions, - RPC / JSON automation — **[Gap]** in elph (pi has RPC); Elph has **ACP** instead (**[Elph delta]**, different protocol) - Public SDK (`createAgentSession`) — **[Gap]** as a first-class TS-style SDK; library is `elph` + crates, not a pi-compatible SDK API - Built-in tools — **[Parity]** via `elph-agent` tools (+ Elph web/multi-agent extras) -- Extensions — **[Partial]** / different — pi: JS/TS host; elph: WASM Component Model +- Extensions — **[Partial]** / different — pi: JS/TS host; elph: wasmi core Wasm (Pi-shaped host API, not jiti) - Skills + prompt templates — **[Partial]** — load paths in agent crate; product wiring incomplete - Themes / keybindings editor — **[Gap]** (or minimal) - Project trust — **[Partial]** diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4c9fe1a6..a8637141 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -6,8 +6,7 @@ # rustup target add x86_64-unknown-linux-musl # rustup target add aarch64-pc-windows-msvc # rustup target add x86_64-pc-windows-gnu -# rustup target add wasm32-wasip1 -# rustup target add wasm32-wasip2 +# rustup target add wasm32-unknown-unknown [toolchain] channel = "1.97.0" @@ -22,6 +21,5 @@ components = ["clippy", "rustfmt", "rust-analysis", "rust-analyzer"] # "x86_64-pc-windows-gnu", # "aarch64-pc-windows-msvc", # "x86_64-pc-windows-msvc", -# "wasm32-wasip1", -# "wasm32-wasip2", +# "wasm32-unknown-unknown", # ] diff --git a/website/content/blog/0003-surfaces-and-transfer.md b/website/content/blog/0003-surfaces-and-transfer.md index f678be7f..87eaafb2 100644 --- a/website/content/blog/0003-surfaces-and-transfer.md +++ b/website/content/blog/0003-surfaces-and-transfer.md @@ -31,4 +31,4 @@ Plan mode designs and asks. Approved plans land in `.elph/plans/` before the ful `elph import` reads Claude Code and Codex transcripts as **inert** context. Foreign tool calls are not executed. Use it when you are moving a conversation into Elph, not when you want another agent to keep running commands. -WASM extensions (`elph ext`) and MCP (`elph mcp`) stay behind those same approval and trust boundaries. +WASM extensions (`elph extensions`) and MCP (`elph mcp`) stay behind those same approval and trust boundaries. diff --git a/website/src/pages/faqs.vto b/website/src/pages/faqs.vto index 683a009c..026f7c30 100644 --- a/website/src/pages/faqs.vto +++ b/website/src/pages/faqs.vto @@ -89,7 +89,7 @@
How do I extend it?

- MCP servers (stdio and streamable HTTP) via elph mcp, WASM extensions on wasmtime’s Component Model (elph ext), and SKILL.md packages. The MIT crates — elph-ai, elph-agent, elph-tui, floppy — are the embeddable runtime. + MCP servers (stdio and streamable HTTP) via elph mcp, WASM extensions via wasmi (elph extensions), and SKILL.md packages. The MIT crates — elph-ai, elph-agent, elph-tui, floppy — are the embeddable runtime.

diff --git a/website/src/pages/index.vto b/website/src/pages/index.vto index e44677e5..052e0bd7 100644 --- a/website/src/pages/index.vto +++ b/website/src/pages/index.vto @@ -157,7 +157,7 @@

Extension points

-

MCP (stdio + HTTP), WASM Component Model, SKILL.md, ACP for editors, headless elph run, and worktrees.

+

MCP (stdio + HTTP), wasmi WASM extensions, SKILL.md, ACP for editors, headless elph run, and worktrees.