@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.
Files changed (152) hide show
  1. package/lib/AutoBeMockAgent.js +1 -1
  2. package/lib/AutoBeMockAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +10 -8
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/index.mjs +1276 -834
  6. package/lib/index.mjs.map +1 -1
  7. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +4 -9
  8. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
  9. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -8
  10. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  11. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js +1 -1
  12. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js.map +1 -1
  13. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js +1 -1
  14. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js.map +1 -1
  15. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.d.ts +3 -0
  16. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +65 -0
  17. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -0
  18. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +4 -0
  19. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +62 -0
  20. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -0
  21. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +4 -0
  22. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +28 -0
  23. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -0
  24. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +3 -0
  25. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +28 -0
  26. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -0
  27. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +4 -0
  28. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +28 -0
  29. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -0
  30. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +3 -0
  31. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js +63 -0
  32. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +1 -0
  33. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +4 -0
  34. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +28 -0
  35. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -0
  36. package/lib/orchestrate/interface/orchestrateInterface.js +14 -9
  37. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  38. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  39. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +13 -40
  40. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  41. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +3 -2
  42. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +52 -32
  43. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  44. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -0
  45. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +350 -0
  46. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -0
  47. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +249 -225
  48. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  49. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +4 -0
  50. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +411 -0
  51. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -0
  52. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +55 -0
  53. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js +3 -0
  54. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js.map +1 -0
  55. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.d.ts +23 -0
  56. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js +3 -0
  57. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js.map +1 -0
  58. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +108 -0
  59. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js +3 -0
  60. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js.map +1 -0
  61. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +122 -0
  62. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js +3 -0
  63. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js.map +1 -0
  64. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +75 -0
  65. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js +3 -0
  66. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js.map +1 -0
  67. package/lib/orchestrate/interface/{OpenApiEndpointComparator.d.ts → utils/OpenApiEndpointComparator.d.ts} +1 -0
  68. package/lib/orchestrate/interface/{OpenApiEndpointComparator.js → utils/OpenApiEndpointComparator.js} +6 -0
  69. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +1 -0
  70. package/lib/orchestrate/realize/orchestrateRealize.js +16 -2
  71. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  72. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +5 -7
  73. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  74. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +2 -2
  75. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +3 -2
  76. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
  77. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +1 -1
  78. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +34 -13
  79. package/lib/orchestrate/realize/transformRealizeAuthorization.js +1 -1
  80. package/lib/orchestrate/realize/transformRealizeAuthorization.js.map +1 -1
  81. package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js +1 -1
  82. package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  83. package/lib/orchestrate/realize/transformRealizeCoderHistories.js +5 -5
  84. package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
  85. package/lib/orchestrate/realize/utils/InternalFileSystem.d.ts +8 -0
  86. package/lib/orchestrate/realize/utils/InternalFileSystem.js +17 -0
  87. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -0
  88. package/lib/orchestrate/realize/utils/ProviderFileSystem.d.ts +3 -0
  89. package/lib/orchestrate/realize/utils/ProviderFileSystem.js +8 -0
  90. package/lib/orchestrate/realize/utils/ProviderFileSystem.js.map +1 -0
  91. package/lib/orchestrate/realize/utils/replaceImportStatements.js +2 -2
  92. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  93. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +36 -36
  94. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
  95. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +1 -0
  96. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  97. package/lib/orchestrate/test/orchestrateTestScenario.js +29 -13
  98. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  99. package/lib/orchestrate/test/transformTestWriteHistories.js +3 -2
  100. package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
  101. package/lib/utils/arrayToRecord.d.ts +17 -0
  102. package/lib/utils/arrayToRecord.js +19 -0
  103. package/lib/utils/arrayToRecord.js.map +1 -0
  104. package/lib/utils/backoffRetry.js +0 -1
  105. package/lib/utils/backoffRetry.js.map +1 -1
  106. package/package.json +5 -5
  107. package/src/AutoBeMockAgent.ts +1 -1
  108. package/src/constants/AutoBeSystemPromptConstant.ts +10 -8
  109. package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +1 -3
  110. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +1 -3
  111. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +75 -0
  112. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +69 -0
  113. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +34 -0
  114. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +32 -0
  115. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +34 -0
  116. package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.ts +66 -0
  117. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +34 -0
  118. package/src/orchestrate/interface/orchestrateInterface.ts +17 -8
  119. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +22 -97
  120. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +48 -55
  121. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +109 -0
  122. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +81 -120
  123. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +197 -0
  124. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +58 -0
  125. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.ts +24 -0
  126. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +112 -0
  127. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +125 -0
  128. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +76 -0
  129. package/src/orchestrate/interface/{OpenApiEndpointComparator.ts → utils/OpenApiEndpointComparator.ts} +8 -0
  130. package/src/orchestrate/realize/orchestrateRealize.ts +19 -2
  131. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +6 -19
  132. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +3 -6
  133. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +1 -1
  134. package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +42 -24
  135. package/src/orchestrate/realize/transformRealizeCoderHistories.ts +4 -4
  136. package/src/orchestrate/realize/utils/InternalFileSystem.ts +12 -0
  137. package/src/orchestrate/realize/utils/ProviderFileSystem.ts +4 -0
  138. package/src/orchestrate/realize/utils/replaceImportStatements.ts +2 -2
  139. package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +59 -53
  140. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +1 -0
  141. package/src/orchestrate/test/orchestrateTestScenario.ts +4 -2
  142. package/src/utils/arrayToRecord.ts +49 -0
  143. package/src/utils/backoffRetry.ts +0 -1
  144. package/lib/orchestrate/interface/OpenApiEndpointComparator.js.map +0 -1
  145. package/lib/orchestrate/interface/orchestrateInterfaceComponents.d.ts +0 -4
  146. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +0 -473
  147. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +0 -1
  148. package/lib/orchestrate/interface/transformInterfaceHistories.d.ts +0 -3
  149. package/lib/orchestrate/interface/transformInterfaceHistories.js +0 -149
  150. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +0 -1
  151. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +0 -292
  152. 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
