@autobe/agent 0.21.0 → 0.22.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 (301) hide show
  1. package/lib/agent/src/AutoBeAgent.js +2 -2
  2. package/lib/agent/src/AutoBeAgent.js.map +1 -1
  3. package/lib/agent/src/constants/AutoBeConfigConstant.d.ts +3 -0
  4. package/lib/agent/src/{orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js → constants/AutoBeConfigConstant.js} +1 -1
  5. package/lib/agent/src/constants/AutoBeConfigConstant.js.map +1 -0
  6. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +27 -27
  7. package/lib/agent/src/context/AutoBeContext.d.ts +1 -0
  8. package/lib/agent/src/context/AutoBeTokenUsageComponent.js +4 -3
  9. package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
  10. package/lib/agent/src/factory/consentFunctionCall.js +4 -4
  11. package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
  12. package/lib/agent/src/factory/createAutoBeContext.js +13 -10
  13. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  14. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  15. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  16. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  17. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  18. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
  19. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  20. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +6 -6
  21. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +50 -8
  22. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  23. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +4 -4
  24. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  25. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  26. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  27. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  28. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +19 -1
  29. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  30. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  31. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  32. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  33. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  34. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +2 -2
  35. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  36. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  37. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  38. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  39. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  40. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  41. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  42. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  43. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  44. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  45. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  46. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  47. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +5 -1
  48. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
  49. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +16 -10
  50. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  51. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  52. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +3731 -228
  53. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  54. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +2 -2
  55. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +2 -2
  56. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +43 -63
  57. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  58. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +1261 -1628
  59. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  60. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +3468 -105
  61. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  62. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  63. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +3674 -360
  64. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  65. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  66. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
  67. package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  68. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  69. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js +1385 -0
  70. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -0
  71. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  72. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js +78 -0
  73. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js.map +1 -0
  74. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.d.ts +10 -0
  75. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js +59 -0
  76. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -0
  77. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  78. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js +81 -0
  79. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js.map +1 -0
  80. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
  81. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  82. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  83. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  84. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  85. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  86. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  87. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  88. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  89. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +2 -2
  90. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  91. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
  92. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  93. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
  94. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  95. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  96. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +22 -7
  97. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  98. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  99. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +13 -29
  100. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  101. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  102. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js +2 -8
  103. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  104. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +6 -49
  105. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
  106. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +4 -2
  107. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  108. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +5 -3
  109. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  110. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  111. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +206 -118
  112. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  113. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  114. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
  115. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  116. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +24 -39
  117. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  118. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  119. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  120. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  121. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  122. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js +3 -0
  123. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js.map +1 -0
  124. package/{src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts → lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts} +2 -13
  125. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js +3 -0
  126. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js.map +1 -0
  127. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
  128. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  129. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +86 -0
  130. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -0
  131. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  132. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js +55 -0
  133. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -0
  134. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  135. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js +20 -0
  136. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -0
  137. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  138. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js +73 -0
  139. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js.map +1 -0
  140. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  141. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +63 -69
  142. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  143. package/lib/agent/src/orchestrate/test/compile/completeTestCode.d.ts +3 -1
  144. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +25 -18
  145. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
  146. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +5 -1
  147. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  148. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  149. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js +19 -0
  150. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js.map +1 -0
  151. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  152. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js +2 -0
  153. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  154. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  155. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js +21 -0
  156. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js.map +1 -0
  157. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
  158. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +16 -17
  159. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  160. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +5 -4
  161. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  162. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +21 -2
  163. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  164. package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -0
  165. package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
  166. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  167. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +123 -75
  168. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  169. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +46 -40
  170. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  171. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +117 -45
  172. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  173. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  174. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  175. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js +3 -0
  176. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js.map +1 -0
  177. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  178. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  179. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  180. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js +28 -0
  181. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js.map +1 -0
  182. package/lib/agent/src/structures/IAutoBeConfig.d.ts +2 -0
  183. package/lib/constants/AutoBeConfigConstant.d.ts +3 -0
  184. package/lib/constants/AutoBeSystemPromptConstant.d.ts +27 -27
  185. package/lib/context/AutoBeContext.d.ts +1 -0
  186. package/lib/index.mjs +13871 -3912
  187. package/lib/index.mjs.map +1 -1
  188. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  189. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  190. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  191. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  192. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  193. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  194. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
  195. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  196. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  197. package/lib/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  198. package/lib/orchestrate/interface/utils/JsonSchemaValidator.d.ts +10 -0
  199. package/lib/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  200. package/lib/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  201. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  202. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  203. package/lib/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  204. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  205. package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  206. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  207. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  208. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  209. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  210. package/lib/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  211. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts +36 -0
  212. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
  213. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  214. package/lib/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  215. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  216. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  217. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  218. package/lib/orchestrate/test/compile/completeTestCode.d.ts +3 -1
  219. package/lib/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  220. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  221. package/lib/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  222. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
  223. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  224. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  225. package/lib/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  226. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  227. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  228. package/lib/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  229. package/lib/structures/IAutoBeConfig.d.ts +2 -0
  230. package/package.json +6 -6
  231. package/src/AutoBeAgent.ts +2 -0
  232. package/src/constants/AutoBeConfigConstant.ts +3 -0
  233. package/src/constants/AutoBeSystemPromptConstant.ts +27 -27
  234. package/src/context/AutoBeContext.ts +1 -0
  235. package/src/context/AutoBeTokenUsageComponent.ts +3 -3
  236. package/src/factory/consentFunctionCall.ts +2 -0
  237. package/src/factory/createAutoBeContext.ts +145 -136
  238. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +6 -0
  239. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.ts +4 -0
  240. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +19 -1
  241. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +1 -4
  242. package/src/orchestrate/interface/orchestrateInterface.ts +15 -4
  243. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +13 -5
  244. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +58 -19
  245. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +11 -11
  246. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +13 -117
  247. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +35 -93
  248. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +74 -97
  249. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +0 -39
  250. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +50 -146
  251. package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +31 -27
  252. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +171 -0
  253. package/src/orchestrate/interface/utils/JsonSchemaNamingConvention.ts +83 -0
  254. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +66 -0
  255. package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +90 -0
  256. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -2
  257. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +30 -15
  258. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +27 -49
  259. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +4 -11
  260. package/src/orchestrate/realize/orchestrateRealize.ts +19 -75
  261. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
  262. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +114 -25
  263. package/src/orchestrate/realize/orchestrateRealizeScenario.ts +2 -2
  264. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +11 -15
  265. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +17 -0
  266. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +20 -0
  267. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +40 -74
  268. package/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.ts +9 -0
  269. package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.ts +45 -0
  270. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +33 -22
  271. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +97 -0
  272. package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +64 -0
  273. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +29 -0
  274. package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +82 -0
  275. package/src/orchestrate/realize/utils/replaceImportStatements.ts +101 -111
  276. package/src/orchestrate/test/compile/completeTestCode.ts +18 -31
  277. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +12 -0
  278. package/src/orchestrate/test/compile/getTestImportStatements.ts +25 -0
  279. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +6 -1
  280. package/src/orchestrate/test/compile/getTestTemplateCode.ts +25 -0
  281. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +26 -26
  282. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +6 -5
  283. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +19 -0
  284. package/src/orchestrate/test/orchestrateTest.ts +6 -0
  285. package/src/orchestrate/test/orchestrateTestCorrect.ts +44 -20
  286. package/src/orchestrate/test/orchestrateTestScenario.ts +52 -48
  287. package/src/orchestrate/test/orchestrateTestWrite.ts +20 -10
  288. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +49 -46
  289. package/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.ts +8 -0
  290. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +1 -0
  291. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +14 -0
  292. package/src/orchestrate/test/utils/getReferenceIds.ts +25 -0
  293. package/src/structures/IAutoBeConfig.ts +3 -0
  294. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +0 -7
  295. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js +0 -35
  296. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +0 -1
  297. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  298. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js.map +0 -1
  299. package/lib/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +0 -7
  300. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  301. package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +0 -41
