@autobe/agent 0.25.0 → 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 (184) 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 +13 -13
  6. package/lib/factory/createAutoBeContext.js +1 -0
  7. package/lib/factory/createAutoBeContext.js.map +1 -1
  8. package/lib/index.mjs +2250 -806
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  11. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  12. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
  13. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  14. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
  15. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
  16. package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
  17. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
  18. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +2 -2
  19. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  20. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +3 -3
  21. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  22. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
  23. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
  24. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
  25. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  26. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  27. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  28. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  29. package/lib/orchestrate/interface/orchestrateInterface.js +25 -9
  30. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  31. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +260 -29
  32. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  33. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +56 -64
  34. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  35. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -3
  36. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  37. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +2 -2
  38. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +4 -5
  39. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  40. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +260 -29
  41. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  42. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
  43. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
  44. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
  45. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +47 -35
  46. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  47. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +41 -7
  48. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  49. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
  50. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
  51. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
  52. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js +3 -0
  53. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
  54. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
  55. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
  56. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +105 -5
  57. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  58. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +20 -1
  59. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  60. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
  61. package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
  62. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  63. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +9 -10
  64. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -1
  65. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
  66. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  67. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
  68. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
  69. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  70. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
  71. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  72. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
  73. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +103 -40
  74. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  75. package/lib/orchestrate/realize/orchestrateRealize.js +81 -45
  76. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  77. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +117 -87
  78. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  79. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
  80. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
  81. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  82. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
  83. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
  84. package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
  85. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
  86. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
  87. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
  88. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  89. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
  90. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
  91. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  92. package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
  93. package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
  94. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
  95. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
  96. package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -55
  97. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  98. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  99. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  100. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  101. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  102. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +10 -79
  103. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  104. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +15 -65
  105. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  106. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  107. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  108. package/lib/orchestrate/test/orchestrateTestCorrect.js +32 -17
  109. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  110. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
  111. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  112. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  113. package/lib/orchestrate/test/orchestrateTestScenario.js +5 -5
  114. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  115. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +1 -1
  116. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  117. package/lib/orchestrate/test/orchestrateTestWrite.js +37 -21
  118. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  119. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
  120. package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
  121. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
  122. package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
  123. package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
  124. package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
  125. package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
  126. package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
  127. package/package.json +5 -5
  128. package/src/AutoBeAgent.ts +17 -1
  129. package/src/AutoBeMockAgent.ts +1 -0
  130. package/src/constants/AutoBeSystemPromptConstant.ts +13 -13
  131. package/src/factory/createAutoBeContext.ts +1 -0
  132. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
  133. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
  134. package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
  135. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +4 -2
  136. package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
  137. package/src/orchestrate/interface/orchestrateInterface.ts +43 -17
  138. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +12 -33
  139. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +5 -5
  140. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +7 -6
  141. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
  142. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +1 -1
  143. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
  144. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
  145. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
  146. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
  147. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
  148. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
  149. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +19 -1
  150. package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
  151. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +9 -10
  152. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
  153. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
  154. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
  155. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
  156. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +84 -17
  157. package/src/orchestrate/realize/orchestrateRealize.ts +125 -74
  158. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +33 -6
  159. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
  160. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
  161. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
  162. package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
  163. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
  164. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
  165. package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
  166. package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -102
  167. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +18 -91
  168. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +17 -90
  169. package/src/orchestrate/test/orchestrateTestCorrect.ts +7 -6
  170. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
  171. package/src/orchestrate/test/orchestrateTestScenario.ts +12 -6
  172. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +3 -3
  173. package/src/orchestrate/test/orchestrateTestWrite.ts +7 -6
  174. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
  175. package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
  176. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
  177. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
  178. package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
  179. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
  180. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
  181. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
  182. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
  183. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
  184. package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
@@ -4,124 +4,121 @@ import { ILlmSchema } from "@samchon/openapi";
4
4
  import { AutoBeContext } from "../../../context/AutoBeContext";
5
5
  import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
6
6
 
