@gaunt-sloth/core 0.0.1
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.backstory.md +17 -0
- package/.gsloth.chat.md +11 -0
- package/.gsloth.code.md +27 -0
- package/.gsloth.guidelines.md +1 -0
- package/.gsloth.review.md +15 -0
- package/.gsloth.system.md +10 -0
- package/README.md +27 -0
- package/dist/config.d.ts +533 -0
- package/dist/config.js +412 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/GthAgentRunner.d.ts +27 -0
- package/dist/core/GthAgentRunner.js +109 -0
- package/dist/core/GthAgentRunner.js.map +1 -0
- package/dist/core/GthLangChainAgent.d.ts +56 -0
- package/dist/core/GthLangChainAgent.js +355 -0
- package/dist/core/GthLangChainAgent.js.map +1 -0
- package/dist/core/types.d.ts +39 -0
- package/dist/core/types.js +16 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/anthropic.d.ts +7 -0
- package/dist/providers/anthropic.js +34 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/deepseek.d.ts +4 -0
- package/dist/providers/deepseek.js +30 -0
- package/dist/providers/deepseek.js.map +1 -0
- package/dist/providers/fake.d.ts +3 -0
- package/dist/providers/fake.js +12 -0
- package/dist/providers/fake.js.map +1 -0
- package/dist/providers/google-genai.d.ts +7 -0
- package/dist/providers/google-genai.js +34 -0
- package/dist/providers/google-genai.js.map +1 -0
- package/dist/providers/groq.d.ts +4 -0
- package/dist/providers/groq.js +30 -0
- package/dist/providers/groq.js.map +1 -0
- package/dist/providers/openai.d.ts +5 -0
- package/dist/providers/openai.js +46 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openrouter.d.ts +5 -0
- package/dist/providers/openrouter.js +57 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/vertexai.d.ts +7 -0
- package/dist/providers/vertexai.js +41 -0
- package/dist/providers/vertexai.js.map +1 -0
- package/dist/providers/xai.d.ts +4 -0
- package/dist/providers/xai.js +30 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/state/artifactStore.d.ts +21 -0
- package/dist/state/artifactStore.js +30 -0
- package/dist/state/artifactStore.js.map +1 -0
- package/dist/utils/ProgressIndicator.d.ts +7 -0
- package/dist/utils/ProgressIndicator.js +26 -0
- package/dist/utils/ProgressIndicator.js.map +1 -0
- package/dist/utils/aiignoreUtils.d.ts +29 -0
- package/dist/utils/aiignoreUtils.js +82 -0
- package/dist/utils/aiignoreUtils.js.map +1 -0
- package/dist/utils/binaryOutputUtils.d.ts +13 -0
- package/dist/utils/binaryOutputUtils.js +138 -0
- package/dist/utils/binaryOutputUtils.js.map +1 -0
- package/dist/utils/consoleUtils.d.ts +76 -0
- package/dist/utils/consoleUtils.js +230 -0
- package/dist/utils/consoleUtils.js.map +1 -0
- package/dist/utils/debugUtils.d.ts +20 -0
- package/dist/utils/debugUtils.js +89 -0
- package/dist/utils/debugUtils.js.map +1 -0
- package/dist/utils/fileUtils.d.ts +68 -0
- package/dist/utils/fileUtils.js +216 -0
- package/dist/utils/fileUtils.js.map +1 -0
- package/dist/utils/globalConfigUtils.d.ts +28 -0
- package/dist/utils/globalConfigUtils.js +61 -0
- package/dist/utils/globalConfigUtils.js.map +1 -0
- package/dist/utils/llmUtils.d.ts +39 -0
- package/dist/utils/llmUtils.js +153 -0
- package/dist/utils/llmUtils.js.map +1 -0
- package/dist/utils/stringUtils.d.ts +4 -0
- package/dist/utils/stringUtils.js +10 -0
- package/dist/utils/stringUtils.js.map +1 -0
- package/dist/utils/systemUtils.d.ts +70 -0
- package/dist/utils/systemUtils.js +207 -0
- package/dist/utils/systemUtils.js.map +1 -0
- package/dist/utils/vertexaiUtils.d.ts +2 -0
- package/dist/utils/vertexaiUtils.js +18 -0
- package/dist/utils/vertexaiUtils.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { createInterface } from 'node:readline/promises';
|
|
4
|
+
import { displayInfo, displayWarning } from './consoleUtils.js';
|
|
5
|
+
import { createWriteStream, readFileSync } from 'node:fs';
|
|
6
|
+
import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
|
|
7
|
+
const innerState = {
|
|
8
|
+
installDir: undefined,
|
|
9
|
+
stringFromStdin: '',
|
|
10
|
+
useColour: false,
|
|
11
|
+
waitForEscapeCallback: undefined,
|
|
12
|
+
logWriteStream: undefined,
|
|
13
|
+
};
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const keypressHandler = (callback) => (_, key) => {
|
|
16
|
+
if (key?.name === 'escape' || key?.name === 'q') {
|
|
17
|
+
displayWarning('\nInterrupting...');
|
|
18
|
+
callback();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const waitForEscape = (callback, enabled) => {
|
|
23
|
+
if (!enabled) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
process.stdin.setRawMode(true);
|
|
27
|
+
innerState.waitForEscapeCallback = keypressHandler(callback);
|
|
28
|
+
process.stdin.on('keypress', innerState.waitForEscapeCallback);
|
|
29
|
+
displayInfo(`
|
|
30
|
+
┌--------------------------------------┐
|
|
31
|
+
│ Press Escape or Q to interrupt Agent │
|
|
32
|
+
└--------------------------------------┘
|
|
33
|
+
`);
|
|
34
|
+
};
|
|
35
|
+
export const stopWaitingForEscape = () => {
|
|
36
|
+
if (innerState.waitForEscapeCallback) {
|
|
37
|
+
process.stdin.setRawMode(false);
|
|
38
|
+
process.stdin.off('keypress', innerState.waitForEscapeCallback);
|
|
39
|
+
innerState.waitForEscapeCallback = undefined;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const setRawMode = (rawMode) => {
|
|
43
|
+
if (process.stdin.isTTY) {
|
|
44
|
+
process.stdin.setRawMode(rawMode);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const initLogStream = (logFileName) => {
|
|
48
|
+
try {
|
|
49
|
+
// Close existing stream if present
|
|
50
|
+
if (innerState.logWriteStream) {
|
|
51
|
+
innerState.logWriteStream.end();
|
|
52
|
+
}
|
|
53
|
+
// Create new write stream with append mode
|
|
54
|
+
innerState.logWriteStream = createWriteStream(logFileName, {
|
|
55
|
+
flags: 'a',
|
|
56
|
+
autoClose: true,
|
|
57
|
+
});
|
|
58
|
+
// Handle stream errors
|
|
59
|
+
innerState.logWriteStream.on('error', (err) => {
|
|
60
|
+
displayWarning(`Log stream error: ${err.message}`);
|
|
61
|
+
innerState.logWriteStream = undefined;
|
|
62
|
+
});
|
|
63
|
+
// Handle stream close
|
|
64
|
+
innerState.logWriteStream.on('close', () => {
|
|
65
|
+
innerState.logWriteStream = undefined;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
displayWarning(`Failed to create log stream: ${err instanceof Error ? err.message : String(err)}`);
|
|
70
|
+
innerState.logWriteStream = undefined;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export const writeToLogStream = (message) => {
|
|
74
|
+
if (innerState.logWriteStream && !innerState.logWriteStream.destroyed) {
|
|
75
|
+
innerState.logWriteStream.write(message);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const closeLogStream = () => {
|
|
79
|
+
if (innerState.logWriteStream && !innerState.logWriteStream.destroyed) {
|
|
80
|
+
innerState.logWriteStream.end();
|
|
81
|
+
innerState.logWriteStream = undefined;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// Ensure log stream is closed on process exit
|
|
85
|
+
process.on('exit', () => {
|
|
86
|
+
closeLogStream();
|
|
87
|
+
});
|
|
88
|
+
process.on('SIGINT', () => {
|
|
89
|
+
closeLogStream();
|
|
90
|
+
process.exit(0);
|
|
91
|
+
});
|
|
92
|
+
process.on('SIGTERM', () => {
|
|
93
|
+
closeLogStream();
|
|
94
|
+
process.exit(0);
|
|
95
|
+
});
|
|
96
|
+
// Process-related functions and objects
|
|
97
|
+
/**
|
|
98
|
+
* The process.cwd() has a weird behaviour when the app is a part of monorepo,
|
|
99
|
+
* always returning the directory of this specific project,
|
|
100
|
+
* this causes integration tests to fail, because they are specifically testing ability to respect actual current dirs.
|
|
101
|
+
* Gaunt Sloth is a command line tool and it is always supposed to function in the current directory.
|
|
102
|
+
* Using INIT_CWD forces to always use actual CWD. cwd() fallback is just in case.
|
|
103
|
+
* In environments where INIT_CWD is available (npm and alike) - INIT_CWD is the correct choice,
|
|
104
|
+
* since they are likely to juggle the process.cwd(), where it is unavailable process.cwd() is used.
|
|
105
|
+
*/
|
|
106
|
+
export const getCurrentWorkDir = () => process.env?.INIT_CWD ?? process.cwd();
|
|
107
|
+
export const getInstallDir = () => {
|
|
108
|
+
if (innerState.installDir) {
|
|
109
|
+
return innerState.installDir;
|
|
110
|
+
}
|
|
111
|
+
throw new Error('Install directory not set');
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Cached string from stdin. Should only be called after readStdin completes execution.
|
|
115
|
+
*/
|
|
116
|
+
export const getStringFromStdin = () => {
|
|
117
|
+
return innerState.stringFromStdin;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Get the current useColour setting.
|
|
121
|
+
*/
|
|
122
|
+
export const getUseColour = () => {
|
|
123
|
+
return innerState.useColour;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Set the useColour setting.
|
|
127
|
+
*/
|
|
128
|
+
export const setUseColour = (useColour) => {
|
|
129
|
+
innerState.useColour = useColour;
|
|
130
|
+
};
|
|
131
|
+
export const isTTY = () => !!stdin.isTTY;
|
|
132
|
+
export const exit = (code) => process.exit(code || 0);
|
|
133
|
+
export const stdin = process.stdin;
|
|
134
|
+
export const stdout = process.stdout;
|
|
135
|
+
export const argv = process.argv;
|
|
136
|
+
export const env = process.env;
|
|
137
|
+
export const setExitCode = (code) => {
|
|
138
|
+
process.exitCode = code;
|
|
139
|
+
};
|
|
140
|
+
export { createInterface };
|
|
141
|
+
// noinspection JSUnusedGlobalSymbols
|
|
142
|
+
/**
|
|
143
|
+
* Provide the path to the entry point of the application.
|
|
144
|
+
* This is used to set the install directory.
|
|
145
|
+
* This is called from cli.js root entry point.
|
|
146
|
+
*/
|
|
147
|
+
export const setEntryPoint = (indexJs) => {
|
|
148
|
+
const filePath = fileURLToPath(indexJs);
|
|
149
|
+
const dirPath = dirname(filePath);
|
|
150
|
+
innerState.installDir = resolve(dirPath);
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Asynchronously reads the stdin and stores it as a string,
|
|
154
|
+
* it can later be retrieved with getStringFromStdin.
|
|
155
|
+
*/
|
|
156
|
+
export function readStdin(program) {
|
|
157
|
+
return new Promise((resolvePromise) => {
|
|
158
|
+
if (stdin.isTTY || program.getOptionValue('nopipe')) {
|
|
159
|
+
program.parseAsync().then(() => resolvePromise());
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// Support piping diff into gsloth
|
|
163
|
+
const progressIndicator = new ProgressIndicator('reading STDIN', true);
|
|
164
|
+
stdin.on('readable', function () {
|
|
165
|
+
const chunk = this.read();
|
|
166
|
+
progressIndicator.indicate();
|
|
167
|
+
if (chunk !== null) {
|
|
168
|
+
const chunkStr = chunk.toString('utf8');
|
|
169
|
+
innerState.stringFromStdin = innerState.stringFromStdin + chunkStr;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
stdin.on('end', function () {
|
|
173
|
+
program.parseAsync(argv).then(() => resolvePromise());
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// Console-related functions
|
|
179
|
+
export const log = (message) => console.log(message);
|
|
180
|
+
export const error = (message) => console.error(message);
|
|
181
|
+
export const warn = (message) => console.warn(message);
|
|
182
|
+
export const info = (message) => console.info(message);
|
|
183
|
+
export const debug = (message) => console.debug(message);
|
|
184
|
+
export const stream = (chunk) => process.stdout.write(chunk);
|
|
185
|
+
export async function execAsync(command) {
|
|
186
|
+
const { exec } = await import('node:child_process');
|
|
187
|
+
return new Promise((resolve, reject) => {
|
|
188
|
+
exec(command, (error, stdout, stderr) => {
|
|
189
|
+
if (error) {
|
|
190
|
+
reject(error);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (stderr) {
|
|
194
|
+
reject(new Error(stderr));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
resolve(stdout.trim());
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
export function getSlothVersion() {
|
|
202
|
+
const installDir = getInstallDir();
|
|
203
|
+
const jsonPath = resolve(installDir, 'package.json');
|
|
204
|
+
const projectJson = readFileSync(jsonPath, { encoding: 'utf8' });
|
|
205
|
+
return JSON.parse(projectJson).version;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=systemUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemUtils.js","sourceRoot":"","sources":["../../src/utils/systemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,eAAe,EAAuC,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAoB,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AA6BpE,MAAM,UAAU,GAAe;IAC7B,UAAU,EAAE,SAAS;IACrB,eAAe,EAAE,EAAE;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Llm(llm) {
|
|
2
|
+
if (!llm || typeof llm !== 'object') {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const model = llm;
|
|
6
|
+
return model._platform === 'gcp';
|
|
7
|
+
}
|
|
8
|
+
export function enhanceVertexUnauthorizedMessage(originalMessage, llm) {
|
|
9
|
+
if (!isVertexGoogleLlm(llm) || !/\b401\b|unauthori[sz]ed/i.test(originalMessage)) {
|
|
10
|
+
return originalMessage;
|
|
11
|
+
}
|
|
12
|
+
return (`${originalMessage}\n` +
|
|
13
|
+
'Vertex AI authentication failed (401). ' +
|
|
14
|
+
'If you use ADC, run `gcloud auth application-default login`. ' +
|
|
15
|
+
'Also make sure `GOOGLE_API_KEY` is unset or not a Google AI Studio key, ' +
|
|
16
|
+
'since AI Studio keys are not valid for Vertex AI endpoints.');
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=vertexaiUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertexaiUtils.js","sourceRoot":"","sources":["../../src/utils/vertexaiUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,GAA6B,CAAC;IAC5C,OAAO,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,eAAuB,EAAE,GAAY;IACpF,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;QACjF,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,OAAO,CACL,GAAG,eAAe,IAAI;QACtB,yCAAyC;QACzC,+DAA+D;QAC/D,0EAA0E;QAC1E,6DAA6D,CAC9D,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gaunt-sloth/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Core utilities and types for Gaunt Sloth",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Andrew Kondratev",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/index.js",
|
|
15
|
+
"./*.js": "./dist/*.js"
|
|
16
|
+
},
|
|
17
|
+
"imports": {
|
|
18
|
+
"#src/*.js": "./dist/*.js"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@langchain/core": "^1.1.35",
|
|
22
|
+
"@langchain/langgraph": "^1.2.5",
|
|
23
|
+
"langchain": "^1.2.36"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@langchain/anthropic": "^1.3.25",
|
|
27
|
+
"@langchain/deepseek": "^1.0.18",
|
|
28
|
+
"@langchain/google": "^0.1.8",
|
|
29
|
+
"@langchain/groq": "^1.1.5",
|
|
30
|
+
"@langchain/openai": "^1.2.0",
|
|
31
|
+
"@langchain/xai": "^1.3.10"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"@langchain/anthropic": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"@langchain/deepseek": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"@langchain/google": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"@langchain/groq": {
|
|
44
|
+
"optional": true
|
|
45
|
+
},
|
|
46
|
+
"@langchain/openai": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"@langchain/xai": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"./dist/*",
|
|
55
|
+
".gsloth.*.md"
|
|
56
|
+
]
|
|
57
|
+
}
|