@@ -0,0 +1,82 @@
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
+ import { StringUtil } from "@autobe/utils";
3
+
4
+ /**
5
+ * Generate TypeScript type definition string for provider function props
6
+ *
7
+ * This utility creates the exact props interface that the Realize Agent's
8
+ * generated provider functions must accept. It combines:
9
+ *
10
+ * - Authentication context (user/admin/member from authorization)
11
+ * - URL path parameters (e.g., id, boardId, postId)
12
+ * - Request body type (if applicable)
13
+ *
14
+ * The output is injected into REALIZE_WRITE_ARTIFACT.md template to tell the AI
15
+ * exactly what parameter type the function should accept.
16
+ *
17
+ * @example
18
+ * // For DELETE /posts/:id (authenticated)
19
+ * // Returns: "props: { user: IUser; id: string & tags.Format<'uuid'>; }"
20
+ *
21
+ * @example
22
+ * // For GET /public/info (no auth, no params)
23
+ * // Returns: "// No props parameter needed - function should have no parameters"
24
+ *
25
+ * @param operation - OpenAPI operation definition containing parameters and
26
+ * auth requirements
27
+ * @param authorization - Authorization context with user/role information (if
28
+ * authenticated endpoint)
29
+ * @returns TypeScript interface string like "props: { user: IUser; id: string;
30
+ * body: IRequest; }"
31
+ */
32
+ export function getRealizeWriteInputType(
33
+ operation: AutoBeOpenApi.IOperation,
34
+ authorization: AutoBeRealizeAuthorization | null,
35
+ ): string {
36
+ const functionParameterFields: string[] = [];
37
+
38
+ // Add authentication field (user/admin/member) if endpoint requires auth
39
+ const hasAuthentication = authorization && operation.authorizationRole;
40
+ if (hasAuthentication) {
41
+ const authFieldName = operation.authorizationRole;
42
+ const authFieldType = authorization.payload.name;
43
+ functionParameterFields.push(`${authFieldName}: ${authFieldType};`);
44
+ }
45
+
46
+ // Add URL path parameters (e.g., /posts/:id → id parameter)
47
+ const pathParameters = operation.parameters;
48
+ pathParameters.forEach((pathParam) => {
49
+ const paramName = pathParam.name;
50
+ const paramType = pathParam.schema.type;
51
+ const paramFormat =
52
+ "format" in pathParam.schema
53
+ ? ` & tags.Format<'${pathParam.schema.format}'>`
54
+ : "";
55
+
56
+ const parameterField = `${paramName}: ${paramType}${paramFormat};`;
57
+ functionParameterFields.push(parameterField);
58
+ });
59
+
60
+ // Add request body if present (POST/PUT/PATCH operations)
61
+ const hasRequestBody = operation.requestBody?.typeName;
62
+ if (hasRequestBody) {
63
+ const bodyTypeName = operation.requestBody?.typeName;
64
+ functionParameterFields.push(`body: ${bodyTypeName};`);
65
+ }
66
+
67
+ // Format as TypeScript props interface or indicate no parameters needed
68
+ const hasParameters = functionParameterFields.length > 0;
69
+
70
+ if (!hasParameters) {
71
+ return `// No props parameter needed - function should have no parameters`;
72
+ }
73
+
74
+ const formattedFields = functionParameterFields
75
+ .map((field) => ` ${field}`)
76
+ .join("\n");
77
+
78
+ return StringUtil.trim`
79
+ props: {
80
+ ${formattedFields}
81
+ }`;
82
+ }
@@ -1,133 +1,123 @@
1
- import { IAutoBeCompiler } from "@autobe/interface";
1
+ import { AutoBeOpenApi, IAutoBeCompiler } from "@autobe/interface";
2
2
  import { ILlmSchema } from "@samchon/openapi";
