@autobe/agent 0.9.2 → 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 (175) hide show
  1. package/lib/AutoBeAgent.js +11 -4
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +6 -6
  4. package/lib/context/AutoBeTokenUsage.d.ts +15 -1
  5. package/lib/context/AutoBeTokenUsage.js +56 -1
  6. package/lib/context/AutoBeTokenUsage.js.map +1 -1
  7. package/lib/factory/createAutoBeApplication.js +288 -643
  8. package/lib/factory/createAutoBeApplication.js.map +1 -1
  9. package/lib/index.mjs +5057 -7211
  10. package/lib/index.mjs.map +1 -1
  11. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +82 -319
  12. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
  13. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js +0 -1
  14. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -1
  15. package/lib/orchestrate/analyze/orchestrateAnalyze.js +95 -266
  16. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  17. package/lib/orchestrate/facade/transformFacadeStateMessage.js +2 -2
  18. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  19. package/lib/orchestrate/index.d.ts +2 -2
  20. package/lib/orchestrate/index.js +4 -4
  21. package/lib/orchestrate/index.js.map +1 -1
  22. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +56 -142
  23. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  24. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +195 -199
  25. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
  26. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +75 -172
  27. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  28. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +772 -1097
  29. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  30. package/lib/orchestrate/interface/transformInterfaceHistories.js +2 -0
  31. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
  32. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +64 -175
  33. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  34. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +552 -1073
  35. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  36. package/lib/orchestrate/prisma/orchestratePrismaSchema.js +571 -1119
  37. package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
  38. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +9 -0
  39. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
  40. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +8 -0
  41. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
  42. package/lib/orchestrate/realize/orchestrateRealize.d.ts +11 -0
  43. package/lib/orchestrate/realize/orchestrateRealize.js +109 -0
  44. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -0
  45. package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +25 -0
  46. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +337 -0
  47. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -0
  48. package/lib/orchestrate/realize/orchestrateRealizeIntegrator.d.ts +52 -0
  49. package/lib/orchestrate/realize/orchestrateRealizeIntegrator.js +57 -0
  50. package/lib/orchestrate/realize/orchestrateRealizeIntegrator.js.map +1 -0
  51. package/lib/orchestrate/realize/orchestrateRealizePlanner.d.ts +80 -0
  52. package/lib/orchestrate/realize/orchestrateRealizePlanner.js +53 -0
  53. package/lib/orchestrate/realize/orchestrateRealizePlanner.js.map +1 -0
  54. package/lib/orchestrate/realize/orchestrateRealizeValidator.d.ts +46 -0
  55. package/lib/orchestrate/realize/orchestrateRealizeValidator.js +37 -0
  56. package/lib/orchestrate/realize/orchestrateRealizeValidator.js.map +1 -0
  57. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +33 -0
  58. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js +3 -0
  59. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +1 -0
  60. package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +5 -0
  61. package/lib/orchestrate/realize/transformRealizeCoderHistories.js +127 -0
  62. package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -0
  63. package/lib/orchestrate/test/compile/completeTestCode.d.ts +2 -0
  64. package/lib/orchestrate/test/compile/completeTestCode.js +21 -0
  65. package/lib/orchestrate/test/compile/completeTestCode.js.map +1 -0
  66. package/lib/orchestrate/test/{filterTestFileName.js → compile/filterTestFileName.js} +1 -1
  67. package/lib/orchestrate/test/compile/filterTestFileName.js.map +1 -0
  68. package/lib/orchestrate/test/compile/getTestExternalDeclarations.d.ts +3 -0
  69. package/lib/orchestrate/test/compile/getTestExternalDeclarations.js +27 -0
  70. package/lib/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -0
  71. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +5 -0
  72. package/lib/orchestrate/test/{compileTestScenario.js → compile/getTestScenarioArtifacts.js} +10 -5
  73. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -0
  74. package/lib/orchestrate/test/orchestrateTest.js +14 -9
  75. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  76. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +3 -2
  77. package/lib/orchestrate/test/orchestrateTestCorrect.js +150 -448
  78. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  79. package/lib/orchestrate/test/orchestrateTestScenario.js +272 -530
  80. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  81. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +3 -2
  82. package/lib/orchestrate/test/orchestrateTestWrite.js +139 -90
  83. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  84. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +121 -0
  85. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js +3 -0
  86. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js.map +1 -0
  87. package/lib/orchestrate/test/structures/IAutoBeTestFunction.d.ts +8 -0
  88. package/lib/{utils/types/BackoffOptions.js → orchestrate/test/structures/IAutoBeTestFunction.js} +1 -1
  89. package/lib/orchestrate/test/structures/IAutoBeTestFunction.js.map +1 -0
  90. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +14 -2
  91. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +112 -0
  92. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js +3 -0
  93. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js.map +1 -0
  94. package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.d.ts +7 -0
  95. package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js +3 -0
  96. package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js.map +1 -0
  97. package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +3 -2
  98. package/lib/orchestrate/test/transformTestCorrectHistories.js +28 -67
  99. package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
  100. package/lib/orchestrate/test/transformTestWriteHistories.d.ts +5 -4
  101. package/lib/orchestrate/test/transformTestWriteHistories.js +168 -43
  102. package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
  103. package/lib/structures/IAutoBeConfig.d.ts +11 -0
  104. package/lib/utils/backoffRetry.d.ts +4 -7
  105. package/lib/utils/backoffRetry.js +19 -37
  106. package/lib/utils/backoffRetry.js.map +1 -1
  107. package/lib/utils/forceRetry.d.ts +1 -0
  108. package/lib/{orchestrate/orchestrateRealize.js → utils/forceRetry.js} +15 -8
  109. package/lib/utils/forceRetry.js.map +1 -0
  110. package/package.json +8 -7
  111. package/src/AutoBeAgent.ts +17 -3
  112. package/src/constants/AutoBeSystemPromptConstant.ts +6 -6
  113. package/src/context/AutoBeTokenUsage.ts +85 -1
  114. package/src/factory/createAutoBeApplication.ts +2 -3
  115. package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +8 -3
  116. package/src/orchestrate/analyze/AutoBeAnalyzeReviewer.ts +0 -1
  117. package/src/orchestrate/analyze/orchestrateAnalyze.ts +6 -5
  118. package/src/orchestrate/facade/transformFacadeStateMessage.ts +2 -1
  119. package/src/orchestrate/index.ts +2 -2
  120. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +4 -3
  121. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +26 -23
  122. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +6 -4
  123. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +14 -11
  124. package/src/orchestrate/interface/transformInterfaceHistories.ts +2 -0
  125. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +10 -5
  126. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +11 -5
  127. package/src/orchestrate/prisma/orchestratePrismaSchema.ts +16 -8
  128. package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +9 -0
  129. package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +8 -0
  130. package/src/orchestrate/realize/orchestrateRealize.ts +169 -0
  131. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +156 -0
  132. package/src/orchestrate/realize/orchestrateRealizeIntegrator.ts +75 -0
  133. package/src/orchestrate/realize/orchestrateRealizePlanner.ts +115 -0
  134. package/src/orchestrate/realize/orchestrateRealizeValidator.ts +64 -0
  135. package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +36 -0
  136. package/src/orchestrate/realize/transformRealizeCoderHistories.ts +136 -0
  137. package/src/orchestrate/test/compile/completeTestCode.ts +35 -0
  138. package/src/orchestrate/test/{filterTestFileName.ts → compile/filterTestFileName.ts} +1 -1
  139. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +24 -0
  140. package/src/orchestrate/test/{compileTestScenario.ts → compile/getTestScenarioArtifacts.ts} +16 -8
  141. package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +240 -0
  142. package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +316 -0
  143. package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -0
  144. package/src/orchestrate/test/orchestrateTest.ts +33 -16
  145. package/src/orchestrate/test/orchestrateTestCorrect.ts +109 -497
  146. package/src/orchestrate/test/orchestrateTestScenario.ts +102 -71
  147. package/src/orchestrate/test/orchestrateTestWrite.ts +55 -181
  148. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +126 -0
  149. package/src/orchestrate/test/structures/IAutoBeTestFunction.ts +10 -0
  150. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +14 -2
  151. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +117 -0
  152. package/src/orchestrate/test/structures/IAutoBeTestWriteResult.ts +9 -0
  153. package/src/orchestrate/test/transformTestCorrectHistories.ts +38 -71
  154. package/src/orchestrate/test/transformTestWriteHistories.ts +88 -46
  155. package/src/structures/IAutoBeConfig.ts +9 -0
  156. package/src/utils/backoffRetry.ts +25 -36
  157. package/src/utils/forceRetry.ts +13 -0
  158. package/lib/factory/invertOpenApiDocument.d.ts +0 -3
  159. package/lib/factory/invertOpenApiDocument.js +0 -51
  160. package/lib/factory/invertOpenApiDocument.js.map +0 -1
  161. package/lib/orchestrate/orchestrateRealize.d.ts +0 -5
  162. package/lib/orchestrate/orchestrateRealize.js.map +0 -1
  163. package/lib/orchestrate/test/compileTestScenario.d.ts +0 -5
  164. package/lib/orchestrate/test/compileTestScenario.js.map +0 -1
  165. package/lib/orchestrate/test/filterTestFileName.js.map +0 -1
  166. package/lib/utils/StringUtil.d.ts +0 -4
  167. package/lib/utils/StringUtil.js +0 -43
  168. package/lib/utils/StringUtil.js.map +0 -1
  169. package/lib/utils/types/BackoffOptions.d.ts +0 -12
  170. package/lib/utils/types/BackoffOptions.js.map +0 -1
  171. package/src/factory/invertOpenApiDocument.ts +0 -63
  172. package/src/orchestrate/orchestrateRealize.ts +0 -18
  173. package/src/utils/StringUtil.ts +0 -45
  174. package/src/utils/types/BackoffOptions.ts +0 -15
  175. /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,10 +16,22 @@ 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
 
