@autobe/agent 0.24.2 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/lib/AutoBeAgent.js +11 -1
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/AutoBeMockAgent.js +1 -0
  4. package/lib/AutoBeMockAgent.js.map +1 -1
  5. package/lib/constants/AutoBeSystemPromptConstant.d.ts +21 -21
  6. package/lib/context/IAutoBeApplication.d.ts +101 -6
  7. package/lib/context/IAutoBeApplicationProps.d.ts +6 -2
  8. package/lib/factory/createAgenticaHistory.js +1 -1
  9. package/lib/factory/createAgenticaHistory.js.map +1 -1
  10. package/lib/factory/createAutoBeApplication.js +80 -90
  11. package/lib/factory/createAutoBeApplication.js.map +1 -1
  12. package/lib/factory/createAutoBeContext.js +6 -5
  13. package/lib/factory/createAutoBeContext.js.map +1 -1
  14. package/lib/index.mjs +3914 -2594
  15. package/lib/index.mjs.map +1 -1
  16. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +5 -1
  17. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  18. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
  19. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +18 -3
  20. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  21. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +5 -1
  22. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +19 -7
  23. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  24. package/lib/orchestrate/analyze/orchestrateAnalyze.js +3 -2
  25. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  26. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
  27. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
  28. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  29. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +1 -0
  30. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -2
  31. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  32. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  33. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  34. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
  35. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  36. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
  37. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  38. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  39. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +2 -1
  40. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  41. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +5 -1
  42. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +20 -7
  43. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  44. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
  45. package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
  46. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
  47. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +6 -1
  48. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -23
  49. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  50. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +6 -1
  51. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +22 -6
  52. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  53. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
  54. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  55. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +4 -1
  56. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +27 -6
  57. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  58. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +5 -1
  59. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +21 -5
  60. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  61. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
  62. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  63. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
  64. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
  65. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
  66. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +5 -1
  67. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +20 -4
  68. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  69. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  70. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  71. package/lib/orchestrate/interface/orchestrateInterface.js +45 -11
  72. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  73. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
  74. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +277 -37
  75. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  76. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
  77. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +69 -70
  78. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  79. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
  80. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +28 -13
  81. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  82. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
  83. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +11 -8
  84. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  85. package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
  86. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +36 -21
  87. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  88. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +260 -29
  89. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  90. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
  91. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
  92. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
  93. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
  94. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +83 -53
  95. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  96. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +41 -7
  97. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  98. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
  99. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
  100. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
  101. package/lib/orchestrate/{common/structures/IAutoBeCommonCorrectDateApplication.js → interface/structures/IAutoBeInterfacePrerequisitesApplication.js} +1 -1
  102. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
  103. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
  104. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
  105. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +105 -5
  106. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  107. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +20 -1
  108. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  109. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
  110. package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
  111. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  112. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.d.ts +4 -1
  113. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +19 -8
  114. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  115. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
  116. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  117. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.d.ts +6 -1
  118. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +20 -6
  119. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  120. package/lib/orchestrate/prisma/orchestratePrisma.js +3 -3
  121. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  122. package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -1
  123. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -3
  124. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  125. package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +1 -1
  126. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +12 -6
  127. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  128. package/lib/orchestrate/{common/histories/transformCommonCorrectDateHistories.d.ts → realize/histories/transformRealizeCorrectCastingHistories.d.ts} +1 -2
  129. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +32 -0
  130. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
  131. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
  132. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  133. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
  134. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
  135. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  136. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
  137. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  138. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
  139. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +119 -42
  140. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  141. package/lib/orchestrate/realize/orchestrateRealize.js +82 -52
  142. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  143. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +128 -88
  144. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  145. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
  146. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
  147. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  148. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
  149. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
  150. package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
  151. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
  152. package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -5
  153. package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
  154. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
  155. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
  156. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  157. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
  158. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
  159. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  160. package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
  161. package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
  162. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
  163. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
  164. package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -53
  165. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  166. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +5 -1
  167. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +11 -7
  168. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  169. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  170. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  171. package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +7 -1
  172. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +35 -96
  173. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  174. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +6 -3
  175. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +33 -77
  176. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  177. package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +5 -1
  178. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +111 -94
  179. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  180. package/lib/orchestrate/test/orchestrateTest.js +20 -14
  181. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  182. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -1
  183. package/lib/orchestrate/test/orchestrateTestCorrect.js +81 -50
  184. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  185. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
  186. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  187. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  188. package/lib/orchestrate/test/orchestrateTestScenario.js +18 -7
  189. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  190. package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -1
  191. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +20 -12
  192. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  193. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
  194. package/lib/orchestrate/test/orchestrateTestWrite.js +46 -25
  195. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  196. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
  197. package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
  198. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
  199. package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
  200. package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
  201. package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
  202. package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
  203. package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
  204. package/package.json +5 -5
  205. package/src/AutoBeAgent.ts +17 -1
  206. package/src/AutoBeMockAgent.ts +1 -0
  207. package/src/constants/AutoBeSystemPromptConstant.ts +21 -21
  208. package/src/context/IAutoBeApplication.ts +101 -6
  209. package/src/context/IAutoBeApplicationProps.ts +6 -2
  210. package/src/factory/createAgenticaHistory.ts +11 -5
  211. package/src/factory/createAutoBeContext.ts +6 -5
  212. package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +5 -1
  213. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +16 -0
  214. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +22 -7
  215. package/src/orchestrate/analyze/orchestrateAnalyze.ts +3 -2
  216. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
  217. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
  218. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
  219. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
  220. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +2 -1
  221. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
  222. package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
  223. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +33 -24
  224. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +26 -9
  225. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +30 -6
  226. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
  227. package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
  228. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
  229. package/src/orchestrate/interface/orchestrateInterface.ts +65 -20
  230. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
  231. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +34 -47
  232. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +40 -28
  233. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
  234. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +51 -35
  235. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
  236. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +52 -33
  237. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
  238. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
  239. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
  240. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
  241. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
  242. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
  243. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +19 -1
  244. package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
  245. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +20 -6
  246. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +24 -9
  247. package/src/orchestrate/prisma/orchestratePrisma.ts +7 -3
  248. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +5 -1
  249. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -10
  250. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +44 -0
  251. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
  252. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
  253. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
  254. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
  255. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +102 -16
  256. package/src/orchestrate/realize/orchestrateRealize.ts +121 -81
  257. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +50 -7
  258. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
  259. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
  260. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
  261. package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
  262. package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
  263. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
  264. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
  265. package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
  266. package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -97
  267. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
  268. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +50 -115
  269. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +41 -111
  270. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
  271. package/src/orchestrate/test/orchestrateTest.ts +19 -13
  272. package/src/orchestrate/test/orchestrateTestCorrect.ts +71 -51
  273. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
  274. package/src/orchestrate/test/orchestrateTestScenario.ts +27 -17
  275. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +32 -19
  276. package/src/orchestrate/test/orchestrateTestWrite.ts +20 -10
  277. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
  278. package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
  279. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
  280. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
  281. package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
  282. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +0 -48
  283. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +0 -1
  284. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +0 -35
  285. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +0 -1
  286. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
  287. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
  288. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
  289. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
  290. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
  291. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +0 -4
  292. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +0 -540
  293. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +0 -1
  294. package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +0 -60
  295. package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +0 -40
  296. package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
  297. package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +0 -372