3
3
 
4
4
  import { AutoBeContext } from "../../../context/AutoBeContext";
5
- import { IAutoBeTestScenarioArtifacts } from "../../test/structures/IAutoBeTestScenarioArtifacts";
5
+ import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
6
6
 
7
- export function replaceImportStatements<Model extends ILlmSchema.Model>(
7
+ export async function replaceImportStatements<Model extends ILlmSchema.Model>(
8
8
  ctx: AutoBeContext<Model>,
9
+ props: {
10
+ operation: AutoBeOpenApi.IOperation;
11
+ code: string;
12
+ decoratorType?: string;
13
+ },
9
14
  ) {
10
- return async function (
11
- artifacts: IAutoBeTestScenarioArtifacts,
12
- code: string,
13
- decoratorType?: string,
14
- ) {
15
- const typeReferences: string[] = Array.from(
16
- new Set(
17
- Object.keys(artifacts.document.components.schemas).map(
18
- (key) => key.split(".")[0]!,
19
- ),
20
- ),
21
- );
15
+ let { operation, code, decoratorType } = props;
22
16
 
23
- const compiler: IAutoBeCompiler = await ctx.compiler();
24
- code = await compiler.typescript.beautify(code);
25
- // Remove existing import statements using flexible regex patterns
26
- code = code
27
- .replace(
28
- /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
29
- "",
30
- )
31
- .replace(
32
- /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
33
- "",
34
- )
35
- .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
36
- .replace(
37
- /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
38
- "",
39
- )
40
- .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
41
- .replace(
42
- /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
43
- "",
44
- )
45
- .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
46
- .replace(
47
- /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm,
48
- "",
49
- )
50
- // Remove JWT import if it exists (to prevent duplication)
51
- .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
52
- .replace(
53
- /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
54
- "",
55
- );
17
+ const typeReferences: string[] = Array.from(
18
+ new Set(
19
+ [operation.requestBody, operation.responseBody]
20
+ .filter((el) => el !== null)
21
+ .map((el) => el.typeName.split(".")[0]!),
22
+ ),
23
+ );
56
24
 
57
- // Remove any existing API structure imports
58
- // Pattern 1: ../api/structures path
59
- code = code.replace(
60
- /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
25
+ const compiler: IAutoBeCompiler = await ctx.compiler();
26
+ code = await compiler.typescript.beautify(code);
27
+ // Remove existing import statements using flexible regex patterns
28
+ code = code
29
+ .replace(
30
+ /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
61
31
  "",
62
- );
63
- // Pattern 2: @ORGANIZATION/PROJECT-api/lib/structures path
64
- code = code.replace(
65
- /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
32
+ )
33
+ .replace(
34
+ /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
35
+ "",
36
+ )
37
+ .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
38
+ .replace(
39
+ /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
40
+ "",
41
+ )
42
+ .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
43
+ .replace(
44
+ /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
45
+ "",
46
+ )
47
+ .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
48
+ .replace(
49
+ /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm,
50
+ "",
51
+ )
52
+ // Remove JWT import if it exists (to prevent duplication)
53
+ .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
54
+ .replace(
55
+ /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
66
56
  "",
67
57
  );
68
58
 
69
- // Remove specific type imports that match our typeReferences
70
- for (const ref of typeReferences) {
71
- // Remove any import of this specific type from any path
72
- const typeImportRegex = new RegExp(
73
- `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
74
- "gm",
75
- );
76
- code = code.replace(typeImportRegex, "");
77
- }
59
+ // Remove any existing API structure imports
60
+ // Pattern 1: ../api/structures path
61
+ code = code.replace(
62
+ /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
63
+ "",
64
+ );
65
+ // Pattern 2: @ORGANIZATION/PROJECT-api/lib/structures path
66
+ code = code.replace(
67
+ /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
68
+ "",
69
+ );
78
70
 
79
- // Remove any existing decoratorType imports if LLM mistakenly added them
80
- if (decoratorType) {
81
- const decoratorTypeRegex = new RegExp(
82
- `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
83
- "gm",
84
- );
85
- code = code.replace(decoratorTypeRegex, "");
86
- }
71
+ // Remove specific type imports that match our typeReferences
72
+ for (const ref of typeReferences) {
73
+ // Remove any import of this specific type from any path
74
+ const typeImportRegex = new RegExp(
75
+ `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
76
+ "gm",
77
+ );
78
+ code = code.replace(typeImportRegex, "");
79
+ }
87
80
 
88
- // Build the standard imports
89
- const imports = [
90
- 'import jwt from "jsonwebtoken";',
91
- 'import { MyGlobal } from "../MyGlobal";',
92
- 'import typia, { tags } from "typia";',
93
- 'import { Prisma } from "@prisma/client";',
94
- 'import { v4 } from "uuid";',
95
- 'import { toISOStringSafe } from "../util/toISOStringSafe"',
96
- ...typeReferences.map(
97
- (ref) =>
98
- `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
99
- ),
100
- ];
81
+ // Remove any existing decoratorType imports if LLM mistakenly added them
82
+ if (decoratorType) {
83
+ const decoratorTypeRegex = new RegExp(
84
+ `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
85
+ "gm",
86
+ );
87
+ code = code.replace(decoratorTypeRegex, "");
88
+ }
101
89
 
102
- // Only add decoratorType import if it exists
103
- if (decoratorType) {
104
- imports.push(
105
- `import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`,
106
- );
107
- }
90
+ // Build the standard imports
91
+ const imports = getRealizeWriteImportStatements(operation);
92
+
93
+ // Only add decoratorType import if it exists
94
+ if (decoratorType) {
95
+ imports.push(
96
+ `import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`,
97
+ );
98
+ }
108
99
 
109
- code = [...imports, "", code].join("\n");
100
+ code = [...imports, "", code].join("\n");
110
101
 
111
- // Clean up formatting issues
112
- code =
113
- code
114
- // Remove lines with only whitespace
115
- .replace(/^\s+$/gm, "")
116
- // Replace 3+ consecutive newlines with exactly 2 newlines
117
- .replace(/\n{3,}/g, "\n\n")
118
- // Ensure proper spacing after import section
119
- .replace(/(import.*?;)(\s*)(\n(?!import|\s*$))/g, "$1\n\n$3")
120
- // Trim and ensure single trailing newline
121
- .trim() + "\n";
102
+ // Clean up formatting issues
103
+ code =
104
+ code
105
+ // Remove lines with only whitespace
106
+ .replace(/^\s+$/gm, "")
107
+ // Replace 3+ consecutive newlines with exactly 2 newlines
108
+ .replace(/\n{3,}/g, "\n\n")
109
+ // Ensure proper spacing after import section
110
+ .replace(/(import.*?;)(\s*)(\n(?!import|\s*$))/g, "$1\n\n$3")
111
+ // Trim and ensure single trailing newline
112
+ .trim() + "\n";
122
113
 
123
- // fix escaped codes
124
- code = code.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\'/g, "'");
114
+ // fix escaped codes
115
+ code = code.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\'/g, "'");
125
116
 
126
- // Apply final beautification
127
- code = await compiler.typescript.beautify(code);
117
+ // Apply final beautification
118
+ code = await compiler.typescript.beautify(code);
128
119
 
129
- code = code.replaceAll("typia.tags.assert", "typia.assert");
120
+ code = code.replaceAll("typia.tags.assert", "typia.assert");
130
121
 
131
- return code;
132
- };
122
+ return code;
133
123
  }
@@ -1,39 +1,26 @@
1
1
  import { StringUtil } from "@autobe/utils";
2
+ import { ILlmSchema } from "@samchon/openapi";
2
3
 
4
+ import { AutoBeContext } from "../../../context/AutoBeContext";
3
5
  import { IAutoBeTestScenarioArtifacts } from "../structures/IAutoBeTestScenarioArtifacts";
6
+ import { getTestImportStatements } from "./getTestImportStatements";
4
7
 
5
- export function completeTestCode(
8
+ export const completeTestCode = async <Model extends ILlmSchema.Model>(
9
+ ctx: AutoBeContext<Model>,
6
10
  artifacts: IAutoBeTestScenarioArtifacts,
7
11
  code: string,
8
- ): string {
9
- const typeReferences: string[] = Array.from(
10
- new Set(
11
- Object.keys(artifacts.document.components.schemas).map(
12
- (key) => key.split(".")[0]!,
13
- ),
14
- ),
15
- );
16
-
17
- code = code.replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "").trim();
18
- code = code.replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "").trim();
19
- code = code.replaceAll(
20
- 'string & Format<"uuid">',
21
- 'string & tags.Format<"uuid">',
22
- );
23
- code = StringUtil.trim`
24
- import { ArrayUtil, RandomGenerator, TestValidator } from "@nestia/e2e";
25
- import { IConnection } from "@nestia/fetcher";
26
- import typia, { tags } from "typia";
27
-
28
- import api from "@ORGANIZATION/PROJECT-api";
29
- ${typeReferences
30
- .map(
31
- (ref) =>
32
- `import type { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
33
- )
34
- .join("\n")}
12
+ ): Promise<string> => {
13
+ const compiler = await ctx.compiler();
14
+ code = await compiler.typescript.beautify(code);
15
+ code = code
16
+ .split("\r\n")
17
+ .join("\n")
18
+ .split("\n")
19
+ .filter((str) => str.trim().startsWith("import") === false)
20
+ .join("\n");
21
+ return await compiler.typescript.beautify(StringUtil.trim`
22
+ ${getTestImportStatements(artifacts.document)}
35
23
 
36
24
  ${code}
37
- `;
38
- return code;
39
- }
25
+ `);
26
+ };
@@ -18,10 +18,22 @@ const singleton = new Singleton(async (compiler: IAutoBeTestCompiler) => {
18
18
  if (content === undefined) throw new Error(`File not found: ${location}`);
19
19
  return { [location]: content };
20
20
  };
21
+ const filter = (
22
+ closure: (key: string) => boolean,
23
+ ): Record<string, string> => {
24
+ const entries = Object.entries(records).filter(([key]) => closure(key));
25
+ return Object.fromEntries(entries);
26
+ };
21
27
  return {
22
28
  ...external("node_modules/@nestia/e2e/lib/ArrayUtil.d.ts"),
23
29
  ...external("node_modules/@nestia/e2e/lib/RandomGenerator.d.ts"),
24
30
  ...external("node_modules/@nestia/e2e/lib/TestValidator.d.ts"),
25
31
  ...external("node_modules/@nestia/fetcher/lib/IConnection.d.ts"),
32
+ ...external("node_modules/@samchon/openapi/lib/http/HttpError.d.ts"),
33
+ ...external("node_modules/typia/lib/module.d.ts"),
34
+ ...filter(
35
+ (key) =>
36
+ key.startsWith("node_modules/typia/lib/tags") && key.endsWith(".d.ts"),
37
+ ),
26
38
  } satisfies Record<string, string>;
27
39
  });
@@ -0,0 +1,25 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+ import { StringUtil } from "@autobe/utils";
3
+
4
+ export const getTestImportStatements = (
5
+ document: AutoBeOpenApi.IDocument,
6
+ ): string => {
7
+ const typeReferences: string[] = Array.from(
8
+ new Set(
9
+ Object.keys(document.components.schemas).map((key) => key.split(".")[0]!),
10
+ ),
11
+ ).sort();
12
+ return StringUtil.trim`
13
+ import { ArrayUtil, RandomGenerator, TestValidator } from "@nestia/e2e";
14
+ import { IConnection } from "@nestia/fetcher";
15
+ import typia, { tags } from "typia";
16
+
17
+ import api from "@ORGANIZATION/PROJECT-api";
18
+ ${typeReferences
19
+ .map(
20
+ (ref) =>
21
+ `import type { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
22
+ )
23
+ .join("\n")}
24
+ `;
25
+ };
@@ -7,10 +7,14 @@ import { ILlmSchema, OpenApiTypeChecker } from "@samchon/openapi";
7
7
 
8
8
  import { AutoBeContext } from "../../../context/AutoBeContext";
9
9
  import { IAutoBeTestScenarioArtifacts } from "../structures/IAutoBeTestScenarioArtifacts";
10
+ import { getTestTemplateCode } from "./getTestTemplateCode";
10
11
 
11
12
  export async function getTestScenarioArtifacts<Model extends ILlmSchema.Model>(
12
13
  ctx: AutoBeContext<Model>,
13
- scenario: Pick<AutoBeTestScenario, "endpoint" | "dependencies">,
14
+ scenario: Pick<
15
+ AutoBeTestScenario,
16
+ "endpoint" | "dependencies" | "functionName"
17
+ >,
14
18
  ): Promise<IAutoBeTestScenarioArtifacts> {
15
19
  const compiler: IAutoBeCompiler = await ctx.compiler();
16
20
  const document: AutoBeOpenApi.IDocument = filterDocument(
@@ -35,6 +39,7 @@ export async function getTestScenarioArtifacts<Model extends ILlmSchema.Model>(
35
39
  sdk: filter("src/api", "src/api/structures"),
36
40
  dto: filter("src/api/structures"),
37
41
  e2e: filter("test/features"),
42
+ template: getTestTemplateCode(scenario, document),
38
43
  };
39
44
  }
40
45
 
@@ -0,0 +1,25 @@
1
+ import { AutoBeOpenApi, AutoBeTestScenario } from "@autobe/interface";
2
+ import { StringUtil } from "@autobe/utils";
3
+
4
+ import { getTestImportStatements } from "./getTestImportStatements";
5
+
6
+ export const getTestTemplateCode = (
7
+ scenario: Pick<
8
+ AutoBeTestScenario,
9
+ "endpoint" | "dependencies" | "functionName"
10
+ >,
11
+ document: AutoBeOpenApi.IDocument,
12
+ ): string => {
13
+ return StringUtil.trim`
14
+ ${getTestImportStatements(document)}
15
+
16
+ /**
17
+ * <SCENARIO DESCRIPTION HERE>
18
+ */
19
+ export async function ${scenario.functionName}(
20
+ connection: api.IConnection,
21
+ ) {
22
+ // <E2E TEST CODE HERE>
23
+ }
24
+ `;
25
+ };
@@ -1,12 +1,12 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
- import { IAutoBeTypeScriptCompileResult } from "@autobe/interface";
3
2
  import { StringUtil } from "@autobe/utils";
4
3
  import { ILlmSchema } from "@samchon/openapi";
5
- import { v7 } from "uuid";
4
+ import { v4, v7 } from "uuid";
6
5
 
7
6
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
8
7
  import { AutoBeContext } from "../../../context/AutoBeContext";
9
8
  import { IAutoBeTestFunction } from "../structures/IAutoBeTestFunction";
9
+ import { IAutoBeTestFunctionFailure } from "../structures/IAutoBeTestFunctionFailure";
10
10
  import { transformTestWriteHistories } from "./transformTestWriteHistories";
11
11
 
12
12
  export const transformTestCorrectHistories = async <
@@ -14,17 +14,15 @@ export const transformTestCorrectHistories = async <
14
14
  >(
15
15
  ctx: AutoBeContext<Model>,
16
16
  func: IAutoBeTestFunction,
17
- failure: IAutoBeTypeScriptCompileResult.IFailure,
17
+ failures: IAutoBeTestFunctionFailure[],
18
18
  ): Promise<
19
19
  Array<
20
20
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
21
21
  >
22
22
  > => {
23
- const previous = await transformTestWriteHistories(
24
- ctx,
25
- func.scenario,
26
- func.artifacts,
27
- );
23
+ const previous: Array<
24
+ IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
25
+ > = await transformTestWriteHistories(ctx, func.scenario, func.artifacts);
28
26
  return [
29
27
  ...previous.slice(0, -1),
30
28
  {
@@ -33,27 +31,29 @@ export const transformTestCorrectHistories = async <
33
31
  type: "systemMessage",
34
32
  text: AutoBeSystemPromptConstant.TEST_CORRECT,
35
33
  },
36
- {
37
- id: v7(),
38
- created_at: new Date().toISOString(),
39
- type: "assistantMessage",
40
- text: StringUtil.trim`
41
- ${previous.at(-1)!.text}
34
+ previous.at(-1)!,
35
+ ...failures.map(
36
+ (f) =>
37
+ ({
38
+ id: v4(),
39
+ created_at: new Date().toISOString(),
40
+ type: "assistantMessage",
41
+ text: StringUtil.trim`
42
+ ## Generated TypeScript Code
42
43
 
43
- ## Generated TypeScript Code
44
+ \`\`\`typescript
45
+ ${f.function.script}
46
+ \`\`\`
44
47
 
45
- \`\`\`typescript
46
- ${func.script}
47
- \`\`\`
48
+ ## Compile Errors
48
49
 
49
- ## Compile Errors
50
-
51
- Fix the compilation error in the provided code.
50
+ Fix the compilation error in the provided code.
52
51
 
53
- \`\`\`json
54
- ${JSON.stringify(failure.diagnostics)}
55
- \`\`\`
56
- `,
57
- },
52
+ \`\`\`json
53
+ ${JSON.stringify(f.failure.diagnostics)}
54
+ \`\`\`
55
+ `,
56
+ }) satisfies IAgenticaHistoryJson.IAssistantMessage,
57
+ ),
58
58
  ];
59
59
  };
@@ -48,7 +48,7 @@ export const transformTestScenarioHistories = (
48
48
  {
49
49
  id: v7(),
50
50
  created_at: new Date().toISOString(),
51
- type: "systemMessage",
51
+ type: "assistantMessage",
52
52
  text: StringUtil.trim`
53
53
  # Operations
54
54
 
@@ -73,17 +73,18 @@ export const transformTestScenarioHistories = (
73
73
  )}
74
74
  \`\`\`
75
75
  `,
76
- } satisfies IAgenticaHistoryJson.ISystemMessage,
76
+ } satisfies IAgenticaHistoryJson.IAssistantMessage,
77
77
  {
78
78
  id: v7(),
79
79
  created_at: new Date().toISOString(),
80
- type: "systemMessage",
80
+ type: "assistantMessage",
81
81
  text: StringUtil.trim`
82
82
  # Included in Test Plan
83
83
 
84
84
  Below are the endpoints that have been included in the test plan.
85
85
  Each endpoint shows its authentication requirements and related authentication APIs.
86
- When testing endpoints that require authentication, ensure you include the corresponding join/login operations in your test scenario to establish proper authentication context.
86
+ When testing endpoints that require authentication, ensure you include the corresponding
87
+ join/login operations in your test scenario to establish proper authentication context.
87
88
 
88
89
  ${include
89
90
  .map((el, i) => {
@@ -121,6 +122,6 @@ export const transformTestScenarioHistories = (
121
122
  .map((el) => `- ${el.method.toUpperCase()}: ${el.path}`)
122
123
  .join("\n")}
123
124
  `,
124
- } satisfies IAgenticaHistoryJson.ISystemMessage,
125
+ } satisfies IAgenticaHistoryJson.IAssistantMessage,
125
126
  ];
