@vybestack/llxprt-code-core 0.5.0-nightly.251125.8cac021f2 → 0.5.0-nightly.251126.fea76aebd

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 (77) hide show
  1. package/dist/src/agents/codebase-investigator.d.ts +46 -0
  2. package/dist/src/agents/codebase-investigator.js +136 -0
  3. package/dist/src/agents/codebase-investigator.js.map +1 -0
  4. package/dist/src/agents/executor.d.ts +92 -0
  5. package/dist/src/agents/executor.js +624 -0
  6. package/dist/src/agents/executor.js.map +1 -0
  7. package/dist/src/agents/invocation.d.ts +45 -0
  8. package/dist/src/agents/invocation.js +106 -0
  9. package/dist/src/agents/invocation.js.map +1 -0
  10. package/dist/src/agents/registry.d.ts +36 -0
  11. package/dist/src/agents/registry.js +61 -0
  12. package/dist/src/agents/registry.js.map +1 -0
  13. package/dist/src/agents/types.d.ts +145 -0
  14. package/dist/src/agents/types.js +17 -0
  15. package/dist/src/agents/types.js.map +1 -0
  16. package/dist/src/agents/utils.d.ts +15 -0
  17. package/dist/src/agents/utils.js +27 -0
  18. package/dist/src/agents/utils.js.map +1 -0
  19. package/dist/src/config/config.d.ts +14 -3
  20. package/dist/src/config/config.js +36 -2
  21. package/dist/src/config/config.js.map +1 -1
  22. package/dist/src/core/client.d.ts +2 -0
  23. package/dist/src/core/client.js +5 -0
  24. package/dist/src/core/client.js.map +1 -1
  25. package/dist/src/core/geminiChat.d.ts +8 -1
  26. package/dist/src/core/geminiChat.js +14 -14
  27. package/dist/src/core/geminiChat.js.map +1 -1
  28. package/dist/src/ide/ide-client.js +3 -3
  29. package/dist/src/index.d.ts +2 -0
  30. package/dist/src/index.js +7 -0
  31. package/dist/src/index.js.map +1 -1
  32. package/dist/src/providers/anthropic/AnthropicProvider.js +24 -0
  33. package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
  34. package/dist/src/providers/openai/OpenAIProvider.d.ts +3 -0
  35. package/dist/src/providers/openai/OpenAIProvider.js +8 -2
  36. package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
  37. package/dist/src/providers/utils/localEndpoint.d.ts +39 -0
  38. package/dist/src/providers/utils/localEndpoint.js +117 -0
  39. package/dist/src/providers/utils/localEndpoint.js.map +1 -0
  40. package/dist/src/runtime/createAgentRuntimeContext.js +8 -7
  41. package/dist/src/runtime/createAgentRuntimeContext.js.map +1 -1
  42. package/dist/src/services/shellExecutionService.d.ts +46 -3
  43. package/dist/src/services/shellExecutionService.js +189 -49
  44. package/dist/src/services/shellExecutionService.js.map +1 -1
  45. package/dist/src/storage/sessionTypes.d.ts +27 -0
  46. package/dist/src/storage/sessionTypes.js +10 -0
  47. package/dist/src/storage/sessionTypes.js.map +1 -0
  48. package/dist/src/telemetry/constants.d.ts +8 -0
  49. package/dist/src/telemetry/constants.js +8 -0
  50. package/dist/src/telemetry/constants.js.map +1 -1
  51. package/dist/src/telemetry/loggers.d.ts +9 -1
  52. package/dist/src/telemetry/loggers.js +154 -2
  53. package/dist/src/telemetry/loggers.js.map +1 -1
  54. package/dist/src/telemetry/metrics.d.ts +5 -0
  55. package/dist/src/telemetry/metrics.js +4 -0
  56. package/dist/src/telemetry/metrics.js.map +1 -1
  57. package/dist/src/telemetry/types.d.ts +61 -0
  58. package/dist/src/telemetry/types.js +92 -0
  59. package/dist/src/telemetry/types.js.map +1 -1
  60. package/dist/src/test-utils/config.js +14 -0
  61. package/dist/src/test-utils/config.js.map +1 -1
  62. package/dist/src/tools/mcp-client.d.ts +3 -2
  63. package/dist/src/tools/mcp-client.js +28 -30
  64. package/dist/src/tools/mcp-client.js.map +1 -1
  65. package/dist/src/tools/shell.js +8 -3
  66. package/dist/src/tools/shell.js.map +1 -1
  67. package/dist/src/tools/tools.d.ts +2 -1
  68. package/dist/src/tools/tools.js.map +1 -1
  69. package/dist/src/utils/memoryDiscovery.d.ts +1 -0
  70. package/dist/src/utils/memoryDiscovery.js +2 -1
  71. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  72. package/dist/src/utils/retry.js +11 -11
  73. package/dist/src/utils/retry.js.map +1 -1
  74. package/dist/src/utils/terminalSerializer.d.ts +28 -0
  75. package/dist/src/utils/terminalSerializer.js +418 -0
  76. package/dist/src/utils/terminalSerializer.js.map +1 -0
  77. 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,106 @@
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
+ const stringValue = typeof value === 'object' && value !== null
43
+ ? JSON.stringify(value)
44
+ : String(value);
45
+ return `${key}: ${stringValue.slice(0, INPUT_PREVIEW_MAX_LENGTH)}`;
46
+ })
47
+ .join(', ');
48
+ const description = `Running subagent '${this.definition.name}' with inputs: { ${inputSummary} }`;
49
+ return description.slice(0, DESCRIPTION_MAX_LENGTH);
50
+ }
51
+ /**
52
+ * Executes the subagent.
53
+ *
54
+ * @param signal An `AbortSignal` to cancel the agent's execution.
55
+ * @param updateOutput A callback to stream intermediate output, such as the
56
+ * agent's thoughts, to the user interface.
57
+ * @returns A `Promise` that resolves with the final `ToolResult`.
58
+ */
59
+ async execute(signal, updateOutput) {
60
+ try {
61
+ if (updateOutput) {
62
+ updateOutput('Subagent starting...\n');
63
+ }
64
+ // Create an activity callback to bridge the executor's events to the
65
+ // tool's streaming output.
66
+ const onActivity = (activity) => {
67
+ if (!updateOutput)
68
+ return;
69
+ if (activity.type === 'THOUGHT_CHUNK' &&
70
+ typeof activity.data['text'] === 'string') {
71
+ updateOutput(`🤖💭 ${activity.data['text']}`);
72
+ }
73
+ };
74
+ const executor = await AgentExecutor.create(this.definition, this.config, onActivity);
75
+ const output = await executor.run(this.params, signal);
76
+ const resultContent = `Subagent '${this.definition.name}' finished.
77
+ Termination Reason: ${output.terminate_reason}
78
+ Result:
79
+ ${output.result}`;
80
+ const displayContent = `
81
+ Subagent ${this.definition.name} Finished
82
+
83
+ Termination Reason:\n ${output.terminate_reason}
84
+
85
+ Result:
86
+ ${output.result}
87
+ `;
88
+ return {
89
+ llmContent: [{ text: resultContent }],
90
+ returnDisplay: displayContent,
91
+ };
92
+ }
93
+ catch (error) {
94
+ const errorMessage = error instanceof Error ? error.message : String(error);
95
+ return {
96
+ llmContent: `Subagent '${this.definition.name}' failed. Error: ${errorMessage}`,
97
+ returnDisplay: `Subagent Failed: ${this.definition.name}\nError: ${errorMessage}`,
98
+ error: {
99
+ message: errorMessage,
100
+ type: ToolErrorType.EXECUTION_FAILED,
101
+ },
102
+ };
103
+ }
104
+ }
105
+ }
106
+ //# 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,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YAAY;oBACrB,IAAI,EAAE,aAAa,CAAC,gBAAgB;iBACrC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Config } from '../config/config.js';
7
+ import type { AgentDefinition } 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
+ constructor(config: Config);
17
+ /**
18
+ * Discovers and loads agents.
19
+ */
20
+ initialize(): Promise<void>;
21
+ private loadBuiltInAgents;
22
+ /**
23
+ * Registers an agent definition. If an agent with the same name exists,
24
+ * it will be overwritten, respecting the precedence established by the
25
+ * initialization order.
26
+ */
27
+ protected registerAgent<TOutput extends z.ZodTypeAny>(definition: AgentDefinition<TOutput>): void;
28
+ /**
29
+ * Retrieves an agent definition by name.
30
+ */
31
+ getDefinition(name: string): AgentDefinition | undefined;
32
+ /**
33
+ * Returns all active agent definitions.
34
+ */
35
+ getAllDefinitions(): AgentDefinition[];
36
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Manages the discovery, loading, validation, and registration of
8
+ * AgentDefinitions.
9
+ */
10
+ export class AgentRegistry {
11
+ config;
12
+ // Using unknown output type for the internal map to handle generic variance correctly
13
+ // Callers will cast to specific types as needed
14
+ agents = new Map();
15
+ constructor(config) {
16
+ this.config = config;
17
+ }
18
+ /**
19
+ * Discovers and loads agents.
20
+ */
21
+ async initialize() {
22
+ this.loadBuiltInAgents();
23
+ if (this.config.getDebugMode()) {
24
+ console.log(`[AgentRegistry] Initialized with ${this.agents.size} agents.`);
25
+ }
26
+ }
27
+ loadBuiltInAgents() {
28
+ // No built-in agents registered - CodebaseInvestigatorAgent was removed
29
+ // because it hardcodes DEFAULT_GEMINI_MODEL, violating multi-provider support
30
+ }
31
+ /**
32
+ * Registers an agent definition. If an agent with the same name exists,
33
+ * it will be overwritten, respecting the precedence established by the
34
+ * initialization order.
35
+ */
36
+ registerAgent(definition) {
37
+ // Basic validation
38
+ if (!definition.name || !definition.description) {
39
+ console.warn(`[AgentRegistry] Skipping invalid agent definition. Missing name or description.`);
40
+ return;
41
+ }
42
+ if (this.agents.has(definition.name) && this.config.getDebugMode()) {
43
+ console.log(`[AgentRegistry] Overriding agent '${definition.name}'`);
44
+ }
45
+ // Cast to default AgentDefinition type for storage - callers will cast back as needed
46
+ this.agents.set(definition.name, definition);
47
+ }
48
+ /**
49
+ * Retrieves an agent definition by name.
50
+ */
51
+ getDefinition(name) {
52
+ return this.agents.get(name);
53
+ }
54
+ /**
55
+ * Returns all active agent definitions.
56
+ */
57
+ getAllDefinitions() {
58
+ return Array.from(this.agents.values());
59
+ }
60
+ }
61
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/agents/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;GAGG;AACH,MAAM,OAAO,aAAa;IAKK;IAJ7B,sFAAsF;IACtF,gDAAgD;IAC/B,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAE7D,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CACT,oCAAoC,IAAI,CAAC,MAAM,CAAC,IAAI,UAAU,CAC/D,CAAC;QACJ,CAAC;IACH,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,OAAO,CAAC,IAAI,CACV,iFAAiF,CAClF,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;YACnE,OAAO,CAAC,GAAG,CAAC,qCAAqC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;QACvE,CAAC;QAED,sFAAsF;QACtF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAwC,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;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"}
@@ -23,6 +23,7 @@ export type { MCPOAuthConfig, AnyToolInvocation };
23
23
  import type { AnyToolInvocation } from '../tools/tools.js';
