@autobe/agent 0.13.0 → 0.14.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.
Files changed (62) hide show
  1. package/lib/AutoBeMockAgent.js +2 -1
  2. package/lib/AutoBeMockAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +7 -9
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/factory/getAutoBeGenerated.js +11 -1
  6. package/lib/factory/getAutoBeGenerated.js.map +1 -1
  7. package/lib/index.mjs +391 -236
  8. package/lib/index.mjs.map +1 -1
  9. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +1 -1
  10. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
  11. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +1 -1
  12. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  13. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +107 -110
  14. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  15. package/lib/orchestrate/interface/transformInterfaceHistories.js +10 -0
  16. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
  17. package/lib/orchestrate/realize/orchestrateRealize.js +30 -8
  18. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  19. package/lib/orchestrate/realize/{orchestrateRealizeDecorator.d.ts → orchestrateRealizeAuthorization.d.ts} +2 -2
  20. package/lib/orchestrate/realize/{orchestrateRealizeDecorator.js → orchestrateRealizeAuthorization.js} +104 -67
  21. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -0
  22. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +51 -40
  23. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
  24. package/lib/orchestrate/realize/orchestrateRealizePlanner.d.ts +11 -2
  25. package/lib/orchestrate/realize/orchestrateRealizePlanner.js +2 -1
  26. package/lib/orchestrate/realize/orchestrateRealizePlanner.js.map +1 -1
  27. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +148 -17
  28. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +10 -2
  29. package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.d.ts +4 -4
  30. package/lib/orchestrate/realize/transformRealizeCoderHistories.js +58 -11
  31. package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
  32. package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.d.ts +2 -3
  33. package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js +15 -2
  34. package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js.map +1 -1
  35. package/lib/orchestrate/realize/utils/AuthorizationFileSystem.d.ts +5 -0
  36. package/lib/orchestrate/realize/utils/AuthorizationFileSystem.js +10 -0
  37. package/lib/orchestrate/realize/utils/AuthorizationFileSystem.js.map +1 -0
  38. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +3 -0
  39. package/lib/orchestrate/realize/utils/replaceImportStatements.js +65 -0
  40. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -0
  41. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.d.ts +2 -3
  42. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +45 -24
  43. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
  44. package/package.json +5 -5
  45. package/src/AutoBeMockAgent.ts +3 -2
  46. package/src/constants/AutoBeSystemPromptConstant.ts +7 -9
  47. package/src/factory/getAutoBeGenerated.ts +20 -5
  48. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +26 -18
  49. package/src/orchestrate/interface/transformInterfaceHistories.ts +10 -0
  50. package/src/orchestrate/realize/orchestrateRealize.ts +32 -7
  51. package/src/orchestrate/realize/{orchestrateRealizeDecorator.ts → orchestrateRealizeAuthorization.ts} +90 -80
  52. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +9 -30
  53. package/src/orchestrate/realize/orchestrateRealizePlanner.ts +13 -1
  54. package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +150 -17
  55. package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +13 -2
  56. package/src/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.ts +4 -4
  57. package/src/orchestrate/realize/transformRealizeCoderHistories.ts +55 -8
  58. package/src/orchestrate/realize/transformRealizeDecoratorCorrectHistories.ts +23 -3
  59. package/src/orchestrate/realize/utils/AuthorizationFileSystem.ts +10 -0
  60. package/src/orchestrate/realize/utils/replaceImportStatements.ts +85 -0
  61. package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +58 -33
  62. package/lib/orchestrate/realize/orchestrateRealizeDecorator.js.map +0 -1
