@@ -25,7 +25,9 @@ export const ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE =
2525
2626const maxAuthorizationUrlLength = 16_384 ;
2727const maxBrowserHelperLineLength =
28- ANTIGRAVITY_AUTH_BROWSER_MARKER . length + maxAuthorizationUrlLength + 2 ;
28+ Math . max ( ANTIGRAVITY_AUTH_BROWSER_MARKER . length , ANTIGRAVITY_AUTH_STDOUT_PREFIX . length ) +
29+ maxAuthorizationUrlLength +
30+ 2 ;
2931const maxStdoutLineBytes = 16 * 1024 * 1024 ;
3032const authPrefixBytes = new TextEncoder ( ) . encode ( ANTIGRAVITY_AUTH_STDOUT_PREFIX ) ;
3133const decodeUrl = Schema . decodeUnknownEffect ( Schema . URLFromString ) ;
@@ -458,25 +460,35 @@ export function makeAntigravityStdoutTransform(
458460 } ) ;
459461}
460462
461- /** Receives the URL emitted by T3's no-browser helper on stderr. */
462- export function makeAntigravityStderrHandler ( input : {
463- readonly onAuthorizationUrl : (
464- authorizationUrl : string ,
465- ) => Effect . Effect < void , AcpErrors . AcpError > ;
466- } ) {
463+ /** Receives native 1.1.1 sign-in URLs and T3 browser-helper URLs without logging stderr. */
464+ export function makeAntigravityStderrHandler (
465+ input : {
466+ readonly onAuthorizationUrl ?: (
467+ authorizationUrl : string ,
468+ ) => Effect . Effect < void , AcpErrors . AcpError > ;
469+ } = { } ,
470+ ) {
467471 let pending = "" ;
468472 const handleLine = ( line : string ) => {
469473 const message = line . endsWith ( "\r" ) ? line . slice ( 0 , - 1 ) : line ;
470- if (
471- message . length > maxBrowserHelperLineLength ||
472- ! message . startsWith ( ANTIGRAVITY_AUTH_BROWSER_MARKER )
473- ) {
474+ if ( message . length > maxBrowserHelperLineLength ) {
474475 return Effect . void ;
475476 }
476- return decodeBrowserHelperUrl ( message . slice ( ANTIGRAVITY_AUTH_BROWSER_MARKER . length ) ) . pipe (
477+ const url = message . startsWith ( ANTIGRAVITY_AUTH_STDOUT_PREFIX )
478+ ? Effect . succeed ( message . slice ( ANTIGRAVITY_AUTH_STDOUT_PREFIX . length ) )
479+ : message . startsWith ( ANTIGRAVITY_AUTH_BROWSER_MARKER )
480+ ? decodeBrowserHelperUrl ( message . slice ( ANTIGRAVITY_AUTH_BROWSER_MARKER . length ) )
481+ : undefined ;
482+ if ( url === undefined ) return Effect . void ;
483+ return url . pipe (
477484 Effect . flatMap ( parseAntigravityAuthorizationUrl ) ,
478- Effect . flatMap ( ( request ) => input . onAuthorizationUrl ( request . authorizationUrl ) ) ,
479- Effect . ignore ,
485+ Effect . matchEffect ( {
486+ onFailure : ( ) => Effect . void ,
487+ onSuccess : ( request ) =>
488+ input . onAuthorizationUrl
489+ ? input . onAuthorizationUrl ( request . authorizationUrl )
490+ : Effect . fail ( authSupportError ( ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE ) ) ,
491+ } ) ,
480492 ) ;
481493 } ;
482494
0 commit comments