diff --git a/Cargo.lock b/Cargo.lock index 96628891a..6a20811a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,8 +82,9 @@ dependencies = [ "url", "urlencoding", "uuid", + "webpki-roots", "windows-sys 0.52.0", - "zip 8.6.0", + "zip", ] [[package]] @@ -151,7 +152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d" dependencies = [ "alsa-sys", - "bitflags", + "bitflags 2.13.1", "cfg-if", "libc", ] @@ -181,15 +182,6 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" -[[package]] -name = "arbitrary" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "arboard" version = "3.6.1" @@ -224,6 +216,17 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atomicwrites" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef1bb8d1b645fe38d51dfc331d720fb5fc2c94b440c76cc79c80ff265ca33e3" +dependencies = [ + "rustix 0.38.44", + "tempfile", + "windows-sys 0.52.0", +] + [[package]] name = "autocfg" version = "1.5.1" @@ -242,6 +245,12 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.13.1" @@ -321,6 +330,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d262e149917187838d5b42777c8253bcb64500067342904e7d429499a6f277e" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -336,6 +347,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures 0.2.17", +] + [[package]] name = "chacha20" version = "0.10.2" @@ -347,6 +369,19 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20 0.9.1", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "chrono" version = "0.4.45" @@ -368,6 +403,16 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common 0.1.7", "inout", + "zeroize", +] + +[[package]] +name = "clack-private-fs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fcca21d8096fca7f1c3a22c3109e38927c9b587007c9c7a13b327e5a955baba" +dependencies = [ + "windows-sys 0.61.2", ] [[package]] @@ -395,7 +440,7 @@ version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a68fa787550392a9d58f44c21a3022cfb3ea3e2458b7f85d3b399d0ceeccf409" dependencies = [ - "nix", + "nix 0.27.1", "winapi", ] @@ -427,7 +472,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ - "bitflags", + "bitflags 2.13.1", "core-foundation", "core-graphics-types", "foreign-types", @@ -440,7 +485,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" dependencies = [ - "bitflags", + "bitflags 2.13.1", "core-foundation", "core-graphics-types", "foreign-types", @@ -453,7 +498,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags", + "bitflags 2.13.1", "core-foundation", "libc", ] @@ -464,7 +509,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58" dependencies = [ - "bitflags", + "bitflags 2.13.1", "libc", "objc2-audio-toolbox", "objc2-core-audio", @@ -529,12 +574,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" - [[package]] name = "crypto-common" version = "0.1.7" @@ -582,17 +621,6 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -[[package]] -name = "derive_arbitrary" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "digest" version = "0.10.7" @@ -642,7 +670,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", ] @@ -776,6 +804,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs4" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e72ed92b67c146290f88e9c89d60ca163ea417a446f61ffd7b72df3e7f1dfd5" +dependencies = [ + "rustix 1.1.4", + "windows-sys 0.61.2", +] + [[package]] name = "futures" version = "0.3.34" @@ -880,7 +918,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix", + "rustix 1.1.4", "windows-link", ] @@ -897,6 +935,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + [[package]] name = "getrandom" version = "0.4.3" @@ -906,7 +956,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi", + "r-efi 6.0.0", "rand_core 0.10.1", "wasm-bindgen", ] @@ -933,6 +983,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + [[package]] name = "hmac" version = "0.12.1" @@ -1029,7 +1088,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots 1.0.9", + "webpki-roots", ] [[package]] @@ -1298,6 +1357,16 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + [[package]] name = "js-sys" version = "0.3.105" @@ -1324,6 +1393,12 @@ dependencies = [ "libc", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -1431,7 +1506,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags", + "bitflags 2.13.1", "jni-sys 0.3.1", "log", "ndk-sys", @@ -1460,8 +1535,20 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags", + "bitflags 2.13.1", + "cfg-if", + "libc", +] + +[[package]] +name = "nix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +dependencies = [ + "bitflags 2.13.1", "cfg-if", + "cfg_aliases", "libc", ] @@ -1553,7 +1640,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -1569,7 +1656,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-core-foundation", "objc2-core-graphics", @@ -1582,7 +1669,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08" dependencies = [ - "bitflags", + "bitflags 2.13.1", "libc", "objc2 0.6.4", "objc2-core-audio", @@ -1597,7 +1684,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-foundation 0.3.2", ] @@ -1621,7 +1708,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", ] @@ -1631,7 +1718,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1643,7 +1730,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "libc", @@ -1656,7 +1743,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags", + "bitflags 2.13.1", "dispatch2", "objc2 0.6.4", "objc2-core-foundation", @@ -1687,7 +1774,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -1699,7 +1786,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.6.2", "libc", "objc2 0.6.4", @@ -1712,7 +1799,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-core-foundation", ] @@ -1723,7 +1810,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1735,7 +1822,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1807,13 +1894,24 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags", + "bitflags 2.13.1", "crc32fast", "fdeflate", "flate2", "miniz_oxide", ] +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash", +] + [[package]] name = "polyval" version = "0.6.2" @@ -1945,6 +2043,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "r-efi" version = "6.0.0" @@ -1958,17 +2062,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + [[package]] name = "rand" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ - "chacha20", + "chacha20 0.10.2", "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -1983,6 +2097,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1992,6 +2116,15 @@ dependencies = [ "getrandom 0.2.17", ] +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "rand_core" version = "0.10.1" @@ -2013,7 +2146,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags", + "bitflags 2.13.1", ] [[package]] @@ -2094,7 +2227,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 1.0.9", + "webpki-roots", ] [[package]] @@ -2161,24 +2294,37 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.1", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.52.0", +] + [[package]] name = "rustix" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.13.1", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.12.1", "windows-sys 0.61.2", ] [[package]] name = "rustls" -version = "0.23.45" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ "log", "once_cell", @@ -2201,9 +2347,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.15" +version = "0.103.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" dependencies = [ "ring", "rustls-pki-types", @@ -2494,9 +2640,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.3", + "getrandom 0.3.4", "once_cell", - "rustix", + "rustix 1.1.4", "windows-sys 0.61.2", ] @@ -2572,7 +2718,7 @@ dependencies = [ [[package]] name = "tinybus" -version = "0.1.5" +version = "0.1.6" dependencies = [ "async-trait", "flate2", @@ -2588,12 +2734,12 @@ dependencies = [ "toml", "tracing", "ureq", - "zip 2.4.2", + "zip", ] [[package]] name = "tinybus-macros" -version = "0.1.5" +version = "0.1.6" dependencies = [ "proc-macro2", "quote", @@ -2602,7 +2748,7 @@ dependencies = [ [[package]] name = "tinybus-module" -version = "0.1.5" +version = "0.1.6" dependencies = [ "async-trait", "serde", @@ -2628,6 +2774,7 @@ dependencies = [ "tinycomputer-desktop", "tinycomputer-engine", "tokio", + "url", ] [[package]] @@ -2722,12 +2869,14 @@ dependencies = [ "getrandom 0.4.3", "serde", "serde_json", + "tinycomputer-browser", "tinycomputer-bus", "tinycomputer-core", "tinycomputer-desktop", "tinyinference-decisions", "tinyinference-llm", "tokio", + "url", ] [[package]] @@ -2758,7 +2907,7 @@ dependencies = [ [[package]] name = "tinyinference-core" -version = "0.3.0" +version = "0.5.0" dependencies = [ "anyhow", "httpdate", @@ -2768,7 +2917,7 @@ dependencies = [ [[package]] name = "tinyinference-decisions" -version = "0.3.0" +version = "0.5.0" dependencies = [ "async-trait", "httpdate", @@ -2781,10 +2930,10 @@ dependencies = [ [[package]] name = "tinyinference-llm" -version = "0.3.0" +version = "0.5.0" dependencies = [ "async-trait", - "base64 0.22.1", + "base64 0.23.1", "bytes", "futures", "reqwest", @@ -2792,11 +2941,67 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tinyinference-core", + "tinyinference-providers", "tinytools-agent", "tokio", "tracing", ] +[[package]] +name = "tinyinference-providers" +version = "0.5.0" +dependencies = [ + "base64 0.23.1", + "rand 0.10.3", + "reqwest", + "serde", + "serde_json", + "sha2 0.11.0", + "tinystoragedrivers-secrets", + "tracing", + "url", + "zeroize", +] + +[[package]] +name = "tinystoragedrivers-core" +version = "1.0.0" +source = "git+https://github.com/tinyhumansai/tinystoragedrivers?tag=v1.0.0#141fd9ed0ad5d14a8fb5a1b3e837a719e81ac08d" +dependencies = [ + "async-trait", + "data-encoding", + "serde", + "serde_json", + "sha2 0.10.9", + "thiserror 2.0.20", + "tokio", + "ulid", + "zstd", +] + +[[package]] +name = "tinystoragedrivers-secrets" +version = "1.0.0" +source = "git+https://github.com/tinyhumansai/tinystoragedrivers?tag=v1.0.0#141fd9ed0ad5d14a8fb5a1b3e837a719e81ac08d" +dependencies = [ + "async-trait", + "atomicwrites", + "chacha20poly1305", + "clack-private-fs", + "fs4", + "hkdf", + "rustix 1.1.4", + "serde", + "serde_json", + "sha2 0.10.9", + "tinystoragedrivers-core", + "tokio", + "winapi-util", + "windows-permissions", + "winsafe", + "zeroize", +] + [[package]] name = "tinystr" version = "0.8.4" @@ -2885,7 +3090,6 @@ dependencies = [ "tokio", "tokio-rustls", "tungstenite", - "webpki-roots 0.26.11", ] [[package]] @@ -2973,7 +3177,7 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags", + "bitflags 2.13.1", "bytes", "futures-util", "http", @@ -3066,6 +3270,16 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" +[[package]] +name = "ulid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe" +dependencies = [ + "rand 0.9.5", + "web-time", +] + [[package]] name = "unicase" version = "2.9.0" @@ -3108,7 +3322,7 @@ dependencies = [ "rustls-pki-types", "ureq-proto", "utf8-zero", - "webpki-roots 1.0.9", + "webpki-roots", ] [[package]] @@ -3201,6 +3415,15 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.128" @@ -3291,18 +3514,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" -dependencies = [ - "webpki-roots 1.0.9", -] - -[[package]] -name = "webpki-roots" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9" dependencies = [ "rustls-pki-types", ] @@ -3329,7 +3543,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] @@ -3510,6 +3724,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-permissions" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2ccdc3c6bf4d4a094e031b63fadd08d8e42abd259940eb8aa5fdc09d4bf9be" +dependencies = [ + "bitflags 1.3.2", + "winapi", +] + [[package]] name = "windows-result" version = "0.1.2" @@ -3722,6 +3946,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "winsafe" +version = "0.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef0ffc427f045c0cc9ebffd6f4f91153dcd2a1547b5c3c29ee3f541e16e95c6" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + [[package]] name = "writeable" version = "0.6.4" @@ -3735,7 +3971,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" dependencies = [ "gethostname", - "rustix", + "rustix 1.1.4", "x11rb-protocol", ] @@ -3752,7 +3988,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" dependencies = [ "libc", - "rustix", + "rustix 1.1.4", ] [[package]] @@ -3877,31 +4113,15 @@ dependencies = [ [[package]] name = "zip" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50" -dependencies = [ - "arbitrary", - "crc32fast", - "crossbeam-utils", - "displaydoc", - "flate2", - "indexmap", - "memchr", - "thiserror 2.0.20", - "zopfli", -] - -[[package]] -name = "zip" -version = "8.6.0" +version = "9.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e" dependencies = [ "crc32fast", "flate2", "indexmap", "memchr", + "nix 0.31.3", "typed-path", "zopfli", ] @@ -3930,6 +4150,34 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.1.2+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "zune-core" version = "0.5.3" diff --git a/crates/tinycomputer-browser/src/action_gate.rs b/crates/tinycomputer-browser/src/action_gate.rs new file mode 100644 index 000000000..3dbeb4831 --- /dev/null +++ b/crates/tinycomputer-browser/src/action_gate.rs @@ -0,0 +1,243 @@ +//! Host policy for actions sent to a browser page. + +use std::sync::Arc; + +use serde_json::Value; +use tinycomputer_bus::browser::{Action, ElementRef, Target}; + +/// Per-task facts supplied by the host when it creates a browser surface. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct ActionContext { + /// The task that is driving the page, when there is one. + pub task_id: Option, + /// The retained browser session driving this request, when it is open. + pub session_id: Option, + /// Whether payment handling is in play for the task. + pub payment_in_play: bool, +} + +/// A target resolved as far as the latest accessibility snapshot allows. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct ActionTarget { + /// The element's accessibility role, when known. + pub role: Option, + /// The element's accessible name, when known. + pub name: Option, + /// The snapshot ref used to identify the element, when known. + pub reference: Option, + /// Whether exactly one element in the latest snapshot has this role and + /// accessible name. Locators without a snapshot ref are never unique. + pub unique: bool, +} + +/// Page content an engine caller is about to receive. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ObservationKind { + /// The page's accessibility tree and controls. + Snapshot, + /// The page's extracted text, Markdown, or HTML. + ReadPage, + /// A screenshot of the page. + Screenshot, + /// A fixed browser-surface page-stability watcher. This exposes only + /// whether the page changed, not its content. + PageStability, + /// A fixed-purpose hit-test used by the browser surface before it decides + /// whether a target's pointer action is covered. + TargetCheck, +} + +/// Information a trusted host may inspect before the browser acts or returns +/// page content. +/// +/// `payload` contains the requested action and its value, including typed +/// text. It is intentionally omitted from `Debug`; implementations must treat +/// it as confidential and must not log or persist it. +pub struct ActionRequest { + /// The typed or raw browser action, including values sent to the page. + pub payload: Value, + /// The resolved semantic target, if the request names one. + pub target: Option, + /// The page's actual current URL immediately before the request. + /// The actual address the browser reported immediately before the request, + /// or `None` when the page is between documents and has no readable URL. + /// A host that makes page-specific decisions should refuse an unknown URL. + pub current_url: Option, + /// The requested destination for a navigation, when applicable. + pub destination_url: Option, + /// Whether this request observes page content rather than acting on it. + pub observation: Option, + /// Host-supplied task context. + pub context: ActionContext, +} + +impl ActionRequest { + pub(crate) fn typed( + action: &Action, + current_url: Option, + destination_url: Option, + context: &ActionContext, + refs: &[ElementRef], + ) -> Self { + let payload = serde_json::to_value(action).unwrap_or(Value::Null); + let target = action_target(action, refs); + Self { + payload, + target, + current_url, + destination_url, + observation: None, + context: context.clone(), + } + } + + pub(crate) fn raw( + payload: Value, + current_url: Option, + destination_url: Option, + context: &ActionContext, + refs: &[ElementRef], + ) -> Self { + let target = payload + .get("selector") + .and_then(Value::as_str) + .and_then(|selector| selector.strip_prefix('@')) + .and_then(|reference| resolve_reference(reference, refs)); + Self { + payload, + target, + current_url, + destination_url, + observation: None, + context: context.clone(), + } + } + + pub(crate) fn observation( + kind: ObservationKind, + current_url: Option, + context: &ActionContext, + ) -> Self { + Self { + payload: serde_json::json!({ "action": "observe" }), + target: None, + current_url, + destination_url: None, + observation: Some(kind), + context: context.clone(), + } + } +} + +impl std::fmt::Debug for ActionRequest { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter + .debug_struct("ActionRequest") + .field( + "action", + &self.payload.get("action").and_then(Value::as_str), + ) + .field("target", &self.target) + .field("current_url", &self.current_url) + .field("destination_url", &self.destination_url) + .field("observation", &self.observation) + .field("context", &self.context) + .finish_non_exhaustive() + } +} + +/// The host's decision for one action. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ActionVerdict { + /// Let the browser perform the request. + Allow, + /// Refuse it before any page interaction occurs. + Refuse { + /// A short explanation safe to show in task reports. Do not include + /// the request value in this message. + reason: String, + }, +} + +/// A synchronous host policy consulted before every typed or raw action and +/// before a snapshot, page read, or screenshot can expose content. +pub trait ActionGate: Send + Sync { + /// Decide whether this request may reach the page. + fn check(&self, request: &ActionRequest) -> ActionVerdict; +} + +/// A gate that leaves browser behavior unchanged. +#[derive(Debug, Default)] +pub struct AllowAllActions; + +impl ActionGate for AllowAllActions { + fn check(&self, _request: &ActionRequest) -> ActionVerdict { + ActionVerdict::Allow + } +} + +pub(crate) fn default_gate() -> Arc { + Arc::new(AllowAllActions) +} + +fn action_target(action: &Action, refs: &[ElementRef]) -> Option { + let target = match action { + Action::Click { target, .. } + | Action::DoubleClick { target } + | Action::Hover { target } + | Action::Focus { target } + | Action::Fill { target, .. } + | Action::Select { target, .. } + | Action::Check { target, .. } + | Action::GetText { target } + | Action::GetAttribute { target, .. } + | Action::IsVisible { target } => Some(target), + Action::Type { target, .. } + | Action::Press { target, .. } + | Action::Scroll { target, .. } + | Action::WaitFor { target, .. } => target.as_ref(), + Action::Back | Action::Forward | Action::Reload => None, + }?; + target_from_target(target, refs) +} + +fn target_from_target(target: &Target, refs: &[ElementRef]) -> Option { + match target { + Target::Ref { value } => resolve_reference(value, refs), + Target::Selector { .. } => None, + Target::Locator { value } if value.by == tinycomputer_bus::browser::LocateBy::Role => { + Some(ActionTarget { + role: Some(value.value.clone()), + name: value.name.clone(), + reference: None, + unique: false, + }) + } + Target::Locator { value } => Some(ActionTarget { + role: None, + name: Some(value.value.clone()), + reference: None, + unique: false, + }), + } +} + +fn resolve_reference(value: &str, refs: &[ElementRef]) -> Option { + let reference = value.strip_prefix('@').unwrap_or(value); + refs.iter() + .find(|item| item.id == reference) + .map(|item| ActionTarget { + role: Some(item.role.clone()), + name: Some(item.name.clone()), + reference: Some(item.id.clone()), + unique: refs + .iter() + .filter(|candidate| candidate.role == item.role && candidate.name == item.name) + .count() + == 1, + }) +} + +#[cfg(test)] +#[path = "action_gate_tests.rs"] +mod tests; diff --git a/crates/tinycomputer-browser/src/action_gate_tests.rs b/crates/tinycomputer-browser/src/action_gate_tests.rs new file mode 100644 index 000000000..18898b1be --- /dev/null +++ b/crates/tinycomputer-browser/src/action_gate_tests.rs @@ -0,0 +1,82 @@ +//! Tests for tests behavior. + +use serde_json::json; +use tinycomputer_bus::browser::{Action, ElementRef, Target}; + +use super::{ActionContext, ActionRequest, action_target, resolve_reference}; + +fn refs() -> Vec { + vec![ElementRef { + id: "e1".to_owned(), + role: "button".to_owned(), + name: "Place order".to_owned(), + }] +} + +#[test] +fn only_explicit_snapshot_refs_resolve_to_snapshot_metadata() { + let refs = refs(); + assert_eq!( + resolve_reference("@e1", &refs).map(|target| target.unique), + Some(true) + ); + assert_eq!( + resolve_reference("e1", &refs).map(|target| target.unique), + Some(true) + ); + assert!( + action_target( + &Action::Click { + target: Target::selector("e1"), + new_tab: false, + }, + &refs, + ) + .is_none() + ); +} + +#[test] +fn duplicate_snapshot_targets_are_not_reported_as_unique() { + let mut refs = refs(); + refs.push(ElementRef { + id: "e2".to_owned(), + role: "button".to_owned(), + name: "Place order".to_owned(), + }); + assert_eq!( + resolve_reference("e1", &refs).map(|target| target.unique), + Some(false) + ); + assert_eq!( + resolve_reference("e2", &refs).map(|target| target.unique), + Some(false) + ); +} + +#[test] +fn raw_css_selectors_do_not_alias_snapshot_refs() { + let refs = refs(); + let css = ActionRequest::raw( + json!({"action": "click", "selector": "e1"}), + Some("https://shop.test/".to_owned()), + None, + &ActionContext::default(), + &refs, + ); + let reference = ActionRequest::raw( + json!({"action": "click", "selector": "@e1"}), + Some("https://shop.test/".to_owned()), + None, + &ActionContext::default(), + &refs, + ); + assert!(css.target.is_none()); + assert_eq!( + reference + .target + .as_ref() + .and_then(|target| target.name.as_deref()), + Some("Place order") + ); +} diff --git a/crates/tinycomputer-browser/src/error/error_tests.rs b/crates/tinycomputer-browser/src/error/error_tests.rs index 899581155..2c10c7b70 100644 --- a/crates/tinycomputer-browser/src/error/error_tests.rs +++ b/crates/tinycomputer-browser/src/error/error_tests.rs @@ -62,6 +62,25 @@ fn a_lost_connection_tells_the_host_to_open_a_new_session() { ); } +#[test] +fn a_host_refusal_is_a_non_retryable_policy_denial() { + let error = Error::ActionRefused { + reason: "host did not allow the action".to_owned(), + }; + let envelope = error.envelope(); + + assert_eq!(error.wire_name(), errors::BLOCKED_BY_POLICY); + assert_eq!(envelope.code, "POLICY_DENIED"); + assert_eq!( + envelope.disposition.delivery, + DeliveryDisposition::NotDelivered + ); + assert_eq!( + envelope.message, + "action refused by host: host did not allow the action" + ); +} + #[test] fn stale_ref_tells_the_caller_to_snapshot_again() { let error = Error::StaleRef { @@ -110,6 +129,9 @@ fn every_variant() -> Vec { Error::BlockedByPolicy { url: "https://evil.test/".to_string(), }, + Error::ActionRefused { + reason: "blocked by the trusted host".to_owned(), + }, Error::LeftRefusedPage { url: "https://evil.test/".to_string(), }, @@ -218,6 +240,7 @@ fn only_failures_decided_before_the_page_claim_nothing_was_delivered() { | Error::NoSuchOutput { .. } | Error::StaleRef { .. } | Error::BlockedByPolicy { .. } + | Error::ActionRefused { .. } ) }; for error in every_variant() { diff --git a/crates/tinycomputer-browser/src/error/mod.rs b/crates/tinycomputer-browser/src/error/mod.rs index 258409d3e..1d4ee7989 100644 --- a/crates/tinycomputer-browser/src/error/mod.rs +++ b/crates/tinycomputer-browser/src/error/mod.rs @@ -98,6 +98,13 @@ pub enum Error { url: String, }, + /// The trusted host's action policy refused a request before it reached the page. + #[error("action refused by host: {reason}")] + ActionRefused { + /// The host's refusal reason. + reason: String, + }, + /// No browser could be launched or reached. #[error("browser unavailable: {message}")] BrowserUnavailable { @@ -175,6 +182,7 @@ impl Error { Self::PageError { .. } => errors::PAGE_ERROR, Self::NoSuchOutput { .. } => errors::NO_SUCH_OUTPUT, Self::LimitExceeded { .. } => errors::LIMIT_EXCEEDED, + Self::ActionRefused { .. } => errors::BLOCKED_BY_POLICY, Self::ModuleFailed { .. } => errors::MODULE_FAILED, } } @@ -243,6 +251,9 @@ impl Error { Self::LimitExceeded { .. } => { Some("close sessions or release outputs you no longer need") } + Self::ActionRefused { .. } => { + Some("follow the host policy before retrying this action") + } Self::InvalidInput { .. } | Self::Timeout { .. } | Self::BrowserUnavailable { .. } @@ -268,6 +279,7 @@ impl Error { | Self::NoSuchOutput { .. } | Self::StaleRef { .. } | Self::BlockedByPolicy { .. } + | Self::ActionRefused { .. } ) } diff --git a/crates/tinycomputer-browser/src/fake/mod.rs b/crates/tinycomputer-browser/src/fake/mod.rs index 8ab5ec21c..283a1d736 100644 --- a/crates/tinycomputer-browser/src/fake/mod.rs +++ b/crates/tinycomputer-browser/src/fake/mod.rs @@ -3,7 +3,10 @@ #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] -use std::sync::{Arc, Mutex}; +use std::{ + sync::{Arc, Mutex}, + time::Duration, +}; use serde_json::{Value, json}; @@ -38,6 +41,8 @@ pub(crate) struct Fake { script: Arc