@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,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { AgentDefinition } from './types.js';
7
+ import { z } from 'zod';
8
+ declare const CodebaseInvestigationReportSchema: z.ZodObject<{
9
+ SummaryOfFindings: z.ZodString;
10
+ ExplorationTrace: z.ZodArray<z.ZodString, "many">;
11
+ RelevantLocations: z.ZodArray<z.ZodObject<{
12
+ FilePath: z.ZodString;
13
+ Reasoning: z.ZodString;
14
+ KeySymbols: z.ZodArray<z.ZodString, "many">;
15
+ }, "strip", z.ZodTypeAny, {
16
+ FilePath: string;
17
+ Reasoning: string;
18
+ KeySymbols: string[];
19
+ }, {
20
+ FilePath: string;
21
+ Reasoning: string;
22
+ KeySymbols: string[];
23
+ }>, "many">;
24
+ }, "strip", z.ZodTypeAny, {
25
+ SummaryOfFindings: string;
26
+ ExplorationTrace: string[];
27
+ RelevantLocations: {
28
+ FilePath: string;
29
+ Reasoning: string;
30
+ KeySymbols: string[];
31
+ }[];
32
+ }, {
33
+ SummaryOfFindings: string;
34
+ ExplorationTrace: string[];
35
+ RelevantLocations: {
36
+ FilePath: string;
37
+ Reasoning: string;
38
+ KeySymbols: string[];
39
+ }[];
40
+ }>;
41
+ /**
42
+ * A Proof-of-Concept subagent specialized in analyzing codebase structure,
43
+ * dependencies, and technologies.
44
+ */
45
+ export declare const CodebaseInvestigatorAgent: AgentDefinition<typeof CodebaseInvestigationReportSchema>;
46
+ export {};
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { LSTool } from '../tools/ls.js';
7
+ import { ReadFileTool } from '../tools/read-file.js';
8
+ import { GlobTool } from '../tools/glob.js';
9
+ import { GrepTool } from '../tools/grep.js';
10
+ import { DEFAULT_GEMINI_MODEL } from '../config/models.js';
11
+ import { z } from 'zod';
12
+ // Define a type that matches the outputConfig schema for type safety.
13
+ const CodebaseInvestigationReportSchema = z.object({
14
+ SummaryOfFindings: z
15
+ .string()
16
+ .describe("A summary of the investigation's conclusions and insights for the main agent."),
17
+ ExplorationTrace: z
18
+ .array(z.string())
19
+ .describe('A step-by-step list of actions and tools used during the investigation.'),
20
+ RelevantLocations: z
21
+ .array(z.object({
22
+ FilePath: z.string(),
23
+ Reasoning: z.string(),
24
+ KeySymbols: z.array(z.string()),
25
+ }))
26
+ .describe('A list of relevant files and the key symbols within them.'),
27
+ });
28
+ /**
29
+ * A Proof-of-Concept subagent specialized in analyzing codebase structure,
30
+ * dependencies, and technologies.
31
+ */
32
+ export const CodebaseInvestigatorAgent = {
33
+ name: 'codebase_investigator',
34
+ displayName: 'Codebase Investigator Agent',
35
+ description: `Your primary tool for multifile search tasks and codebase exploration.
36
+ Invoke this tool to delegate search tasks to an autonomous subagent.
37
+ Use this to find features, understand context, or locate specific files, functions, or symbols.
38
+ Returns a structured Json report with key file paths, symbols, architectural map and insights to solve a task or answer questions`,
39
+ inputConfig: {
40
+ inputs: {
41
+ objective: {
42
+ description: `A comprehensive and detailed description of the user's ultimate goal.
43
+ You must include original user's objective as well as questions and any extra context and questions you may have.`,
44
+ type: 'string',
45
+ required: true,
46
+ },
47
+ },
48
+ },
49
+ outputConfig: {
50
+ outputName: 'report',
51
+ description: 'The final investigation report as a JSON object.',
52
+ schema: CodebaseInvestigationReportSchema,
53
+ },
54
+ // The 'output' parameter is now strongly typed as CodebaseInvestigationReportSchema
55
+ processOutput: (output) => JSON.stringify(output, null, 2),
56
+ modelConfig: {
57
+ model: DEFAULT_GEMINI_MODEL,
58
+ temp: 0.1,
59
+ top_p: 0.95,
60
+ thinkingBudget: -1,
61
+ },
62
+ runConfig: {
63
+ max_time_minutes: 5,
64
+ max_turns: 15,
65
+ },
66
+ toolConfig: {
67
+ // Grant access only to read-only tools.
68
+ tools: [LSTool.Name, ReadFileTool.Name, GlobTool.Name, GrepTool.Name],
69
+ },
70
+ promptConfig: {
71
+ query: `Your task is to do a deep investigation of the codebase to find all relevant files, code locations, architectural mental map and insights to solve for the following user objective:
72
+ <objective>
73
+ \${objective}
74
+ </objective>`,
75
+ systemPrompt: `You are **Codebase Investigator**, a hyper-specialized AI agent and an expert in reverse-engineering complex software projects. You are a sub-agent within a larger development system.
76
+ Your **SOLE PURPOSE** is to build a complete mental model of the code relevant to a given investigation. You must identify all relevant files, understand their roles, and foresee the direct architectural consequences of potential changes.
77
+ You are a sub-agent in a larger system. Your only responsibility is to provide deep, actionable context.
78
+ - **DO:** Find the key modules, classes, and functions that are part of the problem and its solution.
79
+ - **DO:** Understand *why* the code is written the way it is. Question everything.
80
+ - **DO:** Foresee the ripple effects of a change. If \`function A\` is modified, you must check its callers. If a data structure is altered, you must identify where its type definitions need to be updated.
81
+ - **DO:** provide a conclusion and insights to the main agent that invoked you. If the agent is trying to solve a bug, you should provide the root cause of the bug, its impacts, how to fix it etc. If it's a new feature, you should provide insights on where to implement it, what chagnes are necessary etc.
82
+ - **DO NOT:** Write the final implementation code yourself.
83
+ - **DO NOT:** Stop at the first relevant file. Your goal is a comprehensive understanding of the entire relevant subsystem.
84
+ You operate in a non-interactive loop and must reason based on the information provided and the output of your tools.
85
+ ---
86
+ ## Core Directives
87
+ <RULES>
88
+ 1. **DEEP ANALYSIS, NOT JUST FILE FINDING:** Your goal is to understand the *why* behind the code. Don't just list files; explain their purpose and the role of their key components. Your final report should empower another agent to make a correct and complete fix.
89
+ 2. **SYSTEMATIC & CURIOUS EXPLORATION:** Start with high-value clues (like tracebacks or ticket numbers) and broaden your search as needed. Think like a senior engineer doing a code review. An initial file contains clues (imports, function calls, puzzling logic). **If you find something you don't understand, you MUST prioritize investigating it until it is clear.** Treat confusion as a signal to dig deeper.
90
+ 3. **HOLISTIC & PRECISE:** Your goal is to find the complete and minimal set of locations that need to be understood or changed. Do not stop until you are confident you have considered the side effects of a potential fix (e.g., type errors, breaking changes to callers, opportunities for code reuse).
91
+ 4. **Web Search:** You are allowed to use the \`web_fetch\` tool to research libraries, language features, or concepts you don't understand (e.g., "what does gettext.translation do with localedir=None?").
92
+ </RULES>
93
+ ---
94
+ ## Scratchpad Management
95
+ **This is your most critical function. Your scratchpad is your memory and your plan.**
96
+ 1. **Initialization:** On your very first turn, you **MUST** create the \`<scratchpad>\` section. Analyze the \`task\` and create an initial \`Checklist\` of investigation goals and a \`Questions to Resolve\` section for any initial uncertainties.
97
+ 2. **Constant Updates:** After **every** \`<OBSERVATION>\`, you **MUST** update the scratchpad.
98
+ * Mark checklist items as complete: \`[x]\`.
99
+ * Add new checklist items as you trace the architecture.
100
+ * **Explicitly log questions in \`Questions to Resolve\`** (e.g., \`[ ] What is the purpose of the 'None' element in this list?\`). Do not consider your investigation complete until this list is empty.
101
+ * Record \`Key Findings\` with file paths and notes about their purpose and relevance.
102
+ * Update \`Irrelevant Paths to Ignore\` to avoid re-investigating dead ends.
103
+ 3. **Thinking on Paper:** The scratchpad must show your reasoning process, including how you resolve your questions.
104
+ ---
105
+ ## Termination
106
+ Your mission is complete **ONLY** when your \`Questions to Resolve\` list is empty and you have identified all files and necessary change *considerations*.
107
+ When you are finished, you **MUST** call the \`complete_task\` tool. The \`report\` argument for this tool **MUST** be a valid JSON object containing your findings.
108
+
109
+ **Example of the final report**
110
+ \`\`\`json
111
+ {
112
+ "SummaryOfFindings": "The core issue is a race condition in the \`updateUser\` function. The function reads the user's state, performs an asynchronous operation, and then writes the state back. If another request modifies the user state during the async operation, that change will be overwritten. The fix requires implementing a transactional read-modify-write pattern, potentially using a database lock or a versioning system.",
113
+ "ExplorationTrace": [
114
+ "Used \`grep\` to search for \`updateUser\` to locate the primary function.",
115
+ "Read the file \`src/controllers/userController.js\` to understand the function's logic.",
116
+ "Used \`ls -R\` to look for related files, such as services or database models.",
117
+ "Read \`src/services/userService.js\` and \`src/models/User.js\` to understand the data flow and how state is managed."
118
+ ],
119
+ "RelevantLocations": [
120
+ {
121
+ "FilePath": "src/controllers/userController.js",
122
+ "Reasoning": "This file contains the \`updateUser\` function which has the race condition. It's the entry point for the problematic logic.",
123
+ "KeySymbols": ["updateUser", "getUser", "saveUser"]
124
+ },
125
+ {
126
+ "FilePath": "src/services/userService.js",
127
+ "Reasoning": "This service is called by the controller and handles the direct interaction with the data layer. Any locking mechanism would likely be implemented here.",
128
+ "KeySymbols": ["updateUserData"]
129
+ }
130
+ ]
131
+ }
132
+ \`\`\`
133
+ `,
134
+ },
135
+ };
136
+ //# sourceMappingURL=codebase-investigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebase-investigator.js","sourceRoot":"","sources":["../../../src/agents/codebase-investigator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sEAAsE;AACtE,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,QAAQ,CACP,+EAA+E,CAChF;IACH,gBAAgB,EAAE,CAAC;SAChB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,CACP,yEAAyE,CAC1E;IACH,iBAAiB,EAAE,CAAC;SACjB,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC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CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Config } from '../config/config.js';
7
+ import type { AgentDefinition, AgentInputs, OutputObject, SubagentActivityEvent } from './types.js';
8
+ import { type z } from 'zod';
9
+ /** A callback function to report on agent activity. */
10
+ export type ActivityCallback = (activity: SubagentActivityEvent) => void;
11
+ /**
12
+ * Executes an agent loop based on an {@link AgentDefinition}.
13
+ *
14
+ * This executor runs the agent in a loop, calling tools until it calls the
15
+ * mandatory `complete_task` tool to signal completion.
16
+ */
17
+ export declare class AgentExecutor<TOutput extends z.ZodTypeAny> {
18
+ readonly definition: AgentDefinition<TOutput>;
19
+ private readonly agentId;
20
+ private readonly toolRegistry;
21
+ private readonly runtimeContext;
22
+ private readonly onActivity?;
23
+ /**
24
+ * Creates and validates a new `AgentExecutor` instance.
25
+ *
26
+ * This method ensures that all tools specified in the agent's definition are
27
+ * safe for non-interactive use before creating the executor.
28
+ *
29
+ * @param definition The definition object for the agent.
30
+ * @param runtimeContext The global runtime configuration.
31
+ * @param onActivity An optional callback to receive activity events.
32
+ * @returns A promise that resolves to a new `AgentExecutor` instance.
33
+ */
34
+ static create<TOutput extends z.ZodTypeAny>(definition: AgentDefinition<TOutput>, runtimeContext: Config, onActivity?: ActivityCallback): Promise<AgentExecutor<TOutput>>;
35
+ /**
36
+ * Constructs a new AgentExecutor instance.
37
+ *
38
+ * @private This constructor is private. Use the static `create` method to
39
+ * instantiate the class.
40
+ */
41
+ private constructor();
42
+ /**
43
+ * Runs the agent.
44
+ *
45
+ * @param inputs The validated input parameters for this invocation.
46
+ * @param signal An `AbortSignal` for cancellation.
47
+ * @returns A promise that resolves to the agent's final output.
48
+ */
49
+ run(inputs: AgentInputs, signal: AbortSignal): Promise<OutputObject>;
50
+ /**
51
+ * Calls the generative model with the current context and tools.
52
+ *
53
+ * @returns The model's response, including any tool calls or text.
54
+ */
55
+ private callModel;
56
+ /** Initializes a `GeminiChat` instance for the agent run. */
57
+ private createChatObject;
58
+ /**
59
+ * Executes function calls requested by the model and returns the results.
60
+ *
61
+ * @returns A new `Content` object for history, any submitted output, and completion status.
62
+ */
63
+ private processFunctionCalls;
64
+ /**
65
+ * Prepares the list of tool function declarations to be sent to the model.
66
+ */
67
+ private prepareToolsList;
68
+ /** Builds the system prompt from the agent definition and inputs. */
69
+ private buildSystemPrompt;
70
+ /**
71
+ * Applies template strings to initial messages.
72
+ *
73
+ * @param initialMessages The initial messages from the prompt config.
74
+ * @param inputs The validated input parameters for this invocation.
75
+ * @returns A new array of `Content` with templated strings.
76
+ */
77
+ private applyTemplateToInitialMessages;
78
+ /**
79
+ * Validates that all tools in a registry are safe for non-interactive use.
80
+ *
81
+ * @throws An error if a tool is not on the allow-list for non-interactive execution.
82
+ */
83
+ private static validateTools;
84
+ /**
85
+ * Checks if the agent should terminate due to exceeding configured limits.
86
+ *
87
+ * @returns The reason for termination, or `null` if execution can continue.
88
+ */
89
+ private checkTermination;
90
+ /** Emits an activity event to the configured callback. */
91
+ private emitActivity;
92
+ }