@@ -93,11 +93,26 @@ export async function getAutoBeGenerated(
93
93
 
94
94
  // REALIZE
95
95
  if (state.realize?.step === state.analyze.step)
96
- Object.assign<
97
- Record<string, string>,
98
- Record<string, string>,
99
- Record<string, string>
100
- >(ret, state.realize.files, await compiler.realize.getTemplate());
96
+ Object.assign<Record<string, string>, Record<string, string>>(ret, {
97
+ ...Object.fromEntries(
98
+ state.realize.functions.map((f) => [f.location, f.content]),
99
+ ),
100
+ ...Object.fromEntries(
101
+ state.realize.authorizations
102
+ .map((auth) => [
103
+ [auth.decorator.location, auth.decorator.content],
104
+ [auth.provider.location, auth.provider.content],
105
+ [auth.payload.location, auth.payload.content],
106
+ ])
107
+ .flat(),
108
+ ),
109
+ ...(await compiler.realize.getTemplate()),
110
+ ...(await compiler.realize.controller({
111
+ document: state.interface!.document,
112
+ functions: state.realize.functions,
113
+ authorizations: state.realize.authorizations,
114
+ })),
115
+ });
101
116
 
102
117
  // LOGGING
103
118
  Object.assign<Record<string, string>, Record<string, string>>(ret, {
@@ -119,6 +119,15 @@ async function process<Model extends ILlmSchema.Model>(
119
119
  [
120
120
  "Make API operations for below endpoints:",
121
121
  "",
122
+ "**CRITICAL INSTRUCTIONS**:",
123
+ "1. Base ALL operation descriptions on ACTUAL fields in the Prisma schema",
124
+ "2. NEVER reference fields that don't exist (e.g., deleted_at, created_by, updated_by)",
125
+ "3. For DELETE operations:",
126
+ " - Check if the entity has soft delete fields in the schema",
127
+ " - If YES: Describe soft delete behavior using those fields",
128
+ " - If NO: Describe hard delete behavior (permanent removal)",
129
+ "4. Every field mentioned in descriptions MUST exist in the Prisma schema",
130
+ "",
122
131
  "```json",
123
132
  JSON.stringify(Array.from(endpoints), null, 2),
124
133
  "```",
@@ -156,24 +165,23 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
156
165
  "GET method should not have request body. Change method, or re-design the operation.",
157
166
  value: op.requestBody,
158
167
  });
159
- op.authorizationRoles?.forEach((role, j) => {
160
- if (props.roles === null) {
161
- op.authorizationRoles = null;
162
- }
163
- if (props.roles?.find((it) => it === role) === undefined)
164
- errors.push({
165
- path: `operations[${i}].authorizationRoles[${j}]`,
166
- expected: `undefined | ${props.roles?.join(" | ")}`,
167
- description: [
168
- `Role "${role}" is not defined in the roles list.`,
169
- "",
170
- "Please select one of them below, or do not define (undefined): ",
171
- "",
172
- ...(props.roles ?? []).map((role) => `- ${role}`),
173
- ].join("\n"),
174
- value: role,
175
- });
176
- });
168
+ if (props.roles === null) {
169
+ op.authorizationRole = null;
170
+ } else if (
171
+ props.roles?.find((it) => it === op.authorizationRole) === undefined
172
+ )
173
+ errors.push({
174
+ path: `operations[${i}].authorizationRole`,
175
+ expected: `undefined | ${props.roles?.join(" | ")}`,
176
+ description: [
177
+ `Role "${op.authorizationRole}" is not defined in the roles list.`,
178
+ "",
179
+ "Please select one of them below, or do not define (undefined): ",
180
+ "",
181
+ ...(props.roles ?? []).map((role) => `- ${role}`),
182
+ ].join("\n"),
183
+ value: op.authorizationRole,
184
+ });
177
185
  });
178
186
  if (errors.length !== 0)
179
187
  return {
@@ -127,6 +127,16 @@ export const transformInterfaceHistories = (
127
127
  "You should also look at this and consider logic including membership/login and token issuance.",
128
128
  "You can use table's name to define role in operations.",
129
129
  "",
130
+ "## Critical Schema Verification Instructions",
131
+ "",
132
+ "**IMPORTANT**: When generating API operations and descriptions:",
133
+ "1. ONLY reference fields that ACTUALLY EXIST in the Prisma schema below",
134
+ "2. NEVER assume common fields like `deleted_at`, `created_by`, `updated_by`, `is_deleted` exist",
135
+ "3. For DELETE operations:",
136
+ " - If schema HAS soft delete fields (e.g., `deleted_at`), describe soft delete behavior",
137
+ " - If schema LACKS soft delete fields, describe hard delete behavior",
138
+ "4. Verify EVERY field reference against the actual schema before including in descriptions",
139
+ "",
130
140
  "## Prisma DB Schema",
131
141
  "```json",
132
142
  JSON.stringify(state.prisma.schemas),
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AutoBeAssistantMessageHistory,
3
+ AutoBeRealizeAuthorization,
3
4
  AutoBeRealizeHistory,
4
5
  } from "@autobe/interface";
5
6
  import { ILlmSchema } from "@samchon/openapi";
@@ -7,7 +8,7 @@ import { v4 } from "uuid";
7
8
 
8
9
  import { AutoBeContext } from "../../context/AutoBeContext";
9
10
  import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
10
- import { orchestrateRealizeDecorator } from "./orchestrateRealizeDecorator";
11
+ import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
11
12
  import { writeCodeUntilCompilePassed } from "./writeCodeUntilCompilePassed";
12
13
 
13
14
  export const orchestrateRealize =
@@ -28,11 +29,32 @@ export const orchestrateRealize =
28
29
  step: ctx.state().test?.step ?? 0,
29
30
  });
