@autobe/agent 0.24.2 → 0.25.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 (297) hide show
  1. package/lib/AutoBeAgent.js +11 -1
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/AutoBeMockAgent.js +1 -0
  4. package/lib/AutoBeMockAgent.js.map +1 -1
  5. package/lib/constants/AutoBeSystemPromptConstant.d.ts +21 -21
  6. package/lib/context/IAutoBeApplication.d.ts +101 -6
  7. package/lib/context/IAutoBeApplicationProps.d.ts +6 -2
  8. package/lib/factory/createAgenticaHistory.js +1 -1
  9. package/lib/factory/createAgenticaHistory.js.map +1 -1
  10. package/lib/factory/createAutoBeApplication.js +80 -90
  11. package/lib/factory/createAutoBeApplication.js.map +1 -1
  12. package/lib/factory/createAutoBeContext.js +6 -5
  13. package/lib/factory/createAutoBeContext.js.map +1 -1
  14. package/lib/index.mjs +3914 -2594
  15. package/lib/index.mjs.map +1 -1
  16. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +5 -1
  17. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  18. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
  19. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +18 -3
  20. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  21. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +5 -1
  22. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +19 -7
  23. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  24. package/lib/orchestrate/analyze/orchestrateAnalyze.js +3 -2
  25. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  26. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
  27. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
  28. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  29. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +1 -0
  30. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -2
  31. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  32. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  33. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  34. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
  35. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  36. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
  37. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  38. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  39. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +2 -1
  40. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  41. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +5 -1
  42. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +20 -7
  43. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  44. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
  45. package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
  46. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
  47. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +6 -1
  48. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -23
  49. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  50. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +6 -1
  51. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +22 -6
  52. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  53. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
  54. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  55. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +4 -1
  56. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +27 -6
  57. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  58. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +5 -1
  59. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +21 -5
  60. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  61. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
  62. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  63. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
  64. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
  65. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
  66. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +5 -1
  67. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +20 -4
  68. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  69. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  70. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  71. package/lib/orchestrate/interface/orchestrateInterface.js +45 -11
  72. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  73. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
  74. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +277 -37
  75. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  76. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
  77. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +69 -70
  78. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  79. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
  80. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +28 -13
  81. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  82. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
  83. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +11 -8
  84. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  85. package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
  86. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +36 -21
  87. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  88. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +260 -29
  89. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  90. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
  91. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
  92. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
  93. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
  94. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +83 -53
  95. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  96. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +41 -7
  97. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  98. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
  99. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
  100. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
  101. package/lib/orchestrate/{common/structures/IAutoBeCommonCorrectDateApplication.js → interface/structures/IAutoBeInterfacePrerequisitesApplication.js} +1 -1
  102. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
  103. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
  104. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
  105. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +105 -5
  106. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  107. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +20 -1
  108. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  109. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
  110. package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
  111. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  112. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.d.ts +4 -1
  113. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +19 -8
  114. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  115. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
  116. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  117. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.d.ts +6 -1
  118. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +20 -6
  119. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  120. package/lib/orchestrate/prisma/orchestratePrisma.js +3 -3
  121. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  122. package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -1
  123. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -3
  124. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  125. package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +1 -1
  126. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +12 -6
  127. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  128. package/lib/orchestrate/{common/histories/transformCommonCorrectDateHistories.d.ts → realize/histories/transformRealizeCorrectCastingHistories.d.ts} +1 -2
  129. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +32 -0
  130. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
  131. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
  132. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  133. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
  134. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
  135. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  136. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
  137. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  138. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
  139. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +119 -42
  140. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  141. package/lib/orchestrate/realize/orchestrateRealize.js +82 -52
  142. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  143. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +128 -88
  144. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  145. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
  146. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
  147. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  148. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
  149. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
  150. package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
  151. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
  152. package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -5
  153. package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
  154. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
  155. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
  156. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  157. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
  158. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
  159. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  160. package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
  161. package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
  162. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
  163. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
  164. package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -53
  165. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  166. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +5 -1
  167. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +11 -7
  168. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  169. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  170. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  171. package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +7 -1
  172. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +35 -96
  173. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  174. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +6 -3
  175. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +33 -77
  176. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  177. package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +5 -1
  178. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +111 -94
  179. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  180. package/lib/orchestrate/test/orchestrateTest.js +20 -14
  181. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  182. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -1
  183. package/lib/orchestrate/test/orchestrateTestCorrect.js +81 -50
  184. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  185. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
  186. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  187. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  188. package/lib/orchestrate/test/orchestrateTestScenario.js +18 -7
  189. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  190. package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -1
  191. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +20 -12
  192. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  193. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
  194. package/lib/orchestrate/test/orchestrateTestWrite.js +46 -25
  195. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  196. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
  197. package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
  198. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
  199. package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
  200. package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
  201. package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
  202. package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
  203. package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
  204. package/package.json +5 -5
  205. package/src/AutoBeAgent.ts +17 -1
  206. package/src/AutoBeMockAgent.ts +1 -0
  207. package/src/constants/AutoBeSystemPromptConstant.ts +21 -21
  208. package/src/context/IAutoBeApplication.ts +101 -6
  209. package/src/context/IAutoBeApplicationProps.ts +6 -2
  210. package/src/factory/createAgenticaHistory.ts +11 -5
  211. package/src/factory/createAutoBeContext.ts +6 -5
  212. package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +5 -1
  213. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +16 -0
  214. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +22 -7
  215. package/src/orchestrate/analyze/orchestrateAnalyze.ts +3 -2
  216. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
  217. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
  218. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
  219. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
  220. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +2 -1
  221. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
  222. package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
  223. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +33 -24
  224. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +26 -9
  225. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +30 -6
  226. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
  227. package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
  228. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
  229. package/src/orchestrate/interface/orchestrateInterface.ts +65 -20
  230. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
  231. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +34 -47
  232. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +40 -28
  233. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
  234. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +51 -35
  235. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
  236. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +52 -33
  237. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
  238. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
  239. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
  240. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
  241. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
  242. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
  243. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +19 -1
  244. package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
  245. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +20 -6
  246. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +24 -9
  247. package/src/orchestrate/prisma/orchestratePrisma.ts +7 -3
  248. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +5 -1
  249. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -10
  250. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +44 -0
  251. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
  252. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
  253. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
  254. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
  255. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +102 -16
  256. package/src/orchestrate/realize/orchestrateRealize.ts +121 -81
  257. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +50 -7
  258. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
  259. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
  260. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
  261. package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
  262. package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
  263. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
  264. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
  265. package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
  266. package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -97
  267. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
  268. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +50 -115
  269. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +41 -111
  270. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
  271. package/src/orchestrate/test/orchestrateTest.ts +19 -13
  272. package/src/orchestrate/test/orchestrateTestCorrect.ts +71 -51
  273. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
  274. package/src/orchestrate/test/orchestrateTestScenario.ts +27 -17
  275. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +32 -19
  276. package/src/orchestrate/test/orchestrateTestWrite.ts +20 -10
  277. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
  278. package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
  279. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
  280. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
  281. package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
  282. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +0 -48
  283. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +0 -1
  284. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +0 -35
  285. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +0 -1
  286. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
  287. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
  288. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
  289. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
  290. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
  291. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +0 -4
  292. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +0 -540
  293. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +0 -1
  294. package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +0 -60
  295. package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +0 -40
  296. package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
  297. package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +0 -372
