@autobe/agent 0.9.2 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AutoBeAgent.js +11 -4
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +7 -6
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/context/AutoBeTokenUsage.d.ts +15 -1
- package/lib/context/AutoBeTokenUsage.js +56 -1
- package/lib/context/AutoBeTokenUsage.js.map +1 -1
- package/lib/factory/createAutoBeApplication.js +288 -653
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/index.mjs +4225 -6681
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +80 -321
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js +0 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +93 -266
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +2 -2
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/orchestrate/index.d.ts +2 -2
- package/lib/orchestrate/index.js +4 -4
- package/lib/orchestrate/index.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +54 -142
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +189 -201
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +71 -174
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +706 -1099
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/transformInterfaceHistories.js +2 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +60 -177
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +502 -1073
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +519 -1125
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +9 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +8 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.d.ts +11 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +78 -0
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +25 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +326 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.d.ts +80 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.js +53 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +39 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js +3 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +5 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +127 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -0
- package/lib/orchestrate/test/compile/completeTestCode.d.ts +2 -0
- package/lib/orchestrate/test/compile/completeTestCode.js +21 -0
- package/lib/orchestrate/test/compile/completeTestCode.js.map +1 -0
- package/lib/orchestrate/test/{filterTestFileName.js → compile/filterTestFileName.js} +1 -1
- package/lib/orchestrate/test/compile/filterTestFileName.js.map +1 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.d.ts +3 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.js +27 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -0
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +5 -0
- package/lib/orchestrate/test/{compileTestScenario.js → compile/getTestScenarioArtifacts.js} +10 -5
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTest.js +14 -9
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.js +142 -448
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +258 -532
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestWrite.js +124 -90
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +121 -0
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestFunction.d.ts +8 -0
- package/lib/{utils/types/BackoffOptions.js → orchestrate/test/structures/IAutoBeTestFunction.js} +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestFunction.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +14 -2
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +112 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.d.ts +7 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js.map +1 -0
- package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +3 -2
- package/lib/orchestrate/test/transformTestCorrectHistories.js +28 -67
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.d.ts +5 -4
- package/lib/orchestrate/test/transformTestWriteHistories.js +161 -43
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
- package/lib/structures/IAutoBeConfig.d.ts +11 -0
- package/lib/utils/backoffRetry.d.ts +4 -7
- package/lib/utils/backoffRetry.js +19 -37
- package/lib/utils/backoffRetry.js.map +1 -1
- package/lib/utils/forceRetry.d.ts +1 -0
- package/lib/{orchestrate/orchestrateRealize.js → utils/forceRetry.js} +15 -8
- package/lib/utils/forceRetry.js.map +1 -0
- package/package.json +9 -12
- package/src/AutoBeAgent.ts +17 -3
- package/src/constants/AutoBeSystemPromptConstant.ts +7 -6
- package/src/context/AutoBeTokenUsage.ts +85 -1
- package/src/factory/createAutoBeApplication.ts +2 -3
- package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +8 -3
- package/src/orchestrate/analyze/AutoBeAnalyzeReviewer.ts +0 -1
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +6 -5
- package/src/orchestrate/facade/transformFacadeStateMessage.ts +2 -1
- package/src/orchestrate/index.ts +2 -2
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +4 -3
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +26 -23
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +6 -4
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +14 -11
- package/src/orchestrate/interface/transformInterfaceHistories.ts +2 -0
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +10 -5
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +11 -5
- package/src/orchestrate/prisma/orchestratePrismaSchema.ts +16 -8
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +9 -0
- package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +8 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +129 -0
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +148 -0
- package/src/orchestrate/realize/orchestrateRealizePlanner.ts +115 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +46 -0
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +136 -0
- package/src/orchestrate/test/compile/completeTestCode.ts +35 -0
- package/src/orchestrate/test/{filterTestFileName.ts → compile/filterTestFileName.ts} +1 -1
- package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +24 -0
- package/src/orchestrate/test/{compileTestScenario.ts → compile/getTestScenarioArtifacts.ts} +16 -8
- package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +240 -0
- package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +316 -0
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -0
- package/src/orchestrate/test/orchestrateTest.ts +33 -16
- package/src/orchestrate/test/orchestrateTestCorrect.ts +109 -497
- package/src/orchestrate/test/orchestrateTestScenario.ts +102 -71
- package/src/orchestrate/test/orchestrateTestWrite.ts +55 -181
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +126 -0
- package/src/orchestrate/test/structures/IAutoBeTestFunction.ts +10 -0
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +14 -2
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +117 -0
- package/src/orchestrate/test/structures/IAutoBeTestWriteResult.ts +9 -0
- package/src/orchestrate/test/transformTestCorrectHistories.ts +38 -71
- package/src/orchestrate/test/transformTestWriteHistories.ts +88 -46
- package/src/structures/IAutoBeConfig.ts +9 -0
- package/src/utils/backoffRetry.ts +25 -36
- package/src/utils/forceRetry.ts +13 -0
- package/lib/factory/invertOpenApiDocument.d.ts +0 -3
- package/lib/factory/invertOpenApiDocument.js +0 -51
- package/lib/factory/invertOpenApiDocument.js.map +0 -1
- package/lib/orchestrate/orchestrateRealize.d.ts +0 -5
- package/lib/orchestrate/orchestrateRealize.js.map +0 -1
- package/lib/orchestrate/test/compileTestScenario.d.ts +0 -5
- package/lib/orchestrate/test/compileTestScenario.js.map +0 -1
- package/lib/orchestrate/test/filterTestFileName.js.map +0 -1
- package/lib/utils/StringUtil.d.ts +0 -4
- package/lib/utils/StringUtil.js +0 -43
- package/lib/utils/StringUtil.js.map +0 -1
- package/lib/utils/types/BackoffOptions.d.ts +0 -12
- package/lib/utils/types/BackoffOptions.js.map +0 -1
- package/src/factory/invertOpenApiDocument.ts +0 -63
- package/src/orchestrate/orchestrateRealize.ts +0 -18
- package/src/utils/StringUtil.ts +0 -45
- package/src/utils/types/BackoffOptions.ts +0 -15
- /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
|
-
/**
|
|
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
|
-
/**
|
|
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 {
|
|
6
|
+
import { IAutoBeTestFunction } from "./structures/IAutoBeTestFunction";
|
|
7
|
+
import { transformTestWriteHistories } from "./transformTestWriteHistories";
|
|
6
8
|
|
|
7
9
|
export const transformTestCorrectHistories = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
diagnostics: string[],
|
|
10
|
+
func: IAutoBeTestFunction,
|
|
11
|
+
failure: IAutoBeTypeScriptCompileResult.IFailure,
|
|
11
12
|
): Array<
|
|
12
13
|
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
13
|
-
> =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
9
|
-
scenario: AutoBeTestScenario
|
|
10
|
-
artifacts: IAutoBeTestScenarioArtifacts
|
|
11
|
-
|
|
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:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
JSON.stringify(
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
36
|
-
|
|
10
|
+
if (isRetryError(error) === false) {
|
|
11
|
+
throw error;
|
|
37
12
|
}
|
|
38
13
|
|
|
39
|
-
|
|
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
|
+
}
|