gaunt-sloth-assistant 0.9.0 → 0.9.2
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/cli.js +17 -12
- package/dist/cli.js.map +1 -1
- package/dist/commands/askCommand.d.ts +3 -1
- package/dist/commands/askCommand.js +3 -2
- package/dist/commands/askCommand.js.map +1 -1
- package/dist/commands/chatCommand.d.ts +2 -1
- package/dist/commands/chatCommand.js +3 -3
- package/dist/commands/chatCommand.js.map +1 -1
- package/dist/commands/codeCommand.d.ts +2 -1
- package/dist/commands/codeCommand.js +2 -2
- package/dist/commands/codeCommand.js.map +1 -1
- package/dist/commands/prCommand.d.ts +2 -1
- package/dist/commands/prCommand.js +2 -2
- package/dist/commands/prCommand.js.map +1 -1
- package/dist/commands/reviewCommand.d.ts +2 -1
- package/dist/commands/reviewCommand.js +2 -2
- package/dist/commands/reviewCommand.js.map +1 -1
- package/dist/config.d.ts +41 -6
- package/dist/config.js +37 -34
- package/dist/config.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +0 -2
- package/dist/core/GthAgentRunner.js +0 -8
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +0 -2
- package/dist/core/GthLangChainAgent.js +2 -9
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/llmUtils.d.ts +0 -1
- package/dist/llmUtils.js +0 -8
- package/dist/llmUtils.js.map +1 -1
- package/dist/modules/interactiveSessionModule.d.ts +2 -1
- package/dist/modules/interactiveSessionModule.js +4 -4
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/presets/anthropic.d.ts +15 -0
- package/dist/presets/anthropic.js +48 -2
- package/dist/presets/anthropic.js.map +1 -1
- package/package.json +7 -7
package/dist/cli.js
CHANGED
|
@@ -7,32 +7,37 @@ import { chatCommand } from '#src/commands/chatCommand.js';
|
|
|
7
7
|
import { codeCommand } from '#src/commands/codeCommand.js';
|
|
8
8
|
import { getSlothVersion } from '#src/utils.js';
|
|
9
9
|
import { argv, readStdin } from '#src/systemUtils.js';
|
|
10
|
-
import { setVerbose } from '#src/llmUtils.js';
|
|
11
|
-
import { setCustomConfigPath } from '#src/config.js';
|
|
12
10
|
const program = new Command();
|
|
13
11
|
program
|
|
14
12
|
.name('gsloth')
|
|
15
13
|
.description('Gaunt Sloth Assistant reviewing your PRs')
|
|
16
14
|
.version(getSlothVersion())
|
|
17
|
-
.option('--verbose', '
|
|
15
|
+
.option('--verbose', 'Set LangChain/LangGraph to verbose mode, ' +
|
|
16
|
+
'causing LangChain/LangGraph to log many details to the console. ' +
|
|
17
|
+
'Consider using debugLog from config.ts for less intrusive debug logging.')
|
|
18
18
|
.option('-c, --config <path>', 'Path to custom configuration file')
|
|
19
19
|
.addOption(new Option('--nopipe').hideHelp(true));
|
|
20
|
+
const cliConfigOverrides = {};
|
|
20
21
|
// Parse global options before binding any commands
|
|
21
22
|
program.parseOptions(argv);
|
|
22
23
|
if (program.getOptionValue('verbose')) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Set LangChain/LangGraph to verbose mode,
|
|
26
|
+
* causing LangChain/LangGraph to log many details to the console.
|
|
27
|
+
* debugLog from config.ts may be a less intrusive option.
|
|
28
|
+
*/
|
|
29
|
+
cliConfigOverrides.verbose = true;
|
|
25
30
|
}
|
|
26
31
|
if (program.getOptionValue('config')) {
|
|
27
|
-
// Set custom config path
|
|
28
|
-
|
|
32
|
+
// Set a custom config path
|
|
33
|
+
cliConfigOverrides.customConfigPath = program.getOptionValue('config');
|
|
29
34
|
}
|
|
30
35
|
// Initialize all commands - they will handle their own config loading
|
|
31
36
|
initCommand(program);
|
|
32
|
-
reviewCommand(program);
|
|
33
|
-
prCommand(program);
|
|
34
|
-
askCommand(program);
|
|
35
|
-
chatCommand(program);
|
|
36
|
-
codeCommand(program);
|
|
37
|
+
reviewCommand(program, cliConfigOverrides);
|
|
38
|
+
prCommand(program, cliConfigOverrides);
|
|
39
|
+
askCommand(program, cliConfigOverrides);
|
|
40
|
+
chatCommand(program, cliConfigOverrides);
|
|
41
|
+
codeCommand(program, cliConfigOverrides);
|
|
37
42
|
await readStdin(program);
|
|
38
43
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO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-1,6 +1,8 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { CommandLineConfigOverrides } from '#src/config.js';
|
|
2
3
|
/**
|
|
3
4
|
* Adds the ask command to the program
|
|
4
5
|
* @param program - The commander program
|
|
6
|
+
* @param commandLineConfigOverrides - command line config overrides
|
|
5
7
|
*/
|
|
6
|
-
export declare function askCommand(program: Command): void;
|
|
8
|
+
export declare function askCommand(program: Command, commandLineConfigOverrides: CommandLineConfigOverrides): void;
|
|
@@ -5,15 +5,16 @@ import { getStringFromStdin } from '#src/systemUtils.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Adds the ask command to the program
|
|
7
7
|
* @param program - The commander program
|
|
8
|
+
* @param commandLineConfigOverrides - command line config overrides
|
|
8
9
|
*/
|
|
9
|
-
export function askCommand(program) {
|
|
10
|
+
export function askCommand(program, commandLineConfigOverrides) {
|
|
10
11
|
program
|
|
11
12
|
.command('ask')
|
|
12
13
|
.description('Ask a question')
|
|
13
14
|
.argument('[message]', 'A message')
|
|
14
15
|
.option('-f, --file [files...]', 'Input files. Content of these files will be added BEFORE the message')
|
|
15
16
|
.action(async (message, options) => {
|
|
16
|
-
const config = await initConfig();
|
|
17
|
+
const config = await initConfig(commandLineConfigOverrides);
|
|
17
18
|
const systemPrompt = readSystemPrompt();
|
|
18
19
|
const preamble = [readBackstory(), readGuidelines(config.projectGuidelines)];
|
|
19
20
|
if (systemPrompt) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"askCommand.js","sourceRoot":"","sources":["../../src/commands/askCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"askCommand.js","sourceRoot":"","sources":["../../src/commands/askCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,E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C,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;QACxF,CAAC;QAED,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,yCAAyC,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
|
|
2
|
+
import { CommandLineConfigOverrides } from '#src/config.js';
|
|
3
|
+
export declare function chatCommand(program: Command, commandLineConfigOverrides: CommandLineConfigOverrides): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInteractiveSession } from '#src/modules/interactiveSessionModule.js';
|
|
2
2
|
import { readChatPrompt } from '#src/prompt.js';
|
|
3
|
-
export function chatCommand(program) {
|
|
3
|
+
export function chatCommand(program, commandLineConfigOverrides) {
|
|
4
4
|
const sessionConfig = {
|
|
5
5
|
mode: 'chat',
|
|
6
6
|
readModePrompt: readChatPrompt,
|
|
@@ -10,7 +10,7 @@ export function chatCommand(program) {
|
|
|
10
10
|
};
|
|
11
11
|
// Start chat when no command typed
|
|
12
12
|
program.action(async () => {
|
|
13
|
-
await createInteractiveSession(sessionConfig);
|
|
13
|
+
await createInteractiveSession(sessionConfig, commandLineConfigOverrides);
|
|
14
14
|
});
|
|
15
15
|
// Chat command
|
|
16
16
|
program
|
|
@@ -18,7 +18,7 @@ export function chatCommand(program) {
|
|
|
18
18
|
.description('Start an interactive chat session with Gaunt Sloth')
|
|
19
19
|
.argument('[message]', 'Initial message to start the chat')
|
|
20
20
|
.action(async (message) => {
|
|
21
|
-
await createInteractiveSession(sessionConfig, message);
|
|
21
|
+
await createInteractiveSession(sessionConfig, commandLineConfigOverrides, message);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=chatCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatCommand.js","sourceRoot":"","sources":["../../src/commands/chatCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAiB,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"chatCommand.js","sourceRoot":"","sources":["../../src/commands/chatCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAiB,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,UAAU,WAAW,CACzB,OAAgB,EAChB,0BAAsD;IAEtD,MAAM,aAAa,GAAkB;QACnC,IAAI,EAAE,MAAM;QACZ,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,oDAAoD;QACjE,YAAY,EAAE,mDAAmD;QACjE,WAAW,EAAE,0CAA0C;KACxD,CAAC;IACF,mCAAmC;IACnC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACxB,MAAM,wBAAwB,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,eAAe;IACf,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,oDAAoD,CAAC;SACjE,QAAQ,CAAC,WAAW,EAAE,mCAAmC,CAAC;SAC1D,MAAM,CAAC,KAAK,EAAE,OAAe,EAAE,EAAE;QAChC,MAAM,wBAAwB,CAAC,aAAa,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
|
|
2
|
+
import { CommandLineConfigOverrides } from '#src/config.js';
|
|
3
|
+
export declare function codeCommand(program: Command, commandLineConfigOverrides: CommandLineConfigOverrides): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInteractiveSession } from '#src/modules/interactiveSessionModule.js';
|
|
2
2
|
import { readCodePrompt } from '#src/prompt.js';
|
|
3
|
-
export function codeCommand(program) {
|
|
3
|
+
export function codeCommand(program, commandLineConfigOverrides) {
|
|
4
4
|
program
|
|
5
5
|
.command('code')
|
|
6
6
|
.description('Interactively write code with sloth (has full file system access within your project)')
|
|
@@ -13,7 +13,7 @@ export function codeCommand(program) {
|
|
|
13
13
|
readyMessage: '\nGaunt Sloth is ready to code. Type your prompt.',
|
|
14
14
|
exitMessage: "Type 'exit' or hit Ctrl+C to exit code session\n",
|
|
15
15
|
};
|
|
16
|
-
await createInteractiveSession(sessionConfig, message);
|
|
16
|
+
await createInteractiveSession(sessionConfig, commandLineConfigOverrides, message);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=codeCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeCommand.js","sourceRoot":"","sources":["../../src/commands/codeCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAiB,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"codeCommand.js","sourceRoot":"","sources":["../../src/commands/codeCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAiB,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,UAAU,WAAW,CACzB,OAAgB,EAChB,0BAAsD;IAEtD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,uFAAuF,CACxF;SACA,QAAQ,CAAC,WAAW,EAAE,2CAA2C,CAAC;SAClE,MAAM,CAAC,KAAK,EAAE,OAAe,EAAE,EAAE;QAChC,MAAM,aAAa,GAAkB;YACnC,IAAI,EAAE,MAAM;YACZ,cAAc,EAAE,cAAc;YAC9B,WAAW,EACT,uFAAuF;YACzF,YAAY,EAAE,mDAAmD;YACjE,WAAW,EAAE,kDAAkD;SAChE,CAAC;QAEF,MAAM,wBAAwB,CAAC,aAAa,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
|
|
2
|
+
import { CommandLineConfigOverrides } from '#src/config.js';
|
|
3
|
+
export declare function prCommand(program: Command, commandLineConfigOverrides: CommandLineConfigOverrides): void;
|
|
@@ -3,7 +3,7 @@ import { readBackstory, readGuidelines, readReviewInstructions, readSystemPrompt
|
|
|
3
3
|
import { readMultipleFilesFromCurrentDir } from '#src/utils.js';
|
|
4
4
|
import { CONTENT_PROVIDERS, getRequirementsFromProvider, REQUIREMENTS_PROVIDERS, } from './commandUtils.js';
|
|
5
5
|
import jiraLogWork from '#src/helpers/jira/jiraLogWork.js';
|
|
6
|
-
export function prCommand(program) {
|
|
6
|
+
export function prCommand(program, commandLineConfigOverrides) {
|
|
7
7
|
program
|
|
8
8
|
.command('pr')
|
|
9
9
|
.description('Review provided Pull Request in current directory. ' +
|
|
@@ -16,7 +16,7 @@ export function prCommand(program) {
|
|
|
16
16
|
.option('-m, --message <message>', 'Extra message to provide just before the content')
|
|
17
17
|
.action(async (prId, requirementsId, options) => {
|
|
18
18
|
const { initConfig } = await import('#src/config.js');
|
|
19
|
-
const config = await initConfig(); // Initialize and get config
|
|
19
|
+
const config = await initConfig(commandLineConfigOverrides); // Initialize and get config
|
|
20
20
|
const systemPrompt = readSystemPrompt();
|
|
21
21
|
const systemMessage = [
|
|
22
22
|
readBackstory(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prCommand.js","sourceRoot":"","sources":["../../src/commands/prCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EACL,iBAAiB,EAEjB,2BAA2B,EAC3B,sBAAsB,GAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,WAAW,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"prCommand.js","sourceRoot":"","sources":["../../src/commands/prCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EACL,iBAAiB,EAEjB,2BAA2B,EAC3B,sBAAsB,GAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAU3D,MAAM,UAAU,SAAS,CACvB,OAAgB,EAChB,0BAAsD;IAEtD,OAAO;SACJ,OAAO,CAAC,IAAI,CAAC;SACb,WAAW,CACV,qDAAqD;QACnD,iFAAiF;QACjF,8EAA8E,CACjF;SACA,QAAQ,CAAC,QAAQ,EAAE,4BAA4B,CAAC;SAChD,QAAQ,CACP,kBAAkB,EAClB,uFAAuF,CACxF;SACA,SAAS,CACR,IAAI,MAAM,CACR,oDAAoD,EACpD,wCAAwC,CACzC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAC/C;SACA,MAAM,CACL,uBAAuB,EACvB,2FAA2F,CAC5F;SACA,MAAM,CAAC,yBAAyB,EAAE,kDAAkD,CAAC;SACrF,MAAM,CAAC,KAAK,EAAE,I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CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAEpC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAChE,0CAA0C;QAC1C,qBAAqB;QACrB,MAAM,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAEvF,IACE,cAAc;YACd,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,oBAAoB,IAAI,MAAM,CAAC,oBAAoB,CAAC,KAAK,MAAM;YACrF,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,yBAAyB,EAC9C,CAAC;YACD,0DAA0D;YAC1D,IAAI,UAAU,GACZ,MAAM,CAAC,kBAAkB,EAAE,IAAI;gBAC9B,MAAM,CAAC,0BAA0B,EAAE,IAAmB,CAAC;YAC1D,MAAM,WAAW,CACf,UAAU,EACV,cAAc,EACd,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,yBAAyB,EAC9C,aAAa,CACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
|
|
2
|
+
import { CommandLineConfigOverrides } from '#src/config.js';
|
|
3
|
+
export declare function reviewCommand(program: Command, cliConfigOverrides: CommandLineConfigOverrides): void;
|
|
@@ -3,7 +3,7 @@ import { readBackstory, readGuidelines, readReviewInstructions, readSystemPrompt
|
|
|
3
3
|
import { readMultipleFilesFromCurrentDir } from '#src/utils.js';
|
|
4
4
|
import { getStringFromStdin } from '#src/systemUtils.js';
|
|
5
5
|
import { REQUIREMENTS_PROVIDERS, CONTENT_PROVIDERS, getRequirementsFromProvider, getContentFromProvider, } from './commandUtils.js';
|
|
6
|
-
export function reviewCommand(program) {
|
|
6
|
+
export function reviewCommand(program, cliConfigOverrides) {
|
|
7
7
|
program
|
|
8
8
|
.command('review')
|
|
9
9
|
.description('Review provided diff or other content')
|
|
@@ -18,7 +18,7 @@ export function reviewCommand(program) {
|
|
|
18
18
|
.option('-m, --message <message>', 'Extra message to provide just before the content')
|
|
19
19
|
.action(async (contentId, options) => {
|
|
20
20
|
const { initConfig } = await import('#src/config.js');
|
|
21
|
-
const config = await initConfig(); // Initialize and get config
|
|
21
|
+
const config = await initConfig(cliConfigOverrides); // Initialize and get config
|
|
22
22
|
const systemPrompt = readSystemPrompt();
|
|
23
23
|
const systemMessage = [
|
|
24
24
|
readBackstory(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewCommand.js","sourceRoot":"","sources":["../../src/commands/reviewCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EAGjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"reviewCommand.js","sourceRoot":"","sources":["../../src/commands/reviewCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,gBAAg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AAG,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAChE,MAAM,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { GthAgentInterface } from '#src/core/types.js';
|
|
|
6
6
|
import type { GthAgentRunner } from '#src/core/GthAgentRunner.js';
|
|
7
7
|
import type { Message } from '#src/modules/types.js';
|
|
8
8
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
9
|
+
import { StateDefinition, StateType } from '@langchain/langgraph';
|
|
9
10
|
/**
|
|
10
11
|
* This is a processed Gaunt Sloth config ready to be passed down into components.
|
|
11
12
|
*/
|
|
@@ -19,7 +20,7 @@ export interface GthConfig extends BaseGthConfig {
|
|
|
19
20
|
useColour: boolean;
|
|
20
21
|
filesystem: string[] | 'all' | 'read' | 'none';
|
|
21
22
|
builtInTools?: string[];
|
|
22
|
-
tools?: StructuredToolInterface[] | BaseToolkit[];
|
|
23
|
+
tools?: StructuredToolInterface[] | BaseToolkit[] | ServerTool[];
|
|
23
24
|
/**
|
|
24
25
|
* Hooks are only available on JS config
|
|
25
26
|
*/
|
|
@@ -32,8 +33,29 @@ export interface GthConfig extends BaseGthConfig {
|
|
|
32
33
|
*/
|
|
33
34
|
afterAgentInit?: RunnerHook | RunnerHook[];
|
|
34
35
|
beforeProcessMessages?: BeforeMessageHook | BeforeMessageHook[];
|
|
36
|
+
/**
|
|
37
|
+
* LangGraph preModelHook
|
|
38
|
+
* Provide 'skip' if you don't need default hook.
|
|
39
|
+
*/
|
|
40
|
+
preModelHook?: LangChainHook;
|
|
41
|
+
/**
|
|
42
|
+
* LangGraph postModelHook
|
|
43
|
+
* Provide 'skip' if you don't need default hook.
|
|
44
|
+
*/
|
|
45
|
+
postModelHook?: LangChainHook;
|
|
35
46
|
};
|
|
36
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Server tools such as Anthropic Web Search.
|
|
50
|
+
* These tools are meant to be magic objects like
|
|
51
|
+
* `{"type": "web_search_20250305", "name": "web_search", "max_uses": 10}`,
|
|
52
|
+
* AI Provider does the rest of the magic on their side.
|
|
53
|
+
*/
|
|
54
|
+
export interface ServerTool extends Record<string, unknown> {
|
|
55
|
+
type: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
}
|
|
58
|
+
type LangChainHook = (state: StateType<StateDefinition>) => StateType<StateDefinition>;
|
|
37
59
|
type RunnerHook = (runner: GthAgentRunner) => Promise<void>;
|
|
38
60
|
type BeforeMessageHook = (runner: GthAgentRunner, message: Message[], runConfig: RunnableConfig) => Promise<void>;
|
|
39
61
|
/**
|
|
@@ -41,6 +63,8 @@ type BeforeMessageHook = (runner: GthAgentRunner, message: Message[], runConfig:
|
|
|
41
63
|
*/
|
|
42
64
|
export interface RawGthConfig extends BaseGthConfig {
|
|
43
65
|
llm: LLMConfig;
|
|
66
|
+
preModelHook?: LangChainHook | 'skip';
|
|
67
|
+
postModelHook?: LangChainHook | 'skip';
|
|
44
68
|
}
|
|
45
69
|
/**
|
|
46
70
|
* Do not export this one.
|
|
@@ -62,6 +86,7 @@ interface BaseGthConfig {
|
|
|
62
86
|
mcpServers?: Record<string, Connection>;
|
|
63
87
|
builtInTools?: string[];
|
|
64
88
|
builtInToolsConfig?: BuiltInToolsConfig;
|
|
89
|
+
tools?: StructuredToolInterface[] | BaseToolkit[] | ServerTool[];
|
|
65
90
|
commands?: {
|
|
66
91
|
pr?: {
|
|
67
92
|
contentProvider?: string;
|
|
@@ -133,21 +158,31 @@ export interface LLMConfig extends Record<string, unknown> {
|
|
|
133
158
|
}
|
|
134
159
|
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai", "xai", "openrouter"];
|
|
135
160
|
export type ConfigType = (typeof availableDefaultConfigs)[number];
|
|
136
|
-
export
|
|
137
|
-
|
|
138
|
-
|
|
161
|
+
export interface CommandLineConfigOverrides {
|
|
162
|
+
/**
|
|
163
|
+
* Custom config path
|
|
164
|
+
*/
|
|
165
|
+
customConfigPath?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Set LangChain/LangGraph to verbose mode,
|
|
168
|
+
* causing LangChain/LangGraph to log many details to the console.
|
|
169
|
+
* debugLog from config.ts may be a less intrusive option.
|
|
170
|
+
*/
|
|
171
|
+
verbose?: boolean;
|
|
172
|
+
}
|
|
139
173
|
export declare const DEFAULT_CONFIG: Partial<GthConfig>;
|
|
140
174
|
/**
|
|
141
175
|
* Initialize configuration by loading from available config files
|
|
142
176
|
* @returns The loaded GthConfig
|
|
143
177
|
*/
|
|
144
|
-
export declare function initConfig(): Promise<GthConfig>;
|
|
178
|
+
export declare function initConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
|
|
145
179
|
/**
|
|
146
180
|
* Process JSON LLM config by creating the appropriate LLM instance
|
|
147
181
|
* @param jsonConfig - The parsed JSON config
|
|
182
|
+
* @param commandLineConfigOverrides - command line config overrides
|
|
148
183
|
* @returns Promise<GthConfig>
|
|
149
184
|
*/
|
|
150
|
-
export declare function tryJsonConfig(jsonConfig: RawGthConfig): Promise<GthConfig>;
|
|
185
|
+
export declare function tryJsonConfig(jsonConfig: RawGthConfig, commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
|
|
151
186
|
export declare function createProjectConfig(configType: string): Promise<void>;
|
|
152
187
|
export declare function writeProjectReviewPreamble(): void;
|
|
153
188
|
export {};
|
package/dist/config.js
CHANGED
|
@@ -4,7 +4,6 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
4
4
|
import { error, exit, setUseColour } from '#src/systemUtils.js';
|
|
5
5
|
import { getGslothConfigReadPath, getGslothConfigWritePath } from '#src/filePathUtils.js';
|
|
6
6
|
import { PROJECT_GUIDELINES, PROJECT_REVIEW_INSTRUCTIONS, USER_PROJECT_CONFIG_JS, USER_PROJECT_CONFIG_JSON, USER_PROJECT_CONFIG_MJS, } from '#src/constants.js';
|
|
7
|
-
import { resolve } from 'node:path';
|
|
8
7
|
export const availableDefaultConfigs = [
|
|
9
8
|
'vertexai',
|
|
10
9
|
'anthropic',
|
|
@@ -15,18 +14,6 @@ export const availableDefaultConfigs = [
|
|
|
15
14
|
'xai',
|
|
16
15
|
'openrouter',
|
|
17
16
|
];
|
|
18
|
-
const configGlobalSettings = {
|
|
19
|
-
customConfigPath: undefined,
|
|
20
|
-
};
|
|
21
|
-
export function setCustomConfigPath(path) {
|
|
22
|
-
configGlobalSettings.customConfigPath = resolve(path);
|
|
23
|
-
}
|
|
24
|
-
export function getCustomConfigPath() {
|
|
25
|
-
return configGlobalSettings.customConfigPath;
|
|
26
|
-
}
|
|
27
|
-
export function clearCustomConfigPath() {
|
|
28
|
-
configGlobalSettings.customConfigPath = undefined;
|
|
29
|
-
}
|
|
30
17
|
export const DEFAULT_CONFIG = {
|
|
31
18
|
llm: undefined,
|
|
32
19
|
contentProvider: 'file',
|
|
@@ -36,6 +23,10 @@ export const DEFAULT_CONFIG = {
|
|
|
36
23
|
streamOutput: true,
|
|
37
24
|
useColour: true,
|
|
38
25
|
filesystem: 'read',
|
|
26
|
+
/**
|
|
27
|
+
* Log messages and events to gaunt-sloth.log,
|
|
28
|
+
* use llm.verbose or `gth --verbose` as more intrusive option, setting verbose to LangChain / LangGraph
|
|
29
|
+
*/
|
|
39
30
|
debugLog: false,
|
|
40
31
|
commands: {
|
|
41
32
|
pr: {
|
|
@@ -51,11 +42,13 @@ export const DEFAULT_CONFIG = {
|
|
|
51
42
|
* Initialize configuration by loading from available config files
|
|
52
43
|
* @returns The loaded GthConfig
|
|
53
44
|
*/
|
|
54
|
-
export async function initConfig() {
|
|
55
|
-
if (
|
|
56
|
-
|
|
45
|
+
export async function initConfig(commandLineConfigOverrides) {
|
|
46
|
+
if (commandLineConfigOverrides.customConfigPath &&
|
|
47
|
+
!existsSync(commandLineConfigOverrides.customConfigPath)) {
|
|
48
|
+
throw new Error(`Provided manual config "${commandLineConfigOverrides.customConfigPath}" does not exist`);
|
|
57
49
|
}
|
|
58
|
-
const jsonConfigPath =
|
|
50
|
+
const jsonConfigPath = commandLineConfigOverrides.customConfigPath ??
|
|
51
|
+
getGslothConfigReadPath(USER_PROJECT_CONFIG_JSON);
|
|
59
52
|
// Try loading the JSON config file first
|
|
60
53
|
if (jsonConfigPath.endsWith('.json') && existsSync(jsonConfigPath)) {
|
|
61
54
|
try {
|
|
@@ -63,7 +56,7 @@ export async function initConfig() {
|
|
|
63
56
|
const jsonConfig = JSON.parse(readFileSync(jsonConfigPath, 'utf8'));
|
|
64
57
|
// If the config has an LLM with a type, create the appropriate LLM instance
|
|
65
58
|
if (jsonConfig.llm && typeof jsonConfig.llm === 'object' && 'type' in jsonConfig.llm) {
|
|
66
|
-
return await tryJsonConfig(jsonConfig);
|
|
59
|
+
return await tryJsonConfig(jsonConfig, commandLineConfigOverrides);
|
|
67
60
|
}
|
|
68
61
|
else {
|
|
69
62
|
error(`${jsonConfigPath} is not in valid format. Should at least define llm.type`);
|
|
@@ -78,43 +71,43 @@ export async function initConfig() {
|
|
|
78
71
|
displayDebug(e instanceof Error ? e : String(e));
|
|
79
72
|
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JSON}, will try other formats.`);
|
|
80
73
|
// Continue to try other formats
|
|
81
|
-
return tryJsConfig();
|
|
74
|
+
return tryJsConfig(commandLineConfigOverrides);
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
77
|
else {
|
|
85
78
|
// JSON config not found, try JS
|
|
86
|
-
return tryJsConfig();
|
|
79
|
+
return tryJsConfig(commandLineConfigOverrides);
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
82
|
// Helper function to try loading JS config
|
|
90
|
-
async function tryJsConfig() {
|
|
91
|
-
const jsConfigPath =
|
|
83
|
+
async function tryJsConfig(commandLineConfigOverrides) {
|
|
84
|
+
const jsConfigPath = commandLineConfigOverrides.customConfigPath ?? getGslothConfigReadPath(USER_PROJECT_CONFIG_JS);
|
|
92
85
|
if (jsConfigPath.endsWith('.js') && existsSync(jsConfigPath)) {
|
|
93
86
|
try {
|
|
94
87
|
const i = await importExternalFile(jsConfigPath);
|
|
95
88
|
const customConfig = await i.configure();
|
|
96
|
-
return mergeConfig(customConfig);
|
|
89
|
+
return mergeConfig(customConfig, commandLineConfigOverrides);
|
|
97
90
|
}
|
|
98
91
|
catch (e) {
|
|
99
92
|
displayDebug(e instanceof Error ? e : String(e));
|
|
100
93
|
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JS}, will try other formats.`);
|
|
101
94
|
// Continue to try other formats
|
|
102
|
-
return tryMjsConfig();
|
|
95
|
+
return tryMjsConfig(commandLineConfigOverrides);
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
98
|
else {
|
|
106
99
|
// JS config not found, try MJS
|
|
107
|
-
return tryMjsConfig();
|
|
100
|
+
return tryMjsConfig(commandLineConfigOverrides);
|
|
108
101
|
}
|
|
109
102
|
}
|
|
110
103
|
// Helper function to try loading MJS config
|
|
111
|
-
async function tryMjsConfig() {
|
|
112
|
-
const mjsConfigPath =
|
|
104
|
+
async function tryMjsConfig(commandLineConfigOverrides) {
|
|
105
|
+
const mjsConfigPath = commandLineConfigOverrides.customConfigPath ?? getGslothConfigReadPath(USER_PROJECT_CONFIG_MJS);
|
|
113
106
|
if (mjsConfigPath.endsWith('.mjs') && existsSync(mjsConfigPath)) {
|
|
114
107
|
try {
|
|
115
108
|
const i = await importExternalFile(mjsConfigPath);
|
|
116
109
|
const customConfig = await i.configure();
|
|
117
|
-
return mergeConfig(customConfig);
|
|
110
|
+
return mergeConfig(customConfig, commandLineConfigOverrides);
|
|
118
111
|
}
|
|
119
112
|
catch (e) {
|
|
120
113
|
displayDebug(e instanceof Error ? e : String(e));
|
|
@@ -136,12 +129,13 @@ async function tryMjsConfig() {
|
|
|
136
129
|
/**
|
|
137
130
|
* Process JSON LLM config by creating the appropriate LLM instance
|
|
138
131
|
* @param jsonConfig - The parsed JSON config
|
|
132
|
+
* @param commandLineConfigOverrides - command line config overrides
|
|
139
133
|
* @returns Promise<GthConfig>
|
|
140
134
|
*/
|
|
141
|
-
export async function tryJsonConfig(jsonConfig) {
|
|
135
|
+
export async function tryJsonConfig(jsonConfig, commandLineConfigOverrides) {
|
|
142
136
|
try {
|
|
143
137
|
if (jsonConfig.llm && typeof jsonConfig.llm === 'object') {
|
|
144
|
-
// Get the type of LLM (e.g
|
|
138
|
+
// Get the type of LLM (e.g. 'vertexai', 'anthropic') - this should exist
|
|
145
139
|
const llmType = jsonConfig.llm.type;
|
|
146
140
|
if (!llmType) {
|
|
147
141
|
displayError('LLM type not specified in config.');
|
|
@@ -153,7 +147,13 @@ export async function tryJsonConfig(jsonConfig) {
|
|
|
153
147
|
const configModule = await import(`./presets/${llmType}.js`);
|
|
154
148
|
if (configModule.processJsonConfig) {
|
|
155
149
|
const llm = (await configModule.processJsonConfig(llmConfig));
|
|
156
|
-
|
|
150
|
+
const mergedConfig = mergeRawConfig(jsonConfig, llm, commandLineConfigOverrides);
|
|
151
|
+
if (configModule.postProcessJsonConfig) {
|
|
152
|
+
return configModule.postProcessJsonConfig(mergedConfig);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return mergedConfig;
|
|
156
|
+
}
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
159
|
displayWarning(`Config module for ${llmType} does not have processJsonConfig function.`);
|
|
@@ -233,13 +233,16 @@ Important! You are likely to be dealing with git diff below, please don't confus
|
|
|
233
233
|
/**
|
|
234
234
|
* Merge config with default config
|
|
235
235
|
*/
|
|
236
|
-
function mergeConfig(partialConfig) {
|
|
236
|
+
function mergeConfig(partialConfig, commandLineConfigOverrides) {
|
|
237
237
|
const config = partialConfig;
|
|
238
238
|
const mergedConfig = {
|
|
239
239
|
...DEFAULT_CONFIG,
|
|
240
240
|
...config,
|
|
241
241
|
commands: { ...DEFAULT_CONFIG.commands, ...(config?.commands ?? {}) },
|
|
242
242
|
};
|
|
243
|
+
if (commandLineConfigOverrides.verbose !== undefined) {
|
|
244
|
+
mergedConfig.llm.verbose = commandLineConfigOverrides.verbose;
|
|
245
|
+
}
|
|
243
246
|
// Set the useColour value in systemUtils
|
|
244
247
|
setUseColour(mergedConfig.useColour);
|
|
245
248
|
return mergedConfig;
|
|
@@ -247,7 +250,7 @@ function mergeConfig(partialConfig) {
|
|
|
247
250
|
/**
|
|
248
251
|
* Merge raw with default config
|
|
249
252
|
*/
|
|
250
|
-
function mergeRawConfig(config, llm) {
|
|
251
|
-
return mergeConfig({ ...config, llm });
|
|
253
|
+
function mergeRawConfig(config, llm, commandLineConfigOverrides) {
|
|
254
|
+
return mergeConfig({ ...config, llm }, commandLineConfigOverrides);
|
|
252
255
|
}
|
|
253
256
|
//# sourceMappingURL=config.js.map
|
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,uBAAuB,CAAC;AAG1F,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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,CAAC,SAAS,CAAC,CAAC;IAErC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CACrB,MAAoB,EACpB,GAAkB,EAClB,0BAAsD;IAEtD,OAAO,WAAW,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,0BAA0B,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -9,12 +9,10 @@ import { StatusUpdateCallback } from '#src/core/GthLangChainAgent.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class GthAgentRunner {
|
|
11
11
|
private statusUpdate;
|
|
12
|
-
private verbose;
|
|
13
12
|
private agent;
|
|
14
13
|
private config;
|
|
15
14
|
private runConfig;
|
|
16
15
|
constructor(statusUpdate: StatusUpdateCallback);
|
|
17
|
-
setVerbose(verbose: boolean): void;
|
|
18
16
|
/**
|
|
19
17
|
* Init is split into a separate method. This may create a number of connections,
|
|
20
18
|
* and we'd better have an instance by that moment, for the case things will go wrong,
|
|
@@ -8,16 +8,12 @@ import { initDebugLogging, debugLog, debugLogError, debugLogObject } from '#src/
|
|
|
8
8
|
*/
|
|
9
9
|
export class GthAgentRunner {
|
|
10
10
|
statusUpdate;
|
|
11
|
-
verbose = false;
|
|
12
11
|
agent = null;
|
|
13
12
|
config = null;
|
|
14
13
|
runConfig = null;
|
|
15
14
|
constructor(statusUpdate) {
|
|
16
15
|
this.statusUpdate = statusUpdate;
|
|
17
16
|
}
|
|
18
|
-
setVerbose(verbose) {
|
|
19
|
-
this.verbose = verbose;
|
|
20
|
-
}
|
|
21
17
|
/**
|
|
22
18
|
* Init is split into a separate method. This may create a number of connections,
|
|
23
19
|
* and we'd better have an instance by that moment, for the case things will go wrong,
|
|
@@ -35,10 +31,6 @@ export class GthAgentRunner {
|
|
|
35
31
|
this.agent = this.config.hooks?.createAgent
|
|
36
32
|
? await this.config.hooks?.createAgent(this.config)
|
|
37
33
|
: new GthLangChainAgent(this.statusUpdate);
|
|
38
|
-
// Set verbose mode before initialization so it can be used during init
|
|
39
|
-
if (this.verbose) {
|
|
40
|
-
this.agent.setVerbose(this.verbose);
|
|
41
|
-
}
|
|
42
34
|
// Call before init hook
|
|
43
35
|
debugLog('Executing beforeAgentInit hooks...');
|
|
44
36
|
await executeHooks(this.config.hooks?.beforeAgentInit, this);
|
|
@@ -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;AACxD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE/F;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,YAAY,CAAuB;IACnC,
|
|
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;AACxD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE/F;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,YAAY,CAAuB;IACnC,KAAK,GAA6B,IAAI,CAAC;IACvC,MAAM,GAAqB,IAAI,CAAC;IAChC,SAAS,GAA0B,IAAI,CAAC;IAEhD,YAAY,YAAkC;QAC5C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CACR,OAA+B,EAC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C,CAAC;gBACtE,OAAO,MAAM,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACN,oBAAoB;gBACpB,QAAQ,CAAC,0BAA0B,CAAC,CAAC;gBACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBACjE,QAAQ,CAAC,+BAA+B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;gBACzD,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iCAAiC;YACjC,aAAa,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;YACzC,MAAM,IAAI,KAAK,CACb,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrF,CAAC;QACJ,CAAC;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"}
|
|
@@ -9,12 +9,10 @@ import type { Message } from '#src/modules/types.js';
|
|
|
9
9
|
export type StatusUpdateCallback = (level: StatusLevel, message: string) => void;
|
|
10
10
|
export declare class GthLangChainAgent implements GthAgentInterface {
|
|
11
11
|
private statusUpdate;
|
|
12
|
-
private verbose;
|
|
13
12
|
private mcpClient;
|
|
14
13
|
private agent;
|
|
15
14
|
private config;
|
|
16
15
|
constructor(statusUpdate: StatusUpdateCallback);
|
|
17
|
-
setVerbose(verbose: boolean): void;
|
|
18
16
|
init(command: GthCommand | undefined, configIn: GthConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
19
17
|
/**
|
|
20
18
|
* Invoke LLM with a message and runnable config.
|
|
@@ -9,7 +9,6 @@ import { IterableReadableStream } from '@langchain/core/utils/stream';
|
|
|
9
9
|
import { debugLog, debugLogError, debugLogObject } from '#src/debugUtils.js';
|
|
10
10
|
export class GthLangChainAgent {
|
|
11
11
|
statusUpdate;
|
|
12
|
-
verbose = false;
|
|
13
12
|
mcpClient = null;
|
|
14
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
14
|
agent = null;
|
|
@@ -19,16 +18,8 @@ export class GthLangChainAgent {
|
|
|
19
18
|
statusUpdate(level, message);
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
|
-
setVerbose(verbose) {
|
|
23
|
-
this.verbose = verbose;
|
|
24
|
-
}
|
|
25
21
|
async init(command, configIn, checkpointSaver) {
|
|
26
22
|
debugLog(`GthLangChainAgent.init called with command: ${command || 'default'}`);
|
|
27
|
-
// Set verbose mode on LLM
|
|
28
|
-
if (this.verbose) {
|
|
29
|
-
configIn.llm.verbose = true;
|
|
30
|
-
debugLog('Verbose mode enabled on LLM');
|
|
31
|
-
}
|
|
32
23
|
// Merge command-specific filesystem config if provided
|
|
33
24
|
this.config = this.getEffectiveConfig(configIn, command);
|
|
34
25
|
debugLogObject('Effective Config', {
|
|
@@ -65,6 +56,8 @@ export class GthLangChainAgent {
|
|
|
65
56
|
llm: this.config.llm,
|
|
66
57
|
tools,
|
|
67
58
|
checkpointSaver,
|
|
59
|
+
postModelHook: configIn.hooks?.postModelHook,
|
|
60
|
+
preModelHook: configIn.hooks?.preModelHook,
|
|
68
61
|
});
|
|
69
62
|
debugLog('React agent created successfully');
|
|
70
63
|
}
|
|
@@ -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;AAGtE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAI7E,MAAM,OAAO,iBAAiB;IACpB,YAAY,CAAuB;IACnC,
|
|
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,EA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AAE,IAAI;gBACtB,4BAA4B,EAAE,IAAI;gBAClC,wBAAwB,EAAE,KAAK;gBAC/B,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,2BAA2B,CAAC,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -9,5 +9,4 @@ export interface GthAgentInterface {
|
|
|
9
9
|
init(command: GthCommand | undefined, configIn: GthConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
10
10
|
invoke(messages: Message[], runConfig: RunnableConfig): Promise<string>;
|
|
11
11
|
stream(messages: Message[], runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
|
|
12
|
-
setVerbose(verbose: boolean): void;
|
|
13
12
|
}
|
package/dist/llmUtils.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { RunnableConfig } from '@langchain/core/runnables';
|
|
|
5
5
|
* @deprecated prefer using src/core/GthAgentRunner.ts directly
|
|
6
6
|
*/
|
|
7
7
|
export declare function invoke(command: 'ask' | 'pr' | 'review' | 'chat' | 'code' | undefined, messages: Message[], config: GthConfig): Promise<string>;
|
|
8
|
-
export declare function setVerbose(debug: boolean): void;
|
|
9
8
|
/**
|
|
10
9
|
* Creates new runnable config.
|
|
11
10
|
* configurable.thread_id is an important part of that because it helps to distinguish different chat sessions.
|
package/dist/llmUtils.js
CHANGED
|
@@ -2,9 +2,6 @@ import { display, displayError, displayInfo, displayWarning } from '#src/console
|
|
|
2
2
|
import { stdout } from '#src/systemUtils.js';
|
|
3
3
|
import { GthAgentRunner } from '#src/core/GthAgentRunner.js';
|
|
4
4
|
import { randomUUID } from 'crypto';
|
|
5
|
-
const llmGlobalSettings = {
|
|
6
|
-
verbose: false,
|
|
7
|
-
};
|
|
8
5
|
/**
|
|
9
6
|
* @deprecated prefer using src/core/GthAgentRunner.ts directly
|
|
10
7
|
*/
|
|
@@ -32,7 +29,6 @@ export async function invoke(command, messages, config) {
|
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
31
|
const runner = new GthAgentRunner(statusUpdate);
|
|
35
|
-
runner.setVerbose(llmGlobalSettings.verbose);
|
|
36
32
|
try {
|
|
37
33
|
await runner.init(command, config);
|
|
38
34
|
return await runner.processMessages(messages);
|
|
@@ -41,10 +37,6 @@ export async function invoke(command, messages, config) {
|
|
|
41
37
|
await runner.cleanup();
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
// TODO make sure that it still works after refactoring
|
|
45
|
-
export function setVerbose(debug) {
|
|
46
|
-
llmGlobalSettings.verbose = debug;
|
|
47
|
-
}
|
|
48
40
|
/**
|
|
49
41
|
* Creates new runnable config.
|
|
50
42
|
* configurable.thread_id is an important part of that because it helps to distinguish different chat sessions.
|
package/dist/llmUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llmUtils.js","sourceRoot":"","sources":["../src/llmUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC
|
|
1
|
+
{"version":3,"file":"llmUtils.js","sourceRoot":"","sources":["../src/llmUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAA8D,EAC9D,QAAmB,EACnB,MAAiB;IAEjB,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAE,OAAe,EAAE,EAAE;QAC3D,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,CAAC,OAAO,CAAC,CAAC;gBACjB,MAAM;YACR,KAAK,MAAM;gBACT,WAAW,CAAC,OAAO,CAAC,CAAC;gBACrB,MAAM;YACR,KAAK,SAAS;gBACZ,cAAc,CAAC,OAAO,CAAC,CAAC;gBACxB,MAAM;YACR,KAAK,OAAO;gBACV,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC/B,MAAM;YACR;gBACE,OAAO,CAAC,OAAO,CAAC,CAAC;gBACjB,MAAM;QACV,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,YAAY,CAAC,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnC,OAAO,MAAM,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,cAAc,EAAE,GAAG;QACnB,YAAY,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CommandLineConfigOverrides } from '#src/config.js';
|
|
1
2
|
export interface SessionConfig {
|
|
2
3
|
mode: 'chat' | 'code';
|
|
3
4
|
readModePrompt: () => string | null;
|
|
@@ -5,4 +6,4 @@ export interface SessionConfig {
|
|
|
5
6
|
readyMessage: string;
|
|
6
7
|
exitMessage: string;
|
|
7
8
|
}
|
|
8
|
-
export declare function createInteractiveSession(sessionConfig: SessionConfig, message?: string): Promise<void>;
|
|
9
|
+
export declare function createInteractiveSession(sessionConfig: SessionConfig, commandLineConfigOverrides: CommandLineConfigOverrides, message?: string): Promise<void>;
|
|
@@ -7,8 +7,8 @@ import { getGslothFilePath } from '#src/filePathUtils.js';
|
|
|
7
7
|
import { appendToFile, generateStandardFileName } from '#src/utils.js';
|
|
8
8
|
import { readBackstory, readGuidelines, readSystemPrompt } from '#src/prompt.js';
|
|
9
9
|
import { GthAgentRunner } from '#src/core/GthAgentRunner.js';
|
|
10
|
-
export async function createInteractiveSession(sessionConfig, message) {
|
|
11
|
-
const config = { ...(await initConfig()) };
|
|
10
|
+
export async function createInteractiveSession(sessionConfig, commandLineConfigOverrides, message) {
|
|
11
|
+
const config = { ...(await initConfig(commandLineConfigOverrides)) };
|
|
12
12
|
const checkpointSaver = new MemorySaver();
|
|
13
13
|
// Initialize Runner
|
|
14
14
|
const runner = new GthAgentRunner(defaultStatusCallbacks);
|
|
@@ -53,16 +53,16 @@ export async function createInteractiveSession(sessionConfig, message) {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
let shouldRetry = false;
|
|
56
|
-
let currentInput = userInput;
|
|
57
56
|
do {
|
|
58
57
|
try {
|
|
59
|
-
await processMessage(
|
|
58
|
+
await processMessage(userInput);
|
|
60
59
|
shouldRetry = false;
|
|
61
60
|
}
|
|
62
61
|
catch (err) {
|
|
63
62
|
display(`\n❌ Error processing message: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
64
63
|
const retryResponse = await rl.question('Do you want to try again with the same prompt? (y/n): ');
|
|
65
64
|
shouldRetry = retryResponse.toLowerCase().trim().startsWith('y');
|
|
65
|
+
isFirstMessage = false; // To make sure we don't resend system prompt if the first message failed
|
|
66
66
|
if (!shouldRetry) {
|
|
67
67
|
display('\nSkipping to next prompt...');
|
|
68
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,WAAW,EACX,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAoB,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EACL,eAAe,EACf,KAAK,EACL,IAAI,EACJ,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAU7D,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,aAA4B,EAC5B,0BAAsD,EACtD,OAAgB;IAEhB,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,MAAM,UAAU,CAAC,0BAA0B,CAAC,CAAC,EAAE,CAAC;IACrE,MAAM,eAAe,GAAG,IAAI,WAAW,EAAE,CAAC;IAC1C,oBAAoB;IACpB,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,sBAAsB,CAAC,CAAC;IAE1D,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,C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AC,8BAA8B,CAAC,CAAC;wBAC1C,CAAC;oBACH,CAAC;gBACH,CAAC,QAAQ,WAAW,IAAI,CAAC,UAAU,EAAE;gBAErC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACpC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,MAAM,WAAW,EAAE,CAAC;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,CAAC,YAAY,aAAa,CAAC,IAAI,aAAa,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { AnthropicInput } from '@langchain/anthropic';
|
|
2
2
|
import type { BaseChatModel, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
|
|
3
|
+
import { StateDefinition, StateType } from '@langchain/langgraph';
|
|
4
|
+
import { GthConfig } from '#src/config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Function to process JSON config and create Anthropic LLM instance
|
|
7
|
+
*/
|
|
3
8
|
export declare function processJsonConfig(llmConfig: AnthropicInput & BaseChatModelParams): Promise<BaseChatModel>;
|
|
4
9
|
export declare function init(configFileName: string): void;
|
|
10
|
+
export declare function postProcessJsonConfig(config: GthConfig): GthConfig;
|
|
11
|
+
/**
|
|
12
|
+
* There's something off with calling server tools with ReAct agent,
|
|
13
|
+
* the tool is not added in react_agent_executor because it is not Runnable,
|
|
14
|
+
* but the tool_node explodes because LLM reports calling non-existing tool.
|
|
15
|
+
* This method removes tool calls from messages, leaving the resulting content.
|
|
16
|
+
* This method seems unnecessary with OpenAI, but is needed for Anthropic,
|
|
17
|
+
* OpenAI does not need a name on the tool and does not seem to return server_tool_use.
|
|
18
|
+
*/
|
|
19
|
+
export declare function postModelHook(state: StateType<StateDefinition>): StateType<StateDefinition>;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { displayWarning } from '#src/consoleUtils.js';
|
|
1
|
+
import { displayInfo, displayWarning } from '#src/consoleUtils.js';
|
|
2
2
|
import { env } from '#src/systemUtils.js';
|
|
3
3
|
import { writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
|
4
|
-
|
|
4
|
+
import { isAIMessage } from '@langchain/core/messages';
|
|
5
|
+
import { debugLog, debugLogError } from '#src/debugUtils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Function to process JSON config and create Anthropic LLM instance
|
|
8
|
+
*/
|
|
9
|
+
// noinspection JSUnusedGlobalSymbols
|
|
5
10
|
export async function processJsonConfig(llmConfig) {
|
|
6
11
|
const anthropic = await import('@langchain/anthropic');
|
|
7
12
|
// Use config value if available, otherwise use the environment variable
|
|
@@ -18,6 +23,7 @@ const jsonContent = `{
|
|
|
18
23
|
"model": "claude-sonnet-4-20250514"
|
|
19
24
|
}
|
|
20
25
|
}`;
|
|
26
|
+
// noinspection JSUnusedGlobalSymbols
|
|
21
27
|
export function init(configFileName) {
|
|
22
28
|
// Determine which content to use based on file extension
|
|
23
29
|
if (!configFileName.endsWith('.json')) {
|
|
@@ -27,4 +33,44 @@ export function init(configFileName) {
|
|
|
27
33
|
displayWarning(`You need to update your ${configFileName} to add your Anthropic API key, ` +
|
|
28
34
|
'or define ANTHROPIC_API_KEY environment variable.');
|
|
29
35
|
}
|
|
36
|
+
// noinspection JSUnusedGlobalSymbols
|
|
37
|
+
export function postProcessJsonConfig(config) {
|
|
38
|
+
// eslint-disable-next-line
|
|
39
|
+
if (config.hooks?.postModelHook === 'skip') {
|
|
40
|
+
return {
|
|
41
|
+
...config,
|
|
42
|
+
hooks: { ...config.hooks, postModelHook: undefined },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
displayInfo('Applying Anthropic post-processing to config.');
|
|
46
|
+
return {
|
|
47
|
+
...config,
|
|
48
|
+
hooks: { ...config.hooks, postModelHook: config.hooks?.postModelHook || postModelHook },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* There's something off with calling server tools with ReAct agent,
|
|
53
|
+
* the tool is not added in react_agent_executor because it is not Runnable,
|
|
54
|
+
* but the tool_node explodes because LLM reports calling non-existing tool.
|
|
55
|
+
* This method removes tool calls from messages, leaving the resulting content.
|
|
56
|
+
* This method seems unnecessary with OpenAI, but is needed for Anthropic,
|
|
57
|
+
* OpenAI does not need a name on the tool and does not seem to return server_tool_use.
|
|
58
|
+
*/
|
|
59
|
+
export function postModelHook(state) {
|
|
60
|
+
try {
|
|
61
|
+
const lastMessage = state.messages[state.messages.length - 1];
|
|
62
|
+
if (isAIMessage(lastMessage) && lastMessage.tool_calls && Array.isArray(lastMessage.content)) {
|
|
63
|
+
const serverToolsCalled = lastMessage.content
|
|
64
|
+
.filter((content) => content.type == 'server_tool_use' && content.name)
|
|
65
|
+
.map((content) => content.name);
|
|
66
|
+
debugLog('found server tool calls ' + serverToolsCalled.join(','));
|
|
67
|
+
lastMessage.tool_calls = lastMessage.tool_calls.filter((tc) => !serverToolsCalled.includes(tc.name));
|
|
68
|
+
}
|
|
69
|
+
return state;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
debugLogError('removeServerToolCalls error', e);
|
|
73
|
+
return state;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
30
76
|
//# sourceMappingURL=anthropic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/presets/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/presets/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAOjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG7D;;GAEG;AACH,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA+C;IAE/C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACvD,wEAAwE;IACxE,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,iBAAiB,CAAC;IAClE,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC;QACjC,GAAG,SAAS;QACZ,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,0BAA0B;KACrD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,WAAW,GAAG;;;;;EAKlB,CAAC;AAEH,qCAAqC;AACrC,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,yDAAyD;IACzD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,gCAAgC,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC9D,cAAc,CACZ,2BAA2B,cAAc,kCAAkC;QACzE,mDAAmD,CACtD,CAAC;AACJ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EAAE,CAAC,IAAI,CAAC,CAC7C,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,aAAa,CAAC,6BAA6B,EAAE,CAAC,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaunt-sloth-assistant",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andrew Kondratev",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@langchain/anthropic": "^0.3.24",
|
|
38
|
-
"@langchain/core": "^0.3.
|
|
38
|
+
"@langchain/core": "^0.3.66",
|
|
39
39
|
"@langchain/deepseek": "^0.0.2",
|
|
40
40
|
"@langchain/google-genai": "^0.2.15",
|
|
41
41
|
"@langchain/google-vertexai": "^0.2.15",
|
|
42
42
|
"@langchain/groq": "^0.2.3",
|
|
43
|
-
"@langchain/langgraph": "^0.3.
|
|
44
|
-
"@langchain/mcp-adapters": "^0.5.
|
|
43
|
+
"@langchain/langgraph": "^0.3.10",
|
|
44
|
+
"@langchain/mcp-adapters": "^0.5.4",
|
|
45
45
|
"@langchain/openai": "^0.5.18",
|
|
46
46
|
"@langchain/xai": "^0.0.3",
|
|
47
47
|
"commander": "^14.0.0",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"@eslint/js": "^9.26.0",
|
|
54
54
|
"@types/diff": "^7.0.2",
|
|
55
55
|
"@types/express": "^5.0.3",
|
|
56
|
-
"@types/node": "^24.0.
|
|
56
|
+
"@types/node": "^24.0.15",
|
|
57
57
|
"@types/uuid": "^10.0.0",
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
59
59
|
"@typescript-eslint/parser": "^8.37.0",
|
|
60
60
|
"eslint": "^9.31.0",
|
|
61
|
-
"eslint-config-prettier": "^10.1.
|
|
62
|
-
"eslint-plugin-prettier": "^5.5.
|
|
61
|
+
"eslint-config-prettier": "^10.1.8",
|
|
62
|
+
"eslint-plugin-prettier": "^5.5.3",
|
|
63
63
|
"globals": "^16.3.0",
|
|
64
64
|
"prettier": "3.6.2",
|
|
65
65
|
"typedoc": "^0.28.7",
|