@autobe/agent 0.18.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/lib/AutoBeMockAgent.d.ts +2 -10
  2. package/lib/agent/src/AutoBeAgent.js +5 -0
  3. package/lib/agent/src/AutoBeAgent.js.map +1 -1
  4. package/lib/agent/src/AutoBeMockAgent.d.ts +2 -10
  5. package/lib/agent/src/AutoBeMockAgent.js +7 -2
  6. package/lib/agent/src/AutoBeMockAgent.js.map +1 -1
  7. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +23 -29
  8. package/lib/agent/src/constants/AutoBeSystemPromptConstant.js.map +1 -1
  9. package/lib/agent/src/context/AutoBeTokenUsageComponent.d.ts +1 -0
  10. package/lib/agent/src/context/AutoBeTokenUsageComponent.js +14 -0
  11. package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
  12. package/lib/agent/src/factory/consentFunctionCall.d.ts +10 -0
  13. package/lib/agent/src/factory/consentFunctionCall.js +212 -0
  14. package/lib/agent/src/factory/consentFunctionCall.js.map +1 -0
  15. package/lib/agent/src/factory/createAgenticaHistory.js +1 -0
  16. package/lib/agent/src/factory/createAgenticaHistory.js.map +1 -1
  17. package/lib/agent/src/factory/createAutoBeContext.js +71 -14
  18. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  19. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +3 -1
  20. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.js +4 -4
  21. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.js.map +1 -1
  22. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +1 -1
  23. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +3 -1
  24. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +16 -4
  25. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  26. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js +8 -3
  27. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  28. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +2 -3
  29. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +7 -7
  30. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js.map +1 -1
  31. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +24 -37
  32. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  33. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +5 -3
  34. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  35. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +16 -16
  36. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +5 -5
  37. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js +1 -0
  38. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  39. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +1 -1
  40. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  41. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  42. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  43. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +2 -10
  44. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  45. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  46. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  47. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  48. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  49. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +3 -3
  50. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  51. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  52. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  53. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +9 -3
  54. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  55. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +29 -9
  56. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
  57. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +2 -2
  58. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +1565 -1142
  59. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  60. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +22 -4
  61. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  62. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.d.ts +2 -2
  63. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js +11 -15
  64. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  65. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +32 -26
  66. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  67. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.d.ts +2 -3
  68. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +135 -124
  69. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  70. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +371 -209
  71. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  72. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +185 -179
  73. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  74. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +38 -0
  75. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +16 -16
  76. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +59 -14
  77. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +37 -1
  78. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +46 -14
  79. package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +18 -24
  80. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +7 -0
  81. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js +35 -0
  82. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +1 -0
  83. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +11 -17
  84. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  85. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  86. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  87. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  88. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  89. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  90. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  91. package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js +13 -4
  92. package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  93. package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -2
  94. package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js +6 -10
  95. package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  96. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +35 -2
  97. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  98. package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js +44 -3
  99. package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js.map +1 -1
  100. package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js +40 -3
  101. package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  102. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +2 -2
  103. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  104. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +5 -5
  105. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  106. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +1 -0
  107. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +2 -2
  108. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  109. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.d.ts +3 -0
  110. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +278 -0
  111. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js.map +1 -0
  112. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -2
  113. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +12 -20
  114. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  115. package/lib/agent/src/orchestrate/realize/internal/compile.d.ts +3 -3
  116. package/lib/agent/src/orchestrate/realize/internal/compile.js +9 -26
  117. package/lib/agent/src/orchestrate/realize/internal/compile.js.map +1 -1
  118. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +59 -42
  119. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
  120. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +6 -6
  121. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  122. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +6 -6
  123. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +8 -1
  124. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +17 -16
  125. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  126. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +6 -1
  127. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +24 -19
  128. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  129. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +3 -3
  130. package/lib/agent/src/orchestrate/realize/structures/{IAutoBeRealizeCoderApplication.js → IAutoBeRealizeCorrectApplication.js} +1 -1
  131. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.js.map +1 -0
  132. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +19 -16
  133. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +5 -1
  134. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  135. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  136. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  137. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.d.ts +2 -1
  138. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +95 -50
  139. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  140. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  141. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  142. package/lib/agent/src/orchestrate/test/orchestrateTest.js +12 -0
  143. package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
  144. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +4 -4
  145. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +119 -16
  146. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  147. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  148. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +6 -5
  149. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +1 -1
  150. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.d.ts +6 -0
  151. package/lib/agent/src/orchestrate/{internal/IProgress.js → test/structures/IAutoBeTestScenarioAuthorizationRole.js} +1 -1
  152. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.js.map +1 -0
  153. package/lib/agent/src/utils/predicateStateMessage.d.ts +4 -0
  154. package/lib/agent/src/utils/predicateStateMessage.js +87 -0
  155. package/lib/agent/src/utils/predicateStateMessage.js.map +1 -0
  156. package/lib/constants/AutoBeSystemPromptConstant.d.ts +23 -29
  157. package/lib/context/AutoBeTokenUsageComponent.d.ts +1 -0
  158. package/lib/factory/consentFunctionCall.d.ts +10 -0
  159. package/lib/index.mjs +3036 -1648
  160. package/lib/index.mjs.map +1 -1
  161. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +3 -1
  162. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +3 -1
  163. package/lib/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +2 -3
  164. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +16 -16
  165. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +5 -5
  166. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +2 -2
  167. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +2 -2
  168. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.d.ts +2 -3
  169. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +38 -0
  170. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +16 -16
  171. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +59 -14
  172. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +37 -1
  173. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +46 -14
  174. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +18 -24
  175. package/lib/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +7 -0
  176. package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -2
  177. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +1 -0
  178. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.d.ts +3 -0
  179. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -2
  180. package/lib/orchestrate/realize/internal/compile.d.ts +3 -3
  181. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +8 -1
  182. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +6 -1
  183. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +3 -3
  184. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +19 -16
  185. package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +2 -1
  186. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +6 -5
  187. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +1 -1
  188. package/lib/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.d.ts +6 -0
  189. package/lib/utils/predicateStateMessage.d.ts +4 -0
  190. package/package.json +6 -6
  191. package/src/AutoBeAgent.ts +14 -0
  192. package/src/AutoBeMockAgent.ts +9 -11
  193. package/src/constants/AutoBeSystemPromptConstant.ts +23 -29
  194. package/src/context/AutoBeTokenUsageComponent.ts +20 -0
  195. package/src/factory/consentFunctionCall.ts +128 -0
  196. package/src/factory/createAgenticaHistory.ts +1 -0
  197. package/src/factory/createAutoBeContext.ts +99 -14
  198. package/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.ts +11 -4
  199. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +26 -4
  200. package/src/orchestrate/analyze/orchestrateAnalyze.ts +19 -14
  201. package/src/orchestrate/analyze/orchestrateAnalyzeReview.ts +3 -3
  202. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +8 -32
  203. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +5 -3
  204. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +16 -16
  205. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +5 -5
  206. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +1 -0
  207. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +0 -10
  208. package/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.ts +1 -1
  209. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +9 -3
  210. package/src/orchestrate/interface/orchestrateInterface.ts +51 -12
  211. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +126 -23
  212. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +6 -19
  213. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +32 -27
  214. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +49 -32
  215. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +127 -33
  216. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +67 -65
  217. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +39 -0
  218. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +16 -16
  219. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +62 -14
  220. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +38 -1
  221. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +47 -14
  222. package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +18 -24
  223. package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +41 -0
  224. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +9 -16
  225. package/src/orchestrate/prisma/orchestratePrisma.ts +15 -6
  226. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +6 -19
  227. package/src/orchestrate/prisma/orchestratePrismaReview.ts +15 -9
  228. package/src/orchestrate/realize/histories/transformRealizeAuthorization.ts +1 -1
  229. package/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts +19 -23
  230. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +4 -2
  231. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +285 -0
  232. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +27 -27
  233. package/src/orchestrate/realize/internal/compile.ts +28 -45
  234. package/src/orchestrate/realize/orchestrateRealize.ts +71 -67
  235. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +3 -3
  236. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +19 -15
  237. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +23 -15
  238. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +3 -3
  239. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +19 -16
  240. package/src/orchestrate/realize/utils/replaceImportStatements.ts +7 -0
  241. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +110 -59
  242. package/src/orchestrate/test/orchestrateTest.ts +12 -0
  243. package/src/orchestrate/test/orchestrateTestScenario.ts +155 -19
  244. package/src/orchestrate/test/orchestrateTestWrite.ts +3 -3
  245. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +6 -5
  246. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +1 -1
  247. package/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.ts +7 -0
  248. package/src/utils/predicateStateMessage.ts +107 -0
  249. package/lib/agent/src/orchestrate/internal/IProgress.d.ts +0 -4
  250. package/lib/agent/src/orchestrate/internal/IProgress.js.map +0 -1
  251. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCoderHistories.d.ts +0 -7
  252. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCoderHistories.js +0 -213
  253. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCoderHistories.js.map +0 -1
  254. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +0 -345
  255. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +0 -1
  256. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +0 -56
  257. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCompile.js +0 -3
  258. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCompile.js.map +0 -1
  259. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.d.ts +0 -2
  260. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.js +0 -5
  261. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.js.map +0 -1
  262. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeReviewApplication.js +0 -3
  263. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeReviewApplication.js.map +0 -1
  264. package/lib/agent/src/utils/pipe.d.ts +0 -5
  265. package/lib/agent/src/utils/pipe.js +0 -14
  266. package/lib/agent/src/utils/pipe.js.map +0 -1
  267. package/lib/orchestrate/internal/IProgress.d.ts +0 -4
  268. package/lib/orchestrate/realize/histories/transformRealizeCoderHistories.d.ts +0 -7
  269. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +0 -345
  270. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +0 -56
  271. package/lib/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.d.ts +0 -2
  272. package/lib/utils/pipe.d.ts +0 -5
  273. package/src/orchestrate/internal/IProgress.ts +0 -4
  274. package/src/orchestrate/realize/histories/transformRealizeCoderHistories.ts +0 -248
  275. package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +0 -358
  276. package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +0 -70
  277. package/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.ts +0 -2
  278. package/src/utils/pipe.ts +0 -39
  279. /package/lib/agent/src/orchestrate/realize/structures/{IAutoBeRealizeReviewApplication.d.ts → IAutoBeRealizeCorrectApplication.d.ts} +0 -0
  280. /package/lib/orchestrate/realize/structures/{IAutoBeRealizeReviewApplication.d.ts → IAutoBeRealizeCorrectApplication.d.ts} +0 -0
  281. /package/src/orchestrate/realize/structures/{IAutoBeRealizeReviewApplication.ts → IAutoBeRealizeCorrectApplication.ts} +0 -0
