From 246098ee7df2ad3e02bf22f2e01cc68a63da0d44 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:53:01 +0530 Subject: [PATCH 01/14] fix: merge duplicate imports in core/ directory --- packages/core/src/core/baseLlmClient.test.ts | 11 +++---- packages/core/src/core/client.ts | 31 ++++++++++++------- .../core/src/core/contentGenerator.test.ts | 2 +- packages/core/src/core/contentGenerator.ts | 16 +++++----- .../core/src/core/coreToolScheduler.test.ts | 3 +- packages/core/src/core/coreToolScheduler.ts | 8 +++-- packages/core/src/core/geminiChat.test.ts | 8 +++-- packages/core/src/core/geminiChat.ts | 21 +++++++------ .../src/core/geminiChat_network_retry.test.ts | 3 +- packages/core/src/core/localLiteRtLmClient.ts | 3 +- packages/core/src/core/logger.test.ts | 2 +- .../core/src/core/loggingContentGenerator.ts | 3 +- packages/core/src/core/turn.test.ts | 16 ++++++---- packages/core/src/core/turn.ts | 19 ++++++------ 14 files changed, 80 insertions(+), 66 deletions(-) diff --git a/packages/core/src/core/baseLlmClient.test.ts b/packages/core/src/core/baseLlmClient.test.ts index db1086fe81d..b9711608a77 100644 --- a/packages/core/src/core/baseLlmClient.test.ts +++ b/packages/core/src/core/baseLlmClient.test.ts @@ -15,17 +15,16 @@ import { type Mock, } from 'vitest'; -import type { - GenerateContentOptions, - GenerateJsonOptions, +import { + BaseLlmClient, + type GenerateContentOptions, + type GenerateJsonOptions, } from './baseLlmClient.js'; -import { BaseLlmClient } from './baseLlmClient.js'; -import type { ContentGenerator } from './contentGenerator.js'; +import { AuthType, type ContentGenerator } from './contentGenerator.js'; import type { ModelAvailabilityService } from '../availability/modelAvailabilityService.js'; import { createAvailabilityServiceMock } from '../availability/testUtils.js'; import type { GenerateContentResponse } from '@google/genai'; import type { Config } from '../config/config.js'; -import { AuthType } from './contentGenerator.js'; import { reportError } from '../utils/errorReporting.js'; import { logMalformedJsonResponse } from '../telemetry/loggers.js'; import { retryWithBackoff } from '../utils/retry.js'; diff --git a/packages/core/src/core/client.ts b/packages/core/src/core/client.ts index 18887462f62..1bf4c5cd89e 100644 --- a/packages/core/src/core/client.ts +++ b/packages/core/src/core/client.ts @@ -4,27 +4,35 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - GenerateContentConfig, - PartListUnion, - Content, - Tool, - GenerateContentResponse, +import { + createUserContent, + type GenerateContentConfig, + type PartListUnion, + type Content, + type Tool, + type GenerateContentResponse, } from '@google/genai'; -import { createUserContent } from '@google/genai'; import { partListUnionToString } from './geminiRequest.js'; import { getDirectoryContextString, getInitialChatHistory, } from '../utils/environmentContext.js'; -import type { ServerGeminiStreamEvent, ChatCompressionInfo } from './turn.js'; -import { CompressionStatus, Turn, GeminiEventType } from './turn.js'; +import { + CompressionStatus, + Turn, + GeminiEventType, + type ServerGeminiStreamEvent, + type ChatCompressionInfo, +} from './turn.js'; import type { Config } from '../config/config.js'; import { getCoreSystemPrompt } from './prompts.js'; import { checkNextSpeaker } from '../utils/nextSpeakerChecker.js'; import { reportError } from '../utils/errorReporting.js'; import { GeminiChat } from './geminiChat.js'; -import { retryWithBackoff } from '../utils/retry.js'; +import { + retryWithBackoff, + type RetryAvailabilityContext, +} from '../utils/retry.js'; import type { ValidationRequiredError } from '../utils/googleQuotaErrors.js'; import { getErrorMessage } from '../utils/errors.js'; import { tokenLimit } from './tokenLimits.js'; @@ -47,6 +55,7 @@ import type { import { ContentRetryFailureEvent, NextSpeakerCheckEvent, + type LlmRole, } from '../telemetry/types.js'; import { uiTelemetryService } from '../telemetry/uiTelemetry.js'; import type { IdeContext, File } from '../ide/types.js'; @@ -61,10 +70,8 @@ import { createAvailabilityContextProvider, } from '../availability/policyHelpers.js'; import { resolveModel, isGemini2Model } from '../config/models.js'; -import type { RetryAvailabilityContext } from '../utils/retry.js'; import { partToString } from '../utils/partUtils.js'; import { coreEvents, CoreEvent } from '../utils/events.js'; -import type { LlmRole } from '../telemetry/types.js'; const MAX_TURNS = 100; diff --git a/packages/core/src/core/contentGenerator.test.ts b/packages/core/src/core/contentGenerator.test.ts index 9b7c3ac8028..d86eb6f7382 100644 --- a/packages/core/src/core/contentGenerator.test.ts +++ b/packages/core/src/core/contentGenerator.test.ts @@ -5,11 +5,11 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { ContentGenerator } from './contentGenerator.js'; import { createContentGenerator, AuthType, createContentGeneratorConfig, + type ContentGenerator, } from './contentGenerator.js'; import { createCodeAssistContentGenerator } from '../code_assist/codeAssist.js'; import { GoogleGenAI } from '@google/genai'; diff --git a/packages/core/src/core/contentGenerator.ts b/packages/core/src/core/contentGenerator.ts index d9bb02a2307..4270305ca71 100644 --- a/packages/core/src/core/contentGenerator.ts +++ b/packages/core/src/core/contentGenerator.ts @@ -4,15 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - CountTokensResponse, - GenerateContentResponse, - GenerateContentParameters, - CountTokensParameters, - EmbedContentResponse, - EmbedContentParameters, +import { + GoogleGenAI, + type CountTokensResponse, + type GenerateContentResponse, + type GenerateContentParameters, + type CountTokensParameters, + type EmbedContentResponse, + type EmbedContentParameters, } from '@google/genai'; -import { GoogleGenAI } from '@google/genai'; import { createCodeAssistContentGenerator } from '../code_assist/codeAssist.js'; import type { Config } from '../config/config.js'; import { loadApiKey } from './apiKeyCredentialStorage.js'; diff --git a/packages/core/src/core/coreToolScheduler.test.ts b/packages/core/src/core/coreToolScheduler.test.ts index 6bdad0dddbb..fcddc05a44c 100644 --- a/packages/core/src/core/coreToolScheduler.test.ts +++ b/packages/core/src/core/coreToolScheduler.test.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from 'vitest'; -import type { Mock } from 'vitest'; +import { describe, it, expect, vi, type Mock } from 'vitest'; import type { CallableTool } from '@google/genai'; import { CoreToolScheduler } from './coreToolScheduler.js'; import { diff --git a/packages/core/src/core/coreToolScheduler.ts b/packages/core/src/core/coreToolScheduler.ts index f8d1b260fda..f919cc01a47 100644 --- a/packages/core/src/core/coreToolScheduler.ts +++ b/packages/core/src/core/coreToolScheduler.ts @@ -21,10 +21,13 @@ import { ToolCallEvent } from '../telemetry/types.js'; import { runInDevTraceSpan } from '../telemetry/trace.js'; import { ToolModificationHandler } from '../scheduler/tool-modifier.js'; import { getToolSuggestion } from '../utils/tool-utils.js'; -import type { ToolConfirmationRequest } from '../confirmation-bus/types.js'; -import { MessageBusType } from '../confirmation-bus/types.js'; +import { + MessageBusType, + type ToolConfirmationRequest, +} from '../confirmation-bus/types.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; import { + CoreToolCallStatus, type ToolCall, type ValidatingToolCall, type ScheduledToolCall, @@ -42,7 +45,6 @@ import { type ToolCallRequestInfo, type ToolCallResponseInfo, } from '../scheduler/types.js'; -import { CoreToolCallStatus } from '../scheduler/types.js'; import { ToolExecutor } from '../scheduler/tool-executor.js'; import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; import { getPolicyDenialError } from '../scheduler/policy.js'; diff --git a/packages/core/src/core/geminiChat.test.ts b/packages/core/src/core/geminiChat.test.ts index 770a594bdae..105d70e49f3 100644 --- a/packages/core/src/core/geminiChat.test.ts +++ b/packages/core/src/core/geminiChat.test.ts @@ -5,8 +5,12 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { Content, GenerateContentResponse } from '@google/genai'; -import { ApiError, ThinkingLevel } from '@google/genai'; +import { + ApiError, + ThinkingLevel, + type Content, + type GenerateContentResponse, +} from '@google/genai'; import type { ContentGenerator } from '../core/contentGenerator.js'; import { GeminiChat, diff --git a/packages/core/src/core/geminiChat.ts b/packages/core/src/core/geminiChat.ts index 789ea73ff19..87d0c235f40 100644 --- a/packages/core/src/core/geminiChat.ts +++ b/packages/core/src/core/geminiChat.ts @@ -7,17 +7,18 @@ // DISCLAIMER: This is a copied version of https://github.com/googleapis/js-genai/blob/main/src/chats.ts with the intention of working around a key bug // where function responses are not treated as "valid" responses: https://b.corp.google.com/issues/420354090 -import type { - GenerateContentResponse, - Content, - Part, - Tool, - PartListUnion, - GenerateContentConfig, - GenerateContentParameters, +import { + createUserContent, + FinishReason, + type GenerateContentResponse, + type Content, + type Part, + type Tool, + type PartListUnion, + type GenerateContentConfig, + type GenerateContentParameters, } from '@google/genai'; import { toParts } from '../code_assist/converter.js'; -import { createUserContent, FinishReason } from '@google/genai'; import { retryWithBackoff, isRetryableError } from '../utils/retry.js'; import type { ValidationRequiredError } from '../utils/googleQuotaErrors.js'; import type { Config } from '../config/config.js'; @@ -40,6 +41,7 @@ import { import { ContentRetryEvent, ContentRetryFailureEvent, + type LlmRole, } from '../telemetry/types.js'; import { handleFallback } from '../fallback/handler.js'; import { isFunctionResponse } from '../utils/messageInspectors.js'; @@ -51,7 +53,6 @@ import { createAvailabilityContextProvider, } from '../availability/policyHelpers.js'; import { coreEvents } from '../utils/events.js'; -import type { LlmRole } from '../telemetry/types.js'; export enum StreamEventType { /** A regular content chunk from the API. */ diff --git a/packages/core/src/core/geminiChat_network_retry.test.ts b/packages/core/src/core/geminiChat_network_retry.test.ts index 161cadaf521..1a73b236a21 100644 --- a/packages/core/src/core/geminiChat_network_retry.test.ts +++ b/packages/core/src/core/geminiChat_network_retry.test.ts @@ -5,8 +5,7 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { GenerateContentResponse } from '@google/genai'; -import { ApiError } from '@google/genai'; +import { ApiError, type GenerateContentResponse } from '@google/genai'; import type { ContentGenerator } from '../core/contentGenerator.js'; import { GeminiChat, StreamEventType, type StreamEvent } from './geminiChat.js'; import type { Config } from '../config/config.js'; diff --git a/packages/core/src/core/localLiteRtLmClient.ts b/packages/core/src/core/localLiteRtLmClient.ts index 8f4a020a507..798dcb57656 100644 --- a/packages/core/src/core/localLiteRtLmClient.ts +++ b/packages/core/src/core/localLiteRtLmClient.ts @@ -4,10 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { GoogleGenAI } from '@google/genai'; +import { GoogleGenAI, type Content } from '@google/genai'; import type { Config } from '../config/config.js'; import { debugLogger } from '../utils/debugLogger.js'; -import type { Content } from '@google/genai'; /** * A client for making single, non-streaming calls to a local Gemini-compatible API diff --git a/packages/core/src/core/logger.test.ts b/packages/core/src/core/logger.test.ts index 498aa85ca17..a479654233c 100644 --- a/packages/core/src/core/logger.test.ts +++ b/packages/core/src/core/logger.test.ts @@ -13,12 +13,12 @@ import { afterEach, afterAll, } from 'vitest'; -import type { LogEntry } from './logger.js'; import { Logger, MessageSenderType, encodeTagName, decodeTagName, + type LogEntry, } from './logger.js'; import { AuthType } from './contentGenerator.js'; import { Storage } from '../config/storage.js'; diff --git a/packages/core/src/core/loggingContentGenerator.ts b/packages/core/src/core/loggingContentGenerator.ts index 23416a5202a..60144740c24 100644 --- a/packages/core/src/core/loggingContentGenerator.ts +++ b/packages/core/src/core/loggingContentGenerator.ts @@ -16,11 +16,12 @@ import type { GenerateContentResponseUsageMetadata, GenerateContentResponse, } from '@google/genai'; -import type { ServerDetails, ContextBreakdown } from '../telemetry/types.js'; import { ApiRequestEvent, ApiResponseEvent, ApiErrorEvent, + type ServerDetails, + type ContextBreakdown, } from '../telemetry/types.js'; import type { LlmRole } from '../telemetry/llmRole.js'; import type { Config } from '../config/config.js'; diff --git a/packages/core/src/core/turn.test.ts b/packages/core/src/core/turn.test.ts index 6634f6f4c81..435323f73d9 100644 --- a/packages/core/src/core/turn.test.ts +++ b/packages/core/src/core/turn.test.ts @@ -5,15 +5,19 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { - ServerGeminiToolCallRequestEvent, - ServerGeminiErrorEvent, +import { + Turn, + GeminiEventType, + type ServerGeminiToolCallRequestEvent, + type ServerGeminiErrorEvent, } from './turn.js'; -import { Turn, GeminiEventType } from './turn.js'; import type { GenerateContentResponse, Part, Content } from '@google/genai'; import { reportError } from '../utils/errorReporting.js'; -import type { GeminiChat } from './geminiChat.js'; -import { InvalidStreamError, StreamEventType } from './geminiChat.js'; +import { + InvalidStreamError, + StreamEventType, + type GeminiChat, +} from './geminiChat.js'; import { LlmRole } from '../telemetry/types.js'; const mockSendMessageStream = vi.fn(); diff --git a/packages/core/src/core/turn.ts b/packages/core/src/core/turn.ts index 23b55afe297..4fd6af2185b 100644 --- a/packages/core/src/core/turn.ts +++ b/packages/core/src/core/turn.ts @@ -4,13 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - PartListUnion, - GenerateContentResponse, - FunctionCall, - FunctionDeclaration, - FinishReason, - GenerateContentResponseUsageMetadata, +import { + createUserContent, + type PartListUnion, + type GenerateContentResponse, + type FunctionCall, + type FunctionDeclaration, + type FinishReason, + type GenerateContentResponseUsageMetadata, } from '@google/genai'; import type { ToolCallConfirmationDetails, @@ -23,10 +24,8 @@ import { UnauthorizedError, toFriendlyError, } from '../utils/errors.js'; -import type { GeminiChat } from './geminiChat.js'; -import { InvalidStreamError } from './geminiChat.js'; +import { InvalidStreamError, type GeminiChat } from './geminiChat.js'; import { parseThought, type ThoughtSummary } from '../utils/thoughtUtils.js'; -import { createUserContent } from '@google/genai'; import type { ModelConfigKey } from '../services/modelConfigService.js'; import { getCitations } from '../utils/generateContentResponseUtilities.js'; import { LlmRole } from '../telemetry/types.js'; From e78daf9ee1f131c2b87036be6498cc7c27445845 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:53:18 +0530 Subject: [PATCH 02/14] fix: merge duplicate imports in config/ directory --- packages/core/src/config/config.test.ts | 32 +++++++++++++++++-------- packages/core/src/config/config.ts | 32 +++++++++++++------------ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts index 83ee54f8e0f..f5375a169a5 100644 --- a/packages/core/src/config/config.test.ts +++ b/packages/core/src/config/config.test.ts @@ -4,16 +4,30 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { Mock } from 'vitest'; -import type { ConfigParameters, SandboxConfig } from './config.js'; -import { Config, DEFAULT_FILE_FILTERING_OPTIONS } from './config.js'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; +import { + Config, + DEFAULT_FILE_FILTERING_OPTIONS, + type ConfigParameters, + type SandboxConfig, +} from './config.js'; import { DEFAULT_MAX_ATTEMPTS } from '../utils/retry.js'; import { ExperimentFlags } from '../code_assist/experiments/flagNames.js'; import { debugLogger } from '../utils/debugLogger.js'; import { ApprovalMode } from '../policy/types.js'; -import type { HookDefinition } from '../hooks/types.js'; -import { HookType, HookEventName } from '../hooks/types.js'; +import { + HookType, + HookEventName, + type HookDefinition, +} from '../hooks/types.js'; import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; import * as path from 'node:path'; import * as fs from 'node:fs'; @@ -23,14 +37,12 @@ import { DEFAULT_OTLP_ENDPOINT, uiTelemetryService, } from '../telemetry/index.js'; -import type { - ContentGeneratorConfig, - ContentGenerator, -} from '../core/contentGenerator.js'; import { AuthType, createContentGenerator, createContentGeneratorConfig, + type ContentGeneratorConfig, + type ContentGenerator, } from '../core/contentGenerator.js'; import { GeminiClient } from '../core/client.js'; import { GitService } from '../services/gitService.js'; diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 1a5c14b12c8..51f5fc5f468 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -9,16 +9,14 @@ import * as path from 'node:path'; import * as os from 'node:os'; import { inspect } from 'node:util'; import process from 'node:process'; -import type { - ContentGenerator, - ContentGeneratorConfig, -} from '../core/contentGenerator.js'; -import type { OverageStrategy } from '../billing/billing.js'; import { AuthType, createContentGenerator, createContentGeneratorConfig, + type ContentGenerator, + type ContentGeneratorConfig, } from '../core/contentGenerator.js'; +import type { OverageStrategy } from '../billing/billing.js'; import { PromptRegistry } from '../prompts/prompt-registry.js'; import { ResourceRegistry } from '../resources/resource-registry.js'; import { ToolRegistry } from '../tools/tool-registry.js'; @@ -43,12 +41,12 @@ import { LocalLiteRtLmClient } from '../core/localLiteRtLmClient.js'; import type { HookDefinition, HookEventName } from '../hooks/types.js'; import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; import { GitService } from '../services/gitService.js'; -import type { TelemetryTarget } from '../telemetry/index.js'; import { initializeTelemetry, DEFAULT_TELEMETRY_TARGET, DEFAULT_OTLP_ENDPOINT, uiTelemetryService, + type TelemetryTarget, } from '../telemetry/index.js'; import { coreEvents, CoreEvent } from '../utils/events.js'; import { tokenLimit } from '../core/tokenLimits.js'; @@ -68,8 +66,10 @@ import { shouldAttemptBrowserLaunch } from '../utils/browser.js'; import type { MCPOAuthConfig } from '../mcp/oauth-provider.js'; import { ideContextStore } from '../ide/ideContext.js'; import { WriteTodosTool } from '../tools/write-todos.js'; -import type { FileSystemService } from '../services/fileSystemService.js'; -import { StandardFileSystemService } from '../services/fileSystemService.js'; +import { + StandardFileSystemService, + type FileSystemService, +} from '../services/fileSystemService.js'; import { logRipgrepFallback, logFlashFallback, @@ -89,11 +89,11 @@ import type { import { ModelAvailabilityService } from '../availability/modelAvailabilityService.js'; import { ModelRouterService } from '../routing/modelRouterService.js'; import { OutputFormat } from '../output/types.js'; -import type { - ModelConfig, - ModelConfigServiceConfig, +import { + ModelConfigService, + type ModelConfig, + type ModelConfigServiceConfig, } from '../services/modelConfigService.js'; -import { ModelConfigService } from '../services/modelConfigService.js'; import { DEFAULT_MODEL_CONFIGS } from './defaultModelConfigs.js'; import { ContextManager } from '../services/contextManager.js'; import type { GenerateContentParameters } from '@google/genai'; @@ -123,12 +123,14 @@ import type { } from '../code_assist/types.js'; import type { HierarchicalMemory } from './memory.js'; import { getCodeAssistServer } from '../code_assist/codeAssist.js'; -import type { Experiments } from '../code_assist/experiments/experiments.js'; +import { + getExperiments, + type Experiments, +} from '../code_assist/experiments/experiments.js'; import { AgentRegistry } from '../agents/registry.js'; import { AcknowledgedAgentsService } from '../agents/acknowledgedAgents.js'; import { setGlobalProxy } from '../utils/fetch.js'; import { SubagentTool } from '../agents/subagent-tool.js'; -import { getExperiments } from '../code_assist/experiments/experiments.js'; import { ExperimentFlags } from '../code_assist/experiments/flagNames.js'; import { debugLogger } from '../utils/debugLogger.js'; import { SkillManager, type SkillDefinition } from '../skills/skillManager.js'; @@ -351,10 +353,10 @@ export interface ExtensionInstallMetadata { } import { DEFAULT_MAX_ATTEMPTS } from '../utils/retry.js'; -import type { FileFilteringOptions } from './constants.js'; import { DEFAULT_FILE_FILTERING_OPTIONS, DEFAULT_MEMORY_FILE_FILTERING_OPTIONS, + type FileFilteringOptions, } from './constants.js'; import { DEFAULT_TOOL_PROTECTION_THRESHOLD, From 38fd021bf7683f4f898ae8f6f3bdc69fc9537363 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:53:33 +0530 Subject: [PATCH 03/14] fix: merge duplicate imports in tools/ directory --- packages/core/src/tools/activate-skill.ts | 14 ++++---- packages/core/src/tools/glob.test.ts | 8 +++-- packages/core/src/tools/glob.ts | 9 +++-- packages/core/src/tools/grep.test.ts | 3 +- packages/core/src/tools/grep.ts | 9 +++-- packages/core/src/tools/ls.ts | 9 +++-- packages/core/src/tools/mcp-client.ts | 34 ++++++++++--------- packages/core/src/tools/mcp-tool.test.ts | 14 +++++--- packages/core/src/tools/mcp-tool.ts | 12 +++---- packages/core/src/tools/memoryTool.test.ts | 11 ++++-- packages/core/src/tools/memoryTool.ts | 3 +- .../core/src/tools/modifiable-tool.test.ts | 6 ++-- packages/core/src/tools/modifiable-tool.ts | 3 +- packages/core/src/tools/read-file.test.ts | 3 +- packages/core/src/tools/read-file.ts | 10 ++++-- .../core/src/tools/read-many-files.test.ts | 11 ++++-- packages/core/src/tools/read-many-files.ts | 11 ++++-- packages/core/src/tools/ripGrep.test.ts | 11 +++--- packages/core/src/tools/ripGrep.ts | 9 +++-- packages/core/src/tools/shell.test.ts | 3 +- packages/core/src/tools/shell.ts | 26 +++++++------- packages/core/src/tools/tool-registry.test.ts | 22 ++++++++---- packages/core/src/tools/tool-registry.ts | 12 ++++--- packages/core/src/tools/tools.test.ts | 9 +++-- packages/core/src/tools/web-fetch.ts | 14 ++++---- packages/core/src/tools/web-search.test.ts | 14 +++++--- packages/core/src/tools/web-search.ts | 9 +++-- packages/core/src/tools/write-file.test.ts | 22 ++++++------ packages/core/src/tools/write-file.ts | 20 ++++++----- packages/core/src/tools/write-todos.ts | 10 ++++-- 30 files changed, 222 insertions(+), 129 deletions(-) diff --git a/packages/core/src/tools/activate-skill.ts b/packages/core/src/tools/activate-skill.ts index cf6a33f3e6d..21ee2e98c69 100644 --- a/packages/core/src/tools/activate-skill.ts +++ b/packages/core/src/tools/activate-skill.ts @@ -7,13 +7,15 @@ import * as path from 'node:path'; import { getFolderStructure } from '../utils/getFolderStructure.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; -import type { - ToolResult, - ToolCallConfirmationDetails, - ToolInvocation, - ToolConfirmationOutcome, +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolResult, + type ToolCallConfirmationDetails, + type ToolInvocation, + type ToolConfirmationOutcome, } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; import type { Config } from '../config/config.js'; import { ACTIVATE_SKILL_TOOL_NAME } from './tool-names.js'; import { ToolErrorType } from './tool-error.js'; diff --git a/packages/core/src/tools/glob.test.ts b/packages/core/src/tools/glob.test.ts index 2aa4d52c7ed..f3390f5d3cc 100644 --- a/packages/core/src/tools/glob.test.ts +++ b/packages/core/src/tools/glob.test.ts @@ -4,8 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { GlobToolParams, GlobPath } from './glob.js'; -import { GlobTool, sortFileEntries } from './glob.js'; +import { + GlobTool, + sortFileEntries, + type GlobToolParams, + type GlobPath, +} from './glob.js'; import { partListUnionToString } from '../core/geminiRequest.js'; import path from 'node:path'; import { isSubpath } from '../utils/paths.js'; diff --git a/packages/core/src/tools/glob.ts b/packages/core/src/tools/glob.ts index 78b445e7624..c2f3c4ab544 100644 --- a/packages/core/src/tools/glob.ts +++ b/packages/core/src/tools/glob.ts @@ -8,8 +8,13 @@ import type { MessageBus } from '../confirmation-bus/message-bus.js'; import fs from 'node:fs'; import path from 'node:path'; import { glob, escape } from 'glob'; -import type { ToolInvocation, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { shortenPath, makeRelative } from '../utils/paths.js'; import { type Config } from '../config/config.js'; import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js'; diff --git a/packages/core/src/tools/grep.test.ts b/packages/core/src/tools/grep.test.ts index 6f98b0f2fc4..508ae7775b8 100644 --- a/packages/core/src/tools/grep.test.ts +++ b/packages/core/src/tools/grep.test.ts @@ -5,8 +5,7 @@ */ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; -import type { GrepToolParams } from './grep.js'; -import { GrepTool } from './grep.js'; +import { GrepTool, type GrepToolParams } from './grep.js'; import type { ToolResult } from './tools.js'; import path from 'node:path'; import { isSubpath } from '../utils/paths.js'; diff --git a/packages/core/src/tools/grep.ts b/packages/core/src/tools/grep.ts index 3d745215137..c7e676951a1 100644 --- a/packages/core/src/tools/grep.ts +++ b/packages/core/src/tools/grep.ts @@ -10,13 +10,18 @@ import fsPromises from 'node:fs/promises'; import path from 'node:path'; import { spawn } from 'node:child_process'; import { globStream } from 'glob'; -import type { ToolInvocation, ToolResult } from './tools.js'; import { execStreaming } from '../utils/shell-utils.js'; import { DEFAULT_TOTAL_MAX_MATCHES, DEFAULT_SEARCH_TIMEOUT_MS, } from './constants.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import { getErrorMessage, isNodeError } from '../utils/errors.js'; import { isGitRepository } from '../utils/gitUtils.js'; diff --git a/packages/core/src/tools/ls.ts b/packages/core/src/tools/ls.ts index b98dfb9e388..9456f8ffc90 100644 --- a/packages/core/src/tools/ls.ts +++ b/packages/core/src/tools/ls.ts @@ -7,8 +7,13 @@ import type { MessageBus } from '../confirmation-bus/message-bus.js'; import fs from 'node:fs/promises'; import path from 'node:path'; -import type { ToolInvocation, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import type { Config } from '../config/config.js'; import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js'; diff --git a/packages/core/src/tools/mcp-client.ts b/packages/core/src/tools/mcp-client.ts index 24f93052bf8..6e0d1066de7 100644 --- a/packages/core/src/tools/mcp-client.ts +++ b/packages/core/src/tools/mcp-client.ts @@ -11,19 +11,16 @@ import type { JsonSchemaType, JsonSchemaValidator, } from '@modelcontextprotocol/sdk/validation/types.js'; -import type { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js'; -import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'; +import { + SSEClientTransport, + type SSEClientTransportOptions, +} from '@modelcontextprotocol/sdk/client/sse.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; -import type { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; -import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; +import { + StreamableHTTPClientTransport, + type StreamableHTTPClientTransportOptions, +} from '@modelcontextprotocol/sdk/client/streamableHttp.js'; import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'; -import type { - GetPromptResult, - Prompt, - ReadResourceResult, - Resource, - Tool as McpTool, -} from '@modelcontextprotocol/sdk/types.js'; import { ListResourcesResultSchema, ListRootsRequestSchema, @@ -32,14 +29,19 @@ import { ToolListChangedNotificationSchema, PromptListChangedNotificationSchema, ProgressNotificationSchema, + type GetPromptResult, + type Prompt, + type ReadResourceResult, + type Resource, + type Tool as McpTool, } from '@modelcontextprotocol/sdk/types.js'; import { parse } from 'shell-quote'; -import type { - Config, - MCPServerConfig, - GeminiCLIExtension, +import { + AuthProviderType, + type Config, + type MCPServerConfig, + type GeminiCLIExtension, } from '../config/config.js'; -import { AuthProviderType } from '../config/config.js'; import { GoogleCredentialProvider } from '../mcp/google-auth-provider.js'; import { ServiceAccountImpersonationProvider } from '../mcp/sa-impersonation-provider.js'; import { DiscoveredMCPTool } from './mcp-tool.js'; diff --git a/packages/core/src/tools/mcp-tool.test.ts b/packages/core/src/tools/mcp-tool.test.ts index 4cdad898274..bfa126b2af2 100644 --- a/packages/core/src/tools/mcp-tool.test.ts +++ b/packages/core/src/tools/mcp-tool.test.ts @@ -5,12 +5,18 @@ */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { Mocked } from 'vitest'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mocked, +} from 'vitest'; import { safeJsonStringify } from '../utils/safeJsonStringify.js'; import { DiscoveredMCPTool, generateValidName } from './mcp-tool.js'; // Added getStringifiedResultForDisplay -import type { ToolResult } from './tools.js'; -import { ToolConfirmationOutcome } from './tools.js'; // Added ToolConfirmationOutcome +import { ToolConfirmationOutcome, type ToolResult } from './tools.js'; import type { CallableTool, Part } from '@google/genai'; import { ToolErrorType } from './tool-error.js'; import { diff --git a/packages/core/src/tools/mcp-tool.ts b/packages/core/src/tools/mcp-tool.ts index 3d492457f24..475c87a6f27 100644 --- a/packages/core/src/tools/mcp-tool.ts +++ b/packages/core/src/tools/mcp-tool.ts @@ -5,18 +5,16 @@ */ import { safeJsonStringify } from '../utils/safeJsonStringify.js'; -import type { - ToolCallConfirmationDetails, - ToolInvocation, - ToolMcpConfirmationDetails, - ToolResult, - PolicyUpdateOptions, -} from './tools.js'; import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, + type ToolCallConfirmationDetails, + type ToolInvocation, + type ToolMcpConfirmationDetails, + type ToolResult, + type PolicyUpdateOptions, } from './tools.js'; import type { CallableTool, FunctionCall, Part } from '@google/genai'; import { ToolErrorType } from './tool-error.js'; diff --git a/packages/core/src/tools/memoryTool.test.ts b/packages/core/src/tools/memoryTool.test.ts index 12cb8baa2e5..4b0aa1b6167 100644 --- a/packages/core/src/tools/memoryTool.test.ts +++ b/packages/core/src/tools/memoryTool.test.ts @@ -4,8 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; +import { + vi, + describe, + it, + expect, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import { MemoryTool, setGeminiMdFilename, diff --git a/packages/core/src/tools/memoryTool.ts b/packages/core/src/tools/memoryTool.ts index 33cb9483e18..68a0942a536 100644 --- a/packages/core/src/tools/memoryTool.ts +++ b/packages/core/src/tools/memoryTool.ts @@ -4,12 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { ToolEditConfirmationDetails, ToolResult } from './tools.js'; import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, + type ToolEditConfirmationDetails, + type ToolResult, } from './tools.js'; import * as fs from 'node:fs/promises'; import * as path from 'node:path'; diff --git a/packages/core/src/tools/modifiable-tool.test.ts b/packages/core/src/tools/modifiable-tool.test.ts index 4f34b20b57c..6ff9126478b 100644 --- a/packages/core/src/tools/modifiable-tool.test.ts +++ b/packages/core/src/tools/modifiable-tool.test.ts @@ -5,13 +5,11 @@ */ import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; -import type { - ModifyContext, - ModifiableDeclarativeTool, -} from './modifiable-tool.js'; import { modifyWithEditor, isModifiableDeclarativeTool, + type ModifyContext, + type ModifiableDeclarativeTool, } from './modifiable-tool.js'; import { DEFAULT_GUI_EDITOR } from '../utils/editor.js'; import fs from 'node:fs'; diff --git a/packages/core/src/tools/modifiable-tool.ts b/packages/core/src/tools/modifiable-tool.ts index 328158bb780..69abeacb828 100644 --- a/packages/core/src/tools/modifiable-tool.ts +++ b/packages/core/src/tools/modifiable-tool.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { EditorType } from '../utils/editor.js'; -import { openDiff } from '../utils/editor.js'; +import { openDiff, type EditorType } from '../utils/editor.js'; import os from 'node:os'; import path from 'node:path'; import fs from 'node:fs'; diff --git a/packages/core/src/tools/read-file.test.ts b/packages/core/src/tools/read-file.test.ts index 8f79bffe17b..6b82a152a60 100644 --- a/packages/core/src/tools/read-file.test.ts +++ b/packages/core/src/tools/read-file.test.ts @@ -5,8 +5,7 @@ */ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; -import type { ReadFileToolParams } from './read-file.js'; -import { ReadFileTool } from './read-file.js'; +import { ReadFileTool, type ReadFileToolParams } from './read-file.js'; import { ToolErrorType } from './tool-error.js'; import path from 'node:path'; import { isSubpath } from '../utils/paths.js'; diff --git a/packages/core/src/tools/read-file.ts b/packages/core/src/tools/read-file.ts index 170cccf9056..0f044a4998f 100644 --- a/packages/core/src/tools/read-file.ts +++ b/packages/core/src/tools/read-file.ts @@ -7,8 +7,14 @@ import type { MessageBus } from '../confirmation-bus/message-bus.js'; import path from 'node:path'; import { makeRelative, shortenPath } from '../utils/paths.js'; -import type { ToolInvocation, ToolLocation, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolLocation, + type ToolResult, +} from './tools.js'; import { ToolErrorType } from './tool-error.js'; import type { PartUnion } from '@google/genai'; diff --git a/packages/core/src/tools/read-many-files.test.ts b/packages/core/src/tools/read-many-files.test.ts index f340424a35f..875ccf0bd5a 100644 --- a/packages/core/src/tools/read-many-files.test.ts +++ b/packages/core/src/tools/read-many-files.test.ts @@ -4,8 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; -import type { Mock } from 'vitest'; +import { + vi, + describe, + it, + expect, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import { mockControl } from '../__mocks__/fs/promises.js'; import { ReadManyFilesTool } from './read-many-files.js'; import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; diff --git a/packages/core/src/tools/read-many-files.ts b/packages/core/src/tools/read-many-files.ts index 0a5d68a6ba5..c9c4e230e6f 100644 --- a/packages/core/src/tools/read-many-files.ts +++ b/packages/core/src/tools/read-many-files.ts @@ -5,18 +5,23 @@ */ import type { MessageBus } from '../confirmation-bus/message-bus.js'; -import type { ToolInvocation, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { getErrorMessage } from '../utils/errors.js'; import * as fsPromises from 'node:fs/promises'; import * as path from 'node:path'; import { glob, escape } from 'glob'; -import type { ProcessedFileReadResult } from '../utils/fileUtils.js'; import { detectFileType, processSingleFileContent, DEFAULT_ENCODING, getSpecificMimeType, + type ProcessedFileReadResult, } from '../utils/fileUtils.js'; import type { PartListUnion } from '@google/genai'; import { diff --git a/packages/core/src/tools/ripGrep.test.ts b/packages/core/src/tools/ripGrep.test.ts index 0eaf5c0b689..265bb8e53c0 100644 --- a/packages/core/src/tools/ripGrep.test.ts +++ b/packages/core/src/tools/ripGrep.test.ts @@ -13,8 +13,12 @@ import { afterAll, vi, } from 'vitest'; -import type { RipGrepToolParams } from './ripGrep.js'; -import { canUseRipgrep, RipGrepTool, ensureRgPath } from './ripGrep.js'; +import { + canUseRipgrep, + RipGrepTool, + ensureRgPath, + type RipGrepToolParams, +} from './ripGrep.js'; import path from 'node:path'; import { isSubpath } from '../utils/paths.js'; import fs from 'node:fs/promises'; @@ -23,8 +27,7 @@ import type { Config } from '../config/config.js'; import { Storage } from '../config/storage.js'; import { GEMINI_IGNORE_FILE_NAME } from '../config/constants.js'; import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.js'; -import type { ChildProcess } from 'node:child_process'; -import { spawn } from 'node:child_process'; +import { spawn, type ChildProcess } from 'node:child_process'; import { PassThrough, Readable } from 'node:stream'; import EventEmitter from 'node:events'; import { downloadRipGrep } from '@joshua.litt/get-ripgrep'; diff --git a/packages/core/src/tools/ripGrep.ts b/packages/core/src/tools/ripGrep.ts index ac65cf63621..000b4f0071a 100644 --- a/packages/core/src/tools/ripGrep.ts +++ b/packages/core/src/tools/ripGrep.ts @@ -9,8 +9,13 @@ import fs from 'node:fs'; import fsPromises from 'node:fs/promises'; import path from 'node:path'; import { downloadRipGrep } from '@joshua.litt/get-ripgrep'; -import type { ToolInvocation, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import { getErrorMessage, isNodeError } from '../utils/errors.js'; diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts index 907d1174391..d3e47de17f5 100644 --- a/packages/core/src/tools/shell.test.ts +++ b/packages/core/src/tools/shell.test.ts @@ -51,7 +51,6 @@ import { } from '../services/shellExecutionService.js'; import * as fs from 'node:fs'; import * as os from 'node:os'; -import { EOL } from 'node:os'; import * as path from 'node:path'; import { isSubpath } from '../utils/paths.js'; import * as crypto from 'node:crypto'; @@ -264,7 +263,7 @@ describe('ShellTool', () => { // Simulate pgrep output file creation by the shell command const tmpFile = path.join(os.tmpdir(), 'shell_pgrep_abcdef.tmp'); - fs.writeFileSync(tmpFile, `54321${EOL}54322${EOL}`); + fs.writeFileSync(tmpFile, `54321${os.EOL}54322${os.EOL}`); const result = await promise; diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index 6afded3faa2..351557c7784 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -6,33 +6,31 @@ import fsPromises from 'node:fs/promises'; import path from 'node:path'; -import os, { EOL } from 'node:os'; +import os from 'node:os'; import crypto from 'node:crypto'; import type { Config } from '../config/config.js'; import { debugLogger } from '../index.js'; import { ToolErrorType } from './tool-error.js'; -import type { - ToolInvocation, - ToolResult, - ToolCallConfirmationDetails, - ToolExecuteConfirmationDetails, - PolicyUpdateOptions, - ToolLiveOutput, -} from './tools.js'; import { BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, + type ToolInvocation, + type ToolResult, + type ToolCallConfirmationDetails, + type ToolExecuteConfirmationDetails, + type PolicyUpdateOptions, + type ToolLiveOutput, } from './tools.js'; import { getErrorMessage } from '../utils/errors.js'; import { summarizeToolOutput } from '../utils/summarizer.js'; -import type { - ShellExecutionConfig, - ShellOutputEvent, +import { + ShellExecutionService, + type ShellExecutionConfig, + type ShellOutputEvent, } from '../services/shellExecutionService.js'; -import { ShellExecutionService } from '../services/shellExecutionService.js'; import { formatBytes } from '../utils/formatters.js'; import type { AnsiOutput } from '../utils/terminalSerializer.js'; import { @@ -309,7 +307,7 @@ export class ShellToolInvocation extends BaseToolInvocation< if (tempFileExists) { const pgrepContent = await fsPromises.readFile(tempFilePath, 'utf8'); - const pgrepLines = pgrepContent.split(EOL).filter(Boolean); + const pgrepLines = pgrepContent.split(os.EOL).filter(Boolean); for (const line of pgrepLines) { if (!/^\d+$/.test(line)) { debugLogger.error(`pgrep: ${line}`); diff --git a/packages/core/src/tools/tool-registry.test.ts b/packages/core/src/tools/tool-registry.test.ts index d44c1337057..eab05294d07 100644 --- a/packages/core/src/tools/tool-registry.test.ts +++ b/packages/core/src/tools/tool-registry.test.ts @@ -5,17 +5,27 @@ */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { Mocked, MockInstance } from 'vitest'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { ConfigParameters } from '../config/config.js'; -import { Config } from '../config/config.js'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mocked, + type MockInstance, +} from 'vitest'; +import { Config, type ConfigParameters } from '../config/config.js'; import { ApprovalMode } from '../policy/types.js'; import { ToolRegistry, DiscoveredTool } from './tool-registry.js'; import { DISCOVERED_TOOL_PREFIX } from './tool-names.js'; import { DiscoveredMCPTool, MCP_QUALIFIED_NAME_SEPARATOR } from './mcp-tool.js'; -import type { FunctionDeclaration, CallableTool } from '@google/genai'; -import { mcpToTool } from '@google/genai'; +import { + mcpToTool, + type FunctionDeclaration, + type CallableTool, +} from '@google/genai'; import { spawn } from 'node:child_process'; import fs from 'node:fs'; diff --git a/packages/core/src/tools/tool-registry.ts b/packages/core/src/tools/tool-registry.ts index e7fd7a6a66c..bdd8c7d4036 100644 --- a/packages/core/src/tools/tool-registry.ts +++ b/packages/core/src/tools/tool-registry.ts @@ -5,12 +5,14 @@ */ import type { FunctionDeclaration } from '@google/genai'; -import type { - AnyDeclarativeTool, - ToolResult, - ToolInvocation, +import { + Kind, + BaseDeclarativeTool, + BaseToolInvocation, + type AnyDeclarativeTool, + type ToolResult, + type ToolInvocation, } from './tools.js'; -import { Kind, BaseDeclarativeTool, BaseToolInvocation } from './tools.js'; import type { Config } from '../config/config.js'; import { ApprovalMode } from '../policy/types.js'; import { spawn } from 'node:child_process'; diff --git a/packages/core/src/tools/tools.test.ts b/packages/core/src/tools/tools.test.ts index 41edf9f21dc..edbc4871607 100644 --- a/packages/core/src/tools/tools.test.ts +++ b/packages/core/src/tools/tools.test.ts @@ -5,8 +5,13 @@ */ import { describe, it, expect, vi } from 'vitest'; -import type { ToolInvocation, ToolResult } from './tools.js'; -import { DeclarativeTool, hasCycleInSchema, Kind } from './tools.js'; +import { + DeclarativeTool, + hasCycleInSchema, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { createMockMessageBus } from '../test-utils/mock-message-bus.js'; import { ReadFileTool } from './read-file.js'; diff --git a/packages/core/src/tools/web-fetch.ts b/packages/core/src/tools/web-fetch.ts index 55d2474c1c3..3170227188d 100644 --- a/packages/core/src/tools/web-fetch.ts +++ b/packages/core/src/tools/web-fetch.ts @@ -4,13 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ToolCallConfirmationDetails, - ToolInvocation, - ToolResult, - ToolConfirmationOutcome, +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolCallConfirmationDetails, + type ToolInvocation, + type ToolResult, + type ToolConfirmationOutcome, } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; import { ToolErrorType } from './tool-error.js'; import { getErrorMessage } from '../utils/errors.js'; diff --git a/packages/core/src/tools/web-search.test.ts b/packages/core/src/tools/web-search.test.ts index 3812a548793..bd07ce0dea6 100644 --- a/packages/core/src/tools/web-search.test.ts +++ b/packages/core/src/tools/web-search.test.ts @@ -4,10 +4,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { WebSearchToolParams } from './web-search.js'; -import { WebSearchTool } from './web-search.js'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; +import { WebSearchTool, type WebSearchToolParams } from './web-search.js'; import type { Config } from '../config/config.js'; import { GeminiClient } from '../core/client.js'; import { ToolErrorType } from './tool-error.js'; diff --git a/packages/core/src/tools/web-search.ts b/packages/core/src/tools/web-search.ts index a5ac9937b8a..2756599b287 100644 --- a/packages/core/src/tools/web-search.ts +++ b/packages/core/src/tools/web-search.ts @@ -7,8 +7,13 @@ import type { MessageBus } from '../confirmation-bus/message-bus.js'; import { WEB_SEARCH_TOOL_NAME } from './tool-names.js'; import type { GroundingMetadata } from '@google/genai'; -import type { ToolInvocation, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type ToolResult, +} from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { getErrorMessage } from '../utils/errors.js'; diff --git a/packages/core/src/tools/write-file.test.ts b/packages/core/src/tools/write-file.test.ts index 0b978f14f93..e90937bd7db 100644 --- a/packages/core/src/tools/write-file.test.ts +++ b/packages/core/src/tools/write-file.test.ts @@ -13,16 +13,19 @@ import { vi, type Mocked, } from 'vitest'; -import type { WriteFileToolParams } from './write-file.js'; -import { getCorrectedFileContent, WriteFileTool } from './write-file.js'; +import { + getCorrectedFileContent, + WriteFileTool, + type WriteFileToolParams, +} from './write-file.js'; import { ToolErrorType } from './tool-error.js'; -import type { - FileDiff, - ToolEditConfirmationDetails, - ToolInvocation, - ToolResult, +import { + ToolConfirmationOutcome, + type FileDiff, + type ToolEditConfirmationDetails, + type ToolInvocation, + type ToolResult, } from './tools.js'; -import { ToolConfirmationOutcome } from './tools.js'; import type { Config } from '../config/config.js'; import { ApprovalMode } from '../policy/types.js'; import type { ToolRegistry } from './tool-registry.js'; @@ -34,8 +37,7 @@ import { GeminiClient } from '../core/client.js'; import type { BaseLlmClient } from '../core/baseLlmClient.js'; import { ensureCorrectFileContent } from '../utils/editCorrector.js'; import { StandardFileSystemService } from '../services/fileSystemService.js'; -import type { DiffUpdateResult } from '../ide/ide-client.js'; -import { IdeClient } from '../ide/ide-client.js'; +import { IdeClient, type DiffUpdateResult } from '../ide/ide-client.js'; import { WorkspaceContext } from '../utils/workspaceContext.js'; import { createMockMessageBus, diff --git a/packages/core/src/tools/write-file.ts b/packages/core/src/tools/write-file.ts index 1c8a2300010..f78821f0e1c 100644 --- a/packages/core/src/tools/write-file.ts +++ b/packages/core/src/tools/write-file.ts @@ -13,16 +13,18 @@ import { WRITE_FILE_TOOL_NAME, WRITE_FILE_DISPLAY_NAME } from './tool-names.js'; import type { Config } from '../config/config.js'; import { ApprovalMode } from '../policy/types.js'; -import type { - FileDiff, - ToolCallConfirmationDetails, - ToolEditConfirmationDetails, - ToolInvocation, - ToolLocation, - ToolResult, - ToolConfirmationOutcome, +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type FileDiff, + type ToolCallConfirmationDetails, + type ToolEditConfirmationDetails, + type ToolInvocation, + type ToolLocation, + type ToolResult, + type ToolConfirmationOutcome, } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import { getErrorMessage, isNodeError } from '../utils/errors.js'; diff --git a/packages/core/src/tools/write-todos.ts b/packages/core/src/tools/write-todos.ts index 5eb42c73f4a..dd7ab780e6a 100644 --- a/packages/core/src/tools/write-todos.ts +++ b/packages/core/src/tools/write-todos.ts @@ -4,8 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { ToolInvocation, Todo, ToolResult } from './tools.js'; -import { BaseDeclarativeTool, BaseToolInvocation, Kind } from './tools.js'; +import { + BaseDeclarativeTool, + BaseToolInvocation, + Kind, + type ToolInvocation, + type Todo, + type ToolResult, +} from './tools.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; import { WRITE_TODOS_TOOL_NAME } from './tool-names.js'; import { WRITE_TODOS_DEFINITION } from './definitions/coreTools.js'; From 870934ee44cec3f429d7307352561cec1cd7fdfe Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:54:03 +0530 Subject: [PATCH 04/14] fix: merge duplicate imports in scheduler/ directory --- .../core/src/scheduler/confirmation.test.ts | 7 +++-- packages/core/src/scheduler/policy.test.ts | 10 +++---- packages/core/src/scheduler/scheduler.test.ts | 3 +- packages/core/src/scheduler/scheduler.ts | 3 +- .../src/scheduler/scheduler_parallel.test.ts | 14 ++++----- .../core/src/scheduler/state-manager.test.ts | 3 +- packages/core/src/scheduler/state-manager.ts | 3 +- .../core/src/scheduler/tool-executor.test.ts | 3 +- packages/core/src/scheduler/tool-executor.ts | 30 +++++++++---------- .../core/src/scheduler/tool-modifier.test.ts | 12 ++++---- 10 files changed, 46 insertions(+), 42 deletions(-) diff --git a/packages/core/src/scheduler/confirmation.test.ts b/packages/core/src/scheduler/confirmation.test.ts index e9e55e807d0..abd07ba86ef 100644 --- a/packages/core/src/scheduler/confirmation.test.ts +++ b/packages/core/src/scheduler/confirmation.test.ts @@ -28,8 +28,11 @@ import { } from '../tools/tools.js'; import type { SchedulerStateManager } from './state-manager.js'; import type { ToolModificationHandler } from './tool-modifier.js'; -import type { ValidatingToolCall, WaitingToolCall } from './types.js'; -import { ROOT_SCHEDULER_ID } from './types.js'; +import { + ROOT_SCHEDULER_ID, + type ValidatingToolCall, + type WaitingToolCall, +} from './types.js'; import type { Config } from '../config/config.js'; import { type EditorType } from '../utils/editor.js'; import { randomUUID } from 'node:crypto'; diff --git a/packages/core/src/scheduler/policy.test.ts b/packages/core/src/scheduler/policy.test.ts index be79b7c62d8..05f5b08a2f7 100644 --- a/packages/core/src/scheduler/policy.test.ts +++ b/packages/core/src/scheduler/policy.test.ts @@ -25,16 +25,16 @@ import { type ToolExecuteConfirmationDetails, type AnyToolInvocation, } from '../tools/tools.js'; -import type { - ValidatingToolCall, - ToolCallRequestInfo, - CompletedToolCall, +import { + ROOT_SCHEDULER_ID, + type ValidatingToolCall, + type ToolCallRequestInfo, + type CompletedToolCall, } from './types.js'; import type { PolicyEngine } from '../policy/policy-engine.js'; import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; import { CoreToolScheduler } from '../core/coreToolScheduler.js'; import { Scheduler } from './scheduler.js'; -import { ROOT_SCHEDULER_ID } from './types.js'; import { ToolErrorType } from '../tools/tool-error.js'; import type { ToolRegistry } from '../tools/tool-registry.js'; diff --git a/packages/core/src/scheduler/scheduler.test.ts b/packages/core/src/scheduler/scheduler.test.ts index b2c1adade07..912e56d1570 100644 --- a/packages/core/src/scheduler/scheduler.test.ts +++ b/packages/core/src/scheduler/scheduler.test.ts @@ -86,8 +86,9 @@ import type { ExecutingToolCall, Status, ToolCall, + CoreToolCallStatus, + ROOT_SCHEDULER_ID, } from './types.js'; -import { CoreToolCallStatus, ROOT_SCHEDULER_ID } from './types.js'; import { ToolErrorType } from '../tools/tool-error.js'; import { GeminiCliOperation } from '../telemetry/constants.js'; import * as ToolUtils from '../utils/tool-utils.js'; diff --git a/packages/core/src/scheduler/scheduler.ts b/packages/core/src/scheduler/scheduler.ts index 58e45868870..de0fb2b4a4b 100644 --- a/packages/core/src/scheduler/scheduler.ts +++ b/packages/core/src/scheduler/scheduler.ts @@ -24,8 +24,7 @@ import { type ScheduledToolCall, } from './types.js'; import { ToolErrorType } from '../tools/tool-error.js'; -import type { ApprovalMode } from '../policy/types.js'; -import { PolicyDecision } from '../policy/types.js'; +import { PolicyDecision, type ApprovalMode } from '../policy/types.js'; import { ToolConfirmationOutcome, type AnyDeclarativeTool, diff --git a/packages/core/src/scheduler/scheduler_parallel.test.ts b/packages/core/src/scheduler/scheduler_parallel.test.ts index 9633784323d..56e6e262436 100644 --- a/packages/core/src/scheduler/scheduler_parallel.test.ts +++ b/packages/core/src/scheduler/scheduler_parallel.test.ts @@ -72,14 +72,14 @@ import { type AnyToolInvocation, Kind, } from '../tools/tools.js'; -import type { - ToolCallRequestInfo, - CompletedToolCall, - SuccessfulToolCall, - Status, - ToolCall, +import { + ROOT_SCHEDULER_ID, + type ToolCallRequestInfo, + type CompletedToolCall, + type SuccessfulToolCall, + type Status, + type ToolCall, } from './types.js'; -import { ROOT_SCHEDULER_ID } from './types.js'; import { GeminiCliOperation } from '../telemetry/constants.js'; import type { EditorType } from '../utils/editor.js'; diff --git a/packages/core/src/scheduler/state-manager.test.ts b/packages/core/src/scheduler/state-manager.test.ts index b27e51de8f9..60435efeb89 100644 --- a/packages/core/src/scheduler/state-manager.test.ts +++ b/packages/core/src/scheduler/state-manager.test.ts @@ -15,8 +15,9 @@ import type { ExecutingToolCall, ToolCallRequestInfo, ToolCallResponseInfo, + CoreToolCallStatus, + ROOT_SCHEDULER_ID, } from './types.js'; -import { CoreToolCallStatus, ROOT_SCHEDULER_ID } from './types.js'; import { ToolConfirmationOutcome, type AnyDeclarativeTool, diff --git a/packages/core/src/scheduler/state-manager.ts b/packages/core/src/scheduler/state-manager.ts index b14b492e4b4..5fec3e85b88 100644 --- a/packages/core/src/scheduler/state-manager.ts +++ b/packages/core/src/scheduler/state-manager.ts @@ -16,8 +16,9 @@ import type { ValidatingToolCall, ExecutingToolCall, ToolCallResponseInfo, + CoreToolCallStatus, + ROOT_SCHEDULER_ID, } from './types.js'; -import { CoreToolCallStatus, ROOT_SCHEDULER_ID } from './types.js'; import type { ToolConfirmationOutcome, ToolResultDisplay, diff --git a/packages/core/src/scheduler/tool-executor.test.ts b/packages/core/src/scheduler/tool-executor.test.ts index d5f92806f52..b0df2aa2045 100644 --- a/packages/core/src/scheduler/tool-executor.test.ts +++ b/packages/core/src/scheduler/tool-executor.test.ts @@ -13,8 +13,7 @@ import { } from '../index.js'; import { makeFakeConfig } from '../test-utils/config.js'; import { MockTool } from '../test-utils/mock-tool.js'; -import type { ScheduledToolCall } from './types.js'; -import { CoreToolCallStatus } from './types.js'; +import { CoreToolCallStatus, type ScheduledToolCall } from './types.js'; import { SHELL_TOOL_NAME } from '../tools/tool-names.js'; import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; import type { CallableTool } from '@google/genai'; diff --git a/packages/core/src/scheduler/tool-executor.ts b/packages/core/src/scheduler/tool-executor.ts index e358c53c8b4..57c020fe4ab 100644 --- a/packages/core/src/scheduler/tool-executor.ts +++ b/packages/core/src/scheduler/tool-executor.ts @@ -4,19 +4,17 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ToolCallRequestInfo, - ToolCallResponseInfo, - ToolResult, - Config, - ToolResultDisplay, - ToolLiveOutput, -} from '../index.js'; import { ToolErrorType, ToolOutputTruncatedEvent, logToolOutputTruncated, runInDevTraceSpan, + type ToolCallRequestInfo, + type ToolCallResponseInfo, + type ToolResult, + type Config, + type ToolResultDisplay, + type ToolLiveOutput, } from '../index.js'; import { SHELL_TOOL_NAME } from '../tools/tool-names.js'; import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; @@ -27,15 +25,15 @@ import { formatTruncatedToolOutput, } from '../utils/fileUtils.js'; import { convertToFunctionResponse } from '../utils/generateContentResponseUtilities.js'; -import type { - CompletedToolCall, - ToolCall, - ExecutingToolCall, - ErroredToolCall, - SuccessfulToolCall, - CancelledToolCall, +import { + CoreToolCallStatus, + type CompletedToolCall, + type ToolCall, + type ExecutingToolCall, + type ErroredToolCall, + type SuccessfulToolCall, + type CancelledToolCall, } from './types.js'; -import { CoreToolCallStatus } from './types.js'; import { GeminiCliOperation, GEN_AI_TOOL_CALL_ID, diff --git a/packages/core/src/scheduler/tool-modifier.test.ts b/packages/core/src/scheduler/tool-modifier.test.ts index 35ff2cd79cf..98be4098c42 100644 --- a/packages/core/src/scheduler/tool-modifier.test.ts +++ b/packages/core/src/scheduler/tool-modifier.test.ts @@ -4,11 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { ToolModificationHandler } from './tool-modifier.js'; -import type { WaitingToolCall, ToolCallRequestInfo } from './types.js'; -import { CoreToolCallStatus } from './types.js'; +import { + CoreToolCallStatus, + type WaitingToolCall, + type ToolCallRequestInfo, +} from './types.js'; import * as modifiableToolModule from '../tools/modifiable-tool.js'; +import type { ModifyContext } from '../tools/modifiable-tool.js'; import * as Diff from 'diff'; import { MockModifiableTool, MockTool } from '../test-utils/mock-tool.js'; import type { @@ -16,8 +20,6 @@ import type { ToolInvocation, ToolConfirmationPayload, } from '../tools/tools.js'; -import type { ModifyContext } from '../tools/modifiable-tool.js'; -import type { Mock } from 'vitest'; // Mock the modules that export functions we need to control vi.mock('diff', () => ({ From 3a62be915bbf6e6f8484cde773de0b1efdddacc1 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:55:11 +0530 Subject: [PATCH 05/14] fix: merge duplicate imports in agents/ directory --- .../src/agents/a2a-client-manager.test.ts | 3 ++- packages/core/src/agents/agentLoader.test.ts | 7 +++-- .../core/src/agents/local-executor.test.ts | 15 +++++------ packages/core/src/agents/local-executor.ts | 24 ++++++++--------- .../core/src/agents/local-invocation.test.ts | 12 ++++----- packages/core/src/agents/remote-invocation.ts | 26 ++++++++++--------- .../core/src/agents/subagent-tool.test.ts | 14 +++++----- 7 files changed, 52 insertions(+), 49 deletions(-) diff --git a/packages/core/src/agents/a2a-client-manager.test.ts b/packages/core/src/agents/a2a-client-manager.test.ts index 58e68759fed..68189a67718 100644 --- a/packages/core/src/agents/a2a-client-manager.test.ts +++ b/packages/core/src/agents/a2a-client-manager.test.ts @@ -10,12 +10,13 @@ import { type SendMessageResult, } from './a2a-client-manager.js'; import type { AgentCard, Task } from '@a2a-js/sdk'; -import type { AuthenticationHandler, Client } from '@a2a-js/sdk/client'; import { ClientFactory, DefaultAgentCardResolver, createAuthenticatingFetchWithRetry, ClientFactoryOptions, + type AuthenticationHandler, + type Client, } from '@a2a-js/sdk/client'; import { debugLogger } from '../utils/debugLogger.js'; diff --git a/packages/core/src/agents/agentLoader.test.ts b/packages/core/src/agents/agentLoader.test.ts index 7d264ad2992..a7ef62318fe 100644 --- a/packages/core/src/agents/agentLoader.test.ts +++ b/packages/core/src/agents/agentLoader.test.ts @@ -15,8 +15,11 @@ import { AgentLoadError, } from './agentLoader.js'; import { GEMINI_MODEL_ALIAS_PRO } from '../config/models.js'; -import type { LocalAgentDefinition } from './types.js'; -import { DEFAULT_MAX_TIME_MINUTES, DEFAULT_MAX_TURNS } from './types.js'; +import { + DEFAULT_MAX_TIME_MINUTES, + DEFAULT_MAX_TURNS, + type LocalAgentDefinition, +} from './types.js'; describe('loader', () => { let tempDir: string; diff --git a/packages/core/src/agents/local-executor.test.ts b/packages/core/src/agents/local-executor.test.ts index 5fb28d0e8a2..50eb30da760 100644 --- a/packages/core/src/agents/local-executor.test.ts +++ b/packages/core/src/agents/local-executor.test.ts @@ -54,13 +54,13 @@ import { AgentFinishEvent, RecoveryAttemptEvent, } from '../telemetry/types.js'; -import type { - AgentInputs, - LocalAgentDefinition, - SubagentActivityEvent, - OutputConfig, +import { + AgentTerminateMode, + type AgentInputs, + type LocalAgentDefinition, + type SubagentActivityEvent, + type OutputConfig, } from './types.js'; -import { AgentTerminateMode } from './types.js'; import type { AnyDeclarativeTool, AnyToolInvocation } from '../tools/tools.js'; import type { ToolCallRequestInfo } from '../scheduler/types.js'; import { CompressionStatus } from '../core/turn.js'; @@ -69,8 +69,7 @@ import type { ModelConfigKey, ResolvedModelConfig, } from '../services/modelConfigService.js'; -import type { AgentRegistry } from './registry.js'; -import { getModelConfigAlias } from './registry.js'; +import { getModelConfigAlias, type AgentRegistry } from './registry.js'; import type { ModelRouterService } from '../routing/modelRouterService.js'; const { diff --git a/packages/core/src/agents/local-executor.ts b/packages/core/src/agents/local-executor.ts index 44616d29fa3..7bbecdac7c3 100644 --- a/packages/core/src/agents/local-executor.ts +++ b/packages/core/src/agents/local-executor.ts @@ -7,13 +7,13 @@ import type { Config } from '../config/config.js'; import { reportError } from '../utils/errorReporting.js'; import { GeminiChat, StreamEventType } from '../core/geminiChat.js'; -import { Type } from '@google/genai'; -import type { - Content, - Part, - FunctionCall, - FunctionDeclaration, - Schema, +import { + Type, + type Content, + type Part, + type FunctionCall, + type FunctionDeclaration, + type Schema, } from '@google/genai'; import { ToolRegistry } from '../tools/tool-registry.js'; import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; @@ -33,17 +33,15 @@ import { LlmRole, RecoveryAttemptEvent, } from '../telemetry/types.js'; -import type { - LocalAgentDefinition, - AgentInputs, - OutputObject, - SubagentActivityEvent, -} from './types.js'; import { AgentTerminateMode, DEFAULT_QUERY_STRING, DEFAULT_MAX_TURNS, DEFAULT_MAX_TIME_MINUTES, + type LocalAgentDefinition, + type AgentInputs, + type OutputObject, + type SubagentActivityEvent, } from './types.js'; import { getErrorMessage } from '../utils/errors.js'; import { templateString } from './utils.js'; diff --git a/packages/core/src/agents/local-invocation.test.ts b/packages/core/src/agents/local-invocation.test.ts index 77509881afe..c0be41442be 100644 --- a/packages/core/src/agents/local-invocation.test.ts +++ b/packages/core/src/agents/local-invocation.test.ts @@ -13,15 +13,15 @@ import { afterEach, type Mocked, } from 'vitest'; -import type { - LocalAgentDefinition, - SubagentActivityEvent, - AgentInputs, - SubagentProgress, +import { + AgentTerminateMode, + type LocalAgentDefinition, + type SubagentActivityEvent, + type AgentInputs, + type SubagentProgress, } from './types.js'; import { LocalSubagentInvocation } from './local-invocation.js'; import { LocalAgentExecutor } from './local-executor.js'; -import { AgentTerminateMode } from './types.js'; import { makeFakeConfig } from '../test-utils/config.js'; import type { Config } from '../config/config.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; diff --git a/packages/core/src/agents/remote-invocation.ts b/packages/core/src/agents/remote-invocation.ts index dad7f8167d6..a8c75ec51cb 100644 --- a/packages/core/src/agents/remote-invocation.ts +++ b/packages/core/src/agents/remote-invocation.ts @@ -4,26 +4,28 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ToolConfirmationOutcome, - ToolResult, - ToolCallConfirmationDetails, +import { + BaseToolInvocation, + type ToolConfirmationOutcome, + type ToolResult, + type ToolCallConfirmationDetails, } from '../tools/tools.js'; -import { BaseToolInvocation } from '../tools/tools.js'; -import { DEFAULT_QUERY_STRING } from './types.js'; -import type { - RemoteAgentInputs, - RemoteAgentDefinition, - AgentInputs, +import { + DEFAULT_QUERY_STRING, + type RemoteAgentInputs, + type RemoteAgentDefinition, + type AgentInputs, } from './types.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; -import { A2AClientManager } from './a2a-client-manager.js'; +import { + A2AClientManager, + type SendMessageResult, +} from './a2a-client-manager.js'; import { extractIdsFromResponse, A2AResultReassembler } from './a2aUtils.js'; import { GoogleAuth } from 'google-auth-library'; import type { AuthenticationHandler } from '@a2a-js/sdk/client'; import { debugLogger } from '../utils/debugLogger.js'; import type { AnsiOutput } from '../utils/terminalSerializer.js'; -import type { SendMessageResult } from './a2a-client-manager.js'; import { A2AAuthProviderFactory } from './auth-provider/factory.js'; /** diff --git a/packages/core/src/agents/subagent-tool.test.ts b/packages/core/src/agents/subagent-tool.test.ts index c6e90ea1983..622fd054f07 100644 --- a/packages/core/src/agents/subagent-tool.test.ts +++ b/packages/core/src/agents/subagent-tool.test.ts @@ -7,7 +7,13 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { SubagentTool } from './subagent-tool.js'; import { SubagentToolWrapper } from './subagent-tool-wrapper.js'; -import { Kind } from '../tools/tools.js'; +import { + Kind, + type DeclarativeTool, + type ToolCallConfirmationDetails, + type ToolInvocation, + type ToolResult, +} from '../tools/tools.js'; import type { LocalAgentDefinition, RemoteAgentDefinition, @@ -17,12 +23,6 @@ import { makeFakeConfig } from '../test-utils/config.js'; import { createMockMessageBus } from '../test-utils/mock-message-bus.js'; import type { Config } from '../config/config.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; -import type { - DeclarativeTool, - ToolCallConfirmationDetails, - ToolInvocation, - ToolResult, -} from '../tools/tools.js'; import { GeminiCliOperation, GEN_AI_AGENT_DESCRIPTION, From 1666c93c43614e7ddce281f76da8f29da7eaef9a Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:55:30 +0530 Subject: [PATCH 06/14] fix: merge duplicate imports in hooks/ directory --- .../core/src/hooks/hookAggregator.test.ts | 13 +++--- packages/core/src/hooks/hookAggregator.ts | 8 ++-- .../core/src/hooks/hookEventHandler.test.ts | 3 +- packages/core/src/hooks/hookEventHandler.ts | 43 ++++++++++--------- packages/core/src/hooks/hookPlanner.ts | 7 ++- packages/core/src/hooks/hookRegistry.ts | 9 +++- packages/core/src/hooks/hookRunner.test.ts | 9 +++- packages/core/src/hooks/hookRunner.ts | 4 +- packages/core/src/hooks/hookSystem.test.ts | 3 +- packages/core/src/hooks/hookSystem.ts | 32 +++++++------- packages/core/src/hooks/types.test.ts | 9 ++-- packages/core/src/hooks/types.ts | 10 ++--- 12 files changed, 83 insertions(+), 67 deletions(-) diff --git a/packages/core/src/hooks/hookAggregator.test.ts b/packages/core/src/hooks/hookAggregator.test.ts index ea675464f26..ee9ade9a87a 100644 --- a/packages/core/src/hooks/hookAggregator.test.ts +++ b/packages/core/src/hooks/hookAggregator.test.ts @@ -6,13 +6,14 @@ import { describe, it, expect, beforeEach } from 'vitest'; import { HookAggregator } from './hookAggregator.js'; -import type { - HookExecutionResult, - BeforeToolSelectionOutput, - BeforeModelOutput, - HookOutput, +import { + HookType, + HookEventName, + type HookExecutionResult, + type BeforeToolSelectionOutput, + type BeforeModelOutput, + type HookOutput, } from './types.js'; -import { HookType, HookEventName } from './types.js'; // Helper function to create proper HookExecutionResult objects function createHookExecutionResult( diff --git a/packages/core/src/hooks/hookAggregator.ts b/packages/core/src/hooks/hookAggregator.ts index 5cd53e8c6ee..523bc823fd2 100644 --- a/packages/core/src/hooks/hookAggregator.ts +++ b/packages/core/src/hooks/hookAggregator.ts @@ -5,11 +5,6 @@ */ import { FunctionCallingConfigMode } from '@google/genai'; -import type { - HookOutput, - HookExecutionResult, - BeforeToolSelectionOutput, -} from './types.js'; import { DefaultHookOutput, BeforeToolHookOutput, @@ -18,6 +13,9 @@ import { AfterModelHookOutput, AfterAgentHookOutput, HookEventName, + type HookOutput, + type HookExecutionResult, + type BeforeToolSelectionOutput, } from './types.js'; /** diff --git a/packages/core/src/hooks/hookEventHandler.test.ts b/packages/core/src/hooks/hookEventHandler.test.ts index 9a07d396725..5c1a18c76e7 100644 --- a/packages/core/src/hooks/hookEventHandler.test.ts +++ b/packages/core/src/hooks/hookEventHandler.test.ts @@ -11,12 +11,13 @@ import type { import { describe, it, expect, vi, beforeEach } from 'vitest'; import { HookEventHandler } from './hookEventHandler.js'; import type { Config } from '../config/config.js'; -import type { HookConfig, HookExecutionResult } from './types.js'; import { NotificationType, SessionStartSource, HookEventName, HookType, + type HookConfig, + type HookExecutionResult, } from './types.js'; import type { HookPlanner } from './hookPlanner.js'; import type { HookRunner } from './hookRunner.js'; diff --git a/packages/core/src/hooks/hookEventHandler.ts b/packages/core/src/hooks/hookEventHandler.ts index 00909094cee..7fa45e32712 100644 --- a/packages/core/src/hooks/hookEventHandler.ts +++ b/packages/core/src/hooks/hookEventHandler.ts @@ -8,27 +8,28 @@ import type { Config } from '../config/config.js'; import type { HookPlanner, HookEventContext } from './hookPlanner.js'; import type { HookRunner } from './hookRunner.js'; import type { HookAggregator, AggregatedHookResult } from './hookAggregator.js'; -import { HookEventName, HookType } from './types.js'; -import type { - HookConfig, - HookInput, - BeforeToolInput, - AfterToolInput, - BeforeAgentInput, - NotificationInput, - AfterAgentInput, - SessionStartInput, - SessionEndInput, - PreCompressInput, - BeforeModelInput, - AfterModelInput, - BeforeToolSelectionInput, - NotificationType, - SessionStartSource, - SessionEndReason, - PreCompressTrigger, - HookExecutionResult, - McpToolContext, +import { + HookEventName, + HookType, + type HookConfig, + type HookInput, + type BeforeToolInput, + type AfterToolInput, + type BeforeAgentInput, + type NotificationInput, + type AfterAgentInput, + type SessionStartInput, + type SessionEndInput, + type PreCompressInput, + type BeforeModelInput, + type AfterModelInput, + type BeforeToolSelectionInput, + type NotificationType, + type SessionStartSource, + type SessionEndReason, + type PreCompressTrigger, + type HookExecutionResult, + type McpToolContext, } from './types.js'; import { defaultHookTranslator } from './hookTranslator.js'; import type { diff --git a/packages/core/src/hooks/hookPlanner.ts b/packages/core/src/hooks/hookPlanner.ts index 3e016efe23d..3da7aeec211 100644 --- a/packages/core/src/hooks/hookPlanner.ts +++ b/packages/core/src/hooks/hookPlanner.ts @@ -5,8 +5,11 @@ */ import type { HookRegistry, HookRegistryEntry } from './hookRegistry.js'; -import type { HookExecutionPlan, HookEventName } from './types.js'; -import { getHookKey } from './types.js'; +import { + getHookKey, + type HookExecutionPlan, + type HookEventName, +} from './types.js'; import { debugLogger } from '../utils/debugLogger.js'; /** diff --git a/packages/core/src/hooks/hookRegistry.ts b/packages/core/src/hooks/hookRegistry.ts index b76478d152a..1dad67bad54 100644 --- a/packages/core/src/hooks/hookRegistry.ts +++ b/packages/core/src/hooks/hookRegistry.ts @@ -5,8 +5,13 @@ */ import type { Config } from '../config/config.js'; -import type { HookDefinition, HookConfig } from './types.js'; -import { HookEventName, ConfigSource, HOOKS_CONFIG_FIELDS } from './types.js'; +import { + HookEventName, + ConfigSource, + HOOKS_CONFIG_FIELDS, + type HookDefinition, + type HookConfig, +} from './types.js'; import { debugLogger } from '../utils/debugLogger.js'; import { TrustedHooksManager } from './trustedHooks.js'; import { coreEvents } from '../utils/events.js'; diff --git a/packages/core/src/hooks/hookRunner.test.ts b/packages/core/src/hooks/hookRunner.test.ts index ca88b9411e0..eb806aba3da 100644 --- a/packages/core/src/hooks/hookRunner.test.ts +++ b/packages/core/src/hooks/hookRunner.test.ts @@ -7,8 +7,13 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process'; import { HookRunner } from './hookRunner.js'; -import { HookEventName, HookType, ConfigSource } from './types.js'; -import type { HookConfig, HookInput } from './types.js'; +import { + HookEventName, + HookType, + ConfigSource, + type HookConfig, + type HookInput, +} from './types.js'; import type { Readable, Writable } from 'node:stream'; import type { Config } from '../config/config.js'; diff --git a/packages/core/src/hooks/hookRunner.ts b/packages/core/src/hooks/hookRunner.ts index a9945afbc1b..2ecb13874c7 100644 --- a/packages/core/src/hooks/hookRunner.ts +++ b/packages/core/src/hooks/hookRunner.ts @@ -16,8 +16,10 @@ import type { BeforeModelInput, BeforeModelOutput, BeforeToolInput, + HookEventName, + ConfigSource, + HookType, } from './types.js'; -import { HookEventName, ConfigSource, HookType } from './types.js'; import type { Config } from '../config/config.js'; import type { LLMRequest } from './hookTranslator.js'; import { debugLogger } from '../utils/debugLogger.js'; diff --git a/packages/core/src/hooks/hookSystem.test.ts b/packages/core/src/hooks/hookSystem.test.ts index 85f1a7407b6..959aa4591de 100644 --- a/packages/core/src/hooks/hookSystem.test.ts +++ b/packages/core/src/hooks/hookSystem.test.ts @@ -8,11 +8,10 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { HookSystem } from './hookSystem.js'; import { Config } from '../config/config.js'; import { HookType } from './types.js'; -import { spawn } from 'node:child_process'; +import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process'; import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; -import type { ChildProcessWithoutNullStreams } from 'node:child_process'; import type { Readable, Writable } from 'node:stream'; // Mock type for the child_process spawn diff --git a/packages/core/src/hooks/hookSystem.ts b/packages/core/src/hooks/hookSystem.ts index 84494ee1ea4..f748665985b 100644 --- a/packages/core/src/hooks/hookSystem.ts +++ b/packages/core/src/hooks/hookSystem.ts @@ -5,28 +5,26 @@ */ import type { Config } from '../config/config.js'; -import { HookRegistry } from './hookRegistry.js'; +import { HookRegistry, type HookRegistryEntry } from './hookRegistry.js'; import { HookRunner } from './hookRunner.js'; -import { HookAggregator } from './hookAggregator.js'; +import { HookAggregator, type AggregatedHookResult } from './hookAggregator.js'; import { HookPlanner } from './hookPlanner.js'; import { HookEventHandler } from './hookEventHandler.js'; -import type { HookRegistryEntry } from './hookRegistry.js'; import { debugLogger } from '../utils/debugLogger.js'; -import type { - SessionStartSource, - SessionEndReason, - PreCompressTrigger, - DefaultHookOutput, - BeforeModelHookOutput, - AfterModelHookOutput, - BeforeToolSelectionHookOutput, - McpToolContext, - HookConfig, - HookEventName, - ConfigSource, +import { + NotificationType, + type SessionStartSource, + type SessionEndReason, + type PreCompressTrigger, + type DefaultHookOutput, + type BeforeModelHookOutput, + type AfterModelHookOutput, + type BeforeToolSelectionHookOutput, + type McpToolContext, + type HookConfig, + type HookEventName, + type ConfigSource, } from './types.js'; -import { NotificationType } from './types.js'; -import type { AggregatedHookResult } from './hookAggregator.js'; import type { GenerateContentParameters, GenerateContentResponse, diff --git a/packages/core/src/hooks/types.test.ts b/packages/core/src/hooks/types.test.ts index 933b0425e2c..ab809cbec72 100644 --- a/packages/core/src/hooks/types.test.ts +++ b/packages/core/src/hooks/types.test.ts @@ -14,15 +14,18 @@ import { HookEventName, HookType, BeforeToolHookOutput, + type HookDecision, } from './types.js'; -import { defaultHookTranslator } from './hookTranslator.js'; +import { + defaultHookTranslator, + type LLMRequest, + type LLMResponse, +} from './hookTranslator.js'; import type { GenerateContentParameters, GenerateContentResponse, ToolConfig, } from '@google/genai'; -import type { LLMRequest, LLMResponse } from './hookTranslator.js'; -import type { HookDecision } from './types.js'; vi.mock('./hookTranslator.js', () => ({ defaultHookTranslator: { diff --git a/packages/core/src/hooks/types.ts b/packages/core/src/hooks/types.ts index b053f22f596..9c6217ffa45 100644 --- a/packages/core/src/hooks/types.ts +++ b/packages/core/src/hooks/types.ts @@ -10,12 +10,12 @@ import type { ToolConfig as GenAIToolConfig, ToolListUnion, } from '@google/genai'; -import type { - LLMRequest, - LLMResponse, - HookToolConfig, +import { + defaultHookTranslator, + type LLMRequest, + type LLMResponse, + type HookToolConfig, } from './hookTranslator.js'; -import { defaultHookTranslator } from './hookTranslator.js'; /** * Configuration source levels in precedence order (highest to lowest) From a540ddd56a9ef159281de7b024535452d16710a4 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:55:49 +0530 Subject: [PATCH 07/14] fix: merge duplicate imports in code_assist/ directory --- packages/core/src/code_assist/codeAssist.ts | 6 +-- .../core/src/code_assist/converter.test.ts | 10 ++--- packages/core/src/code_assist/converter.ts | 44 +++++++++---------- packages/core/src/code_assist/oauth2.test.ts | 19 ++++++-- packages/core/src/code_assist/oauth2.ts | 4 +- packages/core/src/code_assist/server.ts | 44 +++++++++---------- packages/core/src/code_assist/setup.test.ts | 3 +- packages/core/src/code_assist/setup.ts | 18 ++++---- 8 files changed, 77 insertions(+), 71 deletions(-) diff --git a/packages/core/src/code_assist/codeAssist.ts b/packages/core/src/code_assist/codeAssist.ts index caec96a4a30..3c3487bcff4 100644 --- a/packages/core/src/code_assist/codeAssist.ts +++ b/packages/core/src/code_assist/codeAssist.ts @@ -4,12 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { ContentGenerator } from '../core/contentGenerator.js'; -import { AuthType } from '../core/contentGenerator.js'; +import { AuthType, type ContentGenerator } from '../core/contentGenerator.js'; import { getOauthClient } from './oauth2.js'; import { setupUser } from './setup.js'; -import type { HttpOptions } from './server.js'; -import { CodeAssistServer } from './server.js'; +import { CodeAssistServer, type HttpOptions } from './server.js'; import type { Config } from '../config/config.js'; import { LoggingContentGenerator } from '../core/loggingContentGenerator.js'; diff --git a/packages/core/src/code_assist/converter.test.ts b/packages/core/src/code_assist/converter.test.ts index 674bbaf70e6..83309412038 100644 --- a/packages/core/src/code_assist/converter.test.ts +++ b/packages/core/src/code_assist/converter.test.ts @@ -5,21 +5,19 @@ */ import { describe, it, expect } from 'vitest'; -import type { CaGenerateContentResponse } from './converter.js'; import { toGenerateContentRequest, fromGenerateContentResponse, toContents, + type CaGenerateContentResponse, } from './converter.js'; -import type { - ContentListUnion, - GenerateContentParameters, - Part, -} from '@google/genai'; import { GenerateContentResponse, FinishReason, BlockedReason, + type ContentListUnion, + type GenerateContentParameters, + type Part, } from '@google/genai'; describe('converter', () => { diff --git a/packages/core/src/code_assist/converter.ts b/packages/core/src/code_assist/converter.ts index 81bda4adc68..005a8cf85d6 100644 --- a/packages/core/src/code_assist/converter.ts +++ b/packages/core/src/code_assist/converter.ts @@ -4,29 +4,29 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - Content, - ContentListUnion, - ContentUnion, - GenerateContentConfig, - GenerateContentParameters, - CountTokensParameters, - CountTokensResponse, - GenerationConfigRoutingConfig, - MediaResolution, - Candidate, - ModelSelectionConfig, - GenerateContentResponsePromptFeedback, - GenerateContentResponseUsageMetadata, - Part, - SafetySetting, - PartUnion, - SpeechConfigUnion, - ThinkingConfig, - ToolListUnion, - ToolConfig, +import { + GenerateContentResponse, + type Content, + type ContentListUnion, + type ContentUnion, + type GenerateContentConfig, + type GenerateContentParameters, + type CountTokensParameters, + type CountTokensResponse, + type GenerationConfigRoutingConfig, + type MediaResolution, + type Candidate, + type ModelSelectionConfig, + type GenerateContentResponsePromptFeedback, + type GenerateContentResponseUsageMetadata, + type Part, + type SafetySetting, + type PartUnion, + type SpeechConfigUnion, + type ThinkingConfig, + type ToolListUnion, + type ToolConfig, } from '@google/genai'; -import { GenerateContentResponse } from '@google/genai'; import { debugLogger } from '../utils/debugLogger.js'; import type { Credits } from './types.js'; diff --git a/packages/core/src/code_assist/oauth2.test.ts b/packages/core/src/code_assist/oauth2.test.ts index c1fe162e632..f462db16e92 100644 --- a/packages/core/src/code_assist/oauth2.test.ts +++ b/packages/core/src/code_assist/oauth2.test.ts @@ -4,9 +4,21 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Credentials } from 'google-auth-library'; -import type { Mock } from 'vitest'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { + OAuth2Client, + Compute, + GoogleAuth, + type Credentials, +} from 'google-auth-library'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import { getOauthClient, resetOauthClientForTesting, @@ -15,7 +27,6 @@ import { authEvents, } from './oauth2.js'; import { UserAccountManager } from '../utils/userAccountManager.js'; -import { OAuth2Client, Compute, GoogleAuth } from 'google-auth-library'; import * as fs from 'node:fs'; import * as path from 'node:path'; import http from 'node:http'; diff --git a/packages/core/src/code_assist/oauth2.ts b/packages/core/src/code_assist/oauth2.ts index 31bc3c0e5eb..335600e5c46 100644 --- a/packages/core/src/code_assist/oauth2.ts +++ b/packages/core/src/code_assist/oauth2.ts @@ -4,12 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Credentials, AuthClient, JWTInput } from 'google-auth-library'; import { OAuth2Client, Compute, CodeChallengeMethod, GoogleAuth, + type Credentials, + type AuthClient, + type JWTInput, } from 'google-auth-library'; import * as http from 'node:http'; import url from 'node:url'; diff --git a/packages/core/src/code_assist/server.ts b/packages/core/src/code_assist/server.ts index dbb749e45db..ced2ddb8010 100644 --- a/packages/core/src/code_assist/server.ts +++ b/packages/core/src/code_assist/server.ts @@ -5,26 +5,26 @@ */ import type { AuthClient } from 'google-auth-library'; -import type { - CodeAssistGlobalUserSettingResponse, - LoadCodeAssistRequest, - LoadCodeAssistResponse, - LongRunningOperationResponse, - OnboardUserRequest, - SetCodeAssistGlobalUserSettingRequest, - ClientMetadata, - RetrieveUserQuotaRequest, - RetrieveUserQuotaResponse, - FetchAdminControlsRequest, - FetchAdminControlsResponse, - ConversationOffered, - ConversationInteraction, - StreamingLatency, - RecordCodeAssistMetricsRequest, - GeminiUserTier, - Credits, +import { + UserTierId, + type CodeAssistGlobalUserSettingResponse, + type LoadCodeAssistRequest, + type LoadCodeAssistResponse, + type LongRunningOperationResponse, + type OnboardUserRequest, + type SetCodeAssistGlobalUserSettingRequest, + type ClientMetadata, + type RetrieveUserQuotaRequest, + type RetrieveUserQuotaResponse, + type FetchAdminControlsRequest, + type FetchAdminControlsResponse, + type ConversationOffered, + type ConversationInteraction, + type StreamingLatency, + type RecordCodeAssistMetricsRequest, + type GeminiUserTier, + type Credits, } from './types.js'; -import { UserTierId } from './types.js'; import type { ListExperimentsRequest, ListExperimentsResponse, @@ -49,15 +49,13 @@ import { } from '../billing/billing.js'; import { logBillingEvent } from '../telemetry/loggers.js'; import { CreditsUsedEvent } from '../telemetry/billingEvents.js'; -import type { - CaCountTokenResponse, - CaGenerateContentResponse, -} from './converter.js'; import { fromCountTokenResponse, fromGenerateContentResponse, toCountTokenRequest, toGenerateContentRequest, + type CaCountTokenResponse, + type CaGenerateContentResponse, } from './converter.js'; import { formatProtoJsonDuration, diff --git a/packages/core/src/code_assist/setup.test.ts b/packages/core/src/code_assist/setup.test.ts index e4418aeca2e..6c6375debc5 100644 --- a/packages/core/src/code_assist/setup.test.ts +++ b/packages/core/src/code_assist/setup.test.ts @@ -14,8 +14,7 @@ import { ValidationRequiredError } from '../utils/googleQuotaErrors.js'; import { ChangeAuthRequestedError } from '../utils/errors.js'; import { CodeAssistServer } from '../code_assist/server.js'; import type { OAuth2Client } from 'google-auth-library'; -import type { GeminiUserTier } from './types.js'; -import { UserTierId } from './types.js'; +import { UserTierId, type GeminiUserTier } from './types.js'; vi.mock('../code_assist/server.js'); diff --git a/packages/core/src/code_assist/setup.ts b/packages/core/src/code_assist/setup.ts index 3da24c5d052..35ef980db27 100644 --- a/packages/core/src/code_assist/setup.ts +++ b/packages/core/src/code_assist/setup.ts @@ -4,16 +4,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ClientMetadata, - GeminiUserTier, - IneligibleTier, - LoadCodeAssistResponse, - OnboardUserRequest, +import { + UserTierId, + IneligibleTierReasonCode, + type ClientMetadata, + type GeminiUserTier, + type IneligibleTier, + type LoadCodeAssistResponse, + type OnboardUserRequest, } from './types.js'; -import { UserTierId, IneligibleTierReasonCode } from './types.js'; -import type { HttpOptions } from './server.js'; -import { CodeAssistServer } from './server.js'; +import { CodeAssistServer, type HttpOptions } from './server.js'; import type { AuthClient } from 'google-auth-library'; import type { ValidationHandler } from '../fallback/types.js'; import { ChangeAuthRequestedError } from '../utils/errors.js'; From a18faaca81673315531c6d82a6a671fedd87f936 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:56:13 +0530 Subject: [PATCH 08/14] fix: merge duplicate imports in services/ directory --- .../core/src/services/chatCompressionService.test.ts | 3 ++- .../core/src/services/chatRecordingService.test.ts | 10 +++++----- packages/core/src/services/fileDiscoveryService.ts | 12 ++++++++---- packages/core/src/services/gitService.ts | 3 +-- .../core/src/services/loopDetectionService.test.ts | 10 +++++----- packages/core/src/services/loopDetectionService.ts | 3 +-- .../src/services/modelConfig.integration.test.ts | 6 ++++-- .../core/src/services/modelConfigService.test.ts | 8 ++++---- .../core/src/services/shellExecutionService.test.ts | 8 ++++---- packages/core/src/services/shellExecutionService.ts | 3 +-- 10 files changed, 35 insertions(+), 31 deletions(-) diff --git a/packages/core/src/services/chatCompressionService.test.ts b/packages/core/src/services/chatCompressionService.test.ts index 4ddd38e25cb..2911119a25d 100644 --- a/packages/core/src/services/chatCompressionService.test.ts +++ b/packages/core/src/services/chatCompressionService.test.ts @@ -16,8 +16,9 @@ import type { BaseLlmClient } from '../core/baseLlmClient.js'; import type { GeminiChat } from '../core/geminiChat.js'; import type { Config } from '../config/config.js'; import * as fileUtils from '../utils/fileUtils.js'; -import { TOOL_OUTPUTS_DIR } from '../utils/fileUtils.js'; import { getInitialChatHistory } from '../utils/environmentContext.js'; + +const { TOOL_OUTPUTS_DIR } = fileUtils; import * as tokenCalculation from '../utils/tokenCalculation.js'; import { tokenLimit } from '../core/tokenLimits.js'; import os from 'node:os'; diff --git a/packages/core/src/services/chatRecordingService.test.ts b/packages/core/src/services/chatRecordingService.test.ts index 086a7b6ff56..9653d0df8b1 100644 --- a/packages/core/src/services/chatRecordingService.test.ts +++ b/packages/core/src/services/chatRecordingService.test.ts @@ -8,14 +8,14 @@ import { expect, it, describe, vi, beforeEach, afterEach } from 'vitest'; import fs from 'node:fs'; import path from 'node:path'; import os from 'node:os'; -import type { - ConversationRecord, - ToolCallRecord, - MessageRecord, +import { + ChatRecordingService, + type ConversationRecord, + type ToolCallRecord, + type MessageRecord, } from './chatRecordingService.js'; import { CoreToolCallStatus } from '../scheduler/types.js'; import type { Content, Part } from '@google/genai'; -import { ChatRecordingService } from './chatRecordingService.js'; import type { Config } from '../config/config.js'; import { getProjectHash } from '../utils/paths.js'; diff --git a/packages/core/src/services/fileDiscoveryService.ts b/packages/core/src/services/fileDiscoveryService.ts index 44a28c1ff2e..d816c42e312 100644 --- a/packages/core/src/services/fileDiscoveryService.ts +++ b/packages/core/src/services/fileDiscoveryService.ts @@ -4,10 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { GitIgnoreFilter } from '../utils/gitIgnoreParser.js'; -import type { IgnoreFileFilter } from '../utils/ignoreFileParser.js'; -import { GitIgnoreParser } from '../utils/gitIgnoreParser.js'; -import { IgnoreFileParser } from '../utils/ignoreFileParser.js'; +import { + GitIgnoreParser, + type GitIgnoreFilter, +} from '../utils/gitIgnoreParser.js'; +import { + IgnoreFileParser, + type IgnoreFileFilter, +} from '../utils/ignoreFileParser.js'; import { isGitRepository } from '../utils/gitUtils.js'; import { GEMINI_IGNORE_FILE_NAME } from '../config/constants.js'; import fs from 'node:fs'; diff --git a/packages/core/src/services/gitService.ts b/packages/core/src/services/gitService.ts index 2caad248ffe..5409b1a5262 100644 --- a/packages/core/src/services/gitService.ts +++ b/packages/core/src/services/gitService.ts @@ -8,8 +8,7 @@ import * as fs from 'node:fs/promises'; import * as path from 'node:path'; import { isNodeError } from '../utils/errors.js'; import { spawnAsync } from '../utils/shell-utils.js'; -import type { SimpleGit } from 'simple-git'; -import { simpleGit, CheckRepoActions } from 'simple-git'; +import { simpleGit, CheckRepoActions, type SimpleGit } from 'simple-git'; import type { Storage } from '../config/storage.js'; import { debugLogger } from '../utils/debugLogger.js'; diff --git a/packages/core/src/services/loopDetectionService.test.ts b/packages/core/src/services/loopDetectionService.test.ts index 840c9ae18ef..5d697ab8b5e 100644 --- a/packages/core/src/services/loopDetectionService.test.ts +++ b/packages/core/src/services/loopDetectionService.test.ts @@ -9,12 +9,12 @@ import type { Content } from '@google/genai'; import type { Config } from '../config/config.js'; import type { GeminiClient } from '../core/client.js'; import type { BaseLlmClient } from '../core/baseLlmClient.js'; -import type { - ServerGeminiContentEvent, - ServerGeminiStreamEvent, - ServerGeminiToolCallRequestEvent, +import { + GeminiEventType, + type ServerGeminiContentEvent, + type ServerGeminiStreamEvent, + type ServerGeminiToolCallRequestEvent, } from '../core/turn.js'; -import { GeminiEventType } from '../core/turn.js'; import * as loggers from '../telemetry/loggers.js'; import { LoopType } from '../telemetry/types.js'; import { LoopDetectionService } from './loopDetectionService.js'; diff --git a/packages/core/src/services/loopDetectionService.ts b/packages/core/src/services/loopDetectionService.ts index 67207915c1d..54ac5d8d506 100644 --- a/packages/core/src/services/loopDetectionService.ts +++ b/packages/core/src/services/loopDetectionService.ts @@ -6,8 +6,7 @@ import type { Content } from '@google/genai'; import { createHash } from 'node:crypto'; -import type { ServerGeminiStreamEvent } from '../core/turn.js'; -import { GeminiEventType } from '../core/turn.js'; +import { GeminiEventType, type ServerGeminiStreamEvent } from '../core/turn.js'; import { logLoopDetected, logLoopDetectionDisabled, diff --git a/packages/core/src/services/modelConfig.integration.test.ts b/packages/core/src/services/modelConfig.integration.test.ts index 2ed2cb47af1..09723b95eaf 100644 --- a/packages/core/src/services/modelConfig.integration.test.ts +++ b/packages/core/src/services/modelConfig.integration.test.ts @@ -5,8 +5,10 @@ */ import { describe, it, expect } from 'vitest'; -import { ModelConfigService } from './modelConfigService.js'; -import type { ModelConfigServiceConfig } from './modelConfigService.js'; +import { + ModelConfigService, + type ModelConfigServiceConfig, +} from './modelConfigService.js'; // This test suite is designed to validate the end-to-end logic of the // ModelConfigService with a complex, realistic configuration. diff --git a/packages/core/src/services/modelConfigService.test.ts b/packages/core/src/services/modelConfigService.test.ts index 767cb2ecfdd..2bc69bbfe27 100644 --- a/packages/core/src/services/modelConfigService.test.ts +++ b/packages/core/src/services/modelConfigService.test.ts @@ -5,11 +5,11 @@ */ import { describe, it, expect } from 'vitest'; -import type { - ModelConfigAlias, - ModelConfigServiceConfig, +import { + ModelConfigService, + type ModelConfigAlias, + type ModelConfigServiceConfig, } from './modelConfigService.js'; -import { ModelConfigService } from './modelConfigService.js'; describe('ModelConfigService', () => { it('should resolve a basic alias to its model and settings', () => { diff --git a/packages/core/src/services/shellExecutionService.test.ts b/packages/core/src/services/shellExecutionService.test.ts index 61186c9eb2f..77de13de3a6 100644 --- a/packages/core/src/services/shellExecutionService.test.ts +++ b/packages/core/src/services/shellExecutionService.test.ts @@ -16,11 +16,11 @@ import { import EventEmitter from 'node:events'; import type { Readable } from 'node:stream'; import { type ChildProcess } from 'node:child_process'; -import type { - ShellOutputEvent, - ShellExecutionConfig, +import { + ShellExecutionService, + type ShellOutputEvent, + type ShellExecutionConfig, } from './shellExecutionService.js'; -import { ShellExecutionService } from './shellExecutionService.js'; import type { AnsiOutput, AnsiToken } from '../utils/terminalSerializer.js'; // Hoisted Mocks diff --git a/packages/core/src/services/shellExecutionService.ts b/packages/core/src/services/shellExecutionService.ts index c21eeb11369..fdb2ca79b5d 100644 --- a/packages/core/src/services/shellExecutionService.ts +++ b/packages/core/src/services/shellExecutionService.ts @@ -5,8 +5,7 @@ */ import stripAnsi from 'strip-ansi'; -import type { PtyImplementation } from '../utils/getPty.js'; -import { getPty } from '../utils/getPty.js'; +import { getPty, type PtyImplementation } from '../utils/getPty.js'; import { spawn as cpSpawn, type ChildProcess } from 'node:child_process'; import { TextDecoder } from 'node:util'; import os from 'node:os'; From 6535291cc586dbb9609a4d954b33e79e77d7522e Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:56:39 +0530 Subject: [PATCH 09/14] fix: merge duplicate imports in telemetry/ directory --- .../src/telemetry/activity-monitor.test.ts | 2 +- .../clearcut-logger/clearcut-logger.test.ts | 18 ++-- packages/core/src/telemetry/conseca-logger.ts | 3 +- .../core/src/telemetry/file-exporters.test.ts | 6 +- packages/core/src/telemetry/file-exporters.ts | 11 +-- packages/core/src/telemetry/gcp-exporters.ts | 10 +- .../src/telemetry/loggers.test.circular.ts | 2 +- packages/core/src/telemetry/loggers.test.ts | 2 - packages/core/src/telemetry/loggers.ts | 94 +++++++++---------- packages/core/src/telemetry/metrics.ts | 11 ++- packages/core/src/telemetry/semantic.ts | 14 +-- packages/core/src/telemetry/types.ts | 2 +- .../core/src/telemetry/uiTelemetry.test.ts | 3 +- packages/core/src/telemetry/uiTelemetry.ts | 10 +- 14 files changed, 98 insertions(+), 90 deletions(-) diff --git a/packages/core/src/telemetry/activity-monitor.test.ts b/packages/core/src/telemetry/activity-monitor.test.ts index 8d20daa3012..68dbe9a1c22 100644 --- a/packages/core/src/telemetry/activity-monitor.test.ts +++ b/packages/core/src/telemetry/activity-monitor.test.ts @@ -13,9 +13,9 @@ import { recordGlobalActivity, startGlobalActivityMonitoring, stopGlobalActivityMonitoring, + type ActivityEvent, } from './activity-monitor.js'; import { ActivityType } from './activity-types.js'; -import type { ActivityEvent } from './activity-monitor.js'; import type { Config } from '../config/config.js'; import { debugLogger } from '../utils/debugLogger.js'; diff --git a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.test.ts b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.test.ts index b8148bac622..195c5544bf9 100644 --- a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.test.ts +++ b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.test.ts @@ -14,10 +14,17 @@ import { afterAll, beforeEach, } from 'vitest'; -import type { LogEvent, LogEventEntry } from './clearcut-logger.js'; -import { ClearcutLogger, EventNames, TEST_ONLY } from './clearcut-logger.js'; -import type { ContentGeneratorConfig } from '../../core/contentGenerator.js'; -import { AuthType } from '../../core/contentGenerator.js'; +import { + ClearcutLogger, + EventNames, + TEST_ONLY, + type LogEvent, + type LogEventEntry, +} from './clearcut-logger.js'; +import { + AuthType, + type ContentGeneratorConfig, +} from '../../core/contentGenerator.js'; import type { SuccessfulToolCall } from '../../core/coreToolScheduler.js'; import type { ConfigParameters } from '../../config/config.js'; import { EventMetadataKey } from './event-metadata-key.js'; @@ -42,8 +49,7 @@ import { GIT_COMMIT_INFO, CLI_VERSION } from '../../generated/git-commit.js'; import { UserAccountManager } from '../../utils/userAccountManager.js'; import { InstallationManager } from '../../utils/installationManager.js'; -import si from 'systeminformation'; -import type { Systeminformation } from 'systeminformation'; +import si, { type Systeminformation } from 'systeminformation'; import * as os from 'node:os'; interface CustomMatchers { diff --git a/packages/core/src/telemetry/conseca-logger.ts b/packages/core/src/telemetry/conseca-logger.ts index 41f1ac3d15b..ad88d092ee9 100644 --- a/packages/core/src/telemetry/conseca-logger.ts +++ b/packages/core/src/telemetry/conseca-logger.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { LogRecord } from '@opentelemetry/api-logs'; -import { logs } from '@opentelemetry/api-logs'; +import { logs, type LogRecord } from '@opentelemetry/api-logs'; import type { Config } from '../config/config.js'; import { SERVICE_NAME } from './constants.js'; import { isTelemetrySdkInitialized } from './sdk.js'; diff --git a/packages/core/src/telemetry/file-exporters.test.ts b/packages/core/src/telemetry/file-exporters.test.ts index 80a2ccafad5..4b4f688ab8b 100644 --- a/packages/core/src/telemetry/file-exporters.test.ts +++ b/packages/core/src/telemetry/file-exporters.test.ts @@ -13,8 +13,10 @@ import { import { ExportResultCode } from '@opentelemetry/core'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; import type { ReadableLogRecord } from '@opentelemetry/sdk-logs'; -import type { ResourceMetrics } from '@opentelemetry/sdk-metrics'; -import { AggregationTemporality } from '@opentelemetry/sdk-metrics'; +import { + AggregationTemporality, + type ResourceMetrics, +} from '@opentelemetry/sdk-metrics'; import * as fs from 'node:fs'; function createMockWriteStream(): { diff --git a/packages/core/src/telemetry/file-exporters.ts b/packages/core/src/telemetry/file-exporters.ts index def6e91f441..9f8d7f51c1d 100644 --- a/packages/core/src/telemetry/file-exporters.ts +++ b/packages/core/src/telemetry/file-exporters.ts @@ -5,18 +5,17 @@ */ import * as fs from 'node:fs'; -import type { ExportResult } from '@opentelemetry/core'; -import { ExportResultCode } from '@opentelemetry/core'; +import { ExportResultCode, type ExportResult } from '@opentelemetry/core'; import type { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base'; import type { ReadableLogRecord, LogRecordExporter, } from '@opentelemetry/sdk-logs'; -import type { - ResourceMetrics, - PushMetricExporter, +import { + AggregationTemporality, + type ResourceMetrics, + type PushMetricExporter, } from '@opentelemetry/sdk-metrics'; -import { AggregationTemporality } from '@opentelemetry/sdk-metrics'; import { safeJsonStringify } from '../utils/safeJsonStringify.js'; class FileExporter { diff --git a/packages/core/src/telemetry/gcp-exporters.ts b/packages/core/src/telemetry/gcp-exporters.ts index c7429383ebe..3bf1781b878 100644 --- a/packages/core/src/telemetry/gcp-exporters.ts +++ b/packages/core/src/telemetry/gcp-exporters.ts @@ -7,10 +7,12 @@ import { type JWTInput } from 'google-auth-library'; import { TraceExporter } from '@google-cloud/opentelemetry-cloud-trace-exporter'; import { MetricExporter } from '@google-cloud/opentelemetry-cloud-monitoring-exporter'; -import { Logging } from '@google-cloud/logging'; -import type { Log } from '@google-cloud/logging'; -import { hrTimeToMilliseconds, ExportResultCode } from '@opentelemetry/core'; -import type { ExportResult } from '@opentelemetry/core'; +import { Logging, type Log } from '@google-cloud/logging'; +import { + hrTimeToMilliseconds, + ExportResultCode, + type ExportResult, +} from '@opentelemetry/core'; import type { ReadableLogRecord, LogRecordExporter, diff --git a/packages/core/src/telemetry/loggers.test.circular.ts b/packages/core/src/telemetry/loggers.test.circular.ts index d6b6ea86ce2..119c661e86a 100644 --- a/packages/core/src/telemetry/loggers.test.circular.ts +++ b/packages/core/src/telemetry/loggers.test.circular.ts @@ -14,10 +14,10 @@ import { ToolCallEvent } from './types.js'; import type { Config } from '../config/config.js'; import type { CompletedToolCall } from '../core/coreToolScheduler.js'; import { + CoreToolCallStatus, type ToolCallRequestInfo, type ToolCallResponseInfo, } from '../scheduler/types.js'; -import { CoreToolCallStatus } from '../scheduler/types.js'; import { MockTool } from '../test-utils/mock-tool.js'; describe('Circular Reference Handling', () => { diff --git a/packages/core/src/telemetry/loggers.test.ts b/packages/core/src/telemetry/loggers.test.ts index de2f94c8d75..468fa5c52a0 100644 --- a/packages/core/src/telemetry/loggers.test.ts +++ b/packages/core/src/telemetry/loggers.test.ts @@ -11,8 +11,6 @@ import type { ContentGeneratorConfig, ErroredToolCall, MessageBus, -} from '../index.js'; -import { CoreToolCallStatus, AuthType, EditTool, diff --git a/packages/core/src/telemetry/loggers.ts b/packages/core/src/telemetry/loggers.ts index e96db385964..2625f10789d 100644 --- a/packages/core/src/telemetry/loggers.ts +++ b/packages/core/src/telemetry/loggers.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { LogRecord } from '@opentelemetry/api-logs'; -import { logs } from '@opentelemetry/api-logs'; +import { logs, type LogRecord } from '@opentelemetry/api-logs'; import type { Config } from '../config/config.js'; import { SERVICE_NAME } from './constants.js'; import { @@ -13,51 +12,49 @@ import { EVENT_API_RESPONSE, EVENT_TOOL_CALL, EVENT_REWIND, -} from './types.js'; -import type { - ApiErrorEvent, - ApiRequestEvent, - ApiResponseEvent, - FileOperationEvent, - IdeConnectionEvent, - StartSessionEvent, - ToolCallEvent, - UserPromptEvent, - FlashFallbackEvent, - NextSpeakerCheckEvent, - LoopDetectedEvent, - LoopDetectionDisabledEvent, - SlashCommandEvent, - RewindEvent, - ConversationFinishedEvent, - ChatCompressionEvent, - MalformedJsonResponseEvent, - ContentRetryEvent, - ContentRetryFailureEvent, - RipgrepFallbackEvent, - ToolOutputTruncatedEvent, - ModelRoutingEvent, - ExtensionDisableEvent, - ExtensionEnableEvent, - ExtensionUninstallEvent, - ExtensionInstallEvent, - ModelSlashCommandEvent, - EditStrategyEvent, - EditCorrectionEvent, - AgentStartEvent, - AgentFinishEvent, - RecoveryAttemptEvent, - WebFetchFallbackAttemptEvent, - ExtensionUpdateEvent, - ApprovalModeSwitchEvent, - ApprovalModeDurationEvent, - HookCallEvent, - StartupStatsEvent, - LlmLoopCheckEvent, - PlanExecutionEvent, - ToolOutputMaskingEvent, - KeychainAvailabilityEvent, - TokenStorageInitializationEvent, + type ApiErrorEvent, + type ApiRequestEvent, + type ApiResponseEvent, + type FileOperationEvent, + type IdeConnectionEvent, + type StartSessionEvent, + type ToolCallEvent, + type UserPromptEvent, + type FlashFallbackEvent, + type NextSpeakerCheckEvent, + type LoopDetectedEvent, + type LoopDetectionDisabledEvent, + type SlashCommandEvent, + type RewindEvent, + type ConversationFinishedEvent, + type ChatCompressionEvent, + type MalformedJsonResponseEvent, + type ContentRetryEvent, + type ContentRetryFailureEvent, + type RipgrepFallbackEvent, + type ToolOutputTruncatedEvent, + type ModelRoutingEvent, + type ExtensionDisableEvent, + type ExtensionEnableEvent, + type ExtensionUninstallEvent, + type ExtensionInstallEvent, + type ModelSlashCommandEvent, + type EditStrategyEvent, + type EditCorrectionEvent, + type AgentStartEvent, + type AgentFinishEvent, + type RecoveryAttemptEvent, + type WebFetchFallbackAttemptEvent, + type ExtensionUpdateEvent, + type ApprovalModeSwitchEvent, + type ApprovalModeDurationEvent, + type HookCallEvent, + type StartupStatsEvent, + type LlmLoopCheckEvent, + type PlanExecutionEvent, + type ToolOutputMaskingEvent, + type KeychainAvailabilityEvent, + type TokenStorageInitializationEvent, } from './types.js'; import { recordApiErrorMetrics, @@ -80,8 +77,7 @@ import { recordTokenStorageInitialization, } from './metrics.js'; import { bufferTelemetryEvent } from './sdk.js'; -import type { UiEvent } from './uiTelemetry.js'; -import { uiTelemetryService } from './uiTelemetry.js'; +import { uiTelemetryService, type UiEvent } from './uiTelemetry.js'; import { ClearcutLogger } from './clearcut-logger/clearcut-logger.js'; import { debugLogger } from '../utils/debugLogger.js'; import type { BillingTelemetryEvent } from './billingEvents.js'; diff --git a/packages/core/src/telemetry/metrics.ts b/packages/core/src/telemetry/metrics.ts index 598158af073..70b188f5170 100644 --- a/packages/core/src/telemetry/metrics.ts +++ b/packages/core/src/telemetry/metrics.ts @@ -4,8 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Attributes, Meter, Counter, Histogram } from '@opentelemetry/api'; -import { diag, metrics, ValueType } from '@opentelemetry/api'; +import { + diag, + metrics, + ValueType, + type Attributes, + type Meter, + type Counter, + type Histogram, +} from '@opentelemetry/api'; import { SERVICE_NAME } from './constants.js'; import type { Config } from '../config/config.js'; import type { diff --git a/packages/core/src/telemetry/semantic.ts b/packages/core/src/telemetry/semantic.ts index c05d110e9f0..cb38502c91a 100644 --- a/packages/core/src/telemetry/semantic.ts +++ b/packages/core/src/telemetry/semantic.ts @@ -11,13 +11,13 @@ * @see https://github.com/open-telemetry/semantic-conventions/blob/8b4f210f43136e57c1f6f47292eb6d38e3bf30bb/docs/gen-ai/gen-ai-events.md */ -import { FinishReason } from '@google/genai'; -import type { - Candidate, - Content, - ContentUnion, - Part, - PartUnion, +import { + FinishReason, + type Candidate, + type Content, + type ContentUnion, + type Part, + type PartUnion, } from '@google/genai'; import { truncateString } from '../utils/textUtils.js'; diff --git a/packages/core/src/telemetry/types.ts b/packages/core/src/telemetry/types.ts index a4b3cfb4c96..a84f051cac2 100644 --- a/packages/core/src/telemetry/types.ts +++ b/packages/core/src/telemetry/types.ts @@ -31,13 +31,13 @@ import type { AgentTerminateMode } from '../agents/types.js'; import { getCommonAttributes } from './telemetryAttributes.js'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; import { safeJsonStringify } from '../utils/safeJsonStringify.js'; -import type { OTelFinishReason } from './semantic.js'; import { toInputMessages, toOutputMessages, toFinishReasons, toOutputType, toSystemInstruction, + type OTelFinishReason, } from './semantic.js'; import { sanitizeHookName } from './sanitize.js'; import { getFileDiffFromResultDisplay } from '../utils/fileDiffUtils.js'; diff --git a/packages/core/src/telemetry/uiTelemetry.test.ts b/packages/core/src/telemetry/uiTelemetry.test.ts index d1a3b1a9a67..f78f0801af4 100644 --- a/packages/core/src/telemetry/uiTelemetry.test.ts +++ b/packages/core/src/telemetry/uiTelemetry.test.ts @@ -7,12 +7,13 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { UiTelemetryService } from './uiTelemetry.js'; import { ToolCallDecision } from './tool-call-decision.js'; -import type { ApiErrorEvent, ApiResponseEvent } from './types.js'; import { ToolCallEvent, EVENT_API_ERROR, EVENT_API_RESPONSE, EVENT_TOOL_CALL, + type ApiErrorEvent, + type ApiResponseEvent, } from './types.js'; import type { CompletedToolCall, diff --git a/packages/core/src/telemetry/uiTelemetry.ts b/packages/core/src/telemetry/uiTelemetry.ts index 669b6a8c684..36953c02c13 100644 --- a/packages/core/src/telemetry/uiTelemetry.ts +++ b/packages/core/src/telemetry/uiTelemetry.ts @@ -9,15 +9,13 @@ import { EVENT_API_ERROR, EVENT_API_RESPONSE, EVENT_TOOL_CALL, + type ApiErrorEvent, + type ApiResponseEvent, + type ToolCallEvent, + type LlmRole, } from './types.js'; import { ToolCallDecision } from './tool-call-decision.js'; -import type { - ApiErrorEvent, - ApiResponseEvent, - ToolCallEvent, - LlmRole, -} from './types.js'; export type UiEvent = | (ApiResponseEvent & { 'event.name': typeof EVENT_API_RESPONSE }) From 3e4b3cb25a5b81dd2aa4a334d6de3b746b5f7c07 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:57:01 +0530 Subject: [PATCH 10/14] fix: merge duplicate imports in utils/ directory --- .../core/src/utils/apiConversionUtils.test.ts | 2 +- packages/core/src/utils/authConsent.test.ts | 3 +-- packages/core/src/utils/editCorrector.test.ts | 3 +-- packages/core/src/utils/fileUtils.test.ts | 2 +- .../core/src/utils/filesearch/crawler.test.ts | 3 +-- .../core/src/utils/filesearch/fileSearch.ts | 6 ++---- .../generateContentResponseUtilities.test.ts | 14 +++++++------- packages/core/src/utils/getFolderStructure.ts | 6 ++++-- packages/core/src/utils/googleErrors.test.ts | 3 +-- packages/core/src/utils/googleQuotaErrors.ts | 14 +++++++------- .../core/src/utils/installationManager.test.ts | 11 +++++++++-- packages/core/src/utils/memoryDiscovery.test.ts | 3 +-- packages/core/src/utils/memoryDiscovery.ts | 6 ++++-- .../core/src/utils/nextSpeakerChecker.test.ts | 17 +++++++++++++---- packages/core/src/utils/retry.ts | 3 +-- packages/core/src/utils/shell-utils.ts | 3 +-- packages/core/src/utils/summarizer.test.ts | 11 +++++++++-- packages/core/src/utils/tool-utils.test.ts | 3 ++- packages/core/src/utils/tool-utils.ts | 7 +++++-- .../core/src/utils/userAccountManager.test.ts | 11 +++++++++-- 20 files changed, 80 insertions(+), 51 deletions(-) diff --git a/packages/core/src/utils/apiConversionUtils.test.ts b/packages/core/src/utils/apiConversionUtils.test.ts index 615bcb1de81..fa907ca2e69 100644 --- a/packages/core/src/utils/apiConversionUtils.test.ts +++ b/packages/core/src/utils/apiConversionUtils.test.ts @@ -6,11 +6,11 @@ import { describe, it, expect } from 'vitest'; import { convertToRestPayload } from './apiConversionUtils.js'; -import type { GenerateContentParameters } from '@google/genai'; import { FunctionCallingConfigMode, HarmCategory, HarmBlockThreshold, + type GenerateContentParameters, } from '@google/genai'; describe('apiConversionUtils', () => { diff --git a/packages/core/src/utils/authConsent.test.ts b/packages/core/src/utils/authConsent.test.ts index 7fc05b2a036..2eccbd39c83 100644 --- a/packages/core/src/utils/authConsent.test.ts +++ b/packages/core/src/utils/authConsent.test.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import type { Mock } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import readline from 'node:readline'; import process from 'node:process'; import { coreEvents } from './events.js'; diff --git a/packages/core/src/utils/editCorrector.test.ts b/packages/core/src/utils/editCorrector.test.ts index 533b49b9e4d..f9620d74b57 100644 --- a/packages/core/src/utils/editCorrector.test.ts +++ b/packages/core/src/utils/editCorrector.test.ts @@ -5,8 +5,7 @@ */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { Mocked } from 'vitest'; -import { vi, describe, it, expect, beforeEach } from 'vitest'; +import { vi, describe, it, expect, beforeEach, type Mocked } from 'vitest'; import type { BaseLlmClient } from '../core/baseLlmClient.js'; // MOCKS diff --git a/packages/core/src/utils/fileUtils.test.ts b/packages/core/src/utils/fileUtils.test.ts index de668db3adc..dcbf22c5a7d 100644 --- a/packages/core/src/utils/fileUtils.test.ts +++ b/packages/core/src/utils/fileUtils.test.ts @@ -14,8 +14,8 @@ import { type Mock, } from 'vitest'; -import * as actualNodeFs from 'node:fs'; // For setup/teardown import fs from 'node:fs'; +import * as actualNodeFs from 'node:fs'; // For setup/teardown import fsPromises from 'node:fs/promises'; import path from 'node:path'; import os from 'node:os'; diff --git a/packages/core/src/utils/filesearch/crawler.test.ts b/packages/core/src/utils/filesearch/crawler.test.ts index 192c0274b8a..5cdeb79fdb3 100644 --- a/packages/core/src/utils/filesearch/crawler.test.ts +++ b/packages/core/src/utils/filesearch/crawler.test.ts @@ -10,8 +10,7 @@ import * as path from 'node:path'; import * as cache from './crawlCache.js'; import { crawl } from './crawler.js'; import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils'; -import type { Ignore } from './ignore.js'; -import { loadIgnoreRules } from './ignore.js'; +import { loadIgnoreRules, type Ignore } from './ignore.js'; import { GEMINI_IGNORE_FILE_NAME } from '../../config/constants.js'; import { FileDiscoveryService } from '../../services/fileDiscoveryService.js'; diff --git a/packages/core/src/utils/filesearch/fileSearch.ts b/packages/core/src/utils/filesearch/fileSearch.ts index 97560f7070c..3536eb62054 100644 --- a/packages/core/src/utils/filesearch/fileSearch.ts +++ b/packages/core/src/utils/filesearch/fileSearch.ts @@ -6,12 +6,10 @@ import path from 'node:path'; import picomatch from 'picomatch'; -import type { Ignore } from './ignore.js'; -import { loadIgnoreRules } from './ignore.js'; +import { loadIgnoreRules, type Ignore } from './ignore.js'; import { ResultCache } from './result-cache.js'; import { crawl } from './crawler.js'; -import type { FzfResultItem } from 'fzf'; -import { AsyncFzf } from 'fzf'; +import { AsyncFzf, type FzfResultItem } from 'fzf'; import { unescapePath } from '../paths.js'; import type { FileDiscoveryService } from '../../services/fileDiscoveryService.js'; diff --git a/packages/core/src/utils/generateContentResponseUtilities.test.ts b/packages/core/src/utils/generateContentResponseUtilities.test.ts index 0562f918889..179144964e9 100644 --- a/packages/core/src/utils/generateContentResponseUtilities.test.ts +++ b/packages/core/src/utils/generateContentResponseUtilities.test.ts @@ -16,14 +16,14 @@ import { getCitations, convertToFunctionResponse, } from './generateContentResponseUtilities.js'; -import type { - GenerateContentResponse, - Part, - SafetyRating, - CitationMetadata, - PartListUnion, +import { + FinishReason, + type GenerateContentResponse, + type Part, + type SafetyRating, + type CitationMetadata, + type PartListUnion, } from '@google/genai'; -import { FinishReason } from '@google/genai'; import { DEFAULT_GEMINI_MODEL, PREVIEW_GEMINI_MODEL, diff --git a/packages/core/src/utils/getFolderStructure.ts b/packages/core/src/utils/getFolderStructure.ts index 8f871e12837..6e1814cd903 100644 --- a/packages/core/src/utils/getFolderStructure.ts +++ b/packages/core/src/utils/getFolderStructure.ts @@ -12,8 +12,10 @@ import type { FileDiscoveryService, FilterFilesOptions, } from '../services/fileDiscoveryService.js'; -import type { FileFilteringOptions } from '../config/constants.js'; -import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js'; +import { + DEFAULT_FILE_FILTERING_OPTIONS, + type FileFilteringOptions, +} from '../config/constants.js'; import { debugLogger } from './debugLogger.js'; const MAX_ITEMS = 200; diff --git a/packages/core/src/utils/googleErrors.test.ts b/packages/core/src/utils/googleErrors.test.ts index 46a6aa7b7ae..6e11d01f31f 100644 --- a/packages/core/src/utils/googleErrors.test.ts +++ b/packages/core/src/utils/googleErrors.test.ts @@ -5,8 +5,7 @@ */ import { describe, it, expect } from 'vitest'; -import { parseGoogleApiError } from './googleErrors.js'; -import type { QuotaFailure } from './googleErrors.js'; +import { parseGoogleApiError, type QuotaFailure } from './googleErrors.js'; describe('parseGoogleApiError', () => { it('should return null for non-gaxios errors', () => { diff --git a/packages/core/src/utils/googleQuotaErrors.ts b/packages/core/src/utils/googleQuotaErrors.ts index e9955493bda..d0c251e839a 100644 --- a/packages/core/src/utils/googleQuotaErrors.ts +++ b/packages/core/src/utils/googleQuotaErrors.ts @@ -4,14 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ErrorInfo, - GoogleApiError, - Help, - QuotaFailure, - RetryInfo, +import { + parseGoogleApiError, + type ErrorInfo, + type GoogleApiError, + type Help, + type QuotaFailure, + type RetryInfo, } from './googleErrors.js'; -import { parseGoogleApiError } from './googleErrors.js'; import { getErrorStatus, ModelNotFoundError } from './httpErrors.js'; /** diff --git a/packages/core/src/utils/installationManager.test.ts b/packages/core/src/utils/installationManager.test.ts index 1cc7f69926f..a5251697c27 100644 --- a/packages/core/src/utils/installationManager.test.ts +++ b/packages/core/src/utils/installationManager.test.ts @@ -4,8 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; +import { + vi, + describe, + it, + expect, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import { InstallationManager } from './installationManager.js'; import * as fs from 'node:fs'; import * as os from 'node:os'; diff --git a/packages/core/src/utils/memoryDiscovery.test.ts b/packages/core/src/utils/memoryDiscovery.test.ts index 3df110d6784..a23b7660fff 100644 --- a/packages/core/src/utils/memoryDiscovery.test.ts +++ b/packages/core/src/utils/memoryDiscovery.test.ts @@ -20,10 +20,9 @@ import { setGeminiMdFilename, DEFAULT_CONTEXT_FILENAME, } from '../tools/memoryTool.js'; -import { flattenMemory } from '../config/memory.js'; +import { flattenMemory, type HierarchicalMemory } from '../config/memory.js'; import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; import { GEMINI_DIR, normalizePath, homedir as pathsHomedir } from './paths.js'; -import type { HierarchicalMemory } from '../config/memory.js'; function flattenResult(result: { memoryContent: HierarchicalMemory; diff --git a/packages/core/src/utils/memoryDiscovery.ts b/packages/core/src/utils/memoryDiscovery.ts index c35d009e1dc..677c571becf 100644 --- a/packages/core/src/utils/memoryDiscovery.ts +++ b/packages/core/src/utils/memoryDiscovery.ts @@ -11,8 +11,10 @@ import { bfsFileSearch } from './bfsFileSearch.js'; import { getAllGeminiMdFilenames } from '../tools/memoryTool.js'; import type { FileDiscoveryService } from '../services/fileDiscoveryService.js'; import { processImports } from './memoryImportProcessor.js'; -import type { FileFilteringOptions } from '../config/constants.js'; -import { DEFAULT_MEMORY_FILE_FILTERING_OPTIONS } from '../config/constants.js'; +import { + DEFAULT_MEMORY_FILE_FILTERING_OPTIONS, + type FileFilteringOptions, +} from '../config/constants.js'; import { GEMINI_DIR, homedir, normalizePath } from './paths.js'; import type { ExtensionLoader } from './extensionLoader.js'; import { debugLogger } from './debugLogger.js'; diff --git a/packages/core/src/utils/nextSpeakerChecker.test.ts b/packages/core/src/utils/nextSpeakerChecker.test.ts index fbf3bb8b90b..bfc1dbde56c 100644 --- a/packages/core/src/utils/nextSpeakerChecker.test.ts +++ b/packages/core/src/utils/nextSpeakerChecker.test.ts @@ -4,14 +4,23 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import type { Content } from '@google/genai'; import { BaseLlmClient } from '../core/baseLlmClient.js'; import type { ContentGenerator } from '../core/contentGenerator.js'; import type { Config } from '../config/config.js'; -import type { NextSpeakerResponse } from './nextSpeakerChecker.js'; -import { checkNextSpeaker } from './nextSpeakerChecker.js'; +import { + checkNextSpeaker, + type NextSpeakerResponse, +} from './nextSpeakerChecker.js'; import { GeminiChat } from '../core/geminiChat.js'; // Mock fs module to prevent actual file system operations during tests diff --git a/packages/core/src/utils/retry.ts b/packages/core/src/utils/retry.ts index 50c992d6de3..a16e823e745 100644 --- a/packages/core/src/utils/retry.ts +++ b/packages/core/src/utils/retry.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { GenerateContentResponse } from '@google/genai'; -import { ApiError } from '@google/genai'; +import { ApiError, type GenerateContentResponse } from '@google/genai'; import { TerminalQuotaError, RetryableQuotaError, diff --git a/packages/core/src/utils/shell-utils.ts b/packages/core/src/utils/shell-utils.ts index 6f92ec63864..00b35334001 100644 --- a/packages/core/src/utils/shell-utils.ts +++ b/packages/core/src/utils/shell-utils.ts @@ -14,8 +14,7 @@ import { type SpawnOptionsWithoutStdio, } from 'node:child_process'; import * as readline from 'node:readline'; -import type { Node, Tree } from 'web-tree-sitter'; -import { Language, Parser, Query } from 'web-tree-sitter'; +import { Language, Parser, Query, type Node, type Tree } from 'web-tree-sitter'; import { loadWasmBinary } from './fileUtils.js'; import { debugLogger } from './debugLogger.js'; diff --git a/packages/core/src/utils/summarizer.test.ts b/packages/core/src/utils/summarizer.test.ts index 83d30128a76..0f72badcc35 100644 --- a/packages/core/src/utils/summarizer.test.ts +++ b/packages/core/src/utils/summarizer.test.ts @@ -4,8 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { + describe, + it, + expect, + vi, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import { GeminiClient } from '../core/client.js'; import { Config } from '../config/config.js'; import { diff --git a/packages/core/src/utils/tool-utils.test.ts b/packages/core/src/utils/tool-utils.test.ts index c007b37715f..cddbec66b0f 100644 --- a/packages/core/src/utils/tool-utils.test.ts +++ b/packages/core/src/utils/tool-utils.test.ts @@ -10,7 +10,6 @@ import { getToolSuggestion, shouldHideToolCall, } from './tool-utils.js'; -import type { AnyToolInvocation, Config } from '../index.js'; import { ReadFileTool, ApprovalMode, @@ -19,6 +18,8 @@ import { WRITE_FILE_DISPLAY_NAME, EDIT_DISPLAY_NAME, READ_FILE_DISPLAY_NAME, + type AnyToolInvocation, + type Config, } from '../index.js'; import { createMockMessageBus } from '../test-utils/mock-message-bus.js'; diff --git a/packages/core/src/utils/tool-utils.ts b/packages/core/src/utils/tool-utils.ts index 17ccbda8d67..cc863e15ccc 100644 --- a/packages/core/src/utils/tool-utils.ts +++ b/packages/core/src/utils/tool-utils.ts @@ -4,8 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { AnyDeclarativeTool, AnyToolInvocation } from '../index.js'; -import { isTool } from '../index.js'; +import { + isTool, + type AnyDeclarativeTool, + type AnyToolInvocation, +} from '../index.js'; import { SHELL_TOOL_NAMES } from './shell-utils.js'; import levenshtein from 'fast-levenshtein'; import { ApprovalMode } from '../policy/types.js'; diff --git a/packages/core/src/utils/userAccountManager.test.ts b/packages/core/src/utils/userAccountManager.test.ts index 4e970c334fa..5b38ac3cfe7 100644 --- a/packages/core/src/utils/userAccountManager.test.ts +++ b/packages/core/src/utils/userAccountManager.test.ts @@ -4,8 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; +import { + vi, + describe, + it, + expect, + beforeEach, + afterEach, + type Mock, +} from 'vitest'; import { UserAccountManager } from './userAccountManager.js'; import * as fs from 'node:fs'; import * as os from 'node:os'; From 529e259a8d30358605c706c1ba60c7e45fc32b70 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:57:22 +0530 Subject: [PATCH 11/14] fix: merge duplicate imports in safety/, policy/, and mcp/ directories --- packages/core/src/mcp/google-auth-provider.test.ts | 3 +-- packages/core/src/mcp/oauth-provider.test.ts | 10 +++++----- packages/core/src/mcp/oauth-utils.test.ts | 8 ++++---- .../core/src/mcp/token-storage/hybrid-token-storage.ts | 7 +++++-- packages/core/src/policy/config.test.ts | 8 ++++++-- packages/core/src/policy/toml-loader.test.ts | 2 +- packages/core/src/safety/built-in.test.ts | 3 +-- packages/core/src/safety/built-in.ts | 7 +++++-- packages/core/src/safety/checker-runner.test.ts | 3 +-- packages/core/src/safety/checker-runner.ts | 7 +++++-- packages/core/src/safety/conseca/conseca.test.ts | 3 +-- packages/core/src/safety/conseca/conseca.ts | 7 +++++-- 12 files changed, 40 insertions(+), 28 deletions(-) diff --git a/packages/core/src/mcp/google-auth-provider.test.ts b/packages/core/src/mcp/google-auth-provider.test.ts index 8a25f15ad7a..f535f17d83a 100644 --- a/packages/core/src/mcp/google-auth-provider.test.ts +++ b/packages/core/src/mcp/google-auth-provider.test.ts @@ -6,8 +6,7 @@ import { GoogleAuth } from 'google-auth-library'; import { GoogleCredentialProvider } from './google-auth-provider.js'; -import type { Mock } from 'vitest'; -import { vi, describe, beforeEach, it, expect } from 'vitest'; +import { vi, describe, beforeEach, it, expect, type Mock } from 'vitest'; import type { MCPServerConfig } from '../config/config.js'; vi.mock('google-auth-library'); diff --git a/packages/core/src/mcp/oauth-provider.test.ts b/packages/core/src/mcp/oauth-provider.test.ts index 77c46305a61..5cd4460e97e 100644 --- a/packages/core/src/mcp/oauth-provider.test.ts +++ b/packages/core/src/mcp/oauth-provider.test.ts @@ -56,12 +56,12 @@ vi.mock('node:readline', () => ({ import * as http from 'node:http'; import * as crypto from 'node:crypto'; -import type { - MCPOAuthConfig, - OAuthTokenResponse, - OAuthClientRegistrationResponse, +import { + MCPOAuthProvider, + type MCPOAuthConfig, + type OAuthTokenResponse, + type OAuthClientRegistrationResponse, } from './oauth-provider.js'; -import { MCPOAuthProvider } from './oauth-provider.js'; import { getConsentForOauth } from '../utils/authConsent.js'; import type { OAuthToken } from './token-storage/types.js'; import { MCPOAuthTokenStorage } from './oauth-token-storage.js'; diff --git a/packages/core/src/mcp/oauth-utils.test.ts b/packages/core/src/mcp/oauth-utils.test.ts index c318261aef3..f27ee7727b2 100644 --- a/packages/core/src/mcp/oauth-utils.test.ts +++ b/packages/core/src/mcp/oauth-utils.test.ts @@ -5,11 +5,11 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { - OAuthAuthorizationServerMetadata, - OAuthProtectedResourceMetadata, +import { + OAuthUtils, + type OAuthAuthorizationServerMetadata, + type OAuthProtectedResourceMetadata, } from './oauth-utils.js'; -import { OAuthUtils } from './oauth-utils.js'; // Mock fetch globally const mockFetch = vi.fn(); diff --git a/packages/core/src/mcp/token-storage/hybrid-token-storage.ts b/packages/core/src/mcp/token-storage/hybrid-token-storage.ts index 3bda6050e6c..20560ba30ee 100644 --- a/packages/core/src/mcp/token-storage/hybrid-token-storage.ts +++ b/packages/core/src/mcp/token-storage/hybrid-token-storage.ts @@ -6,8 +6,11 @@ import { BaseTokenStorage } from './base-token-storage.js'; import { FileTokenStorage } from './file-token-storage.js'; -import type { TokenStorage, OAuthCredentials } from './types.js'; -import { TokenStorageType } from './types.js'; +import { + TokenStorageType, + type TokenStorage, + type OAuthCredentials, +} from './types.js'; import { coreEvents } from '../../utils/events.js'; import { TokenStorageInitializationEvent } from '../../telemetry/types.js'; diff --git a/packages/core/src/policy/config.test.ts b/packages/core/src/policy/config.test.ts index 3ded361084e..f1cb8d07882 100644 --- a/packages/core/src/policy/config.test.ts +++ b/packages/core/src/policy/config.test.ts @@ -8,8 +8,12 @@ import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; import nodePath from 'node:path'; -import type { PolicySettings } from './types.js'; -import { ApprovalMode, PolicyDecision, InProcessCheckerType } from './types.js'; +import { + ApprovalMode, + PolicyDecision, + InProcessCheckerType, + type PolicySettings, +} from './types.js'; import { isDirectorySecure } from '../utils/security.js'; vi.unmock('../config/storage.js'); diff --git a/packages/core/src/policy/toml-loader.test.ts b/packages/core/src/policy/toml-loader.test.ts index 30236d80c2c..ffeccf1a18b 100644 --- a/packages/core/src/policy/toml-loader.test.ts +++ b/packages/core/src/policy/toml-loader.test.ts @@ -17,8 +17,8 @@ import { fileURLToPath } from 'node:url'; import { loadPoliciesFromToml, validateMcpPolicyToolNames, + type PolicyLoadResult, } from './toml-loader.js'; -import type { PolicyLoadResult } from './toml-loader.js'; import { PolicyEngine } from './policy-engine.js'; const __filename = fileURLToPath(import.meta.url); diff --git a/packages/core/src/safety/built-in.test.ts b/packages/core/src/safety/built-in.test.ts index d940929009f..ecfc8e6bd5c 100644 --- a/packages/core/src/safety/built-in.test.ts +++ b/packages/core/src/safety/built-in.test.ts @@ -9,8 +9,7 @@ import * as fs from 'node:fs/promises'; import * as os from 'node:os'; import * as path from 'node:path'; import { AllowedPathChecker } from './built-in.js'; -import type { SafetyCheckInput } from './protocol.js'; -import { SafetyCheckDecision } from './protocol.js'; +import { SafetyCheckDecision, type SafetyCheckInput } from './protocol.js'; import type { FunctionCall } from '@google/genai'; describe('AllowedPathChecker', () => { diff --git a/packages/core/src/safety/built-in.ts b/packages/core/src/safety/built-in.ts index 540af362908..aae8c8ee533 100644 --- a/packages/core/src/safety/built-in.ts +++ b/packages/core/src/safety/built-in.ts @@ -6,8 +6,11 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; -import type { SafetyCheckInput, SafetyCheckResult } from './protocol.js'; -import { SafetyCheckDecision } from './protocol.js'; +import { + SafetyCheckDecision, + type SafetyCheckInput, + type SafetyCheckResult, +} from './protocol.js'; import type { AllowedPathConfig } from '../policy/types.js'; /** diff --git a/packages/core/src/safety/checker-runner.test.ts b/packages/core/src/safety/checker-runner.test.ts index cd3c0e18bab..6358541ecff 100644 --- a/packages/core/src/safety/checker-runner.test.ts +++ b/packages/core/src/safety/checker-runner.test.ts @@ -13,8 +13,7 @@ import { type InProcessCheckerConfig, InProcessCheckerType, } from '../policy/types.js'; -import type { SafetyCheckResult } from './protocol.js'; -import { SafetyCheckDecision } from './protocol.js'; +import { SafetyCheckDecision, type SafetyCheckResult } from './protocol.js'; import type { Config } from '../config/config.js'; // Mock dependencies diff --git a/packages/core/src/safety/checker-runner.ts b/packages/core/src/safety/checker-runner.ts index a46c3e6dbd8..c0ed57aa20e 100644 --- a/packages/core/src/safety/checker-runner.ts +++ b/packages/core/src/safety/checker-runner.ts @@ -11,8 +11,11 @@ import type { InProcessCheckerConfig, ExternalCheckerConfig, } from '../policy/types.js'; -import type { SafetyCheckInput, SafetyCheckResult } from './protocol.js'; -import { SafetyCheckDecision } from './protocol.js'; +import { + SafetyCheckDecision, + type SafetyCheckInput, + type SafetyCheckResult, +} from './protocol.js'; import type { CheckerRegistry } from './registry.js'; import type { ContextBuilder } from './context-builder.js'; import { z } from 'zod'; diff --git a/packages/core/src/safety/conseca/conseca.test.ts b/packages/core/src/safety/conseca/conseca.test.ts index 8d871777de1..2ad9ef32955 100644 --- a/packages/core/src/safety/conseca/conseca.test.ts +++ b/packages/core/src/safety/conseca/conseca.test.ts @@ -6,8 +6,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'; import { ConsecaSafetyChecker } from './conseca.js'; -import { SafetyCheckDecision } from '../protocol.js'; -import type { SafetyCheckInput } from '../protocol.js'; +import { SafetyCheckDecision, type SafetyCheckInput } from '../protocol.js'; import { logConsecaPolicyGeneration, logConsecaVerdict, diff --git a/packages/core/src/safety/conseca/conseca.ts b/packages/core/src/safety/conseca/conseca.ts index 4d837bbc47d..39649117962 100644 --- a/packages/core/src/safety/conseca/conseca.ts +++ b/packages/core/src/safety/conseca/conseca.ts @@ -5,8 +5,11 @@ */ import type { InProcessChecker } from '../built-in.js'; -import type { SafetyCheckInput, SafetyCheckResult } from '../protocol.js'; -import { SafetyCheckDecision } from '../protocol.js'; +import { + SafetyCheckDecision, + type SafetyCheckInput, + type SafetyCheckResult, +} from '../protocol.js'; import { logConsecaPolicyGeneration, From 96a8319be6e89e7b279b6f40d4907f011ce4824d Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Tue, 3 Mar 2026 11:57:46 +0530 Subject: [PATCH 12/14] fix: merge duplicate imports in test-utils/, output/, and routing/ directories --- .../src/output/stream-json-formatter.test.ts | 16 ++++++++-------- .../strategies/gemmaClassifierStrategy.test.ts | 3 +-- packages/core/src/test-utils/config.ts | 3 +-- packages/core/src/test-utils/mock-tool.ts | 8 +++----- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/core/src/output/stream-json-formatter.test.ts b/packages/core/src/output/stream-json-formatter.test.ts index 69dbaac23bb..c911a9dbc25 100644 --- a/packages/core/src/output/stream-json-formatter.test.ts +++ b/packages/core/src/output/stream-json-formatter.test.ts @@ -6,14 +6,14 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { StreamJsonFormatter } from './stream-json-formatter.js'; -import { JsonStreamEventType } from './types.js'; -import type { - InitEvent, - MessageEvent, - ToolUseEvent, - ToolResultEvent, - ErrorEvent, - ResultEvent, +import { + JsonStreamEventType, + type InitEvent, + type MessageEvent, + type ToolUseEvent, + type ToolResultEvent, + type ErrorEvent, + type ResultEvent, } from './types.js'; import type { SessionMetrics } from '../telemetry/uiTelemetry.js'; import { ToolCallDecision } from '../telemetry/tool-call-decision.js'; diff --git a/packages/core/src/routing/strategies/gemmaClassifierStrategy.test.ts b/packages/core/src/routing/strategies/gemmaClassifierStrategy.test.ts index 9425208fd73..967a185eaf2 100644 --- a/packages/core/src/routing/strategies/gemmaClassifierStrategy.test.ts +++ b/packages/core/src/routing/strategies/gemmaClassifierStrategy.test.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { Mock } from 'vitest'; -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { GemmaClassifierStrategy } from './gemmaClassifierStrategy.js'; import type { RoutingContext } from '../routingStrategy.js'; import type { Config } from '../../config/config.js'; diff --git a/packages/core/src/test-utils/config.ts b/packages/core/src/test-utils/config.ts index 880599d9b9d..5d896752f91 100644 --- a/packages/core/src/test-utils/config.ts +++ b/packages/core/src/test-utils/config.ts @@ -4,8 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { ConfigParameters } from '../config/config.js'; -import { Config } from '../config/config.js'; +import { Config, type ConfigParameters } from '../config/config.js'; /** * Default parameters used for {@link FAKE_CONFIG} diff --git a/packages/core/src/test-utils/mock-tool.ts b/packages/core/src/test-utils/mock-tool.ts index 4fa536d2dbd..5f89a506cd3 100644 --- a/packages/core/src/test-utils/mock-tool.ts +++ b/packages/core/src/test-utils/mock-tool.ts @@ -8,15 +8,13 @@ import type { ModifiableDeclarativeTool, ModifyContext, } from '../tools/modifiable-tool.js'; -import type { - ToolCallConfirmationDetails, - ToolInvocation, - ToolResult, -} from '../tools/tools.js'; import { BaseDeclarativeTool, BaseToolInvocation, Kind, + type ToolCallConfirmationDetails, + type ToolInvocation, + type ToolResult, } from '../tools/tools.js'; import { createMockMessageBus } from './mock-message-bus.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; From ca9c90a2953db2a3659dba24813f8c985e0f10df Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Wed, 4 Mar 2026 03:57:54 +0530 Subject: [PATCH 13/14] fix: correct type vs value imports for enums and classes - Move enums (CoreToolCallStatus, ROOT_SCHEDULER_ID, HookEventName, ConfigSource, HookType, AuthType, ToolConfirmationOutcome, ToolErrorType) from type imports to value imports - Move classes (ToolRegistry, GeminiClient, EditTool) from type imports to value imports - These were incorrectly marked as type-only imports during duplicate import merge - Fixes TypeScript error TS1361: cannot be used as a value because it was imported using 'import type' --- packages/core/src/hooks/hookRunner.ts | 22 ++++++++--------- packages/core/src/scheduler/scheduler.test.ts | 22 ++++++++--------- .../core/src/scheduler/state-manager.test.ts | 18 +++++++------- packages/core/src/scheduler/state-manager.ts | 24 +++++++++---------- packages/core/src/telemetry/loggers.test.ts | 14 +++++------ 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/packages/core/src/hooks/hookRunner.ts b/packages/core/src/hooks/hookRunner.ts index 2ecb13874c7..4f449587877 100644 --- a/packages/core/src/hooks/hookRunner.ts +++ b/packages/core/src/hooks/hookRunner.ts @@ -5,20 +5,20 @@ */ import { spawn, execSync } from 'node:child_process'; -import type { - HookConfig, - CommandHookConfig, - RuntimeHookConfig, - HookInput, - HookOutput, - HookExecutionResult, - BeforeAgentInput, - BeforeModelInput, - BeforeModelOutput, - BeforeToolInput, +import { HookEventName, ConfigSource, HookType, + type HookConfig, + type CommandHookConfig, + type RuntimeHookConfig, + type HookInput, + type HookOutput, + type HookExecutionResult, + type BeforeAgentInput, + type BeforeModelInput, + type BeforeModelOutput, + type BeforeToolInput, } from './types.js'; import type { Config } from '../config/config.js'; import type { LLMRequest } from './hookTranslator.js'; diff --git a/packages/core/src/scheduler/scheduler.test.ts b/packages/core/src/scheduler/scheduler.test.ts index 912e56d1570..aacf45e3aa1 100644 --- a/packages/core/src/scheduler/scheduler.test.ts +++ b/packages/core/src/scheduler/scheduler.test.ts @@ -75,19 +75,19 @@ import { type AnyDeclarativeTool, type AnyToolInvocation, } from '../tools/tools.js'; -import type { - ToolCallRequestInfo, - ValidatingToolCall, - SuccessfulToolCall, - ErroredToolCall, - CancelledToolCall, - CompletedToolCall, - ToolCallResponseInfo, - ExecutingToolCall, - Status, - ToolCall, +import { CoreToolCallStatus, ROOT_SCHEDULER_ID, + type ToolCallRequestInfo, + type ValidatingToolCall, + type SuccessfulToolCall, + type ErroredToolCall, + type CancelledToolCall, + type CompletedToolCall, + type ToolCallResponseInfo, + type ExecutingToolCall, + type Status, + type ToolCall, } from './types.js'; import { ToolErrorType } from '../tools/tool-error.js'; import { GeminiCliOperation } from '../telemetry/constants.js'; diff --git a/packages/core/src/scheduler/state-manager.test.ts b/packages/core/src/scheduler/state-manager.test.ts index 60435efeb89..dd5071c5bfa 100644 --- a/packages/core/src/scheduler/state-manager.test.ts +++ b/packages/core/src/scheduler/state-manager.test.ts @@ -6,17 +6,17 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { SchedulerStateManager } from './state-manager.js'; -import type { - ValidatingToolCall, - WaitingToolCall, - SuccessfulToolCall, - ErroredToolCall, - CancelledToolCall, - ExecutingToolCall, - ToolCallRequestInfo, - ToolCallResponseInfo, +import { CoreToolCallStatus, ROOT_SCHEDULER_ID, + type ValidatingToolCall, + type WaitingToolCall, + type SuccessfulToolCall, + type ErroredToolCall, + type CancelledToolCall, + type ExecutingToolCall, + type ToolCallRequestInfo, + type ToolCallResponseInfo, } from './types.js'; import { ToolConfirmationOutcome, diff --git a/packages/core/src/scheduler/state-manager.ts b/packages/core/src/scheduler/state-manager.ts index 5fec3e85b88..92a4b4c6b0c 100644 --- a/packages/core/src/scheduler/state-manager.ts +++ b/packages/core/src/scheduler/state-manager.ts @@ -4,20 +4,20 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ToolCall, - Status, - WaitingToolCall, - CompletedToolCall, - SuccessfulToolCall, - ErroredToolCall, - CancelledToolCall, - ScheduledToolCall, - ValidatingToolCall, - ExecutingToolCall, - ToolCallResponseInfo, +import { CoreToolCallStatus, ROOT_SCHEDULER_ID, + type ToolCall, + type Status, + type WaitingToolCall, + type CompletedToolCall, + type SuccessfulToolCall, + type ErroredToolCall, + type CancelledToolCall, + type ScheduledToolCall, + type ValidatingToolCall, + type ExecutingToolCall, + type ToolCallResponseInfo, } from './types.js'; import type { ToolConfirmationOutcome, diff --git a/packages/core/src/telemetry/loggers.test.ts b/packages/core/src/telemetry/loggers.test.ts index 468fa5c52a0..3d9ed780e62 100644 --- a/packages/core/src/telemetry/loggers.test.ts +++ b/packages/core/src/telemetry/loggers.test.ts @@ -4,13 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - AnyDeclarativeTool, - AnyToolInvocation, - CompletedToolCall, - ContentGeneratorConfig, - ErroredToolCall, - MessageBus, +import { CoreToolCallStatus, AuthType, EditTool, @@ -18,6 +12,12 @@ import type { ToolConfirmationOutcome, ToolErrorType, ToolRegistry, + type AnyDeclarativeTool, + type AnyToolInvocation, + type CompletedToolCall, + type ContentGeneratorConfig, + type ErroredToolCall, + type MessageBus, } from '../index.js'; import { OutputFormat } from '../output/types.js'; import { logs } from '@opentelemetry/api-logs'; From 277623286b31c3d994b41a706d4196c6245431b4 Mon Sep 17 00:00:00 2001 From: Nixxx19 Date: Wed, 4 Mar 2026 04:20:35 +0530 Subject: [PATCH 14/14] fix: remove duplicate imports from merge conflict --- packages/core/src/scheduler/tool-executor.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/core/src/scheduler/tool-executor.ts b/packages/core/src/scheduler/tool-executor.ts index c5e1563b0cb..8269f1fc41b 100644 --- a/packages/core/src/scheduler/tool-executor.ts +++ b/packages/core/src/scheduler/tool-executor.ts @@ -4,13 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { - ToolCallRequestInfo, - ToolCallResponseInfo, - ToolResult, - Config, - ToolLiveOutput, -} from '../index.js'; import { ToolErrorType, ToolOutputTruncatedEvent, @@ -20,7 +13,6 @@ import { type ToolCallResponseInfo, type ToolResult, type Config, - type ToolResultDisplay, type ToolLiveOutput, } from '../index.js'; import { SHELL_TOOL_NAME } from '../tools/tool-names.js'; @@ -41,7 +33,6 @@ import { type SuccessfulToolCall, type CancelledToolCall, } from './types.js'; -import { CoreToolCallStatus } from './types.js'; import type { PartListUnion, Part } from '@google/genai'; import { GeminiCliOperation,