interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-cli / src / bin / aien-browser-mirror.rs

93 lines · 3749 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! `aien-browser-mirror`: headless-Chrome Cockpit mirror over the Chrome
17//! DevTools Protocol. Rust replacement for the removed Python script
18//! `basecamp/scripts/browser_mirror_test.py` (sovereign-core #180), same flags.
19//!
20//! ```text
21//! aien-browser-mirror --test Cockpit self-test (default)
22//! aien-browser-mirror --mentor "PROMPT" one chat prompt, wait for the reply
23//! aien-browser-mirror --screenshot [FILE.png] screenshot of --url
24//! aien-browser-mirror --eval "EXPR" evaluate JavaScript on --url
25//! --url URL Cockpit or any page (default http://127.0.0.1:18095)
26//! --out-dir DIR where screenshots and reports go (default ~/basecamp/ui-tests)
27//! ```
28//!
29//! Prints the JSON report on stdout. Exit status 0 when the report says
30//! PASSED, COMPLETED or ok; 1 otherwise; 2 for a usage error.
31
32use aien_cli::browser_mirror as bm;
33use std::path::PathBuf;
34
35fn usage() -> ! {
36 eprintln!(
37 "usage: aien-browser-mirror [--test | --mentor PROMPT | --screenshot [FILE] | --eval EXPR]\n\
38 \x20 [--url URL] [--out-dir DIR]"
39 );
40 std::process::exit(2)
41}
42
43fn main() {
44 let args: Vec<String> = std::env::args().skip(1).collect();
45 let mut action = "test".to_string();
46 let mut arg: Option<String> = None;
47 let mut url = std::env::var("AIEN_COCKPIT_URL").unwrap_or_else(|_| bm::DEFAULT_URL.to_string());
48 let mut out_dir: PathBuf = bm::default_out_dir();
49 let mut i = 0;
50 while i < args.len() {
51 match args[i].as_str() {
52 "--test" => action = "test".to_string(),
53 "--mentor" => {
54 action = "mentor".to_string();
55 if let Some(p) = args.get(i + 1).filter(|p| !p.starts_with("--")) {
56 arg = Some(p.clone());
57 i += 1;
58 }
59 }
60 "--screenshot" => {
61 action = "screenshot".to_string();
62 if let Some(p) = args.get(i + 1).filter(|p| !p.starts_with("--")) {
63 arg = Some(p.clone());
64 i += 1;
65 }
66 }
67 "--eval" => {
68 action = "eval".to_string();
69 arg = Some(args.get(i + 1).cloned().unwrap_or_else(|| usage()));
70 i += 1;
71 }
72 "--url" => {
73 url = args.get(i + 1).cloned().unwrap_or_else(|| usage());
74 i += 1;
75 }
76 "--out-dir" => {
77 out_dir = PathBuf::from(args.get(i + 1).cloned().unwrap_or_else(|| usage()));
78 i += 1;
79 }
80 "-h" | "--help" => usage(),
81 _ => usage(),
82 }
83 i += 1;
84 }
85 let report = bm::dispatch(&action, arg.as_deref(), &url, &out_dir);
86 println!(
87 "{}",
88 serde_json::to_string_pretty(&report).unwrap_or_default()
89 );
90 let status = report.get("status").and_then(|s| s.as_str()).unwrap_or("");
91 let ok = matches!(status, "PASSED" | "COMPLETED" | "ok");
92 std::process::exit(if ok { 0 } else { 1 });
93}