cortexweaver
Version:
CortexWeaver is a command-line interface (CLI) tool that orchestrates a swarm of specialized AI agents, powered by Claude Code and Gemini CLI, to assist in software development. It transforms a high-level project plan (plan.md) into a series of coordinate
64 lines • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BudgetEnforcer = void 0;
/**
* BudgetEnforcer handles budget limits and enforcement for the Governor agent
*/
class BudgetEnforcer {
constructor(projectConfig) {
this.projectConfig = projectConfig;
}
/**
* Enforce budget limits from config.json
*/
async enforceBudgets(costData) {
if (!this.projectConfig) {
return {
tokenLimitExceeded: false,
costLimitExceeded: false,
allowContinue: true,
warnings: [],
recommendations: []
};
}
const tokenLimit = this.projectConfig.budget.maxTokens;
const costLimit = this.projectConfig.budget.maxCost;
const tokenUtilization = costData.totalTokens / tokenLimit;
const costUtilization = costData.totalCost / costLimit;
const tokenLimitExceeded = costData.totalTokens > tokenLimit;
const costLimitExceeded = costData.totalCost > costLimit;
const warnings = [];
const recommendations = [];
// Check for approaching limits (90% threshold)
if (tokenUtilization >= 0.9) {
warnings.push('approaching token limit');
}
if (costUtilization >= 0.9) {
warnings.push('approaching cost limit');
}
// Generate recommendations based on usage
if (tokenLimitExceeded || tokenUtilization > 0.8) {
recommendations.push('reduce token usage');
recommendations.push('optimize prompt efficiency');
}
if (costLimitExceeded || costUtilization > 0.8) {
recommendations.push('consider increasing budget');
recommendations.push('use more cost-effective models');
}
return {
tokenLimitExceeded,
costLimitExceeded,
allowContinue: !tokenLimitExceeded && !costLimitExceeded,
warnings,
recommendations
};
}
/**
* Update project config reference
*/
updateProjectConfig(projectConfig) {
this.projectConfig = projectConfig;
}
}
exports.BudgetEnforcer = BudgetEnforcer;
//# sourceMappingURL=budget-enforcer.js.map