@autobe/agent
Version:
AI backend server code generator
660 lines • 60 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.orchestrateRealizeCollectorCorrectOverall = void 0;
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 AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const orchestrateRealizeCorrectOverall_1 = require("./correct/orchestrateRealizeCorrectOverall");
const transformRealizeCollectorCorrectHistory_1 = require("./histories/transformRealizeCollectorCorrectHistory");
const AutoBeRealizeCollectorProgrammer_1 = require("./programmers/AutoBeRealizeCollectorProgrammer");
const orchestrateRealizeCollectorCorrectOverall = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () {
const document = ctx.state().interface.document;
const getNeighbors = (func) => {
const visited = new Set();
utils_1.AutoBeOpenApiTypeChecker.visit({
components: document.components,
schema: { $ref: `#/components/schemas/${func.plan.dtoTypeName}` },
closure: (next) => {
if (utils_1.AutoBeOpenApiTypeChecker.isReference(next)) {
const key = next.$ref.split("/").pop();
visited.add(key);
}
},
});
return props.functions.filter((y) => y.plan.dtoTypeName !== func.plan.dtoTypeName &&
visited.has(y.plan.dtoTypeName));
};
return yield (0, orchestrateRealizeCorrectOverall_1.orchestrateRealizeCorrectOverall)(ctx, {
programmer: {
location: "src/collectors",
// Recalculate template for corrected collector function
template: (func) => AutoBeRealizeCollectorProgrammer_1.AutoBeRealizeCollectorProgrammer.writeTemplate({
plan: func.plan,
body: document.components.schemas[func.plan.dtoTypeName],
model: ctx
.state()
.database.result.data.files.map((f) => f.models)
.flat()
.find((m) => m.name === func.plan.databaseSchemaName),
application: ctx.state().database.result.data,
}),
// Replace import statements using Collector-specific programmer
replaceImportStatements: (next) => __awaiter(void 0, void 0, void 0, function* () {
return yield AutoBeRealizeCollectorProgrammer_1.AutoBeRealizeCollectorProgrammer.replaceImportStatements(ctx, {
dtoTypeName: next.function.plan.dtoTypeName,
schemas: document.components.schemas,
code: next.code,
});
}),
// No additional files needed for collectors (unlike operations)
additional: (_functions) => ({}),
// Create preliminary controller with only databaseSchemas support
preliminary: (next) => new AutoBePreliminaryController_1.AutoBePreliminaryController({
source: next.source,
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeRealizeCollectorCorrectApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Think before you act.\n\nFor preliminary requests: what critical information is missing?\n\nFor write: what errors you're fixing and the correction strategy."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBeRealizeCollectorCorrectApplication.IWrite"
}
],
discriminator: {
propertyName: "type",
mapping: {
getDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas",
write: "#/components/schemas/IAutoBeRealizeCollectorCorrectApplication.IWrite"
}
},
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls."
}
},
required: [
"thinking",
"request"
]
},
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."
},
"IAutoBeRealizeCollectorCorrectApplication.IWrite": {
type: "object",
properties: {
type: {
"const": "write",
description: "Type discriminator for write submission."
},
think: {
type: "string",
description: "Systematic error analysis. MUST contain four sections:\n\n1. Error Inventory \u2014 categorize ALL compilation errors by root cause\n2. Root Cause Analysis \u2014 identify WHY each error occurs (wrong field, type\n mismatch, etc.)\n3. Schema Verification \u2014 cross-check error-related fields against actual\n database schema\n4. Correction Strategy \u2014 specific fix for each error (not workarounds)\n\nThis forces you to understand the REAL problem (not guess) and plan\nsurgical fixes that address root causes, not symptoms."
},
mappings: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeRealizeCollectorMapping"
},
description: "Field-by-field mapping verification. For each database schema member:\n\n- `member`: Exact Prisma field/relation name \u2014 verify against schema\n- `kind`: scalar, belongsTo, hasOne, or hasMany\n- `nullable`: true/false for scalar/belongsTo, null for hasMany/hasOne\n- `how`: Current state + correction plan (\"No change needed\", \"Fix:\n [problem] \u2192 [solution]\")\n\nEven fields without errors must be included with \"No change needed\" to\nensure complete review. MUST include EVERY field/relation from the\ndatabase schema.\n\nMissing even a single field will cause validation failure."
},
draft: {
type: "string",
description: "Complete corrected code. EVERY error from think Section 1 MUST be\naddressed. Implement:\n\n- Field name corrections (exact names from database schema)\n- Type fixes (proper CreateInput types, nullable handling)\n- Neighbor collector reuse (replace inline logic if collector exists)\n- Relationship fixes (connect/create syntax)\n\nApply fixes surgically \u2014 change ONLY what's broken, preserve working\nlogic."
},
revise: {
$ref: "#/components/schemas/IAutoBeRealizeCollectorCorrectApplication.IReviseProps",
description: "Reviews draft corrections and produces final error-free code."
}
},
required: [
"type",
"think",
"mappings",
"draft",
"revise"
],
description: "Correct collector compilation errors via think/draft/revise."
},
AutoBeRealizeCollectorMapping: {
type: "object",
properties: {
member: {
type: "string",
description: "Exact field or relation name from Prisma schema (case-sensitive).\n\n**Examples**:\n\n```typescript\n// Scalar fields\n{ member: \"id\", kind: \"scalar\", nullable: false, how: \"Generate with v4()\" }\n{ member: \"email\", kind: \"scalar\", nullable: false, how: \"From props.body.email\" }\n{ member: \"created_at\", kind: \"scalar\", nullable: false, how: \"Default to new Date()\" }\n{ member: \"description\", kind: \"scalar\", nullable: true, how: \"From props.body.description ?? null\" }\n\n// BelongsTo relations \u2014 use Prisma RELATION name, NOT FK column name\n{ member: \"customer\", kind: \"belongsTo\", nullable: false, how: \"Connect using props.customer.id\" }\n{ member: \"parent\", kind: \"belongsTo\", nullable: true, how: \"Undefined (nullable FK)\" }\n\n// HasMany relations\n{ member: \"tags\", kind: \"hasMany\", nullable: null, how: \"Nested create with TagCollector\" }\n{ member: \"comments\", kind: \"hasMany\", nullable: null, how: \"Not needed (optional has-many)\" }\n```\n\nDO NOT use FK column names (e.g., \"customer_id\" is WRONG \u2014 use \"customer\").\nInclude ALL members even if unused in this collector."
},
kind: {
oneOf: [
{
"const": "scalar"
},
{
"const": "belongsTo"
},
{
"const": "hasOne"
},
{
"const": "hasMany"
}
],
description: "Kind of Prisma schema member.\n\n- `\"scalar\"`: Regular column \u2192 direct value assignment\n- `\"belongsTo\"`: FK relation \u2192 `{ connect: { id } }`\n- `\"hasOne\"`: 1:1 relation this side owns\n- `\"hasMany\"`: 1:N or M:N \u2192 `{ create: [...] }` or omit\n\nThe kind forces explicit classification BEFORE deciding how to handle it,\npreventing confusion like treating belongsTo relations as scalar fields."
},
nullable: {
oneOf: [
{
type: "null"
},
{
type: "boolean"
}
],
description: "Whether nullable in Prisma schema.\n\n- `false`: Non-nullable \u2014 must provide value\n- `true`: Nullable \u2014 use `?? null` for scalar, `undefined` for belongsTo\n- `null`: Not applicable (hasMany/hasOne)"
},
how: {
type: "string",
description: "Brief strategy for obtaining this field's value (NOT code).\n\nWrite phase: \"Generate with v4()\", \"From props.body.email\", \"Connect using\nprops.customer.id\", \"Nested create with TagCollector\".\n\nCorrect phase: \"No change needed\", \"Fix: Wrong name 'x' \u2192 'y'\".\n\nEven if correct or unused, you MUST include it. This ensures complete\nschema coverage."
}
},
required: [
"member",
"kind",
"nullable",
"how"
],
description: "Field/relation mapping for Prisma CreateInput generation.\n\nDocuments handling strategy for ONE Prisma schema member. EVERY field and\nrelation must be listed \u2014 the validator rejects incomplete mappings."
},
"IAutoBeRealizeCollectorCorrectApplication.IReviseProps": {
type: "object",
properties: {
review: {
type: "string",
description: "MUST systematically verify four checklists:\n\n1. Error Resolution \u2014 confirm EVERY error from think Section 1 is fixed\n2. Root Cause Fix \u2014 verify fixes address root causes (not workarounds/hacks)\n3. System Rules \u2014 neighbor reuse, proper types, no fabricated fields\n4. No Regression \u2014 confirm no NEW errors, business logic intact\n\nCatch Band-Aid fixes (type assertions, any casts) that hide real\nproblems."
},
final: {
oneOf: [
{
type: "null"
},
{
type: "string"
}
],
description: "Final error-free code with all corrections applied, or null if draft\nneeds no changes."
}
},
required: [
"review",
"final"
]
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
description: " Preliminary data request or write submission",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeRealizeCollectorCorrectApplication.IProps"
}
}
],
description: "Process collector correction task or preliminary data requests."
}
]
},
kinds: ["databaseSchemas"],
dispatch: (e) => ctx.dispatch(e),
state: ctx.state(),
local: {
databaseSchemas: ctx
.state()
.database.result.data.files.map((f) => f.models)
.flat()
.filter((m) => m.name === next.function.plan.databaseSchemaName),
},
}),
// Transform history using Collector-specific transformer
histories: (next) => (0, transformRealizeCollectorCorrectHistory_1.transformRealizeCollectorCorrectHistory)(ctx, {
function: next.function,
neighbors: getNeighbors(next.function),
failures: next.failures,
preliminary: next.preliminary,
}),
// Create controller with Collector-specific validation
controller: (next) => {
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 => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "write" === input.type && "string" === typeof input.think && (Array.isArray(input.mappings) && input.mappings.every(elem => "object" === typeof elem && null !== elem && _io3(elem))) && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io4(input.revise)); const _io3 = input => "string" === typeof input.member && ("scalar" === input.kind || "belongsTo" === input.kind || "hasOne" === input.kind || "hasMany" === input.kind) && (null === input.nullable || "boolean" === typeof input.nullable) && "string" === typeof input.how; const _io4 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _iu0 = input => (() => {
if ("getDatabaseSchemas" === input.type)
return _io1(input);
else if ("write" === input.type)
return _io2(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: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeCollectorCorrectApplication.IWrite)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeCollectorCorrectApplication.IWrite)",
value: input.request
})].every(flag => flag); const _vo1 = (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, _index3) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index3 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})].every(flag => flag); const _vo2 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"write\"",
value: input.type
}), "string" === typeof input.think || _report(_exceptionable, {
path: _path + ".think",
expected: "string",
value: input.think
}), (Array.isArray(input.mappings) || _report(_exceptionable, {
path: _path + ".mappings",
expected: "Array<AutoBeRealizeCollectorMapping>",
value: input.mappings
})) && input.mappings.map((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".mappings[" + _index4 + "]",
expected: "AutoBeRealizeCollectorMapping",
value: elem
})) && _vo3(elem, _path + ".mappings[" + _index4 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".mappings[" + _index4 + "]",
expected: "AutoBeRealizeCollectorMapping",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".mappings",
expected: "Array<AutoBeRealizeCollectorMapping>",
value: input.mappings
}), "string" === typeof input.draft || _report(_exceptionable, {
path: _path + ".draft",
expected: "string",
value: input.draft
}), ("object" === typeof input.revise && null !== input.revise || _report(_exceptionable, {
path: _path + ".revise",
expected: "IAutoBeRealizeCollectorCorrectApplication.IReviseProps",
value: input.revise
})) && _vo4(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".revise",
expected: "IAutoBeRealizeCollectorCorrectApplication.IReviseProps",
value: input.revise
})].every(flag => flag); const _vo3 = (input, _path, _exceptionable = true) => ["string" === typeof input.member || _report(_exceptionable, {
path: _path + ".member",
expected: "string",
value: input.member
}), "scalar" === input.kind || "belongsTo" === input.kind || "hasOne" === input.kind || "hasMany" === input.kind || _report(_exceptionable, {
path: _path + ".kind",
expected: "(\"belongsTo\" | \"hasMany\" | \"hasOne\" | \"scalar\")",
value: input.kind
}), null === input.nullable || "boolean" === typeof input.nullable || _report(_exceptionable, {
path: _path + ".nullable",
expected: "(boolean | null)",
value: input.nullable
}), "string" === typeof input.how || _report(_exceptionable, {
path: _path + ".how",
expected: "string",
value: input.how
})].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["string" === typeof input.review || _report(_exceptionable, {
path: _path + ".review",
expected: "string",
value: input.review
}), null === input.final || "string" === typeof input.final || _report(_exceptionable, {
path: _path + ".final",
expected: "(null | string)",
value: input.final
})].every(flag => flag); const _vu0 = (input, _path, _exceptionable = true) => (() => {
if ("getDatabaseSchemas" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("write" === input.type)
return _vo2(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeCollectorCorrectApplication.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: "IAutoBeRealizeCollectorCorrectApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeCollectorCorrectApplication.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 next.preliminary.validate({
thinking: result.data.thinking,
request: result.data.request,
});
// Validate collector-specific constraints
const errors = AutoBeRealizeCollectorProgrammer_1.AutoBeRealizeCollectorProgrammer.validate({
plan: next.function.plan,
mappings: result.data.request.mappings,
neighbors: props.functions.map((f) => f.plan),
draft: result.data.request.draft,
revise: result.data.request.revise,
application: ctx.state().database.result.data,
});
return errors.length
? {
success: false,
errors,
data: result.data,
}
: result;
};
const application = next.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({
functions: [
{
name: "process",
parameters: {
description: "Current Type: {@link IAutoBeRealizeCollectorCorrectApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Think before you act.\n\nFor preliminary requests: what critical information is missing?\n\nFor write: what errors you're fixing and the correction strategy.",
type: "string"
},
request: {
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBeRealizeCollectorCorrectApplication.IWrite"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
getDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas",
write: "#/$defs/IAutoBeRealizeCollectorCorrectApplication.IWrite"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
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"
]
},
"IAutoBeRealizeCollectorCorrectApplication.IWrite": {
description: "Correct collector compilation errors via think/draft/revise.",
type: "object",
properties: {
type: {
description: "Type discriminator for write submission.",
type: "string",
"enum": [
"write"
]
},
think: {
description: "Systematic error analysis. MUST contain four sections:\n\n1. Error Inventory \u2014 categorize ALL compilation errors by root cause\n2. Root Cause Analysis \u2014 identify WHY each error occurs (wrong field, type\n mismatch, etc.)\n3. Schema Verification \u2014 cross-check error-related fields against actual\n database schema\n4. Correction Strategy \u2014 specific fix for each error (not workarounds)\n\nThis forces you to understand the REAL problem (not guess) and plan\nsurgical fixes that address root causes, not symptoms.",
type: "string"
},
mappings: {
description: "Field-by-field mapping verification. For each database schema member:\n\n- `member`: Exact Prisma field/relation name \u2014 verify against schema\n- `kind`: scalar, belongsTo, hasOne, or hasMany\n- `nullable`: true/false for scalar/belongsTo, null for hasMany/hasOne\n- `how`: Current state + correction plan (\"No change needed\", \"Fix:\n [problem] \u2192 [solution]\")\n\nEven fields without errors must be included with \"No change needed\" to\nensure complete review. MUST include EVERY field/relation from the\ndatabase schema.\n\nMissing even a single field will cause validation failure.",
type: "array",
items: {
$ref: "#/$defs/AutoBeRealizeCollectorMapping"
}
},
draft: {
description: "Complete corrected code. EVERY error from think Section 1 MUST be\naddressed. Implement:\n\n- Field name corrections (exact names from database schema)\n- Type fixes (proper CreateInput types, nullable handling)\n- Neighbor collector reuse (replace inline logic if collector exists)\n- Relationship fixes (connect/create syntax)\n\nApply fixes surgically \u2014 change ONLY what's broken, preserve working\nlogic.",
type: "string"
},
revise: {
description: "Reviews draft corrections and produces final error-free code.",
$ref: "#/$defs/IAutoBeRealizeCollectorCorrectApplication.IReviseProps"
}
},
required: [
"type",
"think",
"mappings",
"draft",
"revise"
]
},
AutoBeRealizeCollectorMapping: {
description: "Field/relation mapping for Prisma CreateInput generation.\n\nDocuments handling strategy for ONE Prisma schema member. EVERY field and\nrelation must be listed \u2014 the validator rejects incomplete mappings.",
type: "object",
properties: {
member: {
description: "Exact field or relation name from Prisma schema (case-sensitive).\n\n**Examples**:\n\n```typescript\n// Scalar fields\n{ member: \"id\", kind: \"scalar\", nullable: false, how: \"Generate with v4()\" }\n{ member: \"email\", kind: \"scalar\", nullable: false, how: \"From props.body.email\" }\n{ member: \"created_at\", kind: \"scalar\", nullable: false, how: \"Default to new Date()\" }\n{ member: \"description\", kind: \"scalar\", nullable: true, how: \"From props.body.description ?? null\" }\n\n// BelongsTo relations \u2014 use Prisma RELATION name, NOT FK column name\n{ member: \"customer\", kind: \"belongsTo\", nullable: false, how: \"Connect using props.customer.id\" }\n{ member: \"parent\", kind: \"belongsTo\", nullable: true, how: \"Undefined (nullable FK)\" }\n\n// HasMany relations\n{ member: \"tags\", kind: \"hasMany\", nullable: null, how: \"Nested create with TagCollector\" }\n{ member: \"comments\", kind: \"hasMany\", nullable: null, how: \"Not needed (optional has-many)\" }\n```\n\nDO NOT use FK column names (e.g., \"customer_id\" is WRONG \u2014 use \"customer\").\nInclude ALL members even if unused in this collector.",
type: "string"
},
kind: {
description: "Kind of Prisma schema member.\n\n- `\"scalar\"`: Regular column \u2192 direct value assignment\n- `\"belongsTo\"`: FK relation \u2192 `{ connect: { id } }`\n- `\"hasOne\"`: 1:1 relation this side owns\n- `\"hasMany\"`: 1:N or M:N \u2192 `{ create: [...] }` or omit\n\nThe kind forces explicit classification BEFORE deciding how to handle it,\npreventing confusion like treating belongsTo relations as scalar fields.",
type: "string",
"enum": [
"scalar",
"belongsTo",
"hasOne",
"hasMany"
]
},
nullable: {
description: "Whether nullable in Prisma schema.\n\n- `false`: Non-nullable \u2014 must provide value\n- `true`: Nullable \u2014 use `?? null` for scalar, `undefined` for belongsTo\n- `null`: Not applicable (hasMany/hasOne)",
anyOf: [
{
type: "null"
},
{
type: "boolean"
}
]
},
how: {
description: "Brief strategy for obtaining this field's value (NOT code).\n\nWrite phase: \"Generate with v4()\", \"From props.body.email\", \"Connect using\nprops.customer.id\", \"Nested create with TagCollector\".\n\nCorrect phase: \"No change needed\", \"Fix: Wrong name 'x' \u2192 'y'\".\n\nEven if correct or unused, you MUST include it. This ensures complete\nschema coverage.",
type: "string"
}
},
required: [
"member",
"kind",
"nullable",
"how"
]
},
"IAutoBeRealizeCollectorCorrectApplication.IReviseProps": {
type: "object",
properties: {
review: {
description: "MUST systematically verify four checklists:\n\n1. Error Resolution \u2014 confirm EVERY error from think Section 1 is fixed\n2. Root Cause Fix \u2014 verify fixes address root causes (not workarounds/hacks)\n3. System Rules \u2014 neighbor reuse, proper types, no fabricated fields\n4. No Regression \u2014 confirm no NEW errors, business logic intact\n\nCatch Band-Aid fixes (type assertions, any casts) that hide real\nproblems.",
type: "string"
},
final: {
description: "Final error-free code with all corrections applied, or null if draft\nneeds no changes.",
anyOf: [
{
type: "null"
},
{
type: "string"
}
]
}
},
required: [
"review",
"final"
]
}
}
},
description: "Process collector correction task or preliminary data requests.",
validate: (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "write" === input.type && "string" === typeof input.think && (Array.isArray(input.mappings) && input.mappings.every(elem => "object" === typeof elem && null !== elem && _io3(elem))) && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io4(input.revise)); const _io3 = input => "string" === typeof input.member && ("scalar" === input.kind || "belongsTo" === input.kind || "hasOne" === input.kind || "hasMany" === input.kind) && (null === input.nullable || "boolean" === typeof input.nullable) && "string" === typeof input.how; const _io4 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _iu0 = input => (() => {
if ("getDatabaseSchemas" === input.type)
return _io1(input);
else if ("write" === input.type)
return _io2(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: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeCollectorCorrectApplication.IWrite)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeCollectorCorrectApplication.IWrite)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["getDatabaseSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getDatabaseSchemas\"",
value: input.typ