@autobe/agent 0.21.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/lib/agent/src/AutoBeAgent.js +2 -2
  2. package/lib/agent/src/AutoBeAgent.js.map +1 -1
  3. package/lib/agent/src/constants/AutoBeConfigConstant.d.ts +3 -0
  4. package/lib/agent/src/{orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js → constants/AutoBeConfigConstant.js} +1 -1
  5. package/lib/agent/src/constants/AutoBeConfigConstant.js.map +1 -0
  6. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +27 -27
  7. package/lib/agent/src/context/AutoBeContext.d.ts +1 -0
  8. package/lib/agent/src/context/AutoBeTokenUsageComponent.js +4 -3
  9. package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
  10. package/lib/agent/src/factory/consentFunctionCall.js +4 -4
  11. package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
  12. package/lib/agent/src/factory/createAutoBeContext.js +13 -10
  13. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  14. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  15. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  16. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  17. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  18. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
  19. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  20. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +6 -6
  21. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +50 -8
  22. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  23. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +4 -4
  24. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  25. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  26. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  27. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  28. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +19 -1
  29. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  30. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  31. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  32. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  33. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  34. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +2 -2
  35. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  36. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  37. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  38. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  39. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  40. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  41. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  42. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  43. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  44. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  45. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  46. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  47. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +5 -1
  48. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
  49. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +16 -10
  50. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  51. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  52. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +3731 -228
  53. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  54. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +2 -2
  55. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +2 -2
  56. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +43 -63
  57. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  58. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +1261 -1628
  59. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  60. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +3468 -105
  61. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  62. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  63. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +3674 -360
  64. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  65. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  66. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
  67. package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  68. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  69. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js +1385 -0
  70. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -0
  71. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  72. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js +78 -0
  73. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js.map +1 -0
  74. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.d.ts +10 -0
  75. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js +59 -0
  76. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -0
  77. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  78. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js +81 -0
  79. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js.map +1 -0
  80. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
  81. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  82. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  83. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  84. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  85. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  86. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  87. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  88. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  89. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +2 -2
  90. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  91. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
  92. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  93. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
  94. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  95. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  96. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +22 -7
  97. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  98. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  99. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +13 -29
  100. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  101. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  102. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js +2 -8
  103. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  104. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +6 -49
  105. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
  106. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +4 -2
  107. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  108. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +5 -3
  109. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  110. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  111. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +206 -118
  112. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  113. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  114. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
  115. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  116. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +24 -39
  117. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  118. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  119. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  120. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  121. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  122. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js +3 -0
  123. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js.map +1 -0
  124. package/{src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts → lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts} +2 -13
  125. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js +3 -0
  126. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js.map +1 -0
  127. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
  128. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  129. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +86 -0
  130. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -0
  131. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  132. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js +55 -0
  133. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -0
  134. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  135. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js +20 -0
  136. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -0
  137. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  138. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js +73 -0
  139. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js.map +1 -0
  140. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  141. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +63 -69
  142. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  143. package/lib/agent/src/orchestrate/test/compile/completeTestCode.d.ts +3 -1
  144. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +25 -18
  145. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
  146. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +5 -1
  147. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  148. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  149. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js +19 -0
  150. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js.map +1 -0
  151. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  152. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js +2 -0
  153. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  154. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  155. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js +21 -0
  156. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js.map +1 -0
  157. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
  158. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +16 -17
  159. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  160. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +5 -4
  161. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  162. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +21 -2
  163. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  164. package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -0
  165. package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
  166. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  167. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +123 -75
  168. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  169. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +46 -40
  170. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  171. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +117 -45
  172. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  173. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  174. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  175. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js +3 -0
  176. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js.map +1 -0
  177. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  178. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  179. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  180. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js +28 -0
  181. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js.map +1 -0
  182. package/lib/agent/src/structures/IAutoBeConfig.d.ts +2 -0
  183. package/lib/constants/AutoBeConfigConstant.d.ts +3 -0
  184. package/lib/constants/AutoBeSystemPromptConstant.d.ts +27 -27
  185. package/lib/context/AutoBeContext.d.ts +1 -0
  186. package/lib/index.mjs +13871 -3912
  187. package/lib/index.mjs.map +1 -1
  188. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  189. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  190. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  191. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  192. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  193. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  194. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
  195. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  196. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  197. package/lib/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  198. package/lib/orchestrate/interface/utils/JsonSchemaValidator.d.ts +10 -0
  199. package/lib/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  200. package/lib/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  201. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  202. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  203. package/lib/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  204. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  205. package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  206. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  207. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  208. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  209. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  210. package/lib/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  211. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts +36 -0
  212. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
  213. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  214. package/lib/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  215. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  216. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  217. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  218. package/lib/orchestrate/test/compile/completeTestCode.d.ts +3 -1
  219. package/lib/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  220. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  221. package/lib/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  222. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
  223. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  224. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  225. package/lib/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  226. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  227. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  228. package/lib/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  229. package/lib/structures/IAutoBeConfig.d.ts +2 -0
  230. package/package.json +6 -6
  231. package/src/AutoBeAgent.ts +2 -0
  232. package/src/constants/AutoBeConfigConstant.ts +3 -0
  233. package/src/constants/AutoBeSystemPromptConstant.ts +27 -27
  234. package/src/context/AutoBeContext.ts +1 -0
  235. package/src/context/AutoBeTokenUsageComponent.ts +3 -3
  236. package/src/factory/consentFunctionCall.ts +2 -0
  237. package/src/factory/createAutoBeContext.ts +145 -136
  238. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +6 -0
  239. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.ts +4 -0
  240. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +19 -1
  241. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +1 -4
  242. package/src/orchestrate/interface/orchestrateInterface.ts +15 -4
  243. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +13 -5
  244. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +58 -19
  245. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +11 -11
  246. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +13 -117
  247. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +35 -93
  248. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +74 -97
  249. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +0 -39
  250. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +50 -146
  251. package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +31 -27
  252. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +171 -0
  253. package/src/orchestrate/interface/utils/JsonSchemaNamingConvention.ts +83 -0
  254. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +66 -0
  255. package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +90 -0
  256. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -2
  257. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +30 -15
  258. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +27 -49
  259. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +4 -11
  260. package/src/orchestrate/realize/orchestrateRealize.ts +19 -75
  261. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
  262. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +114 -25
  263. package/src/orchestrate/realize/orchestrateRealizeScenario.ts +2 -2
  264. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +11 -15
  265. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +17 -0
  266. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +20 -0
  267. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +40 -74
  268. package/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.ts +9 -0
  269. package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.ts +45 -0
  270. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +33 -22
  271. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +97 -0
  272. package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +64 -0
  273. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +29 -0
  274. package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +82 -0
  275. package/src/orchestrate/realize/utils/replaceImportStatements.ts +101 -111
  276. package/src/orchestrate/test/compile/completeTestCode.ts +18 -31
  277. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +12 -0
  278. package/src/orchestrate/test/compile/getTestImportStatements.ts +25 -0
  279. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +6 -1
  280. package/src/orchestrate/test/compile/getTestTemplateCode.ts +25 -0
  281. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +26 -26
  282. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +6 -5
  283. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +19 -0
  284. package/src/orchestrate/test/orchestrateTest.ts +6 -0
  285. package/src/orchestrate/test/orchestrateTestCorrect.ts +44 -20
  286. package/src/orchestrate/test/orchestrateTestScenario.ts +52 -48
  287. package/src/orchestrate/test/orchestrateTestWrite.ts +20 -10
  288. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +49 -46
  289. package/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.ts +8 -0
  290. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +1 -0
  291. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +14 -0
  292. package/src/orchestrate/test/utils/getReferenceIds.ts +25 -0
  293. package/src/structures/IAutoBeConfig.ts +3 -0
  294. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +0 -7
  295. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js +0 -35
  296. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +0 -1
  297. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  298. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js.map +0 -1
  299. package/lib/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +0 -7
  300. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  301. package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +0 -41
