gaunt-sloth-assistant 0.8.7 → 0.8.10
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.guidelines.md +1 -1
- package/README.md +23 -13
- package/{index.js → cli.js} +2 -2
- package/dist/builtInToolsConfig.d.ts +2 -2
- package/dist/builtInToolsConfig.js.map +1 -1
- package/dist/{index.js → cli.js} +7 -1
- package/dist/cli.js.map +1 -0
- package/dist/commands/commandUtils.d.ts +3 -3
- package/dist/commands/commandUtils.js.map +1 -1
- package/dist/commands/prCommand.js +1 -1
- package/dist/commands/prCommand.js.map +1 -1
- package/dist/config.d.ts +38 -12
- package/dist/config.js +24 -8
- package/dist/config.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +18 -5
- package/dist/core/GthAgentRunner.js +36 -11
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +5 -4
- package/dist/core/GthLangChainAgent.js +4 -0
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/llmUtils.d.ts +2 -2
- package/dist/llmUtils.js +1 -1
- package/dist/llmUtils.js.map +1 -1
- package/dist/modules/interactiveSessionModule.js +7 -9
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/modules/questionAnsweringModule.d.ts +2 -2
- package/dist/modules/questionAnsweringModule.js.map +1 -1
- package/dist/modules/reviewModule.d.ts +2 -2
- package/dist/modules/reviewModule.js.map +1 -1
- package/dist/prompt.js +3 -10
- package/dist/prompt.js.map +1 -1
- package/dist/systemUtils.d.ts +1 -1
- package/dist/systemUtils.js +1 -1
- package/dist/tools/gthJiraLogWorkTool.d.ts +2 -2
- package/dist/tools/gthJiraLogWorkTool.js +3 -3
- package/dist/tools/gthJiraLogWorkTool.js.map +1 -1
- package/dist/tools/gthStatusUpdateTool.d.ts +2 -2
- package/dist/tools/gthStatusUpdateTool.js.map +1 -1
- package/dist/utils.d.ts +9 -2
- package/dist/utils.js +19 -0
- package/dist/utils.js.map +1 -1
- package/package.json +28 -11
- package/.gsloth.config_.json +0 -7
- package/.gsloth.config_.mjs +0 -33
- package/.gsloth.config_claude.mjs +0 -18
- package/.gsloth.config_vertex.json +0 -6
- package/.prettierrc.json +0 -9
- package/assets/gaunt-sloth-logo.png +0 -0
- package/assets/release-notes/RELEASE-NOTES-HOWTO.md +0 -12
- package/assets/release-notes/v0_4_0.md +0 -39
- package/assets/release-notes/v0_5_0.md +0 -10
- package/assets/release-notes/v0_5_1.md +0 -47
- package/assets/release-notes/v0_5_2.md +0 -23
- package/assets/release-notes/v0_5_3.md +0 -25
- package/assets/release-notes/v0_6_0.md +0 -44
- package/assets/release-notes/v0_6_2.md +0 -4
- package/assets/release-notes/v0_6_4.md +0 -4
- package/assets/release-notes/v0_6_5.md +0 -3
- package/assets/release-notes/v0_7_0.md +0 -7
- package/assets/release-notes/v0_7_2.md +0 -14
- package/assets/release-notes/v0_7_3.md +0 -64
- package/assets/release-notes/v0_8_0.md +0 -13
- package/assets/release-notes/v0_8_2.md +0 -9
- package/assets/release-notes/v0_8_5.md +0 -12
- package/assets/release-notes/v0_8_6.md +0 -12
- package/assets/release-notes/v0_8_7.md +0 -5
- package/dist/index.js.map +0 -1
- package/docs/COMMANDS.md +0 -231
- package/docs/CONFIGURATION.md +0 -642
- package/docs/DEVELOPMENT.md +0 -46
- package/docs/RELEASE-HOWTO.md +0 -40
- package/eslint.config.js +0 -122
- package/it.js +0 -16
- package/maintenance/doc-maintenance.md +0 -8
- package/src/builtInToolsConfig.ts +0 -99
- package/src/commands/askCommand.ts +0 -51
- package/src/commands/chatCommand.ts +0 -25
- package/src/commands/codeCommand.ts +0 -24
- package/src/commands/commandUtils.ts +0 -77
- package/src/commands/initCommand.ts +0 -19
- package/src/commands/prCommand.ts +0 -118
- package/src/commands/reviewCommand.ts +0 -106
- package/src/config.ts +0 -337
- package/src/consoleUtils.ts +0 -84
- package/src/constants.ts +0 -12
- package/src/core/GthAgentRunner.ts +0 -85
- package/src/core/GthLangChainAgent.ts +0 -257
- package/src/core/types.ts +0 -22
- package/src/filePathUtils.ts +0 -77
- package/src/globalConfigUtils.ts +0 -71
- package/src/helpers/jira/jiraClient.ts +0 -99
- package/src/helpers/jira/jiraLogWork.ts +0 -81
- package/src/index.ts +0 -36
- package/src/llmUtils.ts +0 -72
- package/src/mcp/OAuthClientProviderImpl.ts +0 -236
- package/src/modules/interactiveSessionModule.ts +0 -105
- package/src/modules/questionAnsweringModule.ts +0 -39
- package/src/modules/reviewModule.ts +0 -34
- package/src/modules/types.ts +0 -23
- package/src/presets/anthropic.ts +0 -42
- package/src/presets/deepseek.ts +0 -42
- package/src/presets/fake.ts +0 -15
- package/src/presets/google-genai.ts +0 -42
- package/src/presets/groq.ts +0 -37
- package/src/presets/openai.ts +0 -59
- package/src/presets/vertexai.ts +0 -32
- package/src/prompt.ts +0 -74
- package/src/providers/file.ts +0 -24
- package/src/providers/ghIssueProvider.ts +0 -39
- package/src/providers/ghPrDiffProvider.ts +0 -39
- package/src/providers/jiraIssueLegacyProvider.ts +0 -103
- package/src/providers/jiraIssueProvider.ts +0 -89
- package/src/providers/text.ts +0 -14
- package/src/providers/types.ts +0 -24
- package/src/systemUtils.ts +0 -107
- package/src/tools/GthFileSystemToolkit.ts +0 -833
- package/src/tools/gthJiraLogWorkTool.ts +0 -51
- package/src/tools/gthStatusUpdateTool.ts +0 -17
- package/src/utils.ts +0 -331
- package/tsconfig.json +0 -24
- package/vitest-it.config.ts +0 -13
- package/vitest.config.ts +0 -14
- /package/dist/{index.d.ts → cli.d.ts} +0 -0
package/.gsloth.guidelines.md
CHANGED
|
@@ -19,7 +19,7 @@ Vendor and system abstractions and wrappers should be used in most cases.
|
|
|
19
19
|
|
|
20
20
|
Project uses import alias with `#src/*.js` pointing to `src/` and after build resolving to generated `dist/`.
|
|
21
21
|
Please abstain from using relative imports, only use them when no other choices are available
|
|
22
|
-
(currently the only exception is entry point
|
|
22
|
+
(currently the only exception is entry point cli.js)
|
|
23
23
|
|
|
24
24
|
### Architecture and Flow
|
|
25
25
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Gaunt Sloth Assistant
|
|
2
|
-
[](https://github.com/andruhon/gaunt-sloth-assistant/actions/workflows/unit-tests.yml) [](https://github.com/andruhon/gaunt-sloth-assistant/actions/workflows/unit-tests.yml) [](https://github.com/andruhon/gaunt-sloth-assistant/actions/workflows/integration-tests.yml)
|
|
3
3
|
|
|
4
|
-
Gaunt
|
|
4
|
+
Gaunt Sloth Assistant is a lightweight **command line AI assistant**
|
|
5
5
|
built with TypeScript (JavaScript) and distributed via NPM with minimum dependencies.
|
|
6
6
|
|
|
7
7
|

|
|
@@ -49,7 +49,7 @@ The promise of Gaunt Sloth:
|
|
|
49
49
|
|
|
50
50
|
- Groq;
|
|
51
51
|
- DeepSeek;
|
|
52
|
-
- Google
|
|
52
|
+
- Google AI Studio and Google Vertex AI;
|
|
53
53
|
- Anthropic;
|
|
54
54
|
- OpenAI (and other providers using OpenAI format, such as Inception);
|
|
55
55
|
- Ollama with JS config (some of the models, see https://github.com/andruhon/gaunt-sloth-assistant/discussions/107)
|
|
@@ -129,31 +129,34 @@ npm install gaunt-sloth-assistant -g
|
|
|
129
129
|
|
|
130
130
|
## Configuration
|
|
131
131
|
|
|
132
|
-
> Gaunt Sloth currently only functions from the directory which has a configuration file (`.gsloth.config.js`, `.gsloth.config.json`, or `.gsloth.config.mjs`) and `.gsloth.guidelines.md`.
|
|
132
|
+
> Gaunt Sloth currently only functions from the directory which has a configuration file (`.gsloth.config.js`, `.gsloth.config.json`, or `.gsloth.config.mjs`) and `.gsloth.guidelines.md`. Configuration files can be located in the project root or in the `.gsloth/.gsloth-settings/` directory.
|
|
133
|
+
>
|
|
134
|
+
> You can also specify a path to a configuration file directly using the `-c` or `--config` global flag, for example `gth -c /path/to/your/config.json ask "who are you?"`
|
|
135
|
+
> 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.
|
|
133
136
|
|
|
134
137
|
Configuration can be created with `gsloth init [vendor]` command.
|
|
135
|
-
Currently,
|
|
138
|
+
Currently, anthropic, groq, deepseek, openai, google-genai and vertexai can be configured with `gsloth init [vendor]`.
|
|
136
139
|
For OpenAI-compatible providers like Inception, use `gsloth init openai` and modify the configuration.
|
|
137
140
|
|
|
138
141
|
More detailed information on configuration can be found in [CONFIGURATION.md](./docs/CONFIGURATION.md)
|
|
139
142
|
|
|
140
|
-
### Google
|
|
143
|
+
### Google GenAI (AI Studio)
|
|
141
144
|
|
|
142
145
|
```shell
|
|
143
146
|
cd ./your-project
|
|
144
|
-
gsloth init
|
|
145
|
-
gcloud auth login
|
|
146
|
-
gcloud auth application-default login
|
|
147
|
+
gsloth init google-genai
|
|
147
148
|
```
|
|
149
|
+
Make sure you either define `GOOGLE_API_KEY` environment variable or edit your configuration file and set up your key.
|
|
150
|
+
It is recommended to obtain API key from Google AI Studio official website rather than from a reseller.
|
|
148
151
|
|
|
149
|
-
### Google
|
|
152
|
+
### Google Vertex AI
|
|
150
153
|
|
|
151
154
|
```shell
|
|
152
155
|
cd ./your-project
|
|
153
|
-
gsloth init
|
|
156
|
+
gsloth init vertexai
|
|
157
|
+
gcloud auth login
|
|
158
|
+
gcloud auth application-default login
|
|
154
159
|
```
|
|
155
|
-
Make sure you either define `GOOGLE_API_KEY` environment variable or edit your configuration file and set up your key.
|
|
156
|
-
It is recommended to obtain API key from Google AI Studio official website rather than from a reseller.
|
|
157
160
|
|
|
158
161
|
### Anthropic
|
|
159
162
|
|
|
@@ -196,6 +199,13 @@ Then edit your configuration to add custom base URL and API key. See [CONFIGURAT
|
|
|
196
199
|
|
|
197
200
|
### Other AI providers
|
|
198
201
|
Any other AI provider supported by Langchain.js can be configured with js [Config](./docs/CONFIGURATION.md).
|
|
202
|
+
For example, Ollama can be set up with JS config (some of the models, see https://github.com/andruhon/gaunt-sloth-assistant/discussions/107)
|
|
203
|
+
|
|
204
|
+
## Integration with GitHub Workflows / Actions
|
|
205
|
+
|
|
206
|
+
Example GitHub workflows integration can be found in [.github/workflows/review.yml;](.github/workflows/review.yml)
|
|
207
|
+
this example workflow performs AI review on any pushes to Pull Request, resulting in a comment left by,
|
|
208
|
+
GitHub actions bot.
|
|
199
209
|
|
|
200
210
|
## MCP (Model Context Protocol) Servers
|
|
201
211
|
|
package/{index.js → cli.js}
RENAMED
|
@@ -10,14 +10,14 @@ process.on('warning', (warning) => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
// This is a minimalistic entry point that sets the installDir in systemUtils
|
|
13
|
-
// and delegates to the compiled TypeScript code in dist/
|
|
13
|
+
// and delegates to the compiled TypeScript code in dist/cli.js
|
|
14
14
|
import { setEntryPoint } from './dist/systemUtils.js';
|
|
15
15
|
|
|
16
16
|
// Set the installation directory in systemUtils
|
|
17
17
|
setEntryPoint(import.meta.url);
|
|
18
18
|
|
|
19
19
|
// Import and run the compiled TypeScript code
|
|
20
|
-
import('./dist/
|
|
20
|
+
import('./dist/cli.js').catch((err) => {
|
|
21
21
|
console.error('Failed to load application:', err);
|
|
22
22
|
process.exit(1);
|
|
23
23
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
2
|
-
import {
|
|
2
|
+
import { GthConfig } from '#src/config.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get default tools based on filesystem and built-in tools configuration
|
|
5
5
|
*/
|
|
6
|
-
export declare function getDefaultTools(config:
|
|
6
|
+
export declare function getDefaultTools(config: GthConfig): Promise<StructuredToolInterface[]>;
|
|
@@ -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,E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AAM,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/{index.js → cli.js}
RENAMED
|
@@ -8,12 +8,14 @@ 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
10
|
import { setVerbose } from '#src/llmUtils.js';
|
|
11
|
+
import { setCustomConfigPath } from '#src/config.js';
|
|
11
12
|
const program = new Command();
|
|
12
13
|
program
|
|
13
14
|
.name('gsloth')
|
|
14
15
|
.description('Gaunt Sloth Assistant reviewing your PRs')
|
|
15
16
|
.version(getSlothVersion())
|
|
16
17
|
.option('--verbose', 'Print entire prompt sent to LLM.')
|
|
18
|
+
.option('-c, --config <path>', 'Path to custom configuration file')
|
|
17
19
|
.addOption(new Option('--nopipe').hideHelp(true));
|
|
18
20
|
// Parse global options before binding any commands
|
|
19
21
|
program.parseOptions(argv);
|
|
@@ -21,6 +23,10 @@ if (program.getOptionValue('verbose')) {
|
|
|
21
23
|
// Set global prompt debug
|
|
22
24
|
setVerbose(true);
|
|
23
25
|
}
|
|
26
|
+
if (program.getOptionValue('config')) {
|
|
27
|
+
// Set custom config path
|
|
28
|
+
setCustomConfigPath(program.getOptionValue('config'));
|
|
29
|
+
}
|
|
24
30
|
// Initialize all commands - they will handle their own config loading
|
|
25
31
|
initCommand(program);
|
|
26
32
|
reviewCommand(program);
|
|
@@ -29,4 +35,4 @@ askCommand(program);
|
|
|
29
35
|
chatCommand(program);
|
|
30
36
|
codeCommand(program);
|
|
31
37
|
await readStdin(program);
|
|
32
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +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;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,eAAe,EAAE,CAAC;KAC1B,MAAM,CAAC,WAAW,EAAE,kCAAkC,CAAC;KACvD,MAAM,CAAC,qBAAqB,EAAE,mCAAmC,CAAC;KAClE,SAAS,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAEpD,mDAAmD;AACnD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,IAAI,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;IACtC,0BAA0B;IAC1B,UAAU,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC;AACD,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;IACrC,yBAAyB;IACzB,mBAAmB,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,sEAAsE;AACtE,WAAW,CAAC,OAAO,CAAC,CAAC;AACrB,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,SAAS,CAAC,OAAO,CAAC,CAAC;AACnB,UAAU,CAAC,OAAO,CAAC,CAAC;AACpB,WAAW,CAAC,OAAO,CAAC,CAAC;AACrB,WAAW,CAAC,OAAO,CAAC,CAAC;AAErB,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GthConfig } from '#src/config.js';
|
|
2
2
|
/**
|
|
3
3
|
* Requirements providers. Expected to be in `.providers/` dir.
|
|
4
4
|
* Aliases are mapped to actual providers in this file
|
|
@@ -21,5 +21,5 @@ export declare const CONTENT_PROVIDERS: {
|
|
|
21
21
|
readonly file: "file.js";
|
|
22
22
|
};
|
|
23
23
|
export type ContentProviderType = keyof typeof CONTENT_PROVIDERS;
|
|
24
|
-
export declare function getRequirementsFromProvider(requirementsProvider: RequirementsProviderType | undefined, requirementsId: string | undefined, config:
|
|
25
|
-
export declare function getContentFromProvider(contentProvider: ContentProviderType | undefined, contentId: string | undefined, config:
|
|
24
|
+
export declare function getRequirementsFromProvider(requirementsProvider: RequirementsProviderType | undefined, requirementsId: string | undefined, config: GthConfig): Promise<string>;
|
|
25
|
+
export declare function getContentFromProvider(contentProvider: ContentProviderType | undefined, contentId: string | undefined, config: GthConfig): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../src/commands/commandUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,aAAa,EAAE,4BAA4B;IAC3C,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE,oBAAoB;IAC5B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CACP,CAAC;AAIX;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,qBAAqB;IAC7B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CACP,CAAC;AAIX,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,oBAA0D,EAC1D,cAAkC,EAClC,
|
|
1
|
+
{"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../src/commands/commandUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,aAAa,EAAE,4BAA4B;IAC3C,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE,oBAAoB;IAC5B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CACP,CAAC;AAIX;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,qBAAqB;IAC7B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CACP,CAAC;AAIX,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jira' &&
|
|
57
57
|
config.commands?.pr?.logWorkForReviewInSeconds) {
|
|
58
58
|
// TODO we need to figure out some sort of post-processors
|
|
59
|
-
let jiraConfig = config.
|
|
59
|
+
let jiraConfig = config.builtInToolsConfig?.jira ||
|
|
60
60
|
config.requirementsProviderConfig?.jira;
|
|
61
61
|
await jiraLogWork(jiraConfig, requirementsId, config.commands?.pr?.logWorkForReviewInSeconds, 'code review');
|
|
62
62
|
}
|
|
@@ -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;AAS3D,MAAM,UAAU,SAAS,CAAC,OAAgB;IACxC,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,IAAY,EAAE,cAAkC,EAAE,OAAyB,EAAE,EAAE;QAC5F,MAAM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.ts
CHANGED
|
@@ -2,7 +2,14 @@ import type { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
|
|
2
2
|
import type { Connection } from '@langchain/mcp-adapters';
|
|
3
3
|
import type { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
|
|
4
4
|
import { JiraConfig } from '#src/providers/types.js';
|
|
5
|
-
|
|
5
|
+
import type { GthAgentInterface } from '#src/core/types.js';
|
|
6
|
+
import type { GthAgentRunner } from '#src/core/GthAgentRunner.js';
|
|
7
|
+
import type { Message } from '#src/modules/types.js';
|
|
8
|
+
import { RunnableConfig } from '@langchain/core/runnables';
|
|
9
|
+
/**
|
|
10
|
+
* This is a processed Gaunt Sloth config ready to be passed down into components.
|
|
11
|
+
*/
|
|
12
|
+
export interface GthConfig extends BaseGthConfig {
|
|
6
13
|
llm: BaseChatModel;
|
|
7
14
|
contentProvider: string;
|
|
8
15
|
requirementsProvider: string;
|
|
@@ -13,17 +20,33 @@ export interface SlothConfig extends BaseSlothConfig {
|
|
|
13
20
|
filesystem: string[] | 'all' | 'read' | 'none';
|
|
14
21
|
builtInTools?: string[];
|
|
15
22
|
tools?: StructuredToolInterface[] | BaseToolkit[];
|
|
23
|
+
/**
|
|
24
|
+
* Hooks are only available on JS config
|
|
25
|
+
*/
|
|
26
|
+
hooks?: {
|
|
27
|
+
createRunnableConfig?: (config: GthConfig) => Promise<RunnableConfig>;
|
|
28
|
+
createAgent?: (config: GthConfig) => Promise<GthAgentInterface>;
|
|
29
|
+
beforeAgentInit?: RunnerHook | RunnerHook[];
|
|
30
|
+
/**
|
|
31
|
+
* After agent init.
|
|
32
|
+
*/
|
|
33
|
+
afterAgentInit?: RunnerHook | RunnerHook[];
|
|
34
|
+
beforeProcessMessages?: BeforeMessageHook | BeforeMessageHook[];
|
|
35
|
+
};
|
|
16
36
|
}
|
|
37
|
+
type RunnerHook = (runner: GthAgentRunner) => Promise<void>;
|
|
38
|
+
type BeforeMessageHook = (runner: GthAgentRunner, message: Message[], runConfig: RunnableConfig) => Promise<void>;
|
|
17
39
|
/**
|
|
18
|
-
* Raw, unprocessed
|
|
40
|
+
* Raw, unprocessed Gaunt Sloth config.
|
|
19
41
|
*/
|
|
20
|
-
export interface
|
|
42
|
+
export interface RawGthConfig extends BaseGthConfig {
|
|
21
43
|
llm: LLMConfig;
|
|
22
44
|
}
|
|
23
45
|
/**
|
|
24
|
-
* Do not export this one
|
|
46
|
+
* Do not export this one.
|
|
47
|
+
* This is a basic interface for Gaunt Sloth config.
|
|
25
48
|
*/
|
|
26
|
-
interface
|
|
49
|
+
interface BaseGthConfig {
|
|
27
50
|
llm: unknown;
|
|
28
51
|
contentProvider?: string;
|
|
29
52
|
requirementsProvider?: string;
|
|
@@ -32,12 +55,12 @@ interface BaseSlothConfig {
|
|
|
32
55
|
streamOutput?: boolean;
|
|
33
56
|
useColour?: boolean;
|
|
34
57
|
filesystem?: string[] | 'all' | 'read' | 'none';
|
|
35
|
-
prebuiltToolsConfig?: PreBuiltToolsConfig;
|
|
36
58
|
customToolsConfig?: CustomToolsConfig;
|
|
37
59
|
requirementsProviderConfig?: Record<string, unknown>;
|
|
38
60
|
contentProviderConfig?: Record<string, unknown>;
|
|
39
61
|
mcpServers?: Record<string, Connection>;
|
|
40
62
|
builtInTools?: string[];
|
|
63
|
+
builtInToolsConfig?: BuiltInToolsConfig;
|
|
41
64
|
commands?: {
|
|
42
65
|
pr?: {
|
|
43
66
|
contentProvider?: string;
|
|
@@ -67,7 +90,7 @@ interface BaseSlothConfig {
|
|
|
67
90
|
};
|
|
68
91
|
}
|
|
69
92
|
export type CustomToolsConfig = Record<string, object>;
|
|
70
|
-
export type
|
|
93
|
+
export type BuiltInToolsConfig = {
|
|
71
94
|
jira: JiraConfig;
|
|
72
95
|
};
|
|
73
96
|
export interface LLMConfig extends Record<string, unknown> {
|
|
@@ -78,18 +101,21 @@ export interface LLMConfig extends Record<string, unknown> {
|
|
|
78
101
|
}
|
|
79
102
|
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai"];
|
|
80
103
|
export type ConfigType = (typeof availableDefaultConfigs)[number];
|
|
81
|
-
export declare
|
|
104
|
+
export declare function setCustomConfigPath(path: string): void;
|
|
105
|
+
export declare function getCustomConfigPath(): string | undefined;
|
|
106
|
+
export declare function clearCustomConfigPath(): void;
|
|
107
|
+
export declare const DEFAULT_CONFIG: Partial<GthConfig>;
|
|
82
108
|
/**
|
|
83
109
|
* Initialize configuration by loading from available config files
|
|
84
|
-
* @returns The loaded
|
|
110
|
+
* @returns The loaded GthConfig
|
|
85
111
|
*/
|
|
86
|
-
export declare function initConfig(): Promise<
|
|
112
|
+
export declare function initConfig(): Promise<GthConfig>;
|
|
87
113
|
/**
|
|
88
114
|
* Process JSON LLM config by creating the appropriate LLM instance
|
|
89
115
|
* @param jsonConfig - The parsed JSON config
|
|
90
|
-
* @returns Promise<
|
|
116
|
+
* @returns Promise<GthConfig>
|
|
91
117
|
*/
|
|
92
|
-
export declare function tryJsonConfig(jsonConfig:
|
|
118
|
+
export declare function tryJsonConfig(jsonConfig: RawGthConfig): Promise<GthConfig>;
|
|
93
119
|
export declare function createProjectConfig(configType: string): Promise<void>;
|
|
94
120
|
export declare function writeProjectReviewPreamble(): void;
|
|
95
121
|
export {};
|
package/dist/config.js
CHANGED
|
@@ -4,6 +4,7 @@ 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';
|
|
7
8
|
export const availableDefaultConfigs = [
|
|
8
9
|
'vertexai',
|
|
9
10
|
'anthropic',
|
|
@@ -12,6 +13,18 @@ export const availableDefaultConfigs = [
|
|
|
12
13
|
'openai',
|
|
13
14
|
'google-genai',
|
|
14
15
|
];
|
|
16
|
+
const configGlobalSettings = {
|
|
17
|
+
customConfigPath: undefined,
|
|
18
|
+
};
|
|
19
|
+
export function setCustomConfigPath(path) {
|
|
20
|
+
configGlobalSettings.customConfigPath = resolve(path);
|
|
21
|
+
}
|
|
22
|
+
export function getCustomConfigPath() {
|
|
23
|
+
return configGlobalSettings.customConfigPath;
|
|
24
|
+
}
|
|
25
|
+
export function clearCustomConfigPath() {
|
|
26
|
+
configGlobalSettings.customConfigPath = undefined;
|
|
27
|
+
}
|
|
15
28
|
export const DEFAULT_CONFIG = {
|
|
16
29
|
llm: undefined,
|
|
17
30
|
contentProvider: 'file',
|
|
@@ -33,12 +46,15 @@ export const DEFAULT_CONFIG = {
|
|
|
33
46
|
};
|
|
34
47
|
/**
|
|
35
48
|
* Initialize configuration by loading from available config files
|
|
36
|
-
* @returns The loaded
|
|
49
|
+
* @returns The loaded GthConfig
|
|
37
50
|
*/
|
|
38
51
|
export async function initConfig() {
|
|
39
|
-
|
|
52
|
+
if (configGlobalSettings.customConfigPath && !existsSync(configGlobalSettings.customConfigPath)) {
|
|
53
|
+
throw new Error(`Provided manual config "${configGlobalSettings.customConfigPath}" does not exist`);
|
|
54
|
+
}
|
|
55
|
+
const jsonConfigPath = configGlobalSettings.customConfigPath ?? getGslothConfigReadPath(USER_PROJECT_CONFIG_JSON);
|
|
40
56
|
// Try loading the JSON config file first
|
|
41
|
-
if (existsSync(jsonConfigPath)) {
|
|
57
|
+
if (jsonConfigPath.endsWith('.json') && existsSync(jsonConfigPath)) {
|
|
42
58
|
try {
|
|
43
59
|
// TODO makes sense to employ ZOD to validate config
|
|
44
60
|
const jsonConfig = JSON.parse(readFileSync(jsonConfigPath, 'utf8'));
|
|
@@ -69,8 +85,8 @@ export async function initConfig() {
|
|
|
69
85
|
}
|
|
70
86
|
// Helper function to try loading JS config
|
|
71
87
|
async function tryJsConfig() {
|
|
72
|
-
const jsConfigPath = getGslothConfigReadPath(USER_PROJECT_CONFIG_JS);
|
|
73
|
-
if (existsSync(jsConfigPath)) {
|
|
88
|
+
const jsConfigPath = configGlobalSettings.customConfigPath ?? getGslothConfigReadPath(USER_PROJECT_CONFIG_JS);
|
|
89
|
+
if (jsConfigPath.endsWith('.js') && existsSync(jsConfigPath)) {
|
|
74
90
|
try {
|
|
75
91
|
const i = await importExternalFile(jsConfigPath);
|
|
76
92
|
const customConfig = await i.configure();
|
|
@@ -90,8 +106,8 @@ async function tryJsConfig() {
|
|
|
90
106
|
}
|
|
91
107
|
// Helper function to try loading MJS config
|
|
92
108
|
async function tryMjsConfig() {
|
|
93
|
-
const mjsConfigPath = getGslothConfigReadPath(USER_PROJECT_CONFIG_MJS);
|
|
94
|
-
if (existsSync(mjsConfigPath)) {
|
|
109
|
+
const mjsConfigPath = configGlobalSettings.customConfigPath ?? getGslothConfigReadPath(USER_PROJECT_CONFIG_MJS);
|
|
110
|
+
if (mjsConfigPath.endsWith('.mjs') && existsSync(mjsConfigPath)) {
|
|
95
111
|
try {
|
|
96
112
|
const i = await importExternalFile(mjsConfigPath);
|
|
97
113
|
const customConfig = await i.configure();
|
|
@@ -117,7 +133,7 @@ async function tryMjsConfig() {
|
|
|
117
133
|
/**
|
|
118
134
|
* Process JSON LLM config by creating the appropriate LLM instance
|
|
119
135
|
* @param jsonConfig - The parsed JSON config
|
|
120
|
-
* @returns Promise<
|
|
136
|
+
* @returns Promise<GthConfig>
|
|
121
137
|
*/
|
|
122
138
|
export async function tryJsonConfig(jsonConfig) {
|
|
123
139
|
try {
|
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,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C;IACpD,MAAM,MAAM,GAAG,aAA0B,CAAC;IAC1C,MAAM,YAAY,GAAG;QACnB,GAAG,cAAc;QACjB,GAAG,MAAM;QACT,QAAQ,EAAE,EAAE,GAAG,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,17 +1,30 @@
|
|
|
1
1
|
import type { Message } from '#src/modules/types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { GthConfig } from '#src/config.js';
|
|
3
3
|
import { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
4
4
|
import { GthAgentInterface, GthCommand } from '#src/core/types.js';
|
|
5
5
|
import { StatusUpdateCallback } from '#src/core/GthLangChainAgent.js';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Agent simplifies interaction with LLM and reduces it to calling a few methods
|
|
8
|
+
* {@link #init} and {@link #processMessages}.
|
|
9
|
+
*/
|
|
7
10
|
export declare class GthAgentRunner {
|
|
8
11
|
private statusUpdate;
|
|
9
12
|
private verbose;
|
|
10
13
|
private agent;
|
|
11
14
|
private config;
|
|
12
|
-
|
|
15
|
+
private runConfig;
|
|
16
|
+
constructor(statusUpdate: StatusUpdateCallback);
|
|
13
17
|
setVerbose(verbose: boolean): void;
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Init is split into a separate method. This may create a number of connections,
|
|
20
|
+
* and we'd better have an instance by that moment, for the case things will go wrong,
|
|
21
|
+
* so we can wrap init into try-catch and then call {@link #cleanup} within finally.
|
|
22
|
+
*/
|
|
23
|
+
init(command: GthCommand | undefined, configIn: GthConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* processMessages deals with both streaming and non-streaming approaches.
|
|
26
|
+
*/
|
|
27
|
+
processMessages(messages: Message[]): Promise<string>;
|
|
28
|
+
getAgent(): GthAgentInterface | null;
|
|
16
29
|
cleanup(): Promise<void>;
|
|
17
30
|
}
|
|
@@ -1,38 +1,59 @@
|
|
|
1
1
|
import { GthLangChainAgent } from '#src/core/GthLangChainAgent.js';
|
|
2
|
+
import { executeHooks } from '#src/utils.js';
|
|
3
|
+
import { getNewRunnableConfig } from '#src/llmUtils.js';
|
|
4
|
+
/**
|
|
5
|
+
* Agent simplifies interaction with LLM and reduces it to calling a few methods
|
|
6
|
+
* {@link #init} and {@link #processMessages}.
|
|
7
|
+
*/
|
|
2
8
|
export class GthAgentRunner {
|
|
3
9
|
statusUpdate;
|
|
4
10
|
verbose = false;
|
|
5
11
|
agent = null;
|
|
6
12
|
config = null;
|
|
7
|
-
|
|
13
|
+
runConfig = null;
|
|
14
|
+
constructor(statusUpdate) {
|
|
8
15
|
this.statusUpdate = statusUpdate;
|
|
9
|
-
this.agent = agent || null;
|
|
10
16
|
}
|
|
11
17
|
setVerbose(verbose) {
|
|
12
18
|
this.verbose = verbose;
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Init is split into a separate method. This may create a number of connections,
|
|
22
|
+
* and we'd better have an instance by that moment, for the case things will go wrong,
|
|
23
|
+
* so we can wrap init into try-catch and then call {@link #cleanup} within finally.
|
|
24
|
+
*/
|
|
14
25
|
async init(command, configIn, checkpointSaver) {
|
|
15
26
|
this.config = configIn;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
this.runConfig = this.config.hooks?.createRunnableConfig
|
|
28
|
+
? await this.config.hooks.createRunnableConfig(this.config)
|
|
29
|
+
: getNewRunnableConfig();
|
|
30
|
+
this.agent = this.config.hooks?.createAgent
|
|
31
|
+
? await this.config.hooks?.createAgent(this.config)
|
|
32
|
+
: new GthLangChainAgent(this.statusUpdate);
|
|
20
33
|
// Set verbose mode before initialization so it can be used during init
|
|
21
34
|
if (this.verbose) {
|
|
22
35
|
this.agent.setVerbose(this.verbose);
|
|
23
36
|
}
|
|
24
|
-
//
|
|
37
|
+
// Call before init hook
|
|
38
|
+
await executeHooks(this.config.hooks?.beforeAgentInit, this);
|
|
39
|
+
// Initialize the agent
|
|
25
40
|
await this.agent.init(command, configIn, checkpointSaver);
|
|
41
|
+
// Call after init hook
|
|
42
|
+
await executeHooks(this.config.hooks?.afterAgentInit, this);
|
|
26
43
|
}
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
/**
|
|
45
|
+
* processMessages deals with both streaming and non-streaming approaches.
|
|
46
|
+
*/
|
|
47
|
+
async processMessages(messages) {
|
|
48
|
+
if (!this.agent || !this.config || !this.runConfig) {
|
|
29
49
|
throw new Error('AgentRunner not initialized. Call init() first.');
|
|
30
50
|
}
|
|
51
|
+
await executeHooks(this.config.hooks?.beforeProcessMessages, this, messages, this.runConfig);
|
|
31
52
|
try {
|
|
32
53
|
// Decision: Use streaming or non-streaming based on config
|
|
33
54
|
if (this.config.streamOutput) {
|
|
34
55
|
// Use streaming
|
|
35
|
-
const stream = await this.agent.stream(messages, runConfig);
|
|
56
|
+
const stream = await this.agent.stream(messages, this.runConfig);
|
|
36
57
|
let result = '';
|
|
37
58
|
try {
|
|
38
59
|
for await (const chunk of stream) {
|
|
@@ -47,7 +68,7 @@ export class GthAgentRunner {
|
|
|
47
68
|
}
|
|
48
69
|
else {
|
|
49
70
|
// Use non-streaming
|
|
50
|
-
return await this.agent.invoke(messages, runConfig);
|
|
71
|
+
return await this.agent.invoke(messages, this.runConfig);
|
|
51
72
|
}
|
|
52
73
|
}
|
|
53
74
|
catch (error) {
|
|
@@ -55,6 +76,10 @@ export class GthAgentRunner {
|
|
|
55
76
|
throw new Error(`Agent processing failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
56
77
|
}
|
|
57
78
|
}
|
|
79
|
+
// noinspection JSUnusedGlobalSymbols
|
|
80
|
+
getAgent() {
|
|
81
|
+
return this.agent;
|
|
82
|
+
}
|
|
58
83
|
async cleanup() {
|
|
59
84
|
if (this.agent && 'cleanup' in this.agent && typeof this.agent.cleanup === 'function') {
|
|
60
85
|
await this.agent.cleanup();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GthAgentRunner.js","sourceRoot":"","sources":["../../src/core/GthAgentRunner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gCAAgC,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,MAAM,kBAAkB,CAAC;AAExD;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,YAAY,CAAuB;IACnC,OAAO,GAAY,KAAK,CAAC;IACzB,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,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CACR,OAA+B,EAC/B,QAAmB,EACnB,eAAiD;QAEjD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;QAEvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,oBAAoB;YACtD,CAAC,CAAC,MAAM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C7B,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GthConfig } from '#src/config.js';
|
|
2
2
|
import type { Connection } from '@langchain/mcp-adapters';
|
|
3
3
|
import { MultiServerMCPClient } from '@langchain/mcp-adapters';
|
|
4
4
|
import { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
@@ -15,7 +15,7 @@ export declare class GthLangChainAgent implements GthAgentInterface {
|
|
|
15
15
|
private config;
|
|
16
16
|
constructor(statusUpdate: StatusUpdateCallback);
|
|
17
17
|
setVerbose(verbose: boolean): void;
|
|
18
|
-
init(command: GthCommand | undefined, configIn:
|
|
18
|
+
init(command: GthCommand | undefined, configIn: GthConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
19
19
|
/**
|
|
20
20
|
* Invoke LLM with a message and runnable config.
|
|
21
21
|
* For streaming use {@link #stream} method, streaming is preferred if model API supports it.
|
|
@@ -28,12 +28,13 @@ export declare class GthLangChainAgent implements GthAgentInterface {
|
|
|
28
28
|
* When stream is not appropriate use {@link invoke}.
|
|
29
29
|
*/
|
|
30
30
|
stream(messages: Message[], runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
|
|
31
|
+
getMCPClient(): MultiServerMCPClient | null;
|
|
31
32
|
cleanup(): Promise<void>;
|
|
32
|
-
getEffectiveConfig(config:
|
|
33
|
+
getEffectiveConfig(config: GthConfig, command: GthCommand | undefined): GthConfig;
|
|
33
34
|
/**
|
|
34
35
|
* Extract and flatten tools from toolkits
|
|
35
36
|
*/
|
|
36
37
|
private extractAndFlattenTools;
|
|
37
38
|
protected getDefaultMcpServers(): Record<string, Connection>;
|
|
38
|
-
protected getMcpClient(config:
|
|
39
|
+
protected getMcpClient(config: GthConfig): Promise<MultiServerMCPClient | null>;
|
|
39
40
|
}
|