@autobe/agent 0.16.0 → 0.17.1

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 (135) hide show
  1. package/LICENSE +661 -21
  2. package/lib/AutoBeAgent.js +9 -9
  3. package/lib/AutoBeAgent.js.map +1 -1
  4. package/lib/constants/AutoBeSystemPromptConstant.d.ts +2 -2
  5. package/lib/context/AutoBeContext.d.ts +16 -4
  6. package/lib/context/AutoBeTokenUsage.d.ts +168 -11
  7. package/lib/context/AutoBeTokenUsage.js +152 -32
  8. package/lib/context/AutoBeTokenUsage.js.map +1 -1
  9. package/lib/context/AutoBeTokenUsageComponent.d.ts +116 -0
  10. package/lib/context/AutoBeTokenUsageComponent.js +120 -0
  11. package/lib/context/AutoBeTokenUsageComponent.js.map +1 -0
  12. package/lib/factory/createAutoBeApplication.js +1 -1
  13. package/lib/factory/createAutoBeApplication.js.map +1 -1
  14. package/lib/factory/createAutoBeContext.d.ts +19 -0
  15. package/lib/factory/createAutoBeContext.js +141 -0
  16. package/lib/factory/createAutoBeContext.js.map +1 -0
  17. package/lib/factory/getAutoBeGenerated.d.ts +1 -1
  18. package/lib/factory/getAutoBeGenerated.js +14 -11
  19. package/lib/factory/getAutoBeGenerated.js.map +1 -1
  20. package/lib/factory/getAutoBeRealizeGenerated.d.ts +7 -0
  21. package/lib/factory/getAutoBeRealizeGenerated.js +27 -0
  22. package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -0
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -0
  25. package/lib/index.js.map +1 -1
  26. package/lib/index.mjs +1090 -927
  27. package/lib/index.mjs.map +1 -1
  28. package/lib/orchestrate/analyze/orchestrateAnalyze.js +9 -36
  29. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  30. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +9 -9
  31. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
  32. package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js +1 -1
  33. package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js.map +1 -1
  34. package/lib/orchestrate/interface/orchestrateInterface.js +6 -23
  35. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  36. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +1 -1
  37. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  38. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +1 -1
  39. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  40. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +1 -1
  41. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  42. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +1 -1
  43. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  44. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +1 -1
  45. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  46. package/lib/orchestrate/prisma/{transformPrismaComponentsHistories.d.ts → histories/transformPrismaComponentsHistories.d.ts} +1 -1
  47. package/lib/orchestrate/prisma/{transformPrismaComponentsHistories.js → histories/transformPrismaComponentsHistories.js} +1 -1
  48. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -0
  49. package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -0
  50. package/lib/orchestrate/prisma/{transformPrismaHistories.d.ts → histories/transformPrismaHistories.d.ts} +1 -1
  51. package/lib/orchestrate/prisma/histories/transformPrismaHistories.js.map +1 -0
  52. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +48 -0
  53. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -0
  54. package/lib/orchestrate/prisma/orchestratePrisma.d.ts +1 -1
  55. package/lib/orchestrate/prisma/orchestratePrisma.js +9 -29
  56. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  57. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +126 -19
  58. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  59. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +10 -10
  60. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  61. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +128 -150
  62. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  63. package/lib/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.d.ts +120 -0
  64. package/lib/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.js +3 -0
  65. package/lib/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.js.map +1 -0
  66. package/lib/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.d.ts +142 -0
  67. package/lib/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.js +3 -0
  68. package/lib/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.js.map +1 -0
  69. package/lib/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.d.ts +209 -0
  70. package/lib/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.js +3 -0
  71. package/lib/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.js.map +1 -0
  72. package/lib/orchestrate/realize/orchestrateRealize.js +13 -24
  73. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  74. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +1 -1
  75. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  76. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +1 -1
  77. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  78. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +23 -23
  79. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
  80. package/lib/orchestrate/test/orchestrateTest.js +8 -26
  81. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  82. package/lib/orchestrate/test/orchestrateTestCorrect.js +1 -1
  83. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  84. package/lib/orchestrate/test/orchestrateTestScenario.js +1 -1
  85. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  86. package/lib/orchestrate/test/orchestrateTestWrite.js +1 -1
  87. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  88. package/package.json +8 -8
  89. package/src/AutoBeAgent.ts +10 -9
  90. package/src/constants/AutoBeSystemPromptConstant.ts +2 -2
  91. package/src/context/AutoBeContext.ts +30 -3
  92. package/src/context/AutoBeTokenUsage.ts +252 -54
  93. package/src/context/AutoBeTokenUsageComponent.ts +180 -0
  94. package/src/factory/createAutoBeApplication.ts +1 -1
  95. package/src/factory/createAutoBeContext.ts +193 -0
  96. package/src/factory/getAutoBeGenerated.ts +14 -21
  97. package/src/factory/getAutoBeRealizeGenerated.ts +30 -0
  98. package/src/index.ts +1 -0
  99. package/src/orchestrate/analyze/orchestrateAnalyze.ts +9 -38
  100. package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +1 -1
  101. package/src/orchestrate/analyze/writeDocumentUntilReviewPassed.ts +1 -1
  102. package/src/orchestrate/interface/orchestrateInterface.ts +4 -21
  103. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +1 -1
  104. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +1 -1
  105. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +1 -1
  106. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +1 -1
  107. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +1 -1
  108. package/src/orchestrate/prisma/{transformPrismaComponentsHistories.ts → histories/transformPrismaComponentsHistories.ts} +2 -2
  109. package/src/orchestrate/prisma/{transformPrismaCorrectHistories.ts → histories/transformPrismaCorrectHistories.ts} +1 -1
  110. package/src/orchestrate/prisma/{transformPrismaHistories.ts → histories/transformPrismaHistories.ts} +2 -2
  111. package/src/orchestrate/prisma/{transformPrismaSchemaHistories.ts → histories/transformPrismaSchemaHistories.ts} +1 -1
  112. package/src/orchestrate/prisma/orchestratePrisma.ts +45 -68
  113. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +13 -81
  114. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +8 -148
  115. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -82
  116. package/src/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.ts +124 -0
  117. package/src/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.ts +144 -0
  118. package/src/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.ts +214 -0
  119. package/src/orchestrate/realize/orchestrateRealize.ts +19 -32
  120. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +1 -1
  121. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
  122. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +1 -1
  123. package/src/orchestrate/test/orchestrateTest.ts +6 -26
  124. package/src/orchestrate/test/orchestrateTestCorrect.ts +1 -1
  125. package/src/orchestrate/test/orchestrateTestScenario.ts +1 -1
  126. package/src/orchestrate/test/orchestrateTestWrite.ts +1 -1
  127. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +0 -1
  128. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +0 -1
  129. package/lib/orchestrate/prisma/transformPrismaHistories.js.map +0 -1
  130. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +0 -48
  131. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +0 -1
  132. /package/lib/orchestrate/prisma/{transformPrismaCorrectHistories.d.ts → histories/transformPrismaCorrectHistories.d.ts} +0 -0
  133. /package/lib/orchestrate/prisma/{transformPrismaCorrectHistories.js → histories/transformPrismaCorrectHistories.js} +0 -0
  134. /package/lib/orchestrate/prisma/{transformPrismaHistories.js → histories/transformPrismaHistories.js} +0 -0
  135. /package/lib/orchestrate/prisma/{transformPrismaSchemaHistories.d.ts → histories/transformPrismaSchemaHistories.d.ts} +0 -0
