From 7654eb82c9352238be3aaeb5a2f771cd76104c53 Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Sun, 2 Aug 2026 15:25:03 -0700 Subject: [PATCH 1/2] chore: prefix bare Node built-in imports with the node: protocol A bare specifier like 'fs' or 'path' only resolves to the Node built-in because no package of that name happens to be installed; all of them are real, publishable npm package names, so a package in a consumer's dependency tree can shadow the built-in. Prefix the 56 remaining bare built-in specifiers across core/src, dev/src, core/test, tests/e2e and vitest.config.ts with node:. Specifier-only edits; no behaviour, type or API surface changes. prettier-plugin-organize-imports re-sorts the import block of tests/e2e/tools/rest_api_tool_auth_e2e_test.ts as a result, which is the only line movement in the change. --- core/src/artifacts/file_artifact_service.ts | 6 +++--- core/test/a2a/agent_to_a2a_body_parsing_test.ts | 4 ++-- core/test/agents/llm_agent_auth_integration_test.ts | 2 +- core/test/artifacts/file_artifact_service_test.ts | 6 +++--- .../tools/openapi_tool/openapi_toolset_integration_test.ts | 4 ++-- dev/src/cli/cli.ts | 2 +- tests/e2e/context_compaction/agent_controlled_e2e_test.ts | 4 ++-- .../e2e/context_compaction/e2e_anchored_compaction_test.ts | 4 ++-- tests/e2e/context_compaction/e2e_compaction_test.ts | 4 ++-- .../e2e/context_compaction/e2e_compaction_vertexai_test.ts | 4 ++-- tests/e2e/custom_metadata/custom_metadata_test.ts | 6 +++--- tests/e2e/routing/ab_testing_agent_test.ts | 4 ++-- tests/e2e/routing/ab_testing_llm_test.ts | 4 ++-- tests/e2e/routing/auto_routing_agent_test.ts | 4 ++-- tests/e2e/routing/auto_routing_llm_test.ts | 4 ++-- tests/e2e/routing/model_fallback_test.ts | 4 ++-- tests/e2e/routing/planning_mode_test.ts | 4 ++-- tests/e2e/streaming/streaming_e2e_test.ts | 4 ++-- tests/e2e/tools/agent_registry_e2e_test.ts | 4 ++-- tests/e2e/tools/agent_tool_e2e_test.ts | 4 ++-- tests/e2e/tools/before_tool_selection_test.ts | 4 ++-- tests/e2e/tools/load_artifacts_tool_test.ts | 4 ++-- tests/e2e/tools/load_memory_tool_test.ts | 4 ++-- tests/e2e/tools/preload_memory_tool_test.ts | 4 ++-- tests/e2e/tools/rest_api_tool_auth_e2e_test.ts | 6 +++--- tests/e2e/tools/skills_registry_e2e_test.ts | 6 +++--- vitest.config.ts | 2 +- 27 files changed, 56 insertions(+), 56 deletions(-) diff --git a/core/src/artifacts/file_artifact_service.ts b/core/src/artifacts/file_artifact_service.ts index 2d5b7c496..5dc879638 100644 --- a/core/src/artifacts/file_artifact_service.ts +++ b/core/src/artifacts/file_artifact_service.ts @@ -5,9 +5,9 @@ */ import {Part} from '@google/genai'; -import * as fs from 'fs/promises'; -import * as path from 'path'; -import {fileURLToPath, pathToFileURL} from 'url'; +import * as fs from 'node:fs/promises'; +import * as path from 'node:path'; +import {fileURLToPath, pathToFileURL} from 'node:url'; import {logger} from '../utils/logger.js'; diff --git a/core/test/a2a/agent_to_a2a_body_parsing_test.ts b/core/test/a2a/agent_to_a2a_body_parsing_test.ts index 16c420e50..199a2bde1 100644 --- a/core/test/a2a/agent_to_a2a_body_parsing_test.ts +++ b/core/test/a2a/agent_to_a2a_body_parsing_test.ts @@ -5,8 +5,8 @@ */ import express from 'express'; -import type {Server} from 'http'; -import type {AddressInfo} from 'net'; +import type {Server} from 'node:http'; +import type {AddressInfo} from 'node:net'; import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import {toA2a} from '../../src/a2a/agent_to_a2a.js'; import {BaseAgent} from '../../src/agents/base_agent.js'; diff --git a/core/test/agents/llm_agent_auth_integration_test.ts b/core/test/agents/llm_agent_auth_integration_test.ts index 14f6ea813..68170b34f 100644 --- a/core/test/agents/llm_agent_auth_integration_test.ts +++ b/core/test/agents/llm_agent_auth_integration_test.ts @@ -17,7 +17,7 @@ import { RestApiTool, Runner, } from '@google/adk'; -import * as http from 'http'; +import * as http from 'node:http'; import {OpenAPIV3} from 'openapi-types'; import { afterAll, diff --git a/core/test/artifacts/file_artifact_service_test.ts b/core/test/artifacts/file_artifact_service_test.ts index 0356b0edd..08e6f2519 100644 --- a/core/test/artifacts/file_artifact_service_test.ts +++ b/core/test/artifacts/file_artifact_service_test.ts @@ -5,9 +5,9 @@ */ import {FileArtifactService} from '@google/adk'; -import * as fs from 'fs/promises'; -import * as os from 'os'; -import * as path from 'path'; +import * as fs from 'node:fs/promises'; +import * as os from 'node:os'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; import { assertInsideRoot, diff --git a/core/test/tools/openapi_tool/openapi_toolset_integration_test.ts b/core/test/tools/openapi_tool/openapi_toolset_integration_test.ts index 22fdbf3fa..ba7f7c9f3 100644 --- a/core/test/tools/openapi_tool/openapi_toolset_integration_test.ts +++ b/core/test/tools/openapi_tool/openapi_toolset_integration_test.ts @@ -5,8 +5,8 @@ */ import {Context, OpenAPIToolset} from '@google/adk'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {beforeEach, describe, expect, it, vi} from 'vitest'; describe('OpenAPIToolset Integration', () => { diff --git a/dev/src/cli/cli.ts b/dev/src/cli/cli.ts index f227c979f..ab5fdd2ae 100644 --- a/dev/src/cli/cli.ts +++ b/dev/src/cli/cli.ts @@ -15,7 +15,7 @@ import { } from '@google/adk'; import {Argument, Command, Option} from 'commander'; import dotenv from 'dotenv'; -import * as path from 'path'; +import * as path from 'node:path'; import {runIntegrationTests} from '../integration/run_integration_tests.js'; import {AdkApiServer} from '../server/adk_api_server.js'; import {FileModuleType} from '../utils/agent_loader.js'; diff --git a/tests/e2e/context_compaction/agent_controlled_e2e_test.ts b/tests/e2e/context_compaction/agent_controlled_e2e_test.ts index 7d613d0c1..20b8493a4 100644 --- a/tests/e2e/context_compaction/agent_controlled_e2e_test.ts +++ b/tests/e2e/context_compaction/agent_controlled_e2e_test.ts @@ -13,8 +13,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; import {createAgentControlledCompactionAgent} from './agent.js'; diff --git a/tests/e2e/context_compaction/e2e_anchored_compaction_test.ts b/tests/e2e/context_compaction/e2e_anchored_compaction_test.ts index 779cf1284..5d89a5353 100644 --- a/tests/e2e/context_compaction/e2e_anchored_compaction_test.ts +++ b/tests/e2e/context_compaction/e2e_anchored_compaction_test.ts @@ -19,8 +19,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; class TestCompactionPlugin extends BasePlugin { diff --git a/tests/e2e/context_compaction/e2e_compaction_test.ts b/tests/e2e/context_compaction/e2e_compaction_test.ts index bf9ff82ca..12c3dd349 100644 --- a/tests/e2e/context_compaction/e2e_compaction_test.ts +++ b/tests/e2e/context_compaction/e2e_compaction_test.ts @@ -13,8 +13,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; import {createCompactionAgent} from './agent.js'; diff --git a/tests/e2e/context_compaction/e2e_compaction_vertexai_test.ts b/tests/e2e/context_compaction/e2e_compaction_vertexai_test.ts index 3c7b38ddb..d82609891 100644 --- a/tests/e2e/context_compaction/e2e_compaction_vertexai_test.ts +++ b/tests/e2e/context_compaction/e2e_compaction_vertexai_test.ts @@ -16,8 +16,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; function createVertexAICompactionAgent(): LlmAgent { diff --git a/tests/e2e/custom_metadata/custom_metadata_test.ts b/tests/e2e/custom_metadata/custom_metadata_test.ts index b2ed3351d..921c386e7 100644 --- a/tests/e2e/custom_metadata/custom_metadata_test.ts +++ b/tests/e2e/custom_metadata/custom_metadata_test.ts @@ -7,9 +7,9 @@ import {Agent, Gemini, InMemoryRunner} from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; -import {fileURLToPath} from 'url'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import {fileURLToPath} from 'node:url'; import {describe, expect, it} from 'vitest'; const __filename = fileURLToPath(import.meta.url); diff --git a/tests/e2e/routing/ab_testing_agent_test.ts b/tests/e2e/routing/ab_testing_agent_test.ts index 776646ced..f39fae70f 100644 --- a/tests/e2e/routing/ab_testing_agent_test.ts +++ b/tests/e2e/routing/ab_testing_agent_test.ts @@ -6,8 +6,8 @@ import {InMemoryRunner, LlmAgent, RoutedAgent} from '@google/adk'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; const envPath = path.resolve(__dirname, '.env'); diff --git a/tests/e2e/routing/ab_testing_llm_test.ts b/tests/e2e/routing/ab_testing_llm_test.ts index 54f21e8b6..db43178ae 100644 --- a/tests/e2e/routing/ab_testing_llm_test.ts +++ b/tests/e2e/routing/ab_testing_llm_test.ts @@ -6,8 +6,8 @@ import {Gemini, LlmRequest, RoutedLlm} from '@google/adk'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; const envPath = path.resolve(__dirname, '.env'); diff --git a/tests/e2e/routing/auto_routing_agent_test.ts b/tests/e2e/routing/auto_routing_agent_test.ts index d0c17968b..dafdc44d3 100644 --- a/tests/e2e/routing/auto_routing_agent_test.ts +++ b/tests/e2e/routing/auto_routing_agent_test.ts @@ -13,8 +13,8 @@ import { RoutedAgent, } from '@google/adk'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; const envPath = path.resolve(__dirname, '.env'); diff --git a/tests/e2e/routing/auto_routing_llm_test.ts b/tests/e2e/routing/auto_routing_llm_test.ts index ebe7cc029..832d3a008 100644 --- a/tests/e2e/routing/auto_routing_llm_test.ts +++ b/tests/e2e/routing/auto_routing_llm_test.ts @@ -6,8 +6,8 @@ import {BaseLlm, Gemini, LlmRequest, RoutedLlm} from '@google/adk'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; const envPath = path.resolve(__dirname, '.env'); diff --git a/tests/e2e/routing/model_fallback_test.ts b/tests/e2e/routing/model_fallback_test.ts index c6ee36004..5eb1250d2 100644 --- a/tests/e2e/routing/model_fallback_test.ts +++ b/tests/e2e/routing/model_fallback_test.ts @@ -6,8 +6,8 @@ import {BaseLlm, Gemini, LlmRequest, RoutedLlm} from '@google/adk'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; const envPath = path.resolve(__dirname, '.env'); diff --git a/tests/e2e/routing/planning_mode_test.ts b/tests/e2e/routing/planning_mode_test.ts index 4302a7695..eae4bcf47 100644 --- a/tests/e2e/routing/planning_mode_test.ts +++ b/tests/e2e/routing/planning_mode_test.ts @@ -6,8 +6,8 @@ import {FunctionTool, InMemoryRunner, LlmAgent, RoutedAgent} from '@google/adk'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; import {z} from 'zod'; diff --git a/tests/e2e/streaming/streaming_e2e_test.ts b/tests/e2e/streaming/streaming_e2e_test.ts index 6b1abcf27..e7dba064b 100644 --- a/tests/e2e/streaming/streaming_e2e_test.ts +++ b/tests/e2e/streaming/streaming_e2e_test.ts @@ -13,8 +13,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; import {z} from 'zod'; diff --git a/tests/e2e/tools/agent_registry_e2e_test.ts b/tests/e2e/tools/agent_registry_e2e_test.ts index 23f1bb49d..77ed490c0 100644 --- a/tests/e2e/tools/agent_registry_e2e_test.ts +++ b/tests/e2e/tools/agent_registry_e2e_test.ts @@ -7,8 +7,8 @@ import {AgentRegistry, InMemoryRunner, LlmAgent} from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; describe('E2E Live Agent Registry', () => { diff --git a/tests/e2e/tools/agent_tool_e2e_test.ts b/tests/e2e/tools/agent_tool_e2e_test.ts index 63357006b..cf0f5fbc3 100644 --- a/tests/e2e/tools/agent_tool_e2e_test.ts +++ b/tests/e2e/tools/agent_tool_e2e_test.ts @@ -7,8 +7,8 @@ import {AgentTool, InMemoryRunner, LlmAgent, State} from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; describe('E2E AgentTool State Filtering', () => { diff --git a/tests/e2e/tools/before_tool_selection_test.ts b/tests/e2e/tools/before_tool_selection_test.ts index e40e1ae0a..683d0a1f7 100644 --- a/tests/e2e/tools/before_tool_selection_test.ts +++ b/tests/e2e/tools/before_tool_selection_test.ts @@ -14,8 +14,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; class FilterPlugin extends BasePlugin { diff --git a/tests/e2e/tools/load_artifacts_tool_test.ts b/tests/e2e/tools/load_artifacts_tool_test.ts index b725f3a17..9dc0fbac1 100644 --- a/tests/e2e/tools/load_artifacts_tool_test.ts +++ b/tests/e2e/tools/load_artifacts_tool_test.ts @@ -7,8 +7,8 @@ import {InMemoryRunner, LlmAgent, LOAD_ARTIFACTS} from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; describe('E2E LoadArtifactsTool', () => { diff --git a/tests/e2e/tools/load_memory_tool_test.ts b/tests/e2e/tools/load_memory_tool_test.ts index 33cda21a9..e16713c28 100644 --- a/tests/e2e/tools/load_memory_tool_test.ts +++ b/tests/e2e/tools/load_memory_tool_test.ts @@ -7,8 +7,8 @@ import {createEvent, InMemoryRunner, LlmAgent, LOAD_MEMORY} from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; describe('E2E LoadMemoryTool', () => { diff --git a/tests/e2e/tools/preload_memory_tool_test.ts b/tests/e2e/tools/preload_memory_tool_test.ts index 641571d96..40de8587b 100644 --- a/tests/e2e/tools/preload_memory_tool_test.ts +++ b/tests/e2e/tools/preload_memory_tool_test.ts @@ -12,8 +12,8 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import {describe, expect, it} from 'vitest'; describe('E2E PreloadMemoryTool', () => { diff --git a/tests/e2e/tools/rest_api_tool_auth_e2e_test.ts b/tests/e2e/tools/rest_api_tool_auth_e2e_test.ts index 50d55832d..459f3578e 100644 --- a/tests/e2e/tools/rest_api_tool_auth_e2e_test.ts +++ b/tests/e2e/tools/rest_api_tool_auth_e2e_test.ts @@ -7,10 +7,10 @@ import {InMemoryRunner, LlmAgent, RestApiTool} from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as http from 'http'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; +import * as path from 'node:path'; import {OpenAPIV3} from 'openapi-types'; -import * as path from 'path'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; describe('RestApiTool Auth E2E', () => { diff --git a/tests/e2e/tools/skills_registry_e2e_test.ts b/tests/e2e/tools/skills_registry_e2e_test.ts index cc31a6882..dfcd17bb7 100644 --- a/tests/e2e/tools/skills_registry_e2e_test.ts +++ b/tests/e2e/tools/skills_registry_e2e_test.ts @@ -12,9 +12,9 @@ import { } from '@google/adk'; import {createUserContent} from '@google/genai'; import * as dotenv from 'dotenv'; -import * as fs from 'fs'; -import * as path from 'path'; -import {fileURLToPath} from 'url'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import {fileURLToPath} from 'node:url'; import {describe, expect, it} from 'vitest'; const __filename = fileURLToPath(import.meta.url); diff --git a/vitest.config.ts b/vitest.config.ts index 1b7eaee63..16cbc834f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import path from 'path'; +import path from 'node:path'; import {defineConfig} from 'vitest/config'; /** From df33422c5b26f70ce395db0eb0779ae97d550970 Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Sun, 2 Aug 2026 15:25:13 -0700 Subject: [PATCH 2/2] chore: prefix the module built-in in the generated ESM banner with node: core/build.js and integrations/build.js prepend a createRequire banner to every emitted ESM file. It imported the built-in with the bare specifier 'module', so the shadowing hazard shipped inside published bundles and landed in consumers' dependency graphs rather than ours. --- core/build.js | 2 +- integrations/build.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/build.js b/core/build.js index 99d01f9d7..2717604f8 100644 --- a/core/build.js +++ b/core/build.js @@ -73,7 +73,7 @@ function build({ buildOptions.banner = { js: (buildOptions.banner?.js || '') + - `import {createRequire as topLevelCreateRequire} from 'module';\nconst require = topLevelCreateRequire(import.meta.url);`, + `import {createRequire as topLevelCreateRequire} from 'node:module';\nconst require = topLevelCreateRequire(import.meta.url);`, }; } diff --git a/integrations/build.js b/integrations/build.js index d07ba5194..a38958db3 100644 --- a/integrations/build.js +++ b/integrations/build.js @@ -67,7 +67,7 @@ function build({ buildOptions.banner = { js: (buildOptions.banner?.js || '') + - `import {createRequire as topLevelCreateRequire} from 'module';\nconst require = topLevelCreateRequire(import.meta.url);`, + `import {createRequire as topLevelCreateRequire} from 'node:module';\nconst require = topLevelCreateRequire(import.meta.url);`, }; }