@@ -571,9 +571,13 @@ export function extractAntigravityBackgroundTaskId(toolCall: AcpToolCallState):
571571 const outputText = extractAntigravityToolOutputText ( toolCall ) ;
572572 if ( outputText !== undefined ) {
573573 const match =
574- / r u n n i n g a s a b a c k g r o u n d t a s k w i t h t a s k i d : \s * ( [ ^ \s \r \n ] + ) / i. exec ( outputText ) ??
575- / s c h e d u l e d t a s k w i t h (?: t a s k ) ? i d : \s * ( [ ^ \s \r \n ] + ) / i. exec ( outputText ) ??
576- / b a c k g r o u n d t a s k w i t h t a s k i d : \s * ( [ ^ \s \r \n ] + ) / i. exec ( outputText ) ;
574+ / (?: ^ | \n ) (?: T o o l i s ) ? r u n n i n g a s a b a c k g r o u n d t a s k w i t h t a s k i d : \s * ( [ ^ \s \r \n ] + ) / i. exec (
575+ outputText ,
576+ ) ??
577+ / (?: ^ | \n ) (?: S c h e d u l e d | T o o l s c h e d u l e d ) t a s k w i t h (?: t a s k ) ? i d : \s * ( [ ^ \s \r \n ] + ) / i. exec (
578+ outputText ,
579+ ) ??
580+ / (?: ^ | \n ) (?: T o o l ) ? b a c k g r o u n d t a s k w i t h t a s k i d : \s * ( [ ^ \s \r \n ] + ) / i. exec ( outputText ) ;
577581 if ( match ?. [ 1 ] ) {
578582 // Strip only trailing punctuation such as quotes, commas, dots
579583 return match [ 1 ] . replace ( / [ " ' , . ] + $ / , "" ) . trim ( ) ;
@@ -613,11 +617,13 @@ export function extractAntigravityBackgroundTaskCompletion(
613617 const action = typeof rawInput ?. Action === "string" ? rawInput . Action . toLowerCase ( ) : "" ;
614618
615619 if ( action === "kill" || / k i l l / i. test ( title ) ) {
616- if ( toolCall . status === "completed" || / c a n c e l l e d | k i l l e d / i. test ( outputText ) ) {
617- const taskId =
618- taskIdFromInput ??
619- / T a s k " ( [ ^ " ] + ) " \s + (?: c a n c e l l e d | k i l l e d ) / i. exec ( outputText ) ?. [ 1 ] ??
620- / T a s k i d " ( [ ^ " ] + ) " \s + (?: w a s c a n c e l e d | f i n i s h e d ) / i. exec ( outputText ) ?. [ 1 ] ;
620+ const killMatch =
621+ / (?: ^ | \n ) T a s k " ( [ ^ " ] + ) " \s + (?: c a n c e l l e d | k i l l e d ) \b / i. exec ( outputText ) ??
622+ / (?: ^ | \n ) T a s k i d " ( [ ^ " ] + ) " \s + w a s c a n c e l e d \b / i. exec ( outputText ) ;
623+ const hasSuccessfulKillNotice = killMatch !== null ;
624+ const isExplicitKillError = / (?: f a i l e d | e r r o r | n o t f o u n d | n o t a s k ) / i. test ( outputText ) ;
625+ if ( ( toolCall . status === "completed" && ! isExplicitKillError ) || hasSuccessfulKillNotice ) {
626+ const taskId = taskIdFromInput ?? killMatch ?. [ 1 ] ;
621627 if ( taskId ) {
622628 return [
623629 {
@@ -685,13 +691,24 @@ export function extractAntigravityBackgroundToolMutation(text: string): Readonly
685691 if ( taskFinishedMatch ?. [ 1 ] && taskFinishedMatch [ 2 ] ) {
686692 const taskId = taskFinishedMatch [ 1 ] . replace ( / [ " ' , . ] + $ / , "" ) . trim ( ) ;
687693 const kind = taskFinishedMatch [ 2 ] . toLowerCase ( ) ;
688- const hasFailedExitCode = / c o m m a n d e x i t e d w i t h c o d e \s + ( [ 1 - 9 ] \d * ) / i. test ( text ) ;
689- const status : "completed" | "failed" =
690- kind === "failed" || hasFailedExitCode ? "failed" : "completed" ;
694+ let status : "completed" | "failed" ;
695+ if ( kind === "was canceled" ) {
696+ status = "completed" ;
697+ } else if ( kind === "failed" ) {
698+ status = "failed" ;
699+ } else {
700+ const resultPrefix = text . slice ( taskFinishedMatch . index + taskFinishedMatch [ 0 ] . length ) ;
701+ const outputIdx = resultPrefix . search ( / (?: ^ | \n ) O u t p u t : / i) ;
702+ const header = outputIdx !== - 1 ? resultPrefix . slice ( 0 , outputIdx ) : resultPrefix ;
703+ const hasFailedExitCode =
704+ / (?: ^ | \n ) (?: T h e c o m m a n d e x i t e d w i t h c o d e \s + ( [ 1 - 9 ] \d * ) | E x i t c o d e : \s * ( [ 1 - 9 ] \d * ) | S t a t u s : \s * F A I L E D ) / i. test (
705+ header ,
706+ ) ;
707+ status = hasFailedExitCode ? "failed" : "completed" ;
708+ }
691709 results . push ( { taskId, status, appendOutput : text } ) ;
692710 return results ;
693711 }
694-
695712 const taskCancelledMatch = / (?: ^ | \n ) T a s k " ( [ ^ " ] + ) " \s + (?: c a n c e l l e d | k i l l e d ) \b / i. exec ( text ) ;
696713 if ( taskCancelledMatch ?. [ 1 ] ) {
697714 results . push ( {
0 commit comments