fix(owpenbot): use --opencode-url CLI arg instead of env var

Added --opencode-url option to start command and updated spawn.rs
to pass URL as CLI argument for explicit, traceable configuration.
This commit is contained in:
Benjamin Shafii
2026-01-28 21:45:43 -08:00
parent 22d4678cc0
commit cde5bebb38
2 changed files with 14 additions and 19 deletions

View File

@@ -9,12 +9,13 @@ pub fn build_owpenbot_args(
workspace_path: &str,
opencode_url: Option<&str>,
) -> Vec<String> {
let args = vec!["start".to_string(), workspace_path.to_string()];
let mut args = vec!["start".to_string(), workspace_path.to_string()];
if let Some(url) = opencode_url {
if !url.trim().is_empty() {
// Set via environment variable instead since CLI doesn't have --opencode-url flag
// The bridge will use OPENCODE_URL env var
let trimmed = url.trim();
if !trimmed.is_empty() {
args.push("--opencode-url".to_string());
args.push(trimmed.to_string());
}
}
@@ -33,19 +34,9 @@ pub fn spawn_owpenbot(
let args = build_owpenbot_args(workspace_path, opencode_url);
let mut cmd = command.args(args);
// Pass opencode URL via environment if provided
if let Some(url) = opencode_url {
if !url.trim().is_empty() {
cmd = cmd.env("OPENCODE_URL", url);
}
}
// Set the opencode directory
cmd = cmd.env("OPENCODE_DIRECTORY", workspace_path);
cmd.current_dir(Path::new(workspace_path))
command
.args(args)
.current_dir(Path::new(workspace_path))
.spawn()
.map_err(|e| format!("Failed to start owpenbot: {e}"))
}

View File

@@ -131,10 +131,13 @@ function parseConfigValue(value: string): unknown {
// Start command
// -----------------------------------------------------------------------------
async function runStart(pathOverride?: string) {
async function runStart(pathOverride?: string, options?: { opencodeUrl?: string }) {
if (pathOverride?.trim()) {
process.env.OPENCODE_DIRECTORY = pathOverride.trim();
}
if (options?.opencodeUrl?.trim()) {
process.env.OPENCODE_URL = options.opencodeUrl.trim();
}
const config = loadConfig();
const logger = createAppLogger(config);
const reporter = createConsoleReporter();
@@ -223,7 +226,8 @@ program
.command("start")
.description("Start the bridge")
.argument("[path]", "OpenCode workspace path")
.action((pathArg?: string) => runStart(pathArg));
.option("--opencode-url <url>", "OpenCode server URL")
.action((pathArg?: string, options?: { opencodeUrl?: string }) => runStart(pathArg, options));
// -----------------------------------------------------------------------------
// health command