126
127
  };
@@ -83,9 +83,28 @@ export async function transformTestWriteHistories<
83
83
 
84
84
  ## External Definitions
85
85
 
86
+ Here is the external declaration files (d.ts) you can reference.
87
+
86
88
  \`\`\`json
87
89
  ${JSON.stringify(await getTestExternalDeclarations(ctx))}
88
90
  \`\`\`
91
+
92
+ ## Template Code
93
+
94
+ Here is the template e2e test code what you must follow.
95
+
96
+ You're only allowed to modify the "<SCENARIO DESCRIPTION HERE>" and
97
+ code inside the function block marked as "// <E2E TEST CODE HERE>".
98
+ Change the template code by writing your scenario description to the
99
+ comment, and filling your implementation logic into the function.
100
+
101
+ Note that, you don't need to add any "import" statement more than
102
+ this template code. Everything you need is already imported, so
103
+ make your implementation code in the import scope.
104
+
105
+ \`\`\`typescript
106
+ ${artifacts.template}
107
+ \`\`\`
89
108
  `,
90
109
  },
91
110
  ];
@@ -68,6 +68,12 @@ export const orchestrateTest =
68
68
  ctx,
69
69
  written,
70
70
  );
71
+ // for (const c of corrects)
72
+ // if (c.result.type !== "success")
73
+ // c.file.content = c.file.content
74
+ // .split("\n")
75
+ // .map((s) => `// ${s}`)
76
+ // .join("\n");
71
77
 
72
78
  // DO COMPILE
73
79
  const compiler: IAutoBeCompiler = await ctx.compiler();