@google/gemini-cli-core 0.10.0-preview.3 → 0.11.0-nightly.20251020.a96f0659
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/README.md +9 -0
- package/dist/google-gemini-cli-core-0.11.0-nightly.20251015.203bad7c.tgz +0 -0
- package/dist/src/agents/codebase-investigator.js +2 -5
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/executor.js +6 -13
- package/dist/src/agents/executor.js.map +1 -1
- package/dist/src/agents/executor.test.js +36 -31
- package/dist/src/agents/executor.test.js.map +1 -1
- package/dist/src/config/config.d.ts +1 -3
- package/dist/src/config/config.js +0 -5
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +0 -4
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +5 -0
- package/dist/src/core/client.test.js +0 -1
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +6 -0
- package/dist/src/core/coreToolScheduler.js +30 -6
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +37 -3
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +1 -0
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +3 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +13 -20
- package/dist/src/core/prompts.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/generated/git-commit.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +52 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.js +479 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +63 -1
- package/dist/src/output/types.js +11 -0
- package/dist/src/output/types.js.map +1 -1
- package/dist/src/services/shellExecutionService.js +9 -9
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +16 -11
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +208 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/activity-monitor.test.js +248 -0
- package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +7 -7
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +3 -10
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -1
- package/dist/src/telemetry/index.js +2 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +0 -1
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +0 -1
- package/dist/src/tools/edit.js +4 -5
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +0 -1
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +0 -1
- package/dist/src/tools/glob.js +1 -2
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/grep.d.ts +0 -1
- package/dist/src/tools/grep.js +10 -5
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/ls.d.ts +0 -1
- package/dist/src/tools/ls.js +2 -2
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +0 -1
- package/dist/src/tools/memoryTool.js +3 -3
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +14 -1
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +0 -1
- package/dist/src/tools/read-file.js +3 -3
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +0 -1
- package/dist/src/tools/read-many-files.js +3 -3
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +0 -1
- package/dist/src/tools/ripGrep.js +2 -2
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/shell.d.ts +0 -1
- package/dist/src/tools/shell.js +21 -58
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +61 -8
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +0 -1
- package/dist/src/tools/smart-edit.js +3 -4
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +0 -1
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +8 -0
- package/dist/src/tools/tool-names.js +8 -5
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tools.d.ts +10 -6
- package/dist/src/tools/tools.js +19 -33
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +3 -3
- package/dist/src/tools/web-fetch.js +43 -18
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +261 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +0 -1
- package/dist/src/tools/web-search.js +1 -2
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +0 -1
- package/dist/src/tools/write-file.js +2 -3
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +0 -1
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +1 -7
- package/dist/src/tools/write-todos.js +2 -3
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -2
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/debugLogger.d.ts +25 -0
- package/dist/src/utils/debugLogger.js +33 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +6 -0
- package/dist/src/utils/debugLogger.test.js +67 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +6 -0
- package/dist/src/utils/delay.test.js +88 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.js +5 -9
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +3 -5
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/environmentContext.js +0 -33
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +0 -34
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +31 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.js +6 -5
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +14 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/retry.d.ts +1 -0
- package/dist/src/utils/retry.js +14 -12
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +17 -0
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.d.ts +4 -4
- package/dist/src/utils/safeJsonStringify.js +31 -7
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +2 -2
- package/dist/src/utils/shell-utils.js +307 -136
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +126 -60
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +2 -2
- package/dist/src/utils/tool-utils.js +14 -5
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/dist/google-gemini-cli-core-0.10.0-preview.2.tgz +0 -0
- package/dist/src/core/subagent.d.ts +0 -236
- package/dist/src/core/subagent.js +0 -482
- package/dist/src/core/subagent.js.map +0 -1
- package/dist/src/core/subagent.test.js +0 -556
- package/dist/src/core/subagent.test.js.map +0 -1
- /package/dist/src/{core/subagent.test.d.ts → output/stream-json-formatter.test.d.ts} +0 -0
|
@@ -1,482 +0,0 @@
|
|
|
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 { ToolRegistry } from '../tools/tool-registry.js';
|
|
8
|
-
import { executeToolCall } from './nonInteractiveToolExecutor.js';
|
|
9
|
-
import { getEnvironmentContext } from '../utils/environmentContext.js';
|
|
10
|
-
import { Type } from '@google/genai';
|
|
11
|
-
import { GeminiChat, StreamEventType } from './geminiChat.js';
|
|
12
|
-
/**
|
|
13
|
-
* @fileoverview Defines the configuration interfaces for a subagent.
|
|
14
|
-
*
|
|
15
|
-
* These interfaces specify the structure for defining the subagent's prompt,
|
|
16
|
-
* the model parameters, and the execution settings.
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Describes the possible termination modes for a subagent.
|
|
20
|
-
* This enum provides a clear indication of why a subagent's execution might have ended.
|
|
21
|
-
*/
|
|
22
|
-
export var SubagentTerminateMode;
|
|
23
|
-
(function (SubagentTerminateMode) {
|
|
24
|
-
/**
|
|
25
|
-
* Indicates that the subagent's execution terminated due to an unrecoverable error.
|
|
26
|
-
*/
|
|
27
|
-
SubagentTerminateMode["ERROR"] = "ERROR";
|
|
28
|
-
/**
|
|
29
|
-
* Indicates that the subagent's execution terminated because it exceeded the maximum allowed working time.
|
|
30
|
-
*/
|
|
31
|
-
SubagentTerminateMode["TIMEOUT"] = "TIMEOUT";
|
|
32
|
-
/**
|
|
33
|
-
* Indicates that the subagent's execution successfully completed all its defined goals.
|
|
34
|
-
*/
|
|
35
|
-
SubagentTerminateMode["GOAL"] = "GOAL";
|
|
36
|
-
/**
|
|
37
|
-
* Indicates that the subagent's execution terminated because it exceeded the maximum number of turns.
|
|
38
|
-
*/
|
|
39
|
-
SubagentTerminateMode["MAX_TURNS"] = "MAX_TURNS";
|
|
40
|
-
})(SubagentTerminateMode || (SubagentTerminateMode = {}));
|
|
41
|
-
/**
|
|
42
|
-
* Manages the runtime context state for the subagent.
|
|
43
|
-
* This class provides a mechanism to store and retrieve key-value pairs
|
|
44
|
-
* that represent the dynamic state and variables accessible to the subagent
|
|
45
|
-
* during its execution.
|
|
46
|
-
*/
|
|
47
|
-
export class ContextState {
|
|
48
|
-
state = {};
|
|
49
|
-
/**
|
|
50
|
-
* Retrieves a value from the context state.
|
|
51
|
-
*
|
|
52
|
-
* @param key - The key of the value to retrieve.
|
|
53
|
-
* @returns The value associated with the key, or undefined if the key is not found.
|
|
54
|
-
*/
|
|
55
|
-
get(key) {
|
|
56
|
-
return this.state[key];
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets a value in the context state.
|
|
60
|
-
*
|
|
61
|
-
* @param key - The key to set the value under.
|
|
62
|
-
* @param value - The value to set.
|
|
63
|
-
*/
|
|
64
|
-
set(key, value) {
|
|
65
|
-
this.state[key] = value;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Retrieves all keys in the context state.
|
|
69
|
-
*
|
|
70
|
-
* @returns An array of all keys in the context state.
|
|
71
|
-
*/
|
|
72
|
-
get_keys() {
|
|
73
|
-
return Object.keys(this.state);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Replaces `${...}` placeholders in a template string with values from a context.
|
|
78
|
-
*
|
|
79
|
-
* This function identifies all placeholders in the format `${key}`, validates that
|
|
80
|
-
* each key exists in the provided `ContextState`, and then performs the substitution.
|
|
81
|
-
*
|
|
82
|
-
* @param template The template string containing placeholders.
|
|
83
|
-
* @param context The `ContextState` object providing placeholder values.
|
|
84
|
-
* @returns The populated string with all placeholders replaced.
|
|
85
|
-
* @throws {Error} if any placeholder key is not found in the context.
|
|
86
|
-
*/
|
|
87
|
-
function templateString(template, context) {
|
|
88
|
-
const placeholderRegex = /\$\{(\w+)\}/g;
|
|
89
|
-
// First, find all unique keys required by the template.
|
|
90
|
-
const requiredKeys = new Set(Array.from(template.matchAll(placeholderRegex), (match) => match[1]));
|
|
91
|
-
// Check if all required keys exist in the context.
|
|
92
|
-
const contextKeys = new Set(context.get_keys());
|
|
93
|
-
const missingKeys = Array.from(requiredKeys).filter((key) => !contextKeys.has(key));
|
|
94
|
-
if (missingKeys.length > 0) {
|
|
95
|
-
throw new Error(`Missing context values for the following keys: ${missingKeys.join(', ')}`);
|
|
96
|
-
}
|
|
97
|
-
// Perform the replacement using a replacer function.
|
|
98
|
-
return template.replace(placeholderRegex, (_match, key) => String(context.get(key)));
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Represents the scope and execution environment for a subagent.
|
|
102
|
-
* This class orchestrates the subagent's lifecycle, managing its chat interactions,
|
|
103
|
-
* runtime context, and the collection of its outputs.
|
|
104
|
-
*/
|
|
105
|
-
export class SubAgentScope {
|
|
106
|
-
name;
|
|
107
|
-
runtimeContext;
|
|
108
|
-
promptConfig;
|
|
109
|
-
modelConfig;
|
|
110
|
-
runConfig;
|
|
111
|
-
output = {
|
|
112
|
-
terminate_reason: SubagentTerminateMode.ERROR,
|
|
113
|
-
emitted_vars: {},
|
|
114
|
-
};
|
|
115
|
-
subagentId;
|
|
116
|
-
toolConfig;
|
|
117
|
-
outputConfig;
|
|
118
|
-
onMessage;
|
|
119
|
-
toolRegistry;
|
|
120
|
-
/**
|
|
121
|
-
* Constructs a new SubAgentScope instance.
|
|
122
|
-
* @param name - The name for the subagent, used for logging and identification.
|
|
123
|
-
* @param runtimeContext - The shared runtime configuration and services.
|
|
124
|
-
* @param promptConfig - Configuration for the subagent's prompt and behavior.
|
|
125
|
-
* @param modelConfig - Configuration for the generative model parameters.
|
|
126
|
-
* @param runConfig - Configuration for the subagent's execution environment.
|
|
127
|
-
* @param options - Optional configurations for the subagent.
|
|
128
|
-
*/
|
|
129
|
-
constructor(name, runtimeContext, promptConfig, modelConfig, runConfig, toolRegistry, options = {}) {
|
|
130
|
-
this.name = name;
|
|
131
|
-
this.runtimeContext = runtimeContext;
|
|
132
|
-
this.promptConfig = promptConfig;
|
|
133
|
-
this.modelConfig = modelConfig;
|
|
134
|
-
this.runConfig = runConfig;
|
|
135
|
-
const randomPart = Math.random().toString(36).slice(2, 8);
|
|
136
|
-
this.subagentId = `${this.name}-${randomPart}`;
|
|
137
|
-
this.toolConfig = options.toolConfig;
|
|
138
|
-
this.outputConfig = options.outputConfig;
|
|
139
|
-
this.onMessage = options.onMessage;
|
|
140
|
-
this.toolRegistry = toolRegistry;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Creates and validates a new SubAgentScope instance.
|
|
144
|
-
* This factory method ensures that all tools provided in the prompt configuration
|
|
145
|
-
* are valid for non-interactive use before creating the subagent instance.
|
|
146
|
-
* @param name - The name of the subagent.
|
|
147
|
-
* @param runtimeContext - The shared runtime configuration and services.
|
|
148
|
-
* @param promptConfig - Configuration for the subagent's prompt and behavior.
|
|
149
|
-
* @param modelConfig - Configuration for the generative model parameters.
|
|
150
|
-
* @param runConfig - Configuration for the subagent's execution environment.
|
|
151
|
-
* @param options - Optional configurations for the subagent.
|
|
152
|
-
* @returns A promise that resolves to a valid SubAgentScope instance.
|
|
153
|
-
* @throws {Error} If any tool requires user confirmation.
|
|
154
|
-
*/
|
|
155
|
-
static async create(name, runtimeContext, promptConfig, modelConfig, runConfig, options = {}) {
|
|
156
|
-
const subagentToolRegistry = new ToolRegistry(runtimeContext);
|
|
157
|
-
if (options.toolConfig) {
|
|
158
|
-
for (const tool of options.toolConfig.tools) {
|
|
159
|
-
if (typeof tool === 'string') {
|
|
160
|
-
const toolFromRegistry = (await runtimeContext.getToolRegistry()).getTool(tool);
|
|
161
|
-
if (toolFromRegistry) {
|
|
162
|
-
subagentToolRegistry.registerTool(toolFromRegistry);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else if (typeof tool === 'object' &&
|
|
166
|
-
'name' in tool &&
|
|
167
|
-
'build' in tool) {
|
|
168
|
-
subagentToolRegistry.registerTool(tool);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
// This is a FunctionDeclaration, which we can't add to the registry.
|
|
172
|
-
// We'll rely on the validation below to catch any issues.
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
for (const tool of subagentToolRegistry.getAllTools()) {
|
|
176
|
-
const schema = tool.schema.parametersJsonSchema;
|
|
177
|
-
const requiredParams = schema?.required ?? [];
|
|
178
|
-
if (requiredParams.length > 0) {
|
|
179
|
-
// This check is imperfect. A tool might require parameters but still
|
|
180
|
-
// be interactive (e.g., `delete_file(path)`). However, we cannot
|
|
181
|
-
// build a generic invocation without knowing what dummy parameters
|
|
182
|
-
// to provide. Crashing here because `build({})` fails is worse
|
|
183
|
-
// than allowing a potential hang later if an interactive tool is
|
|
184
|
-
// used. This is a best-effort check.
|
|
185
|
-
console.warn(`Cannot check tool "${tool.name}" for interactivity because it requires parameters. Assuming it is safe for non-interactive use.`);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const invocation = tool.build({});
|
|
189
|
-
const confirmationDetails = await invocation.shouldConfirmExecute(new AbortController().signal);
|
|
190
|
-
if (confirmationDetails) {
|
|
191
|
-
throw new Error(`Tool "${tool.name}" requires user confirmation and cannot be used in a non-interactive subagent.`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return new SubAgentScope(name, runtimeContext, promptConfig, modelConfig, runConfig, subagentToolRegistry, options);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Runs the subagent in a non-interactive mode.
|
|
199
|
-
* This method orchestrates the subagent's execution loop, including prompt templating,
|
|
200
|
-
* tool execution, and termination conditions.
|
|
201
|
-
* @param {ContextState} context - The current context state containing variables for prompt templating.
|
|
202
|
-
* @returns {Promise<void>} A promise that resolves when the subagent has completed its execution.
|
|
203
|
-
*/
|
|
204
|
-
async runNonInteractive(context) {
|
|
205
|
-
const startTime = Date.now();
|
|
206
|
-
let turnCounter = 0;
|
|
207
|
-
try {
|
|
208
|
-
const chat = await this.createChatObject(context);
|
|
209
|
-
if (!chat) {
|
|
210
|
-
this.output.terminate_reason = SubagentTerminateMode.ERROR;
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const abortController = new AbortController();
|
|
214
|
-
// Prepare the list of tools available to the subagent.
|
|
215
|
-
const toolsList = [];
|
|
216
|
-
if (this.toolConfig) {
|
|
217
|
-
const toolsToLoad = [];
|
|
218
|
-
for (const tool of this.toolConfig.tools) {
|
|
219
|
-
if (typeof tool === 'string') {
|
|
220
|
-
toolsToLoad.push(tool);
|
|
221
|
-
}
|
|
222
|
-
else if (typeof tool === 'object' && 'schema' in tool) {
|
|
223
|
-
// This is a tool instance with a schema property
|
|
224
|
-
toolsList.push(tool.schema);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
// This is a raw FunctionDeclaration
|
|
228
|
-
toolsList.push(tool);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
toolsList.push(...this.toolRegistry.getFunctionDeclarationsFiltered(toolsToLoad));
|
|
232
|
-
}
|
|
233
|
-
// Add local scope functions if outputs are expected.
|
|
234
|
-
if (this.outputConfig && this.outputConfig.outputs) {
|
|
235
|
-
toolsList.push(...this.getScopeLocalFuncDefs());
|
|
236
|
-
}
|
|
237
|
-
let currentMessages = [
|
|
238
|
-
{ role: 'user', parts: [{ text: 'Get Started!' }] },
|
|
239
|
-
];
|
|
240
|
-
while (true) {
|
|
241
|
-
// Check termination conditions.
|
|
242
|
-
if (this.runConfig.max_turns &&
|
|
243
|
-
turnCounter >= this.runConfig.max_turns) {
|
|
244
|
-
this.output.terminate_reason = SubagentTerminateMode.MAX_TURNS;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
let durationMin = (Date.now() - startTime) / (1000 * 60);
|
|
248
|
-
if (durationMin >= this.runConfig.max_time_minutes) {
|
|
249
|
-
this.output.terminate_reason = SubagentTerminateMode.TIMEOUT;
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
const promptId = `${this.runtimeContext.getSessionId()}#${this.subagentId}#${turnCounter++}`;
|
|
253
|
-
const messageParams = {
|
|
254
|
-
message: currentMessages[0]?.parts || [],
|
|
255
|
-
config: {
|
|
256
|
-
abortSignal: abortController.signal,
|
|
257
|
-
tools: [{ functionDeclarations: toolsList }],
|
|
258
|
-
},
|
|
259
|
-
};
|
|
260
|
-
const responseStream = await chat.sendMessageStream(this.modelConfig.model, messageParams, promptId);
|
|
261
|
-
const functionCalls = [];
|
|
262
|
-
let textResponse = '';
|
|
263
|
-
for await (const resp of responseStream) {
|
|
264
|
-
if (abortController.signal.aborted)
|
|
265
|
-
return;
|
|
266
|
-
if (resp.type === StreamEventType.CHUNK && resp.value.functionCalls) {
|
|
267
|
-
functionCalls.push(...resp.value.functionCalls);
|
|
268
|
-
}
|
|
269
|
-
if (resp.type === StreamEventType.CHUNK && resp.value.text) {
|
|
270
|
-
textResponse += resp.value.text;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (this.onMessage && textResponse) {
|
|
274
|
-
this.onMessage(textResponse);
|
|
275
|
-
}
|
|
276
|
-
durationMin = (Date.now() - startTime) / (1000 * 60);
|
|
277
|
-
if (durationMin >= this.runConfig.max_time_minutes) {
|
|
278
|
-
this.output.terminate_reason = SubagentTerminateMode.TIMEOUT;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
if (functionCalls.length > 0) {
|
|
282
|
-
currentMessages = await this.processFunctionCalls(functionCalls, abortController, promptId);
|
|
283
|
-
}
|
|
284
|
-
// Check for goal completion after processing function calls,
|
|
285
|
-
// as `self.emitvalue` might have completed the requirements.
|
|
286
|
-
if (this.outputConfig &&
|
|
287
|
-
Object.keys(this.outputConfig.outputs).length > 0) {
|
|
288
|
-
const remainingVars = Object.keys(this.outputConfig.outputs).filter((key) => !(key in this.output.emitted_vars));
|
|
289
|
-
if (remainingVars.length === 0) {
|
|
290
|
-
this.output.terminate_reason = SubagentTerminateMode.GOAL;
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
if (functionCalls.length === 0) {
|
|
295
|
-
// Model stopped calling tools. Check if goal is met.
|
|
296
|
-
if (!this.outputConfig ||
|
|
297
|
-
Object.keys(this.outputConfig.outputs).length === 0) {
|
|
298
|
-
this.output.terminate_reason = SubagentTerminateMode.GOAL;
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
const remainingVars = Object.keys(this.outputConfig.outputs).filter((key) => !(key in this.output.emitted_vars));
|
|
302
|
-
if (remainingVars.length === 0) {
|
|
303
|
-
this.output.terminate_reason = SubagentTerminateMode.GOAL;
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
const nudgeMessage = `You have stopped calling tools but have not emitted the following required variables: ${remainingVars.join(', ')}. Please use the 'self.emitvalue' tool to emit them now, or continue working if necessary.`;
|
|
307
|
-
console.debug(nudgeMessage);
|
|
308
|
-
currentMessages = [
|
|
309
|
-
{
|
|
310
|
-
role: 'user',
|
|
311
|
-
parts: [{ text: nudgeMessage }],
|
|
312
|
-
},
|
|
313
|
-
];
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
catch (error) {
|
|
318
|
-
console.error('Error during subagent execution:', error);
|
|
319
|
-
this.output.terminate_reason = SubagentTerminateMode.ERROR;
|
|
320
|
-
throw error;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Processes a list of function calls, executing each one and collecting their responses.
|
|
325
|
-
* This method iterates through the provided function calls, executes them using the
|
|
326
|
-
* `executeToolCall` function (or handles `self.emitvalue` internally), and aggregates
|
|
327
|
-
* their results. It also manages error reporting for failed tool executions.
|
|
328
|
-
* @param {FunctionCall[]} functionCalls - An array of `FunctionCall` objects to process.
|
|
329
|
-
* @param {ToolRegistry} toolRegistry - The tool registry to look up and execute tools.
|
|
330
|
-
* @param {AbortController} abortController - An `AbortController` to signal cancellation of tool executions.
|
|
331
|
-
* @returns {Promise<Content[]>} A promise that resolves to an array of `Content` parts representing the tool responses,
|
|
332
|
-
* which are then used to update the chat history.
|
|
333
|
-
*/
|
|
334
|
-
async processFunctionCalls(functionCalls, abortController, promptId) {
|
|
335
|
-
const toolResponseParts = [];
|
|
336
|
-
for (const functionCall of functionCalls) {
|
|
337
|
-
if (this.onMessage) {
|
|
338
|
-
const args = JSON.stringify(functionCall.args ?? {});
|
|
339
|
-
// Truncate arguments
|
|
340
|
-
const MAX_ARGS_LENGTH = 250;
|
|
341
|
-
const truncatedArgs = args.length > MAX_ARGS_LENGTH
|
|
342
|
-
? `${args.substring(0, MAX_ARGS_LENGTH)}...`
|
|
343
|
-
: args;
|
|
344
|
-
this.onMessage(`
|
|
345
|
-
|
|
346
|
-
**Executing tool: ${functionCall.name} with args ${truncatedArgs}**
|
|
347
|
-
|
|
348
|
-
`);
|
|
349
|
-
}
|
|
350
|
-
const callId = functionCall.id ?? `${functionCall.name}-${Date.now()}`;
|
|
351
|
-
const requestInfo = {
|
|
352
|
-
callId,
|
|
353
|
-
name: functionCall.name,
|
|
354
|
-
args: (functionCall.args ?? {}),
|
|
355
|
-
isClientInitiated: true,
|
|
356
|
-
prompt_id: promptId,
|
|
357
|
-
};
|
|
358
|
-
let toolResponse;
|
|
359
|
-
// Handle scope-local tools first.
|
|
360
|
-
if (functionCall.name === 'self.emitvalue') {
|
|
361
|
-
const valName = String(requestInfo.args['emit_variable_name']);
|
|
362
|
-
const valVal = String(requestInfo.args['emit_variable_value']);
|
|
363
|
-
this.output.emitted_vars[valName] = valVal;
|
|
364
|
-
toolResponse = {
|
|
365
|
-
callId,
|
|
366
|
-
responseParts: [{ text: `Emitted variable ${valName} successfully` }],
|
|
367
|
-
resultDisplay: `Emitted variable ${valName} successfully`,
|
|
368
|
-
error: undefined,
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
toolResponse = (await executeToolCall(this.runtimeContext, requestInfo, abortController.signal)).response;
|
|
373
|
-
}
|
|
374
|
-
if (toolResponse.error) {
|
|
375
|
-
console.error(`Error executing tool ${functionCall.name}: ${toolResponse.resultDisplay || toolResponse.error.message}`);
|
|
376
|
-
}
|
|
377
|
-
if (toolResponse.responseParts) {
|
|
378
|
-
toolResponseParts.push(...toolResponse.responseParts);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
// If all tool calls failed, inform the model so it can re-evaluate.
|
|
382
|
-
if (functionCalls.length > 0 && toolResponseParts.length === 0) {
|
|
383
|
-
toolResponseParts.push({
|
|
384
|
-
text: 'All tool calls failed. Please analyze the errors and try an alternative approach.',
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
return [{ role: 'user', parts: toolResponseParts }];
|
|
388
|
-
}
|
|
389
|
-
async createChatObject(context) {
|
|
390
|
-
if (!this.promptConfig.systemPrompt && !this.promptConfig.initialMessages) {
|
|
391
|
-
throw new Error('PromptConfig must have either `systemPrompt` or `initialMessages` defined.');
|
|
392
|
-
}
|
|
393
|
-
if (this.promptConfig.systemPrompt && this.promptConfig.initialMessages) {
|
|
394
|
-
throw new Error('PromptConfig cannot have both `systemPrompt` and `initialMessages` defined.');
|
|
395
|
-
}
|
|
396
|
-
const envParts = await getEnvironmentContext(this.runtimeContext);
|
|
397
|
-
const envHistory = [
|
|
398
|
-
{ role: 'user', parts: envParts },
|
|
399
|
-
{ role: 'model', parts: [{ text: 'Got it. Thanks for the context!' }] },
|
|
400
|
-
];
|
|
401
|
-
const start_history = [
|
|
402
|
-
...envHistory,
|
|
403
|
-
...(this.promptConfig.initialMessages ?? []),
|
|
404
|
-
];
|
|
405
|
-
const systemInstruction = this.promptConfig.systemPrompt
|
|
406
|
-
? this.buildChatSystemPrompt(context)
|
|
407
|
-
: undefined;
|
|
408
|
-
try {
|
|
409
|
-
const generationConfig = {
|
|
410
|
-
temperature: this.modelConfig.temp,
|
|
411
|
-
topP: this.modelConfig.top_p,
|
|
412
|
-
};
|
|
413
|
-
if (systemInstruction) {
|
|
414
|
-
generationConfig.systemInstruction = systemInstruction;
|
|
415
|
-
}
|
|
416
|
-
this.runtimeContext.setModel(this.modelConfig.model);
|
|
417
|
-
return new GeminiChat(this.runtimeContext, generationConfig, start_history);
|
|
418
|
-
}
|
|
419
|
-
catch (error) {
|
|
420
|
-
await reportError(error, 'Error initializing Gemini chat session.', start_history, 'startChat');
|
|
421
|
-
// The calling function will handle the undefined return.
|
|
422
|
-
return undefined;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Returns an array of FunctionDeclaration objects for tools that are local to the subagent's scope.
|
|
427
|
-
* Currently, this includes the `self.emitvalue` tool for emitting variables.
|
|
428
|
-
* @returns An array of `FunctionDeclaration` objects.
|
|
429
|
-
*/
|
|
430
|
-
getScopeLocalFuncDefs() {
|
|
431
|
-
const emitValueTool = {
|
|
432
|
-
name: 'self.emitvalue',
|
|
433
|
-
description: `* This tool emits A SINGLE return value from this execution, such that it can be collected and presented to the calling function.
|
|
434
|
-
* You can only emit ONE VALUE each time you call this tool. You are expected to call this tool MULTIPLE TIMES if you have MULTIPLE OUTPUTS.`,
|
|
435
|
-
parameters: {
|
|
436
|
-
type: Type.OBJECT,
|
|
437
|
-
properties: {
|
|
438
|
-
emit_variable_name: {
|
|
439
|
-
description: 'This is the name of the variable to be returned.',
|
|
440
|
-
type: Type.STRING,
|
|
441
|
-
},
|
|
442
|
-
emit_variable_value: {
|
|
443
|
-
description: 'This is the _value_ to be returned for this variable.',
|
|
444
|
-
type: Type.STRING,
|
|
445
|
-
},
|
|
446
|
-
},
|
|
447
|
-
required: ['emit_variable_name', 'emit_variable_value'],
|
|
448
|
-
},
|
|
449
|
-
};
|
|
450
|
-
return [emitValueTool];
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Builds the system prompt for the chat based on the provided configurations.
|
|
454
|
-
* It templates the base system prompt and appends instructions for emitting
|
|
455
|
-
* variables if an `OutputConfig` is provided.
|
|
456
|
-
* @param {ContextState} context - The context for templating.
|
|
457
|
-
* @returns {string} The complete system prompt.
|
|
458
|
-
*/
|
|
459
|
-
buildChatSystemPrompt(context) {
|
|
460
|
-
if (!this.promptConfig.systemPrompt) {
|
|
461
|
-
// This should ideally be caught in createChatObject, but serves as a safeguard.
|
|
462
|
-
return '';
|
|
463
|
-
}
|
|
464
|
-
let finalPrompt = templateString(this.promptConfig.systemPrompt, context);
|
|
465
|
-
// Add instructions for emitting variables if needed.
|
|
466
|
-
if (this.outputConfig && this.outputConfig.outputs) {
|
|
467
|
-
let outputInstructions = '\n\nAfter you have achieved all other goals, you MUST emit the required output variables. For each expected output, make one final call to the `self.emitvalue` tool.';
|
|
468
|
-
for (const [key, value] of Object.entries(this.outputConfig.outputs)) {
|
|
469
|
-
outputInstructions += `\n* Use 'self.emitvalue' to emit the '${key}' key, with a value described as: '${value}'`;
|
|
470
|
-
}
|
|
471
|
-
finalPrompt += outputInstructions;
|
|
472
|
-
}
|
|
473
|
-
// Add general non-interactive instructions.
|
|
474
|
-
finalPrompt += `
|
|
475
|
-
|
|
476
|
-
Important Rules:
|
|
477
|
-
* You are running in a non-interactive mode. You CANNOT ask the user for input or clarification. You must proceed with the information you have.
|
|
478
|
-
* Once you believe all goals have been met and all required outputs have been emitted, stop calling tools.`;
|
|
479
|
-
return finalPrompt;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
//# sourceMappingURL=subagent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../../src/core/subagent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIzD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAQvE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAN,IAAY,qBAiBX;AAjBD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,wCAAe,CAAA;IACf;;OAEG;IACH,4CAAmB,CAAA;IACnB;;OAEG;IACH,sCAAa,CAAA;IACb;;OAEG;IACH,gDAAuB,CAAA;AACzB,CAAC,EAjBW,qBAAqB,KAArB,qBAAqB,QAiBhC;AAwGD;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACf,KAAK,GAA4B,EAAE,CAAC;IAE5C;;;;;OAKG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAW,EAAE,KAAc;QAC7B,IAAI,CAAC,KAAK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