The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat: route document conversion through TinyDocs
Steven Enamakel2f99cb505ed7
diff --git a/Cargo.lock b/Cargo.lockindex f377ca7f78..3b6143e8fa 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -17,15 +17,6 @@ version = "2.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"-[[package]]-name = "adobe-cmap-parser"-version = "0.4.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "ae8abfa9a4688de8fc9f42b3f013b6fffec18ed8a554f5f113577e0b9b3212a3"-dependencies = [- "pom",-]-[[package]]name = "aead"version = "0.5.2"@@ -331,16 +322,6 @@ dependencies = ["syn 3.0.6",]-[[package]]-name = "atoi_simd"-version = "0.18.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f3cdb3708a128e559a30fb830e8a77a5022ee6902806925c216658652b452a44"-dependencies = [- "debug_unsafe",- "rustversion",-]-[[package]]name = "atomic"version = "0.6.1"@@ -571,15 +552,6 @@ dependencies = ["hybrid-array",]-[[package]]-name = "block-padding"-version = "0.3.3"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"-dependencies = [- "generic-array",-]-[[package]]name = "block-padding"version = "0.4.2"@@ -775,23 +747,6 @@ dependencies = ["serde",]-[[package]]-name = "calamine"-version = "0.36.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5fa68281b1a76b54a62156474adb06bb380a67e07dd60656e3217152b42183f3"-dependencies = [- "atoi_simd",- "byteorder",- "codepage",- "encoding_rs",- "fast-float2",- "log",- "quick-xml 0.41.0",- "serde",- "zip 8.6.0",-]-[[package]]name = "cap-fs-ext"version = "4.0.3"@@ -843,15 +798,6 @@ dependencies = ["rustversion",]-[[package]]-name = "cbc"-version = "0.1.2"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"-dependencies = [- "cipher 0.4.4",-]-[[package]]name = "cbc"version = "0.2.1"@@ -871,12 +817,6 @@ dependencies = ["shlex",]-[[package]]-name = "cff-parser"-version = "0.2.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c5810ca1a2b5870df2aab1c03e11c40c361ba51d6e3e361e56310f1cb3b4e087"-[[package]]name = "cfg-if"version = "1.0.5"@@ -1040,15 +980,6 @@ dependencies = ["objc",]-[[package]]-name = "codepage"-version = "0.1.3"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "bdff162541cd8b79de82e2edcc7eff3a8c2a6dc3d75152636028f96d93de3b26"-dependencies = [- "encoding_rs",-]-[[package]]name = "coins-bip32"version = "0.13.2"@@ -1315,12 +1246,6 @@ dependencies = ["libc",]-[[package]]-name = "core_detect"-version = "1.0.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"-[[package]]name = "coreaudio-rs"version = "0.14.2"@@ -1648,12 +1573,6 @@ version = "0.1.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b"-[[package]]-name = "debug_unsafe"-version = "0.1.4"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7eed2c4702fa172d1ce21078faa7c5203e69f5394d48cc436d25928394a867a2"-[[package]]name = "debugid"version = "0.8.0"@@ -1879,15 +1798,6 @@ version = "1.0.20"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"-[[package]]-name = "ecb"-version = "0.1.2"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1a8bfa975b1aec2145850fcaa1c6fe269a16578c44705a532ae3edc92b8881c7"-dependencies = [- "cipher 0.4.4",-]-[[package]]name = "ecdsa"version = "0.16.9"@@ -1970,20 +1880,6 @@ dependencies = ["serde",]-[[package]]-name = "encoding_rs"-version = "0.8.42"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"-dependencies = [- "cfg-if",- "core_detect",- "multiversion_no_op",- "rustversion",- "scopeguard",- "simdutf8",-]-[[package]]name = "engineioxide"version = "0.15.2"@@ -2095,15 +1991,6 @@ version = "3.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7"-[[package]]-name = "euclid"-version = "0.20.14"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "2bb7ef65b3777a325d1eeefefab5b6d4959da54747e33bd6258e789640f307ad"-dependencies = [- "num-traits",-]-[[package]]name = "euclid"version = "0.22.14"@@ -2172,12 +2059,6 @@ dependencies = ["regex-syntax",]-[[package]]-name = "fast-float2"-version = "0.2.4"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c6e8948ce679d00a02a94739ea185595dca7118ed04feb991127e443bd3d761f"-[[package]]name = "fastrand"version = "2.5.0"@@ -3106,7 +2987,6 @@ version = "0.1.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"dependencies = [- "block-padding 0.3.3","generic-array",]@@ -3116,7 +2996,7 @@ version = "0.2.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"dependencies = [- "block-padding 0.4.2",+ "block-padding","hybrid-array",]@@ -3597,33 +3477,6 @@ version = "0.4.34"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"-[[package]]-name = "lopdf"-version = "0.42.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "25aab26d99567469098e64a02f42679f8965c6401263eefa31d8f2dcc37a221c"-dependencies = [- "aes 0.8.4",- "bitflags 2.13.2",- "cbc 0.1.2",- "ecb",- "encoding_rs",- "flate2",- "getrandom 0.4.3",- "indexmap",- "itoa",- "log",- "md-5 0.10.6",- "nom 8.0.0",- "rand 0.10.2",- "rangemap",- "sha2 0.10.9",- "stringprep",- "thiserror 2.0.20",- "ttf-parser",- "weezl",-]-[[package]]name = "lru"version = "0.18.4"@@ -3748,16 +3601,6 @@ version = "0.3.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4"-[[package]]-name = "md-5"-version = "0.10.6"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"-dependencies = [- "cfg-if",- "digest 0.10.7",-]-[[package]]name = "md-5"version = "0.11.0"@@ -3918,7 +3761,7 @@ dependencies = ["hickory-resolver","hmac 0.13.0","macro_magic",- "md-5 0.11.0",+ "md-5","mongocrypt","mongodb-internal-macros","pbkdf2 0.13.0",@@ -3956,12 +3799,6 @@ dependencies = ["syn 2.0.119",]-[[package]]-name = "multiversion_no_op"-version = "1.0.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"-[[package]]name = "native-tls"version = "0.2.18"@@ -4701,7 +4538,7 @@ dependencies = ["wiremock","x25519-dalek 2.0.1","zeroize",- "zip 2.4.2",+ "zip",][[package]]@@ -5054,23 +4891,6 @@ dependencies = ["digest 0.11.3",]-[[package]]-name = "pdf-extract"-version = "0.12.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "e5c4820f5811e424ce037d08493ac87752ecc54339e0f1e40c3d17da93278861"-dependencies = [- "adobe-cmap-parser",- "cff-parser",- "encoding_rs",- "euclid 0.20.14",- "log",- "lopdf",- "postscript",- "type1-encoding-parser",- "unicode-normalization",-]-[[package]]name = "percent-encoding"version = "2.3.2"@@ -5245,7 +5065,7 @@ checksum = "2896bade328c13f7042a297ea5ac5b0951f6cf989dea5f32c2fd98da398195cb"dependencies = ["base64 0.23.1","indexmap",- "quick-xml 0.42.0",+ "quick-xml","serde","time",]@@ -5284,12 +5104,6 @@ dependencies = ["universal-hash 0.6.1",]-[[package]]-name = "pom"-version = "1.1.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "60f6ce597ecdcc9a098e7fddacb1065093a3d66446fa16c675e7e71d1b5c28e6"-[[package]]name = "portable-atomic"version = "1.15.0"@@ -5305,12 +5119,6 @@ dependencies = ["portable-atomic",]-[[package]]-name = "postscript"-version = "0.14.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "78451badbdaebaf17f053fd9152b3ffb33b516104eacb45e7864aaa9c712f306"-[[package]]name = "potential_utf"version = "0.1.6"@@ -5432,16 +5240,6 @@ version = "1.2.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"-[[package]]-name = "quick-xml"-version = "0.41.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1"-dependencies = [- "encoding_rs",- "memchr",-]-[[package]]name = "quick-xml"version = "0.42.0"@@ -5634,12 +5432,6 @@ dependencies = ["rand_core 0.9.5",]-[[package]]-name = "rangemap"-version = "1.8.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d"-[[package]]name = "ratatui"version = "0.30.2"@@ -7225,7 +7017,7 @@ dependencies = ["tracing","uuid","wait-timeout",- "zip 2.4.2",+ "zip",][[package]]@@ -7384,7 +7176,7 @@ dependencies = ["toml","tracing","ureq",- "zip 2.4.2",+ "zip",][[package]]@@ -7508,7 +7300,7 @@ dependencies = [[[package]]name = "tinydocs-bus"-version = "0.1.22"+version = "0.2.0"dependencies = ["serde","thiserror 2.0.20",@@ -7883,12 +7675,9 @@ name = "tinymemory-integrations"version = "1.27.2"dependencies = ["async-trait",- "calamine","chrono","futures","log",- "pdf-extract",- "quick-xml 0.41.0","regex","reqwest 0.12.28","rusqlite",@@ -7902,7 +7691,6 @@ dependencies = ["tokio","tracing","walkdir",- "zip 8.6.0",][[package]]@@ -8526,12 +8314,6 @@ version = "0.2.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"-[[package]]-name = "ttf-parser"-version = "0.25.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31"-[[package]]name = "tungstenite"version = "0.24.0"@@ -8587,15 +8369,6 @@ dependencies = ["thiserror 2.0.20",]-[[package]]-name = "type1-encoding-parser"-version = "0.1.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "fa10c302f5a53b7ad27fd42a3996e23d096ba39b5b8dd6d9e683a05b01bee749"-dependencies = [- "pom",-]-[[package]]name = "typed-arena"version = "2.0.2"@@ -8622,12 +8395,6 @@ dependencies = ["syn 2.0.119",]-[[package]]-name = "typed-path"-version = "0.12.3"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e"-[[package]]name = "typenum"version = "1.20.1"@@ -9003,7 +8770,7 @@ dependencies = ["async-trait","buffa","bytes",- "cbc 0.2.1",+ "cbc","chrono","ctr 0.10.1","curve25519-dalek 5.0.0",@@ -9216,12 +8983,6 @@ dependencies = ["rustls-pki-types",]-[[package]]-name = "weezl"-version = "0.1.12"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"-[[package]]name = "wezterm-bidi"version = "0.2.3"@@ -9288,7 +9049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e"dependencies = ["bitflags 1.3.2",- "euclid 0.22.14",+ "euclid","lazy_static","serde","wezterm-dynamic",@@ -10053,20 +9814,6 @@ dependencies = ["zopfli",]-[[package]]-name = "zip"-version = "8.6.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"-dependencies = [- "crc32fast",- "flate2",- "indexmap",- "memchr",- "typed-path",- "zopfli",-]-[[package]]name = "zlib-rs"version = "0.6.8"diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.tomlindex 5a3364b60d..2f7d3c4ff0 100644--- a/crates/openhuman-core/Cargo.toml+++ b/crates/openhuman-core/Cargo.toml@@ -686,8 +686,8 @@ storage-file = []# Why the split: the gates left ON below cost almost nothing to compile, so# keeping them on means `cargo check` and rust-analyzer still typecheck nearly# all of the tree. The gates turned OFF are the ones that carry the graph —-# web3's ethers/secp256k1 cohort, `documents`' zstd/bzip2 native builds,-# `voice`+`inference`'s cpal/lettre/arboard/enigo/rdev stack and+# web3's ethers/secp256k1 cohort, the+# `voice`+`inference` cpal/lettre/arboard/enigo/rdev stack and# `crash-reporting`'s sentry tree. The terminal-specific# ratatui/crossterm cohort lives in the separate `openhuman-tui` package.# Turning the core gates off takes a@@ -760,10 +760,10 @@ inference = ["tinycomputer-accessibility/microphone-probe"]# reference instead of extracted text# (`agent::multimodal::extract_pdf_text`). Slim / headless builds opt out via# `--no-default-features --features "<explicit list without documents>"`.-# `tinymemory-integrations/documents-office`: memory's brain and file sources-# read PDF, DOCX, PPTX and XLSX (memory::convert). Kept behind `documents` so-# the parsers stay off the always-on path (kernel floor).-documents = ["modules", "dep:tinydocs-bus", "tinymemory-integrations/documents-office"]+# Memory's brain and file sources send PDF, DOCX, PPTX and XLSX to the+# TinyDocs module. The host includes only its pure bus vocabulary; document+# parsers stay in the module.+documents = ["modules", "dep:tinydocs-bus"]# Hosting: the `hosting_*` agent tools that put a workspace on a real hosting# provider — a site, a managed database wired into it, its environment, its# domains, its deployments and the traffic they served. Default-OFF,diff --git a/crates/openhuman-core/src/agent/attachments/README.md b/crates/openhuman-core/src/agent/attachments/README.mdindex 059fe42c37..5ed7ebeb1b 100644--- a/crates/openhuman-core/src/agent/attachments/README.md+++ b/crates/openhuman-core/src/agent/attachments/README.md@@ -92,7 +92,8 @@ retain the source references so later requests can reevaluate routing.## Published document capability-The pinned TinyDocs `0.1.22` release exposes `ExtractDocument` and `RenderPdf`.+The pinned TinyDocs `0.2.0` release exposes `ExtractDocument`, `InspectImage`+and `RenderPdf`.Its source tag and all 11 platform archive digests match the published releasemanifest. Office extraction, PDF text extraction, and bounded scanned-pagerendering use this native module through the shared bus contract. A disabled ordiff --git a/crates/openhuman-core/src/memory/README.md b/crates/openhuman-core/src/memory/README.mdindex e5cd38c04c..34fcec6122 100644--- a/crates/openhuman-core/src/memory/README.md+++ b/crates/openhuman-core/src/memory/README.md@@ -196,10 +196,11 @@ The brain is the set of documents every agent under a root shares, filed at`source:<connector>` nodes with no agent id ([`brain.rs`](./brain.rs)). A file ingestedfrom the UI (`memory_brain_ingest`) goes under `files`; synced sources arefiled by what they read. Files are converted through [`convert.rs`](./convert.rs): PDF,-DOCX, PPTX and XLSX go through TinyMemory's `OfficeConverter` on Tokio's-blocking pool when the `documents` feature is on, then `NativeConverter`-handles text, markdown, HTML and code. Every ingest queues a belief build of-the source's scope.+DOCX, PPTX and XLSX are streamed to the configured TinyDocs module when the+`documents` feature is on, then `NativeConverter` handles text, markdown, HTML+and code. The host carries only the bus contract and current config; it has no+local office parser fallback. Every ingest queues a belief build of the+source's scope.Sources ([`sources/`](./sources/)) are the `[[memory.sources]]` registry in `config.toml`:a folder, a file, a web page, a GitHub repository or an RSS feed, plus howdiff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rsindex ae17416dc7..41d67b8921 100644--- a/crates/openhuman-core/src/memory/brain.rs+++ b/crates/openhuman-core/src/memory/brain.rs@@ -343,7 +343,7 @@ pub async fn ingest(config: &Config, params: BrainIngestParams) -> MemoryResult<let mut meta = tinymemory_api::MemoryMeta::default();meta.file_path = Some(path.display().to_string());tinymemory_integrations::brain::brain_document(- super::convert::converter(),+ &super::convert::converter(config),&raw,Some(source.unwrap_or_else(files_source)),meta,diff --git a/crates/openhuman-core/src/memory/convert.rs b/crates/openhuman-core/src/memory/convert.rsindex ebe43beec5..4422e74e5f 100644--- a/crates/openhuman-core/src/memory/convert.rs+++ b/crates/openhuman-core/src/memory/convert.rs@@ -1,77 +1,88 @@-//! The document converter memory files with: PDF, DOCX, PPTX and XLSX through-//! TinyMemory's `OfficeConverter` (with the `documents` feature, which the-//! shipped product enables), then its `NativeConverter` for text, markdown,-//! HTML and code. Without `documents` the chain is native only, and an office-//! file is refused as before; the parsers stay off the always-on path.+//! Memory document conversion through the TinyDocs module.//!-//! Brain ingest (`memory_brain_ingest` with a `path`) and file-backed sources-//! (folder, file) both convert through [`converter`], so a PDF filed by hand-//! and a PDF in a synced folder read the same. Without the office converter-//! both refused office formats with "the native converter does not handle-//! pdf" (#6718).-//!-//! Office parsing is CPU-bound and synchronous, so it runs on Tokio's-//! blocking pool rather than on a runtime worker (`OfficeConverter`'s own-//! async `convert` would parse inline). Size is capped upstream by-//! `MAX_DOCUMENT_BYTES`.--use std::sync::LazyLock;+//! Brain ingest and file-backed sources share this chain. Textual formats stay+//! with TinyMemory's native converter; PDF, DOCX, PPTX and XLSX are extracted+//! by the configured TinyDocs module, with no host-side parser fallback.+use crate::config::Config;use tinymemory_integrations::documents::ConverterChain;++#[cfg(feature = "documents")]+use async_trait::async_trait;#[cfg(feature = "documents")]-use {- async_trait::async_trait,- tinymemory_integrations::documents::{- ConvertedDocument, DocumentConverter, DocumentFormat, Error, OfficeConverter, RawDocument,- Result,- },+use tinymemory_integrations::documents::{+ ConvertedDocument, DocumentConverter, DocumentFormat, Error, RawDocument, Result,};-/// [`OfficeConverter`] on the blocking pool.+/// The bus-backed document extraction adapter. Its name and metadata stay+/// compatible with the former OfficeConverter while parsing belongs to TinyDocs.#[cfg(feature = "documents")]-struct BlockingOffice;+struct TinyDocsConverter {+ config: Config,+}#[cfg(feature = "documents")]#[async_trait]-impl DocumentConverter for BlockingOffice {+impl DocumentConverter for TinyDocsConverter {fn name(&self) -> &str {- OfficeConverter.name()+ "office"}fn supports(&self, format: DocumentFormat) -> bool {- OfficeConverter.supports(format)+ matches!(+ format,+ DocumentFormat::Pdf+ | DocumentFormat::Docx+ | DocumentFormat::Pptx+ | DocumentFormat::Xlsx+ )}async fn convert(&self, document: &RawDocument) -> Result<ConvertedDocument> {- let document = document.clone();- crate::core::runtime::spawn_blocking_scoped(move || {- OfficeConverter.convert_blocking(&document)- })- .await- .map_err(task_failed)?+ let format = document.format();+ let wire_format = match format {+ DocumentFormat::Pdf => tinydocs_bus::DocumentFormat::Pdf,+ DocumentFormat::Docx => tinydocs_bus::DocumentFormat::Docx,+ DocumentFormat::Pptx => tinydocs_bus::DocumentFormat::Pptx,+ DocumentFormat::Xlsx => tinydocs_bus::DocumentFormat::Xlsx,+ _ => unreachable!("supports limits formats to TinyDocs formats"),+ };+ let markdown =+ crate::modules::documents::convert_markdown(&self.config, wire_format, &document.bytes)+ .await+ .map_err(map_module_error)?;++ Ok(+ ConvertedDocument::new(markdown, format, document.bytes.len())+ .with_metadata(serde_json::json!({ "converter": self.name() })),+ )}}-/// The error for a conversion task that never finished (it panicked or was-/// cancelled): a converter failure, never a crash of the caller.#[cfg(feature = "documents")]-fn task_failed(error: impl std::fmt::Display) -> Error {- Error::Converter {- converter: "office".to_string(),- message: format!("the conversion task did not finish: {error}"),+fn map_module_error(error: crate::modules::documents::DocumentCallError) -> Error {+ use crate::modules::documents::DocumentCallError;+ match error {+ DocumentCallError::InvalidInput(message) => Error::Invalid(message),+ DocumentCallError::Unavailable(message) | DocumentCallError::Failed(message) => {+ Error::Converter {+ converter: "tinydocs".to_string(),+ message,+ }+ }}}-static CHAIN: LazyLock<ConverterChain> = LazyLock::new(|| {+/// Build the host's format-first converter chain against this config snapshot.+pub(crate) fn converter(config: &Config) -> ConverterChain {let chain = ConverterChain::default();#[cfg(feature = "documents")]- let chain = chain.prepend(Box::new(BlockingOffice));+ let chain = chain.prepend(Box::new(TinyDocsConverter {+ config: config.clone(),+ }));+ #[cfg(not(feature = "documents"))]+ let _ = config;chain-});--/// The converter every memory write of a file goes through.-pub(crate) fn converter() -> &'static ConverterChain {- &CHAIN}#[cfg(test)]diff --git a/crates/openhuman-core/src/memory/convert_tests.rs b/crates/openhuman-core/src/memory/convert_tests.rsindex 4987e23b13..6c793a7684 100644--- a/crates/openhuman-core/src/memory/convert_tests.rs+++ b/crates/openhuman-core/src/memory/convert_tests.rs@@ -1,5 +1,6 @@use super::*;+use crate::config::Config;use tinymemory_integrations::documents::{DocumentConverter, Error, RawDocument};#[cfg(feature = "documents")]use {@@ -44,11 +45,118 @@ fn pdf_saying(text: &str) -> Vec<u8> {out.into_bytes()}+/// A valid PDF with one text-bearing page per supplied string.+fn pdf_pages_saying(texts: &[String]) -> Vec<u8> {+ let mut objects = Vec::with_capacity(3 + texts.len() * 2);+ objects.push("<< /Type /Catalog /Pages 2 0 R >>".to_string());+ let kids = (0..texts.len())+ .map(|index| format!("{} 0 R", 4 + index * 2))+ .collect::<Vec<_>>()+ .join(" ");+ objects.push(format!(+ "<< /Type /Pages /Kids [{kids}] /Count {} >>",+ texts.len()+ ));+ objects.push("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>".to_string());+ for (index, text) in texts.iter().enumerate() {+ let content_object = 5 + index * 2;+ let stream = format!("BT /F1 12 Tf 72 720 Td ({text}) Tj ET");+ objects.push(format!(+ "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents {content_object} 0 R \+ /Resources << /Font << /F1 3 0 R >> >> >>"+ ));+ objects.push(format!(+ "<< /Length {} >>\nstream\n{stream}\nendstream",+ stream.len()+ ));+ }+ let mut out = String::from("%PDF-1.4\n");+ let mut offsets = Vec::with_capacity(objects.len());+ for (index, object) in objects.iter().enumerate() {+ offsets.push(out.len());+ out.push_str(&format!("{} 0 obj\n{object}\nendobj\n", index + 1));+ }+ let xref = out.len();+ out.push_str(&format!(+ "xref\n0 {}\n0000000000 65535 f \n",+ objects.len() + 1+ ));+ for offset in offsets {+ out.push_str(&format!("{offset:010} 00000 n \n"));+ }+ out.push_str(&format!(+ "trailer\n<< /Size {} /Root 1 0 R >>\nstartxref\n{xref}\n%%EOF\n",+ objects.len() + 1+ ));+ out.into_bytes()+}++#[cfg(feature = "documents")]+fn office_archive(parts: &[(&str, &str)]) -> Vec<u8> {+ use std::io::Write;+ let mut archive = zip::ZipWriter::new(std::io::Cursor::new(Vec::new()));+ let options = zip::write::SimpleFileOptions::default();+ for (name, contents) in parts {+ archive.start_file(*name, options).unwrap();+ archive.write_all(contents.as_bytes()).unwrap();+ }+ archive.finish().unwrap().into_inner()+}++#[cfg(feature = "documents")]+fn docx_saying(text: &str) -> Vec<u8> {+ let xml = format!(+ "<w:document xmlns:w='w'><w:body><w:p><w:r><w:t>{text}</w:t></w:r></w:p></w:body></w:document>"+ );+ office_archive(&[("word/document.xml", &xml)])+}++#[cfg(feature = "documents")]+fn pptx_saying(text: &str) -> Vec<u8> {+ let slide =+ format!("<p:sld xmlns:p='p' xmlns:a='a'><a:p><a:r><a:t>{text}</a:t></a:r></a:p></p:sld>");+ office_archive(&[+ (+ "ppt/presentation.xml",+ "<p:presentation xmlns:p='p' xmlns:r='r'><p:sldIdLst><p:sldId r:id='r1'/></p:sldIdLst></p:presentation>",+ ),+ (+ "ppt/_rels/presentation.xml.rels",+ "<Relationships><Relationship Id='r1' Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide' Target='slides/slide1.xml'/></Relationships>",+ ),+ ("ppt/slides/slide1.xml", &slide),+ ])+}++#[cfg(feature = "documents")]+fn xlsx_saying(text: &str) -> Vec<u8> {+ let content_types = "<Types xmlns='http://schemas.openxmlformats.org/package/2006/content-types'><Default Extension='rels' ContentType='application/vnd.openxmlformats-package.relationships+xml'/><Default Extension='xml' ContentType='application/xml'/><Override PartName='/xl/workbook.xml' ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'/><Override PartName='/xl/worksheets/sheet1.xml' ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'/></Types>";+ let root_rels = "<Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships'><Relationship Id='rId1' Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument' Target='xl/workbook.xml'/></Relationships>";+ let workbook = "<workbook xmlns='http://schemas.openxmlformats.org/spreadsheetml/2006/main' xmlns:r='http://schemas.openxmlformats.org/officeDocument/2006/relationships'><sheets><sheet name='Sheet1' sheetId='1' r:id='rId1'/></sheets></workbook>";+ let workbook_rels = "<Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships'><Relationship Id='rId1' Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet' Target='worksheets/sheet1.xml'/></Relationships>";+ let sheet = format!("<worksheet xmlns='http://schemas.openxmlformats.org/spreadsheetml/2006/main'><sheetData><row r='1'><c r='A1' t='inlineStr'><is><t>{text}</t></is></c></row></sheetData></worksheet>");+ office_archive(&[+ ("[Content_Types].xml", content_types),+ ("_rels/.rels", root_rels),+ ("xl/workbook.xml", workbook),+ ("xl/_rels/workbook.xml.rels", workbook_rels),+ ("xl/worksheets/sheet1.xml", &sheet),+ ])+}++#[cfg(feature = "documents")]+fn local_module_config() -> Config {+ let mut config = Config::default();+ config.modules.allow_download = false;+ config+}+#[cfg(feature = "documents")]#[tokio::test]+#[ignore = "needs a built TinyDocs module and its own process; set OPENHUMAN_MODULE_PATH"]async fn a_pdf_converts_to_its_text() {let raw = RawDocument::new(pdf_saying("The vendor code is PV-7023")).with_filename("brief.pdf");- let converted = converter()+ let converted = converter(&local_module_config()).convert(&raw).await.expect("the office converter reads pdf");@@ -57,12 +165,102 @@ async fn a_pdf_converts_to_its_text() {"{}",converted.markdown);+ assert_eq!(converted.source_bytes, raw.bytes.len());+ assert_eq!(converted.metadata["converter"], "office");+}++#[cfg(feature = "documents")]+#[tokio::test]+#[ignore = "needs the released TinyDocs module in OPENHUMAN_MODULE_PATH and its own process"]+async fn the_released_module_extracts_all_memory_office_formats() {+ let config = local_module_config();+ let cases = [+ (+ RawDocument::new(pdf_saying("receipt PDF text")).with_filename("receipt.pdf"),+ "receipt PDF text",+ ),+ (+ RawDocument::new(docx_saying("word text")).with_filename("letter.docx"),+ "word text",+ ),+ (+ RawDocument::new(pptx_saying("slide text")).with_filename("deck.pptx"),+ "slide text",+ ),+ (+ RawDocument::new(xlsx_saying("cell text")).with_filename("sheet.xlsx"),+ "cell text",+ ),+ ];+ for (raw, expected) in cases {+ let converted = converter(&config)+ .convert(&raw)+ .await+ .unwrap_or_else(|error| panic!("{} extraction failed: {error}", raw.display_name()));+ assert!(+ converted.markdown.contains(expected),+ "{}",+ converted.markdown+ );+ assert_eq!(converted.source_bytes, raw.bytes.len());+ assert_eq!(converted.metadata["converter"], "office");+ if raw.display_name() == "sheet.xlsx" {+ assert_eq!(converted.markdown, "Sheet1 | cell text");+ }+ }++ let large_docx = "complete paragraph ".repeat(12_500);+ let raw = RawDocument::new(docx_saying(&large_docx)).with_filename("long.docx");+ let bounded_preview = crate::modules::documents::extract_document(+ &config,+ &raw.bytes,+ &tinydocs_bus::ExtractDocumentSpec {+ format: tinydocs_bus::DocumentFormat::Docx,+ max_text_bytes: 200_000,+ max_sections: 256,+ },+ )+ .await+ .expect("the preview operation remains bounded");+ assert!(bounded_preview.truncated);+ let converted = converter(&config)+ .convert(&raw)+ .await+ .expect("text beyond the intake preview limit remains complete");+ assert!(converted.markdown.len() > 200_000);+ let normalized = large_docx.split_whitespace().collect::<Vec<_>>().join(" ");+ assert_eq!(converted.markdown, normalized);++ let pages = (1..=300)+ .map(|page| format!("Page {page} content"))+ .collect::<Vec<_>>();+ let raw = RawDocument::new(pdf_pages_saying(&pages)).with_filename("many-pages.pdf");+ let bounded_preview = crate::modules::documents::extract_document(+ &config,+ &raw.bytes,+ &tinydocs_bus::ExtractDocumentSpec {+ format: tinydocs_bus::DocumentFormat::Pdf,+ max_text_bytes: 200_000,+ max_sections: 256,+ },+ )+ .await+ .expect("the preview operation remains bounded");+ assert!(bounded_preview.truncated);+ assert_eq!(bounded_preview.section_count, 300);+ assert_eq!(bounded_preview.sections.len(), 256);+ let converted = converter(&config)+ .convert(&raw)+ .await+ .expect("page counts beyond the intake section limit remain complete");+ assert!(converted.markdown.contains("Page 300 content"));+ assert_eq!(converted.markdown.matches('\u{c}').count(), 299);}#[tokio::test]async fn markdown_still_goes_through_the_native_converter() {let raw = RawDocument::new(b"# Note\n\nPlain markdown.".to_vec()).with_filename("note.md");- let converted = converter()+ let converted = converter(&Config::default()).convert(&raw).await.expect("native handles markdown");@@ -72,15 +270,21 @@ async fn markdown_still_goes_through_the_native_converter() {#[tokio::test]async fn an_unknown_binary_is_still_refused_with_a_clear_error() {let raw = RawDocument::new(vec![0u8, 1, 2, 3, 255]).with_filename("blob.bin");- let error = converter().convert(&raw).await.unwrap_err();+ let error = converter(&Config::default())+ .convert(&raw)+ .await+ .unwrap_err();assert!(matches!(error, Error::UnsupportedFormat(_)), "{error}");}#[cfg(feature = "documents")]#[tokio::test]+#[ignore = "needs a built TinyDocs module and its own process; set OPENHUMAN_MODULE_PATH"]async fn brain_ingest_files_a_pdf_by_path() {let tmp = tempfile::tempdir().unwrap();let config = config_in(&tmp);+ let mut config = config;+ config.modules.allow_download = false;let engine = bind_reference(&config);let path = tmp.path().join("brief.pdf");std::fs::write(&path, pdf_saying("The vendor code is PV-7023")).unwrap();@@ -110,28 +314,59 @@ async fn brain_ingest_files_a_pdf_by_path() {#[tokio::test]async fn without_the_documents_feature_a_pdf_is_refused_cleanly() {let raw = RawDocument::new(pdf_saying("The vendor code is PV-7023")).with_filename("brief.pdf");- let error = converter().convert(&raw).await.unwrap_err();+ let error = converter(&Config::default())+ .convert(&raw)+ .await+ .unwrap_err();assert!(matches!(error, Error::UnsupportedFormat(_)), "{error}");}#[cfg(feature = "documents")]-#[test]-fn the_office_converter_names_itself_and_claims_only_office_formats() {- use tinymemory_integrations::documents::DocumentFormat;- assert_eq!(BlockingOffice.name(), "office");- assert!(BlockingOffice.supports(DocumentFormat::Pdf));- assert!(BlockingOffice.supports(DocumentFormat::Docx));- assert!(!BlockingOffice.supports(DocumentFormat::Markdown));+#[tokio::test]+async fn a_pdf_does_not_fall_back_to_a_local_parser_when_modules_are_disabled() {+ let raw = RawDocument::new(pdf_saying("The vendor code is PV-7023")).with_filename("brief.pdf");+ let mut config = Config::default();+ config.modules.enabled = false;++ let error = converter(&config).convert(&raw).await.unwrap_err();+ assert!(+ matches!(error, Error::Converter { ref converter, .. } if converter == "tinydocs"),+ "expected a TinyDocs-unavailable converter error, got {error}"+ );+}++#[cfg(feature = "documents")]+#[tokio::test]+async fn memory_module_intake_keeps_the_32_mib_limit() {+ let raw = RawDocument::new(vec![+ 0;+ tinymemory_integrations::documents::MAX_DOCUMENT_BYTES+ + 1+ ])+ .with_filename("oversized.pdf");+ let mut config = Config::default();+ config.modules.enabled = false;++ let error = converter(&config).convert(&raw).await.unwrap_err();+ assert!(+ matches!(error, Error::TooLarge { size, limit }+ if size == tinymemory_integrations::documents::MAX_DOCUMENT_BYTES + 1+ && limit == tinymemory_integrations::documents::MAX_DOCUMENT_BYTES),+ "the 32 MiB guard must run before module loading, got {error}"+ );}#[cfg(feature = "documents")]#[test]-fn a_conversion_task_that_dies_is_a_converter_error_not_a_crash() {- match task_failed("task panicked") {- Error::Converter { converter, message } => {- assert_eq!(converter, "office");- assert!(message.contains("task panicked"), "{message}");- }- other => panic!("expected a converter error, got {other:?}"),- }+fn the_office_converter_names_itself_and_claims_only_office_formats() {+ use tinymemory_integrations::documents::DocumentFormat;+ let office = TinyDocsConverter {+ config: Config::default(),+ };+ assert_eq!(office.name(), "office");+ assert!(office.supports(DocumentFormat::Pdf));+ assert!(office.supports(DocumentFormat::Docx));+ assert!(office.supports(DocumentFormat::Pptx));+ assert!(office.supports(DocumentFormat::Xlsx));+ assert!(!office.supports(DocumentFormat::Markdown));}diff --git a/crates/openhuman-core/src/memory/sources/sync.rs b/crates/openhuman-core/src/memory/sources/sync.rsindex 57fc8ac30e..08994c27dd 100644--- a/crates/openhuman-core/src/memory/sources/sync.rs+++ b/crates/openhuman-core/src/memory/sources/sync.rs@@ -76,7 +76,7 @@ pub async fn sync_one(config: &Config, source: &MemorySourceConfig) -> MemoryResreader.as_ref(),&entry,&config.action_dir,- crate::memory::convert::converter(),+ &crate::memory::convert::converter(config),).await.map_err(|error| MemoryError::Engine(format!("reading the source failed: {error}")))?;diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.mdindex 19b687fc6c..011b4cb927 100644--- a/crates/openhuman-core/src/modules/README.md+++ b/crates/openhuman-core/src/modules/README.md@@ -211,7 +211,7 @@ download, its `dlopen`, or its resident memory.| Path | Module | What it does || --- | --- | --- |-| [`documents.rs`](documents.rs) | `tinydocs` | `generate_docx`, `generate_pptx`, `extract_text`, `extract_document`, `render_pdf`. Inbound bytes ride a tinybus stream; produced documents are held by the module and pulled with `ReadOutput`, then released. Feature `documents`. |+| [`documents.rs`](documents.rs) | `tinydocs` | `generate_docx`, `generate_pptx`, `extract_text`, bounded `extract_document`, complete `convert_markdown`, `inspect_image`, and `render_pdf`. Inbound bytes ride a TinyBus stream; held results are pulled with `ReadOutput` and released. Feature `documents`. || [`wallet.rs`](wallet.rs) | `tinywallet` | `derive_account`, `sign_transaction_in_module`, `sign_message`, `export_key`. Key material goes only to an attested module whose attested digest is one the registry pinned (`attested_proxy`). Feature `web3`. || [`voice.rs`](voice.rs) | `tinyvoice` | Intent routing, command extraction, wake-word and hallucination checks, capture preparation, WAV encoding, frame energies, and a `VadSession` driven from the always-on capture loop. Every call returns a `VoiceCallError` the caller falls back from. Feature `voice`. || [`runtime.rs`](runtime.rs) | `tinyruntime` + providers | `ensure_language` loads the router and the language provider, then `resolve`, `execute`, `languages`, `pool_stats`. Settings (`settings_for`, `pool_settings_for`) are read from config on every call. |diff --git a/crates/openhuman-core/src/modules/documents.rs b/crates/openhuman-core/src/modules/documents.rsindex b5cce601ba..f8710dd24b 100644--- a/crates/openhuman-core/src/modules/documents.rs+++ b/crates/openhuman-core/src/modules/documents.rs@@ -1,9 +1,9 @@-//! Calling the `tinydocs` module: the three document operations, over the bus.+//! Calling the `tinydocs` module over the bus.//!//! Each function here is the host half of one method on-//! `ai.tinyhumans.tinydocs.Documents`. They exist so the three tools that need a-//! document do not each have to know about streams, held outputs, or wire error-//! names — a tool asks for bytes and gets bytes or a reason.+//! `ai.tinyhumans.tinydocs.Documents`. These wrappers keep document tools from+//! needing to know about streams, held outputs, or wire error names — a caller+//! gets a typed result or a reason.//!//! # The shape of a call//!@@ -387,6 +387,69 @@ pub async fn extract_document(.map_err(|e| classify(&e))}+/// Convert a streamed PDF or Office document to complete normalized Markdown.+///+/// Unlike [`extract_document`], this operation preserves the full text needed+/// for memory persistence and returns it through the module's bounded held+/// output store.+///+/// # Errors+///+/// Returns [`DocumentCallError`] when the module is unavailable, the document+/// is invalid, the output transfer fails, or the complete text is not UTF-8.+pub async fn convert_markdown(+ config: &Config,+ format: tinydocs_bus::DocumentFormat,+ document: &[u8],+) -> Result<String, DocumentCallError> {+ let (runtime, record) = ready(config).await?;+ let proxy = proxy(runtime, record)?;+ let (destination, path, interface) = address(record)?;+ let handle: OutputRef = runtime+ .connection()+ .call_with_stream(+ destination,+ path,+ interface,+ member(methods::CONVERT_MARKDOWN)?,+ |stream| serde_json::json!([format, stream]),+ document,+ )+ .await+ .map_err(|error| classify(&error))?;+ let bytes = collect(&proxy, handle).await?;+ String::from_utf8(bytes)+ .map_err(|_| DocumentCallError::Failed("converted Markdown was not valid UTF-8".into()))+}++/// Inspect bounded PNG/JPEG bytes through TinyDocs and return their verified+/// format and dimensions.+pub async fn inspect_image(+ config: &Config,+ image: &[u8],+) -> Result<tinydocs_bus::ImageFacts, DocumentCallError> {+ let max = tinydocs_bus::spec::presentation::MAX_IMAGE_BYTES;+ if image.is_empty() || image.len() > max {+ return Err(DocumentCallError::InvalidInput(format!(+ "image must contain 1 to {max} bytes"+ )));+ }+ let (runtime, record) = ready(config).await?;+ let (destination, path, interface) = address(record)?;+ runtime+ .connection()+ .call_with_stream(+ destination,+ path,+ interface,+ member(methods::INSPECT_IMAGE)?,+ |stream| serde_json::json!([stream]),+ image,+ )+ .await+ .map_err(|error| classify(&error))+}+/// Render selected PDF pages and collect/release every held PNG output.pub async fn render_pdf(config: &Config,diff --git a/crates/openhuman-core/src/modules/documents_tests.rs b/crates/openhuman-core/src/modules/documents_tests.rsindex f58664de50..61f982bbbf 100644--- a/crates/openhuman-core/src/modules/documents_tests.rs+++ b/crates/openhuman-core/src/modules/documents_tests.rs@@ -8,7 +8,9 @@use super::*;use crate::config::Config;-use crate::tools::implementations::document::format::spec::{DocumentSpec, WirePresentationSpec};+use crate::tools::implementations::document::format::spec::{+ DocumentSection, DocumentSpec, WirePresentationSpec,+};/// A config with modules enabled but nothing fetchable.fn offline_config() -> Config {@@ -131,6 +133,10 @@ async fn a_disabled_host_reports_unavailable_without_starting_a_broker() {super::extract_document(&config, b"%PDF-1.4\n", &extraction).await,Err(DocumentCallError::Unavailable(_))));+ assert!(matches!(+ super::convert_markdown(&config, tinydocs_bus::DocumentFormat::Pdf, b"%PDF-1.4\n").await,+ Err(DocumentCallError::Unavailable(_))+ ));let rendering = tinydocs_bus::RenderPdfSpec {pages: vec![1],max_dimension: 256,@@ -143,6 +149,85 @@ async fn a_disabled_host_reports_unavailable_without_starting_a_broker() {));}+#[tokio::test]+#[ignore = "needs a built TinyDocs module and its own process; set OPENHUMAN_MODULE_PATH"]+async fn held_outputs_are_released_after_success_read_failure_and_cancellation() {+ async fn held_docx(config: &Config) -> (tinybus::Proxy, OutputRef) {+ let (runtime, record) = ready(config).await.expect("module should be ready");+ let proxy = proxy(runtime, record).expect("proxy should resolve");+ let spec = DocumentSpec {+ title: "Output lifecycle".to_string(),+ author: None,+ sections: vec![DocumentSection {+ heading: Some("Held output".to_string()),+ paragraphs: vec!["the generated document".to_string()],+ bullets: Vec::new(),+ }],+ };+ let handle: OutputRef = proxy+ .call(methods::GENERATE_DOCX, (spec,))+ .await+ .expect("module should retain generated output");+ (proxy, handle)+ }++ async fn assert_output_is_gone(proxy: &tinybus::Proxy, output_id: &str) {+ assert!(+ proxy+ .call::<String>(+ methods::READ_OUTPUT,+ (output_id.to_string(), 0_u64, READ_CHUNK)+ )+ .await+ .is_err(),+ "released output must no longer be readable"+ );+ }++ let config = offline_config();++ let (proxy, handle) = held_docx(&config).await;+ let bytes = collect(&proxy, handle.clone())+ .await+ .expect("complete output should be collected");+ assert!(!bytes.is_empty());+ assert_output_is_gone(&proxy, &handle.output_id).await;++ let (proxy, mut handle) = held_docx(&config).await;+ handle.sha256 = "0".repeat(64);+ let output_id = handle.output_id.clone();+ assert!(matches!(+ collect(&proxy, handle).await,+ Err(DocumentCallError::Failed(_))+ ));+ assert_output_is_gone(&proxy, &output_id).await;++ let (proxy, handle) = held_docx(&config).await;+ let output_id = handle.output_id;+ let release = OutputReleaseGuard {+ proxy: proxy.clone(),+ ids: vec![output_id.clone()],+ };+ let cancelled = tokio::spawn(async move {+ let _release = release;+ std::future::pending::<()>().await;+ });+ tokio::task::yield_now().await;+ cancelled.abort();+ let _ = cancelled.await;+ for _ in 0..100 {+ if proxy+ .call::<String>(methods::READ_OUTPUT, (output_id.clone(), 0_u64, READ_CHUNK))+ .await+ .is_err()+ {+ return;+ }+ tokio::task::yield_now().await;+ }+ panic!("cancelling the collector should schedule output release");+}+#[test]fn the_registry_entry_matches_the_interface_this_client_calls() {// The registry is a plain `const` table and cannot name a gated crate, so@@ -168,6 +253,8 @@ fn every_member_this_client_calls_is_one_the_contract_declares() {methods::GENERATE_PPTX,methods::EXTRACT_TEXT,methods::EXTRACT_DOCUMENT,+ methods::CONVERT_MARKDOWN,+ methods::INSPECT_IMAGE,methods::RENDER_PDF,methods::READ_OUTPUT,methods::RELEASE_OUTPUT,@@ -182,6 +269,6 @@ fn every_member_this_client_calls_is_one_the_contract_declares() {#[test]fn pinned_release_exposes_intake_without_loading() {- assert_eq!(registry::find(MODULE_ID).unwrap().version, "0.1.22");+ assert_eq!(registry::find(MODULE_ID).unwrap().version, "0.2.0");assert!(intake_available().is_ok());}diff --git a/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs b/crates/openhuman-core/src/modules/registry/records_docs_wallet.rsindex f1e5564e54..0933a0daa6 100644--- a/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs+++ b/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs@@ -2,72 +2,73 @@use crate::modules::types::{LoadPolicy, ModuleRecord, PlatformAsset};-/// The `tinydocs` module: document synthesis, bounded extraction, and PDF rendering.+/// The `tinydocs` module: document synthesis, bounded extraction, image facts,+/// and PDF rendering.////// Lazy, because a user who never asks for a document should not pay a download,/// a `dlopen`, and the resident cost of a library that is never unloaded.pub(crate) const TINYDOCS: ModuleRecord = ModuleRecord {id: "tinydocs",- description: "Document synthesis, Office/PDF extraction, and PDF rendering",+ description: "Document synthesis, Office/PDF extraction, image inspection, and PDF rendering",bus_name: "ai.tinyhumans.tinydocs.Documents",object_path: "/ai/tinyhumans/tinydocs/Documents",- version: "0.1.22",- release_url: "https://github.com/tinyhumansai/tinydocs/releases/tag/v0.1.22",+ version: "0.2.0",+ release_url: "https://github.com/tinyhumansai/tinydocs/releases/tag/v0.2.0",assets: &[PlatformAsset {host_key: "ubuntu-24.04-x86_64",- archive: "tinydocs-module-0.1.22-ubuntu-24.04-x86_64.tar.gz",- sha256: "b96f7bd28bed47dd89d17c56dec6d3e98a1053342d0edb54d05487bfa264ab28",+ archive: "tinydocs-module-0.2.0-ubuntu-24.04-x86_64.tar.gz",+ sha256: "2db0db216f6bd25e07d66cd13485672dd2edcd84bed9c4f5ee383f603ced7c95",},PlatformAsset {host_key: "ubuntu-24.04-arm64",- archive: "tinydocs-module-0.1.22-ubuntu-24.04-arm64.tar.gz",- sha256: "b43f1f3c8a7d26020d38eb50ab787271d1540205a30ab421f0bf89421ce719fc",+ archive: "tinydocs-module-0.2.0-ubuntu-24.04-arm64.tar.gz",+ sha256: "9d77120bceac02ac607192f12884023c8f10a18baecef18acb3694ecb8b42217",},PlatformAsset {host_key: "ubuntu-22.04-x86_64",- archive: "tinydocs-module-0.1.22-ubuntu-22.04-x86_64.tar.gz",- sha256: "22c07a48c6e1f684bd16f309bd1045ff766c52205c7f4df6edec84aadbe0c59a",+ archive: "tinydocs-module-0.2.0-ubuntu-22.04-x86_64.tar.gz",+ sha256: "d3a84df5f375a9774183dd5c1fd344ac373752b54473a6d2fb611c7cab5142d2",},PlatformAsset {host_key: "ubuntu-22.04-arm64",- archive: "tinydocs-module-0.1.22-ubuntu-22.04-arm64.tar.gz",- sha256: "d58ce05f62e5367d0b1f996e1b52c1e73006fac91b97b0104c562481c60c2c58",+ archive: "tinydocs-module-0.2.0-ubuntu-22.04-arm64.tar.gz",+ sha256: "fa094051f186e085db8bdc304215aa5553c0f29c958b78cc337623815e62c39a",},PlatformAsset {host_key: "macos-26-arm64",- archive: "tinydocs-module-0.1.22-macos-26-arm64.tar.gz",- sha256: "56086b08fe560b9281db6ee86123bff213c81a7686a549b5dc3d18a5c1a6fbe4",+ archive: "tinydocs-module-0.2.0-macos-26-arm64.tar.gz",+ sha256: "94553eef6029b61ad135d406000e7ccfb03857e68be03fed990d8912b9b1995f",},PlatformAsset {host_key: "macos-26-x86_64",- archive: "tinydocs-module-0.1.22-macos-26-x86_64.tar.gz",- sha256: "4ee4ea1c0b4832057d21d975400f08f08ae385a5137ac9335d73dfd5e8cb5dd2",+ archive: "tinydocs-module-0.2.0-macos-26-x86_64.tar.gz",+ sha256: "b01bba79f64731534ca93c89d045cfdd8cd8d6ce34249810a99e76735e4e3b59",},PlatformAsset {host_key: "macos-15-arm64",- archive: "tinydocs-module-0.1.22-macos-15-arm64.tar.gz",- sha256: "9f2625614fe342609302a09a303a3fd03f1c0c29e4030b103d8d1b03387f7ce0",+ archive: "tinydocs-module-0.2.0-macos-15-arm64.tar.gz",+ sha256: "b92f0b31d942f56784bf9fd6897736595f5c1bf39db34a7115e5d9ddafb0fe72",},PlatformAsset {host_key: "macos-15-x86_64",- archive: "tinydocs-module-0.1.22-macos-15-x86_64.tar.gz",- sha256: "04f69b78b2b4c73f407b7faf71dedc1481dd941b0f9a6477159874338b749b13",+ archive: "tinydocs-module-0.2.0-macos-15-x86_64.tar.gz",+ sha256: "2f6ff91ff580462a234e7476bb0dc3c6fda975786e2ea920b0a85ece3df760d8",},PlatformAsset {host_key: "windows-2025-x86_64",- archive: "tinydocs-module-0.1.22-windows-2025-x86_64.zip",- sha256: "27d70441b427bb94b3ceb30500eea0f86f253ba998d68eaaeb4c62be2569ade8",+ archive: "tinydocs-module-0.2.0-windows-2025-x86_64.zip",+ sha256: "e799aca9485cff97eceb4a3f8f6882c5e92abb17e639a68d2f774fcf57f035c2",},PlatformAsset {host_key: "windows-2022-x86_64",- archive: "tinydocs-module-0.1.22-windows-2022-x86_64.zip",- sha256: "47852edcc57f2b6d626f68310f66fee9bf926833a83b52310671998803924c99",+ archive: "tinydocs-module-0.2.0-windows-2022-x86_64.zip",+ sha256: "5a271fa3a9c472cdd531d259db92dc04512199ac1cd586fdf31c3af14c3299fb",},PlatformAsset {host_key: "windows-11-arm64",- archive: "tinydocs-module-0.1.22-windows-11-arm64.zip",- sha256: "e6f4b174f52e61f643d6c13fc424718c8dcd41c7cee2826a3ec6c20391413396",+ archive: "tinydocs-module-0.2.0-windows-11-arm64.zip",+ sha256: "15541820df3ff69621485846d328495d42d06e7d9b2e73c42eea5af2242a9a4c",},],load: LoadPolicy::Lazy,diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rsindex d9547675ae..3f331eb219 100644--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs@@ -27,7 +27,6 @@//! #3026 Files panel, and the orchestrator grounding rule in #3029//! continue to work without change.-use crate::tools::implementations::document::format::spec::ImageFormat;use std::path::PathBuf;use std::sync::Arc;use std::time::Duration;@@ -102,10 +101,11 @@ impl PresentationTool {/// The agent-registry constructor: the artifact metadata goes to/// `config.workspace_dir`, the deck to the files folder (#5505).pub fn for_config(config: &crate::config::Config, security: Arc<SecurityPolicy>) -> Self {- Self::new(+ Self::with_config(config.workspace_dir.clone(),crate::agent::artifacts::FileRoots::from_config(config),security,+ config.clone(),)}@@ -479,24 +479,21 @@ impl PresentationTool {));}- // Identification and measurement live in `crate::tools::implementations::document::format::spec::image`, which- // is ungated: a host resolving image bytes has to do this to build a- // spec, and it must not need the writer to do it. One implementation- // also means the host and the module cannot disagree about what is- // embeddable.- let format = ImageFormat::sniff(&bytes).ok_or_else(|| {- "unsupported image type (only PNG and JPEG are embeddable)".to_string()- })?;-- let (width_px, height_px) = format- .dimensions(&bytes)- .ok_or_else(|| format!("could not read {format} dimensions (corrupt header?)"))?;+ let config = match &self.config {+ Some(config) => config.clone(),+ None => crate::config::ops::load_current_or_init()+ .await+ .map_err(|error| format!("could not load runtime configuration: {error}"))?,+ };+ let facts = crate::modules::documents::inspect_image(&config, &bytes)+ .await+ .map_err(|error| error.to_string())?;Ok(ResolvedSlideImage {bytes,- format,- width_px,- height_px,+ format: facts.format,+ width_px: facts.width_px,+ height_px: facts.height_px,caption: image.caption.clone(),})}diff --git a/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rs b/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rsindex 2722ba2fce..218e9f5773 100644--- a/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rs@@ -39,10 +39,18 @@ fn test_security(workspace: &Path) -> Arc<SecurityPolicy> {/// Build a tool whose security policy is rooted at `workspace`.fn make_tool(workspace: &Path) -> PresentationTool {- PresentationTool::new(+ let mut config = crate::config::Config::default();+ config.workspace_dir = workspace.to_path_buf();+ config.modules.enabled = false;+ make_tool_with_config(workspace, config)+}++fn make_tool_with_config(workspace: &Path, config: crate::config::Config) -> PresentationTool {+ PresentationTool::with_config(workspace.to_path_buf(),workspace.join("Files"),test_security(workspace),+ config,)}@@ -239,7 +247,10 @@ async fn execute_embeds_file_image_into_deck() {let img_path = ws.path().join("chart.png");std::fs::write(&img_path, png_1x1()).expect("write png");- let tool = make_tool(ws.path());+ let mut config = crate::config::Config::default();+ config.workspace_dir = ws.path().to_path_buf();+ config.modules.allow_download = false;+ let tool = make_tool_with_config(ws.path(), config);let args = json!({"title": "Deck with image","slides": [{@@ -295,12 +306,43 @@ async fn execute_skips_unsupported_mime_image_with_warning() {);assert_eq!(warnings.len(), 1, "exactly one image warning expected");assert!(- warnings[0].contains("unsupported image type"),- "warning should name the MIME problem: {:?}",+ !warnings[0].is_empty(),+ "the image rejection should be explained: {:?}",warnings[0]);}+#[tokio::test]+async fn image_inspection_does_not_fall_back_when_modules_are_disabled() {+ let ws = workspace();+ let img_path = ws.path().join("chart.png");+ std::fs::write(&img_path, png_1x1()).expect("write png");+ let mut config = crate::config::Config::default();+ config.workspace_dir = ws.path().to_path_buf();+ config.modules.enabled = false;+ let tool = PresentationTool::with_config(+ ws.path().to_path_buf(),+ ws.path().join("Files"),+ test_security(ws.path()),+ config,+ );+ let input: GeneratePresentationInput = serde_json::from_value(json!({+ "title": "No host image parser",+ "slides": [{+ "title": "Chart",+ "bullets": ["See below"],+ "images": [{ "source": { "type": "file", "path": img_path.to_string_lossy() } }]+ }]+ }))+ .expect("parse presentation input");+ validate_input(&input).expect("valid presentation input");++ let (resolved, warnings) = tool.resolve_images(&input).await;+ assert!(resolved.iter().all(Vec::is_empty));+ assert_eq!(warnings.len(), 1);+ assert!(warnings[0].contains("disabled"), "{warnings:?}");+}+#[tokio::test]async fn execute_skips_oversize_image_with_warning() {let ws = workspace();diff --git a/gitbooks/features/native-tools/documents.md b/gitbooks/features/native-tools/documents.mdindex c8b7106880..fab356d907 100644--- a/gitbooks/features/native-tools/documents.md+++ b/gitbooks/features/native-tools/documents.md@@ -55,7 +55,7 @@ Nothing is written to disk during extraction, no office application is launched,## Where it runs-Document work happens in the `tinydocs` module. It is a signed native library that downloads on first use and is checked against a SHA-256 pinned in OpenHuman. The document writers and the PDF reader are not part of the app's own code in any build. With the `documents` feature off, the two tools are simply missing from the agent's list instead of failing, and a PDF attachment becomes a file reference instead of extracted text.+Document work happens in the `tinydocs` module. It is a signed native library that downloads on first use and is checked against a SHA-256 pinned in OpenHuman. The document writers, PDF and Office readers, and image inspection are not part of the app's own code in any build. With the `documents` feature off, the generation tools are absent and PDF/Office extraction and image inspection are unavailable.## See alsodiff --git a/scripts/ci/module-boundaries.json b/scripts/ci/module-boundaries.jsonindex ba4ed889df..bdc4092f10 100644--- a/scripts/ci/module-boundaries.json+++ b/scripts/ci/module-boundaries.json@@ -174,16 +174,6 @@"package": "tinywallet-x402","reason": "Validation, transaction construction, web3 and x402 need module operations."},- {- "scope": "hosts",- "package": "pdf-extract",- "reason": "Memory documents-office still enables local PDF extraction."- },- {- "scope": "hosts",- "package": "calamine",- "reason": "Memory documents-office still enables local XLSX parsing."- },{"scope": "tinychannels-bus","package": "anyhow",diff --git a/vendor/tinydocs b/vendor/tinydocsindex d5eb283594..f95c461e07 160000--- a/vendor/tinydocs+++ b/vendor/tinydocs@@ -1 +1 @@-Subproject commit d5eb283594c70b44882a4dafc57973a95a70f584+Subproject commit f95c461e071233d2a86ecb029318e0e4aa2df46c