mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Co-authored-by: Dev Randalpura <devrandalpura@google.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import * as path from 'node:path';
|
|||||||
import type { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
import type { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||||
import type { FileFilteringOptions } from '../config/constants.js';
|
import type { FileFilteringOptions } from '../config/constants.js';
|
||||||
import { debugLogger } from './debugLogger.js';
|
import { debugLogger } from './debugLogger.js';
|
||||||
|
import { getErrorMessage } from './errors.js';
|
||||||
// Simple console logger for now.
|
// Simple console logger for now.
|
||||||
// TODO: Integrate with a more robust server-side logger.
|
// TODO: Integrate with a more robust server-side logger.
|
||||||
const logger = {
|
const logger = {
|
||||||
@@ -80,10 +81,8 @@ export async function bfsFileSearch(
|
|||||||
return { currentDir, entries };
|
return { currentDir, entries };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Warn user that a directory could not be read, as this affects search results.
|
// Warn user that a directory could not be read, as this affects search results.
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
||||||
const message = (error as Error)?.message ?? 'Unknown error';
|
|
||||||
debugLogger.warn(
|
debugLogger.warn(
|
||||||
`[WARN] Skipping unreadable directory: ${currentDir} (${message})`,
|
`[WARN] Skipping unreadable directory: ${currentDir} (${getErrorMessage(error)})`,
|
||||||
);
|
);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
logger.debug(`Full error for ${currentDir}:`, error);
|
logger.debug(`Full error for ${currentDir}:`, error);
|
||||||
@@ -154,10 +153,8 @@ export function bfsFileSearchSync(
|
|||||||
foundFiles,
|
foundFiles,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
||||||
const message = (error as Error)?.message ?? 'Unknown error';
|
|
||||||
debugLogger.warn(
|
debugLogger.warn(
|
||||||
`[WARN] Skipping unreadable directory: ${currentDir} (${message})`,
|
`[WARN] Skipping unreadable directory: ${currentDir} (${getErrorMessage(error)})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ export function generateCheckpointFileName(
|
|||||||
toolCall: ToolCallRequestInfo,
|
toolCall: ToolCallRequestInfo,
|
||||||
): string | null {
|
): string | null {
|
||||||
const toolArgs = toolCall.args;
|
const toolArgs = toolCall.args;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
const rawFilePath = toolArgs['file_path'];
|
||||||
const toolFilePath = toolArgs['file_path'] as string;
|
|
||||||
|
|
||||||
if (!toolFilePath) {
|
if (typeof rawFilePath !== 'string' || !rawFilePath) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const toolFilePath = rawFilePath;
|
||||||
|
|
||||||
const timestamp = new Date()
|
const timestamp = new Date()
|
||||||
.toISOString()
|
.toISOString()
|
||||||
@@ -168,11 +168,14 @@ export function getCheckpointInfoList(
|
|||||||
|
|
||||||
for (const [file, content] of checkpointFiles) {
|
for (const [file, content] of checkpointFiles) {
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
const parsed: unknown = JSON.parse(content);
|
||||||
const toolCallData = JSON.parse(content) as ToolCallData;
|
const result = z
|
||||||
if (toolCallData.messageId) {
|
.object({ messageId: z.string() })
|
||||||
|
.passthrough()
|
||||||
|
.safeParse(parsed);
|
||||||
|
if (result.success) {
|
||||||
checkpointInfoList.push({
|
checkpointInfoList.push({
|
||||||
messageId: toolCallData.messageId,
|
messageId: result.data.messageId,
|
||||||
checkpoint: file.replace('.json', ''),
|
checkpoint: file.replace('.json', ''),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user