@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
@@ -0,0 +1,270 @@
1
+ import { IAgenticaController } from "@agentica/core";
2
+ import {
3
+ AutoBeInterfaceSchemaRefactor,
4
+ AutoBeInterfaceSchemaRenameEvent,
5
+ AutoBeOpenApi,
6
+ AutoBeProgressEventBase,
7
+ } from "@autobe/interface";
8
+ import {
9
+ ILlmApplication,
10
+ ILlmSchema,
11
+ OpenApi,
12
+ OpenApiTypeChecker,
13
+ } from "@samchon/openapi";
14
+ import { IPointer } from "tstl";
15
+ import typia from "typia";
16
+ import { v7 } from "uuid";
17
+
18
+ import { AutoBeConfigConstant } from "../../constants/AutoBeConfigConstant";
19
+ import { AutoBeContext } from "../../context/AutoBeContext";
20
+ import { assertSchemaModel } from "../../context/assertSchemaModel";
21
+ import { divideArray } from "../../utils/divideArray";
22
+ import { executeCachedBatch } from "../../utils/executeCachedBatch";
23
+ import { transformInterfaceSchemaRenameHistories } from "./histories/transformInterfaceSchemaRenameHistories";
24
+ import { IAutoBeInterfaceSchemaRenameApplication } from "./structures/IAutoBeInterfaceSchemaRenameApplication";
25
+
26
+ export async function orchestrateInterfaceSchemaRename<
27
+ Mode extends ILlmSchema.Model,
28
+ >(
29
+ ctx: AutoBeContext<Mode>,
30
+ document: AutoBeOpenApi.IDocument,
31
+ capacity: number = AutoBeConfigConstant.INTERFACE_CAPACITY * 10,
32
+ ): Promise<void> {
33
+ const tableNames: string[] = ctx
34
+ .state()
35
+ .prisma!.result.data.files.map((f) => f.models)
36
+ .flat()
37
+ .map((m) => m.name)
38
+ .filter((m) => m.startsWith("mv_") === false);
39
+ const entireTypeNames: Set<string> = new Set();
40
+ for (let name of Object.keys(document.components.schemas)) {
41
+ if (name.startsWith("IPage")) name = name.replace("IPage", "");
42
+ name = name.split(".")[0];
43
+ entireTypeNames.add(name);
44
+ }
45
+
46
+ const matrix: string[][] = divideArray({
47
+ array: Array.from(entireTypeNames),
48
+ capacity,
49
+ });
50
+ const progress: AutoBeProgressEventBase = {
51
+ total: entireTypeNames.size,
52
+ completed: 0,
53
+ };
54
+ const refactors: AutoBeInterfaceSchemaRefactor[] = uniqueRefactors(
55
+ (
56
+ await executeCachedBatch(
57
+ matrix.map(
58
+ (typeNames) => (promptCacheKey) =>
59
+ divideAndConquer(ctx, {
60
+ tableNames,
61
+ typeNames,
62
+ promptCacheKey,
63
+ progress,
64
+ }),
65
+ ),
66
+ )
67
+ ).flat(),
68
+ );
69
+ orchestrateInterfaceSchemaRename.rename(document, refactors);
70
+ }
71
+ export namespace orchestrateInterfaceSchemaRename {
72
+ export const rename = (
73
+ document: AutoBeOpenApi.IDocument,
74
+ refactors: AutoBeInterfaceSchemaRefactor[],
75
+ ): void => {
76
+ // REPLACE RULE
77
+ const replace = (typeName: string): string | null => {
78
+ // exact match
79
+ const exact: AutoBeInterfaceSchemaRefactor | undefined = refactors.find(
80
+ (r) => r.from === typeName,
81
+ );
82
+ if (exact !== undefined) return exact.to;
83
+
84
+ // T.X match
85
+ const prefix: AutoBeInterfaceSchemaRefactor | undefined = refactors.find(
86
+ (r) => typeName.startsWith(`${r.from}.`),
87
+ );
88
+ if (prefix !== undefined)
89
+ return typeName.replace(`${prefix.from}.`, `${prefix.to}.`);
90
+
91
+ // IPageT exact match
92
+ const pageExact: AutoBeInterfaceSchemaRefactor | undefined =
93
+ refactors.find((r) => typeName === `IPage${r.from}`);
94
+ if (pageExact !== undefined) return `IPage${pageExact.to}`;
95
+
96
+ // IPageT.X match
97
+ const pagePrefix: AutoBeInterfaceSchemaRefactor | undefined =
98
+ refactors.find((r) => typeName.startsWith(`IPage${r.from}.`));
99
+ if (pagePrefix !== undefined)
100
+ return typeName.replace(
101
+ `IPage${pagePrefix.from}.`,
102
+ `IPage${pagePrefix.to}.`,
103
+ );
104
+ return null;
105
+ };
106
+
107
+ // JSON SCHEMA REFERENCES
108
+ const $refChangers: Map<OpenApi.IJsonSchema, () => void> = new Map();
109
+ for (const value of Object.values(document.components.schemas))
110
+ OpenApiTypeChecker.visit({
111
+ components: document.components,
112
+ schema: value,
113
+ closure: (schema) => {
114
+ if (OpenApiTypeChecker.isReference(schema) === false) return;
115
+ const x: string = schema.$ref.split("/").pop()!;
116
+ const y: string | null = replace(x);
117
+ if (y !== null)
118
+ $refChangers.set(schema, () => {
119
+ schema.$ref = `#/components/schemas/${y}`;
120
+ });
121
+ },
122
+ });
123
+ for (const fn of $refChangers.values()) fn();
124
+
125
+ // COMPONENT SCHEMAS
126
+ for (const x of Object.keys(document.components.schemas)) {
127
+ const y: string | null = replace(x);
128
+ if (y !== null) {
129
+ document.components.schemas[y] = document.components.schemas[x];
130
+ delete document.components.schemas[x];
131
+ }
132
+ }
133
+
134
+ // OPERATIONS
135
+ for (const op of document.operations) {
136
+ if (op.requestBody)
137
+ op.requestBody.typeName =
138
+ replace(op.requestBody.typeName) ?? op.requestBody.typeName;
139
+ if (op.responseBody)
140
+ op.responseBody.typeName =
141
+ replace(op.responseBody.typeName) ?? op.responseBody.typeName;
142
+ }
143
+ };
144
+ }
145
+
146
+ const divideAndConquer = async <Model extends ILlmSchema.Model>(
147
+ ctx: AutoBeContext<Model>,
148
+ props: {
149
+ tableNames: string[];
150
+ typeNames: string[];
151
+ promptCacheKey: string;
152
+ progress: AutoBeProgressEventBase;
153
+ },
154
+ ): Promise<AutoBeInterfaceSchemaRefactor[]> => {
155
+ try {
156
+ const pointer: IPointer<IAutoBeInterfaceSchemaRenameApplication.IProps | null> =
157
+ {
158
+ value: null,
159
+ };
160
+ const { metric, tokenUsage } = await ctx.conversate({
161
+ source: "interfaceSchemaRename",
162
+ controller: createController<Model>(
163
+ ctx.model,
164
+ (value) => (pointer.value = value),
165
+ ),
166
+ histories: transformInterfaceSchemaRenameHistories(props),
167
+ enforceFunctionCall: true,
168
+ promptCacheKey: props.promptCacheKey,
169
+ message: "Rename DTO type names for consistency and clarity.",
170
+ });
171
+ if (pointer.value === null) {
172
+ props.progress.completed += props.typeNames.length;
173
+ return [];
174
+ }
175
+
176
+ pointer.value.refactors = uniqueRefactors(pointer.value.refactors);
177
+ ctx.dispatch({
178
+ type: "interfaceSchemaRename",
179
+ id: v7(),
180
+ refactors: pointer.value.refactors,
181
+ total: props.progress.total,
182
+ completed: (props.progress.completed += props.typeNames.length),
183
+ metric,
184
+ tokenUsage,
185
+ created_at: new Date().toISOString(),
186
+ } satisfies AutoBeInterfaceSchemaRenameEvent);
187
+ return pointer.value.refactors;
188
+ } catch {
189
+ props.progress.completed += props.typeNames.length;
190
+ return [];
191
+ }
192
+ };
193
+
194
+ const uniqueRefactors = (
195
+ refactors: AutoBeInterfaceSchemaRefactor[],
196
+ ): AutoBeInterfaceSchemaRefactor[] => {
197
+ // Remove self-references (A->A)
198
+ refactors = refactors.filter((r) => r.from !== r.to);
199
+
200
+ // Remove duplicates (keep the first occurrence)
201
+ refactors = Array.from(new Map(refactors.map((r) => [r.from, r])).values());
202
+
203
+ // Build adjacency map: from -> to
204
+ const renameMap: Map<string, string> = new Map();
205
+ for (const r of refactors) {
206
+ renameMap.set(r.from, r.to);
207
+ }
208
+
209
+ // Resolve transitive chains: A->B, B->C becomes A->C
210
+ const resolveChain = (from: string): string => {
211
+ const visited: Set<string> = new Set();
212
+ let current: string = from;
213
+
214
+ while (renameMap.has(current)) {
215
+ // Cycle detection: A->B, B->C, C->A
216
+ if (visited.has(current)) {
217
+ // Cycle detected, keep the last valid mapping before cycle
218
+ return current;
219
+ }
220
+ visited.add(current);
221
+ current = renameMap.get(current)!;
222
+ }
223
+ return current;
224
+ };
225
+
226
+ // Build final refactor list with resolved chains
227
+ const resolved: Map<string, AutoBeInterfaceSchemaRefactor> = new Map();
228
+ for (const from of renameMap.keys()) {
229
+ const finalTo: string = resolveChain(from);
230
+ // Only include if actually changes
231
+ if (from !== finalTo) {
232
+ resolved.set(from, {
233
+ from,
234
+ to: finalTo,
235
+ });
236
+ }
237
+ }
238
+ return Array.from(resolved.values());
239
+ };
240
+
241
+ const createController = <Model extends ILlmSchema.Model>(
242
+ model: Model,
243
+ build: (value: IAutoBeInterfaceSchemaRenameApplication.IProps) => void,
244
+ ): IAgenticaController.IClass<Model> => {
245
+ assertSchemaModel(model);
246
+ const application: ILlmApplication<Model> = collection[
247
+ model === "chatgpt" ? "chatgpt" : "claude"
248
+ ] satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
249
+ return {
250
+ protocol: "class",
251
+ name: "SchemaRenamer",
252
+ application,
253
+ execute: {
254
+ rename: (props) => {
255
+ build(props);
256
+ },
257
+ } satisfies IAutoBeInterfaceSchemaRenameApplication,
258
+ };
259
+ };
260
+
261
+ const collection = {
262
+ chatgpt: typia.llm.application<
263
+ IAutoBeInterfaceSchemaRenameApplication,
264
+ "chatgpt"
265
+ >(),
266
+ claude: typia.llm.application<
267
+ IAutoBeInterfaceSchemaRenameApplication,
268
+ "claude"
269
+ >(),
270
+ };
@@ -1,9 +1,6 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
- import {
3
- AutoBeInterfaceSchemasReviewEvent,
4
- AutoBeOpenApi,
5
- AutoBeProgressEventBase,
6
- } from "@autobe/interface";
2
+ import { AutoBeOpenApi, AutoBeProgressEventBase } from "@autobe/interface";
3
+ import { AutoBeInterfaceSchemaReviewEvent } from "@autobe/interface/src/events/AutoBeInterfaceSchemaReviewEvent";
7
4
  import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
