test_opencode_go/
test_opencode_go.rs1use seher::{BrowserDetector, CookieReader};
7
8#[tokio::main(flavor = "current_thread")]
9async fn main() {
10 let detector = BrowserDetector::new();
11 let browsers = detector.detect_browsers();
12
13 for browser in &browsers {
14 for prof in detector.list_profiles(*browser) {
15 let Ok(cookies) = CookieReader::read_cookies(&prof, "opencode.ai") else {
16 continue;
17 };
18 let has_auth = cookies
19 .iter()
20 .any(|c| c.name == "auth" || c.name == "__Host-auth");
21 if !has_auth {
22 continue;
23 }
24 println!(
25 "Using {} - {} ({} opencode.ai cookies)",
26 browser.name(),
27 prof.name,
28 cookies.len(),
29 );
30 match seher::opencode_go::fetch_remote_usage(&cookies).await {
31 Ok(usage) => {
32 println!("\nSuccess! OpenCode Go usage (hosted dashboard):");
33 for w in &usage.windows {
34 println!(
35 " {:<8} {:>6.1}% reset_in_sec={:?} limited={}",
36 w.name,
37 w.used_percent,
38 w.reset_in_sec,
39 w.is_limited()
40 );
41 }
42 println!(" => limited: {}", usage.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch OpenCode Go usage: {e}");
47 }
48 }
49 }
50 }
51
52 println!("No opencode.ai session cookie (auth / __Host-auth) found in any browser");
53}