@autobe/agent 0.24.1 → 0.25.0

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 (225) hide show
  1. package/lib/AutoBeMockAgent.js +1 -0
  2. package/lib/AutoBeMockAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +19 -18
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/context/IAutoBeApplication.d.ts +101 -6
  6. package/lib/context/IAutoBeApplicationProps.d.ts +6 -2
  7. package/lib/factory/createAgenticaHistory.js +1 -1
  8. package/lib/factory/createAgenticaHistory.js.map +1 -1
  9. package/lib/factory/createAutoBeApplication.js +80 -90
  10. package/lib/factory/createAutoBeApplication.js.map +1 -1
  11. package/lib/factory/createAutoBeContext.js +8 -8
  12. package/lib/factory/createAutoBeContext.js.map +1 -1
  13. package/lib/factory/getAutoBeGenerated.js +4 -1
  14. package/lib/factory/getAutoBeGenerated.js.map +1 -1
  15. package/lib/factory/getAutoBeRealizeGenerated.d.ts +2 -1
  16. package/lib/factory/getAutoBeRealizeGenerated.js +1 -1
  17. package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -1
  18. package/lib/factory/getCriticalCompiler.js +1 -1
  19. package/lib/factory/getCriticalCompiler.js.map +1 -1
  20. package/lib/index.mjs +2222 -1393
  21. package/lib/index.mjs.map +1 -1
  22. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +5 -1
  23. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  24. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
  25. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +18 -3
  26. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  27. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +5 -1
  28. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +19 -7
  29. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  30. package/lib/orchestrate/analyze/orchestrateAnalyze.js +3 -2
  31. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  32. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
  33. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
  34. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  35. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +1 -0
  36. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -2
  37. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  38. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  39. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  40. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +2 -1
  41. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  42. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +5 -1
  43. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +20 -7
  44. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  45. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +6 -1
  46. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -23
  47. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  48. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +6 -1
  49. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +22 -6
  50. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  51. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
  52. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  53. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +4 -1
  54. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +26 -5
  55. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  56. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +5 -1
  57. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +21 -5
  58. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  59. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
  60. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  61. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +5 -1
  62. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +20 -4
  63. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  64. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +1 -1
  65. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  66. package/lib/orchestrate/interface/orchestrateInterface.js +25 -7
  67. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  68. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
  69. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +17 -8
  70. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  71. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
  72. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +18 -11
  73. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  74. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
  75. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +25 -10
  76. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  77. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
  78. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +9 -6
  79. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  80. package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
  81. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +33 -17
  82. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  83. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
  84. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +36 -18
  85. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  86. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +67 -8
  87. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  88. package/lib/orchestrate/interface/utils/OperationValidator.js +2 -1
  89. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  90. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.d.ts +4 -1
  91. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +19 -8
  92. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  93. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
  94. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  95. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.d.ts +6 -1
  96. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +20 -6
  97. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  98. package/lib/orchestrate/prisma/orchestratePrisma.js +3 -3
  99. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  100. package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -1
  101. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -3
  102. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  103. package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +1 -1
  104. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +12 -6
  105. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  106. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +1 -1
  107. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  108. package/lib/orchestrate/{common/histories/transformCommonCorrectDateHistories.d.ts → realize/histories/transformRealizeCorrectCastingHistories.d.ts} +1 -2
  109. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +33 -0
  110. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
  111. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +1 -1
  112. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  113. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +1 -1
  114. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  115. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +3 -1
  116. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  117. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +25 -8
  118. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  119. package/lib/orchestrate/realize/orchestrateRealize.js +12 -8
  120. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  121. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +3 -1
  122. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  123. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +16 -5
  124. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  125. package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -5
  126. package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
  127. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +1 -0
  128. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  129. package/lib/orchestrate/realize/utils/replaceImportStatements.js +3 -1
  130. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  131. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +5 -1
  132. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +11 -7
  133. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  134. package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +7 -1
  135. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +39 -31
  136. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  137. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +8 -0
  138. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +119 -0
  139. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -0
  140. package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +5 -1
  141. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +111 -94
  142. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  143. package/lib/orchestrate/test/orchestrateTest.js +20 -14
  144. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  145. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -1
  146. package/lib/orchestrate/test/orchestrateTestCorrect.js +51 -35
  147. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  148. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  149. package/lib/orchestrate/test/orchestrateTestScenario.js +21 -4
  150. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  151. package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +9 -0
  152. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +855 -0
  153. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -0
  154. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
  155. package/lib/orchestrate/test/orchestrateTestWrite.js +9 -4
  156. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  157. package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.d.ts +47 -0
  158. package/lib/orchestrate/{common/structures/IAutoBeCommonCorrectDateApplication.js → test/structures/IAutoBeTestScenarioReviewApplication.js} +1 -1
  159. package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js.map +1 -0
  160. package/package.json +6 -6
  161. package/src/AutoBeMockAgent.ts +1 -0
  162. package/src/constants/AutoBeSystemPromptConstant.ts +19 -18
  163. package/src/context/IAutoBeApplication.ts +101 -6
  164. package/src/context/IAutoBeApplicationProps.ts +6 -2
  165. package/src/factory/createAgenticaHistory.ts +11 -5
  166. package/src/factory/createAutoBeContext.ts +5 -5
  167. package/src/factory/getAutoBeGenerated.ts +3 -0
  168. package/src/factory/getAutoBeRealizeGenerated.ts +3 -1
  169. package/src/factory/getCriticalCompiler.ts +2 -1
  170. package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +5 -1
  171. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +16 -0
  172. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +22 -7
  173. package/src/orchestrate/analyze/orchestrateAnalyze.ts +3 -2
  174. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
  175. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
  176. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +2 -1
  177. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
  178. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +33 -24
  179. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +26 -9
  180. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +27 -5
  181. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
  182. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
  183. package/src/orchestrate/interface/orchestrateInterface.ts +29 -10
  184. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
  185. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +25 -17
  186. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +35 -23
  187. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
  188. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +44 -29
  189. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +51 -32
  190. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +68 -8
  191. package/src/orchestrate/interface/utils/OperationValidator.ts +2 -1
  192. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +20 -6
  193. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +24 -9
  194. package/src/orchestrate/prisma/orchestratePrisma.ts +7 -3
  195. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +5 -1
  196. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -10
  197. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +45 -0
  198. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +3 -1
  199. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +30 -8
  200. package/src/orchestrate/realize/orchestrateRealize.ts +36 -40
  201. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +5 -1
  202. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +38 -16
  203. package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
  204. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +1 -0
  205. package/src/orchestrate/realize/utils/replaceImportStatements.ts +5 -0
  206. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
  207. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +44 -36
  208. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +159 -0
  209. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
  210. package/src/orchestrate/test/orchestrateTest.ts +19 -13
  211. package/src/orchestrate/test/orchestrateTestCorrect.ts +65 -46
  212. package/src/orchestrate/test/orchestrateTestScenario.ts +23 -9
  213. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +198 -0
  214. package/src/orchestrate/test/orchestrateTestWrite.ts +13 -4
  215. package/src/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.ts +52 -0
  216. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +0 -48
  217. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +0 -1
  218. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +0 -35
  219. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +0 -1
  220. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +0 -4
  221. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +0 -540
  222. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +0 -1
  223. package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +0 -60
  224. package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +0 -40
  225. package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +0 -372
