@autobe/agent
Version:
AI backend server code generator
838 lines (834 loc) • 80.3 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.orchestrateInterfaceGroup = orchestrateInterfaceGroup;
const __typia_transform__isTypeUint32 = __importStar(require("typia/lib/internal/_isTypeUint32"));
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport"));
const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize"));
const utils_1 = require("@autobe/utils");
const typia_1 = __importDefault(require("typia"));
const uuid_1 = require("uuid");
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const transformInterfaceGroupHistory_1 = require("./histories/transformInterfaceGroupHistory");
function orchestrateInterfaceGroup(ctx, props) {
return __awaiter(this, void 0, void 0, function* () {
const start = new Date();
const prisma = ctx.state().database;
const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({
dispatch: (e) => ctx.dispatch(e),
state: ctx.state(),
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeInterfaceGroupApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Reasoning: what's missing (preliminary), what you're submitting (write),\nor why you're finalizing (complete)."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryComplete"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPreviousAnalysisSections"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPreviousDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPreviousInterfaceOperations"
},
{
$ref: "#/components/schemas/IAutoBeInterfaceGroupApplication.IWrite"
}
],
discriminator: {
propertyName: "type",
mapping: {
complete: "#/components/schemas/IAutoBePreliminaryComplete",
getAnalysisSections: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections",
getDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas",
getPreviousAnalysisSections: "#/components/schemas/IAutoBePreliminaryGetPreviousAnalysisSections",
getPreviousDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetPreviousDatabaseSchemas",
getPreviousInterfaceOperations: "#/components/schemas/IAutoBePreliminaryGetPreviousInterfaceOperations",
write: "#/components/schemas/IAutoBeInterfaceGroupApplication.IWrite"
}
},
description: "Action to perform. Exhausted preliminary types are removed from the\nunion."
}
},
required: [
"thinking",
"request"
]
},
IAutoBePreliminaryComplete: {
type: "object",
properties: {
type: {
"const": "complete",
description: "Type discriminator for completion request."
}
},
required: [
"type"
],
description: "Finalize the write loop by accepting your most recent `write` as-is.\n\nAfter submitting a `write`, review it yourself thoroughly against the review\nchecklist in your instructions. If you find issues worth fixing, submit\nanother `write` with corrections. When you are satisfied with the quality,\ncall `complete` to finalize.\n\nYou have a maximum of 3 write attempts, but this is a safety cap \u2014 not a\ntarget to fill.\n\nOnly valid after at least one `write` submission \u2014 rejected otherwise."
},
IAutoBePreliminaryGetAnalysisSections: {
type: "object",
properties: {
type: {
"const": "getAnalysisSections",
description: "Type discriminator."
},
sectionIds: {
type: "array",
items: {
type: "integer",
minimum: 0
},
minItems: 1,
maxItems: 100,
description: "Section IDs to retrieve. DO NOT request same IDs already requested in\nprevious calls."
}
},
required: [
"type",
"sectionIds"
],
description: "Request to retrieve individual analysis sections by numeric ID."
},
IAutoBePreliminaryGetDatabaseSchemas: {
type: "object",
properties: {
type: {
"const": "getDatabaseSchemas",
description: "Type discriminator."
},
schemaNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "Database table names to retrieve. DO NOT request same names already\nrequested in previous calls."
}
},
required: [
"type",
"schemaNames"
],
description: "Request to retrieve database schema definitions for context."
},
IAutoBePreliminaryGetPreviousAnalysisSections: {
type: "object",
properties: {
type: {
"const": "getPreviousAnalysisSections",
description: "Type discriminator."
},
sectionIds: {
type: "array",
items: {
type: "integer",
minimum: 0
},
minItems: 1,
description: "Section IDs to retrieve from previous iteration. DO NOT request same IDs\nalready requested in previous calls."
}
},
required: [
"type",
"sectionIds"
],
description: "Request to retrieve analysis sections from the previous iteration by numeric\nID."
},
IAutoBePreliminaryGetPreviousDatabaseSchemas: {
type: "object",
properties: {
type: {
"const": "getPreviousDatabaseSchemas",
description: "Type discriminator."
},
schemaNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "Table names to retrieve from previous iteration. DO NOT request same names\nalready requested in previous calls."
}
},
required: [
"type",
"schemaNames"
],
description: "Request to retrieve database schemas from the previous iteration.\n\nLoads database table definitions from the last successfully generated\nversion, used as reference context during regeneration or modification\ncycles."
},
IAutoBePreliminaryGetPreviousInterfaceOperations: {
type: "object",
properties: {
type: {
"const": "getPreviousInterfaceOperations",
description: "Type discriminator."
},
endpoints: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeOpenApi.IEndpoint"
},
minItems: 1,
description: "Endpoints to retrieve from previous iteration. DO NOT request same\nendpoints already requested in previous calls."
}
},
required: [
"type",
"endpoints"
],
description: "Request to retrieve interface operations from the previous iteration.\n\nLoads API operation definitions from the last successfully generated version,\nused as reference context during regeneration or modification cycles."
},
"AutoBeOpenApi.IEndpoint": {
type: "object",
properties: {
path: {
type: "string",
pattern: "^\\/[a-zA-Z0-9\\/_{}.-]*$",
description: "HTTP path of the API operation.\n\nMust start with `/`. Parameters use curly braces: `{paramName}`. Resource\nnames in camelCase. No quotes, spaces, role prefixes (`/admin/`), or API\nversion prefixes (`/api/v1/`).\n\nAllowed characters: letters, digits, `/`, `{`, `}`, `-`, `_`, `.`"
},
method: {
oneOf: [
{
"const": "get"
},
{
"const": "post"
},
{
"const": "put"
},
{
"const": "delete"
},
{
"const": "patch"
}
],
description: "HTTP method (lowercase only).\n\nUse `patch` (not `get`) when a read operation needs a complex\n{@link requestBody}. `get` cannot have a request body."
}
},
required: [
"path",
"method"
],
description: "API endpoint information."
},
"IAutoBeInterfaceGroupApplication.IWrite": {
type: "object",
properties: {
type: {
"const": "write",
description: "Type discriminator for write submission."
},
analysis: {
type: "string",
description: "Analysis of the database schema structure and grouping needs."
},
rationale: {
type: "string",
description: "Rationale for the group design decisions."
},
groups: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeInterfaceGroup"
},
minItems: 1,
description: "Array of API endpoint groups. Derive from database schema organization\n(namespaces, table prefixes), not arbitrary business domains. Provide\ncomplete coverage without overlap."
}
},
required: [
"type",
"analysis",
"rationale",
"groups"
],
description: "Submit API endpoint groups."
},
AutoBeInterfaceGroup: {
type: "object",
properties: {
name: {
type: "string",
description: "Group name derived from Prisma schema structure (PascalCase).\n\nPriority: 1) namespace names, 2) schema file names, 3) table prefix\npatterns. Examples: \"Shopping\", \"BBS\", \"UserManagement\"."
},
description: {
type: "string",
description: "Scope and purpose of this group. Include: schema foundation\n(namespace/file/prefix), specific table names covered, functional\noperations, and entity relationships. 100-2000 characters."
},
databaseSchemas: {
type: "array",
items: {
type: "string"
},
description: "Prisma model names needed for this group's endpoints.\n\nInclude ALL models users interact with, related CRUD models, parent/child\nmodels, and snapshot models. Exclude system-internal, cache, and framework\ntables. Be thorough \u2014 include extra rather than miss required ones."
}
},
required: [
"name",
"description",
"databaseSchemas"
],
description: "Logical grouping of API endpoints based on Prisma schema structure.\n\nGroups divide large API specifications into manageable generation cycles,\nmaintaining alignment between API structure and database schema."
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeInterfaceGroupApplication.IProps"
}
}
],
description: "Process task or retrieve preliminary data."
}
]
},
source: SOURCE,
kinds: [
"analysisSections",
"databaseSchemas",
"previousAnalysisSections",
"previousDatabaseSchemas",
"previousInterfaceOperations",
"complete",
],
});
return yield preliminary.orchestrate(ctx, (out) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const pointer = {
value: null,
};
const result = yield ctx.conversate(Object.assign({ source: SOURCE, controller: createController({
pointer,
preliminary,
databaseSchemas: new Set(prisma !== null
? prisma.result.data.files
.map((f) => f.models)
.flat()
.map((m) => m.name)
: []),
}), enforceFunctionCall: true }, (0, transformInterfaceGroupHistory_1.transformInterfaceGroupHistory)({
state: ctx.state(),
instruction: props.instruction,
preliminary,
})));
if (pointer.value === null)
return out(result)(null);
const event = {
type: SOURCE,
id: (0, uuid_1.v7)(),
analysis: pointer.value.analysis,
rationale: pointer.value.rationale,
created_at: start.toISOString(),
groups: pointer.value.groups,
acquisition: preliminary.getAcquisition(),
metric: result.metric,
tokenUsage: result.tokenUsage,
step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0,
};
return out(result)(event);
}));
});
}
function createController(props) {
const validate = (input) => {
const result = (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "complete" === input.type; const _io2 = input => "getAnalysisSections" === input.type && (Array.isArray(input.sectionIds) && (1 <= input.sectionIds.length && input.sectionIds.length <= 100 && input.sectionIds.every(elem => "number" === typeof elem && __typia_transform__isTypeUint32._isTypeUint32(elem)))); const _io3 = input => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io4 = input => "getPreviousAnalysisSections" === input.type && (Array.isArray(input.sectionIds) && (1 <= input.sectionIds.length && input.sectionIds.every(elem => "number" === typeof elem && __typia_transform__isTypeUint32._isTypeUint32(elem)))); const _io5 = input => "getPreviousDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io6 = input => "getPreviousInterfaceOperations" === input.type && (Array.isArray(input.endpoints) && (1 <= input.endpoints.length && input.endpoints.every(elem => "object" === typeof elem && null !== elem && _io7(elem)))); const _io7 = input => "string" === typeof input.path && RegExp("^\\/[a-zA-Z0-9\\/_{}.-]*$").test(input.path) && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method); const _io8 = input => "write" === input.type && "string" === typeof input.analysis && "string" === typeof input.rationale && (Array.isArray(input.groups) && (1 <= input.groups.length && input.groups.every(elem => "object" === typeof elem && null !== elem && _io9(elem)))); const _io9 = input => "string" === typeof input.name && "string" === typeof input.description && (Array.isArray(input.databaseSchemas) && input.databaseSchemas.every(elem => "string" === typeof elem)); const _iu0 = input => (() => {
if ("complete" === input.type)
return _io1(input);
else if ("getAnalysisSections" === input.type)
return _io2(input);
else if ("getDatabaseSchemas" === input.type)
return _io3(input);
else if ("getPreviousAnalysisSections" === input.type)
return _io4(input);
else if ("getPreviousDatabaseSchemas" === input.type)
return _io5(input);
else if ("getPreviousInterfaceOperations" === input.type)
return _io6(input);
else if ("write" === input.type)
return _io8(input);
else
return false;
})(); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.thinking || _report(_exceptionable, {
path: _path + ".thinking",
expected: "string",
value: input.thinking
}), ("object" === typeof input.request && null !== input.request || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBeInterfaceGroupApplication.IWrite | IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetPreviousAnalysisSections | IAutoBePreliminaryGetPreviousDatabaseSchemas | IAutoBePreliminaryGetPreviousInterfaceOperations)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBeInterfaceGroupApplication.IWrite | IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetPreviousAnalysisSections | IAutoBePreliminaryGetPreviousDatabaseSchemas | IAutoBePreliminaryGetPreviousInterfaceOperations)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["complete" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"complete\"",
value: input.type
})].every(flag => flag); const _vo2 = (input, _path, _exceptionable = true) => ["getAnalysisSections" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getAnalysisSections\"",
value: input.type
}), (Array.isArray(input.sectionIds) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1> & MaxItems<100>)",
value: input.sectionIds
})) && ((1 <= input.sectionIds.length || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "Array<> & MinItems<1>",
value: input.sectionIds
})) && (input.sectionIds.length <= 100 || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "Array<> & MaxItems<100>",
value: input.sectionIds
})) && input.sectionIds.map((elem, _index8) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index8 + "]",
expected: "number & Type<\"uint32\">",
value: elem
})) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index8 + "]",
expected: "(number & Type<\"uint32\">)",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1> & MaxItems<100>)",
value: input.sectionIds
})].every(flag => flag); const _vo3 = (input, _path, _exceptionable = true) => ["getDatabaseSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getDatabaseSchemas\"",
value: input.type
}), (Array.isArray(input.schemaNames) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})) && ((1 <= input.schemaNames.length || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "Array<> & MinItems<1>",
value: input.schemaNames
})) && input.schemaNames.map((elem, _index9) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index9 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["getPreviousAnalysisSections" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPreviousAnalysisSections\"",
value: input.type
}), (Array.isArray(input.sectionIds) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1>)",
value: input.sectionIds
})) && ((1 <= input.sectionIds.length || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "Array<> & MinItems<1>",
value: input.sectionIds
})) && input.sectionIds.map((elem, _index10) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index10 + "]",
expected: "number & Type<\"uint32\">",
value: elem
})) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index10 + "]",
expected: "(number & Type<\"uint32\">)",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1>)",
value: input.sectionIds
})].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => ["getPreviousDatabaseSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPreviousDatabaseSchemas\"",
value: input.type
}), (Array.isArray(input.schemaNames) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})) && ((1 <= input.schemaNames.length || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "Array<> & MinItems<1>",
value: input.schemaNames
})) && input.schemaNames.map((elem, _index11) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index11 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})].every(flag => flag); const _vo6 = (input, _path, _exceptionable = true) => ["getPreviousInterfaceOperations" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPreviousInterfaceOperations\"",
value: input.type
}), (Array.isArray(input.endpoints) || _report(_exceptionable, {
path: _path + ".endpoints",
expected: "(Array<AutoBeOpenApi.IEndpoint> & MinItems<1>)",
value: input.endpoints
})) && ((1 <= input.endpoints.length || _report(_exceptionable, {
path: _path + ".endpoints",
expected: "Array<> & MinItems<1>",
value: input.endpoints
})) && input.endpoints.map((elem, _index12) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".endpoints[" + _index12 + "]",
expected: "AutoBeOpenApi.IEndpoint",
value: elem
})) && _vo7(elem, _path + ".endpoints[" + _index12 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".endpoints[" + _index12 + "]",
expected: "AutoBeOpenApi.IEndpoint",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".endpoints",
expected: "(Array<AutoBeOpenApi.IEndpoint> & MinItems<1>)",
value: input.endpoints
})].every(flag => flag); const _vo7 = (input, _path, _exceptionable = true) => ["string" === typeof input.path && (RegExp("^\\/[a-zA-Z0-9\\/_{}.-]*$").test(input.path) || _report(_exceptionable, {
path: _path + ".path",
expected: "string & Pattern<\"^\\\\/[a-zA-Z0-9\\\\/_{}.-]*$\">",
value: input.path
})) || _report(_exceptionable, {
path: _path + ".path",
expected: "(string & Pattern<\"^\\\\/[a-zA-Z0-9\\\\/_{}.-]*$\">)",
value: input.path
}), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, {
path: _path + ".method",
expected: "(\"delete\" | \"get\" | \"patch\" | \"post\" | \"put\")",
value: input.method
})].every(flag => flag); const _vo8 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"write\"",
value: input.type
}), "string" === typeof input.analysis || _report(_exceptionable, {
path: _path + ".analysis",
expected: "string",
value: input.analysis
}), "string" === typeof input.rationale || _report(_exceptionable, {
path: _path + ".rationale",
expected: "string",
value: input.rationale
}), (Array.isArray(input.groups) || _report(_exceptionable, {
path: _path + ".groups",
expected: "(Array<AutoBeInterfaceGroup> & MinItems<1>)",
value: input.groups
})) && ((1 <= input.groups.length || _report(_exceptionable, {
path: _path + ".groups",
expected: "Array<> & MinItems<1>",
value: input.groups
})) && input.groups.map((elem, _index13) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".groups[" + _index13 + "]",
expected: "AutoBeInterfaceGroup",
value: elem
})) && _vo9(elem, _path + ".groups[" + _index13 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".groups[" + _index13 + "]",
expected: "AutoBeInterfaceGroup",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".groups",
expected: "(Array<AutoBeInterfaceGroup> & MinItems<1>)",
value: input.groups
})].every(flag => flag); const _vo9 = (input, _path, _exceptionable = true) => ["string" === typeof input.name || _report(_exceptionable, {
path: _path + ".name",
expected: "string",
value: input.name
}), "string" === typeof input.description || _report(_exceptionable, {
path: _path + ".description",
expected: "string",
value: input.description
}), (Array.isArray(input.databaseSchemas) || _report(_exceptionable, {
path: _path + ".databaseSchemas",
expected: "Array<string>",
value: input.databaseSchemas
})) && input.databaseSchemas.map((elem, _index14) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".databaseSchemas[" + _index14 + "]",
expected: "string",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".databaseSchemas",
expected: "Array<string>",
value: input.databaseSchemas
})].every(flag => flag); const _vu0 = (input, _path, _exceptionable = true) => (() => {
if ("complete" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("getAnalysisSections" === input.type)
return _vo2(input, _path, true && _exceptionable);
else if ("getDatabaseSchemas" === input.type)
return _vo3(input, _path, true && _exceptionable);
else if ("getPreviousAnalysisSections" === input.type)
return _vo4(input, _path, true && _exceptionable);
else if ("getPreviousDatabaseSchemas" === input.type)
return _vo5(input, _path, true && _exceptionable);
else if ("getPreviousInterfaceOperations" === input.type)
return _vo6(input, _path, true && _exceptionable);
else if ("write" === input.type)
return _vo8(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetPreviousAnalysisSections | IAutoBePreliminaryGetPreviousDatabaseSchemas | IAutoBePreliminaryGetPreviousInterfaceOperations | IAutoBeInterfaceGroupApplication.IWrite)",
value: input
});
})(); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
if (false === __is(input)) {
errors = [];
_report = __typia_transform__validateReport._validateReport(errors);
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
path: _path + "",
expected: "IAutoBeInterfaceGroupApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeInterfaceGroupApplication.IProps",
value: input
}))(input, "$input", true);
const success = 0 === errors.length;
return success ? {
success,
data: input
} : {
success,
errors,
data: input
};
}
return {
success: true,
data: input
};
}; })()(input);
if (result.success === false)
return result;
// Preliminary request validation
if (result.data.request.type !== "write")
return props.preliminary.validate({
thinking: result.data.thinking,
request: result.data.request,
});
// Complete request validation - check databaseSchemas
const errors = [];
result.data.request.groups.forEach((group, i) => {
group.databaseSchemas.forEach((key, j) => {
if (props.databaseSchemas.has(key) === false)
errors.push({
expected: Array.from(props.databaseSchemas)
.map((s) => JSON.stringify(s))
.join(" | "),
value: key,
path: `request.groups[${i}].databaseSchemas[${j}]`,
description: utils_1.StringUtil.trim `
The database schema "${key}" does not exist in the current project.
Make sure to provide only the valid database schema names that are present in your project.
Here is the list of available database schemas in the project:
${Array.from(props.databaseSchemas)
.map((s) => `- ${s}`)
.join("\n")}
`,
});
});
});
return errors.length === 0
? result
: {
success: false,
data: result.data,
errors,
};
};
const application = props.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({
functions: [
{
name: "process",
parameters: {
description: "Current Type: {@link IAutoBeInterfaceGroupApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Reasoning: what's missing (preliminary), what you're submitting (write),\nor why you're finalizing (complete).",
type: "string"
},
request: {
description: "Action to perform. Exhausted preliminary types are removed from the\nunion.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryComplete"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetAnalysisSections"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetPreviousAnalysisSections"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetPreviousDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetPreviousInterfaceOperations"
},
{
$ref: "#/$defs/IAutoBeInterfaceGroupApplication.IWrite"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
complete: "#/$defs/IAutoBePreliminaryComplete",
getAnalysisSections: "#/$defs/IAutoBePreliminaryGetAnalysisSections",
getDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas",
getPreviousAnalysisSections: "#/$defs/IAutoBePreliminaryGetPreviousAnalysisSections",
getPreviousDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetPreviousDatabaseSchemas",
getPreviousInterfaceOperations: "#/$defs/IAutoBePreliminaryGetPreviousInterfaceOperations",
write: "#/$defs/IAutoBeInterfaceGroupApplication.IWrite"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
IAutoBePreliminaryComplete: {
description: "Finalize the write loop by accepting your most recent `write` as-is.\n\nAfter submitting a `write`, review it yourself thoroughly against the review\nchecklist in your instructions. If you find issues worth fixing, submit\nanother `write` with corrections. When you are satisfied with the quality,\ncall `complete` to finalize.\n\nYou have a maximum of 3 write attempts, but this is a safety cap \u2014 not a\ntarget to fill.\n\nOnly valid after at least one `write` submission \u2014 rejected otherwise.",
type: "object",
properties: {
type: {
description: "Type discriminator for completion request.",
type: "string",
"enum": [
"complete"
]
}
},
required: [
"type"
]
},
IAutoBePreliminaryGetAnalysisSections: {
description: "Request to retrieve individual analysis sections by numeric ID.",
type: "object",
properties: {
type: {
description: "Type discriminator.",
type: "string",
"enum": [
"getAnalysisSections"
]
},
sectionIds: {
description: "Section IDs to retrieve. DO NOT request same IDs already requested in\nprevious calls.",
type: "array",
items: {
type: "integer",
minimum: 0
},
minItems: 1,
maxItems: 100
}
},
required: [
"type",
"sectionIds"
]
},
IAutoBePreliminaryGetDatabaseSchemas: {
description: "Request to retrieve database schema definitions for context.",
type: "object",
properties: {
type: {
description: "Type discriminator.",
type: "string",
"enum": [
"getDatabaseSchemas"
]
},
schemaNames: {
description: "Database table names to retrieve. DO NOT request same names already\nrequested in previous calls.",
type: "array",
items: {
type: "string"
},
minItems: 1
}
},
required: [
"type",
"schemaNames"
]
},
IAutoBePreliminaryGetPreviousAnalysisSections: {
description: "Request to retrieve analysis sections from the previous iteration by numeric\nID.",
type: "object",
properties: {