@autobe/agent 0.5.2 → 0.7.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 (119) hide show
  1. package/lib/AutoBeAgent.js +4 -4
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +5 -2
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/context/AutoBeContext.d.ts +2 -2
  6. package/lib/context/IAutoBeApplicationProps.d.ts +6 -0
  7. package/lib/factory/createAgenticaHistory.js +1 -0
  8. package/lib/factory/createAgenticaHistory.js.map +1 -1
  9. package/lib/factory/createAutoBeApplication.js +17 -17
  10. package/lib/factory/createAutoBeApplication.js.map +1 -1
  11. package/lib/index.mjs +6228 -4563
  12. package/lib/index.mjs.map +1 -1
  13. package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeAgent.d.ts +4 -8
  14. package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeAgent.js +25 -20
  15. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -0
  16. package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.js.map +1 -0
  17. package/lib/orchestrate/analyze/AutoBeAnalyzePointer.d.ts +9 -0
  18. package/lib/orchestrate/analyze/AutoBeAnalyzePointer.js +3 -0
  19. package/lib/orchestrate/analyze/AutoBeAnalyzePointer.js.map +1 -0
  20. package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeReviewer.d.ts +1 -1
  21. package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeReviewer.js +8 -5
  22. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -0
  23. package/lib/orchestrate/analyze/orchestrateAnalyze.d.ts +31 -0
  24. package/lib/orchestrate/{orchestrateAnalyze.js → analyze/orchestrateAnalyze.js} +200 -59
  25. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -0
  26. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  27. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  28. package/lib/orchestrate/index.d.ts +3 -3
  29. package/lib/orchestrate/index.js +6 -6
  30. package/lib/orchestrate/index.js.map +1 -1
  31. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +8 -1
  32. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  33. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +6 -1
  34. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
  35. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +3 -1
  36. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  37. package/lib/orchestrate/interface/transformInterfaceHistories.js +41 -0
  38. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
  39. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -5
  40. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  41. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.d.ts +1 -1
  42. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +28 -1
  43. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
  44. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js +9 -0
  45. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +1 -1
  46. package/lib/orchestrate/prisma/transformPrismaHistories.js +9 -0
  47. package/lib/orchestrate/prisma/transformPrismaHistories.js.map +1 -1
  48. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +7 -0
  49. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
  50. package/lib/orchestrate/{orchestrateTest.d.ts → test/orchestrateTest.d.ts} +2 -2
  51. package/lib/orchestrate/test/orchestrateTest.js +70 -0
  52. package/lib/orchestrate/test/orchestrateTest.js.map +1 -0
  53. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -0
  54. package/lib/orchestrate/test/orchestrateTestCorrect.js +543 -0
  55. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -0
  56. package/lib/orchestrate/test/orchestrateTestProgress.d.ts +4 -0
  57. package/lib/orchestrate/test/orchestrateTestProgress.js +403 -0
  58. package/lib/orchestrate/test/orchestrateTestProgress.js.map +1 -0
  59. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +4 -0
  60. package/lib/orchestrate/test/orchestrateTestScenario.js +700 -0
  61. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -0
  62. package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -0
  63. package/lib/orchestrate/test/transformTestCorrectHistories.js +47 -0
  64. package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -0
  65. package/lib/orchestrate/test/transformTestHistories.d.ts +3 -0
  66. package/lib/orchestrate/test/transformTestHistories.js +74 -0
  67. package/lib/orchestrate/test/transformTestHistories.js.map +1 -0
  68. package/lib/orchestrate/test/transformTestProgressHistories.d.ts +2 -0
  69. package/lib/orchestrate/test/transformTestProgressHistories.js +47 -0
  70. package/lib/orchestrate/test/transformTestProgressHistories.js.map +1 -0
  71. package/lib/orchestrate/test/transformTestScenarioHistories.d.ts +4 -0
  72. package/lib/orchestrate/test/transformTestScenarioHistories.js +176 -0
  73. package/lib/orchestrate/test/transformTestScenarioHistories.js.map +1 -0
  74. package/lib/structures/IAutoBeVendor.d.ts +45 -2
  75. package/package.json +6 -6
  76. package/src/AutoBeAgent.ts +5 -3
  77. package/src/constants/AutoBeSystemPromptConstant.ts +5 -2
  78. package/src/context/AutoBeContext.ts +2 -2
  79. package/src/context/IAutoBeApplicationProps.ts +6 -0
  80. package/src/factory/createAgenticaHistory.ts +1 -0
  81. package/src/factory/createAutoBeApplication.ts +2 -2
  82. package/src/{analyze → orchestrate/analyze}/AutoBeAnalyzeAgent.ts +38 -36
  83. package/src/orchestrate/analyze/AutoBeAnalyzePointer.ts +10 -0
  84. package/src/{analyze → orchestrate/analyze}/AutoBeAnalyzeReviewer.ts +9 -6
  85. package/src/orchestrate/{orchestrateAnalyze.ts → analyze/orchestrateAnalyze.ts} +91 -39
  86. package/src/orchestrate/index.ts +3 -3
  87. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +8 -1
  88. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +6 -1
  89. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +3 -1
  90. package/src/orchestrate/interface/transformInterfaceHistories.ts +40 -0
  91. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +4 -1
  92. package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +28 -0
  93. package/src/orchestrate/prisma/transformPrismaCorrectHistories.ts +9 -0
  94. package/src/orchestrate/prisma/transformPrismaHistories.ts +9 -0
  95. package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +7 -0
  96. package/src/orchestrate/test/orchestrateTest.ts +86 -0
  97. package/src/orchestrate/test/orchestrateTestCorrect.ts +368 -0
  98. package/src/orchestrate/test/orchestrateTestProgress.ts +264 -0
  99. package/src/orchestrate/test/orchestrateTestScenario.ts +178 -0
  100. package/src/orchestrate/test/transformTestCorrectHistories.ts +51 -0
  101. package/src/orchestrate/test/transformTestHistories.ts +77 -0
  102. package/src/orchestrate/test/transformTestProgressHistories.ts +51 -0
  103. package/src/orchestrate/test/transformTestScenarioHistories.ts +184 -0
  104. package/src/structures/IAutoBeVendor.ts +48 -2
  105. package/lib/analyze/AnalyzeAgent.d.ts +0 -24
  106. package/lib/analyze/AnalyzeAgent.js +0 -942
  107. package/lib/analyze/AnalyzeAgent.js.map +0 -1
  108. package/lib/analyze/AutoBeAnalyzeAgent.js.map +0 -1
  109. package/lib/analyze/AutoBeAnalyzeFileSystem.js.map +0 -1
  110. package/lib/analyze/AutoBeAnalyzeReviewer.js.map +0 -1
  111. package/lib/orchestrate/orchestrateAnalyze.d.ts +0 -6
  112. package/lib/orchestrate/orchestrateAnalyze.js.map +0 -1
  113. package/lib/orchestrate/orchestrateTest.js +0 -19
  114. package/lib/orchestrate/orchestrateTest.js.map +0 -1
  115. package/src/analyze/AnalyzeAgent.ts +0 -183
  116. package/src/orchestrate/orchestrateTest.ts +0 -18
  117. /package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeFileSystem.d.ts +0 -0
  118. /package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeFileSystem.js +0 -0
  119. /package/src/{analyze → orchestrate/analyze}/AutoBeAnalyzeFileSystem.ts +0 -0
