@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
@@ -0,0 +1,90 @@
1
+ import { StringUtil } from "@autobe/utils";
2
+ import { IValidation } from "typia";
3
+
4
+ export const fulfillJsonSchemaErrorMessages = (
5
+ errors: IValidation.IError[],
6
+ ): void => {
7
+ for (const e of errors)
8
+ if (
9
+ // type := ["number", "string", ...] case
10
+ isInvalidJsonSchema(e) &&
11
+ typeof e.value === "object" &&
12
+ e.value !== null &&
13
+ "type" in e.value &&
14
+ Array.isArray(e.value.type)
15
+ )
16
+ e.description = StringUtil.trim`
17
+ You have defined the JSON schema's type property value as an
18
+ array type listing up the every types what you want, but it is not
19
+ allowed in the JSON schema.
20
+
21
+ The JSON schema's type property value must be a single string type.
22
+ In your case, you have to change it to an "oneOf" type which
23
+ represents an union type.
24
+
25
+ So, please change the value as below:
26
+
27
+ \`\`\`
28
+ {
29
+ oneOf: [
30
+ ${e.value.type.map((t) => ` { "type": ${JSON.stringify(t)}, ... },`).join("\n")}
31
+ ],${"description" in e.value ? `\n description: ${JSON.stringify(e.value.description)},` : ""}
32
+ }
33
+ \`\`\`
34
+ `;
35
+ else if (
36
+ isInvalidJsonSchema(e) &&
37
+ typeof e.value === "object" &&
38
+ e.value !== null &&
39
+ "enum" in e.value &&
40
+ Array.isArray(e.value.enum)
41
+ )
42
+ e.description = StringUtil.trim`
43
+ You have defined only enum property, but it is not allowed in the
44
+ JSON schema. You have to define it as oneOf type containing multiple
45
+ const types like below:
46
+
47
+ \`\`\`
48
+ {
49
+ oneOf: [
50
+ ${e.value.enum.map((t) => ` { "const": ${JSON.stringify(t)} },`).join("\n")}
51
+ ],${"description" in e.value ? `\n description: ${JSON.stringify(e.value.description)},` : ""}
52
+ }
53
+ \`\`\`
54
+ `;
55
+ else if (e.value === undefined && e.path.endsWith(".description"))
56
+ // no description
57
+ e.description = StringUtil.trim`
58
+ You have missed the "description" property in the JSON schema.
59
+
60
+ Please fill it with detailed description about the type.
61
+ `;
62
+ else if (
63
+ e.value === undefined &&
64
+ e.path.endsWith(".required") &&
65
+ e.expected === "Array<string>"
66
+ )
67
+ e.description = StringUtil.trim`
68
+ You have missed the "required" property in the JSON schema of object type.
69
+
70
+ When defining the object type, you have to fill the "required" property
71
+ which lists up the every required property names.
72
+
73
+ Please fill it with the required fields. If you think that there is
74
+ not any required fields at all, you still have to fill the
75
+ "required" property even though it becomes an empty array.
76
+ `;
77
+ };
78
+
79
+ const isInvalidJsonSchema = (e: IValidation.IError): boolean =>
80
+ e.expected.startsWith("(") &&
81
+ e.expected.endsWith(")") &&
82
+ e.expected.includes("|") &&
83
+ e.expected
84
+ .split("|")
85
+ .map((s) => s.trim())
86
+ .every(
87
+ (s) =>
88
+ s.startsWith("AutoBeOpenApi.IJsonSchema.") ||
89
+ s.startsWith("AutoBeOpenApi.IJsonSchemaDescriptive."),
90
+ );
@@ -18,7 +18,6 @@ import { IAutoBePrismaCorrectApplication } from "./structures/IAutoBePrismaCorre
18
18
  export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
19
19
  ctx: AutoBeContext<Model>,
20
20
  application: AutoBePrisma.IApplication,
21
- life: number = 4,
22
21
  ): Promise<IAutoBePrismaValidation> {
23
22
  const unique: Set<string> = new Set();
24
23
  for (const file of application.files)
@@ -28,7 +27,7 @@ export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
28
27
  return true;
29
28
  });
