pub mod agents;
pub mod browser;
pub mod cli;
pub mod customization;
pub mod daemon;
pub mod debugger;
pub mod development;
pub mod experiments;
pub mod external_agents;
pub mod fim;
pub mod git;
pub mod github;
pub mod harness;
pub mod intelligence;
pub mod kernels;
pub mod lsp;
pub mod mcp;
pub mod pi_runtime;
pub mod tasks;
pub mod testing;
pub mod todos;
pub mod tools;
pub mod trust;
pub mod tui;
pub mod workspace;
use glass_browser::cli::args::Cli;
pub use agents::{
AgentEvent, AgentId, AgentRegistry, AgentSnapshot, AgentSpec, AgentStatus, ResidentAgentBroker,
};
pub use browser::{BrowserRuntimeState, BrowserService, BrowserStartConfig};
pub use customization::{Customization, GlassConfig, Skill};
pub use experiments::{
ExperimentComparison, ExperimentEvidence, ExperimentManager, ExperimentRanking,
ExperimentSnapshot, ExperimentState, ExperimentTrustPolicy, ExperimentWeights,
};
pub use intelligence::{
CausalPath, DevelopmentEdge, DevelopmentIntelligence, DevelopmentNode, DevelopmentNodeKind,
ObservableDevelopmentEvent, ObservableEventInput, ReplayDiff,
};
pub use lsp::{LanguageServerConfig, LanguageService, LanguageServiceEvent};
pub use pi_runtime::{
PINNED_PI_SDK_VERSION, PiReadiness, PiReadinessComponent, PiReadinessState, PiSessionRequest,
};
pub use tasks::{
CrewWake, CrewWakeLiveEvidence, CrewWakeMember, RetryPolicy, TaskBudget, TaskEvidence, TaskId,
TaskScheduler, TaskSnapshot, TaskSpec, TaskState, VerificationRequirement,
load_latest_crew_wake, persist_crew_wake,
};
pub use todos::{SessionTodo, SessionTodoList, TodoStatus};
pub use tools::{DevelopmentToolContext, DevelopmentToolRouter};
pub use trust::{LocalTrustDecision, WorkspaceIdentity, WorkspaceTrust, WorkspaceTrustStore};
pub use workspace::{AgentTurnMode, DevelopmentWorkspace, SharedDevelopmentWorkspace};
pub async fn dispatch(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
if cli.mcp {
let backend = std::sync::Arc::new(mcp::DevelopmentMcpBackend::open(
std::env::current_dir()?,
cli.yolo,
)?);
return glass_browser::mcp::server::run_mcp_server_with_backend(&cli, backend).await;
}
if let Some(glass_browser::cli::args::Commands::Agent { action }) = &cli.command
&& matches!(
action,
glass_browser::cli::args::AgentCommand::Tool { .. }
| glass_browser::cli::args::AgentCommand::ToolFile { .. }
)
{
let result = dispatch_external_tool(action, cli.yolo).await?;
println!("{}", serde_json::to_string_pretty(&result)?);
return Ok(());
}
if let Some(glass_browser::cli::args::Commands::Agent { action }) = &cli.command {
enforce_legacy_development_trust(&cli)?;
return cli::dispatch_agent(action, cli.yolo);
}
if let Some(glass_browser::cli::args::Commands::Harness { action }) = &cli.command {
enforce_legacy_development_trust(&cli)?;
return cli::dispatch_harness(action);
}
if let Some(glass_browser::cli::args::Commands::Daemon { action }) = &cli.command {
return daemon::dispatch(action).await;
}
if let Some(glass_browser::cli::args::Commands::Project { action }) = &cli.command {
enforce_legacy_development_trust(&cli)?;
return cli::dispatch_project(action);
}
if cli.prompt.is_none()
&& matches!(
cli.command.as_ref(),
Some(glass_browser::cli::args::Commands::Tui)
)
{
return run_development_tui(&cli);
}
if cli.command.is_none() && cli.prompt.is_none() && !cli.mcp {
return run_development_tui(&cli);
}
enforce_legacy_development_trust(&cli)?;
glass_browser::cli::runner::dispatch(cli).await
}
fn run_development_tui(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
let visual_options = tui::TuiVisualOptions {
mode: cli.tui_live,
backend: cli.tui_live_backend,
quality: cli.tui_live_quality,
fit: cli.tui_live_fit,
};
tui::run(
std::env::current_dir()?,
cli.tui_layout,
visual_options,
cli.yolo,
cli.policy,
)
}
fn enforce_legacy_development_trust(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
use glass_browser::cli::args::{
AgentCommand, AgentHarness, Commands, HarnessCommand, ProjectCommand,
};
let (root, safe_static) = match cli.command.as_ref() {
Some(Commands::Project { action }) => {
let root = match action {
ProjectCommand::Inspect { root }
| ProjectCommand::Files { root }
| ProjectCommand::Search { root, .. }
| ProjectCommand::Read { root, .. }
| ProjectCommand::Edit { root, .. }
| ProjectCommand::Mkdir { root, .. }
| ProjectCommand::Rename { root, .. }
| ProjectCommand::Delete { root, .. }
| ProjectCommand::Diagnostics { root, .. }
| ProjectCommand::Run { root, .. }
| ProjectCommand::Test { root }
| ProjectCommand::Lint { root }
| ProjectCommand::Process { root, .. }
| ProjectCommand::Diff { root }
| ProjectCommand::Link { root, .. }
| ProjectCommand::Graph { root, .. }
| ProjectCommand::Breakpoint { root, .. }
| ProjectCommand::Timeline { root }
| ProjectCommand::Replay { root, .. }
| ProjectCommand::Neovim { root, .. }
| ProjectCommand::Experiment { root, .. }
| ProjectCommand::Attach { root, .. } => root,
};
let safe = matches!(
action,
ProjectCommand::Inspect { .. }
| ProjectCommand::Files { .. }
| ProjectCommand::Search { .. }
| ProjectCommand::Read { .. }
| ProjectCommand::Diff { .. }
| ProjectCommand::Graph { .. }
| ProjectCommand::Breakpoint { .. }
| ProjectCommand::Timeline { .. }
| ProjectCommand::Replay { .. }
);
(root, safe)
}
Some(Commands::Harness { action }) => match action {
HarnessCommand::List => return Ok(()),
HarnessCommand::Start { root, .. } => (root, false),
},
Some(Commands::Agent { action }) => {
let (root, safe) = match action {
AgentCommand::Doctor | AgentCommand::Setup { .. } | AgentCommand::Status => {
return Ok(());
}
AgentCommand::Hello { root, harness } => {
(root, matches!(harness, AgentHarness::Local))
}
AgentCommand::Prompt { root, harness, .. } => {
(root, matches!(harness, AgentHarness::Local))
}
AgentCommand::Delegate { root, sandbox, .. } => (
root,
matches!(
sandbox,
glass_browser::cli::args::ExternalAgentSandbox::ReadOnly
),
),
AgentCommand::Tool { .. } | AgentCommand::ToolFile { .. } => return Ok(()),
AgentCommand::Steer { root, .. }
| AgentCommand::FollowUp { root, .. }
| AgentCommand::Models { root }
| AgentCommand::SetModel { root, .. }
| AgentCommand::Thinking { root, .. }
| AgentCommand::Abort { root }
| AgentCommand::NewSession { root } => (root, false),
};
(root, safe)
}
_ => return Ok(()),
};
let workspace = DevelopmentWorkspace::open(root)?;
if workspace.trust() == WorkspaceTrust::Untrusted && !safe_static {
return Err(format!(
"repository-controlled development execution is blocked for {}; open the TUI to inspect and trust this workspace",
workspace.root().display()
)
.into());
}
Ok(())
}
async fn dispatch_external_tool(
action: &glass_browser::cli::args::AgentCommand,
unrestricted: bool,
) -> Result<serde_json::Value, Box<dyn std::error::Error>> {
use crate::development::{Actor, ToolAuthorization, ToolCall};
use glass_browser::cli::args::AgentCommand;
let (call, root, allow_mutation, confirmed) = match action {
AgentCommand::Tool {
call,
root,
allow_mutation,
yes,
} => (
serde_json::from_str::<ToolCall>(call)?,
root,
*allow_mutation || unrestricted,
*yes || unrestricted,
),
AgentCommand::ToolFile {
path,
root,
allow_mutation,
yes,
} if std::env::var_os("GLASS_DEV_DAEMON_SOCKET").is_some() => {
return daemon::forward_resident_tool_file(
path,
root,
*allow_mutation || unrestricted,
*yes || unrestricted,
)
.await;
}
AgentCommand::ToolFile {
path,
root,
allow_mutation,
yes,
} => (
daemon::read_private_tool_call(path)?,
root,
*allow_mutation || unrestricted,
*yes || unrestricted,
),
_ => return Err("expected an external agent tool action".into()),
};
let mut workspace = DevelopmentWorkspace::open(root)?;
let context = DevelopmentToolContext {
authorization: ToolAuthorization {
actor: Actor::external("cli"),
allow_mutation,
confirmed,
unrestricted: allow_mutation && confirmed,
},
initiator: None,
expected_generation: workspace.generation(),
expected_project_revision: workspace.project().revision(),
};
Ok(workspace.execute_tool(&call, &context)?)
}