@autobe/agent 0.9.1 → 0.10.0

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 (185) hide show
  1. package/lib/AutoBeAgent.js +16 -5
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +6 -4
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/context/AutoBeTokenUsage.d.ts +15 -1
  6. package/lib/context/AutoBeTokenUsage.js +56 -1
  7. package/lib/context/AutoBeTokenUsage.js.map +1 -1
  8. package/lib/context/IAutoBeApplicationProps.d.ts +0 -61
  9. package/lib/factory/createAutoBeApplication.js +298 -773
  10. package/lib/factory/createAutoBeApplication.js.map +1 -1
  11. package/lib/index.mjs +5116 -7271
  12. package/lib/index.mjs.map +1 -1
  13. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +82 -319
  14. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
  15. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js +0 -1
  16. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -1
  17. package/lib/orchestrate/analyze/orchestrateAnalyze.js +97 -294
  18. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  19. package/lib/orchestrate/facade/transformFacadeStateMessage.js +2 -2
  20. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  21. package/lib/orchestrate/index.d.ts +2 -2
  22. package/lib/orchestrate/index.js +4 -4
  23. package/lib/orchestrate/index.js.map +1 -1
  24. package/lib/orchestrate/interface/orchestrateInterface.js +9 -3
  25. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  26. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +56 -142
  27. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  28. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +195 -199
  29. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
  30. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +75 -172
  31. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  32. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +772 -1097
  33. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  34. package/lib/orchestrate/interface/transformInterfaceHistories.js +2 -0
  35. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
  36. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +64 -175
  37. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  38. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +552 -1073
  39. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  40. package/lib/orchestrate/prisma/orchestratePrismaSchema.js +571 -1119
  41. package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
  42. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +9 -0
  43. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
  44. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +8 -0
  45. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
  46. package/lib/orchestrate/realize/orchestrateRealize.d.ts +11 -0
  47. package/lib/orchestrate/realize/orchestrateRealize.js +109 -0
  48. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -0
  49. package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +25 -0
  50. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +337 -0
  51. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -0
  52. package/lib/orchestrate/realize/orchestrateRealizeIntegrator.d.ts +52 -0
  53. package/lib/orchestrate/realize/orchestrateRealizeIntegrator.js +57 -0
  54. package/lib/orchestrate/realize/orchestrateRealizeIntegrator.js.map +1 -0
  55. package/lib/orchestrate/realize/orchestrateRealizePlanner.d.ts +80 -0
  56. package/lib/orchestrate/realize/orchestrateRealizePlanner.js +53 -0
  57. package/lib/orchestrate/realize/orchestrateRealizePlanner.js.map +1 -0
  58. package/lib/orchestrate/realize/orchestrateRealizeValidator.d.ts +46 -0
  59. package/lib/orchestrate/realize/orchestrateRealizeValidator.js +37 -0
  60. package/lib/orchestrate/realize/orchestrateRealizeValidator.js.map +1 -0
  61. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +33 -0
  62. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js +3 -0
  63. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +1 -0
  64. package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +5 -0
  65. package/lib/orchestrate/realize/transformRealizeCoderHistories.js +127 -0
  66. package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -0
  67. package/lib/orchestrate/test/compile/completeTestCode.d.ts +2 -0
  68. package/lib/orchestrate/test/compile/completeTestCode.js +21 -0
  69. package/lib/orchestrate/test/compile/completeTestCode.js.map +1 -0
  70. package/lib/orchestrate/test/{filterTestFileName.js → compile/filterTestFileName.js} +1 -1
  71. package/lib/orchestrate/test/compile/filterTestFileName.js.map +1 -0
  72. package/lib/orchestrate/test/compile/getTestExternalDeclarations.d.ts +3 -0
  73. package/lib/orchestrate/test/compile/getTestExternalDeclarations.js +27 -0
  74. package/lib/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -0
  75. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +5 -0
  76. package/lib/orchestrate/test/{compileTestScenario.js → compile/getTestScenarioArtifacts.js} +11 -5
  77. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -0
  78. package/lib/orchestrate/test/orchestrateTest.js +14 -9
  79. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  80. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +3 -2
  81. package/lib/orchestrate/test/orchestrateTestCorrect.js +150 -349
  82. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  83. package/lib/orchestrate/test/orchestrateTestScenario.js +323 -566
  84. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  85. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +3 -2
  86. package/lib/orchestrate/test/orchestrateTestWrite.js +139 -76
  87. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  88. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +121 -0
  89. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js +3 -0
  90. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js.map +1 -0
  91. package/lib/orchestrate/test/structures/IAutoBeTestFunction.d.ts +8 -0
  92. package/lib/{utils/types/BackoffOptions.js → orchestrate/test/structures/IAutoBeTestFunction.js} +1 -1
  93. package/lib/orchestrate/test/structures/IAutoBeTestFunction.js.map +1 -0
  94. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +32 -22
  95. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +2 -0
  96. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +112 -0
  97. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js +3 -0
  98. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js.map +1 -0
  99. package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.d.ts +7 -0
  100. package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js +3 -0
  101. package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js.map +1 -0
  102. package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +3 -2
  103. package/lib/orchestrate/test/transformTestCorrectHistories.js +28 -41
  104. package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
  105. package/lib/orchestrate/test/transformTestWriteHistories.d.ts +5 -4
  106. package/lib/orchestrate/test/transformTestWriteHistories.js +169 -32
  107. package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
  108. package/lib/structures/IAutoBeConfig.d.ts +11 -0
  109. package/lib/structures/IAutoBeProps.d.ts +12 -1
  110. package/lib/utils/backoffRetry.d.ts +4 -7
  111. package/lib/utils/backoffRetry.js +19 -37
  112. package/lib/utils/backoffRetry.js.map +1 -1
  113. package/lib/utils/forceRetry.d.ts +1 -0
  114. package/lib/{orchestrate/orchestrateRealize.js → utils/forceRetry.js} +15 -8
  115. package/lib/utils/forceRetry.js.map +1 -0
  116. package/package.json +8 -8
  117. package/src/AutoBeAgent.ts +26 -4
  118. package/src/constants/AutoBeSystemPromptConstant.ts +6 -4
  119. package/src/context/AutoBeTokenUsage.ts +85 -1
  120. package/src/context/IAutoBeApplicationProps.ts +0 -62
  121. package/src/factory/createAutoBeApplication.ts +2 -3
  122. package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +8 -3
  123. package/src/orchestrate/analyze/AutoBeAnalyzeReviewer.ts +0 -1
  124. package/src/orchestrate/analyze/orchestrateAnalyze.ts +8 -37
  125. package/src/orchestrate/facade/transformFacadeStateMessage.ts +2 -1
  126. package/src/orchestrate/index.ts +2 -2
  127. package/src/orchestrate/interface/orchestrateInterface.ts +7 -0
  128. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +4 -3
  129. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +26 -23
  130. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +6 -4
  131. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +14 -11
  132. package/src/orchestrate/interface/transformInterfaceHistories.ts +2 -0
  133. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +10 -5
  134. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +11 -5
  135. package/src/orchestrate/prisma/orchestratePrismaSchema.ts +16 -8
  136. package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +9 -0
  137. package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +8 -0
  138. package/src/orchestrate/realize/orchestrateRealize.ts +169 -0
  139. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +156 -0
  140. package/src/orchestrate/realize/orchestrateRealizeIntegrator.ts +75 -0
  141. package/src/orchestrate/realize/orchestrateRealizePlanner.ts +115 -0
  142. package/src/orchestrate/realize/orchestrateRealizeValidator.ts +64 -0
  143. package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +36 -0
  144. package/src/orchestrate/realize/transformRealizeCoderHistories.ts +136 -0
  145. package/src/orchestrate/test/compile/completeTestCode.ts +35 -0
  146. package/src/orchestrate/test/{filterTestFileName.ts → compile/filterTestFileName.ts} +1 -1
  147. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +24 -0
  148. package/src/orchestrate/test/{compileTestScenario.ts → compile/getTestScenarioArtifacts.ts} +17 -8
  149. package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +240 -0
  150. package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +316 -0
  151. package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -0
  152. package/src/orchestrate/test/orchestrateTest.ts +38 -16
  153. package/src/orchestrate/test/orchestrateTestCorrect.ts +111 -338
  154. package/src/orchestrate/test/orchestrateTestScenario.ts +114 -69
  155. package/src/orchestrate/test/orchestrateTestWrite.ts +55 -153
  156. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +126 -0
  157. package/src/orchestrate/test/structures/IAutoBeTestFunction.ts +10 -0
  158. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +32 -22
  159. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +3 -0
  160. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +117 -0
  161. package/src/orchestrate/test/structures/IAutoBeTestWriteResult.ts +9 -0
  162. package/src/orchestrate/test/transformTestCorrectHistories.ts +38 -43
  163. package/src/orchestrate/test/transformTestWriteHistories.ts +89 -35
  164. package/src/structures/IAutoBeConfig.ts +9 -0
  165. package/src/structures/IAutoBeProps.ts +17 -1
  166. package/src/utils/backoffRetry.ts +25 -36
  167. package/src/utils/forceRetry.ts +13 -0
  168. package/lib/factory/invertOpenApiDocument.d.ts +0 -3
  169. package/lib/factory/invertOpenApiDocument.js +0 -51
  170. package/lib/factory/invertOpenApiDocument.js.map +0 -1
  171. package/lib/orchestrate/orchestrateRealize.d.ts +0 -5
  172. package/lib/orchestrate/orchestrateRealize.js.map +0 -1
  173. package/lib/orchestrate/test/compileTestScenario.d.ts +0 -5
  174. package/lib/orchestrate/test/compileTestScenario.js.map +0 -1
  175. package/lib/orchestrate/test/filterTestFileName.js.map +0 -1
  176. package/lib/utils/StringUtil.d.ts +0 -4
  177. package/lib/utils/StringUtil.js +0 -43
  178. package/lib/utils/StringUtil.js.map +0 -1
  179. package/lib/utils/types/BackoffOptions.d.ts +0 -12
  180. package/lib/utils/types/BackoffOptions.js.map +0 -1
  181. package/src/factory/invertOpenApiDocument.ts +0 -63
  182. package/src/orchestrate/orchestrateRealize.ts +0 -18
  183. package/src/utils/StringUtil.ts +0 -45
  184. package/src/utils/types/BackoffOptions.ts +0 -15
  185. /package/lib/orchestrate/test/{filterTestFileName.d.ts → compile/filterTestFileName.d.ts} +0 -0