@@ -8,7 +8,6 @@ import {
8
8
  } from "@autobe/interface";
9
9
  import { AutoBePrismaSchemasEvent } from "@autobe/interface/src/events/AutoBePrismaSchemasEvent";
10
10
  import { ILlmSchema } from "@samchon/openapi";
11
- import { v4 } from "uuid";
12
11
 
13
12
  import { AutoBeContext } from "../../context/AutoBeContext";
14
13
  import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
@@ -16,75 +15,53 @@ import { orchestratePrismaComponents } from "./orchestratePrismaComponent";
16
15
  import { orchestratePrismaCorrect } from "./orchestratePrismaCorrect";
17
16
  import { orchestratePrismaSchemas } from "./orchestratePrismaSchemas";
18
17
 
19
- export const orchestratePrisma =
20
- <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
21
- async (
22
- props: IAutoBeApplicationProps,
23
- ): Promise<AutoBePrismaHistory | AutoBeAssistantMessageHistory> => {
24
- const start: Date = new Date();
25
- ctx.dispatch({
26
- type: "prismaStart",
27
- created_at: start.toISOString(),
28
- reason: props.reason,
29
- step: ctx.state().analyze?.step ?? 0,
30
- });
18
+ export const orchestratePrisma = async <Model extends ILlmSchema.Model>(
19
+ ctx: AutoBeContext<Model>,
20
+ props: IAutoBeApplicationProps,
21
+ ): Promise<AutoBePrismaHistory | AutoBeAssistantMessageHistory> => {
22
+ const start: Date = new Date();
23
+ ctx.dispatch({
24
+ type: "prismaStart",
25
+ created_at: start.toISOString(),
26
+ reason: props.reason,
27
+ step: ctx.state().analyze?.step ?? 0,
28
+ });
31
29
 
32
- // COMPONENTS
33
- const components:
34
- | AutoBeAssistantMessageHistory
35
- | AutoBePrismaComponentsEvent = await orchestratePrismaComponents(ctx);
36
- if (components.type === "assistantMessage") {
37
- ctx.histories().push(components);
38
- ctx.dispatch(components);
39
- return components;
40
- } else ctx.dispatch(components);
30
+ // COMPONENTS
31
+ const components:
32
+ | AutoBeAssistantMessageHistory
33
+ | AutoBePrismaComponentsEvent = await orchestratePrismaComponents(ctx);
34
+ if (components.type === "assistantMessage")
35
+ return ctx.assistantMessage(components);
36
+ else ctx.dispatch(components);
41
37
 
42
- // CONSTRUCT AST DATA
43
- const events: AutoBePrismaSchemasEvent[] = await orchestratePrismaSchemas(
44
- ctx,
45
- components.components,
46
- );
38
+ // CONSTRUCT AST DATA
39
+ const events: AutoBePrismaSchemasEvent[] = await orchestratePrismaSchemas(
40
+ ctx,
41
+ components.components,
42
+ );
47
43
 
48
- // VALIDATE
49
- const result: IAutoBePrismaValidation = await orchestratePrismaCorrect(
50
- ctx,
51
- {
52
- files: events.map((e) => e.file),
53
- },
54
- );
44
+ // VALIDATE
45
+ const result: IAutoBePrismaValidation = await orchestratePrismaCorrect(ctx, {
46
+ files: events.map((e) => e.file),
47
+ });
55
48
 
56
- // COMPILE
57
- const compiler: IAutoBeCompiler = await ctx.compiler();
58
- const schemas: Record<string, string> = await compiler.prisma.write(
59
- result.data,
60
- "postgres",
61
- );
49
+ // COMPILE
50
+ const compiler: IAutoBeCompiler = await ctx.compiler();
51
+ const schemas: Record<string, string> = await compiler.prisma.write(
52
+ result.data,
53
+ "postgres",
54
+ );
62
55
 
63
- // PROPAGATE
64
- const history: AutoBePrismaHistory = {
65
- type: "prisma",
66
- id: v4(),
67
- created_at: start.toISOString(),
68
- completed_at: new Date().toISOString(),
69
- reason: props.reason,
70
- description: "",
71
- result: result,
72
- schemas,
73
- compiled: await compiler.prisma.compile({
74
- files: schemas,
75
- }),
76
- step: ctx.state().analyze?.step ?? 0,
77
- };
78
- ctx.state().prisma = history;
79
- ctx.histories().push(history);
80
- if (history.result.success === true)
81
- ctx.dispatch({
82
- type: "prismaComplete",
83
- application: history.result.data,
84
- schemas: history.schemas,
85
- compiled: history.compiled,
86
- step: ctx.state().analyze?.step ?? 0,
87
- created_at: new Date().toISOString(),
88
- } satisfies AutoBePrismaCompleteEvent);
89
- return history;
90
- };
56
+ // PROPAGATE
57
+ return ctx.dispatch({
58
+ type: "prismaComplete",
59
+ result,
60
+ schemas,
61
+ compiled: await compiler.prisma.compile({
62
+ files: schemas,
63
+ }),
64
+ step: ctx.state().analyze?.step ?? 0,
65
+ created_at: new Date().toISOString(),
66
+ } satisfies AutoBePrismaCompleteEvent);
67
+ };
@@ -4,7 +4,7 @@ import {
4
4
  MicroAgentica,
5
5
  MicroAgenticaHistory,
6
6
  } from "@agentica/core";
