@autobe/agent 0.30.2 → 0.30.4-dev.20260324
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 -661
- package/README.md +261 -0
- package/lib/AutoBeMockAgent.d.ts +2 -1
- package/lib/AutoBeMockAgent.js +37 -18
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeConfigConstant.d.ts +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +12 -11
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/index.mjs +497 -71
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeExtractDecisionsHistory.d.ts +18 -0
- package/lib/orchestrate/analyze/histories/transformAnalyzeExtractDecisionsHistory.js +51 -0
- package/lib/orchestrate/analyze/histories/transformAnalyzeExtractDecisionsHistory.js.map +1 -0
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistory.js +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistory.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioReviewHistory.js +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioReviewHistory.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeSectionCrossFileReviewHistory.d.ts +1 -0
- package/lib/orchestrate/analyze/histories/transformAnalyzeSectionCrossFileReviewHistory.js +15 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeSectionCrossFileReviewHistory.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeSectionReviewHistory.js +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeSectionReviewHistory.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +48 -13
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeExtractDecisions.d.ts +17 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeExtractDecisions.js +345 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeExtractDecisions.js.map +1 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
- package/lib/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.d.ts +1 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.js +1 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.js.map +1 -1
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeExtractDecisionsApplication.d.ts +91 -0
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeExtractDecisionsApplication.js +3 -0
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeExtractDecisionsApplication.js.map +1 -0
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +15 -5
- package/lib/orchestrate/analyze/utils/buildErrorCodeRegistry.d.ts +0 -9
- package/lib/orchestrate/analyze/utils/buildErrorCodeRegistry.js +1 -13
- package/lib/orchestrate/analyze/utils/buildErrorCodeRegistry.js.map +1 -1
- package/lib/orchestrate/analyze/utils/detectDecisionConflicts.d.ts +63 -0
- package/lib/orchestrate/analyze/utils/detectDecisionConflicts.js +105 -0
- package/lib/orchestrate/analyze/utils/detectDecisionConflicts.js.map +1 -0
- package/lib/orchestrate/common/histories/transformPreliminaryHistory.js +1 -1
- package/lib/orchestrate/common/histories/transformPreliminaryHistory.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceActionEndpointReviewHistory.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceActionEndpointReviewHistory.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceBaseEndpointReviewHistory.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceBaseEndpointReviewHistory.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaRefineHistory.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaRefineHistory.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemaRefine.js +1 -2
- package/lib/orchestrate/interface/orchestrateInterfaceSchemaRefine.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js +1 -2
- package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js.map +1 -1
- package/lib/orchestrate/interface/utils/AutoBeJsonSchemaValidator.js +316 -283
- package/lib/orchestrate/interface/utils/AutoBeJsonSchemaValidator.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentReviewHistory.js +2 -2
- package/lib/orchestrate/prisma/histories/transformPrismaComponentReviewHistory.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistory.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistory.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaGroupHistory.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaGroupHistory.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaGroupReviewHistory.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaGroupReviewHistory.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistory.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistory.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaReviewHistory.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaReviewHistory.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +1 -1
- package/lib/structures/IAutoBeVendor.d.ts +13 -0
- package/package.json +5 -5
- package/src/AutoBeMockAgent.ts +283 -254
- package/src/constants/AutoBeConfigConstant.ts +1 -1
- package/src/constants/AutoBeSystemPromptConstant.ts +12 -11
- package/src/orchestrate/analyze/histories/transformAnalyzeExtractDecisionsHistory.ts +69 -0
- package/src/orchestrate/analyze/histories/transformAnalyzeSectionCrossFileReviewHistory.ts +20 -0
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +58 -1
- package/src/orchestrate/analyze/orchestrateAnalyzeExtractDecisions.ts +97 -0
- package/src/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.ts +2 -0
- package/src/orchestrate/analyze/structures/IAutoBeAnalyzeExtractDecisionsApplication.ts +99 -0
- package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +15 -5
- package/src/orchestrate/analyze/utils/buildErrorCodeRegistry.ts +0 -20
- package/src/orchestrate/analyze/utils/detectDecisionConflicts.ts +172 -0
- package/src/orchestrate/interface/orchestrateInterfaceSchemaRefine.ts +291 -292
- package/src/orchestrate/interface/orchestrateInterfaceSchemaReview.ts +309 -310
- package/src/orchestrate/interface/utils/AutoBeJsonSchemaValidator.ts +763 -725
- package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +237 -237
- package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +322 -322
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -52
- package/src/structures/IAutoBeVendor.ts +127 -113
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/agent",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.4-dev.20260324",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Wrtn Technologies",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"typia": "^12.0.1",
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
33
|
"yaml": "^2.8.2",
|
|
34
|
-
"@autobe/
|
|
35
|
-
"@autobe/
|
|
34
|
+
"@autobe/utils": "^0.30.4-dev.20260324",
|
|
35
|
+
"@autobe/interface": "^0.30.4-dev.20260324"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"rollup": "^4.40.1",
|
|
45
45
|
"ts-node": "^10.9.2",
|
|
46
46
|
"typescript": "~5.9.3",
|
|
47
|
-
"@autobe/filesystem": "^0.30.
|
|
48
|
-
"@autobe/compiler": "^0.30.
|
|
47
|
+
"@autobe/filesystem": "^0.30.4-dev.20260324",
|
|
48
|
+
"@autobe/compiler": "^0.30.4-dev.20260324"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"ai",
|
package/src/AutoBeMockAgent.ts
CHANGED
|
@@ -1,254 +1,283 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeAssistantMessageHistory,
|
|
3
|
-
AutoBeEvent,
|
|
4
|
-
AutoBeEventSnapshot,
|
|
5
|
-
AutoBeHistory,
|
|
6
|
-
AutoBePhase,
|
|
7
|
-
AutoBeUserConversateContent,
|
|
8
|
-
AutoBeUserMessageHistory,
|
|
9
|
-
IAutoBeAgent,
|
|
10
|
-
IAutoBeCompiler,
|
|
11
|
-
IAutoBeCompilerListener,
|
|
12
|
-
IAutoBeGetFilesOptions,
|
|
13
|
-
IAutoBePlaygroundReplay,
|
|
14
|
-
} from "@autobe/interface";
|
|
15
|
-
import { Singleton, randint, sleep_for } from "tstl";
|
|
16
|
-
import { v7 } from "uuid";
|
|
17
|
-
|
|
18
|
-
import { AutoBeAgentBase } from "./AutoBeAgentBase";
|
|
19
|
-
import { AutoBeState } from "./context/AutoBeState";
|
|
20
|
-
import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
|
|
21
|
-
import { createAutoBeUserMessageContent } from "./factory/createAutoBeMessageContent";
|
|
22
|
-
import { createAutoBeState } from "./factory/createAutoBeState";
|
|
23
|
-
import { getAutoBeGenerated } from "./factory/getAutoBeGenerated";
|
|
24
|
-
|
|
25
|
-
/** @internal */
|
|
26
|
-
export class AutoBeMockAgent extends AutoBeAgentBase implements IAutoBeAgent {
|
|
27
|
-
private readonly props_: AutoBeMockAgent.IProps;
|
|
28
|
-
private readonly histories_: AutoBeHistory[];
|
|
29
|
-
private readonly compiler_: Singleton<Promise<IAutoBeCompiler>>;
|
|
30
|
-
private token_usage_: AutoBeTokenUsage;
|
|
31
|
-
|
|
32
|
-
public constructor(props: AutoBeMockAgent.IProps) {
|
|
33
|
-
super();
|
|
34
|
-
this.props_ = props;
|
|
35
|
-
this.histories_ = [];
|
|
36
|
-
this.compiler_ = new Singleton(async () =>
|
|
37
|
-
props.compiler({
|
|
38
|
-
realize: {
|
|
39
|
-
test: {
|
|
40
|
-
onOperation: async () => {},
|
|
41
|
-
onReset: async () => {},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
46
|
-
this.token_usage_ = new AutoBeTokenUsage();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public async conversate(
|
|
50
|
-
content:
|
|
51
|
-
| string
|
|
52
|
-
| AutoBeUserConversateContent
|
|
53
|
-
| AutoBeUserConversateContent[],
|
|
54
|
-
): Promise<AutoBeHistory[]> {
|
|
55
|
-
const contents: AutoBeUserConversateContent[] =
|
|
56
|
-
typeof content === "string"
|
|
57
|
-
? [
|
|
58
|
-
{
|
|
59
|
-
type: "text",
|
|
60
|
-
text: content,
|
|
61
|
-
},
|
|
62
|
-
]
|
|
63
|
-
: Array.isArray(content)
|
|
64
|
-
? content
|
|
65
|
-
: [content];
|
|
66
|
-
//
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (state.analyze === null)
|
|
156
|
-
else if (state.
|
|
157
|
-
else if (state.
|
|
158
|
-
else if (state.
|
|
159
|
-
else if (state.
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return this.
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAssistantMessageHistory,
|
|
3
|
+
AutoBeEvent,
|
|
4
|
+
AutoBeEventSnapshot,
|
|
5
|
+
AutoBeHistory,
|
|
6
|
+
AutoBePhase,
|
|
7
|
+
AutoBeUserConversateContent,
|
|
8
|
+
AutoBeUserMessageHistory,
|
|
9
|
+
IAutoBeAgent,
|
|
10
|
+
IAutoBeCompiler,
|
|
11
|
+
IAutoBeCompilerListener,
|
|
12
|
+
IAutoBeGetFilesOptions,
|
|
13
|
+
IAutoBePlaygroundReplay,
|
|
14
|
+
} from "@autobe/interface";
|
|
15
|
+
import { Singleton, randint, sleep_for } from "tstl";
|
|
16
|
+
import { v7 } from "uuid";
|
|
17
|
+
|
|
18
|
+
import { AutoBeAgentBase } from "./AutoBeAgentBase";
|
|
19
|
+
import { AutoBeState } from "./context/AutoBeState";
|
|
20
|
+
import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
|
|
21
|
+
import { createAutoBeUserMessageContent } from "./factory/createAutoBeMessageContent";
|
|
22
|
+
import { createAutoBeState } from "./factory/createAutoBeState";
|
|
23
|
+
import { getAutoBeGenerated } from "./factory/getAutoBeGenerated";
|
|
24
|
+
|
|
25
|
+
/** @internal */
|
|
26
|
+
export class AutoBeMockAgent extends AutoBeAgentBase implements IAutoBeAgent {
|
|
27
|
+
private readonly props_: AutoBeMockAgent.IProps;
|
|
28
|
+
private readonly histories_: AutoBeHistory[];
|
|
29
|
+
private readonly compiler_: Singleton<Promise<IAutoBeCompiler>>;
|
|
30
|
+
private token_usage_: AutoBeTokenUsage;
|
|
31
|
+
|
|
32
|
+
public constructor(props: AutoBeMockAgent.IProps) {
|
|
33
|
+
super();
|
|
34
|
+
this.props_ = props;
|
|
35
|
+
this.histories_ = [];
|
|
36
|
+
this.compiler_ = new Singleton(async () =>
|
|
37
|
+
props.compiler({
|
|
38
|
+
realize: {
|
|
39
|
+
test: {
|
|
40
|
+
onOperation: async () => {},
|
|
41
|
+
onReset: async () => {},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
this.token_usage_ = new AutoBeTokenUsage();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async conversate(
|
|
50
|
+
content:
|
|
51
|
+
| string
|
|
52
|
+
| AutoBeUserConversateContent
|
|
53
|
+
| AutoBeUserConversateContent[],
|
|
54
|
+
): Promise<AutoBeHistory[]> {
|
|
55
|
+
const contents: AutoBeUserConversateContent[] =
|
|
56
|
+
typeof content === "string"
|
|
57
|
+
? [
|
|
58
|
+
{
|
|
59
|
+
type: "text",
|
|
60
|
+
text: content,
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
: Array.isArray(content)
|
|
64
|
+
? content
|
|
65
|
+
: [content];
|
|
66
|
+
// ALREADY REALIZED CASE
|
|
67
|
+
const state: AutoBeState = createAutoBeState(this.histories_);
|
|
68
|
+
if (state.realize !== null) {
|
|
69
|
+
const userMessage: AutoBeUserMessageHistory = {
|
|
70
|
+
id: v7(),
|
|
71
|
+
type: "userMessage",
|
|
72
|
+
contents: contents.map((c) =>
|
|
73
|
+
createAutoBeUserMessageContent({ content: c }),
|
|
74
|
+
),
|
|
75
|
+
created_at: new Date().toISOString(),
|
|
76
|
+
};
|
|
77
|
+
void this.dispatch(userMessage).catch(() => {});
|
|
78
|
+
await sleep_for(2_000);
|
|
79
|
+
const assistantMessage: AutoBeAssistantMessageHistory = {
|
|
80
|
+
id: v7(),
|
|
81
|
+
type: "assistantMessage",
|
|
82
|
+
text: [
|
|
83
|
+
"AutoBE has successfully realized the application.",
|
|
84
|
+
"",
|
|
85
|
+
"Thanks for using AutoBE!",
|
|
86
|
+
].join("\n"),
|
|
87
|
+
created_at: new Date().toISOString(),
|
|
88
|
+
completed_at: new Date().toISOString(),
|
|
89
|
+
};
|
|
90
|
+
void this.dispatch(assistantMessage).catch(() => {});
|
|
91
|
+
this.histories_.push(userMessage, assistantMessage);
|
|
92
|
+
return this.histories_;
|
|
93
|
+
}
|
|
94
|
+
const take = async (type: AutoBePhase): Promise<void> => {
|
|
95
|
+
const snapshots: AutoBeEventSnapshot[] | null =
|
|
96
|
+
this.getEventSnapshots(type);
|
|
97
|
+
if (snapshots === null) {
|
|
98
|
+
this.histories_.push({
|
|
99
|
+
id: v7(),
|
|
100
|
+
type: "userMessage",
|
|
101
|
+
contents: contents.map((c) =>
|
|
102
|
+
createAutoBeUserMessageContent({ content: c }),
|
|
103
|
+
),
|
|
104
|
+
created_at: new Date().toISOString(),
|
|
105
|
+
});
|
|
106
|
+
this.histories_.push({
|
|
107
|
+
id: v7(),
|
|
108
|
+
type: "assistantMessage",
|
|
109
|
+
text: [
|
|
110
|
+
"The histories are prepared until current state.",
|
|
111
|
+
"",
|
|
112
|
+
"Thanks for using AutoBE!",
|
|
113
|
+
].join("\n"),
|
|
114
|
+
created_at: new Date().toISOString(),
|
|
115
|
+
completed_at: new Date().toISOString(),
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Find the nearest user message that led into this phase for history
|
|
120
|
+
// tracking. There may be assistant messages between the user request
|
|
121
|
+
// and the resulting phase history, so we search backwards.
|
|
122
|
+
const phaseIndex = this.props_.replay.histories.findIndex(
|
|
123
|
+
(h) => h.type === type,
|
|
124
|
+
);
|
|
125
|
+
const originalUserMessage: AutoBeHistory | undefined =
|
|
126
|
+
phaseIndex > 0
|
|
127
|
+
? this.props_.replay.histories
|
|
128
|
+
.slice(0, phaseIndex)
|
|
129
|
+
.reverse()
|
|
130
|
+
.find((h) => h.type === "userMessage")
|
|
131
|
+
: undefined;
|
|
132
|
+
for (const s of snapshots) {
|
|
133
|
+
const time: number =
|
|
134
|
+
this.props_.delay?.(s.event.type) ?? sleepMap[s.event.type] ?? 500;
|
|
135
|
+
await sleep_for(randint(time * 0.2, time * 1.8));
|
|
136
|
+
void this.dispatch(s.event).catch(() => {});
|
|
137
|
+
this.token_usage_ = new AutoBeTokenUsage(s.tokenUsage);
|
|
138
|
+
}
|
|
139
|
+
this.histories_.push(
|
|
140
|
+
originalUserMessage?.type === "userMessage"
|
|
141
|
+
? originalUserMessage
|
|
142
|
+
: {
|
|
143
|
+
id: v7(),
|
|
144
|
+
type: "userMessage",
|
|
145
|
+
contents: contents.map((c) =>
|
|
146
|
+
createAutoBeUserMessageContent({ content: c }),
|
|
147
|
+
),
|
|
148
|
+
created_at: new Date().toISOString(),
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
this.histories_.push(
|
|
152
|
+
this.props_.replay.histories.find((h) => h.type === type)!,
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
if (state.analyze === null) await take("analyze");
|
|
156
|
+
else if (state.database === null) await take("database");
|
|
157
|
+
else if (state.interface === null) await take("interface");
|
|
158
|
+
else if (state.test === null) await take("test");
|
|
159
|
+
else if (state.realize === null) await take("realize");
|
|
160
|
+
return this.histories_;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public getHistories(): AutoBeHistory[] {
|
|
164
|
+
return this.histories_;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public getTokenUsage(): AutoBeTokenUsage {
|
|
168
|
+
return this.token_usage_;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public async getFiles(
|
|
172
|
+
options?: IAutoBeGetFilesOptions,
|
|
173
|
+
): Promise<Record<string, string>> {
|
|
174
|
+
return await getAutoBeGenerated({
|
|
175
|
+
compiler: await this.compiler_.get(),
|
|
176
|
+
state: createAutoBeState(this.histories_),
|
|
177
|
+
histories: this.getHistories(),
|
|
178
|
+
tokenUsage: this.getTokenUsage(),
|
|
179
|
+
options,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public getPhase(): AutoBePhase | null {
|
|
184
|
+
const state: AutoBeState = createAutoBeState(this.histories_);
|
|
185
|
+
if (state.analyze === null) return null;
|
|
186
|
+
else if (state.realize?.step === state.analyze.step) return "realize";
|
|
187
|
+
else if (state.test?.step === state.analyze.step) return "test";
|
|
188
|
+
else if (state.interface?.step === state.analyze.step) return "interface";
|
|
189
|
+
else if (state.database?.step === state.analyze.step) return "database";
|
|
190
|
+
return "analyze";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private getEventSnapshots(state: AutoBePhase): AutoBeEventSnapshot[] | null {
|
|
194
|
+
return this.props_.replay[state] ?? null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export namespace AutoBeMockAgent {
|
|
198
|
+
export interface IProps {
|
|
199
|
+
compiler: (
|
|
200
|
+
listener: IAutoBeCompilerListener,
|
|
201
|
+
) => IAutoBeCompiler | Promise<IAutoBeCompiler>;
|
|
202
|
+
replay: IAutoBePlaygroundReplay;
|
|
203
|
+
delay?: ((type: AutoBeEvent.Type) => number | undefined) | undefined;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const sleepMap: Record<AutoBeEvent.Type, number> = {
|
|
208
|
+
userMessage: 1_000,
|
|
209
|
+
assistantMessage: 1_000,
|
|
210
|
+
vendorRequest: 0,
|
|
211
|
+
vendorResponse: 0,
|
|
212
|
+
vendorTimeout: 0,
|
|
213
|
+
jsonParseError: 0,
|
|
214
|
+
jsonValidateError: 0,
|
|
215
|
+
consentFunctionCall: 0,
|
|
216
|
+
preliminary: 0,
|
|
217
|
+
// DESCRIBE
|
|
218
|
+
imageDescribeStart: 1_000,
|
|
219
|
+
imageDescribeDraft: 300,
|
|
220
|
+
imageDescribeComplete: 1_000,
|
|
221
|
+
// ANALYZE
|
|
222
|
+
analyzeStart: 1_000,
|
|
223
|
+
analyzeScenario: 1_000,
|
|
224
|
+
analyzeWriteModule: 500,
|
|
225
|
+
analyzeWriteUnit: 250,
|
|
226
|
+
analyzeWriteSection: 200,
|
|
227
|
+
analyzeSectionReview: 300,
|
|
228
|
+
analyzeScenarioReview: 300,
|
|
229
|
+
analyzeComplete: 1_000,
|
|
230
|
+
// PRISMA
|
|
231
|
+
databaseStart: 1_000,
|
|
232
|
+
databaseGroup: 1_000,
|
|
233
|
+
databaseGroupReview: 1_000,
|
|
234
|
+
databaseAuthorization: 1_000,
|
|
235
|
+
databaseAuthorizationReview: 500,
|
|
236
|
+
databaseComponent: 1_000,
|
|
237
|
+
databaseComponentReview: 500,
|
|
238
|
+
databaseSchema: 500,
|
|
239
|
+
databaseSchemaReview: 500,
|
|
240
|
+
databaseValidate: 2_000,
|
|
241
|
+
databaseCorrect: 500,
|
|
242
|
+
databaseComplete: 1_000,
|
|
243
|
+
// INTERFACE
|
|
244
|
+
interfaceStart: 1_000,
|
|
245
|
+
interfaceGroup: 1_000,
|
|
246
|
+
interfaceEndpoint: 500,
|
|
247
|
+
interfaceEndpointReview: 1_000,
|
|
248
|
+
interfaceOperation: 400,
|
|
249
|
+
interfaceOperationReview: 500,
|
|
250
|
+
interfaceAuthorization: 400,
|
|
251
|
+
interfaceSchema: 400,
|
|
252
|
+
interfaceSchemaCasting: 400,
|
|
253
|
+
interfaceSchemaRefine: 400,
|
|
254
|
+
interfaceSchemaReview: 200,
|
|
255
|
+
interfaceSchemaRename: 200,
|
|
256
|
+
interfaceSchemaComplement: 2_000,
|
|
257
|
+
interfaceComplete: 1_000,
|
|
258
|
+
interfacePrerequisite: 400,
|
|
259
|
+
// TEST
|
|
260
|
+
testStart: 1_000,
|
|
261
|
+
testScenario: 40,
|
|
262
|
+
testScenarioReview: 40,
|
|
263
|
+
testWrite: 40,
|
|
264
|
+
testValidate: 100,
|
|
265
|
+
testCorrect: 100,
|
|
266
|
+
testComplete: 1_000,
|
|
267
|
+
// REALIZE
|
|
268
|
+
realizeStart: 1_000,
|
|
269
|
+
realizeComplete: 1_000,
|
|
270
|
+
realizePlan: 80,
|
|
271
|
+
realizeWrite: 80,
|
|
272
|
+
realizeCorrect: 80,
|
|
273
|
+
realizeValidate: 200,
|
|
274
|
+
realizeAuthorizationStart: 1_000,
|
|
275
|
+
realizeAuthorizationWrite: 200,
|
|
276
|
+
realizeAuthorizationValidate: 200,
|
|
277
|
+
realizeAuthorizationCorrect: 200,
|
|
278
|
+
realizeAuthorizationComplete: 1_000,
|
|
279
|
+
realizeTestStart: 1_000,
|
|
280
|
+
realizeTestReset: 2_500,
|
|
281
|
+
realizeTestOperation: 400,
|
|
282
|
+
realizeTestComplete: 1_000,
|
|
283
|
+
};
|
|
@@ -66,7 +66,7 @@ export const enum AutoBeConfigConstant {
|
|
|
66
66
|
* while still providing a reasonable bound to prevent infinite correction
|
|
67
67
|
* loops.
|
|
68
68
|
*/
|
|
69
|
-
DATABASE_CORRECT_RETRY =
|
|
69
|
+
DATABASE_CORRECT_RETRY = 30,
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Retry attempts for LLM function-calling execution flows.
|