import { OnGoalAchievedFunction, OnGoalFailedFunction } from '../../functions/index.js';
export class AgentConfig {
    functions;
    timeout;
    shouldTerminate;
    prompts;
    constructor(promptFactory, functions, timeout, shouldTerminate, overrideDefaultFunctions) {
        this.functions = functions;
        this.timeout = timeout;
        const onGoalAchievedFn = new OnGoalAchievedFunction();
        const onGoalFailedFn = new OnGoalFailedFunction();
        const defaultFunctions = !overrideDefaultFunctions ? [onGoalAchievedFn, onGoalFailedFn] : [];
        const existingFunctions = new Map(functions.map(x => [x.name, x]));
        functions.push(...defaultFunctions.filter(x => !existingFunctions.has(x.name)));
        this.shouldTerminate =
            shouldTerminate ??
                (functionCalled => {
                    return [onGoalAchievedFn.name, onGoalFailedFn.name].includes(functionCalled.name);
                });
        this.prompts = promptFactory(onGoalAchievedFn, onGoalFailedFn);
    }
}