@@ -14,9 +14,12 @@ import { v7 } from "uuid";
14
14
  import { AutoBeContext } from "../../context/AutoBeContext";
15
15
  import { assertSchemaModel } from "../../context/assertSchemaModel";
16
16
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
17
- import { transformCommonCorrectCastingHistories } from "../common/histories/transformCommonCorrectCastingHistories";
18
17
  import { IAutoBeCommonCorrectCastingApplication } from "../common/structures/IAutoBeCommonCorrectCastingApplication";
18
+ import { transformRealizeCorrectCastingHistories } from "./histories/transformRealizeCorrectCastingHistories";
19
19
  import { compileRealizeFiles } from "./internal/compileRealizeFiles";
20
+ import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
21
+ import { getRealizeWriteCodeTemplate } from "./utils/getRealizeWriteCodeTemplate";
22
+ import { replaceImportStatements } from "./utils/replaceImportStatements";
20
23
 
21
24
  /** Result of attempting to correct a single function */
22
25
  type CorrectionResult = {
@@ -28,6 +31,7 @@ export const orchestrateRealizeCorrectCasting = async <
28
31
  Model extends ILlmSchema.Model,
29
32
  >(
30
33
  ctx: AutoBeContext<Model>,
34
+ scenarios: IAutoBeRealizeScenarioResult[],
31
35
  authorizations: AutoBeRealizeAuthorization[],
32
36
  functions: AutoBeRealizeFunction[],
33
37
  progress: AutoBeProgressEventBase,
@@ -40,9 +44,9 @@ export const orchestrateRealizeCorrectCasting = async <
40
44
  functions,
41
45
  },
42
46
  );