@@ -0,0 +1,126 @@
1
+ export interface IAutoBeTestCorrectApplication {
2
+ /**
3
+ * Main entry point for AI Function Call - analyzes compilation errors and
4
+ * generates corrected E2E test code.
5
+ *
6
+ * The AI executes this function to perform the complete error correction
7
+ * workflow: error-free analysis → compilation error analysis → draft
8
+ * correction → code review → final corrected implementation. This multi-step
9
+ * process ensures systematic error resolution while preserving original test
10
+ * functionality and maintaining code quality.
11
+ *
12
+ * The corrector first analyzes the scenario without considering compilation
13
+ * errors to understand the intended functionality, then incorporates
14
+ * compilation diagnostics to identify specific issues, and finally produces
15
+ * corrected code through iterative refinement with comprehensive review and
16
+ * validation.
17
+ *
18
+ * @param props Complete specification for error correction workflow including
19
+ * analysis steps, draft implementation, review process, and final code
20
+ * generation
21
+ */
22
+ rewrite(props: IAutoBeTestCorrectApplication.IProps): void;
23
+ }
24
+
25
+ export namespace IAutoBeTestCorrectApplication {
26
+ export interface IProps {
27
+ /**
28
+ * Step 1: Initial analysis and understanding without compilation error
29
+ * context.
30
+ *
31
+ * AI analyzes the original test scenario, business requirements, and
32
+ * intended functionality without being influenced by compilation errors.
33
+ * This clean analysis establishes a clear understanding of what the test
34
+ * should accomplish, the expected business workflow, and the correct API
35
+ * integration patterns.
36
+ *
37
+ * This step ensures that error correction doesn't lose sight of the
38
+ * original test purpose and helps maintain the intended business logic
39
+ * while addressing technical compilation issues. The AI develops a
40
+ * comprehensive understanding of the test requirements before diving into
41
+ * error-specific details.
42
+ *
43
+ * Workflow: Scenario understanding → Business logic analysis → Intended
44
+ * functionality mapping
45
+ */
46
+ think_without_compile_error: string;
47
+
48
+ /**
49
+ * Step 2: Compilation error analysis and root cause identification.
50
+ *
51
+ * AI re-analyzes the scenario and implementation with full awareness of
52
+ * compilation errors and diagnostic information. This step involves
53
+ * systematic examination of error messages, identification of error
54
+ * patterns, and understanding of how compilation issues relate to the
55
+ * intended functionality.
56
+ *
57
+ * The AI correlates compilation diagnostics with the original requirements
58
+ * to understand where the implementation diverged from correct TypeScript
59
+ * usage while maintaining the business logic intent. This analysis forms
60
+ * the foundation for targeted error correction strategies.
61
+ *
62
+ * Workflow: Error diagnostic analysis → Root cause identification →
63
+ * Correction strategy planning
64
+ */
65
+ think_again_with_compile_error: string;
66
+
67
+ /**
68
+ * Step 3: Draft corrected TypeScript E2E test code implementation.
69
+ *
70
+ * AI generates the first corrected version of the test code based on error
71
+ * analysis and correction strategies. This draft addresses all identified
72
+ * compilation errors while preserving the original business logic and test
73
+ * workflow. The code must be compilation-error-free and follow all
74
+ * established conventions.
75
+ *
76
+ * The implementation incorporates lessons learned from error analysis to
77
+ * produce properly typed, syntactically correct code that maintains the
78
+ * intended test functionality. All type safety requirements and framework
79
+ * conventions must be followed in this corrected implementation.
80
+ *
81
+ * Workflow: Error correction → TypeScript implementation → Functional
82
+ * preservation Critical: Must resolve all compilation errors while
83
+ * maintaining original test intent
84
+ */
85
+ draft: string;
86
+
87
+ /**
88
+ * Step 4: Code review and correction validation.
89
+ *
90
+ * AI performs a comprehensive review of the corrected draft implementation,
91
+ * validating that all compilation errors have been resolved and that the
92
+ * code maintains the original functionality. This review examines both
93
+ * technical correctness and business logic preservation.
94
+ *
95
+ * The review process includes verification of TypeScript compilation
96
+ * compatibility, API integration correctness, test workflow completeness,
97
+ * and adherence to all quality standards. Any remaining issues or potential
98
+ * improvements are identified for incorporation into the final
99
+ * implementation.
100
+ *
101
+ * Workflow: Draft validation → Compilation verification → Functionality
102
+ * review → Quality assessment
103
+ */
104
+ review: string;
105
+
106
+ /**
107
+ * Step 5: Final production-ready corrected test code.
108
+ *
109
+ * AI produces the final, polished version of the corrected test code
110
+ * incorporating all review feedback and validation results. This code
111
+ * represents the completed error correction, guaranteed to compile
112
+ * successfully while preserving all original test functionality and
113
+ * business logic.
114
+ *
115
+ * The final implementation resolves all compilation issues, maintains
116
+ * strict type safety, follows all established conventions, and delivers a
117
+ * production-ready test that accurately validates the intended API
118
+ * behaviors and user workflows.
119
+ *
120
+ * Workflow: Review integration → Final refinement → Production-ready
121
+ * implementation This is the ultimate deliverable that will replace the
122
+ * compilation-failed code.
123
+ */
124
+ final: string;
125
+ }
126
+ }
@@ -0,0 +1,10 @@
1
+ import { AutoBeTestScenario } from "@autobe/interface";
2
+
3
+ import { IAutoBeTestScenarioArtifacts } from "./IAutoBeTestScenarioArtifacts";
4
+
5
+ export interface IAutoBeTestFunction {
6
+ artifacts: IAutoBeTestScenarioArtifacts;
7
+ scenario: AutoBeTestScenario;
8
+ location: string;
9
+ script: string;
10
+ }
@@ -16,27 +16,31 @@ export namespace IAutoBeTestScenarioApplication {
16
16
  }
