@autobe/agent 0.25.7 → 0.27.0

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 (339) hide show
  1. package/lib/AutoBeAgent.d.ts +2 -1
  2. package/lib/AutoBeAgent.js +30 -7
  3. package/lib/AutoBeAgent.js.map +1 -1
  4. package/lib/AutoBeMockAgent.js +13 -12
  5. package/lib/AutoBeMockAgent.js.map +1 -1
  6. package/lib/constants/AutoBeSystemPromptConstant.d.ts +27 -20
  7. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  8. package/lib/context/AutoBeContext.d.ts +4 -1
  9. package/lib/context/AutoBeTokenUsage.d.ts +1 -1
  10. package/lib/context/AutoBeTokenUsage.js.map +1 -1
  11. package/lib/factory/AutoBeFunctionCallingMetricFactory.d.ts +7 -0
  12. package/lib/factory/AutoBeFunctionCallingMetricFactory.js +35 -0
  13. package/lib/factory/AutoBeFunctionCallingMetricFactory.js.map +1 -0
  14. package/lib/factory/AutoBeProcessAggregateFactory.d.ts +13 -0
  15. package/lib/factory/AutoBeProcessAggregateFactory.js +100 -0
  16. package/lib/factory/AutoBeProcessAggregateFactory.js.map +1 -0
  17. package/lib/factory/consentFunctionCall.js +3 -0
  18. package/lib/factory/consentFunctionCall.js.map +1 -1
  19. package/lib/factory/createAutoBeContext.d.ts +2 -1
  20. package/lib/factory/createAutoBeContext.js +82 -28
  21. package/lib/factory/createAutoBeContext.js.map +1 -1
  22. package/lib/factory/getCommonPrompt.d.ts +2 -0
  23. package/lib/factory/getCommonPrompt.js +20 -0
  24. package/lib/factory/getCommonPrompt.js.map +1 -0
  25. package/lib/index.mjs +20929 -19874
  26. package/lib/index.mjs.map +1 -1
  27. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  28. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  29. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  30. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  31. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +6 -6
  32. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  33. package/lib/orchestrate/analyze/orchestrateAnalyze.js +2 -1
  34. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  35. package/lib/orchestrate/analyze/orchestrateAnalyzeReview.js +2 -1
  36. package/lib/orchestrate/analyze/orchestrateAnalyzeReview.js.map +1 -1
  37. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +75 -74
  38. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  39. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +5 -4
  40. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  41. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +9 -9
  42. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +1 -1
  43. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +2 -17
  44. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  45. package/lib/orchestrate/common/histories/transformPreviousAndLatestCorrectHistories.d.ts +6 -0
  46. package/lib/orchestrate/common/histories/transformPreviousAndLatestCorrectHistories.js +58 -0
  47. package/lib/orchestrate/common/histories/transformPreviousAndLatestCorrectHistories.js.map +1 -0
  48. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.d.ts +2 -1
  49. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +3 -2
  50. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  51. package/lib/{factory/createAutoBeApplication.d.ts → orchestrate/facade/createAutoBeFacadeController.d.ts} +2 -2
  52. package/lib/{factory/createAutoBeApplication.js → orchestrate/facade/createAutoBeFacadeController.js} +53 -57
  53. package/lib/orchestrate/facade/createAutoBeFacadeController.js.map +1 -0
  54. package/lib/orchestrate/facade/histories/IAutoBeFacadeApplication.js.map +1 -0
  55. package/lib/orchestrate/facade/histories/IAutoBeFacadeApplicationProps.js.map +1 -0
  56. package/lib/orchestrate/facade/histories/IAutoBeFacadeApplicationResult.js.map +1 -0
  57. package/lib/orchestrate/facade/{transformFacadeStateMessage.d.ts → structures/transformFacadeStateMessage.d.ts} +1 -1
  58. package/lib/orchestrate/facade/structures/transformFacadeStateMessage.js +46 -0
  59. package/lib/orchestrate/facade/structures/transformFacadeStateMessage.js.map +1 -0
  60. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +2 -2
  61. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +8 -8
  62. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  63. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  64. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  65. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  66. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  67. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +3 -2
  68. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  69. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  70. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  71. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  72. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  73. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  74. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  75. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +1 -0
  76. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +46 -20
  77. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  78. package/lib/orchestrate/interface/histories/transformInterfaceSchemaRenameHistories.d.ts +5 -0
  79. package/lib/orchestrate/interface/histories/transformInterfaceSchemaRenameHistories.js +51 -0
  80. package/lib/orchestrate/interface/histories/transformInterfaceSchemaRenameHistories.js.map +1 -0
  81. package/lib/orchestrate/interface/histories/transformInterfaceSchemaReviewHistories.d.ts +11 -0
  82. package/lib/orchestrate/interface/histories/transformInterfaceSchemaReviewHistories.js +81 -0
  83. package/lib/orchestrate/interface/histories/transformInterfaceSchemaReviewHistories.js.map +1 -0
  84. package/lib/orchestrate/interface/orchestrateInterface.d.ts +1 -1
  85. package/lib/orchestrate/interface/orchestrateInterface.js +33 -6
  86. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  87. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +185 -97
  88. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  89. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +234 -59
  90. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  91. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +5 -4
  92. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  93. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +0 -6
  94. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +4 -4
  95. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.js.map +1 -1
  96. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +2 -2
  97. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +4 -3
  98. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  99. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +178 -90
  100. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  101. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +176 -88
  102. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  103. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +6 -5
  104. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -1
  105. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRename.d.ts +7 -0
  106. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRename.js +445 -0
  107. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRename.js.map +1 -0
  108. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.d.ts +14 -0
  109. package/lib/orchestrate/interface/{orchestrateInterfaceSchemasReview.js → orchestrateInterfaceSchemaReview.js} +302 -121
  110. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js.map +1 -0
  111. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +243 -65
  112. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  113. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +22 -22
  114. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +7 -7
  115. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaContentReviewApplication.d.ts +101 -0
  116. package/lib/orchestrate/interface/structures/{IAutobeInterfaceSchemasReviewApplication.js → IAutoBeInterfaceSchemaContentReviewApplication.js} +1 -1
  117. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaContentReviewApplication.js.map +1 -0
  118. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRelationReviewApplication.d.ts +97 -0
  119. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRelationReviewApplication.js +3 -0
  120. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRelationReviewApplication.js.map +1 -0
  121. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.d.ts +44 -0
  122. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.js +3 -0
  123. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.js.map +1 -0
  124. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaSecurityReviewApplication.d.ts +92 -0
  125. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaSecurityReviewApplication.js +3 -0
  126. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaSecurityReviewApplication.js.map +1 -0
  127. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +65 -24
  128. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  129. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +94 -0
  130. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  131. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +1 -1
  132. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +13 -13
  133. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  134. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
  135. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  136. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  137. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  138. package/lib/orchestrate/prisma/orchestratePrisma.d.ts +1 -1
  139. package/lib/orchestrate/prisma/orchestratePrisma.js +1 -0
  140. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  141. package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +2 -2
  142. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +4 -3
  143. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  144. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +2 -1
  145. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  146. package/lib/orchestrate/prisma/orchestratePrismaReview.js +2 -1
  147. package/lib/orchestrate/prisma/orchestratePrismaReview.js.map +1 -1
  148. package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +2 -2
  149. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +4 -3
  150. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  151. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.d.ts +2 -2
  152. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.js +8 -7
  153. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  154. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +4 -4
  155. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  156. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.d.ts +4 -7
  157. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +8 -18
  158. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -1
  159. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +0 -1
  160. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +8 -28
  161. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  162. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.d.ts +1 -1
  163. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +16 -280
  164. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js.map +1 -1
  165. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +1 -1
  166. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  167. package/lib/orchestrate/realize/orchestrateRealize.d.ts +1 -1
  168. package/lib/orchestrate/realize/orchestrateRealize.js +4 -3
  169. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  170. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +14 -13
  171. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  172. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +12 -11
  173. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  174. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +1 -1
  175. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +46 -24
  176. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  177. package/lib/orchestrate/realize/{orchestRateRealizeCorrectCasting.js → orchestrateRealizeCorrectCasting.js} +64 -51
  178. package/lib/orchestrate/realize/orchestrateRealizeCorrectCasting.js.map +1 -0
  179. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +2 -1
  180. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  181. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +3 -3
  182. package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.d.ts +2 -2
  183. package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.js +6 -6
  184. package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.js.map +1 -1
  185. package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -1
  186. package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
  187. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +2 -2
  188. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  189. package/lib/orchestrate/realize/utils/getRealizeWriteDto.js +1 -1
  190. package/lib/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -1
  191. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.js +2 -2
  192. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.js.map +1 -1
  193. package/lib/orchestrate/realize/utils/printErrorHints.js +1 -1
  194. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -1
  195. package/lib/orchestrate/realize/utils/replaceImportStatements.js +0 -85
  196. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  197. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +1 -1
  198. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  199. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +5 -22
  200. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  201. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +10 -10
  202. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  203. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +5 -5
  204. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  205. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +2 -2
  206. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  207. package/lib/orchestrate/test/orchestrateTest.d.ts +1 -1
  208. package/lib/orchestrate/test/orchestrateTest.js +2 -1
  209. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  210. package/lib/orchestrate/test/orchestrateTestCorrect.js +5 -1
  211. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  212. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +4 -2
  213. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  214. package/lib/orchestrate/test/orchestrateTestScenario.js +28 -27
  215. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  216. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +4 -3
  217. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  218. package/lib/orchestrate/test/orchestrateTestWrite.js +2 -1
  219. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  220. package/lib/orchestrate/test/structures/{IAutoBeTestScenarioAuthorizationRole.d.ts → IAutoBeTestScenarioAuthorizationActor.d.ts} +1 -1
  221. package/lib/orchestrate/test/structures/{IAutoBeTestScenarioAuthorizationRole.js → IAutoBeTestScenarioAuthorizationActor.js} +1 -1
  222. package/lib/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationActor.js.map +1 -0
  223. package/lib/utils/TokenUsageComputer.d.ts +5 -0
  224. package/lib/utils/TokenUsageComputer.js +29 -0
  225. package/lib/utils/TokenUsageComputer.js.map +1 -0
  226. package/package.json +7 -7
  227. package/src/AutoBeAgent.ts +43 -6
  228. package/src/AutoBeMockAgent.ts +13 -12
  229. package/src/constants/AutoBeSystemPromptConstant.ts +27 -20
  230. package/src/context/AutoBeContext.ts +8 -0
  231. package/src/context/AutoBeTokenUsage.ts +1 -1
  232. package/src/factory/AutoBeFunctionCallingMetricFactory.ts +44 -0
  233. package/src/factory/AutoBeProcessAggregateFactory.ts +141 -0
  234. package/src/factory/consentFunctionCall.ts +4 -0
  235. package/src/factory/createAutoBeContext.ts +101 -37
  236. package/src/factory/getCommonPrompt.ts +25 -0
  237. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +5 -5
  238. package/src/orchestrate/analyze/orchestrateAnalyze.ts +2 -1
  239. package/src/orchestrate/analyze/orchestrateAnalyzeReview.ts +2 -1
  240. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +5 -4
  241. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
  242. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +9 -9
  243. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.ts +1 -1
  244. package/src/orchestrate/common/histories/transformCommonCorrectCastingHistories.ts +2 -20
  245. package/src/orchestrate/common/histories/transformPreviousAndLatestCorrectHistories.ts +65 -0
  246. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +5 -2
  247. package/src/orchestrate/facade/createAutoBeFacadeController.ts +135 -0
  248. package/src/orchestrate/facade/{transformFacadeStateMessage.ts → structures/transformFacadeStateMessage.ts} +2 -2
  249. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +9 -9
  250. package/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.ts +1 -0
  251. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +45 -20
  252. package/src/orchestrate/interface/histories/transformInterfaceSchemaRenameHistories.ts +55 -0
  253. package/src/orchestrate/interface/histories/transformInterfaceSchemaReviewHistories.ts +90 -0
  254. package/src/orchestrate/interface/orchestrateInterface.ts +47 -16
  255. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +20 -19
  256. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +2 -1
  257. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +7 -6
  258. package/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.ts +5 -6
  259. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +7 -6
  260. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +25 -24
  261. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +6 -5
  262. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +4 -3
  263. package/src/orchestrate/interface/orchestrateInterfaceSchemaRename.ts +270 -0
  264. package/src/orchestrate/interface/{orchestrateInterfaceSchemasReview.ts → orchestrateInterfaceSchemaReview.ts} +89 -76
  265. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +18 -9
  266. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +26 -22
  267. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +7 -7
  268. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaContentReviewApplication.ts +108 -0
  269. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaRelationReviewApplication.ts +104 -0
  270. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.ts +45 -0
  271. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaSecurityReviewApplication.ts +99 -0
  272. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +45 -3
  273. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +110 -0
  274. package/src/orchestrate/interface/utils/OperationValidator.ts +1 -1
  275. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +12 -12
  276. package/src/orchestrate/prisma/orchestratePrisma.ts +6 -5
  277. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +6 -5
  278. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +2 -1
  279. package/src/orchestrate/prisma/orchestratePrismaReview.ts +2 -1
  280. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +9 -8
  281. package/src/orchestrate/realize/histories/transformRealizeAuthorization.ts +8 -7
  282. package/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts +4 -4
  283. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +14 -28
  284. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -30
  285. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +20 -285
  286. package/src/orchestrate/realize/orchestrateRealize.ts +4 -3
  287. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +11 -10
  288. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +5 -4
  289. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +77 -62
  290. package/src/orchestrate/realize/{orchestRateRealizeCorrectCasting.ts → orchestrateRealizeCorrectCasting.ts} +92 -90
  291. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +2 -1
  292. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +3 -3
  293. package/src/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.ts +10 -7
  294. package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -1
  295. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +2 -2
  296. package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +1 -1
  297. package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +2 -2
  298. package/src/orchestrate/realize/utils/printErrorHints.ts +1 -1
  299. package/src/orchestrate/realize/utils/replaceImportStatements.ts +0 -90
  300. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +1 -1
  301. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +6 -24
  302. package/src/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.ts +10 -10
  303. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +12 -10
  304. package/src/orchestrate/test/orchestrateTest.ts +3 -2
  305. package/src/orchestrate/test/orchestrateTestCorrect.ts +5 -1
  306. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +4 -2
  307. package/src/orchestrate/test/orchestrateTestScenario.ts +32 -31
  308. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +4 -3
  309. package/src/orchestrate/test/orchestrateTestWrite.ts +2 -1
  310. package/src/orchestrate/test/structures/{IAutoBeTestScenarioAuthorizationRole.ts → IAutoBeTestScenarioAuthorizationActor.ts} +1 -1
  311. package/src/utils/TokenUsageComputer.ts +35 -0
  312. package/lib/context/IAutoBeFacadeApplication.js.map +0 -1
  313. package/lib/context/IAutoBeFacadeApplicationProps.js.map +0 -1
  314. package/lib/context/IAutoBeFacadeApplicationResult.js.map +0 -1
  315. package/lib/factory/createAutoBeApplication.js.map +0 -1
  316. package/lib/orchestrate/facade/transformFacadeStateMessage.js +0 -46
  317. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +0 -1
  318. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +0 -4
  319. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +0 -60
  320. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +0 -1
  321. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +0 -9
  322. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +0 -1
  323. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +0 -91
  324. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.js.map +0 -1
  325. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +0 -1
  326. package/lib/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.js.map +0 -1
  327. package/src/factory/createAutoBeApplication.ts +0 -123
  328. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +0 -67
  329. package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +0 -96
  330. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplication.d.ts +0 -0
  331. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplication.js +0 -0
  332. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationProps.d.ts +0 -0
  333. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationProps.js +0 -0
  334. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationResult.d.ts +0 -0
  335. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationResult.js +0 -0
  336. /package/lib/orchestrate/realize/{orchestRateRealizeCorrectCasting.d.ts → orchestrateRealizeCorrectCasting.d.ts} +0 -0
  337. /package/src/{context → orchestrate/facade/histories}/IAutoBeFacadeApplication.ts +0 -0
  338. /package/src/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationProps.ts +0 -0
  339. /package/src/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationResult.ts +0 -0