7
- import { AutoBeAssistantMessageHistory, AutoBePrisma } from "@autobe/interface";
7
+ import { AutoBeAssistantMessageHistory } from "@autobe/interface";
8
8
  import { AutoBePrismaComponentsEvent } from "@autobe/interface/src/events/AutoBePrismaComponentsEvent";
9
9
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
10
10
  import { IPointer } from "tstl";
@@ -13,7 +13,8 @@ import { v4 } from "uuid";
13
13
 
14
14
  import { AutoBeContext } from "../../context/AutoBeContext";
15
15
  import { assertSchemaModel } from "../../context/assertSchemaModel";
16
- import { transformPrismaComponentsHistories } from "./transformPrismaComponentsHistories";
16
+ import { transformPrismaComponentsHistories } from "./histories/transformPrismaComponentsHistories";
17
+ import { IAutoBePrismaComponentApplication } from "./structures/IAutoBePrismaComponentApplication";
17
18
 
18
19
  export async function orchestratePrismaComponents<
19
20
  Model extends ILlmSchema.Model,
@@ -22,11 +23,10 @@ export async function orchestratePrismaComponents<
22
23
  content: string = "Please extract files and tables from the given documents.",
23
24
  ): Promise<AutoBeAssistantMessageHistory | AutoBePrismaComponentsEvent> {
24
25
  const start: Date = new Date();
25
- const pointer: IPointer<IExtractComponentsProps | null> = {
26
+ const pointer: IPointer<IAutoBePrismaComponentApplication.IProps | null> = {
26
27
  value: null,
27
28
  };
28
29
  const prefix: string | null = ctx.state().analyze?.prefix ?? null;
29
-
30
30
  const agentica: MicroAgentica<Model> = new MicroAgentica({
31
31
  model: ctx.model,
32
32
  vendor: ctx.vendor,
@@ -41,10 +41,7 @@ export async function orchestratePrismaComponents<
41
41
  createApplication({
42
42
  model: ctx.model,
43
43
  build: (next) => {
44
- pointer.value ??= {
45
- components: [],
46
- };
47
- pointer.value.components.push(...next.components);
44
+ pointer.value = next;
48
45
  },
49
46
  }),
50
47
  ],
@@ -53,7 +50,7 @@ export async function orchestratePrismaComponents<
53
50
  const histories: MicroAgenticaHistory<Model>[] = await agentica
54
51
  .conversate(content)
55
52
  .finally(() => {
56
- const tokenUsage = agentica.getTokenUsage();
53
+ const tokenUsage = agentica.getTokenUsage().aggregate;
57
54
  ctx.usage().record(tokenUsage, ["prisma"]);
58
55
  });
59
56
  if (histories.at(-1)?.type === "assistantMessage")
@@ -69,6 +66,9 @@ export async function orchestratePrismaComponents<
69
66
  return {
70
67
  type: "prismaComponents",
71
68
  created_at: start.toISOString(),
69
+ thinking: pointer.value.thinking,
70
+ review: pointer.value.review,
71
+ decision: pointer.value.decision,
72
72
  components: pointer.value.components,
73
73
  step: ctx.state().analyze?.step ?? 0,
74
74
  };
@@ -76,7 +76,7 @@ export async function orchestratePrismaComponents<
76
76
 
77
77
  function createApplication<Model extends ILlmSchema.Model>(props: {
78
78
  model: Model;
79
- build: (next: IExtractComponentsProps) => void;
79
+ build: (next: IAutoBePrismaComponentApplication.IProps) => void;
80
80
  }): IAgenticaController.IClass<Model> {
81
81
  assertSchemaModel(props.model);
82
82
 
@@ -91,18 +91,18 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
91
91
  extractComponents: (next) => {
92
92
  props.build(next);
93
93
  },
94
- } satisfies IApplication,
94
+ } satisfies IAutoBePrismaComponentApplication,
95
95
  };
96
96
  }
