@autobe/agent 0.25.0 → 0.25.2

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 (199) 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/AutoBeConfigConstant.d.ts +1 -1
  6. package/lib/constants/AutoBeSystemPromptConstant.d.ts +13 -13
  7. package/lib/factory/createAutoBeContext.js +32 -3
  8. package/lib/factory/createAutoBeContext.js.map +1 -1
  9. package/lib/index.mjs +2585 -1009
  10. package/lib/index.mjs.map +1 -1
  11. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +8 -8
  12. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +2 -2
  13. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  14. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  15. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
  16. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  17. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
  18. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
  19. package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
  20. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
  21. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +2 -2
  22. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  23. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +3 -3
  24. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  25. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
  26. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
  27. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
  28. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  29. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  30. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  31. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  32. package/lib/orchestrate/interface/orchestrateInterface.js +25 -9
  33. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  34. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +278 -47
  35. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  36. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +96 -70
  37. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  38. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -3
  39. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  40. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +2 -2
  41. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +29 -30
  42. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  43. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +278 -47
  44. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  45. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
  46. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
  47. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
  48. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +88 -42
  49. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  50. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +82 -14
  51. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  52. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
  53. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
  54. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +3 -3
  55. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
  56. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js +3 -0
  57. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
  58. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
  59. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
  60. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +114 -9
  61. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  62. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +46 -3
  63. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  64. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
  65. package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
  66. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  67. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +8 -8
  68. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +20 -20
  69. package/lib/orchestrate/prisma/orchestratePrismaReview.js +20 -20
  70. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +30 -30
  71. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +9 -10
  72. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -1
  73. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
  74. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  75. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
  76. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
  77. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  78. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
  79. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  80. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
  81. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +103 -40
  82. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  83. package/lib/orchestrate/realize/orchestrateRealize.js +79 -45
  84. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  85. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +16 -16
  86. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +12 -12
  87. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +117 -87
  88. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  89. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
  90. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
  91. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  92. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +21 -13
  93. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
  94. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
  95. package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
  96. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
  97. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
  98. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
  99. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  100. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
  101. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
  102. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  103. package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
  104. package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
  105. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
  106. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
  107. package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -55
  108. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  109. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  110. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  111. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  112. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  113. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +10 -79
  114. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  115. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +15 -65
  116. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  117. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  118. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  119. package/lib/orchestrate/test/orchestrateTestCorrect.js +32 -17
  120. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  121. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
  122. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  123. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  124. package/lib/orchestrate/test/orchestrateTestScenario.js +5 -5
  125. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  126. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +1 -1
  127. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  128. package/lib/orchestrate/test/orchestrateTestWrite.js +37 -21
  129. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  130. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
  131. package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
  132. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
  133. package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
  134. package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
  135. package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
  136. package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
  137. package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
  138. package/package.json +5 -5
  139. package/src/AutoBeAgent.ts +17 -1
  140. package/src/AutoBeMockAgent.ts +1 -0
  141. package/src/constants/AutoBeConfigConstant.ts +1 -1
  142. package/src/constants/AutoBeSystemPromptConstant.ts +13 -13
  143. package/src/factory/createAutoBeContext.ts +33 -3
  144. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +2 -2
  145. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
  146. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
  147. package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
  148. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +4 -2
  149. package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
  150. package/src/orchestrate/interface/orchestrateInterface.ts +43 -17
  151. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +12 -33
  152. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +5 -5
  153. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +7 -6
  154. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
  155. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +1 -1
  156. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
  157. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
  158. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
  159. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +4 -5
  160. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
  161. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
  162. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
  163. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +49 -3
  164. package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
  165. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +9 -10
  166. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
  167. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
  168. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
  169. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
  170. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +84 -17
  171. package/src/orchestrate/realize/orchestrateRealize.ts +123 -74
  172. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +33 -6
  173. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
  174. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +21 -13
  175. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
  176. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
  177. package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
  178. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
  179. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
  180. package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
  181. package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -102
  182. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +18 -91
  183. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +17 -90
  184. package/src/orchestrate/test/orchestrateTestCorrect.ts +7 -6
  185. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
  186. package/src/orchestrate/test/orchestrateTestScenario.ts +12 -6
  187. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +3 -3
  188. package/src/orchestrate/test/orchestrateTestWrite.ts +7 -6
  189. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
  190. package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
  191. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
  192. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
  193. package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
  194. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
  195. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
  196. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
  197. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
  198. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
  199. package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
@@ -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);
@@ -99,11 +99,12 @@ async function process<Model extends ILlmSchema.Model>(
99
99
  throw new Error("Failed to create test code.");
100
100
  }
101
101
 
