Skip to content

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

feat(core): add turnCitation to wire schema

Steven Enamakel3f0b1a423718
diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rs
index 1874407dd3..568f0b92d6 100644
--- a/crates/openhuman-core/src/memory/types.rs
+++ b/crates/openhuman-core/src/memory/types.rs
@@ -396,7 +396,7 @@ pub struct ImportStateView {
/// memory-informed answer came from. Same JSON shape the chat surface has
/// always rendered: `key` is the item kind, `namespace` its source kind,
/// `timestamp` when it was observed, `snippet` a short excerpt.
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, schemars::JsonSchema)]
pub struct TurnCitation {
/// Item id.
pub id: String,
diff --git a/crates/openhuman-core/src/threads/wire_schema.rs b/crates/openhuman-core/src/threads/wire_schema.rs
index 95f10b3026..ba116e44be 100644
--- a/crates/openhuman-core/src/threads/wire_schema.rs
+++ b/crates/openhuman-core/src/threads/wire_schema.rs
@@ -37,6 +37,8 @@ pub struct ThreadWireTypes {
pub agent_run_list: tinyagents_session::run_ledger::types::AgentRunListResponse,
pub agent_run_get: RunLedgerGetWireResponse,
pub run_event_list: tinyagents_session::run_ledger::types::RunEventListResponse,
+ pub turn_citation: crate::memory::types::TurnCitation,
+ pub queue_mode: tinychannels_bus::web::QueueMode,
}
/// Serialize the authoritative core/session record schemas for TypeScript codegen.
diff --git a/crates/openhuman-core/src/threads/wire_schema_tests.rs b/crates/openhuman-core/src/threads/wire_schema_tests.rs
index 703c250ca1..5f8e9e93bc 100644
--- a/crates/openhuman-core/src/threads/wire_schema_tests.rs
+++ b/crates/openhuman-core/src/threads/wire_schema_tests.rs
@@ -1,5 +1,44 @@
use super::*;
+fn resolve_schema<'a>(
+ root: &'a serde_json::Value,
+ mut schema: &'a serde_json::Value,
+) -> &'a serde_json::Value {
+ while let Some(reference) = schema.get("$ref").and_then(serde_json::Value::as_str) {
+ let pointer = reference.strip_prefix('#').expect("local schema reference");
+ schema = root.pointer(pointer).expect("schema reference resolves");
+ }
+ schema
+}
+
+fn schema_string_values(root: &serde_json::Value, schema: &serde_json::Value) -> Vec<String> {
+ let schema = resolve_schema(root, schema);
+ let mut values: Vec<String> = if let Some(values) = schema
+ .get("enum")
+ .and_then(serde_json::Value::as_array)
+ {
+ values
+ .iter()
+ .map(|value| value.as_str().expect("string enum value").to_owned())
+ .collect()
+ } else {
+ schema
+ .get("oneOf")
+ .and_then(serde_json::Value::as_array)
+ .expect("string enum or oneOf schema")
+ .iter()
+ .map(|variant| {
+ variant["const"]
+ .as_str()
+ .expect("string oneOf const")
+ .to_owned()
+ })
+ .collect()
+ };
+ values.sort();
+ values
+}
+
#[test]
fn thread_wire_schema_exports_the_core_and_session_records() {
let schema: serde_json::Value =
@@ -23,12 +62,31 @@ fn thread_wire_schema_exports_the_core_and_session_records() {
"agentRun",
"runEvent",
"runTelemetry",
+ "turnCitation",
+ "queueMode",
] {
assert!(
properties.contains_key(property),
"schema is missing {property}"
);
}
+ assert_eq!(
+ schema_string_values(&schema, &properties["queueMode"]),
+ vec![
+ "collect".to_owned(),
+ "followup".to_owned(),
+ "interrupt".to_owned(),
+ "parallel".to_owned(),
+ "steer".to_owned(),
+ ]
+ );
+ let citation_schema = resolve_schema(&schema, &properties["turnCitation"]);
+ for field in ["id", "key", "namespace", "score", "timestamp", "snippet"] {
+ assert!(
+ citation_schema["properties"].get(field).is_some(),
+ "citation schema is missing {field}: {citation_schema}"
+ );
+ }
let ack = &schema["$defs"]["QueuedChatAck"];
for field in [
"queued",