UNPKG

@autobe/agent

Version:

AI backend server code generator

39 lines 2.13 kB
"use strict"; 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.orchestrateRealizeCorrectWithRetry = orchestrateRealizeCorrectWithRetry; function orchestrateRealizeCorrectWithRetry(props) { return __awaiter(this, void 0, void 0, function* () { const process = (functions) => __awaiter(this, void 0, void 0, function* () { props.addProgress(functions.length); const casted = yield props.correctCasting(functions); return yield props.correctOverall(casted); }); const partition = (results) => ({ success: results.filter((r) => r.success).map((r) => r.function), failures: results.filter((r) => !r.success).map((r) => r.function), }); // first attempt const initial = partition(yield process(yield props.write())); const success = initial.success; let failures = initial.failures; // retry loop const limit = Math.max(Math.floor(4 /* AutoBeConfigConstant.COMPILER_RETRY */ / 2), 1); for (let i = 0; failures.length !== 0 && i < limit; i++) { const retry = partition(yield process(yield props.rewrite(failures))); success.push(...retry.success); failures = retry.failures; } // remaining failures are included as-is return [...success, ...failures]; }); } //# sourceMappingURL=orchestrateRealizeCorrectWithRetry.js.map