@@ -24,6 +24,7 @@ import { validateEmptyCode } from "../../utils/validateEmptyCode";
24
24
  import { IAutoBeCommonCorrectCastingApplication } from "../common/structures/IAutoBeCommonCorrectCastingApplication";
25
25
  import { transformRealizeCorrectCastingHistories } from "./histories/transformRealizeCorrectCastingHistories";
26
26
  import { compileRealizeFiles } from "./internal/compileRealizeFiles";
27
+ import { IAutoBeRealizeFunctionFailure } from "./structures/IAutoBeRealizeFunctionFailure";
27
28
  import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
28
29
  import { getRealizeWriteCodeTemplate } from "./utils/getRealizeWriteCodeTemplate";
29
30
  import { replaceImportStatements } from "./utils/replaceImportStatements";
@@ -53,94 +54,103 @@ export const orchestrateRealizeCorrectCasting = async <
53
54
  );
54
55
  return predicate(
55
56
  ctx,
56
- scenarios,
57
- authorizations,
58
- functions,
59
- [],
60
- progress,
61
- validateEvent,
57
+ {
58
+ scenarios,
59
+ authorizations,
60
+ functions,
61
+ previousFailures: [],
62
+ progress,
63
+ event: validateEvent,
64
+ },
62
65
  life,
63
66
  );
