diff --git a/packages/a2a-server/src/agent/task.ts b/packages/a2a-server/src/agent/task.ts index a76054263f..b6654abb72 100644 --- a/packages/a2a-server/src/agent/task.ts +++ b/packages/a2a-server/src/agent/task.ts @@ -880,9 +880,7 @@ export class Task { if ( part.kind !== 'data' || !part.data || - // eslint-disable-next-line no-restricted-syntax typeof part.data['callId'] !== 'string' || - // eslint-disable-next-line no-restricted-syntax typeof part.data['outcome'] !== 'string' ) { return false; diff --git a/packages/cli/src/commands/hooks/migrate.ts b/packages/cli/src/commands/hooks/migrate.ts index 36bb2cf9aa..5522221b90 100644 --- a/packages/cli/src/commands/hooks/migrate.ts +++ b/packages/cli/src/commands/hooks/migrate.ts @@ -79,7 +79,7 @@ function migrateClaudeHook(claudeHook: unknown): unknown { migrated['command'] = hook['command']; // Replace CLAUDE_PROJECT_DIR with GEMINI_PROJECT_DIR in command - // eslint-disable-next-line no-restricted-syntax + if (typeof migrated['command'] === 'string') { migrated['command'] = migrated['command'].replace( /\$CLAUDE_PROJECT_DIR/g, @@ -94,7 +94,7 @@ function migrateClaudeHook(claudeHook: unknown): unknown { } // Map timeout field (Claude uses seconds, Gemini uses seconds) - // eslint-disable-next-line no-restricted-syntax + if ('timeout' in hook && typeof hook['timeout'] === 'number') { migrated['timeout'] = hook['timeout']; } @@ -142,7 +142,6 @@ function migrateClaudeHooks(claudeConfig: unknown): Record { // Transform matcher if ( 'matcher' in definition && - // eslint-disable-next-line no-restricted-syntax typeof definition['matcher'] === 'string' ) { migratedDef['matcher'] = transformMatcher(definition['matcher']); diff --git a/packages/core/src/context/chatCompressionService.ts b/packages/core/src/context/chatCompressionService.ts index 992ca67cf9..0f442fb9bf 100644 --- a/packages/core/src/context/chatCompressionService.ts +++ b/packages/core/src/context/chatCompressionService.ts @@ -159,13 +159,11 @@ async function truncateHistoryToBudget( } else if (responseObj && typeof responseObj === 'object') { if ( 'output' in responseObj && - // eslint-disable-next-line no-restricted-syntax typeof responseObj['output'] === 'string' ) { contentStr = responseObj['output']; } else if ( 'content' in responseObj && - // eslint-disable-next-line no-restricted-syntax typeof responseObj['content'] === 'string' ) { contentStr = responseObj['content']; diff --git a/packages/core/src/hooks/hookAggregator.ts b/packages/core/src/hooks/hookAggregator.ts index b67266edf5..af7f93cfab 100644 --- a/packages/core/src/hooks/hookAggregator.ts +++ b/packages/core/src/hooks/hookAggregator.ts @@ -362,7 +362,6 @@ export class HookAggregator { // Extract additionalContext from various hook types if ( 'additionalContext' in specific && - // eslint-disable-next-line no-restricted-syntax typeof specific['additionalContext'] === 'string' ) { contexts.push(specific['additionalContext']); diff --git a/packages/core/src/services/loopDetectionService.ts b/packages/core/src/services/loopDetectionService.ts index 53030911b0..d8b72233be 100644 --- a/packages/core/src/services/loopDetectionService.ts +++ b/packages/core/src/services/loopDetectionService.ts @@ -584,12 +584,10 @@ export class LoopDetectionService { } const flashConfidence = - // eslint-disable-next-line no-restricted-syntax typeof flashResult['unproductive_state_confidence'] === 'number' ? flashResult['unproductive_state_confidence'] : 0; const flashAnalysis = - // eslint-disable-next-line no-restricted-syntax typeof flashResult['unproductive_state_analysis'] === 'string' ? flashResult['unproductive_state_analysis'] : ''; @@ -636,13 +634,11 @@ export class LoopDetectionService { const mainModelConfidence = mainModelResult && - // eslint-disable-next-line no-restricted-syntax typeof mainModelResult['unproductive_state_confidence'] === 'number' ? mainModelResult['unproductive_state_confidence'] : 0; const mainModelAnalysis = mainModelResult && - // eslint-disable-next-line no-restricted-syntax typeof mainModelResult['unproductive_state_analysis'] === 'string' ? mainModelResult['unproductive_state_analysis'] : undefined; @@ -691,7 +687,6 @@ export class LoopDetectionService { if ( result && - // eslint-disable-next-line no-restricted-syntax typeof result['unproductive_state_confidence'] === 'number' ) { return result; diff --git a/packages/core/src/telemetry/semantic.ts b/packages/core/src/telemetry/semantic.ts index 6dae06d381..cb38502c91 100644 --- a/packages/core/src/telemetry/semantic.ts +++ b/packages/core/src/telemetry/semantic.ts @@ -63,7 +63,6 @@ function getStringReferences(parts: AnyPart[]): StringReference[] { }); } } else if (part instanceof GenericPart) { - // eslint-disable-next-line no-restricted-syntax if (part.type === 'executableCode' && typeof part['code'] === 'string') { refs.push({ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion @@ -74,7 +73,6 @@ function getStringReferences(parts: AnyPart[]): StringReference[] { }); } else if ( part.type === 'codeExecutionResult' && - // eslint-disable-next-line no-restricted-syntax typeof part['output'] === 'string' ) { refs.push({ diff --git a/packages/core/src/test-utils/mock-message-bus.ts b/packages/core/src/test-utils/mock-message-bus.ts index 322b38d9a8..3b7a5bd101 100644 --- a/packages/core/src/test-utils/mock-message-bus.ts +++ b/packages/core/src/test-utils/mock-message-bus.ts @@ -62,6 +62,7 @@ export class MockMessageBus { if (!this.subscriptions.has(type)) { this.subscriptions.set(type, new Set()); } + this.subscriptions.get(type)!.add(listener as (message: Message) => void); }, ); diff --git a/packages/core/src/tools/mcp-tool.ts b/packages/core/src/tools/mcp-tool.ts index caaba717d1..c14f277e07 100644 --- a/packages/core/src/tools/mcp-tool.ts +++ b/packages/core/src/tools/mcp-tool.ts @@ -106,13 +106,12 @@ export interface McpToolAnnotation extends Record { export function isMcpToolAnnotation( annotation: unknown, ): annotation is McpToolAnnotation { - if (typeof annotation !== 'object' || annotation === null) { - return false; - } - // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion - const record = annotation as Record; - const serverName = record['_serverName']; - return typeof serverName === 'string'; + return ( + typeof annotation === 'object' && + annotation !== null && + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion + typeof (annotation as Record)['_serverName'] === 'string' + ); } type ToolParams = Record; diff --git a/packages/core/src/utils/editCorrector.ts b/packages/core/src/utils/editCorrector.ts index 2c58bad98f..f8ff81b97e 100644 --- a/packages/core/src/utils/editCorrector.ts +++ b/packages/core/src/utils/editCorrector.ts @@ -112,7 +112,6 @@ Return ONLY the corrected string in the specified JSON format with the key 'corr if ( result && - // eslint-disable-next-line no-restricted-syntax typeof result['corrected_string_escaping'] === 'string' && result['corrected_string_escaping'].length > 0 ) { diff --git a/packages/core/src/utils/googleErrors.ts b/packages/core/src/utils/googleErrors.ts index bcb57425b3..82d6e56ed0 100644 --- a/packages/core/src/utils/googleErrors.ts +++ b/packages/core/src/utils/googleErrors.ts @@ -231,7 +231,7 @@ export function parseGoogleApiError(error: unknown): GoogleApiError | null { } // Basic structural check before casting. // Since the proto definitions are loose, we primarily rely on @type presence. - // eslint-disable-next-line no-restricted-syntax + if (typeof detailObj['@type'] === 'string') { // We can just cast it; the consumer will have to switch on @type // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion diff --git a/packages/core/src/utils/oauth-flow.ts b/packages/core/src/utils/oauth-flow.ts index 67062c9ec5..723728fd13 100644 --- a/packages/core/src/utils/oauth-flow.ts +++ b/packages/core/src/utils/oauth-flow.ts @@ -376,24 +376,20 @@ async function parseTokenEndpointResponse( data && typeof data === 'object' && 'access_token' in data && - // eslint-disable-next-line no-restricted-syntax typeof (data as Record)['access_token'] === 'string' ) { const obj = data as Record; const result: OAuthTokenResponse = { access_token: String(obj['access_token']), token_type: - // eslint-disable-next-line no-restricted-syntax typeof obj['token_type'] === 'string' ? obj['token_type'] : 'Bearer', expires_in: - // eslint-disable-next-line no-restricted-syntax typeof obj['expires_in'] === 'number' ? obj['expires_in'] : undefined, refresh_token: - // eslint-disable-next-line no-restricted-syntax typeof obj['refresh_token'] === 'string' ? obj['refresh_token'] : undefined, - // eslint-disable-next-line no-restricted-syntax + scope: typeof obj['scope'] === 'string' ? obj['scope'] : undefined, }; return result;