17
17
 
18
18
  export interface IScenarioGroup {
19
- /** Target API endpoint to test. */
19
+ /**
20
+ * Target API endpoint to test.
21
+ *
22
+ * This must be **unique** across all scenario groups. An endpoint is
23
+ * identified by its `path` and `method` combination.
24
+ *
25
+ * Multiple test scenarios may exist for a single endpoint.
26
+ */
20
27
  endpoint: AutoBeOpenApi.IEndpoint;
21
28
 
22
- /** Array of test scenarios. */
29
+ /**
30
+ * An array of test scenarios associated with the given endpoint.
31
+ *
32
+ * Each scenario represents a specific test case for the same `path` and
33
+ * `method`.
34
+ */
23
35
  scenarios: IScenario[];
24
36
  }
25
37
 
26
38
  /**
27
39
  * Represents a test scenario for a single API operation.
28
40
  *
29
- * This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP
30
- * method and path information, and adds two key properties:
31
- *
32
- * - `draft`: A free-form, human-readable test scenario description for the API
33
- * endpoint.
34
- * - `dependsOn`: A list of other API endpoints that must be invoked beforehand
35
- * in order to prepare the context for this test. Each dependency includes
36
- * the purpose of the dependency.
37
- *
38
- * This structure is intended to help organize test specifications for complex
39
- * workflows and ensure that all prerequisites are explicitly declared.
41
+ * This interface defines a structured, user-centric test draft that includes
42
+ * a descriptive function name, a detailed scenario draft, and logical
43
+ * dependencies on other endpoints required for context or setup.
40
44
  */
