diff --git a/.gitmodules b/.gitmodules index 5625b913..e270f8ab 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,6 @@ path = vendor/tinycortex url = https://github.com/tinyhumansai/tinycortex.git branch = main -[submodule "vendor/tinyagents"] - path = vendor/tinyagents - url = https://github.com/tinyhumansai/tinyagents - branch = main +[submodule "vendor/tinyinference"] + path = vendor/tinyinference + url = https://github.com/tinyhumansai/tinyinference.git diff --git a/Cargo.lock b/Cargo.lock index 06fb6eba..6ebdf2a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1818,24 +1818,6 @@ dependencies = [ "syn 3.0.3", ] -[[package]] -name = "tinyagents" -version = "2.1.0" -dependencies = [ - "async-trait", - "bytes", - "chrono", - "futures", - "reqwest", - "rusqlite", - "serde", - "serde_json", - "sha2 0.11.0", - "thiserror 2.0.20", - "tokio", - "tracing", -] - [[package]] name = "tinycortex" version = "0.1.1" @@ -1862,8 +1844,8 @@ dependencies = [ "serde_json", "sha2 0.10.9", "thiserror 2.0.20", - "tinyagents", "tinycortex-api", + "tinyinference", "tokio", "toml", "tracing", @@ -1878,6 +1860,22 @@ dependencies = [ "tinymemory-api", ] +[[package]] +name = "tinyinference" +version = "0.2.1" +dependencies = [ + "async-trait", + "bytes", + "futures", + "httpdate", + "reqwest", + "serde", + "serde_json", + "sha2 0.11.0", + "thiserror 2.0.20", + "tokio", +] + [[package]] name = "tinymemory" version = "1.13.3" @@ -1958,9 +1956,9 @@ dependencies = [ "sha2 0.11.0", "tempfile", "thiserror 2.0.20", - "tinyagents", "tinycortex", "tinycortex-api", + "tinyinference", "tinymemory", "tinymemory-api", "tinymemory-conformance", diff --git a/Cargo.toml b/Cargo.toml index 2d36b675..64aee772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,8 @@ default-members = [ "crates/tinymemory-sync", "crates/tinymemory-tinycortex", ] -# `vendor/` holds engine submodules (tinycortex, tinybus, tinyagents), each of +# `vendor/` holds pinned source submodules (tinycortex, tinybus, +# tinyinference), each of # which is its own workspace with its own lockfile. Same exclusion # `vendor/tinycortex` uses for its own nested vendor directory. # @@ -73,24 +74,19 @@ exclude = ["vendor", "crates/tinymemory-module", "worktrees"] [patch."https://github.com/tinyhumansai/tinymemory"] tinymemory-api = { path = "crates/tinymemory-api" } +# TinyCortex pins TinyInference by git until it is published. Collapse that git +# source onto the same checkout `tinymemory-core` resolves through crates.io so +# both crates share one trait identity. +[patch."https://github.com/tinyhumansai/tinyinference"] +tinyinference = { path = "vendor/tinyinference/crates/tinyinference" } + [patch.crates-io] tinycortex = { path = "vendor/tinycortex" } tinycortex-api = { path = "vendor/tinycortex/api" } -# `tinymemory-core`'s summariser and embedder factory name tinyagents' chat and -# embedding model traits. It is not published, so a standalone build of this -# workspace has to be told where it is — hence its own submodule alongside -# tinycortex and tinybus. -# -# Deliberately NOT `vendor/tinycortex/vendor/tinyagents`: the engine pins v2.1.0 -# there, which predates `RECOMMENDED_OLLAMA_CONTEXT_TOKENS` that the embedder -# factory needs. Reaching through another submodule's pin also makes this -# crate's dependency an accident of the engine's, which is not a relationship -# worth having. -# -# A host that embeds this crate patches tinyagents itself — patch tables only -# apply from the workspace root being built — so this entry affects standalone -# builds and `cargo test` here, and nothing downstream. -tinyagents = { path = "vendor/tinyagents" } +# `tinymemory-core` names the provider-neutral chat and embedding contracts +# from TinyInference. It is not published, so standalone builds resolve the +# version requirement to the pinned checkout here. +tinyinference = { path = "vendor/tinyinference/crates/tinyinference" } [profile.release] # Cross-crate optimization and smaller, faster binaries for release builds. diff --git a/README.md b/README.md index 3233d64f..43686fab 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ crates/ workspace on purpose — see the note in `Cargo.toml`. vendor/ ├── tinycortex/ the engine, pinned as a submodule -├── tinyagents/ pinned TinyAgents submodule +├── tinyinference/ provider-neutral inference APIs, pinned as a submodule └── tinybus/ pinned TinyBus submodule ``` @@ -103,8 +103,8 @@ families answer — see the engine table under Run `git submodule update --init --recursive` after cloning. Nothing in the -workspace builds without it — `tinymemory-core` names `tinyagents` and -`tinycortex` by path through `vendor/`, so an uninitialized checkout fails at +workspace builds without it — `tinymemory-core` names `tinyinference` and +`tinycortex` by path through `vendor/`. An uninitialized checkout therefore fails at manifest resolution rather than at compile time, which reads as a confusing error. @@ -134,7 +134,7 @@ without any `[patch]` entries. The remote recipe above works by git because the remote adapter reaches only published crates. The embedded engine does not: it pulls `tinycortex`, -`tinycortex-api` and `tinyagents`, none of which are published, and +`tinycortex-api` and `tinyinference`, none of which are published, and `tinycortex-api` takes `tinymemory-api` *by git*, which cargo will resolve as a second copy of a crate this workspace also provides by path. Patching that away needs the crates on disk, so the embedded path is a submodule dependency until @@ -149,21 +149,25 @@ git -C vendor/tinymemory submodule update --init --recursive [dependencies] tinymemory = { path = "vendor/tinymemory", features = ["tinycortex"] } -# All four are required. The first three are unpublished crates the engine -# needs; the fourth collapses `tinycortex-api`'s git dependency on -# `tinymemory-api` onto the copy in this tree — without it two distinct +# All five entries are required. The three crates.io patches resolve unpublished +# crates used by the memory layer and embedded engine. The TinyInference source +# patch collapses TinyCortex's git dependency onto that same crate identity. The +# fifth entry collapses `tinycortex-api`'s git dependency on `tinymemory-api` +# onto the copy in this tree — without it two distinct # `tinymemory_api::MemoryEntry` types exist and the seam stops type-checking. [patch.crates-io] tinycortex = { path = "vendor/tinymemory/vendor/tinycortex" } tinycortex-api = { path = "vendor/tinymemory/vendor/tinycortex/api" } -tinyagents = { path = "vendor/tinymemory/vendor/tinyagents" } +tinyinference = { path = "vendor/tinymemory/vendor/tinyinference/crates/tinyinference" } +[patch."https://github.com/tinyhumansai/tinyinference"] +tinyinference = { path = "vendor/tinymemory/vendor/tinyinference/crates/tinyinference" } [patch."https://github.com/tinyhumansai/tinymemory"] tinymemory-api = { path = "vendor/tinymemory/api" } ``` This exact patch set is what the reference consumer in `crates/tinymemory/examples/` and the repository's own root manifest use; a -build missing any of the four fails at resolution, before compiling a line. +build missing any of the five fails at resolution, before compiling a line. ```rust,ignore use std::sync::Arc; diff --git a/crates/tinymemory-api/Cargo.toml b/crates/tinymemory-api/Cargo.toml index 4ff3c999..e2c2cff2 100644 --- a/crates/tinymemory-api/Cargo.toml +++ b/crates/tinymemory-api/Cargo.toml @@ -7,7 +7,7 @@ publish = false version = "0.1.1" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" repository = "https://github.com/tinyhumansai/tinymemory" description = "Stable public contracts for the TinyMemory memory system" diff --git a/crates/tinymemory-bus/Cargo.toml b/crates/tinymemory-bus/Cargo.toml index 881e8881..23bbd20a 100644 --- a/crates/tinymemory-bus/Cargo.toml +++ b/crates/tinymemory-bus/Cargo.toml @@ -6,7 +6,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" repository = "https://github.com/tinyhumansai/tinymemory" description = "The TinyBus wire contract for the TinyMemory module: member names, payload types, and typed calls" diff --git a/crates/tinymemory-conformance/Cargo.toml b/crates/tinymemory-conformance/Cargo.toml index 286585f5..7f5c10c7 100644 --- a/crates/tinymemory-conformance/Cargo.toml +++ b/crates/tinymemory-conformance/Cargo.toml @@ -4,7 +4,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" description = "Behavioural conformance suite every MemoryProvider driver must pass" repository = "https://github.com/tinyhumansai/tinymemory" diff --git a/crates/tinymemory-core/Cargo.toml b/crates/tinymemory-core/Cargo.toml index 07eb474b..d9840c09 100644 --- a/crates/tinymemory-core/Cargo.toml +++ b/crates/tinymemory-core/Cargo.toml @@ -7,7 +7,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" description = "The engine-neutral memory subsystem: store, summary tree, sync pipelines, ingestion and recall" repository = "https://github.com/tinyhumansai/tinymemory" readme = "../../README.md" @@ -37,9 +37,10 @@ regex = "1.10" tinycortex = { version = "0.1", features = ["obsidian", "persona", "people", "sync"] } tinycortex-api = { version = "0.1" } -# Chat-model and embedding primitives used by the tree summarizer and the -# embedding factory. -tinyagents = { version = "2.1", features = ["sqlite"] } +# Provider-neutral chat-model and embedding primitives used by the tree +# summarizer and embedding factory. Agent runtime and session behavior do not +# belong in the memory layer. +tinyinference = "0.2" anyhow = "1.0" async-trait = "0.1" # NO `git2` HERE, DELIBERATELY — do not add it back. `diff/` holds the ops and diff --git a/crates/tinymemory-core/src/chat.rs b/crates/tinymemory-core/src/chat.rs index f9f4b5d9..ae3137ce 100644 --- a/crates/tinymemory-core/src/chat.rs +++ b/crates/tinymemory-core/src/chat.rs @@ -13,8 +13,8 @@ use async_trait::async_trait; use crate::chat_host::{create_chat_model_with_model_id, provider_for_role, UsageInfo}; use crate::Config; -use tinyagents::harness::message::Message; -use tinyagents::harness::model::{ChatModel, ModelRequest}; +use tinyinference::message::Message; +use tinyinference::model::{ChatModel, ModelRequest}; /// One pair of prompt messages handed to the memory LLM backend. #[derive(Debug, Clone)] diff --git a/crates/tinymemory-core/src/chat_host.rs b/crates/tinymemory-core/src/chat_host.rs index c6edc7c4..076779f4 100644 --- a/crates/tinymemory-core/src/chat_host.rs +++ b/crates/tinymemory-core/src/chat_host.rs @@ -8,10 +8,10 @@ //! //! # Why this trait is here and not in `tinymemory-api` //! -//! It names `tinyagents::harness::model::ChatModel`, and the contract crate is -//! deliberately dependency-light — it must not pull in tinyagents. This crate -//! already depends on tinyagents, so it is the one place that can name both the -//! model trait and the config seam. The host implements it here. +//! It names [`tinyinference::model::ChatModel`], and the contract crate is +//! deliberately dependency-light — it must not pull in an inference SDK. This +//! crate already depends on TinyInference, so it is the one place that can name +//! both the model trait and the config seam. The host implements it here. //! //! Reached through a process-global for the same reason as //! [`crate::embedding_host`]; see that module for the rationale, and for why an @@ -20,7 +20,7 @@ use std::sync::Arc; use parking_lot::RwLock; -use tinyagents::harness::model::{ChatModel, ModelResponse}; +use tinyinference::model::{ChatModel, ModelResponse}; use crate::Config; diff --git a/crates/tinymemory-core/src/embedding_adapter.rs b/crates/tinymemory-core/src/embedding_adapter.rs index 25073584..037f33c2 100644 --- a/crates/tinymemory-core/src/embedding_adapter.rs +++ b/crates/tinymemory-core/src/embedding_adapter.rs @@ -1,24 +1,24 @@ -//! [`TinyAgentsEmbeddingProvider`] — the adapter from tinyagents' own embedding +//! [`TinyInferenceEmbeddingProvider`] — the adapter from TinyInference's embedding //! model trait onto the seam's [`EmbeddingProvider`]. //! //! It lives in this crate rather than in `tinymemory-api` because the contract -//! crate must stay dependency-light and cannot name `tinyagents`; and rather +//! crate must stay dependency-light and cannot name `tinyinference`; and rather //! than in the host because the tree's embedder factory — which is core code — //! builds Ollama models directly and needs to wrap them. The host re-exports it //! from `inference::embeddings`, so every existing path there keeps resolving //! and keeps naming this one type. use async_trait::async_trait; -use tinyagents::harness::embeddings::EmbeddingModel; +use tinyinference::embeddings::EmbeddingModel; pub use tinymemory_api::host::{format_embedding_signature, EmbeddingProvider}; -/// Compatibility adapter from the canonical tinyagents embedding model. -pub struct TinyAgentsEmbeddingProvider { +/// Compatibility adapter from the canonical TinyInference embedding model. +pub struct TinyInferenceEmbeddingProvider { model: Box, } -impl TinyAgentsEmbeddingProvider { +impl TinyInferenceEmbeddingProvider { pub fn new(model: impl EmbeddingModel + 'static) -> Self { Self { model: Box::new(model), @@ -31,7 +31,7 @@ impl TinyAgentsEmbeddingProvider { } #[async_trait] -impl EmbeddingProvider for TinyAgentsEmbeddingProvider { +impl EmbeddingProvider for TinyInferenceEmbeddingProvider { fn name(&self) -> &str { self.model.name() } diff --git a/crates/tinymemory-core/src/engine/mod.rs b/crates/tinymemory-core/src/engine/mod.rs index 6a936456..39e37469 100644 --- a/crates/tinymemory-core/src/engine/mod.rs +++ b/crates/tinymemory-core/src/engine/mod.rs @@ -3,7 +3,7 @@ //! //! OpenHuman's memory subsystem migrates onto the `tinycortex` crate (store / //! chunks / tree / retrieval / queue / ingest / score + the long tail). This -//! module is the **adapter seam**, mirroring `src/openhuman/agent/tinyagents/`: it +//! module is the **adapter seam**, mirroring the host's inference adapters: it //! implements the crate's engine traits over OpenHuman services and derives the //! engine's [`tinycortex::memory::MemoryConfig`] from the host `Config`. Nothing here contains //! engine logic — that lives in the crate. diff --git a/crates/tinymemory-core/src/sources/reconcile.rs b/crates/tinymemory-core/src/sources/reconcile.rs index 6703a46c..7261f274 100644 --- a/crates/tinymemory-core/src/sources/reconcile.rs +++ b/crates/tinymemory-core/src/sources/reconcile.rs @@ -119,19 +119,6 @@ pub async fn apply_composio_source_caps_migration() -> Result<(), String> { Ok(()) } -#[cfg(test)] -fn short_id(id: &str) -> &str { - // Show only the last 8 Unicode scalar values to keep labels compact. - // Byte-slicing would panic if the cut point isn't a UTF-8 boundary. - let n = id.chars().count(); - if n <= 8 { - return id; - } - let skip = n - 8; - let start = id.char_indices().nth(skip).map(|(idx, _)| idx).unwrap_or(0); - &id[start..] -} - #[cfg(test)] #[path = "reconcile_tests.rs"] mod tests; diff --git a/crates/tinymemory-core/src/sources/reconcile_tests.rs b/crates/tinymemory-core/src/sources/reconcile_tests.rs index e36e3d94..b7661b2f 100644 --- a/crates/tinymemory-core/src/sources/reconcile_tests.rs +++ b/crates/tinymemory-core/src/sources/reconcile_tests.rs @@ -3,6 +3,18 @@ use super::*; use crate::sources::types::{MemorySourceEntry, SourceKind}; +fn short_id(id: &str) -> &str { + // Show only the last 8 Unicode scalar values to keep labels compact. + // Byte-slicing would panic if the cut point isn't a UTF-8 boundary. + let n = id.chars().count(); + if n <= 8 { + return id; + } + let skip = n - 8; + let start = id.char_indices().nth(skip).map(|(idx, _)| idx).unwrap_or(0); + &id[start..] +} + fn make_composio_entry( id: &str, toolkit: &str, diff --git a/crates/tinymemory-core/src/store/factories.rs b/crates/tinymemory-core/src/store/factories.rs index e46fed49..9272bde3 100644 --- a/crates/tinymemory-core/src/store/factories.rs +++ b/crates/tinymemory-core/src/store/factories.rs @@ -18,7 +18,7 @@ use rusqlite::Connection; use crate::embedding_host::require_embedding_host; use crate::store::namespace_store::UnifiedMemory; use crate::traits::Memory; -use tinyagents::harness::embeddings::{DEFAULT_OLLAMA_DIMENSIONS, DEFAULT_OLLAMA_MODEL}; +use tinyinference::embeddings::{DEFAULT_OLLAMA_DIMENSIONS, DEFAULT_OLLAMA_MODEL}; use tinymemory_api::host::MemoryConfig; use tinymemory_api::host::{format_embedding_signature, EmbeddingProvider}; use tinymemory_api::host::{EmbeddingRouteConfig, StorageProviderConfig}; diff --git a/crates/tinymemory-core/src/store/factories_tests.rs b/crates/tinymemory-core/src/store/factories_tests.rs index 4ffbf480..f3a993aa 100644 --- a/crates/tinymemory-core/src/store/factories_tests.rs +++ b/crates/tinymemory-core/src/store/factories_tests.rs @@ -91,7 +91,7 @@ fn embedding_settings_local_overrides_memory_config() { assert_eq!(model, "nomic-embed-text:latest"); assert_eq!( dims, - tinyagents::harness::embeddings::DEFAULT_OLLAMA_DIMENSIONS, + tinyinference::embeddings::DEFAULT_OLLAMA_DIMENSIONS, "dimensions must default to Ollama default" ); } @@ -105,13 +105,10 @@ fn embedding_settings_local_with_empty_model_uses_default() { assert_eq!(provider, "ollama"); assert_eq!( model, - tinyagents::harness::embeddings::DEFAULT_OLLAMA_MODEL, + tinyinference::embeddings::DEFAULT_OLLAMA_MODEL, "empty model ID must fall back to default Ollama model" ); - assert_eq!( - dims, - tinyagents::harness::embeddings::DEFAULT_OLLAMA_DIMENSIONS - ); + assert_eq!(dims, tinyinference::embeddings::DEFAULT_OLLAMA_DIMENSIONS); } #[test] @@ -226,7 +223,7 @@ async fn start_mock_ollama() -> String { /// the legacy `local_ai.usage.embeddings = true` flag was set. Used so /// the existing test scenarios continue to drive the local code path. fn local_embedding_for_test() -> &'static str { - tinyagents::harness::embeddings::DEFAULT_OLLAMA_MODEL + tinyinference::embeddings::DEFAULT_OLLAMA_MODEL } #[tokio::test] diff --git a/crates/tinymemory-core/src/store/identity.rs b/crates/tinymemory-core/src/store/identity.rs index edb306f9..a70fd7ea 100644 --- a/crates/tinymemory-core/src/store/identity.rs +++ b/crates/tinymemory-core/src/store/identity.rs @@ -122,8 +122,6 @@ pub fn is_self_identity_any_toolkit(kind: IdentityKind, raw_value: &str) -> bool .skill_identity_matches(&key_pattern, &canonical) } -/// Render a compact section for prompt injection. Skips `user_id` (not -/// human-readable), prefixes `handle` with `@`. /// Fold a token to the shape used in a profile-store key. pub fn normalize_token(raw: &str) -> String { let mut out = String::with_capacity(raw.len()); diff --git a/crates/tinymemory-core/src/store/memory_trait_tests.rs b/crates/tinymemory-core/src/store/memory_trait_tests.rs index 12fd955e..f753821e 100644 --- a/crates/tinymemory-core/src/store/memory_trait_tests.rs +++ b/crates/tinymemory-core/src/store/memory_trait_tests.rs @@ -682,8 +682,8 @@ async fn subconscious_recall_surfaces_external_sync_taint_for_origin_upgrade() { // ── Same-session self-echo exclusion, via the ambient thread scope ──── // // `Memory::recall` (backing the agent's `memory_recall` tool) reads the -// ambient chat-thread id set by `tinyagents::thread_context` -// around a live turn, and excludes documents tagged with that same id — +// ambient chat-thread id set by the host around a live turn, and excludes +// documents tagged with that same id — // guarding against the harness's own `user_msg:` autosave being // recalled as the top "relevant" result for the very request that // triggered the search. See `agent::harness::session::turn::core` diff --git a/crates/tinymemory-core/src/test_seams.rs b/crates/tinymemory-core/src/test_seams.rs index d8211d8f..6f6defad 100644 --- a/crates/tinymemory-core/src/test_seams.rs +++ b/crates/tinymemory-core/src/test_seams.rs @@ -72,13 +72,13 @@ impl crate::chat_host::ChatHost for TestChatHost { _role: &str, _config: &Config, _temperature: f64, - ) -> Result<(Arc>, String), String> { + ) -> Result<(Arc>, String), String> { Err("TestChatHost does not build models — model routing is host behaviour".to_string()) } fn usage_from_response( &self, - _response: &tinyagents::harness::model::ModelResponse, + _response: &tinyinference::model::ModelResponse, ) -> Option { None } diff --git a/crates/tinymemory-core/src/tree/README.md b/crates/tinymemory-core/src/tree/README.md index 22bbd000..beb0d5f0 100644 --- a/crates/tinymemory-core/src/tree/README.md +++ b/crates/tinymemory-core/src/tree/README.md @@ -30,7 +30,7 @@ memory_store::trees (persistence: one Tree table, one schema) | [`tree/`](tree/) | `bucket_seal` (append leaf + cascade seal), `flush` (time-based partial seal), `registry` (kind-parameterized `get_or_create_tree` with UNIQUE-race recovery), `mod.rs` (re-exports + `memory_store::trees` shims for legacy paths). | | [`summarise.rs`](summarise.rs) | One function: produce the next-level summary text for a bucket. Wraps the chat model with a fixed prompt and token budget. | | [`retrieval/`](retrieval/) | Agent-facing tools. Read: `walk` (agentic), `drill_down`, `fetch_leaves`, `query_{source,global,topic}`, `search_entities`. Write: `ingest_document` (orchestrator-facing). | -| [`score/`](score/) | Product adapters over TinyCortex scoring and TinyAgents embedding models, plus entity extraction and the entity index store. | +| [`score/`](score/) | Product adapters over TinyCortex scoring and TinyInference embedding models, plus entity extraction and the entity index store. | ## Layer rules diff --git a/crates/tinymemory-core/src/tree/score/embed/README.md b/crates/tinymemory-core/src/tree/score/embed/README.md index 43b71bd3..2a004ca6 100644 --- a/crates/tinymemory-core/src/tree/score/embed/README.md +++ b/crates/tinymemory-core/src/tree/score/embed/README.md @@ -1,7 +1,7 @@ # Memory tree embedding bridge The memory tree stores fixed 1024-dimensional vectors. Concrete provider -transports live in TinyAgents; this directory keeps only memory-tree policy and +transports live in TinyInference; this directory keeps only memory-tree policy and compatibility: - `factory.rs`: read/write provider resolution, cloud-session policy, and @@ -11,7 +11,7 @@ compatibility: - `mod.rs`: the legacy `Embedder` contract, `ProviderEmbedder` bridge, batch fallback/dimension checks, cosine math, and SQLite f32 packing helpers. -Ollama uses TinyAgents `OllamaEmbeddingModel` and `/api/embed`, with the shared +Ollama uses TinyInference `OllamaEmbeddingModel` and `/api/embed`, with the shared 8192-token context and batch window. Managed cloud uses the host credential and -privacy wrapper around TinyAgents `CloudEmbeddingModel`. Do not add provider +privacy wrapper around TinyInference `CloudEmbeddingModel`. Do not add provider HTTP clients in this directory. diff --git a/crates/tinymemory-core/src/tree/score/embed/factory.rs b/crates/tinymemory-core/src/tree/score/embed/factory.rs index b9f9b514..72aa74e5 100644 --- a/crates/tinymemory-core/src/tree/score/embed/factory.rs +++ b/crates/tinymemory-core/src/tree/score/embed/factory.rs @@ -39,7 +39,7 @@ use tinymemory_api::host::test_support::TestHostConfig; use super::{Embedder, InertEmbedder, ProviderEmbedder, EMBEDDING_DIM}; use crate::embedding_host::require_embedding_host; use crate::Config; -use tinyagents::harness::embeddings::{OllamaEmbeddingModel, RECOMMENDED_OLLAMA_CONTEXT_TOKENS}; +use tinyinference::embeddings::{OllamaEmbeddingModel, RECOMMENDED_OLLAMA_CONTEXT_TOKENS}; /// Cheap heuristic for "is a backend session reachable?" — the cloud /// embedder needs one and bails on first embed call without it. We use @@ -355,7 +355,7 @@ fn build_ollama_embedder(endpoint: &str, model: &str, timeout_ms: u64) -> Result ) .with_client(client); Ok(ProviderEmbedder::new( - crate::embedding_adapter::TinyAgentsEmbeddingProvider::boxed(model), + crate::embedding_adapter::TinyInferenceEmbeddingProvider::boxed(model), "ollama", )) } diff --git a/crates/tinymemory-core/src/tree/score/embed/mod.rs b/crates/tinymemory-core/src/tree/score/embed/mod.rs index 5e5e9a27..56cc6b75 100644 --- a/crates/tinymemory-core/src/tree/score/embed/mod.rs +++ b/crates/tinymemory-core/src/tree/score/embed/mod.rs @@ -87,7 +87,7 @@ pub trait Embedder: Send + Sync { /// Adapts the canonical host embedding-provider contract to the legacy /// memory-tree embedder shape. Concrete network implementations live in -/// `tinyagents::harness::embeddings`; this bridge owns only dimension checks +/// `tinyinference::embeddings`; this bridge owns only dimension checks /// and the memory tree's per-position batch fallback contract. pub struct ProviderEmbedder { inner: Box, diff --git a/crates/tinymemory-core/src/tree/tree_runtime/engine.rs b/crates/tinymemory-core/src/tree/tree_runtime/engine.rs index de3151f9..6d00d3f2 100644 --- a/crates/tinymemory-core/src/tree/tree_runtime/engine.rs +++ b/crates/tinymemory-core/src/tree/tree_runtime/engine.rs @@ -8,8 +8,8 @@ use crate::engine::backend::tree::runtime::{ use anyhow::{Context, Result}; use async_trait::async_trait; use chrono::{DateTime, Timelike, Utc}; -use tinyagents::harness::message::Message; -use tinyagents::harness::model::{ChatModel, ModelRequest}; +use tinyinference::message::Message; +use tinyinference::model::{ChatModel, ModelRequest}; use crate::engine::engine_config; use crate::Config; diff --git a/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs b/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs index a2cb8ed7..54691fe6 100644 --- a/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs +++ b/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs @@ -5,7 +5,7 @@ use crate::tree::tree_runtime::store; use chrono::TimeZone; use std::sync::Mutex; use tempfile::TempDir; -use tinyagents::harness::model::ModelResponse; +use tinyinference::model::ModelResponse; use tinymemory_api::host::test_support::TestHostConfig; struct RecordingModel { @@ -28,11 +28,11 @@ impl ChatModel<()> for RecordingModel { &self, _state: &(), request: ModelRequest, - ) -> tinyagents::Result { + ) -> tinyinference::Result { self.requests.lock().unwrap().push(request); match &self.reply { Ok(reply) => Ok(ModelResponse::assistant(reply.clone())), - Err(message) => Err(tinyagents::TinyAgentsError::Memory(message.clone())), + Err(message) => Err(tinyinference::Error::Model(message.clone())), } } } diff --git a/crates/tinymemory-documents/Cargo.toml b/crates/tinymemory-documents/Cargo.toml index 6ff2ab3e..02f92479 100644 --- a/crates/tinymemory-documents/Cargo.toml +++ b/crates/tinymemory-documents/Cargo.toml @@ -3,7 +3,7 @@ name = "tinymemory-documents" version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" repository = "https://github.com/tinyhumansai/tinymemory" description = "Document and URL intake for TinyMemory: sniff a format, convert it to markdown, put it in whichever engine is bound" publish = false diff --git a/crates/tinymemory-module/Cargo.lock b/crates/tinymemory-module/Cargo.lock index b0d2df52..6a495514 100644 --- a/crates/tinymemory-module/Cargo.lock +++ b/crates/tinymemory-module/Cargo.lock @@ -619,6 +619,12 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + [[package]] name = "hybrid-array" version = "0.4.14" @@ -1741,24 +1747,6 @@ dependencies = [ "syn 3.0.3", ] -[[package]] -name = "tinyagents" -version = "2.1.0" -dependencies = [ - "async-trait", - "bytes", - "chrono", - "futures", - "reqwest", - "rusqlite", - "serde", - "serde_json", - "sha2 0.11.0", - "thiserror 2.0.20", - "tokio", - "tracing", -] - [[package]] name = "tinybus" version = "0.1.1" @@ -1825,8 +1813,8 @@ dependencies = [ "serde_json", "sha2 0.10.9", "thiserror 2.0.20", - "tinyagents", "tinycortex-api", + "tinyinference", "tokio", "toml 1.1.4+spec-1.1.0", "tracing", @@ -1841,6 +1829,22 @@ dependencies = [ "tinymemory-api", ] +[[package]] +name = "tinyinference" +version = "0.2.1" +dependencies = [ + "async-trait", + "bytes", + "futures", + "httpdate", + "reqwest", + "serde", + "serde_json", + "sha2 0.11.0", + "thiserror 2.0.20", + "tokio", +] + [[package]] name = "tinymemory" version = "1.13.3" @@ -1898,9 +1902,9 @@ dependencies = [ "serde_json", "sha2 0.11.0", "thiserror 2.0.20", - "tinyagents", "tinycortex", "tinycortex-api", + "tinyinference", "tinymemory-api", "tinymemory-sources", "tinymemory-sync", @@ -1922,10 +1926,10 @@ dependencies = [ "serde", "serde_json", "tempfile", - "tinyagents", "tinybus", "tinybus-module", "tinycortex", + "tinyinference", "tinymemory", "tinymemory-api", "tinymemory-bus", diff --git a/crates/tinymemory-module/Cargo.toml b/crates/tinymemory-module/Cargo.toml index d35bdffc..dc4323ed 100644 --- a/crates/tinymemory-module/Cargo.toml +++ b/crates/tinymemory-module/Cargo.toml @@ -11,7 +11,7 @@ name = "tinymemory-module" version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" description = "Trusted TinyBus module adapter for TinyMemory." repository = "https://github.com/tinyhumansai/tinymemory" publish = false @@ -52,7 +52,8 @@ tinymemory-tinycortex = { path = "../tinymemory-tinycortex", features = ["memory # it. The four objc2 crates behind the gate sit under a macOS target table # upstream, so a Linux or Windows artifact still compiles none of them. tinycortex = { version = "0.1", features = ["contacts"] } -tinyagents = { version = "2.1" } +# Provider-neutral chat request and response types carried over TinyBus. +tinyinference = "0.2" # TinyBus provides the typed service interface and the dynamic module host ABI. # Reached by path now that this crate is its own workspace root: the nested # checkout's `[workspace.package]` resolves correctly from here. @@ -91,9 +92,8 @@ tempfile = "3" # Its own table, because a patch table only applies from the workspace root being # built and this crate is now its own root — the parent workspace's identical -# entries do not reach here. `tinycortex` and `tinyagents` are named by version -# requirement upstream and neither is published, so without these the resolver -# goes to crates.io and fails. +# entries do not reach here. `tinycortex` and `tinyinference` are unpublished, +# so without these the resolver goes to crates.io and fails. # # The paths reach up out of this crate into the parent checkout's `vendor/`, # which is unusual but correct: these are the same submodules the parent builds @@ -107,10 +107,13 @@ tempfile = "3" [patch."https://github.com/tinyhumansai/tinymemory"] tinymemory-api = { path = "../tinymemory-api" } +[patch."https://github.com/tinyhumansai/tinyinference"] +tinyinference = { path = "../../vendor/tinyinference/crates/tinyinference" } + [patch.crates-io] tinycortex = { path = "../../vendor/tinycortex" } tinycortex-api = { path = "../../vendor/tinycortex/api" } -tinyagents = { path = "../../vendor/tinyagents" } +tinyinference = { path = "../../vendor/tinyinference/crates/tinyinference" } # Mirrors the root package's set. `unsafe_code = "forbid"` holds even though # `module_export!` emits `unsafe extern "C"` symbols: the macro's expansion diff --git a/crates/tinymemory-module/src/chat.rs b/crates/tinymemory-module/src/chat.rs index c4057ce5..eb3509b2 100644 --- a/crates/tinymemory-module/src/chat.rs +++ b/crates/tinymemory-module/src/chat.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use async_trait::async_trait; -use tinyagents::harness::model::{ChatModel, ModelRequest, ModelResponse}; use tinybus::Connection; +use tinyinference::model::{ChatModel, ModelRequest, ModelResponse}; use crate::ModuleConfig; @@ -97,7 +97,7 @@ impl ChatModel<()> for BusChatModel { &self, _state: &(), request: ModelRequest, - ) -> tinyagents::Result { + ) -> tinyinference::Result { let proxy = self .connection .proxy( @@ -105,11 +105,11 @@ impl ChatModel<()> for BusChatModel { CHAT_HOST_OBJECT_PATH, CHAT_HOST_INTERFACE, ) - .map_err(|error| tinyagents::TinyAgentsError::Model(error.to_string()))?; + .map_err(|error| tinyinference::Error::Model(error.to_string()))?; proxy .call("Complete", (self.role.clone(), request)) .await - .map_err(|error| tinyagents::TinyAgentsError::Model(error.to_string())) + .map_err(|error| tinyinference::Error::Model(error.to_string())) } } diff --git a/crates/tinymemory-module/src/chat_test.rs b/crates/tinymemory-module/src/chat_test.rs index a2d971dd..6fd9910d 100644 --- a/crates/tinymemory-module/src/chat_test.rs +++ b/crates/tinymemory-module/src/chat_test.rs @@ -1,11 +1,11 @@ //! Tests for the host-owned chat bridge over an in-memory TinyBus. -use tinyagents::harness::message::{AssistantMessage, ContentBlock, Message}; -use tinyagents::harness::model::{ModelRequest, ModelResponse}; -use tinyagents::harness::usage::Usage; use tinybus::broker::Broker; use tinybus::transport::memory::MemoryBus; use tinybus::{Connection, Result as BusResult}; +use tinyinference::message::{AssistantMessage, ContentBlock, Message}; +use tinyinference::model::{ModelRequest, ModelResponse}; +use tinyinference::usage::Usage; use super::{BusChatHost, CHAT_HOST_BUS_NAME, CHAT_HOST_OBJECT_PATH}; use crate::config::ModuleConfig; diff --git a/crates/tinymemory-module/src/lib.rs b/crates/tinymemory-module/src/lib.rs index 3d7612b6..926d1a15 100644 --- a/crates/tinymemory-module/src/lib.rs +++ b/crates/tinymemory-module/src/lib.rs @@ -13,15 +13,15 @@ //! wrong. This module sheds **no third-party dependencies** from a host. Every //! crate the engine uses (`rusqlite`, `reqwest`, `chrono`, `regex`, `uuid`, //! `walkdir`, `sha2`, `tokio`) is shared with surface a host keeps, and -//! `libsqlite3-sys` in particular has several other parents — `tinyagents`' -//! session store among them — so the native `SQLite` build does not leave. That -//! was measured on `OpenHuman`, on both its kernel and its shipping feature +//! `libsqlite3-sys` in particular has several other parents, so the native +//! `SQLite` build remains in the host dependency graph. This was measured on +//! `OpenHuman`, on both its kernel and its shipping feature //! profiles: four crate names leave, and all four are ours. //! //! What it does buy is **compile time on the critical path**, and that was //! measured too. `tinycortex` and `tinymemory-core` compile strictly serially -//! ahead of the host crate — `tinyagents` → `tinycortex` → `tinymemory-core` → -//! host, each starting as the previous one ends — putting 14.7s directly in +//! ahead of the host crate — `tinycortex` → `tinymemory-core` → host, each +//! starting as the previous one ends — putting 14.7s directly in //! front of the host's own compilation. Removing them from the host's graph //! moved a full build from 176s to about 161s. //! diff --git a/crates/tinymemory-module/tests/module_e2e.rs b/crates/tinymemory-module/tests/module_e2e.rs index 09453885..e4dc6a36 100644 --- a/crates/tinymemory-module/tests/module_e2e.rs +++ b/crates/tinymemory-module/tests/module_e2e.rs @@ -122,13 +122,13 @@ impl HostChat { async fn complete( &self, _role: String, - _request: tinyagents::harness::model::ModelRequest, - ) -> BusResult { - use tinyagents::harness::message::{AssistantMessage, ContentBlock}; - use tinyagents::harness::usage::Usage; + _request: tinyinference::model::ModelRequest, + ) -> BusResult { + use tinyinference::message::{AssistantMessage, ContentBlock}; + use tinyinference::usage::Usage; std::future::ready(()).await; - Ok(tinyagents::harness::model::ModelResponse { + Ok(tinyinference::model::ModelResponse { message: AssistantMessage { id: None, content: vec![ContentBlock::Text("deterministic summary".into())], diff --git a/crates/tinymemory-remote/Cargo.toml b/crates/tinymemory-remote/Cargo.toml index f824c597..ff34d978 100644 --- a/crates/tinymemory-remote/Cargo.toml +++ b/crates/tinymemory-remote/Cargo.toml @@ -4,7 +4,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" description = "HTTP adapters for self-hosted Supermemory, Mem0, and Cognee" repository = "https://github.com/tinyhumansai/tinymemory" diff --git a/crates/tinymemory-sources/Cargo.toml b/crates/tinymemory-sources/Cargo.toml index 1e6c8345..47ee7692 100644 --- a/crates/tinymemory-sources/Cargo.toml +++ b/crates/tinymemory-sources/Cargo.toml @@ -3,7 +3,7 @@ name = "tinymemory-sources" version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" repository = "https://github.com/tinyhumansai/tinymemory" description = "Engine-neutral memory-source contracts: what a source is, and what a reader hands back" publish = false diff --git a/crates/tinymemory-sync/Cargo.toml b/crates/tinymemory-sync/Cargo.toml index 8c9dd189..7d7c4658 100644 --- a/crates/tinymemory-sync/Cargo.toml +++ b/crates/tinymemory-sync/Cargo.toml @@ -4,7 +4,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" repository = "https://github.com/tinyhumansai/tinymemory" description = "Engine-neutral Composio payload normalisers for TinyMemory" diff --git a/crates/tinymemory-testing-ui/Cargo.toml b/crates/tinymemory-testing-ui/Cargo.toml index 7742b8b3..e23bcb43 100644 --- a/crates/tinymemory-testing-ui/Cargo.toml +++ b/crates/tinymemory-testing-ui/Cargo.toml @@ -4,7 +4,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.85" -license = "MIT" +license = "GPL-3.0-only" description = "Local HTTP + web UI harness for exercising TinyMemory engines by hand" [[bin]] diff --git a/crates/tinymemory-tinycortex/Cargo.toml b/crates/tinymemory-tinycortex/Cargo.toml index b4a70da8..f24253ef 100644 --- a/crates/tinymemory-tinycortex/Cargo.toml +++ b/crates/tinymemory-tinycortex/Cargo.toml @@ -7,7 +7,7 @@ publish = false version = "0.1.0" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" description = "TinyCortex engine adapter for the TinyMemory contract" repository = "https://github.com/tinyhumansai/tinymemory" diff --git a/crates/tinymemory/Cargo.toml b/crates/tinymemory/Cargo.toml index 9dafb1fc..58d3cfb9 100644 --- a/crates/tinymemory/Cargo.toml +++ b/crates/tinymemory/Cargo.toml @@ -7,7 +7,7 @@ publish = false version = "1.13.3" edition = "2021" rust-version = "1.96" -license = "MIT" +license = "GPL-3.0-only" description = "Engine-neutral memory contract, driver registry, and engine adapters" repository = "https://github.com/tinyhumansai/tinymemory" documentation = "https://docs.rs/tinymemory" diff --git a/docs/specs/tinybus-module.md b/docs/specs/tinybus-module.md index 4117ccc5..2c8cffda 100644 --- a/docs/specs/tinybus-module.md +++ b/docs/specs/tinybus-module.md @@ -13,20 +13,26 @@ Cutting the whole memory-engine cohort (`tinycortex`, `tinycortex-api`, `tinymemory-core`, `tinymemory-tinycortex`) from OpenHuman, via `scripts/dep-sim.py`: +> Historical measurement: these dependency counts and timings were captured +> before the TinyInference migration. They document why the module boundary was +> introduced, not the current dependency graph. Re-measure before using them as +> present-day performance or dependency claims. + | Profile | Before | After | Delta | | --- | --- | --- | --- | | kernel (`flows`) | 307 pkg / 284 names / 2 native | 297 / 278 / 2 | −6 names, **0 native** | | product (ships) | 431 / 398 / 5 native | 427 / 394 / 5 | −4 names, **0 native** | -All four names leaving the shipping profile are first-party. `libsqlite3-sys` -does not leave, because `rusqlite` has five parents there — the host crate -directly, plus `tinyagents` (its session store), `tinychannels` and `tinyflows`. -Everything else the engine uses (`reqwest`, `chrono`, `regex`, `uuid`, -`walkdir`, `sha2`, `tokio`, `git2`) is shared with surface the host keeps. +At that snapshot, all four names leaving the shipping profile were first-party. +`libsqlite3-sys` did not leave, because `rusqlite` had five parents there — the +host crate directly, plus `tinyagents` (its session store), `tinychannels` and +`tinyflows`. +Everything else the engine used (`reqwest`, `chrono`, `regex`, `uuid`, +`walkdir`, `sha2`, `tokio`, `git2`) was shared with surface the host kept. -**What it does buy is compile time on the critical path.** `cargo build ---timings` on the host shows a strictly serial chain, each link starting as the -previous one ends: +**What it demonstrated was compile time on the critical path.** The historical +`cargo build --timings` snapshot showed a strictly serial chain, each link +starting as the previous one ends: ```text tinyagents 12.8 -> 25.4 (12.6s) @@ -36,9 +42,9 @@ host crate 40.1 -> 174.7 wall 176.0s ``` -The engine therefore puts **14.7s directly in front of** the host's own -compilation. Removing it from the host's graph moves a full build to roughly -161s, about 8.4%. +In that snapshot, the engine put **14.7s directly in front of** the host's own +compilation. Removing it from the host's graph moved a full build to roughly +161s, about 8.4%. The current TinyInference-based graph has not been re-measured. Do not re-justify this module on dependency count. diff --git a/vendor/tinyagents b/vendor/tinyagents deleted file mode 160000 index 27a3f39d..00000000 --- a/vendor/tinyagents +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 27a3f39dc6d7db676efe58d0f7b89752a8ab4746 diff --git a/vendor/tinycortex b/vendor/tinycortex index 84c994b7..cb1c1639 160000 --- a/vendor/tinycortex +++ b/vendor/tinycortex @@ -1 +1 @@ -Subproject commit 84c994b71eeeb1df1dd5669253353e19e2c2b62c +Subproject commit cb1c1639c8a82221e1d8e8a9715b7640bb3f05d8 diff --git a/vendor/tinyinference b/vendor/tinyinference new file mode 160000 index 00000000..cc8aca48 --- /dev/null +++ b/vendor/tinyinference @@ -0,0 +1 @@ +Subproject commit cc8aca484bb995fbab3b7358f0d72ab5056b587c