43
-
44
47
  return predicate(
45
48
  ctx,
49
+ scenarios,
46
50
  authorizations,
47
51
  functions,
48
52
  [],
@@ -54,6 +58,7 @@ export const orchestrateRealizeCorrectCasting = async <
54
58
 
55
59
  const predicate = async <Model extends ILlmSchema.Model>(
56
60
  ctx: AutoBeContext<Model>,
61
+ scenarios: IAutoBeRealizeScenarioResult[],
57
62
  authorizations: AutoBeRealizeAuthorization[],
58
63
  functions: AutoBeRealizeFunction[],
59
64
  failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
@@ -63,9 +68,9 @@ const predicate = async <Model extends ILlmSchema.Model>(
63
68
  ): Promise<AutoBeRealizeFunction[]> => {
64
69
  if (event.result.type === "failure") {
65
70
  ctx.dispatch(event);
66
-
67
71
  return await correct(
68
72
  ctx,
73
+ scenarios,
69
74
  authorizations,
70
75
  functions,
71
76
  [...failures, ...event.result.diagnostics],
@@ -79,6 +84,7 @@ const predicate = async <Model extends ILlmSchema.Model>(
79
84
 
80
85
  const correct = async <Model extends ILlmSchema.Model>(
81
86
  ctx: AutoBeContext<Model>,
87
+ scenarios: IAutoBeRealizeScenarioResult[],
82
88
  authorizations: AutoBeRealizeAuthorization[],
83
89
  functions: AutoBeRealizeFunction[],
84
90
  failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
@@ -94,6 +100,12 @@ const correct = async <Model extends ILlmSchema.Model>(
94
100
  const locations: string[] = diagnose(event).filter((l) =>
95
101
  functions.map((f) => f.location).includes(l),
96
102
  );
103
+
104
+ // If no locations to correct, return original functions
105
+ if (locations.length === 0) {
106
+ return functions;
107
+ }
108
+
97
109
  progress.total += locations.length;
98
110
 
99
111
  const converted: CorrectionResult[] = await executeCachedBatch(
@@ -102,6 +114,13 @@ const correct = async <Model extends ILlmSchema.Model>(
102
114
  (f) => f.location === location,
103
115
  )!;
104
116
 
117
+ const scenario = scenarios.find((s) => s.location === func.location)!;
118
+
119
+ const operation = scenario.operation;
120
+ const authorization = authorizations.find(
121
+ (a) => a.role.name === operation.authorizationRole,
122
+ );
123
+
105
124
  const pointer: IPointer<
106
125
  IAutoBeCommonCorrectCastingApplication.IProps | false | null
107
126
  > = {
@@ -110,7 +129,7 @@ const correct = async <Model extends ILlmSchema.Model>(
110
129
 
111
130
  const { tokenUsage } = await ctx.conversate({
112
131
  source: "realizeCorrect",
113
- histories: transformCommonCorrectCastingHistories([
132
+ histories: transformRealizeCorrectCastingHistories([
114
133
  {
115
134
  script: func.content,
116
135
  diagnostics: failures.filter((d) => d.file === location),
@@ -137,18 +156,62 @@ const correct = async <Model extends ILlmSchema.Model>(
137
156
 
138
157
  You don't need to explain me anything, but just fix or give it up
139
158
  immediately without any hesitation, explanation, and questions.
159
+
160
+ The instruction to write at first was as follows, and the code you received is the code you wrote according to this instruction.
161
+ When modifying, modify the entire code, but not the import statement.
162
+
163
+ Below is template code you wrote:
164
+
165
+ ${getRealizeWriteCodeTemplate({
166
+ scenario,
167
+ schemas: ctx.state().interface!.document.components.schemas,
168
+ operation: scenario.operation,
169
+ authorization: authorization ?? null,
170
+ })}
171
+
172
+ Current code is as follows:
173
+
174
+ \`\`\`typescript
175
+ ${func.content}
176
+ \`\`\`
177
+
178
+ Also, never use typia.assert and typia.assertGuard like functions
179
+ to the Prisma types. Your mission is to fix the casting problem of
180
+ primitive types like string or number. Prisma type is not your scope.
181
+
182
+ If you take a mistake that casting the Prisma type with the typia.assert
183
+ function, it would be fallen into the infinite compilation due to extremely
184
+ complicated Prisma type. Note that, the typia.assert function is allowed
185
+ only in the individual property level string or literal type.
186
+
187
+ I repeat that, never assert the Prisma type. It's not your mission.
140
188
  `,
141
189
  });
142
190
  ++progress.completed;
191
+
143
192
  if (pointer.value === null)
144
193
  return { result: "exception" as const, func: func };
145
194
  else if (pointer.value === false)
146
195
  return { result: "ignore" as const, func: func };
147
196
 
197
+ pointer.value.draft = await replaceImportStatements(ctx, {
198
+ schemas: ctx.state().interface!.document.components.schemas,
199
+ operation: operation,
200
+ code: pointer.value.draft,
201
+ decoratorType: authorization?.payload.name,
202
+ });
203
+ if (pointer.value.revise.final)
204
+ pointer.value.revise.final = await replaceImportStatements(ctx, {
205
+ schemas: ctx.state().interface!.document.components.schemas,
206
+ operation: operation,
207
+ code: pointer.value.revise.final,
208
+ decoratorType: authorization?.payload.name,
209
+ });
210
+
148
211
  ctx.dispatch({
149
212
  id: v7(),
150
213
  type: "realizeCorrect",
151
- content: pointer.value.revise.final,
214
+ content: pointer.value.revise.final ?? pointer.value.draft,
152
215
  created_at: new Date().toISOString(),
153
216
  location: func.location,
154
217
  step: ctx.state().analyze?.step ?? 0,
@@ -156,24 +219,48 @@ const correct = async <Model extends ILlmSchema.Model>(
156
219
  completed: progress.completed,
157
220
  total: progress.total,
158
221
  });
159
-
160
222
  return {
161
223
  result: "success" as const,
162
- func: { ...func, content: pointer.value.revise.final },
224
+ func: {
225
+ ...func,
226
+ content: pointer.value.revise.final ?? pointer.value.draft,
227
+ },
163
228
  };
164
229
  }),
165
230
  );
166
231
 
232
+ // Get functions that were not modified (not in locations array)
233
+ const unchangedFunctions: AutoBeRealizeFunction[] = functions.filter(
234
+ (f) => !locations.includes(f.location),
235
+ );
236
+
237
+ // Merge converted functions with unchanged functions for validation
238
+ const allFunctionsForValidation = [
239
+ ...converted.map((c) => c.func),
240
+ ...unchangedFunctions,
241
+ ];
242
+
167
243
  const newValidate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
168
244
  ctx,
169
245
  {
170
246
  authorizations,
171
- functions: converted.map((c) => c.func),
247
+ functions: allFunctionsForValidation,
172
248
  },
173
249
  );
174
250
 
175
- if (newValidate.result.type === "success") {
176
- return converted.map((c) => c.func);
251
+ const newResult: IAutoBeTypeScriptCompileResult = newValidate.result;
252
+ if (newResult.type === "success") {
253
+ return allFunctionsForValidation;
254
+ } else if (newResult.type === "exception") {
255
+ // Compilation exception, return current functions. because retrying won't help.
256
+ return functions;
257
+ }
258
+
259
+ if (
260
+ newResult.diagnostics.every((d) => !d.file?.startsWith("src/providers"))
261
+ ) {
262
+ // No diagnostics related to provider functions, stop correcting
263
+ return allFunctionsForValidation;
177
264
  }
178
265
 
179
266
  const newLocations: string[] = diagnose(newValidate);
@@ -184,18 +271,16 @@ const correct = async <Model extends ILlmSchema.Model>(
184
271
  newLocations,
185
272
  );
186
273
 
187
- // If no failures to retry, return success and ignored functions
274
+ // If no failures to retry, return all functions
188
275
  if (failed.length === 0) {
189
- return [...success, ...ignored];
276
+ return [...success, ...ignored, ...unchangedFunctions];
190
277
  }
191
278
 
192
279
  // Collect diagnostics relevant to failed functions
193
280
  const failedLocations: string[] = failed.map((f) => f.location);
194
281
  const allDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] = [
195
282
  ...failures,
196
- ...(newValidate.result.type === "failure"
197
- ? newValidate.result.diagnostics
198
- : []),
283
+ ...(newResult.type === "failure" ? newResult.diagnostics : []),
199
284
  ];
200
285
  const relevantDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] =
201
286
  filterRelevantDiagnostics(allDiagnostics, failedLocations);
@@ -203,6 +288,7 @@ const correct = async <Model extends ILlmSchema.Model>(
203
288
  // Recursively retry failed functions
204
289
  const retriedFunctions: AutoBeRealizeFunction[] = await predicate(
205
290
  ctx,
291
+ scenarios,
206
292
  authorizations,
207
293
  failed,
208
294
  relevantDiagnostics,
@@ -211,7 +297,7 @@ const correct = async <Model extends ILlmSchema.Model>(
211
297
  life - 1,
212
298
  );
213
299
 
214
- return [...success, ...ignored, ...retriedFunctions];
300
+ return [...success, ...ignored, ...retriedFunctions, ...unchangedFunctions];
215
301
  };
216
302
 
217
303
  /**
@@ -5,6 +5,7 @@ import {
5
5
  AutoBeRealizeAuthorization,
6
6
  AutoBeRealizeFunction,
7
7
  AutoBeRealizeHistory,
8
+ AutoBeRealizeValidateEvent,
8
9
  AutoBeRealizeWriteEvent,
9
10
  IAutoBeCompiler,
10
11
  } from "@autobe/interface";
@@ -19,7 +20,6 @@ import { compileRealizeFiles } from "./internal/compileRealizeFiles";
19
20
  import { orchestrateRealizeCorrectCasting } from "./orchestRateRealizeCorrectCasting";
20
21
  import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
21
22
  import { orchestrateRealizeCorrect } from "./orchestrateRealizeCorrect";
22
- import { orchestrateRealizeCorrectDate } from "./orchestrateRealizeCorrectDate";
23
23
  import { orchestrateRealizeWrite } from "./orchestrateRealizeWrite";
24
24
  import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
25
25
  import { generateRealizeScenario } from "./utils/generateRealizeScenario";
@@ -30,9 +30,9 @@ export const orchestrateRealize =
30
30
  props: IAutoBeApplicationProps,
31
31
  ): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
32
32
  // PREDICATION
33
- const operations: AutoBeOpenApi.IOperation[] | undefined =
34
- ctx.state().interface?.document.operations;
35
- if (!operations)
33
+ const document: AutoBeOpenApi.IDocument | undefined =
34
+ ctx.state().interface?.document;
35
+ if (document === undefined)
36
36
  throw new Error("Can't do realize agent because operations are nothing.");
37
37
 
38
38
  const start: Date = new Date();
@@ -52,116 +52,156 @@ export const orchestrateRealize =
52
52
  type: "realizeStart",
53
53
  id: v7(),
54
54
  created_at: start.toISOString(),
55
- reason: props.reason,
55
+ reason: props.instruction,
56
56
  step: ctx.state().test?.step ?? 0,
57
57
  });
58
58
 
59
- // AUTHORIZATIONS
59
+ // PREPARE ASSETS
60
+ const compiler: IAutoBeCompiler = await ctx.compiler();
60
61
  const authorizations: AutoBeRealizeAuthorization[] =
61
62
  await orchestrateRealizeAuthorization(ctx);
62
63
 
63
- // SCENARIOS
64
- const scenarios: IAutoBeRealizeScenarioResult[] = operations.map(
65
- (operation) => generateRealizeScenario(ctx, operation, authorizations),
66
- );
67
-
68
64
  const writeProgress: AutoBeProgressEventBase = {
69
- total: scenarios.length,
65
+ total: document.operations.length,
70
66
  completed: 0,
71
67
  };
72
- const writeEvents: (AutoBeRealizeWriteEvent | null)[] =
73
- await executeCachedBatch(
74
- scenarios.map((scenario) => async (promptCacheKey) => {
75
- const props = {
76
- totalAuthorizations: authorizations,
77
- authorization: scenario.decoratorEvent ?? null,
78
- scenario,
79
- progress: writeProgress,
80
- promptCacheKey,
81
- };
82
-
83
- const code: AutoBeRealizeWriteEvent | null =
84
- await orchestrateRealizeWrite(ctx, props).catch(() => {
85
- return orchestrateRealizeWrite(ctx, props).catch(() => null);
86
- });
87
-
88
- return code;
89
- }),
90
- );
91
-
92
- const functions: AutoBeRealizeFunction[] = Object.entries(
93
- Object.fromEntries(
94
- writeEvents
95
- .filter((w) => w !== null)
96
- .map((event) => [event.location, event.content]),
97
- ),
98
- ).map(([location, content]) => {
99
- const scenario = scenarios.find((el) => el.location === location)!;
100
- return {
101
- location,
102
- content,
103
- endpoint: {
104
- method: scenario.operation.method,
105
- path: scenario.operation.path,
106
- },
107
- name: scenario.functionName,
108
- };
109
- });
110
-
111
- const reviewProgress: AutoBeProgressEventBase = {
112
- total: writeEvents.length,
113
- completed: writeEvents.length,
68
+ const correctProgress: AutoBeProgressEventBase = {
69
+ total: document.operations.length,
70
+ completed: 0,
114
71
  };
115
72
 
116
- console.log("casting", reviewProgress);
117
- const totalCorrected: AutoBeRealizeFunction[] =
118
- await orchestrateRealizeCorrectCasting(
119
- ctx,
120
- authorizations,
121
- functions,
122
- reviewProgress,
123
- ).then(async (res) => {
124
- console.log("date", reviewProgress);
125
- return orchestrateRealizeCorrectDate(
73
+ const process = async (
74
+ artifacts: IAutoBeRealizeScenarioResult[],
75
+ ): Promise<IBucket> => {
76
+ const writes: AutoBeRealizeWriteEvent[] = (
77
+ await executeCachedBatch(
78
+ artifacts.map((art) => async (promptCacheKey) => {
79
+ const props = {
80
+ totalAuthorizations: authorizations,
81
+ authorization: art.decoratorEvent ?? null,
82
+ scenario: art,
83
+ document,
84
+ progress: writeProgress,
85
+ promptCacheKey,
86
+ };
87
+ try {
88
+ return await orchestrateRealizeWrite(ctx, props);
89
+ } catch {
90
+ try {
91
+ return await orchestrateRealizeWrite(ctx, props);
92
+ } catch {
93
+ return null;
94
+ }
95
+ }
96
+ }),
97
+ )
98
+ ).filter((w) => w !== null);
99
+ const functions: AutoBeRealizeFunction[] = Object.entries(
100
+ Object.fromEntries(writes.map((w) => [w.location, w.content])),
101
+ ).map(([location, content]) => {
102
+ const scenario: IAutoBeRealizeScenarioResult = artifacts.find(
103
+ (el) => el.location === location,
104
+ )!;
105
+ return {
106
+ location,
107
+ content,
108
+ endpoint: {
109
+ method: scenario.operation.method,
110
+ path: scenario.operation.path,
111
+ },
112
+ name: scenario.functionName,
113
+ };
114
+ });
115
+ const corrected: AutoBeRealizeFunction[] =
116
+ await orchestrateRealizeCorrectCasting(
126
117
  ctx,
118
+ artifacts,
127
119
  authorizations,
128
- res,
129
- reviewProgress,
120
+ functions,
121
+ correctProgress,
130
122
  ).then(async (res) => {
131
- console.log("correct", reviewProgress);
132
- return orchestrateRealizeCorrect(
123
+ return await orchestrateRealizeCorrect(
133
124
  ctx,
134
- scenarios,
125
+ artifacts,
135
126
  authorizations,
136
127
  res,
137
128
  [],
138
- reviewProgress,
129
+ correctProgress,
139
130
  );
140
131
  });
141
- });
132
+ const validate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
133
+ ctx,
134
+ {
135
+ authorizations,
136
+ functions: corrected,
137
+ },
138
+ );
139
+ return {
140
+ corrected,
141
+ validate,
142
+ };
143
+ };
144
+
145
+ // SCENARIOS
146
+ const entireScenarios: IAutoBeRealizeScenarioResult[] =
147
+ document.operations.map((operation) =>
148
+ generateRealizeScenario(ctx, operation, authorizations),
149
+ );
150
+ let bucket: IBucket = await process(entireScenarios);
151
+ for (let i: number = 0; i < 2; ++i) {
152
+ if (bucket.validate.result.type !== "failure") break;
153
+
154
+ const failedScenarios: IAutoBeRealizeScenarioResult[] = Array.from(
155
+ new Set(bucket.validate.result.diagnostics.map((f) => f.file)),
156
+ )
157
+ .map((location) =>
158
+ bucket.corrected.find((f) => f.location === location),
159
+ )
160
+ .filter((f) => f !== undefined)
161
+ .map((f) =>
162
+ entireScenarios.find(
163
+ (s) =>
164
+ s.operation.path === f.endpoint.path &&
165
+ s.operation.method === f.endpoint.method,
166
+ ),
167
+ )
168
+ .filter((o) => o !== undefined);
169
+ if (failedScenarios.length === 0) break;
170
+
171
+ writeProgress.total += failedScenarios.length;
172
+ correctProgress.total += failedScenarios.length;
173
+
174
+ const newBucket: IBucket = await process(failedScenarios);
175
+ const corrected: Map<string, AutoBeRealizeFunction> = new Map([
176
+ ...bucket.corrected.map((f) => [f.location, f] as const),
177
+ ...newBucket.corrected.map((f) => [f.location, f] as const),
178
+ ]);
179
+ bucket = {
180
+ corrected: Array.from(corrected.values()),
181
+ validate: newBucket.validate,
182
+ };
183
+ }
142
184
 
143
- const compiler: IAutoBeCompiler = await ctx.compiler();
144
185
  const controllers: Record<string, string> =
145
186
  await compiler.realize.controller({
146
187
  document: ctx.state().interface!.document,
147
- functions: totalCorrected,
188
+ functions: bucket.corrected,
148
189
  authorizations,
149
190
  });
150
-
151
- const { result } = await compileRealizeFiles(ctx, {
152
- authorizations,
153
- functions: totalCorrected,
154
- });
155
-
156
191
  return ctx.dispatch({
157
192
  type: "realizeComplete",
158
193
  id: v7(),
159
194
  created_at: new Date().toISOString(),
160
- functions,
195
+ functions: bucket.corrected,
161
196
  authorizations,
162
197
  controllers,
163
- compiled: result,
198
+ compiled: bucket.validate.result,
164
199
  step: ctx.state().analyze?.step ?? 0,
165
200
  elapsed: new Date().getTime() - start.getTime(),
166
201
  });
167
202
  };
203
+
204
+ interface IBucket {
205
+ corrected: AutoBeRealizeFunction[];
206
+ validate: AutoBeRealizeValidateEvent;
207
+ }
@@ -19,6 +19,7 @@ import { IAutoBeRealizeCorrectApplication } from "./structures/IAutoBeRealizeCor
19
19
  import { IAutoBeRealizeFunctionFailure } from "./structures/IAutoBeRealizeFunctionFailure";
20
20
  import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
21
21
  import { filterDiagnostics } from "./utils/filterDiagnostics";
22
+ import { getRealizeWriteCodeTemplate } from "./utils/getRealizeWriteCodeTemplate";
22
23
  import { getRealizeWriteDto } from "./utils/getRealizeWriteDto";
23
24
  import { replaceImportStatements } from "./utils/replaceImportStatements";
24
25
 
@@ -40,6 +41,16 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
40
41
 
41
42
  // Extract and process diagnostics
42
43
  const diagnostics = event.result.diagnostics;
44
+
45
+ if (
46
+ event.result.diagnostics.every(
47
+ (d) => !d.file?.startsWith("src/providers"),
48
+ ) === true
49
+ ) {
50
+ // No diagnostics related to provider functions, stop correcting
51
+ return functions;
52
+ }
53
+
43
54
  const locations: string[] = Array.from(
44
55
  new Set(
45
56
  diagnostics
@@ -91,7 +102,6 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
91
102
  ),
92
103
  progress,
93
104
  );
94
-
95
105
  return orchestrateRealizeCorrect(
96
106
  ctx,
97
107
  scenarios,
@@ -115,7 +125,11 @@ async function correct<Model extends ILlmSchema.Model>(
115
125
  failures: IAutoBeRealizeFunctionFailure[],
116
126
  progress: AutoBeProgressEventBase,
117
127
  ): Promise<AutoBeRealizeFunction[]> {
118
- const result: AutoBeRealizeFunction[] = await executeCachedBatch(
128
+ if (locations.length === 0) {
129
+ return functions;
130
+ }
131
+
132
+ const corrected: AutoBeRealizeFunction[] = await executeCachedBatch(
119
133
  locations.map((location) => async (): Promise<AutoBeRealizeFunction> => {
120
134
  const scenario = scenarios.find((el) => el.location === location);
121
135
  const func = functions.find((el) => el.location === location);
@@ -154,7 +168,11 @@ async function correct<Model extends ILlmSchema.Model>(
154
168
  }),
155
169
  );
156
170
 
157
- return result;
171
+ // Create a map of corrected functions for efficient lookup
172
+ const correctedMap = new Map(corrected.map((f) => [f.location, f]));
173
+
174
+ // Return all functions, with corrected ones replaced
175
+ return functions.map((func) => correctedMap.get(func.location) || func);
158
176
  }
159
177
 
160
178
  async function step<Model extends ILlmSchema.Model>(
@@ -195,6 +213,23 @@ async function step<Model extends ILlmSchema.Model>(
195
213
  enforceFunctionCall: true,
196
214
  message: StringUtil.trim`
197
215
  Correct the TypeScript code implementation.
216
+
217
+ The instruction to write at first was as follows, and the code you received is the code you wrote according to this instruction.
218
+ When modifying, modify the entire code, but not the import statement.
219
+
220
+ Below is template code you wrote:
221
+
222
+ ${getRealizeWriteCodeTemplate({
223
+ scenario: props.scenario,
224
+ schemas: ctx.state().interface!.document.components.schemas,
225
+ operation: props.scenario.operation,
226
+ authorization: props.authorization ?? null,
227
+ })}
228
+
229
+ Current code is as follows:
230
+ \`\`\`typescript
231
+ ${props.function.content}
232
+ \`\`\`
198
233
  `,
199
234
  });
200
235
 
@@ -202,17 +237,25 @@ async function step<Model extends ILlmSchema.Model>(
202
237
  return null;
203
238
  }
204
239
 
205
- pointer.value.revise.final = await replaceImportStatements(ctx, {
240
+ pointer.value.draft = await replaceImportStatements(ctx, {
206
241
  operation: props.scenario.operation,
207
- code: pointer.value.revise.final,
242
+ schemas: ctx.state().interface!.document.components.schemas,
243
+ code: pointer.value.draft,
208
244
  decoratorType: props.authorization?.payload.name,
209
245
  });
246
+ if (pointer.value.revise.final)
247
+ pointer.value.revise.final = await replaceImportStatements(ctx, {
248
+ operation: props.scenario.operation,
249
+ schemas: ctx.state().interface!.document.components.schemas,
250
+ code: pointer.value.revise.final,
251
+ decoratorType: props.authorization?.payload.name,
252
+ });
210
253
 
211
254
  const event: AutoBeRealizeCorrectEvent = {
212
255
  type: "realizeCorrect",
213
256
  id: v7(),
214
257
  location: props.scenario.location,
215
- content: pointer.value.revise.final,
258
+ content: pointer.value.revise.final ?? pointer.value.draft,
216
259
  tokenUsage,
217
260
  completed: ++props.progress.completed,
218
261
  total: props.progress.total,
@@ -237,7 +280,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
237
280
  name: "Write code",
238
281
  application,
239
282
  execute: {
240
- review: (next) => {
283
+ correct: (next) => {
241
284
  props.build(next);
242
285
  },
243
286
  } satisfies IAutoBeRealizeCorrectApplication,
@@ -1,4 +1,5 @@
1
1
  import {
2
+ AutoBeOpenApi,
2
3
  AutoBeProgressEventBase,
3
4
  AutoBeRealizeAuthorization,
4
5
  AutoBeRealizeWriteEvent,
@@ -20,6 +21,7 @@ import { replaceImportStatements } from "./utils/replaceImportStatements";
20
21
  export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
21
22
  ctx: AutoBeContext<Model>,
22
23
  props: {
24
+ document: AutoBeOpenApi.IDocument;
23
25
  totalAuthorizations: AutoBeRealizeAuthorization[];
24
26
  authorization: AutoBeRealizeAuthorization | null;
25
27
  scenario: IAutoBeRealizeScenarioResult;
@@ -69,17 +71,25 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
69
71
  });
70
72
  if (pointer.value === null) throw new Error("Failed to write code.");
71
73
 
72
- pointer.value.final = await replaceImportStatements(ctx, {
74
+ pointer.value.draft = await replaceImportStatements(ctx, {
73
75
  operation: props.scenario.operation,
74
- code: pointer.value.final,
76
+ schemas: props.document.components.schemas,
77
+ code: pointer.value.draft,
75
78
  decoratorType: props.authorization?.payload.name,
76
79
  });
80
+ if (pointer.value.revise.final)
81
+ pointer.value.revise.final = await replaceImportStatements(ctx, {
82
+ operation: props.scenario.operation,
83
+ schemas: props.document.components.schemas,
84
+ code: pointer.value.revise.final,
85
+ decoratorType: props.authorization?.payload.name,
86
+ });
77
87
 
78
88
  const event: AutoBeRealizeWriteEvent = {
79
89
  type: "realizeWrite",
80
90
  id: v7(),
81
91
  location: props.scenario.location,
82
- content: pointer.value.final,
92
+ content: pointer.value.revise.final ?? pointer.value.draft,
83
93
  tokenUsage,
84
94
  completed: ++props.progress.completed,
85
95
  total: props.progress.total,
@@ -105,7 +115,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
105
115
  name: "Write code",
106
116
  application,
107
117
  execute: {
108
- coding: (next) => {
118
+ write: (next) => {
109
119
  props.build(next);
110
120
  },
111
121
  } satisfies IAutoBeRealizeWriteApplication,