From e4644504b67b3c64ef3e972eb200da4812d0ee1d Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Fri, 13 Dec 2024 12:47:45 +0100 Subject: [PATCH 1/5] servlet: wayback machine Signed-off-by: Edoardo Vacchi --- servlets/wayback-machine/.cargo/config.toml | 2 + servlets/wayback-machine/.gitignore | 2 + servlets/wayback-machine/Cargo.lock | 942 ++++++++++++++++++++ servlets/wayback-machine/Cargo.toml | 20 + servlets/wayback-machine/README.md | 32 + servlets/wayback-machine/prepare.sh | 58 ++ servlets/wayback-machine/src/lib.rs | 59 ++ servlets/wayback-machine/src/pdk.rs | 339 +++++++ servlets/wayback-machine/xtp.toml | 17 + 9 files changed, 1471 insertions(+) create mode 100755 servlets/wayback-machine/.cargo/config.toml create mode 100644 servlets/wayback-machine/.gitignore create mode 100644 servlets/wayback-machine/Cargo.lock create mode 100755 servlets/wayback-machine/Cargo.toml create mode 100644 servlets/wayback-machine/README.md create mode 100644 servlets/wayback-machine/prepare.sh create mode 100755 servlets/wayback-machine/src/lib.rs create mode 100755 servlets/wayback-machine/src/pdk.rs create mode 100755 servlets/wayback-machine/xtp.toml diff --git a/servlets/wayback-machine/.cargo/config.toml b/servlets/wayback-machine/.cargo/config.toml new file mode 100755 index 0000000..6b509f5 --- /dev/null +++ b/servlets/wayback-machine/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "wasm32-wasip1" diff --git a/servlets/wayback-machine/.gitignore b/servlets/wayback-machine/.gitignore new file mode 100644 index 0000000..c507849 --- /dev/null +++ b/servlets/wayback-machine/.gitignore @@ -0,0 +1,2 @@ +target +.idea diff --git a/servlets/wayback-machine/Cargo.lock b/servlets/wayback-machine/Cargo.lock new file mode 100644 index 0000000..2512b92 --- /dev/null +++ b/servlets/wayback-machine/Cargo.lock @@ -0,0 +1,942 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64-serde" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba368df5de76a5bea49aaf0cf1b39ccfbbef176924d1ba5db3e4135216cbe3c7" +dependencies = [ + "base64 0.21.7", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytemuck" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" + +[[package]] +name = "cc" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "extism-convert" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33423cbb1226c483f47a9cad883ee804caf45d8b0d2e5c03cd33d9e43ca5561" +dependencies = [ + "anyhow", + "base64 0.22.1", + "bytemuck", + "extism-convert-macros", + "prost", + "rmp-serde", + "serde", + "serde_json", +] + +[[package]] +name = "extism-convert-macros" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb132f6e20aab7e8eb3715e26ff8893c611abba73242e00771d740a0fbcb384" +dependencies = [ + "manyhow", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "extism-manifest" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9c8b50558af0a75ce08b8ef90a37fb018d99cc99a5f7365c33ba008afdbfb4" +dependencies = [ + "base64 0.22.1", + "serde", + "serde_json", +] + +[[package]] +name = "extism-pdk" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccd50f3ebae4132239ee188c00d91bda2b283db007213dd4bd6f3b4be4d3f82c" +dependencies = [ + "anyhow", + "base64 0.22.1", + "extism-convert", + "extism-manifest", + "extism-pdk-derive", + "serde", + "serde_json", +] + +[[package]] +name = "extism-pdk-derive" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a225e26f498571c273e095d9c2437acb0fd5d6ef3cb88d284d7e2d037d4d10" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "js-sys" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.168" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" + +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "manyhow" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b33efb3ca6d3b07393750d4030418d594ab1139cee518f0dc88db70fec873587" +dependencies = [ + "manyhow-macros", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "manyhow-macros" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fce34d199b78b6e6073abf984c9cf5fd3e9330145a93ee0738a7443e371495" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-utils" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaf08a13de400bc215877b5bdc088f241b12eb42f0a548d3390dc1c56bb7071" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "query-string-builder" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b71ad2010fcd6b911a2efb67fead507f6dd847301c1f77c870499e46b3768c" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rmp" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "2.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "wasm-bindgen" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" + +[[package]] +name = "wayback-machine" +version = "0.1.0" +dependencies = [ + "base64 0.21.7", + "base64-serde", + "chrono", + "extism-pdk", + "query-string-builder", + "serde", + "serde_json", + "url", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/servlets/wayback-machine/Cargo.toml b/servlets/wayback-machine/Cargo.toml new file mode 100755 index 0000000..2724e36 --- /dev/null +++ b/servlets/wayback-machine/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "wayback-machine" +version = "0.1.0" +edition = "2021" + +[lib] +name = "plugin" +crate-type = ["cdylib"] + +[dependencies] +extism-pdk = "1.1.0" +chrono = { version = "0.4", features = ["serde"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +base64-serde = "0.7" +base64 = "0.21" +url = "2.5.4" +query-string-builder = "0.6.0" + +[workspace] diff --git a/servlets/wayback-machine/README.md b/servlets/wayback-machine/README.md new file mode 100644 index 0000000..182777c --- /dev/null +++ b/servlets/wayback-machine/README.md @@ -0,0 +1,32 @@ +# Wayback Machine + +A simple tool to query the `archive.org` Wayback Machine using the API describe at https://archive.org/help/wayback_api.php. + +Requires domain access on `archive.org`. + +## Example + +Combined with the `fetch` tool, with domain access on `web.archive.org`: + +
+– what did the Onion home page looked on the closest date to 2014? + +Based on the Wayback Machine snapshot from January 1, 2014, The Onion's homepage featured several notable headlines and sections: +Top Stories: + +"The Onion's Tips For Hosting A New Year's Eve Party" +"Cousins Meaner This Year" +"Relatives Gather From Across The Country To Stare Into Screens Together" + +Other Key Sections: + +A "Our Annual Year: 2013" retrospective section +Commentary section featuring articles like "What Do You Get For The Man Who Already Has The Complete Fleetwood Mac Discography?" +American Voices section discussing "2013 In Entertainment" +News sections covering Politics, Local, Entertainment, Business +Video content including "The Onion Looks Back At 'It's A Wonderful Life'" review + +The site had a classic news website layout with multiple columns featuring different types of content, including news articles, commentary, videos, and special features. The design included social media links, a newsletter signup, and navigation menus for different content sections. +Would you like me to pull out any specific details about a particular section or article from this snapshot? + +
\ No newline at end of file diff --git a/servlets/wayback-machine/prepare.sh b/servlets/wayback-machine/prepare.sh new file mode 100644 index 0000000..edafa78 --- /dev/null +++ b/servlets/wayback-machine/prepare.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Function to check if a command exists +command_exists () { + command -v "$1" >/dev/null 2>&1 +} + +missing_deps=0 + +# Check for Cargo +if ! (command_exists cargo); then + missing_deps=1 + echo "❌ Cargo/rust is not installed." + echo "" + echo "To install Rust, visit the official download page:" + echo "👉 https://www.rust-lang.org/tools/install" + echo "" + echo "Or install it using a package manager:" + echo "" + echo "🔹 macOS (Homebrew):" + echo " brew install cargo" + echo "" + echo "🔹 Ubuntu/Debian:" + echo " sudo apt-get install -y cargo" + echo "" + echo "🔹 Arch Linux:" + echo " sudo pacman -S rust" + echo "" +fi + +if ! (command_exists rustup); then + missing_deps=1 + echo "❌ rustup is missing. Check your rust installation." + echo "" +fi + +# Exit with a bad exit code if any dependencies are missing +if [ "$missing_deps" -ne 0 ]; then + echo "Install the missing dependencies and ensure they are on your path. Then run this command again." + # TODO: remove sleep when cli bug is fixed + sleep 2 + exit 1 +fi + +if ! (rustup target list --installed | grep -q '^wasm32-wasip1$'); then + if ! (rustup target add wasm32-wasip1); then + echo "❌ error encountered while adding target \"wasm32-wasip1\"" + echo "" + echo "Update rustup with:" + echo "👉 rustup update" + echo "" + exit 1 + fi +fi + +if ! (rustup target list --installed | grep -q '^wasm32-unknown-unknown$'); then + rustup target add wasm32-unknown-unknown +fi diff --git a/servlets/wayback-machine/src/lib.rs b/servlets/wayback-machine/src/lib.rs new file mode 100755 index 0000000..8660908 --- /dev/null +++ b/servlets/wayback-machine/src/lib.rs @@ -0,0 +1,59 @@ +mod pdk; + +use extism_pdk::*; +use pdk::types::{CallToolResult, Content, ContentType, ToolDescription}; +use pdk::*; +use query_string_builder::QueryString; +use serde_json::json; + +// Called when the tool is invoked. +pub(crate) fn call(request: types::CallToolRequest) -> Result { + let args = request.params.arguments.unwrap_or_default(); + let qs = QueryString::simple() + .with_value("url", args.get("url").unwrap()) + .with_opt_value("timestamp", args.get("timestamp")); + + let wmurl = format!("http://archive.org/wayback/available{qs}"); + let req = HttpRequest::new(wmurl); + let res = http::request::<()>(&req, None)?; + + // http://archive.org/wayback/available?url= + Ok(CallToolResult { + content: vec![Content { + text: Some(std::str::from_utf8(&res.body()).unwrap().to_string()), + r#type: ContentType::Text, + ..Default::default() + }], + is_error: Some(false), + }) +} + +// Called by mcpx to understand how and why to use this tool. +// Note: these imports are NOT available in this context: config_get +pub(crate) fn describe() -> Result { + Ok(ToolDescription { + name: "wayback-machine".into(), + description: "Looks up a URL on the Wayback Machine \ + and returns the snapshots that are available".into(), + input_schema: json!({ + "type": "object", + "required": ["name"], + "properties": { + "url": { + "type": "string", + "description": "The URL to lookup on the Wayback Machine", + }, + "timestamp": { + "type": "string", + "description": "Optional timestamp. The format of the timestamp is 1-14 digits (YYYYMMDDhhmmss) ex: + timestamp=20060101 would return the closest snapshot to January 1, 2006. You can omit any parts of the timestamp, + ex: timestamp=2006 would return the closest snapshot to January 1, 2006." + }, + "required" : ["url"] + } + }) + .as_object() + .unwrap() + .clone(), + }) +} diff --git a/servlets/wayback-machine/src/pdk.rs b/servlets/wayback-machine/src/pdk.rs new file mode 100755 index 0000000..9dcff0e --- /dev/null +++ b/servlets/wayback-machine/src/pdk.rs @@ -0,0 +1,339 @@ +// THIS FILE WAS GENERATED BY `xtp-rust-bindgen`. DO NOT EDIT. + +#![allow(non_snake_case)] +#![allow(unused_macros)] +use extism_pdk::*; + +#[allow(unused)] +fn panic_if_key_missing() -> ! { + panic!("missing key"); +} + +pub(crate) mod internal { + pub(crate) fn return_error(e: extism_pdk::Error) -> i32 { + let err = format!("{:?}", e); + let mem = extism_pdk::Memory::from_bytes(&err).unwrap(); + unsafe { + extism_pdk::extism::error_set(mem.offset()); + } + -1 + } +} + +#[allow(unused)] +macro_rules! try_input { + () => {{ + let x = extism_pdk::input(); + match x { + Ok(x) => x, + Err(e) => return internal::return_error(e), + } + }}; +} + +#[allow(unused)] +macro_rules! try_input_json { + () => {{ + let x = extism_pdk::input(); + match x { + Ok(extism_pdk::Json(x)) => x, + Err(e) => return internal::return_error(e), + } + }}; +} + +use base64_serde::base64_serde_type; + +base64_serde_type!(Base64Standard, base64::engine::general_purpose::STANDARD); + +mod exports { + use super::*; + + #[no_mangle] + pub extern "C" fn call() -> i32 { + let ret = + crate::call(try_input_json!()).and_then(|x| extism_pdk::output(extism_pdk::Json(x))); + + match ret { + Ok(()) => 0, + Err(e) => internal::return_error(e), + } + } + + #[no_mangle] + pub extern "C" fn describe() -> i32 { + let ret = crate::describe().and_then(|x| extism_pdk::output(extism_pdk::Json(x))); + + match ret { + Ok(()) => 0, + Err(e) => internal::return_error(e), + } + } +} + +pub mod types { + use super::*; + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct BlobResourceContents { + /// A base64-encoded string representing the binary data of the item. + #[serde(rename = "blob")] + pub blob: String, + + /// The MIME type of this resource, if known. + #[serde(rename = "mimeType")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub mime_type: Option, + + /// The URI of this resource. + #[serde(rename = "uri")] + pub uri: String, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct CallToolRequest { + #[serde(rename = "method")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub method: Option, + + #[serde(rename = "params")] + pub params: types::Params, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct CallToolResult { + #[serde(rename = "content")] + pub content: Vec, + + /// Whether the tool call ended in an error. + /// + /// If not set, this is assumed to be false (the call was successful). + #[serde(rename = "isError")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_error: Option, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct Content { + #[serde(rename = "annotations")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub annotations: Option, + + /// The base64-encoded image data. + #[serde(rename = "data")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub data: Option, + + /// The MIME type of the image. Different providers may support different image types. + #[serde(rename = "mimeType")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub mime_type: Option, + + /// The text content of the message. + #[serde(rename = "text")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub text: Option, + + #[serde(rename = "type")] + pub r#type: types::ContentType, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub enum ContentType { + #[default] + #[serde(rename = "text")] + Text, + #[serde(rename = "image")] + Image, + #[serde(rename = "resource")] + Resource, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct Params { + #[serde(rename = "arguments")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub arguments: Option>, + + #[serde(rename = "name")] + pub name: String, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub enum Role { + #[default] + #[serde(rename = "assistant")] + Assistant, + #[serde(rename = "user")] + User, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct TextAnnotation { + /// Describes who the intended customer of this object or data is. + /// + /// It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). + #[serde(rename = "audience")] + pub audience: Vec, + + /// Describes how important this data is for operating the server. + /// + /// A value of 1 means "most important," and indicates that the data is + /// effectively required, while 0 means "least important," and indicates that + /// the data is entirely optional. + #[serde(rename = "priority")] + pub priority: f32, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct TextResourceContents { + /// The MIME type of this resource, if known. + #[serde(rename = "mimeType")] + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub mime_type: Option, + + /// The text of the item. This must only be set if the item can actually be represented as text (not binary data). + #[serde(rename = "text")] + pub text: String, + + /// The URI of this resource. + #[serde(rename = "uri")] + pub uri: String, + } + + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct ToolDescription { + /// A description of the tool + #[serde(rename = "description")] + pub description: String, + + /// The JSON schema describing the argument input + #[serde(rename = "inputSchema")] + pub input_schema: serde_json::Map, + + /// The name of the tool. It should match the plugin / binding name. + #[serde(rename = "name")] + pub name: String, + } +} + +mod raw_imports { + use super::*; + #[host_fn] + extern "ExtismHost" { + + pub(crate) fn config_get(input: String) -> Json; + + } +} + +/// config_get Get the configuration for the tool +/// It takes input of String (The config key) +/// And it returns an output String (The config value for the given key, or empty if not found) +#[allow(unused)] +pub(crate) fn config_get(input: String) -> std::result::Result { + let res = unsafe { raw_imports::config_get(input)? }; + + let extism_pdk::Json(res) = res; + + Ok(res) +} diff --git a/servlets/wayback-machine/xtp.toml b/servlets/wayback-machine/xtp.toml new file mode 100755 index 0000000..4df043d --- /dev/null +++ b/servlets/wayback-machine/xtp.toml @@ -0,0 +1,17 @@ +app_id = "app_01je4dgpcyfvgrz8f1ys3pbxas" + +# This is where 'xtp plugin push' expects to find the wasm file after the build script has run. +bin = "target/wasm32-wasip1/release/plugin.wasm" +extension_point_id = "ext_01je4jj1tteaktf0zd0anm8854" +name = "wayback-machine" + +[scripts] + + # xtp plugin build runs this script to generate the wasm file + build = "cargo build --release --target wasm32-wasip1" + + # xtp plugin init runs this script to format the plugin code + format = "cargo fmt" + + # xtp plugin init runs this script before running the format script + prepare = "bash prepare.sh" From bfb0472f8ed812900a7d34ab785283d09171a676 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Fri, 13 Dec 2024 15:03:17 +0100 Subject: [PATCH 2/5] incorrect schema Signed-off-by: Edoardo Vacchi --- servlets/wayback-machine/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/servlets/wayback-machine/src/lib.rs b/servlets/wayback-machine/src/lib.rs index 8660908..13bb5b7 100755 --- a/servlets/wayback-machine/src/lib.rs +++ b/servlets/wayback-machine/src/lib.rs @@ -37,7 +37,7 @@ pub(crate) fn describe() -> Result { and returns the snapshots that are available".into(), input_schema: json!({ "type": "object", - "required": ["name"], + "required" : ["url"], "properties": { "url": { "type": "string", @@ -49,7 +49,6 @@ pub(crate) fn describe() -> Result { timestamp=20060101 would return the closest snapshot to January 1, 2006. You can omit any parts of the timestamp, ex: timestamp=2006 would return the closest snapshot to January 1, 2006." }, - "required" : ["url"] } }) .as_object() From 5d757fcee0285f8964547e2cfa453168a74e8026 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Fri, 13 Dec 2024 15:06:08 +0100 Subject: [PATCH 3/5] incorrect schema Signed-off-by: Edoardo Vacchi --- servlets/wayback-machine/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servlets/wayback-machine/src/lib.rs b/servlets/wayback-machine/src/lib.rs index 13bb5b7..23ce320 100755 --- a/servlets/wayback-machine/src/lib.rs +++ b/servlets/wayback-machine/src/lib.rs @@ -37,7 +37,6 @@ pub(crate) fn describe() -> Result { and returns the snapshots that are available".into(), input_schema: json!({ "type": "object", - "required" : ["url"], "properties": { "url": { "type": "string", @@ -49,6 +48,7 @@ pub(crate) fn describe() -> Result { timestamp=20060101 would return the closest snapshot to January 1, 2006. You can omit any parts of the timestamp, ex: timestamp=2006 would return the closest snapshot to January 1, 2006." }, + "required" : ["url"] } }) .as_object() From 5dc78fe2a06079889682199ee49d280d66abcf47 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Fri, 13 Dec 2024 15:51:07 +0100 Subject: [PATCH 4/5] incorrect schema Signed-off-by: Edoardo Vacchi --- servlets/wayback-machine/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servlets/wayback-machine/src/lib.rs b/servlets/wayback-machine/src/lib.rs index 23ce320..7ea2515 100755 --- a/servlets/wayback-machine/src/lib.rs +++ b/servlets/wayback-machine/src/lib.rs @@ -37,6 +37,7 @@ pub(crate) fn describe() -> Result { and returns the snapshots that are available".into(), input_schema: json!({ "type": "object", + "required" : ["url"], "properties": { "url": { "type": "string", @@ -48,7 +49,6 @@ pub(crate) fn describe() -> Result { timestamp=20060101 would return the closest snapshot to January 1, 2006. You can omit any parts of the timestamp, ex: timestamp=2006 would return the closest snapshot to January 1, 2006." }, - "required" : ["url"] } }) .as_object() From 149c612f2a54a75390a5859897d7fe78c4062244 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 15 Dec 2024 20:50:48 +0100 Subject: [PATCH 5/5] update schema Signed-off-by: Edoardo Vacchi --- servlets/wayback-machine/src/lib.rs | 10 +++++---- servlets/wayback-machine/src/pdk.rs | 34 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/servlets/wayback-machine/src/lib.rs b/servlets/wayback-machine/src/lib.rs index 7ea2515..59c2bd8 100755 --- a/servlets/wayback-machine/src/lib.rs +++ b/servlets/wayback-machine/src/lib.rs @@ -1,10 +1,11 @@ mod pdk; use extism_pdk::*; -use pdk::types::{CallToolResult, Content, ContentType, ToolDescription}; +use pdk::types::{CallToolResult, Content, ContentType, ListToolsResult}; use pdk::*; use query_string_builder::QueryString; use serde_json::json; +use types::ToolDescription; // Called when the tool is invoked. pub(crate) fn call(request: types::CallToolRequest) -> Result { @@ -30,8 +31,9 @@ pub(crate) fn call(request: types::CallToolRequest) -> Result Result { - Ok(ToolDescription { +pub(crate) fn describe() -> Result { + Ok(ListToolsResult{ + tools: vec![ToolDescription { name: "wayback-machine".into(), description: "Looks up a URL on the Wayback Machine \ and returns the snapshots that are available".into(), @@ -54,5 +56,5 @@ pub(crate) fn describe() -> Result { .as_object() .unwrap() .clone(), - }) + }]}) } diff --git a/servlets/wayback-machine/src/pdk.rs b/servlets/wayback-machine/src/pdk.rs index 9dcff0e..c7d199b 100755 --- a/servlets/wayback-machine/src/pdk.rs +++ b/servlets/wayback-machine/src/pdk.rs @@ -201,6 +201,22 @@ pub mod types { Resource, } + #[derive( + Default, + Debug, + Clone, + serde::Serialize, + serde::Deserialize, + extism_pdk::FromBytes, + extism_pdk::ToBytes, + )] + #[encoding(Json)] + pub struct ListToolsResult { + /// The list of ToolDescription objects provided by this servlet. + #[serde(rename = "tools")] + pub tools: Vec, + } + #[derive( Default, Debug, @@ -319,21 +335,5 @@ pub mod types { mod raw_imports { use super::*; #[host_fn] - extern "ExtismHost" { - - pub(crate) fn config_get(input: String) -> Json; - - } -} - -/// config_get Get the configuration for the tool -/// It takes input of String (The config key) -/// And it returns an output String (The config value for the given key, or empty if not found) -#[allow(unused)] -pub(crate) fn config_get(input: String) -> std::result::Result { - let res = unsafe { raw_imports::config_get(input)? }; - - let extism_pdk::Json(res) = res; - - Ok(res) + extern "ExtismHost" {} }