UNPKG

@autobe/agent

Version:

AI backend server code generator

659 lines 48.8 kB
"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.orchestrateTestCorrect = void 0; 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 executeCachedBatch_1 = require("../../utils/executeCachedBatch"); const validateEmptyCode_1 = require("../../utils/validateEmptyCode"); const orchestrateCommonCorrectCasting_1 = require("../common/orchestrateCommonCorrectCasting"); const completeTestCode_1 = require("./compile/completeTestCode"); const transformTestCorrectHistories_1 = require("./histories/transformTestCorrectHistories"); const transformTestValidateEvent_1 = require("./histories/transformTestValidateEvent"); const orchestrateTestCorrectInvalidRequest_1 = require("./orchestrateTestCorrectInvalidRequest"); const orchestrateTestCorrect = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () { const result = yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, props.functions.map((w) => (promptCacheKey) => __awaiter(void 0, void 0, void 0, function* () { try { const compile = (script) => compileTestFile(ctx, Object.assign(Object.assign({}, w), { script })); const x = yield (0, orchestrateTestCorrectInvalidRequest_1.orchestrateTestCorrectInvalidRequest)(ctx, compile, w); const y = yield (0, orchestrateCommonCorrectCasting_1.orchestrateCommonCorrectCasting)(ctx, { source: "testCorrect", validate: compile, correct: (next) => { var _a, _b, _c; return ({ type: "testCorrect", kind: "casting", id: (0, uuid_1.v7)(), created_at: new Date().toISOString(), file: { scenario: w.scenario, location: w.location, content: (_a = next.final) !== null && _a !== void 0 ? _a : next.draft, }, result: next.failure, tokenUsage: next.tokenUsage, metric: next.metric, think: next.think, draft: next.draft, review: next.review, final: next.final, step: (_c = (_b = ctx.state().analyze) === null || _b === void 0 ? void 0 : _b.step) !== null && _c !== void 0 ? _c : 0, }); }, script: (event) => event.file.content, functionName: w.scenario.functionName, }, x.file.content); return yield predicate(ctx, { function: (0, transformTestValidateEvent_1.transformTestValidateEvent)(y, w.artifacts), failures: [], validate: y, promptCacheKey, instruction: props.instruction, }, ctx.retry); } catch (_a) { return null; } }))); return result.filter((r) => r !== null); }); exports.orchestrateTestCorrect = orchestrateTestCorrect; const compileTestFile = (ctx, func) => __awaiter(void 0, void 0, void 0, function* () { var _a, _b; const compiler = yield ctx.compiler(); const result = yield compiler.test.compile({ files: Object.assign(Object.assign(Object.assign({}, func.artifacts.dto), func.artifacts.sdk), { [func.location]: func.script }), }); return { type: "testValidate", id: (0, uuid_1.v7)(), file: { scenario: func.scenario, location: func.location, content: func.script, }, result, created_at: new Date().toISOString(), step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0, }; }); const predicate = (ctx, props, life) => __awaiter(void 0, void 0, void 0, function* () { if (props.validate.result.type === "failure") ctx.dispatch(props.validate); return props.validate.result.type === "failure" ? yield correct(ctx, props, life - 1) : props.validate; }); const correct = (ctx, props, life) => __awaiter(void 0, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g; if (props.validate.result.type !== "failure") return props.validate; else if (life < 0) return props.validate; const pointer = { value: null, }; const { metric, tokenUsage } = yield ctx.conversate(Object.assign({ source: "testCorrect", controller: createController({ model: ctx.model, functionName: props.function.scenario.functionName, failure: props.validate.result, build: (next) => { pointer.value = next; }, }), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, (yield (0, transformTestCorrectHistories_1.transformTestCorrectHistory)(ctx, { instruction: props.instruction, function: props.function, failures: [ ...props.failures, { function: props.function, failure: props.validate.result, }, ], })))); if (pointer.value === null) throw new Error("Failed to correct test code."); if (pointer.value.revise.final) pointer.value.revise.final = yield (0, completeTestCode_1.completeTestCode)(ctx, props.function.artifacts, pointer.value.revise.final); pointer.value.draft = yield (0, completeTestCode_1.completeTestCode)(ctx, props.function.artifacts, pointer.value.draft); ctx.dispatch({ type: "testCorrect", kind: "overall", id: (0, uuid_1.v7)(), created_at: new Date().toISOString(), file: props.validate.file, result: props.validate.result, metric, tokenUsage, step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0, think: pointer.value.think, draft: pointer.value.draft, review: (_c = pointer.value.revise) === null || _c === void 0 ? void 0 : _c.review, final: (_e = (_d = pointer.value.revise) === null || _d === void 0 ? void 0 : _d.final) !== null && _e !== void 0 ? _e : undefined, }); const newFunction = Object.assign(Object.assign({}, props.function), { script: (_g = (_f = pointer.value.revise) === null || _f === void 0 ? void 0 : _f.final) !== null && _g !== void 0 ? _g : pointer.value.draft }); const newValidate = yield compileTestFile(ctx, newFunction); return predicate(ctx, { function: newFunction, failures: [ ...props.failures, { function: props.function, failure: props.validate.result, }, ], validate: newValidate, promptCacheKey: props.promptCacheKey, instruction: props.instruction, }, life); }); const createController = (props) => { (0, assertSchemaModel_1.assertSchemaModel)(props.model); const validate = (input) => { const result = (() => { const _io0 = input => "string" === typeof input.think && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io1(input.revise)); const _io1 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.think || _report(_exceptionable, { path: _path + ".think", expected: "string", value: input.think }), "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: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })) && _vo1(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, { path: _path + ".revise", expected: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })].every(flag => flag); const _vo1 = (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 __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: "IAutoBeTestCorrectApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeTestCorrectApplication.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; const errors = (0, validateEmptyCode_1.validateEmptyCode)({ functionName: props.functionName, draft: result.data.draft, revise: result.data.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: "correct", application, execute: { rewrite: (next) => { props.build(next); }, }, }; }; const collection = { chatgpt: (validate) => (() => { const application = { model: "chatgpt", options: { reference: true, strict: false, separate: null }, functions: [ { name: "rewrite", parameters: { description: " Complete specification for error correction workflow including\nanalysis steps, draft implementation, review process, and final code\ngeneration\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestCorrectApplication.IProps}", type: "object", properties: { think: { description: "Step 1: Deep compilation error analysis and correction strategy.\n\nAI performs comprehensive analysis of compilation errors to develop\ntargeted correction strategies. This step involves deep examination of\nerror messages, identification of error patterns, understanding root\ncauses, and planning systematic corrections.\n\nThe AI examines each compilation diagnostic to understand where the\nimplementation diverged from correct TypeScript usage, identifies the\nbusiness logic intent behind the failed code, and formulates strategies\nto fix errors while preserving the original test purpose. This analysis\ncorrelates error patterns with code structure to ensure corrections\naddress root causes rather than symptoms.\n\nThis deep analysis forms the foundation for all subsequent correction\nefforts, ensuring a methodical approach to resolving compilation issues.\n\nWorkflow: Error diagnostic analysis \u2192 Root cause identification \u2192\nCorrection strategy planning \u2192 Business logic preservation strategy", type: "string" }, draft: { description: "Step 2: Draft corrected TypeScript E2E test code implementation.\n\nAI generates the first corrected version of the test code based on error\nanalysis and correction strategies. This draft addresses all identified\ncompilation errors while preserving the original business logic and test\nworkflow. The code is compilation-error-free and follows all established\nconventions.\n\nThe implementation incorporates lessons learned from error analysis to\nproduce properly typed, syntactically correct code that maintains the\nintended test functionality. All type safety requirements and framework\nconventions are followed in this corrected implementation.\n\nWorkflow: Error correction \u2192 TypeScript implementation \u2192 Functional\npreservation\n\nDO: Resolve all compilation errors while maintaining original test intent", type: "string" }, revise: { description: "Step 3-4: Review and finalization process.\n\nEncapsulates the review and final implementation phases into a single\nrevision process. This structured approach ensures systematic validation\nand refinement of the corrected code through comprehensive review\nfollowed by production-ready implementation.\n\nThe revision process maintains clear separation between review feedback\nand final deliverable while ensuring all corrections are properly\nvalidated and integrated.", $ref: "#/$defs/IAutoBeTestCorrectApplication.IReviseProps" } }, required: [ "think", "draft", "revise" ], additionalProperties: false, $defs: { "IAutoBeTestCorrectApplication.IReviseProps": { description: "Revision properties for the final review and implementation phases.\n\nThis interface encapsulates the final two steps of the error correction\nworkflow, ensuring systematic review and production-ready code delivery.", type: "object", properties: { review: { description: "Step 3: Code review and correction validation.\n\nAI performs a comprehensive review of the corrected draft implementation,\nvalidating that all compilation errors have been resolved and that the\ncode maintains the original functionality. This review examines both\ntechnical correctness and business logic preservation.\n\nThe review process includes verification of TypeScript compilation\ncompatibility, API integration correctness, test workflow completeness,\nand adherence to all quality standards. Any remaining issues or potential\nimprovements are identified for incorporation into the final\nimplementation.\n\nWorkflow: Draft validation \u2192 Compilation verification \u2192 Functionality\nreview \u2192 Quality assessment", type: "string" }, final: { description: "Step 4: Final production-ready corrected test code.\n\nAI produces the final, polished version of the corrected test code\nincorporating all review feedback and validation results. This code\nrepresents the completed error correction, guaranteed to compile\nsuccessfully while preserving all original test functionality and\nbusiness logic. When the draft correction already perfectly resolves all\nissues with no problems found during review, this value can be null,\nindicating no further refinement was necessary.\n\nThe final implementation resolves all compilation issues, maintains\nstrict type safety, follows all established conventions, and delivers a\nproduction-ready test that accurately validates the intended API\nbehaviors and user workflows. A null value signifies the draft correction\nwas already optimal and requires no modifications.\n\nWorkflow: Review integration \u2192 Final refinement \u2192 Production-ready\nimplementation (or null if draft needs no changes). This is the ultimate\ndeliverable that will replace the compilation-failed code when provided,\notherwise the draft correction is used as-is.", anyOf: [ { type: "null" }, { type: "string" } ] } }, required: [ "review", "final" ] } } }, description: "Main entry point for AI Function Call - analyzes compilation errors and\ngenerates corrected E2E test code.\n\nThe AI executes this function to perform the complete error correction\nworkflow: compilation error analysis \u2192 draft correction \u2192 code review \u2192\nfinal corrected implementation. This multi-step process ensures systematic\nerror resolution while preserving original test functionality and\nmaintaining code quality.\n\nThe corrector analyzes compilation diagnostics to identify specific issues,\ndevelops correction strategies, and produces corrected code through\niterative refinement with comprehensive review and validation.", validate: (() => { const _io0 = input => "string" === typeof input.think && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io1(input.revise)); const _io1 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.think || _report(_exceptionable, { path: _path + ".think", expected: "string", value: input.think }), "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: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })) && _vo1(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, { path: _path + ".revise", expected: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })].every(flag => flag); const _vo1 = (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 __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: "IAutoBeTestCorrectApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeTestCorrectApplication.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: { rewrite: validate, }, }), { equals: false })); return application; })(), claude: (validate) => (() => { const application = { model: "claude", options: { reference: true, separate: null }, functions: [ { name: "rewrite", parameters: { description: " Complete specification for error correction workflow including\nanalysis steps, draft implementation, review process, and final code\ngeneration\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestCorrectApplication.IProps}", type: "object", properties: { think: { description: "Step 1: Deep compilation error analysis and correction strategy.\n\nAI performs comprehensive analysis of compilation errors to develop\ntargeted correction strategies. This step involves deep examination of\nerror messages, identification of error patterns, understanding root\ncauses, and planning systematic corrections.\n\nThe AI examines each compilation diagnostic to understand where the\nimplementation diverged from correct TypeScript usage, identifies the\nbusiness logic intent behind the failed code, and formulates strategies\nto fix errors while preserving the original test purpose. This analysis\ncorrelates error patterns with code structure to ensure corrections\naddress root causes rather than symptoms.\n\nThis deep analysis forms the foundation for all subsequent correction\nefforts, ensuring a methodical approach to resolving compilation issues.\n\nWorkflow: Error diagnostic analysis \u2192 Root cause identification \u2192\nCorrection strategy planning \u2192 Business logic preservation strategy", type: "string" }, draft: { description: "Step 2: Draft corrected TypeScript E2E test code implementation.\n\nAI generates the first corrected version of the test code based on error\nanalysis and correction strategies. This draft addresses all identified\ncompilation errors while preserving the original business logic and test\nworkflow. The code is compilation-error-free and follows all established\nconventions.\n\nThe implementation incorporates lessons learned from error analysis to\nproduce properly typed, syntactically correct code that maintains the\nintended test functionality. All type safety requirements and framework\nconventions are followed in this corrected implementation.\n\nWorkflow: Error correction \u2192 TypeScript implementation \u2192 Functional\npreservation\n\nDO: Resolve all compilation errors while maintaining original test intent", type: "string" }, revise: { description: "Step 3-4: Review and finalization process.\n\nEncapsulates the review and final implementation phases into a single\nrevision process. This structured approach ensures systematic validation\nand refinement of the corrected code through comprehensive review\nfollowed by production-ready implementation.\n\nThe revision process maintains clear separation between review feedback\nand final deliverable while ensuring all corrections are properly\nvalidated and integrated.", $ref: "#/$defs/IAutoBeTestCorrectApplication.IReviseProps" } }, required: [ "think", "draft", "revise" ], additionalProperties: false, $defs: { "IAutoBeTestCorrectApplication.IReviseProps": { description: "Revision properties for the final review and implementation phases.\n\nThis interface encapsulates the final two steps of the error correction\nworkflow, ensuring systematic review and production-ready code delivery.", type: "object", properties: { review: { description: "Step 3: Code review and correction validation.\n\nAI performs a comprehensive review of the corrected draft implementation,\nvalidating that all compilation errors have been resolved and that the\ncode maintains the original functionality. This review examines both\ntechnical correctness and business logic preservation.\n\nThe review process includes verification of TypeScript compilation\ncompatibility, API integration correctness, test workflow completeness,\nand adherence to all quality standards. Any remaining issues or potential\nimprovements are identified for incorporation into the final\nimplementation.\n\nWorkflow: Draft validation \u2192 Compilation verification \u2192 Functionality\nreview \u2192 Quality assessment", type: "string" }, final: { description: "Step 4: Final production-ready corrected test code.\n\nAI produces the final, polished version of the corrected test code\nincorporating all review feedback and validation results. This code\nrepresents the completed error correction, guaranteed to compile\nsuccessfully while preserving all original test functionality and\nbusiness logic. When the draft correction already perfectly resolves all\nissues with no problems found during review, this value can be null,\nindicating no further refinement was necessary.\n\nThe final implementation resolves all compilation issues, maintains\nstrict type safety, follows all established conventions, and delivers a\nproduction-ready test that accurately validates the intended API\nbehaviors and user workflows. A null value signifies the draft correction\nwas already optimal and requires no modifications.\n\nWorkflow: Review integration \u2192 Final refinement \u2192 Production-ready\nimplementation (or null if draft needs no changes). This is the ultimate\ndeliverable that will replace the compilation-failed code when provided,\notherwise the draft correction is used as-is.", oneOf: [ { type: "null" }, { type: "string" } ] } }, required: [ "review", "final" ] } } }, description: "Main entry point for AI Function Call - analyzes compilation errors and\ngenerates corrected E2E test code.\n\nThe AI executes this function to perform the complete error correction\nworkflow: compilation error analysis \u2192 draft correction \u2192 code review \u2192\nfinal corrected implementation. This multi-step process ensures systematic\nerror resolution while preserving original test functionality and\nmaintaining code quality.\n\nThe corrector analyzes compilation diagnostics to identify specific issues,\ndevelops correction strategies, and produces corrected code through\niterative refinement with comprehensive review and validation.", validate: (() => { const _io0 = input => "string" === typeof input.think && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io1(input.revise)); const _io1 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.think || _report(_exceptionable, { path: _path + ".think", expected: "string", value: input.think }), "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: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })) && _vo1(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, { path: _path + ".revise", expected: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })].every(flag => flag); const _vo1 = (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 __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: "IAutoBeTestCorrectApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeTestCorrectApplication.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: { rewrite: validate, }, }), { equals: false })); return application; })(), gemini: (validate) => (() => { const application = { model: "gemini", options: { reference: true, separate: null }, functions: [ { name: "rewrite", parameters: { description: " Complete specification for error correction workflow including\nanalysis steps, draft implementation, review process, and final code\ngeneration\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestCorrectApplication.IProps}", type: "object", properties: { think: { description: "Step 1: Deep compilation error analysis and correction strategy.\n\nAI performs comprehensive analysis of compilation errors to develop\ntargeted correction strategies. This step involves deep examination of\nerror messages, identification of error patterns, understanding root\ncauses, and planning systematic corrections.\n\nThe AI examines each compilation diagnostic to understand where the\nimplementation diverged from correct TypeScript usage, identifies the\nbusiness logic intent behind the failed code, and formulates strategies\nto fix errors while preserving the original test purpose. This analysis\ncorrelates error patterns with code structure to ensure corrections\naddress root causes rather than symptoms.\n\nThis deep analysis forms the foundation for all subsequent correction\nefforts, ensuring a methodical approach to resolving compilation issues.\n\nWorkflow: Error diagnostic analysis \u2192 Root cause identification \u2192\nCorrection strategy planning \u2192 Business logic preservation strategy", type: "string" }, draft: { description: "Step 2: Draft corrected TypeScript E2E test code implementation.\n\nAI generates the first corrected version of the test code based on error\nanalysis and correction strategies. This draft addresses all identified\ncompilation errors while preserving the original business logic and test\nworkflow. The code is compilation-error-free and follows all established\nconventions.\n\nThe implementation incorporates lessons learned from error analysis to\nproduce properly typed, syntactically correct code that maintains the\nintended test functionality. All type safety requirements and framework\nconventions are followed in this corrected implementation.\n\nWorkflow: Error correction \u2192 TypeScript implementation \u2192 Functional\npreservation\n\nDO: Resolve all compilation errors while maintaining original test intent", type: "string" }, revise: { description: "Step 3-4: Review and finalization process.\n\nEncapsulates the review and final implementation phases into a single\nrevision process. This structured approach ensures systematic validation\nand refinement of the corrected code through comprehensive review\nfollowed by production-ready implementation.\n\nThe revision process maintains clear separation between review feedback\nand final deliverable while ensuring all corrections are properly\nvalidated and integrated.", $ref: "#/$defs/IAutoBeTestCorrectApplication.IReviseProps" } }, required: [ "think", "draft", "revise" ], additionalProperties: false, $defs: { "IAutoBeTestCorrectApplication.IReviseProps": { description: "Revision properties for the final review and implementation phases.\n\nThis interface encapsulates the final two steps of the error correction\nworkflow, ensuring systematic review and production-ready code delivery.", type: "object", properties: { review: { description: "Step 3: Code review and correction validation.\n\nAI performs a comprehensive review of the corrected draft implementation,\nvalidating that all compilation errors have been resolved and that the\ncode maintains the original functionality. This review examines both\ntechnical correctness and business logic preservation.\n\nThe review process includes verification of TypeScript compilation\ncompatibility, API integration correctness, test workflow completeness,\nand adherence to all quality standards. Any remaining issues or potential\nimprovements are identified for incorporation into the final\nimplementation.\n\nWorkflow: Draft validation \u2192 Compilation verification \u2192 Functionality\nreview \u2192 Quality assessment", type: "string" }, final: { description: "Step 4: Final production-ready corrected test code.\n\nAI produces the final, polished version of the corrected test code\nincorporating all review feedback and validation results. This code\nrepresents the completed error correction, guaranteed to compile\nsuccessfully while preserving all original test functionality and\nbusiness logic. When the draft correction already perfectly resolves all\nissues with no problems found during review, this value can be null,\nindicating no further refinement was necessary.\n\nThe final implementation resolves all compilation issues, maintains\nstrict type safety, follows all established conventions, and delivers a\nproduction-ready test that accurately validates the intended API\nbehaviors and user workflows. A null value signifies the draft correction\nwas already optimal and requires no modifications.\n\nWorkflow: Review integration \u2192 Final refinement \u2192 Production-ready\nimplementation (or null if draft needs no changes). This is the ultimate\ndeliverable that will replace the compilation-failed code when provided,\notherwise the draft correction is used as-is.", anyOf: [ { type: "null" }, { type: "string" } ] } }, required: [ "review", "final" ] } } }, description: "Main entry point for AI Function Call - analyzes compilation errors and\ngenerates corrected E2E test code.\n\nThe AI executes this function to perform the complete error correction\nworkflow: compilation error analysis \u2192 draft correction \u2192 code review \u2192\nfinal corrected implementation. This multi-step process ensures systematic\nerror resolution while preserving original test functionality and\nmaintaining code quality.\n\nThe corrector analyzes compilation diagnostics to identify specific issues,\ndevelops correction strategies, and produces corrected code through\niterative refinement with comprehensive review and validation.", validate: (() => { const _io0 = input => "string" === typeof input.think && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io1(input.revise)); const _io1 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.think || _report(_exceptionable, { path: _path + ".think", expected: "string", value: input.think }), "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: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })) && _vo1(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, { path: _path + ".revise", expected: "IAutoBeTestCorrectApplication.IReviseProps", value: input.revise })].every(flag => flag); const _vo1 = (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 __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: "IAutoBeTestCorrectApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeTestCorrectApplication.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: { rewrite: validate, }, }), { equals: false })); return application; })(), }; //# sourceMappingURL=orchestrateTestCorrect.js.map