mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-18 14:00:27 -07:00
refactor(core): consolidate execute() arguments into ExecuteOptions (#25101)
This commit is contained in:
@@ -34,6 +34,8 @@ export type ForcedToolDecision = 'allow' | 'deny' | 'ask_user';
|
||||
* only relevant to specific tool types.
|
||||
*/
|
||||
export interface ExecuteOptions {
|
||||
abortSignal: AbortSignal;
|
||||
updateOutput?: (output: ToolLiveOutput) => void;
|
||||
shellExecutionConfig?: ShellExecutionConfig;
|
||||
setExecutionIdCallback?: (executionId: number) => void;
|
||||
}
|
||||
@@ -90,16 +92,10 @@ export interface ToolInvocation<
|
||||
|
||||
/**
|
||||
* Executes the tool with the validated parameters.
|
||||
* @param signal AbortSignal for tool cancellation.
|
||||
* @param updateOutput Optional callback to stream output.
|
||||
* @param setExecutionIdCallback Optional callback for tools that expose a background execution handle.
|
||||
* @param options Options for tool execution including signal and output updates.
|
||||
* @returns Result of the tool execution.
|
||||
*/
|
||||
execute(
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<TResult>;
|
||||
execute(options: ExecuteOptions): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Returns tool-specific options for policy updates.
|
||||
@@ -374,11 +370,7 @@ export abstract class BaseToolInvocation<
|
||||
});
|
||||
}
|
||||
|
||||
abstract execute(
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<TResult>;
|
||||
abstract execute(options: ExecuteOptions): Promise<TResult>;
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
@@ -609,10 +601,14 @@ export abstract class DeclarativeTool<
|
||||
params: TParams,
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
options?: ExecuteOptions,
|
||||
options?: Omit<ExecuteOptions, 'abortSignal' | 'updateOutput'>,
|
||||
): Promise<TResult> {
|
||||
const invocation = this.build(params);
|
||||
return invocation.execute(signal, updateOutput, options);
|
||||
return invocation.execute({
|
||||
...options,
|
||||
abortSignal: signal,
|
||||
updateOutput,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -658,7 +654,7 @@ export abstract class DeclarativeTool<
|
||||
}
|
||||
|
||||
try {
|
||||
return await invocationOrError.execute(abortSignal);
|
||||
return await invocationOrError.execute({ abortSignal });
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
|
||||
Reference in New Issue
Block a user