gaunt-sloth-assistant
Version:
[](https://github.com/Galvanized-Pukeko/gaunt-sloth-assistant/actions/workflows/unit-tests.yml) [ • 9.41 kB
TypeScript
import type { GthAgentRunner } from '#src/core/GthAgentRunner.js';
import type { GthAgentInterface } from '#src/core/types.js';
import type { Message } from '#src/modules/types.js';
import { JiraConfig } from '#src/providers/types.js';
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
import { AIMessage } from '@langchain/core/messages';
import { RunnableConfig } from '@langchain/core/runnables';
import type { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
import { BinaryOperatorAggregate, Messages, StateType } from '@langchain/langgraph';
import type { Connection } from '@langchain/mcp-adapters';
/**
* This is a processed Gaunt Sloth config ready to be passed down into components.
*
* Default values can be found in {@link DEFAULT_CONFIG}
*/
export interface GthConfig {
llm: BaseChatModel;
/**
* Content Provider. Provider used to fetch content (usually diff) for `review` or `pr` command.
*
* {@link DEFAULT_CONFIG#contentProvider}
*/
contentProvider: string;
requirementsProvider: string;
projectGuidelines: string;
projectReviewInstructions: string;
filesystem: string[] | 'all' | 'read' | 'none';
builtInTools?: string[];
tools?: StructuredToolInterface[] | BaseToolkit[] | ServerTool[];
/**
* Hooks are only available on JS config
*/
hooks?: {
createRunnableConfig?: (config: GthConfig) => Promise<RunnableConfig>;
createAgent?: (config: GthConfig) => Promise<GthAgentInterface>;
beforeAgentInit?: RunnerHook | RunnerHook[];
/**
* After agent init.
*/
afterAgentInit?: RunnerHook | RunnerHook[];
beforeProcessMessages?: BeforeMessageHook | BeforeMessageHook[];
/**
* LangGraph preModelHook
* Provide 'skip' if you don't need default hook.
*/
preModelHook?: LangChainHook;
/**
* LangGraph postModelHook
* Provide 'skip' if you don't need default hook.
*/
postModelHook?: LangChainHook;
};
/**
* Stream output. Some models do not support streaming. Set value to `false` for them.
*
* {@link DEFAULT_CONFIG#streamOutput}
*/
streamOutput: boolean;
/**
* Should the output be written to md file.
* (e.g. gth_2025-07-26_22-59-06_REVIEW.md).
* Can be set to false with `-wn` or `-w0`
* Can be set to a specific filename or path by passing a string (e.g. `-w review.md`)
* Please note the string does not accept absolute path, but allows to exit project with `..` if necessary.
*/
writeOutputToFile: boolean | string;
/**
* Use colour in output
*/
useColour: boolean;
/**
* Stream session log instead of writing it when inference streaming is complete.
* (only works when {@link streamOutput} is true)
*/
streamSessionInferenceLog: boolean;
/**
* Allow inference to be interrupted with esc. Only has an effect in TTY mode.
*/
canInterruptInferenceWithEsc: boolean;
/**
* Log messages and events to gaunt-sloth.log,
* use llm.verbose or `gth --verbose` as more intrusive option, setting verbose to LangChain / LangGraph
*/
debugLog?: boolean;
customToolsConfig?: CustomToolsConfig;
requirementsProviderConfig?: Record<string, unknown>;
contentProviderConfig?: Record<string, unknown>;
mcpServers?: Record<string, Connection>;
builtInToolsConfig?: BuiltInToolsConfig;
commands?: {
pr?: {
contentProvider?: string;
requirementsProvider?: string;
filesystem?: string[] | 'all' | 'read' | 'none';
builtInTools?: string[];
logWorkForReviewInSeconds?: number;
};
review?: {
requirementsProvider?: string;
contentProvider?: string;
filesystem?: string[] | 'all' | 'read' | 'none';
builtInTools?: string[];
};
ask?: {
filesystem?: string[] | 'all' | 'read' | 'none';
builtInTools?: string[];
};
chat?: {
filesystem?: string[] | 'all' | 'read' | 'none';
builtInTools?: string[];
};
code?: {
filesystem?: string[] | 'all' | 'read' | 'none';
builtInTools?: string[];
devTools?: GthDevToolsConfig;
};
};
modelDisplayName?: string;
}
/**
* Server tools such as Anthropic Web Search.
* These tools are meant to be magic objects like
* `{"type": "web_search_20250305", "name": "web_search", "max_uses": 10}`,
* AI Provider does the rest of the magic on their side.
*/
export interface ServerTool extends Record<string, unknown> {
type: string;
name?: string;
}
type LangChainHook = (state: StateType<{
messages: BinaryOperatorAggregate<AIMessage[], Messages>;
}>) => StateType<{
messages: BinaryOperatorAggregate<AIMessage[], Messages>;
}>;
type RunnerHook = (runner: GthAgentRunner) => Promise<void>;
type BeforeMessageHook = (runner: GthAgentRunner, message: Message[], runConfig: RunnableConfig) => Promise<void>;
/**
* Raw, unprocessed Gaunt Sloth config.
*/
export interface RawGthConfig extends Omit<GthConfig, 'llm'> {
llm: LLMConfig;
preModelHook?: LangChainHook | 'skip';
postModelHook?: LangChainHook | 'skip';
}
export type CustomToolsConfig = Record<string, object>;
export type BuiltInToolsConfig = {
jira: JiraConfig;
};
/**
* Config for {@link GthDevToolkit}.
* Tools are not applied when config is not provided.
* Only available in `code` mode.
*/
export interface GthDevToolsConfig {
/**
* Optional shell command to run tests.
* Not applied when config is not provided.
*/
run_tests?: string;
/**
* Optional shell command to run static analysis (lint).
* Not applied when config is not provided.
*/
run_lint?: string;
/**
* Optional shell command to run the build.
* Not applied when config is not provided.
*/
run_build?: string;
/**
* Optional shell command to run a single test file.
* Supports command interpolation with the `${testPath}` placeholder.
* Example: "npm test -- ${testPath}" or "jest ${testPath}"
* Example: "npm test" - the test will simply be appended
* Not applied when config is not provided.
*/
run_single_test?: string;
}
export interface LLMConfig extends Record<string, unknown> {
type: string;
model: string;
configuration: Record<string, unknown>;
apiKeyEnvironmentVariable?: string;
}
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai", "xai", "openrouter"];
export type ConfigType = (typeof availableDefaultConfigs)[number];
export interface CommandLineConfigOverrides {
/**
* Custom config path
*/
customConfigPath?: string;
/**
* Set LangChain/LangGraph to verbose mode,
* causing LangChain/LangGraph to log many details to the console.
* debugLog from config.ts may be a less intrusive option.
*/
verbose?: boolean;
/**
* Should the output be written to md file.
* (e.g. gth_2025-07-26_22-59-06_REVIEW.md).
* Can be set to false with `-wn` or `-w0`
* Can be set to a specific filename or path by passing a string (e.g. `-w review.md`)
* Please note the string does not accept absolute path, but allows to exit project with `..` if necessary.
*/
writeOutputToFile?: boolean | string;
}
/**
* Default config
*/
export declare const DEFAULT_CONFIG: {
readonly contentProvider: "file";
readonly requirementsProvider: "file";
readonly projectGuidelines: ".gsloth.guidelines.md";
readonly projectReviewInstructions: ".gsloth.review.md";
readonly filesystem: "read";
readonly debugLog: false;
/**
* Default provider for both requirements and content is GitHub.
* It needs GitHub CLI (gh).
*
* `github` content provider uses `gh pr diff NN` internally. {@link src/providers/ghPrDiffProvider.ts!}
*
*
* `github` requirements provider `gh issue view NN` internally
*/
readonly commands: {
readonly pr: {
readonly contentProvider: "github";
readonly requirementsProvider: "github";
};
readonly code: {
readonly filesystem: "all";
};
};
readonly streamOutput: true;
readonly writeOutputToFile: true;
readonly useColour: true;
readonly streamSessionInferenceLog: true;
readonly canInterruptInferenceWithEsc: true;
};
/**
* Initialize configuration by loading from available config files
* @returns The loaded GthConfig
*/
export declare function initConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
/**
* Process JSON LLM config by creating the appropriate LLM instance
* @param jsonConfig - The parsed JSON config
* @param commandLineConfigOverrides - command line config overrides
* @returns Promise<GthConfig>
*/
export declare function tryJsonConfig(jsonConfig: RawGthConfig, commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
export declare function createProjectConfig(configType: string): Promise<void>;
export declare function writeProjectReviewPreamble(): void;
export {};