UNPKG

@autobe/agent

Version:

AI backend server code generator

578 lines (543 loc) 34.2 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 __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.validatePreliminary = void 0; const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport")); const utils_1 = require("@autobe/utils"); const tstl_1 = require("tstl"); const typia_1 = __importDefault(require("typia")); const validatePreliminary = (controller, data) => { // discriminator const type = (data.request.type.startsWith("getPrevious") ? data.request.type.replace("getPrevious", "get") : data.request.type); // --------------------------------------------------------------------------- // COMPLETE CASE // // Every IXApplication interface (e.g. IAutoBeRealizeCollectorWriteApplication, // IAutoBeInterfaceEndpointWriteApplication, IAutoBeDatabaseSchemaApplication, // etc.) exposes a single `process()` whose `request` parameter is a // discriminated union: // // request: IWrite — submit generated artifacts // | IAutoBePreliminaryGet* — incremental RAG data loading // | IAutoBePreliminaryComplete — finalize the loop // // The LLM sends `{ type: "complete" }` when it believes the cyclinic // write → validate → correct loop is finished. However, LLMs frequently // attempt to call complete() prematurely — before ever submitting a write — // especially when the context window is thin or when exhausted preliminary // types are removed from the union, leaving only `complete` as a seemingly // valid choice. // // To guard against this, we check `controller.getPreviousWrite()`: // // - Prior write EXISTS → validate the `IAutoBePreliminaryComplete` // structure via typia and allow finalization. // - NO prior write → reject with an explicit error instructing the // LLM to submit its write first before requesting completion. // // @see IAutoBePreliminaryComplete — shared completion request structure // @see AutoBePreliminaryController — orchestrate() loop that consumes // the completed flag // @see orchestratePreliminary — sets completed.value when // confirm === true // --------------------------------------------------------------------------- if (type === "complete") { const previousWrite = controller.getPreviousWrite(); if (previousWrite !== null) return (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _io1(input.request)); const _io1 = input => "complete" === input.type; 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", value: input.request })) && _vo1(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, { path: _path + ".request", expected: "IAutoBePreliminaryComplete", 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 __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: "__type", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "__type", value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })()(data); return { success: false, data, errors: [ { path: "$input.request", value: data.request, expected: "IWrite", description: utils_1.StringUtil.trim ` No write has been submitted yet. Please call \`process({ request: { type: "write", ... } })\` with your content first, then call "complete" once you are satisfied with the result. `, }, ], }; } // individual validation const func = PreliminaryApplicationValidator[type]; // biome-ignore-start lint: intended return func(controller, data, data.request.type.startsWith("getPrevious")); // biome-ignore-end lint: intended }; exports.validatePreliminary = validatePreliminary; var PreliminaryApplicationValidator; (function (PreliminaryApplicationValidator) { PreliminaryApplicationValidator.getAnalysisSections = (controller, input, previous) => { const accessor = previous ? "previousAnalysisSections" : "analysisSections"; if (controller.getAll()[accessor] === undefined) return nonExisting(controller, accessor, input); const all = new Set(controller.getAll()[accessor].map((s) => s.id)); const oldbie = new Set(controller.getLocal()[accessor].map((s) => s.id)); const newbie = new Set(controller .getAll()[accessor].filter((s) => oldbie.has(s.id) === false) .map((s) => s.id)); const errors = []; input.request.sectionIds.forEach((key, i) => { if (all.has(key) === false) errors.push({ path: `$input.request.sectionIds[${i}]`, value: key, expected: Array.from(newbie) .sort((a, b) => a - b) .map((x) => String(x)) .join(" | "), description: utils_1.StringUtil.trim ` You've requested a NON-EXISTING analysis section ID: ${key} This section ID does NOT exist in the system. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request section ID ${key} again - it does not exist! ⛔ NEVER assume or invent section IDs that are not in the catalog! ⛔ You MUST choose ONLY from the available section IDs listed in the catalog! Available analysis sections you can request: ID | File | Unit | Section ---|------|------|-------- ${controller .getAll()[accessor].filter((s) => newbie.has(s.id)) .sort((a, b) => a.id - b.id) .map((s) => `${s.id} | ${s.filename} | ${s.unitTitle} | ${s.sectionTitle}`) .join("\n")} ${newbie.size === 0 ? "<!--\nfilename: PRELIMINARY_ANALYSIS_SECTION_EXHAUSTED.md\n-->\n> All analysis sections have been loaded into memory, so no available analysis sections remain.\n>\n> Therefore, never call `process()` with `type: \"getAnalysisSections\"` again. If you're planning to request more analysis sections, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getAnalysisSections\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_ANALYSIS_SECTION_EXHAUSTED */.replace("getAnalysisSections", previous ? "getPreviousAnalysisSections" : "getAnalysisSections") : ""} `, }); }); if (input.request.sectionIds.every((k) => oldbie.has(k))) errors.push({ path: `$input.request`, value: input.request, expected: controller .getArgumentTypeNames() .filter((k) => k !== "IAutoBePreliminaryGetAnalysisSections") .join(" | "), description: "<!--\nfilename: PRELIMINARY_ARGUMENT_ALL_DUPLICATED.md\n-->\n# All Requested Items Already Loaded\n\nEvery item you requested via `\"{{REQUEST_TYPE}}\"` is **already in your memory**. You already have this data \u2014 requesting it again does nothing.\n\n## Already loaded (do NOT re-request these):\n\n{{OLDBIE}}\n\n## Not yet loaded:\n\n{{NEWBIE}}\n\n## What to do now:\n\n1. If there are items in \"Not yet loaded\" above, request ONLY those items via `\"{{REQUEST_TYPE}}\"`\n2. If \"Not yet loaded\" is empty, use a **different type** from the `expected` field\n3. If you have all the data you need, call `{ type: \"complete\" }` immediately" /* AutoBeSystemPromptConstant.PRELIMINARY_ARGUMENT_ALL_DUPLICATED */.replaceAll("{{REQUEST_TYPE}}", [ "getAnalysisSections" ][0]), }); return finalize(input, errors); }; PreliminaryApplicationValidator.getDatabaseSchemas = (controller, input, previous) => { const accessor = previous ? "previousDatabaseSchemas" : "databaseSchemas"; if (controller.getAll()[accessor] === undefined) return nonExisting(controller, accessor, input); const all = new Set(controller.getAll()[accessor].map((s) => s.name)); const oldbie = new Set(controller.getLocal()[accessor].map((s) => s.name)); const newbie = new Set(controller .getAll()[accessor].filter((s) => oldbie.has(s.name) === false) .map((s) => s.name)); const errors = []; const quoted = Array.from(newbie) .sort() .map((x) => JSON.stringify(x)); input.request.schemaNames.forEach((key, i) => { if (all.has(key) === false) errors.push({ path: `$input.request.schemaNames[${i}]`, value: key, expected: quoted.join(" | "), description: utils_1.StringUtil.trim ` You've referenced a NON-EXISTING database schema name: ${JSON.stringify(key)} This database schema does NOT exist in the system. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request ${JSON.stringify(key)} again - it does not exist! ⛔ NEVER assume or invent schema names that are not in the list below! ⛔ NEVER repeat the same invalid value - I repeat: ${JSON.stringify(key)} is INVALID! ⛔ You MUST choose ONLY from the existing database schemas listed below! Existing database schema names you can request: ${quoted.map((q) => `- ${q}`).join("\n")} ${newbie.size === 0 ? "<!--\nfilename: PRELIMINARY_DATABASE_SCHEMA_EXHAUSTED.md\n-->\n> All database schemas have been loaded into memory, so no available database schemas remain.\n>\n> Therefore, never call `process()` with `type: \"getDatabaseSchemas\"` again. If you're planning to request more database schemas, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getDatabaseSchemas\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_DATABASE_SCHEMA_EXHAUSTED */.replace("getDatabaseSchemas", previous ? "getPreviousDatabaseSchemas" : "getDatabaseSchemas") : ""} `, }); }); if (input.request.schemaNames.every((k) => oldbie.has(k))) errors.push({ path: `$input.request`, value: input.request, expected: controller.getArgumentTypeNames().join(" | "), description: "<!--\nfilename: PRELIMINARY_ARGUMENT_ALL_DUPLICATED.md\n-->\n# All Requested Items Already Loaded\n\nEvery item you requested via `\"{{REQUEST_TYPE}}\"` is **already in your memory**. You already have this data \u2014 requesting it again does nothing.\n\n## Already loaded (do NOT re-request these):\n\n{{OLDBIE}}\n\n## Not yet loaded:\n\n{{NEWBIE}}\n\n## What to do now:\n\n1. If there are items in \"Not yet loaded\" above, request ONLY those items via `\"{{REQUEST_TYPE}}\"`\n2. If \"Not yet loaded\" is empty, use a **different type** from the `expected` field\n3. If you have all the data you need, call `{ type: \"complete\" }` immediately" /* AutoBeSystemPromptConstant.PRELIMINARY_ARGUMENT_ALL_DUPLICATED */.replaceAll("{{REQUEST_TYPE}}", [ "getDatabaseSchemas" ][0]) .replace("{{OLDBIE}}", Array.from(oldbie.keys()) .map((k) => `- ${k}`) .join("\n")) .replace("{{NEWBIE}}", Array.from(newbie.keys()) .map((k) => `- ${k}`) .join("\n") || "(none)"), }); return finalize(input, errors); }; PreliminaryApplicationValidator.getInterfaceOperations = (controller, input, previous) => { const accessor = previous ? "previousInterfaceOperations" : "interfaceOperations"; if (controller.getAll()[accessor] === undefined) return nonExisting(controller, accessor, input); const all = new tstl_1.HashSet(controller.getAll()[accessor].map((o) => ({ method: o.method, path: o.path, })), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals); const oldbie = new tstl_1.HashSet(controller.getLocal()[accessor].map((o) => ({ method: o.method, path: o.path, })), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals); const newbie = new tstl_1.HashSet(controller .getAll()[accessor].map((o) => ({ method: o.method, path: o.path, })) .filter((e) => oldbie.has(e) === false), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals); const errors = []; input.request.endpoints.forEach((key, i) => { if (all.has(key) === false) errors.push({ path: `$input.request.endpoints[${i}]`, value: key, expected: "AutoBeOpenApi.IEndpoint", description: utils_1.StringUtil.trim ` You've requested a NON-EXISTING API endpoint: \`${JSON.stringify(key)}\` This endpoint does NOT exist in the system. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request \`${JSON.stringify(key)}\` again - it does not exist! ⛔ NEVER assume or invent endpoints that are not in the list below! ⛔ NEVER repeat the same invalid endpoint! ⛔ You MUST choose ONLY from the existing endpoints listed below! Existing API endpoints you can request: Method | Path ------ | ---- ${newbie .toJSON() .sort(utils_1.AutoBeOpenApiEndpointComparator.compare) .map((o) => `${o.method} | ${o.path}`) .join("\n")} ${newbie.size() === 0 ? "<!--\nfilename: PRELIMINARY_INTERFACE_OPERATION_EXHAUSTED.md\n-->\n> All API operations have been loaded into memory, so no available API operations remain.\n>\n> Therefore, never call `process()` with `type: \"getInterfaceOperations\"` again. If you're planning to request more API operations, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getInterfaceOperations\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_INTERFACE_OPERATION_EXHAUSTED */.replace("getInterfaceOperations", previous ? "getPreviousInterfaceOperations" : "getInterfaceOperations") : ""} `, }); }); if (input.request.endpoints.every((k) => oldbie.has(k))) errors.push({ path: `$input.request`, value: input.request, expected: controller.getArgumentTypeNames().join(" | "), description: "<!--\nfilename: PRELIMINARY_ARGUMENT_ALL_DUPLICATED.md\n-->\n# All Requested Items Already Loaded\n\nEvery item you requested via `\"{{REQUEST_TYPE}}\"` is **already in your memory**. You already have this data \u2014 requesting it again does nothing.\n\n## Already loaded (do NOT re-request these):\n\n{{OLDBIE}}\n\n## Not yet loaded:\n\n{{NEWBIE}}\n\n## What to do now:\n\n1. If there are items in \"Not yet loaded\" above, request ONLY those items via `\"{{REQUEST_TYPE}}\"`\n2. If \"Not yet loaded\" is empty, use a **different type** from the `expected` field\n3. If you have all the data you need, call `{ type: \"complete\" }` immediately" /* AutoBeSystemPromptConstant.PRELIMINARY_ARGUMENT_ALL_DUPLICATED */.replaceAll("{{REQUEST_TYPE}}", [ "getInterfaceOperations" ][0]) .replace("{{OLDBIE}}", utils_1.StringUtil.trim ` Path | Method -----|------- ${Array.from(oldbie.toJSON()) .sort(utils_1.AutoBeOpenApiEndpointComparator.compare) .map((o) => `${o.path} | ${o.method}`) .join("\n")} `) .replace("{{NEWBIE}}", newbie .toJSON() .sort(utils_1.AutoBeOpenApiEndpointComparator.compare) .map((o) => `- ${o.method} ${o.path}`) .join("\n") || "(none)"), }); return finalize(input, errors); }; PreliminaryApplicationValidator.getInterfaceSchemas = (controller, input, previous) => { const accessor = previous ? "previousInterfaceSchemas" : "interfaceSchemas"; if (controller.getAll()[accessor] === undefined) return nonExisting(controller, accessor, input); const all = new Set(Object.keys(controller.getAll()[accessor])); const oldbie = new Set(Object.keys(controller.getLocal()[accessor])); const newbie = new Set(Object.keys(controller.getAll()[accessor]).filter((k) => oldbie.has(k) === false)); const errors = []; const quoted = Array.from(newbie) .sort() .map((k) => JSON.stringify(k)); input.request.typeNames.forEach((key, i) => { if (all.has(key) === false) errors.push({ path: `$input.request.typeNames[${i}]`, value: key, expected: quoted.join(" | "), description: utils_1.StringUtil.trim ` You've referenced a NON-EXISTING interface schema name: ${JSON.stringify(key)} This interface schema does NOT exist in the system. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request ${JSON.stringify(key)} again - it does not exist! ⛔ NEVER assume or invent schema names that are not in the list below! ⛔ NEVER repeat the same invalid value - I repeat: ${JSON.stringify(key)} is INVALID! ⛔ You MUST choose ONLY from the existing interface schemas listed below! Existing interface schema names you can request: ${quoted.map((q) => `- ${q}`).join("\n")} ${newbie.size === 0 ? "<!--\nfilename: PRELIMINARY_INTERFACE_SCHEMA_EXHAUSTED.md\n-->\n> All TypeScript type schemas have been loaded into memory, so no available type schemas remain.\n>\n> Therefore, never call `process()` with `type: \"getInterfaceSchemas\"` again. If you're planning to request more type schemas, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getInterfaceSchemas\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_INTERFACE_SCHEMA_EXHAUSTED */.replace("getInterfaceSchemas", previous ? "getPreviousInterfaceSchemas" : "getInterfaceSchemas") : ""} `, }); }); if (input.request.typeNames.every((k) => oldbie.has(k))) errors.push({ path: `$input.request`, value: input.request, expected: controller.getArgumentTypeNames().join(" | "), description: "<!--\nfilename: PRELIMINARY_ARGUMENT_ALL_DUPLICATED.md\n-->\n# All Requested Items Already Loaded\n\nEvery item you requested via `\"{{REQUEST_TYPE}}\"` is **already in your memory**. You already have this data \u2014 requesting it again does nothing.\n\n## Already loaded (do NOT re-request these):\n\n{{OLDBIE}}\n\n## Not yet loaded:\n\n{{NEWBIE}}\n\n## What to do now:\n\n1. If there are items in \"Not yet loaded\" above, request ONLY those items via `\"{{REQUEST_TYPE}}\"`\n2. If \"Not yet loaded\" is empty, use a **different type** from the `expected` field\n3. If you have all the data you need, call `{ type: \"complete\" }` immediately" /* AutoBeSystemPromptConstant.PRELIMINARY_ARGUMENT_ALL_DUPLICATED */.replaceAll("{{REQUEST_TYPE}}", [ "getInterfaceSchemas" ][0]) .replace("{{OLDBIE}}", Array.from(oldbie.keys()) .map((k) => `- ${k}`) .join("\n")) .replace("{{NEWBIE}}", Array.from(newbie.keys()) .map((k) => `- ${k}`) .join("\n") || "(none)"), }); return finalize(input, errors); }; PreliminaryApplicationValidator.getRealizeCollectors = (controller, input, _previous) => { const all = new Set(controller.getAll().realizeCollectors.map((c) => c.plan.dtoTypeName)); const oldbie = new Set(controller.getLocal().realizeCollectors.map((c) => c.plan.dtoTypeName)); const newbie = new Set(controller .getAll() .realizeCollectors.filter((c) => oldbie.has(c.plan.dtoTypeName) === false) .map((c) => c.plan.dtoTypeName)); const errors = []; const quoted = Array.from(newbie) .sort() .map((x) => JSON.stringify(x)); input.request.dtoTypeNames.forEach((key, i) => { if (all.has(key) === false) errors.push({ path: `$input.request.dtoTypeNames[${i}]`, value: key, expected: quoted.join(" | "), description: utils_1.StringUtil.trim ` You've referenced a NON-EXISTING realize collector: ${JSON.stringify(key)} This collector does NOT exist in the system. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request ${JSON.stringify(key)} again - it does not exist! ⛔ NEVER assume or invent collector names that are not in the list below! ⛔ NEVER repeat the same invalid value - I repeat: ${JSON.stringify(key)} is INVALID! ⛔ You MUST choose ONLY from the existing collectors listed below! Existing realize collectors you can request: ${quoted.map((q) => `- ${q}`).join("\n")} ${newbie.size === 0 ? "<!--\nfilename: PRELIMINARY_REALIZE_COLLECTOR_EXHAUSTED.md\n-->\n> All Realize Collector functions have been loaded into memory, so no available collectors remain.\n>\n> Therefore, never call `process()` with `type: \"getRealizeCollectors\"` again. If you're planning to request more collectors, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getRealizeCollectors\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_REALIZE_COLLECTOR_EXHAUSTED */ : ""} `, }); }); if (input.request.dtoTypeNames.every((k) => oldbie.has(k))) errors.push({ path: `$input.request`, value: input.request, expected: controller.getArgumentTypeNames().join(" | "), description: "<!--\nfilename: PRELIMINARY_ARGUMENT_ALL_DUPLICATED.md\n-->\n# All Requested Items Already Loaded\n\nEvery item you requested via `\"{{REQUEST_TYPE}}\"` is **already in your memory**. You already have this data \u2014 requesting it again does nothing.\n\n## Already loaded (do NOT re-request these):\n\n{{OLDBIE}}\n\n## Not yet loaded:\n\n{{NEWBIE}}\n\n## What to do now:\n\n1. If there are items in \"Not yet loaded\" above, request ONLY those items via `\"{{REQUEST_TYPE}}\"`\n2. If \"Not yet loaded\" is empty, use a **different type** from the `expected` field\n3. If you have all the data you need, call `{ type: \"complete\" }` immediately" /* AutoBeSystemPromptConstant.PRELIMINARY_ARGUMENT_ALL_DUPLICATED */.replaceAll("{{REQUEST_TYPE}}", [ "getRealizeCollectors" ][0]) .replace("{{OLDBIE}}", Array.from(oldbie.keys()) .map((k) => `- ${k}`) .join("\n")) .replace("{{NEWBIE}}", Array.from(newbie.keys()) .map((k) => `- ${k}`) .join("\n") || "(none)"), }); return finalize(input, errors); }; PreliminaryApplicationValidator.getRealizeTransformers = (controller, input, _previous) => { const all = new Set(controller.getAll().realizeTransformers.map((t) => t.plan.dtoTypeName)); const oldbie = new Set(controller.getLocal().realizeTransformers.map((t) => t.plan.dtoTypeName)); const newbie = new Set(controller .getAll() .realizeTransformers.filter((t) => oldbie.has(t.plan.dtoTypeName) === false) .map((t) => t.plan.dtoTypeName)); const errors = []; const quoted = Array.from(newbie) .sort() .map((x) => JSON.stringify(x)); input.request.dtoTypeNames.forEach((key, i) => { if (all.has(key) === false) errors.push({ path: `$input.request.dtoTypeNames[${i}]`, value: key, expected: quoted.join(" | "), description: utils_1.StringUtil.trim ` You've referenced a NON-EXISTING realize transformer: ${JSON.stringify(key)} This transformer does NOT exist in the system. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request ${JSON.stringify(key)} again - it does not exist! ⛔ NEVER assume or invent transformer names that are not in the list below! ⛔ NEVER repeat the same invalid value - I repeat: ${JSON.stringify(key)} is INVALID! ⛔ You MUST choose ONLY from the existing transformers listed below! Existing realize transformers you can request: ${quoted.map((q) => `- ${q}`).join("\n")} ${newbie.size === 0 ? "<!--\nfilename: PRELIMINARY_REALIZE_TRANSFORMER_EXHAUSTED.md\n-->\n> All Realize Transformer functions have been loaded into memory, so no available transformers remain.\n>\n> Therefore, never call `process()` with `type: \"getRealizeTransformers\"` again. If you're planning to request more transformers, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getRealizeTransformers\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_REALIZE_TRANSFORMER_EXHAUSTED */ : ""} `, }); }); if (input.request.dtoTypeNames.every((k) => oldbie.has(k))) errors.push({ path: `$input.request`, value: input.request, expected: controller.getArgumentTypeNames().join(" | "), description: "<!--\nfilename: PRELIMINARY_ARGUMENT_ALL_DUPLICATED.md\n-->\n# All Requested Items Already Loaded\n\nEvery item you requested via `\"{{REQUEST_TYPE}}\"` is **already in your memory**. You already have this data \u2014 requesting it again does nothing.\n\n## Already loaded (do NOT re-request these):\n\n{{OLDBIE}}\n\n## Not yet loaded:\n\n{{NEWBIE}}\n\n## What to do now:\n\n1. If there are items in \"Not yet loaded\" above, request ONLY those items via `\"{{REQUEST_TYPE}}\"`\n2. If \"Not yet loaded\" is empty, use a **different type** from the `expected` field\n3. If you have all the data you need, call `{ type: \"complete\" }` immediately" /* AutoBeSystemPromptConstant.PRELIMINARY_ARGUMENT_ALL_DUPLICATED */.replaceAll("{{REQUEST_TYPE}}", [ "getRealizeTransformers" ][0]) .replace("{{OLDBIE}}", Array.from(oldbie.keys()) .map((k) => `- ${k}`) .join("\n")) .replace("{{NEWBIE}}", Array.from(newbie.keys()) .map((k) => `- ${k}`) .join("\n") || "(none)"), }); return finalize(input, errors); }; })(PreliminaryApplicationValidator || (PreliminaryApplicationValidator = {})); const finalize = (data, errors) => errors.length === 0 ? { success: true, data, } : { success: false, data, errors, }; const nonExisting = (controller, kind, data) => ({ success: false, data, errors: [ { path: "$input.request.type", expected: controller .getKinds() .map((k) => JSON.stringify(k)) .join(" | "), value: kind, description: utils_1.StringUtil.trim ` You've requested a NON-EXISTING preliminary data type: "${kind}" This data type does NOT exist in the current context. This is NOT a recommendation, but an ABSOLUTE INSTRUCTION you MUST follow: ⛔ NEVER request "${kind}" again - it is NOT available in this context! ⛔ NEVER assume data types that are not in the list below! ⛔ NEVER repeat the same invalid request type! ${controller.getKinds().length === 0 ? utils_1.StringUtil.trim ` ⛔ NO preliminary data is available at all in this context. ✅ You MUST call process({ request: { type: "write", ... } }) RIGHT NOW. ✅ Stop requesting preliminary data and submit your write immediately. ` : utils_1.StringUtil.trim ` ⛔ You MUST choose ONLY from the available kinds listed below! Available preliminary data kinds you can request: ${controller .getKinds() .map((k) => `- ${k}`) .join("\n")} `} `, }, ], }); //# sourceMappingURL=validatePreliminary.js.map