@@ -7,11 +7,12 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
9
9
 
10
- export const transformInterfaceComplementHistories = (
11
- state: AutoBeState,
12
- document: AutoBeOpenApi.IDocument,
13
- missed: string[],
14
- ): Array<
10
+ export const transformInterfaceComplementHistories = (props: {
11
+ state: AutoBeState;
12
+ instruction: string;
13
+ missed: string[];
14
+ document: AutoBeOpenApi.IDocument;
15
+ }): Array<
15
16
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
16
17
  > => [
17
18
  {
@@ -20,7 +21,7 @@ export const transformInterfaceComplementHistories = (
20
21
  created_at: new Date().toISOString(),
21
22
  text: AutoBeSystemPromptConstant.INTERFACE_OPERATION,
22
23
  },
23
- ...transformInterfaceAssetHistories(state),
24
+ ...transformInterfaceAssetHistories(props.state),
24
25
  {
25
26
  type: "systemMessage",
26
27
  id: v7(),
@@ -38,33 +39,41 @@ export const transformInterfaceComplementHistories = (
38
39
  id: v7(),
39
40
  created_at: new Date().toISOString(),
40
41
  text: StringUtil.trim`
42
+ ## API Design Instructions
43
+
44
+ The following API-specific instructions were extracted by AI from
45
+ the user's utterances. These focus ONLY on API interface design aspects
46
+ such as endpoint patterns, request/response formats, DTO schemas,
47
+ and operation specifications.
48
+
49
+ Apply these instructions when completing the missing schema types.
50
+ Focus on ensuring the schemas align with the overall API design patterns
51
+ and data structure requirements. If the instructions are not relevant
52
+ to the specific schemas you need to create, you may ignore them.
53
+
54
+ ${props.instruction}
55
+
56
+ ## Operations
57
+
41
58
  Here is the OpenAPI operations what you AI have made:
42
59
 
43
60
  \`\`\`json
44
- ${JSON.stringify(document.operations)}
61
+ ${JSON.stringify(props.document.operations)}
45
62
  \`\`\`
46
- `,
47
- },
48
- {
49
- type: "assistantMessage",
50
- id: v7(),
51
- created_at: new Date().toISOString(),
52
- text: StringUtil.trim`
63
+
64
+ ## Schemas
65
+
53
66
  Here is the OpenAPI schemas what you AI have made:
54
67
 
55
68
  \`\`\`json
56
- ${JSON.stringify(document.components.schemas)}
69
+ ${JSON.stringify(props.document.components.schemas)}
57
70
  \`\`\`
58
- `,
59
- },
60
- {
61
- type: "assistantMessage",
62
- id: v7(),
63
- created_at: new Date().toISOString(),
64
- text: StringUtil.trim`
65
- You AI have missed below schema types:
66
71
 
67
- ${missed.map((s) => `- ${s}`).join("\n")}
72
+ ## Missed Types
73
+
74
+ However, you AI have missed below schema types:
75
+
76
+ ${props.missed.map((s) => `- ${s}`).join("\n")}
68
77
  `,
69
78
  },
70
79
  ];
@@ -8,11 +8,12 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
8
8
  import { AutoBeState } from "../../../context/AutoBeState";
9
9
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
10
10
 
11
- export const transformInterfaceEndpointHistories = (
12
- state: AutoBeState,
13
- group: AutoBeInterfaceGroup,
14
- authorizations: AutoBeOpenApi.IOperation[],
15
- ): Array<
11
+ export const transformInterfaceEndpointHistories = (props: {
12
+ state: AutoBeState;
13
+ group: AutoBeInterfaceGroup;
14
+ authorizations: AutoBeOpenApi.IOperation[];
15
+ instruction: string;
16
+ }): Array<
16
17
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
17
18
  > => [
18
19
  {
@@ -21,25 +22,41 @@ export const transformInterfaceEndpointHistories = (
21
22
  created_at: new Date().toISOString(),
22
23
  text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
23
24
  },
24
- ...transformInterfaceAssetHistories(state),
25
+ ...transformInterfaceAssetHistories(props.state),
25
26
  {
26
27
  type: "assistantMessage",
27
28
  id: v7(),
28
29
  created_at: new Date().toISOString(),
29
30
  text: StringUtil.trim`
31
+ ## API Design Instructions
32
+
33
+ The following API-specific instructions were extracted by AI from
34
+ the user's utterances. These focus ONLY on API interface design aspects
35
+ such as endpoint patterns, request/response formats, DTO schemas,
36
+ and operation specifications.
37
+
38
+ Apply these instructions when designing endpoints for the ${props.group.name} group.
39
+ Consider the specified URL patterns, HTTP methods, parameter structures,
40
+ and response formats. If the instructions are not relevant to this specific
41
+ endpoint group, you may ignore them.
42
+
43
+ ${props.instruction}
44
+
45
+ ## Group Information
46
+
30
47
  Here is the target group for the endpoints:
31
48
 
32
49
  \`\`\`json
33
- ${JSON.stringify(group)}
50
+ ${JSON.stringify(props.group)}
34
51
  \`\`\`
35
52
 
36
- **IMPORTANT: DO NOT DUPLICATE EXISTING OPERATIONS**
53
+ ## Already Existing Operations
37
54
 
38
55
  These operations already exist. Do NOT create similar endpoints:
39
56
 
40
57
  \`\`\`json
41
58
  ${JSON.stringify(
42
- authorizations.map((op) => ({
59
+ props.authorizations.map((op) => ({
43
60
  path: op.path,
44
61
  method: op.method,
45
62
  name: op.name,
@@ -1,17 +1,21 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { StringUtil } from "@autobe/utils";
2
3
  import { v7 } from "uuid";
3
4
 
4
5
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
5
6
  import { AutoBeState } from "../../../context/AutoBeState";
6
7
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
7
- import { transformInterfacePrerequisiteHistories } from "./transformInterfacePrerequisiteHistories";
8
+ import { transformInterfaceCommonPrerequisiteHistories } from "./transformInterfaceCommonPrerequisiteHistories";
8
9
 
9
- export const transformInterfaceGroupHistories = (
10
- state: AutoBeState,
11
- ): Array<
10
+ export const transformInterfaceGroupHistories = (props: {
11
+ state: AutoBeState;
12
+ instruction: string;
13
+ }): Array<
12
14
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
13
15
  > => {
14
- const prerequisite = transformInterfacePrerequisiteHistories(state);
16
+ const prerequisite = transformInterfaceCommonPrerequisiteHistories(
17
+ props.state,
18
+ );
15
19
  if (prerequisite !== null) return prerequisite;
16
20
 
17
21
  return [
@@ -21,12 +25,32 @@ export const transformInterfaceGroupHistories = (
21
25
  type: "systemMessage",
22
26
  text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
23
27
  },
24
- ...transformInterfaceAssetHistories(state),
28
+ ...transformInterfaceAssetHistories(props.state),
25
29
  {
26
30
  id: v7(),
27
31
  created_at: new Date().toISOString(),
28
32
  type: "systemMessage",
29
33
  text: AutoBeSystemPromptConstant.INTERFACE_GROUP,
30
34
  },
35
+ {
36
+ id: v7(),
37
+ created_at: new Date().toISOString(),
38
+ type: "assistantMessage",
39
+ text: StringUtil.trim`
40
+ ## API Design Instructions
41
+
42
+ The following API-specific instructions were extracted by AI from
43
+ the user's utterances. These focus ONLY on API interface design aspects
44
+ such as endpoint patterns, request/response formats, DTO schemas,
45
+ and operation specifications.
46
+
47
+ Apply these instructions when organizing API endpoints into logical groups.
48
+ Consider how to structure and categorize endpoints based on business domains,
49
+ resource types, or functional areas. If the instructions are not relevant
50
+ to endpoint grouping and organization, you may ignore them.
51
+
52
+ ${props.instruction}
53
+ `,
54
+ },
31
55
  ];
32
56
  };
@@ -7,13 +7,14 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
9
9
 
10
- export const transformInterfaceOperationHistories = (
11
- state: AutoBeState,
12
- endpoints: AutoBeOpenApi.IEndpoint[],
13
- ): Array<
10
+ export const transformInterfaceOperationHistories = (props: {
11
+ state: AutoBeState;
12
+ endpoints: AutoBeOpenApi.IEndpoint[];
13
+ instruction: string;
14
+ }): Array<
14
15
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
16
  > => {
16
- const analyze: AutoBeAnalyzeHistory = state.analyze!;
17
+ const analyze: AutoBeAnalyzeHistory = props.state.analyze!;
17
18
  return [
18
19
  {
19
20
  type: "systemMessage",
@@ -21,7 +22,7 @@ export const transformInterfaceOperationHistories = (
21
22
  created_at: new Date().toISOString(),
22
23
  text: AutoBeSystemPromptConstant.INTERFACE_OPERATION,
23
24
  },
24
- ...transformInterfaceAssetHistories(state),
25
+ ...transformInterfaceAssetHistories(props.state),
25
26
  {
26
27
  type: "systemMessage",
27
28
  id: v7(),
@@ -44,10 +45,26 @@ export const transformInterfaceOperationHistories = (
44
45
  id: v7(),
45
46
  created_at: new Date().toISOString(),
46
47
  text: StringUtil.trim`
48
+ ## API Design Instructions
49
+
50
+ The following API-specific instructions were extracted by AI from
51
+ the user's utterances. These focus ONLY on API interface design aspects
52
+ such as endpoint patterns, request/response formats, DTO schemas,
53
+ and operation specifications.
54
+
55
+ Apply these instructions when designing the detailed operation specifications
56
+ for each endpoint. Consider parameter types, request/response structures,
57
+ error handling, and API behavior patterns. If the instructions are not
58
+ relevant to the operations you need to implement, you may ignore them.
59
+
60
+ ${props.instruction}
61
+
62
+ ## Operations
63
+
47
64
  You have to make API operations for the given endpoints:
48
65
 
49
66
  \`\`\`json
50
- ${JSON.stringify(endpoints)}
67
+ ${JSON.stringify(props.endpoints)}
51
68
  \`\`\`
52
69
 
53
70
  If there is a content in the failure, it is to explain why it failed before.
@@ -0,0 +1,118 @@
1
+ import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { AutoBeOpenApi } from "@autobe/interface";
3
+ import { StringUtil } from "@autobe/utils";
4
+ import { OpenApiTypeChecker } from "@samchon/openapi";
5
+ import { v7 } from "uuid";
6
+
7
+ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
8
+ import { getReferenceIds } from "../../test/utils/getReferenceIds";
9
+
10
+ export const transformInterfacePrerequisitesHistories = (
11
+ document: AutoBeOpenApi.IDocument,
12
+ include: AutoBeOpenApi.IOperation[],
13
+ ): Array<
14
+ IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
+ > => {
16
+ const domainSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
17
+ {};
18
+ const visit = (key: string) =>
19
+ OpenApiTypeChecker.visit({
20
+ schema: {
21
+ $ref: `#/components/schemas/${key}`,
22
+ },
23
+ components: document.components,
24
+ closure: (next) => {
25
+ if (OpenApiTypeChecker.isReference(next))
26
+ domainSchemas[next.$ref.split("/").pop()!] =
27
+ document.components.schemas[next.$ref.split("/").pop()!];
28
+ },
29
+ });
30
+ for (const op of include) {
31
+ if (op.requestBody) visit(op.requestBody.typeName);
32
+ if (op.responseBody) visit(op.responseBody.typeName);
33
+ }
34
+
35
+ return [
36
+ {
37
+ type: "systemMessage",
38
+ id: v7(),
39
+ created_at: new Date().toISOString(),
40
+ text: AutoBeSystemPromptConstant.INTERFACE_PREREQUISITE,
41
+ },
42
+ {
43
+ type: "assistantMessage",
44
+ id: v7(),
45
+ created_at: new Date().toISOString(),
46
+ text: StringUtil.trim`
47
+ ## Document Overview
48
+
49
+ ### Entire API Operations
50
+
51
+ All operations in this project for prerequisite references.
52
+
53
+ These are the complete list of API endpoints that can be used
54
+ as prerequisites. You should select appropriate operations from
55
+ this list when establishing dependency chains.
56
+
57
+ \`\`\`json
58
+ ${JSON.stringify({
59
+ operations: document.operations
60
+ .filter(
61
+ (op) => op.authorizationType === null && op.method === "post",
62
+ )
63
+ .map((op) => {
64
+ return {
65
+ ...op,
66
+ prerequisites: undefined,
67
+ };
68
+ }),
69
+ })}
70
+ \`\`\`
71
+
72
+ ### Entire Schema Definitions
73
+
74
+ Data structure definitions to understand entity relationships.
75
+
76
+ Use these schemas to identify parent-child relationships and
77
+ data dependencies between operations.
78
+
79
+ \`\`\`json
80
+ ${JSON.stringify({
81
+ components: {
82
+ schemas: document.components.schemas,
83
+ },
84
+ })}
85
+ \`\`\`
86
+
87
+ ## Target Operations and Schemas
88
+
89
+ ### Target Operations
90
+
91
+ Operations requiring prerequisite analysis.
92
+
93
+ For each of these operations, analyze if they need any prerequisites
94
+ from the available operations above. Add prerequisites only when there
95
+ are genuine dependencies like resource existence checks or state validations.
96
+
97
+ \`\`\`json
98
+ ${JSON.stringify(
99
+ include.map((op) => {
100
+ return {
101
+ ...op,
102
+ requiredIds: getReferenceIds({ document, operation: op }),
103
+ };
104
+ }),
105
+ )}
106
+ \`\`\`
107
+
108
+ ### Domain Schemas
109
+
110
+ Schema definitions for the target operations.
111
+
112
+ \`\`\`json
113
+ ${JSON.stringify(domainSchemas)}
114
+ \`\`\`
115
+ `,
116
+ },
117
+ ];
118
+ };
@@ -7,10 +7,11 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
9
9
 
10
- export const transformInterfaceSchemaHistories = (
11
- state: AutoBeState,
12
- operations: AutoBeOpenApi.IOperation[],
13
- ): Array<
10
+ export const transformInterfaceSchemaHistories = (props: {
11
+ state: AutoBeState;
12
+ operations: AutoBeOpenApi.IOperation[];
13
+ instruction: string;
14
+ }): Array<
14
15
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
16
  > => [
16
17
  {
@@ -19,16 +20,32 @@ export const transformInterfaceSchemaHistories = (
19
20
  created_at: new Date().toISOString(),
20
21
  text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
21
22
  },
22
- ...transformInterfaceAssetHistories(state),
23
+ ...transformInterfaceAssetHistories(props.state),
23
24
  {
24
25
  type: "assistantMessage",
25
26
  id: v7(),
26
27
  created_at: new Date().toISOString(),
27
28
  text: StringUtil.trim`
29
+ ## API Design Instructions
30
+
31
+ The following API-specific instructions were extracted by AI from
32
+ the user's utterances. These focus ONLY on API interface design aspects
33
+ such as endpoint patterns, request/response formats, DTO schemas,
34
+ and operation specifications.
35
+
36
+ Apply these instructions when creating JSON schema components for the operations.
37
+ Focus on data structure design, field naming conventions, validation rules,
38
+ and type definitions. If the instructions are not relevant to the schema
39
+ components you need to create, you may ignore them.
40
+
41
+ ${props.instruction}
42
+
43
+ ## Operations
44
+
28
45
  Here is the list of API operations you have to implement its types:
29
46
 
30
47
  \`\`\`json
31
- ${JSON.stringify(operations)}
48
+ ${JSON.stringify(props.operations)}
32
49
  \`\`\`
33
50
  `,
34
51
  },
@@ -6,7 +6,12 @@ import {
6
6
  AutoBeInterfaceHistory,
7
7
  AutoBeOpenApi,
8
8
  } from "@autobe/interface";
9
- import { AutoBeEndpointComparator } from "@autobe/utils";
9
+ import { AutoBeInterfacePrerequisite } from "@autobe/interface/src/histories/contents/AutoBeInterfacePrerequisite";
10
+ import {
11
+ AutoBeOpenApiEndpointComparator,
12
+ missedOpenApiSchemas,
13
+ revertOpenApiAccessor,
14
+ } from "@autobe/utils";
10
15
  import { ILlmSchema } from "@samchon/openapi";
11
16
  import { HashMap, Pair } from "tstl";
12
17
  import { v7 } from "uuid";
@@ -19,8 +24,10 @@ import { orchestrateInterfaceComplement } from "./orchestrateInterfaceComplement
19
24
  import { orchestrateInterfaceEndpoints } from "./orchestrateInterfaceEndpoints";
20
25
  import { orchestrateInterfaceGroups } from "./orchestrateInterfaceGroups";
21
26
  import { orchestrateInterfaceOperations } from "./orchestrateInterfaceOperations";
27
+ import { orchestrateInterfacePrerequisites } from "./orchestrateInterfacePrerequisites";
22
28
  import { orchestrateInterfaceSchemas } from "./orchestrateInterfaceSchemas";
23
29
  import { orchestrateInterfaceSchemasReview } from "./orchestrateInterfaceSchemasReview";
30
+ import { JsonSchemaFactory } from "./utils/JsonSchemaFactory";
24
31
 
25
32
  export const orchestrateInterface =
26
33
  <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
@@ -45,28 +52,38 @@ export const orchestrateInterface =
45
52
  type: "interfaceStart",
46
53
  id: v7(),
47
54
  created_at: start.toISOString(),
48
- reason: props.reason,
55
+ reason: props.instruction,
49
56
  step: ctx.state().analyze?.step ?? 0,
50
57
  });
51
58
 
52
59
  // ENDPOINTS
53
- const init: AutoBeInterfaceGroupsEvent =
54
- await orchestrateInterfaceGroups(ctx);
60
+ const init: AutoBeInterfaceGroupsEvent = await orchestrateInterfaceGroups(
61
+ ctx,
62
+ {
63
+ instruction: props.instruction,
64
+ },
65
+ );
55
66
  ctx.dispatch(init);
56
67
 
57
68
  // AUTHORIZATION
58
69
  const authorizations: AutoBeInterfaceAuthorization[] =
59
- await orchestrateInterfaceAuthorizations(ctx);
60
-
61
- const authOperations = authorizations
70
+ await orchestrateInterfaceAuthorizations(ctx, props.instruction);
71
+ const authOperations: AutoBeOpenApi.IOperation[] = authorizations
62
72
  .map((authorization) => authorization.operations)
63
73
  .flat();
64
74
 
65
75
  // ENDPOINTS & OPERATIONS
66
76
  const endpoints: AutoBeOpenApi.IEndpoint[] =
67
- await orchestrateInterfaceEndpoints(ctx, init.groups, authOperations);
77
+ await orchestrateInterfaceEndpoints(ctx, {
78
+ groups: init.groups,
79
+ authorizations: authOperations,
80
+ instruction: props.instruction,
81
+ });
68
82
  const firstOperations: AutoBeOpenApi.IOperation[] =
69
- await orchestrateInterfaceOperations(ctx, endpoints);
83
+ await orchestrateInterfaceOperations(ctx, {
84
+ endpoints,
85
+ instruction: props.instruction,
86
+ });
70
87
  const operations: AutoBeOpenApi.IOperation[] = new HashMap<
71
88
  AutoBeOpenApi.IEndpoint,
72
89
  AutoBeOpenApi.IOperation
@@ -81,8 +98,8 @@ export const orchestrateInterface =
81
98
  o, // early inserted be kept
82
99
  ),
