@autobe/agent
Version:
AI backend server code generator
758 lines (757 loc) • 74.5 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.orchestrateRealizeWrite = orchestrateRealizeWrite;
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport.js"));
const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize.js"));
const typia_1 = __importDefault(require("typia"));
const uuid_1 = require("uuid");
const assertSchemaModel_1 = require("../../context/assertSchemaModel");
const validateEmptyCode_1 = require("../../utils/validateEmptyCode");
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const transformRealizeWriteHistories_1 = require("./histories/transformRealizeWriteHistories");
const getRealizeWriteDto_1 = require("./utils/getRealizeWriteDto");
const replaceImportStatements_1 = require("./utils/replaceImportStatements");
function orchestrateRealizeWrite(ctx, props) {
return __awaiter(this, void 0, void 0, function* () {
const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({
source: SOURCE,
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeRealizeWriteApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on your\ncurrent state and explain your reasoning:\n\nFor preliminary requests (getAnalysisFiles, getPrismaSchemas, etc.):\n- What critical information is missing that you don't already have?\n- Why do you need it specifically right now?\n- Be brief - state the gap, don't list everything you have.\n\nFor completion (complete):\n- What key assets did you acquire?\n- What did you accomplish?\n- Why is it sufficient to complete?\n- Summarize - don't enumerate every single item.\n\nThis reflection helps you avoid duplicate requests and premature completion."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPrismaSchemas"
},
{
$ref: "#/components/schemas/IAutoBeRealizeWriteApplication.IComplete"
}
],
discriminator: {
propertyName: "type",
mapping: {
getPrismaSchemas: "#/components/schemas/IAutoBePreliminaryGetPrismaSchemas",
complete: "#/components/schemas/IAutoBeRealizeWriteApplication.IComplete"
}
},
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval\n(getPrismaSchemas) or final implementation generation (complete). When\npreliminary returns empty array, that type is removed from the union,\nphysically preventing repeated calls."
}
},
required: [
"thinking",
"request"
]
},
IAutoBePreliminaryGetPrismaSchemas: {
type: "object",
properties: {
type: {
"const": "getPrismaSchemas",
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"getPrismaSchemas\" indicates this is a preliminary\ndata request for Prisma schemas."
},
schemaNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "List of Prisma table names to retrieve.\n\nTable names from the Prisma schema file representing database entities\n(e.g., \"user\", \"post\", \"comment\").\n\nCRITICAL: DO NOT request the same schema names that you have already\nrequested in previous calls."
}
},
required: [
"type",
"schemaNames"
],
description: "Request to retrieve Prisma database schema definitions for context.\n\nThis type is used in the preliminary phase to request specific Prisma table\nschemas needed for generating type-safe API operations."
},
"IAutoBeRealizeWriteApplication.IComplete": {
type: "object",
properties: {
type: {
"const": "complete",
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"complete\" indicates this is the final task\nexecution request."
},
plan: {
type: "string",
description: "Implementation plan and strategy.\n\nAnalyzes the provider function requirements, identifies related Prisma\nschemas, and outlines the implementation approach. Includes schema\nvalidation and API contract verification."
},
draft: {
type: "string",
description: "Initial implementation draft.\n\nThe first complete implementation attempt based on the plan. May contain\nareas that need refinement in the review phase."
},
revise: {
$ref: "#/components/schemas/IAutoBeRealizeWriteApplication.IReviseProps",
description: "Revision and finalization phase.\n\nReviews the draft implementation and produces the final code with all\nimprovements and corrections applied."
}
},
required: [
"type",
"plan",
"draft",
"revise"
],
description: "Request to generate provider function implementation.\n\nExecutes three-phase generation to create complete provider implementation.\nFollows plan \u2192 draft \u2192 revise pattern to ensure type safety, proper Prisma\nusage, and API contract compliance."
},
"IAutoBeRealizeWriteApplication.IReviseProps": {
type: "object",
properties: {
review: {
type: "string",
description: "Review and improvement suggestions.\n\nIdentifies areas for improvement in the draft code, including:\n\n- Type safety enhancements\n- Prisma query optimizations\n- Null/undefined handling corrections\n- Authentication/authorization improvements\n- Error handling refinements"
},
final: {
oneOf: [
{
type: "null"
},
{
type: "string"
}
],
description: "Final implementation code.\n\nThe complete, production-ready implementation with all review suggestions\napplied.\n\nReturns `null` if the draft is already perfect and needs no changes."
}
},
required: [
"review",
"final"
]
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
description: " Request containing either preliminary data request or complete\ntask",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeRealizeWriteApplication.IProps"
}
}
],
description: "Process provider implementation task or preliminary data requests.\n\nGenerates complete provider function implementation through three-phase\nworkflow (plan \u2192 draft \u2192 revise). Ensures type safety, proper Prisma usage,\nand API contract compliance."
}
]
},
kinds: ["prismaSchemas"],
state: ctx.state(),
});
return yield preliminary.orchestrate(ctx, (out) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e;
const pointer = {
value: null,
};
const dto = yield (0, getRealizeWriteDto_1.getRealizeWriteDto)(ctx, props.scenario.operation);
const result = yield ctx.conversate(Object.assign({ source: "realizeWrite", controller: createController({
model: ctx.model,
functionName: props.scenario.functionName,
build: (next) => {
pointer.value = next;
},
preliminary,
}), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, (0, transformRealizeWriteHistories_1.transformRealizeWriteHistories)({
state: ctx.state(),
scenario: props.scenario,
authorization: props.authorization,
totalAuthorizations: props.totalAuthorizations,
dto,
preliminary,
})));
if (pointer.value !== null) {
pointer.value.draft = yield (0, replaceImportStatements_1.replaceImportStatements)(ctx, {
operation: props.scenario.operation,
schemas: props.document.components.schemas,
code: pointer.value.draft,
decoratorType: (_a = props.authorization) === null || _a === void 0 ? void 0 : _a.payload.name,
});
if (pointer.value.revise.final)
pointer.value.revise.final = yield (0, replaceImportStatements_1.replaceImportStatements)(ctx, {
operation: props.scenario.operation,
schemas: props.document.components.schemas,
code: pointer.value.revise.final,
decoratorType: (_b = props.authorization) === null || _b === void 0 ? void 0 : _b.payload.name,
});
const event = {
type: "realizeWrite",
id: (0, uuid_1.v7)(),
location: props.scenario.location,
content: (_c = pointer.value.revise.final) !== null && _c !== void 0 ? _c : pointer.value.draft,
metric: result.metric,
tokenUsage: result.tokenUsage,
completed: ++props.progress.completed,
total: props.progress.total,
step: (_e = (_d = ctx.state().analyze) === null || _d === void 0 ? void 0 : _d.step) !== null && _e !== void 0 ? _e : 0,
created_at: new Date().toISOString(),
};
ctx.dispatch(event);
return out(result)(event);
}
return out(result)(null);
}));
});
}
function createController(props) {
(0, assertSchemaModel_1.assertSchemaModel)(props.model);
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 => "getPrismaSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "complete" === input.type && "string" === typeof input.plan && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io3(input.revise)); const _io3 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _iu0 = input => (() => {
if ("getPrismaSchemas" === input.type)
return _io1(input);
else if ("complete" === 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: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeWriteApplication.IComplete)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeWriteApplication.IComplete)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["getPrismaSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPrismaSchemas\"",
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, _index2) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index2 + "]",
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) => ["complete" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"complete\"",
value: input.type
}), "string" === typeof input.plan || _report(_exceptionable, {
path: _path + ".plan",
expected: "string",
value: input.plan
}), "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: "IAutoBeRealizeWriteApplication.IReviseProps",
value: input.revise
})) && _vo3(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".revise",
expected: "IAutoBeRealizeWriteApplication.IReviseProps",
value: input.revise
})].every(flag => flag); const _vo3 = (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 ("getPrismaSchemas" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("complete" === input.type)
return _vo2(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeWriteApplication.IComplete)",
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: "IAutoBeRealizeWriteApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeWriteApplication.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 !== "complete") {
return result;
}
const errors = (0, validateEmptyCode_1.validateEmptyCode)({
functionName: props.functionName,
draft: result.data.request.draft,
revise: result.data.request.revise,
});
return errors.length
? {
success: false,
errors,
data: result.data,
}
: result;
};
const application = collection[props.model === "chatgpt"
? "chatgpt"
: props.model === "gemini"
? "gemini"
: "claude"](validate);
return {
protocol: "class",
name: SOURCE,
application,
execute: {
process: (next) => {
if (next.request.type === "complete")
props.build(next.request);
},
},
};
}
const collection = {
chatgpt: (validate) => (() => {
const application = {
model: "chatgpt",
options: {
reference: true,
strict: false,
separate: null
},
functions: [
{
name: "process",
parameters: {
description: " Request containing either preliminary data request or complete\ntask\n\n------------------------------\n\nCurrent Type: {@link IAutoBeRealizeWriteApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on your\ncurrent state and explain your reasoning:\n\nFor preliminary requests (getAnalysisFiles, getPrismaSchemas, etc.):\n- What critical information is missing that you don't already have?\n- Why do you need it specifically right now?\n- Be brief - state the gap, don't list everything you have.\n\nFor completion (complete):\n- What key assets did you acquire?\n- What did you accomplish?\n- Why is it sufficient to complete?\n- Summarize - don't enumerate every single item.\n\nThis reflection helps you avoid duplicate requests and premature completion.",
type: "string"
},
request: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval\n(getPrismaSchemas) or final implementation generation (complete). When\npreliminary returns empty array, that type is removed from the union,\nphysically preventing repeated calls.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryGetPrismaSchemas"
},
{
$ref: "#/$defs/IAutoBeRealizeWriteApplication.IComplete"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
getPrismaSchemas: "#/$defs/IAutoBePreliminaryGetPrismaSchemas",
complete: "#/$defs/IAutoBeRealizeWriteApplication.IComplete"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
IAutoBePreliminaryGetPrismaSchemas: {
description: "Request to retrieve Prisma database schema definitions for context.\n\nThis type is used in the preliminary phase to request specific Prisma table\nschemas needed for generating type-safe API operations.",
type: "object",
properties: {
type: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"getPrismaSchemas\" indicates this is a preliminary\ndata request for Prisma schemas.",
type: "string",
"enum": [
"getPrismaSchemas"
]
},
schemaNames: {
description: "List of Prisma table names to retrieve.\n\nTable names from the Prisma schema file representing database entities\n(e.g., \"user\", \"post\", \"comment\").\n\nCRITICAL: DO NOT request the same schema names that you have already\nrequested in previous calls.\n\n\n@minItems 1",
type: "array",
items: {
type: "string"
}
}
},
required: [
"type",
"schemaNames"
]
},
"IAutoBeRealizeWriteApplication.IComplete": {
description: "Request to generate provider function implementation.\n\nExecutes three-phase generation to create complete provider implementation.\nFollows plan \u2192 draft \u2192 revise pattern to ensure type safety, proper Prisma\nusage, and API contract compliance.",
type: "object",
properties: {
type: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"complete\" indicates this is the final task\nexecution request.",
type: "string",
"enum": [
"complete"
]
},
plan: {
description: "Implementation plan and strategy.\n\nAnalyzes the provider function requirements, identifies related Prisma\nschemas, and outlines the implementation approach. Includes schema\nvalidation and API contract verification.",
type: "string"
},
draft: {
description: "Initial implementation draft.\n\nThe first complete implementation attempt based on the plan. May contain\nareas that need refinement in the review phase.",
type: "string"
},
revise: {
description: "Revision and finalization phase.\n\nReviews the draft implementation and produces the final code with all\nimprovements and corrections applied.",
$ref: "#/$defs/IAutoBeRealizeWriteApplication.IReviseProps"
}
},
required: [
"type",
"plan",
"draft",
"revise"
]
},
"IAutoBeRealizeWriteApplication.IReviseProps": {
type: "object",
properties: {
review: {
description: "Review and improvement suggestions.\n\nIdentifies areas for improvement in the draft code, including:\n\n- Type safety enhancements\n- Prisma query optimizations\n- Null/undefined handling corrections\n- Authentication/authorization improvements\n- Error handling refinements",
type: "string"
},
final: {
description: "Final implementation code.\n\nThe complete, production-ready implementation with all review suggestions\napplied.\n\nReturns `null` if the draft is already perfect and needs no changes.",
anyOf: [
{
type: "null"
},
{
type: "string"
}
]
}
},
required: [
"review",
"final"
]
}
}
},
description: "Process provider implementation task or preliminary data requests.\n\nGenerates complete provider function implementation through three-phase\nworkflow (plan \u2192 draft \u2192 revise). Ensures type safety, proper Prisma usage,\nand API contract compliance.",
validate: (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "getPrismaSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "complete" === input.type && "string" === typeof input.plan && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io3(input.revise)); const _io3 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _iu0 = input => (() => {
if ("getPrismaSchemas" === input.type)
return _io1(input);
else if ("complete" === 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: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeWriteApplication.IComplete)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeWriteApplication.IComplete)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["getPrismaSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPrismaSchemas\"",
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, _index2) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index2 + "]",
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) => ["complete" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"complete\"",
value: input.type
}), "string" === typeof input.plan || _report(_exceptionable, {
path: _path + ".plan",
expected: "string",
value: input.plan
}), "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: "IAutoBeRealizeWriteApplication.IReviseProps",
value: input.revise
})) && _vo3(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".revise",
expected: "IAutoBeRealizeWriteApplication.IReviseProps",
value: input.revise
})].every(flag => flag); const _vo3 = (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 ("getPrismaSchemas" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("complete" === input.type)
return _vo2(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeWriteApplication.IComplete)",
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: "IAutoBeRealizeWriteApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeWriteApplication.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
};
}; })()
}
]
};
__typia_transform__llmApplicationFinalize._llmApplicationFinalize(application, Object.assign(Object.assign({}, {
validate: {
process: validate,
},
}), { equals: false }));
return application;
})(),
claude: (validate) => (() => {
const application = {
model: "claude",
options: {
reference: true,
separate: null
},
functions: [
{
name: "process",
parameters: {
description: " Request containing either preliminary data request or complete\ntask\n\n------------------------------\n\nCurrent Type: {@link IAutoBeRealizeWriteApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on your\ncurrent state and explain your reasoning:\n\nFor preliminary requests (getAnalysisFiles, getPrismaSchemas, etc.):\n- What critical information is missing that you don't already have?\n- Why do you need it specifically right now?\n- Be brief - state the gap, don't list everything you have.\n\nFor completion (complete):\n- What key assets did you acquire?\n- What did you accomplish?\n- Why is it sufficient to complete?\n- Summarize - don't enumerate every single item.\n\nThis reflection helps you avoid duplicate requests and premature completion.",
type: "string"
},
request: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval\n(getPrismaSchemas) or final implementation generation (complete). When\npreliminary returns empty array, that type is removed from the union,\nphysically preventing repeated calls.",
oneOf: [
{
$ref: "#/$defs/IAutoBePreliminaryGetPrismaSchemas"
},
{
$ref: "#/$defs/IAutoBeRealizeWriteApplication.IComplete"
}
],
discriminator: {
propertyName: "type",
mapping: {
getPrismaSchemas: "#/$defs/IAutoBePreliminaryGetPrismaSchemas",
complete: "#/$defs/IAutoBeRealizeWriteApplication.IComplete"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
IAutoBePreliminaryGetPrismaSchemas: {
description: "Request to retrieve Prisma database schema definitions for context.\n\nThis type is used in the preliminary phase to request specific Prisma table\nschemas needed for generating type-safe API operations.",
type: "object",
properties: {
type: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"getPrismaSchemas\" indicates this is a preliminary\ndata request for Prisma schemas.",
"const": "getPrismaSchemas"
},
schemaNames: {
description: "List of Prisma table names to retrieve.\n\nTable names from the Prisma schema file representing database entities\n(e.g., \"user\", \"post\", \"comment\").\n\nCRITICAL: DO NOT request the same schema names that you have already\nrequested in previous calls.",
type: "array",
items: {
type: "string"
},
minItems: 1
}
},
required: [
"type",
"schemaNames"
]
},
"IAutoBeRealizeWriteApplication.IComplete": {
description: "Request to generate provider function implementation.\n\nExecutes three-phase generation to create complete provider implementation.\nFollows plan \u2192 draft \u2192 revise pattern to ensure type safety, proper Prisma\nusage, and API contract compliance.",
type: "object",
properties: {
type: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"complete\" indicates this is the final task\nexecution request.",
"const": "complete"
},
plan: {
description: "Implementation plan and strategy.\n\nAnalyzes the provider function requirements, identifies related Prisma\nschemas, and outlines the implementation approach. Includes schema\nvalidation and API contract verification.",
type: "string"
},
draft: {
description: "Initial implementation draft.\n\nThe first complete implementation attempt based on the plan. May contain\nareas that need refinement in the review phase.",
type: "string"
},
revise: {
description: "Revision and finalization phase.\n\nReviews the draft implementation and produces the final code with all\nimprovements and corrections applied.",
$ref: "#/$defs/IAutoBeRealizeWriteApplication.IReviseProps"
}
},
required: [
"type",
"plan",
"draft",
"revise"
]
},
"IAutoBeRealizeWriteApplication.IReviseProps": {
type: "object",
properties: {
review: {
description: "Review and improvement suggestions.\n\nIdentifies areas for improvement in the draft code, including:\n\n- Type safety enhancements\n- Prisma query optimizations\n- Null/undefined handling corrections\n- Authentication/authorization improvements\n- Error handling refinements",
type: "string"
},
final: {
description: "Final implementation code.\n\nThe complete, production-ready implementation with all review suggestions\napplied.\n\nReturns `null` if the draft is already perfect and needs no changes.",
oneOf: [
{
type: "null"
},
{
type: "string"
}
]
}
},
required: [
"review",
"final"
]
}
}
},
description: "Process provider implementation task or preliminary data requests.\n\nGenerates complete provider function implementation through three-phase\nworkflow (plan \u2192 draft \u2192 revise). Ensures type safety, proper Prisma usage,\nand API contract compliance.",
validate: (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "getPrismaSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "complete" === input.type && "string" === typeof input.plan && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io3(input.revise)); const _io3 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _iu0 = input => (() => {
if ("getPrismaSchemas" === input.type)