@autobe/agent 0.20.0 → 0.21.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.
Files changed (97) hide show
  1. package/lib/agent/src/AutoBeMockAgent.js +1 -0
  2. package/lib/agent/src/AutoBeMockAgent.js.map +1 -1
  3. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +10 -9
  4. package/lib/agent/src/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/agent/src/context/AutoBeContext.d.ts +2 -2
  6. package/lib/agent/src/factory/createAutoBeContext.js +3 -1
  7. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  8. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  9. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  10. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.d.ts +4 -0
  11. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +33 -0
  12. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -0
  13. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  14. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  15. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
  16. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  17. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  18. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  19. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  20. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  21. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +6 -6
  22. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +5 -3
  23. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  24. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +10 -0
  25. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +365 -0
  26. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js.map +1 -0
  27. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +6 -6
  28. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +1633 -1198
  29. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  30. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.d.ts +60 -0
  31. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.js +3 -0
  32. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.js.map +1 -0
  33. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +40 -0
  34. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +1 -1
  35. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  36. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +1 -1
  37. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  38. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +4 -4
  39. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js +2 -2
  40. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
  41. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +4 -4
  42. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +2 -2
  43. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +7 -2
  44. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +1 -1
  45. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  46. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +3 -1
  47. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +41 -25
  48. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  49. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +1 -1
  50. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  51. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.d.ts +3 -1
  52. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +118 -96
  53. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  54. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +1 -1
  55. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  56. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +10 -10
  57. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +1 -1
  58. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  59. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +28 -1
  60. package/lib/constants/AutoBeSystemPromptConstant.d.ts +10 -9
  61. package/lib/context/AutoBeContext.d.ts +2 -2
  62. package/lib/index.mjs +2315 -1526
  63. package/lib/index.mjs.map +1 -1
  64. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.d.ts +4 -0
  65. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +10 -0
  66. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.d.ts +60 -0
  67. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +40 -0
  68. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +2 -2
  69. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +7 -2
  70. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +3 -1
  71. package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +3 -1
  72. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +28 -1
  73. package/package.json +6 -6
  74. package/src/AutoBeMockAgent.ts +1 -0
  75. package/src/constants/AutoBeSystemPromptConstant.ts +10 -9
  76. package/src/context/AutoBeContext.ts +2 -0
  77. package/src/factory/createAutoBeContext.ts +2 -1
  78. package/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.ts +39 -0
  79. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +5 -1
  80. package/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.ts +95 -0
  81. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +118 -10
  82. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.ts +65 -0
  83. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +42 -0
  84. package/src/orchestrate/realize/orchestrateRealizeScenario.ts +7 -3
  85. package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts +6 -2
  86. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +10 -5
  87. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +2 -0
  88. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +46 -34
  89. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +24 -4
  90. package/src/orchestrate/test/orchestrateTestCorrect.ts +5 -1
  91. package/src/orchestrate/test/orchestrateTestWrite.ts +1 -1
  92. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +28 -1
  93. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.d.ts +0 -3
  94. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js +0 -75
  95. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js.map +0 -1
  96. package/lib/orchestrate/test/histories/transformTestHistories.d.ts +0 -3
  97. package/src/orchestrate/test/histories/transformTestHistories.ts +0 -78
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  IAgenticaVendor,
3
3
  IMicroAgenticaHistoryJson,
4
+ MicroAgentica,
4
5
  MicroAgenticaHistory,
5
6
  } from "@agentica/core";
