diff --git a/Cargo.lock b/Cargo.lock index ceb8524..0c5aba4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -408,18 +408,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a6391a9172a93f413370fa561c6bca786e06c89cf85f23f02f6345b1c8ee34" +checksum = "9515fcc42b6cb5137f76b84c1a6f819782d0cf12473d145d3bc5cd67eedc8bc2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "409c6cbb326604a53ec47eb6341fc85128f24c81012a014b4c728ed24f6e9350" +checksum = "1ad827c6071bfe6d22de1bc331296a29f9ddc506ff926d8415b435ec6a6efce0" dependencies = [ "bumpalo", "cranelift-bforest", @@ -438,33 +438,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff55e100130995b9ad9ac6b03a24ed5da3c1a1261dcdeb8a7a0292656994fb3" +checksum = "10e6b36237a9ca2ce2fb4cc7741d418a080afa1327402138412ef85d5367bef1" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1446e2eb395fc7b3019a36dccb7eccea923f6caf581b903c8e7e751b6d214a7" +checksum = "c36bf4bfb86898a94ccfa773a1f86e8a5346b1983ff72059bdd2db4600325251" [[package]] name = "cranelift-control" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24076ecf69cbf8b9e1e532ae8e7ac01d850a1c2e127058a26eb3245f9d5b89d1" +checksum = "7cbf36560e7a6bd1409ca91e7b43b2cc7ed8429f343d7605eadf9046e8fac0d0" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f40df95180ad317c60459bb90dd87803d35e538f4c54376d8b26c851f6f0a1b" +checksum = "a71e11061a75b1184c09bea97c026a88f08b59ade96a7bb1f259d4ea0df2e942" dependencies = [ "serde", "serde_derive", @@ -472,9 +472,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c3974cc665b699b626742775dae1c1cdea5170f5028ab1f3eb61a7a9a6e2979" +checksum = "af5d4da63143ee3485c7bcedde0a818727d737d1083484a0ceedb8950c89e495" dependencies = [ "cranelift-codegen", "log", @@ -484,15 +484,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99543f92b9c361f3c54a29e945adb5b9ef1318feaa5944453cabbfcb3c495919" +checksum = "457a9832b089e26f5eea70dcf49bed8ec6edafed630ce7c83161f24d46ab8085" [[package]] name = "cranelift-native" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c0d84dc7d9b3f73ad565eacc4ab36525c407ef5150893b4b94d5f5f904eb48a" +checksum = "9b490d579df1ce365e1ea359e24ed86d82289fa785153327c2f6a69a59a731e4" dependencies = [ "cranelift-codegen", "libc", @@ -501,9 +501,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.105.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53781039219944d59c6d3ec57e6cae31a1a33db71573a945d84ba6d875d0a743" +checksum = "8cd747ed7f9a461dda9c388415392f6bb95d1a6ef3b7694d17e0817eb74b7798" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -2056,9 +2056,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-common" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "082a661fe31df4dbb34409f4835ad3d8ba65036bf74aaec9b21fde779978aba7" +checksum = "880c1461417b2bf90262591bf8a5f04358fb86dac8a585a49b87024971296763" dependencies = [ "anyhow", "bitflags 2.4.1", @@ -2174,9 +2174,9 @@ dependencies = [ [[package]] name = "wasm-compose" -version = "0.200.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b81858e6426b8c4f5f65a5dff0e55b7715c903ba5fe6e402805496e1798f57ef" +checksum = "10501f9526fedb9592271a19c34257582b6abcb4636e276ee75cb95aa242ee2a" dependencies = [ "anyhow", "heck 0.4.1", @@ -2188,8 +2188,8 @@ dependencies = [ "serde_derive", "serde_yaml", "smallvec", - "wasm-encoder 0.200.0", - "wasmparser 0.200.0", + "wasm-encoder 0.201.0", + "wasmparser 0.201.0", "wat", ] @@ -2214,12 +2214,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.200.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e3fb0c8fbddd78aa6095b850dfeedbc7506cf5f81e633f69cf8f2333ab84b9" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" dependencies = [ "leb128", - "wasmparser 0.200.0", + "wasmparser 0.201.0", ] [[package]] @@ -2240,9 +2240,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.200.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b8cc0c21f46d55b0aaa419cacce1eadcf28eaebd0e1488d6a6313ee71a586" +checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" dependencies = [ "anyhow", "indexmap 2.1.0", @@ -2250,8 +2250,8 @@ dependencies = [ "serde_derive", "serde_json", "spdx", - "wasm-encoder 0.200.0", - "wasmparser 0.200.0", + "wasm-encoder 0.201.0", + "wasmparser 0.201.0", ] [[package]] @@ -2313,9 +2313,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.200.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a03f65ac876612140c57ff6c3b8fe4990067cce97c2cfdb07368a3cc3354b062" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" dependencies = [ "bitflags 2.4.1", "indexmap 2.1.0", @@ -2334,9 +2334,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06f80b13fdeba0ea5267813d0f06af822309f7125fc8db6094bcd485f0a4ae7" +checksum = "4c843b8bc4dd4f3a76173ba93405c71111d570af0d90ea5f6299c705d0c2add2" dependencies = [ "addr2line", "anyhow", @@ -2378,18 +2378,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d7395b475c6f858c7edfce375f00d8282a32fbf5d1ebc93eddfac5c2458a52" +checksum = "86b9d329c718b3a18412a6a017c912b539baa8fe1210d21b651f6b4dbafed743" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0a78f86b27f099bea3aaa0894464e22e84a08cadf3d8cd353378d3d15385535" +checksum = "6fb4fc2bbf9c790a57875eba65588fa97acf57a7d784dc86d057e648d9a1ed91" dependencies = [ "anyhow", "base64", @@ -2407,9 +2407,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e54483c542e304e17fa73d3f9263bf071e21915c8f048c7d42916da5b4bfd6" +checksum = "d8d55ddfd02898885c39638eae9631cd430c83a368f5996ed0f7bfb181d02157" dependencies = [ "anyhow", "proc-macro2", @@ -2422,15 +2422,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9f72619f484df95fc03162cdef9cb98778abc4103811849501bb34e79a3aac" +checksum = "1d6d69c430cddc70ec42159506962c66983ce0192ebde4eb125b7aabc49cff88" [[package]] name = "wasmtime-cranelift" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "974d9455611e26c97d31705e19545de58fa8867416592bd93b7a54a7fc37cedb" +checksum = "31ca62f519225492bd555d0ec85a2dacb0c10315db3418c8b9aeb3824bf54a24" dependencies = [ "anyhow", "cfg-if", @@ -2453,9 +2453,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40667ba458634db703aea3bd960e80bc9352c21d5e765b69f43e3b0c964eb611" +checksum = "fd5f2071f42e61490bf7cb95b9acdbe6a29dd577a398019304a960585f28b844" dependencies = [ "anyhow", "cranelift-codegen", @@ -2469,9 +2469,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8da991421528c2767053cb0cfa70b5d28279100dbcf70ed7f74b51abe1656ef" +checksum = "82bf1a47f384610da19f58b0fd392ca6a3b720974315c08afb0392c0f3951fed" dependencies = [ "anyhow", "bincode", @@ -2495,9 +2495,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fdd780272515bfcdf316e2efe20231719ec40223d67fcdd7d17068a16d39384" +checksum = "0e31aecada2831e067ebfe93faa3001cc153d506f8af40bbea58aa1d20fe4820" dependencies = [ "anyhow", "cc", @@ -2510,9 +2510,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87be9ed561dbe2aca3bde30d442c292fda53748343d0220873d1df65270c8fcf" +checksum = "833dae95bc7a4f9177bf93f9497419763535b74e37eb8c37be53937d3281e287" dependencies = [ "object", "once_cell", @@ -2522,9 +2522,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3346431a41fbb0c5af0081c2322361b00289f2902e54ee7b115e9b2ad32b156b" +checksum = "33f4121cb29dda08139b2824a734dd095d83ce843f2d613a84eb580b9cfc17ac" dependencies = [ "cfg-if", "libc", @@ -2533,9 +2533,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a489353aa297b46a66cde8da48cab8e1e967e7f4b0ae3d9889a0550bf274810b" +checksum = "4e517f2b996bb3b0e34a82a2bce194f850d9bcfc25c08328ef5fb71b071066b8" dependencies = [ "anyhow", "cc", @@ -2563,9 +2563,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12c56e31fd7fa707fbd7720b2b29ac42ccfb092fe9d85c98f1d3988f9a1d4558" +checksum = "54a327d7a0ef57bd52a507d28b4561a74126c7a8535a2fc6f2025716bc6a52e8" dependencies = [ "cranelift-entity", "serde", @@ -2576,9 +2576,9 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0300976c36a9427d184e3ecf7c121c2cb3f030844faf9fcb767821e9d4c382" +checksum = "8ef32eea9fc7035a55159a679d1e89b43ece5ae45d24eed4808e6a92c99a0da4" dependencies = [ "proc-macro2", "quote", @@ -2587,9 +2587,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7d9cfaf9f70e83a164f5d772e376fafa2d7b7b0ca2ef88f9bcaf8b2363a38b" +checksum = "d04d2fb2257245aa05ff799ded40520ae4d8cd31b0d14972afac89061f12fe12" dependencies = [ "anyhow", "async-trait", @@ -2620,9 +2620,9 @@ dependencies = [ [[package]] name = "wasmtime-winch" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f773a904d2bd5ecd8ad095f4c965ad56a836929d8c26368621f75328d500649" +checksum = "db3378c0e808a744b5d4df2a9a9d2746a53b151811926731f04fc401707f7d54" dependencies = [ "anyhow", "cranelift-codegen", @@ -2637,9 +2637,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6e9754e0a526238ea66da9ba21965a54846a2b22d9de89a298fb8998389507" +checksum = "ca677c36869e45602617b25a9968ec0d895ad9a0aee3756d9dee1ddd89456f91" dependencies = [ "anyhow", "heck 0.4.1", @@ -2649,9 +2649,9 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdf5b8da6ebf7549dad0cd32ca4a3a0461449ef4feec9d0d8450d8da9f51f9b" +checksum = "7f4cbfb052d66f03603a9b77f18171ea245c7805714caad370a549a6344bf86b" [[package]] name = "wast" @@ -2664,24 +2664,24 @@ dependencies = [ [[package]] name = "wast" -version = "200.0.0" +version = "201.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1810d14e6b03ebb8fb05eef4009ad5749c989b65197d83bce7de7172ed91366" +checksum = "1ef6e1ef34d7da3e2b374fd2b1a9c0227aff6cad596e1b24df9b58d0f6222faa" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.200.0", + "wasm-encoder 0.201.0", ] [[package]] name = "wat" -version = "1.200.0" +version = "1.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "776cbd10e217f83869beaa3f40e312bb9e91d5eee29bbf6f560db1261b6a4c3d" +checksum = "453d5b37a45b98dee4f4cb68015fc73634d7883bbef1c65e6e9c78d454cf3f32" dependencies = [ - "wast 200.0.0", + "wast 201.0.0", ] [[package]] @@ -2701,18 +2701,18 @@ dependencies = [ "rustyline", "tokio", "wasi-virt", - "wasm-compose 0.200.0", + "wasm-compose 0.201.0", "wasmtime", "wasmtime-wasi", - "wit-component 0.200.0", - "wit-parser 0.200.0", + "wit-component 0.201.0", + "wit-parser 0.201.0", ] [[package]] name = "wiggle" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "454570f4fecadb881f0ba157e98b575a2850607a9eac79d8868f3ab70633f632" +checksum = "b69812e493f8a43d8551abfaaf9539e1aff0cf56a58cdd276845fc4af035d0cd" dependencies = [ "anyhow", "async-trait", @@ -2725,9 +2725,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443ac1ebb753ca22bca98d01742762de1243ff722839907c35ea683a8264c74e" +checksum = "0446357a5a7af0172848b6eca7b2aa1ab7d90065cd2ab02b633a322e1a52f636" dependencies = [ "anyhow", "heck 0.4.1", @@ -2740,9 +2740,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "18.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9e2f1f06ae07bac15273774782c04ab14e9adfbf414762fc84dbbfcf7fb1ac" +checksum = "9498ef53a12cf25dc6de9baef6ccd8b58d159202c412a19f4d72b218393086c5" dependencies = [ "proc-macro2", "quote", @@ -2783,9 +2783,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f7eaac56988f986181099c15860946fea93ed826322a1f92c4ff04541b7744" +checksum = "8197ed4a2ebf612f0624ddda10de71f8cd2d3a4ecf8ffac0586a264599708d63" dependencies = [ "anyhow", "cranelift-codegen", @@ -2978,9 +2978,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.200.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39979723340baea490b87b11b2abae05f149d86f2b55c18d41d78a2a2b284c16" +checksum = "421c0c848a0660a8c22e2fd217929a0191f14476b68962afd2af89fd22e39825" dependencies = [ "anyhow", "bitflags 2.4.1", @@ -2989,10 +2989,10 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "wasm-encoder 0.200.0", - "wasm-metadata 0.200.0", - "wasmparser 0.200.0", - "wit-parser 0.200.0", + "wasm-encoder 0.201.0", + "wasm-metadata 0.201.0", + "wasmparser 0.201.0", + "wit-parser 0.201.0", ] [[package]] @@ -3032,9 +3032,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.200.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f717576b37f01c15696bda7f6f13868367b9c5913485f9f0ec8e59fd28c8e13" +checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" dependencies = [ "anyhow", "id-arena", @@ -3045,7 +3045,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.200.0", + "wasmparser 0.201.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 512684a..00b8e63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,20 +10,20 @@ repository = "https://github.com/rylev/wepl" [dependencies] anyhow = "1.0" async-trait = "0.1.77" -clap = { version = "4.5.0", features = ["derive"] } bytes = "1.5.0" +clap = { version = "4.5.0", features = ["derive"] } +colored = "2" env_logger = "0.11" home = "0.5.9" log = "0.4" nom = "7.1.3" nom_locate = "4.2" rustyline = "13.0.0" -colored = "2" tokio = { version = "1.36.0", features = ["macros"] } -wasmtime = { version = "18.0.1", features = [ "component-model", ] } -wasmtime-wasi = { version = "18.0.1", features = [ "tokio", ] } +wasmtime = { version = "18.0.1", features = ["component-model"] } +wasmtime-wasi = { version = "18.0.2", features = ["tokio"] } wasi-virt = { git = "https://github.com/bytecodealliance/WASI-Virt", rev = "fd2fae04342ea58aab2426ca041da68be046b030" } -wit-component = "0.200.0" -wit-parser = "0.200.0" -wasm-compose = "0.200.0" +wit-component = "0.201.0" +wit-parser = "0.201.0" +wasm-compose = "0.201.0" diff --git a/src/runtime.rs b/src/runtime.rs index 348fb14..459c530 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -38,11 +38,12 @@ impl Runtime { let mut linker = Linker::::new(&engine); linker.allow_shadowing(true); - if querier.imports_wasi() { + let imports_wasi_cli = querier.imports_wasi_cli(); + if imports_wasi_cli { log::debug!("Linking with wasi"); wasmtime_wasi::preview2::command::sync::add_to_linker(&mut linker)?; } - for (import_name, import) in querier.imports(false) { + for (import_name, import) in querier.imports(!imports_wasi_cli) { let import_name = querier.world_item_name(import_name); let stub_import = stub_import.clone(); match import { @@ -66,6 +67,16 @@ impl Runtime { Ok(()) })?; } + for (name, t) in &interface.types { + let t = querier.type_by_id(*t).unwrap(); + match &t.kind { + wit_parser::TypeDefKind::Resource => { + let ty = wasmtime::component::ResourceType::host::<()>(); + instance.resource(name, ty, |_, _| Ok(())).unwrap(); + } + _ => {} + } + } } _ => {} } diff --git a/src/wit.rs b/src/wit.rs index 2d8fba5..a798a79 100644 --- a/src/wit.rs +++ b/src/wit.rs @@ -258,14 +258,26 @@ impl Querier { Cow::Owned(display) } - pub fn imports_wasi(&self) -> bool { + /// Whether the wasi cli (0.2.0) package is imported. + /// + /// Note that this is being used as a heuristic to determine whether to + /// link wasi command. + pub fn imports_wasi_cli(&self) -> bool { let world = self.world(); for (import_name, _) in &world.imports { if let WorldKey::Interface(interface_id) = import_name { let interface = self.resolve.interfaces.get(*interface_id).unwrap(); if let Some(package_id) = &interface.package { if let Some(package) = self.resolve.packages.get(*package_id) { - if package.name.namespace == "wasi" { + if package.name.namespace == "wasi" + && package.name.name == "cli" + && package + .name + .version + .as_ref() + .map(|v| v.major == 0 && v.minor == 2 && v.patch == 0) + .unwrap_or(false) + { return true; } } @@ -303,19 +315,24 @@ impl Querier { pub(crate) fn imports( &self, - include_wasi: bool, + include_wasi_cli: bool, ) -> impl Iterator { self.world() .imports .iter() .filter(move |(_, item)| match item { - WorldItem::Interface(id) if !include_wasi => { + WorldItem::Interface(id) if !include_wasi_cli => { let interface = self.interface_by_id(*id).unwrap(); let Some(package) = interface.package else { return true; }; let package = self.resolve.packages.get(package).unwrap(); - package.name.namespace != "wasi" + !(package.name.namespace == "wasi" + // This is not 100% correct. + // We're assuming that all interfaces in these packages are handled by `wasmtime-wasi` + // command implementation. This should be true for many components so we'll leave + // the hack for now. + && ["cli", "io", "filesystem", "random"].contains(&package.name.name.as_str())) } _ => true, })