30
29
  application.files = application.files.filter((f) => f.models.length !== 0);
31
- return iterate(ctx, application, life);
30
+ return iterate(ctx, application, ctx.retry);
32
31
  }
33
32
 
34
33
  async function iterate<Model extends ILlmSchema.Model>(
@@ -1,25 +1,22 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
- import {
3
- AutoBeRealizeAuthorization,
4
- IAutoBeTypeScriptCompileResult,
5
- } from "@autobe/interface";
2
+ import { AutoBeRealizeAuthorization } from "@autobe/interface";
6
3
  import { StringUtil } from "@autobe/utils";
7
4
  import { v7 } from "uuid";
8
5
 
9
6
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
10
7
  import { AutoBeState } from "../../../context/AutoBeState";
11
- import { IAutoBeTestScenarioArtifacts } from "../../test/structures/IAutoBeTestScenarioArtifacts";
12
- import { IAutoBeRealizeScenarioApplication } from "../structures/IAutoBeRealizeScenarioApplication";
8
+ import { IAutoBeRealizeFunctionFailure } from "../structures/IAutoBeRealizeFunctionFailure";
9
+ import { IAutoBeRealizeScenarioResult } from "../structures/IAutoBeRealizeScenarioResult";
13
10
  import { transformRealizeWriteHistories } from "./transformRealizeWriteHistories";
14
11
 
15
12
  export function transformRealizeCorrectHistories(props: {
16
13
  state: AutoBeState;
17
- scenario: IAutoBeRealizeScenarioApplication.IProps;
18
- artifacts: IAutoBeTestScenarioArtifacts;
14
+ scenario: IAutoBeRealizeScenarioResult;
19
15
  authorization: AutoBeRealizeAuthorization | null;
20
16
  totalAuthorizations: AutoBeRealizeAuthorization[];
21
17
  code: string;
22
- diagnostic: IAutoBeTypeScriptCompileResult.IDiagnostic;
18
+ dto: Record<string, string>;
19
+ failures: IAutoBeRealizeFunctionFailure[];
23
20
  }): Array<
24
21
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
25
22
  > {
@@ -34,15 +31,33 @@ export function transformRealizeCorrectHistories(props: {
34
31
  \`\`\`typescript
35
32
  ${props.code}
36
33
  \`\`\`
37
-
38
- The code has a compilation error:
39
-
40
- \`\`\`json
41
- ${JSON.stringify(props.diagnostic)}
42
- \`\`\`
43
34
  `,
44
35
  created_at: new Date().toISOString(),
45
36
  },
37
+ ...props.failures.map(
38
+ (f) =>
39
+ ({
40
+ id: v7(),
41
+ type: "assistantMessage",
42
+ text: StringUtil.trim`
43
+
44
+ ## Generated Typescript Code
45
+
46
+ \`\`\`typescript
47
+ ${f.function.content}
48
+ \`\`\`
49
+
50
+ ## Compile Errors
51
+
52
+ Fix the comilation error in the provided code.
53
+
54
+ \`\`\`typescript
55
+ ${JSON.stringify(f.diagnostics)}
56
+ \`\`\`
57
+ `,
58
+ created_at: new Date().toISOString(),
59
+ }) satisfies IAgenticaHistoryJson.IAssistantMessage,
60
+ ),
46
61
  {
47
62
  id: v7(),
48
63
  type: "systemMessage",
@@ -5,13 +5,18 @@ import { v7 } from "uuid";
5
5
 
6
6
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
- import { IAutoBeTestScenarioArtifacts } from "../../test/structures/IAutoBeTestScenarioArtifacts";
9
- import { IAutoBeRealizeScenarioApplication } from "../structures/IAutoBeRealizeScenarioApplication";
8
+ import { IAutoBeRealizeScenarioResult } from "../structures/IAutoBeRealizeScenarioResult";
9
+ import { getRealizeWriteCodeTemplate } from "../utils/getRealizeWriteCodeTemplate";
10
+ import { getRealizeWriteInputType } from "../utils/getRealizeWriteInputType";
10
11
  import { transformRealizeWriteAuthorizationsHistories } from "./transformRealizeWriteAuthorizationsHistories";
11
12
 
12
- export const transformRealizeWriteHistories = (
13
- props: IProps,
14
- ): Array<
13
+ export const transformRealizeWriteHistories = (props: {
14
+ state: AutoBeState;
15
+ scenario: IAutoBeRealizeScenarioResult;
16
+ authorization: AutoBeRealizeAuthorization | null;
17
+ totalAuthorizations: AutoBeRealizeAuthorization[];
18
+ dto: Record<string, string>;
19
+ }): Array<
15
20
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
16
21
  > => {
17
22
  const payloads = Object.fromEntries(
@@ -21,38 +26,7 @@ export const transformRealizeWriteHistories = (
21
26
  ]),
22
27
  );
23
28
 
24
- const [operation] = props.artifacts.document.operations;
25
-
26
- const propsFields: string[] = [];
27
-
28
- // payload 추가
29
- if (props.authorization && operation.authorizationRole) {
30
- propsFields.push(
31
- `${operation.authorizationRole}: ${props.authorization.payload.name};`,
32
- );
33
- }
34
-
35
- // parameters 추가
36
- operation.parameters.forEach((parameter) => {
37
- const format =
38
- "format" in parameter.schema
39
- ? ` & tags.Format<'${parameter.schema.format}'>`
40
- : "";
41
- propsFields.push(`${parameter.name}: ${parameter.schema.type}${format};`);
42
- });
43
-
44
- // body 추가
45
- if (operation.requestBody?.typeName) {
46
- propsFields.push(`body: ${operation.requestBody.typeName};`);
47
- }
48
-
49
- const input =
50
- propsFields.length > 0
51
- ? StringUtil.trim`
52
- props: {
53
- ${propsFields.map((field) => ` ${field},`).join("\n")}
54
- }`
55
- : `// No props parameter needed - function should have no parameters`;
29
+ const operation = props.scenario.operation;
56
30
 
57
31
  if (props.state.analyze === null)
58
32
  return [
@@ -132,7 +106,7 @@ export const transformRealizeWriteHistories = (
132
106
  id: v7(),
133
107
  created_at: new Date().toISOString(),
134
108
  type: "systemMessage",
135
- text: AutoBeSystemPromptConstant.REALIZE_WRITE_TOTAL,
109
+ text: AutoBeSystemPromptConstant.REALIZE_WRITE,
136
110
  },
137
111
  ...authorizationHistories,
138
112
  {
@@ -143,14 +117,26 @@ export const transformRealizeWriteHistories = (
143
117
  `{prisma_schemas}`,
144
118
  JSON.stringify(props.state.prisma.schemas),
145
119
  )
146
- .replaceAll(`{artifacts_sdk}`, JSON.stringify(props.artifacts.sdk))
147
- .replaceAll(`{artifacts_dto}`, JSON.stringify(props.artifacts.dto))
148
- .replaceAll(`{input}`, input),
120
+ .replaceAll(
121
+ `{input}`,
122
+ getRealizeWriteInputType(operation, props.authorization),
123
+ )
124
+ .replaceAll(`{artifacts_dto}`, JSON.stringify(props.dto)),
149
125
  },
150
126
  {
151
127
  id: v7(),
128
+ type: "systemMessage",
152
129
  created_at: new Date().toISOString(),
130
+ text: getRealizeWriteCodeTemplate(
131
+ props.scenario,
132
+ operation,
133
+ props.authorization,
134
+ ),
135
+ },
136
+ {
137
+ id: v7(),
153
138
  type: "systemMessage",
139
+ created_at: new Date().toISOString(),
154
140
  text: StringUtil.trim`
155
141
  Write new code based on the following operation.
156
142
 
@@ -179,11 +165,3 @@ export const transformRealizeWriteHistories = (
179
165
  },
180
166
  ];
181
167
  };
182
-
183
- interface IProps {
184
- state: AutoBeState;
185
- scenario: IAutoBeRealizeScenarioApplication.IProps;
186
- artifacts: IAutoBeTestScenarioArtifacts;
187
- authorization: AutoBeRealizeAuthorization | null;
188
- totalAuthorizations: AutoBeRealizeAuthorization[];
189
- }
@@ -16,7 +16,7 @@ export async function compileRealizeFiles<Model extends ILlmSchema.Model>(
16
16
  authorizations: AutoBeRealizeAuthorization[];
17
17
  functions: AutoBeRealizeFunction[];
18
18
  },
19
- ): Promise<IAutoBeTypeScriptCompileResult> {
19
+ ): Promise<AutoBeRealizeValidateEvent> {
20
20
  const prisma = ctx.state().prisma?.compiled;
21
21
  const payloads: Record<string, string> = Object.fromEntries(
22
22
  props.authorizations.map((el) => [el.payload.location, el.payload.content]),
@@ -50,22 +50,15 @@ export async function compileRealizeFiles<Model extends ILlmSchema.Model>(
50
50
  await compiler.typescript.compile({
51
51
  files: files,
52
52
  });
53
- if (compiled.type === "success") {
54
- return compiled;
55
- }
56
53
 
57
54
  const event: AutoBeRealizeValidateEvent = {
58
55
  type: "realizeValidate",
59
56
  id: v7(),
57
+ files: files,
60
58
  result: compiled,
61
- files: Object.fromEntries(
62
- compiled.type === "failure"
63
- ? compiled.diagnostics.map((d) => [d.file, d.code])
64
- : [],
65
- ),
66
59
  step: ctx.state().analyze?.step ?? 0,
67
60
  created_at: new Date().toISOString(),
68
61
  };
69
- ctx.dispatch(event);
70
- return compiled;
62
+
63
+ return event;
71
64
  }
@@ -7,7 +7,6 @@ import {
7
7
  AutoBeRealizeHistory,
8
8
  AutoBeRealizeWriteEvent,
9
9
  IAutoBeCompiler,
10
- IAutoBeTypeScriptCompileResult,
11
10
  } from "@autobe/interface";
12
11
  import { ILlmSchema } from "@samchon/openapi";
13
12
  import { v7 } from "uuid";
@@ -16,12 +15,11 @@ import { AutoBeContext } from "../../context/AutoBeContext";
16
15
  import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
17
16
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
18
17
  import { predicateStateMessage } from "../../utils/predicateStateMessage";
19
- import { compileRealizeFiles } from "./internal/compileRealizeFiles";
20
18
  import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
21
19
  import { orchestrateRealizeCorrect } from "./orchestrateRealizeCorrect";
22
20
  import { orchestrateRealizeScenario } from "./orchestrateRealizeScenario";
23
21
  import { orchestrateRealizeWrite } from "./orchestrateRealizeWrite";
24
- import { IAutoBeRealizeScenarioApplication } from "./structures/IAutoBeRealizeScenarioApplication";
22
+ import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
25
23
 
26
24
  export const orchestrateRealize =
27
25
  <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
@@ -60,14 +58,15 @@ export const orchestrateRealize =
60
58
  await orchestrateRealizeAuthorization(ctx);
61
59
 
62
60
  // SCENARIOS
63
- const scenarios: IAutoBeRealizeScenarioApplication.IProps[] =
64
- operations.map((operation) => {
61
+ const scenarios: IAutoBeRealizeScenarioResult[] = operations.map(
62
+ (operation) => {
65
63
  const authorization = authorizations.find(
66
64
  (el) => el.role.name === operation.authorizationRole,
67
65
  );
68
66
 
69
67
  return orchestrateRealizeScenario(ctx, operation, authorization);
70
- });
68
+ },
69
+ );
71
70
 
72
71
  const writeProgress: AutoBeProgressEventBase = {
73
72
  total: scenarios.length,
@@ -103,76 +102,20 @@ export const orchestrateRealize =
103
102
  };
104
103
  });
105
104
 
106
- let compilation = await compileRealizeFiles(ctx, {
105
+ const reviewProgress = {
106
+ total: writeEvents.length,
107
+ completed: writeEvents.length,
108
+ };
109
+
110
+ const result = await orchestrateRealizeCorrect(
111
+ ctx,
112
+ scenarios,
107
113
  authorizations,
108
114
  functions,
109
- });
110
-
111
- if (compilation.type !== "success") {
112
- const MAX_CORRECTION_ATTEMPTS = 5 as const;
113
-
114
- const reviewProgress = {
115
- id: v7(),
116
- total: writeEvents.length,
117
- completed: writeEvents.length,
118
- };
119
-
120
- for (let attempt = 0; attempt < MAX_CORRECTION_ATTEMPTS; attempt++) {
121
- if (compilation.type === "failure") {
122
- const failedFiles: Record<string, string> = Object.fromEntries(
123
- compilation.type === "failure"
124
- ? compilation.diagnostics.map((d) => [d.file, d.code])
125
- : [],
126
- );
127
-
128
- reviewProgress.total += Object.keys(failedFiles).length;
129
- const failure: IAutoBeTypeScriptCompileResult.IFailure = compilation;
130
-
131
- await executeCachedBatch(
132
- Object.entries(failedFiles).map(
133
- ([location, content]) =>
134
- async () => {
135
- const diagnostic:
136
- | IAutoBeTypeScriptCompileResult.IDiagnostic
137
- | undefined = failure.diagnostics.find(
138
- (el) => el.file === location,
139
- );
140
-
141
- const scenario = scenarios.find(
142
- (el) => el.location === location,
143
- );
144
- if (diagnostic && scenario) {
145
- const correctEvent = await orchestrateRealizeCorrect(ctx, {
146
- totalAuthorizations: authorizations,
147
- authorization: scenario.decoratorEvent ?? null,
148
- scenario,
149
- code: content,
150
- diagnostic,
151
- progress: reviewProgress,
152
- });
153
-
154
- const corrected = functions.find(
155
- (el) => el.location === correctEvent.location,
156
- );
157
-
158
- if (corrected) {
159
- corrected.content = correctEvent.content;
160
- }
161
- }
162
- },
163
- ),
164
- );
165
-
166
- compilation = await compileRealizeFiles(ctx, {
167
- authorizations,
168
- functions,
169
- });
170
- if (compilation.type === "success") {
171
- break;
172
- }
173
- }
174
- }
175
- }
115
+ [],
116
+ reviewProgress,
117
+ 5,
118
+ );
176
119
 
177
120
  const compiler: IAutoBeCompiler = await ctx.compiler();
178
121
  const controllers: Record<string, string> =
@@ -181,6 +124,7 @@ export const orchestrateRealize =
181
124
  functions,
182
125
  authorizations,
183
126
  });
127
+
184
128
  return ctx.dispatch({
185
129
  type: "realizeComplete",
186
130
  id: v7(),
@@ -188,7 +132,7 @@ export const orchestrateRealize =
188
132
  functions,
189
133
  authorizations,
190
134
  controllers,
191
- compiled: await compileRealizeFiles(ctx, { authorizations, functions }),
135
+ compiled: result.result,
192
136
  step: ctx.state().analyze?.step ?? 0,
193
137
  elapsed: new Date().getTime() - start.getTime(),
194
138
  });
@@ -24,7 +24,7 @@ export async function orchestrateRealizeAuthorizationCorrect<
24
24
  authorization: AutoBeRealizeAuthorization,
25
25
  prismaClients: Record<string, string>,
26
26
  templateFiles: Record<string, string>,
27
- life: number = 4,
27
+ life: number = ctx.retry,
28
28
  ): Promise<AutoBeRealizeAuthorization> {
29
29
  const compiler: IAutoBeCompiler = await ctx.compiler();
30
30
  const providerContent: string = await compiler.typescript.beautify(
@@ -2,7 +2,8 @@ import {
2
2
  AutoBeProgressEventBase,
3
3
  AutoBeRealizeAuthorization,
4
4
  AutoBeRealizeCorrectEvent,
5
- IAutoBeTypeScriptCompileResult,
5
+ AutoBeRealizeFunction,
6
+ AutoBeRealizeValidateEvent,
6
7
  } from "@autobe/interface";
7
8
  import { StringUtil } from "@autobe/utils";
8
9
  import { ILlmApplication, ILlmController, ILlmSchema } from "@samchon/openapi";
@@ -12,33 +13,116 @@ import { v7 } from "uuid";
12
13
 
13
14
  import { AutoBeContext } from "../../context/AutoBeContext";
14
15
  import { assertSchemaModel } from "../../context/assertSchemaModel";
15
- import { getTestScenarioArtifacts } from "../test/compile/getTestScenarioArtifacts";
16
- import { IAutoBeTestScenarioArtifacts } from "../test/structures/IAutoBeTestScenarioArtifacts";
16
+ import { executeCachedBatch } from "../../utils/executeCachedBatch";
17
17
  import { transformRealizeCorrectHistories } from "./histories/transformRealizeCorrectHistories";
18
+ import { compileRealizeFiles } from "./internal/compileRealizeFiles";
18
19
  import { IAutoBeRealizeCorrectApplication } from "./structures/IAutoBeRealizeCorrectApplication";
19
- import { IAutoBeRealizeScenarioApplication } from "./structures/IAutoBeRealizeScenarioApplication";
20
+ import { IAutoBeRealizeFunctionFailure } from "./structures/IAutoBeRealizeFunctionFailure";
21
+ import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
22
+ import { getRealizeWriteDto } from "./utils/getRealizeWriteDto";
20
23
  import { replaceImportStatements } from "./utils/replaceImportStatements";
21
24
 
22
25
  export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
26
+ ctx: AutoBeContext<Model>,
27
+ scenarios: IAutoBeRealizeScenarioResult[],
28
+ authorizations: AutoBeRealizeAuthorization[],
29
+ functions: AutoBeRealizeFunction[],
30
+ failures: IAutoBeRealizeFunctionFailure[],
31
+ progress: IProgress,
32
+ life: number = 5,
33
+ ): Promise<AutoBeRealizeValidateEvent> {
34
+ const event = await compileRealizeFiles(ctx, { authorizations, functions });
35
+ if (event.result.type === "failure") ctx.dispatch(event);
36
+
37
+ if (event.result.type === "success") {
38
+ console.debug("compilation success!");
39
+ return event;
40
+ } else if (--life <= 0) return event;
41
+
42
+ const locations: string[] =
43
+ (event.result.type === "failure"
44
+ ? Array.from(new Set(event.result.diagnostics.map((d) => d.file)))
45
+ : null
46
+ )?.filter((el) => el !== null) ?? [];
47
+
48
+ progress.total += Object.keys(locations).length;
49
+
50
+ const diagnostics =
51
+ event.result.type === "failure" ? event.result.diagnostics : [];
52
+
53
+ const diagnosticsByFile = diagnostics.reduce<
54
+ Record<string, typeof diagnostics>
55
+ >((acc, diagnostic) => {
56
+ const location = diagnostic.file!;
57
+ if (!acc[location]) {
58
+ acc[location] = [];
59
+ }
60
+ acc[location].push(diagnostic);
61
+ return acc;
62
+ }, {});
63
+
64
+ for (const [location, diagnostics] of Object.entries(diagnosticsByFile)) {
65
+ const func = functions.find((el) => el.location === location);
66
+
67
+ if (func) {
68
+ failures.push({
69
+ function: func,
70
+ diagnostics,
71
+ });
72
+ }
73
+ }
74
+
75
+ await executeCachedBatch(
76
+ locations.map((location) => async (): Promise<AutoBeRealizeFunction> => {
77
+ const scenario = scenarios.find((el) => el.location === location);
78
+ const func = functions.find((el) => el.location === location)!;
79
+ const ReailzeFunctionFailures: IAutoBeRealizeFunctionFailure[] =
80
+ failures.filter((f) => f.function.location === location);
81
+
82
+ if (ReailzeFunctionFailures.length && scenario) {
83
+ const correctEvent = await correct(ctx, {
84
+ totalAuthorizations: authorizations,
85
+ authorization: scenario.decoratorEvent ?? null,
86
+ scenario,
87
+ function: func,
88
+ failures: ReailzeFunctionFailures,
89
+ progress: progress,
90
+ });
91
+
92
+ func.content = correctEvent.content;
93
+ }
94
+
95
+ return func;
96
+ }),
97
+ );
98
+
99
+ return orchestrateRealizeCorrect(
100
+ ctx,
101
+ scenarios,
102
+ authorizations,
103
+ functions,
104
+ failures,
105
+ progress,
106
+ life,
107
+ );
108
+ }
109
+
110
+ export async function correct<Model extends ILlmSchema.Model>(
23
111
  ctx: AutoBeContext<Model>,
24
112
  props: {
25
113
  authorization: AutoBeRealizeAuthorization | null;
26
114
  totalAuthorizations: AutoBeRealizeAuthorization[];
27
- scenario: IAutoBeRealizeScenarioApplication.IProps;
28
- code: string;
29
- diagnostic: IAutoBeTypeScriptCompileResult.IDiagnostic;
115
+ scenario: IAutoBeRealizeScenarioResult;
116
+ function: AutoBeRealizeFunction;
117
+ failures: IAutoBeRealizeFunctionFailure[];
30
118
  progress: AutoBeProgressEventBase;
31
119
  },
32
120
  ): Promise<AutoBeRealizeCorrectEvent> {
33
- const artifacts: IAutoBeTestScenarioArtifacts =
34
- await getTestScenarioArtifacts(ctx, {
35
- endpoint: props.scenario.operation,
36
- dependencies: [],
37
- });
38
-
39
121
  const pointer: IPointer<IAutoBeRealizeCorrectApplication.IProps | null> = {
40
122
  value: null,
41
123
  };
124
+
125
+ const dto = await getRealizeWriteDto(ctx, props.scenario.operation);
42
126
  const { tokenUsage } = await ctx.conversate({
43
127
  source: "realizeCorrect",
44
128
  controller: createController({
@@ -50,34 +134,34 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
50
134
  histories: transformRealizeCorrectHistories({
51
135
  state: ctx.state(),
52
136
  scenario: props.scenario,
53
- artifacts,
54
137
  authorization: props.authorization,
55
- code: props.code,
56
- diagnostic: props.diagnostic,
138
+ code: props.function.content,
139
+ dto,
140
+ failures: props.failures.filter(
141
+ (f) => f.function.location === props.function.location,
142
+ ),
57
143
  totalAuthorizations: props.totalAuthorizations,
58
144
  }),
59
145
  enforceFunctionCall: true,
60
146
  message: StringUtil.trim`
61
- Correct the TypeScript code implementation to strictly follow these rules:
62
-
63
- 1. Ensure that the code is production-ready and follows best practices.
147
+ Correct the TypeScript code implementation.
64
148
  `,
65
149
  });
66
150
 
67
151
  if (pointer.value === null)
68
152
  throw new Error("Failed to correct implementation code.");
69
153
 
70
- pointer.value.implementationCode = await replaceImportStatements(ctx)(
71
- artifacts,
72
- pointer.value.implementationCode,
73
- props.authorization?.payload.name,
74
- );
154
+ pointer.value.revise.implementationCode = await replaceImportStatements(ctx, {
155
+ operation: props.scenario.operation,
156
+ code: pointer.value.revise.implementationCode,
157
+ decoratorType: props.authorization?.payload.name,
158
+ });
75
159
 
76
160
  const event: AutoBeRealizeCorrectEvent = {
77
161
  type: "realizeCorrect",
78
162
  id: v7(),
79
163
  location: props.scenario.location,
80
- content: pointer.value.implementationCode,
164
+ content: pointer.value.revise.implementationCode,
81
165
  tokenUsage,
82
166
  completed: ++props.progress.completed,
83
167
  total: props.progress.total,
@@ -120,3 +204,8 @@ const collection = {
120
204
  deepseek: claude,
121
205
  "3.1": claude,
122
206
  };
207
+
208
+ interface IProgress {
209
+ total: number;
210
+ completed: number;
211
+ }