@autobe/agent 0.16.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/lib/AutoBeAgent.js +9 -9
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +2 -2
- package/lib/context/AutoBeContext.d.ts +16 -4
- package/lib/context/AutoBeTokenUsage.d.ts +168 -11
- package/lib/context/AutoBeTokenUsage.js +152 -32
- package/lib/context/AutoBeTokenUsage.js.map +1 -1
- package/lib/context/AutoBeTokenUsageComponent.d.ts +116 -0
- package/lib/context/AutoBeTokenUsageComponent.js +120 -0
- package/lib/context/AutoBeTokenUsageComponent.js.map +1 -0
- package/lib/factory/createAutoBeApplication.js +1 -1
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/factory/createAutoBeContext.d.ts +19 -0
- package/lib/factory/createAutoBeContext.js +141 -0
- package/lib/factory/createAutoBeContext.js.map +1 -0
- package/lib/factory/getAutoBeGenerated.d.ts +1 -1
- package/lib/factory/getAutoBeGenerated.js +14 -11
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/factory/getAutoBeRealizeGenerated.d.ts +7 -0
- package/lib/factory/getAutoBeRealizeGenerated.js +27 -0
- package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1090 -927
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +9 -36
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +9 -9
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js +1 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js +6 -23
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
- package/lib/orchestrate/prisma/{transformPrismaComponentsHistories.d.ts → histories/transformPrismaComponentsHistories.d.ts} +1 -1
- package/lib/orchestrate/prisma/{transformPrismaComponentsHistories.js → histories/transformPrismaComponentsHistories.js} +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -0
- package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -0
- package/lib/orchestrate/prisma/{transformPrismaHistories.d.ts → histories/transformPrismaHistories.d.ts} +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaHistories.js.map +1 -0
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +48 -0
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrisma.d.ts +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +9 -29
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +126 -19
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +10 -10
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +128 -150
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
- package/lib/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.d.ts +120 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.js +3 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.js.map +1 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.d.ts +142 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.js +3 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.js.map +1 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.d.ts +209 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.js +3 -0
- package/lib/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +13 -24
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +23 -23
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js +8 -26
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/package.json +8 -8
- package/src/AutoBeAgent.ts +10 -9
- package/src/constants/AutoBeSystemPromptConstant.ts +2 -2
- package/src/context/AutoBeContext.ts +30 -3
- package/src/context/AutoBeTokenUsage.ts +252 -54
- package/src/context/AutoBeTokenUsageComponent.ts +180 -0
- package/src/factory/createAutoBeApplication.ts +1 -1
- package/src/factory/createAutoBeContext.ts +193 -0
- package/src/factory/getAutoBeGenerated.ts +14 -21
- package/src/factory/getAutoBeRealizeGenerated.ts +30 -0
- package/src/index.ts +1 -0
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +9 -38
- package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +1 -1
- package/src/orchestrate/analyze/writeDocumentUntilReviewPassed.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterface.ts +4 -21
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +1 -1
- package/src/orchestrate/prisma/{transformPrismaComponentsHistories.ts → histories/transformPrismaComponentsHistories.ts} +2 -2
- package/src/orchestrate/prisma/{transformPrismaCorrectHistories.ts → histories/transformPrismaCorrectHistories.ts} +1 -1
- package/src/orchestrate/prisma/{transformPrismaHistories.ts → histories/transformPrismaHistories.ts} +2 -2
- package/src/orchestrate/prisma/{transformPrismaSchemaHistories.ts → histories/transformPrismaSchemaHistories.ts} +1 -1
- package/src/orchestrate/prisma/orchestratePrisma.ts +45 -68
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +13 -81
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +8 -148
- package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -82
- package/src/orchestrate/prisma/structures/IAutoBePrismaComponentApplication.ts +124 -0
- package/src/orchestrate/prisma/structures/IAutoBePrismaCorrectApplication.ts +144 -0
- package/src/orchestrate/prisma/structures/IAutoBePrismaSchemaApplication.ts +214 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +19 -32
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +1 -1
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +1 -1
- package/src/orchestrate/test/orchestrateTest.ts +6 -26
- package/src/orchestrate/test/orchestrateTestCorrect.ts +1 -1
- package/src/orchestrate/test/orchestrateTestScenario.ts +1 -1
- package/src/orchestrate/test/orchestrateTestWrite.ts +1 -1
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +0 -1
- package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +0 -1
- package/lib/orchestrate/prisma/transformPrismaHistories.js.map +0 -1
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +0 -48
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +0 -1
- /package/lib/orchestrate/prisma/{transformPrismaCorrectHistories.d.ts → histories/transformPrismaCorrectHistories.d.ts} +0 -0
- /package/lib/orchestrate/prisma/{transformPrismaCorrectHistories.js → histories/transformPrismaCorrectHistories.js} +0 -0
- /package/lib/orchestrate/prisma/{transformPrismaHistories.js → histories/transformPrismaHistories.js} +0 -0
- /package/lib/orchestrate/prisma/{transformPrismaSchemaHistories.d.ts → histories/transformPrismaSchemaHistories.d.ts} +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAnalyzeCompleteEvent,
|
|
3
|
+
AutoBeAnalyzeHistory,
|
|
4
|
+
AutoBeAnalyzeStartEvent,
|
|
5
|
+
AutoBeAssistantMessageEvent,
|
|
6
|
+
AutoBeEvent,
|
|
7
|
+
AutoBeHistory,
|
|
8
|
+
AutoBeInterfaceCompleteEvent,
|
|
9
|
+
AutoBeInterfaceHistory,
|
|
10
|
+
AutoBeInterfaceStartEvent,
|
|
11
|
+
AutoBePrismaCompleteEvent,
|
|
12
|
+
AutoBePrismaHistory,
|
|
13
|
+
AutoBePrismaStartEvent,
|
|
14
|
+
AutoBeRealizeCompleteEvent,
|
|
15
|
+
AutoBeRealizeHistory,
|
|
16
|
+
AutoBeRealizeStartEvent,
|
|
17
|
+
AutoBeTestCompleteEvent,
|
|
18
|
+
AutoBeTestHistory,
|
|
19
|
+
AutoBeTestStartEvent,
|
|
20
|
+
IAutoBeCompiler,
|
|
21
|
+
IAutoBeCompilerListener,
|
|
22
|
+
IAutoBeGetFilesOptions,
|
|
23
|
+
} from "@autobe/interface";
|
|
24
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
25
|
+
import { v4 } from "uuid";
|
|
26
|
+
|
|
27
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
28
|
+
import { AutoBeState } from "../context/AutoBeState";
|
|
29
|
+
import { AutoBeTokenUsage } from "../context/AutoBeTokenUsage";
|
|
30
|
+
import { IAutoBeConfig } from "../structures/IAutoBeConfig";
|
|
31
|
+
import { IAutoBeVendor } from "../structures/IAutoBeVendor";
|
|
32
|
+
|
|
33
|
+
export const createAutoBeContext = <Model extends ILlmSchema.Model>(props: {
|
|
34
|
+
model: Model;
|
|
35
|
+
vendor: IAutoBeVendor;
|
|
36
|
+
compiler: () => Promise<IAutoBeCompiler>;
|
|
37
|
+
compilerListener: IAutoBeCompilerListener;
|
|
38
|
+
config: IAutoBeConfig;
|
|
39
|
+
state: () => AutoBeState;
|
|
40
|
+
files: (options: IAutoBeGetFilesOptions) => Promise<Record<string, string>>;
|
|
41
|
+
histories: () => AutoBeHistory[];
|
|
42
|
+
usage: () => AutoBeTokenUsage;
|
|
43
|
+
dispatch: (event: AutoBeEvent) => Promise<void>;
|
|
44
|
+
}): AutoBeContext<Model> => ({
|
|
45
|
+
model: props.model,
|
|
46
|
+
vendor: props.vendor,
|
|
47
|
+
config: props.config,
|
|
48
|
+
compilerListener: props.compilerListener,
|
|
49
|
+
compiler: props.compiler,
|
|
50
|
+
files: props.files,
|
|
51
|
+
histories: props.histories,
|
|
52
|
+
state: props.state,
|
|
53
|
+
usage: props.usage,
|
|
54
|
+
dispatch: createDispatch(props),
|
|
55
|
+
assistantMessage: (message) => {
|
|
56
|
+
props.histories().push(message);
|
|
57
|
+
setTimeout(() => props.dispatch(message).catch(() => {}));
|
|
58
|
+
return message;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const createDispatch = (props: {
|
|
63
|
+
state: () => AutoBeState;
|
|
64
|
+
histories: () => AutoBeHistory[];
|
|
65
|
+
dispatch: (event: AutoBeEvent) => Promise<void>;
|
|
66
|
+
}) => {
|
|
67
|
+
let analyzeStart: AutoBeAnalyzeStartEvent | null = null;
|
|
68
|
+
let prismaStart: AutoBePrismaStartEvent | null = null;
|
|
69
|
+
let interfaceStart: AutoBeInterfaceStartEvent | null = null;
|
|
70
|
+
let testStart: AutoBeTestStartEvent | null = null;
|
|
71
|
+
let realizeStart: AutoBeRealizeStartEvent | null = null;
|
|
72
|
+
return <Event extends Exclude<AutoBeEvent, AutoBeAssistantMessageEvent>>(
|
|
73
|
+
event: Event,
|
|
74
|
+
): AutoBeContext.DispatchHistory<Event> => {
|
|
75
|
+
// starts
|
|
76
|
+
if (event.type === "analyzeStart") analyzeStart = event;
|
|
77
|
+
else if (event.type === "prismaStart") prismaStart = event;
|
|
78
|
+
else if (event.type === "interfaceStart") interfaceStart = event;
|
|
79
|
+
else if (event.type === "testStart") testStart = event;
|
|
80
|
+
else if (event.type === "realizeStart") realizeStart = event;
|
|
81
|
+
// completes
|
|
82
|
+
else if (event.type === "analyzeComplete")
|
|
83
|
+
return transformAndDispatch<AutoBeAnalyzeCompleteEvent>({
|
|
84
|
+
dispatch: props.dispatch,
|
|
85
|
+
histories: props.histories,
|
|
86
|
+
state: props.state,
|
|
87
|
+
event,
|
|
88
|
+
history: {
|
|
89
|
+
type: "analyze",
|
|
90
|
+
id: v4(),
|
|
91
|
+
reason: analyzeStart?.reason ?? "",
|
|
92
|
+
prefix: event.prefix,
|
|
93
|
+
roles: event.roles,
|
|
94
|
+
files: event.files,
|
|
95
|
+
created_at: analyzeStart?.created_at ?? new Date().toISOString(),
|
|
96
|
+
completed_at: event.created_at,
|
|
97
|
+
step: event.step,
|
|
98
|
+
} satisfies AutoBeAnalyzeHistory,
|
|
99
|
+
}) as AutoBeContext.DispatchHistory<Event>;
|
|
100
|
+
else if (event.type === "prismaComplete")
|
|
101
|
+
return transformAndDispatch<AutoBePrismaCompleteEvent>({
|
|
102
|
+
dispatch: props.dispatch,
|
|
103
|
+
histories: props.histories,
|
|
104
|
+
state: props.state,
|
|
105
|
+
event,
|
|
106
|
+
history: {
|
|
107
|
+
type: "prisma",
|
|
108
|
+
id: v4(),
|
|
109
|
+
reason: prismaStart?.reason ?? "",
|
|
110
|
+
schemas: event.schemas,
|
|
111
|
+
result: event.result,
|
|
112
|
+
compiled: event.compiled,
|
|
113
|
+
created_at: prismaStart?.created_at ?? new Date().toISOString(),
|
|
114
|
+
completed_at: event.created_at,
|
|
115
|
+
step: event.step,
|
|
116
|
+
} satisfies AutoBePrismaHistory,
|
|
117
|
+
}) as AutoBeContext.DispatchHistory<Event>;
|
|
118
|
+
else if (event.type === "interfaceComplete")
|
|
119
|
+
return transformAndDispatch({
|
|
120
|
+
dispatch: props.dispatch,
|
|
121
|
+
histories: props.histories,
|
|
122
|
+
state: props.state,
|
|
123
|
+
event,
|
|
124
|
+
history: {
|
|
125
|
+
type: "interface",
|
|
126
|
+
id: v4(),
|
|
127
|
+
reason: interfaceStart?.reason ?? "",
|
|
128
|
+
document: event.document,
|
|
129
|
+
created_at: interfaceStart?.created_at ?? new Date().toISOString(),
|
|
130
|
+
completed_at: new Date().toISOString(),
|
|
131
|
+
step: event.step,
|
|
132
|
+
} satisfies AutoBeInterfaceHistory,
|
|
133
|
+
}) as AutoBeContext.DispatchHistory<Event>;
|
|
134
|
+
else if (event.type === "testComplete")
|
|
135
|
+
return transformAndDispatch<AutoBeTestCompleteEvent>({
|
|
136
|
+
dispatch: props.dispatch,
|
|
137
|
+
histories: props.histories,
|
|
138
|
+
state: props.state,
|
|
139
|
+
event,
|
|
140
|
+
history: {
|
|
141
|
+
type: "test",
|
|
142
|
+
id: v4(),
|
|
143
|
+
reason: testStart?.reason ?? "",
|
|
144
|
+
files: event.files,
|
|
145
|
+
compiled: event.compiled,
|
|
146
|
+
created_at: testStart?.created_at ?? new Date().toISOString(),
|
|
147
|
+
completed_at: new Date().toISOString(),
|
|
148
|
+
step: event.step,
|
|
149
|
+
} satisfies AutoBeTestHistory,
|
|
150
|
+
}) as AutoBeContext.DispatchHistory<Event>;
|
|
151
|
+
else if (event.type === "realizeComplete")
|
|
152
|
+
return transformAndDispatch<AutoBeRealizeCompleteEvent>({
|
|
153
|
+
dispatch: props.dispatch,
|
|
154
|
+
histories: props.histories,
|
|
155
|
+
state: props.state,
|
|
156
|
+
event,
|
|
157
|
+
history: {
|
|
158
|
+
type: "realize",
|
|
159
|
+
id: v4(),
|
|
160
|
+
reason: realizeStart?.reason ?? "",
|
|
161
|
+
authorizations: event.authorizations,
|
|
162
|
+
functions: event.functions,
|
|
163
|
+
controllers: event.controllers,
|
|
164
|
+
compiled: event.compiled,
|
|
165
|
+
created_at: realizeStart?.created_at ?? new Date().toISOString(),
|
|
166
|
+
completed_at: new Date().toISOString(),
|
|
167
|
+
step: event.step,
|
|
168
|
+
} satisfies AutoBeRealizeHistory,
|
|
169
|
+
}) as AutoBeContext.DispatchHistory<Event>;
|
|
170
|
+
props.dispatch(event).catch(() => {});
|
|
171
|
+
return null as AutoBeContext.DispatchHistory<Event>;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const transformAndDispatch = <
|
|
176
|
+
Event extends
|
|
177
|
+
| AutoBeAnalyzeCompleteEvent
|
|
178
|
+
| AutoBePrismaCompleteEvent
|
|
179
|
+
| AutoBeInterfaceCompleteEvent
|
|
180
|
+
| AutoBeTestCompleteEvent
|
|
181
|
+
| AutoBeRealizeCompleteEvent,
|
|
182
|
+
>(props: {
|
|
183
|
+
dispatch: (event: Event) => Promise<void>;
|
|
184
|
+
histories: () => AutoBeHistory[];
|
|
185
|
+
state: () => AutoBeState;
|
|
186
|
+
event: Event;
|
|
187
|
+
history: NonNullable<AutoBeContext.DispatchHistory<Event>>;
|
|
188
|
+
}): NonNullable<AutoBeContext.DispatchHistory<Event>> => {
|
|
189
|
+
props.histories().push(props.history);
|
|
190
|
+
props.state()[props.history.type] = props.history as any;
|
|
191
|
+
props.dispatch(props.event).catch(() => {});
|
|
192
|
+
return props.history;
|
|
193
|
+
};
|
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import { AutoBeState } from "../context/AutoBeState";
|
|
8
8
|
import { AutoBeTokenUsage } from "../context/AutoBeTokenUsage";
|
|
9
|
+
import { getAutoBeRealizeGenerated } from "./getAutoBeRealizeGenerated";
|
|
9
10
|
|
|
10
11
|
export async function getAutoBeGenerated(
|
|
11
12
|
compiler: IAutoBeCompiler,
|
|
12
13
|
state: AutoBeState,
|
|
13
|
-
histories: AutoBeHistory[]
|
|
14
|
+
histories: Readonly<AutoBeHistory[]>,
|
|
14
15
|
tokenUsage: AutoBeTokenUsage,
|
|
15
16
|
options?: Partial<IAutoBeGetFilesOptions>,
|
|
16
17
|
): Promise<Record<string, string>> {
|
|
@@ -26,6 +27,7 @@ export async function getAutoBeGenerated(
|
|
|
26
27
|
]),
|
|
27
28
|
),
|
|
28
29
|
);
|
|
30
|
+
if (options?.stage === "analyze") return ret;
|
|
29
31
|
|
|
30
32
|
// PRISMA
|
|
31
33
|
if (state.prisma?.step === state.analyze.step) {
|
|
@@ -54,6 +56,7 @@ export async function getAutoBeGenerated(
|
|
|
54
56
|
else if (state.prisma.compiled.type === "failure")
|
|
55
57
|
ret["prisma/compile-error-reason.log"] = state.prisma.compiled.reason;
|
|
56
58
|
}
|
|
59
|
+
if (options?.stage === "prisma") return ret;
|
|
57
60
|
|
|
58
61
|
// INTERFACE
|
|
59
62
|
if (state.interface?.step === state.analyze.step) {
|
|
@@ -78,6 +81,7 @@ export async function getAutoBeGenerated(
|
|
|
78
81
|
},
|
|
79
82
|
);
|
|
80
83
|
}
|
|
84
|
+
if (options?.stage === "interface") return ret;
|
|
81
85
|
|
|
82
86
|
// TEST
|
|
83
87
|
if (state.test?.step === state.analyze.step)
|
|
@@ -92,28 +96,17 @@ export async function getAutoBeGenerated(
|
|
|
92
96
|
);
|
|
93
97
|
|
|
94
98
|
// REALIZE
|
|
95
|
-
if (state.realize?.step === state.analyze.step)
|
|
96
|
-
Object.assign<Record<string, string>, Record<string, string>>(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
...Object.fromEntries(
|
|
101
|
-
state.realize.authorizations
|
|
102
|
-
.map((auth) => [
|
|
103
|
-
[auth.decorator.location, auth.decorator.content],
|
|
104
|
-
[auth.provider.location, auth.provider.content],
|
|
105
|
-
[auth.payload.location, auth.payload.content],
|
|
106
|
-
])
|
|
107
|
-
.flat(),
|
|
108
|
-
),
|
|
109
|
-
...(await compiler.realize.getTemplate()),
|
|
110
|
-
...(await compiler.realize.controller({
|
|
99
|
+
if (state.realize?.step === state.analyze.step)
|
|
100
|
+
Object.assign<Record<string, string>, Record<string, string>>(
|
|
101
|
+
ret,
|
|
102
|
+
await getAutoBeRealizeGenerated({
|
|
103
|
+
compiler,
|
|
111
104
|
document: state.interface!.document,
|
|
112
|
-
functions: state.realize.functions,
|
|
113
105
|
authorizations: state.realize.authorizations,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
functions: state.realize.functions,
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
if (options?.stage === "test") return ret;
|
|
117
110
|
|
|
118
111
|
// LOGGING
|
|
119
112
|
Object.assign<Record<string, string>, Record<string, string>>(ret, {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeOpenApi,
|
|
3
|
+
AutoBeRealizeAuthorization,
|
|
4
|
+
AutoBeRealizeFunction,
|
|
5
|
+
IAutoBeCompiler,
|
|
6
|
+
} from "@autobe/interface";
|
|
7
|
+
|
|
8
|
+
export const getAutoBeRealizeGenerated = async (props: {
|
|
9
|
+
compiler: IAutoBeCompiler;
|
|
10
|
+
document: AutoBeOpenApi.IDocument;
|
|
11
|
+
authorizations: AutoBeRealizeAuthorization[];
|
|
12
|
+
functions: AutoBeRealizeFunction[];
|
|
13
|
+
}): Promise<Record<string, string>> => ({
|
|
14
|
+
...Object.fromEntries(props.functions.map((f) => [f.location, f.content])),
|
|
15
|
+
...Object.fromEntries(
|
|
16
|
+
props.authorizations
|
|
17
|
+
.map((auth) => [
|
|
18
|
+
[auth.decorator.location, auth.decorator.content],
|
|
19
|
+
[auth.provider.location, auth.provider.content],
|
|
20
|
+
[auth.payload.location, auth.payload.content],
|
|
21
|
+
])
|
|
22
|
+
.flat(),
|
|
23
|
+
),
|
|
24
|
+
...(await props.compiler.realize.getTemplate()),
|
|
25
|
+
...(await props.compiler.realize.controller({
|
|
26
|
+
document: props.document,
|
|
27
|
+
functions: props.functions,
|
|
28
|
+
authorizations: props.authorizations,
|
|
29
|
+
})),
|
|
30
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -41,38 +41,29 @@ export const orchestrateAnalyze =
|
|
|
41
41
|
].join("\n"),
|
|
42
42
|
)
|
|
43
43
|
.finally(() => {
|
|
44
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
44
|
+
const tokenUsage = agentica.getTokenUsage().aggregate;
|
|
45
45
|
ctx.usage().record(tokenUsage, ["analyze"]);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
const composeInput = composeInputPointer.value;
|
|
49
|
-
if (composeInput === null)
|
|
50
|
-
return {
|
|
49
|
+
if (composeInput === null)
|
|
50
|
+
return ctx.assistantMessage({
|
|
51
51
|
id: v4(),
|
|
52
52
|
text: "Failed to analyze your request. please request again.",
|
|
53
53
|
type: "assistantMessage",
|
|
54
54
|
completed_at: new Date().toISOString(),
|
|
55
55
|
created_at: new Date().toISOString(),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
56
|
+
});
|
|
58
57
|
|
|
59
58
|
const { files: tableOfContents, prefix, roles } = composeInput;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const history: AutoBeAssistantMessageHistory = {
|
|
59
|
+
if (tableOfContents.length === 0)
|
|
60
|
+
return ctx.assistantMessage({
|
|
63
61
|
id: v4(),
|
|
64
62
|
type: "assistantMessage",
|
|
65
63
|
text: "The current requirements are insufficient, so file generation will be suspended. It would be better to continue the conversation.",
|
|
66
64
|
created_at,
|
|
67
65
|
completed_at: new Date().toISOString(),
|
|
68
|
-
};
|
|
69
|
-
ctx.dispatch({
|
|
70
|
-
type: "assistantMessage",
|
|
71
|
-
text: "The current requirements are insufficient, so file generation will be suspended. It would be better to continue the conversation.",
|
|
72
|
-
created_at,
|
|
73
66
|
});
|
|
74
|
-
return history;
|
|
75
|
-
}
|
|
76
67
|
|
|
77
68
|
const retryCount = 3 as const;
|
|
78
69
|
const progress = {
|
|
@@ -98,40 +89,20 @@ export const orchestrateAnalyze =
|
|
|
98
89
|
.reduce((acc, cur) => Object.assign(acc, cur));
|
|
99
90
|
|
|
100
91
|
if (Object.keys(files).length) {
|
|
101
|
-
|
|
102
|
-
id: v4(),
|
|
103
|
-
type: "analyze",
|
|
104
|
-
reason: props.reason,
|
|
105
|
-
prefix,
|
|
106
|
-
roles: roles,
|
|
107
|
-
files: files,
|
|
108
|
-
step,
|
|
109
|
-
created_at,
|
|
110
|
-
completed_at: new Date().toISOString(),
|
|
111
|
-
};
|
|
112
|
-
ctx.state().analyze = history;
|
|
113
|
-
ctx.histories().push(history);
|
|
114
|
-
ctx.dispatch({
|
|
92
|
+
return ctx.dispatch({
|
|
115
93
|
type: "analyzeComplete",
|
|
116
94
|
prefix,
|
|
117
95
|
files,
|
|
118
96
|
step,
|
|
97
|
+
roles,
|
|
119
98
|
created_at,
|
|
120
99
|
});
|
|
121
|
-
return history;
|
|
122
100
|
}
|
|
123
|
-
|
|
124
|
-
const history: AutoBeAssistantMessageHistory = {
|
|
101
|
+
return ctx.assistantMessage({
|
|
125
102
|
id: v4(),
|
|
126
103
|
type: "assistantMessage",
|
|
127
104
|
text: determined.find((el) => el.type === "assistantMessage")?.text ?? "",
|
|
128
105
|
created_at,
|
|
129
106
|
completed_at: new Date().toISOString(),
|
|
130
|
-
};
|
|
131
|
-
ctx.dispatch({
|
|
132
|
-
type: history.type,
|
|
133
|
-
text: history.text,
|
|
134
|
-
created_at: history.created_at,
|
|
135
107
|
});
|
|
136
|
-
return history;
|
|
137
108
|
};
|
|
@@ -55,7 +55,7 @@ export const orchestrateAnalyzeReviewer = async <
|
|
|
55
55
|
|
|
56
56
|
const command = `proceed with the review of these files only.` as const;
|
|
57
57
|
await agent.conversate(command).finally(() => {
|
|
58
|
-
const tokenUsage = agent.getTokenUsage();
|
|
58
|
+
const tokenUsage = agent.getTokenUsage().aggregate;
|
|
59
59
|
ctx.usage().record(tokenUsage, ["analyze"]);
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -48,7 +48,7 @@ export async function writeDocumentUntilReviewPassed<
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
await writer.conversate("Write Document.").finally(() => {
|
|
51
|
-
const tokenUsage = writer.getTokenUsage();
|
|
51
|
+
const tokenUsage = writer.getTokenUsage().aggregate;
|
|
52
52
|
ctx.usage().record(tokenUsage, ["analyze"]);
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
AutoBeOpenApi,
|
|
7
7
|
} from "@autobe/interface";
|
|
8
8
|
import { ILlmSchema } from "@samchon/openapi";
|
|
9
|
-
import { v4 } from "uuid";
|
|
10
9
|
|
|
11
10
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
12
11
|
import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
|
|
@@ -32,11 +31,8 @@ export const orchestrateInterface =
|
|
|
32
31
|
|
|
33
32
|
const init: AutoBeAssistantMessageHistory | AutoBeInterfaceGroupsEvent =
|
|
34
33
|
await orchestrateInterfaceGroups(ctx);
|
|
35
|
-
if (init.type === "assistantMessage")
|
|
36
|
-
|
|
37
|
-
ctx.histories().push(init);
|
|
38
|
-
return init;
|
|
39
|
-
} else ctx.dispatch(init);
|
|
34
|
+
if (init.type === "assistantMessage") return ctx.assistantMessage(init);
|
|
35
|
+
else ctx.dispatch(init);
|
|
40
36
|
|
|
41
37
|
// ENDPOINTS & OPERATIONS
|
|
42
38
|
const endpoints: AutoBeOpenApi.IEndpoint[] =
|
|
@@ -58,23 +54,10 @@ export const orchestrateInterface =
|
|
|
58
54
|
);
|
|
59
55
|
|
|
60
56
|
// DO COMPILE
|
|
61
|
-
|
|
62
|
-
type: "interface",
|
|
63
|
-
id: v4(),
|
|
64
|
-
document,
|
|
65
|
-
reason: props.reason,
|
|
66
|
-
step: ctx.state().analyze?.step ?? 0,
|
|
67
|
-
created_at: start.toISOString(),
|
|
68
|
-
completed_at: new Date().toISOString(),
|
|
69
|
-
};
|
|
70
|
-
ctx.state().interface = result;
|
|
71
|
-
ctx.histories().push(result);
|
|
72
|
-
ctx.dispatch({
|
|
57
|
+
return ctx.dispatch({
|
|
73
58
|
type: "interfaceComplete",
|
|
74
|
-
document
|
|
59
|
+
document,
|
|
75
60
|
created_at: start.toISOString(),
|
|
76
|
-
reason: props.reason,
|
|
77
61
|
step: ctx.state().analyze?.step ?? 0,
|
|
78
62
|
} satisfies AutoBeInterfaceCompleteEvent);
|
|
79
|
-
return result;
|
|
80
63
|
};
|
|
@@ -75,7 +75,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
75
75
|
enforceToolCall(agentica);
|
|
76
76
|
|
|
77
77
|
await agentica.conversate("Fill missing schema types please").finally(() => {
|
|
78
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
78
|
+
const tokenUsage = agentica.getTokenUsage().aggregate;
|
|
79
79
|
ctx.usage().record(tokenUsage, ["interface"]);
|
|
80
80
|
});
|
|
81
81
|
if (pointer.value === null) {
|
|
@@ -69,7 +69,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
69
69
|
enforceToolCall(agentica);
|
|
70
70
|
|
|
71
71
|
await agentica.conversate(content).finally(() => {
|
|
72
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
72
|
+
const tokenUsage = agentica.getTokenUsage().aggregate;
|
|
73
73
|
ctx.usage().record(tokenUsage, ["interface"]);
|
|
74
74
|
});
|
|
75
75
|
if (pointer.value === null) throw new Error("Failed to generate endpoints."); // unreachable
|
|
@@ -50,7 +50,7 @@ export async function orchestrateInterfaceGroups<
|
|
|
50
50
|
const histories: MicroAgenticaHistory<Model>[] = await agentica
|
|
51
51
|
.conversate(content)
|
|
52
52
|
.finally(() => {
|
|
53
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
53
|
+
const tokenUsage = agentica.getTokenUsage().aggregate;
|
|
54
54
|
ctx.usage().record(tokenUsage, ["interface"]);
|
|
55
55
|
});
|
|
56
56
|
const last: MicroAgenticaHistory<Model> = histories.at(-1)!;
|
|
@@ -140,7 +140,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
140
140
|
});
|
|
141
141
|
enforceToolCall(agentica);
|
|
142
142
|
await agentica.conversate("Make API operations").finally(() => {
|
|
143
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
143
|
+
const tokenUsage = agentica.getTokenUsage().aggregate;
|
|
144
144
|
ctx.usage().record(tokenUsage, ["interface"]);
|
|
145
145
|
});
|
|
146
146
|
if (pointer.value === null) throw new Error("Failed to create operations."); // never be happened
|
|
@@ -136,7 +136,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
136
136
|
].join("\n"),
|
|
137
137
|
)
|
|
138
138
|
.finally(() => {
|
|
139
|
-
const tokenUsage = agentica.getTokenUsage();
|
|
139
|
+
const tokenUsage = agentica.getTokenUsage().aggregate;
|
|
140
140
|
ctx.usage().record(tokenUsage, ["interface"]);
|
|
141
141
|
});
|
|
142
142
|
if (pointer.value === null) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
|
|
4
|
-
import { AutoBeSystemPromptConstant } from "
|
|
5
|
-
import { AutoBeState } from "
|
|
4
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
5
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
6
6
|
|
|
7
7
|
export const transformPrismaComponentsHistories = (
|
|
8
8
|
state: AutoBeState,
|
|
@@ -2,7 +2,7 @@ import { IAgenticaHistoryJson } from "@agentica/core";
|
|
|
2
2
|
import { IAutoBePrismaValidation } from "@autobe/interface";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
|
|
5
|
-
import { AutoBeSystemPromptConstant } from "
|
|
5
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
6
6
|
|
|
7
7
|
export const transformPrismaCorrectHistories = (
|
|
8
8
|
result: IAutoBePrismaValidation.IFailure,
|
package/src/orchestrate/prisma/{transformPrismaHistories.ts → histories/transformPrismaHistories.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
|
|
4
|
-
import { AutoBeSystemPromptConstant } from "
|
|
5
|
-
import { AutoBeState } from "
|
|
4
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
5
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
6
6
|
|
|
7
7
|
export const transformPrismaHistories = (
|
|
8
8
|
state: AutoBeState,
|
|
@@ -2,7 +2,7 @@ import { IAgenticaHistoryJson } from "@agentica/core";
|
|
|
2
2
|
import { AutoBePrisma } from "@autobe/interface";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
|
|
5
|
-
import { AutoBeSystemPromptConstant } from "
|
|
5
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
6
6
|
|
|
7
7
|
export const transformPrismaSchemaHistories = (
|
|
8
8
|
requirementAnalysisReport: Record<string, string>,
|