41
45
  export interface IScenario {
42
46
  /**
@@ -44,7 +48,7 @@ export namespace IAutoBeTestScenarioApplication {
44
48
  * be tested. This should include both successful and failure scenarios,
45
49
  * business rule validations, edge cases, and any sequence of steps
46
50
  * necessary to perform the test. A subsequent agent will use this draft to
47
- * generate multiple test scenarios.
51
+ * generate multiple concrete test cases.
48
52
  */
49
53
  draft: string;
50
54
 
@@ -109,20 +113,26 @@ export namespace IAutoBeTestScenarioApplication {
109
113
  functionName: string;
110
114
 
111
115
  /**
112
- * A list of other API endpoints that must be executed before this test
113
- * scenario. This helps express dependencies such as data creation or
114
- * authentication steps required to reach the intended test state.
116
+ * A list of other API endpoints that this scenario logically depends on.
117
+ *
118
+ * These dependencies represent context or prerequisite conditions, such as
119
+ * authentication, resource creation, or data setup, that are relevant to
120
+ * the test. This list is not a strict execution order — if ordering is
121
+ * important, it must be described explicitly in the `purpose`.
115
122
  */
116
- dependsOn: IDependsOn[];
123
+ dependencies: IDependencies[];
117
124
  }
118
125
 
119
- export interface IDependsOn {
120
- /** Target API endpoint that must be executed before the main operation. */
126
+ export interface IDependencies {
127
+ /** Target API endpoint that this scenario depends on. */
121
128
  endpoint: AutoBeOpenApi.IEndpoint;
122
129
 
123
130
  /**
124
- * A concise exscenarioation of why this API call is required before
125
- * executing the test for the main operation.
131
+ * A concise explanation of why this API call is relevant or required for
132
+ * the main test scenario.
133
+ *
134
+ * This should describe the contextual or setup role of the dependency, such
135
+ * as creating necessary data or establishing user authentication.
126
136
  *
127
137
  * Example: "Creates a category so that a product can be linked to it during
128
138
  * creation."
@@ -1,4 +1,7 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+
1
3
  export interface IAutoBeTestScenarioArtifacts {
4
+ document: AutoBeOpenApi.IDocument;
2
5
  sdk: Record<string, string>;
3
6
  dto: Record<string, string>;
4
7
  e2e: Record<string, string>;
@@ -0,0 +1,117 @@
1
+ export interface IAutoBeTestWriteApplication {
2
+ /**
3
+ * Main entry point for AI Function Call - generates complete E2E test code.
4
+ *
5
+ * The AI executes this function to perform the entire test generation
6
+ * workflow: scenario analysis → draft implementation → code review → final
7
+ * code production. This structured approach ensures high-quality,
8
+ * compilation-error-free test code.
9
+ *
10
+ * @param props Complete specification for test generation including scenario,
11
+ * domain, and implementation steps
12
+ */
13
+ write(props: IAutoBeTestWriteApplication.IProps): void;
14
+ }
15
+
16
+ export namespace IAutoBeTestWriteApplication {
17
+ export interface IProps {
18
+ /**
19
+ * Step 1: Strategic test planning and scenario analysis.
20
+ *
21
+ * AI analyzes the given test scenario and creates a comprehensive
22
+ * implementation strategy. This planning phase is crucial for generating
23
+ * well-structured, maintainable test code. The AI must define test
24
+ * methodology, data preparation, execution flow, and validation logic
25
+ * before proceeding to code implementation.
26
+ *
27
+ * Workflow: Input scenario → Strategic analysis → Detailed test plan
28
+ */
29
+ scenario: string;
30
+
31
+ /**
32
+ * Step 2: Functional domain classification for test organization.
33
+ *
34
+ * AI determines the appropriate domain category based on the scenario
35
+ * analysis. This classification drives file structure, test categorization,
36
+ * and logical grouping. The domain must be a single, lowercase word that
37
+ * represents the primary API resource.
38
+ *
39
+ * Workflow: Scenario analysis → Domain identification → Test organization
40
+ * structure
41
+ */
42
+ domain: string;
43
+
44
+ /**
45
+ * Step 3: Initial TypeScript E2E test code implementation.
46
+ *
47
+ * AI generates the first working version of the test code based on the
48
+ * strategic plan. This draft must be compilation-error-free and follow
49
+ *
50
+ * @nestia/e2e framework conventions. The code should implement all planned
51
+ * test scenarios with proper async/await patterns, type safety, and
52
+ * comprehensive error handling.
53
+ *
54
+ * Workflow: Strategic plan → TypeScript implementation → Functional test
55
+ * code
56
+ *
57
+ * Critical: NO import statements, start directly with 'export async function'
58
+ */
59
+ draft: string;
60
+
61
+ /**
62
+ * Step 4: Code review and quality assessment.
63
+ *
64
+ * AI performs a thorough review of the draft implementation, examining:
65
+ *
66
+ * **Compilation & Syntax:**
67
+ *
68
+ * - TypeScript compilation errors and type mismatches
69
+ * - Syntax errors and missing semicolons/brackets
70
+ * - Correct function signatures and parameter types
71
+ *
72
+ * **Framework Compliance:**
73
+ *
74
+ * - @nestia/e2e framework conventions adherence
75
+ * - Proper API SDK function calling patterns
76
+ * - Correct use of typia.assert() and TestValidator functions
77
+ *
78
+ * **Business Logic & Test Coverage:**
79
+ *
80
+ * - Complete workflow implementation (authentication → data setup → main test
81
+ * → validation)
82
+ * - Realistic business scenarios and user journeys
83
+ * - Edge case handling and error condition testing
84
+ * - Proper data dependencies and cleanup procedures
85
+ *
86
+ * **Code Quality & Security:**
87
+ *
88
+ * - Type safety violations (any, @ts-ignore, etc.)
89
+ * - Variable naming and code organization
90
+ * - Performance considerations and resource management
91
+ * - Security best practices in test data generation
92
+ *
93
+ * Workflow: Draft code → Systematic analysis → Specific improvement
94
+ * recommendations
95
+ *
96
+ * The review must identify concrete issues with line-by-line feedback and
97
+ * provide actionable solutions for each problem discovered.
98
+ */
99
+ review: string;
100
+
101
+ /**
102
+ * Step 5: Final production-ready test code.
103
+ *
104
+ * AI produces the final, polished version of the test code incorporating
105
+ * all review feedback. This code represents the completed test
106
+ * implementation, ready for production deployment. All identified issues
107
+ * must be resolved, and the code must meet the highest quality standards.
108
+ *
109
+ * Workflow: Review feedback → Code refinement → Production-ready
110
+ * implementation
111
+ *
112
+ * This is the ultimate deliverable that will be used in the actual test
113
+ * suite.
114
+ */
115
+ final: string;
116
+ }
117
+ }
@@ -0,0 +1,9 @@
1
+ import { AutoBeTestScenario, AutoBeTestWriteEvent } from "@autobe/interface";
2
+
3
+ import { IAutoBeTestScenarioArtifacts } from "./IAutoBeTestScenarioArtifacts";
4
+
5
+ export interface IAutoBeTestWriteResult {
6
+ scenario: AutoBeTestScenario;
7
+ artifacts: IAutoBeTestScenarioArtifacts;
8
+ event: AutoBeTestWriteEvent;
9
+ }
@@ -1,51 +1,46 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { IAutoBeTypeScriptCompileResult } from "@autobe/interface";
2
3
  import { v4 } from "uuid";
3
4
 
4
5
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
5
- import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
6
+ import { IAutoBeTestFunction } from "./structures/IAutoBeTestFunction";
7
+ import { transformTestWriteHistories } from "./transformTestWriteHistories";
6
8
 
7
9
  export const transformTestCorrectHistories = (
8
- artifacts: IAutoBeTestScenarioArtifacts,
10
+ func: IAutoBeTestFunction,
11
+ failure: IAutoBeTypeScriptCompileResult.IFailure,
9
12
  ): Array<
10
13
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
11
- > => {
12
- return [
13
- {
14
- id: v4(),
15
- created_at: new Date().toISOString(),
16
- type: "systemMessage",
17
- text: AutoBeSystemPromptConstant.TEST_CORRECT,
18
- },
19
- {
20
- id: v4(),
21
- created_at: new Date().toISOString(),
22
- type: "assistantMessage",
23
- text: [
24
- "You are the world's best TypeScript compiler error fixer.",
25
- "You will be given a **TypeScript code** with compilation errors, and your job is to fix the errors.",
26
- "",
27
- "## Rules",
28
- "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.",
29
- "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.",
30
- "- Use `api.functional.XXX` for all API calls. These are defined in API Files.",
31
- "- Use helper functions like `generate_random_xxx(...)` **only if** they already exist in the base test imports.",
32
- "- Do not invent new helpers or use utilities that are not explicitly shown.",
33
- "- Keep all tests deterministic and reliable.",
34
- "",
35
- "## File References",
36
- "### API Files",
37
- "```typescript",
38
- JSON.stringify(artifacts.sdk),
39
- "```",
40
- "",
41
- "### DTO Files",
42
- "```typescript",
43
- JSON.stringify(artifacts.dto),
44
- "```",
45
- "",
46
- "Now Fix the E2E test function based on the given error information.",
47
- "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary.",
48
- ].join("\n"),
49
- },
50
- ];
51
- };
14
+ > => [
15
+ ...transformTestWriteHistories(func.scenario, func.artifacts),
16
+ {
17
+ id: v4(),
18
+ created_at: new Date().toISOString(),
19
+ type: "assistantMessage",
20
+ text: [
21
+ "## Generated TypeScript Code",
22
+ "```typescript",
23
+ func.script,
24
+ "```",
25
+ "",
26
+ "## Compile Errors",
27
+ "Fix the compilation error in the provided code.",
28
+ "",
29
+ "```json",
30
+ JSON.stringify(failure.diagnostics),
31
+ "```",
32
+ ].join("\n"),
33
+ },
34
+ {
35
+ id: v4(),
36
+ created_at: new Date().toISOString(),
37
+ type: "systemMessage",
38
+ text: AutoBeSystemPromptConstant.TEST_CORRECT.replace(
39
+ "{{API_DTO_SCHEMAS}}",
40
+ transformTestWriteHistories.structures(func.artifacts),
41
+ ).replace(
42
+ "{{API_SDK_FUNCTIONS}}",
43
+ transformTestWriteHistories.functional(func.artifacts),
44
+ ),
45
+ },
46
+ ];
@@ -1,53 +1,107 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
2
  import { AutoBeTestScenario } from "@autobe/interface";
3
+ import { StringUtil, transformOpenApiDocument } from "@autobe/utils";
4
+ import {
5
+ HttpMigration,
6
+ IHttpMigrateApplication,
7
+ OpenApi,
8
+ } from "@samchon/openapi";
9
+ import typia from "typia";
3
10
  import { v4 } from "uuid";
4
11
 
5
12
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
6
13
  import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
7
14
 
8
- export const transformTestWriteHistories = (props: {
9
- scenario: AutoBeTestScenario;
10
- artifacts: IAutoBeTestScenarioArtifacts;
11
- }): Array<
12
- IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
13
- > => {
15
+ export function transformTestWriteHistories(
16
+ scenario: AutoBeTestScenario,
17
+ artifacts: IAutoBeTestScenarioArtifacts,
18
+ ): Array<IAgenticaHistoryJson.ISystemMessage> {
14
19
  return [
15
20
  {
16
21
  id: v4(),
17
22
  created_at: new Date().toISOString(),
18
23
  type: "systemMessage",
19
- text: AutoBeSystemPromptConstant.TEST_WRITE,
24
+ text: AutoBeSystemPromptConstant.TEST_WRITE.replace(
25
+ "{{AutoBeTestScenario}}",
26
+ JSON.stringify(typia.llm.parameters<AutoBeTestScenario, "llama">()),
27
+ ),
20
28
  },
21
29
  {
22
30
  id: v4(),
23
31
  created_at: new Date().toISOString(),
24
- type: "assistantMessage",
25
- text: [
26
- "Here is the list of input material composition.",
27
- "",
28
- "Make e2e test functions based on the following information.",
29
- "",
30
- "## Secnario Plan",
31
- "```json",
32
- JSON.stringify(props.scenario),
33
- "```",
34
- "",
35
- "## DTO Definitions",
36
- "```json",
37
- JSON.stringify(props.artifacts.dto),
38
- "```",
39
- "",
40
- "## API (SDK) Functions",
41
- "```json",
42
- JSON.stringify(props.artifacts.sdk),
43
- "```",
44
- "",
45
- "## E2E Mockup Functions",
46
- "```json",
47
- JSON.stringify(props.artifacts.e2e),
48
- "```",
49
- "",
50
- ].join("\n"),
32
+ type: "systemMessage",
33
+ text: StringUtil.trim`
34
+ Here is the list of input material composition.
35
+
36
+ Make e2e test functions based on the following information.
37
+
38
+ ## Scenario Plan
39
+
40
+ Here is the scenario plan what you have to implement.
41
+
42
+ \`\`\`json
43
+ ${JSON.stringify(scenario)}
44
+ \`\`\`
45
+
46
+ ## DTO Definitions
47
+
48
+ You can use these DTO definitions.
49
+
50
+ Never use the DTO definitions that are not listed here.
51
+
52
+ ${transformTestWriteHistories.structures(artifacts)}
53
+
54
+ ## API (SDK) Functions
55
+
56
+ You can use these API functions.
57
+
58
+ Never use the functions that are not listed here.
59
+
60
+ ${transformTestWriteHistories.functional(artifacts)}
61
+
62
+ ## E2E Mockup Functions
63
+
64
+ Just reference, and never follow this code as it is.
65
+
66
+ \`\`\`json
67
+ ${JSON.stringify(artifacts.e2e)}
68
+ \`\`\`
69
+ `,
51
70
  },
52
71
  ];
53
- };
72
+ }
73
+ export namespace transformTestWriteHistories {
74
+ export function structures(artifacts: IAutoBeTestScenarioArtifacts): string {
75
+ return StringUtil.trim`
76
+ ${Object.keys(artifacts.document.components.schemas)
77
+ .map((k) => `- ${k}`)
78
+ .join("\n")}
79
+
80
+ \`\`\`json
81
+ ${JSON.stringify(artifacts.dto)}
82
+ \`\`\`
83
+ `;
84
+ }
85
+
86
+ export function functional(artifacts: IAutoBeTestScenarioArtifacts): string {
87
+ const document: OpenApi.IDocument = transformOpenApiDocument(
88
+ artifacts.document,
89
+ );
90
+ const app: IHttpMigrateApplication = HttpMigration.application(document);
91
+ return StringUtil.trim`
92
+ Method | Path | Function Accessor
93
+ -------|------|-------------------
94
+ ${app.routes
95
+ .map((r) =>
96
+ [r.method, r.path, `api.functional.${r.accessor.join(".")}`].join(
97
+ " | ",
98
+ ),
99
+ )
100
+ .join("\n")}
101
+
102
+ \`\`\`json
103
+ ${JSON.stringify(artifacts.sdk)}
104
+ \`\`\`
105
+ `;
106
+ }
107
+ }
@@ -60,4 +60,13 @@ export interface IAutoBeConfig {
60
60
  * @default System timezone or "UTC" if unavailable
61
61
  */
62
62
  timezone?: string;
63
+
64
+ /**
65
+ * Backoff strategy for retrying failed operations.
66
+ *
67
+ * Defines the logic for retrying failed operations when the agent encounters
68
+ * errors. This includes retrying function calls, API requests, and other
69
+ * operations that may fail due to temporary issues.
70
+ */
71
+ backoffStrategy?: (props: { count: number; error: unknown }) => number;
63
72
  }
@@ -1,6 +1,11 @@
1
- import { AutoBeHistory, IAutoBeCompiler } from "@autobe/interface";
1
+ import {
2
+ AutoBeHistory,
3
+ IAutoBeCompiler,
4
+ IAutoBeTokenUsageJson,
5
+ } from "@autobe/interface";
2
6
  import { ILlmSchema } from "@samchon/openapi";
3
7
 
8
+ import { AutoBeTokenUsage } from "../context/AutoBeTokenUsage";
4
9
  import { IAutoBeConfig } from "./IAutoBeConfig";
5
10
  import { IAutoBeVendor } from "./IAutoBeVendor";
6
11
 
@@ -101,4 +106,15 @@ export interface IAutoBeProps<Model extends ILlmSchema.Model> {
101
106
  * time-sensitive operations throughout the development process.
102
107
  */
103
108
  config?: IAutoBeConfig | undefined;
109
+
110
+ /**
111
+ * Token usage information.
112
+ *
113
+ * You can start token usage tracing by assigning this property.
114
+ *
115
+ * If you assign {@link IAutoBeTokenUsageJson} value, the token usage tracing
116
+ * would be from the value. Otherwise you assign the {@link AutoBeTokenUsage}
117
+ * typed instance, the tracing would be binded to the instance.
118
+ */
119
+ tokenUsage?: IAutoBeTokenUsageJson | AutoBeTokenUsage | undefined;
104
120
  }