@autobe/agent 0.9.2 → 0.10.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.
- package/lib/AutoBeAgent.js +11 -4
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +7 -6
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/context/AutoBeTokenUsage.d.ts +15 -1
- package/lib/context/AutoBeTokenUsage.js +56 -1
- package/lib/context/AutoBeTokenUsage.js.map +1 -1
- package/lib/factory/createAutoBeApplication.js +288 -653
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/index.mjs +4225 -6681
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +80 -321
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js +0 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +93 -266
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +2 -2
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/orchestrate/index.d.ts +2 -2
- package/lib/orchestrate/index.js +4 -4
- package/lib/orchestrate/index.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +54 -142
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +189 -201
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +71 -174
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +706 -1099
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/transformInterfaceHistories.js +2 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +60 -177
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +502 -1073
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +519 -1125
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +9 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +8 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.d.ts +11 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +78 -0
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +25 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +326 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.d.ts +80 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.js +53 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +39 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js +3 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +5 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +127 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -0
- package/lib/orchestrate/test/compile/completeTestCode.d.ts +2 -0
- package/lib/orchestrate/test/compile/completeTestCode.js +21 -0
- package/lib/orchestrate/test/compile/completeTestCode.js.map +1 -0
- package/lib/orchestrate/test/{filterTestFileName.js → compile/filterTestFileName.js} +1 -1
- package/lib/orchestrate/test/compile/filterTestFileName.js.map +1 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.d.ts +3 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.js +27 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -0
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +5 -0
- package/lib/orchestrate/test/{compileTestScenario.js → compile/getTestScenarioArtifacts.js} +10 -5
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTest.js +14 -9
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.js +142 -448
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +258 -532
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestWrite.js +124 -90
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +121 -0
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestFunction.d.ts +8 -0
- package/lib/{utils/types/BackoffOptions.js → orchestrate/test/structures/IAutoBeTestFunction.js} +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestFunction.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +14 -2
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +112 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.d.ts +7 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js.map +1 -0
- package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +3 -2
- package/lib/orchestrate/test/transformTestCorrectHistories.js +28 -67
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.d.ts +5 -4
- package/lib/orchestrate/test/transformTestWriteHistories.js +161 -43
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
- package/lib/structures/IAutoBeConfig.d.ts +11 -0
- package/lib/utils/backoffRetry.d.ts +4 -7
- package/lib/utils/backoffRetry.js +19 -37
- package/lib/utils/backoffRetry.js.map +1 -1
- package/lib/utils/forceRetry.d.ts +1 -0
- package/lib/{orchestrate/orchestrateRealize.js → utils/forceRetry.js} +15 -8
- package/lib/utils/forceRetry.js.map +1 -0
- package/package.json +9 -12
- package/src/AutoBeAgent.ts +17 -3
- package/src/constants/AutoBeSystemPromptConstant.ts +7 -6
- package/src/context/AutoBeTokenUsage.ts +85 -1
- package/src/factory/createAutoBeApplication.ts +2 -3
- package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +8 -3
- package/src/orchestrate/analyze/AutoBeAnalyzeReviewer.ts +0 -1
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +6 -5
- package/src/orchestrate/facade/transformFacadeStateMessage.ts +2 -1
- package/src/orchestrate/index.ts +2 -2
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +4 -3
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +26 -23
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +6 -4
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +14 -11
- package/src/orchestrate/interface/transformInterfaceHistories.ts +2 -0
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +10 -5
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +11 -5
- package/src/orchestrate/prisma/orchestratePrismaSchema.ts +16 -8
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +9 -0
- package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +8 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +129 -0
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +148 -0
- package/src/orchestrate/realize/orchestrateRealizePlanner.ts +115 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +46 -0
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +136 -0
- package/src/orchestrate/test/compile/completeTestCode.ts +35 -0
- package/src/orchestrate/test/{filterTestFileName.ts → compile/filterTestFileName.ts} +1 -1
- package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +24 -0
- package/src/orchestrate/test/{compileTestScenario.ts → compile/getTestScenarioArtifacts.ts} +16 -8
- package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +240 -0
- package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +316 -0
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -0
- package/src/orchestrate/test/orchestrateTest.ts +33 -16
- package/src/orchestrate/test/orchestrateTestCorrect.ts +109 -497
- package/src/orchestrate/test/orchestrateTestScenario.ts +102 -71
- package/src/orchestrate/test/orchestrateTestWrite.ts +55 -181
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +126 -0
- package/src/orchestrate/test/structures/IAutoBeTestFunction.ts +10 -0
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +14 -2
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +117 -0
- package/src/orchestrate/test/structures/IAutoBeTestWriteResult.ts +9 -0
- package/src/orchestrate/test/transformTestCorrectHistories.ts +38 -71
- package/src/orchestrate/test/transformTestWriteHistories.ts +88 -46
- package/src/structures/IAutoBeConfig.ts +9 -0
- package/src/utils/backoffRetry.ts +25 -36
- package/src/utils/forceRetry.ts +13 -0
- package/lib/factory/invertOpenApiDocument.d.ts +0 -3
- package/lib/factory/invertOpenApiDocument.js +0 -51
- package/lib/factory/invertOpenApiDocument.js.map +0 -1
- package/lib/orchestrate/orchestrateRealize.d.ts +0 -5
- package/lib/orchestrate/orchestrateRealize.js.map +0 -1
- package/lib/orchestrate/test/compileTestScenario.d.ts +0 -5
- package/lib/orchestrate/test/compileTestScenario.js.map +0 -1
- package/lib/orchestrate/test/filterTestFileName.js.map +0 -1
- package/lib/utils/StringUtil.d.ts +0 -4
- package/lib/utils/StringUtil.js +0 -43
- package/lib/utils/StringUtil.js.map +0 -1
- package/lib/utils/types/BackoffOptions.d.ts +0 -12
- package/lib/utils/types/BackoffOptions.js.map +0 -1
- package/src/factory/invertOpenApiDocument.ts +0 -63
- package/src/orchestrate/orchestrateRealize.ts +0 -18
- package/src/utils/StringUtil.ts +0 -45
- package/src/utils/types/BackoffOptions.ts +0 -15
- /package/lib/orchestrate/test/{filterTestFileName.d.ts → compile/filterTestFileName.d.ts} +0 -0
|
@@ -1,3 +1,87 @@
|
|
|
1
1
|
import { AgenticaTokenUsage } from "@agentica/core";
|
|
2
|
+
import { IAutoBeTokenUsageJson } from "@autobe/interface";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { IAutoBeApplication } from "./IAutoBeApplication";
|
|
5
|
+
|
|
6
|
+
export class AutoBeTokenUsage {
|
|
7
|
+
public readonly facade: AgenticaTokenUsage;
|
|
8
|
+
public readonly analyze: AgenticaTokenUsage;
|
|
9
|
+
public readonly prisma: AgenticaTokenUsage;
|
|
10
|
+
public readonly interface: AgenticaTokenUsage;
|
|
11
|
+
public readonly test: AgenticaTokenUsage;
|
|
12
|
+
public readonly realize: AgenticaTokenUsage;
|
|
13
|
+
|
|
14
|
+
public constructor(props?: IAutoBeTokenUsageJson) {
|
|
15
|
+
if (props === undefined) {
|
|
16
|
+
this.facade = new AgenticaTokenUsage();
|
|
17
|
+
this.analyze = new AgenticaTokenUsage();
|
|
18
|
+
this.prisma = new AgenticaTokenUsage();
|
|
19
|
+
this.interface = new AgenticaTokenUsage();
|
|
20
|
+
this.test = new AgenticaTokenUsage();
|
|
21
|
+
this.realize = new AgenticaTokenUsage();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.facade = new AgenticaTokenUsage(props.facade);
|
|
26
|
+
this.analyze = new AgenticaTokenUsage(props.analyze);
|
|
27
|
+
this.prisma = new AgenticaTokenUsage(props.prisma);
|
|
28
|
+
this.interface = new AgenticaTokenUsage(props.interface);
|
|
29
|
+
this.test = new AgenticaTokenUsage(props.test);
|
|
30
|
+
this.realize = new AgenticaTokenUsage(props.realize);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public record(
|
|
34
|
+
usage: AgenticaTokenUsage,
|
|
35
|
+
additionalStages: (keyof IAutoBeApplication)[] = [],
|
|
36
|
+
) {
|
|
37
|
+
this.facade.increment(usage);
|
|
38
|
+
additionalStages.forEach((stage) => {
|
|
39
|
+
this[stage].increment(usage);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public increment(usage: AutoBeTokenUsage) {
|
|
44
|
+
AutoBeTokenUsage.keys().forEach((key) => {
|
|
45
|
+
this[key].increment(usage[key]);
|
|
46
|
+
});
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public static plus(usageA: AutoBeTokenUsage, usageB: AutoBeTokenUsage) {
|
|
51
|
+
return new AutoBeTokenUsage({
|
|
52
|
+
facade: AgenticaTokenUsage.plus(usageA.facade, usageB.facade),
|
|
53
|
+
analyze: AgenticaTokenUsage.plus(usageA.analyze, usageB.analyze),
|
|
54
|
+
prisma: AgenticaTokenUsage.plus(usageA.prisma, usageB.prisma),
|
|
55
|
+
interface: AgenticaTokenUsage.plus(usageA.interface, usageB.interface),
|
|
56
|
+
test: AgenticaTokenUsage.plus(usageA.test, usageB.test),
|
|
57
|
+
realize: AgenticaTokenUsage.plus(usageA.realize, usageB.realize),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public toJSON(): IAutoBeTokenUsageJson {
|
|
62
|
+
return {
|
|
63
|
+
facade: this.facade.toJSON(),
|
|
64
|
+
analyze: this.analyze.toJSON(),
|
|
65
|
+
prisma: this.prisma.toJSON(),
|
|
66
|
+
interface: this.interface.toJSON(),
|
|
67
|
+
test: this.test.toJSON(),
|
|
68
|
+
realize: this.realize.toJSON(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @internal */
|
|
73
|
+
private static keys(): ("facade" | keyof IAutoBeApplication)[] {
|
|
74
|
+
return ["facade", "analyze", "prisma", "interface", "test", "realize"];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// /** Type check statements */
|
|
79
|
+
// 1 as unknown as AutoBeTokenUsage satisfies {
|
|
80
|
+
// [key in "facade" | keyof IAutoBeApplication]: AgenticaTokenUsage;
|
|
81
|
+
// };
|
|
82
|
+
|
|
83
|
+
// 1 as unknown as IAutoBeTokenUsageJson satisfies {
|
|
84
|
+
// [key in "facade" | keyof IAutoBeApplication]: IAutoBeInternalTokenUsageJson;
|
|
85
|
+
// };
|
|
86
|
+
|
|
87
|
+
// 1 as unknown as IAutoBeInternalTokenUsageJson satisfies IAgenticaTokenUsageJson;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IAgenticaController } from "@agentica/core";
|
|
2
|
+
import { StringUtil } from "@autobe/utils";
|
|
2
3
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
3
4
|
import typia from "typia";
|
|
4
5
|
|
|
@@ -7,10 +8,9 @@ import { IAutoBeApplication } from "../context/IAutoBeApplication";
|
|
|
7
8
|
import { assertSchemaModel } from "../context/assertSchemaModel";
|
|
8
9
|
import { orchestrateAnalyze } from "../orchestrate/analyze/orchestrateAnalyze";
|
|
9
10
|
import { orchestrateInterface } from "../orchestrate/interface/orchestrateInterface";
|
|
10
|
-
import { orchestrateRealize } from "../orchestrate/orchestrateRealize";
|
|
11
11
|
import { orchestratePrisma } from "../orchestrate/prisma/orchestratePrisma";
|
|
12
|
+
import { orchestrateRealize } from "../orchestrate/realize/orchestrateRealize";
|
|
12
13
|
import { orchestrateTest } from "../orchestrate/test/orchestrateTest";
|
|
13
|
-
import { StringUtil } from "../utils/StringUtil";
|
|
14
14
|
|
|
15
15
|
export const createAutoBeController = <Model extends ILlmSchema.Model>(props: {
|
|
16
16
|
model: Model;
|
|
@@ -128,5 +128,4 @@ const collection = {
|
|
|
128
128
|
llama: claude,
|
|
129
129
|
deepseek: claude,
|
|
130
130
|
"3.1": claude,
|
|
131
|
-
"3.0": typia.llm.application<IAutoBeApplication, "3.0">(),
|
|
132
131
|
};
|
|
@@ -49,7 +49,6 @@ export class AutoBeAnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
49
49
|
describe: null,
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
-
tokenUsage: ctx.usage(),
|
|
53
52
|
histories: [
|
|
54
53
|
{
|
|
55
54
|
id: v4(),
|
|
@@ -99,7 +98,12 @@ export class AutoBeAnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
99
98
|
return "Abort due to excess retry count";
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
const
|
|
101
|
+
const agent = this.createAnalyzeAgent();
|
|
102
|
+
const response = await agent.conversate(content);
|
|
103
|
+
|
|
104
|
+
const tokenUsage = agent.getTokenUsage();
|
|
105
|
+
this.ctx.usage().record(tokenUsage, ["analyze"]);
|
|
106
|
+
|
|
103
107
|
const lastMessage = response[response.length - 1]!;
|
|
104
108
|
|
|
105
109
|
if ("text" in lastMessage) {
|
|
@@ -134,6 +138,8 @@ export class AutoBeAnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
134
138
|
const filenames = Object.keys(this.fileMap).join(",");
|
|
135
139
|
const command = `Please proceed with the review of these files only.: ${filenames}`;
|
|
136
140
|
const response = await reviewer.conversate(command);
|
|
141
|
+
this.ctx.usage().record(reviewer.getTokenUsage(), ["analyze"]);
|
|
142
|
+
|
|
137
143
|
const review = response.find((el) => el.type === "assistantMessage");
|
|
138
144
|
|
|
139
145
|
if (review) {
|
|
@@ -210,5 +216,4 @@ const collection = {
|
|
|
210
216
|
llama: claude,
|
|
211
217
|
deepseek: claude,
|
|
212
218
|
"3.1": claude,
|
|
213
|
-
"3.0": typia.llm.application<AutoBeAnalyzeFileSystem, "3.0">(),
|
|
214
219
|
};
|
|
@@ -57,13 +57,15 @@ export const orchestrateAnalyze =
|
|
|
57
57
|
(el) => el.type === "assistantMessage" || el.type === "userMessage",
|
|
58
58
|
),
|
|
59
59
|
],
|
|
60
|
-
tokenUsage: ctx.usage(),
|
|
61
60
|
});
|
|
62
61
|
enforceToolCall(agentica);
|
|
63
62
|
|
|
64
|
-
const determined = await agentica
|
|
65
|
-
"Design a complete list of documents for that document"
|
|
66
|
-
|
|
63
|
+
const determined = await agentica
|
|
64
|
+
.conversate("Design a complete list of documents for that document")
|
|
65
|
+
.finally(() => {
|
|
66
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
67
|
+
ctx.usage().record(tokenUsage, ["analyze"]);
|
|
68
|
+
});
|
|
67
69
|
|
|
68
70
|
const lastMessage = determined[determined.length - 1]!;
|
|
69
71
|
if (lastMessage.type === "assistantMessage") {
|
|
@@ -261,5 +263,4 @@ const collection = {
|
|
|
261
263
|
llama: claude,
|
|
262
264
|
deepseek: claude,
|
|
263
265
|
"3.1": claude,
|
|
264
|
-
"3.0": typia.llm.application<DeterminingFiles, "3.0">(),
|
|
265
266
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { StringUtil } from "@autobe/utils";
|
|
2
|
+
|
|
1
3
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
2
4
|
import { AutoBeState } from "../../context/AutoBeState";
|
|
3
|
-
import { StringUtil } from "../../utils/StringUtil";
|
|
4
5
|
|
|
5
6
|
export function transformFacadeStateMessage(state: AutoBeState): string {
|
|
6
7
|
const currentState: ICurrentState = getCurrentState(state);
|
package/src/orchestrate/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { orchestrateAnalyze as analyze } from "./analyze/orchestrateAnalyze";
|
|
2
2
|
export { orchestrateInterface as interface } from "./interface/orchestrateInterface";
|
|
3
|
-
export { orchestrateRealize as realize } from "./orchestrateRealize";
|
|
4
|
-
export { orchestrateTest as test } from "./test/orchestrateTest";
|
|
5
3
|
export { orchestratePrisma as prisma } from "./prisma/orchestratePrisma";
|
|
4
|
+
export { orchestrateRealize as realize } from "./realize/orchestrateRealize";
|
|
5
|
+
export { orchestrateTest as test } from "./test/orchestrateTest";
|
|
@@ -75,7 +75,6 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
75
75
|
].join("\n"),
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
|
-
tokenUsage: ctx.usage(),
|
|
79
78
|
controllers: [
|
|
80
79
|
createApplication({
|
|
81
80
|
model: ctx.model,
|
|
@@ -96,7 +95,10 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
96
95
|
});
|
|
97
96
|
enforceToolCall(agentica);
|
|
98
97
|
|
|
99
|
-
await agentica.conversate("Fill missing schema types please")
|
|
98
|
+
await agentica.conversate("Fill missing schema types please").finally(() => {
|
|
99
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
100
|
+
ctx.usage().record(tokenUsage, ["interface"]);
|
|
101
|
+
});
|
|
100
102
|
if (pointer.value === null) {
|
|
101
103
|
// unreachable
|
|
102
104
|
throw new Error(
|
|
@@ -186,7 +188,6 @@ const collection = {
|
|
|
186
188
|
llama: claude,
|
|
187
189
|
deepseek: claude,
|
|
188
190
|
"3.1": claude,
|
|
189
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
190
191
|
};
|
|
191
192
|
|
|
192
193
|
interface IApplication {
|
|
@@ -127,7 +127,6 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
127
127
|
].join("\n"),
|
|
128
128
|
},
|
|
129
129
|
],
|
|
130
|
-
tokenUsage: ctx.usage(),
|
|
131
130
|
controllers: [
|
|
132
131
|
createApplication({
|
|
133
132
|
model: ctx.model,
|
|
@@ -145,27 +144,32 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
145
144
|
enforceToolCall(agentica);
|
|
146
145
|
|
|
147
146
|
const already: string[] = Object.keys(oldbie.schemas);
|
|
148
|
-
await agentica
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
147
|
+
await agentica
|
|
148
|
+
.conversate(
|
|
149
|
+
[
|
|
150
|
+
"Make type components please.",
|
|
151
|
+
"",
|
|
152
|
+
"Here is the list of request/response bodies' type names from",
|
|
153
|
+
"OpenAPI operations. Make type components of them. If more object",
|
|
154
|
+
"types are required during making the components, please make them",
|
|
155
|
+
"too.",
|
|
156
|
+
"",
|
|
157
|
+
...Array.from(remained).map((k) => `- \`${k}\``),
|
|
158
|
+
...(already.length !== 0
|
|
159
|
+
? [
|
|
160
|
+
"",
|
|
161
|
+
"> By the way, here is the list of components schemas what you've",
|
|
162
|
+
"> already made. So, you don't need to make them again.",
|
|
163
|
+
">",
|
|
164
|
+
...already.map((k) => `> - \`${k}\``),
|
|
165
|
+
]
|
|
166
|
+
: []),
|
|
167
|
+
].join("\n"),
|
|
168
|
+
)
|
|
169
|
+
.finally(() => {
|
|
170
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
171
|
+
ctx.usage().record(tokenUsage, ["interface"]);
|
|
172
|
+
});
|
|
169
173
|
if (pointer.value === null) {
|
|
170
174
|
// never be happened
|
|
171
175
|
throw new Error("Failed to create components.");
|
|
@@ -212,7 +216,6 @@ const collection = {
|
|
|
212
216
|
llama: claude,
|
|
213
217
|
deepseek: claude,
|
|
214
218
|
"3.1": claude,
|
|
215
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
216
219
|
};
|
|
217
220
|
|
|
218
221
|
interface IApplication {
|
|
@@ -43,7 +43,6 @@ export async function orchestrateInterfaceEndpoints<
|
|
|
43
43
|
ctx.state(),
|
|
44
44
|
AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
|
|
45
45
|
),
|
|
46
|
-
tokenUsage: ctx.usage(),
|
|
47
46
|
controllers: [
|
|
48
47
|
createApplication({
|
|
49
48
|
model: ctx.model,
|
|
@@ -55,8 +54,12 @@ export async function orchestrateInterfaceEndpoints<
|
|
|
55
54
|
],
|
|
56
55
|
});
|
|
57
56
|
|
|
58
|
-
const histories: MicroAgenticaHistory<Model>[] =
|
|
59
|
-
|
|
57
|
+
const histories: MicroAgenticaHistory<Model>[] = await agentica
|
|
58
|
+
.conversate(content)
|
|
59
|
+
.finally(() => {
|
|
60
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
61
|
+
ctx.usage().record(tokenUsage, ["interface"]);
|
|
62
|
+
});
|
|
60
63
|
if (histories.at(-1)?.type === "assistantMessage")
|
|
61
64
|
return {
|
|
62
65
|
...(histories.at(-1)! as AgenticaAssistantMessageHistory),
|
|
@@ -114,7 +117,6 @@ const collection = {
|
|
|
114
117
|
llama: claude,
|
|
115
118
|
deepseek: claude,
|
|
116
119
|
"3.1": claude,
|
|
117
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
118
120
|
};
|
|
119
121
|
|
|
120
122
|
interface IApplication {
|
|
@@ -101,7 +101,6 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
101
101
|
ctx.state(),
|
|
102
102
|
AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
|
|
103
103
|
),
|
|
104
|
-
tokenUsage: ctx.usage(),
|
|
105
104
|
controllers: [
|
|
106
105
|
createApplication({
|
|
107
106
|
model: ctx.model,
|
|
@@ -113,15 +112,20 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
113
112
|
],
|
|
114
113
|
});
|
|
115
114
|
enforceToolCall(agentica);
|
|
116
|
-
await agentica
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
await agentica
|
|
116
|
+
.conversate(
|
|
117
|
+
[
|
|
118
|
+
"Make API operations for below endpoints:",
|
|
119
|
+
"",
|
|
120
|
+
"```json",
|
|
121
|
+
JSON.stringify(Array.from(endpoints), null, 2),
|
|
122
|
+
"```",
|
|
123
|
+
].join("\n"),
|
|
124
|
+
)
|
|
125
|
+
.finally(() => {
|
|
126
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
127
|
+
ctx.usage().record(tokenUsage, ["interface"]);
|
|
128
|
+
});
|
|
125
129
|
if (pointer.value === null) throw new Error("Failed to create operations."); // never be happened
|
|
126
130
|
return pointer.value;
|
|
127
131
|
}
|
|
@@ -185,7 +189,6 @@ const collection = {
|
|
|
185
189
|
llama: claude,
|
|
186
190
|
deepseek: claude,
|
|
187
191
|
"3.1": claude,
|
|
188
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
189
192
|
};
|
|
190
193
|
|
|
191
194
|
interface IApplication {
|
|
@@ -124,6 +124,8 @@ export const transformInterfaceHistories = (
|
|
|
124
124
|
type: "assistantMessage",
|
|
125
125
|
text: [
|
|
126
126
|
"Database schema and entity relationship diagrams are ready.",
|
|
127
|
+
"You should also look at this and consider logic including membership/login and token issuance.",
|
|
128
|
+
"You can use table's name to define role in operations.",
|
|
127
129
|
"",
|
|
128
130
|
"## Prisma DB Schema",
|
|
129
131
|
"```json",
|
|
@@ -33,9 +33,11 @@ export async function orchestratePrismaComponents<
|
|
|
33
33
|
vendor: ctx.vendor,
|
|
34
34
|
config: {
|
|
35
35
|
...(ctx.config ?? {}),
|
|
36
|
+
executor: {
|
|
37
|
+
describe: null,
|
|
38
|
+
},
|
|
36
39
|
},
|
|
37
40
|
histories: transformPrismaComponentsHistories(ctx.state(), prefix),
|
|
38
|
-
tokenUsage: ctx.usage(),
|
|
39
41
|
controllers: [
|
|
40
42
|
createApplication({
|
|
41
43
|
model: ctx.model,
|
|
@@ -49,8 +51,12 @@ export async function orchestratePrismaComponents<
|
|
|
49
51
|
],
|
|
50
52
|
});
|
|
51
53
|
|
|
52
|
-
const histories: MicroAgenticaHistory<Model>[] =
|
|
53
|
-
|
|
54
|
+
const histories: MicroAgenticaHistory<Model>[] = await agentica
|
|
55
|
+
.conversate(content)
|
|
56
|
+
.finally(() => {
|
|
57
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
58
|
+
ctx.usage().record(tokenUsage, ["prisma"]);
|
|
59
|
+
});
|
|
54
60
|
if (histories.at(-1)?.type === "assistantMessage")
|
|
55
61
|
return {
|
|
56
62
|
...(histories.at(-1)! as AgenticaAssistantMessageHistory),
|
|
@@ -105,7 +111,6 @@ const collection = {
|
|
|
105
111
|
llama: claude,
|
|
106
112
|
deepseek: claude,
|
|
107
113
|
"3.1": claude,
|
|
108
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
109
114
|
};
|
|
110
115
|
|
|
111
116
|
interface IApplication {
|
|
@@ -154,7 +159,7 @@ interface IExtractComponentsProps {
|
|
|
154
159
|
* {
|
|
155
160
|
* {
|
|
156
161
|
* filename: "schema-01-users.prisma",
|
|
157
|
-
* tables: ["user", "user_profile", "user_settings"]
|
|
162
|
+
* tables: ["user", "admin", "moderator", "user_profile", "user_settings"]
|
|
158
163
|
* },
|
|
159
164
|
* {
|
|
160
165
|
* filename: "schema-02-articles.prisma",
|
|
@@ -60,9 +60,11 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
60
60
|
vendor: ctx.vendor,
|
|
61
61
|
config: {
|
|
62
62
|
...(ctx.config ?? {}),
|
|
63
|
+
executor: {
|
|
64
|
+
describe: null,
|
|
65
|
+
},
|
|
63
66
|
},
|
|
64
67
|
histories: transformPrismaCorrectHistories(result),
|
|
65
|
-
tokenUsage: ctx.usage(),
|
|
66
68
|
controllers: [
|
|
67
69
|
createApplication({
|
|
68
70
|
model: ctx.model,
|
|
@@ -75,9 +77,14 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
75
77
|
enforceToolCall(agentica);
|
|
76
78
|
|
|
77
79
|
// REQUEST CORRECTION
|
|
78
|
-
await agentica
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
await agentica
|
|
81
|
+
.conversate(
|
|
82
|
+
"Resolve the compilation errors in the provided Prisma schema files.",
|
|
83
|
+
)
|
|
84
|
+
.finally(() => {
|
|
85
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
86
|
+
ctx.usage().record(tokenUsage, ["prisma"]);
|
|
87
|
+
});
|
|
81
88
|
if (pointer.value === null) {
|
|
82
89
|
console.error(
|
|
83
90
|
"Unreachable error: PrismaCompilerAgent.pointer.value is null",
|
|
@@ -147,7 +154,6 @@ const collection = {
|
|
|
147
154
|
llama: claude,
|
|
148
155
|
deepseek: claude,
|
|
149
156
|
"3.1": claude,
|
|
150
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
151
157
|
};
|
|
152
158
|
|
|
153
159
|
interface IApplication {
|
|
@@ -8,6 +8,7 @@ import typia from "typia";
|
|
|
8
8
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
9
9
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
10
10
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
11
|
+
import { forceRetry } from "../../utils/forceRetry";
|
|
11
12
|
import { transformPrismaSchemaHistories } from "./transformPrismaSchemaHistories";
|
|
12
13
|
|
|
13
14
|
export async function orchestratePrismaSchemas<Model extends ILlmSchema.Model>(
|
|
@@ -23,11 +24,13 @@ export async function orchestratePrismaSchemas<Model extends ILlmSchema.Model>(
|
|
|
23
24
|
let i: number = 0;
|
|
24
25
|
return await Promise.all(
|
|
25
26
|
components.map(async (c) => {
|
|
26
|
-
const result: IMakePrismaSchemaFileProps = await
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const result: IMakePrismaSchemaFileProps = await forceRetry(() =>
|
|
28
|
+
process(ctx, {
|
|
29
|
+
filename: c.filename,
|
|
30
|
+
tables: c.tables,
|
|
31
|
+
entireTables,
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
31
34
|
const event: AutoBePrismaSchemasEvent = {
|
|
32
35
|
type: "prismaSchemas",
|
|
33
36
|
created_at: start.toISOString(),
|
|
@@ -58,9 +61,11 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
58
61
|
vendor: ctx.vendor,
|
|
59
62
|
config: {
|
|
60
63
|
...(ctx.config ?? {}),
|
|
64
|
+
executor: {
|
|
65
|
+
describe: null,
|
|
66
|
+
},
|
|
61
67
|
},
|
|
62
68
|
histories: transformPrismaSchemaHistories(ctx.state().analyze!, component),
|
|
63
|
-
tokenUsage: ctx.usage(),
|
|
64
69
|
controllers: [
|
|
65
70
|
createApplication({
|
|
66
71
|
model: ctx.model,
|
|
@@ -78,7 +83,11 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
78
83
|
],
|
|
79
84
|
});
|
|
80
85
|
enforceToolCall(agentica);
|
|
81
|
-
await agentica.conversate("Make prisma schema file please")
|
|
86
|
+
await agentica.conversate("Make prisma schema file please").finally(() => {
|
|
87
|
+
const tokenUsage = agentica.getTokenUsage();
|
|
88
|
+
ctx.usage().record(tokenUsage, ["prisma"]);
|
|
89
|
+
});
|
|
90
|
+
|
|
82
91
|
if (pointer.value === null)
|
|
83
92
|
throw new Error("Unreachable code: Prisma Schema not generated");
|
|
84
93
|
return pointer.value;
|
|
@@ -119,7 +128,6 @@ const collection = {
|
|
|
119
128
|
llama: claude,
|
|
120
129
|
deepseek: claude,
|
|
121
130
|
"3.1": claude,
|
|
122
|
-
"3.0": typia.llm.application<IApplication, "3.0">(),
|
|
123
131
|
};
|
|
124
132
|
|
|
125
133
|
interface IApplication {
|
|
@@ -68,6 +68,15 @@ export const transformPrismaComponentsHistories = (
|
|
|
68
68
|
"For example:",
|
|
69
69
|
"",
|
|
70
70
|
"* `mv_shopping_daily_stats`",
|
|
71
|
+
"",
|
|
72
|
+
"## User Role Handling",
|
|
73
|
+
"",
|
|
74
|
+
"If the Requirement Analysis Report contains User Role information, **do not normalize** user roles into a single table.",
|
|
75
|
+
"Instead, create separate tables for each distinct role mentioned in the requirements.",
|
|
76
|
+
"",
|
|
77
|
+
"For example, if the requirements mention User, Admin, and Moderator roles:",
|
|
78
|
+
"",
|
|
79
|
+
"* Create separate tables: `User`, `Admin`, `Moderator` (or with prefix: `shopping_user`, `shopping_admin`, `shopping_moderator`)",
|
|
71
80
|
].join("\n"),
|
|
72
81
|
},
|
|
73
82
|
];
|
|
@@ -59,6 +59,14 @@ export const transformPrismaSchemaHistories = (
|
|
|
59
59
|
...component.tables.map((table) => ` - ${table}`),
|
|
60
60
|
` - Entire tables you can reference:`,
|
|
61
61
|
...component.entireTables.map((table) => ` - ${table}`),
|
|
62
|
+
"",
|
|
63
|
+
"## User Role Rules",
|
|
64
|
+
"",
|
|
65
|
+
"**CRITICAL**: For User Role tables (User, Admin, Moderator, etc.):",
|
|
66
|
+
"1. **Separate tables** - Each role = independent table (User, Admin, Moderator tables)",
|
|
67
|
+
"2. **No `role` field** - Never include role enum fields in any table",
|
|
68
|
+
"",
|
|
69
|
+
"You can use TPT (Table Per Type) pattern with FK relationships if needed, or completely separate tables.",
|
|
62
70
|
].join("\n"),
|
|
63
71
|
},
|
|
64
72
|
];
|