@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.
- package/lib/AutoBeAgent.js +16 -5
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +6 -4
- 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/context/IAutoBeApplicationProps.d.ts +0 -61
- package/lib/factory/createAutoBeApplication.js +298 -773
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/index.mjs +5116 -7271
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +82 -319
- 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 +97 -294
- 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/orchestrateInterface.js +9 -3
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +56 -142
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +195 -199
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +75 -172
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +772 -1097
- 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 +64 -175
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +552 -1073
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +571 -1119
- 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 +109 -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 +337 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizeIntegrator.d.ts +52 -0
- package/lib/orchestrate/realize/orchestrateRealizeIntegrator.js +57 -0
- package/lib/orchestrate/realize/orchestrateRealizeIntegrator.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/orchestrateRealizeValidator.d.ts +46 -0
- package/lib/orchestrate/realize/orchestrateRealizeValidator.js +37 -0
- package/lib/orchestrate/realize/orchestrateRealizeValidator.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +33 -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} +11 -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 +150 -349
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +323 -566
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestWrite.js +139 -76
- 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 +32 -22
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +2 -0
- 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 -41
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.d.ts +5 -4
- package/lib/orchestrate/test/transformTestWriteHistories.js +169 -32
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
- package/lib/structures/IAutoBeConfig.d.ts +11 -0
- package/lib/structures/IAutoBeProps.d.ts +12 -1
- 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 +8 -8
- package/src/AutoBeAgent.ts +26 -4
- package/src/constants/AutoBeSystemPromptConstant.ts +6 -4
- package/src/context/AutoBeTokenUsage.ts +85 -1
- package/src/context/IAutoBeApplicationProps.ts +0 -62
- 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 +8 -37
- package/src/orchestrate/facade/transformFacadeStateMessage.ts +2 -1
- package/src/orchestrate/index.ts +2 -2
- package/src/orchestrate/interface/orchestrateInterface.ts +7 -0
- 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 +169 -0
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +156 -0
- package/src/orchestrate/realize/orchestrateRealizeIntegrator.ts +75 -0
- package/src/orchestrate/realize/orchestrateRealizePlanner.ts +115 -0
- package/src/orchestrate/realize/orchestrateRealizeValidator.ts +64 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +36 -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} +17 -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 +38 -16
- package/src/orchestrate/test/orchestrateTestCorrect.ts +111 -338
- package/src/orchestrate/test/orchestrateTestScenario.ts +114 -69
- package/src/orchestrate/test/orchestrateTestWrite.ts +55 -153
- 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 +32 -22
- package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +3 -0
- 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 -43
- package/src/orchestrate/test/transformTestWriteHistories.ts +89 -35
- package/src/structures/IAutoBeConfig.ts +9 -0
- package/src/structures/IAutoBeProps.ts +17 -1
- 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
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
2
|
import {
|
|
3
|
-
AutoBeTestFile,
|
|
4
|
-
AutoBeTestScenario,
|
|
5
3
|
AutoBeTestValidateEvent,
|
|
6
|
-
|
|
7
|
-
IAutoBeTypeScriptCompilerResult,
|
|
4
|
+
IAutoBeTypeScriptCompileResult,
|
|
8
5
|
} from "@autobe/interface";
|
|
9
6
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
10
7
|
import { IPointer } from "tstl";
|
|
@@ -12,317 +9,147 @@ import typia from "typia";
|
|
|
12
9
|
|
|
13
10
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
14
11
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
15
|
-
import { randomBackoffRetry } from "../../utils/backoffRetry";
|
|
16
12
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
13
|
+
import { forceRetry } from "../../utils/forceRetry";
|
|
14
|
+
import { completeTestCode } from "./compile/completeTestCode";
|
|
15
|
+
import { IAutoBeTestCorrectApplication } from "./structures/IAutoBeTestCorrectApplication";
|
|
16
|
+
import { IAutoBeTestFunction } from "./structures/IAutoBeTestFunction";
|
|
19
17
|
import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
|
|
18
|
+
import { IAutoBeTestWriteResult } from "./structures/IAutoBeTestWriteResult";
|
|
20
19
|
import { transformTestCorrectHistories } from "./transformTestCorrectHistories";
|
|
21
20
|
|
|
22
|
-
export async
|
|
21
|
+
export const orchestrateTestCorrect = async <Model extends ILlmSchema.Model>(
|
|
23
22
|
ctx: AutoBeContext<Model>,
|
|
24
|
-
|
|
25
|
-
scenarios: AutoBeTestScenario[],
|
|
23
|
+
writeResult: IAutoBeTestWriteResult[],
|
|
26
24
|
life: number = 4,
|
|
27
|
-
): Promise<AutoBeTestValidateEvent>
|
|
28
|
-
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
): Promise<AutoBeTestValidateEvent[]> =>
|
|
26
|
+
Promise.all(
|
|
27
|
+
writeResult.map((w) =>
|
|
28
|
+
forceRetry(async () => {
|
|
29
|
+
const event: AutoBeTestValidateEvent = await compile(ctx, {
|
|
30
|
+
artifacts: w.artifacts,
|
|
31
|
+
scenario: w.scenario,
|
|
32
|
+
location: w.event.location,
|
|
33
|
+
script: w.event.final,
|
|
34
|
+
});
|
|
35
|
+
return predicate(
|
|
36
|
+
ctx,
|
|
37
|
+
{
|
|
38
|
+
artifacts: w.artifacts,
|
|
39
|
+
scenario: w.scenario,
|
|
40
|
+
location: w.event.location,
|
|
41
|
+
script: w.event.final,
|
|
42
|
+
},
|
|
43
|
+
event,
|
|
44
|
+
life,
|
|
45
|
+
);
|
|
46
|
+
}),
|
|
44
47
|
),
|
|
45
48
|
);
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
const external = async (
|
|
49
|
-
location: string,
|
|
50
|
-
): Promise<Record<string, string>> => {
|
|
51
|
-
const content: string | undefined =
|
|
52
|
-
await ctx.compiler.typescript.getExternal(location);
|
|
53
|
-
if (content === undefined) throw new Error(`File not found: ${location}`);
|
|
54
|
-
return { [location]: content };
|
|
55
|
-
};
|
|
56
|
-
const mergedFiles: Record<string, string> = {
|
|
57
|
-
...retainedFiles,
|
|
58
|
-
...testFiles,
|
|
59
|
-
...(await external("node_modules/@nestia/e2e/lib/TestValidator.d.ts")),
|
|
60
|
-
...(await external("node_modules/@nestia/fetcher/lib/IConnection.d.ts")),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// 4) Ask the LLM to correct the filtered file set
|
|
64
|
-
const response: AutoBeTestValidateEvent = await step(
|
|
65
|
-
ctx,
|
|
66
|
-
mergedFiles,
|
|
67
|
-
files,
|
|
68
|
-
life,
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// 5) Combine original + corrected files and dispatch event
|
|
72
|
-
const event: AutoBeTestValidateEvent = {
|
|
73
|
-
...response,
|
|
74
|
-
type: "testValidate",
|
|
75
|
-
files: [
|
|
76
|
-
...Object.entries(mergedFiles).map(
|
|
77
|
-
([filename, content]): AutoBeTestFile => {
|
|
78
|
-
return {
|
|
79
|
-
location: filename,
|
|
80
|
-
content,
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
),
|
|
84
|
-
...response.files,
|
|
85
|
-
],
|
|
86
|
-
};
|
|
87
|
-
return event;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Modifies test code for each file and checks for compilation errors. When
|
|
92
|
-
* compilation errors occur, it uses LLM to fix the code and attempts
|
|
93
|
-
* recompilation. This process repeats up to the maximum retry count until
|
|
94
|
-
* compilation succeeds.
|
|
95
|
-
*
|
|
96
|
-
* The function is a critical part of the test generation pipeline that ensures
|
|
97
|
-
* all generated test files are syntactically correct and compilable.
|
|
98
|
-
*
|
|
99
|
-
* @param ctx AutoBe context object
|
|
100
|
-
* @param entireFiles Map of all files to compile (filename: content)
|
|
101
|
-
* @param testFiles Map of files to compile (filename: content)
|
|
102
|
-
* @param life Number of remaining retry attempts
|
|
103
|
-
* @returns Event object containing successful compilation result and modified
|
|
104
|
-
* files
|
|
105
|
-
*/
|
|
106
|
-
async function step<Model extends ILlmSchema.Model>(
|
|
50
|
+
const compile = async <Model extends ILlmSchema.Model>(
|
|
107
51
|
ctx: AutoBeContext<Model>,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (result.type === "success") {
|
|
119
|
-
// SUCCESS
|
|
120
|
-
return {
|
|
121
|
-
type: "testValidate",
|
|
122
|
-
created_at: new Date().toISOString(),
|
|
123
|
-
files: testFiles,
|
|
124
|
-
result,
|
|
125
|
-
step: ctx.state().interface?.step ?? 0,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// EXCEPTION ERROR
|
|
130
|
-
if (result.type === "exception") {
|
|
131
|
-
ctx.dispatch({
|
|
132
|
-
type: "testValidate",
|
|
133
|
-
created_at: new Date().toISOString(),
|
|
134
|
-
files: testFiles,
|
|
135
|
-
result,
|
|
136
|
-
step: ctx.state().interface?.step ?? 0,
|
|
137
|
-
});
|
|
138
|
-
throw new Error(JSON.stringify(result.error, null, 2));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Make the diagnostics object (e.g. { "test/features/api/article.ts": [error1, error2] })
|
|
142
|
-
const diagnostics: Record<
|
|
143
|
-
string,
|
|
144
|
-
IAutoBeTypeScriptCompilerResult.IDiagnostic[]
|
|
145
|
-
> = {};
|
|
146
|
-
|
|
147
|
-
result.diagnostics.forEach((d) => {
|
|
148
|
-
if (d.file === null) return;
|
|
149
|
-
|
|
150
|
-
diagnostics[d.file] = diagnostics[d.file] ?? [];
|
|
151
|
-
diagnostics[d.file].push(d);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (Object.keys(diagnostics).length === 0) {
|
|
155
|
-
/**
|
|
156
|
-
* SUCCESS (Because typescript compiler can't success to compile the json
|
|
157
|
-
* files, so result could be failure. but it's success to compile the ts
|
|
158
|
-
* files.)
|
|
159
|
-
*/
|
|
160
|
-
return {
|
|
161
|
-
type: "testValidate",
|
|
162
|
-
created_at: new Date().toISOString(),
|
|
163
|
-
files: testFiles,
|
|
164
|
-
result: {
|
|
165
|
-
...result,
|
|
166
|
-
type: "success",
|
|
52
|
+
func: IAutoBeTestFunction,
|
|
53
|
+
): Promise<AutoBeTestValidateEvent> => {
|
|
54
|
+
const compiled: IAutoBeTypeScriptCompileResult =
|
|
55
|
+
await ctx.compiler.test.compile({
|
|
56
|
+
files: {
|
|
57
|
+
...func.artifacts.dto,
|
|
58
|
+
...func.artifacts.sdk,
|
|
59
|
+
[func.location]: func.script,
|
|
167
60
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Compile Failed
|
|
173
|
-
ctx.dispatch({
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
174
63
|
type: "testValidate",
|
|
64
|
+
file: {
|
|
65
|
+
scenario: func.scenario,
|
|
66
|
+
location: func.location,
|
|
67
|
+
content: func.script,
|
|
68
|
+
},
|
|
69
|
+
result: compiled,
|
|
175
70
|
created_at: new Date().toISOString(),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
if (life <= 0)
|
|
182
|
-
return {
|
|
183
|
-
type: "testValidate",
|
|
184
|
-
created_at: new Date().toISOString(),
|
|
185
|
-
files: testFiles,
|
|
186
|
-
result,
|
|
187
|
-
step: ctx.state().interface?.step ?? 0,
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// VALIDATION FAILED
|
|
191
|
-
const validatedFiles: AutoBeTestFile[] = await Promise.all(
|
|
192
|
-
Object.entries(diagnostics).map(
|
|
193
|
-
async ([filename, d]): Promise<AutoBeTestFile> => {
|
|
194
|
-
const file = testFiles.find((f) => f.location === filename);
|
|
195
|
-
const code: string = file?.content!;
|
|
196
|
-
const scenario = file?.scenario!;
|
|
197
|
-
|
|
198
|
-
const response: ICorrectTestFunctionProps = await process(
|
|
199
|
-
ctx,
|
|
200
|
-
d,
|
|
201
|
-
code,
|
|
202
|
-
scenario,
|
|
203
|
-
);
|
|
204
|
-
ctx.dispatch({
|
|
205
|
-
type: "testCorrect",
|
|
206
|
-
created_at: new Date().toISOString(),
|
|
207
|
-
files: { ...testFiles, [filename]: response.content },
|
|
208
|
-
result,
|
|
209
|
-
solution: response.solution,
|
|
210
|
-
think_without_compile_error: response.think_without_compile_error,
|
|
211
|
-
think_again_with_compile_error:
|
|
212
|
-
response.think_again_with_compile_error,
|
|
213
|
-
step: ctx.state().interface?.step ?? 0,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
return { location: filename, content: code, scenario: scenario };
|
|
217
|
-
},
|
|
218
|
-
),
|
|
219
|
-
);
|
|
71
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
220
74
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
75
|
+
const predicate = async <Model extends ILlmSchema.Model>(
|
|
76
|
+
ctx: AutoBeContext<Model>,
|
|
77
|
+
content: IAutoBeTestFunction,
|
|
78
|
+
event: AutoBeTestValidateEvent,
|
|
79
|
+
life: number,
|
|
80
|
+
): Promise<AutoBeTestValidateEvent> => {
|
|
81
|
+
ctx.dispatch(event);
|
|
82
|
+
return event.result.type === "failure"
|
|
83
|
+
? correct(ctx, content, event, life - 1)
|
|
84
|
+
: event;
|
|
85
|
+
};
|
|
231
86
|
|
|
232
|
-
|
|
233
|
-
* Modifies the code of test files where errors occurred. This function
|
|
234
|
-
* processes TypeScript compiler diagnostics and attempts to fix compilation
|
|
235
|
-
* errors.
|
|
236
|
-
*
|
|
237
|
-
* @param ctx The AutoBeContext containing application state and configuration
|
|
238
|
-
* @param diagnostics Array of TypeScript compiler diagnostics for the errors
|
|
239
|
-
* @param code The source code content to be fixed
|
|
240
|
-
* @returns Promise resolving to corrected test function properties
|
|
241
|
-
*/
|
|
242
|
-
async function process<Model extends ILlmSchema.Model>(
|
|
87
|
+
const correct = async <Model extends ILlmSchema.Model>(
|
|
243
88
|
ctx: AutoBeContext<Model>,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
): Promise<
|
|
248
|
-
|
|
89
|
+
content: IAutoBeTestFunction,
|
|
90
|
+
validate: AutoBeTestValidateEvent,
|
|
91
|
+
life: number,
|
|
92
|
+
): Promise<AutoBeTestValidateEvent> => {
|
|
93
|
+
if (validate.result.type !== "failure") return validate;
|
|
94
|
+
else if (--life <= 0) return validate;
|
|
95
|
+
|
|
96
|
+
const pointer: IPointer<IAutoBeTestCorrectApplication.IProps | null> = {
|
|
249
97
|
value: null,
|
|
250
98
|
};
|
|
251
|
-
const artifacts: IAutoBeTestScenarioArtifacts = await compileTestScenario(
|
|
252
|
-
ctx,
|
|
253
|
-
scenario,
|
|
254
|
-
);
|
|
255
|
-
|
|
256
99
|
const agentica = new MicroAgentica({
|
|
257
100
|
model: ctx.model,
|
|
258
|
-
vendor:
|
|
101
|
+
vendor: ctx.vendor,
|
|
259
102
|
config: {
|
|
260
103
|
...(ctx.config ?? {}),
|
|
104
|
+
executor: {
|
|
105
|
+
describe: null,
|
|
106
|
+
},
|
|
107
|
+
retry: 4,
|
|
261
108
|
},
|
|
262
|
-
histories: transformTestCorrectHistories(
|
|
109
|
+
histories: transformTestCorrectHistories(content, validate.result),
|
|
263
110
|
controllers: [
|
|
264
111
|
createApplication({
|
|
265
112
|
model: ctx.model,
|
|
113
|
+
artifacts: content.artifacts,
|
|
266
114
|
build: (next) => {
|
|
267
115
|
pointer.value = next;
|
|
268
116
|
},
|
|
269
117
|
}),
|
|
270
118
|
],
|
|
271
|
-
tokenUsage: ctx.usage(),
|
|
272
119
|
});
|
|
273
120
|
enforceToolCall(agentica);
|
|
274
121
|
|
|
275
|
-
await
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
"",
|
|
285
|
-
diagnostics.map((diagnostic) => {
|
|
286
|
-
if (diagnostic.start === undefined || diagnostic.length === undefined)
|
|
287
|
-
return "";
|
|
288
|
-
|
|
289
|
-
const checkDtoRegexp = `Cannot find module '@ORGANIZATION/template-api/lib/structures/IBbsArticleComment' or its corresponding type declarations.`;
|
|
290
|
-
const [group] = [
|
|
291
|
-
...checkDtoRegexp.matchAll(
|
|
292
|
-
/Cannot find module '(.*lib\/structures\/.*)'/g,
|
|
293
|
-
),
|
|
294
|
-
];
|
|
295
|
-
|
|
296
|
-
const [_, filename] = group ?? [];
|
|
122
|
+
await agentica
|
|
123
|
+
.conversate(
|
|
124
|
+
"Fix the `AutoBeTest.IFunction` data to resolve the compilation error.",
|
|
125
|
+
)
|
|
126
|
+
.finally(() => {
|
|
127
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
128
|
+
ctx.usage().record(tokenUsage, ["test"]);
|
|
129
|
+
});
|
|
130
|
+
if (pointer.value === null) throw new Error("Failed to modify test code.");
|
|
297
131
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
`Note: '@ORGANIZATION/PROJECT-api' must be written exactly as is and should not be replaced.\n`
|
|
306
|
-
: "",
|
|
307
|
-
].join("\n");
|
|
308
|
-
}),
|
|
309
|
-
"## Instructions",
|
|
310
|
-
"1. Focus on the specific error location and message",
|
|
311
|
-
"2. Provide the corrected TypeScript code",
|
|
312
|
-
"3. Ensure the fix resolves the compilation error",
|
|
313
|
-
"",
|
|
314
|
-
"Return only the fixed code without explanations.",
|
|
315
|
-
].join("\n"),
|
|
316
|
-
);
|
|
132
|
+
ctx.dispatch({
|
|
133
|
+
type: "testCorrect",
|
|
134
|
+
created_at: new Date().toISOString(),
|
|
135
|
+
file: validate.file,
|
|
136
|
+
result: validate.result,
|
|
137
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
138
|
+
...pointer.value,
|
|
317
139
|
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
140
|
+
const newContent: IAutoBeTestFunction = {
|
|
141
|
+
...content,
|
|
142
|
+
script: pointer.value.final,
|
|
143
|
+
};
|
|
144
|
+
const newValidate: AutoBeTestValidateEvent = await compile(ctx, newContent);
|
|
145
|
+
return predicate(ctx, newContent, newValidate, life);
|
|
146
|
+
};
|
|
321
147
|
|
|
322
|
-
|
|
148
|
+
const createApplication = <Model extends ILlmSchema.Model>(props: {
|
|
323
149
|
model: Model;
|
|
324
|
-
|
|
325
|
-
|
|
150
|
+
artifacts: IAutoBeTestScenarioArtifacts;
|
|
151
|
+
build: (next: IAutoBeTestCorrectApplication.IProps) => void;
|
|
152
|
+
}): IAgenticaController.IClass<Model> => {
|
|
326
153
|
assertSchemaModel(props.model);
|
|
327
154
|
|
|
328
155
|
const application: ILlmApplication<Model> = collection[
|
|
@@ -333,15 +160,17 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
|
333
160
|
name: "Modify Test Code",
|
|
334
161
|
application,
|
|
335
162
|
execute: {
|
|
336
|
-
|
|
163
|
+
rewrite: (next) => {
|
|
164
|
+
next.draft = completeTestCode(props.artifacts, next.draft);
|
|
165
|
+
next.final = completeTestCode(props.artifacts, next.final);
|
|
337
166
|
props.build(next);
|
|
338
167
|
},
|
|
339
|
-
} satisfies
|
|
168
|
+
} satisfies IAutoBeTestCorrectApplication,
|
|
340
169
|
};
|
|
341
|
-
}
|
|
170
|
+
};
|
|
342
171
|
|
|
343
172
|
const claude = typia.llm.application<
|
|
344
|
-
|
|
173
|
+
IAutoBeTestCorrectApplication,
|
|
345
174
|
"claude",
|
|
346
175
|
{
|
|
347
176
|
reference: true;
|
|
@@ -349,7 +178,7 @@ const claude = typia.llm.application<
|
|
|
349
178
|
>();
|
|
350
179
|
const collection = {
|
|
351
180
|
chatgpt: typia.llm.application<
|
|
352
|
-
|
|
181
|
+
IAutoBeTestCorrectApplication,
|
|
353
182
|
"chatgpt",
|
|
354
183
|
{ reference: true }
|
|
355
184
|
>(),
|
|
@@ -357,60 +186,4 @@ const collection = {
|
|
|
357
186
|
llama: claude,
|
|
358
187
|
deepseek: claude,
|
|
359
188
|
"3.1": claude,
|
|
360
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
361
189
|
};
|
|
362
|
-
|
|
363
|
-
interface IApplication {
|
|
364
|
-
correctTestCode(props: ICorrectTestFunctionProps): void;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
interface ICorrectTestFunctionProps {
|
|
368
|
-
/**
|
|
369
|
-
* Step 1: Initial self-reflection on the source code without compiler error
|
|
370
|
-
* context.
|
|
371
|
-
*
|
|
372
|
-
* The AI agent analyzes the previously generated test code to identify
|
|
373
|
-
* potential issues, relying solely on its understanding of TypeScript syntax,
|
|
374
|
-
* testing patterns, and best practices.
|
|
375
|
-
*
|
|
376
|
-
* This encourages the agent to develop independent debugging skills before
|
|
377
|
-
* being influenced by external error messages.
|
|
378
|
-
*/
|
|
379
|
-
think_without_compile_error: string;
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Step 2: Re-evaluation of the code with compiler error messages as
|
|
383
|
-
* additional context.
|
|
384
|
-
*
|
|
385
|
-
* After the initial analysis, the AI agent reviews the same code again, this
|
|
386
|
-
* time incorporating the specific TypeScript compiler error messages.
|
|
387
|
-
*
|
|
388
|
-
* This allows the agent to correlate its initial observations with concrete
|
|
389
|
-
* compilation failures and refine its understanding of what went wrong.
|
|
390
|
-
*/
|
|
391
|
-
think_again_with_compile_error: string;
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Step 3: Concrete action plan for fixing the identified issues.
|
|
395
|
-
*
|
|
396
|
-
* Based on the analysis from steps 1 and 2, the AI agent formulates a
|
|
397
|
-
* specific, step-by-step solution strategy.
|
|
398
|
-
*
|
|
399
|
-
* This should include what changes need to be made, why those changes are
|
|
400
|
-
* necessary, and how they will resolve the compilation errors while
|
|
401
|
-
* maintaining the test's intended functionality.
|
|
402
|
-
*/
|
|
403
|
-
solution: string;
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Step 4: The corrected TypeScript test code.
|
|
407
|
-
*
|
|
408
|
-
* The final, properly fixed TypeScript code that should compile without
|
|
409
|
-
* errors.
|
|
410
|
-
*
|
|
411
|
-
* This represents the implementation of the solution plan from step 3,
|
|
412
|
-
* containing all necessary corrections to make the test code syntactically
|
|
413
|
-
* valid and functionally correct.
|
|
414
|
-
*/
|
|
415
|
-
content: string;
|
|
416
|
-
}
|