@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.
Files changed (164) hide show
  1. package/dist/src/agents/codebase-investigator.d.ts +11 -0
  2. package/dist/src/agents/codebase-investigator.js +164 -0
  3. package/dist/src/agents/codebase-investigator.js.map +1 -0
  4. package/dist/src/agents/executor.d.ts +96 -0
  5. package/dist/src/agents/executor.js +438 -0
  6. package/dist/src/agents/executor.js.map +1 -0
  7. package/dist/src/agents/executor.test.d.ts +6 -0
  8. package/dist/src/agents/executor.test.js +492 -0
  9. package/dist/src/agents/executor.test.js.map +1 -0
  10. package/dist/src/agents/invocation.d.ts +45 -0
  11. package/dist/src/agents/invocation.js +101 -0
  12. package/dist/src/agents/invocation.js.map +1 -0
  13. package/dist/src/agents/invocation.test.d.ts +6 -0
  14. package/dist/src/agents/invocation.test.js +214 -0
  15. package/dist/src/agents/invocation.test.js.map +1 -0
  16. package/dist/src/agents/registry.d.ts +35 -0
  17. package/dist/src/agents/registry.js +58 -0
  18. package/dist/src/agents/registry.js.map +1 -0
  19. package/dist/src/agents/registry.test.d.ts +6 -0
  20. package/dist/src/agents/registry.test.js +146 -0
  21. package/dist/src/agents/registry.test.js.map +1 -0
  22. package/dist/src/agents/schema-utils.d.ts +39 -0
  23. package/dist/src/agents/schema-utils.js +57 -0
  24. package/dist/src/agents/schema-utils.js.map +1 -0
  25. package/dist/src/agents/schema-utils.test.d.ts +6 -0
  26. package/dist/src/agents/schema-utils.test.js +144 -0
  27. package/dist/src/agents/schema-utils.test.js.map +1 -0
  28. package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
  29. package/dist/src/agents/subagent-tool-wrapper.js +48 -0
  30. package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
  31. package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
  32. package/dist/src/agents/subagent-tool-wrapper.test.js +112 -0
  33. package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
  34. package/dist/src/agents/types.d.ts +123 -0
  35. package/dist/src/agents/types.js +17 -0
  36. package/dist/src/agents/types.js.map +1 -0
  37. package/dist/src/agents/utils.d.ts +15 -0
  38. package/dist/src/agents/utils.js +29 -0
  39. package/dist/src/agents/utils.js.map +1 -0
  40. package/dist/src/agents/utils.test.d.ts +6 -0
  41. package/dist/src/agents/utils.test.js +87 -0
  42. package/dist/src/agents/utils.test.js.map +1 -0
  43. package/dist/src/config/config.d.ts +11 -2
  44. package/dist/src/config/config.js +49 -3
  45. package/dist/src/config/config.js.map +1 -1
  46. package/dist/src/config/config.test.js +63 -0
  47. package/dist/src/config/config.test.js.map +1 -1
  48. package/dist/src/core/baseLlmClient.js +19 -21
  49. package/dist/src/core/baseLlmClient.js.map +1 -1
  50. package/dist/src/core/baseLlmClient.test.js +57 -17
  51. package/dist/src/core/baseLlmClient.test.js.map +1 -1
  52. package/dist/src/core/client.js +8 -29
  53. package/dist/src/core/client.js.map +1 -1
  54. package/dist/src/core/client.test.js +223 -94
  55. package/dist/src/core/client.test.js.map +1 -1
  56. package/dist/src/core/coreToolScheduler.test.js +33 -23
  57. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  58. package/dist/src/core/geminiChat.js +1 -1
  59. package/dist/src/core/geminiChat.js.map +1 -1
  60. package/dist/src/core/geminiChat.test.js +2 -1
  61. package/dist/src/core/geminiChat.test.js.map +1 -1
  62. package/dist/src/core/nonInteractiveToolExecutor.test.js +11 -11
  63. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  64. package/dist/src/generated/git-commit.d.ts +2 -2
  65. package/dist/src/generated/git-commit.js +2 -2
  66. package/dist/src/ide/detect-ide.d.ts +1 -0
  67. package/dist/src/ide/detect-ide.js +4 -1
  68. package/dist/src/ide/detect-ide.js.map +1 -1
  69. package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
  70. package/dist/src/mcp/sa-impersonation-provider.js +130 -0
  71. package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
  72. package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
  73. package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
  74. package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
  75. package/dist/src/services/fileSystemService.d.ts +9 -0
  76. package/dist/src/services/fileSystemService.js +11 -0
  77. package/dist/src/services/fileSystemService.js.map +1 -1
  78. package/dist/src/services/shellExecutionService.d.ts +2 -0
  79. package/dist/src/services/shellExecutionService.js +48 -7
  80. package/dist/src/services/shellExecutionService.js.map +1 -1
  81. package/dist/src/services/shellExecutionService.test.js +13 -4
  82. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  83. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +4 -2
  84. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +15 -1
  85. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  86. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +18 -0
  87. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  88. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +2 -1
  89. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +2 -0
  90. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  91. package/dist/src/telemetry/constants.d.ts +1 -24
  92. package/dist/src/telemetry/constants.js +1 -25
  93. package/dist/src/telemetry/constants.js.map +1 -1
  94. package/dist/src/telemetry/index.d.ts +1 -1
  95. package/dist/src/telemetry/index.js +7 -1
  96. package/dist/src/telemetry/index.js.map +1 -1
  97. package/dist/src/telemetry/loggers.d.ts +2 -1
  98. package/dist/src/telemetry/loggers.js +66 -11
  99. package/dist/src/telemetry/loggers.js.map +1 -1
  100. package/dist/src/telemetry/loggers.test.circular.js +3 -3
  101. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  102. package/dist/src/telemetry/loggers.test.js +76 -9
  103. package/dist/src/telemetry/loggers.test.js.map +1 -1
  104. package/dist/src/telemetry/metrics.d.ts +363 -19
  105. package/dist/src/telemetry/metrics.js +415 -235
  106. package/dist/src/telemetry/metrics.js.map +1 -1
  107. package/dist/src/telemetry/metrics.test.js +352 -54
  108. package/dist/src/telemetry/metrics.test.js.map +1 -1
  109. package/dist/src/telemetry/types.d.ts +6 -0
  110. package/dist/src/telemetry/types.js +10 -0
  111. package/dist/src/telemetry/types.js.map +1 -1
  112. package/dist/src/telemetry/uiTelemetry.test.js +2 -2
  113. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  114. package/dist/src/test-utils/mock-tool.d.ts +28 -3
  115. package/dist/src/test-utils/mock-tool.js +71 -1
  116. package/dist/src/test-utils/mock-tool.js.map +1 -1
  117. package/dist/src/tools/glob.js +2 -1
  118. package/dist/src/tools/glob.js.map +1 -1
  119. package/dist/src/tools/mcp-client.js +16 -0
  120. package/dist/src/tools/mcp-client.js.map +1 -1
  121. package/dist/src/tools/shell.js +1 -54
  122. package/dist/src/tools/shell.js.map +1 -1
  123. package/dist/src/tools/shell.test.js +0 -1
  124. package/dist/src/tools/shell.test.js.map +1 -1
  125. package/dist/src/tools/smart-edit.d.ts +20 -1
  126. package/dist/src/tools/smart-edit.js +114 -4
  127. package/dist/src/tools/smart-edit.js.map +1 -1
  128. package/dist/src/tools/smart-edit.test.js +90 -6
  129. package/dist/src/tools/smart-edit.test.js.map +1 -1
  130. package/dist/src/tools/tool-names.d.ts +6 -0
  131. package/dist/src/tools/tool-names.js +15 -0
  132. package/dist/src/tools/tool-names.js.map +1 -0
  133. package/dist/src/tools/tool-registry.test.js +10 -10
  134. package/dist/src/tools/tool-registry.test.js.map +1 -1
  135. package/dist/src/utils/flashFallback.test.js +2 -2
  136. package/dist/src/utils/flashFallback.test.js.map +1 -1
  137. package/dist/src/utils/llm-edit-fixer.js +10 -1
  138. package/dist/src/utils/llm-edit-fixer.js.map +1 -1
  139. package/dist/src/utils/llm-edit-fixer.test.js +81 -0
  140. package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
  141. package/dist/src/utils/memoryImportProcessor.js +13 -20
  142. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  143. package/dist/src/utils/memoryImportProcessor.test.js +14 -0
  144. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  145. package/dist/src/utils/retry.d.ts +3 -1
  146. package/dist/src/utils/retry.js +13 -4
  147. package/dist/src/utils/retry.js.map +1 -1
  148. package/dist/src/utils/retry.test.js +2 -2
  149. package/dist/src/utils/retry.test.js.map +1 -1
  150. package/dist/src/utils/shell-utils.d.ts +0 -1
  151. package/dist/src/utils/shell-utils.js +1 -1
  152. package/dist/src/utils/shell-utils.js.map +1 -1
  153. package/dist/src/utils/terminalSerializer.d.ts +1 -4
  154. package/dist/src/utils/terminalSerializer.js +3 -3
  155. package/dist/src/utils/terminalSerializer.js.map +1 -1
  156. package/dist/src/utils/tool-utils.js +2 -2
  157. package/dist/src/utils/tool-utils.js.map +1 -1
  158. package/dist/src/utils/tool-utils.test.js +0 -8
  159. package/dist/src/utils/tool-utils.test.js.map +1 -1
  160. package/dist/tsconfig.tsbuildinfo +1 -1
  161. package/package.json +1 -1
  162. package/dist/src/test-utils/tools.d.ts +0 -45
  163. package/dist/src/test-utils/tools.js +0 -105
  164. package/dist/src/test-utils/tools.js.map +0 -1
