@autobe/agent 0.0.0 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/lib/AutoBeAgent.d.ts +9 -7
- package/lib/AutoBeAgent.js +106 -14
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/analyze/AnalyzeAgent.d.ts +24 -0
- package/lib/analyze/AnalyzeAgent.js +817 -0
- package/lib/analyze/AnalyzeAgent.js.map +1 -0
- package/lib/analyze/CreateReviewerAgent.d.ts +16 -0
- package/lib/analyze/CreateReviewerAgent.js +97 -0
- package/lib/analyze/CreateReviewerAgent.js.map +1 -0
- package/lib/analyze/Planning.d.ts +63 -0
- package/lib/{orchestrate/orchestratePrisma.js → analyze/Planning.js} +28 -11
- package/lib/analyze/Planning.js.map +1 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +14 -0
- package/lib/constants/AutoBeSystemPromptConstant.js +4 -0
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -0
- package/lib/context/AutoBeContext.d.ts +7 -3
- package/lib/context/IAutoBeApplication.d.ts +72 -32
- package/lib/context/IAutoBeApplicationProps.d.ts +22 -2
- package/lib/context/IAutoBeApplicationResult.d.ts +0 -1
- package/lib/context/assertSchemaModel.d.ts +2 -0
- package/lib/context/assertSchemaModel.js +15 -0
- package/lib/context/assertSchemaModel.js.map +1 -0
- package/lib/{internal/transformAgenticaHistory.d.ts → factory/createAgenticaHistory.d.ts} +1 -1
- package/lib/{internal/transformAgenticaHistory.js → factory/createAgenticaHistory.js} +3 -4
- package/lib/factory/createAgenticaHistory.js.map +1 -0
- package/lib/factory/createAutoBeApplication.js +1195 -0
- package/lib/factory/createAutoBeApplication.js.map +1 -0
- package/lib/factory/createAutoBeState.js.map +1 -0
- package/lib/factory/index.d.ts +2 -0
- package/lib/factory/index.js +19 -0
- package/lib/factory/index.js.map +1 -0
- package/lib/factory/invertOpenApiDocument.d.ts +3 -0
- package/lib/factory/invertOpenApiDocument.js +51 -0
- package/lib/factory/invertOpenApiDocument.js.map +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +5455 -547
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.d.ts +2 -0
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +46 -0
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -0
- package/lib/orchestrate/index.d.ts +2 -2
- package/lib/orchestrate/index.js +2 -2
- package/lib/orchestrate/index.js.map +1 -1
- package/lib/orchestrate/interface/OpenApiEndpointComparator.d.ts +5 -0
- package/lib/orchestrate/interface/OpenApiEndpointComparator.js +16 -0
- package/lib/orchestrate/interface/OpenApiEndpointComparator.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterface.d.ts +5 -0
- package/lib/orchestrate/interface/orchestrateInterface.js +61 -0
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +702 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +452 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +2065 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.d.ts +3 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js +94 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -0
- package/lib/orchestrate/orchestrateAnalyze.d.ts +1 -3
- package/lib/orchestrate/orchestrateAnalyze.js +60 -6
- package/lib/orchestrate/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/{orchestratePrisma.d.ts → prisma/orchestratePrisma.d.ts} +3 -6
- package/lib/orchestrate/prisma/orchestratePrisma.js +103 -0
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrismaCompiler.d.ts +6 -0
- package/lib/orchestrate/prisma/orchestratePrismaCompiler.js +436 -0
- package/lib/orchestrate/prisma/orchestratePrismaCompiler.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +5 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +437 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrismaSchema.d.ts +7 -0
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +369 -0
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaCompilerHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaCompilerHistories.js +44 -0
- package/lib/orchestrate/prisma/transformPrismaCompilerHistories.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +42 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.js +46 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +46 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -0
- package/lib/structures/IAutoBeConfig.d.ts +4 -4
- package/lib/utils/StringUtil.d.ts +4 -0
- package/lib/utils/StringUtil.js +43 -0
- package/lib/utils/StringUtil.js.map +1 -0
- package/lib/utils/divideArray.d.ts +4 -0
- package/lib/utils/divideArray.js +19 -0
- package/lib/utils/divideArray.js.map +1 -0
- package/lib/utils/emplaceMap.d.ts +1 -0
- package/lib/utils/emplaceMap.js +13 -0
- package/lib/utils/emplaceMap.js.map +1 -0
- package/package.json +29 -8
- package/src/AutoBeAgent.ts +227 -101
- package/src/analyze/AnalyzeAgent.ts +167 -0
- package/src/analyze/CreateReviewerAgent.ts +126 -0
- package/src/analyze/Planning.ts +75 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +15 -0
- package/src/context/AutoBeContext.ts +19 -15
- package/src/context/AutoBeState.ts +15 -15
- package/src/context/AutoBeTokenUsage.ts +3 -3
- package/src/context/IAutoBeApplication.ts +112 -72
- package/src/context/IAutoBeApplicationProps.ts +27 -6
- package/src/context/IAutoBeApplicationResult.ts +3 -4
- package/src/context/assertSchemaModel.ts +17 -0
- package/src/{internal/transformAgenticaHistory.ts → factory/createAgenticaHistory.ts} +51 -54
- package/src/{internal → factory}/createAutoBeApplication.ts +52 -47
- package/src/{internal → factory}/createAutoBeState.ts +14 -14
- package/src/factory/index.ts +2 -0
- package/src/factory/invertOpenApiDocument.ts +63 -0
- package/src/index.ts +13 -12
- package/src/orchestrate/facade/transformFacadeStateMessage.ts +58 -0
- package/src/orchestrate/index.ts +5 -5
- package/src/orchestrate/interface/OpenApiEndpointComparator.ts +15 -0
- package/src/orchestrate/interface/orchestrateInterface.ts +66 -0
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +324 -0
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +140 -0
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +247 -0
- package/src/orchestrate/interface/transformInterfaceHistories.ts +98 -0
- package/src/orchestrate/orchestrateAnalyze.ts +86 -21
- package/src/orchestrate/orchestrateRealize.ts +18 -18
- package/src/orchestrate/orchestrateTest.ts +18 -18
- package/src/orchestrate/prisma/orchestratePrisma.ts +117 -0
- package/src/orchestrate/prisma/orchestratePrismaCompiler.ts +194 -0
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +176 -0
- package/src/orchestrate/prisma/orchestratePrismaSchema.ts +181 -0
- package/src/orchestrate/prisma/transformPrismaCompilerHistories.ts +49 -0
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +46 -0
- package/src/orchestrate/prisma/transformPrismaHistories.ts +50 -0
- package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +50 -0
- package/src/structures/IAutoBeConfig.ts +25 -25
- package/src/structures/IAutoBeProps.ts +13 -13
- package/src/structures/IAutoBeVendor.ts +3 -3
- package/src/utils/StringUtil.ts +45 -0
- package/src/utils/divideArray.ts +16 -0
- package/src/utils/emplaceMap.ts +14 -0
- package/lib/factory/transformRouteDocument.d.ts +0 -3
- package/lib/factory/transformRouteDocument.js +0 -50
- package/lib/factory/transformRouteDocument.js.map +0 -1
- package/lib/internal/createAutoBeApplication.js +0 -1452
- package/lib/internal/createAutoBeApplication.js.map +0 -1
- package/lib/internal/createAutoBeState.js.map +0 -1
- package/lib/internal/transformAgenticaHistory.js.map +0 -1
- package/lib/orchestrate/interface/AutoBeInterfaceAgent.d.ts +0 -0
- package/lib/orchestrate/interface/AutoBeInterfaceAgent.js +0 -2
- package/lib/orchestrate/interface/AutoBeInterfaceAgent.js.map +0 -1
- package/lib/orchestrate/orchestrateInterface.d.ts +0 -8
- package/lib/orchestrate/orchestrateInterface.js +0 -22
- package/lib/orchestrate/orchestrateInterface.js.map +0 -1
- package/lib/orchestrate/orchestratePrisma.js.map +0 -1
- package/src/factory/transformRouteDocument.ts +0 -49
- package/src/orchestrate/interface/AutoBeInterfaceAgent.ts +0 -0
- package/src/orchestrate/orchestrateInterface.ts +0 -21
- package/src/orchestrate/orchestratePrisma.ts +0 -21
- /package/lib/{internal → factory}/createAutoBeApplication.d.ts +0 -0
- /package/lib/{internal → factory}/createAutoBeState.d.ts +0 -0
- /package/lib/{internal → factory}/createAutoBeState.js +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
|
+
import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
|
|
4
|
+
import { HashMap, HashSet, IPointer } from "tstl";
|
|
5
|
+
import typia from "typia";
|
|
6
|
+
|
|
7
|
+
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
8
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
9
|
+
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
10
|
+
import { divideArray } from "../../utils/divideArray";
|
|
11
|
+
import { OpenApiEndpointComparator } from "./OpenApiEndpointComparator";
|
|
12
|
+
import { transformInterfaceHistories } from "./transformInterfaceHistories";
|
|
13
|
+
|
|
14
|
+
export async function orchestrateInterfaceOperations<
|
|
15
|
+
Model extends ILlmSchema.Model,
|
|
16
|
+
>(
|
|
17
|
+
ctx: AutoBeContext<Model>,
|
|
18
|
+
endpoints: AutoBeOpenApi.IEndpoint[],
|
|
19
|
+
capacity: number = 12,
|
|
20
|
+
): Promise<AutoBeOpenApi.IOperation[]> {
|
|
21
|
+
const matrix: AutoBeOpenApi.IEndpoint[][] = divideArray({
|
|
22
|
+
array: endpoints,
|
|
23
|
+
capacity,
|
|
24
|
+
});
|
|
25
|
+
let completed: number = 0;
|
|
26
|
+
const operations: AutoBeOpenApi.IOperation[][] = await Promise.all(
|
|
27
|
+
matrix.map(async (it) => {
|
|
28
|
+
const row: AutoBeOpenApi.IOperation[] = await divideAndConquer(
|
|
29
|
+
ctx,
|
|
30
|
+
it,
|
|
31
|
+
3,
|
|
32
|
+
(count) => {
|
|
33
|
+
completed += count;
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
ctx.dispatch({
|
|
37
|
+
type: "interfaceOperations",
|
|
38
|
+
operations: row,
|
|
39
|
+
completed,
|
|
40
|
+
total: endpoints.length,
|
|
41
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
42
|
+
created_at: new Date().toISOString(),
|
|
43
|
+
});
|
|
44
|
+
return row;
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
return operations.flat();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function divideAndConquer<Model extends ILlmSchema.Model>(
|
|
51
|
+
ctx: AutoBeContext<Model>,
|
|
52
|
+
endpoints: AutoBeOpenApi.IEndpoint[],
|
|
53
|
+
retry: number,
|
|
54
|
+
progress: (completed: number) => void,
|
|
55
|
+
): Promise<AutoBeOpenApi.IOperation[]> {
|
|
56
|
+
const remained: HashSet<AutoBeOpenApi.IEndpoint> = new HashSet(
|
|
57
|
+
endpoints,
|
|
58
|
+
OpenApiEndpointComparator.hashCode,
|
|
59
|
+
OpenApiEndpointComparator.equals,
|
|
60
|
+
);
|
|
61
|
+
const operations: HashMap<AutoBeOpenApi.IEndpoint, AutoBeOpenApi.IOperation> =
|
|
62
|
+
new HashMap(
|
|
63
|
+
OpenApiEndpointComparator.hashCode,
|
|
64
|
+
OpenApiEndpointComparator.equals,
|
|
65
|
+
);
|
|
66
|
+
for (let i: number = 0; i < retry; ++i) {
|
|
67
|
+
if (remained.empty() === true || operations.size() >= endpoints.length)
|
|
68
|
+
break;
|
|
69
|
+
const before: number = operations.size();
|
|
70
|
+
const newbie: AutoBeOpenApi.IOperation[] = await process(
|
|
71
|
+
ctx,
|
|
72
|
+
Array.from(remained),
|
|
73
|
+
);
|
|
74
|
+
for (const item of newbie) {
|
|
75
|
+
operations.set(item, item);
|
|
76
|
+
remained.erase(item);
|
|
77
|
+
}
|
|
78
|
+
if (operations.size() - before !== 0) progress(operations.size() - before);
|
|
79
|
+
}
|
|
80
|
+
return operations.toJSON().map((it) => it.second);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function process<Model extends ILlmSchema.Model>(
|
|
84
|
+
ctx: AutoBeContext<Model>,
|
|
85
|
+
endpoints: AutoBeOpenApi.IEndpoint[],
|
|
86
|
+
): Promise<AutoBeOpenApi.IOperation[]> {
|
|
87
|
+
const pointer: IPointer<AutoBeOpenApi.IOperation[] | null> = {
|
|
88
|
+
value: null,
|
|
89
|
+
};
|
|
90
|
+
const agentica: MicroAgentica<Model> = new MicroAgentica({
|
|
91
|
+
model: ctx.model,
|
|
92
|
+
vendor: ctx.vendor,
|
|
93
|
+
config: {
|
|
94
|
+
...(ctx.config ?? {}),
|
|
95
|
+
executor: {
|
|
96
|
+
describe: null,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
histories: transformInterfaceHistories(
|
|
100
|
+
ctx.state(),
|
|
101
|
+
AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
|
|
102
|
+
),
|
|
103
|
+
tokenUsage: ctx.usage(),
|
|
104
|
+
controllers: [
|
|
105
|
+
createApplication({
|
|
106
|
+
model: ctx.model,
|
|
107
|
+
build: async (endpoints) => {
|
|
108
|
+
pointer.value = endpoints;
|
|
109
|
+
},
|
|
110
|
+
pointer,
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
agentica.on("request", async (event) => {
|
|
115
|
+
event.body.tool_choice = "required";
|
|
116
|
+
});
|
|
117
|
+
await agentica.conversate(
|
|
118
|
+
[
|
|
119
|
+
"Make API operations for below endpoints:",
|
|
120
|
+
"",
|
|
121
|
+
"```json",
|
|
122
|
+
JSON.stringify(Array.from(endpoints), null, 2),
|
|
123
|
+
"```",
|
|
124
|
+
].join("\n"),
|
|
125
|
+
);
|
|
126
|
+
if (pointer.value === null) throw new Error("Failed to create operations."); // never be happened
|
|
127
|
+
return pointer.value;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
131
|
+
model: Model;
|
|
132
|
+
build: (operations: AutoBeOpenApi.IOperation[]) => Promise<void>;
|
|
133
|
+
pointer: IPointer<AutoBeOpenApi.IOperation[] | null>;
|
|
134
|
+
}): IAgenticaController.IClass<Model> {
|
|
135
|
+
assertSchemaModel(props.model);
|
|
136
|
+
|
|
137
|
+
const application: ILlmApplication<Model> = collection[
|
|
138
|
+
props.model
|
|
139
|
+
] as unknown as ILlmApplication<Model>;
|
|
140
|
+
application.functions[0].validate = (next: unknown): IValidation => {
|
|
141
|
+
const result: IValidation<IMakeOperationProps> =
|
|
142
|
+
typia.validate<IMakeOperationProps>(next);
|
|
143
|
+
if (result.success === false) return result;
|
|
144
|
+
props.pointer.value = result.data.operations;
|
|
145
|
+
|
|
146
|
+
const errors: IValidation.IError[] = [];
|
|
147
|
+
result.data.operations.forEach((op, i) => {
|
|
148
|
+
if (op.method === "get" && op.requestBody !== null)
|
|
149
|
+
errors.push({
|
|
150
|
+
path: `operations[${i}].requestBody`,
|
|
151
|
+
expected:
|
|
152
|
+
"GET method should not have request body. Change method, or re-design the operation.",
|
|
153
|
+
value: op.requestBody,
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
if (errors.length !== 0)
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
errors,
|
|
160
|
+
data: next,
|
|
161
|
+
};
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
protocol: "class",
|
|
166
|
+
name: "interface",
|
|
167
|
+
application,
|
|
168
|
+
execute: {
|
|
169
|
+
makeOperations: async (next) => {
|
|
170
|
+
await props.build(next.operations);
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
} satisfies IApplication,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const claude = typia.llm.application<
|
|
180
|
+
IApplication,
|
|
181
|
+
"claude",
|
|
182
|
+
{ reference: true }
|
|
183
|
+
>();
|
|
184
|
+
const collection = {
|
|
185
|
+
chatgpt: typia.llm.application<
|
|
186
|
+
IApplication,
|
|
187
|
+
"chatgpt",
|
|
188
|
+
{ reference: true }
|
|
189
|
+
>(),
|
|
190
|
+
claude,
|
|
191
|
+
llama: claude,
|
|
192
|
+
deepseek: claude,
|
|
193
|
+
"3.1": claude,
|
|
194
|
+
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
interface IApplication {
|
|
198
|
+
/**
|
|
199
|
+
* Generate detailed API operations from path/method combinations.
|
|
200
|
+
*
|
|
201
|
+
* This function creates complete API operations following REST principles and
|
|
202
|
+
* quality standards. Each generated operation includes specification, path,
|
|
203
|
+
* method, detailed multi-paragraph description, concise summary, parameters,
|
|
204
|
+
* and appropriate request/response bodies.
|
|
205
|
+
*
|
|
206
|
+
* The function processes as many operations as possible in a single call,
|
|
207
|
+
* with progress tracking to ensure iterative completion of all required
|
|
208
|
+
* endpoints.
|
|
209
|
+
*
|
|
210
|
+
* @param props Properties containing the operations to generate.
|
|
211
|
+
*/
|
|
212
|
+
makeOperations(props: IMakeOperationProps): void;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
interface IMakeOperationProps {
|
|
216
|
+
/**
|
|
217
|
+
* Array of API operations to generate.
|
|
218
|
+
*
|
|
219
|
+
* Each operation in this array must include:
|
|
220
|
+
*
|
|
221
|
+
* - Specification: Detailed API specification with clear purpose and
|
|
222
|
+
* functionality
|
|
223
|
+
* - Path: Resource-centric URL path (e.g., "/resources/{resourceId}")
|
|
224
|
+
* - Method: HTTP method (get, post, put, delete, patch)
|
|
225
|
+
* - Description: Extremely detailed multi-paragraph description referencing
|
|
226
|
+
* Prisma schema comments
|
|
227
|
+
* - Summary: Concise one-sentence summary of the endpoint
|
|
228
|
+
* - Parameters: Array of all necessary parameters with descriptions and schema
|
|
229
|
+
* definitions
|
|
230
|
+
* - RequestBody: For POST/PUT/PATCH methods, with typeName referencing
|
|
231
|
+
* components.schemas
|
|
232
|
+
* - ResponseBody: With typeName referencing appropriate response type
|
|
233
|
+
*
|
|
234
|
+
* All operations must follow strict quality standards:
|
|
235
|
+
*
|
|
236
|
+
* 1. Detailed descriptions referencing Prisma schema comments
|
|
237
|
+
* 2. Accurate parameter definitions matching path parameters
|
|
238
|
+
* 3. Appropriate request/response body type references
|
|
239
|
+
* 4. Consistent patterns for CRUD operations
|
|
240
|
+
*
|
|
241
|
+
* For list retrievals (typically PATCH), include pagination, search, and
|
|
242
|
+
* sorting. For detail retrieval (GET), return a single resource. For creation
|
|
243
|
+
* (POST), use .ICreate request body. For modification (PUT), use .IUpdate
|
|
244
|
+
* request body.
|
|
245
|
+
*/
|
|
246
|
+
operations: AutoBeOpenApi.IOperation[];
|
|
247
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
|
|
3
|
+
import { AutoBeState } from "../../context/AutoBeState";
|
|
4
|
+
|
|
5
|
+
export const transformInterfaceHistories = (
|
|
6
|
+
state: AutoBeState,
|
|
7
|
+
systemMessage: string,
|
|
8
|
+
): Array<
|
|
9
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
10
|
+
> => {
|
|
11
|
+
if (state.analyze === null)
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
type: "systemMessage",
|
|
15
|
+
text: [
|
|
16
|
+
"Requirement analysis is not yet completed.",
|
|
17
|
+
"Don't call the any tool function,",
|
|
18
|
+
"but say to process the requirement analysis.",
|
|
19
|
+
].join(" "),
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
else if (state.prisma === null)
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
type: "systemMessage",
|
|
26
|
+
text: [
|
|
27
|
+
"Prisma DB schema generation is not yet completed.",
|
|
28
|
+
"Don't call the any tool function,",
|
|
29
|
+
"but say to process the Prisma DB schema generation.",
|
|
30
|
+
].join(" "),
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
else if (state.analyze.step !== state.prisma.step)
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
type: "systemMessage",
|
|
37
|
+
text: [
|
|
38
|
+
"Prisma DB schema generation has not been updated",
|
|
39
|
+
"for the latest requirement analysis.",
|
|
40
|
+
"Don't call the any tool function,",
|
|
41
|
+
"but say to re-process the Prisma DB schema generation.",
|
|
42
|
+
].join(" "),
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
else if (state.prisma.result.type !== "success")
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
type: "systemMessage",
|
|
49
|
+
text: [
|
|
50
|
+
"Prisma DB schema generation has not been updated",
|
|
51
|
+
"for the latest requirement analysis.",
|
|
52
|
+
"Don't call the any tool function,",
|
|
53
|
+
"but say to re-process the Prisma DB schema generation.",
|
|
54
|
+
].join(" "),
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
type: "systemMessage",
|
|
60
|
+
text: systemMessage,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "assistantMessage",
|
|
64
|
+
text: [
|
|
65
|
+
"Requirement analysis and Prisma DB schema generation are ready.",
|
|
66
|
+
"",
|
|
67
|
+
"Call the provided tool function to generate the OpenAPI document",
|
|
68
|
+
"referencing below requirement analysis and Prisma DB schema.",
|
|
69
|
+
"",
|
|
70
|
+
// User Request
|
|
71
|
+
`## User Request`,
|
|
72
|
+
"",
|
|
73
|
+
state.analyze.reason,
|
|
74
|
+
"",
|
|
75
|
+
// Requirement Analysis Report
|
|
76
|
+
`## Requirement Analysis Report`,
|
|
77
|
+
"",
|
|
78
|
+
"```json",
|
|
79
|
+
JSON.stringify(state.analyze.files),
|
|
80
|
+
"```",
|
|
81
|
+
].join("\n"),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "assistantMessage",
|
|
85
|
+
text: [
|
|
86
|
+
"## Prisma DB Schema",
|
|
87
|
+
"```json",
|
|
88
|
+
JSON.stringify(state.prisma.result.schemas),
|
|
89
|
+
"```",
|
|
90
|
+
"",
|
|
91
|
+
"## Entity Relationship Diagrams",
|
|
92
|
+
"```json",
|
|
93
|
+
JSON.stringify(state.prisma.result.diagrams),
|
|
94
|
+
"```",
|
|
95
|
+
].join("\n"),
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
};
|
|
@@ -1,21 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeAnalyzeHistory,
|
|
3
|
-
AutoBeAssistantMessageHistory,
|
|
4
|
-
} from "@autobe/interface";
|
|
5
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAnalyzeHistory,
|
|
3
|
+
AutoBeAssistantMessageHistory,
|
|
4
|
+
} from "@autobe/interface";
|
|
5
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
6
|
+
import { IPointer } from "tstl";
|
|
7
|
+
import { v4 } from "uuid";
|
|
8
|
+
|
|
9
|
+
import { AnalyzeAgent } from "../analyze/AnalyzeAgent";
|
|
10
|
+
import { createReviewerAgent } from "../analyze/CreateReviewerAgent";
|
|
11
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
12
|
+
import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
|
|
13
|
+
|
|
14
|
+
type Filename = string;
|
|
15
|
+
type FileContent = string;
|
|
16
|
+
|
|
17
|
+
/** @todo Kakasoo */
|
|
18
|
+
export const orchestrateAnalyze =
|
|
19
|
+
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
20
|
+
async (
|
|
21
|
+
props: IAutoBeApplicationProps,
|
|
22
|
+
): Promise<AutoBeAssistantMessageHistory | AutoBeAnalyzeHistory> => {
|
|
23
|
+
const pointer: IPointer<{ files: Record<Filename, FileContent> } | null> = {
|
|
24
|
+
value: null,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const userPlanningRequirements = props.userPlanningRequirements;
|
|
28
|
+
if (!userPlanningRequirements) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Unable to prepare a proposal because there is no user requirement`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const step = ctx.state().analyze?.step ?? 0;
|
|
35
|
+
const created_at = new Date().toISOString();
|
|
36
|
+
ctx.dispatch({
|
|
37
|
+
type: "analyzeStart",
|
|
38
|
+
reason: userPlanningRequirements,
|
|
39
|
+
step,
|
|
40
|
+
created_at,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const agent = new AnalyzeAgent(createReviewerAgent, ctx, pointer);
|
|
44
|
+
const response = await agent.conversate(
|
|
45
|
+
[
|
|
46
|
+
`Please write a user requirement report.`,
|
|
47
|
+
"```json",
|
|
48
|
+
JSON.stringify(userPlanningRequirements),
|
|
49
|
+
"```",
|
|
50
|
+
].join("\n"),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (pointer.value?.files) {
|
|
54
|
+
const history: AutoBeAnalyzeHistory = {
|
|
55
|
+
id: v4(),
|
|
56
|
+
type: "analyze",
|
|
57
|
+
reason: userPlanningRequirements,
|
|
58
|
+
files: pointer.value.files,
|
|
59
|
+
step,
|
|
60
|
+
created_at,
|
|
61
|
+
completed_at: new Date().toISOString(),
|
|
62
|
+
};
|
|
63
|
+
ctx.state().analyze = history;
|
|
64
|
+
ctx.histories().push(history);
|
|
65
|
+
ctx.dispatch({
|
|
66
|
+
type: "analyzeComplete",
|
|
67
|
+
files: pointer.value.files,
|
|
68
|
+
step,
|
|
69
|
+
created_at,
|
|
70
|
+
});
|
|
71
|
+
return history;
|
|
72
|
+
}
|
|
73
|
+
const history: AutoBeAssistantMessageHistory = {
|
|
74
|
+
id: v4(),
|
|
75
|
+
type: "assistantMessage",
|
|
76
|
+
text: response,
|
|
77
|
+
created_at,
|
|
78
|
+
completed_at: new Date().toISOString(),
|
|
79
|
+
};
|
|
80
|
+
ctx.dispatch({
|
|
81
|
+
type: "assistantMessage",
|
|
82
|
+
text: response,
|
|
83
|
+
created_at,
|
|
84
|
+
});
|
|
85
|
+
return history;
|
|
86
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeAssistantMessageHistory,
|
|
3
|
-
AutoBeRealizeHistory,
|
|
4
|
-
} from "@autobe/interface";
|
|
5
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
6
|
-
|
|
7
|
-
import { AutoBeContext } from "../context/AutoBeContext";
|
|
8
|
-
import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
|
|
9
|
-
|
|
10
|
-
export const orchestrateRealize =
|
|
11
|
-
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
12
|
-
async (
|
|
13
|
-
props: IAutoBeApplicationProps,
|
|
14
|
-
): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
|
|
15
|
-
ctx;
|
|
16
|
-
props;
|
|
17
|
-
return null!;
|
|
18
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAssistantMessageHistory,
|
|
3
|
+
AutoBeRealizeHistory,
|
|
4
|
+
} from "@autobe/interface";
|
|
5
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
6
|
+
|
|
7
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
8
|
+
import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
|
|
9
|
+
|
|
10
|
+
export const orchestrateRealize =
|
|
11
|
+
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
12
|
+
async (
|
|
13
|
+
props: IAutoBeApplicationProps,
|
|
14
|
+
): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
|
|
15
|
+
ctx;
|
|
16
|
+
props;
|
|
17
|
+
return null!;
|
|
18
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeAssistantMessageHistory,
|
|
3
|
-
AutoBeTestHistory,
|
|
4
|
-
} from "@autobe/interface";
|
|
5
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
6
|
-
|
|
7
|
-
import { AutoBeContext } from "../context/AutoBeContext";
|
|
8
|
-
import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
|
|
9
|
-
|
|
10
|
-
export const orchestrateTest =
|
|
11
|
-
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
12
|
-
async (
|
|
13
|
-
props: IAutoBeApplicationProps,
|
|
14
|
-
): Promise<AutoBeAssistantMessageHistory | AutoBeTestHistory> => {
|
|
15
|
-
ctx;
|
|
16
|
-
props;
|
|
17
|
-
return null!;
|
|
18
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAssistantMessageHistory,
|
|
3
|
+
AutoBeTestHistory,
|
|
4
|
+
} from "@autobe/interface";
|
|
5
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
6
|
+
|
|
7
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
8
|
+
import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
|
|
9
|
+
|
|
10
|
+
export const orchestrateTest =
|
|
11
|
+
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
12
|
+
async (
|
|
13
|
+
props: IAutoBeApplicationProps,
|
|
14
|
+
): Promise<AutoBeAssistantMessageHistory | AutoBeTestHistory> => {
|
|
15
|
+
ctx;
|
|
16
|
+
props;
|
|
17
|
+
return null!;
|
|
18
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAssistantMessageHistory,
|
|
3
|
+
AutoBePrismaHistory,
|
|
4
|
+
IAutoBePrismaCompilerResult,
|
|
5
|
+
} from "@autobe/interface";
|
|
6
|
+
import { AutoBePrismaSchemasEvent } from "@autobe/interface/src/events/AutoBePrismaSchemasEvent";
|
|
7
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
8
|
+
import { v4 } from "uuid";
|
|
9
|
+
|
|
10
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
11
|
+
import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
|
|
12
|
+
import { orchestratePrismaCompiler } from "./orchestratePrismaCompiler";
|
|
13
|
+
import { orchestratePrismaComponents } from "./orchestratePrismaComponent";
|
|
14
|
+
import { orchestratePrismaSchemas } from "./orchestratePrismaSchema";
|
|
15
|
+
|
|
16
|
+
export const orchestratePrisma =
|
|
17
|
+
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
18
|
+
async (
|
|
19
|
+
props: IAutoBeApplicationProps,
|
|
20
|
+
): Promise<AutoBePrismaHistory | AutoBeAssistantMessageHistory> => {
|
|
21
|
+
const start: Date = new Date();
|
|
22
|
+
|
|
23
|
+
// COMPONENTS
|
|
24
|
+
const components = await orchestratePrismaComponents(ctx);
|
|
25
|
+
|
|
26
|
+
if (components.type === "assistantMessage") {
|
|
27
|
+
ctx.dispatch(components);
|
|
28
|
+
ctx.histories().push(components);
|
|
29
|
+
return components;
|
|
30
|
+
} else ctx.dispatch(components);
|
|
31
|
+
|
|
32
|
+
// SCHEMAS
|
|
33
|
+
const events: AutoBePrismaSchemasEvent[] = await orchestratePrismaSchemas(
|
|
34
|
+
ctx,
|
|
35
|
+
components.components,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// COMPILER
|
|
39
|
+
const files: Record<string, string> = Object.fromEntries(
|
|
40
|
+
events.map((e) => [e.filename, e.content]),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const { description, ...compiledResult } = await orchestratePrismaCompiler(
|
|
44
|
+
ctx,
|
|
45
|
+
files,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const result = processCompilerResult(compiledResult);
|
|
49
|
+
|
|
50
|
+
const history: AutoBePrismaHistory = {
|
|
51
|
+
type: "prisma",
|
|
52
|
+
id: v4(),
|
|
53
|
+
created_at: start.toISOString(),
|
|
54
|
+
completed_at: new Date().toISOString(),
|
|
55
|
+
reason: props.reason,
|
|
56
|
+
description,
|
|
57
|
+
result: result,
|
|
58
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
59
|
+
};
|
|
60
|
+
ctx.state().prisma = history;
|
|
61
|
+
ctx.histories().push(history);
|
|
62
|
+
if (result.type === "success")
|
|
63
|
+
ctx.dispatch({
|
|
64
|
+
type: "prismaComplete",
|
|
65
|
+
schemas: result.schemas,
|
|
66
|
+
document: result.document,
|
|
67
|
+
diagrams: result.diagrams,
|
|
68
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
69
|
+
created_at: new Date().toISOString(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return history;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Process the compiler result to generate the main Prisma schema file.
|
|
77
|
+
*
|
|
78
|
+
* If the compiler result is a success, the main Prisma schema file will be
|
|
79
|
+
* generated.
|
|
80
|
+
*
|
|
81
|
+
* @param result - The compiler result to process.
|
|
82
|
+
* @returns The processed compiler result with the main Prisma schema file.
|
|
83
|
+
*/
|
|
84
|
+
function processCompilerResult(
|
|
85
|
+
result: IAutoBePrismaCompilerResult,
|
|
86
|
+
): IAutoBePrismaCompilerResult {
|
|
87
|
+
const content = `
|
|
88
|
+
generator client {
|
|
89
|
+
provider = "prisma-client-js"
|
|
90
|
+
previewFeatures = ["postgresqlExtensions", "views"]
|
|
91
|
+
binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
datasource db {
|
|
95
|
+
provider = "postgresql"
|
|
96
|
+
url = env("DATABASE_URL")
|
|
97
|
+
extensions = []
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
generator markdown {
|
|
101
|
+
provider = "prisma-markdown"
|
|
102
|
+
output = "../docs/ERD.md"
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
if (result.type === "success") {
|
|
107
|
+
return {
|
|
108
|
+
...result,
|
|
109
|
+
schemas: {
|
|
110
|
+
...result.schemas,
|
|
111
|
+
"main.prisma": content,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return result;
|
|
117
|
+
}
|