summaryrefslogtreecommitdiff
path: root/packages/server/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server/src/tools')
-rw-r--r--packages/server/src/tools/edit.ts6
-rw-r--r--packages/server/src/tools/glob.ts9
-rw-r--r--packages/server/src/tools/tools.ts1
-rw-r--r--packages/server/src/tools/web-fetch.ts7
-rw-r--r--packages/server/src/tools/write-file.ts19
5 files changed, 15 insertions, 27 deletions
diff --git a/packages/server/src/tools/edit.ts b/packages/server/src/tools/edit.ts
index 3b317a08..72c25603 100644
--- a/packages/server/src/tools/edit.ts
+++ b/packages/server/src/tools/edit.ts
@@ -53,10 +53,10 @@ interface CalculatedEdit {
}
/**
- * Implementation of the Edit tool logic (moved from CLI)
+ * Implementation of the Edit tool logic
*/
export class EditTool extends BaseTool<EditToolParams, ToolResult> {
- static readonly Name = 'replace'; // Keep static name
+ static readonly Name = 'replace';
private shouldAlwaysEdit = false;
/**
@@ -371,7 +371,7 @@ export class EditTool extends BaseTool<EditToolParams, ToolResult> {
editData.newContent,
'Current',
'Proposed',
- { context: 3 }, // Removed ignoreWhitespace for potentially more accurate display diff
+ { context: 3 },
);
displayResult = { fileDiff };
}
diff --git a/packages/server/src/tools/glob.ts b/packages/server/src/tools/glob.ts
index d9d91c7a..9e7df0e8 100644
--- a/packages/server/src/tools/glob.ts
+++ b/packages/server/src/tools/glob.ts
@@ -27,11 +27,10 @@ export interface GlobToolParams {
}
/**
- * Implementation of the Glob tool logic (moved from CLI)
+ * Implementation of the Glob tool logic
*/
export class GlobTool extends BaseTool<GlobToolParams, ToolResult> {
- static readonly Name = 'glob'; // Keep static name
-
+ static readonly Name = 'glob';
/**
* Creates a new instance of the GlobLogic
* @param rootDirectory Root directory to ground this tool in.
@@ -39,8 +38,8 @@ export class GlobTool extends BaseTool<GlobToolParams, ToolResult> {
constructor(private rootDirectory: string) {
super(
GlobTool.Name,
- 'FindFiles', // Display name handled by CLI wrapper
- 'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.', // Description handled by CLI wrapper
+ 'FindFiles',
+ 'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.',
{
properties: {
pattern: {
diff --git a/packages/server/src/tools/tools.ts b/packages/server/src/tools/tools.ts
index 57a388d8..ac04450d 100644
--- a/packages/server/src/tools/tools.ts
+++ b/packages/server/src/tools/tools.ts
@@ -5,7 +5,6 @@
*/
import { FunctionDeclaration, Schema } from '@google/genai';
-// Removed import for ../ui/types.js as confirmation is UI-specific
/**
* Interface representing the base Tool functionality
diff --git a/packages/server/src/tools/web-fetch.ts b/packages/server/src/tools/web-fetch.ts
index 415dc033..12584231 100644
--- a/packages/server/src/tools/web-fetch.ts
+++ b/packages/server/src/tools/web-fetch.ts
@@ -19,7 +19,7 @@ export interface WebFetchToolParams {
}
/**
- * Implementation of the WebFetch tool logic (moved from CLI)
+ * Implementation of the WebFetch tool logic
*/
export class WebFetchTool extends BaseTool<WebFetchToolParams, ToolResult> {
static readonly Name: string = 'web_fetch';
@@ -70,8 +70,6 @@ export class WebFetchTool extends BaseTool<WebFetchToolParams, ToolResult> {
return `Fetching content from ${displayUrl}`;
}
- // Removed shouldConfirmExecute - handled by CLI
-
async execute(params: WebFetchToolParams): Promise<ToolResult> {
const validationError = this.validateParams(params);
if (validationError) {
@@ -86,10 +84,9 @@ export class WebFetchTool extends BaseTool<WebFetchToolParams, ToolResult> {
try {
const response = await fetch(url, {
headers: {
- // Identify the client making the request
'User-Agent': 'GeminiCode-ServerLogic/1.0',
},
- signal: AbortSignal.timeout(15000), // Use AbortSignal for timeout
+ signal: AbortSignal.timeout(15000),
});
if (!response.ok) {
diff --git a/packages/server/src/tools/write-file.ts b/packages/server/src/tools/write-file.ts
index d24080d2..c9a47296 100644
--- a/packages/server/src/tools/write-file.ts
+++ b/packages/server/src/tools/write-file.ts
@@ -6,7 +6,7 @@
import fs from 'fs';
import path from 'path';
-import * as Diff from 'diff'; // Keep for result generation
+import * as Diff from 'diff';
import {
BaseTool,
ToolResult,
@@ -14,11 +14,10 @@ import {
ToolEditConfirmationDetails,
ToolConfirmationOutcome,
ToolCallConfirmationDetails,
-} from './tools.js'; // Updated import (Removed ToolResultDisplay)
+} from './tools.js';
import { SchemaValidator } from '../utils/schemaValidator.js'; // Updated import
import { makeRelative, shortenPath } from '../utils/paths.js'; // Updated import
-import { isNodeError } from '../utils/errors.js'; // Import isNodeError
-
+import { isNodeError } from '../utils/errors.js';
/**
* Parameters for the WriteFile tool
*/
@@ -35,7 +34,7 @@ export interface WriteFileToolParams {
}
/**
- * Implementation of the WriteFile tool logic (moved from CLI)
+ * Implementation of the WriteFile tool logic
*/
export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
static readonly Name: string = 'write_file';
@@ -49,7 +48,6 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
{
properties: {
file_path: {
- // Renamed from filePath in original schema
description:
"The absolute path to the file to write to (e.g., '/home/user/project/file.txt'). Relative paths are not supported.",
type: 'string',
@@ -59,7 +57,7 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
type: 'string',
},
},
- required: ['file_path', 'content'], // Use correct param names
+ required: ['file_path', 'content'],
type: 'object',
},
);
@@ -97,15 +95,13 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
return null;
}
- // Removed shouldConfirmExecute - handled by CLI
-
getDescription(params: WriteFileToolParams): string {
const relativePath = makeRelative(params.file_path, this.rootDirectory);
return `Writing to ${shortenPath(relativePath)}`;
}
/**
- * Handles the confirmation prompt for the WriteFile tool in the CLI.
+ * Handles the confirmation prompt for the WriteFile tool.
*/
async shouldConfirmExecute(
params: WriteFileToolParams,
@@ -203,7 +199,6 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
? `Successfully created and wrote to new file: ${params.file_path}`
: `Successfully overwrote file: ${params.file_path}`;
- // The returnDisplay contains the diff
const displayResult: FileDiff = { fileDiff };
return {
@@ -218,6 +213,4 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
};
}
}
-
- // ensureParentDirectoriesExist logic moved into execute
}