@@ -0,0 +1,492 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, it, expect, vi, beforeEach, afterEach, } from 'vitest';
7
+ import { AgentExecutor } from './executor.js';
8
+ import { AgentTerminateMode } from './types.js';
9
+ import { makeFakeConfig } from '../test-utils/config.js';
10
+ import { ToolRegistry } from '../tools/tool-registry.js';
11
+ import { LSTool } from '../tools/ls.js';
12
+ import { ReadFileTool } from '../tools/read-file.js';
13
+ import { GeminiChat, StreamEventType, } from '../core/geminiChat.js';
14
+ import { MockTool } from '../test-utils/mock-tool.js';
15
+ import { getDirectoryContextString } from '../utils/environmentContext.js';
16
+ const { mockSendMessageStream, mockExecuteToolCall } = vi.hoisted(() => ({
17
+ mockSendMessageStream: vi.fn(),
18
+ mockExecuteToolCall: vi.fn(),
19
+ }));
20
+ vi.mock('../core/geminiChat.js', async (importOriginal) => {
21
+ const actual = await importOriginal();
22
+ return {
23
+ ...actual,
24
+ GeminiChat: vi.fn().mockImplementation(() => ({
25
+ sendMessageStream: mockSendMessageStream,
26
+ })),
27
+ };
28
+ });
29
+ vi.mock('../core/nonInteractiveToolExecutor.js', () => ({
30
+ executeToolCall: mockExecuteToolCall,
31
+ }));
32
+ vi.mock('../utils/environmentContext.js');
33
+ const MockedGeminiChat = GeminiChat;
34
+ // A mock tool that is NOT on the NON_INTERACTIVE_TOOL_ALLOWLIST
35
+ const MOCK_TOOL_NOT_ALLOWED = new MockTool({ name: 'write_file' });
36
+ const createMockResponseChunk = (parts, functionCalls) => ({
37
+ candidates: [{ index: 0, content: { role: 'model', parts } }],
38
+ functionCalls,
39
+ });
40
+ const mockModelResponse = (functionCalls, thought, text) => {
41
+ const parts = [];
42
+ if (thought) {
43
+ parts.push({
44
+ text: `**${thought}** This is the reasoning part.`,
45
+ thought: true,
46
+ });
47
+ }
48
+ if (text)
49
+ parts.push({ text });
50
+ const responseChunk = createMockResponseChunk(parts,
51
+ // Ensure functionCalls is undefined if the array is empty, matching API behavior
52
+ functionCalls.length > 0 ? functionCalls : undefined);
53
+ mockSendMessageStream.mockImplementationOnce(async () => (async function* () {
54
+ yield {
55
+ type: StreamEventType.CHUNK,
56
+ value: responseChunk,
57
+ };
58
+ })());
59
+ };
60
+ let mockConfig;
61
+ let parentToolRegistry;
62
+ const createTestDefinition = (tools = [LSTool.Name], runConfigOverrides = {}, outputConfigOverrides = {}, promptConfigOverrides = {}) => ({
63
+ name: 'TestAgent',
64
+ description: 'An agent for testing.',
65
+ inputConfig: {
66
+ inputs: { goal: { type: 'string', required: true, description: 'goal' } },
67
+ },
68
+ modelConfig: { model: 'gemini-test-model', temp: 0, top_p: 1 },
69
+ runConfig: { max_time_minutes: 5, max_turns: 5, ...runConfigOverrides },
70
+ promptConfig: {
71
+ systemPrompt: 'Achieve the goal: ${goal}.',
72
+ ...promptConfigOverrides,
73
+ },
74
+ toolConfig: { tools },
75
+ outputConfig: { description: 'The final result.', ...outputConfigOverrides },
76
+ });
77
+ describe('AgentExecutor', () => {
78
+ let activities;
79
+ let onActivity;
80
+ let abortController;
81
+ let signal;
82
+ beforeEach(async () => {
83
+ mockSendMessageStream.mockClear();
84
+ mockExecuteToolCall.mockClear();
85
+ vi.clearAllMocks();
86
+ // Use fake timers for timeout and concurrency testing
87
+ vi.useFakeTimers();
88
+ mockConfig = makeFakeConfig();
89
+ parentToolRegistry = new ToolRegistry(mockConfig);
90
+ parentToolRegistry.registerTool(new LSTool(mockConfig));
91
+ parentToolRegistry.registerTool(new ReadFileTool(mockConfig));
92
+ parentToolRegistry.registerTool(MOCK_TOOL_NOT_ALLOWED);
93
+ vi.spyOn(mockConfig, 'getToolRegistry').mockResolvedValue(parentToolRegistry);
94
+ vi.mocked(getDirectoryContextString).mockResolvedValue('Mocked Environment Context');
95
+ activities = [];
96
+ onActivity = (activity) => activities.push(activity);
97
+ abortController = new AbortController();
98
+ signal = abortController.signal;
99
+ });
100
+ afterEach(() => {
101
+ vi.useRealTimers();
102
+ });
103
+ describe('create (Initialization and Validation)', () => {
104
+ it('should create successfully with allowed tools', async () => {
105
+ const definition = createTestDefinition([LSTool.Name]);
106
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
107
+ expect(executor).toBeInstanceOf(AgentExecutor);
108
+ });
109
+ it('SECURITY: should throw if a tool is not on the non-interactive allowlist', async () => {
110
+ const definition = createTestDefinition([MOCK_TOOL_NOT_ALLOWED.name]);
111
+ await expect(AgentExecutor.create(definition, mockConfig, onActivity)).rejects.toThrow(`Tool "${MOCK_TOOL_NOT_ALLOWED.name}" is not on the allow-list for non-interactive execution`);
112
+ });
113
+ it('should create an isolated ToolRegistry for the agent', async () => {
114
+ const definition = createTestDefinition([LSTool.Name, ReadFileTool.Name]);
115
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
116
+ // @ts-expect-error - accessing private property for test validation
117
+ const agentRegistry = executor.toolRegistry;
118
+ expect(agentRegistry).not.toBe(parentToolRegistry);
119
+ expect(agentRegistry.getAllToolNames()).toEqual(expect.arrayContaining([LSTool.Name, ReadFileTool.Name]));
120
+ expect(agentRegistry.getAllToolNames()).toHaveLength(2);
121
+ expect(agentRegistry.getTool(MOCK_TOOL_NOT_ALLOWED.name)).toBeUndefined();
122
+ });
123
+ });
124
+ describe('run (Execution Loop and Logic)', () => {
125
+ it('should execute a successful work and extraction phase (Happy Path) and emit activities', async () => {
126
+ const definition = createTestDefinition();
127
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
128
+ const inputs = { goal: 'Find files' };
129
+ // Turn 1: Model calls ls
130
+ mockModelResponse([{ name: LSTool.Name, args: { path: '.' }, id: 'call1' }], 'T1: Listing');
131
+ mockExecuteToolCall.mockResolvedValueOnce({
132
+ callId: 'call1',
133
+ resultDisplay: 'file1.txt',
134
+ responseParts: [
135
+ {
136
+ functionResponse: {
137
+ name: LSTool.Name,
138
+ response: { result: 'file1.txt' },
139
+ id: 'call1',
140
+ },
141
+ },
142
+ ],
143
+ error: undefined,
144
+ });
145
+ // Turn 2: Model stops
146
+ mockModelResponse([], 'T2: Done');
147
+ // Extraction Phase
148
+ mockModelResponse([], undefined, 'Result: file1.txt.');
149
+ const output = await executor.run(inputs, signal);
150
+ expect(mockSendMessageStream).toHaveBeenCalledTimes(3);
151
+ expect(mockExecuteToolCall).toHaveBeenCalledTimes(1);
152
+ // Verify System Prompt Templating
153
+ const chatConstructorArgs = MockedGeminiChat.mock.calls[0];
154
+ const chatConfig = chatConstructorArgs[1];
155
+ expect(chatConfig?.systemInstruction).toContain('Achieve the goal: Find files.');
156
+ // Verify environment context is appended
157
+ expect(chatConfig?.systemInstruction).toContain('# Environment Context\nMocked Environment Context');
158
+ // Verify standard rules are appended
159
+ expect(chatConfig?.systemInstruction).toContain('You are running in a non-interactive mode.');
160
+ // Verify absolute path rule is appended
161
+ expect(chatConfig?.systemInstruction).toContain('Always use absolute paths for file operations.');
162
+ // Verify Extraction Phase Call (Specific arguments)
163
+ expect(mockSendMessageStream).toHaveBeenCalledWith('gemini-test-model', expect.objectContaining({
164
+ // Extraction message should be based on outputConfig.description
165
+ message: expect.arrayContaining([
166
+ {
167
+ text: expect.stringContaining('Based on your work so far, provide: The final result.'),
168
+ },
169
+ ]),
170
+ config: expect.objectContaining({ tools: undefined }), // No tools in extraction
171
+ }), expect.stringContaining('#extraction'));
172
+ expect(output.result).toBe('Result: file1.txt.');
173
+ expect(output.terminate_reason).toBe(AgentTerminateMode.GOAL);
174
+ // Verify Activity Stream (Observability)
175
+ expect(activities).toEqual(expect.arrayContaining([
176
+ // Thought subjects are extracted by the executor (parseThought)
177
+ expect.objectContaining({
178
+ type: 'THOUGHT_CHUNK',
179
+ data: { text: 'T1: Listing' },
180
+ }),
181
+ expect.objectContaining({
182
+ type: 'TOOL_CALL_START',
183
+ data: { name: LSTool.Name, args: { path: '.' } },
184
+ }),
185
+ expect.objectContaining({
186
+ type: 'TOOL_CALL_END',
187
+ data: { name: LSTool.Name, output: 'file1.txt' },
188
+ }),
189
+ expect.objectContaining({
190
+ type: 'THOUGHT_CHUNK',
191
+ data: { text: 'T2: Done' },
192
+ }),
193
+ ]));
194
+ });
195
+ it('should execute parallel tool calls concurrently', async () => {
196
+ const definition = createTestDefinition([LSTool.Name, ReadFileTool.Name]);
197
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
198
+ const call1 = {
199
+ name: LSTool.Name,
200
+ args: { path: '/dir1' },
201
+ id: 'call1',
202
+ };
203
+ // Using LSTool twice for simplicity in mocking standardized responses.
204
+ const call2 = {
205
+ name: LSTool.Name,
206
+ args: { path: '/dir2' },
207
+ id: 'call2',
208
+ };
209
+ // Turn 1: Model calls two tools simultaneously
210
+ mockModelResponse([call1, call2], 'T1: Listing both');
211
+ // Use concurrency tracking to ensure parallelism
212
+ let activeCalls = 0;
213
+ let maxActiveCalls = 0;
214
+ mockExecuteToolCall.mockImplementation(async (_ctx, reqInfo) => {
215
+ activeCalls++;
216
+ maxActiveCalls = Math.max(maxActiveCalls, activeCalls);
217
+ // Simulate latency. We must advance the fake timers for this to resolve.
218
+ await new Promise((resolve) => setTimeout(resolve, 100));
219
+ activeCalls--;
220
+ return {
221
+ callId: reqInfo.callId,
222
+ resultDisplay: `Result for ${reqInfo.name}`,
223
+ responseParts: [
224
+ {
225
+ functionResponse: {
226
+ name: reqInfo.name,
227
+ response: {},
228
+ id: reqInfo.callId,
229
+ },
230
+ },
231
+ ],
232
+ error: undefined,
233
+ };
234
+ });
235
+ // Turn 2: Model stops
236
+ mockModelResponse([]);
237
+ // Extraction
238
+ mockModelResponse([], undefined, 'Done.');
239
+ const runPromise = executor.run({ goal: 'Parallel test' }, signal);
240
+ // Advance timers while the parallel calls (Promise.all + setTimeout) are running
241
+ await vi.advanceTimersByTimeAsync(150);
242
+ await runPromise;
243
+ expect(mockExecuteToolCall).toHaveBeenCalledTimes(2);
244
+ expect(maxActiveCalls).toBe(2);
245
+ // Verify the input to the next model call (Turn 2) contains both responses
246
+ // sendMessageStream calls: [0] Turn 1, [1] Turn 2, [2] Extraction
247
+ const turn2Input = mockSendMessageStream.mock.calls[1][1];
248
+ const turn2Parts = turn2Input.message;
249
+ // Promise.all preserves the order of the input array.
250
+ expect(turn2Parts.length).toBe(2);
251
+ expect(turn2Parts[0]).toEqual(expect.objectContaining({
252
+ functionResponse: expect.objectContaining({ id: 'call1' }),
253
+ }));
254
+ expect(turn2Parts[1]).toEqual(expect.objectContaining({
255
+ functionResponse: expect.objectContaining({ id: 'call2' }),
256
+ }));
257
+ });
258
+ it('should use the templated query from promptConfig.query when provided', async () => {
259
+ const customQuery = 'Please achieve the goal: ${goal}';
260
+ const definition = createTestDefinition([], // No tools needed for this test
261
+ {}, {}, { query: customQuery, systemPrompt: 'You are a helpful agent.' });
262
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
263
+ const inputs = { goal: 'test custom query' };
264
+ // Model stops immediately
265
+ mockModelResponse([]);
266
+ // Extraction
267
+ mockModelResponse([], undefined, 'Done.');
268
+ await executor.run(inputs, signal);
269
+ // Verify the first call to sendMessageStream (the work phase)
270
+ const workPhaseCallArgs = mockSendMessageStream.mock.calls[0][1];
271
+ const workPhaseMessageParts = workPhaseCallArgs.message;
272
+ expect(workPhaseMessageParts).toEqual([
273
+ { text: 'Please achieve the goal: test custom query' },
274
+ ]);
275
+ });
276
+ it('should default to "Get Started!" when promptConfig.query is not provided', async () => {
277
+ const definition = createTestDefinition([], // No tools needed for this test
278
+ {}, {}, { query: undefined, systemPrompt: 'You are a helpful agent.' });
279
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
280
+ const inputs = { goal: 'test default query' };
281
+ // Model stops immediately
282
+ mockModelResponse([]);
283
+ // Extraction
284
+ mockModelResponse([], undefined, 'Done.');
285
+ await executor.run(inputs, signal);
286
+ // Verify the first call to sendMessageStream (the work phase)
287
+ const workPhaseCallArgs = mockSendMessageStream.mock.calls[0][1];
288
+ const workPhaseMessageParts = workPhaseCallArgs.message;
289
+ expect(workPhaseMessageParts).toEqual([{ text: 'Get Started!' }]);
290
+ });
291
+ it('should handle tool execution failure gracefully and report error', async () => {
292
+ const definition = createTestDefinition([LSTool.Name]);
293
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
294
+ // Turn 1: Model calls ls, but it fails
295
+ mockModelResponse([
296
+ { name: LSTool.Name, args: { path: '/invalid' }, id: 'call1' },
297
+ ]);
298
+ const errorMessage = 'Internal failure.';
299
+ mockExecuteToolCall.mockResolvedValueOnce({
300
+ callId: 'call1',
301
+ resultDisplay: `Error: ${errorMessage}`,
302
+ responseParts: undefined, // Failed tools might return undefined parts
303
+ error: { message: errorMessage },
304
+ });
305
+ // Turn 2: Model stops
306
+ mockModelResponse([]);
307
+ mockModelResponse([], undefined, 'Failed.');
308
+ await executor.run({ goal: 'Failure test' }, signal);
309
+ // Verify that the error was reported in the activity stream
310
+ expect(activities).toContainEqual(expect.objectContaining({
311
+ type: 'ERROR',
312
+ data: {
313
+ error: errorMessage,
314
+ context: 'tool_call',
315
+ name: LSTool.Name,
316
+ },
317
+ }));
318
+ // Verify the input to the next model call (Turn 2) contains the fallback error message
319
+ const turn2Input = mockSendMessageStream.mock.calls[1][1];
320
+ const turn2Parts = turn2Input.message;
321
+ expect(turn2Parts).toEqual([
322
+ {
323
+ text: 'All tool calls failed. Please analyze the errors and try an alternative approach.',
324
+ },
325
+ ]);
326
+ });
327
+ it('SECURITY: should block calls to tools not registered for the agent at runtime', async () => {
328
+ // Agent definition only includes LSTool
329
+ const definition = createTestDefinition([LSTool.Name]);
330
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
331
+ // Turn 1: Model hallucinates a call to ReadFileTool
332
+ // (ReadFileTool exists in the parent registry but not the agent's isolated registry)
333
+ mockModelResponse([
334
+ {
335
+ name: ReadFileTool.Name,
336
+ args: { path: 'config.txt' },
337
+ id: 'call_blocked',
338
+ },
339
+ ]);
340
+ // Turn 2: Model stops
341
+ mockModelResponse([]);
342
+ // Extraction
343
+ mockModelResponse([], undefined, 'Done.');
344
+ const consoleWarnSpy = vi
345
+ .spyOn(console, 'warn')
346
+ .mockImplementation(() => { });
347
+ await executor.run({ goal: 'Security test' }, signal);
348
+ // Verify executeToolCall was NEVER called because the tool was unauthorized
349
+ expect(mockExecuteToolCall).not.toHaveBeenCalled();
350
+ expect(consoleWarnSpy).toHaveBeenCalledWith(expect.stringContaining(`attempted to call unauthorized tool '${ReadFileTool.Name}'`));
351
+ consoleWarnSpy.mockRestore();
352
+ // Verify the input to the next model call (Turn 2) indicates failure (as the only call was blocked)
353
+ const turn2Input = mockSendMessageStream.mock.calls[1][1];
354
+ const turn2Parts = turn2Input.message;
355
+ expect(turn2Parts[0].text).toContain('All tool calls failed');
356
+ });
357
+ it('should use OutputConfig completion_criteria in the extraction message', async () => {
358
+ const definition = createTestDefinition([LSTool.Name], {}, {
359
+ description: 'A summary.',
360
+ completion_criteria: ['Must include file names', 'Must be concise'],
361
+ });
362
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
363
+ // Turn 1: Model stops immediately
364
+ mockModelResponse([]);
365
+ // Extraction Phase
366
+ mockModelResponse([], undefined, 'Result: Done.');
367
+ await executor.run({ goal: 'Extraction test' }, signal);
368
+ // Verify the extraction call (the second call)
369
+ const extractionCallArgs = mockSendMessageStream.mock.calls[1][1];
370
+ const extractionMessageParts = extractionCallArgs.message;
371
+ const extractionText = extractionMessageParts[0].text;
372
+ expect(extractionText).toContain('Based on your work so far, provide: A summary.');
373
+ expect(extractionText).toContain('Be sure you have addressed:');
374
+ expect(extractionText).toContain('- Must include file names');
375
+ expect(extractionText).toContain('- Must be concise');
376
+ });
377
+ it('should apply templating to initialMessages', async () => {
378
+ const definition = createTestDefinition([], // No tools needed
379
+ {}, {}, {
380
+ // Override systemPrompt to be undefined and provide initialMessages
381
+ systemPrompt: undefined,
382
+ initialMessages: [
383
+ {
384
+ role: 'user',
385
+ parts: [{ text: 'The user wants to ${goal}.' }],
386
+ },
387
+ {
388
+ role: 'model',
389
+ parts: [{ text: 'Okay, I will start working on ${goal}.' }],
390
+ },
391
+ ],
392
+ });
393
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
394
+ const inputs = { goal: 'find the file' };
395
+ // Model stops immediately
396
+ mockModelResponse([]);
397
+ // Extraction
398
+ mockModelResponse([], undefined, 'Done.');
399
+ await executor.run(inputs, signal);
400
+ // Verify that the initialMessages were templated correctly
401
+ const chatConstructorArgs = MockedGeminiChat.mock.calls[0];
402
+ const startHistory = chatConstructorArgs[2]; // 3rd argument is startHistory
403
+ expect(startHistory).toEqual([
404
+ {
405
+ role: 'user',
406
+ parts: [{ text: 'The user wants to find the file.' }],
407
+ },
408
+ {
409
+ role: 'model',
410
+ parts: [{ text: 'Okay, I will start working on find the file.' }],
411
+ },
412
+ ]);
413
+ });
414
+ });
415
+ describe('run (Termination Conditions)', () => {
416
+ const mockKeepAliveResponse = () => {
417
+ mockModelResponse([{ name: LSTool.Name, args: { path: '.' }, id: 'loop' }], 'Looping');
418
+ mockExecuteToolCall.mockResolvedValue({
419
+ callId: 'loop',
420
+ resultDisplay: 'ok',
421
+ responseParts: [
422
+ { functionResponse: { name: LSTool.Name, response: {}, id: 'loop' } },
423
+ ],
424
+ error: undefined,
425
+ });
426
+ };
427
+ it('should terminate when max_turns is reached', async () => {
428
+ const MAX_TURNS = 2;
429
+ const definition = createTestDefinition([LSTool.Name], {
430
+ max_turns: MAX_TURNS,
431
+ });
432
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
433
+ // Turn 1
434
+ mockKeepAliveResponse();
435
+ // Turn 2
436
+ mockKeepAliveResponse();
437
+ const output = await executor.run({ goal: 'Termination test' }, signal);
438
+ expect(output.terminate_reason).toBe(AgentTerminateMode.MAX_TURNS);
439
+ expect(mockSendMessageStream).toHaveBeenCalledTimes(MAX_TURNS);
440
+ // Extraction phase should be skipped when termination is forced
441
+ expect(mockSendMessageStream).not.toHaveBeenCalledWith(expect.any(String), expect.any(Object), expect.stringContaining('#extraction'));
442
+ });
443
+ it('should terminate if timeout is reached', async () => {
444
+ const definition = createTestDefinition([LSTool.Name], {
445
+ max_time_minutes: 5,
446
+ max_turns: 100,
447
+ });
448
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
449
+ // Turn 1 setup
450
+ mockModelResponse([{ name: LSTool.Name, args: { path: '.' }, id: 'loop' }], 'Looping');
451
+ // Mock a tool call that takes a long time, causing the overall timeout
452
+ mockExecuteToolCall.mockImplementation(async () => {
453
+ // Advance time past the 5-minute limit during the tool call execution
454
+ await vi.advanceTimersByTimeAsync(5 * 60 * 1000 + 1);
455
+ return {
456
+ callId: 'loop',
457
+ resultDisplay: 'ok',
458
+ responseParts: [
459
+ {
460
+ functionResponse: { name: LSTool.Name, response: {}, id: 'loop' },
461
+ },
462
+ ],
463
+ error: undefined,
464
+ };
465
+ });
466
+ const output = await executor.run({ goal: 'Termination test' }, signal);
467
+ expect(output.terminate_reason).toBe(AgentTerminateMode.TIMEOUT);
468
+ // Should only have called the model once before the timeout check stopped it
469
+ expect(mockSendMessageStream).toHaveBeenCalledTimes(1);
470
+ });
471
+ it('should terminate when AbortSignal is triggered mid-stream', async () => {
472
+ const definition = createTestDefinition();
473
+ const executor = await AgentExecutor.create(definition, mockConfig, onActivity);
474
+ // Mock the model response stream
475
+ mockSendMessageStream.mockImplementation(async () => (async function* () {
476
+ // Yield the first chunk
477
+ yield {
478
+ type: StreamEventType.CHUNK,
479
+ value: createMockResponseChunk([
480
+ { text: '**Thinking** Step 1', thought: true },
481
+ ]),
482
+ };
483
+ // Simulate abort happening mid-stream
484
+ abortController.abort();
485
+ // The loop in callModel should break immediately due to signal check.
486
+ })());
487
+ const output = await executor.run({ goal: 'Termination test' }, signal);
488
+ expect(output.terminate_reason).toBe(AgentTerminateMode.ABORTED);
489
+ });
490
+ });
491
+ });
492
+ //# sourceMappingURL=executor.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.test.js","sourceRoot":"","sources":["../../../src/agents/executor.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,EAAE,EACF,UAAU,EACV,SAAS,GAEV,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,aAAa,EAAyB,MAAM,eAAe,CAAC;AAMrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,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IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,IAAI,EAAE;qBAC/C,CAAC;iBACY,CAAC;gBAEjB,sCAAsC;gBACtC,eAAe,CAAC,KAAK,EAAE,CAAC;gBACxB,sEAAsE;YACxE,CAAC,CAAC,EAAE,CACL,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,MAAM,CAAC,CAAC;YACxE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,45 @@
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 { AnsiOutput } from '../utils/terminalSerializer.js';
8
+ import { BaseToolInvocation, type ToolResult } from '../tools/tools.js';
9
+ import type { AgentDefinition, AgentInputs } from './types.js';
10
+ import type { MessageBus } from '../confirmation-bus/message-bus.js';
11
+ /**
12
+ * Represents a validated, executable instance of a subagent tool.
13
+ *
14
+ * This class orchestrates the execution of a defined agent by:
15
+ * 1. Initializing the {@link AgentExecutor}.
16
+ * 2. Running the agent's execution loop.
17
+ * 3. Bridging the agent's streaming activity (e.g., thoughts) to the tool's
18
+ * live output stream.
19
+ * 4. Formatting the final result into a {@link ToolResult}.
20
+ */
21
+ export declare class SubagentInvocation extends BaseToolInvocation<AgentInputs, ToolResult> {
22
+ private readonly definition;
23
+ private readonly config;
24
+ /**
25
+ * @param params The validated input parameters for the agent.
26
+ * @param definition The definition object that configures the agent.
27
+ * @param config The global runtime configuration.
28
+ * @param messageBus Optional message bus for policy enforcement.
29
+ */
30
+ constructor(params: AgentInputs, definition: AgentDefinition, config: Config, messageBus?: MessageBus);
31
+ /**
32
+ * Returns a concise, human-readable description of the invocation.
33
+ * Used for logging and display purposes.
34
+ */
35
+ getDescription(): string;
36
+ /**
37
+ * Executes the subagent.
38
+ *
39
+ * @param signal An `AbortSignal` to cancel the agent's execution.
40
+ * @param updateOutput A callback to stream intermediate output, such as the
41
+ * agent's thoughts, to the user interface.
42
+ * @returns A `Promise` that resolves with the final `ToolResult`.
43
+ */
44
+ execute(signal: AbortSignal, updateOutput?: (output: string | AnsiOutput) => void): Promise<ToolResult>;
45
+ }