@@ -395,6 +395,7 @@ export const GithubRunCommand = cmd({
395395 const { providerID, modelID } = normalizeModel ( )
396396 const runId = normalizeRunId ( )
397397 const share = normalizeShare ( )
398+ const oidcBaseUrl = normalizeOidcBaseUrl ( )
398399 const { owner, repo } = context . repo
399400 const payload = context . payload as IssueCommentEvent | PullRequestReviewCommentEvent
400401 const issueEvent = isIssueCommentEvent ( payload ) ? payload : undefined
@@ -572,6 +573,12 @@ export const GithubRunCommand = cmd({
572573 throw new Error ( `Invalid use_github_token value: ${ value } . Must be a boolean.` )
573574 }
574575
576+ function normalizeOidcBaseUrl ( ) : string {
577+ const value = process . env [ "OIDC_BASE_URL" ]
578+ if ( ! value ) return "https://api.opencode.ai"
579+ return value . replace ( / \/ + $ / , "" )
580+ }
581+
575582 function isIssueCommentEvent (
576583 event : IssueCommentEvent | PullRequestReviewCommentEvent ,
577584 ) : event is IssueCommentEvent {
@@ -809,14 +816,14 @@ export const GithubRunCommand = cmd({
809816
810817 async function exchangeForAppToken ( token : string ) {
811818 const response = token . startsWith ( "github_pat_" )
812- ? await fetch ( "https://api.opencode.ai/ exchange_github_app_token_with_pat" , {
819+ ? await fetch ( ` ${ oidcBaseUrl } / exchange_github_app_token_with_pat` , {
813820 method : "POST" ,
814821 headers : {
815822 Authorization : `Bearer ${ token } ` ,
816823 } ,
817824 body : JSON . stringify ( { owner, repo } ) ,
818825 } )
819- : await fetch ( "https://api.opencode.ai/ exchange_github_app_token" , {
826+ : await fetch ( ` ${ oidcBaseUrl } / exchange_github_app_token` , {
820827 method : "POST" ,
821828 headers : {
822829 Authorization : `Bearer ${ token } ` ,
0 commit comments