UNPKG

@autobe/agent

Version:

AI backend server code generator

783 lines 82.4 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.orchestrateTestScenario = void 0; const __typia_transform__isTypeUint32 = __importStar(require("typia/lib/internal/_isTypeUint32")); const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport")); const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize")); const utils_1 = require("@autobe/utils"); const utils_2 = require("@typia/utils"); const tstl_1 = require("tstl"); const typia_1 = __importDefault(require("typia")); const uuid_1 = require("uuid"); const RAGRetrieval_1 = require("../../utils/RAGRetrieval"); const executeCachedBatch_1 = require("../../utils/executeCachedBatch"); const getEmbedder_1 = require("../../utils/getEmbedder"); const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController"); const convertToSectionEntries_1 = require("../common/internal/convertToSectionEntries"); const transformTestScenarioHistory_1 = require("./histories/transformTestScenarioHistory"); const AutoBeTestScenarioProgrammer_1 = require("./programmers/AutoBeTestScenarioProgrammer"); const getPrerequisites_1 = require("./utils/getPrerequisites"); /** * Orchestrate test scenario generation for all API operations. * * Following the InterfacePrerequisite pattern: * * - Generate one scenario per operation in parallel * - Review all generated scenarios in parallel * - Return final scenarios array * * @param ctx - AutoBe context * @param instruction - E2E-test-specific instructions from requirements * @returns Array of reviewed test scenarios */ const orchestrateTestScenario = (ctx, instruction) => __awaiter(void 0, void 0, void 0, function* () { var _a; const document = (_a = ctx.state().interface) === null || _a === void 0 ? void 0 : _a.document; if (document === undefined) { throw new Error("Cannot write test scenarios because there are no operations."); } const dict = AutoBeTestScenarioProgrammer_1.AutoBeTestScenarioProgrammer.associate(document.operations); const progress = { total: document.operations.length, completed: 0, }; const matrix = yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, document.operations.map((operation) => (promptCacheKey) => __awaiter(void 0, void 0, void 0, function* () { const counter = new tstl_1.Singleton(() => ++progress.completed); try { return yield process(ctx, { dict, document, operation, progress, counter, promptCacheKey, instruction, }); } catch (error) { counter.get(); console.log(operation, error); return []; } }))); const scenarios = matrix.flat(); // review removed — write agents self-review during rewrite loop return scenarios; }); exports.orchestrateTestScenario = orchestrateTestScenario; /** * Process single operation scenario generation. * * Following InterfacePrerequisite pattern: * * - Preliminary.orchestrate wrapper * - Conversate with controller * - Dispatch event * - Return scenario */ function process(ctx, props) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d; const allSections = (0, convertToSectionEntries_1.convertToSectionEntries)((_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.files) !== null && _b !== void 0 ? _b : []); const pathSegments = props.operation.path .split("/") .filter((p) => p && !p.startsWith(":") && !p.startsWith("{")); const queryText = [ "test", "scenario", props.operation.method, ...pathSegments, ].join(" "); const ragSections = yield (0, RAGRetrieval_1.buildAnalysisContextSections)((0, getEmbedder_1.getEmbedder)(), allSections, queryText, "TOPK", { log: false, logPrefix: "testScenario" }); const authorizations = (_d = (_c = ctx.state().interface) === null || _c === void 0 ? void 0 : _c.authorizations) !== null && _d !== void 0 ? _d : []; const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({ application: { version: "3.1", components: { schemas: { "IAutoBeTestScenarioApplication.IProps": { type: "object", properties: { thinking: { type: "string", description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on\nyour current state and explain your reasoning:\n\nFor preliminary requests: what information is missing and why?\n\nFor write: what scenarios you're submitting and key decisions.\n\nFor complete: why you consider the last write final.\n\nThis reflection helps you avoid duplicate requests and premature\ncompletion." }, request: { oneOf: [ { $ref: "#/components/schemas/IAutoBePreliminaryComplete" }, { $ref: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections" }, { $ref: "#/components/schemas/IAutoBePreliminaryGetInterfaceOperations" }, { $ref: "#/components/schemas/IAutoBePreliminaryGetInterfaceSchemas" }, { $ref: "#/components/schemas/IAutoBeTestScenarioApplication.IWrite" } ], discriminator: { propertyName: "type", mapping: { complete: "#/components/schemas/IAutoBePreliminaryComplete", getAnalysisSections: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections", getInterfaceOperations: "#/components/schemas/IAutoBePreliminaryGetInterfaceOperations", getInterfaceSchemas: "#/components/schemas/IAutoBePreliminaryGetInterfaceSchemas", write: "#/components/schemas/IAutoBeTestScenarioApplication.IWrite" } }, description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval, write\nsubmission, or completion signal. Exhausted preliminary types are removed\nfrom the union, physically preventing repeated calls." } }, required: [ "thinking", "request" ] }, IAutoBePreliminaryComplete: { type: "object", properties: { type: { "const": "complete", description: "Type discriminator for completion request." } }, required: [ "type" ], description: "Finalize the write loop by accepting your most recent `write` as-is.\n\nAfter submitting a `write`, review it yourself thoroughly against the review\nchecklist in your instructions. If you find issues worth fixing, submit\nanother `write` with corrections. When you are satisfied with the quality,\ncall `complete` to finalize.\n\nYou have a maximum of 3 write attempts, but this is a safety cap \u2014 not a\ntarget to fill.\n\nOnly valid after at least one `write` submission \u2014 rejected otherwise." }, IAutoBePreliminaryGetAnalysisSections: { type: "object", properties: { type: { "const": "getAnalysisSections", description: "Type discriminator." }, sectionIds: { type: "array", items: { type: "integer", minimum: 0 }, minItems: 1, maxItems: 100, description: "Section IDs to retrieve. DO NOT request same IDs already requested in\nprevious calls." } }, required: [ "type", "sectionIds" ], description: "Request to retrieve individual analysis sections by numeric ID." }, IAutoBePreliminaryGetInterfaceOperations: { type: "object", properties: { type: { "const": "getInterfaceOperations", description: "Type discriminator." }, endpoints: { type: "array", items: { $ref: "#/components/schemas/AutoBeOpenApi.IEndpoint" }, minItems: 1, description: "API operation endpoints to retrieve. DO NOT request same endpoints already\nrequested in previous calls." } }, required: [ "type", "endpoints" ], description: "Request to retrieve existing interface operations for context." }, "AutoBeOpenApi.IEndpoint": { type: "object", properties: { path: { type: "string", pattern: "^\\/[a-zA-Z0-9\\/_{}.-]*$", description: "HTTP path of the API operation.\n\nMust start with `/`. Parameters use curly braces: `{paramName}`. Resource\nnames in camelCase. No quotes, spaces, role prefixes (`/admin/`), or API\nversion prefixes (`/api/v1/`).\n\nAllowed characters: letters, digits, `/`, `{`, `}`, `-`, `_`, `.`" }, method: { oneOf: [ { "const": "get" }, { "const": "post" }, { "const": "put" }, { "const": "delete" }, { "const": "patch" } ], description: "HTTP method (lowercase only).\n\nUse `patch` (not `get`) when a read operation needs a complex\n{@link requestBody}. `get` cannot have a request body." } }, required: [ "path", "method" ], description: "API endpoint information." }, IAutoBePreliminaryGetInterfaceSchemas: { type: "object", properties: { type: { "const": "getInterfaceSchemas", description: "Type discriminator." }, typeNames: { type: "array", items: { type: "string" }, minItems: 1, description: "Schema type names to retrieve. DO NOT request same names already requested\nin previous calls." } }, required: [ "type", "typeNames" ], description: "Request to retrieve OpenAPI schema type definitions for context." }, "IAutoBeTestScenarioApplication.IWrite": { type: "object", properties: { type: { "const": "write", description: "Type discriminator for write submission." }, scenarios: { type: "array", items: { $ref: "#/components/schemas/AutoBeTestScenario" }, description: "Array of generated test scenarios for the target operation.\n\nContains 1-3 focused test scenarios that cover:\n\n- Primary success paths (most common business workflows)\n- Important edge cases (critical boundary conditions)\n- Key error scenarios (meaningful business logic failures)\n\nEach scenario includes:\n\n- Endpoint: The target API operation being tested\n- FunctionName: snake_case test function name\n- Draft: Detailed test description and validation points\n- Dependencies: Ordered list of prerequisite operations (auth, setup, etc.)\n\nGuidelines:\n\n- Focus on business logic validation, not framework validation\n- Each scenario must be independently implementable\n- Dependencies must be correctly ordered (auth \u2192 setup \u2192 target)\n- Avoid duplicate or overlapping scenarios" } }, required: [ "type", "scenarios" ], description: "Submit test scenarios for API endpoints.\n\nSubmits test scenario data to create focused, implementable test scenarios\n(1-3 per endpoint) covering the most critical business workflows, primary\nsuccess paths, and important edge cases." }, AutoBeTestScenario: { type: "object", properties: { endpoint: { $ref: "#/components/schemas/AutoBeOpenApi.IEndpoint", description: "The API endpoint being tested.\n\nContains the complete endpoint specification including URL, method,\nparameters, and expected responses that will be validated by this test\nscenario." }, draft: { type: "string", description: "A detailed natural language description of how this API endpoint should be\ntested. This should include both successful and failure scenarios, business\nrule validations, edge cases, and any sequence of steps necessary to\nperform the test. A subsequent agent will use this draft to generate\nmultiple concrete test cases." }, functionName: { type: "string", pattern: "^[a-z][a-z0-9_]*$", description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\nDO: Use snake_case naming convention.\n\n- Must start with `test_api_` prefix (mandatory requirement)\n- ALWAYS start with business feature, NOT action verbs\n- Business feature comes first, followed by scenario context\n- Embed action verbs within the scenario description, not at the beginning\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_api_[core_feature]_[specific_scenario]`\n\nWhere:\n\n- `core_feature`: The main business feature or entity being tested (customer,\n seller, cart, push_message, etc.)\n- `specific_scenario`: The specific operation or scenario context\n (join_verification_not_found, login_success, moderator_assignment_update,\n discountable_ticket_duplicated, csv_export, etc.)\n\n## Business Feature-Based Examples\n\n- `test_api_customer_join_verification_not_found` - Customer join\n verification when verification code not found\n- `test_api_seller_login` - Seller login operation\n- `test_api_cart_discountable_ticket_duplicated` - Cart discountable ticket\n with duplication scenario\n- `test_api_push_message_csv` - Push message functionality with CSV format\n- `test_api_product_review_update` - Product review update operation\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions" }, dependencies: { type: "array", items: { $ref: "#/components/schemas/AutoBeTestScenarioDependency" }, description: "A list of other API endpoints that this scenario logically depends on.\n\nThese dependencies represent context or prerequisite conditions, such as\nauthentication, resource creation, or data setup, that are relevant to the\ntest. This list is not a strict execution order \u2014 if ordering is important,\nit must be described explicitly in the `purpose`.\n\nWARNING: Every endpoint referenced here MUST exist in the provided API\noperations. Do NOT reference endpoints that are not explicitly available,\neven if they seem logically necessary based on database schema or business\nlogic." } }, required: [ "endpoint", "draft", "functionName", "dependencies" ], description: "Test scenario specification for E2E testing of a single API endpoint.\n\nDefines comprehensive test strategy including endpoint details, test\ndescription, function name, and prerequisite dependencies with proper\nexecution ordering." }, AutoBeTestScenarioDependency: { type: "object", properties: { purpose: { type: "string", description: "Why this dependency is needed.\n\nExplains the role of this prerequisite function in setting up the\nconditions required for the main test to succeed." }, endpoint: { $ref: "#/components/schemas/AutoBeOpenApi.IEndpoint", description: "The API endpoint for this dependency function.\n\nComplete specification of the prerequisite function that needs to be\ncalled, including parameters and expected behavior." } }, required: [ "purpose", "endpoint" ], description: "A dependency function that must be called before the main test.\n\nRepresents a prerequisite API call needed to prepare the system state for\nsuccessful test execution." } } }, functions: [ { name: "process", async: false, parameters: [ { name: "props", description: " Preliminary data request, write submission, or completion\nconfirmation", required: true, schema: { $ref: "#/components/schemas/IAutoBeTestScenarioApplication.IProps" } } ], description: "Process test scenario generation task or preliminary data requests.\n\nCreates focused test scenarios (1-3 per endpoint) for API endpoints by\nretrieving necessary interface operations via RAG (Retrieval-Augmented\nGeneration) and generating detailed test drafts with dependencies." } ] }, source: SOURCE, kinds: [ "analysisSections", "interfaceOperations", "interfaceSchemas", "complete", ], dispatch: (e) => ctx.dispatch(e), state: ctx.state(), all: { interfaceOperations: props.document.operations, }, local: { analysisSections: ragSections, interfaceOperations: (() => { const unique = new tstl_1.HashSet(utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals); unique.insert({ method: props.operation.method, path: props.operation.path, }); for (const pr of (0, getPrerequisites_1.getPrerequisites)({ document: props.document, endpoint: props.operation, })) unique.insert(pr.endpoint); return unique.toJSON().map((endpoint) => props.dict.get(endpoint)); })(), }, }); const event = yield preliminary.orchestrate(ctx, (out) => __awaiter(this, void 0, void 0, function* () { var _a, _b; const pointer = { value: null, }; const result = yield ctx.conversate(Object.assign({ source: SOURCE, controller: createController({ dict: props.dict, operation: props.operation, authorizations, preliminary, build: (scenarios) => { var _a; // Normalize function name to snake_case for (const s of scenarios) s.functionName = utils_2.NamingConvention.snake(s.functionName); (_a = pointer.value) !== null && _a !== void 0 ? _a : (pointer.value = []); pointer.value.push(...scenarios); }, }), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, (0, transformTestScenarioHistory_1.transformTestScenarioHistory)({ state: ctx.state(), operation: props.operation, instruction: props.instruction, preliminary, }))); if (pointer.value === null) return out(result)(null); pointer.value.splice(3); return out(result)({ type: SOURCE, id: (0, uuid_1.v7)(), metric: result.metric, tokenUsage: result.tokenUsage, scenarios: pointer.value, acquisition: preliminary.getAcquisition(), total: props.progress.total, completed: props.counter.get(), step: (_b = (_a = ctx.state().interface) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0, created_at: new Date().toISOString(), }); })); ctx.dispatch(event); return event.scenarios; }); } function createController(props) { const validate = (next) => { const result = (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "complete" === input.type; const _io2 = input => "getAnalysisSections" === input.type && (Array.isArray(input.sectionIds) && (1 <= input.sectionIds.length && input.sectionIds.length <= 100 && input.sectionIds.every(elem => "number" === typeof elem && __typia_transform__isTypeUint32._isTypeUint32(elem)))); const _io3 = input => "getInterfaceOperations" === input.type && (Array.isArray(input.endpoints) && (1 <= input.endpoints.length && input.endpoints.every(elem => "object" === typeof elem && null !== elem && _io4(elem)))); const _io4 = input => "string" === typeof input.path && RegExp("^\\/[a-zA-Z0-9\\/_{}.-]*$").test(input.path) && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method); const _io5 = input => "getInterfaceSchemas" === input.type && (Array.isArray(input.typeNames) && (1 <= input.typeNames.length && input.typeNames.every(elem => "string" === typeof elem))); const _io6 = input => "write" === input.type && (Array.isArray(input.scenarios) && input.scenarios.every(elem => "object" === typeof elem && null !== elem && _io7(elem))); const _io7 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io4(input.endpoint) && "string" === typeof input.draft && ("string" === typeof input.functionName && RegExp("^[a-z][a-z0-9_]*$").test(input.functionName)) && (Array.isArray(input.dependencies) && input.dependencies.every(elem => "object" === typeof elem && null !== elem && _io8(elem))); const _io8 = input => "string" === typeof input.purpose && ("object" === typeof input.endpoint && null !== input.endpoint && _io4(input.endpoint)); const _iu0 = input => (() => { if ("complete" === input.type) return _io1(input); else if ("getAnalysisSections" === input.type) return _io2(input); else if ("getInterfaceOperations" === input.type) return _io3(input); else if ("getInterfaceSchemas" === input.type) return _io5(input); else if ("write" === input.type) return _io6(input); else return false; })(); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.thinking || _report(_exceptionable, { path: _path + ".thinking", expected: "string", value: input.thinking }), ("object" === typeof input.request && null !== input.request || _report(_exceptionable, { path: _path + ".request", expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetInterfaceOperations | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeTestScenarioApplication.IWrite)", value: input.request })) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, { path: _path + ".request", expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetInterfaceOperations | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeTestScenarioApplication.IWrite)", value: input.request })].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["complete" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"complete\"", value: input.type })].every(flag => flag); const _vo2 = (input, _path, _exceptionable = true) => ["getAnalysisSections" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"getAnalysisSections\"", value: input.type }), (Array.isArray(input.sectionIds) || _report(_exceptionable, { path: _path + ".sectionIds", expected: "(Array<number & Type<\"uint32\">> & MinItems<1> & MaxItems<100>)", value: input.sectionIds })) && ((1 <= input.sectionIds.length || _report(_exceptionable, { path: _path + ".sectionIds", expected: "Array<> & MinItems<1>", value: input.sectionIds })) && (input.sectionIds.length <= 100 || _report(_exceptionable, { path: _path + ".sectionIds", expected: "Array<> & MaxItems<100>", value: input.sectionIds })) && input.sectionIds.map((elem, _index6) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, { path: _path + ".sectionIds[" + _index6 + "]", expected: "number & Type<\"uint32\">", value: elem })) || _report(_exceptionable, { path: _path + ".sectionIds[" + _index6 + "]", expected: "(number & Type<\"uint32\">)", value: elem })).every(flag => flag)) || _report(_exceptionable, { path: _path + ".sectionIds", expected: "(Array<number & Type<\"uint32\">> & MinItems<1> & MaxItems<100>)", value: input.sectionIds })].every(flag => flag); const _vo3 = (input, _path, _exceptionable = true) => ["getInterfaceOperations" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"getInterfaceOperations\"", value: input.type }), (Array.isArray(input.endpoints) || _report(_exceptionable, { path: _path + ".endpoints", expected: "(Array<AutoBeOpenApi.IEndpoint> & MinItems<1>)", value: input.endpoints })) && ((1 <= input.endpoints.length || _report(_exceptionable, { path: _path + ".endpoints", expected: "Array<> & MinItems<1>", value: input.endpoints })) && input.endpoints.map((elem, _index7) => ("object" === typeof elem && null !== elem || _report(_exceptionable, { path: _path + ".endpoints[" + _index7 + "]", expected: "AutoBeOpenApi.IEndpoint", value: elem })) && _vo4(elem, _path + ".endpoints[" + _index7 + "]", true && _exceptionable) || _report(_exceptionable, { path: _path + ".endpoints[" + _index7 + "]", expected: "AutoBeOpenApi.IEndpoint", value: elem })).every(flag => flag)) || _report(_exceptionable, { path: _path + ".endpoints", expected: "(Array<AutoBeOpenApi.IEndpoint> & MinItems<1>)", value: input.endpoints })].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["string" === typeof input.path && (RegExp("^\\/[a-zA-Z0-9\\/_{}.-]*$").test(input.path) || _report(_exceptionable, { path: _path + ".path", expected: "string & Pattern<\"^\\\\/[a-zA-Z0-9\\\\/_{}.-]*$\">", value: input.path })) || _report(_exceptionable, { path: _path + ".path", expected: "(string & Pattern<\"^\\\\/[a-zA-Z0-9\\\\/_{}.-]*$\">)", value: input.path }), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, { path: _path + ".method", expected: "(\"delete\" | \"get\" | \"patch\" | \"post\" | \"put\")", value: input.method })].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => ["getInterfaceSchemas" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"getInterfaceSchemas\"", value: input.type }), (Array.isArray(input.typeNames) || _report(_exceptionable, { path: _path + ".typeNames", expected: "(Array<string> & MinItems<1>)", value: input.typeNames })) && ((1 <= input.typeNames.length || _report(_exceptionable, { path: _path + ".typeNames", expected: "Array<> & MinItems<1>", value: input.typeNames })) && input.typeNames.map((elem, _index8) => "string" === typeof elem || _report(_exceptionable, { path: _path + ".typeNames[" + _index8 + "]", expected: "string", value: elem })).every(flag => flag)) || _report(_exceptionable, { path: _path + ".typeNames", expected: "(Array<string> & MinItems<1>)", value: input.typeNames })].every(flag => flag); const _vo6 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"write\"", value: input.type }), (Array.isArray(input.scenarios) || _report(_exceptionable, { path: _path + ".scenarios", expected: "Array<AutoBeTestScenario>", value: input.scenarios })) && input.scenarios.map((elem, _index9) => ("object" === typeof elem && null !== elem || _report(_exceptionable, { path: _path + ".scenarios[" + _index9 + "]", expected: "AutoBeTestScenario", value: elem })) && _vo7(elem, _path + ".scenarios[" + _index9 + "]", true && _exceptionable) || _report(_exceptionable, { path: _path + ".scenarios[" + _index9 + "]", expected: "AutoBeTestScenario", value: elem })).every(flag => flag) || _report(_exceptionable, { path: _path + ".scenarios", expected: "Array<AutoBeTestScenario>", value: input.scenarios })].every(flag => flag); const _vo7 = (input, _path, _exceptionable = true) => [("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, { path: _path + ".endpoint", expected: "AutoBeOpenApi.IEndpoint", value: input.endpoint })) && _vo4(input.endpoint, _path + ".endpoint", true && _exceptionable) || _report(_exceptionable, { path: _path + ".endpoint", expected: "AutoBeOpenApi.IEndpoint", value: input.endpoint }), "string" === typeof input.draft || _report(_exceptionable, { path: _path + ".draft", expected: "string", value: input.draft }), "string" === typeof input.functionName && (RegExp("^[a-z][a-z0-9_]*$").test(input.functionName) || _report(_exceptionable, { path: _path + ".functionName", expected: "string & SnakeCasePattern", value: input.functionName })) || _report(_exceptionable, { path: _path + ".functionName", expected: "(string & SnakeCasePattern)", value: input.functionName }), (Array.isArray(input.dependencies) || _report(_exceptionable, { path: _path + ".dependencies", expected: "Array<AutoBeTestScenarioDependency>", value: input.dependencies })) && input.dependencies.map((elem, _index10) => ("object" === typeof elem && null !== elem || _report(_exceptionable, { path: _path + ".dependencies[" + _index10 + "]", expected: "AutoBeTestScenarioDependency", value: elem })) && _vo8(elem, _path + ".dependencies[" + _index10 + "]", true && _exceptionable) || _report(_exceptionable, { path: _path + ".dependencies[" + _index10 + "]", expected: "AutoBeTestScenarioDependency", value: elem })).every(flag => flag) || _report(_exceptionable, { path: _path + ".dependencies", expected: "Array<AutoBeTestScenarioDependency>", value: input.dependencies })].every(flag => flag); const _vo8 = (input, _path, _exceptionable = true) => ["string" === typeof input.purpose || _report(_exceptionable, { path: _path + ".purpose", expected: "string", value: input.purpose }), ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, { path: _path + ".endpoint", expected: "AutoBeOpenApi.IEndpoint", value: input.endpoint })) && _vo4(input.endpoint, _path + ".endpoint", true && _exceptionable) || _report(_exceptionable, { path: _path + ".endpoint", expected: "AutoBeOpenApi.IEndpoint", value: input.endpoint })].every(flag => flag); const _vu0 = (input, _path, _exceptionable = true) => (() => { if ("complete" === input.type) return _vo1(input, _path, true && _exceptionable); else if ("getAnalysisSections" === input.type) return _vo2(input, _path, true && _exceptionable); else if ("getInterfaceOperations" === input.type) return _vo3(input, _path, true && _exceptionable); else if ("getInterfaceSchemas" === input.type) return _vo5(input, _path, true && _exceptionable); else if ("write" === input.type) return _vo6(input, _path, true && _exceptionable); else return _report(_exceptionable, { path: _path, expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetInterfaceOperations | IAutoBePreliminaryGetInterfaceSchemas | IAutoBeTestScenarioApplication.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: "IAutoBeTestScenarioApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeTestScenarioApplication.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 }; }; })()(next); if (result.success === false) return result; else if (result.data.request.type !== "write") return props.preliminary.validate({ thinking: result.data.thinking, request: result.data.request, }); const errors = []; result.data.request.scenarios.forEach((scenario, i) => AutoBeTestScenarioProgrammer_1.AutoBeTestScenarioProgrammer.validate({ errors, dict: props.dict, operation: props.operation, scenario, accessor: `$input.request.scenarios[${i}]`, })); return errors.length === 0 ? result : { success: false, data: result.data, errors, }; }; const application = props.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({ functions: [ { name: "process", parameters: { description: "Current Type: {@link IAutoBeTestScenarioApplication.IProps}", type: "object", properties: { thinking: { description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on\nyour current state and explain your reasoning:\n\nFor preliminary requests: what information is missing and why?\n\nFor write: what scenarios you're submitting and key decisions.\n\nFor complete: why you consider the last write final.\n\nThis reflection helps you avoid duplicate requests and premature\ncompletion.", type: "string" }, request: { description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval, write\nsubmission, or completion signal. Exhausted preliminary types are removed\nfrom the union, physically preventing repeated calls.", anyOf: [ { $ref: "#/$defs/IAutoBePreliminaryComplete" }, { $ref: "#/$defs/IAutoBePreliminaryGetAnalysisSections" }, { $ref: "#/$defs/IAutoBePreliminaryGetInterfaceOperations" }, { $ref: "#/$defs/IAutoBePreliminaryGetInterfaceSchemas" }, { $ref: "#/$defs/IAutoBeTestScenarioApplication.IWrite" } ], "x-discriminator": { propertyName: "type", mapping: { complete: "#/$defs/IAutoBePreliminaryComplete", getAnalysisSections: "#/$defs/IAutoBePreliminaryGetAnalysisSections", getInterfaceOperations: "#/$defs/IAutoBePreliminaryGetInterfaceOperations", getInterfaceSchemas: "#/$defs/IAutoBePreliminaryGetInterfaceSchemas", write: "#/$defs/IAutoBeTestScenarioApplication.IWrite" } } } }, required: [ "thinking", "request" ], additionalProperties: false, $defs: { IAutoBePreliminaryComplete: { description: "Finalize the write loop by accepting your most recent `write` as-is.\n\nAfter submitting a `write`, review it yourself thoroughly against the review\nchecklist in your instructions. If you find issues worth fixing, submit\nanother `write` with corrections. When you are satisfied with the quality,\ncall `complete` to finalize.\n\nYou have a maximum of 3 write attempts, but this is a safety cap \u2014 not a\ntarget to fill.\n\nOnly valid after at least one `write` submission \u2014 rejected otherwise.", type: "object", properties: { type: { description: "Type discriminator for completion request.", type: "string", "enum": [ "complete" ] } }, required: [ "type" ] }, IAutoBePreliminaryGetAnalysisSections: { description: "Request to retrieve ind