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
refactor(tokenjuice): move repl tools into mod and drop duplicate file
Steven Enamakelde43e20a604e
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rsindex b329d703a7..60a5e4210b 100644--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs@@ -11,8 +11,8 @@ use std::path::{Path, PathBuf};use std::sync::Arc;use tinyjuice_bus::names::methods;use tinyjuice_bus::repl::ReplLimits;-use tinyjuice_bus::wire::{QueryRequest, QueryResponse};use tinyjuice_bus::types::{AgentTokenjuiceCompression, CompressorKind};+use tinyjuice_bus::wire::{QueryRequest, QueryResponse};use tinytools::{Tool, ToolRunContext, ToolSpec};/// The host-specific query seam for TinyJuice's shared REPL tools.@@ -69,6 +69,11 @@ fn host_repl_tools()}+#[cfg(test)]+fn repl_tools_with(source: Arc<dyn QuerySource>, limits: ReplLimits) -> Vec<Box<dyn Tool>> {+ host_repl_tools(source, limits, None)+}+/// Whether a name is one of TinyJuice's query tools.pub fn is_repl_tool(name: &str) -> bool {tinyjuice_bus::tools::REPL_TOOLS.contains(&name)@@ -129,8 +134,8 @@ pub(crate) fn repl_tools_for_recorded(/// Preserve the nested path used by the integration prelude while the actual/// implementation and only host-specific adapter residue live here.pub mod repl_tools {- pub use super::{is_repl_tool, repl_tools, repl_tools_for};pub(crate) use super::repl_tools_for_recorded;+ pub use super::{is_repl_tool, repl_tools, repl_tools_for};}use tinyjuice_bus::wire::InstallRequest;@@ -527,6 +532,10 @@ pub fn all_tokenjuice_registered_controllers() -> Vec<crate::core::all::Register#[path = "mod_tests.rs"]mod tests;+#[cfg(test)]+#[path = "repl_tools_tests.rs"]+mod repl_tool_tests;+#[cfg(test)]#[path = "module_stub_tests.rs"]pub(crate) mod module_stub;diff --git a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rsdeleted file mode 100644index 282f5e5438..0000000000--- a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs+++ /dev/null@@ -1,153 +0,0 @@-//! OpenHuman's context-bound source adapter for TinyJuice's shared REPL tools.--use crate::core::runtime::DispatchCtx;-use async_trait::async_trait;-use std::path::{Path, PathBuf};-use std::sync::Arc;-use tinyjuice_bus::repl::ReplLimits;-use tinyjuice_bus::wire::{QueryRequest, QueryResponse};-use tinytools::{Tool, ToolRunContext, ToolSpec};--/// Whether a name is one of TinyJuice's query tools.-pub fn is_repl_tool(name: &str) -> bool {- tinyjuice_bus::tools::REPL_TOOLS.contains(&name)-}--/// The host-specific query seam. TinyJuice owns the tool implementation;-/// OpenHuman resolves the active turn's DispatchCtx and module configuration.-#[async_trait]-pub(crate) trait QuerySource: Send + Sync {- async fn query(- &self,- ctx: &DispatchCtx,- request: QueryRequest,- ) -> Result<QueryResponse, String>;-}--struct ModuleSource {- config: Option<Arc<crate::config::Config>>,-}--#[async_trait]-impl QuerySource for ModuleSource {- async fn query(- &self,- ctx: &DispatchCtx,- request: QueryRequest,- ) -> Result<QueryResponse, String> {- match &self.config {- Some(config) => super::query_for_config(config, request).await,- None => super::query(ctx, request).await,- }- }-}--struct QueryBridge(Arc<dyn QuerySource>);--#[async_trait]-impl tinyjuice_host::repl_tools::QuerySource for QueryBridge {- async fn query(- &self,- context: Option<&dyn ToolRunContext>,- request: QueryRequest,- ) -> Result<QueryResponse, String> {- let ctx = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(context);- self.0.query(&ctx, request).await- }-}--const MAX_ARTIFACT_BYTES: u64 = tinytools_std::filesystem::FileReadTool::MAX_FILE_SIZE_BYTES;--fn host_tools(- source: Arc<dyn QuerySource>,- limits: ReplLimits,- artifacts_dir: Option<PathBuf>,-) -> Vec<Box<dyn Tool>> {- tinyjuice_host::repl_tools::repl_tools(- Arc::new(QueryBridge(source)),- limits,- artifacts_dir,- MAX_ARTIFACT_BYTES,- None,- )-}--#[cfg(test)]-pub(crate) fn repl_tools_with(- source: Arc<dyn QuerySource>,- limits: ReplLimits,-) -> Vec<Box<dyn Tool>> {- host_tools(source, limits, None)-}--#[cfg(test)]-pub(crate) fn repl_tools_with_artifacts(- source: Arc<dyn QuerySource>,- limits: ReplLimits,- artifacts_dir: Option<PathBuf>,-) -> Vec<Box<dyn Tool>> {- host_tools(source, limits, artifacts_dir)-}--/// The current TinyJuice REPL declarations for ordinary turns.-pub fn repl_tools() -> Vec<Box<dyn Tool>> {- host_tools(- Arc::new(ModuleSource { config: None }),- ReplLimits::default(),- None,- )-}--/// Offer the REPL only while enabled handle storage can produce queryable handles.-pub fn repl_tools_for(config: &crate::config::Config) -> Vec<Box<dyn Tool>> {- if !super::repl_handle_active(config) {- return Vec::new();- }- host_tools(- Arc::new(ModuleSource {- config: Some(Arc::new(config.clone())),- }),- ReplLimits::default(),- Some(crate::security::policy::tool_result_artifacts_dir(- &config.workspace_dir,- )),- )-}--/// Rebuild the recorded query declarations exactly while keeping current host policy.-pub(crate) fn repl_tools_for_recorded(- config: Option<&crate::config::Config>,- workspace_dir: &Path,- recorded: &[ToolSpec],-) -> Vec<Box<dyn Tool>> {- let current = tinyjuice_bus::tools::repl_tool_declarations();- let declarations = recorded- .iter()- .filter(|spec| is_repl_tool(&spec.name))- .filter_map(|spec| {- let declaration = current.iter().find(|item| item.name == spec.name)?;- Some(tinyjuice_bus::tools::ReplToolDeclaration {- name: spec.name.clone(),- op: declaration.op.clone(),- description: spec.description.clone(),- parameters: spec.parameters.clone(),- })- })- .collect();- tinyjuice_host::repl_tools::repl_tools_with_declarations(- declarations,- Arc::new(QueryBridge(Arc::new(ModuleSource {- config: config.cloned().map(Arc::new),- }))),- ReplLimits::default(),- Some(crate::security::policy::tool_result_artifacts_dir(- workspace_dir,- )),- MAX_ARTIFACT_BYTES,- None,- )-}--#[cfg(test)]-#[path = "repl_tools_tests.rs"]-mod tests;