@@ -1,5 +1,6 @@
1
1
  import { AutoBeAnalyzeRole, CamelPattern } from "@autobe/interface";
2
2
  import { AutoBeAnalyzeFile } from "@autobe/interface/src/histories/contents/AutoBeAnalyzeFile";
3
+ import { tags } from "typia";
3
4
 
4
5
  export interface IAutoBeAnalyzeScenarioApplication {
5
6
  /**
@@ -28,7 +29,7 @@ export namespace IAutoBeAnalyzeScenarioApplication {
28
29
  * Prefix for file names and variable names. This will be used for
29
30
  * organizing documentation files.
30
31
  *
31
- * MUST use camelCase naming convention.
32
+ * DO: Use camelCase naming convention.
32
33
  */
33
34
  prefix: string & CamelPattern;
34
35
 
@@ -64,9 +65,8 @@ export namespace IAutoBeAnalyzeScenarioApplication {
64
65
  * - Service overview and business model description
65
66
  * - User roles and permission requirements (described in natural language)
66
67
  * - Business logic and validation rules
67
- * - STRICTLY PROHIBITED: Do NOT include database schemas, ERD, or API
68
- * specifications
69
- * - All requirements must be written in natural language for clarity
68
+ * - DO NOT: Include database schemas, ERD, or API specifications
69
+ * - DO: Write all requirements in natural language for clarity
70
70
  *
71
71
  * Generate files based on actual requirements gathered from conversation.
72
72
  * Do not create unnecessary documentation - only generate what is needed to
@@ -80,6 +80,6 @@ export namespace IAutoBeAnalyzeScenarioApplication {
80
80
  * user does not specify a number, generate a sufficient number of documents
81
81
  * to adequately support the service.
82
82
  */
83
- files: Array<AutoBeAnalyzeFile.Scenario>;
83
+ files: Array<AutoBeAnalyzeFile.Scenario> & tags.MinItems<1>;
84
84
  }
85
85
  }
@@ -59,6 +59,7 @@ export const transformInterfaceAssetHistories = (
59
59
  "4. Verify EVERY field reference against the actual schema before including in descriptions",
60
60
  "",
61
61
  "## Prisma DB Schema",
62
+ "",
62
63
  "```json",
63
64
  JSON.stringify(prisma.schemas),
64
65
  "```",
@@ -44,18 +44,8 @@ export const transformInterfaceEndpointHistories = (
44
44
  name: op.name,
45
45
  summary: op.summary,
46
46
  })),
