mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 15:21:01 -07:00
refactor(core): replace positional execute params with ExecuteOptions bag (#22674)
This commit is contained in:
@@ -22,13 +22,13 @@ import {
|
||||
type ToolExecuteConfirmationDetails,
|
||||
type PolicyUpdateOptions,
|
||||
type ToolLiveOutput,
|
||||
type ExecuteOptions,
|
||||
} from './tools.js';
|
||||
|
||||
import { getErrorMessage } from '../utils/errors.js';
|
||||
import { summarizeToolOutput } from '../utils/summarizer.js';
|
||||
import {
|
||||
ShellExecutionService,
|
||||
type ShellExecutionConfig,
|
||||
type ShellOutputEvent,
|
||||
} from '../services/shellExecutionService.js';
|
||||
import { formatBytes } from '../utils/formatters.js';
|
||||
@@ -150,9 +150,9 @@ export class ShellToolInvocation extends BaseToolInvocation<
|
||||
async execute(
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
shellExecutionConfig?: ShellExecutionConfig,
|
||||
setExecutionIdCallback?: (executionId: number) => void,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<ToolResult> {
|
||||
const { shellExecutionConfig, setExecutionIdCallback } = options ?? {};
|
||||
const strippedCommand = stripShellWrapper(this.params.command);
|
||||
|
||||
if (signal.aborted) {
|
||||
|
||||
@@ -22,6 +22,15 @@ import {
|
||||
import { type ApprovalMode } from '../policy/types.js';
|
||||
import type { SubagentProgress } from '../agents/types.js';
|
||||
|
||||
/**
|
||||
* Options bag for tool execution, replacing positional parameters that are
|
||||
* only relevant to specific tool types.
|
||||
*/
|
||||
export interface ExecuteOptions {
|
||||
shellExecutionConfig?: ShellExecutionConfig;
|
||||
setExecutionIdCallback?: (executionId: number) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a validated and ready-to-execute tool call.
|
||||
* An instance of this is created by a `ToolBuilder`.
|
||||
@@ -68,8 +77,7 @@ export interface ToolInvocation<
|
||||
execute(
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
shellExecutionConfig?: ShellExecutionConfig,
|
||||
setExecutionIdCallback?: (executionId: number) => void,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<TResult>;
|
||||
|
||||
/**
|
||||
@@ -325,7 +333,7 @@ export abstract class BaseToolInvocation<
|
||||
abstract execute(
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
shellExecutionConfig?: ShellExecutionConfig,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<TResult>;
|
||||
}
|
||||
|
||||
@@ -522,10 +530,10 @@ export abstract class DeclarativeTool<
|
||||
params: TParams,
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
shellExecutionConfig?: ShellExecutionConfig,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<TResult> {
|
||||
const invocation = this.build(params);
|
||||
return invocation.execute(signal, updateOutput, shellExecutionConfig);
|
||||
return invocation.execute(signal, updateOutput, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user