@autobe/agent 0.24.1 → 0.24.2
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/AutoBeMockAgent.js +1 -0
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +4 -3
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/factory/createAutoBeContext.js +3 -3
- package/lib/factory/getAutoBeGenerated.js +4 -1
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/factory/getAutoBeRealizeGenerated.d.ts +2 -1
- package/lib/factory/getAutoBeRealizeGenerated.js +1 -1
- package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -1
- package/lib/factory/getCriticalCompiler.js +1 -1
- package/lib/factory/getCriticalCompiler.js.map +1 -1
- package/lib/index.mjs +1092 -139
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +67 -8
- package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
- package/lib/orchestrate/interface/utils/OperationValidator.js +2 -1
- package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js +3 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +4 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +15 -5
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +3 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +4 -3
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +1 -0
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +5 -0
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +113 -0
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTestScenario.js +8 -2
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -0
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js +847 -0
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.d.ts +47 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js.map +1 -0
- package/package.json +6 -6
- package/src/AutoBeMockAgent.ts +1 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +4 -3
- package/src/factory/getAutoBeGenerated.ts +3 -0
- package/src/factory/getAutoBeRealizeGenerated.ts +3 -1
- package/src/factory/getCriticalCompiler.ts +2 -1
- package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +68 -8
- package/src/orchestrate/interface/utils/OperationValidator.ts +2 -1
- package/src/orchestrate/realize/internal/compileRealizeFiles.ts +3 -1
- package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +4 -1
- package/src/orchestrate/realize/orchestrateRealize.ts +44 -37
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +5 -1
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +20 -14
- package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +1 -0
- package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +156 -0
- package/src/orchestrate/test/orchestrateTestScenario.ts +13 -3
- package/src/orchestrate/test/orchestrateTestScenarioReview.ts +185 -0
- package/src/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.ts +52 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { IAgenticaController } from "@agentica/core";
|
|
2
|
+
import { AutoBeProgressEventBase, AutoBeTestScenario } from "@autobe/interface";
|
|
3
|
+
import { AutoBeEndpointComparator } from "@autobe/utils";
|
|
4
|
+
import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
|
|
5
|
+
import { HashMap, IPointer, Pair } from "tstl";
|
|
6
|
+
import typia from "typia";
|
|
7
|
+
import { v7 } from "uuid";
|
|
8
|
+
|
|
9
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
10
|
+
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
11
|
+
import { transformTestScenarioReviewHistories } from "./histories/transformTestScenarioReviewHistories";
|
|
12
|
+
import { IAutoBeTestScenarioApplication } from "./structures/IAutoBeTestScenarioApplication";
|
|
13
|
+
import { IAutoBeTestScenarioReviewApplication } from "./structures/IAutoBeTestScenarioReviewApplication";
|
|
14
|
+
|
|
15
|
+
export async function orchestrateTestScenarioReview<
|
|
16
|
+
Model extends ILlmSchema.Model,
|
|
17
|
+
>(
|
|
18
|
+
ctx: AutoBeContext<Model>,
|
|
19
|
+
groups: IAutoBeTestScenarioApplication.IScenarioGroup[],
|
|
20
|
+
progress: AutoBeProgressEventBase,
|
|
21
|
+
): Promise<IAutoBeTestScenarioApplication.IScenarioGroup[]> {
|
|
22
|
+
const res: IAutoBeTestScenarioApplication.IScenarioGroup[] = await review(
|
|
23
|
+
ctx,
|
|
24
|
+
groups,
|
|
25
|
+
progress,
|
|
26
|
+
);
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function review<Model extends ILlmSchema.Model>(
|
|
31
|
+
ctx: AutoBeContext<Model>,
|
|
32
|
+
groups: IAutoBeTestScenarioApplication.IScenarioGroup[],
|
|
33
|
+
progress: AutoBeProgressEventBase,
|
|
34
|
+
): Promise<IAutoBeTestScenarioApplication.IScenarioGroup[]> {
|
|
35
|
+
try {
|
|
36
|
+
const pointer: IPointer<IAutoBeTestScenarioReviewApplication.IProps | null> =
|
|
37
|
+
{
|
|
38
|
+
value: null,
|
|
39
|
+
};
|
|
40
|
+
const { tokenUsage } = await ctx.conversate({
|
|
41
|
+
source: "testScenariosReview",
|
|
42
|
+
controller: createController({
|
|
43
|
+
model: ctx.model,
|
|
44
|
+
pointer,
|
|
45
|
+
originalGroups: groups,
|
|
46
|
+
}),
|
|
47
|
+
histories: transformTestScenarioReviewHistories(ctx, groups),
|
|
48
|
+
enforceFunctionCall: true,
|
|
49
|
+
message: "Review the Test Scenario.",
|
|
50
|
+
});
|
|
51
|
+
if (pointer.value === null) {
|
|
52
|
+
// unreachable
|
|
53
|
+
throw new Error("Failed to get review result.");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
progress.total = Math.max(
|
|
57
|
+
progress.total,
|
|
58
|
+
(progress.completed += pointer.value.scenarioGroups.length),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
ctx.dispatch({
|
|
62
|
+
type: "testScenariosReview",
|
|
63
|
+
id: v7(),
|
|
64
|
+
tokenUsage,
|
|
65
|
+
total: progress.total,
|
|
66
|
+
completed: progress.completed,
|
|
67
|
+
scenarios: pointer.value.scenarioGroups
|
|
68
|
+
.map((group) => {
|
|
69
|
+
return group.scenarios.map((s) => {
|
|
70
|
+
return {
|
|
71
|
+
...s,
|
|
72
|
+
endpoint: group.endpoint,
|
|
73
|
+
} satisfies AutoBeTestScenario;
|
|
74
|
+
});
|
|
75
|
+
})
|
|
76
|
+
.flat(),
|
|
77
|
+
step: ctx.state().interface?.step ?? 0,
|
|
78
|
+
created_at: new Date().toISOString(),
|
|
79
|
+
});
|
|
80
|
+
return pointer.value.scenarioGroups;
|
|
81
|
+
} catch {
|
|
82
|
+
progress.completed += groups.length;
|
|
83
|
+
return groups;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function createController<Model extends ILlmSchema.Model>(props: {
|
|
88
|
+
model: Model;
|
|
89
|
+
pointer: IPointer<IAutoBeTestScenarioReviewApplication.IProps | null>;
|
|
90
|
+
originalGroups: IAutoBeTestScenarioApplication.IScenarioGroup[];
|
|
91
|
+
}): IAgenticaController.IClass<Model> {
|
|
92
|
+
assertSchemaModel(props.model);
|
|
93
|
+
|
|
94
|
+
const validate: Validator = (
|
|
95
|
+
next: unknown,
|
|
96
|
+
): IValidation<IAutoBeTestScenarioReviewApplication.IProps> => {
|
|
97
|
+
const result: IValidation<IAutoBeTestScenarioReviewApplication.IProps> =
|
|
98
|
+
typia.validate<IAutoBeTestScenarioReviewApplication.IProps>(next);
|
|
99
|
+
if (result.success === false) return result;
|
|
100
|
+
|
|
101
|
+
// merge to unique scenario groups
|
|
102
|
+
const scenarioGroups: IAutoBeTestScenarioApplication.IScenarioGroup[] =
|
|
103
|
+
uniqueScenarioGroups(result.data.scenarioGroups);
|
|
104
|
+
|
|
105
|
+
const errors: IValidation.IError[] = [];
|
|
106
|
+
|
|
107
|
+
// validate endpoints between scenarioGroups and originalGroups
|
|
108
|
+
const filteredScenarioGroups: IAutoBeTestScenarioApplication.IScenarioGroup[] =
|
|
109
|
+
props.originalGroups.reduce<
|
|
110
|
+
IAutoBeTestScenarioApplication.IScenarioGroup[]
|
|
111
|
+
>((acc, originalGroup) => {
|
|
112
|
+
// Keep only groups whose endpoint matches with one in props.originalGroups
|
|
113
|
+
const matchingGroup = scenarioGroups.find(
|
|
114
|
+
(g) =>
|
|
115
|
+
g.endpoint.method === originalGroup.endpoint.method &&
|
|
116
|
+
g.endpoint.path === originalGroup.endpoint.path,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (!matchingGroup) {
|
|
120
|
+
return [...acc, originalGroup];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return [...acc, matchingGroup];
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
result.data.scenarioGroups = filteredScenarioGroups;
|
|
127
|
+
|
|
128
|
+
if (errors.length > 0) {
|
|
129
|
+
return {
|
|
130
|
+
success: false,
|
|
131
|
+
errors,
|
|
132
|
+
data: result.data,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const application: ILlmApplication<Model> = collection[
|
|
140
|
+
props.model === "chatgpt" ? "chatgpt" : "claude"
|
|
141
|
+
](
|
|
142
|
+
validate,
|
|
143
|
+
) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
protocol: "class",
|
|
147
|
+
name: "Test Scenario Reviewer",
|
|
148
|
+
application,
|
|
149
|
+
execute: {
|
|
150
|
+
review: (input) => {
|
|
151
|
+
props.pointer.value = input;
|
|
152
|
+
},
|
|
153
|
+
} satisfies IAutoBeTestScenarioReviewApplication,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const uniqueScenarioGroups = (
|
|
158
|
+
groups: IAutoBeTestScenarioApplication.IScenarioGroup[],
|
|
159
|
+
): IAutoBeTestScenarioApplication.IScenarioGroup[] =>
|
|
160
|
+
new HashMap(
|
|
161
|
+
groups.map((g) => new Pair(g.endpoint, g)),
|
|
162
|
+
AutoBeEndpointComparator.hashCode,
|
|
163
|
+
AutoBeEndpointComparator.equals,
|
|
164
|
+
)
|
|
165
|
+
.toJSON()
|
|
166
|
+
.map((it) => it.second);
|
|
167
|
+
|
|
168
|
+
const collection = {
|
|
169
|
+
chatgpt: (validate: Validator) =>
|
|
170
|
+
typia.llm.application<IAutoBeTestScenarioReviewApplication, "chatgpt">({
|
|
171
|
+
validate: {
|
|
172
|
+
review: validate,
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
claude: (validate: Validator) =>
|
|
176
|
+
typia.llm.application<IAutoBeTestScenarioReviewApplication, "claude">({
|
|
177
|
+
validate: {
|
|
178
|
+
review: validate,
|
|
179
|
+
},
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
type Validator = (
|
|
184
|
+
input: unknown,
|
|
185
|
+
) => IValidation<IAutoBeTestScenarioReviewApplication.IProps>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IAutoBeTestScenarioApplication } from "./IAutoBeTestScenarioApplication";
|
|
2
|
+
|
|
3
|
+
export interface IAutoBeTestScenarioReviewApplication {
|
|
4
|
+
review: (props: IAutoBeTestScenarioReviewApplication.IProps) => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export namespace IAutoBeTestScenarioReviewApplication {
|
|
8
|
+
export interface IProps {
|
|
9
|
+
/**
|
|
10
|
+
* Concise review summary focusing on critical findings and key
|
|
11
|
+
* improvements.
|
|
12
|
+
*
|
|
13
|
+
* Should include:
|
|
14
|
+
*
|
|
15
|
+
* - Executive summary of overall quality
|
|
16
|
+
* - Critical issues requiring immediate fixes
|
|
17
|
+
* - Key improvement recommendations
|
|
18
|
+
* - Database schema compliance status
|
|
19
|
+
* - Modified scenarios identification by functionName
|
|
20
|
+
*/
|
|
21
|
+
review: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Structured action plan with priority-based improvements.
|
|
25
|
+
*
|
|
26
|
+
* Should contain:
|
|
27
|
+
*
|
|
28
|
+
* - Critical fixes required immediately
|
|
29
|
+
* - High priority enhancements
|
|
30
|
+
* - Implementation guidance
|
|
31
|
+
* - Success criteria
|
|
32
|
+
* - Specific scenario action items by functionName
|
|
33
|
+
*/
|
|
34
|
+
plan: string;
|
|
35
|
+
|
|
36
|
+
/** If the scenario groups pass the review, Set to true. */
|
|
37
|
+
pass: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The reviewed and improved scenario groups with all quality fixes applied.
|
|
41
|
+
*
|
|
42
|
+
* This is the primary output containing:
|
|
43
|
+
*
|
|
44
|
+
* - All critical issues resolved
|
|
45
|
+
* - Authentication flows corrected
|
|
46
|
+
* - Database dependencies validated
|
|
47
|
+
* - Quality enhancements implemented
|
|
48
|
+
* - Only implementable scenarios retained
|
|
49
|
+
*/
|
|
50
|
+
scenarioGroups: IAutoBeTestScenarioApplication.IScenarioGroup[];
|
|
51
|
+
}
|
|
52
|
+
}
|