@google/gemini-cli-core 0.8.0-nightly.20250930.ae51bbda → 0.8.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/agents/codebase-investigator.d.ts +11 -0
- package/dist/src/agents/codebase-investigator.js +73 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +88 -0
- package/dist/src/agents/executor.js +417 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.d.ts +6 -0
- package/dist/src/agents/executor.test.js +419 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +43 -0
- package/dist/src/agents/invocation.js +100 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.d.ts +6 -0
- package/dist/src/agents/invocation.test.js +206 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +35 -0
- package/dist/src/agents/registry.js +58 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +146 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +36 -0
- package/dist/src/agents/subagent-tool-wrapper.js +47 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +105 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +116 -0
- package/dist/src/agents/types.js +17 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +1 -0
- package/dist/src/ide/detect-ide.js +4 -1
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +2 -0
- package/dist/src/services/shellExecutionService.js +48 -7
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +13 -4
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +4 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +18 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -24
- package/dist/src/telemetry/constants.js +0 -25
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/loggers.js +42 -9
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +39 -8
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +278 -19
- package/dist/src/telemetry/metrics.js +303 -235
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +191 -54
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/tools/smart-edit.js +56 -0
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +19 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +10 -1
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +81 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +13 -20
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +14 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +1 -4
- package/dist/src/utils/terminalSerializer.js +3 -3
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentDefinition } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* A Proof-of-Concept subagent specialized in analyzing codebase structure,
|
|
9
|
+
* dependencies, and technologies.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CodebaseInvestigatorAgent: AgentDefinition;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LSTool } from '../tools/ls.js';
|
|
7
|
+
import { ReadFileTool } from '../tools/read-file.js';
|
|
8
|
+
import { GlobTool } from '../tools/glob.js';
|
|
9
|
+
import { GrepTool } from '../tools/grep.js';
|
|
10
|
+
import { DEFAULT_GEMINI_MODEL } from '../config/models.js';
|
|
11
|
+
/**
|
|
12
|
+
* A Proof-of-Concept subagent specialized in analyzing codebase structure,
|
|
13
|
+
* dependencies, and technologies.
|
|
14
|
+
*/
|
|
15
|
+
export const CodebaseInvestigatorAgent = {
|
|
16
|
+
name: 'codebase_investigator',
|
|
17
|
+
displayName: 'Codebase Investigator Agent',
|
|
18
|
+
description: 'A specialized agent used for analyzing and reporting on the structure, technologies, dependencies, and conventions of the current codebase. Use this when asked to understand how the project is set up or how a specific feature is implemented.',
|
|
19
|
+
inputConfig: {
|
|
20
|
+
inputs: {
|
|
21
|
+
investigation_focus: {
|
|
22
|
+
description: 'A high-level description of what the agent should investigate (e.g., "frontend framework", "authentication implementation", "testing conventions").',
|
|
23
|
+
type: 'string',
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
outputConfig: {
|
|
29
|
+
description: 'A detailed markdown report summarizing the findings of the codebase investigation.',
|
|
30
|
+
completion_criteria: [
|
|
31
|
+
'The report must directly address the initial `investigation_focus`.',
|
|
32
|
+
'Cite specific files, functions, or configuration snippets as evidence for your findings.',
|
|
33
|
+
'Conclude with a summary of the key technologies, architectural patterns, and conventions discovered.',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
modelConfig: {
|
|
37
|
+
model: DEFAULT_GEMINI_MODEL,
|
|
38
|
+
temp: 0.2,
|
|
39
|
+
top_p: 1.0,
|
|
40
|
+
thinkingBudget: -1,
|
|
41
|
+
},
|
|
42
|
+
runConfig: {
|
|
43
|
+
max_time_minutes: 5,
|
|
44
|
+
max_turns: 15,
|
|
45
|
+
},
|
|
46
|
+
toolConfig: {
|
|
47
|
+
// Grant access only to read-only tools.
|
|
48
|
+
tools: [LSTool.Name, ReadFileTool.Name, GlobTool.Name, GrepTool.Name],
|
|
49
|
+
},
|
|
50
|
+
promptConfig: {
|
|
51
|
+
systemPrompt: `You are the Codebase Investigator agent. Your sole purpose is to analyze the provided codebase and generate a detailed report on a specific area of focus.
|
|
52
|
+
|
|
53
|
+
# Task
|
|
54
|
+
Your focus for this investigation is: \${investigation_focus}
|
|
55
|
+
|
|
56
|
+
# Methodology
|
|
57
|
+
1. **Discovery:** Start by looking at high-level configuration files (e.g., package.json, README.md, Cargo.toml, requirements.txt, build.gradle) to understand the project's dependencies and structure.
|
|
58
|
+
2. **Structure Analysis:** Use '${GlobTool.Name}' and '${LSTool.Name}' to understand the directory layout and identify relevant files/modules related to your focus.
|
|
59
|
+
3. **Deep Dive:** Use '${ReadFileTool.Name}' and available search tools (Grep/RipGrep) to analyze the contents of relevant files, looking for implementation details, patterns, and conventions.
|
|
60
|
+
4. **Synthesis:** Synthesize all findings into a coherent markdown report.
|
|
61
|
+
|
|
62
|
+
# Rules
|
|
63
|
+
* You MUST ONLY use the tools provided to you.
|
|
64
|
+
* You CANNOT modify the codebase.
|
|
65
|
+
* You must be thorough in your investigation.
|
|
66
|
+
* Once you have gathered sufficient information, stop calling tools. Your findings will be synthesized into the final report.
|
|
67
|
+
|
|
68
|
+
# Report Format
|
|
69
|
+
The final report should be structured markdown, clearly answering the investigation focus, citing the evidence (files analyzed), and summarizing the technologies/patterns found.
|
|
70
|
+
`,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=codebase-investigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codebase-investigator.js","sourceRoot":"","sources":["../../../src/agents/codebase-investigator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EACT,mPAAmP;IAErP,WAAW,EAAE;QACX,MAAM,EAAE;YACN,mBAAmB,EAAE;gBACnB,WAAW,EACT,qJAAqJ;gBACvJ,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;KACF;IACD,YAAY,EAAE;QACZ,WAAW,EACT,oFAAoF;QACtF,mBAAmB,EAAE;YACnB,qEAAqE;YACrE,0FAA0F;YAC1F,sGAAsG;SACvG;KACF;IAED,WAAW,EAAE;QACX,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,GAAG;QACV,cAAc,EAAE,CAAC,CAAC;KACnB;IAED,SAAS,EAAE;QACT,gBAAgB,EAAE,CAAC;QACnB,SAAS,EAAE,EAAE;KACd;IAED,UAAU,EAAE;QACV,wCAAwC;QACxC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;KACtE;IAED,YAAY,EAAE;QACZ,YAAY,EAAE;;;;;;;kCAOgB,QAAQ,CAAC,IAAI,UAAU,MAAM,CAAC,IAAI;yBAC3C,YAAY,CAAC,IAAI;;;;;;;;;;;CAWzC;KACE;CACF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Config } from '../config/config.js';
|
|
7
|
+
import type { AgentDefinition, AgentInputs, OutputObject, SubagentActivityEvent } from './types.js';
|
|
8
|
+
/** A callback function to report on agent activity. */
|
|
9
|
+
export type ActivityCallback = (activity: SubagentActivityEvent) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Executes an agent loop based on an {@link AgentDefinition}.
|
|
12
|
+
*
|
|
13
|
+
* This executor uses a simplified two-phase approach:
|
|
14
|
+
* 1. **Work Phase:** The agent runs in a loop, calling tools until it has
|
|
15
|
+
* gathered all necessary information to fulfill its goal.
|
|
16
|
+
* 2. **Extraction Phase:** A final prompt is sent to the model to summarize
|
|
17
|
+
* the work and extract the final result in the desired format.
|
|
18
|
+
*/
|
|
19
|
+
export declare class AgentExecutor {
|
|
20
|
+
readonly definition: AgentDefinition;
|
|
21
|
+
private readonly agentId;
|
|
22
|
+
private readonly toolRegistry;
|
|
23
|
+
private readonly runtimeContext;
|
|
24
|
+
private readonly onActivity?;
|
|
25
|
+
/**
|
|
26
|
+
* Creates and validates a new `AgentExecutor` instance.
|
|
27
|
+
*
|
|
28
|
+
* This method ensures that all tools specified in the agent's definition are
|
|
29
|
+
* safe for non-interactive use before creating the executor.
|
|
30
|
+
*
|
|
31
|
+
* @param definition The definition object for the agent.
|
|
32
|
+
* @param runtimeContext The global runtime configuration.
|
|
33
|
+
* @param onActivity An optional callback to receive activity events.
|
|
34
|
+
* @returns A promise that resolves to a new `AgentExecutor` instance.
|
|
35
|
+
*/
|
|
36
|
+
static create(definition: AgentDefinition, runtimeContext: Config, onActivity?: ActivityCallback): Promise<AgentExecutor>;
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new AgentExecutor instance.
|
|
39
|
+
*
|
|
40
|
+
* @private This constructor is private. Use the static `create` method to
|
|
41
|
+
* instantiate the class.
|
|
42
|
+
*/
|
|
43
|
+
private constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Runs the agent.
|
|
46
|
+
*
|
|
47
|
+
* @param inputs The validated input parameters for this invocation.
|
|
48
|
+
* @param signal An `AbortSignal` for cancellation.
|
|
49
|
+
* @returns A promise that resolves to the agent's final output.
|
|
50
|
+
*/
|
|
51
|
+
run(inputs: AgentInputs, signal: AbortSignal): Promise<OutputObject>;
|
|
52
|
+
/**
|
|
53
|
+
* Calls the generative model with the current context and tools.
|
|
54
|
+
*
|
|
55
|
+
* @returns The model's response, including any tool calls or text.
|
|
56
|
+
*/
|
|
57
|
+
private callModel;
|
|
58
|
+
/** Initializes a `GeminiChat` instance for the agent run. */
|
|
59
|
+
private createChatObject;
|
|
60
|
+
/**
|
|
61
|
+
* Executes function calls requested by the model and returns the results.
|
|
62
|
+
*
|
|
63
|
+
* @returns A new `Content` object to be added to the chat history.
|
|
64
|
+
*/
|
|
65
|
+
private processFunctionCalls;
|
|
66
|
+
/**
|
|
67
|
+
* Prepares the list of tool function declarations to be sent to the model.
|
|
68
|
+
*/
|
|
69
|
+
private prepareToolsList;
|
|
70
|
+
/** Builds the system prompt from the agent definition and inputs. */
|
|
71
|
+
private buildSystemPrompt;
|
|
72
|
+
/** Builds the final message for the extraction phase. */
|
|
73
|
+
private buildExtractionMessage;
|
|
74
|
+
/**
|
|
75
|
+
* Validates that all tools in a registry are safe for non-interactive use.
|
|
76
|
+
*
|
|
77
|
+
* @throws An error if a tool is not on the allow-list for non-interactive execution.
|
|
78
|
+
*/
|
|
79
|
+
private static validateTools;
|
|
80
|
+
/**
|
|
81
|
+
* Checks if the agent should terminate due to exceeding configured limits.
|
|
82
|
+
*
|
|
83
|
+
* @returns The reason for termination, or `null` if execution can continue.
|
|
84
|
+
*/
|
|
85
|
+
private checkTermination;
|
|
86
|
+
/** Emits an activity event to the configured callback. */
|
|
87
|
+
private emitActivity;
|
|
88
|
+
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { reportError } from '../utils/errorReporting.js';
|
|
7
|
+
import { GeminiChat, StreamEventType } from '../core/geminiChat.js';
|
|
8
|
+
import { executeToolCall } from '../core/nonInteractiveToolExecutor.js';
|
|
9
|
+
import { ToolRegistry } from '../tools/tool-registry.js';
|
|
10
|
+
import { getDirectoryContextString } from '../utils/environmentContext.js';
|
|
11
|
+
import { GlobTool } from '../tools/glob.js';
|
|
12
|
+
import { GrepTool } from '../tools/grep.js';
|
|
13
|
+
import { RipGrepTool } from '../tools/ripGrep.js';
|
|
14
|
+
import { LSTool } from '../tools/ls.js';
|
|
15
|
+
import { MemoryTool } from '../tools/memoryTool.js';
|
|
16
|
+
import { ReadFileTool } from '../tools/read-file.js';
|
|
17
|
+
import { ReadManyFilesTool } from '../tools/read-many-files.js';
|
|
18
|
+
import { WebSearchTool } from '../tools/web-search.js';
|
|
19
|
+
import { AgentTerminateMode } from './types.js';
|
|
20
|
+
import { templateString } from './utils.js';
|
|
21
|
+
import { parseThought } from '../utils/thoughtUtils.js';
|
|
22
|
+
/**
|
|
23
|
+
* Executes an agent loop based on an {@link AgentDefinition}.
|
|
24
|
+
*
|
|
25
|
+
* This executor uses a simplified two-phase approach:
|
|
26
|
+
* 1. **Work Phase:** The agent runs in a loop, calling tools until it has
|
|
27
|
+
* gathered all necessary information to fulfill its goal.
|
|
28
|
+
* 2. **Extraction Phase:** A final prompt is sent to the model to summarize
|
|
29
|
+
* the work and extract the final result in the desired format.
|
|
30
|
+
*/
|
|
31
|
+
export class AgentExecutor {
|
|
32
|
+
definition;
|
|
33
|
+
agentId;
|
|
34
|
+
toolRegistry;
|
|
35
|
+
runtimeContext;
|
|
36
|
+
onActivity;
|
|
37
|
+
/**
|
|
38
|
+
* Creates and validates a new `AgentExecutor` instance.
|
|
39
|
+
*
|
|
40
|
+
* This method ensures that all tools specified in the agent's definition are
|
|
41
|
+
* safe for non-interactive use before creating the executor.
|
|
42
|
+
*
|
|
43
|
+
* @param definition The definition object for the agent.
|
|
44
|
+
* @param runtimeContext The global runtime configuration.
|
|
45
|
+
* @param onActivity An optional callback to receive activity events.
|
|
46
|
+
* @returns A promise that resolves to a new `AgentExecutor` instance.
|
|
47
|
+
*/
|
|
48
|
+
static async create(definition, runtimeContext, onActivity) {
|
|
49
|
+
// Create an isolated tool registry for this agent instance.
|
|
50
|
+
const agentToolRegistry = new ToolRegistry(runtimeContext);
|
|
51
|
+
const parentToolRegistry = await runtimeContext.getToolRegistry();
|
|
52
|
+
if (definition.toolConfig) {
|
|
53
|
+
for (const toolRef of definition.toolConfig.tools) {
|
|
54
|
+
if (typeof toolRef === 'string') {
|
|
55
|
+
// If the tool is referenced by name, retrieve it from the parent
|
|
56
|
+
// registry and register it with the agent's isolated registry.
|
|
57
|
+
const toolFromParent = parentToolRegistry.getTool(toolRef);
|
|
58
|
+
if (toolFromParent) {
|
|
59
|
+
agentToolRegistry.registerTool(toolFromParent);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (typeof toolRef === 'object' &&
|
|
63
|
+
'name' in toolRef &&
|
|
64
|
+
'build' in toolRef) {
|
|
65
|
+
agentToolRegistry.registerTool(toolRef);
|
|
66
|
+
}
|
|
67
|
+
// Note: Raw `FunctionDeclaration` objects in the config don't need to be
|
|
68
|
+
// registered; their schemas are passed directly to the model later.
|
|
69
|
+
}
|
|
70
|
+
// Validate that all registered tools are safe for non-interactive
|
|
71
|
+
// execution.
|
|
72
|
+
await AgentExecutor.validateTools(agentToolRegistry, definition.name);
|
|
73
|
+
}
|
|
74
|
+
return new AgentExecutor(definition, runtimeContext, agentToolRegistry, onActivity);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Constructs a new AgentExecutor instance.
|
|
78
|
+
*
|
|
79
|
+
* @private This constructor is private. Use the static `create` method to
|
|
80
|
+
* instantiate the class.
|
|
81
|
+
*/
|
|
82
|
+
constructor(definition, runtimeContext, toolRegistry, onActivity) {
|
|
83
|
+
this.definition = definition;
|
|
84
|
+
this.runtimeContext = runtimeContext;
|
|
85
|
+
this.toolRegistry = toolRegistry;
|
|
86
|
+
this.onActivity = onActivity;
|
|
87
|
+
const randomIdPart = Math.random().toString(36).slice(2, 8);
|
|
88
|
+
this.agentId = `${this.definition.name}-${randomIdPart}`;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Runs the agent.
|
|
92
|
+
*
|
|
93
|
+
* @param inputs The validated input parameters for this invocation.
|
|
94
|
+
* @param signal An `AbortSignal` for cancellation.
|
|
95
|
+
* @returns A promise that resolves to the agent's final output.
|
|
96
|
+
*/
|
|
97
|
+
async run(inputs, signal) {
|
|
98
|
+
const startTime = Date.now();
|
|
99
|
+
let turnCounter = 0;
|
|
100
|
+
try {
|
|
101
|
+
const chat = await this.createChatObject(inputs);
|
|
102
|
+
const tools = this.prepareToolsList();
|
|
103
|
+
let terminateReason = AgentTerminateMode.GOAL;
|
|
104
|
+
// Phase 1: Work Phase
|
|
105
|
+
// The agent works in a loop until it stops calling tools.
|
|
106
|
+
let currentMessages = [
|
|
107
|
+
{ role: 'user', parts: [{ text: 'Get Started!' }] },
|
|
108
|
+
];
|
|
109
|
+
while (true) {
|
|
110
|
+
// Check for termination conditions like max turns or timeout.
|
|
111
|
+
const reason = this.checkTermination(startTime, turnCounter);
|
|
112
|
+
if (reason) {
|
|
113
|
+
terminateReason = reason;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (signal.aborted) {
|
|
117
|
+
terminateReason = AgentTerminateMode.ABORTED;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
// Call model
|
|
121
|
+
const promptId = `${this.runtimeContext.getSessionId()}#${this.agentId}#${turnCounter++}`;
|
|
122
|
+
const { functionCalls } = await this.callModel(chat, currentMessages, tools, signal, promptId);
|
|
123
|
+
if (signal.aborted) {
|
|
124
|
+
terminateReason = AgentTerminateMode.ABORTED;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
// If the model stops calling tools, the work phase is complete.
|
|
128
|
+
if (functionCalls.length === 0) {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
currentMessages = await this.processFunctionCalls(functionCalls, signal, promptId);
|
|
132
|
+
}
|
|
133
|
+
// If the work phase was terminated early, skip extraction and return.
|
|
134
|
+
if (terminateReason !== AgentTerminateMode.GOAL) {
|
|
135
|
+
return {
|
|
136
|
+
result: 'Agent execution was terminated before completion.',
|
|
137
|
+
terminate_reason: terminateReason,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// Phase 2: Extraction Phase
|
|
141
|
+
// A final message is sent to summarize findings and produce the output.
|
|
142
|
+
const extractionMessage = this.buildExtractionMessage();
|
|
143
|
+
const extractionMessages = [
|
|
144
|
+
{ role: 'user', parts: [{ text: extractionMessage }] },
|
|
145
|
+
];
|
|
146
|
+
const extractionPromptId = `${this.runtimeContext.getSessionId()}#${this.agentId}#extraction`;
|
|
147
|
+
// TODO: Consider if we should keep tools to avoid cache reset.
|
|
148
|
+
const { textResponse } = await this.callModel(chat, extractionMessages, [], // No tools are available in the extraction phase.
|
|
149
|
+
signal, extractionPromptId);
|
|
150
|
+
return {
|
|
151
|
+
result: textResponse || 'No response generated',
|
|
152
|
+
terminate_reason: terminateReason,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
this.emitActivity('ERROR', { error: String(error) });
|
|
157
|
+
throw error; // Re-throw the error for the parent context to handle.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Calls the generative model with the current context and tools.
|
|
162
|
+
*
|
|
163
|
+
* @returns The model's response, including any tool calls or text.
|
|
164
|
+
*/
|
|
165
|
+
async callModel(chat, messages, tools, signal, promptId) {
|
|
166
|
+
const messageParams = {
|
|
167
|
+
message: messages[0]?.parts || [],
|
|
168
|
+
config: {
|
|
169
|
+
abortSignal: signal,
|
|
170
|
+
tools: tools.length > 0 ? [{ functionDeclarations: tools }] : undefined,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
const responseStream = await chat.sendMessageStream(this.definition.modelConfig.model, messageParams, promptId);
|
|
174
|
+
const functionCalls = [];
|
|
175
|
+
let textResponse = '';
|
|
176
|
+
for await (const resp of responseStream) {
|
|
177
|
+
if (signal.aborted)
|
|
178
|
+
break;
|
|
179
|
+
if (resp.type === StreamEventType.CHUNK) {
|
|
180
|
+
const chunk = resp.value;
|
|
181
|
+
const parts = chunk.candidates?.[0]?.content?.parts;
|
|
182
|
+
// Extract and emit any subject "thought" content from the model.
|
|
183
|
+
const { subject } = parseThought(parts?.find((p) => p.thought)?.text || '');
|
|
184
|
+
if (subject) {
|
|
185
|
+
this.emitActivity('THOUGHT_CHUNK', { text: subject });
|
|
186
|
+
}
|
|
187
|
+
// Collect any function calls requested by the model.
|
|
188
|
+
if (chunk.functionCalls) {
|
|
189
|
+
functionCalls.push(...chunk.functionCalls);
|
|
190
|
+
}
|
|
191
|
+
// Handle text response (non-thought text)
|
|
192
|
+
const text = parts
|
|
193
|
+
?.filter((p) => !p.thought && p.text)
|
|
194
|
+
.map((p) => p.text)
|
|
195
|
+
.join('') || '';
|
|
196
|
+
if (text) {
|
|
197
|
+
textResponse += text;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { functionCalls, textResponse };
|
|
202
|
+
}
|
|
203
|
+
/** Initializes a `GeminiChat` instance for the agent run. */
|
|
204
|
+
async createChatObject(inputs) {
|
|
205
|
+
const { promptConfig, modelConfig } = this.definition;
|
|
206
|
+
if (!promptConfig.systemPrompt && !promptConfig.initialMessages) {
|
|
207
|
+
throw new Error('PromptConfig must define either `systemPrompt` or `initialMessages`.');
|
|
208
|
+
}
|
|
209
|
+
const startHistory = [...(promptConfig.initialMessages ?? [])];
|
|
210
|
+
// Build system instruction from the templated prompt string.
|
|
211
|
+
const systemInstruction = promptConfig.systemPrompt
|
|
212
|
+
? await this.buildSystemPrompt(inputs)
|
|
213
|
+
: undefined;
|
|
214
|
+
try {
|
|
215
|
+
const generationConfig = {
|
|
216
|
+
temperature: modelConfig.temp,
|
|
217
|
+
topP: modelConfig.top_p,
|
|
218
|
+
thinkingConfig: {
|
|
219
|
+
includeThoughts: true,
|
|
220
|
+
thinkingBudget: modelConfig.thinkingBudget ?? -1,
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
if (systemInstruction) {
|
|
224
|
+
generationConfig.systemInstruction = systemInstruction;
|
|
225
|
+
}
|
|
226
|
+
return new GeminiChat(this.runtimeContext, generationConfig, startHistory);
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
await reportError(error, `Error initializing Gemini chat for agent ${this.definition.name}.`, startHistory, 'startChat');
|
|
230
|
+
// Re-throw as a more specific error after reporting.
|
|
231
|
+
throw new Error(`Failed to create chat object: ${error}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Executes function calls requested by the model and returns the results.
|
|
236
|
+
*
|
|
237
|
+
* @returns A new `Content` object to be added to the chat history.
|
|
238
|
+
*/
|
|
239
|
+
async processFunctionCalls(functionCalls, signal, promptId) {
|
|
240
|
+
const allowedToolNames = new Set(this.toolRegistry.getAllToolNames());
|
|
241
|
+
// Filter out any tool calls that are not in the agent's allowed list.
|
|
242
|
+
const validatedFunctionCalls = functionCalls.filter((call) => {
|
|
243
|
+
if (!allowedToolNames.has(call.name)) {
|
|
244
|
+
console.warn(`[AgentExecutor] Agent '${this.definition.name}' attempted to call ` +
|
|
245
|
+
`unauthorized tool '${call.name}'. This call has been blocked.`);
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
return true;
|
|
249
|
+
});
|
|
250
|
+
const toolPromises = validatedFunctionCalls.map(async (functionCall) => {
|
|
251
|
+
const callId = functionCall.id ?? `${functionCall.name}-${Date.now()}`;
|
|
252
|
+
const args = functionCall.args ?? {};
|
|
253
|
+
this.emitActivity('TOOL_CALL_START', {
|
|
254
|
+
name: functionCall.name,
|
|
255
|
+
args,
|
|
256
|
+
});
|
|
257
|
+
const requestInfo = {
|
|
258
|
+
callId,
|
|
259
|
+
name: functionCall.name,
|
|
260
|
+
args: args,
|
|
261
|
+
isClientInitiated: true,
|
|
262
|
+
prompt_id: promptId,
|
|
263
|
+
};
|
|
264
|
+
const toolResponse = await executeToolCall(this.runtimeContext, requestInfo, signal);
|
|
265
|
+
if (toolResponse.error) {
|
|
266
|
+
this.emitActivity('ERROR', {
|
|
267
|
+
context: 'tool_call',
|
|
268
|
+
name: functionCall.name,
|
|
269
|
+
error: toolResponse.error.message,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
this.emitActivity('TOOL_CALL_END', {
|
|
274
|
+
name: functionCall.name,
|
|
275
|
+
output: toolResponse.resultDisplay,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return toolResponse;
|
|
279
|
+
});
|
|
280
|
+
const toolResponses = await Promise.all(toolPromises);
|
|
281
|
+
const toolResponseParts = toolResponses
|
|
282
|
+
.flatMap((response) => response.responseParts)
|
|
283
|
+
.filter((part) => part !== undefined);
|
|
284
|
+
// If all authorized tool calls failed, provide a generic error message
|
|
285
|
+
// to the model so it can try a different approach.
|
|
286
|
+
if (functionCalls.length > 0 && toolResponseParts.length === 0) {
|
|
287
|
+
toolResponseParts.push({
|
|
288
|
+
text: 'All tool calls failed. Please analyze the errors and try an alternative approach.',
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return [{ role: 'user', parts: toolResponseParts }];
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Prepares the list of tool function declarations to be sent to the model.
|
|
295
|
+
*/
|
|
296
|
+
prepareToolsList() {
|
|
297
|
+
const toolsList = [];
|
|
298
|
+
const { toolConfig } = this.definition;
|
|
299
|
+
if (toolConfig) {
|
|
300
|
+
const toolNamesToLoad = [];
|
|
301
|
+
for (const toolRef of toolConfig.tools) {
|
|
302
|
+
if (typeof toolRef === 'string') {
|
|
303
|
+
toolNamesToLoad.push(toolRef);
|
|
304
|
+
}
|
|
305
|
+
else if (typeof toolRef === 'object' && 'schema' in toolRef) {
|
|
306
|
+
// Tool instance with an explicit schema property.
|
|
307
|
+
toolsList.push(toolRef.schema);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
// Raw `FunctionDeclaration` object.
|
|
311
|
+
toolsList.push(toolRef);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Add schemas from tools that were registered by name.
|
|
315
|
+
toolsList.push(...this.toolRegistry.getFunctionDeclarationsFiltered(toolNamesToLoad));
|
|
316
|
+
}
|
|
317
|
+
return toolsList;
|
|
318
|
+
}
|
|
319
|
+
/** Builds the system prompt from the agent definition and inputs. */
|
|
320
|
+
async buildSystemPrompt(inputs) {
|
|
321
|
+
const { promptConfig, outputConfig } = this.definition;
|
|
322
|
+
if (!promptConfig.systemPrompt) {
|
|
323
|
+
return '';
|
|
324
|
+
}
|
|
325
|
+
// Inject user inputs into the prompt template.
|
|
326
|
+
let finalPrompt = templateString(promptConfig.systemPrompt, inputs);
|
|
327
|
+
// Append environment context (CWD and folder structure).
|
|
328
|
+
const dirContext = await getDirectoryContextString(this.runtimeContext);
|
|
329
|
+
finalPrompt += `\n\n# Environment Context\n${dirContext}`;
|
|
330
|
+
// Append completion criteria to guide the model's output.
|
|
331
|
+
if (outputConfig?.completion_criteria) {
|
|
332
|
+
finalPrompt += '\n\nEnsure you complete the following:\n';
|
|
333
|
+
for (const criteria of outputConfig.completion_criteria) {
|
|
334
|
+
finalPrompt += `- ${criteria}\n`;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// Append standard rules for non-interactive execution.
|
|
338
|
+
finalPrompt += `
|
|
339
|
+
Important Rules:
|
|
340
|
+
* You are running in a non-interactive mode. You CANNOT ask the user for input or clarification.
|
|
341
|
+
* Work systematically using available tools to complete your task.
|
|
342
|
+
* Always use absolute paths for file operations. Construct them using the provided "Environment Context".
|
|
343
|
+
* When you have completed your analysis and are ready to produce the final answer, stop calling tools.`;
|
|
344
|
+
return finalPrompt;
|
|
345
|
+
}
|
|
346
|
+
/** Builds the final message for the extraction phase. */
|
|
347
|
+
buildExtractionMessage() {
|
|
348
|
+
const { outputConfig } = this.definition;
|
|
349
|
+
if (outputConfig?.description) {
|
|
350
|
+
let message = `Based on your work so far, provide: ${outputConfig.description}`;
|
|
351
|
+
if (outputConfig.completion_criteria?.length) {
|
|
352
|
+
message += `\n\nBe sure you have addressed:\n`;
|
|
353
|
+
for (const criteria of outputConfig.completion_criteria) {
|
|
354
|
+
message += `- ${criteria}\n`;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return message;
|
|
358
|
+
}
|
|
359
|
+
// Fallback to a generic extraction message if no description is provided.
|
|
360
|
+
return 'Based on your work so far, provide a comprehensive summary of your analysis and findings. Do not perform any more function calls.';
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Validates that all tools in a registry are safe for non-interactive use.
|
|
364
|
+
*
|
|
365
|
+
* @throws An error if a tool is not on the allow-list for non-interactive execution.
|
|
366
|
+
*/
|
|
367
|
+
static async validateTools(toolRegistry, agentName) {
|
|
368
|
+
// Tools that are non-interactive. This is temporary until we have tool
|
|
369
|
+
// confirmations for subagents.
|
|
370
|
+
const allowlist = new Set([
|
|
371
|
+
LSTool.Name,
|
|
372
|
+
ReadFileTool.Name,
|
|
373
|
+
GrepTool.Name,
|
|
374
|
+
RipGrepTool.Name,
|
|
375
|
+
GlobTool.Name,
|
|
376
|
+
ReadManyFilesTool.Name,
|
|
377
|
+
MemoryTool.Name,
|
|
378
|
+
WebSearchTool.Name,
|
|
379
|
+
]);
|
|
380
|
+
for (const tool of toolRegistry.getAllTools()) {
|
|
381
|
+
if (!allowlist.has(tool.name)) {
|
|
382
|
+
throw new Error(`Tool "${tool.name}" is not on the allow-list for non-interactive ` +
|
|
383
|
+
`execution in agent "${agentName}". Only tools that do not require user ` +
|
|
384
|
+
`confirmation can be used in subagents.`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Checks if the agent should terminate due to exceeding configured limits.
|
|
390
|
+
*
|
|
391
|
+
* @returns The reason for termination, or `null` if execution can continue.
|
|
392
|
+
*/
|
|
393
|
+
checkTermination(startTime, turnCounter) {
|
|
394
|
+
const { runConfig } = this.definition;
|
|
395
|
+
if (runConfig.max_turns && turnCounter >= runConfig.max_turns) {
|
|
396
|
+
return AgentTerminateMode.MAX_TURNS;
|
|
397
|
+
}
|
|
398
|
+
const elapsedMinutes = (Date.now() - startTime) / (1000 * 60);
|
|
399
|
+
if (elapsedMinutes >= runConfig.max_time_minutes) {
|
|
400
|
+
return AgentTerminateMode.TIMEOUT;
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
/** Emits an activity event to the configured callback. */
|
|
405
|
+
emitActivity(type, data) {
|
|
406
|
+
if (this.onActivity) {
|
|
407
|
+
const event = {
|
|
408
|
+
isSubagentActivityEvent: true,
|
|
409
|
+
agentName: this.definition.name,
|
|
410
|
+
type,
|
|
411
|
+
data,
|
|
412
|
+
};
|
|
413
|
+
this.onActivity(event);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/agents/executor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQpE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,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