File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ impl DbSpec for AgentTraceDbSpec {
8383 fn migrations ( ) -> & ' static [ ( & ' static str , & ' static str ) ] {
8484 AGENT_TRACE_MIGRATIONS
8585 }
86+
87+ fn sync_enabled ( ) -> bool {
88+ true
89+ }
8690}
8791
8892/// Agent trace Turso database adapter.
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ pub trait DbSpec {
3434
3535 /// Ordered embedded migration SQL files as `(id, sql)` pairs.
3636 fn migrations ( ) -> & ' static [ ( & ' static str , & ' static str ) ] ;
37+
38+ /// Whether this database may use Turso Cloud sync mode when sync env vars
39+ /// are configured.
40+ fn sync_enabled ( ) -> bool {
41+ false
42+ }
3743}
3844
3945/// Collect common filesystem health problems for a Turso database path.
@@ -186,8 +192,12 @@ impl<M: DbSpec> TursoDb<M> {
186192 format ! ( "failed to create {db_name} tokio runtime. Try: rerun the command; if the issue persists, verify the local Tokio runtime environment." )
187193 } ) ?;
188194
189- let sync_url = std:: env:: var ( crate :: services:: config:: SYNC_URL_ENV_KEY ) . ok ( ) ;
190- let sync_token = std:: env:: var ( crate :: services:: config:: SYNC_TOKEN_ENV_KEY ) . ok ( ) ;
195+ let sync_url = M :: sync_enabled ( )
196+ . then ( || std:: env:: var ( crate :: services:: config:: SYNC_URL_ENV_KEY ) . ok ( ) )
197+ . flatten ( ) ;
198+ let sync_token = M :: sync_enabled ( )
199+ . then ( || std:: env:: var ( crate :: services:: config:: SYNC_TOKEN_ENV_KEY ) . ok ( ) )
200+ . flatten ( ) ;
191201
192202 let path_str = db_path. to_str ( ) . ok_or_else ( || {
193203 anyhow:: anyhow!( "invalid UTF-8 in database path: {}" , db_path. display( ) )
@@ -198,6 +208,7 @@ impl<M: DbSpec> TursoDb<M> {
198208 let sync_db = turso:: sync:: Builder :: new_remote ( path_str)
199209 . with_remote_url ( url)
200210 . with_auth_token ( token)
211+ . bootstrap_if_empty ( false )
201212 . build ( )
202213 . await
203214 . map_err ( |e| {
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ impl RuntimeCommand for SetupCommand {
5454 for provider in & providers {
5555 let outcome = provider
5656 . setup ( & ctx)
57- . map_err ( |error| ClassifiedError :: runtime ( error . to_string ( ) ) ) ?;
57+ . map_err ( |error| ClassifiedError :: runtime ( format ! ( "{error:#}" ) ) ) ?;
5858
5959 if let Some ( ref hooks_outcome) = outcome. required_hooks_install {
6060 sections. push ( setup:: format_required_hook_install_success_message (
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ impl RuntimeCommand for SyncCommand {
1515 }
1616
1717 fn execute ( & self , _context : & AppContext ) -> Result < String , ClassifiedError > {
18- sync:: run_sync ( self . subcommand ) . map_err ( |error| ClassifiedError :: runtime ( error. to_string ( ) ) )
18+ sync:: run_sync ( self . subcommand )
19+ . map_err ( |error| ClassifiedError :: runtime ( format ! ( "{error:#}" ) ) )
1920 }
2021}
2122
Original file line number Diff line number Diff line change 10711071 typescript-language-server
10721072 vscode-json-languageserver
10731073 opencodePackage
1074+ openssl
1075+ pkg-config
10741076 rust-analyzer
10751077 scePackage
10761078 tursoPackage
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ # Manual smoke test for Turso sync support.
5+ # Contains test credentials supplied for local manual testing only.
6+ # Do not commit this file if the token is sensitive or long-lived.
7+
8+ export DATABASE_URL=" "
9+ export DATABASE_AUTH_TOKEN=" "
10+
11+ export SCE_SYNC_URL=" $DATABASE_URL "
12+ export SCE_SYNC_TOKEN=" $DATABASE_AUTH_TOKEN "
13+
14+ STATE_DIR=" $( mktemp -d) "
15+ export XDG_STATE_HOME=" $STATE_DIR "
16+
17+ echo " Using isolated state dir: $XDG_STATE_HOME "
18+
19+ echo " 1. Show sync command help"
20+ nix develop -c sh -c ' cd cli && cargo run -- sync --help'
21+
22+ echo " 2. Run setup, including best-effort initial pull"
23+ nix develop -c sh -c ' cd cli && cargo run -- setup --opencode --non-interactive'
24+
25+ echo " 3. Pull from Turso"
26+ nix develop -c sh -c ' cd cli && cargo run -- sync pull'
27+
28+ echo " 4. Push to Turso"
29+ nix develop -c sh -c ' cd cli && cargo run -- sync push'
30+
31+ echo " 5. Confirm local Agent Trace DB exists"
32+ test -f " $XDG_STATE_HOME /sce/agent-trace.db"
33+ ls -lh " $XDG_STATE_HOME /sce/agent-trace.db"
34+
35+ echo " Manual Turso sync smoke test passed."
You can’t perform that action at this time.
0 commit comments