97
97
 
98
98
  const claude = typia.llm.application<
99
- IApplication,
99
+ IAutoBePrismaComponentApplication,
100
100
  "claude",
101
101
  { reference: true }
102
102
  >();
103
103
  const collection = {
104
104
  chatgpt: typia.llm.application<
105
- IApplication,
105
+ IAutoBePrismaComponentApplication,
106
106
  "chatgpt",
107
107
  { reference: true }
108
108
  >(),
@@ -111,71 +111,3 @@ const collection = {
111
111
  deepseek: claude,
112
112
  "3.1": claude,
113
113
  };
114
-
115
- interface IApplication {
116
- /**
117
- * Extracts and organizes database schema files with their corresponding table
118
- * definitions.
119
- *
120
- * Processes Prisma schema files and maps each file to its contained database
121
- * tables, enabling structured organization of schemas across multiple files
122
- * for large projects.
123
- *
124
- * @example
125
- * ```typescript
126
- * application.extractFilesAndTables({
127
- * components: [
128
- * {
129
- * filename: "schema-01-users.prisma",
130
- * tables: ["user", "user_profile"]
131
- * },
132
- * {
133
- * filename: "schema-02-articles.prisma",
134
- * tables: ["article", "attachment_file"]
135
- * }
136
- * ]
137
- * });
138
- * ```;
139
- *
140
- * @param props - Configuration object containing the file-to-table mapping
141
- * structure
142
- */
143
- extractComponents(props: IExtractComponentsProps): void;
144
- }
145
-
146
- interface IExtractComponentsProps {
147
- /**
148
- * Maps Prisma schema filenames to their contained database tables.
149
- *
150
- * **Structure:**
151
- *
152
- * - Key: Prisma schema filename with .prisma extension
153
- * - Value: Array of table names defined in that file
154
- *
155
- * **Example:**
156
- *
157
- * ```typescript
158
- * {
159
- * {
160
- * filename: "schema-01-users.prisma",
161
- * tables: ["user", "admin", "moderator", "user_profile", "user_settings"]
162
- * },
163
- * {
164
- * filename: "schema-02-articles.prisma",
165
- * tables: ["article", "article_snapshot"]
166
- * },
167
- * {
168
- * filename: "schema-03-comments.prisma",
169
- * tables: ["comment", "comment_like"]
170
- * }
171
- * }
172
- * ```
173
- *
174
- * **Notes:**
175
- *
176
- * - Table names must match exact Prisma model names (case-sensitive)
177
- * - Keep mapping synchronized with actual schema files
178
- * - Use consistent naming convention for files
179
- */
180
- components: AutoBePrisma.IComponent[];
181
- }
@@ -11,7 +11,8 @@ import typia from "typia";
11
11
  import { AutoBeContext } from "../../context/AutoBeContext";
12
12
  import { assertSchemaModel } from "../../context/assertSchemaModel";
13
13
  import { enforceToolCall } from "../../utils/enforceToolCall";
14
- import { transformPrismaCorrectHistories } from "./transformPrismaCorrectHistories";
14
+ import { transformPrismaCorrectHistories } from "./histories/transformPrismaCorrectHistories";
15
+ import { IAutoBePrismaCorrectApplication } from "./structures/IAutoBePrismaCorrectApplication";
15
16
 
16
17
  export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
17
18
  ctx: AutoBeContext<Model>,
@@ -57,7 +58,7 @@ async function step<Model extends ILlmSchema.Model>(
57
58
  created_at: new Date().toISOString(),
58
59
  });
