@autobe/agent
Version:
AI backend server code generator
62 lines • 2.99 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.orchestrateInterface = void 0;
const uuid_1 = require("uuid");
const orchestrateInterfaceComplement_1 = require("./orchestrateInterfaceComplement");
const orchestrateInterfaceComponents_1 = require("./orchestrateInterfaceComponents");
const orchestrateInterfaceEndpoints_1 = require("./orchestrateInterfaceEndpoints");
const orchestrateInterfaceOperations_1 = require("./orchestrateInterfaceOperations");
const orchestrateInterface = (ctx) => (props) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d;
// ENDPOINTS
const start = new Date();
const init = yield (0, orchestrateInterfaceEndpoints_1.orchestrateInterfaceEndpoints)(ctx);
if (init.type === "assistantMessage") {
ctx.dispatch(init);
ctx.histories().push(init);
return init;
}
else
ctx.dispatch(init);
// OPERATIONS
const operations = yield (0, orchestrateInterfaceOperations_1.orchestrateInterfaceOperations)(ctx, init.endpoints);
// TYPE SCHEMAS
const document = {
operations,
components: yield (0, orchestrateInterfaceComponents_1.orchestrateInterfaceComponents)(ctx, operations),
};
document.components = yield (0, orchestrateInterfaceComplement_1.orchestrateInterfaceComplement)(ctx, document);
// DO COMPILE
const result = {
type: "interface",
id: (0, uuid_1.v4)(),
document,
files: yield ctx.compiler.interface(document),
reason: props.reason,
step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0,
created_at: start.toISOString(),
completed_at: new Date().toISOString(),
};
ctx.state().interface = result;
ctx.histories().push(result);
ctx.dispatch({
type: "interfaceComplete",
files: result.files,
document: result.document,
created_at: start.toISOString(),
reason: props.reason,
step: (_d = (_c = ctx.state().analyze) === null || _c === void 0 ? void 0 : _c.step) !== null && _d !== void 0 ? _d : 0,
});
return result;
});
exports.orchestrateInterface = orchestrateInterface;
//# sourceMappingURL=orchestrateInterface.js.map