mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 13:34:15 -07:00
feat(core): Standardize Tool and Agent Invocation constructors (Phase 2) (#15775)
This commit is contained in:
@@ -80,8 +80,13 @@ class GetInternalDocsInvocation extends BaseToolInvocation<
|
||||
GetInternalDocsParams,
|
||||
ToolResult
|
||||
> {
|
||||
constructor(params: GetInternalDocsParams, messageBus?: MessageBus) {
|
||||
super(params, messageBus, GET_INTERNAL_DOCS_TOOL_NAME);
|
||||
constructor(
|
||||
params: GetInternalDocsParams,
|
||||
messageBus?: MessageBus,
|
||||
_toolName?: string,
|
||||
_toolDisplayName?: string,
|
||||
) {
|
||||
super(params, messageBus, _toolName, _toolDisplayName);
|
||||
}
|
||||
|
||||
override async shouldConfirmExecute(
|
||||
@@ -181,7 +186,14 @@ export class GetInternalDocsTool extends BaseDeclarativeTool<
|
||||
protected createInvocation(
|
||||
params: GetInternalDocsParams,
|
||||
messageBus?: MessageBus,
|
||||
_toolName?: string,
|
||||
_toolDisplayName?: string,
|
||||
): ToolInvocation<GetInternalDocsParams, ToolResult> {
|
||||
return new GetInternalDocsInvocation(params, messageBus);
|
||||
return new GetInternalDocsInvocation(
|
||||
params,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName ?? GetInternalDocsTool.Name,
|
||||
_toolDisplayName,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ export class GlobTool extends BaseDeclarativeTool<GlobToolParams, ToolResult> {
|
||||
return new GlobToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -681,7 +681,7 @@ export class GrepTool extends BaseDeclarativeTool<GrepToolParams, ToolResult> {
|
||||
return new GrepToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -337,7 +337,7 @@ export class LSTool extends BaseDeclarativeTool<LSToolParams, ToolResult> {
|
||||
return new LSToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -290,11 +290,11 @@ export class DiscoveredMCPTool extends BaseDeclarativeTool<
|
||||
this.mcpTool,
|
||||
this.serverName,
|
||||
this.serverToolName,
|
||||
this.displayName,
|
||||
_displayName ?? this.displayName,
|
||||
this.trust,
|
||||
params,
|
||||
this.cliConfig,
|
||||
_messageBus,
|
||||
_messageBus ?? this.messageBus,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,18 @@ class TestTool extends BaseDeclarativeTool<TestParams, TestResult> {
|
||||
);
|
||||
}
|
||||
|
||||
protected createInvocation(params: TestParams, messageBus: MessageBus) {
|
||||
return new TestToolInvocation(params, messageBus);
|
||||
protected createInvocation(
|
||||
params: TestParams,
|
||||
messageBus?: MessageBus,
|
||||
_toolName?: string,
|
||||
_toolDisplayName?: string,
|
||||
) {
|
||||
return new TestToolInvocation(
|
||||
params,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +138,7 @@ describe('Message Bus Integration', () => {
|
||||
expect(publishSpy).toHaveBeenCalledWith({
|
||||
type: MessageBusType.TOOL_CONFIRMATION_REQUEST,
|
||||
toolCall: {
|
||||
name: 'TestToolInvocation',
|
||||
name: 'test-tool',
|
||||
args: { testParam: 'test-value' },
|
||||
},
|
||||
correlationId: 'test-correlation-id',
|
||||
|
||||
@@ -232,7 +232,7 @@ export class ReadFileTool extends BaseDeclarativeTool<
|
||||
return new ReadFileToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -535,7 +535,7 @@ Use this tool when the user's query implies needing the content of several files
|
||||
return new ReadManyFilesToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -594,7 +594,7 @@ export class RipGrepTool extends BaseDeclarativeTool<
|
||||
this.config,
|
||||
this.geminiIgnoreParser,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -485,7 +485,7 @@ export class ShellTool extends BaseDeclarativeTool<
|
||||
return new ShellToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -955,11 +955,12 @@ A good instruction should concisely answer:
|
||||
|
||||
protected createInvocation(
|
||||
params: EditToolParams,
|
||||
messageBus?: MessageBus,
|
||||
): ToolInvocation<EditToolParams, ToolResult> {
|
||||
return new EditToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
this.messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
this.name,
|
||||
this.displayName,
|
||||
);
|
||||
|
||||
@@ -179,9 +179,9 @@ Signal: Signal number or \`(none)\` if no signal was received.
|
||||
return new DiscoveredToolInvocation(
|
||||
this.config,
|
||||
this.originalName,
|
||||
this.name,
|
||||
_toolName ?? this.name,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ export class WebFetchTool extends BaseDeclarativeTool<
|
||||
return new WebFetchToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -238,7 +238,7 @@ export class WebSearchTool extends BaseDeclarativeTool<
|
||||
return new WebSearchToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_toolDisplayName,
|
||||
);
|
||||
|
||||
@@ -145,7 +145,7 @@ export class WriteTodosTool extends BaseDeclarativeTool<
|
||||
> {
|
||||
static readonly Name = WRITE_TODOS_TOOL_NAME;
|
||||
|
||||
constructor() {
|
||||
constructor(messageBus?: MessageBus) {
|
||||
super(
|
||||
WriteTodosTool.Name,
|
||||
'WriteTodos',
|
||||
@@ -180,6 +180,9 @@ export class WriteTodosTool extends BaseDeclarativeTool<
|
||||
required: ['todos'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
true, // isOutputMarkdown
|
||||
false, // canUpdateOutput
|
||||
messageBus,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,13 +251,13 @@ export class WriteTodosTool extends BaseDeclarativeTool<
|
||||
|
||||
protected createInvocation(
|
||||
params: WriteTodosToolParams,
|
||||
_messageBus?: MessageBus,
|
||||
messageBus?: MessageBus,
|
||||
_toolName?: string,
|
||||
_displayName?: string,
|
||||
): ToolInvocation<WriteTodosToolParams, ToolResult> {
|
||||
return new WriteTodosToolInvocation(
|
||||
params,
|
||||
_messageBus,
|
||||
messageBus ?? this.messageBus,
|
||||
_toolName,
|
||||
_displayName,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user