Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Bump app to v2.0.203

Louis Beaumont73a3e3ef1e23
diff --git a/Cargo.lock b/Cargo.lock
index 5aa33c9ae..ee0a4d93c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -650,7 +650,7 @@ dependencies = [
"bitflags 2.9.0",
"cexpr",
"clang-sys",
- "itertools 0.10.5",
+ "itertools 0.12.1",
"lazy_static",
"lazycell",
"log",
@@ -3983,7 +3983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
- "windows-targets 0.48.5",
+ "windows-targets 0.52.6",
]
[[package]]
@@ -4260,6 +4260,12 @@ dependencies = [
"digest",
]
+[[package]]
+name = "md5"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
+
[[package]]
name = "memchr"
version = "2.7.4"
@@ -6806,10 +6812,12 @@ dependencies = [
"fastrand",
"futures",
"hf-hub",
+ "hostname",
"image",
"imageproc",
"killport",
"lru",
+ "md5",
"moka",
"ndarray 0.15.6",
"nix 0.29.0",
diff --git a/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx b/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
index 6bcaa7b87..58ba3679f 100644
--- a/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
+++ b/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
@@ -464,7 +464,7 @@ export function AIProviderConfig({
...formData,
provider: "opencode",
url: "", // URL is dynamic - set at runtime
- model: "claude-haiku-4-5@20251001",
+ model: "screenpipe/claude-haiku-4-5",
});
}}
>
@@ -707,8 +707,8 @@ export function AIProviderConfig({
<SelectValue placeholder="select model" />
</SelectTrigger>
<SelectContent>
- <SelectItem value="claude-haiku-4-5@20251001">Haiku 4.5 (fast)</SelectItem>
- <SelectItem value="claude-opus-4-5@20251101">Opus 4.5 (powerful)</SelectItem>
+ <SelectItem value="screenpipe/claude-haiku-4-5">Haiku 4.5 (fast)</SelectItem>
+ <SelectItem value="screenpipe/claude-opus-4-5">Opus 4.5 (powerful)</SelectItem>
</SelectContent>
</Select>
</div>
diff --git a/screenpipe-app-tauri/components/settings/ai-presets.tsx b/screenpipe-app-tauri/components/settings/ai-presets.tsx
index 717cfd4b0..15fe0f368 100644
--- a/screenpipe-app-tauri/components/settings/ai-presets.tsx
+++ b/screenpipe-app-tauri/components/settings/ai-presets.tsx
@@ -373,7 +373,7 @@ const AISection = ({
break;
case "opencode":
newUrl = ""; // URL is dynamic - set at runtime
- newModel = "claude-haiku-4-5@20251001";
+ newModel = "screenpipe/claude-haiku-4-5";
break;
}
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index 37e6ea5d3..1ee50bc81 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -6733,7 +6733,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "screenpipe-app"
-version = "2.0.197"
+version = "2.0.203"
dependencies = [
"anyhow",
"async-stream",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index e40f298ae..7261d2c10 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.0.202"
+version = "2.0.203"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/opencode.rs b/screenpipe-app-tauri/src-tauri/src/opencode.rs
index 3b3bc12be..451000ccd 100644
--- a/screenpipe-app-tauri/src-tauri/src/opencode.rs
+++ b/screenpipe-app-tauri/src-tauri/src/opencode.rs
@@ -100,11 +100,11 @@ fn find_free_port() -> Result<u16, String> {
}
/// Get the OpenCode config directory
+/// OpenCode uses ~/.config/opencode on all platforms (XDG standard)
fn get_opencode_config_dir() -> Result<PathBuf, String> {
- let config_dir = dirs::config_dir()
- .ok_or_else(|| "Could not find config directory".to_string())?
- .join("opencode");
- Ok(config_dir)
+ let home_dir = dirs::home_dir()
+ .ok_or_else(|| "Could not find home directory".to_string())?;
+ Ok(home_dir.join(".config").join("opencode"))
}
/// Ensure OpenCode is configured to use screenpipe-cloud as the AI provider
@@ -123,26 +123,29 @@ fn ensure_opencode_config(user_token: Option<&str>) -> Result<(), String> {
"$schema": "https://opencode.ai/config.json",
"provider": {
"screenpipe": {
- "api": "anthropic",
- "baseURL": "https://api.screenpi.pe/anthropic",
+ "npm": "@ai-sdk/anthropic",
+ "options": {
+ "baseURL": "https://api.screenpi.pe/anthropic"
+ },
"models": {
- "claude-haiku-4-5@20251001": {
+ "claude-haiku-4-5": {
"name": "Claude Haiku 4.5",
- "attachment": true,
- "reasoning": false
+ "limit": {
+ "context": 200000,
+ "output": 8192
+ }
},
- "claude-opus-4-5@20251101": {
+ "claude-opus-4-5": {
"name": "Claude Opus 4.5",
- "attachment": true,
- "reasoning": true
+ "limit": {
+ "context": 200000,
+ "output": 32768
+ }
}
}
}
},
- "model": {
- "default": "screenpipe/claude-haiku-4-5@20251001",
- "reasoning": "screenpipe/claude-opus-4-5@20251101"
- }
+ "model": "screenpipe/claude-haiku-4-5"
});
// Write the config
diff --git a/screenpipe-app-tauri/src-tauri/src/sync.rs b/screenpipe-app-tauri/src-tauri/src/sync.rs
index d03489c94..22c35b0c8 100644
--- a/screenpipe-app-tauri/src-tauri/src/sync.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sync.rs
@@ -175,7 +175,7 @@ pub async fn set_sync_enabled(state: State<'_, SyncState>, enabled: bool) -> Res
Ok(())
}
-/// Trigger an immediate sync.
+/// Trigger an immediate sync via the screenpipe server.
#[tauri::command]
#[specta::specta]
pub async fn trigger_sync(state: State<'_, SyncState>) -> Result<(), String> {
@@ -197,14 +197,32 @@ pub async fn trigger_sync(state: State<'_, SyncState>) -> Result<(), String> {
// Mark as syncing
*state.is_syncing.write().await = true;
- // TODO: Trigger actual sync via SyncService
- // For now, simulate completion
- let is_syncing = state.is_syncing.clone();
- let last_sync = state.last_sync.clone();
+ // Trigger sync via the screenpipe server endpoint
+ let is_syncing_clone = state.is_syncing.clone();
+ let last_sync_clone = state.last_sync.clone();
+ let last_error_clone = state.last_error.clone();
+
tokio::spawn(async move {
- tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
- *is_syncing.write().await = false;
- *last_sync.write().await = Some(Utc::now().to_rfc3339());
+ let client = reqwest::Client::new();
+ let result = client
+ .post("http://localhost:3030/sync/trigger")
+ .send()
+ .await;
+
+ match result {
+ Ok(response) if response.status().is_success() => {
+ *last_sync_clone.write().await = Some(Utc::now().to_rfc3339());
+ *last_error_clone.write().await = None;
+ }
+ Ok(response) => {
+ let error_text = response.text().await.unwrap_or_else(|_| "unknown error".to_string());
+ *last_error_clone.write().await = Some(error_text);
+ }
+ Err(e) => {
+ *last_error_clone.write().await = Some(format!("failed to trigger sync: {}", e));
+ }
+ }
+ *is_syncing_clone.write().await = false;
});
Ok(())
diff --git a/screenpipe-server/Cargo.toml b/screenpipe-server/Cargo.toml
index f5a5060a4..c1db2f272 100644
--- a/screenpipe-server/Cargo.toml
+++ b/screenpipe-server/Cargo.toml
@@ -95,6 +95,10 @@ base64 = "0.22.1"
uuid = { version = "1.5.0", features = ["v4"] }
+# Cloud sync utilities
+hostname = "0.4"
+md5 = "0.7"
+
tempfile = "3.3.0"
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 73908f194..1dd94e6f5 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -19,17 +19,22 @@ use screenpipe_db::{
use screenpipe_server::{
analytics,
cli::{
- AudioCommand, Cli, CliAudioTranscriptionEngine, CliOcrEngine, Command, McpCommand,
- MigrationSubCommand, OutputFormat, PipeCommand, VisionCommand,
+ get_or_create_machine_id, AudioCommand, Cli, CliAudioTranscriptionEngine, CliOcrEngine,
+ Command, McpCommand, MigrationSubCommand, OutputFormat, PipeCommand, SyncCommand,
+ VisionCommand,
},
handle_index_command,
pipe_manager::PipeInfo,
start_continuous_recording, start_sleep_monitor, start_ui_recording,
+ sync_provider::ScreenpipeSyncProvider,
vision_manager::{
start_monitor_watcher, stop_monitor_watcher, VisionManager, VisionManagerConfig,
},
watch_pid, PipeManager, ResourceMonitor, SCServer,
};
+use screenpipe_core::sync::{
+ BlobType, SyncClientConfig, SyncEvent, SyncManager, SyncService, SyncServiceConfig,
+};
use screenpipe_vision::monitor::list_monitors;
use serde::Deserialize;
use serde_json::{json, Value};
@@ -621,6 +626,10 @@ async fn main() -> anyhow::Result<()> {
handle_mcp_command(subcommand, &local_data_dir_clone).await?;
return Ok(());
}
+ Command::Sync { subcommand } => {
+ handle_sync_command(subcommand).await?;
+ return Ok(());
+ }
}
}
@@ -711,6 +720,22 @@ async fn main() -> anyhow::Result<()> {
})?,
);
+ // Start cloud sync service if enabled
+ let sync_service_handle = if cli.enable_sync {
+ match start_sync_service(&cli, db.clone()).await {
+ Ok(handle) => {
+ info!("cloud sync service started");
+ Some(handle)
+ }
+ Err(e) => {
+ error!("failed to start sync service: {}", e);
+ None
+ }
+ }
+ } else {
+ None
+ };
+
let db_server = db.clone();
let warning_ocr_engine_clone = cli.ocr_engine.clone();
@@ -943,6 +968,13 @@ async fn main() -> anyhow::Result<()> {
cli.use_pii_removal,
);
+ // Attach sync handle if sync is enabled
+ let server = if let Some(ref handle) = sync_service_handle {
+ server.with_sync_handle_arc(handle.clone())
+ } else {
+ server
+ };
+
// print screenpipe in gradient
println!("\n\n{}", DISPLAY.truecolor(147, 112, 219).bold());
println!(
@@ -1020,6 +1052,16 @@ async fn main() -> anyhow::Result<()> {
"│ capture unfocused wins │ {:<34} │",
cli.capture_unfocused_windows
);
+ println!(
+ "│ cloud sync │ {:<34} │",
+ if cli.enable_sync { "enabled" } else { "disabled" }
+ );
+ if cli.enable_sync {
+ println!(
+ "│ sync interval │ {:<34} │",
+ format!("{} seconds", cli.sync_interval_secs)
+ );
+ }
println!(
"│ auto-destruct pid │ {:<34} │",
cli.auto_destruct_pid.unwrap_or(0)
@@ -1331,6 +1373,11 @@ async fn main() -> anyhow::Result<()> {
info!("stopping UI event capture");
handle.stop();
}
+ // Stop sync service if running
+ if let Some(ref handle) = sync_service_handle {
+ info!("stopping sync service");
+ let _ = handle.stop().await;
+ }
let _ = shutdown_tx.send(());
}
}
@@ -1888,3 +1935,174 @@ fn is_command_available(command: &str) -> bool {
.map(|output| output.status.success())
.unwrap_or(false)
}
+
+/// Start the cloud sync service
+async fn start_sync_service(
+ cli: &Cli,
+ db: Arc<DatabaseManager>,
+) -> anyhow::Result<Arc<screenpipe_core::sync::SyncServiceHandle>> {
+ // Validate required credentials
+ let token = cli
+ .sync_token
+ .as_ref()
+ .ok_or_else(|| anyhow::anyhow!("--sync-token or SCREENPIPE_SYNC_TOKEN required for sync"))?;
+
+ let password = cli.sync_password.as_ref().ok_or_else(|| {
+ anyhow::anyhow!("--sync-password or SCREENPIPE_SYNC_PASSWORD required for sync")
+ })?;
+
+ // Get machine ID
+ let machine_id = get_or_create_machine_id(cli.sync_machine_id.clone());
+ info!("sync machine ID: {}", machine_id);
+
+ // Get device info
+ let device_name = hostname::get()
+ .map(|h| h.to_string_lossy().to_string())
+ .unwrap_or_else(|_| "Unknown".to_string());
+ let device_os = std::env::consts::OS.to_string();
+
+ // Create sync manager
+ let config = SyncClientConfig::new(token.clone(), machine_id.clone(), device_name, device_os);
+ let manager = SyncManager::new(config)?;
+
+ // Initialize with password
+ let is_new_user = manager.initialize(password).await?;
+ info!(
+ "sync initialized for {} user",
+ if is_new_user { "new" } else { "existing" }
+ );
+
+ let manager = Arc::new(manager);
+
+ // Create sync data provider
+ let provider = Arc::new(ScreenpipeSyncProvider::new(db, machine_id));
+
+ // Create sync service config
+ let service_config = SyncServiceConfig {
+ enabled: true,
+ sync_interval_secs: cli.sync_interval_secs,
+ sync_types: vec![BlobType::Ocr, BlobType::Transcripts],
+ max_blobs_per_cycle: 10,
+ sync_on_startup: true,
+ };
+
+ // Create and start service
+ let service = SyncService::new(manager, service_config, provider);
+ let (handle, mut event_rx) = service.start();
+
+ // Spawn event handler
+ tokio::spawn(async move {
+ while let Some(event) = event_rx.recv().await {
+ match event {
+ SyncEvent::Started => {
+ info!("sync cycle started");
+ }
+ SyncEvent::Completed(report) => {
+ info!(
+ "sync cycle completed: {} blobs uploaded ({} bytes) in {:.2}s",
+ report.blobs_uploaded, report.bytes_uploaded, report.duration_secs
+ );
+ }
+ SyncEvent::Failed(err) => {
+ error!("sync cycle failed: {}", err);
+ }
+ SyncEvent::Progress {
+ uploaded,
+ total,
+ bytes_transferred,
+ } => {
+ debug!(
+ "sync progress: {}/{} blobs, {} bytes",
+ uploaded, total, bytes_transferred
+ );
+ }
+ SyncEvent::Stopped => {
+ info!("sync service stopped");
+ break;
+ }
+ }
+ }
+ });
+
+ Ok(Arc::new(handle))
+}
+
+/// Handle sync subcommands
+async fn handle_sync_command(command: &SyncCommand) -> anyhow::Result<()> {
+ let client = reqwest::Client::new();
+ let server_url = "http://localhost";
+
+ match command {
+ SyncCommand::Status { output, port } => {
+ let url = format!("{}:{}/sync/status", server_url, port);
+ match client.get(&url).send().await {
+ Ok(response) if response.status().is_success() => {
+ let data: serde_json::Value = response.json().await?;
+ match output {
+ OutputFormat::Json => println!("{}", serde_json::to_string_pretty(&data)?),
+ OutputFormat::Text => {
+ println!("sync status:");
+ if let Some(enabled) = data.get("enabled") {
+ println!(" enabled: {}", enabled);
+ }
+ if let Some(is_syncing) = data.get("is_syncing") {
+ println!(" syncing: {}", is_syncing);
+ }
+ if let Some(last_sync) = data.get("last_sync") {
+ println!(" last sync: {}", last_sync);
+ }
+ if let Some(storage_used) = data.get("storage_used") {
+ println!(" storage used: {} bytes", storage_used);
+ }
+ }
+ }
+ }
+ _ => {
+ println!("note: server not running or sync not enabled");
+ }
+ }
+ }
+ SyncCommand::Now { port } => {
+ let url = format!("{}:{}/sync/trigger", server_url, port);
+ match client.post(&url).send().await {
+ Ok(response) if response.status().is_success() => {
+ println!("sync triggered successfully");
+ }
+ Ok(response) => {
+ let error: serde_json::Value = response.json().await.unwrap_or_default();
+ println!(
+ "failed to trigger sync: {}",
+ error.get("error").unwrap_or(&serde_json::json!("unknown error"))
+ );
+ }
+ Err(e) => {
+ println!("failed to connect to server: {}", e);
+ }
+ }
+ }
+ SyncCommand::Download { hours, port } => {
+ let url = format!("{}:{}/sync/download?hours={}", server_url, port, hours);
+ match client.post(&url).send().await {
+ Ok(response) if response.status().is_success() => {
+ let data: serde_json::Value = response.json().await?;
+ println!(
+ "download complete: {} records imported",
+ data.get("imported").unwrap_or(&serde_json::json!(0))
+ );
+ }
+ Ok(response) => {
+ let error: serde_json::Value = response.json().await.unwrap_or_default();
+ println!(
+ "failed to download: {}",
+ error.get("error").unwrap_or(&serde_json::json!("unknown error"))
+ );
+ }
+ Err(e) => {
+ println!("failed to connect to server: {}", e);
+ }
+ }
+ }
+ }
+
+ Ok(())
+}
diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rs
index 6e1347ef1..7046979a6 100644
--- a/screenpipe-server/src/cli.rs
+++ b/screenpipe-server/src/cli.rs
@@ -315,6 +315,35 @@ pub struct Cli {
#[arg(long, default_value_t = false)]
pub enable_ui_events: bool,
+ // =========================================================================
+ // Cloud Sync Options
+ // =========================================================================
+
+ /// Enable cloud sync for cross-device data synchronization.
+ /// Requires a valid sync token and password.
+ #[arg(long, default_value_t = false)]
+ pub enable_sync: bool,
+
+ /// API token for cloud sync authentication.
+ /// Can also be set via SCREENPIPE_SYNC_TOKEN environment variable.
+ #[arg(long, env = "SCREENPIPE_SYNC_TOKEN")]
+ pub sync_token: Option<String>,
+
+ /// Password for encrypting synced data.
+ /// This password is used to derive encryption keys - it never leaves your device.
+ /// Can also be set via SCREENPIPE_SYNC_PASSWORD environment variable.
+ #[arg(long, env = "SCREENPIPE_SYNC_PASSWORD")]
+ pub sync_password: Option<String>,
+
+ /// Interval between sync cycles in seconds (default: 300 = 5 minutes)
+ #[arg(long, default_value_t = 300)]
+ pub sync_interval_secs: u64,
+
+ /// Override the machine ID for this device.
+ /// By default, a unique ID is derived from the hostname.
+ #[arg(long)]
+ pub sync_machine_id: Option<String>,
+
#[command(subcommand)]
pub command: Option<Command>,
}
@@ -370,6 +399,11 @@ pub enum Command {
#[command(subcommand)]
subcommand: PipeCommand,
},
+ /// Cloud sync management commands
+ Sync {
+ #[command(subcommand)]
+ subcommand: SyncCommand,
+ },
/// MCP Server management commands
Mcp {
#[command(subcommand)]
@@ -588,3 +622,46 @@ pub enum OutputFormat {
Text,
Json,
}
+
+#[derive(Subcommand)]
+pub enum SyncCommand {
+ /// Show sync status
+ Status {
+ /// Output format
+ #[arg(short, long, value_enum, default_value_t = OutputFormat::Text)]
+ output: OutputFormat,
+ /// Server port
+ #[arg(short = 'p', long, default_value_t = 3030)]
+ port: u16,
+ },
+ /// Trigger an immediate sync
+ Now {
+ /// Server port
+ #[arg(short = 'p', long, default_value_t = 3030)]
+ port: u16,
+ },
+ /// Download data from other devices
+ Download {
+ /// Time range in hours to download (default: 24)
+ #[arg(long, default_value_t = 24)]
+ hours: u32,
+ /// Server port
+ #[arg(short = 'p', long, default_value_t = 3030)]
+ port: u16,
+ },
+}
+
+/// Get or create a persistent machine ID for sync
+pub fn get_or_create_machine_id(override_id: Option<String>) -> String {
+ if let Some(id) = override_id {
+ return id;
+ }
+
+ // Use hostname hash as machine ID
+ if let Ok(hostname) = hostname::get() {
+ let hostname_str = hostname.to_string_lossy();
+ format!("{:x}", md5::compute(hostname_str.as_bytes()))
+ } else {
+ uuid::Uuid::new_v4().to_string()
+ }
+}
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 16ea89f12..0899f6fc8 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -48,6 +48,7 @@ use screenpipe_audio::{
},
};
use screenpipe_core::pii_removal::detect_pii_regions;
+use screenpipe_core::sync::SyncServiceHandle;
use tracing::{debug, error, info};
use screenpipe_vision::monitor::{get_monitor_by_id, list_monitors};
@@ -114,6 +115,8 @@ pub struct AppState {
pub use_pii_removal: bool,
/// Cloud search client for hybrid local + cloud queries
pub cloud_search: Arc<crate::cloud_search::CloudSearchClient>,
+ /// Cloud sync service handle (if enabled)
+ pub sync_handle: Option<Arc<SyncServiceHandle>>,
}
// Update the SearchQuery struct
@@ -1269,6 +1272,7 @@ pub struct SCServer {
audio_disabled: bool,
enable_pipe: bool,
use_pii_removal: bool,
+ sync_handle: Option<Arc<SyncServiceHandle>>,
}
impl SCServer {
@@ -1294,9 +1298,22 @@ impl SCServer {
audio_manager,
enable_pipe,
use_pii_removal,
+ sync_handle: None,
}
}
+ /// Set the sync service handle
+ pub fn with_sync_handle(mut self, handle: SyncServiceHandle) -> Self {
+ self.sync_handle = Some(Arc::new(handle));
+ self
+ }
+
+ /// Set the sync service handle from an Arc
+ pub fn with_sync_handle_arc(mut self, handle: Arc<SyncServiceHandle>) -> Self {
+ self.sync_handle = Some(handle);
+ self
+ }
+
pub async fn start(self, enable_frame_cache: bool) -> Result<(), std::io::Error> {
// Create the OpenAPI server
let app = self.create_router(enable_frame_cache).await;
@@ -1351,6 +1368,8 @@ impl SCServer {
use_pii_removal: self.use_pii_removal,
// Cloud search client (disabled by default, can be enabled via API)
cloud_search: Arc::new(crate::cloud_search::CloudSearchClient::new()),
+ // Cloud sync service handle
+ sync_handle: self.sync_handle.clone(),
});
let cors = CorsLayer::new()
@@ -1411,6 +1430,9 @@ impl SCServer {
// UI Events API routes
.route("/ui-events", get(ui_events_search_handler))
.route("/ui-events/stats", get(ui_events_stats_handler))
+ // Cloud Sync API routes
+ .route("/sync/status", get(sync_status_handler))
+ .route("/sync/trigger", axum::routing::post(sync_trigger_handler))
// NOTE: websockerts and sse is not supported by openapi so we move it down here
.route("/stream/frames", get(stream_frames_handler))
.route("/ws/events", get(ws_events_handler))
@@ -3982,6 +4004,50 @@ struct MergeSpeakersRequest {
#[derive(Debug, OaSchema, Deserialize)]
pub struct PurgePipeRequest {}
+
+// ============================================================================
+// Cloud Sync Handlers
+// ============================================================================
+
+#[derive(Serialize)]
+struct SyncStatusResponse {
+ enabled: bool,
+ is_syncing: bool,
+ last_sync: Option<String>,
+ last_error: Option<String>,
+}
+
+async fn sync_status_handler(
+ State(state): State<Arc<AppState>>,
+) -> Result<Json<SyncStatusResponse>, (StatusCode, Json<Value>)> {
+ let enabled = state.sync_handle.is_some();
+
+ Ok(Json(SyncStatusResponse {
+ enabled,
+ is_syncing: false, // TODO: Track this in AppState
+ last_sync: None, // TODO: Track this in AppState
+ last_error: None,
+ }))
+}
+
+async fn sync_trigger_handler(
+ State(state): State<Arc<AppState>>,
+) -> Result<Json<Value>, (StatusCode, Json<Value>)> {
+ match &state.sync_handle {
+ Some(handle) => match handle.sync_now().await {
+ Ok(_) => Ok(Json(json!({"success": true, "message": "sync triggered"}))),
+ Err(e) => Err((
+ StatusCode::INTERNAL_SERVER_ERROR,
+ Json(json!({"error": format!("failed to trigger sync: {}", e)})),
+ )),
+ },
+ None => Err((
+ StatusCode::BAD_REQUEST,
+ Json(json!({"error": "sync not enabled"})),
+ )),
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;