Compare commits

...

2 Commits

Author SHA1 Message Date
Alisa 404828373e Merge branch 'main' into fix_benchmarking 2026-02-19 19:00:08 -08:00
Alisa Novikova 4a599db2bf fix(cli): resolve devtools build issues and update third-party notices 2026-02-19 18:11:46 -08:00
45 changed files with 5353 additions and 2960 deletions
@@ -56,6 +56,7 @@ creating a "discovery file."
}
}
```
- `port` (number, required): The port of the MCP server.
- `workspacePath` (string, required): A list of all open workspace root paths,
delimited by the OS-specific path separator (`:` for Linux/macOS, `;` for
+1 -1
View File
@@ -82,7 +82,7 @@ const commonAliases = {
const cliConfig = {
...baseConfig,
banner: {
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);`,
js: `const require = (await import('module')).createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);`,
},
entryPoints: ['packages/cli/index.ts'],
outfile: 'bundle/gemini.js',
+5076 -2718
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -66,6 +66,7 @@
"overrides": {
"ink": "npm:@jrichman/ink@6.4.11",
"wrap-ansi": "9.0.2",
"zod": "3.25.76",
"cliui": {
"wrap-ansi": "7.0.0"
}
@@ -92,7 +93,7 @@
"@types/shell-quote": "^1.7.5",
"@types/ws": "^8.18.1",
"@vitest/coverage-v8": "^3.1.1",
"@vitest/eslint-plugin": "^1.3.4",
"@vitest/eslint-plugin": "1.4.3",
"cross-env": "^7.0.3",
"depcheck": "^1.4.7",
"esbuild": "^0.25.0",
+2
View File
@@ -31,6 +31,7 @@
"dependencies": {
"@agentclientprotocol/sdk": "^0.12.0",
"@google/gemini-cli-core": "file:../core",
"@google/gemini-cli-devtools": "file:../devtools",
"@google/genai": "1.30.0",
"@iarna/toml": "^2.2.5",
"@modelcontextprotocol/sdk": "^1.23.0",
@@ -81,6 +82,7 @@
"@types/ws": "^8.5.10",
"@types/yargs": "^17.0.32",
"@xterm/headless": "^5.5.0",
"ink-testing-library": "^4.0.0",
"typescript": "^5.3.3",
"vitest": "^3.1.1"
},
@@ -292,9 +292,8 @@ System using model: \${MODEL_NAME}
});
expect(extension.skills![0].body).toContain('Value is: first');
const { updateSetting, ExtensionSettingScope } = await import(
'./extensions/extensionSettings.js'
);
const { updateSetting, ExtensionSettingScope } =
await import('./extensions/extensionSettings.js');
const extensionConfig =
await extensionManager.loadExtensionConfig(extensionPath);
+2 -3
View File
@@ -746,9 +746,8 @@ describe('gemini.tsx main function kitty protocol', () => {
});
it.skip('should log error when cleanupExpiredSessions fails', async () => {
const { cleanupExpiredSessions } = await import(
'./utils/sessionCleanup.js'
);
const { cleanupExpiredSessions } =
await import('./utils/sessionCleanup.js');
vi.mocked(cleanupExpiredSessions).mockRejectedValue(
new Error('Cleanup failed'),
);
+7 -3
View File
@@ -568,10 +568,14 @@ export async function main() {
adminControlsListner.setConfig(config);
if (config.isInteractive() && settings.merged.general.devtools) {
const { setupInitialActivityLogger } = await import(
'./utils/devtoolsService.js'
);
const { setupInitialActivityLogger, stopDevTools } =
await import('./utils/devtoolsService.js');
const { ActivityLogger } = await import('./utils/activityLogger.js');
await setupInitialActivityLogger(config);
registerCleanup(async () => {
await stopDevTools();
ActivityLogger.getInstance().dispose();
});
}
// Register config for telemetry shutdown
+2 -3
View File
@@ -180,9 +180,8 @@ describe('gemini.tsx main function cleanup', () => {
});
it('should log error when cleanupExpiredSessions fails', async () => {
const { loadCliConfig, parseArguments } = await import(
'./config/config.js'
);
const { loadCliConfig, parseArguments } =
await import('./config/config.js');
const { loadSettings } = await import('./config/settings.js');
cleanupMockState.shouldThrow = true;
cleanupMockState.called = false;
+10 -15
View File
@@ -212,9 +212,8 @@ describe('runNonInteractive', () => {
computeMergedSettings: vi.fn(),
} as unknown as LoadedSettings;
const { handleAtCommand } = await import(
'./ui/hooks/atCommandProcessor.js'
);
const { handleAtCommand } =
await import('./ui/hooks/atCommandProcessor.js');
vi.mocked(handleAtCommand).mockImplementation(async ({ query }) => ({
processedQuery: [{ text: query }],
}));
@@ -636,9 +635,8 @@ describe('runNonInteractive', () => {
it('should preprocess @include commands before sending to the model', async () => {
// 1. Mock the imported atCommandProcessor
const { handleAtCommand } = await import(
'./ui/hooks/atCommandProcessor.js'
);
const { handleAtCommand } =
await import('./ui/hooks/atCommandProcessor.js');
const mockHandleAtCommand = vi.mocked(handleAtCommand);
// 2. Define the raw input and the expected processed output
@@ -995,9 +993,8 @@ describe('runNonInteractive', () => {
});
it('should handle slash commands', async () => {
const nonInteractiveCliCommands = await import(
'./nonInteractiveCliCommands.js'
);
const nonInteractiveCliCommands =
await import('./nonInteractiveCliCommands.js');
const handleSlashCommandSpy = vi.spyOn(
nonInteractiveCliCommands,
'handleSlashCommand',
@@ -1276,13 +1273,11 @@ describe('runNonInteractive', () => {
it('should instantiate CommandService with correct loaders for slash commands', async () => {
// This test indirectly checks that handleSlashCommand is using the right loaders.
const { FileCommandLoader } = await import(
'./services/FileCommandLoader.js'
);
const { FileCommandLoader } =
await import('./services/FileCommandLoader.js');
const { McpPromptLoader } = await import('./services/McpPromptLoader.js');
const { BuiltinCommandLoader } = await import(
'./services/BuiltinCommandLoader.js'
);
const { BuiltinCommandLoader } =
await import('./services/BuiltinCommandLoader.js');
mockGetCommands.mockReturnValue([]); // No commands found, so it will fall through
const events: ServerGeminiStreamEvent[] = [
{ type: GeminiEventType.Content, value: 'Acknowledged' },
+2 -3
View File
@@ -72,9 +72,8 @@ export async function runNonInteractive({
});
if (process.env['GEMINI_CLI_ACTIVITY_LOG_TARGET']) {
const { setupInitialActivityLogger } = await import(
'./utils/devtoolsService.js'
);
const { setupInitialActivityLogger } =
await import('./utils/devtoolsService.js');
await setupInitialActivityLogger(config);
}
+2 -3
View File
@@ -42,9 +42,8 @@ import { AuthState } from '../ui/types.js';
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
const original =
await importOriginal<typeof import('@google/gemini-cli-core')>();
const { MockShellExecutionService: MockService } = await import(
'./MockShellExecutionService.js'
);
const { MockShellExecutionService: MockService } =
await import('./MockShellExecutionService.js');
// Register the real execution logic so MockShellExecutionService can fall back to it
MockService.setOriginalImplementation(original.ShellExecutionService.execute);
+2 -1
View File
@@ -357,7 +357,8 @@ export const render = (
debug: false,
exitOnCtrlC: false,
patchConsole: false,
onRender: (metrics: { output: string; staticOutput?: string }) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onRender: (metrics: any) => {
stdout.onRender(metrics.staticOutput ?? '', metrics.output);
},
});
+4 -6
View File
@@ -3292,9 +3292,8 @@ describe('AppContainer State Management', () => {
describe('Permission Handling', () => {
it('shows permission dialog when checkPermissions returns paths', async () => {
const { checkPermissions } = await import(
'./hooks/atCommandProcessor.js'
);
const { checkPermissions } =
await import('./hooks/atCommandProcessor.js');
vi.mocked(checkPermissions).mockResolvedValue(['/test/file.txt']);
let unmount: () => void;
@@ -3316,9 +3315,8 @@ describe('AppContainer State Management', () => {
it.each([true, false])(
'handles permissions when allowed is %s',
async (allowed) => {
const { checkPermissions } = await import(
'./hooks/atCommandProcessor.js'
);
const { checkPermissions } =
await import('./hooks/atCommandProcessor.js');
vi.mocked(checkPermissions).mockResolvedValue(['/test/file.txt']);
const addReadOnlyPathSpy = vi.spyOn(
mockConfig.getWorkspaceContext(),
+8 -11
View File
@@ -1392,9 +1392,9 @@ Logging in with Google... Restarting Gemini CLI to continue.
}, []);
const shouldShowIdePrompt = Boolean(
currentIDE &&
!config.getIdeMode() &&
!settings.merged.ide.hasSeenNudge &&
!idePromptAnswered,
!config.getIdeMode() &&
!settings.merged.ide.hasSeenNudge &&
!idePromptAnswered,
);
const [showErrorDetails, setShowErrorDetails] = useState<boolean>(false);
@@ -1656,9 +1656,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
if (keyMatchers[Command.SHOW_ERROR_DETAILS](key)) {
if (settings.merged.general.devtools) {
void (async () => {
const { toggleDevToolsPanel } = await import(
'../utils/devtoolsService.js'
);
const { toggleDevToolsPanel } =
await import('../utils/devtoolsService.js');
await toggleDevToolsPanel(
config,
showErrorDetails,
@@ -2073,11 +2072,9 @@ Logging in with Google... Restarting Gemini CLI to continue.
let isMounted = true;
const fetchBannerTexts = async () => {
const [defaultBanner, warningBanner] = await Promise.all([
// TODO: temporarily disabling the banner, it will be re-added.
'',
config.getBannerTextCapacityIssues(),
]);
// TODO: temporarily disabling the banner, it will be re-added.
const defaultBanner = '';
const warningBanner = await config.getBannerTextCapacityIssues();
if (isMounted) {
setDefaultBannerText(defaultBanner);
@@ -73,9 +73,8 @@ describe('authCommand', () => {
const logoutCommand = authCommand.subCommands?.[1];
expect(logoutCommand?.name).toBe('logout');
const { clearCachedCredentialFile } = await import(
'@google/gemini-cli-core'
);
const { clearCachedCredentialFile } =
await import('@google/gemini-cli-core');
await logoutCommand!.action!(mockContext, '');
@@ -1048,9 +1048,8 @@ describe('extensionsCommand', () => {
const prompts = (await import('prompts')).default;
vi.mocked(prompts).mockResolvedValue({ overwrite: true });
const { getScopedEnvContents } = await import(
'../../config/extensions/extensionSettings.js'
);
const { getScopedEnvContents } =
await import('../../config/extensions/extensionSettings.js');
vi.mocked(getScopedEnvContents).mockResolvedValue({});
});
+4 -4
View File
@@ -142,15 +142,15 @@ const inScreen = (): boolean =>
const isSSH = (): boolean =>
Boolean(
process.env['SSH_TTY'] ||
process.env['SSH_CONNECTION'] ||
process.env['SSH_CLIENT'],
process.env['SSH_CONNECTION'] ||
process.env['SSH_CLIENT'],
);
const isWSL = (): boolean =>
Boolean(
process.env['WSL_DISTRO_NAME'] ||
process.env['WSLENV'] ||
process.env['WSL_INTEROP'],
process.env['WSLENV'] ||
process.env['WSL_INTEROP'],
);
const isWindowsTerminal = (): boolean =>
+10 -15
View File
@@ -220,9 +220,8 @@ describe('rewindFileOps', () => {
});
it('reverts exact match', async () => {
const { getFileDiffFromResultDisplay } = await import(
'@google/gemini-cli-core'
);
const { getFileDiffFromResultDisplay } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
filePath: '/abs/path/test.ts',
fileName: 'test.ts',
@@ -270,9 +269,8 @@ describe('rewindFileOps', () => {
});
it('deletes new file on revert', async () => {
const { getFileDiffFromResultDisplay } = await import(
'@google/gemini-cli-core'
);
const { getFileDiffFromResultDisplay } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
filePath: '/abs/path/new.ts',
fileName: 'new.ts',
@@ -317,9 +315,8 @@ describe('rewindFileOps', () => {
});
it('handles smart revert (patching) successfully', async () => {
const { getFileDiffFromResultDisplay } = await import(
'@google/gemini-cli-core'
);
const { getFileDiffFromResultDisplay } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
filePath: '/abs/path/test.ts',
fileName: 'test.ts',
@@ -369,9 +366,8 @@ describe('rewindFileOps', () => {
});
it('emits warning on smart revert failure', async () => {
const { getFileDiffFromResultDisplay } = await import(
'@google/gemini-cli-core'
);
const { getFileDiffFromResultDisplay } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
filePath: '/abs/path/test.ts',
fileName: 'test.ts',
@@ -421,9 +417,8 @@ describe('rewindFileOps', () => {
});
it('emits error if fs.readFile fails with a generic error', async () => {
const { getFileDiffFromResultDisplay } = await import(
'@google/gemini-cli-core'
);
const { getFileDiffFromResultDisplay } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
filePath: '/abs/path/test.ts',
fileName: 'test.ts',
+3 -2
View File
@@ -47,13 +47,14 @@ describe('textUtils', () => {
describe('getCachedStringWidth', () => {
it('should handle unicode characters that crash string-width', () => {
// U+0602 caused string-width to crash (see #16418)
// Newer versions of string-width correctly identify it as width 0.
const char = '؂';
expect(getCachedStringWidth(char)).toBe(1);
expect(getCachedStringWidth(char)).toBe(0);
});
it('should handle unicode characters that crash string-width with ANSI codes', () => {
const charWithAnsi = '\u001b[31m' + '؂' + '\u001b[0m';
expect(getCachedStringWidth(charWithAnsi)).toBe(1);
expect(getCachedStringWidth(charWithAnsi)).toBe(0);
});
});
+13
View File
@@ -561,6 +561,13 @@ export class ActivityLogger extends EventEmitter {
}
this.emit('console', enriched);
}
dispose() {
this.networkLoggingEnabled = false;
this.removeAllListeners();
this.clearBufferedLogs();
this.emit('dispose');
}
}
/**
@@ -820,6 +827,12 @@ function setupNetworkLogging(
flushBuffer();
});
capture.on('dispose', () => {
if (reconnectTimer) clearTimeout(reconnectTimer);
if (ws) ws.close();
cleanup();
});
// Cleanup on process exit
process.on('exit', () => {
if (reconnectTimer) clearTimeout(reconnectTimer);
+6 -6
View File
@@ -100,14 +100,14 @@ async function drainStdin() {
await new Promise((resolve) => setTimeout(resolve, 50));
}
export async function cleanupCheckpoints() {
const storage = new Storage(process.cwd());
await storage.initialize();
const tempDir = storage.getProjectTempDir();
const checkpointsDir = join(tempDir, 'checkpoints');
export async function cleanupCheckpoints(cwd?: string) {
try {
const storage = new Storage(cwd || process.cwd());
await storage.initialize();
const tempDir = storage.getProjectTempDir();
const checkpointsDir = join(tempDir, 'checkpoints');
await fs.rm(checkpointsDir, { recursive: true, force: true });
} catch {
// Ignore errors if the directory doesn't exist or fails to delete.
// Ignore errors if the directory doesn't exist, process.cwd() fails, or it fails to delete.
}
}
+17 -3
View File
@@ -230,9 +230,8 @@ export async function toggleDevToolsPanel(
}
try {
const { openBrowserSecurely, shouldLaunchBrowser } = await import(
'@google/gemini-cli-core'
);
const { openBrowserSecurely, shouldLaunchBrowser } =
await import('@google/gemini-cli-core');
const url = await startDevToolsServer(config);
if (shouldLaunchBrowser()) {
try {
@@ -257,3 +256,18 @@ export function resetForTesting() {
serverStartPromise = null;
connectedUrl = null;
}
/**
* Stops the DevTools server if it was started by this process.
*/
export async function stopDevTools() {
try {
const mod = await import('@google/gemini-cli-devtools');
const devtools: IDevTools = mod.DevTools.getInstance();
await devtools.stop();
serverStartPromise = null;
connectedUrl = null;
} catch (err) {
debugLogger.debug('Failed to stop DevTools:', err);
}
}
+1 -1
View File
@@ -14,5 +14,5 @@
"./package.json"
],
"exclude": ["node_modules", "dist"],
"references": [{ "path": "../core" }]
"references": [{ "path": "../core" }, { "path": "../devtools" }]
}
+2 -4
View File
@@ -28,8 +28,7 @@ interface FrontmatterBaseAgentDefinition {
display_name?: string;
}
interface FrontmatterLocalAgentDefinition
extends FrontmatterBaseAgentDefinition {
interface FrontmatterLocalAgentDefinition extends FrontmatterBaseAgentDefinition {
kind: 'local';
description: string;
tools?: string[];
@@ -57,8 +56,7 @@ interface FrontmatterAuthConfig {
password?: string;
}
interface FrontmatterRemoteAgentDefinition
extends FrontmatterBaseAgentDefinition {
interface FrontmatterRemoteAgentDefinition extends FrontmatterBaseAgentDefinition {
kind: 'remote';
description?: string;
agent_card_url: string;
+6 -9
View File
@@ -1374,9 +1374,8 @@ describe('oauth2', () => {
});
it('should save credentials using OAuthCredentialStorage during web login', async () => {
const { OAuthCredentialStorage } = await import(
'./oauth-credential-storage.js'
);
const { OAuthCredentialStorage } =
await import('./oauth-credential-storage.js');
const mockAuthUrl = 'https://example.com/auth';
const mockCode = 'test-code';
const mockState = 'test-state';
@@ -1476,9 +1475,8 @@ describe('oauth2', () => {
});
it('should load credentials using OAuthCredentialStorage and not from file', async () => {
const { OAuthCredentialStorage } = await import(
'./oauth-credential-storage.js'
);
const { OAuthCredentialStorage } =
await import('./oauth-credential-storage.js');
const cachedCreds = { refresh_token: 'cached-encrypted-token' };
vi.mocked(OAuthCredentialStorage.loadCredentials).mockResolvedValue(
cachedCreds,
@@ -1514,9 +1512,8 @@ describe('oauth2', () => {
});
it('should clear credentials using OAuthCredentialStorage', async () => {
const { OAuthCredentialStorage } = await import(
'./oauth-credential-storage.js'
);
const { OAuthCredentialStorage } =
await import('./oauth-credential-storage.js');
// Create a dummy unencrypted credential file. It should not be deleted.
const credsPath = path.join(tempHomeDir, GEMINI_DIR, 'oauth_creds.json');
+4 -6
View File
@@ -304,9 +304,8 @@ describe('Server Config (config.ts)', () => {
// interactive defaults to false
});
const { McpClientManager } = await import(
'../tools/mcp-client-manager.js'
);
const { McpClientManager } =
await import('../tools/mcp-client-manager.js');
let mcpStarted = false;
vi.mocked(McpClientManager).mockImplementation(
@@ -333,9 +332,8 @@ describe('Server Config (config.ts)', () => {
interactive: true,
});
const { McpClientManager } = await import(
'../tools/mcp-client-manager.js'
);
const { McpClientManager } =
await import('../tools/mcp-client-manager.js');
let mcpStarted = false;
let resolveMcp: (value: unknown) => void;
const mcpPromise = new Promise((resolve) => {
+2 -3
View File
@@ -1636,9 +1636,8 @@ export class Config {
if (this.experimentalJitContext && this.contextManager) {
await this.contextManager.refresh();
} else {
const { refreshServerHierarchicalMemory } = await import(
'../utils/memoryDiscovery.js'
);
const { refreshServerHierarchicalMemory } =
await import('../utils/memoryDiscovery.js');
await refreshServerHierarchicalMemory(this);
}
if (this.geminiClient?.isInitialized()) {
+12 -18
View File
@@ -1159,9 +1159,8 @@ ${JSON.stringify(
true,
);
// Get the mocked checkNextSpeaker function and configure it to trigger infinite loop
const { checkNextSpeaker } = await import(
'../utils/nextSpeakerChecker.js'
);
const { checkNextSpeaker } =
await import('../utils/nextSpeakerChecker.js');
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
mockCheckNextSpeaker.mockResolvedValue({
next_speaker: 'model',
@@ -1283,9 +1282,8 @@ ${JSON.stringify(
// someone tries to bypass it by calling with a very large turns value
// Get the mocked checkNextSpeaker function and configure it to trigger infinite loop
const { checkNextSpeaker } = await import(
'../utils/nextSpeakerChecker.js'
);
const { checkNextSpeaker } =
await import('../utils/nextSpeakerChecker.js');
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
mockCheckNextSpeaker.mockResolvedValue({
next_speaker: 'model',
@@ -2791,9 +2789,8 @@ ${JSON.stringify(
it('should not call checkNextSpeaker when turn.run() yields an error', async () => {
// Arrange
const { checkNextSpeaker } = await import(
'../utils/nextSpeakerChecker.js'
);
const { checkNextSpeaker } =
await import('../utils/nextSpeakerChecker.js');
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
const mockStream = (async function* () {
@@ -2828,9 +2825,8 @@ ${JSON.stringify(
it('should not call checkNextSpeaker when turn.run() yields a value then an error', async () => {
// Arrange
const { checkNextSpeaker } = await import(
'../utils/nextSpeakerChecker.js'
);
const { checkNextSpeaker } =
await import('../utils/nextSpeakerChecker.js');
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
const mockStream = (async function* () {
@@ -2995,9 +2991,8 @@ ${JSON.stringify(
});
it('should fire BeforeAgent once and AfterAgent once even with recursion', async () => {
const { checkNextSpeaker } = await import(
'../utils/nextSpeakerChecker.js'
);
const { checkNextSpeaker } =
await import('../utils/nextSpeakerChecker.js');
vi.mocked(checkNextSpeaker)
.mockResolvedValueOnce({ next_speaker: 'model', reasoning: 'more' })
.mockResolvedValueOnce(null);
@@ -3035,9 +3030,8 @@ ${JSON.stringify(
});
it('should use original request in AfterAgent hook even when continuation happened', async () => {
const { checkNextSpeaker } = await import(
'../utils/nextSpeakerChecker.js'
);
const { checkNextSpeaker } =
await import('../utils/nextSpeakerChecker.js');
vi.mocked(checkNextSpeaker)
.mockResolvedValueOnce({ next_speaker: 'model', reasoning: 'more' })
.mockResolvedValueOnce(null);
@@ -27,9 +27,8 @@ export class HybridTokenStorage extends BaseTokenStorage {
if (!forceFileStorage) {
try {
const { KeychainTokenStorage } = await import(
'./keychain-token-storage.js'
);
const { KeychainTokenStorage } =
await import('./keychain-token-storage.js');
const keychainStorage = new KeychainTokenStorage(this.serviceName);
const isAvailable = await keychainStorage.isAvailable();
@@ -49,9 +49,8 @@ describe('KeychainTokenStorage', () => {
vi.resetAllMocks();
// Reset the internal state of the keychain-token-storage module
vi.resetModules();
const { KeychainTokenStorage } = await import(
'./keychain-token-storage.js'
);
const { KeychainTokenStorage } =
await import('./keychain-token-storage.js');
storage = new KeychainTokenStorage(mockServiceName);
});
+6 -9
View File
@@ -497,9 +497,8 @@ describe('createPolicyEngineConfig', () => {
stat: mockStat,
}));
vi.resetModules();
const { createPolicyEngineConfig: createConfig } = await import(
'./config.js'
);
const { createPolicyEngineConfig: createConfig } =
await import('./config.js');
const config = await createConfig(
settings,
@@ -580,9 +579,8 @@ describe('createPolicyEngineConfig', () => {
it('should have YOLO allow-all rule beat write tool rules in YOLO mode', async () => {
vi.resetModules();
vi.doUnmock('node:fs/promises');
const { createPolicyEngineConfig: createConfig } = await import(
'./config.js'
);
const { createPolicyEngineConfig: createConfig } =
await import('./config.js');
// Re-mock Storage after resetModules because it was reloaded
const { Storage: FreshStorage } = await import('../config/storage.js');
vi.spyOn(FreshStorage, 'getUserPoliciesDir').mockReturnValue(
@@ -988,9 +986,8 @@ name = "invalid-name"
it('should have default ASK_USER rule for discovered tools', async () => {
vi.resetModules();
vi.doUnmock('node:fs/promises');
const { createPolicyEngineConfig: createConfig } = await import(
'./config.js'
);
const { createPolicyEngineConfig: createConfig } =
await import('./config.js');
// Re-mock Storage after resetModules because it was reloaded
const { Storage: FreshStorage } = await import('../config/storage.js');
vi.spyOn(FreshStorage, 'getUserPoliciesDir').mockReturnValue(
@@ -66,9 +66,8 @@ describe('sessionSummaryUtils', () => {
mockGenerateSummary = vi.fn().mockResolvedValue('Add dark mode to the app');
// Import the mocked module to access the constructor
const { SessionSummaryService } = await import(
'./sessionSummaryService.js'
);
const { SessionSummaryService } =
await import('./sessionSummaryService.js');
(
SessionSummaryService as unknown as ReturnType<typeof vi.fn>
).mockImplementation(() => ({
@@ -1475,9 +1475,8 @@ describe('ShellExecutionService environment variables', () => {
vi.stubEnv('GEMINI_CLI_TEST_VAR', 'test-value'); // A test var that should be kept
vi.resetModules();
const { ShellExecutionService } = await import(
'./shellExecutionService.js'
);
const { ShellExecutionService } =
await import('./shellExecutionService.js');
// Test pty path
await ShellExecutionService.execute(
@@ -1534,9 +1533,8 @@ describe('ShellExecutionService environment variables', () => {
vi.stubEnv('GEMINI_CLI_TEST_VAR', 'test-value'); // A test var that should be kept
vi.resetModules();
const { ShellExecutionService } = await import(
'./shellExecutionService.js'
);
const { ShellExecutionService } =
await import('./shellExecutionService.js');
// Test pty path
await ShellExecutionService.execute(
@@ -1590,9 +1588,8 @@ describe('ShellExecutionService environment variables', () => {
vi.stubEnv('GITHUB_SHA', '');
vi.stubEnv('SURFACE', '');
vi.resetModules();
const { ShellExecutionService } = await import(
'./shellExecutionService.js'
);
const { ShellExecutionService } =
await import('./shellExecutionService.js');
// Test pty path
await ShellExecutionService.execute(
+3 -2
View File
@@ -22,8 +22,9 @@ import { debugLogger } from '../utils/debugLogger.js';
/**
* A declarative tool that supports a modify operation.
*/
export interface ModifiableDeclarativeTool<TParams extends object>
extends DeclarativeTool<TParams, ToolResult> {
export interface ModifiableDeclarativeTool<
TParams extends object,
> extends DeclarativeTool<TParams, ToolResult> {
getModifyContext(abortSignal: AbortSignal): ModifyContext<TParams>;
}
+2 -4
View File
@@ -83,8 +83,7 @@ export interface PolicyUpdateOptions {
export abstract class BaseToolInvocation<
TParams extends object,
TResult extends ToolResult,
> implements ToolInvocation<TParams, TResult>
{
> implements ToolInvocation<TParams, TResult> {
constructor(
readonly params: TParams,
protected readonly messageBus: MessageBus,
@@ -353,8 +352,7 @@ export interface ToolBuilder<
export abstract class DeclarativeTool<
TParams extends object,
TResult extends ToolResult,
> implements ToolBuilder<TParams, TResult>
{
> implements ToolBuilder<TParams, TResult> {
constructor(
readonly name: string,
readonly displayName: string,
+2 -1
View File
@@ -916,7 +916,8 @@ describe('WriteFileTool', () => {
const content = 'test content';
let existsSyncSpy: // eslint-disable-next-line @typescript-eslint/no-explicit-any
ReturnType<typeof vi.spyOn<any, 'existsSync'>> | undefined = undefined;
ReturnType<typeof vi.spyOn<any, 'existsSync'>> | undefined =
undefined;
try {
if (mockFsExistsSync) {
+10 -8
View File
@@ -5,7 +5,7 @@
*/
import React, { useState, useEffect, useRef, useMemo } from 'react';
import { useDevToolsData, type ConsoleLog, type NetworkLog } from './hooks';
import { useDevToolsData, type ConsoleLog, type NetworkLog } from './hooks.js';
type ThemeMode = 'light' | 'dark' | null; // null means follow system
@@ -115,7 +115,6 @@ export default function App() {
if (!networkMap.has(id)) {
networkMap.set(id, {
...payload,
type,
timestamp,
id,
} as NetworkLog);
@@ -125,8 +124,7 @@ export default function App() {
networkMap.set(id, {
...existing,
...payload,
// Ensure we don't overwrite the original timestamp or type
type: existing.type,
// Ensure we don't overwrite the original timestamp
timestamp: existing.timestamp,
} as NetworkLog);
}
@@ -158,7 +156,7 @@ export default function App() {
const entries: Array<{ timestamp: number; data: object }> = [];
// Export console logs
filteredConsoleLogs.forEach((log) => {
filteredConsoleLogs.forEach((log: ConsoleLog) => {
entries.push({
timestamp: log.timestamp,
data: {
@@ -171,7 +169,7 @@ export default function App() {
});
// Export network logs
filteredNetworkLogs.forEach((log) => {
filteredNetworkLogs.forEach((log: NetworkLog) => {
entries.push({
timestamp: log.timestamp,
data: {
@@ -230,7 +228,9 @@ export default function App() {
if (selectedSessionId === importedSessionId && importedLogs) {
return importedLogs.console;
}
return consoleLogs.filter((l) => l.sessionId === selectedSessionId);
return consoleLogs.filter(
(l: ConsoleLog) => l.sessionId === selectedSessionId,
);
}, [consoleLogs, selectedSessionId, importedSessionId, importedLogs]);
const filteredNetworkLogs = useMemo(() => {
@@ -238,7 +238,9 @@ export default function App() {
if (selectedSessionId === importedSessionId && importedLogs) {
return importedLogs.network;
}
return networkLogs.filter((l) => l.sessionId === selectedSessionId);
return networkLogs.filter(
(l: NetworkLog) => l.sessionId === selectedSessionId,
);
}, [networkLogs, selectedSessionId, importedSessionId, importedLogs]);
return (
+1 -1
View File
@@ -6,7 +6,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import App from './App.js';
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
+1 -1
View File
@@ -12,7 +12,7 @@
}
},
"scripts": {
"build": "npm run build:client && tsc -p tsconfig.build.json",
"build": "npm run build:client && tsc -p tsconfig.json",
"build:client": "node esbuild.client.js"
},
"files": [
+4 -2
View File
@@ -3,8 +3,10 @@
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"jsx": "react-jsx",
"allowImportingTsExtensions": true,
"noEmit": true
"skipLibCheck": true,
"composite": true,
"noEmit": false,
"outDir": "dist"
},
"include": ["src", "client/src"]
}
+87 -66
View File
@@ -31,15 +31,15 @@ SOFTWARE.
@hono/node-server@1.19.9
(https://github.com/honojs/node-server.git)
License text not found.
License: MIT
============================================================
ajv@6.12.6
(https://github.com/ajv-validator/ajv.git)
ajv@8.18.0
(No repository found)
The MIT License (MIT)
Copyright (c) 2015-2017 Evgeny Poberezkin
Copyright (c) 2015-2021 Evgeny Poberezkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -89,34 +89,44 @@ SOFTWARE.
============================================================
fast-json-stable-stringify@2.1.0
(git://github.com/epoberezkin/fast-json-stable-stringify.git)
fast-uri@3.1.0
(git+https://github.com/fastify/fast-uri.git)
This software is released under the MIT license:
Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
Copyright (c) 2021-present The Fastify team
All rights reserved.
Copyright (c) 2017 Evgeny Poberezkin
Copyright (c) 2013 James Halliday
The Fastify team members are listed at https://github.com/fastify/fastify#team.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* * *
The complete list of contributors can be found at:
- https://github.com/garycourt/uri-js/graphs/contributors
============================================================
json-schema-traverse@0.4.1
json-schema-traverse@1.0.0
(git+https://github.com/epoberezkin/json-schema-traverse.git)
MIT License
@@ -143,46 +153,30 @@ SOFTWARE.
============================================================
uri-js@4.4.1
(http://github.com/garycourt/uri-js)
require-from-string@2.0.2
(No repository found)
Copyright 2011 Gary Court. All rights reserved.
The MIT License (MIT)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THIS SOFTWARE IS PROVIDED BY GARY COURT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Gary Court.
============================================================
punycode@2.3.1
(https://github.com/mathiasbynens/punycode.js.git)
Copyright Mathias Bynens <https://mathiasbynens.be/>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
============================================================
@@ -241,7 +235,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
============================================================
cors@2.8.5
cors@2.8.6
(No repository found)
(The MIT License)
@@ -466,7 +460,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
============================================================
eventsource-parser@3.0.3
eventsource-parser@3.0.6
(git+ssh://git@github.com/rexxars/eventsource-parser.git)
MIT License
@@ -905,8 +899,8 @@ SOFTWARE.
============================================================
iconv-lite@0.6.3
(git://github.com/ashtuchkin/iconv-lite.git)
iconv-lite@0.7.2
(https://github.com/pillarjs/iconv-lite.git)
Copyright (c) 2011 Alexander Shtuchkin
@@ -1016,7 +1010,7 @@ THE SOFTWARE.
============================================================
qs@6.14.2
qs@6.15.0
(https://github.com/ljharb/qs.git)
BSD 3-Clause License
@@ -2129,6 +2123,33 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
============================================================
path-to-regexp@6.3.0
(https://github.com/pillarjs/path-to-regexp.git)
The MIT License (MIT)
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
============================================================
send@1.2.1
(No repository found)
@@ -2241,7 +2262,7 @@ THE SOFTWARE.
============================================================
hono@4.11.9
hono@4.12.0
(git+https://github.com/honojs/hono.git)
MIT License
@@ -2358,7 +2379,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
============================================================
pkce-challenge@5.0.0
pkce-challenge@5.0.1
(git+https://github.com/crouchcd/pkce-challenge.git)
MIT License
@@ -78,6 +78,8 @@ async function getDependencyLicense(depName, depVersion) {
`Warning: Failed to read license file for ${depName}: ${e.message}`,
);
}
} else if (depPackageJson.license) {
licenseContent = `License: ${depPackageJson.license}`;
} else {
console.warn(`Warning: Could not find license file for ${depName}`);
}
+10
View File
@@ -22,6 +22,16 @@ import { existsSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
// Increase memory limit for all subprocesses (tsc, etc) to prevent OOM in CI.
if (
!process.env.NODE_OPTIONS ||
!process.env.NODE_OPTIONS.includes('max-old-space-size')
) {
process.env.NODE_OPTIONS = `${
process.env.NODE_OPTIONS || ''
} --max-old-space-size=8192`.trim();
}
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = join(__dirname, '..');
+6
View File
@@ -124,6 +124,12 @@ const LINTERS = {
function runCommand(command, stdio = 'inherit') {
try {
const env = { ...process.env };
// Increase memory limit for all subprocesses (ESLint, etc) to prevent OOM in CI.
if (!env.NODE_OPTIONS || !env.NODE_OPTIONS.includes('max-old-space-size')) {
env.NODE_OPTIONS = `${
env.NODE_OPTIONS || ''
} --max-old-space-size=8192`.trim();
}
const nodeBin = join(process.cwd(), 'node_modules', '.bin');
env.PATH = `${nodeBin}:${TEMP_DIR}/actionlint:${TEMP_DIR}/shellcheck:${PYTHON_VENV_PATH}/bin:${env.PATH}`;
execSync(command, { stdio, env });