Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(memory): read PDF, Word, PowerPoint and Excel into the brain (#7023)

Ghost Scripter7f63db398410
diff --git a/Cargo.lock b/Cargo.lock
index f0b3887c8d..2f2fc8b870 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17,6 +17,15 @@ 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"
@@ -305,6 +314,16 @@ 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"
@@ -535,6 +554,15 @@ 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"
@@ -701,6 +729,23 @@ 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 = "castaway"
version = "0.2.4"
@@ -710,6 +755,15 @@ 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"
@@ -729,6 +783,12 @@ 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"
@@ -892,6 +952,15 @@ 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"
@@ -1167,6 +1236,12 @@ 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"
@@ -1485,6 +1560,12 @@ 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"
@@ -1703,6 +1784,15 @@ 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"
@@ -1782,6 +1872,20 @@ version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449"
+[[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"
@@ -1893,6 +1997,15 @@ 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"
@@ -1950,6 +2063,12 @@ dependencies = [
"regex",
]
+[[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"
@@ -2815,6 +2934,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
dependencies = [
+ "block-padding 0.3.3",
"generic-array",
]
@@ -2824,7 +2944,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
dependencies = [
- "block-padding",
+ "block-padding 0.4.2",
"hybrid-array",
]
@@ -3261,6 +3381,33 @@ 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",
+ "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"
@@ -3331,6 +3478,16 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
+[[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 = "md5"
version = "0.8.1"
@@ -3437,6 +3594,12 @@ dependencies = [
"pxfm",
]
+[[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"
@@ -4113,7 +4276,7 @@ dependencies = [
"wiremock",
"x25519-dalek 2.0.1",
"zeroize",
- "zip",
+ "zip 2.4.2",
]
[[package]]
@@ -4460,6 +4623,23 @@ dependencies = [
"hmac 0.12.1",
]
+[[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"
@@ -4634,7 +4814,7 @@ checksum = "2896bade328c13f7042a297ea5ac5b0951f6cf989dea5f32c2fd98da398195cb"
dependencies = [
"base64 0.23.1",
"indexmap",
- "quick-xml",
+ "quick-xml 0.42.0",
"serde",
"time",
]
@@ -4686,6 +4866,12 @@ 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"
@@ -4701,6 +4887,12 @@ 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"
@@ -4823,6 +5015,16 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
+[[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"
@@ -5015,6 +5217,12 @@ 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"
@@ -6107,6 +6315,17 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "stringprep"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
+dependencies = [
+ "unicode-bidi",
+ "unicode-normalization",
+ "unicode-properties",
+]
+
[[package]]
name = "strsim"
version = "0.11.1"
@@ -6479,7 +6698,7 @@ dependencies = [
"tracing",
"uuid",
"wait-timeout",
- "zip",
+ "zip 2.4.2",
]
[[package]]
@@ -6606,7 +6825,7 @@ dependencies = [
"toml",
"tracing",
"ureq",
- "zip",
+ "zip 2.4.2",
]
[[package]]
@@ -7095,9 +7314,12 @@ name = "tinymemory-integrations"
version = "1.23.1"
dependencies = [
"async-trait",
+ "calamine",
"chrono",
"futures",
"log",
+ "pdf-extract",
+ "quick-xml 0.41.0",
"regex",
"reqwest",
"rusqlite",
@@ -7111,6 +7333,7 @@ dependencies = [
"tokio",
"tracing",
"walkdir",
+ "zip 8.6.0",
]
[[package]]
@@ -7644,6 +7867,12 @@ 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"
@@ -7681,12 +7910,27 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
+[[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"
@@ -7720,12 +7964,33 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
+[[package]]
+name = "unicode-bidi"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
+
[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
+[[package]]
+name = "unicode-normalization"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
+name = "unicode-properties"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
+
[[package]]
name = "unicode-segmentation"
version = "1.13.3"
@@ -8018,7 +8283,7 @@ dependencies = [
"async-trait",
"buffa",
"bytes",
- "cbc",
+ "cbc 0.2.1",
"chrono",
"ctr 0.10.1",
"curve25519-dalek 5.0.0",
@@ -8303,7 +8568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e"
dependencies = [
"bitflags 1.3.2",
- "euclid",
+ "euclid 0.22.14",
"lazy_static",
"serde",
"wezterm-dynamic",
@@ -9041,6 +9306,20 @@ 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-app/Cargo.lock b/crates/openhuman-app/Cargo.lock
index ebbb701463..2678d4fb67 100644
--- a/crates/openhuman-app/Cargo.lock
+++ b/crates/openhuman-app/Cargo.lock
@@ -17,6 +17,15 @@ 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"
@@ -360,6 +369,16 @@ dependencies = [
"system-deps",
]
+[[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-waker"
version = "1.1.2"
@@ -557,6 +576,15 @@ 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 = "block2"
version = "0.5.1"
@@ -667,6 +695,23 @@ dependencies = [
"system-deps",
]
+[[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 = "camino"
version = "1.2.6"
@@ -709,6 +754,15 @@ dependencies = [
"toml 0.9.12+spec-1.1.0",
]
+[[package]]
+name = "cbc"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "cc"
version = "1.4.7"
@@ -736,6 +790,12 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "cff-parser"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c5810ca1a2b5870df2aab1c03e11c40c361ba51d6e3e361e56310f1cb3b4e087"
+
[[package]]
name = "cfg-expr"
version = "0.15.8"
@@ -858,6 +918,15 @@ 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 = "combine"
version = "4.6.8"
@@ -1051,6 +1120,12 @@ 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"
@@ -1310,6 +1385,12 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
+[[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"
@@ -1626,6 +1707,15 @@ 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",
+]
+
[[package]]
name = "either"
version = "1.18.0"
@@ -1668,6 +1758,20 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
+[[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 = "endi"
version = "1.1.1"
@@ -1774,6 +1878,15 @@ 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 = "event-listener"
version = "2.5.3"
@@ -1812,6 +1925,12 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
+[[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"
@@ -2900,6 +3019,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
dependencies = [
+ "block-padding",
"generic-array",
]
@@ -3394,6 +3514,33 @@ 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",
+ "bitflags 2.13.2",
+ "cbc",
+ "ecb",
+ "encoding_rs",
+ "flate2",
+ "getrandom 0.4.3",
+ "indexmap 2.14.2",
+ "itoa",
+ "log",
+ "md-5",
+ "nom 8.0.0",
+ "rand 0.10.2",
+ "rangemap",
+ "sha2 0.10.9",
+ "stringprep",
+ "thiserror 2.0.20",
+ "ttf-parser",
+ "weezl",
+]
+
[[package]]
name = "lru-slab"
version = "0.1.3"
@@ -3470,6 +3617,16 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
+[[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 = "memchr"
version = "2.8.3"
@@ -3584,6 +3741,12 @@ dependencies = [
"windows-sys 0.60.2",
]
+[[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"
@@ -4649,6 +4812,23 @@ dependencies = [
"subtle",
]
+[[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",
+ "log",
+ "lopdf",
+ "postscript",
+ "type1-encoding-parser",
+ "unicode-normalization",
+]
+
[[package]]
name = "percent-encoding"
version = "2.3.2"
@@ -4893,6 +5073,12 @@ dependencies = [
"universal-hash",
]
+[[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"
@@ -4908,6 +5094,12 @@ 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"
@@ -5041,6 +5233,7 @@ version = "0.41.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1"
dependencies = [
+ "encoding_rs",
"memchr",
]
@@ -5227,6 +5420,12 @@ dependencies = [
"rand_core 0.10.1",
]
+[[package]]
+name = "rangemap"
+version = "1.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d"
+
[[package]]
name = "raw-window-handle"
version = "0.6.2"
@@ -6417,6 +6616,17 @@ dependencies = [
"quote",
]
+[[package]]
+name = "stringprep"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
+dependencies = [
+ "unicode-bidi",
+ "unicode-normalization",
+ "unicode-properties",
+]
+
[[package]]
name = "strsim"
version = "0.11.1"
@@ -7796,9 +8006,12 @@ name = "tinymemory-integrations"
version = "1.23.1"
dependencies = [
"async-trait",
+ "calamine",
"chrono",
"futures",
"log",
+ "pdf-extract",
+ "quick-xml 0.41.0",
"regex",
"reqwest 0.12.28",
"rusqlite",
@@ -7812,6 +8025,7 @@ dependencies = [
"tokio",
"tracing",
"walkdir",
+ "zip 8.6.0",
]
[[package]]
@@ -8396,6 +8610,12 @@ 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"
@@ -8433,12 +8653,27 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
+[[package]]
+name = "typed-path"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e"
+
[[package]]
name = "typeid"
version = "1.0.3"
@@ -8518,12 +8753,33 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
+[[package]]
+name = "unicode-bidi"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
+
[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
+[[package]]
+name = "unicode-normalization"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
+name = "unicode-properties"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
+
[[package]]
name = "unicode-segmentation"
version = "1.13.3"
@@ -10098,6 +10354,20 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "zip"
+version = "8.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"
+dependencies = [
+ "crc32fast",
+ "flate2",
+ "indexmap 2.14.2",
+ "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.toml
index a5f4e59800..67d1eabf8f 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -207,7 +207,7 @@ tinyruntime-pyserver = { path = "../../vendor/tinyruntime/crates/tinyruntime-pys
# `memory::` is the only module that names the engine side.
tinymemory-api = { path = "../../vendor/tinymemory/crates/tinymemory-api" }
tinymemory-tools = { path = "../../vendor/tinymemory/crates/tinymemory-tools" }
-tinymemory-integrations = { path = "../../vendor/tinymemory/crates/tinymemory-integrations", default-features = false, features = ["cortex", "brain", "sources-network", "safety", "legacy-import"] }
+tinymemory-integrations = { path = "../../vendor/tinymemory/crates/tinymemory-integrations", default-features = false, features = ["cortex", "brain", "documents-office", "sources-network", "safety", "legacy-import"] }
# tinyconnectors-bus — the OAuth connector wire contract
# (https://github.com/tinyhumansai/tinyconnectors). Payload types and member
# names for the connector surface, with no transport and no behaviour: this
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs
index 2928ac47ab..a327583cbe 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs
@@ -68,3 +68,119 @@ async fn a_turn_without_a_pack_is_left_alone() {
assert_eq!(request.messages.len(), 1);
assert!(ctx.data.child().memory_turn.is_none());
}
+
+// ── prompt-cache stability across turns (#6718, #7023) ──────────────────────
+//
+// A provider caches the longest prefix two requests share. The pack is
+// recalled per turn, so it differs every turn; what must never happen is the
+// pack rewriting what came before it, or one turn's pack surviving into the
+// next turn's history.
+
+fn pack_saying(fact: &str) -> TurnPack {
+ TurnPack {
+ markdown: format!("# Memory\n\n## Learnings\n- {fact}"),
+ ..pack()
+ }
+}
+
+async fn request_for(
+ history: &[Message],
+ pack: TurnPack,
+ profile: Option<tinyinference_llm::model::ModelProfile>,
+) -> ModelRequest {
+ let mut ctx = context(Some(pack));
+ ctx.model_profile = profile;
+ let mut request = ModelRequest::new(history.to_vec());
+ MemoryPackMiddleware
+ .before_model(&mut ctx, &(), &mut request)
+ .await
+ .unwrap();
+ request
+}
+
+/// Messages two requests share from the start: what a prefix cache can reuse.
+fn shared_prefix(a: &[Message], b: &[Message]) -> usize {
+ a.iter().zip(b).take_while(|(x, y)| x == y).count()
+}
+
+fn two_turns() -> (Vec<Message>, Vec<Message>) {
+ let turn_one = vec![
+ Message::system("You are helpful."),
+ Message::user("How far is Porto from Lisbon?"),
+ ];
+ let mut turn_two = turn_one.clone();
+ turn_two.push(Message::assistant("About 310 km."));
+ turn_two.push(Message::user("And by train?"));
+ (turn_one, turn_two)
+}
+
+#[tokio::test]
+async fn a_new_turn_reuses_the_whole_previous_transcript_as_cached_prefix() {
+ let (turn_one, turn_two) = two_turns();
+ let first = request_for(
+ &turn_one,
+ pack_saying("The user prefers metric units"),
+ None,
+ )
+ .await;
+ let second = request_for(&turn_two, pack_saying("The user travels by rail"), None).await;
+
+ // Turn two's request starts with turn two's transcript, byte for byte.
+ assert_eq!(&second.messages[..turn_two.len()], &turn_two[..]);
+ // The cache hit covers every message turn one sent before its pack.
+ assert_eq!(
+ shared_prefix(&first.messages, &second.messages),
+ turn_one.len()
+ );
+ // Only the tail differs, and turn one's pack is nowhere in turn two.
+ assert_eq!(second.messages.len(), turn_two.len() + 1);
+ let sent: String = second.messages.iter().map(Message::text).collect();
+ assert!(
+ !sent.contains("metric units"),
+ "turn one's pack leaked: {sent}"
+ );
+ assert!(sent.contains("travels by rail"));
+}
+
+#[tokio::test]
+async fn on_a_hoisting_model_only_the_previous_tail_message_falls_out_of_the_cache() {
+ let hoisting = Some(tinyinference_llm::model::ModelProfile {
+ hoists_system_messages: true,
+ ..Default::default()
+ });
+ let (turn_one, turn_two) = two_turns();
+ let first = request_for(
+ &turn_one,
+ pack_saying("The user prefers metric units"),
+ hoisting.clone(),
+ )
+ .await;
+ let second = request_for(&turn_two, pack_saying("The user travels by rail"), hoisting).await;
+
+ // No system message is added: a hoisted one would rewrite the head (#6962).
+ assert_eq!(first.messages.len(), turn_one.len());
+ assert_eq!(second.messages.len(), turn_two.len());
+ // The pack rides the tail user turn; everything before the tail is the
+ // transcript untouched, so the head stays cached.
+ assert_eq!(
+ &second.messages[..turn_two.len() - 1],
+ &turn_two[..turn_two.len() - 1]
+ );
+ assert!(second
+ .messages
+ .last()
+ .unwrap()
+ .text()
+ .contains("travels by rail"));
+ // Turn one's tail carried turn one's pack, so the shared prefix stops just
+ // before it: one user message, never the whole history.
+ assert_eq!(
+ shared_prefix(&first.messages, &second.messages),
+ turn_one.len() - 1
+ );
+ let sent: String = second.messages.iter().map(Message::text).collect();
+ assert!(
+ !sent.contains("metric units"),
+ "turn one's pack leaked: {sent}"
+ );
+}
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rs
index 563113e10a..135b968924 100644
--- a/crates/openhuman-core/src/memory/brain.rs
+++ b/crates/openhuman-core/src/memory/brain.rs
@@ -12,7 +12,7 @@
use serde::{Deserialize, Serialize};
use tinymemory_api::{ExploreRequest, Facet, Hit, Namespace, StoreItem, WriteOptions};
-use tinymemory_integrations::documents::{NativeConverter, RawDocument};
+use tinymemory_integrations::documents::RawDocument;
use tinymemory_tools::{Brain, BrainSource, MemoryLayout};
use crate::config::schema::MemorySourceKind;
@@ -230,11 +230,14 @@ 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(&NativeConverter, &raw, source, meta)
- .await
- .map_err(|error| {
- MemoryError::invalid(format!("cannot convert the file: {error}"))
- })?
+ tinymemory_integrations::brain::brain_document(
+ super::convert::converter(),
+ &raw,
+ source,
+ meta,
+ )
+ .await
+ .map_err(|error| MemoryError::invalid(format!("cannot convert the file: {error}")))?
}
(None, Some(text)) => {
tinymemory_tools::BrainDocument::new(source.unwrap_or(BrainSource::Markdown), text)
diff --git a/crates/openhuman-core/src/memory/convert.rs b/crates/openhuman-core/src/memory/convert.rs
new file mode 100644
index 0000000000..164ae11eb1
--- /dev/null
+++ b/crates/openhuman-core/src/memory/convert.rs
@@ -0,0 +1,58 @@
+//! The document converter memory files with: PDF, DOCX, PPTX and XLSX through
+//! TinyMemory's `OfficeConverter`, then its `NativeConverter` for text,
+//! markdown, HTML and code.
+//!
+//! 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;
+
+use async_trait::async_trait;
+use tinymemory_integrations::documents::{
+ ConvertedDocument, ConverterChain, DocumentConverter, DocumentFormat, Error, OfficeConverter,
+ RawDocument, Result,
+};
+
+/// [`OfficeConverter`] on the blocking pool.
+struct BlockingOffice;
+
+#[async_trait]
+impl DocumentConverter for BlockingOffice {
+ fn name(&self) -> &str {
+ OfficeConverter.name()
+ }
+
+ fn supports(&self, format: DocumentFormat) -> bool {
+ OfficeConverter.supports(format)
+ }
+
+ async fn convert(&self, document: &RawDocument) -> Result<ConvertedDocument> {
+ let document = document.clone();
+ tokio::task::spawn_blocking(move || OfficeConverter.convert_blocking(&document))
+ .await
+ .map_err(|error| Error::Converter {
+ converter: "office".to_string(),
+ message: format!("the conversion task did not finish: {error}"),
+ })?
+ }
+}
+
+static CHAIN: LazyLock<ConverterChain> =
+ LazyLock::new(|| ConverterChain::default().prepend(Box::new(BlockingOffice)));
+
+/// The converter every memory write of a file goes through.
+pub(crate) fn converter() -> &'static ConverterChain {
+ &CHAIN
+}
+
+#[cfg(test)]
+#[path = "convert_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/memory/convert_tests.rs b/crates/openhuman-core/src/memory/convert_tests.rs
new file mode 100644
index 0000000000..234c6be372
--- /dev/null
+++ b/crates/openhuman-core/src/memory/convert_tests.rs
@@ -0,0 +1,99 @@
+use super::*;
+
+use tinymemory_api::{ItemKind, MetaFilter};
+
+use crate::memory::brain::{ingest, BrainIngestParams};
+use crate::memory::test_fixtures::{bind_reference, config_in, stored};
+
+/// A one-page PDF whose only text is `text` (Helvetica, no compression).
+fn pdf_saying(text: &str) -> Vec<u8> {
+ let stream = format!("BT /F1 12 Tf 72 720 Td ({text}) Tj ET");
+ let objects = [
+ "<< /Type /Catalog /Pages 2 0 R >>".to_string(),
+ "<< /Type /Pages /Kids [3 0 R] /Count 1 >>".to_string(),
+ "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R \
+ /Resources << /Font << /F1 5 0 R >> >> >>"
+ .to_string(),
+ format!(
+ "<< /Length {} >>\nstream\n{stream}\nendstream",
+ stream.len()
+ ),
+ "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>".to_string(),
+ ];
+ let mut out = String::from("%PDF-1.4\n");
+ let mut offsets = Vec::new();
+ for (i, object) in objects.iter().enumerate() {
+ offsets.push(out.len());
+ out.push_str(&format!("{} 0 obj\n{object}\nendobj\n", i + 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()
+}
+
+#[tokio::test]
+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()
+ .convert(&raw)
+ .await
+ .expect("the office converter reads pdf");
+ assert!(
+ converted.markdown.contains("PV-7023"),
+ "{}",
+ converted.markdown
+ );
+}
+
+#[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()
+ .convert(&raw)
+ .await
+ .expect("native handles markdown");
+ assert!(converted.markdown.contains("Plain markdown."));
+}
+
+#[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();
+ assert!(matches!(error, Error::UnsupportedFormat(_)), "{error}");
+}
+
+#[tokio::test]
+async fn brain_ingest_files_a_pdf_by_path() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(&tmp);
+ 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();
+
+ let view = ingest(
+ &config,
+ BrainIngestParams {
+ path: Some(path.display().to_string()),
+ text: None,
+ source: None,
+ title: None,
+ },
+ )
+ .await
+ .expect("a pdf is ingested, not refused");
+ assert_eq!(view.source, "pdf");
+
+ let docs = stored(&engine, MetaFilter::kinds([ItemKind::Document])).await;
+ assert_eq!(docs.len(), 1);
+ assert!(docs[0].text.contains("PV-7023"), "{}", docs[0].text);
+}
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
index 51af28b5d2..14e650ab22 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
@@ -312,3 +312,70 @@ fn a_refusal_is_read_back_from_a_skipped_section() {
})];
assert!(refusal_of(&quiet).is_none());
}
+
+// ── the pack's token budget against a large store (#6718, #7023) ────────────
+
+async fn fill_with_learnings(engine: &tinymemory_api::conformance::ReferenceEngine, count: usize) {
+ for i in 0..count {
+ engine
+ .store(StoreItem::learning(
+ format!(
+ "Project note {i}: the Lisbon office ships release {i} on a Thursday, \
+ reviewed by team {} with a rollback window of {} hours.",
+ i % 17,
+ i % 9 + 1
+ ),
+ LearningKind::Fact,
+ 0.8,
+ MemoryMeta::default(),
+ ))
+ .await
+ .unwrap();
+ }
+}
+
+fn budget(config: &crate::config::Config) -> usize {
+ config.memory.recall.budget_tokens as usize
+}
+
+/// Lines that appear more than once in a rendered pack (headings aside).
+fn repeated_lines(markdown: &str) -> Vec<String> {
+ let mut seen = std::collections::HashSet::new();
+ markdown
+ .lines()
+ .map(str::trim)
+ .filter(|line| line.starts_with("- "))
+ .filter(|line| !seen.insert(line.to_string()))
+ .map(str::to_string)
+ .collect()
+}
+
+#[tokio::test]
+async fn a_turn_pack_stays_within_its_budget_against_a_large_store() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(&tmp);
+ let engine = bind_reference(&config);
+ fill_with_learnings(&engine, 1500).await;
+ let identity = MemoryIdentity::agent("orchestrator").resolve(&config);
+
+ let pack = pre_turn(
+ &config,
+ &identity,
+ input("t-large", 0, "when does the Lisbon release ship?"),
+ )
+ .await
+ .expect("a pack");
+ eprintln!(
+ "large store: 1500 learnings -> pack {} tokens (budget {}), {} refs",
+ pack.tokens,
+ budget(&config),
+ pack.refs.len()
+ );
+ assert!(
+ pack.tokens <= budget(&config),
+ "{} > {}",
+ pack.tokens,
+ budget(&config)
+ );
+ assert!(repeated_lines(&pack.markdown).is_empty());
+}
diff --git a/crates/openhuman-core/src/memory/mod.rs b/crates/openhuman-core/src/memory/mod.rs
index e3674d68df..cdf7932183 100644
--- a/crates/openhuman-core/src/memory/mod.rs
+++ b/crates/openhuman-core/src/memory/mod.rs
@@ -23,6 +23,7 @@ pub mod backfill;
pub mod brain;
pub mod bus;
pub mod channels;
+pub(crate) mod convert;
pub mod engine;
pub mod error;
pub mod explore;
diff --git a/crates/openhuman-core/src/memory/sources/sync.rs b/crates/openhuman-core/src/memory/sources/sync.rs
index 214f4e0922..e179d938cd 100644
--- a/crates/openhuman-core/src/memory/sources/sync.rs
+++ b/crates/openhuman-core/src/memory/sources/sync.rs
@@ -11,7 +11,6 @@ use std::path::PathBuf;
use std::sync::{LazyLock, Mutex};
use chrono::{DateTime, Utc};
-use tinymemory_integrations::documents::NativeConverter;
use tinymemory_integrations::sources::readers::reader_for_request;
use tinymemory_integrations::sources::{collect_items, MemorySourceEntry, SourceKind};
@@ -82,7 +81,7 @@ pub async fn sync_one(config: &Config, source: &MemorySourceConfig) -> MemoryRes
reader.as_ref(),
&entry,
&config.action_dir,
- &NativeConverter,
+ crate::memory::convert::converter(),
)
.await
.map_err(|error| MemoryError::Engine(format!("reading the source failed: {error}")))?;
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs b/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
index 2f9c9c8c3b..16474368a1 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
@@ -322,7 +322,7 @@ Capability {
name: "Brain",
domain: "memory",
category: CapabilityCategory::Intelligence,
- description: "Documents every agent shares, filed by source type (pdf, markdown, notion, github, web, and one per other source). Add a document from text or a file, search it, forget a whole source, or keep it synced from a folder, a single file, a link, a GitHub repository, an RSS feed or a connected Composio toolkit, on demand and on a schedule.",
+ description: "Documents every agent shares, filed by source type (pdf, markdown, notion, github, web, and one per other source). Add a document from text or a file (text, markdown, HTML, code, PDF, Word, PowerPoint or Excel; images are not read yet), search it, forget a whole source, or keep it synced from a folder, a single file, a link, a GitHub repository, an RSS feed or a connected Composio toolkit, on demand and on a schedule.",
how_to: "Connections > Memory > Brain (/connections?tab=brain&brain=brain). Programmatic: openhuman.memory_brain_sources, memory_brain_search, memory_brain_ingest, memory_brain_forget, memory_sources_add, memory_sources_sync (RPC).",
status: CapabilityStatus::Beta,
privacy: MEMORY_TO_REMOTE_ENGINE,