59
60
 
60
- const pointer: IPointer<IModifyPrismaSchemaFilesProps | null> = {
61
+ const pointer: IPointer<IAutoBePrismaCorrectApplication.IProps | null> = {
61
62
  value: null,
62
63
  };
63
64
  const agentica: MicroAgentica<Model> = new MicroAgentica({
@@ -87,7 +88,7 @@ async function step<Model extends ILlmSchema.Model>(
87
88
  "Resolve the compilation errors in the provided Prisma schema files.",
88
89
  )
89
90
  .finally(() => {
90
- const tokenUsage = agentica.getTokenUsage();
91
+ const tokenUsage = agentica.getTokenUsage().aggregate;
91
92
  ctx.usage().record(tokenUsage, ["prisma"]);
92
93
  });
93
94
  if (pointer.value === null) {
@@ -126,7 +127,7 @@ async function step<Model extends ILlmSchema.Model>(
126
127
 
127
128
  function createApplication<Model extends ILlmSchema.Model>(props: {
128
129
  model: Model;
129
- build: (next: IModifyPrismaSchemaFilesProps) => void;
130
+ build: (next: IAutoBePrismaCorrectApplication.IProps) => void;
130
131
  }): IAgenticaController.IClass<Model> {
131
132
  assertSchemaModel(props.model);
132
133
  const application: ILlmApplication<Model> = collection[
@@ -140,18 +141,18 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
140
141
  correctPrismaSchemaFiles: (next) => {
141
142
  props.build(next);
142
143
  },
143
- } satisfies IApplication,
144
+ } satisfies IAutoBePrismaCorrectApplication,
144
145
  };
145
146
  }
146
147
 
147
148
  const claude = typia.llm.application<
148
- IApplication,
149
+ IAutoBePrismaCorrectApplication,
149
150
  "claude",
150
151
  { reference: true }
151
152
  >();
152
153
  const collection = {
153
154
  chatgpt: typia.llm.application<
154
- IApplication,
155
+ IAutoBePrismaCorrectApplication,
155
156
  "chatgpt",
156
157
  { reference: true }
157
158
  >(),
@@ -160,144 +161,3 @@ const collection = {
160
161
  deepseek: claude,
161
162
  "3.1": claude,
162
163
  };
163
-
164
- interface IApplication {
165
- /**
166
- * Fixes validation errors in specific AutoBePrisma models while preserving
167
- * ALL existing business logic and model descriptions.
168
- *
169
- * ## Core Rules
170
- *
171
- * 1. Fix ONLY validation errors in provided models - never remove business
172
- * descriptions
173
- * 2. Apply minimal changes to error models only - preserve original design
174
- * intent
175
- * 3. Return ONLY corrected models - unchanged models remain in original schema
176
- * 4. Maintain referential integrity with unchanged models
177
- *
178
- * ## Targeted Scope
179
- *
180
- * - Process ONLY models with validation errors from IError[] array
181
- * - Exclude models without errors from processing and output
182
- * - Minimize context usage by returning corrected models only
183
- * - Preserve unchanged models in their original state
184
- *
185
- * ## Fix Strategy
186
- *
187
- * - Resolve validation errors within specific models only
188
- * - Fix field duplications, invalid references, and type mismatches
189
- * - Update cross-model references without modifying target models
190
- * - Ensure naming conventions and index rules compliance in corrected models
191
- */
192
- correctPrismaSchemaFiles(props: IModifyPrismaSchemaFilesProps): void;
193
- }
194
-
195
- interface IModifyPrismaSchemaFilesProps {
196
- /**
197
- * Detailed execution plan for fixing `AutoBePrisma` validation errors in
198
- * specific models.
199
- *
200
- * 🎯 Purpose: Enable systematic reasoning and step-by-step error resolution
201
- * approach for targeted model validation issues
202
- *
203
- * 📋 Required Planning Content:
204
- *
205
- * 1. **Error Scope Analysis**
206
- *
207
- * - List all validation errors from IAutoBePrismaValidation.IError[] array
208
- * - Extract unique table names from errors to identify affected models
209
- * - Categorize errors by type (field duplications, references, types, indexes)
210
- * - Identify which models need correction vs. which remain unchanged
211
- * 2. **Targeted Fix Strategy**
212
- *
213
- * - Focus ONLY on models mentioned in validation errors
214
- * - Outline minimal changes needed for each affected model
215
- * - Plan cross-model reference updates (if any) without modifying non-error
216
- * models
217
- * - Ensure unchanged models maintain valid references to corrected models
218
- * 3. **Model-Specific Fix Plan**
219
- *
220
- * - Model-by-model modification plan for ONLY affected models
221
- * - Exact field additions, renames, or type corrections required
222
- * - Reference updates within corrected models only
223
- * - Index corrections limited to affected models
224
- * 4. **Minimal Scope Validation**
225
- *
226
- * - Confirm which models will be included in output (error models only)
227
- * - List models that will remain unchanged in original schema
228
- * - Identify cross-model dependencies without including unchanged models
229
- * - Preserve all business logic within corrected models
230
- * 5. **Targeted Impact Assessment**
231
- *
232
- * - Potential effects of fixes on unchanged models (reference validation)
233
- * - Verification points for corrected models only
234
- * - Ensure no new validation errors in targeted models
235
- * - Confirm minimal output scope compliance
236
- *
237
- * 💡 Example Planning Structure:
238
- *
239
- * ## Error Scope
240
- * - Target Models: shopping_customers, shopping_orders (2 models only)
241
- * - Unchanged Models: All others remain in original schema
242
- *
243
- * ## Targeted Fixes
244
- * - shopping_customers: Remove duplicate 'email' field
245
- * - shopping_orders: Update targetModel reference to 'shopping_customers'
246
- *
247
- * ## Output Scope
248
- * - Return: Only shopping_customers and shopping_orders models
249
- * - Preserve: All other models unchanged in original schema
250
- *
251
- * ## Cross-Model Impact
252
- * - Verify: shopping_orders still references shopping_customers correctly
253
- * - No changes needed in other models referencing these
254
- */
255
- planning: string;
256
-
257
- /**
258
- * ONLY the specific models that contain validation errors and need
259
- * correction.
260
- *
261
- * 📥 Input Structure:
262
- *
263
- * - Contains ONLY models mentioned in IAutoBePrismaValidation.IError[] array
264
- * - Each model has specific validation errors that need targeted correction
265
- * - Models not mentioned in errors are excluded from this input
266
- * - Represents minimal scope for error correction
267
- *
268
- * 🔍 Expected Validation Issues (Model-Specific):
269
- *
270
- * - Duplicate field/relation names within these specific models
271
- * - Invalid foreign key references from these models to other models
272
- * - Single foreign key fields in index arrays within these models
273
- * - Invalid naming conventions within these specific models
274
- * - Type validation errors in fields of these models
275
- *
276
- * 📝 Model Content Analysis (Targeted Scope):
277
- *
278
- * - Complete field definitions for each error model only
279
- * - Relationships from these models (may reference unchanged models)
280
- * - Indexes within these models that need correction
281
- * - Business descriptions specific to these models
282
- * - Cross-model references that need validation (read-only for targets)
283
- *
284
- * ⚠️ Processing Notes (Focused Approach):
285
- *
286
- * - Input contains ONLY models with validation errors
287
- * - May reference other models not included in this input
288
- * - Cross-model references must be validated but target models won't be
289
- * modified
290
- * - Output should return corrected versions of ONLY these input models
291
- * - All business logic and descriptions within these models must be preserved
292
- * - Corrections must not break references from unchanged models
293
- *
294
- * 🎯 Correction Scope:
295
- *
296
- * - Fix validation errors within these specific models
297
- * - Update internal model structure (fields, relations, indexes)
298
- * - Correct references to external models (without modifying targets)
299
- * - Maintain compatibility with unchanged models in the full schema
300
- * - Return corrected versions of ONLY these models
301
- */
302
- models: AutoBePrisma.IModel[];
303
- }
@@ -10,7 +10,8 @@ import { AutoBeContext } from "../../context/AutoBeContext";
10
10
  import { assertSchemaModel } from "../../context/assertSchemaModel";
11
11
  import { enforceToolCall } from "../../utils/enforceToolCall";
12
12
  import { forceRetry } from "../../utils/forceRetry";
13
- import { transformPrismaSchemaHistories } from "./transformPrismaSchemaHistories";
13
+ import { transformPrismaSchemaHistories } from "./histories/transformPrismaSchemaHistories";
14
+ import { IAutoBePrismaSchemaApplication } from "./structures/IAutoBePrismaSchemaApplication";
14
15
 
15
16
  export async function orchestratePrismaSchemas<Model extends ILlmSchema.Model>(
16
17
  ctx: AutoBeContext<Model>,
@@ -27,12 +28,16 @@ export async function orchestratePrismaSchemas<Model extends ILlmSchema.Model>(
27
28
  const otherComponents: AutoBePrisma.IComponent[] = components.filter(
28
29
  (y) => comp !== y,
29
30
  );
30
- const result: IMakePrismaSchemaFileProps = await forceRetry(() =>
31
- process(ctx, targetComponent, otherComponents),
31
+ const result: IAutoBePrismaSchemaApplication.IProps = await forceRetry(
32
+ () => process(ctx, targetComponent, otherComponents),
32
33
  );
33
34
  const event: AutoBePrismaSchemasEvent = {
34
35
  type: "prismaSchemas",
35
36
  created_at: start.toISOString(),
37
+ thinking: result.thinking,
38
+ draft: result.draft,
39
+ review: result.review,
40
+ final: result.final,
36
41
  file: {
37
42
  filename: comp.filename,
38
43
  namespace: comp.namespace,
@@ -52,8 +57,8 @@ async function process<Model extends ILlmSchema.Model>(
52
57
  ctx: AutoBeContext<Model>,
53
58
  targetComponent: AutoBePrisma.IComponent,
54
59
  otherComponents: AutoBePrisma.IComponent[],
55
- ): Promise<IMakePrismaSchemaFileProps> {
56
- const pointer: IPointer<IMakePrismaSchemaFileProps | null> = {
60
+ ): Promise<IAutoBePrismaSchemaApplication.IProps> {
61
+ const pointer: IPointer<IAutoBePrismaSchemaApplication.IProps | null> = {
57
62
  value: null,
58
63
  };
59
64
  const agentica: MicroAgentica<Model> = new MicroAgentica({
@@ -83,7 +88,7 @@ async function process<Model extends ILlmSchema.Model>(
83
88
  enforceToolCall(agentica);
84
89
 
85
90
  await agentica.conversate("Make prisma schema file please").finally(() => {
86
- const tokenUsage = agentica.getTokenUsage();
91
+ const tokenUsage = agentica.getTokenUsage().aggregate;
87
92
  ctx.usage().record(tokenUsage, ["prisma"]);
88
93
  });
89
94
  if (pointer.value === null)
@@ -96,7 +101,7 @@ function createApplication<Model extends ILlmSchema.Model>(
96
101
  props: {
97
102
  targetComponent: AutoBePrisma.IComponent;
98
103
  otherComponents: AutoBePrisma.IComponent[];
99
- build: (next: IMakePrismaSchemaFileProps) => void;
104
+ build: (next: IAutoBePrismaSchemaApplication.IProps) => void;
100
105
  },
101
106
  ): IAgenticaController.IClass<Model> {
102
107
  assertSchemaModel(ctx.model);
@@ -171,18 +176,18 @@ function createApplication<Model extends ILlmSchema.Model>(
171
176
  makePrismaSchemaFile: (next) => {
172
177
  props.build(next);
173
178
  },
174
- } satisfies IApplication,
179
+ } satisfies IAutoBePrismaSchemaApplication,
175
180
  };
176
181
  }
177
182
 
178
183
  const claude = typia.llm.application<
179
- IApplication,
184
+ IAutoBePrismaSchemaApplication,
180
185
  "claude",
181
186
  { reference: true }
182
187
  >();
183
188
  const collection = {
184
189
  chatgpt: typia.llm.application<
185
- IApplication,
190
+ IAutoBePrismaSchemaApplication,
186
191
  "chatgpt",
187
192
  { reference: true }
188
193
  >(),
@@ -191,75 +196,3 @@ const collection = {
191
196
  deepseek: claude,
192
197
  "3.1": claude,
193
198
  };
194
-
195
- interface IApplication {
196
- /**
197
- * Generates comprehensive Prisma schema files based on detailed requirements
198
- * analysis.
199
- *
200
- * Creates multiple organized schema files following enterprise patterns
201
- * including proper domain separation, relationship modeling, snapshot
202
- * patterns, inheritance, materialized views, and comprehensive documentation.
203
- * The generated schemas implement best practices for scalability,
204
- * maintainability, and data integrity.
205
- *
206
- * @param props Properties containing the file
207
- */
208
- makePrismaSchemaFile(props: IMakePrismaSchemaFileProps): void;
209
- }
210
-
211
- interface IMakePrismaSchemaFileProps {
212
- /**
213
- * STEP 1: First enumeration of tables that must be created
214
- *
215
- * List all table names that need to be created based on the
216
- * `targetComponent.tables`. This should be an exact copy of the
217
- * `targetComponent.tables` array.
218
- *
219
- * Example: ["shopping_goods", "shopping_goods_options"]
220
- */
221
- tablesToCreate: string[];
222
-
223
- /**
224
- * STEP 2: Validation review of the first enumeration
225
- *
226
- * Compare `tablesToCreate` against `targetComponent.tables` and
227
- * `otherComponents[].tables`. Write a review statement that validates:
228
- *
229
- * - All tables from `targetComponent.tables` are included
230
- * - No tables from `otherComponents[].tables` are included
231
- * - Additional tables (if any) are for M:N junction relationships or
232
- * domain-specific needs
233
- * - No forbidden tables from other domains are included
234
- *
235
- * Example: "VALIDATION PASSED: All required tables from
236
- * `targetComponent.tables` included: shopping_goods, shopping_goods_options.
237
- * FORBIDDEN CHECK: No tables from `otherComponents` included
238
- * (shopping_customers, shopping_sellers are correctly excluded). Additional
239
- * tables: none needed for this domain."
240
- */
241
- validationReview: string;
242
-
243
- /**
244
- * STEP 3: Second enumeration of tables to create
245
- *
246
- * After validation, re-list the tables that will be created. This should be
247
- * identical to `tablesToCreate` if validation passed. This serves as the
248
- * final confirmed list before model creation.
249
- *
250
- * Example: ["shopping_goods", "shopping_goods_options"]
251
- */
252
- confirmedTables: string[];
253
-
254
- /**
255
- * STEP 4: Array of Prisma models (database tables) within the domain
256
- *
257
- * Create exactly one model for each table in `confirmedTables`. Each model
258
- * represents a business entity or concept within the namespace. Models can
259
- * reference each other through foreign key relationships.
260
- *
261
- * The `models` array length must equal `confirmedTables.length`. Each
262
- * `model.name` must match an entry in `confirmedTables`.
263
- */
264
- models: AutoBePrisma.IModel[];
265
- }