@jjdenhertog/ai-driven-development
Version:
AI-driven development workflow with learning capabilities for Claude
44 lines • 2.41 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.autoRetryClaude = autoRetryClaude;
const logger_1 = require("../logger");
const checkUsageLimitInSession_1 = require("./checkUsageLimitInSession");
const checkUsageLimitInSession_2 = require("./checkUsageLimitInSession");
function autoRetryClaude(options) {
return __awaiter(this, void 0, void 0, function* () {
const { claudeCommand, logPath } = options;
let sessionReport;
const maxRetries = 3;
let retryCount = 0;
// Execute Claude with retry logic for usage limits
while (retryCount <= maxRetries) {
sessionReport = yield claudeCommand();
// Check for usage limit
const usageLimitInfo = (0, checkUsageLimitInSession_1.checkUsageLimitInSession)(sessionReport);
if (usageLimitInfo === null || usageLimitInfo === void 0 ? void 0 : usageLimitInfo.isUsageLimitReached) {
if (retryCount < maxRetries) {
retryCount++;
(0, logger_1.log)(`Retry attempt ${retryCount}/${maxRetries} due to usage limit`, 'info', undefined, logPath);
yield (0, checkUsageLimitInSession_2.waitForUsageLimitReset)(usageLimitInfo.waitTimeSeconds, usageLimitInfo.resetTimestamp, logPath);
continue;
}
else {
(0, logger_1.log)(`Max retries (${maxRetries}) reached. Giving up.`, 'error', undefined, logPath);
break;
}
}
// If no usage limit reached, break out of retry loop
return sessionReport;
}
});
}
//# sourceMappingURL=autoRetryClaude.js.map