102
- pointer.value.revise.final = await completeTestCode(
103
- ctx,
104
- artifacts,
105
- pointer.value.revise.final,
106
- );
102
+ if (pointer.value.revise.final)
103
+ pointer.value.revise.final = await completeTestCode(
104
+ ctx,
105
+ artifacts,
106
+ pointer.value.revise.final,
107
+ );
107
108
  pointer.value.draft = await completeTestCode(
108
109
  ctx,
109
110
  artifacts,
@@ -118,7 +119,7 @@ async function process<Model extends ILlmSchema.Model>(
118
119
  domain: pointer.value.domain,
119
120
  draft: pointer.value.draft,
120
121
  review: pointer.value.revise?.review,
121
- final: pointer.value.revise?.final,
122
+ final: pointer.value.revise?.final ?? undefined,
122
123
  tokenUsage,
123
124
  completed: ++progress.completed,
124
125
  total: progress.total,
@@ -91,161 +91,6 @@ export namespace IAutoBeTestCorrectApplication {
91
91
  revise: IReviseProps;
92
92
  }
93
93
 
94
- // /**
95
- // * Comprehensive compilation error analysis and correction planning
96
- // * properties.
97
- // *
98
- // * This interface structures the AI's deep thinking process during error
99
- // * correction, requiring individual analysis of each compilation error along
100
- // * with an overall strategy assessment. The AI must meticulously examine every
101
- // * error message, understand its root cause, and propose targeted solutions
102
- // * while maintaining a holistic view of the correction process.
103
- // *
104
- // * The structure enforces granular error analysis while ensuring the AI
105
- // * maintains awareness of overarching patterns and systemic issues that may
106
- // * require broader strategic changes like scenario rewrites or architectural
107
- // * adjustments.
108
- // */
109
- // export interface IThinkProps {
110
- // /**
111
- // * Individual analyses for each compilation diagnostic.
112
- // *
113
- // * Contains detailed examination of every compilation error encountered,
114
- // * with specific analysis and targeted solutions. Each entry represents a
115
- // * single compilation diagnostic that must be resolved. The AI must read the
116
- // * IAutoBeTypeScriptCompileResult.IDiagnostic objects, interpret their
117
- // * content, and provide human-readable summaries along with precise fixes.
118
- // *
119
- // * This granular approach ensures no error is overlooked and each issue
120
- // * receives appropriate attention and resolution strategy.
121
- // */
122
- // analyses: IDiagnosticAnalysis[] & tags.MinItems<1>;
123
-
124
- // /**
125
- // * Overall assessment of compilation issues and correction strategies.
126
- // *
127
- // * Synthesizes patterns across all individual errors to identify systemic
128
- // * issues and overarching correction strategies. This includes verification
129
- // * of TEST_WRITE.md and TEST_CORRECT.md compliance, assessment of whether
130
- // * scenario rewrites are needed, identification of common error patterns,
131
- // * and documentation of broad strategic decisions.
132
- // *
133
- // * Must address: type safety compliance, async/await patterns, scenario
134
- // * adaptation requirements, and overall code quality considerations that
135
- // * span multiple errors.
136
- // */
137
- // overall: string;
138
- // }
139
-
140
- // /**
141
- // * Detailed analysis structure for individual compilation diagnostics.
142
- // *
143
- // * Represents the AI's systematic approach to understanding and resolving each
144
- // * compilation diagnostic. Each diagnostic must be thoroughly analyzed to
145
- // * understand its root cause, with a specific solution that addresses the
146
- // * exact issue while maintaining type safety and code quality.
147
- // */
148
- // export interface IDiagnosticAnalysis {
149
- // /**
150
- // * AI-generated summary of the compilation diagnostic.
151
- // *
152
- // * The AI must analyze the `IAutoBeTypeScriptCompileResult.IDiagnostic`
153
- // * object and provide a clear, concise summary of the error. This should
154
- // * include the error message, file location, line/column position, and error
155
- // * code in a human-readable format. The AI interprets and restructures the
156
- // * raw diagnostic data to present it in a more understandable way.
157
- // *
158
- // * **IMPORTANT**: The AI should not copy the raw diagnostic object. Instead,
159
- // * it must read and understand the diagnostic details, then compose a clear
160
- // * string description that captures all essential information about the
161
- // * error.
162
- // */
163
- // diagnostic: string;
164
-
165
- // /**
166
- // * Root cause analysis of why this compilation error occurred.
167
- // *
168
- // * **🚨 CRITICAL FIRST CHECK: Is this caused by INTENTIONAL TYPE ERROR TESTING? 🚨**
169
- // * - Look for `as any` usage in the error location
170
- // * - Check if code is intentionally sending wrong types to test type validation
171
- // * - Check if code is testing missing required fields
172
- // * - **IF YES → Root cause: "Prohibited type error testing code that must be DELETED"**
173
- // *
174
- // * **⚠️ THINK BEYOND THE DIAGNOSTIC LINE - EXPAND YOUR INVESTIGATION ⚠️**
175
- // * - Do NOT focus only on the error line - it might be just a symptom
176
- // * - The real cause might be ABOVE the error location in earlier code
177
- // * - The test scenario itself might be fundamentally flawed or impossible
178
- // * - Consider if the scenario is requesting non-existent APIs or prohibited actions
179
- // * - Example: Error on line 50 might be caused by wrong type assignment on line 20
180
- // * - Example: API call fails because the scenario describes unimplemented functionality
181
- // *
182
- // * AI must examine the error message carefully and identify the specific
183
- // * reason for failure. This includes understanding whether it's a missing
184
- // * property, type mismatch, nullable/undefined issue, incorrect API usage,
185
- // * intentional type error testing, flawed scenario, or other TypeScript
186
- // * violations. The analysis should be precise and fact-based, but also
187
- // * consider the broader context and causal relationships.
188
- // *
189
- // * **MANDATORY**: The AI must thoroughly review ALL sections of
190
- // * TEST_CORRECT.md and apply relevant error patterns and analysis guidelines
191
- // * from sections 4.1-4.16 to ensure accurate diagnosis.
192
- // *
193
- // * Example: "Property 'code' is missing because the object literal lacks
194
- // * this required field from ICommunityPlatformCommunity.ICreate interface"
195
- // *
196
- // * Example: "Type error caused by intentional wrong type test using 'as any'
197
- // * - prohibited pattern that must be deleted"
198
- // *
199
- // * Example: "API endpoint doesn't exist - scenario requests unimplemented
200
- // * functionality that cannot be tested"
201
- // */
202
- // analysis: string;
203
-
204
- // /**
205
- // * Specific solution to resolve this compilation error.
206
- // *
207
- // * **🚨 IF ROOT CAUSE IS TYPE ERROR TESTING → Solution: "DELETE entire test block" 🚨**
208
- // * **🚨 IF PROBLEM IS UNRECOVERABLE → Solution: "DELETE the problematic section" 🚨**
209
- // * - NEVER try to "fix" intentional type error tests - DELETE them
210
- // * - NEVER violate type safety to force a fix - DELETE instead
211
- // * - Tests using `as any` to send wrong types must be DELETED
212
- // * - Tests checking type validation must be DELETED
213
- // * - Unrecoverable compilation errors should result in DELETION
214
- // *
215
- // * **THREE SOLUTION TYPES:**
216
- // * 1. **FIX**: Correct the error while maintaining functionality
217
- // * 2. **DELETE**: Remove prohibited or unrecoverable code entirely
218
- // * 3. **REWRITE**: Restructure if the scenario itself is fundamentally flawed
219
- // *
220
- // * Detailed correction strategy that addresses the exact issue identified in
221
- // * the analysis. Solutions must be actionable, type-safe, and compliant with
222
- // * all project guidelines. For nullable/undefined errors with typia tags,
223
- // * immediately apply typia.assert(value!) pattern. For missing properties,
224
- // * specify what will be added and how.
225
- // *
226
- // * **CRITICAL**: The AI must thoroughly review BOTH TEST_WRITE.md and
227
- // * TEST_CORRECT.md before proposing solutions. All prohibitions from
228
- // * TEST_WRITE.md must be strictly respected (no type bypasses, proper
229
- // * async/await usage, etc.), and correction patterns from TEST_CORRECT.md
230
- // * sections 4.1-4.16 must be properly applied.
231
- // *
232
- // * **DELETION IS A VALID SOLUTION** when:
233
- // * - Code violates absolute prohibitions
234
- // * - Fixing would require type safety violations
235
- // * - The scenario describes impossible functionality
236
- // * - Multiple fix attempts have failed
237
- // *
238
- // * Example: "Add missing 'code' property using typia.random<string>() to
239
- // * generate a valid string value that satisfies the interface requirement"
240
- // *
241
- // * Example: "DELETE this entire test - it's testing type errors with 'as any'"
242
- // *
243
- // * Example: "DELETE this section - API endpoint doesn't exist and cannot be
244
- // * tested without violating type safety"
245
- // */
246
- // solution: string;
247
- // }
248
-
249
94
  /**
250
95
  * Revision properties for the final review and implementation phases.
251
96
  *
@@ -253,74 +98,6 @@ export namespace IAutoBeTestCorrectApplication {
253
98
  * workflow, ensuring systematic review and production-ready code delivery.
254
99
  */
255
100
  export interface IReviseProps {
256
- // /**
257
- // * Dual-document compliance validation for TEST_WRITE.md and
258
- // * TEST_CORRECT.md.
259
- // *
260
- // * This property tracks whether each section from BOTH TEST_WRITE.md and
261
- // * TEST_CORRECT.md guidelines has been properly followed. Since the correct
262
- // * agent must ensure compliance with both documents, keys should include
263
- // * sections from both prompt files.
264
- // *
265
- // * Each ICheck item should have:
266
- // *
267
- // * - Title: Prefixed with source document for clarity ("TEST_WRITE: " or
268
- // * "TEST_CORRECT: ")
269
- // * - State: Compliance status (true if followed, false if violated)
270
- // *
271
- // * Note: Section identifiers may evolve as documentation updates, so
272
- // * implementations should be flexible in handling different key formats.
273
- // *
274
- // * Example:
275
- // *
276
- // * ```typescript
277
- // * rules: [
278
- // * { title: "TEST_WRITE: 1. Role and Responsibility", state: true },
279
- // * { title: "TEST_WRITE: 3.1. Import Management", state: true },
280
- // * {
281
- // * title: "TEST_CORRECT: 4.1. Missing Properties Pattern",
282
- // * state: true,
283
- // * },
284
- // * {
285
- // * title: "TEST_CORRECT: 4.2. Type Mismatch Pattern",
286
- // * state: false,
287
- // * },
288
- // * // ... other sections from both documents
289
- // * ];
290
- // * ```
291
- // */
292
- // rules: ICheck[] & tags.MinItems<1>;
293
-
294
- // /**
295
- // * Combined quality checklist validation from both prompt documents.
296
- // *
297
- // * This property captures the compliance status for checklist items from
298
- // * BOTH TEST_WRITE.md (Section 5: Final Checklist) and TEST_CORRECT.md
299
- // * (Section 5: Final Review Checklist). The correct agent must validate
300
- // * against both checklists to ensure comprehensive quality control.
301
- // *
302
- // * Each ICheck item should have:
303
- // *
304
- // * - Title: Checklist item as described in the documents
305
- // * - State: Whether the criterion has been satisfied
306
- // *
307
- // * Note: Checklist items may be updated over time, so implementations should
308
- // * adapt to documentation changes while maintaining the validation purpose.
309
- // *
310
- // * Example:
311
- // *
312
- // * ```typescript
313
- // * checkList: [
314
- // * { title: "No compilation errors", state: true },
315
- // * { title: "Proper async/await usage", state: true },
316
- // * { title: "All typia tags preserved", state: true },
317
- // * { title: "No type bypasses or workarounds", state: false },
318
- // * // ... other checklist items from both documents
319
- // * ];
320
- // * ```
321
- // */
322
- // checkList: ICheck[] & tags.MinItems<1>;
323
-
324
101
  /**
325
102
  * Step 3: Code review and correction validation.
326
103
  *
@@ -347,17 +124,21 @@ export namespace IAutoBeTestCorrectApplication {
347
124
  * incorporating all review feedback and validation results. This code
348
125
  * represents the completed error correction, guaranteed to compile
349
126
  * successfully while preserving all original test functionality and
350
- * business logic.
127
+ * business logic. When the draft correction already perfectly resolves all
128
+ * issues with no problems found during review, this value can be null,
129
+ * indicating no further refinement was necessary.
351
130
  *
352
131
  * The final implementation resolves all compilation issues, maintains
353
132
  * strict type safety, follows all established conventions, and delivers a
354
133
  * production-ready test that accurately validates the intended API
355
- * behaviors and user workflows.
134
+ * behaviors and user workflows. A null value signifies the draft correction
135
+ * was already optimal and requires no modifications.
356
136
  *
357
137
  * Workflow: Review integration → Final refinement → Production-ready
358
- * implementation. This is the ultimate deliverable that will replace the
359
- * compilation-failed code.
138
+ * implementation (or null if draft needs no changes). This is the ultimate
139
+ * deliverable that will replace the compilation-failed code when provided,
140
+ * otherwise the draft correction is used as-is.
360
141
  */
361
- final: string;
142
+ final: string | null;
362
143
  }
363
144
  }
@@ -131,7 +131,10 @@ export namespace IAutoBeTestCorrectInvalidRequestApplication {
131
131
  * Final corrected code.
132
132
  *
133
133
  * The complete, cleaned test code with all invalid API request sections
134
- * removed, ready for compilation.
134
+ * removed, ready for compilation. When the draft already successfully
135
+ * removes all problematic code with no additional issues found during
136
+ * review, this value can be null, indicating the draft deletion was
137
+ * sufficient and requires no further changes.
135
138
  *
136
139
  * This code must:
137
140
  *
@@ -140,7 +143,10 @@ export namespace IAutoBeTestCorrectInvalidRequestApplication {
140
143
  * - Have no `as any` or similar type violations
141
144
  * - Maintain the original file structure
142
145
  * - Be production-ready E2E test code
146
+ *
147
+ * A null value indicates the draft successfully removed all invalid code
148
+ * and needs no additional modifications.
143
149
  */
144
- final: string;
150
+ final: string | null;
145
151
  }
146
152
  }