47
- null,
48
- 2,
49
47
  ),
50
48
  "```",
51
- "",
52
- "**DO NOT CREATE:**",
53
- "- User creation endpoints (POST /users, POST /admins)",
54
- "- Authentication endpoints (handled separately)",
55
- "- Focus only on business data operations",
56
- "",
57
- "Create operations for DIFFERENT paths and DIFFERENT purposes only.",
58
- "",
59
49
  ].join("\n"),
60
50
  },
61
51
  ];
@@ -35,7 +35,7 @@ export function transformInterfaceOperationsReviewHistories<
35
35
  "Review the following API operations:",
36
36
  "",
37
37
  "```json",
38
- JSON.stringify(operations, null, 2),
38
+ JSON.stringify(operations),
39
39
  "```",
40
40
  ].join("\n"),
41
41
  },
@@ -21,9 +21,15 @@ export const transformInterfaceSchemasReviewHistories = (
21
21
  type: "systemMessage",
22
22
  id: v4(),
23
23
  created_at: new Date().toISOString(),
24
- text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA_REVIEW,
24
+ text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
25
25
  },
26
26
  ...transformInterfaceAssetHistories(state),
27
+ {
28
+ type: "systemMessage",
29
+ id: v4(),
30
+ created_at: new Date().toISOString(),
31
+ text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA_REVIEW,
32
+ },
27
33
  {
28
34
  type: "assistantMessage",
29
35
  id: v4(),
@@ -33,7 +39,7 @@ export const transformInterfaceSchemasReviewHistories = (
33
39
  "These operations define what endpoints exist and what request/response types they use:",
34
40
  "",
35
41
  "```json",
36
- JSON.stringify(operations, null, 2),
42
+ JSON.stringify(operations),
37
43
  "```",
38
44
  "",
39
45
  "All schema types referenced in these operations (in requestBody and responses) must exist in the schemas.",
@@ -47,7 +53,7 @@ export const transformInterfaceSchemasReviewHistories = (
47
53
  "Here are the schemas generated by the Schema Agent that need your review:",
48
54
  "",
49
55
  "```json",
50
- JSON.stringify(schemaDescriptive, null, 2),
56
+ JSON.stringify(schemaDescriptive),
51
57
  "```",
52
58
  "",
53
59
  "Please review these schemas for:",
@@ -1,14 +1,19 @@
1
1
  import {
2
2
  AutoBeAssistantMessageHistory,
3
+ AutoBeInterfaceAuthorization,
3
4
  AutoBeInterfaceCompleteEvent,
4
5
  AutoBeInterfaceGroupsEvent,
5
6
  AutoBeInterfaceHistory,
6
7
  AutoBeOpenApi,
7
8
  } from "@autobe/interface";
9
+ import { AutoBeEndpointComparator } from "@autobe/utils";
8
10
  import { ILlmSchema } from "@samchon/openapi";
11
+ import { HashMap, Pair } from "tstl";
12
+ import { v4 } from "uuid";
9
13
 
10
14
  import { AutoBeContext } from "../../context/AutoBeContext";
11
15
  import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
16
+ import { predicateStateMessage } from "../../utils/predicateStateMessage";
12
17
  import { orchestrateInterfaceAuthorizations } from "./orchestrateInterfaceAuthorizations";
13
18
  import { orchestrateInterfaceComplement } from "./orchestrateInterfaceComplement";
14
19
  import { orchestrateInterfaceEndpoints } from "./orchestrateInterfaceEndpoints";
@@ -21,8 +26,20 @@ export const orchestrateInterface =
21
26
  async (
22
27
  props: IAutoBeApplicationProps,
23
28
  ): Promise<AutoBeAssistantMessageHistory | AutoBeInterfaceHistory> => {
24
- // ENDPOINTS
29
+ // PREDICATION
25
30
  const start: Date = new Date();
31
+ const predicate: string | null = predicateStateMessage(
32
+ ctx.state(),
33
+ "interface",
34
+ );
35
+ if (predicate !== null)
36
+ return ctx.assistantMessage({
37
+ type: "assistantMessage",
38
+ id: v4(),
39
+ created_at: start.toISOString(),
40
+ text: predicate,
41
+ completed_at: new Date().toISOString(),
42
+ });
26
43
  ctx.dispatch({
27
44
  type: "interfaceStart",
28
45
  created_at: start.toISOString(),
@@ -30,22 +47,43 @@ export const orchestrateInterface =
30
47
  step: ctx.state().analyze?.step ?? 0,
31
48
  });
32
49
 
33
- const init: AutoBeAssistantMessageHistory | AutoBeInterfaceGroupsEvent =
50
+ // ENDPOINTS
51
+ const init: AutoBeInterfaceGroupsEvent =
34
52
  await orchestrateInterfaceGroups(ctx);
35
- if (init.type === "assistantMessage") return ctx.assistantMessage(init);
36
- else ctx.dispatch(init);
53
+ ctx.dispatch(init);
37
54
 
38
55
  // AUTHORIZATION
39
- const authorizations: AutoBeOpenApi.IOperation[] =
56
+ const authorizations: AutoBeInterfaceAuthorization[] =
40
57
  await orchestrateInterfaceAuthorizations(ctx);
41
58
 
59
+ const authOperations = authorizations
60
+ .map((authorization) => authorization.operations)
61
+ .flat();
62
+
42
63
  // ENDPOINTS & OPERATIONS
43
64
  const endpoints: AutoBeOpenApi.IEndpoint[] =
44
- await orchestrateInterfaceEndpoints(ctx, init.groups, authorizations);
45
- const operations: AutoBeOpenApi.IOperation[] =
65
+ await orchestrateInterfaceEndpoints(ctx, init.groups, authOperations);
66
+ const firstOperations: AutoBeOpenApi.IOperation[] =
46
67
  await orchestrateInterfaceOperations(ctx, endpoints);
47
-
48
- operations.push(...authorizations);
68
+ const operations: AutoBeOpenApi.IOperation[] = new HashMap<
69
+ AutoBeOpenApi.IEndpoint,
70
+ AutoBeOpenApi.IOperation
71
+ >(
72
+ [...authOperations, ...firstOperations].map(
73
+ (o) =>
74
+ new Pair(
75
+ {
76
+ path: o.path,
77
+ method: o.method,
78
+ },
79
+ o, // early inserted be kept
80
+ ),
81
+ ),
82
+ AutoBeEndpointComparator.hashCode,
83
+ AutoBeEndpointComparator.equals,
84
+ )
85
+ .toJSON()
86
+ .map((it) => it.second);
49
87
 
50
88
  // TYPE SCHEMAS
51
89
  const document: AutoBeOpenApi.IDocument = {
@@ -55,15 +93,16 @@ export const orchestrateInterface =
55
93
  schemas: await orchestrateInterfaceSchemas(ctx, operations),
56
94
  },
57
95
  };
58
- document.components.schemas = await orchestrateInterfaceComplement(
59
- ctx,
60
- document,
96
+ Object.assign(
97
+ document.components.schemas,
98
+ await orchestrateInterfaceComplement(ctx, document),
61
99
  );
62
100
 
63
101
  // DO COMPILE
64
102
  return ctx.dispatch({
65
103
  type: "interfaceComplete",
66
104
  document,
105
+ authorizations,
67
106
  created_at: new Date().toISOString(),
68
107
  elapsed: new Date().getTime() - start.getTime(),
69
108
  step: ctx.state().analyze?.step ?? 0,
@@ -1,25 +1,30 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
- import { AutoBeAnalyzeRole, AutoBeOpenApi } from "@autobe/interface";
2
+ import {
3
+ AutoBeAnalyzeRole,
4
+ AutoBeInterfaceAuthorization,
5
+ AutoBeOpenApi,
6
+ AutoBeProgressEventBase,
7
+ } from "@autobe/interface";
3
8
  import { AutoBeInterfaceAuthorizationEvent } from "@autobe/interface/src/events/AutoBeInterfaceAuthorizationEvent";
4
- import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
9
+ import { StringUtil } from "@autobe/utils";
10
+ import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
5
11
  import { IPointer } from "tstl";
6
12
  import typia from "typia";
7
13
 
8
14
  import { AutoBeContext } from "../../context/AutoBeContext";
9
15
  import { assertSchemaModel } from "../../context/assertSchemaModel";
10
- import { IProgress } from "../internal/IProgress";
11
16
  import { transformInterfaceAuthorizationsHistories } from "./histories/transformInterfaceAuthorizationsHistories";
12
17
  import { IAutoBeInterfaceAuthorizationsApplication } from "./structures/IAutoBeInterfaceAuthorizationsApplication";
13
18
 
14
19
  export async function orchestrateInterfaceAuthorizations<
15
20
  Model extends ILlmSchema.Model,
16
- >(ctx: AutoBeContext<Model>): Promise<AutoBeOpenApi.IOperation[]> {
21
+ >(ctx: AutoBeContext<Model>): Promise<AutoBeInterfaceAuthorization[]> {
17
22
  const roles: AutoBeAnalyzeRole[] = ctx.state().analyze?.roles ?? [];
18
- const progress: IProgress = {
23
+ const progress: AutoBeProgressEventBase = {
19
24
  total: roles.length,
20
25
  completed: 0,
21
26
  };
22
- const operations: AutoBeOpenApi.IOperation[][] = await Promise.all(
27
+ const authorizations: AutoBeInterfaceAuthorization[] = await Promise.all(
23
28
  roles.map(async (role) => {
24
29
  const event: AutoBeInterfaceAuthorizationEvent = await process(
25
30
  ctx,
@@ -27,16 +32,20 @@ export async function orchestrateInterfaceAuthorizations<
27
32
  progress,
28
33
  );
29
34
  ctx.dispatch(event);
30
- return event.operations;
35
+ return {
36
+ role: role.name,
37
+ operations: event.operations,
38
+ };
31
39
  }),
32
40
  );
33
- return operations.flat();
41
+
42
+ return authorizations;
34
43
  }
35
44
 
36
45
  async function process<Model extends ILlmSchema.Model>(
37
46
  ctx: AutoBeContext<Model>,
38
47
  role: AutoBeAnalyzeRole,
39
- progress: IProgress,
48
+ progress: AutoBeProgressEventBase,
40
49
  ): Promise<AutoBeInterfaceAuthorizationEvent> {
41
50
  const pointer: IPointer<IAutoBeInterfaceAuthorizationsApplication.IProps | null> =
42
51
  {
@@ -47,6 +56,7 @@ async function process<Model extends ILlmSchema.Model>(
47
56
  histories: transformInterfaceAuthorizationsHistories(ctx.state(), role),
48
57
  controller: createController({
49
58
  model: ctx.model,
59
+ role: role.name,
50
60
  build: (next) => {
51
61
  pointer.value = next;
52
62
  },
@@ -70,13 +80,100 @@ async function process<Model extends ILlmSchema.Model>(
70
80
 
71
81
  function createController<Model extends ILlmSchema.Model>(props: {
72
82
  model: Model;
83
+ role: string;
73
84
  build: (next: IAutoBeInterfaceAuthorizationsApplication.IProps) => void;
74
85
  }): IAgenticaController.IClass<Model> {
75
86
  assertSchemaModel(props.model);
76
87
 
88
+ const validate = (
89
+ next: unknown,
90
+ ): IValidation<IAutoBeInterfaceAuthorizationsApplication.IProps> => {
91
+ const result: IValidation<IAutoBeInterfaceAuthorizationsApplication.IProps> =
92
+ typia.validate<IAutoBeInterfaceAuthorizationsApplication.IProps>(next);
93
+ if (result.success === false) return result;
94
+
95
+ const errors: IValidation.IError[] = [];
96
+ result.data.operations.forEach((op, i) => {
97
+ // validate authorizationRole
98
+ if (op.authorizationRole !== null) {
99
+ op.authorizationRole = props.role;
100
+ }
101
+
102
+ // validate responseBody.typeName -> must be ~.IAuthorized
103
+ if (op.authorizationType === null) return;
104
+ else if (op.responseBody === null)
105
+ errors.push({
106
+ path: `$input.operations.${i}.responseBody`,
107
+ expected:
108
+ "Response body with I{RoleName(PascalCase)}.IAuthorized type is required",
109
+ value: op.responseBody,
110
+ description: [
111
+ "Response body is required for authentication operations.",
112
+ "",
113
+ "The responseBody must contain description and typeName fields.",
114
+ "typeName must be I{Prefix(PascalCase)}{RoleName(PascalCase)}.IAuthorized",
115
+ "description must be a detailed description of the response body.",
116
+ ].join("\n"),
117
+ });
118
+ else if (!op.responseBody.typeName.endsWith(".IAuthorized"))
119
+ errors.push({
120
+ path: `$input.operations.${i}.responseBody.typeName`,
121
+ expected: `Type name must be I{RoleName(PascalCase)}.IAuthorized`,
122
+ value: op.responseBody?.typeName,
123
+ description: [
124
+ `Wrong response body type name: ${op.responseBody?.typeName}`,
125
+ "",
126
+ `For authentication operations (login, join, refresh), the response body type name must follow the convention "I{RoleName}.IAuthorized".`,
127
+ ``,
128
+ `This standardized naming convention ensures consistency across all authentication endpoints and clearly identifies authorization response types.`,
129
+ `The Role name should be in PascalCase format (e.g., IUser.IAuthorized, IAdmin.IAuthorized, ISeller.IAuthorized).`,
130
+ ].join("\n"),
131
+ });
132
+ });
133
+
134
+ // validate authorization types' existence
135
+ type AuthorizationType = NonNullable<
136
+ AutoBeOpenApi.IOperation["authorizationType"]
137
+ >;
138
+ const authorizationTypes: Set<AuthorizationType> = new Set(
139
+ result.data.operations
140
+ .map((o) => o.authorizationType)
141
+ .filter((v) => v !== null),
142
+ );
143
+ for (const type of typia.misc.literals<AuthorizationType>())
144
+ if (authorizationTypes.has(type) === false)
145
+ errors.push({
146
+ path: "$input.operations[].authorizationType",
147
+ expected: StringUtil.trim`{
148
+ ...(AutoBeOpenApi.IOperation data),
149
+ authorizationType: "${type}"
150
+ }`,
151
+ value: `No authorizationType "${type}" found in any operation`,
152
+ description: StringUtil.trim`
153
+ There must be an operation that has defined AutoBeOpenApi.IOperation.authorizationType := "${type}"
154
+ for the "${props.role}" role's authorization activity; "${type}".
155
+
156
+ However, none of the operations have the AutoBeOpenApi.IOperation.authorizationType := "${type}"
157
+ value, so that the "${props.role}" cannot perform the authorization ${type} activity.
158
+
159
+ Please make that operation at the next function calling. You have to do it.
160
+ `,
161
+ });
162
+ if (errors.length !== 0) {
163
+ return {
164
+ success: false,
165
+ errors,
166
+ data: next,
167
+ };
168
+ }
169
+ return result;
170
+ };
171
+
77
172
  const application: ILlmApplication<Model> = collection[
78
- props.model
79
- ] as unknown as ILlmApplication<Model>;
173
+ props.model === "chatgpt" ? "chatgpt" : "claude"
174
+ ](
175
+ validate,
176
+ ) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
80
177
 
81
178
  return {
82
179
  protocol: "class",
@@ -90,17 +187,23 @@ function createController<Model extends ILlmSchema.Model>(props: {
90
187
  };
91
188
  }
92
189
 
93
- const claude = typia.llm.application<
94
- IAutoBeInterfaceAuthorizationsApplication,
95
- "claude"
96
- >();
97
190
  const collection = {
98
- chatgpt: typia.llm.application<
99
- IAutoBeInterfaceAuthorizationsApplication,
100
- "chatgpt"
101
- >(),
102
- claude,
103
- llama: claude,
104
- deepseek: claude,
105
- "3.1": claude,
191
+ chatgpt: (validate: Validator) =>
192
+ typia.llm.application<IAutoBeInterfaceAuthorizationsApplication, "chatgpt">(
193
+ {
194
+ validate: {
195
+ makeOperations: validate,
196
+ },
197
+ },
198
+ ),
199
+ claude: (validate: Validator) =>
200
+ typia.llm.application<IAutoBeInterfaceAuthorizationsApplication, "claude">({
201
+ validate: {
202
+ makeOperations: validate,
203
+ },
204
+ }),
106
205
  };
206
+
207
+ type Validator = (
208
+ input: unknown,
209
+ ) => IValidation<IAutoBeInterfaceAuthorizationsApplication.IProps>;
@@ -1,12 +1,8 @@
1
- import { IAgenticaController, MicroAgenticaHistory } from "@agentica/core";
2
- import {
3
- AutoBeAssistantMessageHistory,
4
- AutoBeInterfaceGroupsEvent,
5
- } from "@autobe/interface";
1
+ import { IAgenticaController } from "@agentica/core";
2
+ import { AutoBeInterfaceGroupsEvent } from "@autobe/interface";
6
3
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
7
4
  import { IPointer } from "tstl";
8
5
  import typia from "typia";
9
- import { v4 } from "uuid";
10
6
 
11
7
  import { AutoBeContext } from "../../context/AutoBeContext";
12
8
  import { assertSchemaModel } from "../../context/assertSchemaModel";
@@ -18,12 +14,12 @@ export async function orchestrateInterfaceGroups<
18
14
  >(
19
15
  ctx: AutoBeContext<Model>,
20
16
  message: string = "Design API operations for the given assets.",
21
- ): Promise<AutoBeAssistantMessageHistory | AutoBeInterfaceGroupsEvent> {
17
+ ): Promise<AutoBeInterfaceGroupsEvent> {
22
18
  const start: Date = new Date();
23
19
  const pointer: IPointer<IAutoBeInterfaceGroupApplication.IProps | null> = {
24
20
  value: null,
25
21
  };
26
- const { histories, tokenUsage } = await ctx.conversate({
22
+ const { tokenUsage } = await ctx.conversate({
27
23
  source: "interfaceGroups",
28
24
  histories: transformInterfaceGroupHistories(ctx.state()),
29
25
  controller: createController({
@@ -32,19 +28,10 @@ export async function orchestrateInterfaceGroups<
32
28
  pointer.value = next;
33
29
  },
34
30
  }),
35
- enforceFunctionCall: false,
31
+ enforceFunctionCall: true,
36
32
  message,
37
33
  });
38
- const last: MicroAgenticaHistory<Model> = histories.at(-1)!;
39
- if (last.type === "assistantMessage")
40
- return {
41
- ...last,
42
- created_at: start.toISOString(),
43
- completed_at: new Date().toISOString(),
44
- id: v4(),
45
- } satisfies AutoBeAssistantMessageHistory;
46
- else if (pointer.value === null)
47
- throw new Error("Failed to generate groups."); // unreachable
34
+ if (pointer.value === null) throw new Error("Failed to generate groups."); // unreachable
48
35
  return {
49
36
  type: "interfaceGroups",
50
37
  created_at: start.toISOString(),
@@ -24,7 +24,7 @@ export async function orchestrateInterfaceOperations<
24
24
  >(
25
25
  ctx: AutoBeContext<Model>,
26
26
  endpoints: AutoBeOpenApi.IEndpoint[],
27
- capacity: number = 12,
27
+ capacity: number = 8,
28
28
  ): Promise<AutoBeOpenApi.IOperation[]> {
29
29
  const matrix: AutoBeOpenApi.IEndpoint[][] = divideArray({
30
30
  array: endpoints,
@@ -34,13 +34,11 @@ export async function orchestrateInterfaceOperations<
34
34
  total: endpoints.length,
35
35
  completed: 0,
36
36
  };
37
-
38
37
  const operationsReviewProgress: IProgress = {
39
- total: endpoints.length,
38
+ total: matrix.length,
40
39
  completed: 0,
41
40
  };
42
-
43
- const operations: AutoBeOpenApi.IOperation[] = (
41
+ return (
44
42
  await Promise.all(
45
43
  matrix.map(async (it) => {
46
44
  const row: AutoBeOpenApi.IOperation[] = await divideAndConquer(
@@ -54,8 +52,6 @@ export async function orchestrateInterfaceOperations<
54
52
  }),
55
53
  )
56
54
  ).flat();
57
-
58
- return operations;
59
55
  }
60
56
 
61
57
  async function divideAndConquer<Model extends ILlmSchema.Model>(
@@ -77,28 +73,28 @@ async function divideAndConquer<Model extends ILlmSchema.Model>(
77
73
  );
78
74
  for (let i: number = 0; i < retry; ++i) {
79
75
  if (remained.empty() === true || unique.size() >= endpoints.length) break;
80
- const operations: AutoBeOpenApi.IOperation[] = await process(
81
- ctx,
82
- Array.from(remained),
83
- operationsProgress,
84
- );
85
- const newbie: AutoBeOpenApi.IOperation[] =
86
- await orchestrateInterfaceOperationsReview(
87
- ctx,
88
- operations,
89
- operationsReviewProgress,
90
- );
91
- for (const item of newbie) {
76
+ const operations: AutoBeOpenApi.IOperation[] = remained.size()
77
+ ? await process(ctx, remained, operationsProgress)
78
+ : [];
79
+
80
+ for (const item of operations) {
92
81
  unique.set(item, item);
93
82
  remained.erase(item);
94
83
  }
95
84
  }
85
+ const newbie: AutoBeOpenApi.IOperation[] =
86
+ await orchestrateInterfaceOperationsReview(
87
+ ctx,
88
+ unique.toJSON().map((it) => it.second),
89
+ operationsReviewProgress,
90
+ );
91
+ for (const item of newbie) unique.set(item, item);
96
92
  return unique.toJSON().map((it) => it.second);
97
93
  }
98
94
 
99
95
  async function process<Model extends ILlmSchema.Model>(
100
96
  ctx: AutoBeContext<Model>,
101
- endpoints: AutoBeOpenApi.IEndpoint[],
97
+ endpoints: HashSet<AutoBeOpenApi.IEndpoint>,
102
98
  progress: IProgress,
103
99
  ): Promise<AutoBeOpenApi.IOperation[]> {
104
100
  const prefix: string = NamingConvention.camel(ctx.state().analyze!.prefix);
@@ -107,7 +103,10 @@ async function process<Model extends ILlmSchema.Model>(
107
103
  };
108
104
  const { tokenUsage } = await ctx.conversate({
109
105
  source: "interfaceOperations",
110
- histories: transformInterfaceOperationHistories(ctx.state(), endpoints),
106
+ histories: transformInterfaceOperationHistories(
107
+ ctx.state(),
108
+ endpoints.toJSON(),
109
+ ),
111
110
  controller: createController({
112
111
  model: ctx.model,
113
112
  roles: ctx.state().analyze?.roles.map((it) => it.name) ?? [],
@@ -124,9 +123,9 @@ async function process<Model extends ILlmSchema.Model>(
124
123
  .filter((it) => it !== "")
125
124
  .join("/"),
126
125
  authorizationRole: null,
126
+ authorizationType: null,
127
127
  },
128
128
  ];
129
-
130
129
  return op.authorizationRoles.map((role) => ({
131
130
  ...op,
132
131
  path:
@@ -135,20 +134,27 @@ async function process<Model extends ILlmSchema.Model>(
135
134
  .filter((it) => it !== "")
136
135
  .join("/"),
137
136
  authorizationRole: role,
137
+ authorizationType: null,
138
138
  }));
139
139
  });
140
+ pointer.value.push(...matrix.flat());
140
141
  progress.completed += matrix.flat().length;
141
- progress.total += matrix
142
- .filter((it) => it.length > 1)
143
- .map((it) => it.length - 1)
142
+ progress.total += operations
143
+ .map((op) =>
144
+ endpoints.has({ path: op.path, method: op.method })
145
+ ? op.authorizationRoles.length === 0
146
+ ? 0
147
+ : op.authorizationRoles.length - 1
148
+ : op.authorizationRoles.length,
149
+ )
144
150
  .reduce((a, b) => a + b, 0);
145
- pointer.value.push(...matrix.flat());
146
151
  },
147
152
  }),
148
153
  enforceFunctionCall: true,
149
154
  message: "Make API operations",
150
155
  });
151
156
  if (pointer.value === null) throw new Error("Failed to create operations."); // never be happened
157
+
152
158
  ctx.dispatch({
153
159
  type: "interfaceOperations",
154
160
  operations: pointer.value,
@@ -288,7 +294,6 @@ function createController<Model extends ILlmSchema.Model>(props: {
288
294
  }
289
295
  indexes.push(i);
290
296
  });
291
-
292
297
  if (errors.length !== 0)
293
298
  return {
294
299
  success: false,