1use ai_cortex_sdk::{CortexClient, CortexConfig};
2
3#[tokio::main]
7async fn main() {
8 let server_url = "http://localhost:40404";
9 let pat = std::env::args()
10 .nth(1)
11 .unwrap_or_else(|| "REPLACE_WITH_YOUR_PAT".to_string());
12
13 let software_id = "00000000-0000-0000-0000-000000000000".to_string();
15
16 let config = CortexConfig::new(server_url, pat, software_id).with_timeout(30);
17 let client = CortexClient::new(config);
18
19 println!("=== Software Store ===");
21 match client.list_software().await {
22 Ok(items) => {
23 if items.is_empty() {
24 println!("No software available.");
25 }
26 for (i, item) in items.iter().enumerate() {
27 let version_str = item
28 .latest_version
29 .as_ref()
30 .map(|v| format!("v{} ({} bytes)", v.version, v.file_size))
31 .unwrap_or_else(|| "no version".to_string());
32 println!(
33 "{}. {} — {} [{}]",
34 i + 1,
35 item.software.name,
36 item.software.description,
37 version_str
38 );
39 }
40
41 if let Some(item) = items.first() {
43 if let Some(version) = &item.latest_version {
44 println!("\n=== Download ===");
45 match client.download(&version.id).await {
46 Ok(info) => {
47 println!(
48 "Download: v{}, size={} bytes\n URL: {}",
49 info.version, info.file_size, info.download_url
50 );
51 }
52 Err(e) => eprintln!("Download failed: {e}"),
53 }
54 }
55 }
56 }
57 Err(e) => eprintln!("List software failed: {e}"),
58 }
59
60 println!("\n=== My Devices ===");
62 match client.list_devices().await {
63 Ok(devices) => {
64 if devices.is_empty() {
65 println!("No bound devices yet (heartbeat may not have fired yet).");
66 }
67 for d in devices {
68 println!(
69 "- id={}, fingerprint={}, last_active={}",
70 d.id, d.fingerprint, d.last_active_time
71 );
72 }
73 }
74 Err(e) => eprintln!("List devices failed: {e}"),
75 }
76}