Fix Basic Auth handling in v2 client and CLI status command

This commit is contained in:
Chris Scott committed 2026-03-27 00:36:04 -04:00
1 parent e14f4c5fa6
commit 2b7c3f7991
2 files changed
+24 -2

No files matched your search

+12 -1
View File
@@ -31,7 +31,18 @@ export async function run(argv: StatusArgs): Promise<void> {
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<typeof createOpencodeClient>[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
+12 -1
View File
@@ -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<typeof createV2Client>[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({