30
31
 
31
- const decorators = await orchestrateRealizeDecorator(ctx);
32
- decorators;
32
+ const decorators: AutoBeRealizeAuthorization[] =
33
+ await orchestrateRealizeAuthorization(ctx);
34
+ const files = await writeCodeUntilCompilePassed(ctx, ops, decorators, 2);
33
35
 
34
- await writeCodeUntilCompilePassed(ctx, ops, 3);
35
36
  const now = new Date().toISOString();
37
+ const realize = ctx.state().realize;
38
+ if (realize !== null) {
39
+ realize.functions = files;
40
+ } else {
41
+ const history = (ctx.state().realize = {
42
+ type: "realize",
43
+ compiled: {
44
+ type: "success",
45
+ },
46
+ functions: files,
47
+ completed_at: now,
48
+ created_at: now,
49
+ id: v4(),
50
+ reason: props.reason,
51
+ step: ctx.state().analyze?.step ?? 0,
52
+ authorizations: ctx.state().realize?.authorizations ?? [],
53
+ } satisfies AutoBeRealizeHistory);
54
+
55
+ ctx.histories().push(history);
56
+ }
57
+
36
58
  ctx.dispatch({
37
59
  type: "assistantMessage",
38
60
  text: "Any codes can not be generated.",
@@ -41,12 +63,15 @@ export const orchestrateRealize =
41
63
 
42
64
  return {
43
65
  type: "realize",
44
- compiled: 1 as any,
45
- files: {},
66
+ compiled: {
67
+ type: "success",
68
+ },
69
+ functions: files,
46
70
  completed_at: now,
47
71
  created_at: now,
48
72
  id: v4(),
49
73
  reason: props.reason,
50
- step: ctx.state().test?.step ?? 0,
74
+ step: ctx.state().analyze?.step ?? 0,
75
+ authorizations: ctx.state().realize?.authorizations ?? [],
51
76
  };
52
77
  };
@@ -1,7 +1,8 @@
1
1
  import { IAgenticaController, MicroAgentica } from "@agentica/core";
2
2
  import {
3
- AutoBeRealizeDecoratorEvent,
3
+ AutoBeRealizeAuthorization,
4
4
  IAutoBeCompiler,
5
+ IAutoBeTypeScriptCompileResult,
5
6
  } from "@autobe/interface";
6
7
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
7
8
  import fs from "fs/promises";
@@ -15,6 +16,7 @@ import { enforceToolCall } from "../../utils/enforceToolCall";
15
16
  import { IAutoBeRealizeDecoratorApplication } from "./structures/IAutoBeRealizeDecoratorApplication";
16
17
  import { transformRealizeDecoratorHistories } from "./transformRealizeDecorator";
17
18
  import { transformRealizeDecoratorCorrectHistories } from "./transformRealizeDecoratorCorrectHistories";
19
+ import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
18
20
 
19
21
  /**
20
22
  * 1. Create decorator and its parameters. and design the Authorization Provider.
@@ -22,19 +24,15 @@ import { transformRealizeDecoratorCorrectHistories } from "./transformRealizeDec
22
24
  *
23
25
  * @param ctx
24
26
  */
25
- export async function orchestrateRealizeDecorator<
27
+ export async function orchestrateRealizeAuthorization<
26
28
  Model extends ILlmSchema.Model,
27
- >(
28
- ctx: AutoBeContext<Model>,
29
- ): Promise<IAutoBeRealizeDecoratorApplication.IProps[]> {
29
+ >(ctx: AutoBeContext<Model>): Promise<AutoBeRealizeAuthorization[]> {
30
30
  const roles =
31
31
  ctx
32
32
  .state()
33
33
  .interface?.document.components.authorization?.map((auth) => auth.name) ??
34
34
  [];
35
35
 
36
- const decorators: IAutoBeRealizeDecoratorApplication.IProps[] = [];
37
-
38
36
  let completed = 0;
39
37
 
40
38
  const templateFiles = {
@@ -54,49 +52,45 @@ export async function orchestrateRealizeDecorator<
54
52
  ),
55
53
  };
56
54
 
57
- const files: Record<string, string> = {
58
- ...templateFiles,
59
- };
60
-
61
- await Promise.all(
55
+ ctx.dispatch({
56
+ type: "realizeAuthorizationStart",
57
+ step: ctx.state().test?.step ?? 0,
58
+ created_at: new Date().toISOString(),
59
+ });
60
+ const authorizations: AutoBeRealizeAuthorization[] = await Promise.all(
62
61
  roles.map(async (role) => {
63
- const decorator: IAutoBeRealizeDecoratorApplication.IProps =
64
- await process(ctx, role, templateFiles);
65
-
66
- files[`src/decorators/${decorator.decorator.name}.ts`] =
67
- decorator.decorator.code;
68
- files[`src/authentications/${decorator.provider.name}.ts`] =
69
- decorator.provider.code;
70
- files[`src/authentications/types/${decorator.decoratorType.name}.ts`] =
71
- decorator.decoratorType.code;
72
-
73
- decorators.push(decorator);
74
-
75
- const events: AutoBeRealizeDecoratorEvent = {
76
- type: "realizeDecorator",
62
+ const authorization: AutoBeRealizeAuthorization = await process(
63
+ ctx,
64
+ role,
65
+ templateFiles,
66
+ );
67
+ ctx.dispatch({
68
+ type: "realizeAuthorizationWrite",
77
69
  created_at: new Date().toISOString(),
78
- files,
70
+ authorization: authorization,
79
71
  completed: ++completed,
80
72
  total: roles.length,
81
73
  step: ctx.state().test?.step ?? 0,
82
- };
83
-
84
- ctx.dispatch(events);
74
+ });
75
+ return authorization;
85
76
  }),
86
77
  );
87
-
88
- return decorators;
78
+ ctx.dispatch({
79
+ type: "realizeAuthorizationComplete",
80
+ created_at: new Date().toISOString(),
81
+ step: ctx.state().test?.step ?? 0,
82
+ });
83
+ return authorizations;
89
84
  }
90
85
 
91
86
  async function process<Model extends ILlmSchema.Model>(
92
87
  ctx: AutoBeContext<Model>,
93
88
  role: string,
94
89
  templateFiles: Record<string, string>,
95
- ): Promise<IAutoBeRealizeDecoratorApplication.IProps> {
90
+ ): Promise<AutoBeRealizeAuthorization> {
96
91
  const pointer: IPointer<IAutoBeRealizeDecoratorApplication.IProps | null> = {
97
92
  value: null,
98
93
  };
99
-
100
94
  const agentica: MicroAgentica<Model> = new MicroAgentica({
101
95
  model: ctx.model,
102
96
  vendor: ctx.vendor,
@@ -116,7 +110,6 @@ async function process<Model extends ILlmSchema.Model>(
116
110
  }),
117
111
  ],
118
112
  });
119
-
120
113
  enforceToolCall(agentica);
121
114
 
122
115
  await agentica
@@ -125,63 +118,73 @@ async function process<Model extends ILlmSchema.Model>(
125
118
  const tokenUsage = agentica.getTokenUsage();
126
119
  ctx.usage().record(tokenUsage, ["realize"]);
127
120
  });