24
24
  import { WorkspaceContext } from '../utils/workspaceContext.js';
25
25
  import { Storage } from './storage.js';
26
+ import type { ShellExecutionConfig } from '../services/shellExecutionService.js';
26
27
  import { FileExclusions } from '../utils/ignorePatterns.js';
27
28
  import type { EventEmitter } from 'node:events';
28
29
  import { MessageBus } from '../confirmation-bus/message-bus.js';
@@ -165,6 +166,7 @@ export interface ConfigParameters {
165
166
  mcpServers?: Record<string, MCPServerConfig>;
166
167
  userMemory?: string;
167
168
  llxprtMdFileCount?: number;
169
+ llxprtMdFilePaths?: string[];
168
170
  approvalMode?: ApprovalMode;
169
171
  showMemoryUsage?: boolean;
170
172
  contextLimit?: number;
@@ -214,15 +216,16 @@ export interface ConfigParameters {
214
216
  useRipgrep?: boolean;
215
217
  shouldUseNodePtyShell?: boolean;
216
218
  skipNextSpeakerCheck?: boolean;
219
+ shellExecutionConfig?: ShellExecutionConfig;
220
+ truncateToolOutputThreshold?: number;
221
+ truncateToolOutputLines?: number;
222
+ enableToolOutputTruncation?: boolean;
217
223
  extensionManagement?: boolean;
218
224
  enablePromptCompletion?: boolean;
219
225
  eventEmitter?: EventEmitter;
220
226
  useSmartEdit?: boolean;
221
227
  settingsService?: SettingsService;
222
228
  policyEngineConfig?: PolicyEngineConfig;
223
- truncateToolOutputThreshold?: number;
224
- truncateToolOutputLines?: number;
225
- enableToolOutputTruncation?: boolean;
226
229
  }
227
230
  export declare class Config {
228
231
  private toolRegistry;
@@ -247,6 +250,7 @@ export declare class Config {
247
250
  private readonly mcpServers;
248
251
  private userMemory;
249
252
  private llxprtMdFileCount;
253
+ private llxprtMdFilePaths;
250
254
  private approvalMode;
251
255
  private readonly showMemoryUsage;
252
256
  private readonly accessibility;
@@ -302,6 +306,7 @@ export declare class Config {
302
306
  private readonly useRipgrep;
303
307
  private readonly shouldUseNodePtyShell;
304
308
  private readonly skipNextSpeakerCheck;
309
+ private shellExecutionConfig;
305
310
  private readonly extensionManagement;
306
311
  private readonly enablePromptCompletion;
307
312
  private initialized;
@@ -352,6 +357,8 @@ export declare class Config {
352
357
  setUserMemory(newUserMemory: string): void;
353
358
  getLlxprtMdFileCount(): number;
354
359
  setLlxprtMdFileCount(count: number): void;
360
+ getLlxprtMdFilePaths(): string[];
361
+ setLlxprtMdFilePaths(paths: string[]): void;
355
362
  getApprovalMode(): ApprovalMode;
356
363
  setApprovalMode(mode: ApprovalMode): void;
357
364
  getMessageBus(): MessageBus;
@@ -452,7 +459,10 @@ export declare class Config {
452
459
  getShellReplacement(): boolean;
453
460
  getUseRipgrep(): boolean;
454
461
  getShouldUseNodePtyShell(): boolean;
462
+ getEnableInteractiveShell(): boolean;
455
463
  getSkipNextSpeakerCheck(): boolean;
464
+ getShellExecutionConfig(): ShellExecutionConfig;
465
+ setShellExecutionConfig(config: ShellExecutionConfig): void;
456
466
  getScreenReader(): boolean;
457
467
  getEnablePromptCompletion(): boolean;
458
468
  getUseSmartEdit(): boolean;
@@ -466,6 +476,7 @@ export declare class Config {
466
476
  refreshMemory(): Promise<{
467
477
  memoryContent: string;
468
478
  fileCount: number;
479
+ filePaths: string[];
469
480
  }>;
470
481
  createToolRegistry(): Promise<ToolRegistry>;
471
482
  /**
@@ -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;
@@ -223,6 +224,7 @@ export class Config {
223
224
  useRipgrep;
224
225
  shouldUseNodePtyShell;
225
226
  skipNextSpeakerCheck;
227
+ shellExecutionConfig;
226
228
  extensionManagement;
227
229
  enablePromptCompletion = false;
228
230
  initialized = false;
@@ -288,6 +290,7 @@ export class Config {
288
290
  this.mcpServers = params.mcpServers;
289
291
  this.userMemory = params.userMemory ?? '';
290
292
  this.llxprtMdFileCount = params.llxprtMdFileCount ?? 0;
293
+ this.llxprtMdFilePaths = params.llxprtMdFilePaths ?? [];
291
294
  this.approvalMode = params.approvalMode ?? ApprovalMode.DEFAULT;
292
295
  this.showMemoryUsage = params.showMemoryUsage ?? false;
293
296
  this.accessibility = params.accessibility ?? {};
@@ -349,6 +352,14 @@ export class Config {
349
352
  this.useRipgrep = params.useRipgrep ?? false;
350
353
  this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? false;
351
354
  this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? false;
355
+ this.shellExecutionConfig = {
356
+ terminalWidth: params.shellExecutionConfig?.terminalWidth ?? 80,
357
+ terminalHeight: params.shellExecutionConfig?.terminalHeight ?? 24,
358
+ showColor: params.shellExecutionConfig?.showColor ?? false,
359
+ pager: params.shellExecutionConfig?.pager ?? 'cat',
360
+ defaultFg: params.shellExecutionConfig?.defaultFg,
361
+ defaultBg: params.shellExecutionConfig?.defaultBg,
362
+ };
352
363
  this.truncateToolOutputThreshold =
353
364
  params.truncateToolOutputThreshold ??
354
365
  DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD;
@@ -638,6 +649,12 @@ export class Config {
638
649
  setLlxprtMdFileCount(count) {
639
650
  this.llxprtMdFileCount = count;
640
651
  }
652
+ getLlxprtMdFilePaths() {
653
+ return this.llxprtMdFilePaths;
654
+ }
655
+ setLlxprtMdFilePaths(paths) {
656
+ this.llxprtMdFilePaths = paths;
657
+ }
641
658
  getApprovalMode() {
642
659
  return this.approvalMode;
643
660
  }
@@ -1067,9 +1084,25 @@ export class Config {
1067
1084
  getShouldUseNodePtyShell() {
1068
1085
  return this.shouldUseNodePtyShell;
1069
1086
  }
1087
+ getEnableInteractiveShell() {
1088
+ return this.shouldUseNodePtyShell;
1089
+ }
1070
1090
  getSkipNextSpeakerCheck() {
1071
1091
  return this.skipNextSpeakerCheck;
1072
1092
  }
1093
+ getShellExecutionConfig() {
1094
+ return this.shellExecutionConfig;
1095
+ }
1096
+ setShellExecutionConfig(config) {
1097
+ this.shellExecutionConfig = {
1098
+ terminalWidth: config.terminalWidth ?? this.shellExecutionConfig.terminalWidth,
1099
+ terminalHeight: config.terminalHeight ?? this.shellExecutionConfig.terminalHeight,
1100
+ showColor: config.showColor ?? this.shellExecutionConfig.showColor,
1101
+ pager: config.pager ?? this.shellExecutionConfig.pager,
1102
+ defaultFg: config.defaultFg ?? this.shellExecutionConfig.defaultFg,
1103
+ defaultBg: config.defaultBg ?? this.shellExecutionConfig.defaultBg,
1104
+ };
1105
+ }
1073
1106
  getScreenReader() {
1074
1107
  return this.accessibility.screenReader ?? false;
1075
1108
  }
@@ -1099,12 +1132,13 @@ export class Config {
1099
1132
  return this.fileExclusions;
1100
1133
  }
1101
1134
  async refreshMemory() {
1102
- const { memoryContent, fileCount } = await loadServerHierarchicalMemory(this.getWorkingDir(), this.shouldLoadMemoryFromIncludeDirectories()
1135
+ const { memoryContent, fileCount, filePaths } = await loadServerHierarchicalMemory(this.getWorkingDir(), this.shouldLoadMemoryFromIncludeDirectories()
1103
1136
  ? this.getWorkspaceContext().getDirectories()
1104
1137
  : [], this.getDebugMode(), this.getFileService(), this.getExtensionContextFilePaths(), this.getFolderTrust());
1105
1138
  this.setUserMemory(memoryContent);
1106
1139
  this.setLlxprtMdFileCount(fileCount);
1107
- return { memoryContent, fileCount };
1140
+ this.setLlxprtMdFilePaths(filePaths);
1141
+ return { memoryContent, fileCount, filePaths };
1108
1142
  }
1109
1143
  async createToolRegistry() {
1110
1144
  const registry = new ToolRegistry(this, this.eventEmitter);