@@ -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,79 +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
- code: string,
9
- artifacts: IAutoBeTestScenarioArtifacts,
10
- diagnostics: string[],
10
+ func: IAutoBeTestFunction,
11
+ failure: IAutoBeTypeScriptCompileResult.IFailure,
11
12
  ): Array<
12
13
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
13
- > => {
14
- return [
15
- {
16
- id: v4(),
17
- created_at: new Date().toISOString(),
18
- type: "systemMessage",
19
- text: AutoBeSystemPromptConstant.TEST_WRITE,
20
- },
21
- {
22
- id: v4(),
23
- created_at: new Date().toISOString(),
24
- type: "assistantMessage",
25
- text: [
26
- "# Original Code",
27
- "```typescript",
28
- code,
29
- "```",
30
- "",
31
- "# Compile Errors",
32
- "Fix the compilation error in the provided code.",
33
- ...diagnostics,
34
- ].join("\n"),
35
- },
36
- {
37
- id: v4(),
38
- created_at: new Date().toISOString(),
39
- type: "systemMessage",
40
- text: AutoBeSystemPromptConstant.TEST_CORRECT,
41
- },
42
- {
43
- id: v4(),
44
- created_at: new Date().toISOString(),
45
- type: "systemMessage",
46
- text: [
47
- "You are the world's best TypeScript compiler error fixer.",
48
- "You will be given a **TypeScript code** with compilation errors, and your job is to fix the errors.",
49
- "",
50
- "# Rules",
51
- "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.",
52
- "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.",
53
- "- Use `api.functional.XXX` for all API calls. These are defined in API Files.",
54
- "- Use helper functions like `generate_random_xxx(...)` **only if** they already exist in the base test imports.",
55
- "- Do not invent new helpers or use utilities that are not explicitly shown.",
56
- "- Keep all tests deterministic and reliable.",
57
- "",
58
- "# File References",
59
- `The import statements are automatically inserted based on the AST, which provides all necessary types and SDKs required.`,
60
- `Therefore, if an import is not automatically included,`,
61
- `it means that the corresponding type or SDK is not available for use in the current test code.`,
62
- `You must solve the issue using only the provided SDK and types.`,
63
- "",
64
- "## API Files",
65
- "```typescript",
66
- JSON.stringify(artifacts.sdk),
67
- "```",
68
- "",
69
- "## DTO Files",
70
- "```typescript",
71
- JSON.stringify(artifacts.dto),
72
- "```",
73
- "",
74
- "Now Fix the E2E test function based on the given error information.",
75
- "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary.",
76
- ].join("\n"),
77
- },
78
- ];
79
- };
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,65 +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
32
  type: "systemMessage",
