chore(lint): burn down remaining warnings to zero

This commit is contained in:
William Valentin
2026-02-15 23:14:21 -08:00
parent 49b752e8b0
commit 948d4ac6d8
67 changed files with 235 additions and 256 deletions
+6 -2
View File
@@ -71,7 +71,11 @@ function validateInput(args: AudioTranscribeArgs): { valid: boolean; error?: str
}
if (hasUrl) {
const urlValidation = validateUrl(args.url!);
const url = args.url;
if (!url) {
return { valid: false, error: 'URL is required when using url mode' };
}
const urlValidation = validateUrl(url);
if (!urlValidation.valid) {
return urlValidation;
}
@@ -153,7 +157,7 @@ export function createAudioTranscribeTool(audioConfig?: AudioTranscriptionConfig
'audio/mp4': 'm4a',
'audio/x-m4a': 'm4a',
};
const ext = extMap[args.mime_type!] || 'bin';
const ext = extMap[args.mime_type ?? ''] || 'bin';
filename = `audio.${ext}`;
const mimeType = args.mime_type ?? 'audio/wav';
+1 -2
View File
@@ -3,8 +3,7 @@ import { BrowserManager } from './manager.js';
// Use vi.hoisted() so these are available inside the hoisted vi.mock() call
const {
mockGoto, mockTitle, mockUrl, mockClose, mockIsClosed,
mockSetDefaultTimeout, mockPage, mockNewPage, mockPages,
mockClose, mockIsClosed, mockPage, mockNewPage, mockPages,
mockBrowserClose,
} = vi.hoisted(() => {
const mockGoto = vi.fn().mockResolvedValue(undefined);
+1 -1
View File
@@ -27,7 +27,7 @@ export const fileListTool: Tool = {
try {
let entries = readdirSync(args.path, { withFileTypes: true });
if (args.pattern) {
entries = entries.filter(e => matchGlob(e.name, args.pattern!));
entries = entries.filter(e => matchGlob(e.name, args.pattern));
}
const output = entries
.map(e => e.isDirectory() ? `${e.name}/` : e.name)
+1 -1
View File
@@ -86,7 +86,7 @@ export function createImageAnalyzeTool(modelClient: ModelClient): Tool {
}
: {
type: 'base64' as const,
media_type: args.media_type!,
media_type: args.media_type ?? 'image/jpeg',
data: args.data,
};
-2
View File
@@ -40,8 +40,6 @@ import { filePatchTool } from './file-patch.js';
import { fileListTool } from './file-list.js';
import { systemInfoTool } from './system-info.js';
import { webFetchTool } from './web-fetch.js';
import { createMediaSendTool } from './media-send.js';
import { createImageAnalyzeTool } from './image-analyze.js';
import { createMemoryReadTool } from './memory-read.js';
import { createMemoryWriteTool } from './memory-write.js';
import { createMemorySearchTool } from './memory-search.js';
+5 -1
View File
@@ -151,12 +151,16 @@ export class ProcessManager {
stdio: ['ignore', 'pipe', 'pipe'],
detached: false,
});
const pid = child.pid;
if (pid === undefined) {
throw new Error('Failed to start process: missing pid');
}
const proc: ManagedProcess = {
id,
command,
cwd,
pid: child.pid!,
pid,
status: 'running',
outputBuffer,
startedAt: Date.now(),
-4
View File
@@ -1,10 +1,6 @@
import type { Tool, ToolResult } from '../types.js';
import type { SessionManager } from '../../session/manager.js';
interface SessionsListArgs {
// no args
}
interface SessionsHistoryArgs {
sessionId: string;
limit?: number;
+2 -2
View File
@@ -396,10 +396,10 @@ describe('ToolExecutor', () => {
const fakeSandbox = {
exec: async () => ({ stdout: 'sandbox-out', stderr: '' }),
} as any;
} as { exec: (command: string, opts?: { cwd?: string }) => Promise<{ stdout: string; stderr: string }> };
const fakeManager = {
getOrCreate: async () => fakeSandbox,
} as any;
} as { getOrCreate: (sessionId: string) => Promise<typeof fakeSandbox> };
executor.setSandboxManager(fakeManager);
const result = await executor.execute('shell.exec', { command: 'echo hi' }, {
+6 -4
View File
@@ -288,11 +288,13 @@ export class ToolPolicy {
*/
getEffectiveProfile(context?: ToolPolicyContext): ToolProfile {
// Check agent override first, then provider, then global
if (context?.agent && this.config.agents[context.agent]?.profile) {
return this.config.agents[context.agent].profile!;
const agentProfile = context?.agent ? this.config.agents[context.agent]?.profile : undefined;
if (agentProfile) {
return agentProfile;
}
if (context?.provider && this.config.providers[context.provider]?.profile) {
return this.config.providers[context.provider].profile!;
const providerProfile = context?.provider ? this.config.providers[context.provider]?.profile : undefined;
if (providerProfile) {
return providerProfile;
}
return this.config.profile;
}
+20 -5
View File
@@ -1,6 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
import { ToolRegistry } from './registry.js';
import type { Tool } from './types.js';
import type { ToolPolicy } from './policy.js';
const echoTool: Tool = {
name: 'test.echo',
@@ -114,8 +115,13 @@ describe('ToolRegistry', () => {
it('inherits the policy from original', () => {
const reg = new ToolRegistry();
const mockPolicy = { filterTools: vi.fn(), isAllowed: vi.fn(), resolveAllowedNames: vi.fn(), getEffectiveProfile: vi.fn() };
reg.setPolicy(mockPolicy as any);
const mockPolicy: ToolPolicy = {
filterTools: vi.fn((tools) => tools),
isAllowed: vi.fn(() => true),
resolveAllowedNames: vi.fn(() => new Set()),
getEffectiveProfile: vi.fn(() => ({ profile: 'full', source: 'explicit' })),
};
reg.setPolicy(mockPolicy);
const cloned = reg.clone();
expect(cloned.getPolicy()).toBe(mockPolicy);
@@ -131,8 +137,13 @@ describe('ToolRegistry', () => {
replacementTool.description = 'Sandboxed version';
cloned.replace(replacementTool);
expect(cloned.get('shell.exec')!.description).toBe('Sandboxed version');
expect(reg.get('shell.exec')!.description).toBe('Mock shell.exec');
const clonedTool = cloned.get('shell.exec');
const originalToolFromReg = reg.get('shell.exec');
if (!clonedTool || !originalToolFromReg) {
throw new Error('Expected shell.exec to exist in both registries');
}
expect(clonedTool.description).toBe('Sandboxed version');
expect(originalToolFromReg.description).toBe('Mock shell.exec');
});
});
@@ -153,7 +164,11 @@ describe('ToolRegistry', () => {
replacement.description = 'New description';
reg.replace(replacement);
expect(reg.get('tool.a')!.description).toBe('New description');
const replaced = reg.get('tool.a');
if (!replaced) {
throw new Error('Expected tool.a to be present');
}
expect(replaced.description).toBe('New description');
});
it('throws if tool does not exist', () => {