File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,18 @@ export async function run(argv: StatusArgs): Promise<void> {
3131
3232 async function tryFetchSessionOutput ( serverUrl : string , sessionId : string , directory : string ) {
3333 try {
34- const client = createOpencodeClient ( { baseUrl : serverUrl , directory } )
34+ const url = new URL ( serverUrl )
35+ const password = url . password || process . env [ 'OPENCODE_SERVER_PASSWORD' ]
36+ const cleanUrl = new URL ( url . toString ( ) )
37+ cleanUrl . username = ''
38+ cleanUrl . password = ''
39+ const clientConfig : Parameters < typeof createOpencodeClient > [ 0 ] = { baseUrl : cleanUrl . toString ( ) , directory }
40+ if ( password ) {
41+ clientConfig . headers = {
42+ Authorization : `Basic ${ Buffer . from ( `opencode:${ password } ` ) . toString ( 'base64' ) } ` ,
43+ }
44+ }
45+ const client = createOpencodeClient ( clientConfig )
3546 return await fetchSessionOutput ( client , sessionId , directory )
3647 } catch {
3748 return null
Original file line number Diff line number Diff line change @@ -264,7 +264,18 @@ export function createMemoryPlugin(config: PluginConfig): Plugin {
264264 const { directory, project, client } = input
265265 const projectId = project . id
266266
267- const v2 = createV2Client ( { baseUrl : input . serverUrl . toString ( ) , directory } )
267+ const serverUrl = input . serverUrl
268+ const serverPassword = serverUrl . password || process . env [ 'OPENCODE_SERVER_PASSWORD' ]
269+ const cleanUrl = new URL ( serverUrl . toString ( ) )
270+ cleanUrl . username = ''
271+ cleanUrl . password = ''
272+ const v2ClientConfig : Parameters < typeof createV2Client > [ 0 ] = { baseUrl : cleanUrl . toString ( ) , directory }
273+ if ( serverPassword ) {
274+ v2ClientConfig . headers = {
275+ Authorization : `Basic ${ Buffer . from ( `opencode:${ serverPassword } ` ) . toString ( 'base64' ) } ` ,
276+ }
277+ }
278+ const v2 = createV2Client ( v2ClientConfig )
268279
269280 const loggingConfig = config . logging
270281 const logger = createLogger ( {
You can’t perform that action at this time.
0 commit comments