25
- text: AutoBeSystemPromptConstant.TEST_VALIDATOR,
26
- },
27
- {
28
- id: v4(),
29
- created_at: new Date().toISOString(),
30
- type: "systemMessage",
31
- text: AutoBeSystemPromptConstant.TEST_TYPESCRIPT_SYNTAX,
32
- },
33
- {
34
- id: v4(),
35
- created_at: new Date().toISOString(),
36
- type: "assistantMessage",
37
- text: [
38
- "Here is the list of input material composition.",
39
- "",
40
- "Make e2e test functions based on the following information.",
41
- "",
42
- "## Secnario Plan",
43
- "```json",
44
- JSON.stringify(props.scenario),
45
- "```",
46
- "",
47
- "## DTO Definitions",
48
- "```json",
49
- JSON.stringify(props.artifacts.dto),
50
- "```",
51
- "",
52
- "## API (SDK) Functions",
53
- "```json",
54
- JSON.stringify(props.artifacts.sdk),
55
- "```",
56
- "",
57
- "## E2E Mockup Functions",
58
- "```json",
59
- JSON.stringify(props.artifacts.e2e),
60
- "```",
61
- "",
62
- ].join("\n"),
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
+ `,
63
70
  },
64
71
  ];
65
- };
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,42 +1,23 @@
1
- import { RetryOptions } from "./types/BackoffOptions";
2
-
3
- /**
4
- * @param fn Function to Apply the retry logic.
5
- * @param maxRetries How many time to try. Max Retry is 5.
6
- * @returns
7
- */
8
- export async function randomBackoffRetry<T>(
9
- fn: () => Promise<T>,
10
- options: Partial<RetryOptions> = {},
11
- ): Promise<T> {
12
- const {
13
- maxRetries = 5,
14
- baseDelay = 4_000,
15
- maxDelay = 60_000,
16
- jitter = 0.8,
17
- handleError = isRetryError,
18
- } = options;
19
-
20
- let lastError: unknown;
21
-
22
- for (let attempt = 0; attempt < maxRetries; attempt++) {
23
- try {
24
- return await fn();
25
- } catch (err) {
26
- lastError = err;
27
-
28
- if (attempt === maxRetries - 1) throw err;
29
-
30
- if (!handleError(err)) throw err;
31
-
32
- const tempDelay = Math.min(baseDelay * 2 ** attempt, maxDelay);
33
- const delay = tempDelay * (1 + Math.random() * jitter);
1
+ export function randomBackoffStrategy(props: {
2
+ count: number;
3
+ error: unknown;
4
+ }): number {
5
+ const { count, error } = props;
6
+ if (count > 5) {
7
+ throw error;
8
+ }
34
9
 
35
- await new Promise((res) => setTimeout(res, delay));
36
- }
10
+ if (isRetryError(error) === false) {
11
+ throw error;
37
12
  }
38
13
 
39
- throw lastError;
14
+ const baseDelay = 4_000;
15
+ const maxDelay = 60_000;
16
+ const jitter = 0.8;
17
+ const tempDelay = Math.min(baseDelay * 2 ** count, maxDelay);
18
+ const delay = tempDelay * (1 + Math.random() * jitter);
19
+
20
+ return delay;
40
21
  }
41
22
 
42
23
  function isRetryError(error: any): boolean {
@@ -80,5 +61,13 @@ function isRetryError(error: any): boolean {
80
61
  return true;
81
62
  }
82
63
 
64
+ if (
65
+ (error?.message as string)?.startsWith(
66
+ `SyntaxError: Expected ',' or '}' after property value in JSON at position`,
67
+ )
68
+ ) {
69
+ return true;
70
+ }
71
+
83
72
  return false;
84
73
  }
@@ -0,0 +1,13 @@
1
+ export async function forceRetry<T>(
2
+ task: () => Promise<T>,
3
+ count: number = 2,
4
+ ): Promise<T> {
5
+ let error: unknown = undefined;
6
+ for (let i: number = 0; i <= count; ++i)
7
+ try {
8
+ return await task();
9
+ } catch (e) {
10
+ error = e;
11
+ }
12
+ throw error;
13
+ }
@@ -1,3 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { OpenApi } from "@samchon/openapi";
3
- export declare function invertOpenApiDocument(document: OpenApi.IDocument): AutoBeOpenApi.IDocument;