@autobe/agent 0.9.0 → 0.9.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 +3 -1
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +2 -2
- package/lib/index.mjs +883 -865
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/test/compileTestScenario.d.ts +5 -0
- package/lib/orchestrate/test/compileTestScenario.js +56 -0
- package/lib/orchestrate/test/compileTestScenario.js.map +1 -0
- package/lib/orchestrate/test/filterTestFileName.d.ts +1 -0
- package/lib/orchestrate/test/filterTestFileName.js +13 -0
- package/lib/orchestrate/test/filterTestFileName.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTest.js +6 -3
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +2 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.js +46 -60
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -0
- package/lib/orchestrate/test/{orchestrateTestProgress.js → orchestrateTestWrite.js} +10 -51
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +5 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.js.map +1 -0
- package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -2
- package/lib/orchestrate/test/transformTestCorrectHistories.js +9 -13
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.d.ts +7 -0
- package/lib/orchestrate/test/transformTestWriteHistories.js +47 -0
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -0
- package/package.json +4 -4
- package/src/AutoBeAgent.ts +5 -1
- package/src/constants/AutoBeSystemPromptConstant.ts +1 -1
- package/src/orchestrate/test/compileTestScenario.ts +63 -0
- package/src/orchestrate/test/filterTestFileName.ts +9 -0
- package/src/orchestrate/test/orchestrateTest.ts +6 -5
- package/src/orchestrate/test/orchestrateTestCorrect.ts +96 -97
- package/src/orchestrate/test/orchestrateTestScenario.ts +6 -3
- package/src/orchestrate/test/{orchestrateTestProgress.ts → orchestrateTestWrite.ts} +14 -73
- package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +5 -0
- package/src/orchestrate/test/transformTestCorrectHistories.ts +10 -14
- package/src/orchestrate/test/{transformTestProgressHistories.ts → transformTestWriteHistories.ts} +9 -10
- package/lib/orchestrate/test/orchestrateTestProgress.d.ts +0 -5
- package/lib/orchestrate/test/orchestrateTestProgress.js.map +0 -1
- package/lib/orchestrate/test/transformTestProgressHistories.d.ts +0 -8
- package/lib/orchestrate/test/transformTestProgressHistories.js +0 -47
- package/lib/orchestrate/test/transformTestProgressHistories.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
AutoBeTestFile,
|
|
4
|
+
AutoBeTestScenario,
|
|
5
5
|
AutoBeTestValidateEvent,
|
|
6
6
|
AutoBeTestWriteEvent,
|
|
7
7
|
IAutoBeTypeScriptCompilerResult,
|
|
@@ -14,59 +14,57 @@ import { AutoBeContext } from "../../context/AutoBeContext";
|
|
|
14
14
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
15
15
|
import { randomBackoffRetry } from "../../utils/backoffRetry";
|
|
16
16
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
17
|
-
import {
|
|
17
|
+
import { compileTestScenario } from "./compileTestScenario";
|
|
18
|
+
import { filterTestFileName } from "./filterTestFileName";
|
|
19
|
+
import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
|
|
18
20
|
import { transformTestCorrectHistories } from "./transformTestCorrectHistories";
|
|
19
21
|
|
|
20
22
|
export async function orchestrateTestCorrect<Model extends ILlmSchema.Model>(
|
|
21
23
|
ctx: AutoBeContext<Model>,
|
|
22
24
|
codes: AutoBeTestWriteEvent[],
|
|
23
|
-
scenarios:
|
|
25
|
+
scenarios: AutoBeTestScenario[],
|
|
24
26
|
life: number = 4,
|
|
25
27
|
): Promise<AutoBeTestValidateEvent> {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const files: AutoBeTestFile[] = codes.map(
|
|
29
|
+
({ filename, content }, index): AutoBeTestFile => {
|
|
30
|
+
const scenario: AutoBeTestScenario = scenarios[index];
|
|
31
|
+
return { location: filename, content, scenario };
|
|
32
|
+
},
|
|
33
|
+
);
|
|
30
34
|
|
|
31
35
|
// 1) Build map of new test files from progress events
|
|
32
|
-
const testFiles: Record<string, string> =
|
|
33
|
-
.map((
|
|
34
|
-
|
|
35
|
-
[`test/features/api/${filename}`]: content,
|
|
36
|
-
};
|
|
37
|
-
})
|
|
38
|
-
.reduce<Record<string, string>>((acc, cur) => Object.assign(acc, cur), {});
|
|
36
|
+
const testFiles: Record<string, string> = Object.fromEntries(
|
|
37
|
+
codes.map((c) => [c.filename, c.content]),
|
|
38
|
+
);
|
|
39
39
|
|
|
40
40
|
// 2) Keep only files outside the test directory from current state
|
|
41
|
-
const retainedFiles: Record<string, string> = Object.
|
|
42
|
-
ctx.state().interface?.files ?? {}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
.map(([filename, content]) => {
|
|
48
|
-
return { [filename]: content };
|
|
49
|
-
})
|
|
50
|
-
.reduce<Record<string, string>>((acc, cur) => Object.assign(acc, cur), {});
|
|
41
|
+
const retainedFiles: Record<string, string> = Object.fromEntries(
|
|
42
|
+
Object.entries(ctx.state().interface?.files ?? {}).filter(([key]) =>
|
|
43
|
+
filterTestFileName(key),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
51
46
|
|
|
52
47
|
// 3) Merge and filter: keep .ts/.json, drop anything under "benchmark"
|
|
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
|
+
};
|
|
53
56
|
const mergedFiles: Record<string, string> = {
|
|
54
57
|
...retainedFiles,
|
|
55
58
|
...testFiles,
|
|
59
|
+
...(await external("node_modules/@nestia/e2e/lib/TestValidator.d.ts")),
|
|
60
|
+
...(await external("node_modules/@nestia/fetcher/lib/IConnection.d.ts")),
|
|
56
61
|
};
|
|
57
|
-
const files: Record<string, string> = Object.fromEntries(
|
|
58
|
-
Object.entries(mergedFiles).filter(
|
|
59
|
-
([filename]) =>
|
|
60
|
-
(filename.endsWith(".ts") && !filename.startsWith("test/benchmark/")) ||
|
|
61
|
-
filename.endsWith(".json"),
|
|
62
|
-
),
|
|
63
|
-
);
|
|
64
62
|
|
|
65
63
|
// 4) Ask the LLM to correct the filtered file set
|
|
66
64
|
const response: AutoBeTestValidateEvent = await step(
|
|
67
65
|
ctx,
|
|
66
|
+
mergedFiles,
|
|
68
67
|
files,
|
|
69
|
-
scenarioMap,
|
|
70
68
|
life,
|
|
71
69
|
);
|
|
72
70
|
|
|
@@ -74,7 +72,17 @@ export async function orchestrateTestCorrect<Model extends ILlmSchema.Model>(
|
|
|
74
72
|
const event: AutoBeTestValidateEvent = {
|
|
75
73
|
...response,
|
|
76
74
|
type: "testValidate",
|
|
77
|
-
files:
|
|
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
|
+
],
|
|
78
86
|
};
|
|
79
87
|
return event;
|
|
80
88
|
}
|
|
@@ -89,29 +97,30 @@ export async function orchestrateTestCorrect<Model extends ILlmSchema.Model>(
|
|
|
89
97
|
* all generated test files are syntactically correct and compilable.
|
|
90
98
|
*
|
|
91
99
|
* @param ctx AutoBe context object
|
|
92
|
-
* @param
|
|
100
|
+
* @param entireFiles Map of all files to compile (filename: content)
|
|
101
|
+
* @param testFiles Map of files to compile (filename: content)
|
|
93
102
|
* @param life Number of remaining retry attempts
|
|
94
103
|
* @returns Event object containing successful compilation result and modified
|
|
95
104
|
* files
|
|
96
105
|
*/
|
|
97
106
|
async function step<Model extends ILlmSchema.Model>(
|
|
98
107
|
ctx: AutoBeContext<Model>,
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
entireFiles: Record<string, string>,
|
|
109
|
+
testFiles: AutoBeTestFile[],
|
|
101
110
|
life: number,
|
|
102
111
|
): Promise<AutoBeTestValidateEvent> {
|
|
103
112
|
// COMPILE TEST CODE
|
|
104
|
-
|
|
105
113
|
const result: IAutoBeTypeScriptCompilerResult =
|
|
106
114
|
await ctx.compiler.typescript.compile({
|
|
107
|
-
files,
|
|
115
|
+
files: entireFiles,
|
|
108
116
|
});
|
|
117
|
+
|
|
109
118
|
if (result.type === "success") {
|
|
110
119
|
// SUCCESS
|
|
111
120
|
return {
|
|
112
121
|
type: "testValidate",
|
|
113
122
|
created_at: new Date().toISOString(),
|
|
114
|
-
files,
|
|
123
|
+
files: testFiles,
|
|
115
124
|
result,
|
|
116
125
|
step: ctx.state().interface?.step ?? 0,
|
|
117
126
|
};
|
|
@@ -122,7 +131,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
122
131
|
ctx.dispatch({
|
|
123
132
|
type: "testValidate",
|
|
124
133
|
created_at: new Date().toISOString(),
|
|
125
|
-
files,
|
|
134
|
+
files: testFiles,
|
|
126
135
|
result,
|
|
127
136
|
step: ctx.state().interface?.step ?? 0,
|
|
128
137
|
});
|
|
@@ -151,7 +160,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
151
160
|
return {
|
|
152
161
|
type: "testValidate",
|
|
153
162
|
created_at: new Date().toISOString(),
|
|
154
|
-
files,
|
|
163
|
+
files: testFiles,
|
|
155
164
|
result: {
|
|
156
165
|
...result,
|
|
157
166
|
type: "success",
|
|
@@ -164,7 +173,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
164
173
|
ctx.dispatch({
|
|
165
174
|
type: "testValidate",
|
|
166
175
|
created_at: new Date().toISOString(),
|
|
167
|
-
files,
|
|
176
|
+
files: testFiles,
|
|
168
177
|
result,
|
|
169
178
|
step: ctx.state().interface?.step ?? 0,
|
|
170
179
|
});
|
|
@@ -173,44 +182,51 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
173
182
|
return {
|
|
174
183
|
type: "testValidate",
|
|
175
184
|
created_at: new Date().toISOString(),
|
|
176
|
-
files,
|
|
185
|
+
files: testFiles,
|
|
177
186
|
result,
|
|
178
187
|
step: ctx.state().interface?.step ?? 0,
|
|
179
188
|
};
|
|
180
189
|
|
|
181
190
|
// VALIDATION FAILED
|
|
182
|
-
const
|
|
183
|
-
Object.entries(diagnostics).map(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
),
|
|
207
219
|
);
|
|
208
220
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
221
|
+
return step(
|
|
222
|
+
ctx,
|
|
223
|
+
entireFiles,
|
|
224
|
+
testFiles.map((f) => {
|
|
225
|
+
const validated = validatedFiles.find((v) => v.location === f.location);
|
|
226
|
+
return validated ? validated : f;
|
|
227
|
+
}),
|
|
228
|
+
life - 1,
|
|
229
|
+
);
|
|
214
230
|
}
|
|
215
231
|
|
|
216
232
|
/**
|
|
@@ -227,32 +243,15 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
227
243
|
ctx: AutoBeContext<Model>,
|
|
228
244
|
diagnostics: IAutoBeTypeScriptCompilerResult.IDiagnostic[],
|
|
229
245
|
code: string,
|
|
230
|
-
scenario:
|
|
246
|
+
scenario: AutoBeTestScenario,
|
|
231
247
|
): Promise<ICorrectTestFunctionProps> {
|
|
232
248
|
const pointer: IPointer<ICorrectTestFunctionProps | null> = {
|
|
233
249
|
value: null,
|
|
234
250
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// const apiFiles = Object.entries(ctx.state().interface?.files ?? {})
|
|
242
|
-
// .filter(([filename]) => {
|
|
243
|
-
// return filename.startsWith("src/api/");
|
|
244
|
-
// })
|
|
245
|
-
// .reduce<Record<string, string>>((acc, [filename, content]) => {
|
|
246
|
-
// return Object.assign(acc, { [filename]: content });
|
|
247
|
-
// }, {});
|
|
248
|
-
|
|
249
|
-
// const dtoFiles = Object.entries(ctx.state().interface?.files ?? {})
|
|
250
|
-
// .filter(([filename]) => {
|
|
251
|
-
// return filename.startsWith("src/api/structures/");
|
|
252
|
-
// })
|
|
253
|
-
// .reduce<Record<string, string>>((acc, [filename, content]) => {
|
|
254
|
-
// return Object.assign(acc, { [filename]: content });
|
|
255
|
-
// }, {});
|
|
251
|
+
const artifacts: IAutoBeTestScenarioArtifacts = await compileTestScenario(
|
|
252
|
+
ctx,
|
|
253
|
+
scenario,
|
|
254
|
+
);
|
|
256
255
|
|
|
257
256
|
const agentica = new MicroAgentica({
|
|
258
257
|
model: ctx.model,
|
|
@@ -260,7 +259,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
260
259
|
config: {
|
|
261
260
|
...(ctx.config ?? {}),
|
|
262
261
|
},
|
|
263
|
-
histories: transformTestCorrectHistories(
|
|
262
|
+
histories: transformTestCorrectHistories(artifacts),
|
|
264
263
|
controllers: [
|
|
265
264
|
createApplication({
|
|
266
265
|
model: ctx.model,
|
|
@@ -3,8 +3,11 @@ import {
|
|
|
3
3
|
IAgenticaHistoryJson,
|
|
4
4
|
MicroAgentica,
|
|
5
5
|
} from "@agentica/core";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
AutoBeOpenApi,
|
|
8
|
+
AutoBeTestScenario,
|
|
9
|
+
AutoBeTestScenarioEvent,
|
|
10
|
+
} from "@autobe/interface";
|
|
8
11
|
import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
|
|
9
12
|
import { IPointer } from "tstl";
|
|
10
13
|
import typia from "typia";
|
|
@@ -69,7 +72,7 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
|
|
|
69
72
|
draft: plan.draft,
|
|
70
73
|
functionName: plan.functionName,
|
|
71
74
|
dependencies: plan.dependsOn,
|
|
72
|
-
} satisfies
|
|
75
|
+
} satisfies AutoBeTestScenario;
|
|
73
76
|
});
|
|
74
77
|
}),
|
|
75
78
|
created_at: new Date().toISOString(),
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
AutoBeTestScenarioEvent,
|
|
5
|
-
AutoBeTestWriteEvent,
|
|
6
|
-
} from "@autobe/interface";
|
|
7
|
-
import {
|
|
8
|
-
ILlmApplication,
|
|
9
|
-
ILlmSchema,
|
|
10
|
-
OpenApiTypeChecker,
|
|
11
|
-
} from "@samchon/openapi";
|
|
2
|
+
import { AutoBeTestScenario, AutoBeTestWriteEvent } from "@autobe/interface";
|
|
3
|
+
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
12
4
|
import { IPointer } from "tstl";
|
|
13
5
|
import typia from "typia";
|
|
14
6
|
|
|
15
7
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
16
8
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
17
9
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
18
|
-
import {
|
|
10
|
+
import { compileTestScenario } from "./compileTestScenario";
|
|
11
|
+
import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
|
|
12
|
+
import { transformTestWriteHistories } from "./transformTestWriteHistories";
|
|
19
13
|
|
|
20
|
-
export async function
|
|
14
|
+
export async function orchestrateTestWrite<Model extends ILlmSchema.Model>(
|
|
21
15
|
ctx: AutoBeContext<Model>,
|
|
22
|
-
scenarios:
|
|
16
|
+
scenarios: AutoBeTestScenario[],
|
|
23
17
|
): Promise<AutoBeTestWriteEvent[]> {
|
|
24
18
|
const start: Date = new Date();
|
|
25
19
|
let complete: number = 0;
|
|
@@ -35,7 +29,7 @@ export async function orchestrateTestProgress<Model extends ILlmSchema.Model>(
|
|
|
35
29
|
const event: AutoBeTestWriteEvent = {
|
|
36
30
|
type: "testWrite",
|
|
37
31
|
created_at: start.toISOString(),
|
|
38
|
-
filename:
|
|
32
|
+
filename: `test/features/api/${code.domain}/${scenario.functionName}.ts`,
|
|
39
33
|
content: code.content,
|
|
40
34
|
completed: ++complete,
|
|
41
35
|
total: scenarios.length,
|
|
@@ -61,20 +55,15 @@ export async function orchestrateTestProgress<Model extends ILlmSchema.Model>(
|
|
|
61
55
|
*/
|
|
62
56
|
async function process<Model extends ILlmSchema.Model>(
|
|
63
57
|
ctx: AutoBeContext<Model>,
|
|
64
|
-
scenario:
|
|
58
|
+
scenario: AutoBeTestScenario,
|
|
65
59
|
): Promise<ICreateTestCodeProps> {
|
|
66
60
|
const pointer: IPointer<ICreateTestCodeProps | null> = {
|
|
67
61
|
value: null,
|
|
68
62
|
};
|
|
69
|
-
const
|
|
63
|
+
const artifacts: IAutoBeTestScenarioArtifacts = await compileTestScenario(
|
|
64
|
+
ctx,
|
|
70
65
|
scenario,
|
|
71
|
-
ctx.state().interface!.document,
|
|
72
66
|
);
|
|
73
|
-
const files: [string, string][] = Object.entries(
|
|
74
|
-
await ctx.compiler.interface.compile(document),
|
|
75
|
-
);
|
|
76
|
-
const filter = (prefix: string) =>
|
|
77
|
-
Object.fromEntries(files.filter(([key]) => key.startsWith(prefix)));
|
|
78
67
|
|
|
79
68
|
const agentica = new MicroAgentica({
|
|
80
69
|
model: ctx.model,
|
|
@@ -82,11 +71,9 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
82
71
|
config: {
|
|
83
72
|
...(ctx.config ?? {}),
|
|
84
73
|
},
|
|
85
|
-
histories:
|
|
86
|
-
scenario
|
|
87
|
-
|
|
88
|
-
sdk: filter("src/api/functional"),
|
|
89
|
-
e2e: filter("test/features"),
|
|
74
|
+
histories: transformTestWriteHistories({
|
|
75
|
+
scenario,
|
|
76
|
+
artifacts,
|
|
90
77
|
}),
|
|
91
78
|
controllers: [
|
|
92
79
|
createApplication({
|
|
@@ -105,52 +92,6 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
105
92
|
return pointer.value;
|
|
106
93
|
}
|
|
107
94
|
|
|
108
|
-
export function filterDocument(
|
|
109
|
-
scenario: AutoBeTestScenarioEvent.IScenario,
|
|
110
|
-
document: AutoBeOpenApi.IDocument,
|
|
111
|
-
): AutoBeOpenApi.IDocument {
|
|
112
|
-
const operations: AutoBeOpenApi.IOperation[] = document.operations.filter(
|
|
113
|
-
(op) => {
|
|
114
|
-
if (
|
|
115
|
-
scenario.endpoint.method === op.method &&
|
|
116
|
-
scenario.endpoint.path === op.path
|
|
117
|
-
) {
|
|
118
|
-
return true;
|
|
119
|
-
} else if (
|
|
120
|
-
scenario.dependencies.some(
|
|
121
|
-
(dp) =>
|
|
122
|
-
dp.endpoint.method === op.method && dp.endpoint.path === op.path,
|
|
123
|
-
)
|
|
124
|
-
) {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
);
|
|
129
|
-
const components: AutoBeOpenApi.IComponents = {
|
|
130
|
-
schemas: {},
|
|
131
|
-
};
|
|
132
|
-
const visit = (typeName: string) => {
|
|
133
|
-
OpenApiTypeChecker.visit({
|
|
134
|
-
components: document.components,
|
|
135
|
-
schema: { $ref: `#/components/schemas/${typeName}` },
|
|
136
|
-
closure: (s) => {
|
|
137
|
-
if (OpenApiTypeChecker.isReference(s)) {
|
|
138
|
-
const key: string = s.$ref.split("/").pop()!;
|
|
139
|
-
components.schemas[key] = document.components.schemas[key];
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
for (const op of operations) {
|
|
145
|
-
if (op.requestBody) visit(op.requestBody.typeName);
|
|
146
|
-
if (op.responseBody) visit(op.responseBody.typeName);
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
operations,
|
|
150
|
-
components,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
95
|
function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
155
96
|
model: Model;
|
|
156
97
|
build: (next: ICreateTestCodeProps) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
-
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
2
|
import { v4 } from "uuid";
|
|
4
3
|
|
|
5
4
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
5
|
+
import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
|
|
6
6
|
|
|
7
7
|
export const transformTestCorrectHistories = (
|
|
8
|
-
|
|
8
|
+
artifacts: IAutoBeTestScenarioArtifacts,
|
|
9
9
|
): Array<
|
|
10
10
|
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
11
11
|
> => {
|
|
@@ -33,19 +33,15 @@ export const transformTestCorrectHistories = (
|
|
|
33
33
|
"- Keep all tests deterministic and reliable.",
|
|
34
34
|
"",
|
|
35
35
|
"## File References",
|
|
36
|
-
"###
|
|
37
|
-
"```
|
|
38
|
-
JSON.stringify(
|
|
36
|
+
"### API Files",
|
|
37
|
+
"```typescript",
|
|
38
|
+
JSON.stringify(artifacts.sdk),
|
|
39
|
+
"```",
|
|
40
|
+
"",
|
|
41
|
+
"### DTO Files",
|
|
42
|
+
"```typescript",
|
|
43
|
+
JSON.stringify(artifacts.dto),
|
|
39
44
|
"```",
|
|
40
|
-
// "### API Files",
|
|
41
|
-
// "```typescript",
|
|
42
|
-
// JSON.stringify(apiFiles, null, 2),
|
|
43
|
-
// "```",
|
|
44
|
-
// "",
|
|
45
|
-
// "### DTO Files",
|
|
46
|
-
// "```typescript",
|
|
47
|
-
// JSON.stringify(dtoFiles, null, 2),
|
|
48
|
-
// "```",
|
|
49
45
|
"",
|
|
50
46
|
"Now Fix the E2E test function based on the given error information.",
|
|
51
47
|
"Only output a single `async function` named `test_api_{...}`. No explanation, no commentary.",
|
package/src/orchestrate/test/{transformTestProgressHistories.ts → transformTestWriteHistories.ts}
RENAMED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
-
import {
|
|
2
|
+
import { AutoBeTestScenario } from "@autobe/interface";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
|
|
5
5
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
6
|
+
import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
scenario:
|
|
9
|
-
|
|
10
|
-
sdk: Record<string, string>;
|
|
11
|
-
e2e: Record<string, string>;
|
|
8
|
+
export const transformTestWriteHistories = (props: {
|
|
9
|
+
scenario: AutoBeTestScenario;
|
|
10
|
+
artifacts: IAutoBeTestScenarioArtifacts;
|
|
12
11
|
}): Array<
|
|
13
12
|
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
14
13
|
> => {
|
|
@@ -17,7 +16,7 @@ export const transformTestProgressHistories = (props: {
|
|
|
17
16
|
id: v4(),
|
|
18
17
|
created_at: new Date().toISOString(),
|
|
19
18
|
type: "systemMessage",
|
|
20
|
-
text: AutoBeSystemPromptConstant.
|
|
19
|
+
text: AutoBeSystemPromptConstant.TEST_WRITE,
|
|
21
20
|
},
|
|
22
21
|
{
|
|
23
22
|
id: v4(),
|
|
@@ -35,17 +34,17 @@ export const transformTestProgressHistories = (props: {
|
|
|
35
34
|
"",
|
|
36
35
|
"## DTO Definitions",
|
|
37
36
|
"```json",
|
|
38
|
-
JSON.stringify(props.dto),
|
|
37
|
+
JSON.stringify(props.artifacts.dto),
|
|
39
38
|
"```",
|
|
40
39
|
"",
|
|
41
40
|
"## API (SDK) Functions",
|
|
42
41
|
"```json",
|
|
43
|
-
JSON.stringify(props.sdk),
|
|
42
|
+
JSON.stringify(props.artifacts.sdk),
|
|
44
43
|
"```",
|
|
45
44
|
"",
|
|
46
45
|
"## E2E Mockup Functions",
|
|
47
46
|
"```json",
|
|
48
|
-
JSON.stringify(props.e2e),
|
|
47
|
+
JSON.stringify(props.artifacts.e2e),
|
|
49
48
|
"```",
|
|
50
49
|
"",
|
|
51
50
|
].join("\n"),
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AutoBeOpenApi, AutoBeTestScenarioEvent, AutoBeTestWriteEvent } from "@autobe/interface";
|
|
2
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
-
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
4
|
-
export declare function orchestrateTestProgress<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, scenarios: AutoBeTestScenarioEvent.IScenario[]): Promise<AutoBeTestWriteEvent[]>;
|
|
5
|
-
export declare function filterDocument(scenario: AutoBeTestScenarioEvent.IScenario, document: AutoBeOpenApi.IDocument): AutoBeOpenApi.IDocument;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrateTestProgress.js","sourceRoot":"","sources":["../../../src/orchestrate/test/orchestrateTestProgress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0DA8BC;AA0DD,wCA4CC;;AAvJD,yCAAoE;AAMpE,8CAI0B;AAE1B,kDAA0B;AAG1B,uEAAoE;AACpE,iEAA8D;AAC9D,qFAAkF;AAElF,SAAsB,uBAAuB,CAC3C,GAAyB,EACzB,SAA8C;;QAE9C,MAAM,KAAK,GAAS,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OAAO;QACL,UAAU;QACV,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAiC,KAG1D;IACC,IAAA,qCAAiB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE/B,MAAM,WAAW,GAA2B,UAAU,CACpD,KAAK,CAAC,KAAK,CACyB,CAAC;IACvC,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,kBAAkB;QACxB,WAAW;QACX,OAAO,EAAE;YACP,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE;gBACvB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;SACqB;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMT,CAAC;AACJ,MAAM,UAAU,GAAG;IACjB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAIJ;IACH,MAAM;IACN,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;IACb,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA8C;CACpD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
-
import { AutoBeTestScenarioEvent } from "@autobe/interface";
|
|
3
|
-
export declare const transformTestProgressHistories: (props: {
|
|
4
|
-
scenario: AutoBeTestScenarioEvent.IScenario;
|
|
5
|
-
dto: Record<string, string>;
|
|
6
|
-
sdk: Record<string, string>;
|
|
7
|
-
e2e: Record<string, string>;
|
|
8
|
-
}) => Array<IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage>;
|