Reduce bundle size & check it in CI (#7395)

This commit is contained in:
Pascal Birchler
2025-09-04 23:00:27 +02:00
committed by GitHub
parent 35a841f71a
commit c38247ed5c
10 changed files with 184 additions and 432 deletions
+5 -4
View File
@@ -7,7 +7,8 @@
import fs from 'node:fs';
import path from 'node:path';
import type { PartUnion } from '@google/genai';
import mime from 'mime-types';
// eslint-disable-next-line import/no-internal-modules
import mime from 'mime/lite';
import type { FileSystemService } from '../services/fileSystemService.js';
import { ToolErrorType } from '../tools/tool-error.js';
import { BINARY_EXTENSIONS } from './ignorePatterns.js';
@@ -157,7 +158,7 @@ export async function readFileWithEncoding(filePath: string): Promise<string> {
* @returns The specific MIME type string (e.g., 'text/python', 'application/javascript') or undefined if not found or ambiguous.
*/
export function getSpecificMimeType(filePath: string): string | undefined {
const lookedUpMime = mime.lookup(filePath);
const lookedUpMime = mime.getType(filePath);
return typeof lookedUpMime === 'string' ? lookedUpMime : undefined;
}
@@ -261,7 +262,7 @@ export async function detectFileType(
return 'svg';
}
const lookedUpMimeType = mime.lookup(filePath); // Returns false if not found, or the mime type string
const lookedUpMimeType = mime.getType(filePath); // Returns null if not found, or the mime type string
if (lookedUpMimeType) {
if (lookedUpMimeType.startsWith('image/')) {
return 'image';
@@ -437,7 +438,7 @@ export async function processSingleFileContent(
llmContent: {
inlineData: {
data: base64Data,
mimeType: mime.lookup(filePath) || 'application/octet-stream',
mimeType: mime.getType(filePath) || 'application/octet-stream',
},
},
returnDisplay: `Read ${fileType} file: ${relativePathForDisplay}`,