- locale: ctx.config?.locale,
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
- locale: ctx.config?.locale,
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
- AutoBeInterfaceEndpointsEvent,
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 | AutoBeInterfaceEndpointsEvent =
33
- await orchestrateInterfaceEndpoints(ctx);
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, init.endpoints);
45
+ await orchestrateInterfaceOperations(ctx, endpoints);
43
46
 
44
47
  // TYPE SCHEMAS
45
48
  const document: AutoBeOpenApi.IDocument = {
46
49
  operations,
47
- components: await orchestrateInterfaceComponents(ctx, operations),
50
+ components: {
51
+ authorization: ctx.state().analyze?.roles ?? [],
52
+ schemas: await orchestrateInterfaceSchemas(ctx, operations),
53
+ },
48
54
  };
49
- document.components = await orchestrateInterfaceComplement(ctx, document);
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 { transformInterfaceHistories } from "./transformInterfaceHistories";
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.IComponents> {
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.IComponents> {
31
+ ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
33
32
  const missed: string[] = getMissed(document);
34
- if (missed.length === 0 || retry <= 0) return document.components;
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
- ...transformInterfaceHistories(
53
- ctx.state(),
54
- AutoBeSystemPromptConstant.INTERFACE_COMPLEMENT,
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 newComponents: AutoBeOpenApi.IComponents = {
118
- schemas: {
119
- ...pointer.value,
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: newComponents,
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 IApplication,
151
+ } satisfies IAutoBeInterfaceComplementApplication,
174
152
  };
175
153
  }
176
154
 
177
155
  const claude = typia.llm.application<
178
- IApplication,
156
+ IAutoBeInterfaceComplementApplication,
179
157
  "claude",
180
158
  { reference: true }
181
159
  >();
182
160
  const collection = {
183
161
  chatgpt: typia.llm.application<
184
- IApplication,
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
- }