Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions architecture/compute-runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ The capability RPC reports driver identity, version, and the default sandbox
image used by the gateway. GPU availability stays driver-local and is validated
when a sandbox create request asks for GPU resources.

The gateway records driver identity and version from the startup capability
response. Elevated gateway info reports that initialized driver snapshot instead
of re-querying drivers on each request.

## Runtime Summary

| Runtime | Best fit | Sandbox boundary | Notes |
Expand Down
52 changes: 38 additions & 14 deletions crates/openshell-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const HELP_TEMPLATE: &str = "\
provider: Manage provider configuration

\x1b[1mGATEWAY COMMANDS\x1b[0m
gateway: Manage gateway registrations
gateway: Manage gateways
status: Show gateway status and information
inference: Manage inference configuration
doctor: Diagnose gateway issues
Expand Down Expand Up @@ -524,7 +524,7 @@ enum Commands {
// ===================================================================
// GATEWAY COMMANDS
// ===================================================================
/// Manage gateway registrations.
/// Manage gateways.
#[command(alias = "gw", after_help = GATEWAY_EXAMPLES, help_template = SUBCOMMAND_HELP_TEMPLATE)]
Gateway {
#[command(subcommand)]
Expand Down Expand Up @@ -1105,18 +1105,19 @@ enum GatewayCommands {
name: Option<String>,
},

/// Show gateway registration details.
/// Show elevated live gateway runtime information.
#[command(help_template = LEAF_HELP_TEMPLATE, next_help_heading = "FLAGS")]
Info {
/// Gateway name (defaults to active gateway).
#[arg(long, env = "OPENSHELL_GATEWAY", add = ArgValueCompleter::new(completers::complete_gateway_names))]
name: Option<String>,
/// Output format.
#[arg(short = 'o', long = "output", value_enum, default_value_t = OutputFormat::Table)]
output: OutputFormat,
},

/// List registered gateways.
///
/// Prints a table of all registered gateways with their endpoint, type,
/// and authentication mode. The active gateway is marked with `*`.
/// Prints all registered gateways with their endpoint, type,
/// authentication mode, source, and remote registration details.
/// The active gateway is marked with `*`.
#[command(help_template = LEAF_HELP_TEMPLATE, next_help_heading = "FLAGS")]
List {
/// Output format.
Expand Down Expand Up @@ -2056,11 +2057,14 @@ async fn main() -> Result<()> {
GatewayCommands::Select { name } => {
run::gateway_select(name.as_deref(), &cli.gateway)?;
}
GatewayCommands::Info { name } => {
let name = name
.or_else(|| resolve_gateway_name(&cli.gateway))
.unwrap_or_else(|| "openshell".to_string());
run::gateway_admin_info(&name)?;
GatewayCommands::Info { output } => {
if let Ok(ctx) = resolve_gateway(&cli.gateway, &cli.gateway_endpoint) {
let mut tls = tls.with_gateway_name(&ctx.name);
apply_auth(&mut tls, &ctx.name);
run::gateway_info(&ctx.name, &ctx.endpoint, &tls, output.as_str()).await?;
} else {
run::gateway_info_not_configured()?;
}
}
GatewayCommands::List { output } => {
run::gateway_list(&cli.gateway, output.as_str())?;
Expand Down Expand Up @@ -3445,7 +3449,7 @@ mod tests {
for (raw_args, index) in [
(vec!["openshell", "--gateway", "a"], 2),
(vec!["openshell", "gateway", "select", "a"], 3),
(vec!["openshell", "gateway", "info", "--name", "a"], 4),
(vec!["openshell", "gateway", "remove", "a"], 3),
] {
let mut cmd = Cli::command();
let args: Vec<OsString> = raw_args.iter().copied().map(Into::into).collect();
Expand Down Expand Up @@ -3473,6 +3477,26 @@ mod tests {
assert!(matches!(cli.command, Some(Commands::Status)));
}

#[test]
fn gateway_info_accepts_output_json() {
let cli = Cli::try_parse_from(["openshell", "gateway", "info", "-o", "json"])
.expect("gateway info -o json should parse");

assert!(matches!(
cli.command,
Some(Commands::Gateway {
command: Some(GatewayCommands::Info {
output: OutputFormat::Json
})
})
));
}

#[test]
fn top_level_info_is_not_a_command() {
assert!(Cli::try_parse_from(["openshell", "info"]).is_err());
}

#[test]
fn hidden_aliases_still_parse() {
let cli = Cli::try_parse_from(["openshell", "lg", "sandbox-1"])
Expand Down
Loading
Loading