7
- /**
8
- * Removes all import statements that LLM might have incorrectly added. This
9
- * includes standard library imports, auto-injected imports, and any API
10
- * structure imports with wrong paths.
11
- *
12
- * @param code - The code containing imports to remove
13
- * @param typeReferences - List of type names to specifically remove
14
- * @param decoratorType - Optional decorator type to remove
15
- * @returns Code with all imports removed
16
- */
17
- function removeAllImports(
18
- code: string,
19
- typeReferences: string[],
20
- decoratorType?: string,
21
- ): string {
22
- // Remove standard library and auto-injected imports
23
- let cleanedCode = code
24
- // MyGlobal - often with wrong path
25
- .replace(
26
- /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
27
- "",
28
- )
29
- // typia - various import patterns
30
- .replace(
31
- /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
32
- "",
33
- )
34
- .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
35
- .replace(
36
- /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
37
- "",
38
- )
39
- .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
40
- // Prisma client
41
- .replace(
42
- /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
43
- "",
44
- )
45
- // uuid
46
- .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
47
- // toISOStringSafe utility
48
- .replace(
49
- /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm,
50
- "",
51
- )
52
- // JWT imports (if LLM adds them)
53
- .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
54
- .replace(
55
- /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
56
- "",
57
- )
58
- // NestJS HttpException
59
- .replace(
60
- /import\s*{\s*HttpException\s*}\s*from\s*["']@nestjs\/common["']\s*;?\s*/gm,
61
- "",
62
- );
63
-
64
- // Remove API structure imports with wrong paths
65
- // Pattern 1: ../api/structures path (LLM often uses this wrong path)
66
- cleanedCode = cleanedCode.replace(
67
- /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
68
- "",
69
- );
70
- // Pattern 2: @ORGANIZATION/PROJECT-api path (correct path but LLM shouldn't write it)
71
- cleanedCode = cleanedCode.replace(
72
- /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
73
- "",
74
- );
75
-
76
- // Remove specific type imports that match our typeReferences
77
- for (const ref of typeReferences) {
78
- const typeImportRegex = new RegExp(
79
- `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
80
- "gm",
81
- );
82
- cleanedCode = cleanedCode.replace(typeImportRegex, "");
83
- }
84
-
85
- // Remove decorator type imports if LLM mistakenly added them
86
- if (decoratorType) {
87
- const decoratorTypeRegex = new RegExp(
88
- `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
89
- "gm",
90
- );
91
- cleanedCode = cleanedCode.replace(decoratorTypeRegex, "");
92
- }
93
-
94
- return cleanedCode;
95
- }
7
+ // /**
8
+ // * Removes all import statements that LLM might have incorrectly added. This
9
+ // * includes standard library imports, auto-injected imports, and any API
10
+ // * structure imports with wrong paths.
11
+ // *
12
+ // * @param code - The code containing imports to remove
13
+ // * @param typeReferences - List of type names to specifically remove
14
+ // * @param decoratorType - Optional decorator type to remove
15
+ // * @returns Code with all imports removed
16
+ // */
17
+ // function removeAllImports(
18
+ // code: string,
19
+ // typeReferences: string[],
20
+ // decoratorType?: string,
21
+ // ): string {
22
+ // // Remove standard library and auto-injected imports
23
+ // let cleanedCode = code
24
+ // // MyGlobal - often with wrong path
25
+ // .replace(
26
+ // /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
27
+ // "",
28
+ // )
29
+ // // typia - various import patterns
30
+ // .replace(
31
+ // /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
32
+ // "",
33
+ // )
34
+ // .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
35
+ // .replace(
36
+ // /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
37
+ // "",
38
+ // )
39
+ // .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
40
+ // // Prisma client
41
+ // .replace(
42
+ // /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
43
+ // "",
44
+ // )
45
+ // // uuid
46
+ // .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
47
+ // // toISOStringSafe utility
48
+ // .replace(
49
+ // /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/utils\/toISOStringSafe["']\s*;?\s*/gm,
50
+ // "",
51
+ // )
52
+ // // JWT imports (if LLM adds them)
53
+ // .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
54
+ // .replace(
55
+ // /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
56
+ // "",
57
+ // )
58
+ // // NestJS HttpException
59
+ // .replace(
60
+ // /import\s*{\s*HttpException\s*}\s*from\s*["']@nestjs\/common["']\s*;?\s*/gm,
61
+ // "",
62
+ // );
63
+
64
+ // // Remove API structure imports with wrong paths
65
+ // // Pattern 1: ../api/structures path (LLM often uses this wrong path)
66
+ // cleanedCode = cleanedCode.replace(
67
+ // /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
68
+ // "",
69
+ // );
70
+ // // Pattern 2: @ORGANIZATION/PROJECT-api path (correct path but LLM shouldn't write it)
71
+ // cleanedCode = cleanedCode.replace(
72
+ // /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
73
+ // "",
74
+ // );
75
+
76
+ // // Remove specific type imports that match our typeReferences
77
+ // for (const ref of typeReferences) {
78
+ // const typeImportRegex = new RegExp(
79
+ // `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
80
+ // "gm",
81
+ // );
82
+ // cleanedCode = cleanedCode.replace(typeImportRegex, "");
83
+ // }
84
+
85
+ // // Remove decorator type imports if LLM mistakenly added them
86
+ // if (decoratorType) {
87
+ // const decoratorTypeRegex = new RegExp(
88
+ // `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
89
+ // "gm",
90
+ // );
91
+ // cleanedCode = cleanedCode.replace(decoratorTypeRegex, "");
92
+ // }
93
+
94
+ // return cleanedCode;
95
+ // }
96
96
 
97
97
  export async function replaceImportStatements<Model extends ILlmSchema.Model>(
98
98
  ctx: AutoBeContext<Model>,
99
99
  props: {
100
100
  operation: AutoBeOpenApi.IOperation;
101
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
101
102
  code: string;
102
103
  decoratorType?: string;
103
104
  },
104
- ) {
105
- let { operation, code, decoratorType } = props;
106
-
107
- // Extract type references from operation
108
- const typeReferences: string[] = Array.from(
109
- new Set(
110
- [operation.requestBody, operation.responseBody]
111
- .filter((el) => el !== null)
112
- .map((el) => el.typeName.split(".")[0]!),
113
- ),
114
- );
105
+ ): Promise<string> {
106
+ let { code, decoratorType } = props;
115
107
 
116
108
  // Beautify code first for consistent formatting
117
109
  const compiler: IAutoBeCompiler = await ctx.compiler();
118
110
  code = await compiler.typescript.beautify(code);
119
111
 
120
112
  // Remove all LLM-generated imports
121
- code = removeAllImports(code, typeReferences, decoratorType);
113
+ code = code
114
+ .split("\r\n")
115
+ .join("\n")
116
+ .split("\n")
117
+ .filter((str) => str.trim().startsWith("import") === false)
118
+ .join("\n");
122
119
 
123
120
  // Build the standard imports
124
- const imports = getRealizeWriteImportStatements(operation);
121
+ const imports = getRealizeWriteImportStatements(props);
125
122
 
126
123
  // Only add decoratorType import if it exists
127
124
  if (decoratorType) {
@@ -6,7 +6,7 @@ import { v7 } from "uuid";
6
6
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { IAutoBeTestScenarioAuthorizationRole } from "../structures/IAutoBeTestScenarioAuthorizationRole";
9
- import { getReferenceIds } from "../utils/getReferenceIds";
9
+ import { getPrerequisites } from "../utils/getPrerequisites";
10
10
 
11
11
  export const transformTestScenarioHistories = (props: {
12
12
  state: AutoBeState;
@@ -17,26 +17,10 @@ export const transformTestScenarioHistories = (props: {
17
17
  }): Array<
18
18
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
19
19
  > => {
20
- interface IRelationship {
21
- endpoint: AutoBeOpenApi.IEndpoint;
22
- ids: string[];
23
- }
24
20
  const authorizations: AutoBeInterfaceAuthorization[] =
25
21
  props.state.interface?.authorizations ?? [];
26
22
  const authorizationRoles: Map<string, IAutoBeTestScenarioAuthorizationRole> =
27
23
  new Map();
28
- const relationships: IRelationship[] = props.document.operations
29
- .map((operation) => ({
30
- endpoint: {
31
- method: operation.method,
32
- path: operation.path,
33
- },
34
- ids: getReferenceIds({
35
- document: props.document,
36
- operation,
37
- }),
38
- }))
39
- .filter((v) => v.ids.length !== 0);
40
24
 
41
25
  for (const authorization of authorizations) {
42
26
  for (const op of authorization.operations) {
@@ -92,10 +76,6 @@ export const transformTestScenarioHistories = (props: {
92
76
  You may write multiple scenarios for a single included endpoint.
93
77
  Focus on business-logic-oriented E2E flows rather than trivial CRUD.
94
78
 
95
- Please analyze the operations to identify all dependencies required for testing.
96
- Pay close attention to IDs and related values in the API,
97
- and ensure you identify all dependencies between endpoints.
98
-
99
79
  \`\`\`json
100
80
  ${JSON.stringify({
101
81
  operations: props.document.operations,
@@ -109,46 +89,20 @@ export const transformTestScenarioHistories = (props: {
109
89
  When testing endpoints that require authentication, ensure you include the corresponding
110
90
  join/login operations in your test scenario to establish proper authentication context.
111
91
 
112
- Generate test scenarios only for these included endpoints. Do not create scenarios for excluded endpoints. Operations not listed here may be used only as dependencies.
113
-
114
- ${props.include
115
- .map((el, i) => {
116
- const roles = Array.from(authorizationRoles.values()).filter(
117
- (role) => role.name === el.authorizationRole,
118
- );
119
-
120
- const requiredIds = getReferenceIds({
92
+ \`\`\`json
93
+ ${JSON.stringify(
94
+ props.include.map((el) => ({
95
+ ...el,
96
+ prerequisites: getPrerequisites({
121
97
  document: props.document,
122
- operation: el,
123
- });
124
- return StringUtil.trim`
125
- ## ${i + 1}. ${el.method.toUpperCase()} ${el.path}
126
-
127
- Related Authentication APIs:
128
-
129
- ${
130
- roles.length > 0
131
- ? roles
132
- .map((role) => {
133
- return StringUtil.trim`
134
- - ${role.join?.method.toUpperCase()}: ${role.join?.path}
135
- - ${role.login?.method.toUpperCase()}: ${role.login?.path}
136
- `;
137
- })
138
- .join("\n")
139
- : "- None"
140
- }
141
-
142
- Required IDs:
143
-
144
- - ${
145
- requiredIds.length > 0
146
- ? requiredIds.map((id) => `\`${id}\``).join(", ")
147
- : "None"
148
- }
149
- `;
150
- })
151
- .join("\n")}
98
+ endpoint: el,
99
+ }),
100
+ authorizationRoles: Array.from(authorizationRoles.values()).filter(
101
+ (role) => role.name === el.authorizationRole,
102
+ ),
103
+ })),
104
+ )}
105
+ \`\`\`
152
106
 
153
107
  ## Excluded from Test Plan
154
108
 
@@ -156,37 +110,10 @@ export const transformTestScenarioHistories = (props: {
156
110
  These endpoints do not need to be tested again.
157
111
  However, it is allowed to reference or depend on these endpoints when writing test codes for other purposes.
158
112
 
159
- ${props.exclude
160
- .map((el) => `- ${el.method.toUpperCase()}: ${el.path}`)
161
- .join("\n")}
162
-
163
- ## Candidate Dependencies
164
-
165
- List of candidate dependencies extracted from path parameters and request bodies.
166
-
167
- Apply dependency resolution to the target endpoint from "Included in Test Plan" and to dependencies found recursively from it.
168
- For each required ID, locate the operation that creates the resource. Include the creator only if that operation exists in the provided operations list. Do not assume or invent operations. If no creator exists, treat the ID as an external or pre-existing input.
169
-
170
- Dependency resolution steps:
171
- 1. Starting from the target endpoint, collect required IDs.
172
- 2. For each ID, search for a creator operation (typically POST).
173
- 3. If found, add it to the dependency chain in execution order and repeat for its own required IDs.
174
- 4. Stop when no further creators exist or are needed.
175
-
176
- For each some_entity_id pattern, use the same approach: include a creator only when it is present in the operations list.
177
-
178
- Endpoint | Required IDs (MUST be created by other APIs)
179
- ---------|---------------------------------------------------
180
- ${relationships
181
- .map((r) =>
182
- [
183
- `\`${r.endpoint.method} ${r.endpoint.path}\``,
184
- r.ids.map((id) => `\`${id}\``).join(", "),
185
- ].join(" | "),
186
- )
187
- .join("\n")}
188
-
189
- Example: If an endpoint requires \`articleId\` and \`POST /articles\` exists, include it in dependencies
113
+ \`\`\`json
114
+ ${JSON.stringify(props.exclude)}
115
+ \`\`\`
116
+
190
117
  `,
191
118
  } satisfies IAgenticaHistoryJson.IAssistantMessage,
192
119
  ];
@@ -6,7 +6,7 @@ import { v7 } from "uuid";
6
6
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { IAutoBeTestScenarioApplication } from "../structures/IAutoBeTestScenarioApplication";
9
- import { getReferenceIds } from "../utils/getReferenceIds";
9
+ import { getPrerequisites } from "../utils/getPrerequisites";
10
10
 
11
11
  export function transformTestScenarioReviewHistories(props: {
12
12
  state: AutoBeState;
@@ -15,11 +15,6 @@ export function transformTestScenarioReviewHistories(props: {
15
15
  }): Array<
16
16
  IAgenticaHistoryJson.ISystemMessage | IAgenticaHistoryJson.IAssistantMessage
17
17
  > {
18
- interface IRelationship {
19
- endpoint: AutoBeOpenApi.IEndpoint;
20
- ids: string[];
21
- }
22
-
23
18
  const document: AutoBeOpenApi.IDocument | undefined =
24
19
  props.state.interface?.document;
25
20
  if (document === undefined) {
@@ -28,20 +23,13 @@ export function transformTestScenarioReviewHistories(props: {
28
23
  );
29
24
  }
30
25
 
31
- const relationships: IRelationship[] = document.operations
32
- .map((o) => ({
33
- endpoint: {
34
- method: o.method,
35
- path: o.path,
36
- },
37
- ids: getReferenceIds({
38
- document,
39
- operation: o,
40
- }),
41
- }))
42
- .filter((v) => v.ids.length !== 0);
43
-
44
26
  return [
27
+ {
28
+ id: v7(),
29
+ created_at: new Date().toISOString(),
30
+ type: "systemMessage",
31
+ text: AutoBeSystemPromptConstant.TEST_SCENARIO,
32
+ },
45
33
  {
46
34
  id: v7(),
47
35
  created_at: new Date().toISOString(),
@@ -74,85 +62,24 @@ export function transformTestScenarioReviewHistories(props: {
74
62
  Match each operation with its corresponding schema.
75
63
 
76
64
  \`\`\`json
77
- ${JSON.stringify({
78
- operations: document.operations,
79
- })}
65
+ ${JSON.stringify({ operations: document.operations })}
80
66
  \`\`\`
81
67
 
82
- ## Test Scenario Groups
68
+ ## Test Scenario Groups to Review
83
69
 
84
- Please review the following test scenario groups:
70
+ Each scenario group includes the target endpoint and its prerequisite endpoints.
85
71
 
86
72
  \`\`\`json
87
73
  ${JSON.stringify(
88
- props.groups.map((g) => {
89
- return {
90
- ...g,
91
- scenarios: g.scenarios.map((s) => {
92
- const requiredId: string[] = [];
93
-
94
- s.dependencies.forEach((dep) => {
95
- document.operations.forEach((op) => {
96
- if (
97
- g.endpoint.method === op.method &&
98
- g.endpoint.path === op.path
99
- ) {
100
- requiredId.push(
101
- ...getReferenceIds({ document, operation: op }),
102
- );
103
- }
104
-
105
- if (
106
- op.method === dep.endpoint.method &&
107
- op.path === dep.endpoint.path
108
- ) {
109
- requiredId.push(
110
- ...getReferenceIds({ document, operation: op }),
111
- );
112
- }
113
- });
114
- });
115
-
116
- return {
117
- ...s,
118
- requiredIds:
119
- requiredId.length > 0
120
- ? Array.from(new Set(requiredId))
121
- : [],
122
- };
123
- }),
124
- };
125
- }),
74
+ props.groups.map((g) => ({
75
+ ...g,
76
+ prerequisites: getPrerequisites({
77
+ document,
78
+ endpoint: g.endpoint,
79
+ }),
80
+ })),
126
81
  )}
127
82
  \`\`\`
128
-
129
- ## Candidate Dependencies
130
-
131
- List of candidate dependencies extracted from path parameters and request bodies.
132
-
133
- Apply dependency resolution to the target endpoint from "Included in Test Plan" and to dependencies found recursively from it.
134
- For each required ID, locate the operation that creates the resource. Include the creator only if that operation exists in the provided operations list. Do not assume or invent operations. If no creator exists, treat the ID as an external or pre-existing input.
135
-
136
- Dependency resolution steps:
137
- 1. Starting from the target endpoint, collect required IDs.
138
- 2. For each ID, search for a creator operation (typically POST).
139
- 3. If found, add it to the dependency chain in execution order and repeat for its own required IDs.
140
- 4. Stop when no further creators exist or are needed.
141
-
142
- For each some_entity_id pattern, use the same approach: include a creator only when it is present in the operations list.
143
-
144
- Endpoint | Required IDs (MUST be created by other APIs)
145
- ---------|---------------------------------------------------
146
- ${relationships
147
- .map((r) =>
148
- [
149
- `\`${r.endpoint.method} ${r.endpoint.path}\``,
150
- r.ids.map((id) => `\`${id}\``).join(", "),
151
- ].join(" | "),
152
- )
153
- .join("\n")}
154
-
155
- Example: If an endpoint requires \`articleId\` and \`POST /articles\` exists, include it in dependencies
156
83
  `,
157
84
  },
158
85
  ];
@@ -179,11 +179,12 @@ const correct = async <Model extends ILlmSchema.Model>(
179
179
  });
180
180
  if (pointer.value === null) throw new Error("Failed to correct test code.");
181
181
 
182
- pointer.value.revise.final = await completeTestCode(
183
- ctx,
184
- props.function.artifacts,
185
- pointer.value.revise.final,
186
- );
182
+ if (pointer.value.revise.final)
183
+ pointer.value.revise.final = await completeTestCode(
184
+ ctx,
185
+ props.function.artifacts,
186
+ pointer.value.revise.final,
187
+ );
187
188
  pointer.value.draft = await completeTestCode(
188
189
  ctx,
189
190
  props.function.artifacts,
@@ -201,7 +202,7 @@ const correct = async <Model extends ILlmSchema.Model>(
201
202
  think: pointer.value.think,
202
203
  draft: pointer.value.draft,
203
204
  review: pointer.value.revise?.review,
204
- final: pointer.value.revise?.final,
205
+ final: pointer.value.revise?.final ?? undefined,
205
206
  } satisfies AutoBeTestCorrectEvent);
206
207
  const newFunction: IAutoBeTestFunction = {
207
208
  ...props.function,
@@ -10,6 +10,7 @@ import { v7 } from "uuid";
10
10
 
11
11
  import { AutoBeContext } from "../../context/AutoBeContext";
12
12
  import { assertSchemaModel } from "../../context/assertSchemaModel";
13
+ import { completeTestCode } from "./compile/completeTestCode";
13
14
  import { transformTestCorrectInvalidRequestHistories } from "./histories/transformTestCorrectInvalidRequestHistories";
14
15
  import { IAutoBeTestCorrectInvalidRequestApplication } from "./structures/IAutoBeTestCorrectInvalidRequestApplication";
15
16
  import { IAutoBeTestFunction } from "./structures/IAutoBeTestFunction";
@@ -82,6 +83,17 @@ const correct = async <Model extends ILlmSchema.Model>(
82
83
  if (pointer.value === null) throw new Error("Failed to correct test code.");
83
84
  else if (pointer.value === false) return event; // other's responsibility
84
85
 
86
+ if (pointer.value.revise.final)
87
+ pointer.value.revise.final = await completeTestCode(
88
+ ctx,
89
+ write.artifacts,
90
+ pointer.value.revise.final,
91
+ );
92
+ pointer.value.draft = await completeTestCode(
93
+ ctx,
94
+ write.artifacts,
95
+ pointer.value.draft,
96
+ );
85
97
  ctx.dispatch({
86
98
  type: "testCorrect",
87
99
  id: v7(),
@@ -97,7 +109,7 @@ const correct = async <Model extends ILlmSchema.Model>(
97
109
  think: pointer.value.think,
98
110
  draft: pointer.value.draft,
99
111
  review: pointer.value.revise?.review,
100
- final: pointer.value.revise?.final,
112
+ final: pointer.value.revise?.final ?? undefined,
101
113
  } satisfies AutoBeTestCorrectEvent);
102
114
  const newWrite: IAutoBeTestFunction = {
103
115
  artifacts: write.artifacts,
@@ -5,13 +5,18 @@ import {
5
5
  AutoBeProgressEventBase,
6
6
  AutoBeTestScenario,
7
7
  } from "@autobe/interface";
8
- import { AutoBeEndpointComparator, MapUtil, StringUtil } from "@autobe/utils";
8
+ import {
9
+ AutoBeOpenApiEndpointComparator,
10
+ MapUtil,
11
+ StringUtil,
12
+ } from "@autobe/utils";
9
13
  import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
10
14
  import { HashMap, IPointer, Pair } from "tstl";
11
15
  import typia from "typia";
12
16
  import { NamingConvention } from "typia/lib/utils/NamingConvention";
13
17
  import { v7 } from "uuid";
14
18
 
19
+ import { AutoBeConfigConstant } from "../../constants/AutoBeConfigConstant";
15
20
  import { AutoBeContext } from "../../context/AutoBeContext";
16
21
  import { assertSchemaModel } from "../../context/assertSchemaModel";
17
22
  import { divideArray } from "../../utils/divideArray";
@@ -24,6 +29,7 @@ import { IAutoBeTestScenarioAuthorizationRole } from "./structures/IAutoBeTestSc
24
29
  export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
25
30
  ctx: AutoBeContext<Model>,
26
31
  instruction: string,
32
+ capacity: number = AutoBeConfigConstant.INTERFACE_CAPACITY,
27
33
  ): Promise<AutoBeTestScenario[]> {
28
34
  const document: AutoBeOpenApi.IDocument | undefined =
29
35
  ctx.state().interface?.document;
@@ -45,8 +51,8 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
45
51
  op,
46
52
  ),
47
53
  ),
48
- AutoBeEndpointComparator.hashCode,
49
- AutoBeEndpointComparator.equals,
54
+ AutoBeOpenApiEndpointComparator.hashCode,
55
+ AutoBeOpenApiEndpointComparator.equals,
50
56
  );
51
57
 
52
58
  const endpointNotFound: string = [
@@ -74,7 +80,7 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
74
80
  do {
75
81
  const matrix: AutoBeOpenApi.IOperation[][] = divideArray({
76
82
  array: include,
77
- capacity: 4,
83
+ capacity: capacity ?? AutoBeConfigConstant.INTERFACE_CAPACITY,
78
84
  });
79
85
  await executeCachedBatch(
80
86
  matrix.map((include) => async (promptCacheKey) => {
@@ -405,8 +411,8 @@ const uniqueScenarioGroups = (
405
411
  ): IAutoBeTestScenarioApplication.IScenarioGroup[] =>
406
412
  new HashMap(
407
413
  groups.map((g) => new Pair(g.endpoint, g)),
408
- AutoBeEndpointComparator.hashCode,
409
- AutoBeEndpointComparator.equals,
414
+ AutoBeOpenApiEndpointComparator.hashCode,
415
+ AutoBeOpenApiEndpointComparator.equals,
410
416
  )
411
417
  .toJSON()
412
418
  .map((it) => it.second);
@@ -1,6 +1,6 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
2
  import { AutoBeProgressEventBase, AutoBeTestScenario } from "@autobe/interface";
3
- import { AutoBeEndpointComparator } from "@autobe/utils";
3
+ import { AutoBeOpenApiEndpointComparator } from "@autobe/utils";
4
4
  import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
5
5
  import { HashMap, IPointer, Pair } from "tstl";
6
6
  import typia from "typia";
@@ -172,8 +172,8 @@ const uniqueScenarioGroups = (
172
172
  ): IAutoBeTestScenarioApplication.IScenarioGroup[] =>
173
173
  new HashMap(
174
174
  groups.map((g) => new Pair(g.endpoint, g)),
175
- AutoBeEndpointComparator.hashCode,
176
- AutoBeEndpointComparator.equals,
175
+ AutoBeOpenApiEndpointComparator.hashCode,
176
+ AutoBeOpenApiEndpointComparator.equals,
177
177
  )
178
178
  .toJSON()
179
179
  .map((it) => it.second);