128
-
129
121
  if (pointer.value === null) throw new Error("Failed to create decorator.");
130
122
 
123
+ const authorization: AutoBeRealizeAuthorization = {
124
+ role,
125
+ decorator: {
126
+ location: AuthorizationFileSystem.decoratorPath(
127
+ pointer.value.decorator.name,
128
+ ),
129
+ name: pointer.value.decorator.name,
130
+ content: pointer.value.decorator.code,
131
+ },
132
+ payload: {
133
+ location: AuthorizationFileSystem.payloadPath(pointer.value.payload.name),
134
+ name: pointer.value.payload.name,
135
+ content: pointer.value.payload.code,
136
+ },
137
+ provider: {
138
+ location: AuthorizationFileSystem.providerPath(
139
+ pointer.value.provider.name,
140
+ ),
141
+ name: pointer.value.provider.name,
142
+ content: pointer.value.provider.code,
143
+ },
144
+ };
131
145
  const compiled = ctx.state().prisma?.compiled;
132
-
133
146
  const prismaClients: Record<string, string> =
134
147
  compiled?.type === "success" ? compiled.nodeModules : {};
135
-
136
- return await correctDecorator(
137
- ctx,
138
- pointer.value,
139
- prismaClients,
140
- templateFiles,
141
- );
148
+ return correctDecorator(ctx, authorization, prismaClients, templateFiles);
142
149
  }
