@autobe/agent
Version:
AI backend server code generator
847 lines (845 loc) • 58.2 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.orchestrateRealizeTransformerPlan = orchestrateRealizeTransformerPlan;
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 tstl_1 = require("tstl");
const typia_1 = __importDefault(require("typia"));
const uuid_1 = require("uuid");
const RAGRetrieval_1 = require("../../utils/RAGRetrieval");
const executeCachedBatch_1 = require("../../utils/executeCachedBatch");
const forceRetry_1 = require("../../utils/forceRetry");
const getEmbedder_1 = require("../../utils/getEmbedder");
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const convertToSectionEntries_1 = require("../common/internal/convertToSectionEntries");
const transformRealizeTransformerPlanHistory_1 = require("./histories/transformRealizeTransformerPlanHistory");
const AutoBeRealizeTransformerProgrammer_1 = require("./programmers/AutoBeRealizeTransformerProgrammer");
function orchestrateRealizeTransformerPlan(ctx, props) {
return __awaiter(this, void 0, void 0, function* () {
const history = ctx.state().interface;
if (history === null)
throw new Error("Cannot realize transformer write without interface.");
const document = history.document;
const dtoTypeNames = Object.keys(document.components.schemas).filter((key) => AutoBeRealizeTransformerProgrammer_1.AutoBeRealizeTransformerProgrammer.filter({
schemas: document.components.schemas,
key,
}));
const prismaSchemaNames = new Set(ctx
.state()
.database.result.data.files.map((f) => f.models)
.flat()
.map((m) => m.name));
const result = yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, Array.from(dtoTypeNames).map((it) => (promptCacheKey) => __awaiter(this, void 0, void 0, function* () {
const counter = new tstl_1.Singleton(() => ++props.progress.completed);
try {
return yield (0, forceRetry_1.forceRetry)(() => process(ctx, {
document,
dtoTypeName: it,
prismaSchemaNames,
promptCacheKey,
progress: props.progress,
counter,
}));
}
catch (error) {
counter.get();
throw error;
}
})));
return result.flat();
});
}
function process(ctx, props) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const allSections = (0, convertToSectionEntries_1.convertToSectionEntries)((_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.files) !== null && _b !== void 0 ? _b : []);
const queryText = [
"transformer",
"plan",
"dto",
"prisma",
props.dtoTypeName,
].join(" ");
const ragSections = yield (0, RAGRetrieval_1.buildAnalysisContextSections)((0, getEmbedder_1.getEmbedder)(), allSections, queryText, "TOPK", { log: false, logPrefix: "realizeTransformerPlan" });
const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({
dispatch: (e) => ctx.dispatch(e),
state: ctx.state(),
source: SOURCE,
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeRealizeTransformerPlanApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Think before you act.\n\nFor preliminary requests: what schemas (database or DTO) are missing?\n\nFor write: is this DTO transformable or non-transformable? What database\ntable does it map to (if transformable)?\n\nFor complete: why you consider the decision final."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryComplete"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetInterfaceSchemas"
},
{
$ref: "#/components/schemas/IAutoBeRealizeTransformerPlanApplication.IWrite"
}
],
discriminator: {
propertyName: "type",
mapping: {
complete: "#/components/schemas/IAutoBePreliminaryComplete",
getAnalysisSections: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections",
getDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas",
getInterfaceSchemas: "#/components/schemas/IAutoBePreliminaryGetInterfaceSchemas",
write: "#/components/schemas/IAutoBeRealizeTransformerPlanApplication.IWrite"
}
},
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls."
}
},
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."
},
IAutoBePreliminaryGetInterfaceSchemas: {
type: "object",
properties: {
type: {
"const": "getInterfaceSchemas",
description: "Type discriminator."
},
typeNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "Schema type names to retrieve. DO NOT request same names already requested\nin previous calls."
}
},
required: [
"type",
"typeNames"
],
description: "Request to retrieve OpenAPI schema type definitions for context."
},
"IAutoBeRealizeTransformerPlanApplication.IWrite": {
type: "object",
properties: {
type: {
"const": "write",
description: "Type discriminator for write submission."
},
plans: {
type: "array",
items: {
$ref: "#/components/schemas/IAutoBeRealizeTransformerPlanApplication.IPlan"
},
description: "Exactly ONE entry. databaseSchemaName non-null = transformable, null = no\ntransformer needed."
}
},
required: [
"type",
"plans"
],
description: "Generates exactly ONE plan entry indicating transformable (has DB schema\nname) or not (null)."
},
"IAutoBeRealizeTransformerPlanApplication.IPlan": {
type: "object",
properties: {
dtoTypeName: {
type: "string",
description: "TypeScript interface type from the operation response (e.g.,\n\"IShoppingSaleUnitStock\")."
},
thinking: {
type: "string",
description: "Reasoning for this DTO's planning decision.\n\nTransformable: \"Transforms shopping_sales to IShoppingSale with nested\ncategory and tags\".\n\nNon-transformable: \"IPage.IRequest is pagination parameter, not\nDB-backed\"."
},
databaseSchemaName: {
oneOf: [
{
type: "null"
},
{
type: "string"
}
],
description: "Database table name if transformable (e.g., \"shopping_sales\"), null if\nnon-transformable (request param, pagination wrapper, business logic)."
}
},
required: [
"dtoTypeName",
"thinking",
"databaseSchemaName"
],
description: "Planning decision for one DTO."
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
description: " Preliminary data request, write submission, or completion\nconfirmation",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeRealizeTransformerPlanApplication.IProps"
}
}
],
description: "Analyzes the given DTO type and generates a plan entry determining whether\na transformer is needed. Returns exactly ONE plan entry."
}
]
},
kinds: [
"analysisSections",
"databaseSchemas",
"interfaceSchemas",
"complete",
],
local: {
analysisSections: ragSections,
interfaceSchemas: Object.fromEntries(Object.entries(props.document.components.schemas).filter(([key]) => key === props.dtoTypeName)),
},
});
const event = 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: "realizePlan", controller: createController({
prismaSchemaNames: props.prismaSchemaNames,
dtoTypeName: props.dtoTypeName,
build: (next) => {
pointer.value = next;
},
preliminary,
}), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, (0, transformRealizeTransformerPlanHistory_1.transformRealizeTransformerPlanHistory)({
state: ctx.state(),
preliminary,
dtoTypeName: props.dtoTypeName,
})));
if (pointer.value === null)
return out(result)(null);
const plans = pointer.value.plans
.filter((p) => p.databaseSchemaName !== null)
.map((p) => ({
type: "transformer",
dtoTypeName: p.dtoTypeName,
thinking: p.thinking,
databaseSchemaName: p.databaseSchemaName,
}));
const event = {
type: "realizePlan",
id: (0, uuid_1.v4)(),
plans,
acquisition: preliminary.getAcquisition(),
metric: result.metric,
tokenUsage: result.tokenUsage,
completed: props.counter.get(),
total: props.progress.total,
step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0,
created_at: new Date().toISOString(),
};
return out(result)(event);
}));
ctx.dispatch(event);
return event.plans;
});
}
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 => "getInterfaceSchemas" === input.type && (Array.isArray(input.typeNames) && (1 <= input.typeNames.length && input.typeNames.every(elem => "string" === typeof elem))); const _io5 = input => "write" === input.type && (Array.isArray(input.plans) && input.plans.every(elem => "object" === typeof elem && null !== elem && _io6(elem))); const _io6 = input => "string" === typeof input.dtoTypeName && "string" === typeof input.thinking && (null === input.databaseSchemaName || "string" === typeof input.databaseSchemaName); 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 ("getInterfaceSchemas" === input.type)
return _io4(input);
else if ("write" === input.type)
return _io5(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: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeRealizeTransformerPlanApplication.IWrite)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeRealizeTransformerPlanApplication.IWrite)",
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, _index5) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index5 + "]",
expected: "number & Type<\"uint32\">",
value: elem
})) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index5 + "]",
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, _index6) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index6 + "]",
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) => ["getInterfaceSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getInterfaceSchemas\"",
value: input.type
}), (Array.isArray(input.typeNames) || _report(_exceptionable, {
path: _path + ".typeNames",
expected: "(Array<string> & MinItems<1>)",
value: input.typeNames
})) && ((1 <= input.typeNames.length || _report(_exceptionable, {
path: _path + ".typeNames",
expected: "Array<> & MinItems<1>",
value: input.typeNames
})) && input.typeNames.map((elem, _index7) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".typeNames[" + _index7 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".typeNames",
expected: "(Array<string> & MinItems<1>)",
value: input.typeNames
})].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"write\"",
value: input.type
}), (Array.isArray(input.plans) || _report(_exceptionable, {
path: _path + ".plans",
expected: "Array<IAutoBeRealizeTransformerPlanApplication.IPlan>",
value: input.plans
})) && input.plans.map((elem, _index8) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".plans[" + _index8 + "]",
expected: "IAutoBeRealizeTransformerPlanApplication.IPlan",
value: elem
})) && _vo6(elem, _path + ".plans[" + _index8 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".plans[" + _index8 + "]",
expected: "IAutoBeRealizeTransformerPlanApplication.IPlan",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".plans",
expected: "Array<IAutoBeRealizeTransformerPlanApplication.IPlan>",
value: input.plans
})].every(flag => flag); const _vo6 = (input, _path, _exceptionable = true) => ["string" === typeof input.dtoTypeName || _report(_exceptionable, {
path: _path + ".dtoTypeName",
expected: "string",
value: input.dtoTypeName
}), "string" === typeof input.thinking || _report(_exceptionable, {
path: _path + ".thinking",
expected: "string",
value: input.thinking
}), null === input.databaseSchemaName || "string" === typeof input.databaseSchemaName || _report(_exceptionable, {
path: _path + ".databaseSchemaName",
expected: "(null | string)",
value: input.databaseSchemaName
})].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 ("getInterfaceSchemas" === input.type)
return _vo4(input, _path, true && _exceptionable);
else if ("write" === input.type)
return _vo5(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeRealizeTransformerPlanApplication.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: "IAutoBeRealizeTransformerPlanApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeTransformerPlanApplication.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;
else if (result.data.request.type !== "write")
return props.preliminary.validate({
thinking: result.data.thinking,
request: result.data.request,
});
const errors = [];
result.data.request.plans.map((plan, i) => {
if (plan.dtoTypeName !== props.dtoTypeName)
errors.push({
path: `$input.request.plans[${i}].dtoTypeName`,
value: plan.dtoTypeName,
expected: JSON.stringify(props.dtoTypeName),
description: utils_1.StringUtil.trim `
The DTO type name must be ${JSON.stringify(props.dtoTypeName)}.
If you have planned other DTO type's transformer,
please entirely remake the plan with ONLY the DTO type
${JSON.stringify(props.dtoTypeName)}.
`,
});
if (plan.databaseSchemaName !== null &&
props.prismaSchemaNames.has(plan.databaseSchemaName) === false)
errors.push({
path: `$input.request.plans[${i}].databaseSchemaName`,
value: plan.databaseSchemaName,
expected: Array.from(props.prismaSchemaNames)
.map((s) => JSON.stringify(s))
.join(" | "),
description: utils_1.StringUtil.trim `
The database schema name must be one of the available database schemas.
${Array.from(props.prismaSchemaNames)
.map((s) => `- ${s}`)
.join("\n")}
`,
});
});
return errors.length
? {
success: false,
errors,
data: result.data,
}
: result;
};
const application = props.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({
functions: [
{
name: "process",
parameters: {
description: "Current Type: {@link IAutoBeRealizeTransformerPlanApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Think before you act.\n\nFor preliminary requests: what schemas (database or DTO) are missing?\n\nFor write: is this DTO transformable or non-transformable? What database\ntable does it map to (if transformable)?\n\nFor complete: why you consider the decision final.",
type: "string"
},
request: {
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryComplete"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetAnalysisSections"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetInterfaceSchemas"
},
{
$ref: "#/$defs/IAutoBeRealizeTransformerPlanApplication.IWrite"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
complete: "#/$defs/IAutoBePreliminaryComplete",
getAnalysisSections: "#/$defs/IAutoBePreliminaryGetAnalysisSections",
getDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas",
getInterfaceSchemas: "#/$defs/IAutoBePreliminaryGetInterfaceSchemas",
write: "#/$defs/IAutoBeRealizeTransformerPlanApplication.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"
]
},
IAutoBePreliminaryGetInterfaceSchemas: {
description: "Request to retrieve OpenAPI schema type definitions for context.",
type: "object",
properties: {
type: {
description: "Type discriminator.",
type: "string",
"enum": [
"getInterfaceSchemas"
]
},
typeNames: {
description: "Schema type names to retrieve. DO NOT request same names already requested\nin previous calls.",
type: "array",
items: {
type: "string"
},
minItems: 1
}
},
required: [
"type",
"typeNames"
]
},
"IAutoBeRealizeTransformerPlanApplication.IWrite": {
description: "Generates exactly ONE plan entry indicating transformable (has DB schema\nname) or not (null).",
type: "object",
properties: {
type: {
description: "Type discriminator for write submission.",
type: "string",
"enum": [
"write"
]
},
plans: {
description: "Exactly ONE entry. databaseSchemaName non-null = transformable, null = no\ntransformer needed.",
type: "array",
items: {
$ref: "#/$defs/IAutoBeRealizeTransformerPlanApplication.IPlan"
}
}
},
required: [
"type",
"plans"
]
},
"IAutoBeRealizeTransformerPlanApplication.IPlan": {
description: "Planning decision for one DTO.",
type: "object",
properties: {
dtoTypeName: {
description: "TypeScript interface type from the operation response (e.g.,\n\"IShoppingSaleUnitStock\").",
type: "string"
},
thinking: {
description: "Reasoning for this DTO's planning decision.\n\nTransformable: \"Transforms shopping_sales to IShoppingSale with nested\ncategory and tags\".\n\nNon-transformable: \"IPage.IRequest is pagination parameter, not\nDB-backed\".",
type: "string"
},
databaseSchemaName: {
description: "Database table name if transformable (e.g., \"shopping_sales\"), null if\nnon-transformable (request param, pagination wrapper, business logic).",
anyOf: [
{
type: "null"
},
{
type: "string"
}
]
}
},
required: [
"dtoTypeName",
"thinking",
"databaseSchemaName"
]
}
}
},
description: "Analyzes the given DTO type and generates a plan entry determining whether\na transformer is needed. Returns exactly ONE plan entry.",
validate: (() => { 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 => "getInterfaceSchemas" === input.type && (Array.isArray(input.typeNames) && (1 <= input.typeNames.length && input.typeNames.every(elem => "string" === typeof elem))); const _io5 = input => "write" === input.type && (Array.isArray(input.plans) && input.plans.every(elem => "object" === typeof elem && null !== elem && _io6(elem))); const _io6 = input => "string" === typeof input.dtoTypeName && "string" === typeof input.thinking && (null === input.databaseSchemaName || "string" === typeof input.databaseSchemaName); 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 ("getInterfaceSchemas" === input.type)
return _io4(input);
else if ("write" === input.type)
return _io5(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: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeRealizeTransformerPlanApplication.IWrite)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeRealizeTransformerPlanApplication.IWrite)",
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, _index5) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index5 + "]",
expected: "number & Type<\"uint32\">",
value: elem
})) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index5 + "]",
expected: "(number & Type<\"uint32\">)",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(A