8
5
  import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
9
6
  import { IPointer } from "tstl";
@@ -15,44 +12,62 @@ import { AutoBeContext } from "../../context/AutoBeContext";
15
12
  import { assertSchemaModel } from "../../context/assertSchemaModel";
16
13
  import { divideArray } from "../../utils/divideArray";
17
14
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
18
- import { transformInterfaceSchemasReviewHistories } from "./histories/transformInterfaceSchemasReviewHistories";
19
- import { IAutoBeInterfaceSchemasReviewApplication } from "./structures/IAutobeInterfaceSchemasReviewApplication";
15
+ import { transformInterfaceSchemaReviewHistories } from "./histories/transformInterfaceSchemaReviewHistories";
16
+ import { IAutoBeInterfaceSchemaContentReviewApplication } from "./structures/IAutoBeInterfaceSchemaContentReviewApplication";
20
17
  import { JsonSchemaFactory } from "./utils/JsonSchemaFactory";
21
18
  import { JsonSchemaNamingConvention } from "./utils/JsonSchemaNamingConvention";
22
19
  import { JsonSchemaValidator } from "./utils/JsonSchemaValidator";
23
20
  import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
24
21
 
25
- export async function orchestrateInterfaceSchemasReview<
22
+ interface IConfig {
23
+ kind: AutoBeInterfaceSchemaReviewEvent["kind"];
24
+ systemPrompt: string;
25
+ }
26
+
27
+ export async function orchestrateInterfaceSchemaReview<
26
28
  Model extends ILlmSchema.Model,