143
150
 
144
151
  async function correctDecorator<Model extends ILlmSchema.Model>(
145
152
  ctx: AutoBeContext<Model>,
146
- result: IAutoBeRealizeDecoratorApplication.IProps,
153
+ auth: AutoBeRealizeAuthorization,
147
154
  prismaClients: Record<string, string>,
148
155
  templateFiles: Record<string, string>,
149
156
  life: number = 4,
150
- ): Promise<IAutoBeRealizeDecoratorApplication.IProps> {
157
+ ): Promise<AutoBeRealizeAuthorization> {
151
158
  // Check Compile
152
159
  const files = {
153
160
  ...templateFiles,
154
161
  ...prismaClients,
155
- [`src/decorators/${result.decorator.name}.ts`]: result.decorator.code,
156
- [`src/authentications/${result.provider.name}.ts`]: result.provider.code,
157
- [`src/authentications/types/${result.decoratorType.name}.ts`]:
158
- result.decoratorType.code,
162
+ [auth.decorator.location]: auth.decorator.content,
163
+ [auth.payload.location]: auth.payload.content,
164
+ [auth.provider.location]: auth.provider.content,
159
165
  };
160
166
 
161
167
  const compiler: IAutoBeCompiler = await ctx.compiler();
162
-
163
- const compiled = await compiler.typescript.compile({
164
- files,
165
- });
166
-
168
+ const result: IAutoBeTypeScriptCompileResult =
169
+ await compiler.typescript.compile({
170
+ files,
171
+ });
167
172
  ctx.dispatch({
168
- type: "realizeDecoratorValidate",
173
+ type: "realizeAuthorizationValidate",
169
174
  created_at: new Date().toISOString(),
170
- result: compiled,
171
- files,
175
+ result,
176
+ authorization: auth,
172
177
  step: ctx.state().test?.step ?? 0,
173
178
  });
174
-
175
- if (compiled.type === "success") {
176
- return result;
177
- } else if (compiled.type === "exception" || life === 0) {
178
- return result;
179
+ if (result.type === "success") {
180
+ return auth;
181
+ } else if (result.type === "exception" || life === 0) {
182
+ return auth;
179
183
  }
180
184
 
181
185
  const pointer: IPointer<IAutoBeRealizeDecoratorApplication.IProps | null> = {
182
186
  value: null,
183
187
  };
184
-
185
188
  const agentica: MicroAgentica<Model> = new MicroAgentica({
186
189
  model: ctx.model,
187
190
  vendor: ctx.vendor,
@@ -193,9 +196,9 @@ async function correctDecorator<Model extends ILlmSchema.Model>(
193
196
  },
194
197
  histories: transformRealizeDecoratorCorrectHistories(
195
198
  ctx,
196
- result,
199
+ auth,
197
200
  templateFiles,
198
- compiled.diagnostics,
201
+ result.diagnostics,
199
202
  ),
200
203
  controllers: [
201
204
  createApplication({
@@ -217,27 +220,34 @@ async function correctDecorator<Model extends ILlmSchema.Model>(
217
220
 
218
221
  if (pointer.value === null) throw new Error("Failed to correct decorator.");
219
222
 
220
- const correctedFiles: Record<string, string> = {
221
- ...files,
222
- [`src/decorators/${pointer.value.decorator.name}.ts`]:
223
- pointer.value.decorator.code,
224
- [`src/authentications/${pointer.value.provider.name}.ts`]:
225
- pointer.value.provider.code,
226
- [`src/authentications/types/${pointer.value.decoratorType.name}.ts`]:
227
- pointer.value.decoratorType.code,
223
+ const corrected: AutoBeRealizeAuthorization = {
224
+ role: auth.role,
225
+ decorator: {
226
+ location: auth.decorator.location,
227
+ name: pointer.value.decorator.name,
228
+ content: pointer.value.decorator.code,
229
+ },
230
+ payload: {
231
+ location: auth.payload.location,
232
+ name: pointer.value.payload.name,
233
+ content: pointer.value.payload.code,
234
+ },
235
+ provider: {
236
+ location: auth.provider.location,
237
+ name: pointer.value.provider.name,
238
+ content: pointer.value.provider.code,
239
+ },
228
240
  };
229
-
230
241
  ctx.dispatch({
231
- type: "realizeDecoratorCorrect",
242
+ type: "realizeAuthorizationCorrect",
232
243
  created_at: new Date().toISOString(),
233
- files: correctedFiles,
234
- result: compiled,
244
+ authorization: corrected,
245
+ result: result,
235
246
  step: ctx.state().test?.step ?? 0,
236
247
  });
237
-
238
248
  return await correctDecorator(
239
249
  ctx,
240
- pointer.value,
250
+ corrected,
241
251
  prismaClients,
242
252
  templateFiles,
243
253
  life - 1,
@@ -1,7 +1,6 @@
1
1
  import { IAgenticaController, MicroAgentica } from "@agentica/core";
2
2
  import {
3
3
  AutoBeOpenApi,
4
- IAutoBeCompiler,
5
4
  IAutoBeTypeScriptCompileResult,
6
5
  } from "@autobe/interface";
7
6
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
@@ -21,6 +20,7 @@ import { RealizePlannerOutput } from "./orchestrateRealizePlanner";
21
20
  import { IAutoBeRealizeCoderApplication } from "./structures/IAutoBeRealizeCoderApplication";
22
21
  import { FAILED } from "./structures/IAutoBeRealizeFailedSymbol";
23
22
  import { transformRealizeCoderHistories } from "./transformRealizeCoderHistories";
23
+ import { replaceImportStatements } from "./utils/replaceImportStatements";
24
24
 
25
25
  /**
26
26
  * Generates a TypeScript function implementation based on the given plan.
@@ -55,6 +55,7 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
55
55
  | FAILED
56
56
  > => {
57
57
  total;
58
+
58
59
  const artifacts: IAutoBeTestScenarioArtifacts =
59
60
  await getTestScenarioArtifacts(ctx, {
60
61
  endpoint: {
@@ -126,43 +127,21 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
126
127
 
127
128
  pointer.value.implementationCode = await replaceImportStatements(ctx)(
128
129
  pointer.value.implementationCode,
130
+ props.decoratorEvent?.payload.name,
129
131
  );
130
132
 
133
+ pointer.value.implementationCode =
134
+ pointer.value.implementationCode.replaceAll(
135
+ "typia.tags.assert",
136
+ "typia.assert",
137
+ );
138
+
131
139
  return {
132
140
  ...pointer.value,
133
141
  filename: `src/providers/${props.functionName}.ts`,
134
142
  };
135
143
  };
136
144
 
137
- function replaceImportStatements<Model extends ILlmSchema.Model>(
138
- ctx: AutoBeContext<Model>,
139
- ) {
140
- return async function (code: string) {
141
- const compiler: IAutoBeCompiler = await ctx.compiler();
142
- code = await compiler.typescript.beautify(code);
143
- code = code
144
- .replaceAll('import { MyGlobal } from "../MyGlobal";', "")
145
- .replaceAll('import typia, { tags } from "typia";', "")
146
- .replaceAll('import { tags } from "typia";', "")
147
- .replaceAll('import { tags, typia } from "typia";', "")
148
- .replaceAll('import typia from "typia";', "")
149
- .replaceAll('import { Prisma } from "@prisma/client";', "")
150
- .replaceAll('import { jwtDecode } from "./jwtDecode"', "")
151
- .replaceAll('import { v4 } from "uuid"', "");
152
- code = [
153
- 'import { MyGlobal } from "../MyGlobal";',
154
- 'import typia, { tags } from "typia";',
155
- 'import { Prisma } from "@prisma/client";',
156
- 'import { jwtDecode } from "./jwtDecode";',
157
- 'import { v4 } from "uuid";',
158
- "",
159
- code,
160
- ].join("\n");
161
-
162
- return code;
163
- };
164
- }
165
-
166
145
  function createApplication<Model extends ILlmSchema.Model>(props: {
167
146
  model: Model;
168
147
  build: (next: IAutoBeRealizeCoderApplication.IProps) => void;
@@ -1,4 +1,4 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
2
  import { ILlmSchema } from "@samchon/openapi";
3
3
 
4
4
  import { AutoBeContext } from "../../context/AutoBeContext";
@@ -65,6 +65,16 @@ export interface RealizePlannerOutput {
65
65
  * conditions. Used as a basis for TDD-style automated test generation.
66
66
  */
67
67
  testScenarios: string[];
68
+
69
+ /**
70
+ * Optional decorator event for customizing code generation behavior.
71
+ *
72
+ * Provides additional metadata or instructions that can modify how the
73
+ * function implementation is generated. Can include custom annotations,
74
+ * middleware configurations, or special handling directives that affect the
75
+ * final code output.
76
+ */
77
+ decoratorEvent?: AutoBeRealizeAuthorization;
68
78
  }
69
79
 
70
80
  /**
@@ -89,6 +99,7 @@ export interface RealizePlannerOutput {
89
99
  export const orchestrateRealizePlanner = async <Model extends ILlmSchema.Model>(
90
100
  ctx: AutoBeContext<Model>,
91
101
  operation: AutoBeOpenApi.IOperation,
102
+ authorization?: AutoBeRealizeAuthorization,
92
103
  ): Promise<RealizePlannerOutput> => {
93
104
  const testScenarios =
94
105
  ctx
@@ -111,5 +122,6 @@ export const orchestrateRealizePlanner = async <Model extends ILlmSchema.Model>(
111
122
  .replaceAll("-", "_")
112
123
  .replaceAll("{", "$")
113
124
  .replaceAll("}", "")}`,
125
+ decoratorEvent: authorization,
114
126
  } satisfies RealizePlannerOutput;
115
127
  };