@@ -79,6 +79,7 @@ import {
7979} from "../settings/environment-variables/execution.js" ;
8080import { resolveExecutionSigningPlan } from "../settings/keys/execution.js" ;
8181import { signGitPayload } from "../settings/keys/ssh-ed25519.js" ;
82+ import { bitbucketControlPlaneFor } from "../source-control/bitbucket/control-plane.js" ;
8283import {
8384 BITBUCKET_GIT_PATH ,
8485 bitbucketRuntimeBroker ,
@@ -2038,8 +2039,8 @@ export class ThreadExecutionObject extends DurableObject<Bindings> {
20382039 ) ;
20392040 // Independent D1 reads: a wake waits for the slowest, not their sum.
20402041 const db = await Effect . runPromise ( decodeD1Binding ( this . env . DB ) ) ;
2041- // Every bitbucket.org remote routes through the dx gateway while the
2042- // Thread owner has an active Bitbucket connection .
2042+ // While the Thread owner has an active Bitbucket connection, SSH
2043+ // bitbucket.org remotes use HTTPS so the native credential helper applies .
20432044 const [ snapshot , signing , bitbucketConnection ] = await Promise . all ( [
20442045 Effect . runPromise ( resolveExecutionEnvironment ( this . env , threadId ) ) ,
20452046 Effect . runPromise ( resolveExecutionSigningPlan ( this . env , threadId ) ) ,
@@ -2426,6 +2427,22 @@ export class ThreadExecutionObject extends DurableObject<Bindings> {
24262427 } ) ;
24272428 return { username : "x-access-token" , password } ;
24282429 }
2430+ if ( host === "bitbucket.org" ) {
2431+ const control = await bitbucketControlPlaneFor ( db , this . env ) ;
2432+ const password = await control . withConnection (
2433+ thread . owner_user_id ,
2434+ undefined ,
2435+ async ( token ) => token ,
2436+ ) ;
2437+ threadDaemonLogger . info ( "Native Bitbucket credential issued." , {
2438+ event : "native_git_credential" ,
2439+ threadId,
2440+ actorUserId : thread . owner_user_id ,
2441+ provider : "bitbucket" ,
2442+ } ) ;
2443+ return { username : "x-token-auth" , password } ;
2444+ }
2445+ // dxd releases that still rewrite bitbucket.org remotes to the gateway.
24292446 const gateway = new URL ( this . env . DX_AUTH_URL as string ) ;
24302447 if (
24312448 host !== gateway . host . toLowerCase ( ) ||
0 commit comments