Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export default tseslint.config(
radix: 'error',
'default-case': 'error',
'@typescript-eslint/no-floating-promises': ['error'],
'@typescript-eslint/no-unnecessary-type-assertion': ['error'],
},
},
{
Expand Down
14 changes: 4 additions & 10 deletions packages/a2a-server/src/agent/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import type {
RequestContext,
ExecutionEventBus,
} from '@a2a-js/sdk/server';
import type {
ToolCallRequestInfo,
ServerGeminiToolCallRequestEvent,
Config,
} from '@google/gemini-cli-core';
import type { ToolCallRequestInfo, Config } from '@google/gemini-cli-core';
import {
GeminiEventType,
SimpleExtensionLoader,
Expand Down Expand Up @@ -287,8 +283,8 @@ export class CoderAgentExecutor implements AgentExecutor {
requestContext: RequestContext,
eventBus: ExecutionEventBus,
): Promise<void> {
const userMessage = requestContext.userMessage as Message;
const sdkTask = requestContext.task as SDKTask | undefined;
const userMessage = requestContext.userMessage;
const sdkTask = requestContext.task;

const taskId = sdkTask?.id || userMessage.taskId || uuidv4();
const contextId: string =
Expand Down Expand Up @@ -485,9 +481,7 @@ export class CoderAgentExecutor implements AgentExecutor {
throw new Error('Execution aborted');
}
if (event.type === GeminiEventType.ToolCallRequest) {
toolCallRequests.push(
(event as ServerGeminiToolCallRequestEvent).value,
);
toolCallRequests.push(event.value);
continue;
}
await currentTask.acceptAgentMessage(event);
Expand Down
7 changes: 1 addition & 6 deletions packages/a2a-server/src/agent/task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,7 @@ describe('Task', () => {
};

// @ts-expect-error - Calling private constructor
task = new Task(
'task-id',
'context-id',
mockConfig as Config,
mockEventBus,
);
task = new Task('task-id', 'context-id', mockConfig, mockEventBus);

// Spy on the method we want to check calls for
setTaskStateAndPublishUpdateSpy = vi.spyOn(
Expand Down
4 changes: 2 additions & 2 deletions packages/a2a-server/src/agent/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,8 @@ export class Task {
return false;
}

const callId = part.data['callId'] as string;
const outcomeString = part.data['outcome'] as string;
const callId = part.data['callId'];
const outcomeString = part.data['outcome'];
let confirmationOutcome: ToolConfirmationOutcome | undefined;

if (outcomeString === 'proceed_once') {
Expand Down
2 changes: 1 addition & 1 deletion packages/a2a-server/src/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function resolveEnvVarsInString(value: string): string {
return value.replace(envVarRegex, (match, varName1, varName2) => {
const varName = varName1 || varName2;
if (process && process.env && typeof process.env[varName] === 'string') {
return process.env[varName]!;
return process.env[varName];
}
return match;
});
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/extensions/disable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Mock,
} from 'vitest';
import { format } from 'node:util';
import { type CommandModule, type Argv } from 'yargs';
import { type Argv } from 'yargs';
import { handleDisable, disableCommand } from './disable.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import {
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('extensions disable command', () => {
});

describe('disableCommand', () => {
const command = disableCommand as CommandModule;
const command = disableCommand;

it('should have correct command and describe', () => {
expect(command.command).toBe('disable [--scope] <name>');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/extensions/disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const disableCommand: CommandModule = {
argv.scope &&
!Object.values(SettingScope)
.map((s) => s.toLowerCase())
.includes((argv.scope as string).toLowerCase())
.includes(argv.scope.toLowerCase())
) {
throw new Error(
`Invalid scope: ${argv.scope}. Please use one of ${Object.values(
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/extensions/enable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Mock,
} from 'vitest';
import { format } from 'node:util';
import { type CommandModule, type Argv } from 'yargs';
import { type Argv } from 'yargs';
import { handleEnable, enableCommand } from './enable.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import {
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('extensions enable command', () => {
});

describe('enableCommand', () => {
const command = enableCommand as CommandModule;
const command = enableCommand;

it('should have correct command and describe', () => {
expect(command.command).toBe('enable [--scope] <name>');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/extensions/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const enableCommand: CommandModule = {
argv.scope &&
!Object.values(SettingScope)
.map((s) => s.toLowerCase())
.includes((argv.scope as string).toLowerCase())
.includes(argv.scope.toLowerCase())
) {
throw new Error(
`Invalid scope: ${argv.scope}. Please use one of ${Object.values(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {
describe,
it,
expect,
vi,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';
Expand Down Expand Up @@ -90,7 +82,7 @@ describe('MCP Server Example', () => {
json: vi.fn().mockResolvedValue(mockPosts),
});

const toolFn = (mockRegisterTool as Mock).mock.calls[0][2];
const toolFn = mockRegisterTool.mock.calls[0][2];
const result = await toolFn();

expect(global.fetch).toHaveBeenCalledWith(
Expand All @@ -109,7 +101,7 @@ describe('MCP Server Example', () => {

describe('poem-writer prompt implementation', () => {
it('should generate a prompt with a title', () => {
const promptFn = (mockRegisterPrompt as Mock).mock.calls[0][2];
const promptFn = mockRegisterPrompt.mock.calls[0][2];
const result = promptFn({ title: 'My Poem' });
expect(result).toEqual({
messages: [
Expand All @@ -125,7 +117,7 @@ describe('MCP Server Example', () => {
});

it('should generate a prompt with a title and mood', () => {
const promptFn = (mockRegisterPrompt as Mock).mock.calls[0][2];
const promptFn = mockRegisterPrompt.mock.calls[0][2];
const result = promptFn({ title: 'My Poem', mood: 'sad' });
expect(result).toEqual({
messages: [
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/extensions/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Mock,
} from 'vitest';
import { format } from 'node:util';
import { type CommandModule, type Argv } from 'yargs';
import { type Argv } from 'yargs';
import { handleLink, linkCommand } from './link.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import { loadSettings, type LoadedSettings } from '../../config/settings.js';
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('extensions link command', () => {
});

describe('linkCommand', () => {
const command = linkCommand as CommandModule;
const command = linkCommand;

it('should have correct command and describe', () => {
expect(command.command).toBe('link <path>');
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/extensions/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import { format } from 'node:util';
import { type CommandModule } from 'yargs';
import { handleList, listCommand } from './list.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import { loadSettings, type LoadedSettings } from '../../config/settings.js';
Expand Down Expand Up @@ -124,7 +123,7 @@ describe('extensions list command', () => {
});

describe('listCommand', () => {
const command = listCommand as CommandModule;
const command = listCommand;

it('should have correct command and describe', () => {
expect(command.command).toBe('list');
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/extensions/uninstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Mock,
} from 'vitest';
import { format } from 'node:util';
import { type CommandModule, type Argv } from 'yargs';
import { type Argv } from 'yargs';
import { handleUninstall, uninstallCommand } from './uninstall.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import { loadSettings, type LoadedSettings } from '../../config/settings.js';
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('extensions uninstall command', () => {
});

describe('uninstallCommand', () => {
const command = uninstallCommand as CommandModule;
const command = uninstallCommand;

it('should have correct command and describe', () => {
expect(command.command).toBe('uninstall <names..>');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/extensions/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const uninstallCommand: CommandModule = {
array: true,
})
.check((argv) => {
if (!argv.names || (argv.names as string[]).length === 0) {
if (!argv.names || argv.names.length === 0) {
throw new Error(
'Please include at least one extension name to uninstall as a positional argument.',
);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/extensions/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Mock,
} from 'vitest';
import { format } from 'node:util';
import { type CommandModule, type Argv } from 'yargs';
import { type Argv } from 'yargs';
import { handleUpdate, updateCommand } from './update.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import { loadSettings, type LoadedSettings } from '../../config/settings.js';
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('extensions update command', () => {
});

describe('updateCommand', () => {
const command = updateCommand as CommandModule;
const command = updateCommand;

it('should have correct command and describe', () => {
expect(command.command).toBe('update [<name>] [--all]');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ vi.mock('fs', async (importOriginal) => {
if (mockPaths.has(p.toString())) {
return { isDirectory: () => true } as unknown as import('fs').Stats;
}
return (actualFs as typeof import('fs')).statSync(p as unknown as string);
return actualFs.statSync(p as unknown as string);
}),
realpathSync: vi.fn((p) => p),
};
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/config/extension-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class ExtensionManager extends ExtensionLoader {
'Extensions not yet loaded, must call `loadExtensions` first',
);
}
return this.loadedExtensions!;
return this.loadedExtensions;
}

async installOrUpdateExtension(
Expand Down Expand Up @@ -319,7 +319,7 @@ export class ExtensionManager extends ExtensionLoader {

// TODO: Gracefully handle this call failing, we should back up the old
// extension prior to overwriting it and then restore and restart it.
extension = await this.loadExtension(destinationPath)!;
extension = await this.loadExtension(destinationPath);
if (!extension) {
throw new Error(`Extension not found`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/config/extensions/github_fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function fetchJson<T>(
if (!res.headers.location) {
return reject(new Error('No location header in redirect response'));
}
fetchJson<T>(res.headers.location!, redirectCount++)
fetchJson<T>(res.headers.location, redirectCount++)
.then(resolve)
.catch(reject);
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/config/settings-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function buildZodSchemaFromJsonSchema(def: any): z.ZodTypeAny {
if (def.anyOf) {
return z.union(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
def.anyOf.map((d: any) => buildZodSchemaFromJsonSchema(d)) as any,
def.anyOf.map((d: any) => buildZodSchemaFromJsonSchema(d)),
);
}

Expand Down
34 changes: 15 additions & 19 deletions packages/cli/src/config/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,7 @@ describe('Settings Loading and Merging', () => {
beforeEach(() => {
vi.resetAllMocks();
mockFsExistsSync = vi.mocked(fs.existsSync);
(mockFsExistsSync as Mock).mockReturnValue(true);
mockFsExistsSync.mockReturnValue(true);
mockFsReadFileSync = vi.mocked(fs.readFileSync);
mockFsReadFileSync.mockReturnValue('{}');
vi.mocked(isWorkspaceTrusted).mockReturnValue({
Expand All @@ -2256,15 +2256,13 @@ describe('Settings Loading and Merging', () => {
},
};

(mockFsReadFileSync as Mock).mockImplementation(
(p: fs.PathOrFileDescriptor) => {
if (p === USER_SETTINGS_PATH)
return JSON.stringify(userSettingsContent);
if (p === MOCK_WORKSPACE_SETTINGS_PATH)
return JSON.stringify(workspaceSettingsContent);
return '{}';
},
);
mockFsReadFileSync.mockImplementation((p: fs.PathOrFileDescriptor) => {
if (p === USER_SETTINGS_PATH)
return JSON.stringify(userSettingsContent);
if (p === MOCK_WORKSPACE_SETTINGS_PATH)
return JSON.stringify(workspaceSettingsContent);
return '{}';
});

const loadedSettings = loadSettings(MOCK_WORKSPACE_DIR);
const setValueSpy = vi.spyOn(loadedSettings, 'setValue');
Expand Down Expand Up @@ -2329,15 +2327,13 @@ describe('Settings Loading and Merging', () => {
someOtherSetting: 'value',
};

(mockFsReadFileSync as Mock).mockImplementation(
(p: fs.PathOrFileDescriptor) => {
if (p === USER_SETTINGS_PATH)
return JSON.stringify(userSettingsContent);
if (p === MOCK_WORKSPACE_SETTINGS_PATH)
return JSON.stringify(workspaceSettingsContent);
return '{}';
},
);
mockFsReadFileSync.mockImplementation((p: fs.PathOrFileDescriptor) => {
if (p === USER_SETTINGS_PATH)
return JSON.stringify(userSettingsContent);
if (p === MOCK_WORKSPACE_SETTINGS_PATH)
return JSON.stringify(workspaceSettingsContent);
return '{}';
});

const loadedSettings = loadSettings(MOCK_WORKSPACE_DIR);
const setValueSpy = vi.spyOn(loadedSettings, 'setValue');
Expand Down
8 changes: 3 additions & 5 deletions packages/cli/src/config/settingsSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('SettingsSchema', () => {
];

expectedSettings.forEach((setting) => {
expect(getSettingsSchema()[setting as keyof Settings]).toBeDefined();
expect(getSettingsSchema()[setting]).toBeDefined();
});
});

Expand Down Expand Up @@ -66,9 +66,7 @@ describe('SettingsSchema', () => {
];

nestedSettings.forEach((setting) => {
const definition = getSettingsSchema()[
setting as keyof Settings
] as SettingDefinition;
const definition = getSettingsSchema()[setting] as SettingDefinition;
expect(definition.type).toBe('object');
expect(definition.properties).toBeDefined();
expect(typeof definition.properties).toBe('object');
Expand Down Expand Up @@ -142,7 +140,7 @@ describe('SettingsSchema', () => {
it('should have consistent default values for boolean settings', () => {
const checkBooleanDefaults = (schema: SettingsSchema) => {
Object.entries(schema).forEach(([, definition]) => {
const def = definition as SettingDefinition;
const def = definition;
if (def.type === 'boolean') {
// Boolean settings can have boolean or undefined defaults (for optional settings)
expect(['boolean', 'undefined']).toContain(typeof def.default);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/services/FileCommandLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describe('FileCommandLoader', () => {
const loader = new FileCommandLoader(mockConfig);
const commands = await loader.loadCommands(signal);
expect(commands).toHaveLength(1);
expect(commands[0]!.name).toBe('gcp:pipelines:run');
expect(commands[0].name).toBe('gcp:pipelines:run');
});

it('creates namespaces from nested directories', async () => {
Expand Down
Loading