@autobe/agent 0.15.1 → 0.16.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 +2 -2
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/AutoBeMockAgent.d.ts +1 -0
- package/lib/AutoBeMockAgent.js +18 -4
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +3 -3
- package/lib/factory/getAutoBeGenerated.js +2 -1
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/index.mjs +739 -577
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.d.ts +0 -15
- package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.js +0 -3
- package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +19 -12
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeComposer.d.ts +1 -2
- package/lib/orchestrate/analyze/orchestrateAnalyzeComposer.js +3 -5
- package/lib/orchestrate/analyze/orchestrateAnalyzeComposer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.d.ts +7 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +363 -4
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +3 -3
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +3 -118
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js.map +1 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.d.ts +11 -4
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js +61 -45
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +17 -10
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/realize/ProviderCodeComparator.d.ts +5 -0
- package/lib/orchestrate/realize/ProviderCodeComparator.js +16 -0
- package/lib/orchestrate/realize/ProviderCodeComparator.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +41 -53
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +13 -87
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +32 -43
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +3 -2
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +25 -39
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +15 -15
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +11 -17
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +4 -2
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +21 -17
- package/lib/orchestrate/realize/transformRealizeAuthorization.js +5 -9
- package/lib/orchestrate/realize/transformRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js +9 -0
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +3 -2
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +58 -27
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
- package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationFileSystem.d.ts +5 -0
- package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationFileSystem.js +10 -0
- package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationFileSystem.js.map +1 -0
- package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.d.ts +4 -0
- package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.js +38 -0
- package/lib/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.js.map +1 -0
- package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +2 -1
- package/lib/orchestrate/realize/utils/replaceImportStatements.js +15 -2
- package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.d.ts +9 -2
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +158 -100
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js +1 -1
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/package.json +6 -6
- package/src/AutoBeAgent.ts +1 -1
- package/src/AutoBeMockAgent.ts +20 -6
- package/src/constants/AutoBeSystemPromptConstant.ts +3 -3
- package/src/factory/getAutoBeGenerated.ts +2 -1
- package/src/orchestrate/analyze/AutoBeAnalyzeFileSystem.ts +0 -15
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +17 -17
- package/src/orchestrate/analyze/orchestrateAnalyzeComposer.ts +4 -7
- package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +100 -6
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +5 -21
- package/src/orchestrate/analyze/writeDocumentUntilReviewPassed.ts +76 -59
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +17 -10
- package/src/orchestrate/realize/ProviderCodeComparator.ts +15 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +54 -59
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +12 -120
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +21 -5
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +10 -9
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +15 -15
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +11 -18
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +4 -2
- package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +24 -17
- package/src/orchestrate/realize/transformRealizeAuthorization.ts +5 -9
- package/src/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.ts +9 -0
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +73 -25
- package/src/orchestrate/realize/utils/AutoBeRealizeAuthorizationFileSystem.ts +9 -0
- package/src/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.ts +64 -0
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +41 -2
- package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +219 -145
- package/src/orchestrate/test/orchestrateTest.ts +1 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AutoBeAssistantMessageHistory,
|
|
3
|
+
AutoBeOpenApi,
|
|
3
4
|
AutoBeRealizeAuthorization,
|
|
5
|
+
AutoBeRealizeFunction,
|
|
4
6
|
AutoBeRealizeHistory,
|
|
7
|
+
IAutoBeCompiler,
|
|
5
8
|
} from "@autobe/interface";
|
|
6
9
|
import { ILlmSchema } from "@samchon/openapi";
|
|
7
10
|
import { v4 } from "uuid";
|
|
8
11
|
|
|
9
12
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
10
13
|
import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
|
|
14
|
+
import { getAutoBeGenerated } from "../../factory/getAutoBeGenerated";
|
|
11
15
|
import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
|
|
12
16
|
import { writeCodeUntilCompilePassed } from "./writeCodeUntilCompilePassed";
|
|
13
17
|
|
|
@@ -16,12 +20,13 @@ export const orchestrateRealize =
|
|
|
16
20
|
async (
|
|
17
21
|
props: IAutoBeApplicationProps,
|
|
18
22
|
): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!
|
|
23
|
+
const operations: AutoBeOpenApi.IOperation[] | undefined =
|
|
24
|
+
ctx.state().interface?.document.operations;
|
|
25
|
+
if (!operations) {
|
|
22
26
|
throw new Error("Can't do realize agent because operations are nothing.");
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
const start: Date = new Date();
|
|
25
30
|
ctx.dispatch({
|
|
26
31
|
type: "realizeStart",
|
|
27
32
|
created_at: new Date().toISOString(),
|
|
@@ -29,71 +34,61 @@ export const orchestrateRealize =
|
|
|
29
34
|
step: ctx.state().test?.step ?? 0,
|
|
30
35
|
});
|
|
31
36
|
|
|
37
|
+
// generate authorizations and functions
|
|
32
38
|
const authorizations: AutoBeRealizeAuthorization[] =
|
|
33
39
|
await orchestrateRealizeAuthorization(ctx);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
ops,
|
|
40
|
+
const result = await writeCodeUntilCompilePassed(ctx)({
|
|
41
|
+
operations,
|
|
37
42
|
authorizations,
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const now = new Date().toISOString();
|
|
42
|
-
const realize = ctx.state().realize;
|
|
43
|
-
if (realize !== null) {
|
|
44
|
-
realize.functions = files;
|
|
45
|
-
} else {
|
|
46
|
-
const history = (ctx.state().realize = {
|
|
47
|
-
type: "realize",
|
|
48
|
-
compiled: {
|
|
49
|
-
type: "success",
|
|
50
|
-
},
|
|
51
|
-
functions: {
|
|
52
|
-
...files,
|
|
53
|
-
...authorizations
|
|
54
|
-
.flatMap((el) => {
|
|
55
|
-
return [
|
|
56
|
-
{
|
|
57
|
-
[el.decorator.location]: el.decorator.content,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
[el.payload.location]: el.payload.content,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
[el.payload.location]: el.payload.content,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
})
|
|
67
|
-
.reduce((acc, cur) => Object.assign(acc, cur)),
|
|
68
|
-
},
|
|
69
|
-
completed_at: now,
|
|
70
|
-
created_at: now,
|
|
71
|
-
id: v4(),
|
|
72
|
-
reason: props.reason,
|
|
73
|
-
step: ctx.state().analyze?.step ?? 0,
|
|
74
|
-
authorizations: ctx.state().realize?.authorizations ?? [],
|
|
75
|
-
} satisfies AutoBeRealizeHistory);
|
|
43
|
+
retry: 4,
|
|
44
|
+
});
|
|
76
45
|
|
|
77
|
-
|
|
78
|
-
}
|
|
46
|
+
const functions: AutoBeRealizeFunction[] = result.functions;
|
|
79
47
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
48
|
+
// compile controllers
|
|
49
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
50
|
+
const controllers: Record<string, string> =
|
|
51
|
+
await compiler.realize.controller({
|
|
52
|
+
document: ctx.state().interface!.document,
|
|
53
|
+
functions,
|
|
54
|
+
authorizations,
|
|
55
|
+
});
|
|
85
56
|
|
|
86
|
-
|
|
57
|
+
const history: AutoBeRealizeHistory = {
|
|
87
58
|
type: "realize",
|
|
88
|
-
compiled:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
completed_at:
|
|
93
|
-
created_at:
|
|
59
|
+
compiled: result.compiled,
|
|
60
|
+
authorizations,
|
|
61
|
+
functions,
|
|
62
|
+
controllers,
|
|
63
|
+
completed_at: new Date().toISOString(),
|
|
64
|
+
created_at: start.toISOString(),
|
|
94
65
|
id: v4(),
|
|
95
66
|
reason: props.reason,
|
|
96
67
|
step: ctx.state().analyze?.step ?? 0,
|
|
97
|
-
authorizations: ctx.state().realize?.authorizations ?? [],
|
|
98
68
|
};
|
|
69
|
+
|
|
70
|
+
// report
|
|
71
|
+
ctx.dispatch({
|
|
72
|
+
type: "realizeComplete",
|
|
73
|
+
created_at: new Date().toISOString(),
|
|
74
|
+
functions: history.functions,
|
|
75
|
+
authorizations: history.authorizations,
|
|
76
|
+
controllers: history.controllers,
|
|
77
|
+
compiled: await compiler.typescript.compile({
|
|
78
|
+
files: await getAutoBeGenerated(
|
|
79
|
+
compiler,
|
|
80
|
+
{
|
|
81
|
+
...ctx.state(),
|
|
82
|
+
realize: history,
|
|
83
|
+
},
|
|
84
|
+
[...ctx.histories(), history],
|
|
85
|
+
ctx.usage(),
|
|
86
|
+
),
|
|
87
|
+
}),
|
|
88
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
89
|
+
});
|
|
90
|
+
ctx.state().realize = history;
|
|
91
|
+
ctx.histories().push(history);
|
|
92
|
+
|
|
93
|
+
return history;
|
|
99
94
|
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
-
import {
|
|
3
|
-
AutoBeRealizeAuthorization,
|
|
4
|
-
IAutoBeCompiler,
|
|
5
|
-
IAutoBeTypeScriptCompileResult,
|
|
6
|
-
} from "@autobe/interface";
|
|
2
|
+
import { AutoBeRealizeAuthorization, IAutoBeCompiler } from "@autobe/interface";
|
|
7
3
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
8
4
|
import { IPointer } from "tstl";
|
|
9
5
|
import typia from "typia";
|
|
@@ -14,7 +10,6 @@ import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
|
14
10
|
import { orchestrateRealizeAuthorizationCorrect } from "./orchestrateRealizeAuthorizationCorrect";
|
|
15
11
|
import { IAutoBeRealizeAuthorizationApplication } from "./structures/IAutoBeRealizeAuthorizationApplication";
|
|
16
12
|
import { transformRealizeAuthorizationHistories } from "./transformRealizeAuthorization";
|
|
17
|
-
import { transformRealizeAuthorizationCorrectHistories } from "./transformRealizeAuthorizationCorrectHistories";
|
|
18
13
|
import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
|
|
19
14
|
import { InternalFileSystem } from "./utils/InternalFileSystem";
|
|
20
15
|
|
|
@@ -27,11 +22,7 @@ import { InternalFileSystem } from "./utils/InternalFileSystem";
|
|
|
27
22
|
export async function orchestrateRealizeAuthorization<
|
|
28
23
|
Model extends ILlmSchema.Model,
|
|
29
24
|
>(ctx: AutoBeContext<Model>): Promise<AutoBeRealizeAuthorization[]> {
|
|
30
|
-
const roles =
|
|
31
|
-
ctx
|
|
32
|
-
.state()
|
|
33
|
-
.interface?.document.components.authorization?.map((auth) => auth.name) ??
|
|
34
|
-
[];
|
|
25
|
+
const roles = ctx.state().analyze?.roles.map((role) => role.name) ?? [];
|
|
35
26
|
|
|
36
27
|
let completed = 0;
|
|
37
28
|
|
|
@@ -109,6 +100,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
109
100
|
});
|
|
110
101
|
if (pointer.value === null) throw new Error("Failed to create decorator.");
|
|
111
102
|
|
|
103
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
112
104
|
const authorization: AutoBeRealizeAuthorization = {
|
|
113
105
|
role,
|
|
114
106
|
decorator: {
|
|
@@ -121,7 +113,9 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
121
113
|
payload: {
|
|
122
114
|
location: AuthorizationFileSystem.payloadPath(pointer.value.payload.name),
|
|
123
115
|
name: pointer.value.payload.name,
|
|
124
|
-
content:
|
|
116
|
+
content: await compiler.typescript.beautify(
|
|
117
|
+
pointer.value.payload.content,
|
|
118
|
+
),
|
|
125
119
|
},
|
|
126
120
|
provider: {
|
|
127
121
|
location: AuthorizationFileSystem.providerPath(
|
|
@@ -135,114 +129,12 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
135
129
|
const prismaClients: Record<string, string> =
|
|
136
130
|
compiled?.type === "success" ? compiled.nodeModules : {};
|
|
137
131
|
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
prismaClients: Record<string, string>,
|
|
145
|
-
templateFiles: Record<string, string>,
|
|
146
|
-
life: number = 4,
|
|
147
|
-
): Promise<AutoBeRealizeAuthorization> {
|
|
148
|
-
// Check Compile
|
|
149
|
-
const files = {
|
|
150
|
-
...templateFiles,
|
|
151
|
-
...prismaClients,
|
|
152
|
-
[auth.decorator.location]: auth.decorator.content,
|
|
153
|
-
[auth.payload.location]: auth.payload.content,
|
|
154
|
-
[auth.provider.location]: auth.provider.content,
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
158
|
-
const result: IAutoBeTypeScriptCompileResult =
|
|
159
|
-
await compiler.typescript.compile({
|
|
160
|
-
files,
|
|
161
|
-
});
|
|
162
|
-
ctx.dispatch({
|
|
163
|
-
type: "realizeAuthorizationValidate",
|
|
164
|
-
created_at: new Date().toISOString(),
|
|
165
|
-
result,
|
|
166
|
-
authorization: auth,
|
|
167
|
-
step: ctx.state().test?.step ?? 0,
|
|
168
|
-
});
|
|
169
|
-
if (result.type === "success") {
|
|
170
|
-
return auth;
|
|
171
|
-
} else if (result.type === "exception" || life === 0) {
|
|
172
|
-
return auth;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const pointer: IPointer<IAutoBeRealizeAuthorizationApplication.IProps | null> =
|
|
176
|
-
{
|
|
177
|
-
value: null,
|
|
178
|
-
};
|
|
179
|
-
const agentica: MicroAgentica<Model> = new MicroAgentica({
|
|
180
|
-
model: ctx.model,
|
|
181
|
-
vendor: ctx.vendor,
|
|
182
|
-
config: {
|
|
183
|
-
...(ctx.config ?? {}),
|
|
184
|
-
executor: {
|
|
185
|
-
describe: null,
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
histories: transformRealizeAuthorizationCorrectHistories(
|
|
189
|
-
ctx,
|
|
190
|
-
auth,
|
|
191
|
-
templateFiles,
|
|
192
|
-
result.diagnostics,
|
|
193
|
-
),
|
|
194
|
-
controllers: [
|
|
195
|
-
createApplication({
|
|
196
|
-
model: ctx.model,
|
|
197
|
-
build: (next) => {
|
|
198
|
-
pointer.value = next;
|
|
199
|
-
},
|
|
200
|
-
}),
|
|
201
|
-
],
|
|
202
|
-
});
|
|
203
|
-
enforceToolCall(agentica);
|
|
204
|
-
|
|
205
|
-
await agentica
|
|
206
|
-
.conversate("Please correct the decorator and the provider.")
|
|
207
|
-
.finally(() => {
|
|
208
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
209
|
-
ctx.usage().record(tokenUsage, ["realize"]);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
if (pointer.value === null) throw new Error("Failed to correct decorator.");
|
|
213
|
-
|
|
214
|
-
const corrected: AutoBeRealizeAuthorization = {
|
|
215
|
-
role: auth.role,
|
|
216
|
-
decorator: {
|
|
217
|
-
location: auth.decorator.location,
|
|
218
|
-
name: pointer.value.decorator.name,
|
|
219
|
-
content: pointer.value.decorator.content,
|
|
220
|
-
},
|
|
221
|
-
payload: {
|
|
222
|
-
location: auth.payload.location,
|
|
223
|
-
name: pointer.value.payload.name,
|
|
224
|
-
content: pointer.value.payload.content,
|
|
225
|
-
},
|
|
226
|
-
provider: {
|
|
227
|
-
location: auth.provider.location,
|
|
228
|
-
name: pointer.value.provider.name,
|
|
229
|
-
content: pointer.value.provider.content,
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const res: AutoBeRealizeAuthorization =
|
|
234
|
-
await orchestrateRealizeAuthorizationCorrect(
|
|
235
|
-
ctx,
|
|
236
|
-
corrected,
|
|
237
|
-
prismaClients,
|
|
238
|
-
templateFiles,
|
|
239
|
-
life - 1,
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
return {
|
|
243
|
-
...res,
|
|
244
|
-
role: auth.role,
|
|
245
|
-
};
|
|
132
|
+
return orchestrateRealizeAuthorizationCorrect(
|
|
133
|
+
ctx,
|
|
134
|
+
authorization,
|
|
135
|
+
prismaClients,
|
|
136
|
+
templateFiles,
|
|
137
|
+
);
|
|
246
138
|
}
|
|
247
139
|
|
|
248
140
|
function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
@@ -15,6 +15,7 @@ import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
|
15
15
|
import { IAutoBeRealizeAuthorizationCorrectApplication } from "./structures/IAutoBeRealizeAuthorizationCorrectApplication";
|
|
16
16
|
import { transformRealizeAuthorizationCorrectHistories } from "./transformRealizeAuthorizationCorrectHistories";
|
|
17
17
|
import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
|
|
18
|
+
import { AutoBeRealizeAuthorizationReplaceImport } from "./utils/AutoBeRealizeAuthorizationReplaceImport";
|
|
18
19
|
|
|
19
20
|
export async function orchestrateRealizeAuthorizationCorrect<
|
|
20
21
|
Model extends ILlmSchema.Model,
|
|
@@ -25,20 +26,32 @@ export async function orchestrateRealizeAuthorizationCorrect<
|
|
|
25
26
|
templateFiles: Record<string, string>,
|
|
26
27
|
life: number = 4,
|
|
27
28
|
): Promise<AutoBeRealizeAuthorization> {
|
|
29
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
30
|
+
const providerContent: string = await compiler.typescript.beautify(
|
|
31
|
+
AutoBeRealizeAuthorizationReplaceImport.replaceProviderImport(
|
|
32
|
+
authorization.role,
|
|
33
|
+
authorization.provider.content,
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
const decoratorContent: string = await compiler.typescript.beautify(
|
|
37
|
+
AutoBeRealizeAuthorizationReplaceImport.replaceDecoratorImport(
|
|
38
|
+
authorization.role,
|
|
39
|
+
authorization.decorator.content,
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
|
|
28
43
|
// Check Compile
|
|
29
44
|
const files: Record<string, string> = {
|
|
30
45
|
...templateFiles,
|
|
31
46
|
...prismaClients,
|
|
32
47
|
[AuthorizationFileSystem.decoratorPath(authorization.decorator.name)]:
|
|
33
|
-
|
|
48
|
+
decoratorContent,
|
|
34
49
|
[AuthorizationFileSystem.providerPath(authorization.provider.name)]:
|
|
35
|
-
|
|
50
|
+
providerContent,
|
|
36
51
|
[AuthorizationFileSystem.payloadPath(authorization.payload.name)]:
|
|
37
52
|
authorization.payload.content,
|
|
38
53
|
};
|
|
39
54
|
|
|
40
|
-
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
41
|
-
|
|
42
55
|
const compiled: IAutoBeTypeScriptCompileResult =
|
|
43
56
|
await compiler.typescript.compile({
|
|
44
57
|
files,
|
|
@@ -113,8 +126,11 @@ export async function orchestrateRealizeAuthorizationCorrect<
|
|
|
113
126
|
),
|
|
114
127
|
},
|
|
115
128
|
payload: {
|
|
116
|
-
|
|
129
|
+
name: pointer.value.payload.name,
|
|
117
130
|
location: AuthorizationFileSystem.payloadPath(pointer.value.payload.name),
|
|
131
|
+
content: await compiler.typescript.beautify(
|
|
132
|
+
pointer.value.payload.content,
|
|
133
|
+
),
|
|
118
134
|
},
|
|
119
135
|
role: authorization.role,
|
|
120
136
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
2
|
import {
|
|
3
3
|
AutoBeOpenApi,
|
|
4
|
+
AutoBeRealizeAuthorization,
|
|
4
5
|
IAutoBeTypeScriptCompileResult,
|
|
5
6
|
} from "@autobe/interface";
|
|
6
7
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
@@ -15,6 +16,7 @@ import { getTestScenarioArtifacts } from "../test/compile/getTestScenarioArtifac
|
|
|
15
16
|
import { IAutoBeTestScenarioArtifacts } from "../test/structures/IAutoBeTestScenarioArtifacts";
|
|
16
17
|
import { RealizePlannerOutput } from "./orchestrateRealizePlanner";
|
|
17
18
|
import { IAutoBeRealizeCoderApplication } from "./structures/IAutoBeRealizeCoderApplication";
|
|
19
|
+
import { IAutoBeRealizeCompile } from "./structures/IAutoBeRealizeCompile";
|
|
18
20
|
import { FAILED } from "./structures/IAutoBeRealizeFailedSymbol";
|
|
19
21
|
import { transformRealizeCoderHistories } from "./transformRealizeCoderHistories";
|
|
20
22
|
import { RealizeFileSystem } from "./utils/ProviderFileSystem";
|
|
@@ -41,17 +43,13 @@ import { replaceImportStatements } from "./utils/replaceImportStatements";
|
|
|
41
43
|
export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
42
44
|
ctx: AutoBeContext<Model>,
|
|
43
45
|
operation: AutoBeOpenApi.IOperation,
|
|
46
|
+
previousCodes: IAutoBeRealizeCompile.Success[],
|
|
44
47
|
props: RealizePlannerOutput,
|
|
45
48
|
previous: string | null,
|
|
46
49
|
total: IAutoBeTypeScriptCompileResult.IDiagnostic[],
|
|
47
50
|
diagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
IAutoBeRealizeCoderApplication.RealizeCoderOutput,
|
|
51
|
-
"filename" | "implementationCode"
|
|
52
|
-
>
|
|
53
|
-
| FAILED
|
|
54
|
-
> => {
|
|
51
|
+
authorization?: AutoBeRealizeAuthorization,
|
|
52
|
+
): Promise<IAutoBeRealizeCoderApplication.RealizeCoderOutput | FAILED> => {
|
|
55
53
|
total;
|
|
56
54
|
|
|
57
55
|
const artifacts: IAutoBeTestScenarioArtifacts =
|
|
@@ -63,9 +61,9 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
|
63
61
|
dependencies: [],
|
|
64
62
|
});
|
|
65
63
|
|
|
66
|
-
const pointer: IPointer<
|
|
64
|
+
const pointer: IPointer<Omit<
|
|
67
65
|
IAutoBeRealizeCoderApplication.RealizeCoderOutput,
|
|
68
|
-
"
|
|
66
|
+
"filename"
|
|
69
67
|
> | null> = {
|
|
70
68
|
value: null,
|
|
71
69
|
};
|
|
@@ -89,10 +87,12 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
|
89
87
|
},
|
|
90
88
|
histories: transformRealizeCoderHistories(
|
|
91
89
|
ctx.state(),
|
|
90
|
+
previousCodes,
|
|
92
91
|
props,
|
|
93
92
|
artifacts,
|
|
94
93
|
previous,
|
|
95
94
|
diagnostics,
|
|
95
|
+
authorization,
|
|
96
96
|
),
|
|
97
97
|
});
|
|
98
98
|
enforceToolCall(agent);
|
|
@@ -123,6 +123,7 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
pointer.value.implementationCode = await replaceImportStatements(ctx)(
|
|
126
|
+
artifacts,
|
|
126
127
|
pointer.value.implementationCode,
|
|
127
128
|
props.decoratorEvent?.payload.name,
|
|
128
129
|
);
|
|
@@ -42,13 +42,12 @@ export namespace IAutoBeRealizeAuthorizationApplication {
|
|
|
42
42
|
name: string;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Complete TypeScript code for the authentication Provider function
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* format) and type (role discriminator) fields using typia tags.
|
|
45
|
+
* Complete TypeScript code for the authentication Provider function. Must
|
|
46
|
+
* include: JWT token verification using jwtAuthorize function, role type
|
|
47
|
+
* checking against payload.type, database query using
|
|
48
|
+
* MyGlobal.prisma.{tableName} pattern to verify user existence, and proper
|
|
49
|
+
* error handling with ForbiddenException and UnauthorizedException. The
|
|
50
|
+
* function should return the authenticated user payload data.
|
|
52
51
|
*/
|
|
53
52
|
content: string;
|
|
54
53
|
}
|
|
@@ -76,19 +75,20 @@ export namespace IAutoBeRealizeAuthorizationApplication {
|
|
|
76
75
|
|
|
77
76
|
export interface IPayloadType {
|
|
78
77
|
/**
|
|
79
|
-
* The name of the
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* payload as a method parameter.
|
|
78
|
+
* The name of the Payload type to be generated in {Role}Payload format
|
|
79
|
+
* (e.g., AdminPayload, UserPayload). This type defines the structure of the
|
|
80
|
+
* authenticated user data that will be injected into Controller methods
|
|
81
|
+
* when using the decorator.
|
|
84
82
|
*/
|
|
85
83
|
name: string;
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
|
-
*
|
|
89
|
-
* AdminPayload, UserPayload).
|
|
86
|
+
* Complete TypeScript code for the Payload type interface in {Role}Payload
|
|
87
|
+
* format (e.g., AdminPayload, UserPayload). Must include: id field with
|
|
88
|
+
* UUID format validation, type field as role discriminator, and proper
|
|
89
|
+
* typia tags for validation. This interface defines the structure of the
|
|
90
90
|
* authenticated user data that will be injected into Controller methods
|
|
91
|
-
* when using the decorator
|
|
91
|
+
* when using the decorator and serves as the TypeScript type for the
|
|
92
92
|
* parameter in Controller method signatures.
|
|
93
93
|
*/
|
|
94
94
|
content: string;
|
|
@@ -12,29 +12,22 @@ export namespace IAutoBeRealizeAuthorizationCorrectApplication {
|
|
|
12
12
|
/**
|
|
13
13
|
* Step 1: TypeScript compilation error analysis and diagnosis.
|
|
14
14
|
*
|
|
15
|
-
* AI identifies all compilation errors (type mismatches,
|
|
16
|
-
*
|
|
17
|
-
* error
|
|
18
|
-
*
|
|
15
|
+
* AI identifies and categorizes all compilation errors (type mismatches,
|
|
16
|
+
* import issues, syntax errors) by component (providers/decorator/payload).
|
|
17
|
+
* Lists specific error messages with their locations and types for
|
|
18
|
+
* systematic troubleshooting.
|
|
19
19
|
*/
|
|
20
20
|
error_analysis: string;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Step 2:
|
|
23
|
+
* Step 2: Solution guidance and fix recommendations.
|
|
24
24
|
*
|
|
25
|
-
* AI
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* AI provides clear, actionable instructions on how to resolve each
|
|
26
|
+
* identified error. Includes specific steps like "add property X to
|
|
27
|
+
* interface Y", "update import path from A to B", or "change type from C to
|
|
28
|
+
* D". Focus on guidance rather than generating complete code
|
|
29
|
+
* implementations.
|
|
28
30
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Step 3: Final validation and comprehensive fix summary.
|
|
33
|
-
*
|
|
34
|
-
* AI validates corrected code compiles successfully and documents all
|
|
35
|
-
* changes made. Provides production-ready code with detailed change log for
|
|
36
|
-
* maintenance reference.
|
|
37
|
-
*/
|
|
38
|
-
validation_summary: string;
|
|
31
|
+
solution_guidance: string;
|
|
39
32
|
}
|
|
40
33
|
}
|
|
@@ -16,7 +16,7 @@ export namespace IAutoBeRealizeCoderApplication {
|
|
|
16
16
|
* The detailed output of the code generation process, containing all phases
|
|
17
17
|
* from planning to final implementation of a TypeScript provider function.
|
|
18
18
|
*/
|
|
19
|
-
output: RealizeCoderOutput
|
|
19
|
+
output: Omit<IAutoBeRealizeCoderApplication.RealizeCoderOutput, "filename">;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -287,8 +287,10 @@ export namespace IAutoBeRealizeCoderApplication {
|
|
|
287
287
|
* - Resolve all TypeScript errors without using `as any`.
|
|
288
288
|
* - Provide safe brand casting only if required (e.g., `as string &
|
|
289
289
|
* tags.Format<'uuid'>`).
|
|
290
|
+
* - If no TypeScript errors exist, this field MUST contain the text: "No
|
|
291
|
+
* TypeScript errors detected - skipping this phase"
|
|
290
292
|
*/
|
|
291
|
-
withCompilerFeedback
|
|
293
|
+
withCompilerFeedback: string;
|
|
292
294
|
|
|
293
295
|
/**
|
|
294
296
|
* Step 5.
|
|
@@ -4,48 +4,55 @@ import {
|
|
|
4
4
|
} from "@autobe/interface";
|
|
5
5
|
import { tags } from "typia";
|
|
6
6
|
|
|
7
|
+
import { IAutoBeRealizeCoderApplication } from "./IAutoBeRealizeCoderApplication";
|
|
7
8
|
import { FAILED } from "./IAutoBeRealizeFailedSymbol";
|
|
8
9
|
|
|
9
10
|
export namespace IAutoBeRealizeCompile {
|
|
11
|
+
export type Result =
|
|
12
|
+
| IAutoBeRealizeCompile.Success
|
|
13
|
+
| IAutoBeRealizeCompile.Fail;
|
|
14
|
+
|
|
10
15
|
type IBase<T extends "success" | "failed"> = {
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether code generation was attempted. "success" means code was
|
|
18
|
+
* generated, but compilation may still fail. "failed" means code generation
|
|
19
|
+
* was not possible (e.g., invalid input).
|
|
20
|
+
*/
|
|
11
21
|
type: T;
|
|
12
22
|
};
|
|
13
23
|
|
|
14
|
-
interface
|
|
24
|
+
export interface Success extends IBase<"success"> {
|
|
15
25
|
/**
|
|
16
26
|
* Operation: An object containing the function specification including the
|
|
17
27
|
* endpoint
|
|
18
28
|
*/
|
|
19
|
-
|
|
20
|
-
}
|
|
29
|
+
operation: AutoBeOpenApi.IOperation;
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
filename: string;
|
|
25
|
-
/** The generated implementation code for the function */
|
|
26
|
-
implementationCode: string;
|
|
27
|
-
/** Function name */
|
|
28
|
-
name: string;
|
|
31
|
+
/** Result */
|
|
32
|
+
result: IAutoBeRealizeCoderApplication.RealizeCoderOutput;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
export interface
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
export interface Fail extends IBase<"failed"> {
|
|
36
|
+
/**
|
|
37
|
+
* Operation: An object containing the function specification including the
|
|
38
|
+
* endpoint
|
|
39
|
+
*/
|
|
40
|
+
operation: AutoBeOpenApi.IOperation;
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
/** Result */
|
|
36
43
|
result: FAILED;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
export interface
|
|
46
|
+
export interface CodeArtifact {
|
|
40
47
|
result: "failed" | "success";
|
|
41
48
|
content: string;
|
|
42
49
|
role?: (string & tags.MinLength<1>) | null;
|
|
43
50
|
endpoint?: AutoBeOpenApi.IEndpoint;
|
|
44
|
-
location
|
|
51
|
+
location: string;
|
|
45
52
|
name?: string;
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
export type FileContentMap = Record<string,
|
|
55
|
+
export type FileContentMap = Record<string, CodeArtifact>;
|
|
49
56
|
|
|
50
57
|
export interface CompileDiagnostics {
|
|
51
58
|
/**
|
|
@@ -4,7 +4,6 @@ import { v4 } from "uuid";
|
|
|
4
4
|
|
|
5
5
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
6
6
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
7
|
-
import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
|
|
8
7
|
|
|
9
8
|
export const transformRealizeAuthorizationHistories = (
|
|
10
9
|
ctx: AutoBeContext<ILlmSchema.Model>,
|
|
@@ -32,16 +31,13 @@ export const transformRealizeAuthorizationHistories = (
|
|
|
32
31
|
"",
|
|
33
32
|
JSON.stringify(ctx.state().prisma?.schemas, null, 2),
|
|
34
33
|
"",
|
|
35
|
-
"##
|
|
34
|
+
"## Component Naming Convention",
|
|
36
35
|
"",
|
|
37
|
-
"Please
|
|
38
|
-
"",
|
|
39
|
-
"File locations:",
|
|
40
|
-
"",
|
|
41
|
-
`- Decorator Path : ${AuthorizationFileSystem.decoratorPath("AdminAuth.ts")}`,
|
|
42
|
-
`- Payload Path : ${AuthorizationFileSystem.payloadPath("AdminPayload.ts")}`,
|
|
43
|
-
`- Provider Path : ${AuthorizationFileSystem.providerPath("adminAuthorize.ts")}`,
|
|
36
|
+
"Please follow this naming convention for the authorization components:",
|
|
44
37
|
"",
|
|
38
|
+
`- Provider Name: ${role}Authorize (e.g. ${role}Authorize)`,
|
|
39
|
+
`- Decorator Name: ${role.charAt(0).toUpperCase() + role.slice(1)}Auth (e.g. ${role.charAt(0).toUpperCase() + role.slice(1)}Auth)`,
|
|
40
|
+
`- Payload Name: ${role.charAt(0).toUpperCase() + role.slice(1)}Payload (e.g. ${role.charAt(0).toUpperCase() + role.slice(1)}Payload)`,
|
|
45
41
|
].join("\n"),
|
|
46
42
|
},
|
|
47
43
|
];
|