UNPKG

autoagent-cli

Version:

Run autonomous AI agents using Claude or Gemini for task execution

43 lines (42 loc) 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_REFLECTION_CONFIG = void 0; exports.validateReflectionConfig = validateReflectionConfig; exports.mergeReflectionConfig = mergeReflectionConfig; exports.DEFAULT_REFLECTION_CONFIG = { enabled: true, maxIterations: 3, improvementThreshold: 0.1, skipForSimpleSpecs: true }; function validateReflectionConfig(config) { const mergedConfig = { ...exports.DEFAULT_REFLECTION_CONFIG, ...config }; if (typeof mergedConfig.enabled !== 'boolean') { throw new Error('Reflection config: enabled must be a boolean'); } if (!Number.isInteger(mergedConfig.maxIterations) || mergedConfig.maxIterations < 1) { throw new Error('Reflection config: maxIterations must be a positive integer'); } if (mergedConfig.maxIterations > 10) { throw new Error('Reflection config: maxIterations must not exceed 10'); } if (typeof mergedConfig.improvementThreshold !== 'number' || mergedConfig.improvementThreshold < 0 || mergedConfig.improvementThreshold > 1) { throw new Error('Reflection config: improvementThreshold must be a number between 0 and 1'); } if (typeof mergedConfig.skipForSimpleSpecs !== 'boolean') { throw new Error('Reflection config: skipForSimpleSpecs must be a boolean'); } return mergedConfig; } function mergeReflectionConfig(fileConfig, cliConfig) { const cleanFileConfig = fileConfig ? Object.fromEntries(Object.entries(fileConfig).filter(([_, value]) => value !== undefined)) : {}; const cleanCliConfig = cliConfig ? Object.fromEntries(Object.entries(cliConfig).filter(([_, value]) => value !== undefined)) : {}; const mergedConfig = { ...exports.DEFAULT_REFLECTION_CONFIG, ...cleanFileConfig, ...cleanCliConfig }; return validateReflectionConfig(mergedConfig); }