83
100
  ),
84
- AutoBeEndpointComparator.hashCode,
85
- AutoBeEndpointComparator.equals,
101
+ AutoBeOpenApiEndpointComparator.hashCode,
102
+ AutoBeOpenApiEndpointComparator.equals,
86
103
  )
87
104
  .toJSON()
88
105
  .map((it) => it.second);
@@ -92,29 +109,57 @@ export const orchestrateInterface =
92
109
  operations,
93
110
  components: {
94
111
  authorization: ctx.state().analyze?.roles ?? [],
95
- schemas: await orchestrateInterfaceSchemas(ctx, operations),
112
+ schemas: await orchestrateInterfaceSchemas(ctx, {
113
+ instruction: props.instruction,
114
+ operations,
115
+ }),
96
116
  },
97
117
  };
98
118
 
99
- const complementedSchemas: Record<
100
- string,
101
- AutoBeOpenApi.IJsonSchemaDescriptive
102
- > = await orchestrateInterfaceComplement(ctx, document);
103
- Object.assign(document.components.schemas, complementedSchemas);
119
+ const complement = async () =>
120
+ Object.assign(
121
+ document.components.schemas,
122
+ await orchestrateInterfaceComplement(ctx, {
123
+ instruction: props.instruction,
124
+ document,
125
+ }),
126
+ );
127
+ await complement();
104
128
 
