@vybestack/llxprt-code-core 0.5.0-nightly.251125.8cac021f2 → 0.5.0-nightly.251126.ec44835c5
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 +46 -0
- package/dist/src/agents/codebase-investigator.js +136 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +92 -0
- package/dist/src/agents/executor.js +624 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +45 -0
- package/dist/src/agents/invocation.js +114 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/registry.d.ts +38 -0
- package/dist/src/agents/registry.js +64 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/types.d.ts +145 -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 +27 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/config/config.d.ts +5 -0
- package/dist/src/config/config.js +11 -2
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/core/client.d.ts +2 -0
- package/dist/src/core/client.js +5 -0
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +8 -1
- package/dist/src/core/geminiChat.js +14 -14
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/ide/ide-client.js +3 -3
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/providers/anthropic/AnthropicProvider.js +24 -0
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/openai/OpenAIProvider.d.ts +3 -0
- package/dist/src/providers/openai/OpenAIProvider.js +8 -2
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/utils/localEndpoint.d.ts +39 -0
- package/dist/src/providers/utils/localEndpoint.js +117 -0
- package/dist/src/providers/utils/localEndpoint.js.map +1 -0
- package/dist/src/runtime/createAgentRuntimeContext.js +8 -7
- package/dist/src/runtime/createAgentRuntimeContext.js.map +1 -1
- package/dist/src/storage/sessionTypes.d.ts +27 -0
- package/dist/src/storage/sessionTypes.js +10 -0
- package/dist/src/storage/sessionTypes.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +8 -0
- package/dist/src/telemetry/constants.js +8 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +9 -1
- package/dist/src/telemetry/loggers.js +154 -2
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +5 -0
- package/dist/src/telemetry/metrics.js +4 -0
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +61 -0
- package/dist/src/telemetry/types.js +92 -0
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/test-utils/config.js +14 -0
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +3 -2
- package/dist/src/tools/mcp-client.js +28 -30
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/shell.js +1 -1
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +1 -0
- package/dist/src/utils/memoryDiscovery.js +2 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/retry.js +11 -11
- package/dist/src/utils/retry.js.map +1 -1
- package/package.json +1 -1
|
@@ -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 { BaseToolInvocation, type ToolResult } from '../tools/tools.js';
|
|
8
|
+
import type { AgentDefinition, AgentInputs } from './types.js';
|
|
9
|
+
import type { MessageBus } from '../confirmation-bus/message-bus.js';
|
|
10
|
+
import { type z } from 'zod';
|
|
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<TOutput extends z.ZodTypeAny> 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<TOutput>, 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) => void): Promise<ToolResult>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { AgentExecutor } from './executor.js';
|
|
7
|
+
import { BaseToolInvocation } from '../tools/tools.js';
|
|
8
|
+
import { ToolErrorType } from '../tools/tool-error.js';
|
|
9
|
+
const INPUT_PREVIEW_MAX_LENGTH = 50;
|
|
10
|
+
const DESCRIPTION_MAX_LENGTH = 200;
|
|
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 class SubagentInvocation extends BaseToolInvocation {
|
|
22
|
+
definition;
|
|
23
|
+
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, definition, config, messageBus) {
|
|
31
|
+
super(params, messageBus);
|
|
32
|
+
this.definition = definition;
|
|
33
|
+
this.config = config;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns a concise, human-readable description of the invocation.
|
|
37
|
+
* Used for logging and display purposes.
|
|
38
|
+
*/
|
|
39
|
+
getDescription() {
|
|
40
|
+
const inputSummary = Object.entries(this.params)
|
|
41
|
+
.map(([key, value]) => {
|
|
42
|
+
let stringValue;
|
|
43
|
+
try {
|
|
44
|
+
stringValue =
|
|
45
|
+
typeof value === 'object' && value !== null
|
|
46
|
+
? JSON.stringify(value)
|
|
47
|
+
: String(value);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Handle circular references/unsupported values gracefully
|
|
51
|
+
stringValue = Object.prototype.toString.call(value);
|
|
52
|
+
}
|
|
53
|
+
return `${key}: ${stringValue.slice(0, INPUT_PREVIEW_MAX_LENGTH)}`;
|
|
54
|
+
})
|
|
55
|
+
.join(', ');
|
|
56
|
+
const description = `Running subagent '${this.definition.name}' with inputs: { ${inputSummary} }`;
|
|
57
|
+
return description.slice(0, DESCRIPTION_MAX_LENGTH);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Executes the subagent.
|
|
61
|
+
*
|
|
62
|
+
* @param signal An `AbortSignal` to cancel the agent's execution.
|
|
63
|
+
* @param updateOutput A callback to stream intermediate output, such as the
|
|
64
|
+
* agent's thoughts, to the user interface.
|
|
65
|
+
* @returns A `Promise` that resolves with the final `ToolResult`.
|
|
66
|
+
*/
|
|
67
|
+
async execute(signal, updateOutput) {
|
|
68
|
+
try {
|
|
69
|
+
if (updateOutput) {
|
|
70
|
+
updateOutput('Subagent starting...\n');
|
|
71
|
+
}
|
|
72
|
+
// Create an activity callback to bridge the executor's events to the
|
|
73
|
+
// tool's streaming output.
|
|
74
|
+
const onActivity = (activity) => {
|
|
75
|
+
if (!updateOutput)
|
|
76
|
+
return;
|
|
77
|
+
if (activity.type === 'THOUGHT_CHUNK' &&
|
|
78
|
+
typeof activity.data['text'] === 'string') {
|
|
79
|
+
updateOutput(`🤖💭 ${activity.data['text']}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const executor = await AgentExecutor.create(this.definition, this.config, onActivity);
|
|
83
|
+
const output = await executor.run(this.params, signal);
|
|
84
|
+
const resultContent = `Subagent '${this.definition.name}' finished.
|
|
85
|
+
Termination Reason: ${output.terminate_reason}
|
|
86
|
+
Result:
|
|
87
|
+
${output.result}`;
|
|
88
|
+
const displayContent = `
|
|
89
|
+
Subagent ${this.definition.name} Finished
|
|
90
|
+
|
|
91
|
+
Termination Reason:\n ${output.terminate_reason}
|
|
92
|
+
|
|
93
|
+
Result:
|
|
94
|
+
${output.result}
|
|
95
|
+
`;
|
|
96
|
+
return {
|
|
97
|
+
llmContent: [{ text: resultContent }],
|
|
98
|
+
returnDisplay: displayContent,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
103
|
+
return {
|
|
104
|
+
llmContent: `Subagent '${this.definition.name}' failed. Error: ${errorMessage}`,
|
|
105
|
+
returnDisplay: `Subagent Failed: ${this.definition.name}\nError: ${errorMessage}`,
|
|
106
|
+
error: {
|
|
107
|
+
message: errorMessage,
|
|
108
|
+
type: ToolErrorType.EXECUTION_FAILED,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation.js","sourceRoot":"","sources":["../../../src/agents/invocation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AASvD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAEX,SAAQ,kBAA2C;IAShC;IACA;IATnB;;;;;OAKG;IACH,YACE,MAAmB,EACF,UAAoC,EACpC,MAAc,EAC/B,UAAuB;QAEvB,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAJT,eAAU,GAAV,UAAU,CAA0B;QACpC,WAAM,GAAN,MAAM,CAAQ;IAIjC,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,MAAM,YAAY,GAAG,MAAM,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ache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Config } from '../config/config.js';
|
|
7
|
+
import type { AgentDefinition } from './types.js';
|
|
8
|
+
import type { z } from 'zod';
|
|
9
|
+
/**
|
|
10
|
+
* Manages the discovery, loading, validation, and registration of
|
|
11
|
+
* AgentDefinitions.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AgentRegistry {
|
|
14
|
+
private readonly config;
|
|
15
|
+
private readonly agents;
|
|
16
|
+
private readonly logger;
|
|
17
|
+
constructor(config: Config);
|
|
18
|
+
/**
|
|
19
|
+
* Discovers and loads agents.
|
|
20
|
+
*/
|
|
21
|
+
initialize(): Promise<void>;
|
|
22
|
+
private loadBuiltInAgents;
|
|
23
|
+
/**
|
|
24
|
+
* Registers an agent definition. If an agent with the same name exists,
|
|
25
|
+
* it will be overwritten, respecting the precedence established by the
|
|
26
|
+
* initialization order.
|
|
27
|
+
*/
|
|
28
|
+
protected registerAgent<TOutput extends z.ZodTypeAny>(definition: AgentDefinition<TOutput>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves an agent definition by name.
|
|
31
|
+
* Callers should cast to their expected AgentDefinition<TOutput> shape before invoking typed callbacks.
|
|
32
|
+
*/
|
|
33
|
+
getDefinition(name: string): AgentDefinition | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Returns all active agent definitions.
|
|
36
|
+
*/
|
|
37
|
+
getAllDefinitions(): AgentDefinition[];
|
|
38
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { DebugLogger } from '../debug/DebugLogger.js';
|
|
7
|
+
/**
|
|
8
|
+
* Manages the discovery, loading, validation, and registration of
|
|
9
|
+
* AgentDefinitions.
|
|
10
|
+
*/
|
|
11
|
+
export class AgentRegistry {
|
|
12
|
+
config;
|
|
13
|
+
// Using unknown output type for the internal map to handle generic variance correctly
|
|
14
|
+
// Callers will cast to specific types as needed
|
|
15
|
+
agents = new Map();
|
|
16
|
+
logger = new DebugLogger('llxprt:agents:registry');
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = config;
|
|
19
|
+
// Access config to satisfy lint and allow future conditional logging
|
|
20
|
+
void this.config;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Discovers and loads agents.
|
|
24
|
+
*/
|
|
25
|
+
async initialize() {
|
|
26
|
+
this.loadBuiltInAgents();
|
|
27
|
+
this.logger.debug(() => `[AgentRegistry] Initialized with ${this.agents.size} agents.`);
|
|
28
|
+
}
|
|
29
|
+
loadBuiltInAgents() {
|
|
30
|
+
// No built-in agents registered - CodebaseInvestigatorAgent was removed
|
|
31
|
+
// because it hardcodes DEFAULT_GEMINI_MODEL, violating multi-provider support
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Registers an agent definition. If an agent with the same name exists,
|
|
35
|
+
* it will be overwritten, respecting the precedence established by the
|
|
36
|
+
* initialization order.
|
|
37
|
+
*/
|
|
38
|
+
registerAgent(definition) {
|
|
39
|
+
// Basic validation
|
|
40
|
+
if (!definition.name || !definition.description) {
|
|
41
|
+
this.logger.warn(`[AgentRegistry] Skipping invalid agent definition. Missing name or description.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this.agents.has(definition.name)) {
|
|
45
|
+
this.logger.debug(`[AgentRegistry] Overriding agent '${definition.name}'`);
|
|
46
|
+
}
|
|
47
|
+
// Cast to default AgentDefinition type for storage - callers will cast back as needed
|
|
48
|
+
this.agents.set(definition.name, definition);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves an agent definition by name.
|
|
52
|
+
* Callers should cast to their expected AgentDefinition<TOutput> shape before invoking typed callbacks.
|
|
53
|
+
*/
|
|
54
|
+
getDefinition(name) {
|
|
55
|
+
return this.agents.get(name);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns all active agent definitions.
|
|
59
|
+
*/
|
|
60
|
+
getAllDefinitions() {
|
|
61
|
+
return Array.from(this.agents.values());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/agents/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,aAAa;IAMK;IAL7B,sFAAsF;IACtF,gDAAgD;IAC/B,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAC5C,MAAM,GAAG,IAAI,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAEpE,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QACzC,qEAAqE;QACrE,KAAK,IAAI,CAAC,MAAM,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,EAAE,CAAC,oCAAoC,IAAI,CAAC,MAAM,CAAC,IAAI,UAAU,CACrE,CAAC;IACJ,CAAC;IAEO,iBAAiB;QACvB,wEAAwE;QACxE,8EAA8E;IAChF,CAAC;IAED;;;;OAIG;IACO,aAAa,CACrB,UAAoC;QAEpC,mBAAmB;QACnB,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;YAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,iFAAiF,CAClF,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,qCAAqC,UAAU,CAAC,IAAI,GAAG,CACxD,CAAC;QACJ,CAAC;QAED,sFAAsF;QACtF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAwC,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview Defines the core configuration interfaces and types for the agent architecture.
|
|
8
|
+
*/
|
|
9
|
+
import type { Content, FunctionDeclaration } from '@google/genai';
|
|
10
|
+
import type { AnyDeclarativeTool } from '../tools/tools.js';
|
|
11
|
+
import { type z } from 'zod';
|
|
12
|
+
/**
|
|
13
|
+
* Describes the possible termination modes for an agent.
|
|
14
|
+
*/
|
|
15
|
+
export declare enum AgentTerminateMode {
|
|
16
|
+
ERROR = "ERROR",
|
|
17
|
+
TIMEOUT = "TIMEOUT",
|
|
18
|
+
GOAL = "GOAL",
|
|
19
|
+
MAX_TURNS = "MAX_TURNS",
|
|
20
|
+
ABORTED = "ABORTED"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents the output structure of an agent's execution.
|
|
24
|
+
*/
|
|
25
|
+
export interface OutputObject {
|
|
26
|
+
result: string;
|
|
27
|
+
terminate_reason: AgentTerminateMode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents the validated input parameters passed to an agent upon invocation.
|
|
31
|
+
* Used primarily for templating the system prompt. (Replaces ContextState)
|
|
32
|
+
*/
|
|
33
|
+
export type AgentInputs = Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Structured events emitted during subagent execution for user observability.
|
|
36
|
+
*/
|
|
37
|
+
export interface SubagentActivityEvent {
|
|
38
|
+
isSubagentActivityEvent: true;
|
|
39
|
+
agentName: string;
|
|
40
|
+
type: 'TOOL_CALL_START' | 'TOOL_CALL_END' | 'THOUGHT_CHUNK' | 'ERROR';
|
|
41
|
+
data: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The definition for an agent.
|
|
45
|
+
* @template TOutput The specific Zod schema for the agent's final output object.
|
|
46
|
+
*/
|
|
47
|
+
export interface AgentDefinition<TOutput extends z.ZodTypeAny = z.ZodUnknown> {
|
|
48
|
+
/** Unique identifier for the agent. */
|
|
49
|
+
name: string;
|
|
50
|
+
displayName?: string;
|
|
51
|
+
description: string;
|
|
52
|
+
promptConfig: PromptConfig;
|
|
53
|
+
modelConfig: ModelConfig;
|
|
54
|
+
runConfig: RunConfig;
|
|
55
|
+
toolConfig?: ToolConfig;
|
|
56
|
+
outputConfig?: OutputConfig<TOutput>;
|
|
57
|
+
inputConfig: InputConfig;
|
|
58
|
+
/**
|
|
59
|
+
* An optional function to process the raw output from the agent's final tool
|
|
60
|
+
* call into a string format.
|
|
61
|
+
*
|
|
62
|
+
* @param output The raw output value from the `complete_task` tool, now strongly typed with TOutput.
|
|
63
|
+
* @returns A string representation of the final output.
|
|
64
|
+
*/
|
|
65
|
+
processOutput?: (output: z.infer<TOutput>) => string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configures the initial prompt for the agent.
|
|
69
|
+
*/
|
|
70
|
+
export interface PromptConfig {
|
|
71
|
+
/**
|
|
72
|
+
* A single system prompt string. Supports templating using `${input_name}` syntax.
|
|
73
|
+
*/
|
|
74
|
+
systemPrompt?: string;
|
|
75
|
+
/**
|
|
76
|
+
* An array of user/model content pairs for few-shot prompting.
|
|
77
|
+
*/
|
|
78
|
+
initialMessages?: Content[];
|
|
79
|
+
/**
|
|
80
|
+
* The specific task or question to trigger the agent's execution loop.
|
|
81
|
+
* This is sent as the first user message, distinct from the systemPrompt (identity/rules)
|
|
82
|
+
* and initialMessages (history/few-shots). Supports templating.
|
|
83
|
+
* If not provided, a generic "Get Started!" message is used.
|
|
84
|
+
*/
|
|
85
|
+
query?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configures the tools available to the agent during its execution.
|
|
89
|
+
*/
|
|
90
|
+
export interface ToolConfig {
|
|
91
|
+
tools: Array<string | FunctionDeclaration | AnyDeclarativeTool>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Configures the expected inputs (parameters) for the agent.
|
|
95
|
+
*/
|
|
96
|
+
export interface InputConfig {
|
|
97
|
+
/**
|
|
98
|
+
* Defines the parameters the agent accepts.
|
|
99
|
+
* This is vital for generating the tool wrapper schema.
|
|
100
|
+
*/
|
|
101
|
+
inputs: Record<string, {
|
|
102
|
+
description: string;
|
|
103
|
+
type: 'string' | 'number' | 'boolean' | 'integer' | 'string[]' | 'number[]';
|
|
104
|
+
required: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Configures the expected outputs for the agent.
|
|
109
|
+
*/
|
|
110
|
+
export interface OutputConfig<T extends z.ZodTypeAny> {
|
|
111
|
+
/**
|
|
112
|
+
* The name of the final result parameter. This will be the name of the
|
|
113
|
+
* argument in the `submit_final_output` tool (e.g., "report", "answer").
|
|
114
|
+
*/
|
|
115
|
+
outputName: string;
|
|
116
|
+
/**
|
|
117
|
+
* A description of the expected output. This will be used as the description
|
|
118
|
+
* for the tool argument.
|
|
119
|
+
*/
|
|
120
|
+
description: string;
|
|
121
|
+
/**
|
|
122
|
+
* Optional JSON schema for the output. If provided, it will be used as the
|
|
123
|
+
* schema for the tool's argument, allowing for structured output enforcement.
|
|
124
|
+
* Defaults to { type: 'string' }.
|
|
125
|
+
*/
|
|
126
|
+
schema: T;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Configures the generative model parameters for the agent.
|
|
130
|
+
*/
|
|
131
|
+
export interface ModelConfig {
|
|
132
|
+
model: string;
|
|
133
|
+
temp: number;
|
|
134
|
+
top_p: number;
|
|
135
|
+
thinkingBudget?: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Configures the execution environment and constraints for the agent.
|
|
139
|
+
*/
|
|
140
|
+
export interface RunConfig {
|
|
141
|
+
/** The maximum execution time for the agent in minutes. */
|
|
142
|
+
max_time_minutes: number;
|
|
143
|
+
/** The maximum number of conversational turns. */
|
|
144
|
+
max_turns?: number;
|
|
145
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Describes the possible termination modes for an agent.
|
|
8
|
+
*/
|
|
9
|
+
export var AgentTerminateMode;
|
|
10
|
+
(function (AgentTerminateMode) {
|
|
11
|
+
AgentTerminateMode["ERROR"] = "ERROR";
|
|
12
|
+
AgentTerminateMode["TIMEOUT"] = "TIMEOUT";
|
|
13
|
+
AgentTerminateMode["GOAL"] = "GOAL";
|
|
14
|
+
AgentTerminateMode["MAX_TURNS"] = "MAX_TURNS";
|
|
15
|
+
AgentTerminateMode["ABORTED"] = "ABORTED";
|
|
16
|
+
})(AgentTerminateMode || (AgentTerminateMode = {}));
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/agents/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;IACf,yCAAmB,CAAA;IACnB,mCAAa,CAAA;IACb,6CAAuB,CAAA;IACvB,yCAAmB,CAAA;AACrB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentInputs } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Simple template string replacement for agent prompts.
|
|
9
|
+
* Replaces ${key} placeholders with values from the inputs object.
|
|
10
|
+
*
|
|
11
|
+
* @param template The template string with ${key} placeholders
|
|
12
|
+
* @param inputs The input values to substitute
|
|
13
|
+
* @returns The template with placeholders replaced
|
|
14
|
+
*/
|
|
15
|
+
export declare function templateString(template: string, inputs: AgentInputs): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Simple template string replacement for agent prompts.
|
|
8
|
+
* Replaces ${key} placeholders with values from the inputs object.
|
|
9
|
+
*
|
|
10
|
+
* @param template The template string with ${key} placeholders
|
|
11
|
+
* @param inputs The input values to substitute
|
|
12
|
+
* @returns The template with placeholders replaced
|
|
13
|
+
*/
|
|
14
|
+
export function templateString(template, inputs) {
|
|
15
|
+
const placeholderRegex = /\$\{(\w+)\}/g;
|
|
16
|
+
// First, find all unique keys required by the template.
|
|
17
|
+
const requiredKeys = new Set(Array.from(template.matchAll(placeholderRegex), (match) => match[1]));
|
|
18
|
+
// Check if all required keys exist in the inputs.
|
|
19
|
+
const inputKeys = new Set(Object.keys(inputs));
|
|
20
|
+
const missingKeys = Array.from(requiredKeys).filter((key) => !inputKeys.has(key));
|
|
21
|
+
if (missingKeys.length > 0) {
|
|
22
|
+
throw new Error(`Missing input values for the following keys: ${missingKeys.join(', ')}`);
|
|
23
|
+
}
|
|
24
|
+
// Perform the replacement using a replacer function.
|
|
25
|
+
return template.replace(placeholderRegex, (_match, key) => String(inputs[key]));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/agents/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,MAAmB;IAClE,MAAM,gBAAgB,GAAG,cAAc,CAAC;IAExC,wDAAwD;IACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAC1B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACrE,CAAC;IAEF,kDAAkD;IAClD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CACjD,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAC7B,CAAC;IAEF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,gDAAgD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACzE,CAAC;IACJ,CAAC;IAED,qDAAqD;IACrD,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CACxD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -165,6 +165,7 @@ export interface ConfigParameters {
|
|
|
165
165
|
mcpServers?: Record<string, MCPServerConfig>;
|
|
166
166
|
userMemory?: string;
|
|
167
167
|
llxprtMdFileCount?: number;
|
|
168
|
+
llxprtMdFilePaths?: string[];
|
|
168
169
|
approvalMode?: ApprovalMode;
|
|
169
170
|
showMemoryUsage?: boolean;
|
|
170
171
|
contextLimit?: number;
|
|
@@ -247,6 +248,7 @@ export declare class Config {
|
|
|
247
248
|
private readonly mcpServers;
|
|
248
249
|
private userMemory;
|
|
249
250
|
private llxprtMdFileCount;
|
|
251
|
+
private llxprtMdFilePaths;
|
|
250
252
|
private approvalMode;
|
|
251
253
|
private readonly showMemoryUsage;
|
|
252
254
|
private readonly accessibility;
|
|
@@ -352,6 +354,8 @@ export declare class Config {
|
|
|
352
354
|
setUserMemory(newUserMemory: string): void;
|
|
353
355
|
getLlxprtMdFileCount(): number;
|
|
354
356
|
setLlxprtMdFileCount(count: number): void;
|
|
357
|
+
getLlxprtMdFilePaths(): string[];
|
|
358
|
+
setLlxprtMdFilePaths(paths: string[]): void;
|
|
355
359
|
getApprovalMode(): ApprovalMode;
|
|
356
360
|
setApprovalMode(mode: ApprovalMode): void;
|
|
357
361
|
getMessageBus(): MessageBus;
|
|
@@ -466,6 +470,7 @@ export declare class Config {
|
|
|
466
470
|
refreshMemory(): Promise<{
|
|
467
471
|
memoryContent: string;
|
|
468
472
|
fileCount: number;
|
|
473
|
+
filePaths: string[];
|
|
469
474
|
}>;
|
|
470
475
|
createToolRegistry(): Promise<ToolRegistry>;
|
|
471
476
|
/**
|
|
@@ -151,6 +151,7 @@ export class Config {
|
|
|
151
151
|
mcpServers;
|
|
152
152
|
userMemory;
|
|
153
153
|
llxprtMdFileCount;
|
|
154
|
+
llxprtMdFilePaths;
|
|
154
155
|
approvalMode;
|
|
155
156
|
showMemoryUsage;
|
|
156
157
|
accessibility;
|
|
@@ -288,6 +289,7 @@ export class Config {
|
|
|
288
289
|
this.mcpServers = params.mcpServers;
|
|
289
290
|
this.userMemory = params.userMemory ?? '';
|
|
290
291
|
this.llxprtMdFileCount = params.llxprtMdFileCount ?? 0;
|
|
292
|
+
this.llxprtMdFilePaths = params.llxprtMdFilePaths ?? [];
|
|
291
293
|
this.approvalMode = params.approvalMode ?? ApprovalMode.DEFAULT;
|
|
292
294
|
this.showMemoryUsage = params.showMemoryUsage ?? false;
|
|
293
295
|
this.accessibility = params.accessibility ?? {};
|
|
@@ -638,6 +640,12 @@ export class Config {
|
|
|
638
640
|
setLlxprtMdFileCount(count) {
|
|
639
641
|
this.llxprtMdFileCount = count;
|
|
640
642
|
}
|
|
643
|
+
getLlxprtMdFilePaths() {
|
|
644
|
+
return this.llxprtMdFilePaths;
|
|
645
|
+
}
|
|
646
|
+
setLlxprtMdFilePaths(paths) {
|
|
647
|
+
this.llxprtMdFilePaths = paths;
|
|
648
|
+
}
|
|
641
649
|
getApprovalMode() {
|
|
642
650
|
return this.approvalMode;
|
|
643
651
|
}
|
|
@@ -1099,12 +1107,13 @@ export class Config {
|
|
|
1099
1107
|
return this.fileExclusions;
|
|
1100
1108
|
}
|
|
1101
1109
|
async refreshMemory() {
|
|
1102
|
-
const { memoryContent, fileCount } = await loadServerHierarchicalMemory(this.getWorkingDir(), this.shouldLoadMemoryFromIncludeDirectories()
|
|
1110
|
+
const { memoryContent, fileCount, filePaths } = await loadServerHierarchicalMemory(this.getWorkingDir(), this.shouldLoadMemoryFromIncludeDirectories()
|
|
1103
1111
|
? this.getWorkspaceContext().getDirectories()
|
|
1104
1112
|
: [], this.getDebugMode(), this.getFileService(), this.getExtensionContextFilePaths(), this.getFolderTrust());
|
|
1105
1113
|
this.setUserMemory(memoryContent);
|
|
1106
1114
|
this.setLlxprtMdFileCount(fileCount);
|
|
1107
|
-
|
|
1115
|
+
this.setLlxprtMdFilePaths(filePaths);
|
|
1116
|
+
return { memoryContent, fileCount, filePaths };
|
|
1108
1117
|
}
|
|
1109
1118
|
async createToolRegistry() {
|
|
1110
1119
|
const registry = new ToolRegistry(this, this.eventEmitter);
|