64
67
  };
65
68
 
66
69
  const predicate = async <Model extends ILlmSchema.Model>(
67
70
  ctx: AutoBeContext<Model>,
68
- scenarios: IAutoBeRealizeScenarioResult[],
69
- authorizations: AutoBeRealizeAuthorization[],
70
- functions: AutoBeRealizeFunction[],
71
- failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
72
- progress: AutoBeProgressEventBase,
73
- event: AutoBeRealizeValidateEvent,
71
+ props: {
72
+ scenarios: IAutoBeRealizeScenarioResult[];
73
+ authorizations: AutoBeRealizeAuthorization[];
74
+ functions: AutoBeRealizeFunction[];
75
+ previousFailures: IAutoBeRealizeFunctionFailure[][];
76
+ progress: AutoBeProgressEventBase;
77
+ event: AutoBeRealizeValidateEvent;
78
+ },
74
79
  life: number,
75
80
  ): Promise<AutoBeRealizeFunction[]> => {
76
- if (event.result.type === "failure") {
77
- ctx.dispatch(event);
78
- return await correct(
79
- ctx,
80
- scenarios,
81
- authorizations,
82
- functions,
83
- [...failures, ...event.result.diagnostics],
84
- progress,
85
- event,
86
- life,
87
- );
81
+ if (props.event.result.type === "failure") {
82
+ ctx.dispatch(props.event);
83
+ return await correct(ctx, props, life);
88
84
  }
89
- return functions;
85
+ return props.functions;
90
86
  };
91
87
 
92
88
  const correct = async <Model extends ILlmSchema.Model>(
93
89
  ctx: AutoBeContext<Model>,
94
- scenarios: IAutoBeRealizeScenarioResult[],
95
- authorizations: AutoBeRealizeAuthorization[],
96
- functions: AutoBeRealizeFunction[],
97
- failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
98
- progress: AutoBeProgressEventBase,
99
- event: AutoBeRealizeValidateEvent,
90
+ props: {
91
+ scenarios: IAutoBeRealizeScenarioResult[];
92
+ authorizations: AutoBeRealizeAuthorization[];
93
+ functions: AutoBeRealizeFunction[];
94
+ previousFailures: IAutoBeRealizeFunctionFailure[][];
95
+ progress: AutoBeProgressEventBase;
96
+ event: AutoBeRealizeValidateEvent;
97
+ },
100
98
  life: number,
101
99
  ): Promise<AutoBeRealizeFunction[]> => {
102
100
  // Early returns for non-correctable cases
103
- if (event.result.type !== "failure" || life < 0) {
104
- return functions;
101
+ if (props.event.result.type !== "failure" || life < 0) {
102
+ return props.functions;
105
103
  }
106
104
 
107
- const locations: string[] = diagnose(event).filter((l) =>
108
- functions.map((f) => f.location).includes(l),
105
+ const failure = props.event.result;
106
+ const locations: string[] = diagnose(props.event).filter((l) =>
107
+ props.functions.map((f) => f.location).includes(l),
109
108
  );
110
109
 
111
110
  // If no locations to correct, return original functions
112
111
  if (locations.length === 0) {
113
- return functions;
112
+ return props.functions;
114
113
  }
115
114
 
116
- progress.total += locations.length;
115
+ props.progress.total += locations.length;
117
116
 
118
117
  const converted: CorrectionResult[] = await executeCachedBatch(
119
118
  locations.map((location) => async (): Promise<CorrectionResult> => {
120
- const func: AutoBeRealizeFunction = functions.find(
119
+ const func: AutoBeRealizeFunction = props.functions.find(
121
120
  (f) => f.location === location,
122
121
  )!;
123
- const scenario: IAutoBeRealizeScenarioResult = scenarios.find(
122
+ const scenario: IAutoBeRealizeScenarioResult = props.scenarios.find(
124
123
  (s) => s.location === func.location,
125
124
  )!;
126
125
  const operation: AutoBeOpenApi.IOperation = scenario.operation;
127
126
  const authorization: AutoBeRealizeAuthorization | undefined =
128
- authorizations.find((a) => a.role.name === operation.authorizationRole);
127
+ props.authorizations.find(
128
+ (a) => a.actor.name === operation.authorizationActor,
129
+ );
129
130
 
130
131
  const pointer: IPointer<
131
132
  IAutoBeCommonCorrectCastingApplication.IProps | false | null
132
133
  > = {
133
134
  value: null,
134
135
  };
135
-
136
- const { tokenUsage } = await ctx.conversate({
136
+ const { metric, tokenUsage } = await ctx.conversate({
137
137
  source: "realizeCorrect",
138
- histories: transformRealizeCorrectCastingHistories([
139
- {
140
- script: func.content,
141
- diagnostics: failures.filter((d) => d.file === location),
142
- },
143
- ]),
138
+ histories: transformRealizeCorrectCastingHistories({
139
+ failures: [
140
+ ...props.previousFailures
141
+ .map(
142
+ (pf) =>
143
+ pf.find((f) => f.function.location === func.location) ?? null,
144
+ )
145
+ .filter((x) => x !== null),
146
+ {
147
+ function: func,
148
+ diagnostics: failure.diagnostics.filter(
149
+ (d) => d.file === func.location,
150
+ ),
151
+ },
152
+ ],
153
+ }),
144
154
  controller: createController({
145
155
  model: ctx.model,
146
156
  functionName: scenario.functionName,
@@ -155,13 +165,13 @@ const correct = async <Model extends ILlmSchema.Model>(
155
165
  message: StringUtil.trim`
156
166
  Fix the TypeScript casting problems to resolve the compilation error.
157
167
 
158
- Most casting errors are caused by type mismatches between Date types and
168
+ Most casting errors are caused by type mismatches between Date types and
159
169
  string & tags.Format<'date-time'>. To fix these:
160
170
  - Use ONLY the pre-provided toISOStringSafe() function to convert Date to string
161
171
  - Do NOT use .toISOString() method directly (use toISOStringSafe instead)
162
172
  - Never use Date type directly in declarations or return values
163
173
 
164
- You don't need to explain me anything, but just fix or give it up
174
+ You don't need to explain me anything, but just fix or give it up
165
175
  immediately without any hesitation, explanation, and questions.
166
176
 
167
177
  The instruction to write at first was as follows, and the code you received is the code you wrote according to this instruction.
@@ -185,16 +195,16 @@ const correct = async <Model extends ILlmSchema.Model>(
185
195
  Also, never use typia.assert and typia.assertGuard like functions
186
196
  to the Prisma types. Your mission is to fix the casting problem of
187
197
  primitive types like string or number. Prisma type is not your scope.
188
-
198
+
189
199
  If you take a mistake that casting the Prisma type with the typia.assert
190
200
  function, it would be fallen into the infinite compilation due to extremely
191
- complicated Prisma type. Note that, the typia.assert function is allowed
201
+ complicated Prisma type. Note that, the typia.assert function is allowed
192
202
  only in the individual property level string or literal type.
193
203
 
194
204
  I repeat that, never assert the Prisma type. It's not your mission.
195
205
  `,
196
206
  });
197
- ++progress.completed;
207
+ ++props.progress.completed;
198
208
 
199
209
  if (pointer.value === null)
200
210
  return { result: "exception" as const, func: func };
@@ -218,13 +228,15 @@ const correct = async <Model extends ILlmSchema.Model>(
218
228
  ctx.dispatch({
219
229
  id: v7(),
220
230
  type: "realizeCorrect",
231
+ kind: "casting",
221
232
  content: pointer.value.revise.final ?? pointer.value.draft,
222
233
  created_at: new Date().toISOString(),
223
234
  location: func.location,
224
235
  step: ctx.state().analyze?.step ?? 0,
236
+ metric,
225
237
  tokenUsage,
226
- completed: progress.completed,
227
- total: progress.total,
238
+ completed: props.progress.completed,
239
+ total: props.progress.total,
228
240
  });
229
241
  return {
230
242
  result: "success" as const,
@@ -237,7 +249,7 @@ const correct = async <Model extends ILlmSchema.Model>(
237
249
  );
238
250
 
239
251
  // Get functions that were not modified (not in locations array)
240
- const unchangedFunctions: AutoBeRealizeFunction[] = functions.filter(
252
+ const unchangedFunctions: AutoBeRealizeFunction[] = props.functions.filter(
241
253
  (f) => !locations.includes(f.location),
242
254
  );
243
255
 
@@ -250,7 +262,7 @@ const correct = async <Model extends ILlmSchema.Model>(
250
262
  const newValidate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
251
263
  ctx,
252
264
  {
253
- authorizations,
265
+ authorizations: props.authorizations,
254
266
  functions: allFunctionsForValidation,
255
267
  },
256
268
  );
@@ -260,7 +272,7 @@ const correct = async <Model extends ILlmSchema.Model>(
260
272
  return allFunctionsForValidation;
261
273
  } else if (newResult.type === "exception") {
262
274
  // Compilation exception, return current functions. because retrying won't help.
263
- return functions;
275
+ return props.functions;
264
276
  }
265
277
 
266
278
  if (
@@ -283,27 +295,33 @@ const correct = async <Model extends ILlmSchema.Model>(
283
295
  return [...success, ...ignored, ...unchangedFunctions];
284
296
  }
285
297
 
286
- // Collect diagnostics relevant to failed functions
287
- const failedLocations: string[] = failed.map((f) => f.location);
288
- const allDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] = [
289
- ...failures,
290
- ...(newResult.type === "failure" ? newResult.diagnostics : []),
291
- ];
292
- const relevantDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] =
293
- filterRelevantDiagnostics(allDiagnostics, failedLocations);
294
-
295
298
  // Recursively retry failed functions
296
299
  const retriedFunctions: AutoBeRealizeFunction[] = await predicate(
297
300
  ctx,
298
- scenarios,
299
- authorizations,
300
- failed,
301
- relevantDiagnostics,
302
- progress,
303
- newValidate,
301
+ {
302
+ scenarios: props.scenarios,
303
+ authorizations: props.authorizations,
304
+ functions: failed,
305
+ previousFailures: [
306
+ ...props.previousFailures,
307
+ failed.map(
308
+ (f) =>
309
+ ({
310
+ function: f,
311
+ diagnostics:
312
+ newValidate.result.type === "failure"
313
+ ? newValidate.result.diagnostics.filter(
314
+ (d) => d.file === f.location,
315
+ )
316
+ : [],
317
+ }) satisfies IAutoBeRealizeFunctionFailure,
318
+ ),
319
+ ],
320
+ progress: props.progress,
321
+ event: newValidate,
322
+ },
304
323
  life - 1,
305
324
  );
306
-
307
325
  return [...success, ...ignored, ...retriedFunctions, ...unchangedFunctions];
308
326
  };
309
327
 
@@ -362,22 +380,6 @@ const separateCorrectionResults = (
362
380
  return { success, failed, ignored };
363
381
  };
364
382
 
365
- /**
366
- * Filter diagnostics to only include those relevant to specific functions
367
- *
368
- * @param diagnostics - All diagnostics
369
- * @param functionLocations - Locations of functions to filter for
370
- * @returns Filtered diagnostics
371
- */
372
- const filterRelevantDiagnostics = (
373
- diagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[],
374
- functionLocations: string[],
375
- ): IAutoBeTypeScriptCompileResult.IDiagnostic[] => {
376
- return diagnostics.filter(
377
- (d) => d.file && functionLocations.includes(d.file),
378
- );
379
- };
380
-
381
383
  const createController = <Model extends ILlmSchema.Model>(props: {
382
384
  model: Model;
383
385
  functionName: string;
@@ -40,7 +40,7 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
40
40
  };
41
41
 
42
42
  const dto = await getRealizeWriteDto(ctx, props.scenario.operation);
43
- const { tokenUsage } = await ctx.conversate({
43
+ const { metric, tokenUsage } = await ctx.conversate({
44
44
  source: "realizeWrite",
45
45
  histories: transformRealizeWriteHistories({
46
46
  state: ctx.state(),
@@ -97,6 +97,7 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
97
97
  id: v7(),
98
98
  location: props.scenario.location,
99
99
  content: pointer.value.revise.final ?? pointer.value.draft,
100
+ metric,
100
101
  tokenUsage,
101
102
  completed: ++props.progress.completed,
102
103
  total: props.progress.total,
@@ -83,7 +83,7 @@ export namespace IAutoBeRealizeAuthorizationApplication {
83
83
 
84
84
  export interface IDecorator {
85
85
  /**
86
- * The name of the Decorator to be generated in {Role}Auth format (e.g.,
86
+ * The name of the Decorator to be generated in {Actor}Auth format (e.g.,
87
87
  * AdminAuth, UserAuth). This decorator will be used as a parameter
88
88
  * decorator in Controller methods to automatically authenticate and
89
89
  * authorize users for the specific role, injecting the authenticated user
@@ -106,7 +106,7 @@ export namespace IAutoBeRealizeAuthorizationApplication {
106
106
 
107
107
  export interface IPayloadType {
108
108
  /**
109
- * The name of the Payload type to be generated in {Role}Payload format
109
+ * The name of the Payload type to be generated in {Actor}Payload format
110
110
  * (e.g., AdminPayload, UserPayload). This type defines the structure of the
111
111
  * authenticated user data that will be injected into Controller methods
112
112
  * when using the decorator.
@@ -116,7 +116,7 @@ export namespace IAutoBeRealizeAuthorizationApplication {
116
116
  name: string & PascalCasePattern;
117
117
 
118
118
  /**
119
- * Complete TypeScript code for the Payload type interface in {Role}Payload
119
+ * Complete TypeScript code for the Payload type interface in {Actor}Payload
120
120
  * format (e.g., AdminPayload, UserPayload). Must include: id field with
121
121
  * UUID format validation, type field as role discriminator, and proper
122
122
  * typia tags for validation. This interface defines the structure of the
@@ -1,9 +1,12 @@
1
1
  export namespace AutoBeRealizeAuthorizationReplaceImport {
2
- export function replaceProviderImport(role: string, content: string): string {
2
+ export function replaceProviderImport(
3
+ actor: string,
4
+ content: string,
5
+ ): string {
3
6
  let updatedContent = content;
4
7
 
5
- const roleCapitalized =
6
- role.charAt(0).toUpperCase() + role.slice(1).toLowerCase();
8
+ const actorCapitalized =
9
+ actor.charAt(0).toUpperCase() + actor.slice(1).toLowerCase();
7
10
 
8
11
  const nestjsCommonPattern =
9
12
  /import\s+{\s*[^}]*\s*}\s+from\s+"@nestjs\/common";/g;
@@ -19,7 +22,7 @@ export namespace AutoBeRealizeAuthorizationReplaceImport {
19
22
  'import { jwtAuthorize } from "./jwtAuthorize";';
20
23
 
21
24
  const payloadPattern = /import\s+{\s*\w*Payload\s*}\s+from\s+[^;]+;/g;
22
- const payloadReplacement = `import { ${roleCapitalized}Payload } from "../../decorators/payload/${roleCapitalized}Payload";`;
25
+ const payloadReplacement = `import { ${actorCapitalized}Payload } from "../../decorators/payload/${actorCapitalized}Payload";`;
23
26
 
24
27
  // 각 패턴을 순차적으로 적용
25
28
  updatedContent = updatedContent.replace(
@@ -40,18 +43,18 @@ export namespace AutoBeRealizeAuthorizationReplaceImport {
40
43
  }
41
44
 
42
45
  export function replaceDecoratorImport(
43
- role: string,
46
+ actor: string,
44
47
  content: string,
45
48
  ): string {
46
49
  let updatedContent = content;
47
50
 
48
- const roleLowercase = role.toLowerCase();
51
+ const actorLowercase = actor.toLowerCase();
49
52
 
50
53
  // ~Authorize로 끝나는 import 구문을 특정 경로로 변경하는 정규표현식
51
54
  const authorizePattern = /import\s+{\s*\w*Authorize\s*}\s+from\s+[^;]+;/g;
52
55
 
53
56
  // role을 기반으로 동적으로 replacement 생성
54
- const authorizeReplacement = `import { ${roleLowercase}Authorize } from "../providers/authorize/${roleLowercase}Authorize";`;
57
+ const authorizeReplacement = `import { ${actorLowercase}Authorize } from "../providers/authorize/${actorLowercase}Authorize";`;
55
58
 
56
59
  // 패턴 적용
57
60
  updatedContent = updatedContent.replace(
@@ -34,7 +34,7 @@ export function generateRealizeScenario<Model extends ILlmSchema.Model>(
34
34
  authorizations: AutoBeRealizeAuthorization[],
35
35
  ): IAutoBeRealizeScenarioResult {
36
36
  const authorization = authorizations.find(
37
- (el) => el.role.name === operation.authorizationRole,
37
+ (el) => el.actor.name === operation.authorizationActor,
38
38
  );
39
39
 
40
40
  const testFiles: AutoBeTestFile[] =
@@ -42,9 +42,9 @@ export function getRealizeWriteCodeTemplate(props: {
42
42
  const functionParameters: string[] = [];
43
43
 
44
44
  // Add authentication parameter if needed (e.g., user: IUser, admin: IAdmin)
45
- if (props.authorization && props.authorization.role.name) {
45
+ if (props.authorization && props.authorization.actor.name) {
46
46
  // Debug: Log the values to check what's being used
47
- const authParameter = `${props.authorization.role.name}: ${props.authorization.payload.name}`;
47
+ const authParameter = `${props.authorization.actor.name}: ${props.authorization.payload.name}`;
48
48
  functionParameters.push(authParameter);
49
49
  }
50
50
 
@@ -37,7 +37,7 @@ function filterDocument(
37
37
  document: AutoBeOpenApi.IDocument,
38
38
  ): AutoBeOpenApi.IDocument {
39
39
  const components: AutoBeOpenApi.IComponents = {
40
- authorization: document.components.authorization,
40
+ authorizations: document.components.authorizations,
41
41
  schemas: {},
42
42
  };
43
43
 
@@ -36,9 +36,9 @@ export function getRealizeWriteInputType(
36
36
  const functionParameterFields: string[] = [];
37
37
 
38
38
  // Add authentication field (user/admin/member) if endpoint requires auth
39
- const hasAuthentication = authorization && operation.authorizationRole;
39
+ const hasAuthentication = authorization && operation.authorizationActor;
40
40
  if (hasAuthentication) {
41
- const authFieldName = operation.authorizationRole;
41
+ const authFieldName = operation.authorizationActor;
42
42
  const authFieldType = authorization.payload.name;
43
43
  functionParameterFields.push(`${authFieldName}: ${authFieldType};`);
44
44
  }
@@ -51,5 +51,5 @@ export function printErrorHints(
51
51
  \`\`\`
52
52
  `;
53
53
  })
54
- .join("\n");
54
+ .join("\n\n");
55
55
  }
@@ -4,96 +4,6 @@ import { ILlmSchema } from "@samchon/openapi";
4
4
  import { AutoBeContext } from "../../../context/AutoBeContext";
5
5
  import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
6
6
 
7
- // /**
8
- // * Removes all import statements that LLM might have incorrectly added. This
9
- // * includes standard library imports, auto-injected imports, and any API
10
- // * structure imports with wrong paths.
11
- // *
12
- // * @param code - The code containing imports to remove
13
- // * @param typeReferences - List of type names to specifically remove
14
- // * @param decoratorType - Optional decorator type to remove
15
- // * @returns Code with all imports removed
16
- // */
17
- // function removeAllImports(
18
- // code: string,
19
- // typeReferences: string[],
20
- // decoratorType?: string,
21
- // ): string {
22
- // // Remove standard library and auto-injected imports
23
- // let cleanedCode = code
24
- // // MyGlobal - often with wrong path
25
- // .replace(
26
- // /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
27
- // "",
28
- // )
29
- // // typia - various import patterns
30
- // .replace(
31
- // /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
32
- // "",
33
- // )
34
- // .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
35
- // .replace(
36
- // /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
37
- // "",
38
- // )
39
- // .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
40
- // // Prisma client
41
- // .replace(
42
- // /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
43
- // "",
44
- // )
45
- // // uuid
46
- // .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
47
- // // toISOStringSafe utility
48
- // .replace(
49
- // /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/utils\/toISOStringSafe["']\s*;?\s*/gm,
50
- // "",
51
- // )
52
- // // JWT imports (if LLM adds them)
53
- // .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
54
- // .replace(
55
- // /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
56
- // "",
57
- // )
58
- // // NestJS HttpException
59
- // .replace(
60
- // /import\s*{\s*HttpException\s*}\s*from\s*["']@nestjs\/common["']\s*;?\s*/gm,
61
- // "",
62
- // );
63
-
64
- // // Remove API structure imports with wrong paths
65
- // // Pattern 1: ../api/structures path (LLM often uses this wrong path)
66
- // cleanedCode = cleanedCode.replace(
67
- // /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
68
- // "",
69
- // );
70
- // // Pattern 2: @ORGANIZATION/PROJECT-api path (correct path but LLM shouldn't write it)
71
- // cleanedCode = cleanedCode.replace(
72
- // /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
73
- // "",
74
- // );
75
-
76
- // // Remove specific type imports that match our typeReferences
77
- // for (const ref of typeReferences) {
78
- // const typeImportRegex = new RegExp(
79
- // `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
80
- // "gm",
81
- // );
82
- // cleanedCode = cleanedCode.replace(typeImportRegex, "");
83
- // }
84
-
85
- // // Remove decorator type imports if LLM mistakenly added them
86
- // if (decoratorType) {
87
- // const decoratorTypeRegex = new RegExp(
88
- // `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
89
- // "gm",
90
- // );
91
- // cleanedCode = cleanedCode.replace(decoratorTypeRegex, "");
92
- // }
93
-
94
- // return cleanedCode;
95
- // }
96
-
97
7
  export async function replaceImportStatements<Model extends ILlmSchema.Model>(
98
8
  ctx: AutoBeContext<Model>,
99
9
  props: {
@@ -57,7 +57,7 @@ function filterDocument(
57
57
  ),
58
58
  );
59
59
  const components: AutoBeOpenApi.IComponents = {
60
- authorization: document.components.authorization,
60
+ authorizations: document.components.authorizations,
61
61
  schemas: {},
62
62
  };
63
63
  const visit = (typeName: string) => {
@@ -1,10 +1,10 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
- import { StringUtil } from "@autobe/utils";
3
2
  import { ILlmSchema } from "@samchon/openapi";
4
3
  import { v7 } from "uuid";
5
4
 
6
5
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
7
6
  import { AutoBeContext } from "../../../context/AutoBeContext";
7
+ import { transformPreviousAndLatestCorrectHistories } from "../../common/histories/transformPreviousAndLatestCorrectHistories";
8
8
  import { IAutoBeTestFunction } from "../structures/IAutoBeTestFunction";
9
9
  import { IAutoBeTestFunctionFailure } from "../structures/IAutoBeTestFunctionFailure";
10
10
  import { transformTestWriteHistories } from "./transformTestWriteHistories";
@@ -39,29 +39,11 @@ export const transformTestCorrectHistories = async <
39
39
  text: AutoBeSystemPromptConstant.TEST_CORRECT,
40
40
  },
41
41
  previous.at(-1)!,
42
- ...props.failures.map(
43
- (f, i, array) =>
44
- ({
45
- id: v7(),
46
- created_at: new Date().toISOString(),
47
- type: "assistantMessage",
48
- text: StringUtil.trim`
49
- ## ${i === array.length - 1 ? "Latest Failure" : "Previous Failure"}
50
- ### Generated TypeScript Code
51
-
52
- \`\`\`typescript
53
- ${f.function.script}
54
- \`\`\`
55
-
56
- ### Compile Errors
57
-
58
- Fix the compilation error in the provided code.
59
-
60
- \`\`\`json
61
- ${JSON.stringify(f.failure.diagnostics)}
62
- \`\`\`
63
- `,
64
- }) satisfies IAgenticaHistoryJson.IAssistantMessage,
42
+ ...transformPreviousAndLatestCorrectHistories(
43
+ props.failures.map((f) => ({
44
+ script: f.function.script,
45
+ diagnostics: f.failure.diagnostics,
46
+ })),
65
47
  ),
66
48
  ];
67
49
  };
@@ -23,17 +23,17 @@ export const transformTestCorrectInvalidRequestHistories = (
23
23
  created_at: new Date().toISOString(),
24
24
  type: "assistantMessage",
25
25
  text: StringUtil.trim`
26
- ## TypeScript Code
27
-
28
- \`\`\`typescript
29
- ${func.script}
30
- \`\`\`
26
+ ## TypeScript Code
27
+
28
+ \`\`\`typescript
29
+ ${func.script}
30
+ \`\`\`
31
31
 
32
- ## Compile Errors
32
+ ## Compile Errors
33
33
 
34
- \`\`\`json
35
- ${JSON.stringify(diagnostics)}
36
- \`\`\`
37
- `,
34
+ \`\`\`json
35
+ ${JSON.stringify(diagnostics)}
36
+ \`\`\`
37
+ `,
38
38
  },
39
39
  ];