UNPKG

@autobe/agent

Version:

AI backend server code generator

48 lines 2.83 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.orchestrateInterfaceEndpointOverall = void 0; const utils_1 = require("@autobe/utils"); const tstl_1 = require("tstl"); const executeCachedBatch_1 = require("../../utils/executeCachedBatch"); const forceRetry_1 = require("../../utils/forceRetry"); const orchestrateInterfaceEndpointWrite_1 = require("./orchestrateInterfaceEndpointWrite"); const AutoBeInterfaceEndpointProgrammer_1 = require("./programmers/AutoBeInterfaceEndpointProgrammer"); const orchestrateInterfaceEndpointOverall = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () { const matrix = yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, props.groups.map((group) => (promptCacheKey) => __awaiter(void 0, void 0, void 0, function* () { const counter = new tstl_1.Singleton(() => ++props.progress.completed); let designs; try { designs = yield (0, forceRetry_1.forceRetry)(() => (0, orchestrateInterfaceEndpointWrite_1.orchestrateInterfaceEndpointWrite)(ctx, Object.assign(Object.assign({}, props), { counter, group, promptCacheKey }))); } catch (error) { counter.get(); throw error; } // review removed — write agents self-review during rewrite loop return designs; }))); return new tstl_1.HashMap(matrix.flat().map((design) => new tstl_1.Pair(design.endpoint, design)), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals) .toJSON() .map((it) => it.second) .filter((design) => { var _a, _b; return AutoBeInterfaceEndpointProgrammer_1.AutoBeInterfaceEndpointProgrammer.filter({ design, kind: props.programmer.kind, actors: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.actors) !== null && _b !== void 0 ? _b : [], }); }); }); exports.orchestrateInterfaceEndpointOverall = orchestrateInterfaceEndpointOverall; //# sourceMappingURL=orchestrateInterfaceEndpointOverall.js.map