@@ -1,8 +1,9 @@
1
1
  import { MicroAgentica } from "@agentica/core";
2
2
  import { ILlmSchema } from "@samchon/openapi";
3
+ import { v4 } from "uuid";
3
4
 
4
- import { AutoBeSystemPromptConstant } from "../constants/AutoBeSystemPromptConstant";
5
- import { AutoBeContext } from "../context/AutoBeContext";
5
+ import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
6
+ import { AutoBeContext } from "../../context/AutoBeContext";
6
7
 
7
8
  export const AutoBeAnalyzeReviewer = <Model extends ILlmSchema.Model>(
8
9
  ctx: AutoBeContext<Model>,
@@ -13,10 +14,8 @@ export const AutoBeAnalyzeReviewer = <Model extends ILlmSchema.Model>(
13
14
  vendor: ctx.vendor,
14
15
  controllers: [],
15
16
  config: {
16
- systemPrompt: {
17
- describe: () => {
18
- return "Answer only 'completion' or 'failure'.";
19
- },
17
+ executor: {
18
+ describe: null,
20
19
  },
21
20
  locale: ctx.config?.locale,
22
21
  },
@@ -27,10 +26,14 @@ export const AutoBeAnalyzeReviewer = <Model extends ILlmSchema.Model>(
27
26
  (el) => el.type === "assistantMessage" || el.type === "userMessage",
28
27
  ),
29
28
  {
29
+ id: v4(),
30
+ created_at: new Date().toISOString(),
30
31
  type: "systemMessage",
31
32
  text: AutoBeSystemPromptConstant.ANALYZE_REVIEWER,
32
33
  },
33
34
  {
35
+ id: v4(),
36
+ created_at: new Date().toISOString(),
34
37
  type: "systemMessage",
35
38
  text: [
36
39
  "Below are all of the files.",
@@ -4,20 +4,17 @@ import {
4
4
  AutoBeAssistantMessageHistory,
5
5
  } from "@autobe/interface";
6
6
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
7
- import { IPointer } from "tstl";
8
7
  import typia from "typia";
9
8
  import { v4 } from "uuid";
10
9
 
11
- import { AutoBeAnalyzeAgent } from "../analyze/AutoBeAnalyzeAgent";
12
- import { IFile } from "../analyze/AutoBeAnalyzeFileSystem";
13
- import { AutoBeAnalyzeReviewer } from "../analyze/AutoBeAnalyzeReviewer";
14
- import { AutoBeSystemPromptConstant } from "../constants/AutoBeSystemPromptConstant";
15
- import { AutoBeContext } from "../context/AutoBeContext";
16
- import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
17
- import { assertSchemaModel } from "../context/assertSchemaModel";
18
-
19
- type Filename = string;
20
- type FileContent = string;
10
+ import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
11
+ import { AutoBeContext } from "../../context/AutoBeContext";
12
+ import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
13
+ import { assertSchemaModel } from "../../context/assertSchemaModel";
14
+ import { AutoBeAnalyzeAgent } from "./AutoBeAnalyzeAgent";
15
+ import { IFile } from "./AutoBeAnalyzeFileSystem";
16
+ import { AutoBeAnalyzePointer } from "./AutoBeAnalyzePointer";
17
+ import { AutoBeAnalyzeReviewer } from "./AutoBeAnalyzeReviewer";
21
18
 
22
19
  /** @todo Kakasoo */
23
20
  export const orchestrateAnalyze =
@@ -52,6 +49,9 @@ export const orchestrateAnalyze =
52
49
  controllers: [controller],
53
50
  config: {
54
51
  locale: ctx.config?.locale,
52
+ executor: {
53
+ describe: null,
54
+ },
55
55
  systemPrompt: {
56
56
  common: () => AutoBeSystemPromptConstant.ANALYZE_PLANNER,
57
57
  },
@@ -98,50 +98,70 @@ export const orchestrateAnalyze =
98
98
  }
99
99
 
100
100
  const described = determined.find((el) => el.type === "describe");
101
- const filenames = Array.from(
102
- new Set(
103
- described
104
- ? described.executes
105
- .flatMap((el) => {
106
- if (el.protocol === "class") {
107
- return (
108
- el.arguments as { files: Array<Pick<IFile, "filename">> }
109
- ).files;
110
- }
111
- return null;
112
- })
113
- .filter((el) => el !== null)
114
- : [],
115
- ),
116
- );
101
+ // const determinedOutput = Array.from(
102
+ // new Set(
103
+ // described
104
+ // ? described.executes
105
+ // .map((el) => {
106
+ // if (el.protocol === "class") {
107
+ // return el.arguments as unknown as IDeterminingInput;
108
+ // }
109
+ // return null;
110
+ // })
111
+ // .filter((el) => el !== null)
112
+ // : [],
113
+ // ),
114
+ // );
115
+
116
+ const determinedOutput = described?.executes.find(
117
+ (el) => el.protocol === "class" && typia.is<IDeterminingInput>(el.value),
118
+ )?.value as IDeterminingInput;
119
+
120
+ const prefix = determinedOutput.prefix;
121
+ const describedFiles = determinedOutput.files;
122
+ if (describedFiles.length === 0) {
123
+ const history: AutoBeAssistantMessageHistory = {
124
+ id: v4(),
125
+ type: "assistantMessage",
126
+ text: "The current requirements are insufficient, so file generation will be suspended. It would be better to continue the conversation.",
127
+ created_at,
128
+ completed_at: new Date().toISOString(),
129
+ };
130
+ ctx.dispatch({
131
+ type: "assistantMessage",
132
+ text: "The current requirements are insufficient, so file generation will be suspended. It would be better to continue the conversation.",
133
+ created_at,
134
+ });
135
+ return history;
136
+ }
117
137
 
118
138
  const pointers = await Promise.all(
119
- filenames.map(async ({ filename }) => {
120
- const pointer: IPointer<{
121
- files: Record<Filename, FileContent>;
122
- } | null> = {
123
- value: null,
124
- };
139
+ describedFiles.map(async ({ filename, reason }) => {
140
+ const pointer: AutoBeAnalyzePointer = { value: null };
125
141
 
126
142
  const agent = new AutoBeAnalyzeAgent(
127
143
  AutoBeAnalyzeReviewer,
128
144
  ctx,
129
145
  pointer,
130
- filenames.map((el) => el.filename),
146
+ describedFiles.map((el) => el.filename),
131
147
  );
132
148
 
133
149
  await agent.conversate(
134
150
  [
135
- `The names of all the files are as follows: ${filenames.join(",")}`,
151
+ `# Instruction`,
152
+ `The names of all the files are as follows: ${describedFiles.join(",")}`,
136
153
  "Assume that all files are in the same folder. Also, when pointing to the location of a file, go to the relative path.",
137
154
  "",
138
155
  `Among the various documents, the part you decided to take care of is as follows.: ${filename}`,
139
156
  `Only write this document named '${filename}'.`,
140
157
  "Never write other documents.",
141
158
  "",
159
+ "# User Planning Requirements",
142
160
  "```md",
143
161
  JSON.stringify(userPlanningRequirements),
144
162
  "```",
163
+ "The reason why this document needs to be written is as follows.",
164
+ `- reason: ${reason}`,
145
165
  ].join("\n"),
146
166
  );
147
167
 
@@ -160,6 +180,7 @@ export const orchestrateAnalyze =
160
180
  id: v4(),
161
181
  type: "analyze",
162
182
  reason: userPlanningRequirements,
183
+ prefix,
163
184
  files: files,
164
185
  step,
165
186
  created_at,
@@ -169,6 +190,7 @@ export const orchestrateAnalyze =
169
190
  ctx.histories().push(history);
170
191
  ctx.dispatch({
171
192
  type: "analyzeComplete",
193
+ prefix,
172
194
  files: files,
173
195
  step,
174
196
  created_at,
@@ -191,18 +213,48 @@ export const orchestrateAnalyze =
191
213
  return history;
192
214
  };
193
215
 
216
+ export interface IDeterminingInput {
217
+ /**
218
+ * Prefix for file names and all prisma schema files, table, interface, and
219
+ * variable names. For example, if you were to create a bulletin board
220
+ * service, the prefix would be bbs. At this time, the name of the document
221
+ * would be, for example, 00_bbs_table_of_contents, and bbs would have to be
222
+ * attached to the name of all documents. This value would then be passed to
223
+ * other agents as well, in the form of bbs_article, bbs_article_snapshot, and
224
+ * bbs_comments in the table name. Interfaces will likewise be used in
225
+ * interfaces and tests because they originate from the name of prisma scheme.
226
+ * Do not use prefixes that are related to the technology stack (e.g., ts_,
227
+ * api_, react_) or unnatural prefixes that typically wouldn’t appear in table
228
+ * names or domain models (e.g., zz_, my_, dev_).
229
+ *
230
+ * @title Prefix
231
+ */
232
+ prefix: string;
233
+
234
+ /**
235
+ * File name must be English. and it must contains the numbering and prefix.
236
+ *
237
+ * @title file names and reason to create.
238
+ */
239
+ files: Array<Pick<IFile, "filename" | "reason">>;
240
+ }
241
+
194
242
  class DeterminingFiles {
195
243
  /**
196
- * Determining the Initial File List
244
+ * Determining the Initial File List.
197
245
  *
198
246
  * Design a list of initial documents that you need to create for that
199
247
  * requirement. The list of documents is determined only by the name of the
200
- * file.
248
+ * file. If you determine from the conversation that the user's requirements
249
+ * have not been fully gathered, you must stop the analysis and continue
250
+ * collecting the remaining requirements. In this case, you do not need to
251
+ * generate any files. Simply pass an empty array to `input.files`, which is
252
+ * the input value for the `determine` tool.
201
253
  *
202
- * @param input
254
+ * @param input Prefix and files
203
255
  * @returns
204
256
  */
205
- determine(input: { files: Array<Pick<IFile, "filename">> }) {
257
+ determine(input: IDeterminingInput): IDeterminingInput {
206
258
  return input;
207
259
  }
208
260
  }
@@ -1,5 +1,5 @@
1
- export { orchestrateAnalyze as analyze } from "./orchestrateAnalyze";
1
+ export { orchestrateAnalyze as analyze } from "./analyze/orchestrateAnalyze";
2
2
  export { orchestrateInterface as interface } from "./interface/orchestrateInterface";
3
- export { orchestratePrisma as prisma } from "./prisma/orchestratePrisma";
4
- export { orchestrateTest as test } from "./orchestrateTest";
5
3
  export { orchestrateRealize as realize } from "./orchestrateRealize";
4
+ export { orchestrateTest as test } from "./test/orchestrateTest";
5
+ export { orchestratePrisma as prisma } from "./prisma/orchestratePrisma";
@@ -8,6 +8,7 @@ import {
8
8
  import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
9
9
  import { IPointer } from "tstl";
10
10
  import typia from "typia";
11
+ import { v4 } from "uuid";
11
12
 
12
13
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
13
14
  import { AutoBeContext } from "../../context/AutoBeContext";
@@ -51,6 +52,8 @@ async function step<Model extends ILlmSchema.Model>(
51
52
  AutoBeSystemPromptConstant.INTERFACE_COMPLEMENT,
52
53
  ),
53
54
  {
55
+ id: v4(),
56
+ created_at: new Date().toISOString(),
54
57
  type: "assistantMessage",
55
58
  text: [
56
59
  "Here is the OpenAPI document what you've made:",
@@ -61,6 +64,8 @@ async function step<Model extends ILlmSchema.Model>(
61
64
  ].join("\n"),
62
65
  },
63
66
  {
67
+ id: v4(),
68
+ created_at: new Date().toISOString(),
64
69
  type: "assistantMessage",
65
70
  text: [
66
71
  "You have missed below schema types in the document.components.schemas:",
@@ -85,7 +90,9 @@ async function step<Model extends ILlmSchema.Model>(
85
90
  ],
86
91
  });
87
92
  agentica.on("request", async (event) => {
88
- event.body.tool_choice = "required";
93
+ if (event.body.tools) {
94
+ event.body.tool_choice = "required";
95
+ }
89
96
  });
90
97
 
91
98
  await agentica.conversate("Fill missing schema types please");
@@ -4,6 +4,7 @@ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
4
4
  import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
5
5
  import { IPointer } from "tstl";
6
6
  import typia from "typia";
7
+ import { v4 } from "uuid";
7
8
 
8
9
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
9
10
  import { AutoBeContext } from "../../context/AutoBeContext";
@@ -113,6 +114,8 @@ async function process<Model extends ILlmSchema.Model>(
113
114
  AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
114
115
  ),
115
116
  {
117
+ id: v4(),
118
+ created_at: new Date().toISOString(),
116
119
  type: "assistantMessage",
117
120
  text: [
118
121
  "Here is the OpenAPI operations generated by phase 2.",
@@ -135,7 +138,9 @@ async function process<Model extends ILlmSchema.Model>(
135
138
  ],
136
139
  });
137
140
  agentica.on("request", async (event) => {
138
- event.body.tool_choice = "required";
141
+ if (event.body.tools) {
142
+ event.body.tool_choice = "required";
143
+ }
139
144
  });
140
145
 
141
146
  const already: string[] = Object.keys(oldbie.schemas);
@@ -112,7 +112,9 @@ async function process<Model extends ILlmSchema.Model>(
112
112
  ],
113
113
  });
114
114
  agentica.on("request", async (event) => {
115
- event.body.tool_choice = "required";
115
+ if (event.body.tools) {
116
+ event.body.tool_choice = "required";
117
+ }
116
118
  });
117
119
  await agentica.conversate(
118
120
  [
@@ -1,4 +1,5 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { v4 } from "uuid";
2
3
 
3
4
  import { AutoBeState } from "../../context/AutoBeState";
4
5
 
@@ -11,6 +12,8 @@ export const transformInterfaceHistories = (
11
12
  if (state.analyze === null)
12
13
  return [
13
14
  {
15
+ id: v4(),
16
+ created_at: new Date().toISOString(),
14
17
  type: "systemMessage",
15
18
  text: [
16
19
  "Requirement analysis is not yet completed.",
@@ -22,6 +25,8 @@ export const transformInterfaceHistories = (
22
25
  else if (state.prisma === null)
23
26
  return [
24
27
  {
28
+ id: v4(),
29
+ created_at: new Date().toISOString(),
25
30
  type: "systemMessage",
26
31
  text: [
27
32
  "Prisma DB schema generation is not yet completed.",
@@ -33,6 +38,8 @@ export const transformInterfaceHistories = (
33
38
  else if (state.analyze.step !== state.prisma.step)
34
39
  return [
35
40
  {
41
+ id: v4(),
42
+ created_at: new Date().toISOString(),
36
43
  type: "systemMessage",
37
44
  text: [
38
45
  "Prisma DB schema generation has not been updated",
@@ -45,6 +52,8 @@ export const transformInterfaceHistories = (
45
52
  else if (state.prisma.compiled.type !== "success")
46
53
  return [
47
54
  {
55
+ id: v4(),
56
+ created_at: new Date().toISOString(),
48
57
  type: "systemMessage",
49
58
  text: [
50
59
  "Prisma DB schema generation has not been updated",
@@ -56,10 +65,14 @@ export const transformInterfaceHistories = (
56
65
  ];
57
66
  return [
58
67
  {
68
+ id: v4(),
69
+ created_at: new Date().toISOString(),
59
70
  type: "systemMessage",
60
71
  text: systemMessage,
61
72
  },
62
73
  {
74
+ id: v4(),
75
+ created_at: new Date().toISOString(),
63
76
  type: "assistantMessage",
64
77
  text: [
65
78
  "Requirement analysis and Prisma DB schema generation are ready.",
@@ -72,6 +85,31 @@ export const transformInterfaceHistories = (
72
85
  "",
73
86
  state.analyze.reason,
74
87
  "",
88
+ "## Prefix",
89
+ "",
90
+ `* Prefix provided by the user: ${state.analyze?.prefix ?? null}`,
91
+ `* When defining TypeScript interfaces, the interface name must be in PascalCase. The property names, however, do not need to follow this convention.`,
92
+ "",
93
+ "The user wants all TypeScript identifiers (such as interfaces, types, and functions) to start with the prefix provided below. ",
94
+ "If the prefix is `null`, it should be ignored. ",
95
+ "If a prefix is provided, all identifier names **must begin with it**.",
96
+ "",
97
+ "However, if there is a special-purpose prefix like `mv` (e.g., for materialized view handlers or performance-related utilities), it **must precede** the given prefix.",
98
+ "",
99
+ "## Prefix Example",
100
+ "",
101
+ "If the prefix is `shopping`, then names should be like:",
102
+ "",
103
+ "* `shoppingSales`",
104
+ "* `shoppingSaleOptions`",
105
+ "* `shoppingCreateSale()`",
106
+ "",
107
+ "In cases where an identifier is created for performance-optimized logic or special processing (e.g., materialized view handling), the `mv` prefix must come first. ",
108
+ "For example:",
109
+ "",
110
+ "* `mvShoppingDailyStats`",
111
+ "* `mvShoppingAggregateView`",
112
+ "",
75
113
  // Requirement Analysis Report
76
114
  `## Requirement Analysis Report`,
77
115
  "",
@@ -81,6 +119,8 @@ export const transformInterfaceHistories = (
81
119
  ].join("\n"),
82
120
  },
83
121
  {
122
+ id: v4(),
123
+ created_at: new Date().toISOString(),
84
124
  type: "assistantMessage",
85
125
  text: [
86
126
  "Database schema and entity relationship diagrams are ready.",
@@ -25,13 +25,16 @@ export async function orchestratePrismaComponents<
25
25
  const pointer: IPointer<IExtractComponentsProps | null> = {
26
26
  value: null,
27
27
  };
28
+
29
+ const prefix = ctx.state().analyze?.prefix ?? null;
30
+
28
31
  const agentica: MicroAgentica<Model> = new MicroAgentica({
29
32
  model: ctx.model,
30
33
  vendor: ctx.vendor,
31
34
  config: {
32
35
  ...(ctx.config ?? {}),
33
36
  },
34
- histories: transformPrismaComponentsHistories(ctx.state()),
37
+ histories: transformPrismaComponentsHistories(ctx.state(), prefix),
35
38
  tokenUsage: ctx.usage(),
36
39
  controllers: [
37
40
  createApplication({
@@ -1,16 +1,20 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { v4 } from "uuid";
2
3
 
3
4
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
4
5
  import { AutoBeState } from "../../context/AutoBeState";
5
6
 
6
7
  export const transformPrismaComponentsHistories = (
7
8
  state: AutoBeState,
9
+ prefix: string | null = null,
8
10
  ): Array<
9
11
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
10
12
  > => {
11
13
  if (state.analyze === null)
12
14
  return [
13
15
  {
16
+ id: v4(),
17
+ created_at: new Date().toISOString(),
14
18
  type: "systemMessage",
15
19
  text: [
16
20
  "Requirement analysis is not yet completed.",
@@ -21,10 +25,14 @@ export const transformPrismaComponentsHistories = (
21
25
  ];
22
26
  return [
23
27
  {
28
+ id: v4(),
29
+ created_at: new Date().toISOString(),
24
30
  type: "systemMessage",
25
31
  text: AutoBeSystemPromptConstant.PRISMA_COMPONENT,
26
32
  },
27
33
  {
34
+ id: v4(),
35
+ created_at: new Date().toISOString(),
28
36
  type: "assistantMessage",
29
37
  text: [
30
38
  "Here is the requirement analysis report.",
@@ -40,6 +48,26 @@ export const transformPrismaComponentsHistories = (
40
48
  "```json",
41
49
  JSON.stringify(state.analyze.files),
42
50
  "```",
51
+ "## Prefix",
52
+ "",
53
+ `* Prefix provided by the user: ${prefix}`,
54
+ "",
55
+ "The user wants all database schema (table) names to start with the prefix provided below.",
56
+ "If the prefix is `null`, it should be ignored.",
57
+ "If a prefix is provided, all table names **must begin with it**.",
58
+ "However, if there is a special-purpose prefix like `mv` (for materialized views), it **must precede** the given prefix.",
59
+ "",
60
+ "## Prefix Example",
61
+ "",
62
+ "If the prefix is `shopping`, then table names should be like:",
63
+ "",
64
+ "* `shopping_sales`",
65
+ "* `shopping_sale_options`",
66
+ "",
67
+ "In cases where a table is created for performance optimization purposes (e.g., materialized views), the `mv_` prefix must come first.",
68
+ "For example:",
69
+ "",
70
+ "* `mv_shopping_daily_stats`",
43
71
  ].join("\n"),
44
72
  },
45
73
  ];
@@ -1,5 +1,6 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
2
  import { IAutoBePrismaValidation } from "@autobe/interface";
3
+ import { v4 } from "uuid";
3
4
 
4
5
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
5
6
 
@@ -10,10 +11,14 @@ export const transformPrismaCorrectHistories = (
10
11
  > => {
11
12
  return [
12
13
  {
14
+ id: v4(),
15
+ created_at: new Date().toISOString(),
13
16
  type: "systemMessage",
14
17
  text: AutoBeSystemPromptConstant.PRISMA_CORRECT,
15
18
  },
16
19
  {
20
+ id: v4(),
21
+ created_at: new Date().toISOString(),
17
22
  type: "assistantMessage",
18
23
  text: [
19
24
  "Here is the Prisma application data what you made:",
@@ -24,6 +29,8 @@ export const transformPrismaCorrectHistories = (
24
29
  ].join("\n"),
25
30
  },
26
31
  {
32
+ id: v4(),
33
+ created_at: new Date().toISOString(),
27
34
  type: "assistantMessage",
28
35
  text: [
29
36
  "Below are the list of errors what you have to fix:",
@@ -34,6 +41,8 @@ export const transformPrismaCorrectHistories = (
34
41
  ].join("\n"),
35
42
  },
36
43
  {
44
+ id: v4(),
45
+ created_at: new Date().toISOString(),
37
46
  type: "systemMessage",
38
47
  text: [
39
48
  "Before fixing the schema files,",
@@ -1,4 +1,5 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { v4 } from "uuid";
2
3
 
3
4
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
4
5
  import { AutoBeState } from "../../context/AutoBeState";
@@ -11,6 +12,8 @@ export const transformPrismaHistories = (
11
12
  if (state.analyze === null)
12
13
  return [
13
14
  {
15
+ id: v4(),
16
+ created_at: new Date().toISOString(),
14
17
  type: "systemMessage",
15
18
  text: [
16
19
  "Requirement analysis is not yet completed.",
@@ -21,14 +24,20 @@ export const transformPrismaHistories = (
21
24
  ];
22
25
  return [
23
26
  {
27
+ id: v4(),
28
+ created_at: new Date().toISOString(),
24
29
  type: "systemMessage",
25
30
  text: AutoBeSystemPromptConstant.PRISMA,
26
31
  },
27
32
  {
33
+ id: v4(),
34
+ created_at: new Date().toISOString(),
28
35
  type: "assistantMessage",
29
36
  text: AutoBeSystemPromptConstant.PRISMA_EXAMPLE,
30
37
  },
31
38
  {
39
+ id: v4(),
40
+ created_at: new Date().toISOString(),
32
41
  type: "assistantMessage",
33
42
  text: [
34
43
  "Here is the requirement analysis report.",
@@ -1,5 +1,6 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
2
  import { AutoBeAnalyzeHistory } from "@autobe/interface";
3
+ import { v4 } from "uuid";
3
4
 
4
5
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
5
6
 
@@ -15,10 +16,14 @@ export const transformPrismaSchemaHistories = (
15
16
  > => {
16
17
  return [
17
18
  {
19
+ id: v4(),
20
+ created_at: new Date().toISOString(),
18
21
  type: "systemMessage",
19
22
  text: AutoBeSystemPromptConstant.PRISMA_SCHEMA,
20
23
  },
21
24
  {
25
+ id: v4(),
26
+ created_at: new Date().toISOString(),
22
27
  type: "systemMessage",
23
28
  text: [
24
29
  "Before making prisma schema files,",
@@ -29,6 +34,8 @@ export const transformPrismaSchemaHistories = (
29
34
  ].join("\n"),
30
35
  },
31
36
  {
37
+ id: v4(),
38
+ created_at: new Date().toISOString(),
32
39
  type: "assistantMessage",
33
40
  text: [
34
41
  "Here is the requirement analysis report.",