summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEric Clemmons <[email protected]>2026-03-09 02:32:13 -0500
committerGitHub <[email protected]>2026-03-09 07:32:13 +0000
commit18fb19da3b5aad7e05af9ebdfb881704319853a7 (patch)
tree6fe96346b6328d8939dc8b598137b141846e601f
parent849e1ac54378ec3b6452ca589266b519fa17ba23 (diff)
downloadopencode-18fb19da3b5aad7e05af9ebdfb881704319853a7.tar.gz
opencode-18fb19da3b5aad7e05af9ebdfb881704319853a7.zip
fix(opencode): pass missing auth headers in `run --attach` (#16097)
Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Shoubhit Dash <[email protected]>
-rw-r--r--packages/opencode/src/cli/cmd/run.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/opencode/src/cli/cmd/run.ts b/packages/opencode/src/cli/cmd/run.ts
index 61bc609bb..5c6dd11f9 100644
--- a/packages/opencode/src/cli/cmd/run.ts
+++ b/packages/opencode/src/cli/cmd/run.ts
@@ -280,6 +280,11 @@ export const RunCommand = cmd({
type: "string",
describe: "attach to a running opencode server (e.g., http://localhost:4096)",
})
+ .option("password", {
+ alias: ["p"],
+ type: "string",
+ describe: "basic auth password (defaults to OPENCODE_SERVER_PASSWORD)",
+ })
.option("dir", {
type: "string",
describe: "directory to run in, path on remote server if attaching",
@@ -648,7 +653,14 @@ export const RunCommand = cmd({
}
if (args.attach) {
- const sdk = createOpencodeClient({ baseUrl: args.attach, directory })
+ const headers = (() => {
+ const password = args.password ?? process.env.OPENCODE_SERVER_PASSWORD
+ if (!password) return undefined
+ const username = process.env.OPENCODE_SERVER_USERNAME ?? "opencode"
+ const auth = `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`
+ return { Authorization: auth }
+ })()
+ const sdk = createOpencodeClient({ baseUrl: args.attach, directory, headers })
return await execute(sdk)
}