From 2b7c3f7991fd7f65336daee9eb91a605741be610 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Fri, 27 Mar 2026 00:36:04 -0400 Subject: [PATCH] Fix Basic Auth handling in v2 client and CLI status command --- packages/memory/src/cli/commands/status.ts | 13 ++++++++++++- packages/memory/src/index.ts | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/memory/src/cli/commands/status.ts b/packages/memory/src/cli/commands/status.ts index 9a5323fa..9b122a34 100644 --- a/packages/memory/src/cli/commands/status.ts +++ b/packages/memory/src/cli/commands/status.ts @@ -31,7 +31,18 @@ export async function run(argv: StatusArgs): Promise { async function tryFetchSessionOutput(serverUrl: string, sessionId: string, directory: string) { try { - const client = createOpencodeClient({ baseUrl: serverUrl, directory }) + const url = new URL(serverUrl) + const password = url.password || process.env['OPENCODE_SERVER_PASSWORD'] + const cleanUrl = new URL(url.toString()) + cleanUrl.username = '' + cleanUrl.password = '' + const clientConfig: Parameters[0] = { baseUrl: cleanUrl.toString(), directory } + if (password) { + clientConfig.headers = { + Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString('base64')}`, + } + } + const client = createOpencodeClient(clientConfig) return await fetchSessionOutput(client, sessionId, directory) } catch { return null diff --git a/packages/memory/src/index.ts b/packages/memory/src/index.ts index b9677c7e..4b0fca68 100644 --- a/packages/memory/src/index.ts +++ b/packages/memory/src/index.ts @@ -264,7 +264,18 @@ export function createMemoryPlugin(config: PluginConfig): Plugin { const { directory, project, client } = input const projectId = project.id - const v2 = createV2Client({ baseUrl: input.serverUrl.toString(), directory }) + const serverUrl = input.serverUrl + const serverPassword = serverUrl.password || process.env['OPENCODE_SERVER_PASSWORD'] + const cleanUrl = new URL(serverUrl.toString()) + cleanUrl.username = '' + cleanUrl.password = '' + const v2ClientConfig: Parameters[0] = { baseUrl: cleanUrl.toString(), directory } + if (serverPassword) { + v2ClientConfig.headers = { + Authorization: `Basic ${Buffer.from(`opencode:${serverPassword}`).toString('base64')}`, + } + } + const v2 = createV2Client(v2ClientConfig) const loggingConfig = config.logging const logger = createLogger({