This reverts commit 96a2984ad2, reversing
changes made to 12e61d5b18.
This commit is contained in:
christinatong01
2026-03-23 17:31:32 -07:00
parent 96a2984ad2
commit 524893174e
19 changed files with 74 additions and 448 deletions

View File

@@ -24,7 +24,6 @@ const rgPath = getRipgrepPath();
interface GlobArgs {
pattern: string;
path?: string;
signal?: AbortSignal;
}
interface GlobResult {
@@ -60,7 +59,7 @@ function applyFileLimit(files: string[], workingDirectory: string): GlobResult {
export async function glob(args: GlobArgs): Promise<GlobResult> {
validateRequiredParams(args, ["pattern"], "Glob");
const { pattern, path: searchPath, signal } = args;
const { pattern, path: searchPath } = args;
// Explicit check for undefined/empty pattern (validateRequiredParams only checks key existence)
if (!pattern) {
@@ -94,7 +93,6 @@ export async function glob(args: GlobArgs): Promise<GlobResult> {
const { stdout } = await execFileAsync(rgPath, rgArgs, {
maxBuffer: 50 * 1024 * 1024, // 50MB buffer for large file lists
cwd: userCwd,
signal,
});
const files = stdout.trim().split("\n").filter(Boolean).sort();
@@ -106,16 +104,6 @@ export async function glob(args: GlobArgs): Promise<GlobResult> {
code?: string | number;
};
const isAbortError =
err.name === "AbortError" ||
err.code === "ABORT_ERR" ||
err.message === "The operation was aborted";
if (isAbortError) {
throw Object.assign(new Error("The operation was aborted"), {
name: "AbortError",
});
}
// ripgrep exits with code 1 when no files match - that's not an error
if (err.code === 1 || err.code === "1") {
return { files: [] };

View File

@@ -11,7 +11,6 @@ interface GlobGeminiArgs {
case_sensitive?: boolean;
respect_git_ignore?: boolean;
respect_gemini_ignore?: boolean;
signal?: AbortSignal;
}
export async function glob_gemini(
@@ -21,7 +20,6 @@ export async function glob_gemini(
const lettaArgs = {
pattern: args.pattern,
path: args.dir_path,
signal: args.signal,
};
const result = await lettaGlob(lettaArgs);

View File

@@ -47,7 +47,6 @@ export interface GrepArgs {
head_limit?: number;
offset?: number;
multiline?: boolean;
signal?: AbortSignal;
}
interface GrepResult {
@@ -72,7 +71,6 @@ export async function grep(args: GrepArgs): Promise<GrepResult> {
head_limit = 100,
offset = 0,
multiline,
signal,
} = args;
const userCwd = process.env.USER_CWD || process.cwd();
@@ -104,7 +102,6 @@ export async function grep(args: GrepArgs): Promise<GrepResult> {
const { stdout } = await execFileAsync(rgPath, rgArgs, {
maxBuffer: 10 * 1024 * 1024,
cwd: userCwd,
signal,
});
if (output_mode === "files_with_matches") {
const allFiles = stdout.trim().split("\n").filter(Boolean);
@@ -181,21 +178,12 @@ export async function grep(args: GrepArgs): Promise<GrepResult> {
} catch (error) {
const err = error as NodeJS.ErrnoException & {
stdout?: string;
code?: string | number;
};
const code = err.code !== undefined ? String(err.code) : undefined;
const code = typeof err.code === "number" ? err.code : undefined;
const _stdout = typeof err.stdout === "string" ? err.stdout : "";
const message =
typeof err.message === "string" ? err.message : "Unknown error";
const isAbortError =
err.name === "AbortError" ||
err.code === "ABORT_ERR" ||
err.message === "The operation was aborted";
if (isAbortError) {
throw Object.assign(new Error("The operation was aborted"), {
name: "AbortError",
});
}
if (code === "1") {
if (code === 1) {
if (output_mode === "files_with_matches")
return { output: "No files found", files: 0 };
if (output_mode === "count")

View File

@@ -6,7 +6,6 @@ interface GrepFilesArgs {
include?: string;
path?: string;
limit?: number;
signal?: AbortSignal;
}
interface GrepFilesResult {
@@ -27,14 +26,13 @@ export async function grep_files(
): Promise<GrepFilesResult> {
validateRequiredParams(args, ["pattern"], "grep_files");
const { pattern, include, path, limit = DEFAULT_LIMIT, signal } = args;
const { pattern, include, path, limit = DEFAULT_LIMIT } = args;
const grepArgs: GrepArgs = {
pattern,
path,
glob: include,
output_mode: "files_with_matches",
signal,
};
const result = await grep(grepArgs);

View File

@@ -9,7 +9,6 @@ interface SearchFileContentGeminiArgs {
pattern: string;
dir_path?: string;
include?: string;
signal?: AbortSignal;
}
export async function search_file_content(
@@ -21,7 +20,6 @@ export async function search_file_content(
path: args.dir_path,
glob: args.include,
output_mode: "content" as const, // Return actual matching lines, not just file paths
signal: args.signal,
};
const result = await grep(lettaArgs);

View File

@@ -46,7 +46,7 @@ const FILE_MODIFYING_TOOLS = new Set([
]);
export const TOOL_NAMES = Object.keys(TOOL_DEFINITIONS) as ToolName[];
const SIGNAL_AWARE_TOOLS = new Set([
const STREAMING_SHELL_TOOLS = new Set([
"Bash",
"BashOutput",
"TaskOutput",
@@ -56,14 +56,6 @@ const SIGNAL_AWARE_TOOLS = new Set([
"Shell",
"run_shell_command",
"RunShellCommand",
"Glob",
"Grep",
"grep_files",
"GrepFiles",
"glob_gemini",
"GlobGemini",
"search_file_content",
"SearchFileContent",
]);
// Maps internal tool names to server/model-facing tool names
@@ -1332,22 +1324,13 @@ export async function executeTool(
// Inject options for tools that support them without altering schemas
let enhancedArgs = args;
if (SIGNAL_AWARE_TOOLS.has(internalName) && options?.signal) {
enhancedArgs = { ...enhancedArgs, signal: options.signal };
}
if (
(internalName === "Bash" ||
internalName === "BashOutput" ||
internalName === "shell_command" ||
internalName === "ShellCommand" ||
internalName === "shell" ||
internalName === "Shell" ||
internalName === "run_shell_command" ||
internalName === "RunShellCommand") &&
options?.onOutput
) {
enhancedArgs = { ...enhancedArgs, onOutput: options.onOutput };
if (STREAMING_SHELL_TOOLS.has(internalName)) {
if (options?.signal) {
enhancedArgs = { ...enhancedArgs, signal: options.signal };
}
if (options?.onOutput) {
enhancedArgs = { ...enhancedArgs, onOutput: options.onOutput };
}
}
// Inject toolCallId and abort signal for Task tool