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
Merge remote-tracking branch 'upstream/main' into tinywallet-release-0192
Steven Enamakeleb55122f371e
diff --cc crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rsindex f49288b594,a15dc65afa..2969f4b6c6--- a/crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rs@@@ -15,3 -15,93 +15,99 @@@ fn registered_controllers_match_schemasfn unknown_agent_has_no_display_name() {assert_eq!(resolve_display_name("__definitely_not_an_agent__"), None);}++ #[test]+ fn an_unknown_function_gets_the_unknown_schema() {+ let s = schema_for("no_such_function");+ assert_eq!(s.namespace, "agent_work");+ assert_eq!(s.function, "unknown");+ }++ #[test]+ fn require_and_optional_strings_ignore_blank_values() {+ let mut params = Map::new();+ params.insert("present".into(), Value::String("x".into()));+ params.insert("blank".into(), Value::String(" ".into()));+ assert_eq!(require_str(¶ms, "present").unwrap(), "x");+ assert_eq!(+ require_str(¶ms, "blank").unwrap_err(),+ "missing required param: blank"+ );+ assert_eq!(+ require_str(¶ms, "absent").unwrap_err(),+ "missing required param: absent"+ );+ assert_eq!(opt_str(¶ms, "present").as_deref(), Some("x"));+ assert_eq!(opt_str(¶ms, "blank"), None);+ assert_eq!(opt_str(¶ms, "absent"), None);+ }++ async fn with_scratch_workspace<F, Fut>(handler: F) -> Result<Value, String>+ where+ F: FnOnce() -> Fut,+ Fut: std::future::Future<Output = Result<Value, String>>,+ {+ let tmp = tempfile::tempdir().expect("tempdir");+ let _env = crate::config::test_env::EnvVarGuard::workspace_async(tmp.path()).await;+ handler().await+ }++ fn params(value: Value) -> Map<String, Value> {+ value.as_object().cloned().unwrap_or_default()+ }++ #[tokio::test]+ async fn listing_work_on_an_empty_ledger_answers() {- let v = with_scratch_workspace(|| handle_agent_work_list(params(serde_json::json!({ "limit": 5 }))))- .await- .expect("an empty ledger lists as an empty view");++ let v = with_scratch_workspace(|| {++ handle_agent_work_list(params(serde_json::json!({ "limit": 5 })))++ })++ .await++ .expect("an empty ledger lists as an empty view");+ assert_eq!(v["total"], 0, "{v}");+ assert!(- v["groups"].as_array().unwrap().iter().all(|g| g["rows"] == serde_json::json!([])),++ v["groups"]++ .as_array()++ .unwrap()++ .iter()++ .all(|g| g["rows"] == serde_json::json!([])),+ "{v}"+ );+ }++ #[tokio::test]+ async fn control_requires_a_run_id_and_action() {+ let err = with_scratch_workspace(|| handle_agent_work_control(Map::new()))+ .await+ .unwrap_err();+ assert_eq!(err, "missing required param: runId");+ let err = with_scratch_workspace(|| {+ handle_agent_work_control(params(serde_json::json!({ "runId": "r1" })))+ })+ .await+ .unwrap_err();+ assert_eq!(err, "missing required param: action");+ }++ #[tokio::test]+ async fn control_refuses_an_unknown_action() {+ let err = with_scratch_workspace(|| {+ handle_agent_work_control(params(+ serde_json::json!({ "runId": "r1", "action": "explode" }),+ ))+ })+ .await+ .unwrap_err();+ assert_eq!(err, "unknown control action: explode");+ }++ #[tokio::test]+ async fn control_of_an_unknown_run_is_an_error_not_a_panic() {+ let err = with_scratch_workspace(|| {+ handle_agent_work_control(params(+ serde_json::json!({ "runId": "no-such-run", "action": "stop", "reason": "test" }),+ ))+ })+ .await+ .unwrap_err();+ assert!(!err.is_empty());+ }diff --cc crates/openhuman-core/src/agent/session_store/workspace_tests.rsindex 0000000000,a3dbc916bc..84e0833f1cmode 000000,100644..100644--- a/crates/openhuman-core/src/agent/session_store/workspace_tests.rs+++ b/crates/openhuman-core/src/agent/session_store/workspace_tests.rs@@@ -1,0 -1,135 +1,141 @@@+ use super::*;+ use tinyagents_session::run_ledger::AgentRunListRequest;++ fn scratch() -> tempfile::TempDir {+ tempfile::tempdir().expect("tempdir")+ }++ #[test]+ fn the_calling_tenants_stores_open_on_the_workspace_default() {+ let ws = scratch();+ let stores = stores_for(ws.path()).expect("the operator has a tenant");+ let state = tinyagents_session::turn_state::TurnState::started(+ "thread-s",+ "req-s",+ 4,+ "2026-10-09T00:00:00Z",+ );+ stores.turn_states.put(&state).unwrap();+ let again = stores_or_ephemeral(ws.path());+ assert!(+ again.turn_states.get("thread-s").unwrap().is_some(),+ "both resolve the same workspace default"+ );+ }++ #[test]+ fn turn_states_for_the_tenant_and_for_the_operator_share_the_default_agent() {+ let ws = scratch();+ let state = tinyagents_session::turn_state::TurnState::started(+ "thread-w",+ "req-w",+ 4,+ "2026-10-09T00:00:00Z",+ );+ turn_states_for(ws.path()).put(&state).unwrap();+ let seen = default_turn_states_for(ws.path())+ .get("thread-w")+ .unwrap()+ .expect("the operator is the default agent");+ assert_eq!(seen.thread_id, "thread-w");+ }++ #[test]+ fn an_attachment_stash_and_artifact_blobs_bind_the_tenant_scope() {+ let ws = scratch();+ assert!(attachment_stash_for(ws.path()).is_some());+ let blobs = artifact_blobs_for(ws.path()).expect("artifact blobs bind");+ let documents = current_documents_for(ws.path());+ assert!(documents.is_some());+ // The blob half is usable: an unknown key reads as absent.+ let found = crate::storage::block_on(async move { Ok(blobs.get("outputs/none").await) });+ assert!(matches!(found, Ok(Ok(None))), "{found:?}");+ }++ #[test]+ fn a_run_status_store_is_built_for_the_workspace() {+ let ws = scratch();+ let _status = status_store_for(ws.path());+ }++ #[test]+ fn the_ledger_serves_reads_from_async_and_sync_callers() {+ let ws = scratch();+ assert!(ledger_for(ws.path()).is_some());+ assert!(require_ledger(ws.path()).is_ok());++ let sync = with_ledger(ws.path(), |ledger| async move {+ ledger+ .list_agent_runs(&AgentRunListRequest::default())+ .await+ })+ .expect("the sync bridge lists an empty ledger");+ let runtime = tokio::runtime::Builder::new_current_thread()+ .enable_all()+ .build()+ .unwrap();+ let asynchronous = runtime+ .block_on(with_ledger_async(ws.path(), |ledger| async move {+ ledger+ .list_agent_runs(&AgentRunListRequest::default())+ .await+ }))+ .expect("the async path lists an empty ledger");+ assert_eq!(+ serde_json::to_value(&sync).unwrap(),+ serde_json::to_value(&asynchronous).unwrap()+ );+ }++ #[test]+ fn an_unusable_workspace_degrades_to_an_in_memory_store() {+ // A path under a regular file cannot hold a storage directory, so the+ // default backend cannot open and the provider degrades rather than fails.+ let ws = scratch();+ let file = ws.path().join("not-a-dir");+ std::fs::write(&file, b"x").unwrap();+ let unusable = file.join("workspace");++ let first = fallback_provider(&unusable);+ let second = fallback_provider(&unusable);+ assert_eq!(first.destination_key(), second.destination_key());+ first+ .try_for_agent("degraded")+ .expect("the in-memory fallback opens an agent");++ assert!(+ artifact_blobs_for(&unusable).is_none()+ || crate::agent::session_store::installed().is_some()+ );+ assert!(+ current_documents_for(&unusable).is_none()+ || crate::agent::session_store::installed().is_some()+ );+ }++ #[test]+ fn releasing_defaults_lets_the_next_call_open_afresh() {+ let ws = scratch();+ let before = fallback_provider(ws.path());+ let cached = fallback_provider(ws.path());- assert!(Arc::ptr_eq(&before, &cached), "a repeat call reuses the provider");++ assert!(++ Arc::ptr_eq(&before, &cached),++ "a repeat call reuses the provider"++ );+ release_workspace_defaults();+ let after = fallback_provider(ws.path());- assert!(!Arc::ptr_eq(&before, &after), "release drops the cached provider");++ assert!(++ !Arc::ptr_eq(&before, &after),++ "release drops the cached provider"++ );+ }++ #[test]+ fn the_workspace_session_stores_are_a_workspace_default_with_nothing_to_recover() {+ let stores = WorkspaceSessionStores;+ assert!(stores.recover().is_ok());+ assert_eq!(+ stores.destination_key().as_deref(),+ Some("workspace-default")+ );+ }diff --cc crates/openhuman-core/src/media/generation/artifact_tool.rsindex 29266a2242,275aeefae1..af81d1ce5f--- a/crates/openhuman-core/src/media/generation/artifact_tool.rs+++ b/crates/openhuman-core/src/media/generation/artifact_tool.rs@@@ -54,9 -55,15 +57,16 @@@ pub struct MediaArtifactTool<T: Tool>workspace_dir: PathBuf,/// Visible folder each generated file is moved into (#5505).files_dir: crate::agent::artifacts::FileRoots,+ blobs: Option<Arc<dyn tinystoragedrivers::BlobStore>>,+ /// Builds the inner tool for one call around that call's poll observer.+ /// Set for the video tool, whose `WaitPolicy::progress` hook is fixed at+ /// construction: a tool per call lets the observer record into the call's+ /// own [`JobStateSlot`]. `inner` still answers the static `Tool` metadata.+ per_call: Option<PerCallInner<T>>,}+ type PerCallInner<T> = std::sync::Arc<dyn Fn(ProgressFn) -> T + Send + Sync>;+impl<T: Tool> MediaArtifactTool<T> {/// `kind` is the artifact category to file every generated output/// under (`ArtifactKind::Image` / `ArtifactKind::Video`); `workspace_dir`@@@ -73,19 -80,21 +83,31 @@@kind,workspace_dir: workspace_dir.into(),files_dir: files_dir.into(),+ blobs: None,+ per_call: None,}}+ /// Reads generated outputs addressed by blob key from the media tool's+ /// backing store. This keeps TinyAgents' blob-backed output contract+ /// separate from the host's visible Files-folder artifact store.+ #[must_use]+ pub fn with_blobs(mut self, blobs: Arc<dyn tinystoragedrivers::BlobStore>) -> Self {+ self.blobs = Some(blobs);+ self+ }++ /// Run each call on a tool built by `build` around that call's poll+ /// observer, so a long job's polled state reaches that call's heartbeat.+ #[must_use]+ pub fn with_per_call_inner(+ mut self,+ build: impl Fn(ProgressFn) -> T + Send + Sync + 'static,+ ) -> Self {+ self.per_call = Some(std::sync::Arc::new(build));+ self+ }+/// Derives a human-readable artifact title from the call's `prompt`/// argument, suffixed with `(i/n)` when the call produced more than one/// file (`n > 1`).diff --cc crates/openhuman-core/src/media/generation/tools.rsindex 914c9d722c,2bb6e8bb0c..7e51eaf0db--- a/crates/openhuman-core/src/media/generation/tools.rs+++ b/crates/openhuman-core/src/media/generation/tools.rs@@@ -76,34 -76,31 +76,36 @@@ pub fn media_tools_fromlet MediaGenerators { image, video } = generators;let output = MediaOutput::new(action_dir).with_reference_policy(reference_policy(action_dir, workspace_dir));+ let output_blobs = Arc::clone(&output.blobs);let tools: Vec<Box<dyn Tool>> = vec![- Box::new(MediaArtifactTool::new(- GenerateImageTool::new(Arc::clone(&image), output.clone())- .with_name(IMAGE_TOOL_NAME)- .with_description(IMAGE_DESCRIPTION)- .with_permission_level(PermissionLevel::Execute)- .with_category(ToolCategory::Workflow),- ArtifactKind::Image,- workspace_dir.to_path_buf(),- files.clone(),- )),+ Box::new(+ MediaArtifactTool::new(+ GenerateImageTool::new(Arc::clone(&image), output.clone())+ .with_name(IMAGE_TOOL_NAME)+ .with_description(IMAGE_DESCRIPTION)+ .with_permission_level(PermissionLevel::Execute)+ .with_category(ToolCategory::Workflow),+ ArtifactKind::Image,+ workspace_dir.to_path_buf(),+ files.clone(),+ )+ .with_blobs(Arc::clone(&output_blobs)),+ ),Box::new(MediaArtifactTool::new(- GenerateVideoTool::new(Arc::clone(&video), output)- .with_name(VIDEO_TOOL_NAME)- .with_description(VIDEO_DESCRIPTION)- .with_permission_level(PermissionLevel::Execute)- .with_category(ToolCategory::Workflow)- .with_wait_policy(video_wait),+ video_tool(&video, &output, video_wait.clone()),ArtifactKind::Video,workspace_dir.to_path_buf(),files,)- .with_blobs(output_blobs),++ .with_blobs(output_blobs)+ .with_per_call_inner({+ let video = Arc::clone(&video);+ let output = output.clone();+ move |observer| {+ video_tool(&video, &output, video_wait.clone().with_progress(observer))+ }+ }),),Box::new(MediaListModelsTool { image, video }),];