The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(tinyagents): add legacy task board migration
Steven Enamakele70076f4ec80
diff --git a/crates/openhuman-core/src/agent/tinyagents/todos.rs b/crates/openhuman-core/src/agent/tinyagents/todos.rsindex 08684fb269..5c0ffd3ee4 100644--- a/crates/openhuman-core/src/agent/tinyagents/todos.rs+++ b/crates/openhuman-core/src/agent/tinyagents/todos.rs@@ -3,6 +3,7 @@use std::path::Path;use std::sync::{Arc, OnceLock};+use tinyagents_graph::todos::{store as todos, TaskBoard};use tinyagents_harness::store::{InMemoryStore, Store};use crate::agent::session_import::ops::open_session_stores;@@ -20,3 +21,79 @@ pub fn scratch_todos_store() -> Arc<dyn Store> {/// Synthetic thread key for the process-global scratch board.pub const SCRATCH_THREAD_ID: &str = "_scratch_";++#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]+pub struct TaskBoardMigrationReport {+ pub total: usize,+ pub copied: usize,+ pub skipped: usize,+}++async fn read_legacy_boards(workspace_dir: &Path) -> Result<Vec<TaskBoard>, String> {+ let dir = workspace_dir.join("agent_task_boards");+ let mut entries = match tokio::fs::read_dir(&dir).await {+ Ok(entries) => entries,+ Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),+ Err(error) => {+ return Err(format!(+ "read legacy task boards dir {}: {error}",+ dir.display()+ ))+ }+ };+ let mut boards = Vec::new();+ while let Some(entry) = entries+ .next_entry()+ .await+ .map_err(|error| format!("iterate legacy task boards dir: {error}"))?+ {+ let path = entry.path();+ let is_board = path.extension().and_then(|value| value.to_str()) == Some("json")+ && !path+ .file_name()+ .and_then(|value| value.to_str())+ .is_some_and(|name| name.ends_with(".runs.json"));+ if !is_board {+ continue;+ }+ match tokio::fs::read_to_string(&path).await {+ Ok(body) => match serde_json::from_str(&body) {+ Ok(board) => boards.push(board),+ Err(error) => {+ tracing::debug!(path = %path.display(), %error, "skip invalid legacy task board")+ }+ },+ Err(error) => {+ tracing::debug!(path = %path.display(), %error, "skip unreadable legacy task board")+ }+ }+ }+ Ok(boards)+}++/// Copy boards from the retired file store without replacing TinyAgents data.+pub async fn migrate_legacy_task_boards(+ workspace_dir: &Path,+) -> Result<TaskBoardMigrationReport, String> {+ let legacy = read_legacy_boards(workspace_dir).await?;+ let store = todos_store(workspace_dir);+ let mut report = TaskBoardMigrationReport {+ total: legacy.len(),+ ..Default::default()+ };+ for board in legacy {+ if todos::import_if_absent(&store, board)+ .await+ .map_err(|error| error.to_string())?+ {+ report.copied += 1;+ } else {+ report.skipped += 1;+ }+ }+ Ok(report)+}++#[cfg(test)]+#[path = "todos_tests.rs"]+mod tests;