@@ -8,11 +8,12 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
8
8
  import { AutoBeState } from "../../../context/AutoBeState";
9
9
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
10
10
 
11
- export const transformInterfaceEndpointHistories = (
12
- state: AutoBeState,
13
- group: AutoBeInterfaceGroup,
14
- authorizations: AutoBeOpenApi.IOperation[],
15
- ): Array<
11
+ export const transformInterfaceEndpointHistories = (props: {
12
+ state: AutoBeState;
13
+ group: AutoBeInterfaceGroup;
14
+ authorizations: AutoBeOpenApi.IOperation[];
15
+ instruction: string;
16
+ }): Array<
16
17
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
17
18
  > => [
18
19
  {
@@ -21,25 +22,41 @@ export const transformInterfaceEndpointHistories = (
21
22
  created_at: new Date().toISOString(),
22
23
  text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
23
24
  },
24
- ...transformInterfaceAssetHistories(state),
25
+ ...transformInterfaceAssetHistories(props.state),
25
26
  {
26
27
  type: "assistantMessage",
27
28
  id: v7(),
28
29
  created_at: new Date().toISOString(),
29
30
  text: StringUtil.trim`
31
+ ## API Design Instructions
32
+
33
+ The following API-specific instructions were extracted by AI from
34
+ the user's utterances. These focus ONLY on API interface design aspects
35
+ such as endpoint patterns, request/response formats, DTO schemas,
36
+ and operation specifications.
37
+
38
+ Apply these instructions when designing endpoints for the ${props.group.name} group.
39
+ Consider the specified URL patterns, HTTP methods, parameter structures,
40
+ and response formats. If the instructions are not relevant to this specific
41
+ endpoint group, you may ignore them.
42
+
43
+ ${props.instruction}
44
+
45
+ ## Group Information
46
+
30
47
  Here is the target group for the endpoints:
31
48
 
32
49
  \`\`\`json
33
- ${JSON.stringify(group)}
50
+ ${JSON.stringify(props.group)}
34
51
  \`\`\`
35
52
 
36
- **IMPORTANT: DO NOT DUPLICATE EXISTING OPERATIONS**
53
+ ## Already Existing Operations
37
54
 
38
55
  These operations already exist. Do NOT create similar endpoints:
39
56
 
40
57
  \`\`\`json
41
58
  ${JSON.stringify(
42
- authorizations.map((op) => ({
59
+ props.authorizations.map((op) => ({
43
60
  path: op.path,
44
61
  method: op.method,
45
62
  name: op.name,
@@ -1,4 +1,5 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { StringUtil } from "@autobe/utils";
2
3
  import { v7 } from "uuid";
3
4
 
4
5
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
@@ -6,12 +7,13 @@ import { AutoBeState } from "../../../context/AutoBeState";
6
7
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
7
8
  import { transformInterfacePrerequisiteHistories } from "./transformInterfacePrerequisiteHistories";
8
9
 
9
- export const transformInterfaceGroupHistories = (
10
- state: AutoBeState,
11
- ): Array<
10
+ export const transformInterfaceGroupHistories = (props: {
11
+ state: AutoBeState;
12
+ instruction: string;
13
+ }): Array<
12
14
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
13
15
  > => {
14
- const prerequisite = transformInterfacePrerequisiteHistories(state);
16
+ const prerequisite = transformInterfacePrerequisiteHistories(props.state);
15
17
  if (prerequisite !== null) return prerequisite;
16
18
 
17
19
  return [
@@ -21,12 +23,32 @@ export const transformInterfaceGroupHistories = (
21
23
  type: "systemMessage",
22
24
  text: AutoBeSystemPromptConstant.INTERFACE_ENDPOINT,
23
25
  },
24
- ...transformInterfaceAssetHistories(state),
26
+ ...transformInterfaceAssetHistories(props.state),
25
27
  {
26
28
  id: v7(),
27
29
  created_at: new Date().toISOString(),
28
30
  type: "systemMessage",
29
31
  text: AutoBeSystemPromptConstant.INTERFACE_GROUP,
30
32
  },
33
+ {
34
+ id: v7(),
35
+ created_at: new Date().toISOString(),
36
+ type: "assistantMessage",
37
+ text: StringUtil.trim`
38
+ ## API Design Instructions
39
+
40
+ The following API-specific instructions were extracted by AI from
41
+ the user's utterances. These focus ONLY on API interface design aspects
42
+ such as endpoint patterns, request/response formats, DTO schemas,
43
+ and operation specifications.
44
+
45
+ Apply these instructions when organizing API endpoints into logical groups.
46
+ Consider how to structure and categorize endpoints based on business domains,
47
+ resource types, or functional areas. If the instructions are not relevant
48
+ to endpoint grouping and organization, you may ignore them.
49
+
50
+ ${props.instruction}
51
+ `,
52
+ },
31
53
  ];
32
54
  };
@@ -7,13 +7,14 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
9
9
 
10
- export const transformInterfaceOperationHistories = (
11
- state: AutoBeState,
12
- endpoints: AutoBeOpenApi.IEndpoint[],
13
- ): Array<
10
+ export const transformInterfaceOperationHistories = (props: {
11
+ state: AutoBeState;
12
+ endpoints: AutoBeOpenApi.IEndpoint[];
13
+ instruction: string;
14
+ }): Array<
14
15
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
16
  > => {
16
- const analyze: AutoBeAnalyzeHistory = state.analyze!;
17
+ const analyze: AutoBeAnalyzeHistory = props.state.analyze!;
17
18
  return [
18
19
  {
19
20
  type: "systemMessage",
@@ -21,7 +22,7 @@ export const transformInterfaceOperationHistories = (
21
22
  created_at: new Date().toISOString(),
22
23
  text: AutoBeSystemPromptConstant.INTERFACE_OPERATION,
23
24
  },
24
- ...transformInterfaceAssetHistories(state),
25
+ ...transformInterfaceAssetHistories(props.state),
25
26
  {
26
27
  type: "systemMessage",
27
28
  id: v7(),
@@ -44,10 +45,26 @@ export const transformInterfaceOperationHistories = (
44
45
  id: v7(),
45
46
  created_at: new Date().toISOString(),
46
47
  text: StringUtil.trim`
48
+ ## API Design Instructions
49
+
50
+ The following API-specific instructions were extracted by AI from
51
+ the user's utterances. These focus ONLY on API interface design aspects
52
+ such as endpoint patterns, request/response formats, DTO schemas,
53
+ and operation specifications.
54
+
55
+ Apply these instructions when designing the detailed operation specifications
56
+ for each endpoint. Consider parameter types, request/response structures,
57
+ error handling, and API behavior patterns. If the instructions are not
58
+ relevant to the operations you need to implement, you may ignore them.
59
+
60
+ ${props.instruction}
61
+
62
+ ## Operations
63
+
47
64
  You have to make API operations for the given endpoints:
48
65
 
49
66
  \`\`\`json
50
- ${JSON.stringify(endpoints)}
67
+ ${JSON.stringify(props.endpoints)}
51
68
  \`\`\`
52
69
 
53
70
  If there is a content in the failure, it is to explain why it failed before.
@@ -7,10 +7,11 @@ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromp
7
7
  import { AutoBeState } from "../../../context/AutoBeState";
8
8
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
9
9
 
10
- export const transformInterfaceSchemaHistories = (
11
- state: AutoBeState,
12
- operations: AutoBeOpenApi.IOperation[],
13
- ): Array<
10
+ export const transformInterfaceSchemaHistories = (props: {
11
+ state: AutoBeState;
12
+ operations: AutoBeOpenApi.IOperation[];
13
+ instruction: string;
14
+ }): Array<
14
15
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
16
  > => [
16
17
  {
@@ -19,16 +20,32 @@ export const transformInterfaceSchemaHistories = (
19
20
  created_at: new Date().toISOString(),
20
21
  text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
21
22
  },
22
- ...transformInterfaceAssetHistories(state),
23
+ ...transformInterfaceAssetHistories(props.state),
23
24
  {
24
25
  type: "assistantMessage",
25
26
  id: v7(),
26
27
  created_at: new Date().toISOString(),
27
28
  text: StringUtil.trim`
29
+ ## API Design Instructions
30
+
31
+ The following API-specific instructions were extracted by AI from
32
+ the user's utterances. These focus ONLY on API interface design aspects
33
+ such as endpoint patterns, request/response formats, DTO schemas,
34
+ and operation specifications.
35
+
36
+ Apply these instructions when creating JSON schema components for the operations.
37
+ Focus on data structure design, field naming conventions, validation rules,
38
+ and type definitions. If the instructions are not relevant to the schema
39
+ components you need to create, you may ignore them.
40
+
41
+ ${props.instruction}
42
+
43
+ ## Operations
44
+
28
45
  Here is the list of API operations you have to implement its types:
29
46
 
30
47
  \`\`\`json
31
- ${JSON.stringify(operations)}
48
+ ${JSON.stringify(props.operations)}
32
49
  \`\`\`
33
50
  `,
34
51
  },
@@ -45,28 +45,38 @@ export const orchestrateInterface =
45
45
  type: "interfaceStart",
46
46
  id: v7(),
47
47
  created_at: start.toISOString(),
48
- reason: props.reason,
48
+ reason: props.instruction,
49
49
  step: ctx.state().analyze?.step ?? 0,
50
50
  });