105
- const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
129
+ Object.assign(
130
+ document.components.schemas,
106
131
  await orchestrateInterfaceSchemasReview(
107
132
  ctx,
108
133
  operations,
109
134
  document.components.schemas,
110
- );
111
- Object.assign(document.components.schemas, schemas);
135
+ ),
136
+ );
137
+ if (missedOpenApiSchemas(document).length !== 0) await complement();
138
+
139
+ JsonSchemaFactory.finalize({
140
+ document,
141
+ application: ctx.state().prisma!.result.data,
142
+ });
143
+
144
+ // CONNECT PRE-REQUISITES
145
+ const prerequisites: AutoBeInterfacePrerequisite[] =
146
+ await orchestrateInterfacePrerequisites(ctx, document);
147
+ document.operations.forEach((op) => {
148
+ op.prerequisites =
149
+ prerequisites.find(
150
+ (p) => p.endpoint.method === op.method && p.endpoint.path === op.path,
151
+ )?.prerequisites ?? [];
152
+ });
153
+
154
+ // NORMALIZE ACCESSORS
155
+ revertOpenApiAccessor(document);
112
156
 
113
157
  // DO COMPILE
114
158
  return ctx.dispatch({
115
159
  type: "interfaceComplete",
116
160
  id: v7(),
117
161
  document,
162
+ missed: missedOpenApiSchemas(document),
118
163
  authorizations,
119
164
  created_at: new Date().toISOString(),
120
165
  elapsed: new Date().getTime() - start.getTime(),
@@ -20,7 +20,10 @@ import { IAutoBeInterfaceAuthorizationsApplication } from "./structures/IAutoBeI
20
20
 
21
21
  export async function orchestrateInterfaceAuthorizations<
22
22
  Model extends ILlmSchema.Model,
23
- >(ctx: AutoBeContext<Model>): Promise<AutoBeInterfaceAuthorization[]> {
23
+ >(
24
+ ctx: AutoBeContext<Model>,
25
+ instruction: string,
26
+ ): Promise<AutoBeInterfaceAuthorization[]> {
24
27
  const roles: AutoBeAnalyzeRole[] = ctx.state().analyze?.roles ?? [];
25
28
  const progress: AutoBeProgressEventBase = {
26
29
  total: roles.length,
@@ -29,12 +32,12 @@ export async function orchestrateInterfaceAuthorizations<
29
32
  const authorizations: AutoBeInterfaceAuthorization[] =
30
33
  await executeCachedBatch(
31
34
  roles.map((role) => async (promptCacheKey) => {
32
- const event: AutoBeInterfaceAuthorizationEvent = await process(
33
- ctx,
35
+ const event: AutoBeInterfaceAuthorizationEvent = await process(ctx, {
34
36
  role,
35
37
  progress,
36
38
  promptCacheKey,
37
- );
39
+ instruction,
40
+ });
38
41
  ctx.dispatch(event);
39
42
  return {
40
43
  role: role.name,
@@ -48,9 +51,12 @@ export async function orchestrateInterfaceAuthorizations<
48
51
 
49
52
  async function process<Model extends ILlmSchema.Model>(
50
53
  ctx: AutoBeContext<Model>,
51
- role: AutoBeAnalyzeRole,
52
- progress: AutoBeProgressEventBase,
53
- promptCacheKey: string,
54
+ props: {
55
+ instruction: string;
56
+ role: AutoBeAnalyzeRole;
57
+ progress: AutoBeProgressEventBase;
58
+ promptCacheKey: string;
59
+ },
54
60
  ): Promise<AutoBeInterfaceAuthorizationEvent> {
55
61
  const pointer: IPointer<IAutoBeInterfaceAuthorizationsApplication.IProps | null> =
56
62
  {
@@ -58,16 +64,20 @@ async function process<Model extends ILlmSchema.Model>(
58
64
  };
59
65
  const { tokenUsage } = await ctx.conversate({
60
66
  source: "interfaceAuthorization",
61
- histories: transformInterfaceAuthorizationsHistories(ctx.state(), role),
67
+ histories: transformInterfaceAuthorizationsHistories({
68
+ state: ctx.state(),
69
+ instruction: props.instruction,
70
+ role: props.role,
71
+ }),
62
72
  controller: createController({
63
73
  model: ctx.model,
64
- role,
74
+ role: props.role,
65
75
  build: (next) => {
66
76
  pointer.value = next;
67
77
  },
68
78
  }),
69
79
  enforceFunctionCall: true,
70
- promptCacheKey,
80
+ promptCacheKey: props.promptCacheKey,
71
81
  message: "Create Authorization Operation for the given roles",
72
82
  });
73
83
  if (pointer.value === null)
@@ -77,11 +87,11 @@ async function process<Model extends ILlmSchema.Model>(
77
87
  type: "interfaceAuthorization",
78
88
  id: v7(),
79
89
  operations: pointer.value.operations,
80
- completed: ++progress.completed,
90
+ completed: ++props.progress.completed,
81
91
  tokenUsage,
82
92
  created_at: new Date().toISOString(),
83
93
  step: ctx.state().analyze?.step ?? 0,
84
- total: progress.total,
94
+ total: props.progress.total,
85
95
  } satisfies AutoBeInterfaceAuthorizationEvent;
86
96
  }
87
97