@google/gemini-cli-core 0.9.0-nightly.20250926.1487841d → 0.9.0-nightly.20251001.33269bdb
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 +164 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +96 -0
- package/dist/src/agents/executor.js +438 -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 +492 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +45 -0
- package/dist/src/agents/invocation.js +101 -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 +214 -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 +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -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 +112 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +123 -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/config/config.d.ts +11 -2
- package/dist/src/config/config.js +49 -3
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +63 -0
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/core/baseLlmClient.js +19 -21
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +57 -17
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.js +8 -29
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +223 -94
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +33 -23
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +1 -1
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +2 -1
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +11 -11
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- 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/mcp/sa-impersonation-provider.d.ts +33 -0
- package/dist/src/mcp/sa-impersonation-provider.js +130 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +11 -0
- package/dist/src/services/fileSystemService.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.d.ts +4 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +15 -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/clearcut-logger/event-metadata-key.d.ts +2 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +2 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +1 -24
- package/dist/src/telemetry/constants.js +1 -25
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +1 -1
- package/dist/src/telemetry/index.js +7 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +2 -1
- package/dist/src/telemetry/loggers.js +66 -11
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -3
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +76 -9
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +363 -19
- package/dist/src/telemetry/metrics.js +415 -235
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +352 -54
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +6 -0
- package/dist/src/telemetry/types.js +10 -0
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +2 -2
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +28 -3
- package/dist/src/test-utils/mock-tool.js +71 -1
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/glob.js +2 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/mcp-client.js +16 -0
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/shell.js +1 -54
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +0 -1
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +20 -1
- package/dist/src/tools/smart-edit.js +114 -4
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +90 -6
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +6 -0
- package/dist/src/tools/tool-names.js +15 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.test.js +10 -10
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +2 -2
- package/dist/src/utils/flashFallback.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/retry.d.ts +3 -1
- package/dist/src/utils/retry.js +13 -4
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +2 -2
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +0 -1
- package/dist/src/utils/shell-utils.js +1 -1
- package/dist/src/utils/shell-utils.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/src/utils/tool-utils.js +2 -2
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +0 -8
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/test-utils/tools.d.ts +0 -45
- package/dist/src/test-utils/tools.js +0 -105
- package/dist/src/test-utils/tools.js.map +0 -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,164 @@
|
|
|
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 { GLOB_TOOL_NAME } from '../tools/tool-names.js';
|
|
9
|
+
import { GrepTool } from '../tools/grep.js';
|
|
10
|
+
import { DEFAULT_GEMINI_MODEL } from '../config/models.js';
|
|
11
|
+
const CODEBASE_REPORT_MARKDOWN = `<CodebaseReport>
|
|
12
|
+
<SummaryOfFindings>
|
|
13
|
+
The user's objective is to remove an optional \`config\` property from the command context. The investigation identified that the \`CommandContext\` interface, defined in \`packages/cli/src/ui/commands/types.ts\`, contains a nullable \`config: Config | null\` property. A \`TODO\` comment confirms the intent to make this property non-nullable.
|
|
14
|
+
The primary challenge is that numerous tests throughout the codebase rely on this property being optional, often setting it to \`null\` during the creation of mock \`CommandContext\` objects. The key to resolving this is to update the mock creation utility, \`createMockCommandContext\`, to provide a default mock \`Config\` object instead of \`null\`.
|
|
15
|
+
The \`Config\` class, defined in \`packages/core/src/config/config.ts\`, is the type of the \`config\` property. To facilitate the required changes, a mock \`Config\` object can be created based on the \`ConfigParameters\` interface from the same file.
|
|
16
|
+
The plan involves three main steps:
|
|
17
|
+
1. Update the \`CommandContext\` interface to make the \`config\` property non-nullable.
|
|
18
|
+
2. Modify \`createMockCommandContext\` to use a default mock \`Config\` object.
|
|
19
|
+
3. Update all test files that currently rely on a null \`config\` to use the updated mock creation utility.
|
|
20
|
+
</SummaryOfFindings>
|
|
21
|
+
<ExplorationTrace>
|
|
22
|
+
1. Searched for "CommandContext" to locate its definition.
|
|
23
|
+
2. Read \`packages/cli/src/ui/commands/types.ts\` and identified the \`config: Config | null\` property.
|
|
24
|
+
3. Searched for \`config: null\` to find all instances where the config is explicitly set to null.
|
|
25
|
+
4. Read \`packages/cli/src/test-utils/mockCommandContext.ts\` to understand how mock contexts are created.
|
|
26
|
+
5. Searched for \`createMockCommandContext\` to find all its usages.
|
|
27
|
+
6. Searched for the definition of the \`Config\` interface to understand how to create a mock object.
|
|
28
|
+
7. Read \`packages/core/src/config/config.ts\` to understand the \`Config\` class and \`ConfigParameters\` interface.
|
|
29
|
+
</ExplorationTrace>
|
|
30
|
+
<RelevantLocations>
|
|
31
|
+
<Location>
|
|
32
|
+
<FilePath>packages/cli/src/ui/commands/types.ts</FilePath>
|
|
33
|
+
<Reasoning>This file contains the definition of the \`CommandContext\` interface, which is the central piece of this investigation. The property \`config: Config | null\` needs to be changed to \`config: Config\` here.</Reasoning>
|
|
34
|
+
<KeySymbols>
|
|
35
|
+
<Symbol>CommandContext</Symbol>
|
|
36
|
+
</KeySymbols>
|
|
37
|
+
</Location>
|
|
38
|
+
<Location>
|
|
39
|
+
<FilePath>packages/cli/src/test-utils/mockCommandContext.ts</FilePath>
|
|
40
|
+
<Reasoning>This file contains the \`createMockCommandContext\` function, which is used in many tests to create mock \`CommandContext\` objects. This function needs to be updated to provide a default mock \`Config\` object instead of \`null\`.</Reasoning>
|
|
41
|
+
<KeySymbols>
|
|
42
|
+
<Symbol>createMockCommandContext</Symbol>
|
|
43
|
+
</KeySymbols>
|
|
44
|
+
</Location>
|
|
45
|
+
<Location>
|
|
46
|
+
<FilePath>packages/core/src/config/config.ts</FilePath>
|
|
47
|
+
<Reasoning>This file defines the \`Config\` class and the \`ConfigParameters\` interface. This information is needed to create a proper mock \`Config\` object to be used in the updated \`createMockCommandContext\` function.</Reasoning>
|
|
48
|
+
<KeySymbols>
|
|
49
|
+
<Symbol>Config</Symbol>
|
|
50
|
+
<Symbol>ConfigParameters</Symbol>
|
|
51
|
+
</KeySymbols>
|
|
52
|
+
</Location>
|
|
53
|
+
</RelevantLocations>
|
|
54
|
+
</CodebaseReport>`;
|
|
55
|
+
/**
|
|
56
|
+
* A Proof-of-Concept subagent specialized in analyzing codebase structure,
|
|
57
|
+
* dependencies, and technologies.
|
|
58
|
+
*/
|
|
59
|
+
export const CodebaseInvestigatorAgent = {
|
|
60
|
+
name: 'codebase_investigator',
|
|
61
|
+
displayName: 'Codebase Investigator Agent',
|
|
62
|
+
description: `Invoke this agent to delegates complex codebase exploration to an autonomous subagent.
|
|
63
|
+
Use for vague user requests that require searching multiple files to understand a feature or find context.
|
|
64
|
+
Returns a structured xml report with key file paths, symbols, architectural map and insights to solve a task.`,
|
|
65
|
+
inputConfig: {
|
|
66
|
+
inputs: {
|
|
67
|
+
objective: {
|
|
68
|
+
description: `A comprehensive and detailed description of the user's ultimate goal.
|
|
69
|
+
You must include original user's objective as well as questions and any extra context and questions you may have.`,
|
|
70
|
+
type: 'string',
|
|
71
|
+
required: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
outputConfig: {
|
|
76
|
+
description: `A detailed markdown report summarizing the findings of the codebase investigation and insights that are the foundation for planning and executing any code modification related to the objective.
|
|
77
|
+
# Report Format
|
|
78
|
+
The final report should be structured markdown, clearly answering the investigation focus, citing the files, symbols, architectural patterns and how they relate to the given investigation focus.
|
|
79
|
+
The report should strictly follow a format like this example:
|
|
80
|
+
${CODEBASE_REPORT_MARKDOWN}
|
|
81
|
+
`,
|
|
82
|
+
completion_criteria: [
|
|
83
|
+
'The report must directly address the initial `objective`.',
|
|
84
|
+
'Cite specific files, functions, or configuration snippets and symbols as evidence for your findings.',
|
|
85
|
+
'Conclude with a xml markdown summary of the key files, symbols, technologies, architectural patterns, and conventions discovered.',
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
modelConfig: {
|
|
89
|
+
model: DEFAULT_GEMINI_MODEL,
|
|
90
|
+
temp: 0.1,
|
|
91
|
+
top_p: 0.95,
|
|
92
|
+
thinkingBudget: -1,
|
|
93
|
+
},
|
|
94
|
+
runConfig: {
|
|
95
|
+
max_time_minutes: 5,
|
|
96
|
+
max_turns: 15,
|
|
97
|
+
},
|
|
98
|
+
toolConfig: {
|
|
99
|
+
// Grant access only to read-only tools.
|
|
100
|
+
tools: [LSTool.Name, ReadFileTool.Name, GLOB_TOOL_NAME, GrepTool.Name],
|
|
101
|
+
},
|
|
102
|
+
promptConfig: {
|
|
103
|
+
query: `Your task is to do a deep investigation of the codebase to find all relevant files, code locations, architectural mental map and insights to solve for the following user objective:
|
|
104
|
+
<objective>
|
|
105
|
+
\${objective}
|
|
106
|
+
</objective>`,
|
|
107
|
+
systemPrompt: `You are **Codebase Investigator**, a hyper-specialized AI agent and an expert in reverse-engineering complex software projects. You are a sub-agent within a larger development system.
|
|
108
|
+
Your **SOLE PURPOSE** is to build a complete mental model of the code relevant to a given investigation. You must identify all relevant files, understand their roles, and foresee the direct architectural consequences of potential changes.
|
|
109
|
+
You are a sub-agent in a larger system. Your only responsibility is to provide deep, actionable context.
|
|
110
|
+
- **DO:** Find the key modules, classes, and functions that are part of the problem and its solution.
|
|
111
|
+
- **DO:** Understand *why* the code is written the way it is. Question everything.
|
|
112
|
+
- **DO:** Foresee the ripple effects of a change. If \`function A\` is modified, you must check its callers. If a data structure is altered, you must identify where its type definitions need to be updated.
|
|
113
|
+
- **DO:** provide a conclusion and insights to the main agent that invoked you. If the agent is trying to solve a bug, you should provide the root cause of the bug, its impacts, how to fix it etc. If it's a new feature, you should provide insights on where to implement it, what chagnes are necessary etc.
|
|
114
|
+
- **DO NOT:** Write the final implementation code yourself.
|
|
115
|
+
- **DO NOT:** Stop at the first relevant file. Your goal is a comprehensive understanding of the entire relevant subsystem.
|
|
116
|
+
You operate in a non-interactive loop and must reason based on the information provided and the output of your tools.
|
|
117
|
+
---
|
|
118
|
+
## Core Directives
|
|
119
|
+
<RULES>
|
|
120
|
+
1. **DEEP ANALYSIS, NOT JUST FILE FINDING:** Your goal is to understand the *why* behind the code. Don't just list files; explain their purpose and the role of their key components. Your final report should empower another agent to make a correct and complete fix.
|
|
121
|
+
2. **SYSTEMATIC & CURIOUS EXPLORATION:** Start with high-value clues (like tracebacks or ticket numbers) and broaden your search as needed. Think like a senior engineer doing a code review. An initial file contains clues (imports, function calls, puzzling logic). **If you find something you don't understand, you MUST prioritize investigating it until it is clear.** Treat confusion as a signal to dig deeper.
|
|
122
|
+
3. **HOLISTIC & PRECISE:** Your goal is to find the complete and minimal set of locations that need to be understood or changed. Do not stop until you are confident you have considered the side effects of a potential fix (e.g., type errors, breaking changes to callers, opportunities for code reuse).
|
|
123
|
+
4. **Web Search:** You are allowed to use the \`web_fetch\` tool to research libraries, language features, or concepts you don't understand (e.g., "what does gettext.translation do with localedir=None?").
|
|
124
|
+
</RULES>
|
|
125
|
+
---
|
|
126
|
+
## Scratchpad Management
|
|
127
|
+
**This is your most critical function. Your scratchpad is your memory and your plan.**
|
|
128
|
+
1. **Initialization:** On your very first turn, you **MUST** create the \`<scratchpad>\` section. Analyze the \`task\` and create an initial \`Checklist\` of investigation goals and a \`Questions to Resolve\` section for any initial uncertainties.
|
|
129
|
+
2. **Constant Updates:** After **every** \`<OBSERVATION>\`, you **MUST** update the scratchpad.
|
|
130
|
+
* Mark checklist items as complete: \`[x]\`.
|
|
131
|
+
* Add new checklist items as you trace the architecture.
|
|
132
|
+
* **Explicitly log questions in \`Questions to Resolve\`** (e.g., \`[ ] What is the purpose of the 'None' element in this list?\`). Do not consider your investigation complete until this list is empty.
|
|
133
|
+
* Record \`Key Findings\` with file paths and notes about their purpose and relevance.
|
|
134
|
+
* Update \`Irrelevant Paths to Ignore\` to avoid re-investigating dead ends.
|
|
135
|
+
3. **Thinking on Paper:** The scratchpad must show your reasoning process, including how you resolve your questions.
|
|
136
|
+
---
|
|
137
|
+
## Scratchpad
|
|
138
|
+
For every turn, you **MUST** update your internal state based on the observation.
|
|
139
|
+
Scratchpad example:
|
|
140
|
+
<SCRATCHPAD>
|
|
141
|
+
**Checklist:**
|
|
142
|
+
- [x] Find the main translation loading logic.
|
|
143
|
+
- [ ] **(New)** Investigate the \`gettext.translation\` function to understand its arguments.
|
|
144
|
+
- [ ] **(New)** Check the signature of \`locale.init\` and its callers for type consistency.
|
|
145
|
+
**Questions to Resolve:**
|
|
146
|
+
- [x] ~~What is the purpose of the 'None' element in the \`locale_dirs\` list?~~ **Finding:** It's for system-wide gettext catalogs.
|
|
147
|
+
**Key Findings:**
|
|
148
|
+
- \`sphinx/application.py\`: Assembles the \`locale_dirs\` list. The order is critical.
|
|
149
|
+
- \`sphinx/locale/__init__.py\`: Consumes \`locale_dirs\`. Its \`init\` function signature might need a type hint update if \`None\` is passed.
|
|
150
|
+
**Irrelevant Paths to Ignore:**
|
|
151
|
+
- \`README.md\`
|
|
152
|
+
**Next Step:**
|
|
153
|
+
- I will use \`web_fetch\` to search for "python gettext translation localedir None" to resolve my open question.
|
|
154
|
+
</SCRATCHPAD>
|
|
155
|
+
## Termination
|
|
156
|
+
Your mission is complete **ONLY** when your \`Questions to Resolve\` list is empty and you are confident you have identified all files and necessary change *considerations*.
|
|
157
|
+
# Report Format
|
|
158
|
+
The final report should be structured markdown, clearly answering the investigation focus, citing the files, symbols, architectural patterns and how they relate to the given investigation focus.
|
|
159
|
+
The report should strictly follow a format like this example:
|
|
160
|
+
${CODEBASE_REPORT_MARKDOWN}
|
|
161
|
+
`,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
//# 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,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2Cf,CAAC;AAEnB;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE;;kHAEmG;IAChH,WAAW,EAAE;QACX,MAAM,EAAE;YACN,SAAS,EAAE;gBACT,WAAW,EAAE;4HACuG;gBACpH,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;KACF;IACD,YAAY,EAAE;QACZ,WAAW,EAAE;;;;EAIf,wBAAwB;CACzB;QACG,mBAAmB,EAAE;YACnB,2DAA2D;YAC3D,sGAAsG;YACtG,mIAAmI;SACpI;KACF;IAED,WAAW,EAAE;QACX,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,IAAI;QACX,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,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC;KACvE;IAED,YAAY,EAAE;QACZ,KAAK,EAAE;;;aAGE;QACT,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDhB,wBAAwB;CACzB;KACE;CACF,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
* Applies template strings to initial messages.
|
|
76
|
+
*
|
|
77
|
+
* @param initialMessages The initial messages from the prompt config.
|
|
78
|
+
* @param inputs The validated input parameters for this invocation.
|
|
79
|
+
* @returns A new array of `Content` with templated strings.
|
|
80
|
+
*/
|
|
81
|
+
private applyTemplateToInitialMessages;
|
|
82
|
+
/**
|
|
83
|
+
* Validates that all tools in a registry are safe for non-interactive use.
|
|
84
|
+
*
|
|
85
|
+
* @throws An error if a tool is not on the allow-list for non-interactive execution.
|
|
86
|
+
*/
|
|
87
|
+
private static validateTools;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if the agent should terminate due to exceeding configured limits.
|
|
90
|
+
*
|
|
91
|
+
* @returns The reason for termination, or `null` if execution can continue.
|
|
92
|
+
*/
|
|
93
|
+
private checkTermination;
|
|
94
|
+
/** Emits an activity event to the configured callback. */
|
|
95
|
+
private emitActivity;
|
|
96
|
+
}
|