@autobe/agent 0.14.4 → 0.14.6
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 +2 -2
- package/lib/index.mjs +662 -182
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +12 -10
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +2 -2
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +77 -82
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.d.ts +4 -0
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +513 -0
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -0
- package/lib/orchestrate/realize/structures/{IAutoBeRealizeDecoratorApplication.d.ts → IAutoBeRealizeAuthorizationApplication.d.ts} +9 -9
- package/lib/orchestrate/realize/structures/{IAutoBeRealizeDecoratorApplication.js → IAutoBeRealizeAuthorizationApplication.js} +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +33 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.js +3 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeAuthorization.d.ts +4 -0
- package/lib/orchestrate/realize/transformRealizeAuthorization.js +43 -0
- package/lib/orchestrate/realize/transformRealizeAuthorization.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.d.ts +5 -0
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js +71 -0
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTestCorrect.js +2 -0
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js +2 -0
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/package.json +6 -5
- package/src/constants/AutoBeSystemPromptConstant.ts +2 -2
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +11 -9
- package/src/orchestrate/realize/orchestrateRealize.ts +7 -2
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +40 -36
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +179 -0
- package/src/orchestrate/realize/structures/{IAutoBeRealizeDecoratorApplication.ts → IAutoBeRealizeAuthorizationApplication.ts} +11 -9
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +40 -0
- package/src/orchestrate/realize/{transformRealizeDecorator.ts → transformRealizeAuthorization.ts} +13 -2
- package/src/orchestrate/realize/{transformRealizeDecoratorCorrectHistories.ts → transformRealizeAuthorizationCorrectHistories.ts} +15 -7
- package/src/orchestrate/test/orchestrateTestCorrect.ts +3 -0
- package/src/orchestrate/test/orchestrateTestWrite.ts +8 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.js.map +0 -1
- package/lib/orchestrate/realize/transformRealizeDecorator.d.ts +0 -4
- package/lib/orchestrate/realize/transformRealizeDecorator.js +0 -32
- package/lib/orchestrate/realize/transformRealizeDecorator.js.map +0 -1
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.d.ts +0 -5
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js +0 -62
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js.map +0 -1
|
@@ -156,27 +156,29 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
|
156
156
|
typia.validate<IMakeOperationProps>(next);
|
|
157
157
|
if (result.success === false) return result;
|
|
158
158
|
|
|
159
|
+
const operations: AutoBeOpenApi.IOperation[] = result.data.operations;
|
|
159
160
|
const errors: IValidation.IError[] = [];
|
|
160
|
-
|
|
161
|
+
operations.forEach((op, i) => {
|
|
161
162
|
if (op.method === "get" && op.requestBody !== null)
|
|
162
163
|
errors.push({
|
|
163
|
-
path:
|
|
164
|
+
path: `$input.operations[${i}].requestBody`,
|
|
164
165
|
expected:
|
|
165
166
|
"GET method should not have request body. Change method, or re-design the operation.",
|
|
166
167
|
value: op.requestBody,
|
|
167
168
|
});
|
|
168
|
-
if (props.roles === null)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
props.roles?.
|
|
169
|
+
if (props.roles === null) op.authorizationRole = null;
|
|
170
|
+
else if (
|
|
171
|
+
op.authorizationRole !== null &&
|
|
172
|
+
!!props.roles?.length &&
|
|
173
|
+
props.roles.find((it) => it === op.authorizationRole) === undefined
|
|
172
174
|
)
|
|
173
175
|
errors.push({
|
|
174
|
-
path:
|
|
175
|
-
expected: `
|
|
176
|
+
path: `$input.operations[${i}].authorizationRole`,
|
|
177
|
+
expected: `null | ${props.roles.map((str) => JSON.stringify(str)).join(" | ")}`,
|
|
176
178
|
description: [
|
|
177
179
|
`Role "${op.authorizationRole}" is not defined in the roles list.`,
|
|
178
180
|
"",
|
|
179
|
-
"Please select one of them below, or do not define (
|
|
181
|
+
"Please select one of them below, or do not define (`null`): ",
|
|
180
182
|
"",
|
|
181
183
|
...(props.roles ?? []).map((role) => `- ${role}`),
|
|
182
184
|
].join("\n"),
|
|
@@ -29,9 +29,14 @@ export const orchestrateRealize =
|
|
|
29
29
|
step: ctx.state().test?.step ?? 0,
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const authorizations: AutoBeRealizeAuthorization[] =
|
|
33
33
|
await orchestrateRealizeAuthorization(ctx);
|
|
34
|
-
const files = await writeCodeUntilCompilePassed(
|
|
34
|
+
const files = await writeCodeUntilCompilePassed(
|
|
35
|
+
ctx,
|
|
36
|
+
ops,
|
|
37
|
+
authorizations,
|
|
38
|
+
2,
|
|
39
|
+
);
|
|
35
40
|
|
|
36
41
|
const now = new Date().toISOString();
|
|
37
42
|
const realize = ctx.state().realize;
|
|
@@ -13,9 +13,10 @@ import typia from "typia";
|
|
|
13
13
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
14
14
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
15
15
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
16
|
+
import { orchestrateRealizeAuthorizationCorrect } from "./orchestrateRealizeAuthorizationCorrect";
|
|
17
|
+
import { IAutoBeRealizeAuthorizationApplication } from "./structures/IAutoBeRealizeAuthorizationApplication";
|
|
18
|
+
import { transformRealizeAuthorizationHistories } from "./transformRealizeAuthorization";
|
|
19
|
+
import { transformRealizeAuthorizationCorrectHistories } from "./transformRealizeAuthorizationCorrectHistories";
|
|
19
20
|
import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -43,7 +44,7 @@ export async function orchestrateRealizeAuthorization<
|
|
|
43
44
|
),
|
|
44
45
|
"utf-8",
|
|
45
46
|
),
|
|
46
|
-
"
|
|
47
|
+
[AuthorizationFileSystem.providerPath("jwtAuthorize")]: await fs.readFile(
|
|
47
48
|
path.join(
|
|
48
49
|
__dirname,
|
|
49
50
|
"../../../../../internals/template/realize/src/providers/jwtAuthorize.ts",
|
|
@@ -88,9 +89,10 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
88
89
|
role: string,
|
|
89
90
|
templateFiles: Record<string, string>,
|
|
90
91
|
): Promise<AutoBeRealizeAuthorization> {
|
|
91
|
-
const pointer: IPointer<
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const pointer: IPointer<IAutoBeRealizeAuthorizationApplication.IProps | null> =
|
|
93
|
+
{
|
|
94
|
+
value: null,
|
|
95
|
+
};
|
|
94
96
|
const agentica: MicroAgentica<Model> = new MicroAgentica({
|
|
95
97
|
model: ctx.model,
|
|
96
98
|
vendor: ctx.vendor,
|
|
@@ -100,7 +102,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
100
102
|
describe: null,
|
|
101
103
|
},
|
|
102
104
|
},
|
|
103
|
-
histories:
|
|
105
|
+
histories: transformRealizeAuthorizationHistories(ctx, role),
|
|
104
106
|
controllers: [
|
|
105
107
|
createApplication({
|
|
106
108
|
model: ctx.model,
|
|
@@ -127,24 +129,25 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
127
129
|
pointer.value.decorator.name,
|
|
128
130
|
),
|
|
129
131
|
name: pointer.value.decorator.name,
|
|
130
|
-
content: pointer.value.decorator.
|
|
132
|
+
content: pointer.value.decorator.content,
|
|
131
133
|
},
|
|
132
134
|
payload: {
|
|
133
135
|
location: AuthorizationFileSystem.payloadPath(pointer.value.payload.name),
|
|
134
136
|
name: pointer.value.payload.name,
|
|
135
|
-
content: pointer.value.payload.
|
|
137
|
+
content: pointer.value.payload.content,
|
|
136
138
|
},
|
|
137
139
|
provider: {
|
|
138
140
|
location: AuthorizationFileSystem.providerPath(
|
|
139
141
|
pointer.value.provider.name,
|
|
140
142
|
),
|
|
141
143
|
name: pointer.value.provider.name,
|
|
142
|
-
content: pointer.value.provider.
|
|
144
|
+
content: pointer.value.provider.content,
|
|
143
145
|
},
|
|
144
146
|
};
|
|
145
147
|
const compiled = ctx.state().prisma?.compiled;
|
|
146
148
|
const prismaClients: Record<string, string> =
|
|
147
149
|
compiled?.type === "success" ? compiled.nodeModules : {};
|
|
150
|
+
|
|
148
151
|
return correctDecorator(ctx, authorization, prismaClients, templateFiles);
|
|
149
152
|
}
|
|
150
153
|
|
|
@@ -182,9 +185,10 @@ async function correctDecorator<Model extends ILlmSchema.Model>(
|
|
|
182
185
|
return auth;
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
const pointer: IPointer<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
const pointer: IPointer<IAutoBeRealizeAuthorizationApplication.IProps | null> =
|
|
189
|
+
{
|
|
190
|
+
value: null,
|
|
191
|
+
};
|
|
188
192
|
const agentica: MicroAgentica<Model> = new MicroAgentica({
|
|
189
193
|
model: ctx.model,
|
|
190
194
|
vendor: ctx.vendor,
|
|
@@ -194,7 +198,7 @@ async function correctDecorator<Model extends ILlmSchema.Model>(
|
|
|
194
198
|
describe: null,
|
|
195
199
|
},
|
|
196
200
|
},
|
|
197
|
-
histories:
|
|
201
|
+
histories: transformRealizeAuthorizationCorrectHistories(
|
|
198
202
|
ctx,
|
|
199
203
|
auth,
|
|
200
204
|
templateFiles,
|
|
@@ -225,38 +229,38 @@ async function correctDecorator<Model extends ILlmSchema.Model>(
|
|
|
225
229
|
decorator: {
|
|
226
230
|
location: auth.decorator.location,
|
|
227
231
|
name: pointer.value.decorator.name,
|
|
228
|
-
content: pointer.value.decorator.
|
|
232
|
+
content: pointer.value.decorator.content,
|
|
229
233
|
},
|
|
230
234
|
payload: {
|
|
231
235
|
location: auth.payload.location,
|
|
232
236
|
name: pointer.value.payload.name,
|
|
233
|
-
content: pointer.value.payload.
|
|
237
|
+
content: pointer.value.payload.content,
|
|
234
238
|
},
|
|
235
239
|
provider: {
|
|
236
240
|
location: auth.provider.location,
|
|
237
241
|
name: pointer.value.provider.name,
|
|
238
|
-
content: pointer.value.provider.
|
|
242
|
+
content: pointer.value.provider.content,
|
|
239
243
|
},
|
|
240
244
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
245
|
+
|
|
246
|
+
const res: AutoBeRealizeAuthorization =
|
|
247
|
+
await orchestrateRealizeAuthorizationCorrect(
|
|
248
|
+
ctx,
|
|
249
|
+
corrected,
|
|
250
|
+
prismaClients,
|
|
251
|
+
templateFiles,
|
|
252
|
+
life - 1,
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
...res,
|
|
257
|
+
role: auth.role,
|
|
258
|
+
};
|
|
255
259
|
}
|
|
256
260
|
|
|
257
261
|
function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
258
262
|
model: Model;
|
|
259
|
-
build: (next:
|
|
263
|
+
build: (next: IAutoBeRealizeAuthorizationApplication.IProps) => void;
|
|
260
264
|
}): IAgenticaController.IClass<Model> {
|
|
261
265
|
assertSchemaModel(props.model);
|
|
262
266
|
|
|
@@ -272,12 +276,12 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
|
272
276
|
createDecorator: (next) => {
|
|
273
277
|
props.build(next);
|
|
274
278
|
},
|
|
275
|
-
} satisfies
|
|
279
|
+
} satisfies IAutoBeRealizeAuthorizationApplication,
|
|
276
280
|
};
|
|
277
281
|
}
|
|
278
282
|
|
|
279
283
|
const claude = typia.llm.application<
|
|
280
|
-
|
|
284
|
+
IAutoBeRealizeAuthorizationApplication,
|
|
281
285
|
"claude",
|
|
282
286
|
{
|
|
283
287
|
reference: true;
|
|
@@ -285,7 +289,7 @@ const claude = typia.llm.application<
|
|
|
285
289
|
>();
|
|
286
290
|
const collection = {
|
|
287
291
|
chatgpt: typia.llm.application<
|
|
288
|
-
|
|
292
|
+
IAutoBeRealizeAuthorizationApplication,
|
|
289
293
|
"chatgpt",
|
|
290
294
|
{ reference: true }
|
|
291
295
|
>(),
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
+
import {
|
|
3
|
+
AutoBeRealizeAuthorization,
|
|
4
|
+
AutoBeRealizeAuthorizationCorrect,
|
|
5
|
+
IAutoBeCompiler,
|
|
6
|
+
IAutoBeTypeScriptCompileResult,
|
|
7
|
+
} from "@autobe/interface";
|
|
8
|
+
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
9
|
+
import { IPointer } from "tstl";
|
|
10
|
+
import typia from "typia";
|
|
11
|
+
|
|
12
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
13
|
+
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
14
|
+
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
15
|
+
import { IAutoBeRealizeAuthorizationCorrectApplication } from "./structures/IAutoBeRealizeAuthorizationCorrectApplication";
|
|
16
|
+
import { transformRealizeAuthorizationCorrectHistories } from "./transformRealizeAuthorizationCorrectHistories";
|
|
17
|
+
import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
|
|
18
|
+
|
|
19
|
+
export async function orchestrateRealizeAuthorizationCorrect<
|
|
20
|
+
Model extends ILlmSchema.Model,
|
|
21
|
+
>(
|
|
22
|
+
ctx: AutoBeContext<Model>,
|
|
23
|
+
authorization: AutoBeRealizeAuthorization,
|
|
24
|
+
prismaClients: Record<string, string>,
|
|
25
|
+
templateFiles: Record<string, string>,
|
|
26
|
+
life: number = 4,
|
|
27
|
+
): Promise<AutoBeRealizeAuthorization> {
|
|
28
|
+
// Check Compile
|
|
29
|
+
const files: Record<string, string> = {
|
|
30
|
+
...templateFiles,
|
|
31
|
+
...prismaClients,
|
|
32
|
+
[AuthorizationFileSystem.decoratorPath(authorization.decorator.name)]:
|
|
33
|
+
authorization.decorator.content,
|
|
34
|
+
[AuthorizationFileSystem.providerPath(authorization.provider.name)]:
|
|
35
|
+
authorization.provider.content,
|
|
36
|
+
[AuthorizationFileSystem.payloadPath(authorization.payload.name)]:
|
|
37
|
+
authorization.payload.content,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
41
|
+
|
|
42
|
+
const compiled: IAutoBeTypeScriptCompileResult =
|
|
43
|
+
await compiler.typescript.compile({
|
|
44
|
+
files,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
ctx.dispatch({
|
|
48
|
+
type: "realizeAuthorizationValidate",
|
|
49
|
+
created_at: new Date().toISOString(),
|
|
50
|
+
authorization: authorization,
|
|
51
|
+
result: compiled,
|
|
52
|
+
step: ctx.state().test?.step ?? 0,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (compiled.type === "success") {
|
|
56
|
+
return authorization;
|
|
57
|
+
} else if (compiled.type === "exception" || life === 0) {
|
|
58
|
+
return authorization;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const pointer: IPointer<IAutoBeRealizeAuthorizationCorrectApplication.IProps | null> =
|
|
62
|
+
{
|
|
63
|
+
value: null,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const agentica: MicroAgentica<Model> = new MicroAgentica({
|
|
67
|
+
model: ctx.model,
|
|
68
|
+
vendor: ctx.vendor,
|
|
69
|
+
config: {
|
|
70
|
+
...(ctx.config ?? {}),
|
|
71
|
+
executor: {
|
|
72
|
+
describe: null,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
histories: transformRealizeAuthorizationCorrectHistories(
|
|
76
|
+
ctx,
|
|
77
|
+
authorization,
|
|
78
|
+
templateFiles,
|
|
79
|
+
compiled.diagnostics,
|
|
80
|
+
),
|
|
81
|
+
controllers: [
|
|
82
|
+
createApplication({
|
|
83
|
+
model: ctx.model,
|
|
84
|
+
build: (next) => {
|
|
85
|
+
pointer.value = next;
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
enforceToolCall(agentica);
|
|
91
|
+
|
|
92
|
+
await agentica
|
|
93
|
+
.conversate("Please correct the decorator and the provider.")
|
|
94
|
+
.finally(() => {
|
|
95
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
96
|
+
ctx.usage().record(tokenUsage, ["realize"]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (pointer.value === null) throw new Error("Failed to correct decorator.");
|
|
100
|
+
|
|
101
|
+
const result: AutoBeRealizeAuthorizationCorrect = {
|
|
102
|
+
...pointer.value,
|
|
103
|
+
decorator: {
|
|
104
|
+
...pointer.value.decorator,
|
|
105
|
+
location: AuthorizationFileSystem.decoratorPath(
|
|
106
|
+
pointer.value.decorator.name,
|
|
107
|
+
),
|
|
108
|
+
},
|
|
109
|
+
provider: {
|
|
110
|
+
...pointer.value.provider,
|
|
111
|
+
location: AuthorizationFileSystem.providerPath(
|
|
112
|
+
pointer.value.provider.name,
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
payload: {
|
|
116
|
+
...pointer.value.payload,
|
|
117
|
+
location: AuthorizationFileSystem.payloadPath(pointer.value.payload.name),
|
|
118
|
+
},
|
|
119
|
+
role: authorization.role,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
ctx.dispatch({
|
|
123
|
+
...pointer.value,
|
|
124
|
+
type: "realizeAuthorizationCorrect",
|
|
125
|
+
created_at: new Date().toISOString(),
|
|
126
|
+
authorization: result,
|
|
127
|
+
result: compiled,
|
|
128
|
+
step: ctx.state().test?.step ?? 0,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return await orchestrateRealizeAuthorizationCorrect(
|
|
132
|
+
ctx,
|
|
133
|
+
result,
|
|
134
|
+
prismaClients,
|
|
135
|
+
templateFiles,
|
|
136
|
+
life - 1,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
141
|
+
model: Model;
|
|
142
|
+
build: (next: IAutoBeRealizeAuthorizationCorrectApplication.IProps) => void;
|
|
143
|
+
}): IAgenticaController.IClass<Model> {
|
|
144
|
+
assertSchemaModel(props.model);
|
|
145
|
+
|
|
146
|
+
const application: ILlmApplication<Model> = collection[
|
|
147
|
+
props.model
|
|
148
|
+
] as unknown as ILlmApplication<Model>;
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
protocol: "class",
|
|
152
|
+
name: "Correct Authorization",
|
|
153
|
+
application,
|
|
154
|
+
execute: {
|
|
155
|
+
correctDecorator: (next) => {
|
|
156
|
+
props.build(next);
|
|
157
|
+
},
|
|
158
|
+
} satisfies IAutoBeRealizeAuthorizationCorrectApplication,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const claude = typia.llm.application<
|
|
163
|
+
IAutoBeRealizeAuthorizationCorrectApplication,
|
|
164
|
+
"claude",
|
|
165
|
+
{
|
|
166
|
+
reference: true;
|
|
167
|
+
}
|
|
168
|
+
>();
|
|
169
|
+
const collection = {
|
|
170
|
+
chatgpt: typia.llm.application<
|
|
171
|
+
IAutoBeRealizeAuthorizationCorrectApplication,
|
|
172
|
+
"chatgpt",
|
|
173
|
+
{ reference: true }
|
|
174
|
+
>(),
|
|
175
|
+
claude,
|
|
176
|
+
llama: claude,
|
|
177
|
+
deepseek: claude,
|
|
178
|
+
"3.1": claude,
|
|
179
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
createDecorator: (
|
|
1
|
+
export interface IAutoBeRealizeAuthorizationApplication {
|
|
2
|
+
createDecorator: (
|
|
3
|
+
next: IAutoBeRealizeAuthorizationApplication.IProps,
|
|
4
|
+
) => void;
|
|
3
5
|
}
|
|
4
6
|
|
|
5
|
-
export namespace
|
|
7
|
+
export namespace IAutoBeRealizeAuthorizationApplication {
|
|
6
8
|
export interface IProps {
|
|
7
9
|
/**
|
|
8
10
|
* Authentication Provider function configuration containing the function
|
|
@@ -10,7 +12,7 @@ export namespace IAutoBeRealizeDecoratorApplication {
|
|
|
10
12
|
* verification, role validation, and database queries to authenticate
|
|
11
13
|
* users.
|
|
12
14
|
*/
|
|
13
|
-
provider:
|
|
15
|
+
provider: IAutoBeRealizeAuthorizationApplication.IProvider;
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Authentication Decorator configuration containing the decorator name and
|
|
@@ -18,7 +20,7 @@ export namespace IAutoBeRealizeDecoratorApplication {
|
|
|
18
20
|
* decorators to automatically inject authenticated user data into
|
|
19
21
|
* Controller methods.
|
|
20
22
|
*/
|
|
21
|
-
decorator:
|
|
23
|
+
decorator: IAutoBeRealizeAuthorizationApplication.IDecorator;
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Authentication Payload Type configuration containing the payload type
|
|
@@ -27,7 +29,7 @@ export namespace IAutoBeRealizeDecoratorApplication {
|
|
|
27
29
|
* Controller methods when using the decorator. It serves as the TypeScript
|
|
28
30
|
* type for the parameter in Controller method signatures.
|
|
29
31
|
*/
|
|
30
|
-
payload:
|
|
32
|
+
payload: IAutoBeRealizeAuthorizationApplication.IPayloadType;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export interface IProvider {
|
|
@@ -48,7 +50,7 @@ export namespace IAutoBeRealizeDecoratorApplication {
|
|
|
48
50
|
* UnauthorizedException, and the Payload interface definition with id (UUID
|
|
49
51
|
* format) and type (role discriminator) fields using typia tags.
|
|
50
52
|
*/
|
|
51
|
-
|
|
53
|
+
content: string;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
export interface IDecorator {
|
|
@@ -69,7 +71,7 @@ export namespace IAutoBeRealizeDecoratorApplication {
|
|
|
69
71
|
* pattern using tstl library for efficient decorator instance management,
|
|
70
72
|
* and proper TypeScript typing for the ParameterDecorator interface.
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
content: string;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
export interface IPayloadType {
|
|
@@ -89,6 +91,6 @@ export namespace IAutoBeRealizeDecoratorApplication {
|
|
|
89
91
|
* when using the decorator. It serves as the TypeScript type for the
|
|
90
92
|
* parameter in Controller method signatures.
|
|
91
93
|
*/
|
|
92
|
-
|
|
94
|
+
content: string;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IAutoBeRealizeAuthorizationApplication } from "./IAutoBeRealizeAuthorizationApplication";
|
|
2
|
+
|
|
3
|
+
export interface IAutoBeRealizeAuthorizationCorrectApplication {
|
|
4
|
+
correctDecorator: (
|
|
5
|
+
next: IAutoBeRealizeAuthorizationCorrectApplication.IProps,
|
|
6
|
+
) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export namespace IAutoBeRealizeAuthorizationCorrectApplication {
|
|
10
|
+
export interface IProps
|
|
11
|
+
extends IAutoBeRealizeAuthorizationApplication.IProps {
|
|
12
|
+
/**
|
|
13
|
+
* Step 1: TypeScript compilation error analysis and diagnosis.
|
|
14
|
+
*
|
|
15
|
+
* AI identifies all compilation errors (type mismatches, imports, syntax)
|
|
16
|
+
* and categorizes them by component (provider/decorator/payload). Analyzes
|
|
17
|
+
* error dependencies and determines fix priorities for systematic
|
|
18
|
+
* resolution.
|
|
19
|
+
*/
|
|
20
|
+
error_analysis: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Step 2: Corrected implementation with all compilation errors resolved.
|
|
24
|
+
*
|
|
25
|
+
* AI generates fixed versions of provider, decorator, and payload code.
|
|
26
|
+
* Maintains original functionality while ensuring TypeScript compilation
|
|
27
|
+
* success and proper NestJS/Prisma framework integration.
|
|
28
|
+
*/
|
|
29
|
+
corrected_implementation: string;
|
|
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;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/orchestrate/realize/{transformRealizeDecorator.ts → transformRealizeAuthorization.ts}
RENAMED
|
@@ -4,8 +4,9 @@ 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";
|
|
7
8
|
|
|
8
|
-
export const
|
|
9
|
+
export const transformRealizeAuthorizationHistories = (
|
|
9
10
|
ctx: AutoBeContext<ILlmSchema.Model>,
|
|
10
11
|
role: string,
|
|
11
12
|
): Array<
|
|
@@ -16,7 +17,7 @@ export const transformRealizeDecoratorHistories = (
|
|
|
16
17
|
id: v4(),
|
|
17
18
|
created_at: new Date().toISOString(),
|
|
18
19
|
type: "systemMessage",
|
|
19
|
-
text: AutoBeSystemPromptConstant.
|
|
20
|
+
text: AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION,
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
23
|
id: v4(),
|
|
@@ -31,6 +32,16 @@ export const transformRealizeDecoratorHistories = (
|
|
|
31
32
|
"",
|
|
32
33
|
JSON.stringify(ctx.state().prisma?.schemas, null, 2),
|
|
33
34
|
"",
|
|
35
|
+
"## File Structure Example",
|
|
36
|
+
"",
|
|
37
|
+
"Please refer to the following file structure to construct appropriate import paths:",
|
|
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")}`,
|
|
44
|
+
"",
|
|
34
45
|
].join("\n"),
|
|
35
46
|
},
|
|
36
47
|
];
|
|
@@ -8,9 +8,8 @@ import { v4 } from "uuid";
|
|
|
8
8
|
|
|
9
9
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
10
10
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
11
|
-
import { IAutoBeRealizeDecoratorApplication } from "./structures/IAutoBeRealizeDecoratorApplication";
|
|
12
11
|
|
|
13
|
-
export const
|
|
12
|
+
export const transformRealizeAuthorizationCorrectHistories = (
|
|
14
13
|
ctx: AutoBeContext<ILlmSchema.Model>,
|
|
15
14
|
auth: AutoBeRealizeAuthorization,
|
|
16
15
|
templateFiles: Record<string, string>,
|
|
@@ -23,7 +22,13 @@ export const transformRealizeDecoratorCorrectHistories = (
|
|
|
23
22
|
id: v4(),
|
|
24
23
|
created_at: new Date().toISOString(),
|
|
25
24
|
type: "systemMessage",
|
|
26
|
-
text: AutoBeSystemPromptConstant.
|
|
25
|
+
text: AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: v4(),
|
|
29
|
+
created_at: new Date().toISOString(),
|
|
30
|
+
type: "systemMessage",
|
|
31
|
+
text: AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT,
|
|
27
32
|
},
|
|
28
33
|
{
|
|
29
34
|
id: v4(),
|
|
@@ -36,18 +41,21 @@ export const transformRealizeDecoratorCorrectHistories = (
|
|
|
36
41
|
`${JSON.stringify(
|
|
37
42
|
{
|
|
38
43
|
provider: {
|
|
44
|
+
location: auth.provider.location,
|
|
39
45
|
name: auth.provider.name,
|
|
40
|
-
|
|
46
|
+
content: auth.provider.content,
|
|
41
47
|
},
|
|
42
48
|
decorator: {
|
|
49
|
+
location: auth.decorator.location,
|
|
43
50
|
name: auth.decorator.name,
|
|
44
|
-
|
|
51
|
+
content: auth.decorator.content,
|
|
45
52
|
},
|
|
46
53
|
payload: {
|
|
54
|
+
location: auth.payload.location,
|
|
47
55
|
name: auth.payload.name,
|
|
48
|
-
|
|
56
|
+
content: auth.payload.content,
|
|
49
57
|
},
|
|
50
|
-
} satisfies
|
|
58
|
+
} satisfies Omit<AutoBeRealizeAuthorization, "role">,
|
|
51
59
|
null,
|
|
52
60
|
2,
|
|
53
61
|
)}`,
|
|
@@ -136,6 +136,9 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
136
136
|
});
|
|
137
137
|
if (pointer.value === null) throw new Error("Failed to modify test code.");
|
|
138
138
|
|
|
139
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
140
|
+
pointer.value.final = await compiler.typescript.beautify(pointer.value.final);
|
|
141
|
+
|
|
139
142
|
ctx.dispatch({
|
|
140
143
|
type: "testCorrect",
|
|
141
144
|
created_at: new Date().toISOString(),
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AutoBeTestScenario,
|
|
4
|
+
AutoBeTestWriteEvent,
|
|
5
|
+
IAutoBeCompiler,
|
|
6
|
+
} from "@autobe/interface";
|
|
3
7
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
4
8
|
import { IPointer } from "tstl";
|
|
5
9
|
import typia from "typia";
|
|
@@ -106,6 +110,9 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
106
110
|
ctx.usage().record(tokenUsage, ["test"]);
|
|
107
111
|
});
|
|
108
112
|
if (pointer.value === null) throw new Error("Failed to create test code.");
|
|
113
|
+
|
|
114
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
115
|
+
pointer.value.final = await compiler.typescript.beautify(pointer.value.final);
|
|
109
116
|
return pointer.value;
|
|
110
117
|
}
|
|
111
118
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAutoBeRealizeDecoratorApplication.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
-
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
4
|
-
export declare const transformRealizeDecoratorHistories: (ctx: AutoBeContext<ILlmSchema.Model>, role: string) => Array<IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage>;
|