51
51
 
52
52
  // ENDPOINTS
53
- const init: AutoBeInterfaceGroupsEvent =
54
- await orchestrateInterfaceGroups(ctx);
53
+ const init: AutoBeInterfaceGroupsEvent = await orchestrateInterfaceGroups(
54
+ ctx,
55
+ {
56
+ instruction: props.instruction,
57
+ },
58
+ );
55
59
  ctx.dispatch(init);
56
60
 
57
61
  // AUTHORIZATION
58
62
  const authorizations: AutoBeInterfaceAuthorization[] =
59
- await orchestrateInterfaceAuthorizations(ctx);
60
-
61
- const authOperations = authorizations
63
+ await orchestrateInterfaceAuthorizations(ctx, props.instruction);
64
+ const authOperations: AutoBeOpenApi.IOperation[] = authorizations
62
65
  .map((authorization) => authorization.operations)
63
66
  .flat();
64
67
 
65
68
  // ENDPOINTS & OPERATIONS
66
69
  const endpoints: AutoBeOpenApi.IEndpoint[] =
67
- await orchestrateInterfaceEndpoints(ctx, init.groups, authOperations);
70
+ await orchestrateInterfaceEndpoints(ctx, {
71
+ groups: init.groups,
72
+ authorizations: authOperations,
73
+ instruction: props.instruction,
74
+ });
68
75
  const firstOperations: AutoBeOpenApi.IOperation[] =