6
7
  import {
@@ -49,6 +50,7 @@ export interface AutoBeContext<Model extends ILlmSchema.Model> {
49
50
  // factories
50
51
  conversate(
51
52
  props: AutoBeContext.IConversate<Model>,
53
+ closure?: (agent: MicroAgentica<Model>) => void,
52
54
  ): Promise<AutoBeContext.IResult<Model>>;
53
55
  }
54
56
  export namespace AutoBeContext {
@@ -63,7 +63,7 @@ export const createAutoBeContext = <Model extends ILlmSchema.Model>(props: {
63
63
  setTimeout(() => props.dispatch(message).catch(() => {}));
64
64
  return message;
65
65
  },
66
- conversate: async (next) => {
66
+ conversate: async (next, closure) => {
67
67
  const execute = async (): Promise<AutoBeContext.IResult<Model>> => {
68
68
  const agent: MicroAgentica<Model> = new MicroAgentica<Model>({
69
69
  model: props.model,
@@ -118,6 +118,7 @@ export const createAutoBeContext = <Model extends ILlmSchema.Model>(props: {
118
118
  })
119
119
  .catch(() => {});
120
120
  });
121
+ if (closure) closure(agent);
121
122
 
122
123
  const histories: MicroAgenticaHistory<Model>[] = await agent.conversate(
123
124
  next.message,
@@ -0,0 +1,39 @@
1
+ import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { AutoBeOpenApi } from "@autobe/interface";
3
+ import { v4 } from "uuid";
4
+
5
+ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
6
+ import { AutoBeState } from "../../../context/AutoBeState";
7
+ import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
8
+
9
+ export const transformInterfaceEndpointsReviewHistories = (
10
+ state: AutoBeState,
11
+ endpoints: AutoBeOpenApi.IEndpoint[],
12
+ ): Array<
13
+ IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
14
+ > => [
15
+ {
16
+ type: "systemMessage",
17
+ id: v4(),
18
+ created_at: new Date().toISOString(),
19
+ text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
20
+ },
21
+ ...transformInterfaceAssetHistories(state),
22
+ {
23
+ id: v4(),
24
+ type: "assistantMessage",
25
+ text: [
26
+ "Below are endpoints generated by your request.",
27
+ "```json",
28
+ JSON.stringify(endpoints),
29
+ "```",
30
+ ].join("\n"),
31
+ created_at: new Date().toISOString(),
32
+ },
33
+ {
34
+ id: v4(),
35
+ type: "systemMessage",
36
+ text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINTS_REVIEW,
37
+ created_at: new Date().toISOString(),
38
+ },
39
+ ];
@@ -14,6 +14,7 @@ import { AutoBeContext } from "../../context/AutoBeContext";
14
14
  import { assertSchemaModel } from "../../context/assertSchemaModel";
15
15
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
16
16
  import { transformInterfaceEndpointHistories } from "./histories/transformInterfaceEndpointHistories";
17
+ import { orchestrateInterfaceEndpointsReview } from "./orchestrateInterfaceEndpointsReview";
17
18
  import { IAutoBeInterfaceEndpointApplication } from "./structures/IAutoBeInterfaceEndpointApplication";
18
19
  import { OpenApiEndpointComparator } from "./utils/OpenApiEndpointComparator";
19
20
 
@@ -37,11 +38,14 @@ export async function orchestrateInterfaceEndpoints<
37
38
  ),
38
39
  )
39
40
  ).flat();
40
- return new HashSet(
41
+
42
+ const deduplicated: AutoBeOpenApi.IEndpoint[] = new HashSet(
41
43
  endpoints,
42
44
  OpenApiEndpointComparator.hashCode,
43
45
  OpenApiEndpointComparator.equals,
44
46
  ).toJSON();
47
+
48
+ return orchestrateInterfaceEndpointsReview(ctx, deduplicated);
45
49
  }
46
50
 
47
51
  async function process<Model extends ILlmSchema.Model>(
@@ -0,0 +1,95 @@
1
+ import { IAgenticaController } from "@agentica/core";
2
+ import { AutoBeOpenApi } from "@autobe/interface";
3
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
4
+ import { IPointer } from "tstl";
5
+ import typia from "typia";
6
+ import { v7 } from "uuid";
7
+
8
+ import { AutoBeContext } from "../../context/AutoBeContext";
9
+ import { assertSchemaModel } from "../../context/assertSchemaModel";
10
+ import { transformInterfaceEndpointsReviewHistories } from "./histories/transformInterfaceEndpointsReviewHistories";
11
+ import { IAutoBeInterfaceEndpointsReviewApplication } from "./structures/IAutoBeInterfaceEndpointsReviewApplication";
12
+
13
+ export async function orchestrateInterfaceEndpointsReview<
14
+ Model extends ILlmSchema.Model,
15
+ >(
16
+ ctx: AutoBeContext<Model>,
17
+ endpoints: AutoBeOpenApi.IEndpoint[],
18
+ message: string = `Review the generated endpoints`,
19
+ ): Promise<AutoBeOpenApi.IEndpoint[]> {
20
+ const pointer: IPointer<IAutoBeInterfaceEndpointsReviewApplication.IProps | null> =
21
+ {
22
+ value: null,
23
+ };
24
+
25
+ const { tokenUsage } = await ctx.conversate({
26
+ source: "interfaceEndpointsReview",
27
+ histories: transformInterfaceEndpointsReviewHistories(
28
+ ctx.state(),
29
+ endpoints,
30
+ ),
31
+ controller: createController({
32
+ model: ctx.model,
33
+ build: (props) => {
34
+ pointer.value = props;
35
+ },
36
+ }),
37
+ enforceFunctionCall: true,
38
+ message,
39
+ });
40
+
41
+ if (pointer.value === null) {
42
+ return endpoints;
43
+ }
44
+
45
+ const response = pointer.value?.endpoints ?? [];
46
+
47
+ ctx.dispatch({
48
+ id: v7(),
49
+ type: "interfaceEndpointsReview",
50
+ endpoints,
51
+ content: response,
52
+ created_at: new Date().toISOString(),
53
+ review: pointer.value?.review,
54
+ step: ctx.state().analyze?.step ?? 0,
55
+ tokenUsage,
56
+ });
57
+
58
+ return response;
59
+ }
60
+
61
+ export function createController<Model extends ILlmSchema.Model>(props: {
62
+ model: Model;
63
+ build: (props: IAutoBeInterfaceEndpointsReviewApplication.IProps) => void;
64
+ }): IAgenticaController.IClass<Model> {
65
+ assertSchemaModel(props.model);
66
+
67
+ const application: ILlmApplication<Model> = collection[
68
+ props.model
69
+ ] satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
70
+ return {
71
+ protocol: "class",
72
+ name: "interface",
73
+ application,
74
+ execute: {
75
+ reviewEndpoints: (next) => {
76
+ props.build(next);
77
+ },
78
+ } satisfies IAutoBeInterfaceEndpointsReviewApplication,
79
+ };
80
+ }
81
+
82
+ const claude = typia.llm.application<
83
+ IAutoBeInterfaceEndpointsReviewApplication,
84
+ "claude"
85
+ >();
86
+ const collection = {
87
+ chatgpt: typia.llm.application<
88
+ IAutoBeInterfaceEndpointsReviewApplication,
89
+ "chatgpt"
90
+ >(),
91
+ claude,
92
+ llama: claude,
93
+ deepseek: claude,
94
+ "3.1": claude,
95
+ };
@@ -2,9 +2,10 @@ import { IAgenticaController } from "@agentica/core";
2
2
  import {
3
3
  AutoBeInterfaceOperationsReviewEvent,
4
4
  AutoBeOpenApi,
5
+ AutoBePrisma,
5
6
  AutoBeProgressEventBase,
6
7
  } from "@autobe/interface";
7
- import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
8
+ import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
8
9
  import { IPointer } from "tstl";
9
10
  import typia from "typia";
10
11
  import { v7 } from "uuid";
@@ -21,6 +22,7 @@ export async function orchestrateInterfaceOperationsReview<
21
22
  progress: AutoBeProgressEventBase,
22
23
  ): Promise<AutoBeOpenApi.IOperation[]> {
23
24
  try {
25
+ const files: AutoBePrisma.IFile[] = ctx.state().prisma?.result.data.files!;
24
26
  const pointer: IPointer<IAutoBeInterfaceOperationsReviewApplication.IProps | null> =
25
27
  {
26
28
  value: null,
@@ -30,6 +32,7 @@ export async function orchestrateInterfaceOperationsReview<
30
32
  histories: transformInterfaceOperationsReviewHistories(ctx, operations),
31
33
  controller: createReviewController({
32
34
  model: ctx.model,
35
+ prismaSchemas: files,
33
36
  build: (next: IAutoBeInterfaceOperationsReviewApplication.IProps) => {
34
37
  pointer.value = next;
35
38
  },
@@ -73,11 +76,102 @@ export async function orchestrateInterfaceOperationsReview<
73
76
 
74
77
  function createReviewController<Model extends ILlmSchema.Model>(props: {
75
78
  model: Model;
79
+ prismaSchemas: AutoBePrisma.IFile[];
76
80
  build: (reviews: IAutoBeInterfaceOperationsReviewApplication.IProps) => void;
77
81
  }): IAgenticaController.IClass<Model> {
82
+ const validate = (
83
+ next: unknown,
84
+ ): IValidation<IAutoBeInterfaceOperationsReviewApplication.IProps> => {
85
+ const result: IValidation<IAutoBeInterfaceOperationsReviewApplication.IProps> =
86
+ typia.validate<IAutoBeInterfaceOperationsReviewApplication.IProps>(next);
87
+ if (result.success === false) return result;
88
+ const errors: IValidation.IError[] = [];
89
+
90
+ const models: AutoBePrisma.IModel[] = props.prismaSchemas.flatMap(
91
+ (schema) => schema.models,
92
+ );
93
+
94
+ result.data.content.forEach((op, index) => {
95
+ // Check if summary or description mentions soft delete
96
+ const mentionsSoftDelete =
97
+ (op.summary && /soft[\s-]?delet/i.test(op.summary)) ||
98
+ (op.description && /soft[\s-]?delet/i.test(op.description));
99
+
100
+ if (op.method === "delete") {
101
+ const model = models.find((model) => model.name === op.model_name);
102
+
103
+ if (mentionsSoftDelete) {
104
+ // If soft delete is mentioned but no soft_delete_column is specified
105
+ if (!op.soft_delete_column) {
106
+ // Check if any soft-delete capable column exists in the model
107
+ const hasSoftDeleteCapableColumn = model?.plainFields.some(
108
+ (field) =>
109
+ /delete|deleted|deleted_at|deletedAt|is_deleted|isDeleted/i.test(
110
+ field.name,
111
+ ),
112
+ );
113
+
114
+ if (hasSoftDeleteCapableColumn) {
115
+ errors.push({
116
+ expected: `Soft delete column to be specified or summary/description to not mention soft delete`,
117
+ value: "null",
118
+ description: `Mismatch: Operation mentions soft delete but soft_delete_column is not specified, while model has soft-delete capable columns`,
119
+ path: `$input.content[${index}].soft_delete_column`,
120
+ });
121
+ } else {
122
+ errors.push({
123
+ expected: `Summary/description to not mention soft delete when model lacks soft-delete capability`,
124
+ value: `${op.summary || ""} ${op.description || ""}`,
125
+ description: `Mismatch: Operation mentions soft delete but model '${op.model_name}' has no soft-delete capable columns`,
126
+ path: `$input.content[${index}].summary || $input.content[${index}].description`,
127
+ });
128
+ }
129
+ } else {
130
+ // If soft_delete_column is specified, check if it exists in the model
131
+ const column = model?.plainFields.find(
132
+ (el) => el.name === op.soft_delete_column,
133
+ );
134
+
135
+ if (!column) {
136
+ errors.push({
137
+ expected: `Field '${op.soft_delete_column}' to exist in model or operation to not mention soft delete`,
138
+ value: "undefined",
139
+ description: `Mismatch: Either the field '${op.soft_delete_column}' should exist in model '${op.model_name}', or the operation should not mention soft delete`,
140
+ path: `$input.content[${index}].soft_delete_column || $input.content[${index}].summary || $input.content[${index}].description`,
141
+ });
142
+ }
143
+ }
144
+ }
145
+
146
+ // Also check if soft_delete_column is specified without mentioning soft delete
147
+ if (op.soft_delete_column && !mentionsSoftDelete) {
148
+ errors.push({
149
+ expected: `Consistency between soft_delete_column and operation description`,
150
+ value: `soft_delete_column: ${op.soft_delete_column}`,
151
+ description: `Mismatch: soft_delete_column is specified but soft delete is not mentioned in summary/description`,
152
+ path: `$input.content[${index}]`,
153
+ });
154
+ }
155
+ }
156
+ });
157
+
158
+ // not implemented
159
+ if (errors.length !== 0) {
160
+ console.log(JSON.stringify(errors, null, 2));
161
+ return {
162
+ success: false,
163
+ errors,
164
+ data: next,
165
+ };
166
+ }
167
+ return result;
168
+ };
169
+
78
170
  const application: ILlmApplication<Model> = collection[
79
171
  props.model === "chatgpt" ? "chatgpt" : "claude"
80
- ] satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
172
+ ](
173
+ validate,
174
+ ) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
81
175
 
82
176
  return {
83
177
  protocol: "class",
@@ -92,12 +186,26 @@ function createReviewController<Model extends ILlmSchema.Model>(props: {
92
186
  }
93
187
 
94
188
  const collection = {
95
- chatgpt: typia.llm.application<
96
- IAutoBeInterfaceOperationsReviewApplication,
97
- "chatgpt"
98
- >(),
99
- claude: typia.llm.application<
100
- IAutoBeInterfaceOperationsReviewApplication,
101
- "claude"
102
- >(),
189
+ chatgpt: (validate: Validator) =>
190
+ typia.llm.application<
191
+ IAutoBeInterfaceOperationsReviewApplication,
192
+ "chatgpt"
193
+ >({
194
+ validate: {
195
+ reviewOperations: validate,
196
+ },
197
+ }),
198
+ claude: (validate: Validator) =>
199
+ typia.llm.application<
200
+ IAutoBeInterfaceOperationsReviewApplication,
201
+ "claude"
202
+ >({
203
+ validate: {
204
+ reviewOperations: validate,
205
+ },
206
+ }),
103
207
  };
208
+
209
+ type Validator = (
210
+ input: unknown,
211
+ ) => IValidation<IAutoBeInterfaceOperationsReviewApplication.IProps>;
@@ -0,0 +1,65 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+
3
+ /**
4
+ * Interface for reviewing and refining API endpoints through holistic analysis.
5
+ *
6
+ * This application performs comprehensive review of all endpoints generated
7
+ * through divide-and-conquer strategy, ensuring consistency, eliminating
8
+ * redundancy, and preventing over-engineering across the entire API surface.
9
+ */
10
+ export interface IAutoBeInterfaceEndpointsReviewApplication {
11
+ /**
12
+ * Reviews and refines the complete collection of API endpoints.
13
+ *
14
+ * This method consolidates all endpoints generated independently by different
15
+ * groups and performs holistic review to:
16
+ * - Ensure naming consistency across all endpoints
17
+ * - Remove duplicate or overlapping endpoints
18
+ * - Eliminate over-engineered solutions
19
+ * - Standardize path structures and HTTP methods
20
+ * - Verify REST API design principles
21
+ *
22
+ * The review process examines the entire API as a cohesive system rather
23
+ * than individual endpoints, ensuring the final API is intuitive, maintainable,
24
+ * and follows best practices.
25
+ *
26
+ * @param next - The review results and refined endpoint collection
27
+ */
28
+ reviewEndpoints(
29
+ next: IAutoBeInterfaceEndpointsReviewApplication.IProps,
30
+ ): void;
31
+ }
32
+
33
+ export namespace IAutoBeInterfaceEndpointsReviewApplication {
34
+ export interface IProps {
35
+ /**
36
+ * Comprehensive review analysis of all collected endpoints.
37
+ *
38
+ * Contains detailed findings from the holistic review including:
39
+ * - Identified inconsistencies in naming conventions
40
+ * - Duplicate endpoints that serve the same purpose
41
+ * - Over-engineered solutions that add unnecessary complexity
42
+ * - Violations of REST API design principles
43
+ * - Recommendations for improvement and standardization
44
+ *
45
+ * The review provides actionable feedback for creating a clean,
46
+ * consistent, and maintainable API structure.
47
+ */
48
+ review: string;
49
+
50
+ /**
51
+ * Refined collection of API endpoints after review and cleanup.
52
+ *
53
+ * The final optimized set of endpoints after:
54
+ * - Removing duplicates and redundant endpoints
55
+ * - Standardizing naming conventions across all paths
56
+ * - Simplifying over-engineered solutions
57
+ * - Ensuring consistent REST patterns
58
+ * - Aligning HTTP methods with their semantic meanings
59
+ *
60
+ * This collection represents the production-ready API structure
61
+ * that balances functionality with simplicity and maintainability.
62
+ */
63
+ endpoints: AutoBeOpenApi.IEndpoint[];
64
+ }
65
+ }
@@ -174,5 +174,47 @@ export namespace IAutoBeInterfaceOperationsReviewApplication {
174
174
  * database structure and business logic requirements.
175
175
  */
176
176
  prisma_schemas: string;
177
+
178
+ /**
179
+ * Primary Prisma model name for this operation.
180
+ *
181
+ * Identifies the main database table/model that this operation targets.
182
+ * This must match exactly with the Prisma model name defined in the schema.
183
+ * When soft deletion is specified, this model name indicates which table
184
+ * should be soft-deleted.
185
+ *
186
+ * For example:
187
+ * - In a "GET /users/:id" operation, this would be "User"
188
+ * - In a "POST /articles" operation, this would be "Article"
189
+ * - In a "DELETE /comments/:id" with soft delete, this specifies the "Comment" model to soft-delete
190
+ *
191
+ * This property is essential for:
192
+ * - Determining the primary entity for CRUD operations
193
+ * - Identifying which table to apply soft deletion to
194
+ * - Validating operations against the correct Prisma model
195
+ * - Generating appropriate database queries and validations
196
+ */
197
+ model_name: string;
198
+
199
+ /**
200
+ * Soft delete column name for the Prisma models.
201
+ *
202
+ * Specifies the column name used for soft deletion in the database tables
203
+ * associated with this operation. When set to a non-null value, it indicates
204
+ * that the related entities support soft deletion through this column
205
+ * (typically a timestamp field like `deleted_at` or `deletedAt`).
206
+ *
207
+ * When null, it means the entities involved in this operation use hard
208
+ * deletion or don't support deletion at all. This information is crucial
209
+ * for generating appropriate CRUD operations and ensuring data integrity
210
+ * policies are correctly implemented.
211
+ *
212
+ * Common soft delete patterns:
213
+ * - `"deleted_at"`: Records deletion timestamp
214
+ * - `"deletedAt"`: Camel-cased deletion timestamp
215
+ * - `"is_deleted"`: Boolean flag for deletion status
216
+ * - `null`: No soft deletion (hard delete only)
217
+ */
218
+ soft_delete_column: string | null;
177
219
  }
178
220
  }
@@ -1,4 +1,8 @@
1
- import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
1
+ import {
2
+ AutoBeOpenApi,
3
+ AutoBeRealizeAuthorization,
4
+ AutoBeTestFile,
5
+ } from "@autobe/interface";
2
6
  import { ILlmSchema } from "@samchon/openapi";
3
7
 
4
8
  import { AutoBeContext } from "../../context/AutoBeContext";
@@ -29,7 +33,7 @@ export const orchestrateRealizeScenario = <Model extends ILlmSchema.Model>(
29
33
  operation: AutoBeOpenApi.IOperation,
30
34
  authorization?: AutoBeRealizeAuthorization,
31
35
  ): IAutoBeRealizeScenarioApplication.IProps => {
32
- const testScenarios =
36
+ const testFiles: AutoBeTestFile[] =
33
37
  ctx
34
38
  .state()
35
39
  .test?.files.filter(
@@ -47,7 +51,7 @@ export const orchestrateRealizeScenario = <Model extends ILlmSchema.Model>(
47
51
  operation: operation,
48
52
  functionName: functionName,
49
53
  location: `src/providers/${functionName}.ts`,
50
- testScenarios: testScenarios.map((el) => el.scenario.draft),
54
+ testFiles: testFiles,
51
55
  decoratorEvent: authorization,
52
56
  };
53
57
  };
@@ -1,4 +1,8 @@
1
- import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
1
+ import {
2
+ AutoBeOpenApi,
3
+ AutoBeRealizeAuthorization,
4
+ AutoBeTestFile,
5
+ } from "@autobe/interface";
2
6
 
3
7
  export namespace IAutoBeRealizeScenarioApplication {
4
8
  export interface IProps {
@@ -28,7 +32,7 @@ export namespace IAutoBeRealizeScenarioApplication {
28
32
  * certain conditions. Used as a basis for TDD-style automated test
29
33
  * generation.
30
34
  */
31
- testScenarios: string[];
35
+ testFiles: AutoBeTestFile[];
32
36
 
33
37
  /**
34
38
  * Optional decorator event for customizing code generation behavior.
@@ -18,13 +18,16 @@ export namespace IAutoBeRealizeWriteApplication {
18
18
  * 📋 STEP 1 - PRISMA SCHEMA VERIFICATION:
19
19
  *
20
20
  * DO:
21
+ *
21
22
  * - Examine the actual Prisma schema model definition
22
23
  * - List EVERY field that exists in the model with exact types
23
24
  * - Explicitly note fields that DO NOT exist
24
- *
25
+ *
25
26
  * DO NOT:
27
+ *
26
28
  * - Assume common fields exist without verification
27
- * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active without checking
29
+ * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
30
+ * without checking
28
31
  *
29
32
  * 📋 STEP 2 - FIELD INVENTORY:
30
33
  *
@@ -161,7 +164,7 @@ export namespace IAutoBeRealizeWriteApplication {
161
164
  *
162
165
  * This is the initial drafting phase where you outline the basic skeleton
163
166
  * of the function.
164
- *
167
+ *
165
168
  * DO NOT: Use the native Date type.
166
169
  *
167
170
  * - The function signature must correctly include `user`, `parameters`, and
@@ -174,10 +177,12 @@ export namespace IAutoBeRealizeWriteApplication {
174
177
  * Import rules:
175
178
  *
176
179
  * DO NOT:
180
+ *
177
181
  * - Add any new import statements manually
178
182
  * - Write import statements directly (this causes compile errors)
179
- *
180
- * Note: All necessary imports are provided globally or by the system automatically.
183
+ *
184
+ * Note: All necessary imports are provided globally or by the system
185
+ * automatically.
181
186
  *
182
187
  * ✅ Requirements:
183
188
  *
@@ -19,6 +19,8 @@ const singleton = new Singleton(async (compiler: IAutoBeTestCompiler) => {
19
19
  return { [location]: content };
20
20
  };
21
21
  return {
22
+ ...external("node_modules/@nestia/e2e/lib/ArrayUtil.d.ts"),
23
+ ...external("node_modules/@nestia/e2e/lib/RandomGenerator.d.ts"),
22
24
  ...external("node_modules/@nestia/e2e/lib/TestValidator.d.ts"),
23
25
  ...external("node_modules/@nestia/fetcher/lib/IConnection.d.ts"),
24
26
  } satisfies Record<string, string>;
@@ -1,47 +1,59 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
2
  import { IAutoBeTypeScriptCompileResult } from "@autobe/interface";
3
3
  import { StringUtil } from "@autobe/utils";
4
+ import { ILlmSchema } from "@samchon/openapi";
4
5
  import { v7 } from "uuid";
5
6
 
6
7
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
8
+ import { AutoBeContext } from "../../../context/AutoBeContext";
7
9
  import { IAutoBeTestFunction } from "../structures/IAutoBeTestFunction";
8
10
  import { transformTestWriteHistories } from "./transformTestWriteHistories";
9
11
 
10
- export const transformTestCorrectHistories = (
12
+ export const transformTestCorrectHistories = async <
13
+ Model extends ILlmSchema.Model,
14
+ >(
15
+ ctx: AutoBeContext<Model>,
11
16
  func: IAutoBeTestFunction,
12
17
  failure: IAutoBeTypeScriptCompileResult.IFailure,
13
- ): Array<
14
- IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
- > => [
16
- ...transformTestWriteHistories(func.scenario, func.artifacts),
17
- {
18
- id: v7(),
19
- created_at: new Date().toISOString(),
20
- type: "assistantMessage",
21
- text: StringUtil.trim`
22
- ## Generated TypeScript Code
23
- \`\`\`typescript
24
- ${func.script}
25
- \`\`\`
18
+ ): Promise<
19
+ Array<
20
+ IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
21
+ >
22
+ > => {
23
+ const previous = await transformTestWriteHistories(
24
+ ctx,
25
+ func.scenario,
26
+ func.artifacts,
27
+ );
28
+ return [
29
+ ...previous.slice(0, -1),
30
+ {
31
+ id: v7(),
32
+ created_at: new Date().toISOString(),
33
+ type: "systemMessage",
34
+ text: AutoBeSystemPromptConstant.TEST_CORRECT,
35
+ },
36
+ {
37
+ id: v7(),
38
+ created_at: new Date().toISOString(),
39
+ type: "assistantMessage",
40
+ text: StringUtil.trim`
41
+ ${previous.at(-1)!.text}
26
42
 
27
- ## Compile Errors
28
- Fix the compilation error in the provided code.
43
+ ## Generated TypeScript Code
29
44
 
30
- \`\`\`json
31
- ${JSON.stringify(failure.diagnostics)}
32
- \`\`\`
33
- `,
34
- },
35
- {
36
- id: v7(),
37
- created_at: new Date().toISOString(),
38
- type: "systemMessage",
39
- text: AutoBeSystemPromptConstant.TEST_CORRECT.replace(
40
- "{{API_DTO_SCHEMAS}}",
41
- transformTestWriteHistories.structures(func.artifacts),
42
- ).replace(
43
- "{{API_SDK_FUNCTIONS}}",
44
- transformTestWriteHistories.functional(func.artifacts),
45
- ),
46
- },
47
- ];
45
+ \`\`\`typescript
46
+ ${func.script}
47
+ \`\`\`
48
+
49
+ ## Compile Errors
50
+
51
+ Fix the compilation error in the provided code.
52
+
53
+ \`\`\`json
54
+ ${JSON.stringify(failure.diagnostics)}
55
+ \`\`\`
56
+ `,
57
+ },
58
+ ];
59
+ };