27
29
  >(
28
30
  ctx: AutoBeContext<Model>,
29
- operations: AutoBeOpenApi.IOperation[],
30
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
31
- capacity: number = AutoBeConfigConstant.INTERFACE_CAPACITY,
31
+ config: IConfig,
32
+ props: {
33
+ document: AutoBeOpenApi.IDocument;
34
+ instruction: string;
35
+ progress: AutoBeProgressEventBase;
36
+ },
32
37
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
33
- const a = Object.entries(schemas).map(([key, schema]) => {
34
- return { [key]: schema };
38
+ const typeNames: string[] = Object.keys(props.document.components.schemas);
39
+ const matrix: string[][] = divideArray({
40
+ array: typeNames,
41
+ capacity: AutoBeConfigConstant.INTERFACE_CAPACITY,
35
42
  });
36
-
37
- const matrix: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>[][] =
38
- divideArray({
39
- array: a,
40
- capacity,
41
- });
42
- const progress: IProgress = {
43
- total: matrix.length,
44
- completed: 0,
45
- };
46
-
47
43
  const x: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
48
44
  for (const y of await executeCachedBatch(
49
45
  matrix.map((it) => async (promptCacheKey) => {
46
+ const operations: AutoBeOpenApi.IOperation[] =
47
+ props.document.operations.filter(
48
+ (op) =>
49
+ (op.requestBody && it.includes(op.requestBody.typeName)) ||
50
+ (op.responseBody && it.includes(op.responseBody.typeName)),
51
+ );
50
52
  const row: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
51
- await divideAndConquer(ctx, operations, it, progress, promptCacheKey);
53
+ await divideAndConquer(ctx, config, {
54
+ instruction: props.instruction,
55
+ operations,
56
+ everySchemas: props.document.components.schemas,
57
+ reviewSchemas: it.reduce(
58
+ (acc, cur) => {
59
+ acc[cur] = props.document.components.schemas[cur];
60
+ return acc;
61
+ },
62
+ {} as Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
63
+ ),
64
+ progress: props.progress,
65
+ promptCacheKey,
66
+ });
52
67
  return row;
53
68
  }),
54
69
  )) {
55
- JsonSchemaNamingConvention.schemas(operations, x, y);
70
+ JsonSchemaNamingConvention.schemas(props.document.operations, x, y);
56
71
  Object.assign(x, y);
57
72
  }
58
73
  return x;
@@ -60,46 +75,41 @@ export async function orchestrateInterfaceSchemasReview<
60
75
 
61
76
  async function divideAndConquer<Model extends ILlmSchema.Model>(
62
77
  ctx: AutoBeContext<Model>,
63
- operations: AutoBeOpenApi.IOperation[],
64
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>[],
65
- progress: AutoBeProgressEventBase,
66
- promptCacheKey: string,
67
- ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
68
- const schema = schemas.reduce((acc, cur) => Object.assign(acc, cur), {});
69
- return step(ctx, operations, schema, progress, promptCacheKey);
70
- }
71
-
72
- export async function step<Model extends ILlmSchema.Model>(
73
- ctx: AutoBeContext<Model>,
74
- operations: AutoBeOpenApi.IOperation[],
75
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
76
- progress: AutoBeProgressEventBase,
77
- promptCacheKey: string,
78
+ config: IConfig,
79
+ props: {
80
+ instruction: string;
81
+ operations: AutoBeOpenApi.IOperation[];
82
+ everySchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
83
+ reviewSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
84
+ progress: AutoBeProgressEventBase;
85
+ promptCacheKey: string;
86
+ },
78
87
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
79
88
  try {
80
- const pointer: IPointer<IAutoBeInterfaceSchemasReviewApplication.IProps | null> =
89
+ const pointer: IPointer<IAutoBeInterfaceSchemaContentReviewApplication.IProps | null> =
81
90
  {
82
91
  value: null,
83
92
  };
84
- const { tokenUsage } = await ctx.conversate({
85
- source: "interfaceSchemasReview",
93
+ const { metric, tokenUsage } = await ctx.conversate({
94
+ source: "interfaceSchemaReview",
86
95
  controller: createController({
87
96
  model: ctx.model,
88
97
  pointer,
89
- operations,
90
- schemas,
91
98
  }),
92
- histories: transformInterfaceSchemasReviewHistories(
93
- ctx.state(),
94
- operations,
95
- schemas,
96
- ),
99
+ histories: transformInterfaceSchemaReviewHistories({
100
+ state: ctx.state(),
101
+ systemPrompt: config.systemPrompt,
102
+ instruction: props.instruction,
103
+ operations: props.operations,
104
+ everySchemas: props.everySchemas,
105
+ reviewSchemas: props.reviewSchemas,
106
+ }),
97
107
  enforceFunctionCall: true,
98
- promptCacheKey,
99
- message: "Review type schemas.",
108
+ promptCacheKey: props.promptCacheKey,
109
+ message: "Review DTO content completeness and consistency.",
100
110
  });
101
111
  if (pointer.value === null) {
102
- ++progress.completed;
112
+ ++props.progress.completed;
103
113
  return {};
104
114
  }
105
115
 
@@ -110,40 +120,42 @@ export async function step<Model extends ILlmSchema.Model>(
110
120
  ).schemas ?? {}) as Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
111
121
 
112
122
  ctx.dispatch({
113
- type: "interfaceSchemasReview",
123
+ type: "interfaceSchemaReview",
124
+ kind: config.kind,
114
125
  id: v7(),
115
- schemas: schemas,
126
+ schemas: props.reviewSchemas,
116
127
  review: pointer.value.think.review,
117
128
  plan: pointer.value.think.plan,
118
129
  content,
130
+ metric,
119
131
  tokenUsage,
120
132
  step: ctx.state().analyze?.step ?? 0,
121
- total: progress.total,
122
- completed: ++progress.completed,
133
+ total: props.progress.total,
134
+ completed: ++props.progress.completed,
123
135
  created_at: new Date().toISOString(),
124
- } satisfies AutoBeInterfaceSchemasReviewEvent);
136
+ });
125
137
  return content;
126
138
  } catch {
127
- ++progress.completed;
139
+ ++props.progress.completed;
128
140
  return {};
129
141
  }
130
142
  }
131
143
 
132
144
  function createController<Model extends ILlmSchema.Model>(props: {
133
145
  model: Model;
134
- pointer: IPointer<IAutoBeInterfaceSchemasReviewApplication.IProps | null>;
135
- operations: AutoBeOpenApi.IOperation[];
136
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
146
+ pointer: IPointer<IAutoBeInterfaceSchemaContentReviewApplication.IProps | null>;
137
147
  }): IAgenticaController.IClass<Model> {
138
148
  assertSchemaModel(props.model);
139
149
 
140
150
  const validate = (
141
151
  next: unknown,
142
- ): IValidation<IAutoBeInterfaceSchemasReviewApplication.IProps> => {
152
+ ): IValidation<IAutoBeInterfaceSchemaContentReviewApplication.IProps> => {
143
153
  JsonSchemaFactory.fixPage("content", next);
144
154
 
145
- const result: IValidation<IAutoBeInterfaceSchemasReviewApplication.IProps> =
146
- typia.validate<IAutoBeInterfaceSchemasReviewApplication.IProps>(next);
155
+ const result: IValidation<IAutoBeInterfaceSchemaContentReviewApplication.IProps> =
156
+ typia.validate<IAutoBeInterfaceSchemaContentReviewApplication.IProps>(
157
+ next,
158
+ );
147
159
  if (result.success === false) {
148
160
  fulfillJsonSchemaErrorMessages(result.errors);
149
161
  return result;
@@ -171,25 +183,31 @@ function createController<Model extends ILlmSchema.Model>(props: {
171
183
  ) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
172
184
  return {
173
185
  protocol: "class",
174
- name: "Reviewer",
186
+ name: "ContentReviewer",
175
187
  application,
176
188
  execute: {
177
189
  review: (input) => {
178
190
  props.pointer.value = input;
179
191
  },
180
- } satisfies IAutoBeInterfaceSchemasReviewApplication,
192
+ } satisfies IAutoBeInterfaceSchemaContentReviewApplication,
181
193
  };
182
194
  }
183
195
 
184
196
  const collection = {
185
197
  chatgpt: (validate: Validator) =>
186
- typia.llm.application<IAutoBeInterfaceSchemasReviewApplication, "chatgpt">({
198
+ typia.llm.application<
199
+ IAutoBeInterfaceSchemaContentReviewApplication,
200
+ "chatgpt"
201
+ >({
187
202
  validate: {
188
203
  review: validate,
189
204
  },
190
205
  }),
191
206
  claude: (validate: Validator) =>
192
- typia.llm.application<IAutoBeInterfaceSchemasReviewApplication, "claude">({
207
+ typia.llm.application<
208
+ IAutoBeInterfaceSchemaContentReviewApplication,
209
+ "claude"
210
+ >({
193
211
  validate: {
194
212
  review: validate,
195
213
  },
@@ -198,9 +216,4 @@ const collection = {
198
216
 
199
217
  type Validator = (
200
218
  input: unknown,
201
- ) => IValidation<IAutoBeInterfaceSchemasReviewApplication.IProps>;
202
-
203
- export interface IProgress {
204
- total: number;
205
- completed: number;
206
- }
219
+ ) => IValidation<IAutoBeInterfaceSchemaContentReviewApplication.IProps>;
@@ -1,6 +1,6 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
2
  import {
3
- AutoBeInterfaceSchemasEvent,
3
+ AutoBeInterfaceSchemaEvent,
4
4
  AutoBeOpenApi,
5
5
  AutoBeProgressEventBase,
6
6
  } from "@autobe/interface";
@@ -59,13 +59,18 @@ export async function orchestrateInterfaceSchemas<
59
59
  };
60
60
  for (const y of await executeCachedBatch(
61
61
  matrix.map((it) => async (promptCacheKey) => {
62
+ const operations: AutoBeOpenApi.IOperation[] = props.operations.filter(
63
+ (op) =>
64
+ (op.requestBody && it.includes(op.requestBody.typeName)) ||
65
+ (op.responseBody && it.includes(op.responseBody.typeName)),
66
+ );
62
67
  const row: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
63
68
  await divideAndConquer(ctx, {
64
- instruction: props.instruction,
65
- operations: props.operations,
66
- typeNames: it,
69
+ operations,
67
70
  progress,
68
71
  promptCacheKey,
72
+ typeNames: it,
73
+ instruction: props.instruction,
69
74
  });
70
75
  return row;
71
76
  }),
@@ -128,10 +133,13 @@ async function process<Model extends ILlmSchema.Model>(
128
133
  > | null> = {
129
134
  value: null,
130
135
  };
131
- const { tokenUsage } = await ctx.conversate({
132
- source: "interfaceSchemas",
136
+ const { metric, tokenUsage } = await ctx.conversate({
137
+ source: "interfaceSchema",
133
138
  histories: transformInterfaceSchemaHistories({
134
139
  state: ctx.state(),
140
+ typeNames: Array.from(
141
+ new Set([...props.remained, ...Object.keys(props.oldbie)]),
142
+ ),
135
143
  operations: props.operations,
136
144
  instruction: props.instruction,
137
145
  }),
@@ -154,7 +162,7 @@ async function process<Model extends ILlmSchema.Model>(
154
162
  too.
155
163
 
156
164
  ${Array.from(props.remained)
157
- .map((k) => ` - \`${k}\``)
165
+ .map((k) => `- \`${k}\``)
158
166
  .join("\n")}${
159
167
  already.length !== 0
160
168
  ? StringUtil.trim`
@@ -176,9 +184,10 @@ async function process<Model extends ILlmSchema.Model>(
176
184
  }) as AutoBeOpenApi.IComponents
177
185
  ).schemas ?? {}) as Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
178
186
  ctx.dispatch({
179
- type: "interfaceSchemas",
187
+ type: "interfaceSchema",
180
188
  id: v7(),
181
189
  schemas,
190
+ metric,
182
191
  tokenUsage,
183
192
  completed: (props.progress.completed += Object.keys(schemas).length),
184
193
  total: (props.progress.total += Object.keys(schemas).filter(
@@ -186,7 +195,7 @@ async function process<Model extends ILlmSchema.Model>(
186
195
  ).length),
187
196
  step: ctx.state().prisma?.step ?? 0,
188
197
  created_at: new Date().toISOString(),
189
- } satisfies AutoBeInterfaceSchemasEvent);
198
+ } satisfies AutoBeInterfaceSchemaEvent);
190
199
  return schemas;
191
200
  }
192
201