use xynthe::prelude::*;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<()> {
println!("=== Xynthe Basic Usage Example ===\n");
println!("1. Initializing Xynthe core components...");
let _identity_fabric = Arc::new(ContextFabric::new());
println!(" ✓ Context Fabric initialized\n");
println!("2. Creating thought streams for cognitive events...");
let observation_stream = ThoughtStream::new("observations");
println!(" Emitting observation event...");
let obs_event = ThoughtEvent::observation(
StructuredContent::text("User requested weather forecast for San Francisco"),
ProvenanceChain::new(),
);
observation_stream.emit(obs_event.clone())?;
println!(" ✓ Observation event emitted\n");
println!("3. Creating hypothesis with confidence...");
let hypothesis = ThoughtEvent::hypothesis(
StructuredContent::text("User is planning outdoor activity"),
ProvenanceChain::new(),
0.7, );
observation_stream.emit(hypothesis)?;
println!(" ✓ Hypothesis event created with 70% confidence\n");
println!("4. Storing events in context fabric...");
let context_fabric = Arc::new(ContextFabric::new());
let context_event = ContextEvent {
content: StructuredContent::text("Initial system state"),
timestamp: Timestamp::now(),
causal_chain: vec![],
confidence: 1.0,
layer: ContextLayer::Working,
};
context_fabric.store(context_event, ContextLayer::Working).await?;
println!(" ✓ Event stored in working memory layer\n");
println!("5. Querying context fabric...");
let time_window = TimeWindow::from_now(chrono::Duration::hours(1));
let query = ContextQuery::recall("system", time_window)
.with_limit(10);
let results = context_fabric.query(query).await?;
println!(" Retrieved {} events(s)", results.events.len());
println!(" Execution time: {} ms\n", results.metadata.execution_time_ms);
println!("6. Setting up capability registry...");
let registry = Arc::new(CapabilityRegistry::new());
let caps = registry.list().await;
println!(" Registered capabilities: {:?}\n", caps);
println!("=== Example completed successfully! ===\n");
println!("Xynthe core components demonstrated:");
println!(" • Thought streams with multiple event types");
println!(" • Confidence-scored hypotheses");
println!(" • Context fabric with temporal querying");
println!(" • Capability registry structure");
Ok(())
}