@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
|
@@ -1,292 +1,291 @@
|
|
|
1
|
-
import { IAgenticaController } from "@agentica/core";
|
|
2
|
-
import {
|
|
3
|
-
AutoBeDatabase,
|
|
4
|
-
AutoBeEventSource,
|
|
5
|
-
AutoBeInterfaceSchemaRefineEvent,
|
|
6
|
-
AutoBeOpenApi,
|
|
7
|
-
AutoBeProgressEventBase,
|
|
8
|
-
} from "@autobe/interface";
|
|
9
|
-
import { AutoBeOpenApiTypeChecker } from "@autobe/utils";
|
|
10
|
-
import { IPointer } from "tstl";
|
|
11
|
-
import typia, { ILlmApplication, IValidation } from "typia";
|
|
12
|
-
import { v7 } from "uuid";
|
|
13
|
-
|
|
14
|
-
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
|
-
import { executeCachedBatch } from "../../utils/executeCachedBatch";
|
|
16
|
-
import { AutoBePreliminaryController } from "../common/AutoBePreliminaryController";
|
|
17
|
-
import { AutoBeDatabaseModelProgrammer } from "../prisma/programmers/AutoBeDatabaseModelProgrammer";
|
|
18
|
-
import { transformInterfaceSchemaRefineHistory } from "./histories/transformInterfaceSchemaRefineHistory";
|
|
19
|
-
import { AutoBeInterfaceSchemaProgrammer } from "./programmers/AutoBeInterfaceSchemaProgrammer";
|
|
20
|
-
import { AutoBeInterfaceSchemaRefineProgrammer } from "./programmers/AutoBeInterfaceSchemaRefineProgrammer";
|
|
21
|
-
import { IAutoBeInterfaceSchemaRefineApplication } from "./structures/IAutoBeInterfaceSchemaRefineApplication";
|
|
22
|
-
import { AutoBeJsonSchemaValidator } from "./utils/AutoBeJsonSchemaValidator";
|
|
23
|
-
import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
|
|
24
|
-
|
|
25
|
-
export async function orchestrateInterfaceSchemaRefine(
|
|
26
|
-
ctx: AutoBeContext,
|
|
27
|
-
props: {
|
|
28
|
-
document: AutoBeOpenApi.IDocument;
|
|
29
|
-
schemas: Record<string, AutoBeOpenApi.IJsonSchema>;
|
|
30
|
-
instruction: string;
|
|
31
|
-
progress: AutoBeProgressEventBase;
|
|
32
|
-
},
|
|
33
|
-
): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
|
|
34
|
-
// Filter to only process object-type schemas (non-preset and object type)
|
|
35
|
-
const typeNames: string[] = Object.entries(props.schemas)
|
|
36
|
-
.filter(
|
|
37
|
-
([k, v]) =>
|
|
38
|
-
AutoBeJsonSchemaValidator.isPreset(k) === false &&
|
|
39
|
-
AutoBeOpenApiTypeChecker.isObject(v)
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(op.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
| "
|
|
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
|
-
props.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const SOURCE = "interfaceSchemaRefine" satisfies AutoBeEventSource;
|
|
1
|
+
import { IAgenticaController } from "@agentica/core";
|
|
2
|
+
import {
|
|
3
|
+
AutoBeDatabase,
|
|
4
|
+
AutoBeEventSource,
|
|
5
|
+
AutoBeInterfaceSchemaRefineEvent,
|
|
6
|
+
AutoBeOpenApi,
|
|
7
|
+
AutoBeProgressEventBase,
|
|
8
|
+
} from "@autobe/interface";
|
|
9
|
+
import { AutoBeOpenApiTypeChecker } from "@autobe/utils";
|
|
10
|
+
import { IPointer } from "tstl";
|
|
11
|
+
import typia, { ILlmApplication, IValidation } from "typia";
|
|
12
|
+
import { v7 } from "uuid";
|
|
13
|
+
|
|
14
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
|
+
import { executeCachedBatch } from "../../utils/executeCachedBatch";
|
|
16
|
+
import { AutoBePreliminaryController } from "../common/AutoBePreliminaryController";
|
|
17
|
+
import { AutoBeDatabaseModelProgrammer } from "../prisma/programmers/AutoBeDatabaseModelProgrammer";
|
|
18
|
+
import { transformInterfaceSchemaRefineHistory } from "./histories/transformInterfaceSchemaRefineHistory";
|
|
19
|
+
import { AutoBeInterfaceSchemaProgrammer } from "./programmers/AutoBeInterfaceSchemaProgrammer";
|
|
20
|
+
import { AutoBeInterfaceSchemaRefineProgrammer } from "./programmers/AutoBeInterfaceSchemaRefineProgrammer";
|
|
21
|
+
import { IAutoBeInterfaceSchemaRefineApplication } from "./structures/IAutoBeInterfaceSchemaRefineApplication";
|
|
22
|
+
import { AutoBeJsonSchemaValidator } from "./utils/AutoBeJsonSchemaValidator";
|
|
23
|
+
import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
|
|
24
|
+
|
|
25
|
+
export async function orchestrateInterfaceSchemaRefine(
|
|
26
|
+
ctx: AutoBeContext,
|
|
27
|
+
props: {
|
|
28
|
+
document: AutoBeOpenApi.IDocument;
|
|
29
|
+
schemas: Record<string, AutoBeOpenApi.IJsonSchema>;
|
|
30
|
+
instruction: string;
|
|
31
|
+
progress: AutoBeProgressEventBase;
|
|
32
|
+
},
|
|
33
|
+
): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
|
|
34
|
+
// Filter to only process object-type schemas (non-preset and object type)
|
|
35
|
+
const typeNames: string[] = Object.entries(props.schemas)
|
|
36
|
+
.filter(
|
|
37
|
+
([k, v]) =>
|
|
38
|
+
AutoBeJsonSchemaValidator.isPreset(k) === false &&
|
|
39
|
+
AutoBeOpenApiTypeChecker.isObject(v),
|
|
40
|
+
)
|
|
41
|
+
.map(([k]) => k);
|
|
42
|
+
props.progress.total += typeNames.length;
|
|
43
|
+
|
|
44
|
+
const x: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
|
|
45
|
+
await executeCachedBatch(
|
|
46
|
+
ctx,
|
|
47
|
+
typeNames.map((it) => async (promptCacheKey) => {
|
|
48
|
+
const predicate = (key: string) => key === it;
|
|
49
|
+
const operations: AutoBeOpenApi.IOperation[] =
|
|
50
|
+
props.document.operations.filter(
|
|
51
|
+
(op) =>
|
|
52
|
+
(op.requestBody && predicate(op.requestBody.typeName)) ||
|
|
53
|
+
(op.responseBody && predicate(op.responseBody.typeName)),
|
|
54
|
+
);
|
|
55
|
+
try {
|
|
56
|
+
const schema: AutoBeOpenApi.IJsonSchema = props.schemas[it];
|
|
57
|
+
if (AutoBeOpenApiTypeChecker.isObject(schema) === false) {
|
|
58
|
+
--props.progress.total;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const refined: AutoBeOpenApi.IJsonSchemaDescriptive.IObject =
|
|
62
|
+
await process(ctx, {
|
|
63
|
+
instruction: props.instruction,
|
|
64
|
+
document: props.document,
|
|
65
|
+
typeName: it,
|
|
66
|
+
operations,
|
|
67
|
+
schema,
|
|
68
|
+
progress: props.progress,
|
|
69
|
+
promptCacheKey,
|
|
70
|
+
});
|
|
71
|
+
x[it] = refined;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.log("interfaceSchemaRefine failure", it, error);
|
|
74
|
+
--props.progress.total;
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
return x;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function process(
|
|
82
|
+
ctx: AutoBeContext,
|
|
83
|
+
props: {
|
|
84
|
+
instruction: string;
|
|
85
|
+
document: AutoBeOpenApi.IDocument;
|
|
86
|
+
typeName: string;
|
|
87
|
+
operations: AutoBeOpenApi.IOperation[];
|
|
88
|
+
schema: AutoBeOpenApi.IJsonSchema.IObject;
|
|
89
|
+
progress: AutoBeProgressEventBase;
|
|
90
|
+
promptCacheKey: string;
|
|
91
|
+
},
|
|
92
|
+
): Promise<AutoBeOpenApi.IJsonSchemaDescriptive.IObject> {
|
|
93
|
+
const preliminary: AutoBePreliminaryController<
|
|
94
|
+
| "analysisSections"
|
|
95
|
+
| "databaseSchemas"
|
|
96
|
+
| "interfaceOperations"
|
|
97
|
+
| "interfaceSchemas"
|
|
98
|
+
| "previousAnalysisSections"
|
|
99
|
+
| "previousDatabaseSchemas"
|
|
100
|
+
| "previousInterfaceOperations"
|
|
101
|
+
| "previousInterfaceSchemas"
|
|
102
|
+
> = new AutoBePreliminaryController({
|
|
103
|
+
application:
|
|
104
|
+
typia.json.application<IAutoBeInterfaceSchemaRefineApplication>(),
|
|
105
|
+
source: SOURCE,
|
|
106
|
+
kinds: [
|
|
107
|
+
"analysisSections",
|
|
108
|
+
"previousAnalysisSections",
|
|
109
|
+
"databaseSchemas",
|
|
110
|
+
"previousDatabaseSchemas",
|
|
111
|
+
"interfaceOperations",
|
|
112
|
+
"previousInterfaceOperations",
|
|
113
|
+
"interfaceSchemas",
|
|
114
|
+
"previousInterfaceSchemas",
|
|
115
|
+
],
|
|
116
|
+
config: {
|
|
117
|
+
database: "text",
|
|
118
|
+
databaseProperty: true,
|
|
119
|
+
},
|
|
120
|
+
state: ctx.state(),
|
|
121
|
+
all: {
|
|
122
|
+
interfaceOperations: props.document.operations,
|
|
123
|
+
interfaceSchemas: props.document.components.schemas,
|
|
124
|
+
},
|
|
125
|
+
local: {
|
|
126
|
+
interfaceOperations: props.operations,
|
|
127
|
+
interfaceSchemas: {
|
|
128
|
+
[props.typeName]: props.schema as AutoBeOpenApi.IJsonSchemaDescriptive,
|
|
129
|
+
},
|
|
130
|
+
databaseSchemas: (() => {
|
|
131
|
+
const expected: string =
|
|
132
|
+
props.schema["x-autobe-database-schema"] ??
|
|
133
|
+
AutoBeInterfaceSchemaProgrammer.getDatabaseSchemaName(props.typeName);
|
|
134
|
+
const model: AutoBeDatabase.IModel | undefined = ctx
|
|
135
|
+
.state()
|
|
136
|
+
.database?.result.data.files.flatMap((f) => f.models)
|
|
137
|
+
.find((m) => m.name === expected);
|
|
138
|
+
if (model === undefined) return [];
|
|
139
|
+
return AutoBeDatabaseModelProgrammer.getNeighbors({
|
|
140
|
+
application: ctx.state().database!.result.data,
|
|
141
|
+
model,
|
|
142
|
+
});
|
|
143
|
+
})(),
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
return await preliminary.orchestrate(ctx, async (out) => {
|
|
147
|
+
const pointer: IPointer<IAutoBeInterfaceSchemaRefineApplication.IComplete | null> =
|
|
148
|
+
{
|
|
149
|
+
value: null,
|
|
150
|
+
};
|
|
151
|
+
const result: AutoBeContext.IResult = await ctx.conversate({
|
|
152
|
+
source: SOURCE,
|
|
153
|
+
controller: createController(ctx, {
|
|
154
|
+
typeName: props.typeName,
|
|
155
|
+
operations: props.document.operations,
|
|
156
|
+
schema: props.schema,
|
|
157
|
+
preliminary,
|
|
158
|
+
pointer,
|
|
159
|
+
}),
|
|
160
|
+
enforceFunctionCall: true,
|
|
161
|
+
promptCacheKey: props.promptCacheKey,
|
|
162
|
+
...transformInterfaceSchemaRefineHistory({
|
|
163
|
+
state: ctx.state(),
|
|
164
|
+
instruction: props.instruction,
|
|
165
|
+
typeName: props.typeName,
|
|
166
|
+
operations: props.operations,
|
|
167
|
+
schema: props.schema,
|
|
168
|
+
preliminary,
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
if (pointer.value === null) return out(result)(null);
|
|
172
|
+
|
|
173
|
+
// Apply refines to generate the enriched schema content
|
|
174
|
+
const content: AutoBeOpenApi.IJsonSchemaDescriptive.IObject =
|
|
175
|
+
AutoBeInterfaceSchemaRefineProgrammer.execute({
|
|
176
|
+
schema: props.schema,
|
|
177
|
+
databaseSchema: pointer.value.databaseSchema,
|
|
178
|
+
specification: pointer.value.specification,
|
|
179
|
+
description: pointer.value.description,
|
|
180
|
+
revises: pointer.value.revises,
|
|
181
|
+
});
|
|
182
|
+
ctx.dispatch({
|
|
183
|
+
type: SOURCE,
|
|
184
|
+
id: v7(),
|
|
185
|
+
typeName: props.typeName,
|
|
186
|
+
schema: props.schema,
|
|
187
|
+
review: pointer.value.review,
|
|
188
|
+
databaseSchema: pointer.value.databaseSchema,
|
|
189
|
+
specification: pointer.value.specification,
|
|
190
|
+
description: pointer.value.description,
|
|
191
|
+
excludes: pointer.value.excludes,
|
|
192
|
+
revises: pointer.value.revises,
|
|
193
|
+
acquisition: preliminary.getAcquisition(),
|
|
194
|
+
metric: result.metric,
|
|
195
|
+
tokenUsage: result.tokenUsage,
|
|
196
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
197
|
+
total: props.progress.total,
|
|
198
|
+
completed: ++props.progress.completed,
|
|
199
|
+
created_at: new Date().toISOString(),
|
|
200
|
+
} satisfies AutoBeInterfaceSchemaRefineEvent);
|
|
201
|
+
return out(result)(content);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function createController(
|
|
206
|
+
ctx: AutoBeContext,
|
|
207
|
+
props: {
|
|
208
|
+
typeName: string;
|
|
209
|
+
schema: AutoBeOpenApi.IJsonSchema.IObject;
|
|
210
|
+
operations: AutoBeOpenApi.IOperation[];
|
|
211
|
+
pointer: IPointer<
|
|
212
|
+
IAutoBeInterfaceSchemaRefineApplication.IComplete | null | false
|
|
213
|
+
>;
|
|
214
|
+
preliminary: AutoBePreliminaryController<
|
|
215
|
+
| "analysisSections"
|
|
216
|
+
| "databaseSchemas"
|
|
217
|
+
| "interfaceOperations"
|
|
218
|
+
| "interfaceSchemas"
|
|
219
|
+
| "previousAnalysisSections"
|
|
220
|
+
| "previousDatabaseSchemas"
|
|
221
|
+
| "previousInterfaceOperations"
|
|
222
|
+
| "previousInterfaceSchemas"
|
|
223
|
+
>;
|
|
224
|
+
},
|
|
225
|
+
): IAgenticaController.IClass {
|
|
226
|
+
const validate: Validator = (next) => {
|
|
227
|
+
const result: IValidation<IAutoBeInterfaceSchemaRefineApplication.IProps> =
|
|
228
|
+
typia.validate<IAutoBeInterfaceSchemaRefineApplication.IProps>(next);
|
|
229
|
+
if (result.success === false) {
|
|
230
|
+
fulfillJsonSchemaErrorMessages(result.errors);
|
|
231
|
+
return result;
|
|
232
|
+
} else if (result.data.request.type !== "complete")
|
|
233
|
+
return props.preliminary.validate({
|
|
234
|
+
thinking: result.data.thinking,
|
|
235
|
+
request: result.data.request,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const errors: IValidation.IError[] = [];
|
|
239
|
+
AutoBeInterfaceSchemaRefineProgrammer.validate({
|
|
240
|
+
typeName: props.typeName,
|
|
241
|
+
schema: props.schema,
|
|
242
|
+
everyModels:
|
|
243
|
+
ctx.state().database?.result.data.files.flatMap((f) => f.models) ?? [],
|
|
244
|
+
databaseSchema: result.data.request.databaseSchema,
|
|
245
|
+
excludes: result.data.request.excludes,
|
|
246
|
+
revises: result.data.request.revises,
|
|
247
|
+
errors,
|
|
248
|
+
path: `$input.request`,
|
|
249
|
+
});
|
|
250
|
+
return errors.length
|
|
251
|
+
? {
|
|
252
|
+
success: false,
|
|
253
|
+
errors,
|
|
254
|
+
data: result.data,
|
|
255
|
+
}
|
|
256
|
+
: result;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const application: ILlmApplication = props.preliminary.fixApplication(
|
|
260
|
+
typia.llm.application<IAutoBeInterfaceSchemaRefineApplication>({
|
|
261
|
+
validate: {
|
|
262
|
+
process: validate,
|
|
263
|
+
},
|
|
264
|
+
}),
|
|
265
|
+
);
|
|
266
|
+
AutoBeInterfaceSchemaRefineProgrammer.fixApplication({
|
|
267
|
+
everyModels:
|
|
268
|
+
ctx.state().database?.result.data.files.flatMap((f) => f.models) ?? [],
|
|
269
|
+
application,
|
|
270
|
+
typeName: props.typeName,
|
|
271
|
+
schema: props.schema,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
protocol: "class",
|
|
276
|
+
name: SOURCE,
|
|
277
|
+
application,
|
|
278
|
+
execute: {
|
|
279
|
+
process: (input) => {
|
|
280
|
+
if (input.request.type === "complete")
|
|
281
|
+
props.pointer.value = input.request;
|
|
282
|
+
},
|
|
283
|
+
} satisfies IAutoBeInterfaceSchemaRefineApplication,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
type Validator = (
|
|
288
|
+
input: unknown,
|
|
289
|
+
) => IValidation<IAutoBeInterfaceSchemaRefineApplication.IProps>;
|
|
290
|
+
|
|
291
|
+
const SOURCE = "interfaceSchemaRefine" satisfies AutoBeEventSource;
|