@autobe/agent
Version:
AI backend server code generator
285 lines (282 loc) • 39.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformPreliminaryHistory = void 0;
const utils_1 = require("@autobe/utils");
const tstl_1 = require("tstl");
const uuid_1 = require("uuid");
const transformPreliminaryHistory = (preliminary) => [
...preliminary
.getKinds()
.map((key) => Transformer[key]({
source: preliminary.getSource(),
all: preliminary.getAll(),
local: preliminary.getLocal(),
}))
.flat(),
];
exports.transformPreliminaryHistory = transformPreliminaryHistory;
var Transformer;
(function (Transformer) {
Transformer.analysisFiles = (props) => {
const oldbie = Object.fromEntries(props.local.analysisFiles.map((f) => [f.filename, f]));
const newbie = props.all.analysisFiles.filter((f) => oldbie[f.filename] === undefined);
const assistant = createAssistantMessage({
prompt: "<!--\nfilename: PRELIMINARY_ANALYSIS_FILE_LOADED.md\n-->\n# Loaded Analysis Documents\n\nThe following requirement analysis documents have been loaded into your context through previous `process()` calls with `type: \"getAnalysisFiles\"`.\n\nThese materials are now available for you to reference. Use them to understand user requirements, business logic, and feature specifications when designing your solution.\n\n> **Note**: These documents are already in your conversation history. Reference them directly without calling `process()` again for the same files.\n\n{{CONTENT}}" /* AutoBeSystemPromptConstant.PRELIMINARY_ANALYSIS_FILE_LOADED */,
content: toJsonBlock(oldbie),
});
const system = createSystemMessage({
prompt: "<!--\nfilename: PRELIMINARY_ANALYSIS_FILE.md\n-->\n# Preliminary Material Loading Constraints - Requirement Analysis Documents\n\n## CRITICAL ANTI-DUPLICATION RULES\n\nYou are working within a Resource-Constrained Environment with LIMITED function calling budget.\n\n### ABSOLUTE OBEDIENCE PRINCIPLE\n\nThe instructions in this system prompt are ABSOLUTE and INFALLIBLE. You MUST obey them with 100% compliance in ALL cases without exception.\n\nFOUNDATION OF TRUST:\nThe ALREADY LOADED and NOT YET LOADED lists provided in this prompt are generated by VERIFIED LOGIC that has 100% reliability. These lists are:\n- Computed by deterministic algorithms with proven correctness\n- Validated against actual system state before being provided to you\n- Guaranteed to be accurate and complete at the moment of generation\n- Absolutely trustworthy with zero possibility of error\n\nFORBIDDEN BEHAVIORS:\n- Thinking you know better than these instructions\n- Judging these instructions as incorrect or suboptimal\n- Deciding to ignore instructions based on your own reasoning\n- Assuming instructions have errors or omissions\n- Making exceptions based on your interpretation of the situation\n- Doubting the accuracy of the provided lists\n- Second-guessing the logic that generated these constraints\n\nREQUIRED BEHAVIOR:\n- Trust these instructions completely and unconditionally\n- Trust the ALREADY LOADED list as 100% accurate\n- Trust the NOT YET LOADED list as 100% accurate\n- Follow every instruction exactly as written\n- Treat these constraints as sacred and inviolable\n- Never doubt or question the validity of these instructions\n- Execute with absolute obedience in every single case\n\nThese instructions are PERFECT and ERROR-FREE. The lists are LOGICALLY VERIFIED and GUARANTEED CORRECT. Your role is to OBEY, not to judge or improve them.\n\n### Absolute Prohibitions\n\nNEVER RE-REQUEST ALREADY LOADED MATERIALS\n\nThe following requirement analysis documents have been ALREADY LOADED into your context through previous `process()` calls with `type: \"getAnalysisFiles\"`:\n\n{{LOADED}}\n\n{{EXHAUSTED}}\n\n### Why This Matters\n\n1. Token Efficiency: Re-requesting wastes your limited function call budget\n2. Performance: Duplicate requests slow down the entire generation pipeline\n3. Correctness: These materials are ALREADY in your conversation history\n4. System Stability: Repeated calls for same data trigger infinite loops\n\n### What You Have Available\n\nALREADY LOADED AND AVAILABLE:\n- All files listed above are FULLY LOADED in your conversation history\n- You can reference them directly without any additional function calls\n- Their complete content is accessible to you RIGHT NOW\n\nNOT YET LOADED (Available on request):\n\n{{AVAILABLE}}\n\n{{EXHAUSTED}}\n\n### Action Rules\n\nALLOWED:\n- Reference any file from the \"ALREADY LOADED\" list directly\n- Request NEW files from the \"NOT YET LOADED\" list if genuinely needed\n- Use batch requests to minimize function calls\n\nABSOLUTELY FORBIDDEN:\n- Calling `process()` with `type: \"getAnalysisFiles\"` for any filename from the \"ALREADY LOADED\" list\n- Re-requesting materials \"to verify\" or \"to refresh\"\n- Requesting same file multiple times in sequence\n- Making duplicate requests \"just to be sure\"\n- Requesting files that do not exist in \"NOT YET LOADED\" list\n- Inventing or imagining file names not explicitly listed\n- Doubting the accuracy of the loaded/available lists\n\n### Request Strategy\n\nWHEN YOU NEED ADDITIONAL CONTEXT:\n1. Check the \"NOT YET LOADED\" list above\n2. Identify ONLY the files you genuinely need\n3. Request them in a SINGLE batched call\n4. NEVER request files from \"ALREADY LOADED\" section\n\nEXAMPLE OF CORRECT USAGE:\n```typescript\n// CORRECT - Request only new, needed files\nprocess({\n request: {\n type: \"getAnalysisFiles\",\n fileNames: [\"NewFeature_A.md\", \"NewFeature_B.md\"]\n }\n})\n\n// WRONG - Re-requesting the same files again\nprocess({\n request: {\n type: \"getAnalysisFiles\",\n fileNames: [\"NewFeature_A.md\"] // This was ALREADY requested above!\n }\n})\n```\n\n## ABSOLUTE PROHIBITION: Never Work from Imagination\n\n**CRITICAL**: You MUST NEVER proceed based on assumptions about analysis file contents. ALWAYS load actual data via function calling FIRST.\n\n**FORBIDDEN**:\n- Guessing requirements based on \"typical patterns\" or file names\n- Assuming validation rules without reading actual documents\n- Imagining specifications based on \"common sense\"\n\n**REQUIRED**:\n- Need business requirements? \u2192 Call `getAnalysisFiles` for the specific file\n- Need validation rules? \u2192 Load the actual document first\n- ALWAYS: Check \"NOT YET LOADED\" list \u2192 Request \u2192 Wait for data \u2192 Then work\n\n**WHY**: Assumptions cause compilation failures. Real requirements differ from \"typical\" patterns. Only actual data guarantees correctness.\n\n**ZERO TOLERANCE**: If you think \"this probably has X, Y, Z\" \u2192 STOP and request the actual file.\n\n## Enforcement\n\nThis constraint has SYSTEM PROMPT AUTHORITY - treating it as optional will cause:\n- Wasted function call budget\n- Performance degradation\n- Potential infinite loops\n- Pipeline failures\n\nZERO TOLERANCE: You MUST NOT call `process()` with `type: \"getAnalysisFiles\"` for any file in the \"ALREADY LOADED\" section. No exceptions, no special cases, no \"verification\" requests." /* AutoBeSystemPromptConstant.PRELIMINARY_ANALYSIS_FILE */,
available: utils_1.StringUtil.trim `
\`\`\`json
${JSON.stringify(newbie.map((f) => ({
filename: f.filename,
documentType: f.documentType,
audience: f.audience,
outline: f.outline,
keyQuestions: f.keyQuestions,
})))}
\`\`\`
`,
loaded: props.local.analysisFiles
.map((f) => `- ${f.filename}`)
.join("\n"),
exhausted: newbie.length === 0
? "<!--\nfilename: PRELIMINARY_ANALYSIS_FILE_EXHAUSTED.md\n-->\n> All analysis files have been loaded into memory, so no available analysis files remain.\n>\n> Therefore, never call `process()` with `type: \"getAnalysisFiles\"` again. If you're planning to request more analysis files, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getAnalysisFiles\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_ANALYSIS_FILE_EXHAUSTED */
: "",
});
return props.local.analysisFiles.length === 0
? [assistant, system]
: [
createFunctionCallingMessage({
controller: props.source,
kind: "analysisFiles",
arguments: {
thinking: "analysis files for detailed requirements' analyses",
request: {
type: "getAnalysisFiles",
fileNames: props.local.analysisFiles.map((f) => f.filename),
},
},
}),
assistant,
system,
];
};
Transformer.prismaSchemas = (props) => {
const oldbie = Object.fromEntries(props.local.prismaSchemas.map((s) => [s.name, s]));
const newbie = props.all.prismaSchemas.filter((s) => oldbie[s.name] === undefined);
const assistant = createAssistantMessage({
prompt: "<!--\nfilename: PRELIMINARY_PRISMA_SCHEMA_LOADED.md\n-->\n# Loaded Prisma Schemas\n\nThe following Prisma database models have been loaded into your context through previous `process()` calls with `type: \"getPrismaSchemas\"`.\n\nThese schema definitions are now available for you to reference. Use them to:\n- Verify actual field names and data types in the database\n- Check relationship definitions (one-to-one, one-to-many, many-to-many)\n- Understand unique constraints, indexes, and validation rules\n- Confirm which fields exist (avoid assuming common fields like `deleted_at` or `created_by`)\n- Design API operations that accurately reflect the database structure\n\n> **Note**: These schemas are already in your conversation history. Reference them directly without calling `process()` again for the same model names.\n\n{{CONTENT}}" /* AutoBeSystemPromptConstant.PRELIMINARY_PRISMA_SCHEMA_LOADED */,
content: utils_1.StringUtil.trim `
## Prisma AST Data
${toJsonBlock(oldbie)}
## Prisma Schema Files
\`\`\`prisma
${(0, utils_1.writePrismaApplication)({
dbms: "postgres",
application: {
files: [
{
filename: "all.prisma",
namespace: "All",
models: Object.values(oldbie),
},
],
},
})}
\`\`\
`,
});
const system = createSystemMessage({
prompt: "<!--\nfilename: PRELIMINARY_PRISMA_SCHEMA.md\n-->\n# Preliminary Material Loading Constraints - Prisma Database Models\n\n## CRITICAL ANTI-DUPLICATION RULES\n\nYou are working within a Resource-Constrained Environment with LIMITED function calling budget.\n\n### ABSOLUTE OBEDIENCE PRINCIPLE\n\nThe instructions in this system prompt are ABSOLUTE and INFALLIBLE. You MUST obey them with 100% compliance in ALL cases without exception.\n\nFOUNDATION OF TRUST:\nThe ALREADY LOADED and NOT YET LOADED lists provided in this prompt are generated by VERIFIED LOGIC that has 100% reliability. These lists are:\n- Computed by deterministic algorithms with proven correctness\n- Validated against actual system state before being provided to you\n- Guaranteed to be accurate and complete at the moment of generation\n- Absolutely trustworthy with zero possibility of error\n\nFORBIDDEN BEHAVIORS:\n- Thinking you know better than these instructions\n- Judging these instructions as incorrect or suboptimal\n- Deciding to ignore instructions based on your own reasoning\n- Assuming instructions have errors or omissions\n- Making exceptions based on your interpretation of the situation\n- Doubting the accuracy of the provided lists\n- Second-guessing the logic that generated these constraints\n\nREQUIRED BEHAVIOR:\n- Trust these instructions completely and unconditionally\n- Trust the ALREADY LOADED list as 100% accurate\n- Trust the NOT YET LOADED list as 100% accurate\n- Follow every instruction exactly as written\n- Treat these constraints as sacred and inviolable\n- Never doubt or question the validity of these instructions\n- Execute with absolute obedience in every single case\n\nThese instructions are PERFECT and ERROR-FREE. The lists are LOGICALLY VERIFIED and GUARANTEED CORRECT. Your role is to OBEY, not to judge or improve them.\n\n### Absolute Prohibitions\n\nNEVER RE-REQUEST ALREADY LOADED MODELS\n\nThe following Prisma database models have been ALREADY LOADED into your context through previous `process()` calls with `type: \"getPrismaSchemas\"`:\n\n{{LOADED}}\n\n{{EXHAUSTED}}\n\n### Why This Matters\n\n1. Token Efficiency: Re-requesting wastes your limited function call budget\n2. Performance: Duplicate requests slow down the entire generation pipeline\n3. Correctness: These models are ALREADY in your conversation history\n4. System Stability: Repeated calls for same data trigger infinite loops\n\n### What You Have Available\n\nALREADY LOADED AND AVAILABLE:\n- All schemas listed above are FULLY LOADED in your conversation history\n- Complete field definitions, relationships, and constraints are accessible\n- You can reference them directly without any additional function calls\n- Their complete Prisma model definitions are accessible to you RIGHT NOW\n\nNOT YET LOADED (Available on request):\n\n{{AVAILABLE}}\n\n{{EXHAUSTED}}\n\n### Action Rules\n\nALLOWED:\n- Reference any schema from the \"ALREADY LOADED\" list directly\n- Request NEW schemas from the \"NOT YET LOADED\" list if genuinely needed\n- Use batch requests to minimize function calls\n- Verify relationships using already-loaded schema definitions\n\nABSOLUTELY FORBIDDEN:\n- Calling `process()` with `type: \"getPrismaSchemas\"` for any schema name from the \"ALREADY LOADED\" list\n- Re-requesting models \"to verify field types\" or \"to check relationships\"\n- Requesting same schema multiple times in sequence\n- Making duplicate requests \"just to be sure\"\n- Requesting schemas that do not exist in \"NOT YET LOADED\" list\n- Inventing or imagining schema names not explicitly listed\n- Doubting the accuracy of the loaded/available lists\n\n### Request Strategy\n\nWHEN YOU NEED ADDITIONAL DATABASE MODELS:\n1. Check the \"NOT YET LOADED\" list above\n2. Identify ONLY the schemas you genuinely need\n3. Request them in a SINGLE batched call\n4. NEVER request schemas from \"ALREADY LOADED\" section\n\nEXAMPLE OF CORRECT USAGE:\n```typescript\n// CORRECT - Request only new, needed schemas\nprocess({\n request: {\n type: \"getPrismaSchemas\",\n schemaNames: [\"shopping_products\", \"shopping_categories\"]\n }\n})\n\n// WRONG - Re-requesting the same schemas again\nprocess({\n request: {\n type: \"getPrismaSchemas\",\n schemaNames: [\"shopping_products\"] // This was ALREADY requested above!\n }\n})\n```\n\n## ABSOLUTE PROHIBITION: Never Work from Imagination\n\n**CRITICAL**: You MUST NEVER proceed based on assumptions about Prisma schema contents. ALWAYS load actual schemas via function calling FIRST.\n\n**FORBIDDEN**:\n- Guessing field names based on \"typical database patterns\" or entity names\n- Assuming relationships/foreign keys without seeing actual schema\n- Imagining field types based on \"common conventions\"\n\n**REQUIRED**:\n- Need field information? \u2192 Call `getPrismaSchemas` for the specific model\n- Need relationship details? \u2192 Load the actual Prisma schema first\n- Need unique constraints? \u2192 Request the schema definition\n- ALWAYS: Check \"NOT YET LOADED\" list \u2192 Request \u2192 Wait for data \u2192 Then work\n\n**WHY**: Assumptions cause compilation failures and incorrect references. Real schemas differ from \"typical\" patterns. Only actual data guarantees type safety.\n\n**ZERO TOLERANCE**: If you think \"this table probably has fields X, Y, Z\" \u2192 STOP and request the actual schema.\n\n## Enforcement\n\nThis constraint has SYSTEM PROMPT AUTHORITY - treating it as optional will cause:\n- Wasted function call budget\n- Performance degradation\n- Potential infinite loops\n- Pipeline failures\n\nZERO TOLERANCE: You MUST NOT call `process()` with `type: \"getPrismaSchemas\"` for any schema in the \"ALREADY LOADED\" section. No exceptions, no special cases, no \"verification\" requests." /* AutoBeSystemPromptConstant.PRELIMINARY_PRISMA_SCHEMA */,
available: utils_1.StringUtil.trim `
Name | Stance | Summary
-----|--------|---------
${newbie
.map((m) => [m.name, m.stance, getSummary(m.description)].join(" | "))
.join("\n")}
`,
loaded: props.local.prismaSchemas.map((s) => `- ${s.name}`).join("\n"),
exhausted: newbie.length === 0
? "<!--\nfilename: PRELIMINARY_PRISMA_SCHEMA_EXHAUSTED.md\n-->\n> All Prisma schemas have been loaded into memory, so no available Prisma schemas remain.\n>\n> Therefore, never call `process()` with `type: \"getPrismaSchemas\"` again. If you're planning to request more Prisma schemas, it is an absolutely wrong decision. You must proceed to complete your task instead.\n>\n> To reiterate: never call `process()` with `type: \"getPrismaSchemas\"` again." /* AutoBeSystemPromptConstant.PRELIMINARY_PRISMA_SCHEMA_EXHAUSTED */
: "",
});
return props.local.prismaSchemas.length === 0
? [assistant, system]
: [
createFunctionCallingMessage({
controller: props.source,
kind: "prismaSchemas",
arguments: {
thinking: "prisma schemas for DB schema information",
request: {
type: "getPrismaSchemas",
schemaNames: props.local.prismaSchemas.map((s) => s.name),
},
},
}),
assistant,
system,
];
};
Transformer.interfaceOperations = (props) => {
const oldbie = new tstl_1.HashSet(props.local.interfaceOperations.map((o) => ({
method: o.method,
path: o.path,
})), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals);
const newbie = props.all.interfaceOperations.filter((o) => oldbie.has({
method: o.method,
path: o.path,
}) === false);
const assistant = createAssistantMessage({
prompt: "<!--\nfilename: PRELIMINARY_INTERFACE_OPERATION_LOADED.md\n-->\n# Loaded API Operations\n\nThe following API operations have been loaded into your context through previous `process()` calls with `type: \"getInterfaceOperations\"`.\n\nThese operation specifications are now available for you to reference. Use them to:\n- Understand existing API patterns and naming conventions\n- Ensure consistency with already-defined operations\n- Check request/response body structures and parameter formats\n- Verify prerequisite relationships and dependencies\n\n> **Note**: These operations are already in your conversation history. Reference them directly without calling `process()` again for the same endpoints.\n\n{{CONTENT}}" /* AutoBeSystemPromptConstant.PRELIMINARY_INTERFACE_OPERATION_LOADED */,
content: toJsonBlock(props.local.interfaceOperations),
});
const system = createSystemMessage({
prompt: "<!--\nfilename: PRELIMINARY_INTERFACE_OPERATION.md\n-->\n# Preliminary Material Loading Constraints - API Operations\n\n## CRITICAL ANTI-DUPLICATION RULES\n\nYou are working within a Resource-Constrained Environment with LIMITED function calling budget.\n\n### ABSOLUTE OBEDIENCE PRINCIPLE\n\nThe instructions in this system prompt are ABSOLUTE and INFALLIBLE. You MUST obey them with 100% compliance in ALL cases without exception.\n\nFOUNDATION OF TRUST:\nThe ALREADY LOADED and NOT YET LOADED lists provided in this prompt are generated by VERIFIED LOGIC that has 100% reliability. These lists are:\n- Computed by deterministic algorithms with proven correctness\n- Validated against actual system state before being provided to you\n- Guaranteed to be accurate and complete at the moment of generation\n- Absolutely trustworthy with zero possibility of error\n\nFORBIDDEN BEHAVIORS:\n- Thinking you know better than these instructions\n- Judging these instructions as incorrect or suboptimal\n- Deciding to ignore instructions based on your own reasoning\n- Assuming instructions have errors or omissions\n- Making exceptions based on your interpretation of the situation\n- Doubting the accuracy of the provided lists\n- Second-guessing the logic that generated these constraints\n\nREQUIRED BEHAVIOR:\n- Trust these instructions completely and unconditionally\n- Trust the ALREADY LOADED list as 100% accurate\n- Trust the NOT YET LOADED list as 100% accurate\n- Follow every instruction exactly as written\n- Treat these constraints as sacred and inviolable\n- Never doubt or question the validity of these instructions\n- Execute with absolute obedience in every single case\n\nThese instructions are PERFECT and ERROR-FREE. The lists are LOGICALLY VERIFIED and GUARANTEED CORRECT. Your role is to OBEY, not to judge or improve them.\n\n### Absolute Prohibitions\n\nNEVER RE-REQUEST ALREADY LOADED OPERATIONS\n\nThe following API operations have been ALREADY LOADED into your context through previous `process()` calls with `type: \"getInterfaceOperations\"`:\n\n{{LOADED}}\n\n{{EXHAUSTED}}\n\n### Why This Matters\n\n1. Token Efficiency: Re-requesting wastes your limited function call budget\n2. Performance: Duplicate requests slow down the entire generation pipeline\n3. Correctness: These operations are ALREADY in your conversation history\n4. System Stability: Repeated calls for same data trigger infinite loops\n\n### What You Have Available\n\nALREADY LOADED AND AVAILABLE:\n- All operations listed above are FULLY LOADED in your conversation history\n- Complete specifications, parameters, request/response bodies are accessible\n- You can reference them directly without any additional function calls\n- Their full OpenAPI operation definitions are accessible to you RIGHT NOW\n\nNOT YET LOADED (Available on request):\n\n{{AVAILABLE}}\n\n{{EXHAUSTED}}\n\n### Action Rules\n\nALLOWED:\n- Reference any operation from the \"ALREADY LOADED\" list directly\n- Request NEW operations from the \"NOT YET LOADED\" list if genuinely needed\n- Use batch requests to minimize function calls\n- Analyze loaded operations for consistency patterns\n\nABSOLUTELY FORBIDDEN:\n- Calling `process()` with `type: \"getInterfaceOperations\"` for any endpoint from the \"ALREADY LOADED\" list\n- Re-requesting operations \"to verify specifications\" or \"to check consistency\"\n- Requesting same operation multiple times in sequence\n- Making duplicate requests \"just to be sure\"\n- Requesting operations that do not exist in \"NOT YET LOADED\" list\n- Inventing or imagining operation paths not explicitly listed\n- Doubting the accuracy of the loaded/available lists\n\n### Request Strategy\n\nWHEN YOU NEED ADDITIONAL API OPERATIONS:\n1. Check the \"NOT YET LOADED\" list above\n2. Identify ONLY the operations you genuinely need\n3. Request them in a SINGLE batched call\n4. NEVER request operations from \"ALREADY LOADED\" section\n\nEXAMPLE OF CORRECT USAGE:\n```typescript\n// CORRECT - Request only new, needed operations\nprocess({\n request: {\n type: \"getInterfaceOperations\",\n endpoints: [\n { path: \"/products\", method: \"post\" },\n { path: \"/orders\", method: \"get\" }\n ]\n }\n})\n\n// WRONG - Re-requesting the same operations again\nprocess({\n request: {\n type: \"getInterfaceOperations\",\n endpoints: [\n { path: \"/products\", method: \"post\" } // This was ALREADY requested above!\n ]\n }\n})\n```\n\n## ABSOLUTE PROHIBITION: Never Work from Imagination\n\n**CRITICAL**: You MUST NEVER proceed based on assumptions about API operation specifications. ALWAYS load actual operations via function calling FIRST.\n\n**FORBIDDEN**:\n- Guessing parameters based on \"typical REST patterns\" or endpoint paths\n- Assuming request/response bodies without seeing actual specification\n- Imagining authorization requirements based on \"common sense\"\n\n**REQUIRED**:\n- Need parameter details? \u2192 Call `getInterfaceOperations` for the specific endpoint\n- Need authorization requirements? \u2192 Load the actual operation specification first\n- Need request/response structures? \u2192 Request the operation definition\n- ALWAYS: Check \"NOT YET LOADED\" list \u2192 Request \u2192 Wait for data \u2192 Then work\n\n**WHY**: Assumptions cause compilation failures and API inconsistency. Real operations differ from \"typical\" REST patterns. Only actual data guarantees correctness.\n\n**ZERO TOLERANCE**: If you think \"this endpoint probably has parameters X, Y, Z\" \u2192 STOP and request the actual operation.\n\n## Enforcement\n\nThis constraint has SYSTEM PROMPT AUTHORITY - treating it as optional will cause:\n- Wasted function call budget\n- Performance degradation\n- Potential infinite loops\n- Pipeline failures\n\nZERO TOLERANCE: You MUST NOT call `process()` with `type: \"getInterfaceOperations\"` for any operation in the \"ALREADY LOADED\" section. No exceptions, no special cases, no \"verification\" requests." /* AutoBeSystemPromptConstant.PRELIMINARY_INTERFACE_OPERATION */,
available: utils_1.StringUtil.trim `
Method | Path | Actor? | Authorization? | Summary
-------|------|--------|----------------|---------
${newbie
.map((o) => {
var _a, _b;
return [
o.method,
o.path,
(_a = o.authorizationActor) !== null && _a !== void 0 ? _a : "-",
(_b = o.authorizationType) !== null && _b !== void 0 ? _b : "-",
getSummary(o.summary),
].join(" | ");
})
.join("\n")}
`,
loaded: utils_1.StringUtil.trim `
Method | Path
-------|-------
${oldbie
.toJSON()
.map((e) => [e.method, e.path].join(" | "))
.join("\n")}
`,
exhausted: newbie.length === 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 */
: "",
});
return props.local.interfaceOperations.length === 0
? [assistant, system]
: [
createFunctionCallingMessage({
controller: props.source,
kind: "interfaceOperations",
arguments: {
thinking: "interface operations for detailed endpoint information",
request: {
type: "getInterfaceOperations",
endpoints: oldbie.toJSON(),
},
},
}),
assistant,
system,
];
};
Transformer.interfaceSchemas = (props) => {
const newbie = {};
for (const [k, v] of Object.entries(props.all.interfaceSchemas))
if (props.local.interfaceSchemas[k] === undefined)
newbie[k] = v;
const assistant = createAssistantMessage({
prompt: "<!--\nfilename: PRELIMINARY_INTERFACE_SCHEMA_LOADED.md\n-->\n# Loaded Type Schemas\n\nThe following TypeScript type schemas have been loaded into your context through previous `process()` calls with `type: \"getInterfaceSchemas\"`.\n\nThese schema definitions are now available for you to reference. Use them to:\n- Verify property names, types, and required fields\n- Check DTO variant structures (.ICreate, .IUpdate, .ISummary, etc.)\n- Understand nested object types and their relationships\n- Ensure type consistency across related operations\n- Validate references to shared schema components\n\n> **Note**: These schemas are already in your conversation history. Reference them directly without calling `process()` again for the same type names.\n\n{{CONTENT}}" /* AutoBeSystemPromptConstant.PRELIMINARY_INTERFACE_SCHEMA_LOADED */,
content: toJsonBlock(props.local.interfaceSchemas),
});
const system = createSystemMessage({
prompt: "<!--\nfilename: PRELIMINARY_INTERFACE_SCHEMA.md\n-->\n# Preliminary Material Loading Constraints - TypeScript Type Schemas\n\n## CRITICAL ANTI-DUPLICATION RULES\n\nYou are working within a Resource-Constrained Environment with LIMITED function calling budget.\n\n### ABSOLUTE OBEDIENCE PRINCIPLE\n\nThe instructions in this system prompt are ABSOLUTE and INFALLIBLE. You MUST obey them with 100% compliance in ALL cases without exception.\n\nFOUNDATION OF TRUST:\nThe ALREADY LOADED and NOT YET LOADED lists provided in this prompt are generated by VERIFIED LOGIC that has 100% reliability. These lists are:\n- Computed by deterministic algorithms with proven correctness\n- Validated against actual system state before being provided to you\n- Guaranteed to be accurate and complete at the moment of generation\n- Absolutely trustworthy with zero possibility of error\n\nFORBIDDEN BEHAVIORS:\n- Thinking you know better than these instructions\n- Judging these instructions as incorrect or suboptimal\n- Deciding to ignore instructions based on your own reasoning\n- Assuming instructions have errors or omissions\n- Making exceptions based on your interpretation of the situation\n- Doubting the accuracy of the provided lists\n- Second-guessing the logic that generated these constraints\n\nREQUIRED BEHAVIOR:\n- Trust these instructions completely and unconditionally\n- Trust the ALREADY LOADED list as 100% accurate\n- Trust the NOT YET LOADED list as 100% accurate\n- Follow every instruction exactly as written\n- Treat these constraints as sacred and inviolable\n- Never doubt or question the validity of these instructions\n- Execute with absolute obedience in every single case\n\nThese instructions are PERFECT and ERROR-FREE. The lists are LOGICALLY VERIFIED and GUARANTEED CORRECT. Your role is to OBEY, not to judge or improve them.\n\n### Absolute Prohibitions\n\nNEVER RE-REQUEST ALREADY LOADED SCHEMAS\n\nThe following TypeScript type schemas have been ALREADY LOADED into your context through previous `process()` calls with `type: \"getInterfaceSchemas\"`:\n\n{{LOADED}}\n\n{{EXHAUSTED}}\n\n### Why This Matters\n\n1. Token Efficiency: Re-requesting wastes your limited function call budget\n2. Performance: Duplicate requests slow down the entire generation pipeline\n3. Correctness: These schemas are ALREADY in your conversation history\n4. System Stability: Repeated calls for same data trigger infinite loops\n\n### What You Have Available\n\nALREADY LOADED AND AVAILABLE:\n- All type schemas listed above are FULLY LOADED in your conversation history\n- Complete JSON Schema definitions with properties, types, and descriptions\n- You can reference them directly without any additional function calls\n- Their full OpenAPI schema definitions are accessible to you RIGHT NOW\n\nNOT YET LOADED (Available on request):\n\n{{AVAILABLE}}\n\n{{EXHAUSTED}}\n\n### Action Rules\n\nALLOWED:\n- Reference any schema from the \"ALREADY LOADED\" list directly\n- Request NEW schemas from the \"NOT YET LOADED\" list if genuinely needed\n- Use batch requests to minimize function calls\n- Verify type compatibility using already-loaded schema definitions\n\nABSOLUTELY FORBIDDEN:\n- Calling `process()` with `type: \"getInterfaceSchemas\"` for any type name from the \"ALREADY LOADED\" list\n- Re-requesting schemas \"to verify properties\" or \"to check field types\"\n- Requesting same schema multiple times in sequence\n- Making duplicate requests \"just to be sure\"\n- Requesting type schemas that do not exist in \"NOT YET LOADED\" list\n- Inventing or imagining type names not explicitly listed\n- Doubting the accuracy of the loaded/available lists\n\n### Request Strategy\n\nWHEN YOU NEED ADDITIONAL TYPE SCHEMAS:\n1. Check the \"NOT YET LOADED\" list above\n2. Identify ONLY the schemas you genuinely need\n3. Request them in a SINGLE batched call\n4. NEVER request schemas from \"ALREADY LOADED\" section\n\nEXAMPLE OF CORRECT USAGE:\n```typescript\n// CORRECT - Request only new, needed schemas\nprocess({\n request: {\n type: \"getInterfaceSchemas\",\n typeNames: [\"IShoppingProduct.ICreate\", \"IShoppingOrder.ISummary\"]\n }\n})\n\n// WRONG - Re-requesting the same schemas again\nprocess({\n request: {\n type: \"getInterfaceSchemas\",\n typeNames: [\"IShoppingProduct.ICreate\"] // This was ALREADY requested above!\n }\n})\n```\n\n## ABSOLUTE PROHIBITION: Never Work from Imagination\n\n**CRITICAL**: You MUST NEVER proceed based on assumptions about TypeScript type schema contents. ALWAYS load actual schemas via function calling FIRST.\n\n**FORBIDDEN**:\n- Guessing DTO properties based on \"typical patterns\" or entity names\n- Assuming field types without seeing actual schema definition\n- Imagining validation rules or DTO variant structures based on \"common conventions\"\n\n**REQUIRED**:\n- Need DTO property information? \u2192 Call `getInterfaceSchemas` for the specific type\n- Need field types or validation constraints? \u2192 Load the actual schema definition first\n- Need DTO variant patterns (.ICreate, .IUpdate, .ISummary)? \u2192 Request and verify the schema\n- ALWAYS: Check \"NOT YET LOADED\" list \u2192 Request \u2192 Wait for data \u2192 Then work\n\n**WHY**: Assumptions cause compilation failures and incorrect type references. Real schemas differ from \"typical\" DTO patterns. Only actual data guarantees type safety.\n\n**ZERO TOLERANCE**: If you think \"this DTO probably has properties X, Y, Z\" \u2192 STOP and request the actual schema.\n\n## Enforcement\n\nThis constraint has SYSTEM PROMPT AUTHORITY - treating it as optional will cause:\n- Wasted function call budget\n- Performance degradation\n- Potential infinite loops\n- Pipeline failures\n\nZERO TOLERANCE: You MUST NOT call `process()` with `type: \"getInterfaceSchemas\"` for any type in the \"ALREADY LOADED\" section. No exceptions, no special cases, no \"verification\" requests." /* AutoBeSystemPromptConstant.PRELIMINARY_INTERFACE_SCHEMA */,
available: utils_1.StringUtil.trim `
Name | Summary
-----|---------
${Object.entries(newbie)
.map(([name, schema]) => [name, getSummary(schema.description)].join(" | "))
.join("\n")}
`,
loaded: Object.keys(props.local.interfaceSchemas)
.map((k) => `- ${k}`)
.join("\n"),
exhausted: Object.keys(newbie).length === 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 */
: "",
});
return Object.keys(props.local.interfaceSchemas).length === 0
? [assistant, system]
: [
createFunctionCallingMessage({
controller: props.source,
kind: "interfaceSchemas",
arguments: {
thinking: "interface schemas for detailed schema information",
request: {
type: "getInterfaceSchemas",
typeNames: Object.keys(props.local.interfaceSchemas),
},
},
}),
assistant,
system,
];
};
})(Transformer || (Transformer = {}));
// experimenting between assistantMessage and execute types
const createFunctionCallingMessage = (props) => ({
type: "execute",
id: (0, uuid_1.v7)(),
operation: {
protocol: "class",
controller: props.controller,
function: "process",
name: "process",
},
arguments: props.arguments,
value: undefined,
success: true,
created_at: new Date().toISOString(),
// type: "assistantMessage",
// id: v7(),
// text: StringUtil.trim`
// # Function Calling History
// Function "${props.function}()" has been called.
// Here is the arguments.
// Note that, never call the same items again.
// As they are loaded onto the memory, you never have to
// request none of them again.
// \`\`\`json
// ${JSON.stringify(props.argument)}
// \`\`\`
// `,
// created_at: new Date().toISOString(),
});
const createAssistantMessage = (props) => ({
id: (0, uuid_1.v7)(),
type: "assistantMessage",
text: props.prompt.replaceAll("{{CONTENT}}", props.content),
created_at: new Date().toISOString(),
});
const createSystemMessage = (props) => ({
id: (0, uuid_1.v7)(),
type: "systemMessage",
text: props.prompt
.replaceAll("{{AVAILABLE}}", props.available)
.replaceAll("{{LOADED}}", props.loaded)
.replaceAll("{{EXHAUSTED}}", props.exhausted),
created_at: new Date().toISOString(),
});
const getSummary = (description) => {
const newLine = description.indexOf("\n");
const dot = description.indexOf(".");
const minimum = Math.min(newLine === -1 ? Number.MAX_SAFE_INTEGER : newLine, dot === -1 ? Number.MAX_SAFE_INTEGER : dot, description.length);
return description.substring(0, minimum);
};
const toJsonBlock = (obj) => utils_1.StringUtil.trim `
\`\`\`json
${JSON.stringify(obj)}
\`\`\`
`;
//# sourceMappingURL=transformPreliminaryHistory.js.map