@autobe/agent 0.24.2 → 0.25.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/constants/AutoBeSystemPromptConstant.d.ts +16 -16
- package/lib/context/IAutoBeApplication.d.ts +101 -6
- package/lib/context/IAutoBeApplicationProps.d.ts +6 -2
- package/lib/factory/createAgenticaHistory.js +1 -1
- package/lib/factory/createAgenticaHistory.js.map +1 -1
- package/lib/factory/createAutoBeApplication.js +80 -90
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/factory/createAutoBeContext.js +5 -5
- package/lib/factory/createAutoBeContext.js.map +1 -1
- package/lib/index.mjs +941 -1065
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +5 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +18 -3
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +5 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +19 -7
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +3 -2
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +1 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -2
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +2 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +5 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +20 -7
- package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +6 -1
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -23
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +6 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +22 -6
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +4 -1
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +26 -5
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +5 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +21 -5
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +5 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +20 -4
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js +25 -7
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +17 -8
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +18 -11
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +25 -10
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +9 -6
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +33 -17
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +36 -18
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.d.ts +4 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +19 -8
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.d.ts +6 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +20 -6
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +3 -3
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -3
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +12 -6
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
- package/lib/orchestrate/{common/histories/transformCommonCorrectDateHistories.d.ts → realize/histories/transformRealizeCorrectCastingHistories.d.ts} +1 -2
- package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +33 -0
- package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +21 -7
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +3 -9
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +12 -2
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -5
- package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
- package/lib/orchestrate/realize/utils/replaceImportStatements.js +3 -1
- package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +5 -1
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +11 -7
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +7 -1
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +39 -31
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +6 -3
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +32 -26
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +5 -1
- package/lib/orchestrate/test/histories/transformTestWriteHistories.js +111 -94
- package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js +20 -14
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +51 -35
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +14 -3
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js +19 -11
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js +9 -4
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/package.json +5 -5
- package/src/constants/AutoBeSystemPromptConstant.ts +16 -16
- package/src/context/IAutoBeApplication.ts +101 -6
- package/src/context/IAutoBeApplicationProps.ts +6 -2
- package/src/factory/createAgenticaHistory.ts +11 -5
- package/src/factory/createAutoBeContext.ts +5 -5
- package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +5 -1
- package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +16 -0
- package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +22 -7
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +3 -2
- package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
- package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +2 -1
- package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
- package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +33 -24
- package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +26 -9
- package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +27 -5
- package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
- package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
- package/src/orchestrate/interface/orchestrateInterface.ts +29 -10
- package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +25 -17
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +35 -23
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +44 -29
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +51 -32
- package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +20 -6
- package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +24 -9
- package/src/orchestrate/prisma/orchestratePrisma.ts +7 -3
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +5 -1
- package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -10
- package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +45 -0
- package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +26 -7
- package/src/orchestrate/realize/orchestrateRealize.ts +6 -17
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +18 -2
- package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +5 -0
- package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
- package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +44 -36
- package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +74 -71
- package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
- package/src/orchestrate/test/orchestrateTest.ts +19 -13
- package/src/orchestrate/test/orchestrateTestCorrect.ts +65 -46
- package/src/orchestrate/test/orchestrateTestScenario.ts +15 -11
- package/src/orchestrate/test/orchestrateTestScenarioReview.ts +29 -16
- package/src/orchestrate/test/orchestrateTestWrite.ts +13 -4
- package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +0 -48
- package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +0 -1
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +0 -35
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js +0 -3
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +0 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +0 -4
- package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +0 -540
- package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +0 -1
- package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +0 -60
- package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +0 -40
- package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +0 -372
|
@@ -19,7 +19,6 @@ import { compileRealizeFiles } from "./internal/compileRealizeFiles";
|
|
|
19
19
|
import { orchestrateRealizeCorrectCasting } from "./orchestRateRealizeCorrectCasting";
|
|
20
20
|
import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
|
|
21
21
|
import { orchestrateRealizeCorrect } from "./orchestrateRealizeCorrect";
|
|
22
|
-
import { orchestrateRealizeCorrectDate } from "./orchestrateRealizeCorrectDate";
|
|
23
22
|
import { orchestrateRealizeWrite } from "./orchestrateRealizeWrite";
|
|
24
23
|
import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
|
|
25
24
|
import { generateRealizeScenario } from "./utils/generateRealizeScenario";
|
|
@@ -52,7 +51,7 @@ export const orchestrateRealize =
|
|
|
52
51
|
type: "realizeStart",
|
|
53
52
|
id: v7(),
|
|
54
53
|
created_at: start.toISOString(),
|
|
55
|
-
reason: props.
|
|
54
|
+
reason: props.instruction,
|
|
56
55
|
step: ctx.state().test?.step ?? 0,
|
|
57
56
|
});
|
|
58
57
|
|
|
@@ -113,7 +112,6 @@ export const orchestrateRealize =
|
|
|
113
112
|
completed: writeEvents.length,
|
|
114
113
|
};
|
|
115
114
|
|
|
116
|
-
console.log("casting", reviewProgress);
|
|
117
115
|
const totalCorrected: AutoBeRealizeFunction[] =
|
|
118
116
|
await orchestrateRealizeCorrectCasting(
|
|
119
117
|
ctx,
|
|
@@ -121,23 +119,14 @@ export const orchestrateRealize =
|
|
|
121
119
|
functions,
|
|
122
120
|
reviewProgress,
|
|
123
121
|
).then(async (res) => {
|
|
124
|
-
|
|
125
|
-
return orchestrateRealizeCorrectDate(
|
|
122
|
+
return orchestrateRealizeCorrect(
|
|
126
123
|
ctx,
|
|
124
|
+
scenarios,
|
|
127
125
|
authorizations,
|
|
128
126
|
res,
|
|
127
|
+
[],
|
|
129
128
|
reviewProgress,
|
|
130
|
-
)
|
|
131
|
-
console.log("correct", reviewProgress);
|
|
132
|
-
return orchestrateRealizeCorrect(
|
|
133
|
-
ctx,
|
|
134
|
-
scenarios,
|
|
135
|
-
authorizations,
|
|
136
|
-
res,
|
|
137
|
-
[],
|
|
138
|
-
reviewProgress,
|
|
139
|
-
);
|
|
140
|
-
});
|
|
129
|
+
);
|
|
141
130
|
});
|
|
142
131
|
|
|
143
132
|
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
@@ -157,7 +146,7 @@ export const orchestrateRealize =
|
|
|
157
146
|
type: "realizeComplete",
|
|
158
147
|
id: v7(),
|
|
159
148
|
created_at: new Date().toISOString(),
|
|
160
|
-
functions,
|
|
149
|
+
functions: totalCorrected,
|
|
161
150
|
authorizations,
|
|
162
151
|
controllers,
|
|
163
152
|
compiled: result,
|
|
@@ -40,6 +40,14 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
|
|
|
40
40
|
|
|
41
41
|
// Extract and process diagnostics
|
|
42
42
|
const diagnostics = event.result.diagnostics;
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
event.result.diagnostics.every((d) => !d.file?.startsWith("src/providers"))
|
|
46
|
+
) {
|
|
47
|
+
// No diagnostics related to provider functions, stop correcting
|
|
48
|
+
return functions;
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
const locations: string[] = Array.from(
|
|
44
52
|
new Set(
|
|
45
53
|
diagnostics
|
|
@@ -115,7 +123,11 @@ async function correct<Model extends ILlmSchema.Model>(
|
|
|
115
123
|
failures: IAutoBeRealizeFunctionFailure[],
|
|
116
124
|
progress: AutoBeProgressEventBase,
|
|
117
125
|
): Promise<AutoBeRealizeFunction[]> {
|
|
118
|
-
|
|
126
|
+
if (locations.length === 0) {
|
|
127
|
+
return functions;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const corrected: AutoBeRealizeFunction[] = await executeCachedBatch(
|
|
119
131
|
locations.map((location) => async (): Promise<AutoBeRealizeFunction> => {
|
|
120
132
|
const scenario = scenarios.find((el) => el.location === location);
|
|
121
133
|
const func = functions.find((el) => el.location === location);
|
|
@@ -154,7 +166,11 @@ async function correct<Model extends ILlmSchema.Model>(
|
|
|
154
166
|
}),
|
|
155
167
|
);
|
|
156
168
|
|
|
157
|
-
|
|
169
|
+
// Create a map of corrected functions for efficient lookup
|
|
170
|
+
const correctedMap = new Map(corrected.map((f) => [f.location, f]));
|
|
171
|
+
|
|
172
|
+
// Return all functions, with corrected ones replaced
|
|
173
|
+
return functions.map((func) => correctedMap.get(func.location) || func);
|
|
158
174
|
}
|
|
159
175
|
|
|
160
176
|
async function step<Model extends ILlmSchema.Model>(
|
|
@@ -78,7 +78,7 @@ function transformFunctionName(operation: AutoBeOpenApi.IOperation): string {
|
|
|
78
78
|
const functionName = `${operation.method}${operation.path
|
|
79
79
|
.split("/")
|
|
80
80
|
.filter(Boolean)
|
|
81
|
-
.map((segment
|
|
81
|
+
.map((segment) => {
|
|
82
82
|
if (segment.startsWith("{") && segment.endsWith("}")) {
|
|
83
83
|
// {userId} → UserId
|
|
84
84
|
const paramName = segment.slice(1, -1);
|
|
@@ -91,10 +91,6 @@ function transformFunctionName(operation: AutoBeOpenApi.IOperation): string {
|
|
|
91
91
|
const words = segment.split("-");
|
|
92
92
|
return words
|
|
93
93
|
.map((word) => {
|
|
94
|
-
if (index === 0 && words.length === 1) {
|
|
95
|
-
// First segment without hyphens stays lowercase for first word
|
|
96
|
-
return word;
|
|
97
|
-
}
|
|
98
94
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
99
95
|
})
|
|
100
96
|
.join("");
|
|
@@ -54,6 +54,11 @@ function removeAllImports(
|
|
|
54
54
|
.replace(
|
|
55
55
|
/import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
|
|
56
56
|
"",
|
|
57
|
+
)
|
|
58
|
+
// NestJS HttpException
|
|
59
|
+
.replace(
|
|
60
|
+
/import\s*{\s*HttpException\s*}\s*from\s*["']@nestjs\/common["']\s*;?\s*/gm,
|
|
61
|
+
"",
|
|
57
62
|
);
|
|
58
63
|
|
|
59
64
|
// Remove API structure imports with wrong paths
|
|
@@ -13,8 +13,11 @@ export const transformTestCorrectHistories = async <
|
|
|
13
13
|
Model extends ILlmSchema.Model,
|
|
14
14
|
>(
|
|
15
15
|
ctx: AutoBeContext<Model>,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
props: {
|
|
17
|
+
instruction: string;
|
|
18
|
+
function: IAutoBeTestFunction;
|
|
19
|
+
failures: IAutoBeTestFunctionFailure[];
|
|
20
|
+
},
|
|
18
21
|
): Promise<
|
|
19
22
|
Array<
|
|
20
23
|
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
@@ -22,7 +25,11 @@ export const transformTestCorrectHistories = async <
|
|
|
22
25
|
> => {
|
|
23
26
|
const previous: Array<
|
|
24
27
|
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
25
|
-
> = await transformTestWriteHistories(ctx,
|
|
28
|
+
> = await transformTestWriteHistories(ctx, {
|
|
29
|
+
instruction: props.instruction,
|
|
30
|
+
scenario: props.function.scenario,
|
|
31
|
+
artifacts: props.function.artifacts,
|
|
32
|
+
});
|
|
26
33
|
return [
|
|
27
34
|
...previous.slice(0, -1),
|
|
28
35
|
{
|
|
@@ -32,21 +39,21 @@ export const transformTestCorrectHistories = async <
|
|
|
32
39
|
text: AutoBeSystemPromptConstant.TEST_CORRECT,
|
|
33
40
|
},
|
|
34
41
|
previous.at(-1)!,
|
|
35
|
-
...failures.map(
|
|
42
|
+
...props.failures.map(
|
|
36
43
|
(f, i, array) =>
|
|
37
44
|
({
|
|
38
45
|
id: v7(),
|
|
39
46
|
created_at: new Date().toISOString(),
|
|
40
47
|
type: "assistantMessage",
|
|
41
48
|
text: StringUtil.trim`
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
## ${i === array.length - 1 ? "Latest Failure" : "Previous Failure"}
|
|
50
|
+
### Generated TypeScript Code
|
|
44
51
|
|
|
45
52
|
\`\`\`typescript
|
|
46
53
|
${f.function.script}
|
|
47
54
|
\`\`\`
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
### Compile Errors
|
|
50
57
|
|
|
51
58
|
Fix the compilation error in the provided code.
|
|
52
59
|
|
|
@@ -8,12 +8,13 @@ import { AutoBeState } from "../../../context/AutoBeState";
|
|
|
8
8
|
import { IAutoBeTestScenarioAuthorizationRole } from "../structures/IAutoBeTestScenarioAuthorizationRole";
|
|
9
9
|
import { getReferenceIds } from "../utils/getReferenceIds";
|
|
10
10
|
|
|
11
|
-
export const transformTestScenarioHistories = (
|
|
12
|
-
state: AutoBeState
|
|
13
|
-
document: AutoBeOpenApi.IDocument
|
|
14
|
-
include: AutoBeOpenApi.IOperation[]
|
|
15
|
-
exclude: Pick<AutoBeOpenApi.IOperation, "method" | "path">[]
|
|
16
|
-
|
|
11
|
+
export const transformTestScenarioHistories = (props: {
|
|
12
|
+
state: AutoBeState;
|
|
13
|
+
document: AutoBeOpenApi.IDocument;
|
|
14
|
+
include: AutoBeOpenApi.IOperation[];
|
|
15
|
+
exclude: Pick<AutoBeOpenApi.IOperation, "method" | "path">[];
|
|
16
|
+
instruction: string;
|
|
17
|
+
}): Array<
|
|
17
18
|
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
18
19
|
> => {
|
|
19
20
|
interface IRelationship {
|
|
@@ -21,18 +22,18 @@ export const transformTestScenarioHistories = (
|
|
|
21
22
|
ids: string[];
|
|
22
23
|
}
|
|
23
24
|
const authorizations: AutoBeInterfaceAuthorization[] =
|
|
24
|
-
state.interface?.authorizations ?? [];
|
|
25
|
+
props.state.interface?.authorizations ?? [];
|
|
25
26
|
const authorizationRoles: Map<string, IAutoBeTestScenarioAuthorizationRole> =
|
|
26
27
|
new Map();
|
|
27
|
-
const relationships: IRelationship[] = document.operations
|
|
28
|
-
.map((
|
|
28
|
+
const relationships: IRelationship[] = props.document.operations
|
|
29
|
+
.map((operation) => ({
|
|
29
30
|
endpoint: {
|
|
30
|
-
method:
|
|
31
|
-
path:
|
|
31
|
+
method: operation.method,
|
|
32
|
+
path: operation.path,
|
|
32
33
|
},
|
|
33
34
|
ids: getReferenceIds({
|
|
34
|
-
document,
|
|
35
|
-
operation
|
|
35
|
+
document: props.document,
|
|
36
|
+
operation,
|
|
36
37
|
}),
|
|
37
38
|
}))
|
|
38
39
|
.filter((v) => v.ids.length !== 0);
|
|
@@ -66,7 +67,22 @@ export const transformTestScenarioHistories = (
|
|
|
66
67
|
created_at: new Date().toISOString(),
|
|
67
68
|
type: "assistantMessage",
|
|
68
69
|
text: StringUtil.trim`
|
|
69
|
-
|
|
70
|
+
## Instructions
|
|
71
|
+
|
|
72
|
+
The following e2e-test-specific instructions were extracted by AI from
|
|
73
|
+
the user's requirements and conversations. These instructions focus
|
|
74
|
+
exclusively on test-related aspects such as test coverage priorities,
|
|
75
|
+
specific edge cases to validate, business logic verification strategies,
|
|
76
|
+
and critical user workflows that must be tested.
|
|
77
|
+
|
|
78
|
+
Apply these instructions when generating test scenarios to ensure the
|
|
79
|
+
tests align with the user's testing requirements and expectations.
|
|
80
|
+
If any instructions are not relevant to the target API operations,
|
|
81
|
+
you may ignore them.
|
|
82
|
+
|
|
83
|
+
${props.instruction}
|
|
84
|
+
|
|
85
|
+
## API Operations
|
|
70
86
|
|
|
71
87
|
Below are the complete API operations.
|
|
72
88
|
Use this information to understand capabilities and dependency relationships.
|
|
@@ -81,16 +97,12 @@ export const transformTestScenarioHistories = (
|
|
|
81
97
|
and ensure you identify all dependencies between endpoints.
|
|
82
98
|
|
|
83
99
|
\`\`\`json
|
|
84
|
-
${JSON.stringify({
|
|
100
|
+
${JSON.stringify({
|
|
101
|
+
operations: props.document.operations,
|
|
102
|
+
})}
|
|
85
103
|
\`\`\`
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
id: v7(),
|
|
90
|
-
created_at: new Date().toISOString(),
|
|
91
|
-
type: "assistantMessage",
|
|
92
|
-
text: StringUtil.trim`
|
|
93
|
-
# Included in Test Plan
|
|
104
|
+
|
|
105
|
+
## Included in Test Plan
|
|
94
106
|
|
|
95
107
|
Below are the endpoints that have been included in the test plan.
|
|
96
108
|
Each endpoint shows its authentication requirements and related authentication APIs.
|
|
@@ -99,14 +111,16 @@ export const transformTestScenarioHistories = (
|
|
|
99
111
|
|
|
100
112
|
Generate test scenarios only for these included endpoints. Do not create scenarios for excluded endpoints. Operations not listed here may be used only as dependencies.
|
|
101
113
|
|
|
102
|
-
${include
|
|
114
|
+
${props.include
|
|
103
115
|
.map((el, i) => {
|
|
104
116
|
const roles = Array.from(authorizationRoles.values()).filter(
|
|
105
117
|
(role) => role.name === el.authorizationRole,
|
|
106
118
|
);
|
|
107
119
|
|
|
108
|
-
const requiredIds = getReferenceIds({
|
|
109
|
-
|
|
120
|
+
const requiredIds = getReferenceIds({
|
|
121
|
+
document: props.document,
|
|
122
|
+
operation: el,
|
|
123
|
+
});
|
|
110
124
|
return StringUtil.trim`
|
|
111
125
|
## ${i + 1}. ${el.method.toUpperCase()} ${el.path}
|
|
112
126
|
|
|
@@ -136,23 +150,17 @@ export const transformTestScenarioHistories = (
|
|
|
136
150
|
})
|
|
137
151
|
.join("\n")}
|
|
138
152
|
|
|
139
|
-
|
|
153
|
+
## Excluded from Test Plan
|
|
140
154
|
|
|
141
155
|
These are the endpoints that have already been used in test codes generated as part of a plan group.
|
|
142
156
|
These endpoints do not need to be tested again.
|
|
143
157
|
However, it is allowed to reference or depend on these endpoints when writing test codes for other purposes.
|
|
144
158
|
|
|
145
|
-
${exclude
|
|
159
|
+
${props.exclude
|
|
146
160
|
.map((el) => `- ${el.method.toUpperCase()}: ${el.path}`)
|
|
147
161
|
.join("\n")}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
id: v7(),
|
|
152
|
-
created_at: new Date().toISOString(),
|
|
153
|
-
type: "assistantMessage",
|
|
154
|
-
text: StringUtil.trim`
|
|
155
|
-
# Candidate Dependencies
|
|
162
|
+
|
|
163
|
+
## Candidate Dependencies
|
|
156
164
|
|
|
157
165
|
List of candidate dependencies extracted from path parameters and request bodies.
|
|
158
166
|
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
2
|
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
3
|
import { StringUtil } from "@autobe/utils";
|
|
4
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
5
4
|
import { v7 } from "uuid";
|
|
6
5
|
|
|
7
6
|
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
8
|
-
import {
|
|
7
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
9
8
|
import { IAutoBeTestScenarioApplication } from "../structures/IAutoBeTestScenarioApplication";
|
|
10
9
|
import { getReferenceIds } from "../utils/getReferenceIds";
|
|
11
10
|
|
|
12
|
-
export function transformTestScenarioReviewHistories
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
): Array<
|
|
11
|
+
export function transformTestScenarioReviewHistories(props: {
|
|
12
|
+
state: AutoBeState;
|
|
13
|
+
instruction: string;
|
|
14
|
+
groups: IAutoBeTestScenarioApplication.IScenarioGroup[];
|
|
15
|
+
}): Array<
|
|
18
16
|
IAgenticaHistoryJson.ISystemMessage | IAgenticaHistoryJson.IAssistantMessage
|
|
19
17
|
> {
|
|
20
18
|
interface IRelationship {
|
|
@@ -23,8 +21,7 @@ export function transformTestScenarioReviewHistories<
|
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
const document: AutoBeOpenApi.IDocument | undefined =
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
props.state.interface?.document;
|
|
28
25
|
if (document === undefined) {
|
|
29
26
|
throw new Error(
|
|
30
27
|
"Cannot review test scenarios because there are no operations.",
|
|
@@ -56,74 +53,80 @@ export function transformTestScenarioReviewHistories<
|
|
|
56
53
|
created_at: new Date().toISOString(),
|
|
57
54
|
type: "assistantMessage",
|
|
58
55
|
text: StringUtil.trim`
|
|
59
|
-
|
|
56
|
+
## Instructions
|
|
57
|
+
|
|
58
|
+
The following e2e-test-specific instructions were extracted by AI from
|
|
59
|
+
the user's requirements and conversations. These instructions focus
|
|
60
|
+
exclusively on test-related aspects such as test coverage priorities,
|
|
61
|
+
specific edge cases to validate, business logic verification strategies,
|
|
62
|
+
and critical user workflows that must be tested.
|
|
63
|
+
|
|
64
|
+
Apply these instructions when reviewing test scenarios to ensure the
|
|
65
|
+
tests align with the user's testing requirements and expectations.
|
|
66
|
+
If any instructions are not relevant to the target API operations,
|
|
67
|
+
you may ignore them.
|
|
68
|
+
|
|
69
|
+
${props.instruction}
|
|
70
|
+
|
|
71
|
+
## Available API Operations for Reference
|
|
60
72
|
|
|
61
73
|
Below are all available API operations and interface schemas for validation purposes.
|
|
62
74
|
Match each operation with its corresponding schema.
|
|
63
75
|
|
|
64
76
|
\`\`\`json
|
|
65
|
-
${JSON.stringify({
|
|
77
|
+
${JSON.stringify({
|
|
78
|
+
operations: document.operations,
|
|
79
|
+
})}
|
|
66
80
|
\`\`\`
|
|
67
|
-
`,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: v7(),
|
|
71
|
-
created_at: new Date().toISOString(),
|
|
72
|
-
type: "assistantMessage",
|
|
73
|
-
text: StringUtil.trim`
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
## Test Scenario Groups
|
|
83
|
+
|
|
84
|
+
Please review the following test scenario groups:
|
|
85
|
+
|
|
86
|
+
\`\`\`json
|
|
87
|
+
${JSON.stringify(
|
|
88
|
+
props.groups.map((g) => {
|
|
89
|
+
return {
|
|
90
|
+
...g,
|
|
91
|
+
scenarios: g.scenarios.map((s) => {
|
|
92
|
+
const requiredId: string[] = [];
|
|
93
|
+
|
|
94
|
+
s.dependencies.forEach((dep) => {
|
|
95
|
+
document.operations.forEach((op) => {
|
|
96
|
+
if (
|
|
97
|
+
g.endpoint.method === op.method &&
|
|
98
|
+
g.endpoint.path === op.path
|
|
99
|
+
) {
|
|
100
|
+
requiredId.push(
|
|
101
|
+
...getReferenceIds({ document, operation: op }),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
op.method === dep.endpoint.method &&
|
|
107
|
+
op.path === dep.endpoint.path
|
|
108
|
+
) {
|
|
109
|
+
requiredId.push(
|
|
110
|
+
...getReferenceIds({ document, operation: op }),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
106
114
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
id: v7(),
|
|
123
|
-
created_at: new Date().toISOString(),
|
|
124
|
-
type: "assistantMessage",
|
|
125
|
-
text: StringUtil.trim`
|
|
126
|
-
# Candidate Dependencies
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
...s,
|
|
118
|
+
requiredIds:
|
|
119
|
+
requiredId.length > 0
|
|
120
|
+
? Array.from(new Set(requiredId))
|
|
121
|
+
: [],
|
|
122
|
+
};
|
|
123
|
+
}),
|
|
124
|
+
};
|
|
125
|
+
}),
|
|
126
|
+
)}
|
|
127
|
+
\`\`\`
|
|
128
|
+
|
|
129
|
+
## Candidate Dependencies
|
|
127
130
|
|
|
128
131
|
List of candidate dependencies extracted from path parameters and request bodies.
|
|
129
132
|
|
|
@@ -151,6 +154,6 @@ export function transformTestScenarioReviewHistories<
|
|
|
151
154
|
|
|
152
155
|
Example: If an endpoint requires \`articleId\` and \`POST /articles\` exists, include it in dependencies
|
|
153
156
|
`,
|
|
154
|
-
}
|
|
157
|
+
},
|
|
155
158
|
];
|
|
156
159
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ILlmSchema,
|
|
8
8
|
OpenApi,
|
|
9
9
|
} from "@samchon/openapi";
|
|
10
|
+
import { Singleton } from "tstl";
|
|
10
11
|
import typia from "typia";
|
|
11
12
|
import { v7 } from "uuid";
|
|
12
13
|
|
|
@@ -19,8 +20,11 @@ export async function transformTestWriteHistories<
|
|
|
19
20
|
Model extends ILlmSchema.Model,
|
|
20
21
|
>(
|
|
21
22
|
ctx: AutoBeContext<Model>,
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
props: {
|
|
24
|
+
instruction: string;
|
|
25
|
+
scenario: AutoBeTestScenario;
|
|
26
|
+
artifacts: IAutoBeTestScenarioArtifacts;
|
|
27
|
+
},
|
|
24
28
|
): Promise<
|
|
25
29
|
Array<
|
|
26
30
|
IAgenticaHistoryJson.ISystemMessage | IAgenticaHistoryJson.IAssistantMessage
|
|
@@ -31,10 +35,7 @@ export async function transformTestWriteHistories<
|
|
|
31
35
|
id: v7(),
|
|
32
36
|
created_at: new Date().toISOString(),
|
|
33
37
|
type: "systemMessage",
|
|
34
|
-
text:
|
|
35
|
-
"{{AutoBeTestScenario}}",
|
|
36
|
-
JSON.stringify(typia.llm.parameters<AutoBeTestScenario, "llama">()),
|
|
37
|
-
),
|
|
38
|
+
text: systemPrompt.get(),
|
|
38
39
|
},
|
|
39
40
|
{
|
|
40
41
|
id: v7(),
|
|
@@ -45,16 +46,31 @@ export async function transformTestWriteHistories<
|
|
|
45
46
|
|
|
46
47
|
Make e2e test functions based on the following information.
|
|
47
48
|
|
|
49
|
+
## Instructions
|
|
50
|
+
|
|
51
|
+
The following e2e-test-specific instructions were extracted by AI from
|
|
52
|
+
the user's requirements and conversations. These instructions focus
|
|
53
|
+
exclusively on test-related aspects such as test data generation strategies,
|
|
54
|
+
assertion patterns, error handling approaches, and specific validation logic
|
|
55
|
+
that should be implemented in the test code.
|
|
56
|
+
|
|
57
|
+
Apply these instructions when implementing the e2e test function to ensure
|
|
58
|
+
the test code aligns with the user's testing requirements and expectations.
|
|
59
|
+
If any instructions are not relevant to the target test scenario,
|
|
60
|
+
you may ignore them.
|
|
61
|
+
|
|
62
|
+
${props.instruction}
|
|
63
|
+
|
|
48
64
|
## Function Name
|
|
49
65
|
|
|
50
|
-
The e2e test function name must be ${JSON.stringify(scenario.functionName)}.
|
|
66
|
+
The e2e test function name must be ${JSON.stringify(props.scenario.functionName)}.
|
|
51
67
|
|
|
52
68
|
## Scenario Plan
|
|
53
69
|
|
|
54
70
|
Here is the scenario plan what you have to implement.
|
|
55
71
|
|
|
56
72
|
\`\`\`json
|
|
57
|
-
${JSON.stringify(scenario)}
|
|
73
|
+
${JSON.stringify(props.scenario)}
|
|
58
74
|
\`\`\`
|
|
59
75
|
|
|
60
76
|
## DTO Definitions
|
|
@@ -63,7 +79,7 @@ export async function transformTestWriteHistories<
|
|
|
63
79
|
|
|
64
80
|
Never use the DTO definitions that are not listed here.
|
|
65
81
|
|
|
66
|
-
${transformTestWriteHistories.structures(artifacts)}
|
|
82
|
+
${transformTestWriteHistories.structures(props.artifacts)}
|
|
67
83
|
|
|
68
84
|
## API (SDK) Functions
|
|
69
85
|
|
|
@@ -71,14 +87,14 @@ export async function transformTestWriteHistories<
|
|
|
71
87
|
|
|
72
88
|
Never use the functions that are not listed here.
|
|
73
89
|
|
|
74
|
-
${transformTestWriteHistories.functional(artifacts)}
|
|
90
|
+
${transformTestWriteHistories.functional(props.artifacts)}
|
|
75
91
|
|
|
76
92
|
## E2E Mockup Functions
|
|
77
93
|
|
|
78
94
|
Just reference, and never follow this code as it is.
|
|
79
95
|
|
|
80
96
|
\`\`\`json
|
|
81
|
-
${JSON.stringify(artifacts.e2e)}
|
|
97
|
+
${JSON.stringify(props.artifacts.e2e)}
|
|
82
98
|
\`\`\`
|
|
83
99
|
|
|
84
100
|
## External Definitions
|
|
@@ -103,7 +119,7 @@ export async function transformTestWriteHistories<
|
|
|
103
119
|
make your implementation code in the import scope.
|
|
104
120
|
|
|
105
121
|
\`\`\`typescript
|
|
106
|
-
${artifacts.template}
|
|
122
|
+
${props.artifacts.template}
|
|
107
123
|
\`\`\`
|
|
108
124
|
`,
|
|
109
125
|
},
|
|
@@ -144,3 +160,10 @@ export namespace transformTestWriteHistories {
|
|
|
144
160
|
`;
|
|
145
161
|
}
|
|
146
162
|
}
|
|
163
|
+
|
|
164
|
+
const systemPrompt = new Singleton(() =>
|
|
165
|
+
AutoBeSystemPromptConstant.TEST_WRITE.replace(
|
|
166
|
+
"{{AutoBeTestScenario}}",
|
|
167
|
+
JSON.stringify(typia.llm.parameters<AutoBeTestScenario, "llama">()),
|
|
168
|
+
),
|
|
169
|
+
);
|