From 655495de7914e857f9ade67a0cef245a56d026e7 Mon Sep 17 00:00:00 2001 From: mkorwel Date: Tue, 24 Mar 2026 16:56:26 -0700 Subject: [PATCH] chore(lint): resolve merge conflicts and fix new lint errors --- packages/a2a-server/src/agent/task.ts | 18 ++++---- packages/cli/src/commands/hooks/migrate.ts | 18 ++++---- .../src/context/chatCompressionService.ts | 16 +++----- packages/core/src/hooks/hookAggregator.ts | 8 ++-- .../core/src/services/loopDetectionService.ts | 30 +++++++------- packages/core/src/telemetry/semantic.ts | 6 ++- packages/core/src/utils/editCorrector.ts | 7 ++-- packages/core/src/utils/googleErrors.ts | 3 +- packages/core/src/utils/oauth-flow.ts | 41 ++++++++++--------- 9 files changed, 73 insertions(+), 74 deletions(-) diff --git a/packages/a2a-server/src/agent/task.ts b/packages/a2a-server/src/agent/task.ts index b6654abb72..0067c30cac 100644 --- a/packages/a2a-server/src/agent/task.ts +++ b/packages/a2a-server/src/agent/task.ts @@ -877,21 +877,21 @@ export class Task { } private async _handleToolConfirmationPart(part: Part): Promise { - if ( - part.kind !== 'data' || - !part.data || - typeof part.data['callId'] !== 'string' || - typeof part.data['outcome'] !== 'string' - ) { - return false; - } - if (!part.data['outcome']) { + if (part.kind !== 'data' || !part.data) { return false; } const callId = part.data['callId']; const outcomeString = part.data['outcome']; + if (typeof callId !== 'string' || typeof outcomeString !== 'string') { + return false; + } + + if (!outcomeString) { + return false; + } + this.toolsAlreadyConfirmed.add(callId); let confirmationOutcome: ToolConfirmationOutcome | undefined; diff --git a/packages/cli/src/commands/hooks/migrate.ts b/packages/cli/src/commands/hooks/migrate.ts index 5522221b90..d9921fbd10 100644 --- a/packages/cli/src/commands/hooks/migrate.ts +++ b/packages/cli/src/commands/hooks/migrate.ts @@ -80,8 +80,9 @@ function migrateClaudeHook(claudeHook: unknown): unknown { // Replace CLAUDE_PROJECT_DIR with GEMINI_PROJECT_DIR in command - if (typeof migrated['command'] === 'string') { - migrated['command'] = migrated['command'].replace( + const command = migrated['command']; + if (typeof command === 'string') { + migrated['command'] = command.replace( /\$CLAUDE_PROJECT_DIR/g, '$GEMINI_PROJECT_DIR', ); @@ -95,8 +96,9 @@ function migrateClaudeHook(claudeHook: unknown): unknown { // Map timeout field (Claude uses seconds, Gemini uses seconds) - if ('timeout' in hook && typeof hook['timeout'] === 'number') { - migrated['timeout'] = hook['timeout']; + const timeout = hook['timeout']; + if ('timeout' in hook && typeof timeout === 'number') { + migrated['timeout'] = timeout; } return migrated; @@ -140,11 +142,9 @@ function migrateClaudeHooks(claudeConfig: unknown): Record { const migratedDef: Record = {}; // Transform matcher - if ( - 'matcher' in definition && - typeof definition['matcher'] === 'string' - ) { - migratedDef['matcher'] = transformMatcher(definition['matcher']); + const matcher = definition['matcher']; + if ('matcher' in definition && typeof matcher === 'string') { + migratedDef['matcher'] = transformMatcher(matcher); } // Copy sequential flag diff --git a/packages/core/src/context/chatCompressionService.ts b/packages/core/src/context/chatCompressionService.ts index 0f442fb9bf..39c52584df 100644 --- a/packages/core/src/context/chatCompressionService.ts +++ b/packages/core/src/context/chatCompressionService.ts @@ -157,16 +157,12 @@ async function truncateHistoryToBudget( if (typeof responseObj === 'string') { contentStr = responseObj; } else if (responseObj && typeof responseObj === 'object') { - if ( - 'output' in responseObj && - typeof responseObj['output'] === 'string' - ) { - contentStr = responseObj['output']; - } else if ( - 'content' in responseObj && - typeof responseObj['content'] === 'string' - ) { - contentStr = responseObj['content']; + const output = responseObj['output']; + const content = responseObj['content']; + if (typeof output === 'string') { + contentStr = output; + } else if (typeof content === 'string') { + contentStr = content; } else { contentStr = JSON.stringify(responseObj, null, 2); } diff --git a/packages/core/src/hooks/hookAggregator.ts b/packages/core/src/hooks/hookAggregator.ts index af7f93cfab..3c3dee96de 100644 --- a/packages/core/src/hooks/hookAggregator.ts +++ b/packages/core/src/hooks/hookAggregator.ts @@ -360,11 +360,9 @@ export class HookAggregator { } // Extract additionalContext from various hook types - if ( - 'additionalContext' in specific && - typeof specific['additionalContext'] === 'string' - ) { - contexts.push(specific['additionalContext']); + const additionalContext = specific['additionalContext']; + if (typeof additionalContext === 'string') { + contexts.push(additionalContext); } } } diff --git a/packages/core/src/services/loopDetectionService.ts b/packages/core/src/services/loopDetectionService.ts index d8b72233be..6cff6b90e2 100644 --- a/packages/core/src/services/loopDetectionService.ts +++ b/packages/core/src/services/loopDetectionService.ts @@ -583,14 +583,12 @@ export class LoopDetectionService { return { isLoop: false }; } + const flashConfidenceValue = flashResult['unproductive_state_confidence']; const flashConfidence = - typeof flashResult['unproductive_state_confidence'] === 'number' - ? flashResult['unproductive_state_confidence'] - : 0; + typeof flashConfidenceValue === 'number' ? flashConfidenceValue : 0; + const flashAnalysisValue = flashResult['unproductive_state_analysis']; const flashAnalysis = - typeof flashResult['unproductive_state_analysis'] === 'string' - ? flashResult['unproductive_state_analysis'] - : ''; + typeof flashAnalysisValue === 'string' ? flashAnalysisValue : ''; const doubleCheckModelName = this.context.config.modelConfigService.getResolvedConfig({ @@ -632,15 +630,17 @@ export class LoopDetectionService { signal, ); + const mainModelConfidenceValue = + mainModelResult?.['unproductive_state_confidence']; const mainModelConfidence = - mainModelResult && - typeof mainModelResult['unproductive_state_confidence'] === 'number' - ? mainModelResult['unproductive_state_confidence'] + typeof mainModelConfidenceValue === 'number' + ? mainModelConfidenceValue : 0; + const mainModelAnalysisValue = + mainModelResult?.['unproductive_state_analysis']; const mainModelAnalysis = - mainModelResult && - typeof mainModelResult['unproductive_state_analysis'] === 'string' - ? mainModelResult['unproductive_state_analysis'] + typeof mainModelAnalysisValue === 'string' + ? mainModelAnalysisValue : undefined; logLlmLoopCheck( @@ -685,10 +685,8 @@ export class LoopDetectionService { role: LlmRole.UTILITY_LOOP_DETECTOR, }); - if ( - result && - typeof result['unproductive_state_confidence'] === 'number' - ) { + const confidenceValue = result?.['unproductive_state_confidence']; + if (result && typeof confidenceValue === 'number') { return result; } return null; diff --git a/packages/core/src/telemetry/semantic.ts b/packages/core/src/telemetry/semantic.ts index cb38502c91..e805c2f84a 100644 --- a/packages/core/src/telemetry/semantic.ts +++ b/packages/core/src/telemetry/semantic.ts @@ -63,7 +63,9 @@ function getStringReferences(parts: AnyPart[]): StringReference[] { }); } } else if (part instanceof GenericPart) { - if (part.type === 'executableCode' && typeof part['code'] === 'string') { + const codeValue = part['code']; + const outputValue = part['output']; + if (part.type === 'executableCode' && typeof codeValue === 'string') { refs.push({ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion get: () => part['code'] as string, @@ -73,7 +75,7 @@ function getStringReferences(parts: AnyPart[]): StringReference[] { }); } else if ( part.type === 'codeExecutionResult' && - typeof part['output'] === 'string' + typeof outputValue === 'string' ) { refs.push({ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion diff --git a/packages/core/src/utils/editCorrector.ts b/packages/core/src/utils/editCorrector.ts index f8ff81b97e..89cd014a19 100644 --- a/packages/core/src/utils/editCorrector.ts +++ b/packages/core/src/utils/editCorrector.ts @@ -110,12 +110,13 @@ Return ONLY the corrected string in the specified JSON format with the key 'corr role: LlmRole.UTILITY_EDIT_CORRECTOR, }); + const correctedStringValue = result?.['corrected_string_escaping']; if ( result && - typeof result['corrected_string_escaping'] === 'string' && - result['corrected_string_escaping'].length > 0 + typeof correctedStringValue === 'string' && + correctedStringValue.length > 0 ) { - return result['corrected_string_escaping']; + return correctedStringValue; } else { return potentiallyProblematicString; } diff --git a/packages/core/src/utils/googleErrors.ts b/packages/core/src/utils/googleErrors.ts index 82d6e56ed0..a77551c0f3 100644 --- a/packages/core/src/utils/googleErrors.ts +++ b/packages/core/src/utils/googleErrors.ts @@ -232,7 +232,8 @@ export function parseGoogleApiError(error: unknown): GoogleApiError | null { // Basic structural check before casting. // Since the proto definitions are loose, we primarily rely on @type presence. - if (typeof detailObj['@type'] === 'string') { + const typeValue = detailObj['@type']; + if (typeof typeValue === 'string') { // We can just cast it; the consumer will have to switch on @type // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion details.push(detailObj as unknown as GoogleApiErrorDetail); diff --git a/packages/core/src/utils/oauth-flow.ts b/packages/core/src/utils/oauth-flow.ts index 723728fd13..95d71510a4 100644 --- a/packages/core/src/utils/oauth-flow.ts +++ b/packages/core/src/utils/oauth-flow.ts @@ -372,27 +372,30 @@ async function parseTokenEndpointResponse( // Try to parse as JSON first, fall back to form-urlencoded try { const data: unknown = JSON.parse(responseText); - if ( - data && - typeof data === 'object' && - 'access_token' in data && - typeof (data as Record)['access_token'] === 'string' - ) { + if (data && typeof data === 'object' && 'access_token' in data) { const obj = data as Record; - const result: OAuthTokenResponse = { - access_token: String(obj['access_token']), - token_type: - typeof obj['token_type'] === 'string' ? obj['token_type'] : 'Bearer', - expires_in: - typeof obj['expires_in'] === 'number' ? obj['expires_in'] : undefined, - refresh_token: - typeof obj['refresh_token'] === 'string' - ? obj['refresh_token'] - : undefined, + const accessTokenValue = obj['access_token']; + if (typeof accessTokenValue === 'string') { + const tokenTypeValue = obj['token_type']; + const expiresInValue = obj['expires_in']; + const refreshTokenValue = obj['refresh_token']; + const scopeValue = obj['scope']; - scope: typeof obj['scope'] === 'string' ? obj['scope'] : undefined, - }; - return result; + const result: OAuthTokenResponse = { + access_token: accessTokenValue, + token_type: + typeof tokenTypeValue === 'string' ? tokenTypeValue : 'Bearer', + expires_in: + typeof expiresInValue === 'number' ? expiresInValue : undefined, + refresh_token: + typeof refreshTokenValue === 'string' + ? refreshTokenValue + : undefined, + + scope: typeof scopeValue === 'string' ? scopeValue : undefined, + }; + return result; + } } // JSON parsed but doesn't look like a token response — fall through } catch {