69
- await orchestrateInterfaceOperations(ctx, endpoints);
76
+ await orchestrateInterfaceOperations(ctx, {
77
+ endpoints,
78
+ instruction: props.instruction,
79
+ });
70
80
  const operations: AutoBeOpenApi.IOperation[] = new HashMap<
71
81
  AutoBeOpenApi.IEndpoint,
72
82
  AutoBeOpenApi.IOperation
@@ -92,14 +102,20 @@ export const orchestrateInterface =
92
102
  operations,
93
103
  components: {
94
104
  authorization: ctx.state().analyze?.roles ?? [],
95
- schemas: await orchestrateInterfaceSchemas(ctx, operations),
105
+ schemas: await orchestrateInterfaceSchemas(ctx, {
106
+ instruction: props.instruction,
107
+ operations,
108
+ }),
96
109
  },
97
110
  };
98
111
 
99
112
  const complementedSchemas: Record<
100
113
  string,
101
114
  AutoBeOpenApi.IJsonSchemaDescriptive
102
- > = await orchestrateInterfaceComplement(ctx, document);
115
+ > = await orchestrateInterfaceComplement(ctx, {
116
+ instruction: props.instruction,
117
+ document,
118
+ });
103
119
  Object.assign(document.components.schemas, complementedSchemas);
