Skip to content

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

chore: files changed crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/C

Steven Enamakel49a0f66bc321
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml
index 3f7c277d95..b0dfc62fcd 100644
--- a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml
+++ b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml
@@ -7,6 +7,8 @@ publish = false
[workspace]
[dependencies]
+openhuman = { path = "../../../../../../../../crates/openhuman-core", default-features = false, features = ["storage-sqlite"] }
tinystoragedrivers = { git = "https://github.com/tinyhumansai/tinystoragedrivers.git", rev = "0c6dcfce57201fadd830431f36fd759c3baa897a", features = ["sqlite"] }
+chrono = { version = "0.4", features = ["serde"] }
serde_json = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs
index 0b171b4c10..b30d43f7c4 100644
--- a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs
+++ b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs
@@ -1,7 +1,14 @@
use std::path::PathBuf;
-use serde_json::json;
-use tinystoragedrivers::{Checkpoint, CollectionSpec, Precondition, Scope, StorageConfig};
+use chrono::{DateTime, Utc};
+use openhuman::artifacts::types::{ArtifactKind, ArtifactMeta, ArtifactStatus};
+use openhuman::platform::cost::types::{CostRecord, CostSource, TokenUsage, UsageScope};
+use openhuman::profiles::{ProfileId, types::ProfileMeta};
+use serde_json::{Value, json};
+use tinystoragedrivers::{CollectionSpec, Precondition, Scope, StorageConfig, WriteOptions};
+
+const PROFILE_ID: &str = "u1";
+const CREATED_AT_MS: i64 = 1_738_548_306_000;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -15,69 +22,107 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = format!("sqlite:{}", path.display());
let backend = tinystoragedrivers::open(&StorageConfig::parse(&url)?).await?;
- // These are the collection names and v1 document bodies written by the
- // pre-port profile owners. The old TSD public writer supplies the actual
- // scoped SQLite storage layout and metadata.
- let profile = backend.for_scope(&Scope::new("profile:u1")?)?;
- let docs = profile.documents();
- for (collection, id, body) in [
- (
- "config",
- "runtime",
- json!({"workspace": "/legacy/workspace", "theme": "dark", "schema_version": 1}),
- ),
- (
- "cost_records",
- "cost-0001",
- json!({"usage": {"timestamp": "2025-02-03T04:05:06.789+02:00", "input_tokens": 12, "output_tokens": 3}, "model": "fixture-model", "ts_ms": 1738548306789_i64}),
- ),
- (
- "artifacts",
- "artifact-1",
- json!({"id": "artifact-1", "title": "Fixture plan", "created_at": "2025-02-03T04:05:06Z", "thread_id": "thread-1"}),
- ),
- ] {
- docs.ensure_collection(&CollectionSpec::new(collection))
- .await?;
- docs.put(collection, id, body, Precondition::Absent).await?;
- }
+ // These transformations are the pre-schema-v2 owner writers from
+ // OpenHuman commit 2d3e22636e^: cost records retained their typed body and
+ // timestamp, artifact documents stored created_ms, args were wrapped,
+ // and the profile registry kept created_at in document metadata. The
+ // actual disk layout and writes are supplied by the historical public
+ // TSD v1 API pinned in this package.
+ let profile_scope = backend.for_scope(&Scope::new("profile:u1")?)?;
+ let docs = profile_scope.documents();
- let cluster = backend.for_scope(&Scope::new("cluster")?)?;
- let docs = cluster.documents();
- docs.ensure_collection(&CollectionSpec::new("profiles"))
- .await?;
- docs.put(
- "profiles",
- "u1",
- json!({"profile_id": "u1", "created_at": 1738548306_i64, "layout_version": 1}),
- Precondition::Absent,
- )
- .await?;
- docs.ensure_collection(&CollectionSpec::new("leases"))
- .await?;
- docs.put(
- "leases",
- "profile:u1",
- json!({"owner": "desktop-legacy", "epoch": 7, "expires_at_ms": 1738548366789_i64, "endpoint": "local"}),
- Precondition::Absent,
+ let cost = CostRecord {
+ id: "cost-0001".into(),
+ session_id: "session-fixture".into(),
+ usage: TokenUsage {
+ model: "fixture-model".into(),
+ input_tokens: 12,
+ output_tokens: 3,
+ total_tokens: 15,
+ cached_input_tokens: 0,
+ cache_creation_tokens: 0,
+ reasoning_tokens: 0,
+ cost_usd: 0.000_015,
+ cost_source: CostSource::Estimated,
+ run_id: None,
+ root_run_id: None,
+ scope: UsageScope::default(),
+ timestamp: DateTime::parse_from_rfc3339("2025-02-03T04:05:06.789+02:00")?
+ .with_timezone(&Utc),
+ },
+ };
+ let mut cost_body = serde_json::to_value(cost)?;
+ cost_body["ts_ms"] = 1_738_548_306_789_i64.into();
+ put(docs, "cost_records", "cost-0001", cost_body).await?;
+
+ let artifact = ArtifactMeta {
+ id: "artifact-1".into(),
+ kind: ArtifactKind::Document,
+ title: "Fixture plan".into(),
+ path: "artifact-1/plan.md".into(),
+ file: None,
+ file_root: None,
+ size_bytes: 4,
+ status: ArtifactStatus::Ready,
+ created_at: DateTime::parse_from_rfc3339("2025-02-03T04:05:06Z")?.with_timezone(&Utc),
+ error: None,
+ thread_id: Some("thread-1".into()),
+ tool_call_id: None,
+ };
+ let mut artifact_body = serde_json::to_value(artifact)?;
+ let created_at = artifact_body
+ .as_object_mut()
+ .and_then(|fields| fields.remove("created_at"))
+ .ok_or("ArtifactMeta serialization omitted created_at")?;
+ artifact_body["created_ms"] = created_at
+ .as_str()
+ .and_then(|text| DateTime::parse_from_rfc3339(text).ok())
+ .map(|at| at.timestamp_millis())
+ .ok_or("ArtifactMeta created_at was not RFC3339")?
+ .into();
+ put(docs, "artifacts", "artifact-1", artifact_body).await?;
+ put(
+ docs,
+ "artifact_args",
+ "artifact-1",
+ json!({"args": {"title": "Fixture plan", "format": "markdown"}}),
)
.await?;
- // One old module-scope source row demonstrates that the inventory reader
- // preserves identities needed by the host's explicit known-module map.
- let module = backend.for_scope(&Scope::new("module:tinybox@local")?)?;
- let docs = module.documents();
- docs.ensure_collection(&CollectionSpec::new("tinybox_jail_index"))
- .await?;
- docs.put(
- "tinybox_jail_index",
- "jail-1",
- json!({"id": "jail-1", "created_at": "2025-02-03T04:05:06Z", "image": "fixture"}),
+ let cluster = backend.for_scope(&Scope::new("cluster")?)?;
+ let profile = ProfileMeta {
+ profile_id: ProfileId::parse(PROFILE_ID)?,
+ created_at: u64::try_from(CREATED_AT_MS / 1000)?,
+ layout_version: 1,
+ };
+ let mut profile_body = serde_json::to_value(profile)?;
+ profile_body
+ .as_object_mut()
+ .ok_or("ProfileMeta did not serialize as an object")?
+ .remove("created_at");
+ let docs = cluster.documents();
+ docs.ensure_collection(&CollectionSpec::new("profiles")).await?;
+ docs.put_with(
+ "profiles",
+ PROFILE_ID,
+ profile_body,
Precondition::Absent,
+ WriteOptions::new().created_ms(CREATED_AT_MS),
)
.await?;
- backend.checkpoint(Checkpoint::Truncate).await?;
+ backend.checkpoint(tinystoragedrivers::Checkpoint::Truncate).await?;
println!("written {}", path.display());
Ok(())
}
+
+async fn put(
+ docs: &dyn tinystoragedrivers::DocumentStore,
+ collection: &str,
+ id: &str,
+ body: Value,
+) -> Result<(), tinystoragedrivers::StorageError> {
+ docs.ensure_collection(&CollectionSpec::new(collection)).await?;
+ docs.put(collection, id, body, Precondition::Absent).await?;
+ Ok(())
+}
diff --git a/vendor/tinyjuice b/vendor/tinyjuice
index 0a0cb2a460..b304cca565 160000
--- a/vendor/tinyjuice
+++ b/vendor/tinyjuice
@@ -1 +1 @@
-Subproject commit 0a0cb2a4602c4c976a642f7350b13f3c7e99287b
+Subproject commit b304cca565bff8ec9e5cd76d5c3fae7d276c1549
diff --git a/vendor/tinystoragedrivers b/vendor/tinystoragedrivers
index e39dc51b56..e1d075bdd1 160000
--- a/vendor/tinystoragedrivers
+++ b/vendor/tinystoragedrivers
@@ -1 +1 @@
-Subproject commit e39dc51b56464b01c57f25b28548f9215038192e
+Subproject commit e1d075bdd1b096d4572dcec71902dfc405674694