gaunt-sloth-assistant 0.8.12 → 0.9.0
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/.gsloth.code.md +32 -19
- package/.gsloth.guidelines.md +4 -2
- package/README.md +11 -1
- package/dist/builtInToolsConfig.d.ts +2 -1
- package/dist/builtInToolsConfig.js +16 -4
- package/dist/builtInToolsConfig.js.map +1 -1
- package/dist/config.d.ts +33 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/core/GthAgentRunner.js +22 -1
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.js +51 -4
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/debugUtils.d.ts +20 -0
- package/dist/debugUtils.js +89 -0
- package/dist/debugUtils.js.map +1 -0
- package/dist/modules/interactiveSessionModule.js +22 -4
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/presets/openrouter.d.ts +5 -0
- package/dist/presets/openrouter.js +54 -0
- package/dist/presets/openrouter.js.map +1 -0
- package/dist/tools/GthDevToolkit.d.ts +21 -0
- package/dist/tools/GthDevToolkit.js +182 -0
- package/dist/tools/GthDevToolkit.js.map +1 -0
- package/dist/tools/GthFileSystemToolkit.js +25 -16
- package/dist/tools/GthFileSystemToolkit.js.map +1 -1
- package/dist/tools/gthSequentialThinkingTool.d.ts +53 -0
- package/dist/tools/gthSequentialThinkingTool.js +130 -0
- package/dist/tools/gthSequentialThinkingTool.js.map +1 -0
- package/package.json +9 -8
package/.gsloth.code.md
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
# Code Mode Instructions
|
|
2
|
-
|
|
3
|
-
You are an AI coding assistant with full file system access within the user's project. Your role is to:
|
|
4
|
-
|
|
5
|
-
- Help write, modify, and debug code
|
|
6
|
-
- Understand and work with the existing codebase
|
|
7
|
-
- Follow project conventions and best practices
|
|
8
|
-
- Create, read, update, and delete files as needed to complete coding tasks
|
|
9
|
-
- Run commands and scripts to test and validate changes
|
|
10
|
-
- Provide clear explanations of the changes you make
|
|
11
|
-
|
|
12
|
-
You have access to the entire project directory and can:
|
|
13
|
-
- Navigate the file system
|
|
14
|
-
- Read and analyze existing code
|
|
15
|
-
- Make modifications to implement features or fix bugs
|
|
16
|
-
- Create new files and directories as needed
|
|
17
|
-
- Execute commands to
|
|
18
|
-
|
|
19
|
-
Focus on writing clean, maintainable code that follows the project's established patterns and conventions. Always test your changes when possible and explain what you're doing and why.
|
|
1
|
+
# Code Mode Instructions
|
|
2
|
+
|
|
3
|
+
You are an AI coding assistant with full file system access within the user's project. Your role is to:
|
|
4
|
+
|
|
5
|
+
- Help write, modify, and debug code
|
|
6
|
+
- Understand and work with the existing codebase
|
|
7
|
+
- Follow project conventions and best practices
|
|
8
|
+
- Create, read, update, and delete files as needed to complete coding tasks
|
|
9
|
+
- Run commands and scripts to test and validate changes
|
|
10
|
+
- Provide clear explanations of the changes you make
|
|
11
|
+
|
|
12
|
+
You have access to the entire project directory and can:
|
|
13
|
+
- Navigate the file system
|
|
14
|
+
- Read and analyze existing code
|
|
15
|
+
- Make modifications to implement features or fix bugs
|
|
16
|
+
- Create new files and directories as needed
|
|
17
|
+
- Execute commands to run tests, build the project or run static analysis (lint)
|
|
18
|
+
|
|
19
|
+
Focus on writing clean, maintainable code that follows the project's established patterns and conventions. Always test your changes when possible and explain what you're doing and why.
|
|
20
|
+
|
|
21
|
+
## Running tests
|
|
22
|
+
|
|
23
|
+
- When working on functionality always prefer running a single test, over the entire suite;
|
|
24
|
+
- Abstain from running tests in circles, run the test once, if it fails — inspect the output carefully and try to fix it;
|
|
25
|
+
- Run full tests suite as a penultimate step, when everything is fixed, but before running the lint;
|
|
26
|
+
- Run lint only as a final step when everything else is fixed;
|
|
27
|
+
- If nothing seems to work, ask for user's assistance;
|
|
28
|
+
|
|
29
|
+
## Sequential thinking
|
|
30
|
+
|
|
31
|
+
Use gth_sequential_thinking tool if the problem has multiple steps, or it turns to be complicated,
|
|
32
|
+
but make sure to continue with your task after finishing with the sequential thinking tool.
|
package/.gsloth.guidelines.md
CHANGED
|
@@ -52,6 +52,8 @@ Use [llmUtils.ts](src/llmUtils.ts) to access LLM.
|
|
|
52
52
|
|
|
53
53
|
## Testing (Important)
|
|
54
54
|
|
|
55
|
+
Tests are located in `spec/`; Integration tests are located in `integration-tests/`;
|
|
56
|
+
|
|
55
57
|
- In spec files never import mocked files themselves, mock them, and a tested file should import them.
|
|
56
58
|
- Always import the tested file dynamically within the test.
|
|
57
59
|
- Mocks are hoisted, so it is better to simply place them at the top of the file to avoid confusion.
|
|
@@ -148,8 +150,8 @@ Please follow this workflow:
|
|
|
148
150
|
- Make sure all tests pass `npm run test` and fix if possible.
|
|
149
151
|
- Request relevant documentation if some of the test failures are unclear.
|
|
150
152
|
- Once all tests are green check lint with `npm run lint`.
|
|
151
|
-
- If any lint failures are present try fixing them with `npm run lint
|
|
153
|
+
- If any lint failures are present try fixing them with `npm run lint-n-fix`.
|
|
152
154
|
- If autofix didn't help, try fixing them yourself.
|
|
153
|
-
- Prefer testing all user outputs, including testing absence of unexpected outputs.
|
|
155
|
+
- Prefer testing all user outputs, including testing the absence of unexpected outputs.
|
|
154
156
|
|
|
155
157
|
---
|
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ The promise of Gaunt Sloth:
|
|
|
47
47
|
|
|
48
48
|
### To make GSloth work, you need an **API key** from some AI provider, such as:
|
|
49
49
|
|
|
50
|
+
- OpenRouter
|
|
50
51
|
- Groq;
|
|
51
52
|
- DeepSeek;
|
|
52
53
|
- Google AI Studio and Google Vertex AI;
|
|
@@ -141,7 +142,7 @@ npm install gaunt-sloth-assistant -g
|
|
|
141
142
|
> Note, however, is that project guidelines are going to be used from current directory if they exist and simple install dir prompt is going to be used if nothing found.
|
|
142
143
|
|
|
143
144
|
Configuration can be created with `gsloth init [vendor]` command.
|
|
144
|
-
Currently, anthropic, groq, deepseek, openai, google-genai, vertexai and xai can be configured with `gsloth init [vendor]`.
|
|
145
|
+
Currently, openrouter, anthropic, groq, deepseek, openai, google-genai, vertexai and xai can be configured with `gsloth init [vendor]`.
|
|
145
146
|
For OpenAI-compatible providers like Inception, use `gsloth init openai` and modify the configuration.
|
|
146
147
|
|
|
147
148
|
More detailed information on configuration can be found in [CONFIGURATION.md](./docs/CONFIGURATION.md)
|
|
@@ -164,6 +165,15 @@ gcloud auth login
|
|
|
164
165
|
gcloud auth application-default login
|
|
165
166
|
```
|
|
166
167
|
|
|
168
|
+
### Open Router
|
|
169
|
+
|
|
170
|
+
```shell
|
|
171
|
+
cd ./your-project
|
|
172
|
+
gsloth init openrouter
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Make sure you either define `OPEN_ROUTER_API_KEY` environment variable or edit your configuration file and set up your key.
|
|
176
|
+
|
|
167
177
|
### Anthropic
|
|
168
178
|
|
|
169
179
|
```shell
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
2
2
|
import { GthConfig } from '#src/config.js';
|
|
3
|
+
import { GthCommand } from '#src/core/types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Get default tools based on filesystem and built-in tools configuration
|
|
5
6
|
*/
|
|
6
|
-
export declare function getDefaultTools(config: GthConfig): Promise<StructuredToolInterface[]>;
|
|
7
|
+
export declare function getDefaultTools(config: GthConfig, command?: GthCommand): Promise<StructuredToolInterface[]>;
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import GthFileSystemToolkit from '#src/tools/GthFileSystemToolkit.js';
|
|
2
2
|
import { displayWarning } from '#src/consoleUtils.js';
|
|
3
3
|
import { getCurrentDir } from '#src/systemUtils.js';
|
|
4
|
+
import GthDevToolkit from '#src/tools/GthDevToolkit.js';
|
|
4
5
|
const AVAILABLE_BUILT_IN_TOOLS = {
|
|
5
6
|
gth_status_update: '#src/tools/gthStatusUpdateTool.js',
|
|
6
7
|
gth_jira_log_work: '#src/tools/gthJiraLogWorkTool.js',
|
|
8
|
+
gth_sequential_thinking: '#src/tools/gthSequentialThinkingTool.js',
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
9
11
|
* Get default tools based on filesystem and built-in tools configuration
|
|
10
12
|
*/
|
|
11
|
-
export async function getDefaultTools(config) {
|
|
12
|
-
const filesystemTools = filterFilesystemTools(
|
|
13
|
+
export async function getDefaultTools(config, command) {
|
|
14
|
+
const filesystemTools = filterFilesystemTools(config.filesystem);
|
|
13
15
|
const builtInTools = await getBuiltInTools(config);
|
|
14
|
-
|
|
16
|
+
const devTools = await filterDevTools(command, config.commands?.code?.devTools);
|
|
17
|
+
return [...filesystemTools, ...devTools, ...builtInTools];
|
|
18
|
+
}
|
|
19
|
+
async function filterDevTools(command, devToolConfig) {
|
|
20
|
+
if (command != 'code' || !devToolConfig) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const thinking = await import(AVAILABLE_BUILT_IN_TOOLS.gth_sequential_thinking);
|
|
24
|
+
const toolkit = new GthDevToolkit(devToolConfig);
|
|
25
|
+
return [thinking.get(), ...toolkit.getTools()];
|
|
15
26
|
}
|
|
16
27
|
/**
|
|
17
28
|
* Filter filesystem tools based on configuration
|
|
18
29
|
*/
|
|
19
|
-
function filterFilesystemTools(
|
|
30
|
+
function filterFilesystemTools(filesystemConfig) {
|
|
31
|
+
const toolkit = new GthFileSystemToolkit([getCurrentDir()]);
|
|
20
32
|
if (filesystemConfig === 'all') {
|
|
21
33
|
return toolkit.getTools();
|
|
22
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtInToolsConfig.js","sourceRoot":"","sources":["../src/builtInToolsConfig.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,wBAAwB,GAAG;IAC/B,iBAAi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AAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,eAAe,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,kBAAkB,CAAC,CAAC;IACjE,OAAO,eAAe,CAAC,MAAM,CAC3B,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,CAC3E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,MAAiB;IAC9C,MAAM,KAAK,GAA8B,EAAE,CAAC;IAE5C,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC3C,IAAI,QAAQ,IAAI,wBAAwB,EAAE,CAAC;YACzC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,MAAM,CACvB,wBAAwB,CAAC,QAAiD,CAAC,CAC5E,CAAC;gBACF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,cAAc,CAAC,iCAAiC,QAAQ,MAAM,KAAK,EAAE,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export interface RawGthConfig extends BaseGthConfig {
|
|
|
47
47
|
* This is a basic interface for Gaunt Sloth config.
|
|
48
48
|
*/
|
|
49
49
|
interface BaseGthConfig {
|
|
50
|
+
debugLog?: boolean;
|
|
50
51
|
llm: unknown;
|
|
51
52
|
contentProvider?: string;
|
|
52
53
|
requirementsProvider?: string;
|
|
@@ -86,6 +87,7 @@ interface BaseGthConfig {
|
|
|
86
87
|
code?: {
|
|
87
88
|
filesystem?: string[] | 'all' | 'read' | 'none';
|
|
88
89
|
builtInTools?: string[];
|
|
90
|
+
devTools?: GthDevToolsConfig;
|
|
89
91
|
};
|
|
90
92
|
};
|
|
91
93
|
}
|
|
@@ -93,13 +95,43 @@ export type CustomToolsConfig = Record<string, object>;
|
|
|
93
95
|
export type BuiltInToolsConfig = {
|
|
94
96
|
jira: JiraConfig;
|
|
95
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* Config for {@link GthDevToolkit}.
|
|
100
|
+
* Tools are not applied when config is not provided.
|
|
101
|
+
* Only available in `code` mode.
|
|
102
|
+
*/
|
|
103
|
+
export interface GthDevToolsConfig {
|
|
104
|
+
/**
|
|
105
|
+
* Optional shell command to run tests.
|
|
106
|
+
* Not applied when config is not provided.
|
|
107
|
+
*/
|
|
108
|
+
run_tests?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Optional shell command to run static analysis (lint).
|
|
111
|
+
* Not applied when config is not provided.
|
|
112
|
+
*/
|
|
113
|
+
run_lint?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Optional shell command to run the build.
|
|
116
|
+
* Not applied when config is not provided.
|
|
117
|
+
*/
|
|
118
|
+
run_build?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Optional shell command to run a single test file.
|
|
121
|
+
* Supports command interpolation with the `${testPath}` placeholder.
|
|
122
|
+
* Example: "npm test -- ${testPath}" or "jest ${testPath}"
|
|
123
|
+
* Example: "npm test" - the test will simply be appended
|
|
124
|
+
* Not applied when config is not provided.
|
|
125
|
+
*/
|
|
126
|
+
run_single_test?: string;
|
|
127
|
+
}
|
|
96
128
|
export interface LLMConfig extends Record<string, unknown> {
|
|
97
129
|
type: string;
|
|
98
130
|
model: string;
|
|
99
131
|
configuration: Record<string, unknown>;
|
|
100
132
|
apiKeyEnvironmentVariable?: string;
|
|
101
133
|
}
|
|
102
|
-
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai", "xai"];
|
|
134
|
+
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai", "xai", "openrouter"];
|
|
103
135
|
export type ConfigType = (typeof availableDefaultConfigs)[number];
|
|
104
136
|
export declare function setCustomConfigPath(path: string): void;
|
|
105
137
|
export declare function getCustomConfigPath(): string | undefined;
|
package/dist/config.js
CHANGED
|
@@ -13,6 +13,7 @@ export const availableDefaultConfigs = [
|
|
|
13
13
|
'openai',
|
|
14
14
|
'google-genai',
|
|
15
15
|
'xai',
|
|
16
|
+
'openrouter',
|
|
16
17
|
];
|
|
17
18
|
const configGlobalSettings = {
|
|
18
19
|
customConfigPath: undefined,
|
|
@@ -35,6 +36,7 @@ export const DEFAULT_CONFIG = {
|
|
|
35
36
|
streamOutput: true,
|
|
36
37
|
useColour: true,
|
|
37
38
|
filesystem: 'read',
|
|
39
|
+
debugLog: false,
|
|
38
40
|
commands: {
|
|
39
41
|
pr: {
|
|
40
42
|
contentProvider: 'github', // gh pr diff NN
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,uB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AG,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC,EAAE;KACtE,CAAC;IAEF,yCAAyC;IACzC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAErC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,MAAoB,EAAE,GAAkB;IAC9D,OAAO,WAAW,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GthLangChainAgent } from '#src/core/GthLangChainAgent.js';
|
|
2
2
|
import { executeHooks } from '#src/utils.js';
|
|
3
3
|
import { getNewRunnableConfig } from '#src/llmUtils.js';
|
|
4
|
+
import { initDebugLogging, debugLog, debugLogError, debugLogObject } from '#src/debugUtils.js';
|
|
4
5
|
/**
|
|
5
6
|
* Agent simplifies interaction with LLM and reduces it to calling a few methods
|
|
6
7
|
* {@link #init} and {@link #processMessages}.
|
|
@@ -24,9 +25,13 @@ export class GthAgentRunner {
|
|
|
24
25
|
*/
|
|
25
26
|
async init(command, configIn, checkpointSaver) {
|
|
26
27
|
this.config = configIn;
|
|
28
|
+
// Initialize debug logging
|
|
29
|
+
initDebugLogging(configIn.debugLog ?? false);
|
|
30
|
+
debugLog(`Initializing GthAgentRunner with command: ${command || 'default'}`);
|
|
27
31
|
this.runConfig = this.config.hooks?.createRunnableConfig
|
|
28
32
|
? await this.config.hooks.createRunnableConfig(this.config)
|
|
29
33
|
: getNewRunnableConfig();
|
|
34
|
+
debugLogObject('Runnable Config', this.runConfig);
|
|
30
35
|
this.agent = this.config.hooks?.createAgent
|
|
31
36
|
? await this.config.hooks?.createAgent(this.config)
|
|
32
37
|
: new GthLangChainAgent(this.statusUpdate);
|
|
@@ -35,11 +40,15 @@ export class GthAgentRunner {
|
|
|
35
40
|
this.agent.setVerbose(this.verbose);
|
|
36
41
|
}
|
|
37
42
|
// Call before init hook
|
|
43
|
+
debugLog('Executing beforeAgentInit hooks...');
|
|
38
44
|
await executeHooks(this.config.hooks?.beforeAgentInit, this);
|
|
39
45
|
// Initialize the agent
|
|
46
|
+
debugLog('Initializing agent...');
|
|
40
47
|
await this.agent.init(command, configIn, checkpointSaver);
|
|
41
48
|
// Call after init hook
|
|
49
|
+
debugLog('Executing afterAgentInit hooks...');
|
|
42
50
|
await executeHooks(this.config.hooks?.afterAgentInit, this);
|
|
51
|
+
debugLog('Agent initialization complete');
|
|
43
52
|
}
|
|
44
53
|
/**
|
|
45
54
|
* processMessages deals with both streaming and non-streaming approaches.
|
|
@@ -48,31 +57,41 @@ export class GthAgentRunner {
|
|
|
48
57
|
if (!this.agent || !this.config || !this.runConfig) {
|
|
49
58
|
throw new Error('AgentRunner not initialized. Call init() first.');
|
|
50
59
|
}
|
|
60
|
+
debugLog('Processing messages...');
|
|
61
|
+
debugLogObject('Input Messages', messages);
|
|
51
62
|
await executeHooks(this.config.hooks?.beforeProcessMessages, this, messages, this.runConfig);
|
|
52
63
|
try {
|
|
53
64
|
// Decision: Use streaming or non-streaming based on config
|
|
54
65
|
if (this.config.streamOutput) {
|
|
55
66
|
// Use streaming
|
|
67
|
+
debugLog('Using streaming mode');
|
|
56
68
|
const stream = await this.agent.stream(messages, this.runConfig);
|
|
57
69
|
let result = '';
|
|
58
70
|
try {
|
|
59
71
|
for await (const chunk of stream) {
|
|
72
|
+
debugLogObject('Stream chunk', chunk);
|
|
60
73
|
result += chunk;
|
|
61
74
|
}
|
|
62
75
|
}
|
|
63
76
|
catch (streamError) {
|
|
64
77
|
// Handle streaming-specific errors
|
|
78
|
+
debugLogError('Stream processing', streamError);
|
|
65
79
|
throw new Error(`Stream processing failed: ${streamError instanceof Error ? streamError.message : String(streamError)}`);
|
|
66
80
|
}
|
|
81
|
+
debugLog(`Stream completed. Total response length: ${result.length}`);
|
|
67
82
|
return result;
|
|
68
83
|
}
|
|
69
84
|
else {
|
|
70
85
|
// Use non-streaming
|
|
71
|
-
|
|
86
|
+
debugLog('Using non-streaming mode');
|
|
87
|
+
const result = await this.agent.invoke(messages, this.runConfig);
|
|
88
|
+
debugLog(`Non-stream response length: ${result.length}`);
|
|
89
|
+
return result;
|
|
72
90
|
}
|
|
73
91
|
}
|
|
74
92
|
catch (error) {
|
|
75
93
|
// Handle agent invocation errors
|
|
94
|
+
debugLogError('Agent processing', error);
|
|
76
95
|
throw new Error(`Agent processing failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
77
96
|
}
|
|
78
97
|
}
|
|
@@ -81,11 +100,13 @@ export class GthAgentRunner {
|
|
|
81
100
|
return this.agent;
|
|
82
101
|
}
|
|
83
102
|
async cleanup() {
|
|
103
|
+
debugLog('Cleaning up GthAgentRunner...');
|
|
84
104
|
if (this.agent && 'cleanup' in this.agent && typeof this.agent.cleanup === 'function') {
|
|
85
105
|
await this.agent.cleanup();
|
|
86
106
|
}
|
|
87
107
|
this.agent = null;
|
|
88
108
|
this.config = null;
|
|
109
|
+
debugLog('GthAgentRunner cleanup complete');
|
|
89
110
|
}
|
|
90
111
|
}
|
|
91
112
|
//# sourceMappingURL=GthAgentRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GthAgentRunner.js","sourceRoot":"","sources":["../../src/core/GthAgentRunner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gCAAgC,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"GthAgentRunner.js","sourceRoot":"","sources":["../../src/core/GthAgentRunner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gCAAgC,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,M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;IACH,CAAC;IAED,qCAAqC;IAC9B,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,QAAQ,CAAC,+BAA+B,CAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACtF,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,QAAQ,CAAC,iCAAiC,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -6,6 +6,7 @@ import { getDefaultTools } from '#src/builtInToolsConfig.js';
|
|
|
6
6
|
import { createAuthProviderAndAuthenticate } from '#src/mcp/OAuthClientProviderImpl.js';
|
|
7
7
|
import { displayInfo } from '#src/consoleUtils.js';
|
|
8
8
|
import { IterableReadableStream } from '@langchain/core/utils/stream';
|
|
9
|
+
import { debugLog, debugLogError, debugLogObject } from '#src/debugUtils.js';
|
|
9
10
|
export class GthLangChainAgent {
|
|
10
11
|
statusUpdate;
|
|
11
12
|
verbose = false;
|
|
@@ -14,25 +15,39 @@ export class GthLangChainAgent {
|
|
|
14
15
|
agent = null;
|
|
15
16
|
config = null;
|
|
16
17
|
constructor(statusUpdate) {
|
|
17
|
-
this.statusUpdate =
|
|
18
|
+
this.statusUpdate = (level, message) => {
|
|
19
|
+
statusUpdate(level, message);
|
|
20
|
+
};
|
|
18
21
|
}
|
|
19
22
|
setVerbose(verbose) {
|
|
20
23
|
this.verbose = verbose;
|
|
21
24
|
}
|
|
22
25
|
async init(command, configIn, checkpointSaver) {
|
|
26
|
+
debugLog(`GthLangChainAgent.init called with command: ${command || 'default'}`);
|
|
23
27
|
// Set verbose mode on LLM
|
|
24
28
|
if (this.verbose) {
|
|
25
29
|
configIn.llm.verbose = true;
|
|
30
|
+
debugLog('Verbose mode enabled on LLM');
|
|
26
31
|
}
|
|
27
32
|
// Merge command-specific filesystem config if provided
|
|
28
33
|
this.config = this.getEffectiveConfig(configIn, command);
|
|
34
|
+
debugLogObject('Effective Config', {
|
|
35
|
+
filesystem: this.config.filesystem,
|
|
36
|
+
builtInTools: this.config.builtInTools,
|
|
37
|
+
streamOutput: this.config.streamOutput,
|
|
38
|
+
debugLog: this.config.debugLog,
|
|
39
|
+
});
|
|
29
40
|
this.mcpClient = await this.getMcpClient(this.config);
|
|
30
41
|
// Get default filesystem tools (filtered based on config)
|
|
31
|
-
|
|
42
|
+
debugLog('Loading default tools...');
|
|
43
|
+
const defaultTools = await getDefaultTools(this.config, command);
|
|
44
|
+
debugLog(`Default tools loaded: ${defaultTools.length}`);
|
|
32
45
|
// Get user config tools
|
|
33
46
|
const flattenedConfigTools = this.extractAndFlattenTools(this.config.tools || []);
|
|
47
|
+
debugLog(`User config tools loaded: ${flattenedConfigTools.length}`);
|
|
34
48
|
// Get MCP tools
|
|
35
49
|
const mcpTools = (await this.mcpClient?.getTools()) ?? [];
|
|
50
|
+
debugLog(`MCP tools loaded: ${mcpTools.length}`);
|
|
36
51
|
// Combine all tools
|
|
37
52
|
const tools = [...defaultTools, ...flattenedConfigTools, ...mcpTools];
|
|
38
53
|
if (tools.length > 0) {
|
|
@@ -41,13 +56,17 @@ export class GthLangChainAgent {
|
|
|
41
56
|
.filter((name) => name)
|
|
42
57
|
.join(', ');
|
|
43
58
|
this.statusUpdate('info', `Loaded tools: ${toolNames}`);
|
|
59
|
+
debugLog(`Total tools available: ${tools.length}`);
|
|
60
|
+
debugLogObject('All Tools', toolNames.split(', '));
|
|
44
61
|
}
|
|
45
62
|
// Create the React agent
|
|
63
|
+
debugLog('Creating React agent...');
|
|
46
64
|
this.agent = createReactAgent({
|
|
47
65
|
llm: this.config.llm,
|
|
48
66
|
tools,
|
|
49
67
|
checkpointSaver,
|
|
50
68
|
});
|
|
69
|
+
debugLog('React agent created successfully');
|
|
51
70
|
}
|
|
52
71
|
/**
|
|
53
72
|
* Invoke LLM with a message and runnable config.
|
|
@@ -59,22 +78,31 @@ export class GthLangChainAgent {
|
|
|
59
78
|
if (!this.agent || !this.config) {
|
|
60
79
|
throw new Error('Agent not initialized. Call init() first.');
|
|
61
80
|
}
|
|
81
|
+
debugLog('=== Starting non-streaming invoke ===');
|
|
82
|
+
debugLogObject('LLM Input Messages', messages);
|
|
83
|
+
debugLogObject('Invoke RunConfig', runConfig);
|
|
62
84
|
try {
|
|
63
85
|
const progress = new ProgressIndicator('Thinking.');
|
|
64
86
|
try {
|
|
87
|
+
debugLog('Calling agent.invoke...');
|
|
65
88
|
const response = await this.agent.invoke({ messages }, runConfig);
|
|
89
|
+
debugLog(`Response received with ${response.messages.length} messages`);
|
|
90
|
+
debugLogObject('Full Response', response);
|
|
66
91
|
const aiMessage = response.messages[response.messages.length - 1].content;
|
|
92
|
+
debugLogObject('LLM Response', aiMessage);
|
|
67
93
|
const toolCalls = response.messages
|
|
68
94
|
.filter((msg) => msg.tool_calls && msg.tool_calls.length > 0)
|
|
69
95
|
.flatMap((msg) => msg.tool_calls ?? [])
|
|
70
96
|
.filter((tc) => tc.name);
|
|
71
97
|
if (toolCalls.length > 0) {
|
|
72
|
-
|
|
98
|
+
debugLogObject('Tool Calls', toolCalls);
|
|
99
|
+
this.statusUpdate('info', `\nRequested tools: ${formatToolCalls(toolCalls)}`);
|
|
73
100
|
}
|
|
74
101
|
this.statusUpdate('display', aiMessage);
|
|
75
102
|
return aiMessage;
|
|
76
103
|
}
|
|
77
104
|
catch (e) {
|
|
105
|
+
debugLogError('invoke inner', e);
|
|
78
106
|
if (e instanceof Error && e?.name === 'ToolException') {
|
|
79
107
|
throw e; // Re-throw ToolException to be handled by outer catch
|
|
80
108
|
}
|
|
@@ -86,6 +114,7 @@ export class GthLangChainAgent {
|
|
|
86
114
|
}
|
|
87
115
|
}
|
|
88
116
|
catch (error) {
|
|
117
|
+
debugLogError('invoke outer', error);
|
|
89
118
|
if (error instanceof Error) {
|
|
90
119
|
if (error?.name === 'ToolException') {
|
|
91
120
|
this.statusUpdate('error', `Tool execution failed: ${error?.message}`);
|
|
@@ -103,26 +132,35 @@ export class GthLangChainAgent {
|
|
|
103
132
|
if (!this.agent || !this.config) {
|
|
104
133
|
throw new Error('Agent not initialized. Call init() first.');
|
|
105
134
|
}
|
|
135
|
+
debugLog('=== Starting streaming invoke ===');
|
|
136
|
+
debugLogObject('LLM Input Messages', messages);
|
|
137
|
+
debugLogObject('Stream RunConfig', runConfig);
|
|
106
138
|
this.statusUpdate('info', '\nThinking...\n');
|
|
107
139
|
const stream = await this.agent.stream({ messages }, { ...runConfig, streamMode: 'messages' });
|
|
108
140
|
const statusUpdate = this.statusUpdate;
|
|
109
141
|
return new IterableReadableStream({
|
|
110
142
|
async start(controller) {
|
|
111
143
|
try {
|
|
144
|
+
debugLog('Starting stream processing...');
|
|
145
|
+
let totalChunks = 0;
|
|
112
146
|
for await (const [chunk, _metadata] of stream) {
|
|
147
|
+
debugLogObject('Stream chunk', { chunk, _metadata });
|
|
113
148
|
if (isAIMessage(chunk)) {
|
|
114
149
|
const text = chunk.text;
|
|
150
|
+
totalChunks++;
|
|
115
151
|
statusUpdate('stream', text);
|
|
116
152
|
controller.enqueue(text);
|
|
117
153
|
const toolCalls = chunk.tool_calls?.filter((tc) => tc.name);
|
|
118
154
|
if (toolCalls && toolCalls.length > 0) {
|
|
119
|
-
statusUpdate('info', `\
|
|
155
|
+
statusUpdate('info', `\nRequested tools: ${formatToolCalls(toolCalls)}`);
|
|
120
156
|
}
|
|
121
157
|
}
|
|
122
158
|
}
|
|
159
|
+
debugLog(`Stream completed. Total chunks: ${totalChunks}`);
|
|
123
160
|
controller.close();
|
|
124
161
|
}
|
|
125
162
|
catch (error) {
|
|
163
|
+
debugLogError('stream processing', error);
|
|
126
164
|
if (error instanceof Error) {
|
|
127
165
|
if (error?.name === 'ToolException') {
|
|
128
166
|
statusUpdate('error', `Tool execution failed: ${error?.message}`);
|
|
@@ -144,17 +182,22 @@ export class GthLangChainAgent {
|
|
|
144
182
|
return this.mcpClient;
|
|
145
183
|
}
|
|
146
184
|
async cleanup() {
|
|
185
|
+
debugLog('Cleaning up GthLangChainAgent...');
|
|
147
186
|
if (this.mcpClient) {
|
|
187
|
+
debugLog('Closing MCP client...');
|
|
148
188
|
await this.mcpClient.close();
|
|
149
189
|
this.mcpClient = null;
|
|
150
190
|
}
|
|
151
191
|
this.agent = null;
|
|
152
192
|
this.config = null;
|
|
193
|
+
debugLog('GthLangChainAgent cleanup complete');
|
|
153
194
|
}
|
|
154
195
|
getEffectiveConfig(config, command) {
|
|
196
|
+
debugLog(`Getting effective config for command: ${command || 'default'}`);
|
|
155
197
|
const supportsTools = !!config.llm.bindTools;
|
|
156
198
|
if (!supportsTools) {
|
|
157
199
|
this.statusUpdate('warning', 'Model does not seem to support tools.');
|
|
200
|
+
debugLog('Warning: Model does not support tools');
|
|
158
201
|
}
|
|
159
202
|
return {
|
|
160
203
|
...config,
|
|
@@ -188,9 +231,11 @@ export class GthLangChainAgent {
|
|
|
188
231
|
return {};
|
|
189
232
|
}
|
|
190
233
|
async getMcpClient(config) {
|
|
234
|
+
debugLog('Setting up MCP client...');
|
|
191
235
|
const defaultServers = this.getDefaultMcpServers();
|
|
192
236
|
// Merge with user's mcpServers
|
|
193
237
|
const rawMcpServers = { ...defaultServers, ...(config.mcpServers || {}) };
|
|
238
|
+
debugLog(`MCP servers count: ${Object.keys(rawMcpServers).length}`);
|
|
194
239
|
const mcpServers = {};
|
|
195
240
|
for (const serverName of Object.keys(rawMcpServers)) {
|
|
196
241
|
const server = rawMcpServers[serverName];
|
|
@@ -209,6 +254,7 @@ export class GthLangChainAgent {
|
|
|
209
254
|
}
|
|
210
255
|
}
|
|
211
256
|
if (Object.keys(mcpServers).length > 0) {
|
|
257
|
+
debugLog('Creating MultiServerMCPClient...');
|
|
212
258
|
return new MultiServerMCPClient({
|
|
213
259
|
throwOnLoadError: true,
|
|
214
260
|
prefixToolNameWithServerName: true,
|
|
@@ -217,6 +263,7 @@ export class GthLangChainAgent {
|
|
|
217
263
|
});
|
|
218
264
|
}
|
|
219
265
|
else {
|
|
266
|
+
debugLog('No MCP servers configured');
|
|
220
267
|
return null;
|
|
221
268
|
}
|
|
222
269
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GthLangChainAgent.js","sourceRoot":"","sources":["../../src/core/GthLangChainAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"GthLangChainAgent.js","sourceRoot":"","sources":["../../src/core/GthLangChainAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EA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