104
120
 
105
121
  const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
@@ -109,6 +125,9 @@ export const orchestrateInterface =
109
125
  document.components.schemas,
110
126
  );
111
127
  Object.assign(document.components.schemas, schemas);
128
+ for (const key of Object.keys(document.components.schemas))
129
+ if (key === "IPageI" || key.startsWith("IPageI."))
130
+ delete document.components.schemas[key];
112
131
 
113
132
  // DO COMPILE
114
133
  return ctx.dispatch({
@@ -20,7 +20,10 @@ import { IAutoBeInterfaceAuthorizationsApplication } from "./structures/IAutoBeI
20
20
 
21
21
  export async function orchestrateInterfaceAuthorizations<
22
22
  Model extends ILlmSchema.Model,
23
- >(ctx: AutoBeContext<Model>): Promise<AutoBeInterfaceAuthorization[]> {
23
+ >(
24
+ ctx: AutoBeContext<Model>,
25
+ instruction: string,
26
+ ): Promise<AutoBeInterfaceAuthorization[]> {
24
27
  const roles: AutoBeAnalyzeRole[] = ctx.state().analyze?.roles ?? [];
25
28
  const progress: AutoBeProgressEventBase = {
26
29
  total: roles.length,
@@ -29,12 +32,12 @@ export async function orchestrateInterfaceAuthorizations<
29
32
  const authorizations: AutoBeInterfaceAuthorization[] =
30
33
  await executeCachedBatch(
31
34
  roles.map((role) => async (promptCacheKey) => {
32
- const event: AutoBeInterfaceAuthorizationEvent = await process(
33
- ctx,
35
+ const event: AutoBeInterfaceAuthorizationEvent = await process(ctx, {
34
36
  role,
35
37
  progress,
36
38
  promptCacheKey,
37
- );
39
+ instruction,
40
+ });
38
41
  ctx.dispatch(event);
39
42
  return {
40
43
  role: role.name,
@@ -48,9 +51,12 @@ export async function orchestrateInterfaceAuthorizations<
48
51
 
49
52
  async function process<Model extends ILlmSchema.Model>(
50
53
  ctx: AutoBeContext<Model>,
51
- role: AutoBeAnalyzeRole,
52
- progress: AutoBeProgressEventBase,
53
- promptCacheKey: string,
54
+ props: {
55
+ instruction: string;
56
+ role: AutoBeAnalyzeRole;
57
+ progress: AutoBeProgressEventBase;
58
+ promptCacheKey: string;
59
+ },
54
60
  ): Promise<AutoBeInterfaceAuthorizationEvent> {
55
61
  const pointer: IPointer<IAutoBeInterfaceAuthorizationsApplication.IProps | null> =
56
62
  {
@@ -58,16 +64,20 @@ async function process<Model extends ILlmSchema.Model>(
58
64
  };
59
65
  const { tokenUsage } = await ctx.conversate({
60
66
  source: "interfaceAuthorization",
61
- histories: transformInterfaceAuthorizationsHistories(ctx.state(), role),
67
+ histories: transformInterfaceAuthorizationsHistories({
68
+ state: ctx.state(),
69
+ instruction: props.instruction,
70
+ role: props.role,
71
+ }),
62
72
  controller: createController({
63
73
  model: ctx.model,
64
- role,
74
+ role: props.role,
65
75
  build: (next) => {
66
76
  pointer.value = next;
67
77
  },
68
78
  }),
69
79
  enforceFunctionCall: true,
70
- promptCacheKey,
80
+ promptCacheKey: props.promptCacheKey,
71
81
  message: "Create Authorization Operation for the given roles",
72
82
  });
73
83
  if (pointer.value === null)
@@ -77,11 +87,11 @@ async function process<Model extends ILlmSchema.Model>(
77
87
  type: "interfaceAuthorization",
78
88
  id: v7(),
79
89
  operations: pointer.value.operations,
80
- completed: ++progress.completed,
90
+ completed: ++props.progress.completed,
81
91
  tokenUsage,
82
92
  created_at: new Date().toISOString(),
83
93
  step: ctx.state().analyze?.step ?? 0,
84
- total: progress.total,
94
+ total: props.progress.total,
85
95
  } satisfies AutoBeInterfaceAuthorizationEvent;
86
96
  }
87
97
 
@@ -22,20 +22,24 @@ import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMe
22
22
 
23
23
  export function orchestrateInterfaceComplement<Model extends ILlmSchema.Model>(
24
24
  ctx: AutoBeContext<Model>,
25
- document: AutoBeOpenApi.IDocument,
25
+ props: {
26
+ instruction: string;
27
+ document: AutoBeOpenApi.IDocument;
28
+ },
26
29
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
27
- return step(ctx, document, 8);
30
+ return step(ctx, props, 8);
28
31
  }
29
32
 
30
33
  async function step<Model extends ILlmSchema.Model>(
31
34
  ctx: AutoBeContext<Model>,
32
- document: AutoBeOpenApi.IDocument,
35
+ props: {
36
+ instruction: string;
37
+ document: AutoBeOpenApi.IDocument;
38
+ },
33
39
  life: number,
34
40
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
35
- const missed: string[] = getMissed(document);
36
- if (missed.length === 0 || life < 0) {
37
- return document.components.schemas;
38
- }
41
+ const missed: string[] = getMissed(props.document);
42
+ if (missed.length === 0 || life < 0) return props.document.components.schemas;
39
43
 
40
44
  const pointer: IPointer<Record<
41
45
  string,
@@ -45,11 +49,12 @@ async function step<Model extends ILlmSchema.Model>(
45
49
  };
46
50
  const { tokenUsage } = await ctx.conversate({
47
51
  source: "interfaceComplement",
48
- histories: transformInterfaceComplementHistories(
49
- ctx.state(),
50
- document,
52
+ histories: transformInterfaceComplementHistories({
53
+ state: ctx.state(),
54
+ instruction: props.instruction,
55
+ document: props.document,
51
56
  missed,
52
- ),
57
+ }),
53
58
  controller: createController({
54
59
  model: ctx.model,
55
60
  build: (next) => {
@@ -85,16 +90,19 @@ async function step<Model extends ILlmSchema.Model>(
85
90
 
86
91
  const newSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {
87
92
  ...pointer.value,
88
- ...document.components.schemas,
93
+ ...props.document.components.schemas,
89
94
  };
90
- JsonSchemaNamingConvention.schemas(document.operations, newSchemas);
95
+ JsonSchemaNamingConvention.schemas(props.document.operations, newSchemas);
91
96
  return step(
92
97
  ctx,
93
98
  {
94
- ...document,
95
- components: {
96
- ...document.components,
97
- schemas: newSchemas,
99
+ instruction: props.instruction,
100
+ document: {
101
+ ...props.document,
102
+ components: {
103
+ ...props.document.components,
104
+ schemas: newSchemas,
105
+ },
98
106
  },
99
107
  },
100
108
  life - 1,
@@ -22,39 +22,50 @@ export async function orchestrateInterfaceEndpoints<
22
22
  Model extends ILlmSchema.Model,
23
23
  >(
24
24
  ctx: AutoBeContext<Model>,
25
- groups: AutoBeInterfaceGroup[],
26
- authorizations: AutoBeOpenApi.IOperation[],
27
- content: string = `Make endpoints for the given assets`,
25
+ props: {
26
+ groups: AutoBeInterfaceGroup[];
27
+ authorizations: AutoBeOpenApi.IOperation[];
28
+ instruction: string;
29
+ message?: string;
30
+ },
28
31
  ): Promise<AutoBeOpenApi.IEndpoint[]> {
29
32
  const progress: AutoBeProgressEventBase = {
30
- total: groups.length,
33
+ total: props.groups.length,
31
34
  completed: 0,
32
35
  };
33
36
  const endpoints: AutoBeOpenApi.IEndpoint[] = (
34
37
  await executeCachedBatch(
35
- groups.map(
36
- (g) => (promptCacheKey) =>
37
- process(ctx, g, content, progress, authorizations, promptCacheKey),
38
+ props.groups.map(
39
+ (group) => (promptCacheKey) =>
40
+ process(ctx, {
41
+ group,
42
+ authorizations: props.authorizations,
43
+ instruction: props.instruction,
44
+ message: props.message ?? "Make endpoints for the given assets.",
45
+ progress,
46
+ promptCacheKey,
47
+ }),
38
48
  ),
39
49
  )
40
50
  ).flat();
41
-
42
51
  const deduplicated: AutoBeOpenApi.IEndpoint[] = new HashSet(
43
52
  endpoints,
44
53
  OpenApiEndpointComparator.hashCode,
45
54
  OpenApiEndpointComparator.equals,
46
55
  ).toJSON();
47
-
48
56
  return orchestrateInterfaceEndpointsReview(ctx, deduplicated);
49
57
  }
50
58
 
51
59
  async function process<Model extends ILlmSchema.Model>(
52
60
  ctx: AutoBeContext<Model>,
53
- group: AutoBeInterfaceGroup,
54
- message: string,
55
- progress: AutoBeProgressEventBase,
56
- authorizations: AutoBeOpenApi.IOperation[],
57
- promptCacheKey: string,
61
+ props: {
62
+ group: AutoBeInterfaceGroup;
63
+ message: string;
64
+ progress: AutoBeProgressEventBase;
65
+ authorizations: AutoBeOpenApi.IOperation[];
66
+ promptCacheKey: string;
67
+ instruction: string;
68
+ },
58
69
  ): Promise<AutoBeOpenApi.IEndpoint[]> {
59
70
  const start: Date = new Date();
60
71
  const pointer: IPointer<AutoBeOpenApi.IEndpoint[] | null> = {
@@ -62,11 +73,12 @@ async function process<Model extends ILlmSchema.Model>(
62
73
  };
63
74
  const { tokenUsage } = await ctx.conversate({
64
75
  source: "interfaceEndpoints",
65
- histories: transformInterfaceEndpointHistories(
66
- ctx.state(),
67
- group,
68
- authorizations,
69
- ),
76
+ histories: transformInterfaceEndpointHistories({
77
+ state: ctx.state(),
78
+ group: props.group,
79
+ authorizations: props.authorizations,
80
+ instruction: props.instruction,
81
+ }),
70
82
  controller: createController({
71
83
  model: ctx.model,
72
84
  build: (endpoints) => {
@@ -75,8 +87,8 @@ async function process<Model extends ILlmSchema.Model>(
75
87
  },
76
88
  }),
77
89
  enforceFunctionCall: true,
78
- promptCacheKey,
79
- message,
90
+ promptCacheKey: props.promptCacheKey,
91
+ message: props.message,
80
92
  });
81
93
  if (pointer.value === null) throw new Error("Failed to generate endpoints."); // unreachable
82
94
 
@@ -91,8 +103,8 @@ async function process<Model extends ILlmSchema.Model>(
91
103
  tokenUsage,
92
104
  created_at: start.toISOString(),
93
105
  step: ctx.state().analyze?.step ?? 0,
94
- completed: ++progress.completed,
95
- total: progress.total,
106
+ completed: ++props.progress.completed,
107
+ total: props.progress.total,
96
108
  };
97
109
  ctx.dispatch(event);
98
110
  return pointer.value;
@@ -14,7 +14,10 @@ export async function orchestrateInterfaceGroups<
14
14
  Model extends ILlmSchema.Model,
15
15
  >(
16
16
  ctx: AutoBeContext<Model>,
17
- message: string = "Design API operations for the given assets.",
17
+ props: {
18
+ instruction: string;
19
+ message?: string;
20
+ },
18
21
  ): Promise<AutoBeInterfaceGroupsEvent> {
19
22
  const start: Date = new Date();
20
23
  const pointer: IPointer<IAutoBeInterfaceGroupApplication.IProps | null> = {
@@ -22,7 +25,10 @@ export async function orchestrateInterfaceGroups<
22
25
  };
23
26
  const { tokenUsage } = await ctx.conversate({
24
27
  source: "interfaceGroups",
25
- histories: transformInterfaceGroupHistories(ctx.state()),
28
+ histories: transformInterfaceGroupHistories({
29
+ state: ctx.state(),
30
+ instruction: props.instruction,
31
+ }),
26
32
  controller: createController({
27
33
  model: ctx.model,
28
34
  build: (next) => {
@@ -30,7 +36,7 @@ export async function orchestrateInterfaceGroups<
30
36
  },
31
37
  }),
32
38
  enforceFunctionCall: true,
33
- message,
39
+ message: props.message ?? "Design API operations for the given assets.",
34
40
  });
35
41
  if (pointer.value === null) throw new Error("Failed to generate groups."); // unreachable
36
42
  return {