@@ -6,7 +6,7 @@ import {
6
6
  import { ILlmSchema } from "@samchon/openapi";
7
7
 
8
8
  import { AutoBeContext } from "../../context/AutoBeContext";
9
- import { IAutoBeRealizeScenarioApplication } from "./structures/IAutoBeRealizeScenarioApplication";
9
+ import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
10
10
 
11
11
  /**
12
12
  * Generates a planning result that defines what kind of function should be
@@ -32,7 +32,7 @@ export const orchestrateRealizeScenario = <Model extends ILlmSchema.Model>(
32
32
  ctx: AutoBeContext<Model>,
33
33
  operation: AutoBeOpenApi.IOperation,
34
34
  authorization?: AutoBeRealizeAuthorization,
35
- ): IAutoBeRealizeScenarioApplication.IProps => {
35
+ ): IAutoBeRealizeScenarioResult => {
36
36
  const testFiles: AutoBeTestFile[] =
37
37
  ctx
38
38
  .state()
@@ -11,11 +11,10 @@ import { v7 } from "uuid";
11
11
 
12
12
  import { AutoBeContext } from "../../context/AutoBeContext";
13
13
  import { assertSchemaModel } from "../../context/assertSchemaModel";
14
- import { getTestScenarioArtifacts } from "../test/compile/getTestScenarioArtifacts";
15
- import { IAutoBeTestScenarioArtifacts } from "../test/structures/IAutoBeTestScenarioArtifacts";
16
14
  import { transformRealizeWriteHistories } from "./histories/transformRealizeWriteHistories";
17
- import { IAutoBeRealizeScenarioApplication } from "./structures/IAutoBeRealizeScenarioApplication";
15
+ import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
18
16
  import { IAutoBeRealizeWriteApplication } from "./structures/IAutoBeRealizeWriteApplication";
17
+ import { getRealizeWriteDto } from "./utils/getRealizeWriteDto";
19
18
  import { replaceImportStatements } from "./utils/replaceImportStatements";
20
19
 
21
20
  export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
@@ -23,27 +22,24 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
23
22
  props: {
24
23
  totalAuthorizations: AutoBeRealizeAuthorization[];
25
24
  authorization: AutoBeRealizeAuthorization | null;
26
- scenario: IAutoBeRealizeScenarioApplication.IProps;
25
+ scenario: IAutoBeRealizeScenarioResult;
27
26
  progress: AutoBeProgressEventBase;
28
27
  promptCacheKey: string;
29
28
  },
30
29
  ): Promise<AutoBeRealizeWriteEvent> {
31
- const artifacts: IAutoBeTestScenarioArtifacts =
32
- await getTestScenarioArtifacts(ctx, {
33
- endpoint: props.scenario.operation,
34
- dependencies: [],
35
- });
36
30
  const pointer: IPointer<IAutoBeRealizeWriteApplication.IProps | null> = {
37
31
  value: null,
38
32
  };
33
+
34
+ const dto = await getRealizeWriteDto(ctx, props.scenario.operation);
39
35
  const { tokenUsage } = await ctx.conversate({
40
36
  source: "realizeWrite",
41
37
  histories: transformRealizeWriteHistories({
42
38
  state: ctx.state(),
43
39
  scenario: props.scenario,
44
- artifacts,
45
40
  authorization: props.authorization,
46
41
  totalAuthorizations: props.totalAuthorizations,
42
+ dto,
47
43
  }),
48
44
  controller: createController({
49
45
  model: ctx.model,
@@ -73,11 +69,11 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
73
69
  });
74
70
  if (pointer.value === null) throw new Error("Failed to write code.");
75
71
 
76
- pointer.value.implementationCode = await replaceImportStatements(ctx)(
77
- artifacts,
78
- pointer.value.implementationCode,
79
- props.authorization?.payload.name,
80
- );
72
+ pointer.value.implementationCode = await replaceImportStatements(ctx, {
73
+ operation: props.scenario.operation,
74
+ code: pointer.value.implementationCode,
75
+ decoratorType: props.authorization?.payload.name,
76
+ });
81
77
 
82
78
  const event: AutoBeRealizeWriteEvent = {
83
79
  type: "realizeWrite",
@@ -1,6 +1,23 @@
1
1
  import { CamelPattern, PascalPattern } from "@autobe/interface";
2
2
 
3
3
  export interface IAutoBeRealizeAuthorizationApplication {
4
+ /**
5
+ * Generates authentication provider, decorator, and payload type for role-based authorization.
6
+ *
7
+ * This method creates a complete authentication infrastructure for a specific
8
+ * role in the NestJS application. It generates three interconnected components
9
+ * that work together to provide JWT-based authentication and authorization.
10
+ *
11
+ * The generated components include:
12
+ * - **Provider Function**: Handles JWT verification and user validation from database
13
+ * - **Decorator**: NestJS parameter decorator for injecting authenticated user data
14
+ * - **Payload Type**: TypeScript interface defining the authenticated user structure
15
+ *
16
+ * All components follow strict naming conventions and integrate with the existing
17
+ * authentication architecture using the shared jwtAuthorize function.
18
+ *
19
+ * @param next Properties containing provider, decorator, and payload type configurations
20
+ */
4
21
  createDecorator: (
5
22
  next: IAutoBeRealizeAuthorizationApplication.IProps,
6
23
  ) => void;
@@ -1,6 +1,26 @@
1
1
  import { IAutoBeRealizeAuthorizationApplication } from "./IAutoBeRealizeAuthorizationApplication";
2
2
 
3
3
  export interface IAutoBeRealizeAuthorizationCorrectApplication {
4
+ /**
5
+ * Corrects TypeScript compilation errors in authentication components.
6
+ *
7
+ * This method analyzes and fixes compilation errors in previously generated
8
+ * authentication provider, decorator, and payload type implementations. It
9
+ * performs systematic error diagnosis and generates corrected versions of
10
+ * all three components while maintaining their interconnected functionality.
11
+ *
12
+ * The correction process includes:
13
+ * - TypeScript error analysis and categorization by component
14
+ * - Identification of type mismatches, import issues, and syntax errors
15
+ * - Clear solution guidance for each identified problem
16
+ * - Regeneration of all components with fixes applied
17
+ *
18
+ * The corrected components maintain the same naming conventions and
19
+ * architectural patterns as the original generation while resolving all
20
+ * compilation issues.
21
+ *
22
+ * @param next Properties containing error analysis, solution guidance, and corrected components
23
+ */
4
24
  correctDecorator: (
5
25
  next: IAutoBeRealizeAuthorizationCorrectApplication.IProps,
6
26
  ) => void;
@@ -1,81 +1,47 @@
1
- import { IAutoBeRealizeWriteApplication } from "./IAutoBeRealizeWriteApplication";
2
-
3
1
  export interface IAutoBeRealizeCorrectApplication {
2
+ /**
3
+ * Reviews and corrects TypeScript compilation errors.
4
+ *
5
+ * Fixes TypeScript compilation errors while preserving original business
6
+ * logic, applying minimal intervention principle.
7
+ *
8
+ * @param props Properties containing the multi-phase error correction process
9
+ */
4
10
  review: (props: IAutoBeRealizeCorrectApplication.IProps) => void;
5
11
  }
6
12
 
7
13
  export namespace IAutoBeRealizeCorrectApplication {
8
- export interface IProps extends IAutoBeRealizeWriteApplication.IProps {
9
- /**
10
- * Compilation Error Analysis and Resolution Strategy
11
- *
12
- * This field contains a detailed analysis of TypeScript compilation errors
13
- * that occurred during the previous compilation attempt, along with
14
- * specific strategies to resolve each error.
15
- *
16
- * The analysis MUST include:
17
- *
18
- * 📊 ERROR BREAKDOWN:
19
- *
20
- * - List of all TypeScript error codes encountered (e.g., TS2339, TS2345)
21
- * - Exact error messages and the lines/files where they occurred
22
- * - Categorization of errors by type (type mismatch, missing property, etc.)
23
- *
24
- * 🔍 ROOT CAUSE ANALYSIS:
25
- *
26
- * - Why each error occurred (e.g., incorrect type assumptions, missing
27
- * fields)
28
- * - Relationship between errors (e.g., cascading errors from a single issue)
29
- * - Common patterns identified across multiple errors
30
- *
31
- * 🛠 RESOLUTION STRATEGY:
32
- *
33
- * - Specific fixes for each error type
34
- * - Priority order for addressing errors (fix critical errors first)
35
- * - Alternative approaches if the direct fix is not possible
36
- *
37
- * 📝 SCHEMA VERIFICATION:
38
- *
39
- * - Re-verification of Prisma schema fields actually available
40
- * - Identification of assumed fields that don't exist
41
- * - Correct field types and relationships
42
- *
43
- * ⚠️ COMMON ERROR PATTERNS TO CHECK:
44
- *
45
- * - Using non-existent fields (e.g., deleted_at, created_by)
46
- * - Type mismatches in Prisma operations
47
- * - Incorrect date handling (using Date instead of string)
48
- * - Missing required fields in create/update operations
49
- * - Incorrect relation handling in nested operations
50
- *
51
- * 🎯 CORRECTION APPROACH:
52
- *
53
- * - Remove references to non-existent fields
54
- * - Fix type conversions (especially dates with toISOStringSafe())
55
- * - Simplify complex nested operations into separate queries
56
- * - Add missing required fields
57
- * - Use correct Prisma input types
58
- *
59
- * Example structure:
60
- *
61
- * Errors Found:
62
- * 1. TS2339: Property 'deleted_at' does not exist on type 'User'
63
- * - Cause: Field assumed but not in schema
64
- * - Fix: Remove all deleted_at references
65
- *
66
- * 2. TS2345: Type 'Date' is not assignable to type 'string'
67
- * - Cause: Direct Date assignment without conversion
68
- * - Fix: Use toISOStringSafe() for all date values
69
- *
70
- * Resolution Plan:
71
- * 1. First, remove all non-existent field references
72
- * 2. Then, fix all date type conversions
73
- * 3. Finally, adjust Prisma query structures
74
- *
75
- * This analysis ensures the review process addresses all compilation errors
76
- * systematically and produces error-free code in the corrected
77
- * implementation.
78
- */
79
- errorAnalysis: string;
14
+ /**
15
+ * Properties for error correction following Chain of Thinking (CoT).
16
+ *
17
+ * All phases are wrapped in a `revise` object for systematic error
18
+ * resolution.
19
+ */
20
+ export interface IProps {
21
+ /** Revision process containing all error correction phases. */
22
+ revise: IRevise;
23
+ }
24
+
25
+ export interface IRevise {
26
+ /** Step 1: Compilation error analysis and resolution strategy. */
27
+ errorAnalysis?: string;
28
+
29
+ /** Step 2: Provider function implementation plan. */
30
+ plan?: string;
31
+
32
+ /** Step 3: Relevant Prisma schema definitions. */
33
+ prismaSchemas?: string;
34
+
35
+ /** Step 4: Initial draft without using native Date type. */
36
+ draftWithoutDateType?: string;
37
+
38
+ /** Step 5: Refined version with improved completeness. */
39
+ review?: string;
40
+
41
+ /** Step 6: Corrected implementation after compiler feedback. */
42
+ withCompilerFeedback?: string;
43
+
44
+ /** Step 7: Final complete TypeScript function implementation. */
45
+ implementationCode: string;
80
46
  }
81
47
  }
@@ -0,0 +1,9 @@
1
+ import {
2
+ AutoBeRealizeFunction,
3
+ IAutoBeTypeScriptCompileResult,
4
+ } from "@autobe/interface";
5
+
6
+ export interface IAutoBeRealizeFunctionFailure {
7
+ function: AutoBeRealizeFunction;
8
+ diagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[];
9
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ AutoBeOpenApi,
3
+ AutoBeRealizeAuthorization,
4
+ AutoBeTestFile,
5
+ } from "@autobe/interface";
6
+
7
+ export interface IAutoBeRealizeScenarioResult {
8
+ /** The OpenAPI operation to be realized. */
9
+ operation: AutoBeOpenApi.IOperation;
10
+
11
+ /**
12
+ * The name of the function to be generated.
13
+ *
14
+ * Derived from the Swagger path and method. The function name must be
15
+ * written in snake_case. It serves as the entry point in both code
16
+ * generation and test code.
17
+ *
18
+ * Once the function is generated, the function name and file name will be
19
+ * the same. The generated file will be located at
20
+ * `src/providers/${function_name}.ts`.
21
+ */
22
+ functionName: string;
23
+
24
+ /** For example, `src/providers/${function_name}.ts`. */
25
+ location: string;
26
+
27
+ /**
28
+ * List of scenario descriptions for test code generation.
29
+ *
30
+ * Each scenario describes the expected behavior of the function under
31
+ * certain conditions. Used as a basis for TDD-style automated test
32
+ * generation.
33
+ */
34
+ testFiles: AutoBeTestFile[];
35
+
36
+ /**
37
+ * Optional decorator event for customizing code generation behavior.
38
+ *
39
+ * Provides additional metadata or instructions that can modify how the
40
+ * function implementation is generated. Can include custom annotations,
41
+ * middleware configurations, or special handling directives that affect the
42
+ * final code output.
43
+ */
44
+ decoratorEvent?: AutoBeRealizeAuthorization;
45
+ }
@@ -1,11 +1,35 @@
1
1
  export interface IAutoBeRealizeWriteApplication {
2
+ /**
3
+ * Generates provider function implementation through multi-phase development.
4
+ *
5
+ * This method implements a systematic approach to generate NestJS provider
6
+ * functions that handle business logic for API operations. It follows a
7
+ * schema-first approach with multiple refinement phases to ensure type-safe,
8
+ * error-free code generation.
9
+ *
10
+ * The generation process includes:
11
+ * 1. Strategic planning based on Prisma schema analysis
12
+ * 2. Initial draft without Date type usage
13
+ * 3. Review and refinement for completeness
14
+ * 4. Compiler feedback integration if errors detected
15
+ * 5. Final implementation with all validations and type safety
16
+ *
17
+ * @param next Properties containing the multi-phase implementation plan and code
18
+ */
2
19
  coding: (next: IAutoBeRealizeWriteApplication.IProps) => void;
3
20
  }
4
21
 
5
22
  export namespace IAutoBeRealizeWriteApplication {
23
+ /**
24
+ * Properties for the Realize Write Application following Chain of Thinking (CoT).
25
+ *
26
+ * Each field represents a distinct phase in the reasoning and implementation process,
27
+ * building upon the previous step to create a complete, error-free implementation.
28
+ * This structured approach ensures clarity, debuggability, and systematic thinking.
29
+ */
6
30
  export interface IProps {
7
31
  /**
8
- * Step 1.
32
+ * Step 1 - Planning Phase (CoT: Initial Reasoning)
9
33
  *
10
34
  * 🧠 Provider Function Implementation Plan
11
35
  *
@@ -22,12 +46,14 @@ export namespace IAutoBeRealizeWriteApplication {
22
46
  * - Examine the actual Prisma schema model definition
23
47
  * - List EVERY field that exists in the model with exact types
24
48
  * - Explicitly note fields that DO NOT exist
49
+ * - Verify database compatibility (PostgreSQL AND SQLite)
25
50
  *
26
51
  * DO NOT:
27
52
  *
28
53
  * - Assume common fields exist without verification
29
54
  * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
30
55
  * without checking
56
+ * - Use PostgreSQL-specific features like mode: "insensitive"
31
57
  *
32
58
  * 📋 STEP 2 - FIELD INVENTORY:
33
59
  *
@@ -136,7 +162,7 @@ export namespace IAutoBeRealizeWriteApplication {
136
162
  plan: string;
137
163
 
138
164
  /**
139
- * Step 2.
165
+ * Step 2 - Schema Definition (CoT: Context Establishment)
140
166
  *
141
167
  * The Prisma schema string that will be used to validate the implementation
142
168
  * logic in this file.
@@ -158,7 +184,7 @@ export namespace IAutoBeRealizeWriteApplication {
158
184
  prisma_schemas: string;
159
185
 
160
186
  /**
161
- * Step 3.
187
+ * Step 3 - Initial Draft (CoT: First Implementation Attempt)
162
188
  *
163
189
  * Draft WITHOUT using native Date type.
164
190
  *
@@ -195,7 +221,7 @@ export namespace IAutoBeRealizeWriteApplication {
195
221
  draft_without_date_type: string;
196
222
 
197
223
  /**
198
- * Step 4.
224
+ * Step 4 - Review and Refinement (CoT: Self-Reflection)
199
225
  *
200
226
  * A refined version of the draft with improved completeness.
201
227
  *
@@ -209,29 +235,13 @@ export namespace IAutoBeRealizeWriteApplication {
209
235
  * - Avoid unsafe `as` casts unless only for branding or literal narrowing.
210
236
  * - Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).
211
237
  * - Ensure all object keys strictly conform to the expected type definitions.
238
+ * - NEVER use `mode: "insensitive"` in string operations (breaks SQLite).
212
239
  */
213
240
  review: string;
214
241
 
215
- /**
216
- * 🛠 Phase 4-2: With compiler feedback (optional)
217
- *
218
- * A correction pass that applies fixes for compile-time errors that arose
219
- * during the review stage (if any).
220
- *
221
- * ✅ Must:
222
- *
223
- * - Only include this field if TypeScript errors are detected in the Review
224
- * phase.
225
- * - Resolve all TypeScript errors without using `as any`.
226
- * - Provide safe brand casting only if required (e.g., `as string &
227
- * tags.Format<'uuid'>`).
228
- * - If no TypeScript errors exist, this field MUST contain the text: "No
229
- * TypeScript errors detected - skipping this phase"
230
- */
231
- withCompilerFeedback: string;
232
242
 
233
243
  /**
234
- * Step 5.
244
+ * Step 5 - Complete Implementation (CoT: Final Synthesis)
235
245
  *
236
246
  * The complete and fully correct TypeScript function implementation.
237
247
  *
@@ -243,6 +253,7 @@ export namespace IAutoBeRealizeWriteApplication {
243
253
  * - Uses only allowed imports (e.g., from `../api/structures` and
244
254
  * `MyGlobal.prisma`).
245
255
  * - NEVER creates intermediate variables for Prisma operations.
256
+ * - NEVER uses `mode: "insensitive"` (PostgreSQL-only, breaks SQLite).
246
257
  *
247
258
  * ⚠️ Fallback Behavior:
248
259
  *
@@ -0,0 +1,97 @@
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
+ import { StringUtil } from "@autobe/utils";
3
+
4
+ import { IAutoBeRealizeScenarioResult } from "../structures/IAutoBeRealizeScenarioResult";
5
+ import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
6
+
7
+ /**
8
+ * Generate a TypeScript function template for the Realize Agent to complete
9
+ *
10
+ * This utility creates a function skeleton with proper imports, parameters, and
11
+ * return type that the AI needs to implement. The template includes:
12
+ *
13
+ * - Import statements for required dependencies
14
+ * - Function signature with all parameters
15
+ * - Return type specification
16
+ *
17
+ * @example
18
+ * // Returns a template like:
19
+ * ```typescript
20
+ * import { MyGlobal } from "../MyGlobal";
21
+ * // ... other imports
22
+ *
23
+ * async function post__users_create(
24
+ * body: IUserCreateRequest
25
+ * ): Promise<IUserResponse> {
26
+ * ...
27
+ * }
28
+ * ```;
29
+ *
30
+ * @param scenario - The realize scenario containing function metadata
31
+ * @param operation - OpenAPI operation definition
32
+ * @param authorization - Authorization context if endpoint is authenticated
33
+ * @returns Complete TypeScript code template as a formatted string
34
+ */
35
+ export function getRealizeWriteCodeTemplate(
36
+ scenario: IAutoBeRealizeScenarioResult,
37
+ operation: AutoBeOpenApi.IOperation,
38
+ authorization: AutoBeRealizeAuthorization | null,
39
+ ): string {
40
+ // Collect all function parameters in order
41
+ const functionParameters: string[] = [];
42
+
43
+ // Add authentication parameter if needed (e.g., user: IUser, admin: IAdmin)
44
+ if (authorization && authorization.role.name) {
45
+ // Debug: Log the values to check what's being used
46
+ const authParameter = `${authorization.role.name}: ${authorization.payload.name}`;
47
+ functionParameters.push(authParameter);
48
+ }
49
+
50
+ // Add path parameters (e.g., id, postId, etc.)
51
+ const pathParameters = operation.parameters.map((param) => {
52
+ const paramType = param.schema.type;
53
+ const paramFormat =
54
+ "format" in param.schema
55
+ ? ` & tags.Format<'${param.schema.format}'>`
56
+ : "";
57
+ return `${param.name}: ${paramType}${paramFormat}`;
58
+ });
59
+ functionParameters.push(...pathParameters);
60
+
61
+ // Add request body parameter if present
62
+ if (operation.requestBody?.typeName) {
63
+ const bodyParameter = `body: ${operation.requestBody.typeName}`;
64
+ functionParameters.push(bodyParameter);
65
+ }
66
+
67
+ // Format parameters for props object
68
+ const hasParameters = functionParameters.length > 0;
69
+
70
+ let formattedSignature: string;
71
+ if (hasParameters) {
72
+ const propsFields = functionParameters
73
+ .map((param) => ` ${param}`)
74
+ .join(";\n");
75
+
76
+ formattedSignature = `props: {\n${propsFields};\n}`;
77
+ } else {
78
+ formattedSignature = "";
79
+ }
80
+
81
+ // Determine return type
82
+ const returnType = operation.responseBody?.typeName ?? "void";
83
+
84
+ // Generate the complete template
85
+ return StringUtil.trim`
86
+ Complete the code below, disregard the import part and return only the function part.
87
+
88
+ \`\`\`typescript
89
+ ${getRealizeWriteImportStatements(operation).join("\n")}
90
+
91
+ // ONLY YOU HAVE TO WRITE THIS, AND USE IMPORTED.
92
+ export async function ${scenario.functionName}(${formattedSignature}): Promise<${returnType}> {
93
+ ...
94
+ }
95
+ \`\`\`
96
+ `;
97
+ }
@@ -0,0 +1,64 @@
1
+ import { AutoBeOpenApi, IAutoBeCompiler } from "@autobe/interface";
2
+ import { ILlmSchema, OpenApiTypeChecker } from "@samchon/openapi";
3
+
4
+ import { AutoBeContext } from "../../../context/AutoBeContext";
5
+
6
+ export async function getRealizeWriteDto<Model extends ILlmSchema.Model>(
7
+ ctx: AutoBeContext<Model>,
8
+ operation: AutoBeOpenApi.IOperation,
9
+ ): Promise<Record<string, string>> {
10
+ const document: AutoBeOpenApi.IDocument = filterDocument(
11
+ operation,
12
+ ctx.state().interface!.document,
13
+ );
14
+
15
+ const compiler: IAutoBeCompiler = await ctx.compiler();
16
+ const entries: [string, string][] = Object.entries(
17
+ await compiler.interface.write(document),
18
+ );
19
+
20
+ const filter = (prefix: string, exclude?: string) => {
21
+ const result: [string, string][] = entries.filter(
22
+ ([key]) => key.startsWith(prefix) === true,
23
+ );
24
+ return Object.fromEntries(
25
+ exclude
26
+ ? result.filter(([key]) => key.startsWith(exclude) === false)
27
+ : result,
28
+ );
29
+ };
30
+
31
+ const dto: Record<string, string> = filter("src/api/structures");
32
+ return dto;
33
+ }
34
+
35
+ function filterDocument(
36
+ operation: AutoBeOpenApi.IOperation,
37
+ document: AutoBeOpenApi.IDocument,
38
+ ): AutoBeOpenApi.IDocument {
39
+ const components: AutoBeOpenApi.IComponents = {
40
+ authorization: document.components.authorization,
41
+ schemas: {},
42
+ };
43
+
44
+ const visit = (typeName: string) => {
45
+ OpenApiTypeChecker.visit({
46
+ components: document.components,
47
+ schema: { $ref: `#/components/schemas/${typeName}` },
48
+ closure: (s) => {
49
+ if (OpenApiTypeChecker.isReference(s)) {
50
+ const key: string = s.$ref.split("/").pop()!;
51
+ components.schemas[key] = document.components.schemas[key];
52
+ }
53
+ },
54
+ });
55
+ };
56
+
57
+ if (operation.requestBody) visit(operation.requestBody.typeName);
58
+ if (operation.responseBody) visit(operation.responseBody.typeName);
59
+
60
+ return {
61
+ operations: [operation],
62
+ components,
63
+ };
64
+ }
@@ -0,0 +1,29 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+
3
+ export function getRealizeWriteImportStatements(
4
+ operation: AutoBeOpenApi.IOperation,
5
+ ) {
6
+ const typeReferences: string[] = Array.from(
7
+ new Set(
8
+ [operation.requestBody, operation.responseBody]
9
+ .filter((el) => el !== null)
10
+ .map((el) => el.typeName.split(".")[0]!),
11
+ ),
12
+ );
13
+
14
+ // Build the standard imports
15
+ const imports = [
16
+ 'import jwt from "jsonwebtoken";',
17
+ 'import { MyGlobal } from "../MyGlobal";',
18
+ 'import typia, { tags } from "typia";',
19
+ 'import { Prisma } from "@prisma/client";',
20
+ 'import { v4 } from "uuid";',
21
+ 'import { toISOStringSafe } from "../util/toISOStringSafe"',
22
+ ...typeReferences.map(
23
+ (ref) =>
24
+ `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
25
+ ),
26
+ ];
27
+
28
+ return imports;
29
+ }