@autobe/agent 0.14.6 → 0.15.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/AutoBeMockAgent.js +1 -1
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +10 -8
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/index.mjs +1276 -834
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +4 -9
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -8
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js.map +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +65 -0
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +62 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js +63 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterface.js +14 -9
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +13 -40
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +3 -2
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +52 -32
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +350 -0
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +249 -225
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +411 -0
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +55 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.d.ts +23 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +108 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +122 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +75 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js.map +1 -0
- package/lib/orchestrate/interface/{OpenApiEndpointComparator.d.ts → utils/OpenApiEndpointComparator.d.ts} +1 -0
- package/lib/orchestrate/interface/{OpenApiEndpointComparator.js → utils/OpenApiEndpointComparator.js} +6 -0
- package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +16 -2
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +5 -7
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +2 -2
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +3 -2
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +34 -13
- package/lib/orchestrate/realize/transformRealizeAuthorization.js +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +5 -5
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
- package/lib/orchestrate/realize/utils/InternalFileSystem.d.ts +8 -0
- package/lib/orchestrate/realize/utils/InternalFileSystem.js +17 -0
- package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -0
- package/lib/orchestrate/realize/utils/ProviderFileSystem.d.ts +3 -0
- package/lib/orchestrate/realize/utils/ProviderFileSystem.js +8 -0
- package/lib/orchestrate/realize/utils/ProviderFileSystem.js.map +1 -0
- package/lib/orchestrate/realize/utils/replaceImportStatements.js +2 -2
- package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +36 -36
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +1 -0
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +29 -13
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.js +3 -2
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
- package/lib/utils/arrayToRecord.d.ts +17 -0
- package/lib/utils/arrayToRecord.js +19 -0
- package/lib/utils/arrayToRecord.js.map +1 -0
- package/lib/utils/backoffRetry.js +0 -1
- package/lib/utils/backoffRetry.js.map +1 -1
- package/package.json +5 -5
- package/src/AutoBeMockAgent.ts +1 -1
- package/src/constants/AutoBeSystemPromptConstant.ts +10 -8
- package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +1 -3
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +1 -3
- package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +75 -0
- package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +69 -0
- package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +34 -0
- package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +32 -0
- package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +34 -0
- package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.ts +66 -0
- package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +34 -0
- package/src/orchestrate/interface/orchestrateInterface.ts +17 -8
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +22 -97
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +48 -55
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +109 -0
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +81 -120
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +197 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +58 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.ts +24 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +112 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +125 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +76 -0
- package/src/orchestrate/interface/{OpenApiEndpointComparator.ts → utils/OpenApiEndpointComparator.ts} +8 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +19 -2
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +6 -19
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +3 -6
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +1 -1
- package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +42 -24
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +4 -4
- package/src/orchestrate/realize/utils/InternalFileSystem.ts +12 -0
- package/src/orchestrate/realize/utils/ProviderFileSystem.ts +4 -0
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +2 -2
- package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +59 -53
- package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +1 -0
- package/src/orchestrate/test/orchestrateTestScenario.ts +4 -2
- package/src/utils/arrayToRecord.ts +49 -0
- package/src/utils/backoffRetry.ts +0 -1
- package/lib/orchestrate/interface/OpenApiEndpointComparator.js.map +0 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.d.ts +0 -4
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +0 -473
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +0 -1
- package/lib/orchestrate/interface/transformInterfaceHistories.d.ts +0 -3
- package/lib/orchestrate/interface/transformInterfaceHistories.js +0 -149
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +0 -1
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +0 -292
- package/src/orchestrate/interface/transformInterfaceHistories.ts +0 -152
|
@@ -2,7 +2,6 @@ import { MicroAgentica } from "@agentica/core";
|
|
|
2
2
|
import { ILlmSchema } from "@samchon/openapi";
|
|
3
3
|
|
|
4
4
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
5
|
-
import { randomBackoffStrategy } from "../../utils/backoffRetry";
|
|
6
5
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
7
6
|
import { transformAnalyzeReviewerHistories } from "./transformAnalyzeReviewerHistories";
|
|
8
7
|
|
|
@@ -20,8 +19,7 @@ export const orchestrateAnalyzeReviewer = async <
|
|
|
20
19
|
vendor: ctx.vendor,
|
|
21
20
|
controllers: [],
|
|
22
21
|
config: {
|
|
23
|
-
|
|
24
|
-
backoffStrategy: randomBackoffStrategy,
|
|
22
|
+
...ctx.config,
|
|
25
23
|
executor: {
|
|
26
24
|
describe: null,
|
|
27
25
|
},
|
|
@@ -6,7 +6,6 @@ import typia from "typia";
|
|
|
6
6
|
|
|
7
7
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
8
8
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
9
|
-
import { randomBackoffStrategy } from "../../utils/backoffRetry";
|
|
10
9
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
11
10
|
import {
|
|
12
11
|
AutoBeAnalyzeFileSystem,
|
|
@@ -46,8 +45,7 @@ export const orchestrateAnalyzeWrite = <Model extends ILlmSchema.Model>(
|
|
|
46
45
|
model: ctx.model,
|
|
47
46
|
vendor: ctx.vendor,
|
|
48
47
|
config: {
|
|
49
|
-
|
|
50
|
-
backoffStrategy: randomBackoffStrategy,
|
|
48
|
+
...ctx.config,
|
|
51
49
|
executor: {
|
|
52
50
|
describe: null,
|
|
53
51
|
},
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import {
|
|
3
|
+
AutoBeAnalyzeHistory,
|
|
4
|
+
AutoBePrismaHistory,
|
|
5
|
+
IAutoBePrismaCompileResult,
|
|
6
|
+
} from "@autobe/interface";
|
|
7
|
+
import { v4 } from "uuid";
|
|
8
|
+
|
|
9
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
10
|
+
|
|
11
|
+
export const transformInterfaceAssetHistories = (
|
|
12
|
+
state: AutoBeState,
|
|
13
|
+
): Array<
|
|
14
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
15
|
+
> => {
|
|
16
|
+
const analyze: AutoBeAnalyzeHistory = state.analyze!;
|
|
17
|
+
const prisma: AutoBePrismaHistory = state.prisma!;
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
id: v4(),
|
|
21
|
+
created_at: new Date().toISOString(),
|
|
22
|
+
type: "assistantMessage",
|
|
23
|
+
text: [
|
|
24
|
+
"Requirement analysis and Prisma DB schema generation are ready.",
|
|
25
|
+
"",
|
|
26
|
+
"Call the provided tool function to generate the OpenAPI document",
|
|
27
|
+
"referencing below requirement analysis and Prisma DB schema.",
|
|
28
|
+
"",
|
|
29
|
+
// User Request
|
|
30
|
+
`## User Request`,
|
|
31
|
+
"",
|
|
32
|
+
analyze.reason,
|
|
33
|
+
"",
|
|
34
|
+
// Requirement Analysis Report
|
|
35
|
+
`## Requirement Analysis Report`,
|
|
36
|
+
"",
|
|
37
|
+
"```json",
|
|
38
|
+
JSON.stringify(analyze.files),
|
|
39
|
+
"```",
|
|
40
|
+
].join("\n"),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: v4(),
|
|
44
|
+
created_at: new Date().toISOString(),
|
|
45
|
+
type: "assistantMessage",
|
|
46
|
+
text: [
|
|
47
|
+
"Database schema and entity relationship diagrams are ready.",
|
|
48
|
+
"You should also look at this and consider logic including membership/login and token issuance.",
|
|
49
|
+
"You can use table's name to define role in operations.",
|
|
50
|
+
"",
|
|
51
|
+
"## Critical Schema Verification Instructions",
|
|
52
|
+
"",
|
|
53
|
+
"**IMPORTANT**: When generating API operations and descriptions:",
|
|
54
|
+
"1. ONLY reference fields that ACTUALLY EXIST in the Prisma schema below",
|
|
55
|
+
"2. NEVER assume common fields like `deleted_at`, `created_by`, `updated_by`, `is_deleted` exist",
|
|
56
|
+
"3. For DELETE operations:",
|
|
57
|
+
" - If schema HAS soft delete fields (e.g., `deleted_at`), describe soft delete behavior",
|
|
58
|
+
" - If schema LACKS soft delete fields, describe hard delete behavior",
|
|
59
|
+
"4. Verify EVERY field reference against the actual schema before including in descriptions",
|
|
60
|
+
"",
|
|
61
|
+
"## Prisma DB Schema",
|
|
62
|
+
"```json",
|
|
63
|
+
JSON.stringify(prisma.schemas),
|
|
64
|
+
"```",
|
|
65
|
+
"",
|
|
66
|
+
"## Entity Relationship Diagrams",
|
|
67
|
+
"```json",
|
|
68
|
+
JSON.stringify(
|
|
69
|
+
(prisma.compiled as IAutoBePrismaCompileResult.ISuccess).diagrams,
|
|
70
|
+
),
|
|
71
|
+
"```",
|
|
72
|
+
].join("\n"),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
|
|
5
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
6
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
7
|
+
import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
|
|
8
|
+
|
|
9
|
+
export const transformInterfaceComplementHistories = (
|
|
10
|
+
state: AutoBeState,
|
|
11
|
+
document: AutoBeOpenApi.IDocument,
|
|
12
|
+
missed: string[],
|
|
13
|
+
): Array<
|
|
14
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
15
|
+
> => [
|
|
16
|
+
{
|
|
17
|
+
type: "systemMessage",
|
|
18
|
+
id: v4(),
|
|
19
|
+
created_at: new Date().toISOString(),
|
|
20
|
+
text: AutoBeSystemPromptConstant.INTERFACE_OPERATION,
|
|
21
|
+
},
|
|
22
|
+
...transformInterfaceAssetHistories(state),
|
|
23
|
+
{
|
|
24
|
+
type: "assistantMessage",
|
|
25
|
+
id: v4(),
|
|
26
|
+
created_at: new Date().toISOString(),
|
|
27
|
+
text: [
|
|
28
|
+
"Here is the OpenAPI operations what you AI have made:",
|
|
29
|
+
"",
|
|
30
|
+
"```json",
|
|
31
|
+
JSON.stringify(document.operations),
|
|
32
|
+
"```",
|
|
33
|
+
].join("\n"),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "systemMessage",
|
|
37
|
+
id: v4(),
|
|
38
|
+
created_at: new Date().toISOString(),
|
|
39
|
+
text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "assistantMessage",
|
|
43
|
+
id: v4(),
|
|
44
|
+
created_at: new Date().toISOString(),
|
|
45
|
+
text: [
|
|
46
|
+
"Here is the OpenAPI schemas what you AI have made:",
|
|
47
|
+
"",
|
|
48
|
+
"```json",
|
|
49
|
+
JSON.stringify(document.components.schemas),
|
|
50
|
+
"```",
|
|
51
|
+
].join("\n"),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: "systemMessage",
|
|
55
|
+
id: v4(),
|
|
56
|
+
created_at: new Date().toISOString(),
|
|
57
|
+
text: AutoBeSystemPromptConstant.INTERFACE_COMPLEMENT,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "assistantMessage",
|
|
61
|
+
id: v4(),
|
|
62
|
+
created_at: new Date().toISOString(),
|
|
63
|
+
text: [
|
|
64
|
+
"You AI have missed below schema types:",
|
|
65
|
+
"",
|
|
66
|
+
...missed.map((s) => `- ${s}`),
|
|
67
|
+
].join("\n"),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { AutoBeInterfaceGroup } from "@autobe/interface/src/histories/contents/AutoBeInterfaceGroup";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
|
|
5
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
6
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
7
|
+
import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
|
|
8
|
+
|
|
9
|
+
export const transformInterfaceEndpointHistories = (
|
|
10
|
+
state: AutoBeState,
|
|
11
|
+
group: AutoBeInterfaceGroup,
|
|
12
|
+
): Array<
|
|
13
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
14
|
+
> => [
|
|
15
|
+
{
|
|
16
|
+
type: "systemMessage",
|
|
17
|
+
id: v4(),
|
|
18
|
+
created_at: new Date().toISOString(),
|
|
19
|
+
text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
|
|
20
|
+
},
|
|
21
|
+
...transformInterfaceAssetHistories(state),
|
|
22
|
+
{
|
|
23
|
+
type: "assistantMessage",
|
|
24
|
+
id: v4(),
|
|
25
|
+
created_at: new Date().toISOString(),
|
|
26
|
+
text: [
|
|
27
|
+
"Here is the target group for the endpoints:",
|
|
28
|
+
"",
|
|
29
|
+
"```json",
|
|
30
|
+
JSON.stringify(group),
|
|
31
|
+
"```",
|
|
32
|
+
].join("\n"),
|
|
33
|
+
},
|
|
34
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
|
|
4
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
5
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
6
|
+
import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
|
|
7
|
+
import { transformInterfacePrerequisiteHistories } from "./transformInterfacePrerequisiteHistories";
|
|
8
|
+
|
|
9
|
+
export const transformInterfaceGroupHistories = (
|
|
10
|
+
state: AutoBeState,
|
|
11
|
+
): Array<
|
|
12
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
13
|
+
> => {
|
|
14
|
+
const prerequisite = transformInterfacePrerequisiteHistories(state);
|
|
15
|
+
if (prerequisite !== null) return prerequisite;
|
|
16
|
+
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
id: v4(),
|
|
20
|
+
created_at: new Date().toISOString(),
|
|
21
|
+
type: "systemMessage",
|
|
22
|
+
text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
|
|
23
|
+
},
|
|
24
|
+
...transformInterfaceAssetHistories(state),
|
|
25
|
+
{
|
|
26
|
+
id: v4(),
|
|
27
|
+
created_at: new Date().toISOString(),
|
|
28
|
+
type: "systemMessage",
|
|
29
|
+
text: AutoBeSystemPromptConstant.INTERFACE_GROUP,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
|
|
5
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
6
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
7
|
+
import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
|
|
8
|
+
|
|
9
|
+
export const transformInterfaceOperationHistories = (
|
|
10
|
+
state: AutoBeState,
|
|
11
|
+
endpoints: AutoBeOpenApi.IEndpoint[],
|
|
12
|
+
): Array<
|
|
13
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
14
|
+
> => [
|
|
15
|
+
{
|
|
16
|
+
type: "systemMessage",
|
|
17
|
+
id: v4(),
|
|
18
|
+
created_at: new Date().toISOString(),
|
|
19
|
+
text: AutoBeSystemPromptConstant.INTERFACE_OPERATION,
|
|
20
|
+
},
|
|
21
|
+
...transformInterfaceAssetHistories(state),
|
|
22
|
+
{
|
|
23
|
+
type: "assistantMessage",
|
|
24
|
+
id: v4(),
|
|
25
|
+
created_at: new Date().toISOString(),
|
|
26
|
+
text: [
|
|
27
|
+
"You have to make API operations for the given endpoints:",
|
|
28
|
+
"",
|
|
29
|
+
"```json",
|
|
30
|
+
JSON.stringify(endpoints),
|
|
31
|
+
"```",
|
|
32
|
+
].join("\n"),
|
|
33
|
+
},
|
|
34
|
+
];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
|
|
4
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
5
|
+
|
|
6
|
+
export const transformInterfacePrerequisiteHistories = (
|
|
7
|
+
state: AutoBeState,
|
|
8
|
+
): Array<
|
|
9
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
10
|
+
> | null => {
|
|
11
|
+
if (state.analyze === null)
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
id: v4(),
|
|
15
|
+
created_at: new Date().toISOString(),
|
|
16
|
+
type: "systemMessage",
|
|
17
|
+
text: [
|
|
18
|
+
"Requirement analysis is not yet completed.",
|
|
19
|
+
"Don't call the any tool function,",
|
|
20
|
+
"but say to process the requirement analysis.",
|
|
21
|
+
].join(" "),
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
else if (state.prisma === null)
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
id: v4(),
|
|
28
|
+
created_at: new Date().toISOString(),
|
|
29
|
+
type: "systemMessage",
|
|
30
|
+
text: [
|
|
31
|
+
"Prisma DB schema generation is not yet completed.",
|
|
32
|
+
"Don't call the any tool function,",
|
|
33
|
+
"but say to process the Prisma DB schema generation.",
|
|
34
|
+
].join(" "),
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
else if (state.analyze.step !== state.prisma.step)
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
id: v4(),
|
|
41
|
+
created_at: new Date().toISOString(),
|
|
42
|
+
type: "systemMessage",
|
|
43
|
+
text: [
|
|
44
|
+
"Prisma DB schema generation has not been updated",
|
|
45
|
+
"for the latest requirement analysis.",
|
|
46
|
+
"Don't call the any tool function,",
|
|
47
|
+
"but say to re-process the Prisma DB schema generation.",
|
|
48
|
+
].join(" "),
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
else if (state.prisma.compiled.type !== "success")
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
id: v4(),
|
|
55
|
+
created_at: new Date().toISOString(),
|
|
56
|
+
type: "systemMessage",
|
|
57
|
+
text: [
|
|
58
|
+
"Prisma DB schema generation has not been updated",
|
|
59
|
+
"for the latest requirement analysis.",
|
|
60
|
+
"Don't call the any tool function,",
|
|
61
|
+
"but say to re-process the Prisma DB schema generation.",
|
|
62
|
+
].join(" "),
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
|
|
5
|
+
import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
|
|
6
|
+
import { AutoBeState } from "../../../context/AutoBeState";
|
|
7
|
+
import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
|
|
8
|
+
|
|
9
|
+
export const transformInterfaceSchemaHistories = (
|
|
10
|
+
state: AutoBeState,
|
|
11
|
+
operations: AutoBeOpenApi.IOperation[],
|
|
12
|
+
): Array<
|
|
13
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
14
|
+
> => [
|
|
15
|
+
{
|
|
16
|
+
type: "systemMessage",
|
|
17
|
+
id: v4(),
|
|
18
|
+
created_at: new Date().toISOString(),
|
|
19
|
+
text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
|
|
20
|
+
},
|
|
21
|
+
...transformInterfaceAssetHistories(state),
|
|
22
|
+
{
|
|
23
|
+
type: "assistantMessage",
|
|
24
|
+
id: v4(),
|
|
25
|
+
created_at: new Date().toISOString(),
|
|
26
|
+
text: [
|
|
27
|
+
"Here is the list of API operations you have to implement its types:",
|
|
28
|
+
"",
|
|
29
|
+
"```json",
|
|
30
|
+
JSON.stringify(operations),
|
|
31
|
+
"```",
|
|
32
|
+
].join("\n"),
|
|
33
|
+
},
|
|
34
|
+
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AutoBeAssistantMessageHistory,
|
|
3
3
|
AutoBeInterfaceCompleteEvent,
|
|
4
|
-
|
|
4
|
+
AutoBeInterfaceGroupsEvent,
|
|
5
5
|
AutoBeInterfaceHistory,
|
|
6
6
|
AutoBeOpenApi,
|
|
7
7
|
} from "@autobe/interface";
|
|
@@ -11,9 +11,10 @@ import { v4 } from "uuid";
|
|
|
11
11
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
12
12
|
import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
|
|
13
13
|
import { orchestrateInterfaceComplement } from "./orchestrateInterfaceComplement";
|
|
14
|
-
import { orchestrateInterfaceComponents } from "./orchestrateInterfaceComponents";
|
|
15
14
|
import { orchestrateInterfaceEndpoints } from "./orchestrateInterfaceEndpoints";
|
|
15
|
+
import { orchestrateInterfaceGroups } from "./orchestrateInterfaceGroups";
|
|
16
16
|
import { orchestrateInterfaceOperations } from "./orchestrateInterfaceOperations";
|
|
17
|
+
import { orchestrateInterfaceSchemas } from "./orchestrateInterfaceSchemas";
|
|
17
18
|
|
|
18
19
|
export const orchestrateInterface =
|
|
19
20
|
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
@@ -29,24 +30,32 @@ export const orchestrateInterface =
|
|
|
29
30
|
step: ctx.state().analyze?.step ?? 0,
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
const init: AutoBeAssistantMessageHistory |
|
|
33
|
-
await
|
|
33
|
+
const init: AutoBeAssistantMessageHistory | AutoBeInterfaceGroupsEvent =
|
|
34
|
+
await orchestrateInterfaceGroups(ctx);
|
|
34
35
|
if (init.type === "assistantMessage") {
|
|
35
36
|
ctx.dispatch(init);
|
|
36
37
|
ctx.histories().push(init);
|
|
37
38
|
return init;
|
|
38
39
|
} else ctx.dispatch(init);
|
|
39
40
|
|
|
40
|
-
// OPERATIONS
|
|
41
|
+
// ENDPOINTS & OPERATIONS
|
|
42
|
+
const endpoints: AutoBeOpenApi.IEndpoint[] =
|
|
43
|
+
await orchestrateInterfaceEndpoints(ctx, init.groups);
|
|
41
44
|
const operations: AutoBeOpenApi.IOperation[] =
|
|
42
|
-
await orchestrateInterfaceOperations(ctx,
|
|
45
|
+
await orchestrateInterfaceOperations(ctx, endpoints);
|
|
43
46
|
|
|
44
47
|
// TYPE SCHEMAS
|
|
45
48
|
const document: AutoBeOpenApi.IDocument = {
|
|
46
49
|
operations,
|
|
47
|
-
components:
|
|
50
|
+
components: {
|
|
51
|
+
authorization: ctx.state().analyze?.roles ?? [],
|
|
52
|
+
schemas: await orchestrateInterfaceSchemas(ctx, operations),
|
|
53
|
+
},
|
|
48
54
|
};
|
|
49
|
-
document.components = await orchestrateInterfaceComplement(
|
|
55
|
+
document.components.schemas = await orchestrateInterfaceComplement(
|
|
56
|
+
ctx,
|
|
57
|
+
document,
|
|
58
|
+
);
|
|
50
59
|
|
|
51
60
|
// DO COMPILE
|
|
52
61
|
const result: AutoBeInterfaceHistory = {
|
|
@@ -8,20 +8,19 @@ import {
|
|
|
8
8
|
import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
|
|
9
9
|
import { IPointer } from "tstl";
|
|
10
10
|
import typia from "typia";
|
|
11
|
-
import { v4 } from "uuid";
|
|
12
11
|
|
|
13
|
-
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
14
12
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
13
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
16
14
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
17
15
|
import { forceRetry } from "../../utils/forceRetry";
|
|
18
|
-
import {
|
|
16
|
+
import { transformInterfaceComplementHistories } from "./histories/transformInterfaceComplementHistories";
|
|
17
|
+
import { IAutoBeInterfaceComplementApplication } from "./structures/IAutoBeInterfaceComplementApplication";
|
|
19
18
|
|
|
20
19
|
export function orchestrateInterfaceComplement<Model extends ILlmSchema.Model>(
|
|
21
20
|
ctx: AutoBeContext<Model>,
|
|
22
21
|
document: AutoBeOpenApi.IDocument,
|
|
23
22
|
life: number = 8,
|
|
24
|
-
): Promise<AutoBeOpenApi.
|
|
23
|
+
): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
|
|
25
24
|
return forceRetry(() => step(ctx, document, life));
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -29,9 +28,11 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
29
28
|
ctx: AutoBeContext<Model>,
|
|
30
29
|
document: AutoBeOpenApi.IDocument,
|
|
31
30
|
retry: number,
|
|
32
|
-
): Promise<AutoBeOpenApi.
|
|
31
|
+
): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
|
|
33
32
|
const missed: string[] = getMissed(document);
|
|
34
|
-
if (missed.length === 0 || retry <= 0)
|
|
33
|
+
if (missed.length === 0 || retry <= 0) {
|
|
34
|
+
return document.components.schemas;
|
|
35
|
+
}
|
|
35
36
|
|
|
36
37
|
const pointer: IPointer<Record<
|
|
37
38
|
string,
|
|
@@ -48,34 +49,11 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
48
49
|
describe: null,
|
|
49
50
|
},
|
|
50
51
|
},
|
|
51
|
-
histories:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
id: v4(),
|
|
58
|
-
created_at: new Date().toISOString(),
|
|
59
|
-
type: "assistantMessage",
|
|
60
|
-
text: [
|
|
61
|
-
"Here is the OpenAPI document what you've made:",
|
|
62
|
-
"",
|
|
63
|
-
"```json",
|
|
64
|
-
JSON.stringify(document),
|
|
65
|
-
"```",
|
|
66
|
-
].join("\n"),
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: v4(),
|
|
70
|
-
created_at: new Date().toISOString(),
|
|
71
|
-
type: "assistantMessage",
|
|
72
|
-
text: [
|
|
73
|
-
"You have missed below schema types in the document.components.schemas:",
|
|
74
|
-
"",
|
|
75
|
-
...missed.map((s) => `- ${s}`),
|
|
76
|
-
].join("\n"),
|
|
77
|
-
},
|
|
78
|
-
],
|
|
52
|
+
histories: transformInterfaceComplementHistories(
|
|
53
|
+
ctx.state(),
|
|
54
|
+
document,
|
|
55
|
+
missed,
|
|
56
|
+
),
|
|
79
57
|
controllers: [
|
|
80
58
|
createApplication({
|
|
81
59
|
model: ctx.model,
|
|
@@ -114,18 +92,18 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
114
92
|
created_at: new Date().toISOString(),
|
|
115
93
|
});
|
|
116
94
|
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
...document.components.schemas,
|
|
121
|
-
},
|
|
122
|
-
authorization: document.components.authorization,
|
|
95
|
+
const newSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {
|
|
96
|
+
...pointer.value,
|
|
97
|
+
...document.components.schemas,
|
|
123
98
|
};
|
|
124
99
|
return step(
|
|
125
100
|
ctx,
|
|
126
101
|
{
|
|
127
102
|
...document,
|
|
128
|
-
components:
|
|
103
|
+
components: {
|
|
104
|
+
...document.components,
|
|
105
|
+
schemas: newSchemas,
|
|
106
|
+
},
|
|
129
107
|
},
|
|
130
108
|
retry - 1,
|
|
131
109
|
);
|
|
@@ -170,18 +148,18 @@ function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
|
170
148
|
complementComponents: (next) => {
|
|
171
149
|
props.build(next.schemas);
|
|
172
150
|
},
|
|
173
|
-
} satisfies
|
|
151
|
+
} satisfies IAutoBeInterfaceComplementApplication,
|
|
174
152
|
};
|
|
175
153
|
}
|
|
176
154
|
|
|
177
155
|
const claude = typia.llm.application<
|
|
178
|
-
|
|
156
|
+
IAutoBeInterfaceComplementApplication,
|
|
179
157
|
"claude",
|
|
180
158
|
{ reference: true }
|
|
181
159
|
>();
|
|
182
160
|
const collection = {
|
|
183
161
|
chatgpt: typia.llm.application<
|
|
184
|
-
|
|
162
|
+
IAutoBeInterfaceComplementApplication,
|
|
185
163
|
"chatgpt",
|
|
186
164
|
{ reference: true }
|
|
187
165
|
>(),
|
|
@@ -190,56 +168,3 @@ const collection = {
|
|
|
190
168
|
deepseek: claude,
|
|
191
169
|
"3.1": claude,
|
|
192
170
|
};
|
|
193
|
-
|
|
194
|
-
interface IApplication {
|
|
195
|
-
/**
|
|
196
|
-
* Complements missing schema types
|
|
197
|
-
*
|
|
198
|
-
* This method fills in schema definitions that are referenced via $ref but
|
|
199
|
-
* not yet defined in the `components.schemas` section. For example, if an API
|
|
200
|
-
* operation references `{ "$ref": "#/components/schemas/UserProfile" }` but
|
|
201
|
-
* `UserProfile` type is not defined in `components.schemas`, this method will
|
|
202
|
-
* add the missing schema definition.
|
|
203
|
-
*
|
|
204
|
-
* This function is designed to be called via AI function calling mechanism to
|
|
205
|
-
* ensure the OpenAPI document is complete and all referenced schemas are
|
|
206
|
-
* properly defined.
|
|
207
|
-
*/
|
|
208
|
-
complementComponents(props: IComplementComponentsProps): void;
|
|
209
|
-
}
|
|
210
|
-
interface IComplementComponentsProps {
|
|
211
|
-
/**
|
|
212
|
-
* A collection of missing schema definitions that need to be added to the
|
|
213
|
-
* OpenAPI document's `components.schemas` section.
|
|
214
|
-
*
|
|
215
|
-
* This object contains schema definitions for types that are referenced but
|
|
216
|
-
* not yet defined:
|
|
217
|
-
*
|
|
218
|
-
* - Key: Schema name (`string`): The name of the schema type that will be
|
|
219
|
-
* referenced in $ref statements
|
|
220
|
-
* - Value: `AutoBeOpenApi.IJsonSchema` - The complete JSON Schema definition
|
|
221
|
-
* for that type
|
|
222
|
-
*
|
|
223
|
-
* Example structure:
|
|
224
|
-
*
|
|
225
|
-
* ```typescript
|
|
226
|
-
* {
|
|
227
|
-
* "UserProfile": {
|
|
228
|
-
* "type": "object",
|
|
229
|
-
* "properties": {
|
|
230
|
-
* "id": { "type": "string" },
|
|
231
|
-
* "name": { "type": "string" },
|
|
232
|
-
* "email": { "type": "string", "format": "email" }
|
|
233
|
-
* },
|
|
234
|
-
* "required": ["id", "name", "email"]
|
|
235
|
-
* }
|
|
236
|
-
* }
|
|
237
|
-
* ```
|
|
238
|
-
*
|
|
239
|
-
* Each schema definition follows the JSON Schema specification and will be
|
|
240
|
-
* directly inserted into the OpenAPI document's components.schemas section,
|
|
241
|
-
* making them available for $ref references throughout the API
|
|
242
|
-
* specification.
|
|
243
|
-
*/
|
|
244
|
-
schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
|
|
245
|
-
}
|