@autobe/agent 0.26.0 → 0.27.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 (189) hide show
  1. package/lib/AutoBeAgent.d.ts +2 -1
  2. package/lib/AutoBeAgent.js +27 -7
  3. package/lib/AutoBeAgent.js.map +1 -1
  4. package/lib/AutoBeMockAgent.js +2 -4
  5. package/lib/AutoBeMockAgent.js.map +1 -1
  6. package/lib/constants/AutoBeSystemPromptConstant.d.ts +10 -10
  7. package/lib/context/AutoBeContext.d.ts +4 -1
  8. package/lib/context/AutoBeTokenUsage.d.ts +1 -1
  9. package/lib/context/AutoBeTokenUsage.js.map +1 -1
  10. package/lib/factory/AutoBeFunctionCallingMetricFactory.d.ts +7 -0
  11. package/lib/factory/AutoBeFunctionCallingMetricFactory.js +35 -0
  12. package/lib/factory/AutoBeFunctionCallingMetricFactory.js.map +1 -0
  13. package/lib/factory/AutoBeProcessAggregateFactory.d.ts +13 -0
  14. package/lib/factory/AutoBeProcessAggregateFactory.js +100 -0
  15. package/lib/factory/AutoBeProcessAggregateFactory.js.map +1 -0
  16. package/lib/factory/createAutoBeContext.d.ts +2 -1
  17. package/lib/factory/createAutoBeContext.js +78 -27
  18. package/lib/factory/createAutoBeContext.js.map +1 -1
  19. package/lib/index.mjs +1891 -1214
  20. package/lib/index.mjs.map +1 -1
  21. package/lib/orchestrate/analyze/orchestrateAnalyze.js +1 -0
  22. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  23. package/lib/orchestrate/analyze/orchestrateAnalyzeReview.js +2 -1
  24. package/lib/orchestrate/analyze/orchestrateAnalyzeReview.js.map +1 -1
  25. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -1
  26. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  27. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +3 -2
  28. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  29. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.d.ts +2 -1
  30. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +3 -2
  31. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  32. package/lib/{factory/createAutoBeApplication.d.ts → orchestrate/facade/createAutoBeFacadeController.d.ts} +2 -2
  33. package/lib/{factory/createAutoBeApplication.js → orchestrate/facade/createAutoBeFacadeController.js} +53 -57
  34. package/lib/orchestrate/facade/createAutoBeFacadeController.js.map +1 -0
  35. package/lib/orchestrate/facade/histories/IAutoBeFacadeApplication.js.map +1 -0
  36. package/lib/orchestrate/facade/histories/IAutoBeFacadeApplicationProps.js.map +1 -0
  37. package/lib/orchestrate/facade/histories/IAutoBeFacadeApplicationResult.js.map +1 -0
  38. package/lib/orchestrate/facade/{transformFacadeStateMessage.d.ts → structures/transformFacadeStateMessage.d.ts} +1 -1
  39. package/lib/orchestrate/facade/structures/transformFacadeStateMessage.js.map +1 -0
  40. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +2 -2
  41. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  42. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  43. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  44. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +3 -2
  45. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  46. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +1 -1
  47. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  48. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  49. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  50. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  51. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  52. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  53. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  54. package/lib/orchestrate/interface/orchestrateInterface.d.ts +1 -1
  55. package/lib/orchestrate/interface/orchestrateInterface.js +15 -8
  56. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  57. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +136 -48
  58. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  59. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +234 -59
  60. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  61. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -2
  62. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  63. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +0 -6
  64. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +2 -2
  65. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.js.map +1 -1
  66. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +2 -1
  67. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  68. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +137 -49
  69. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  70. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +136 -48
  71. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  72. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +2 -1
  73. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -1
  74. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRename.js +2 -1
  75. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRename.js.map +1 -1
  76. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.d.ts +5 -3
  77. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js +241 -69
  78. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js.map +1 -1
  79. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +234 -59
  80. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  81. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +23 -23
  82. package/lib/orchestrate/prisma/orchestratePrisma.d.ts +1 -1
  83. package/lib/orchestrate/prisma/orchestratePrisma.js +1 -0
  84. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  85. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +2 -1
  86. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  87. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +2 -1
  88. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  89. package/lib/orchestrate/prisma/orchestratePrismaReview.js +2 -1
  90. package/lib/orchestrate/prisma/orchestratePrismaReview.js.map +1 -1
  91. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +2 -1
  92. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  93. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +2 -2
  94. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js.map +1 -1
  95. package/lib/orchestrate/realize/orchestrateRealize.d.ts +1 -1
  96. package/lib/orchestrate/realize/orchestrateRealize.js +2 -1
  97. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  98. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +2 -1
  99. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  100. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +3 -2
  101. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  102. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +3 -2
  103. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  104. package/lib/orchestrate/realize/orchestrateRealizeCorrectCasting.js +6 -5
  105. package/lib/orchestrate/realize/orchestrateRealizeCorrectCasting.js.map +1 -1
  106. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +2 -1
  107. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  108. package/lib/orchestrate/realize/utils/replaceImportStatements.js +0 -85
  109. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  110. package/lib/orchestrate/test/orchestrateTest.d.ts +1 -1
  111. package/lib/orchestrate/test/orchestrateTest.js +2 -1
  112. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  113. package/lib/orchestrate/test/orchestrateTestCorrect.js +3 -1
  114. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  115. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +3 -2
  116. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  117. package/lib/orchestrate/test/orchestrateTestScenario.js +2 -1
  118. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  119. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +2 -1
  120. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  121. package/lib/orchestrate/test/orchestrateTestWrite.js +2 -1
  122. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  123. package/lib/utils/TokenUsageComputer.d.ts +5 -0
  124. package/lib/utils/TokenUsageComputer.js +29 -0
  125. package/lib/utils/TokenUsageComputer.js.map +1 -0
  126. package/package.json +7 -7
  127. package/src/AutoBeAgent.ts +40 -6
  128. package/src/AutoBeMockAgent.ts +2 -4
  129. package/src/constants/AutoBeSystemPromptConstant.ts +10 -10
  130. package/src/context/AutoBeContext.ts +8 -0
  131. package/src/context/AutoBeTokenUsage.ts +1 -1
  132. package/src/factory/AutoBeFunctionCallingMetricFactory.ts +44 -0
  133. package/src/factory/AutoBeProcessAggregateFactory.ts +141 -0
  134. package/src/factory/createAutoBeContext.ts +96 -36
  135. package/src/orchestrate/analyze/orchestrateAnalyze.ts +1 -0
  136. package/src/orchestrate/analyze/orchestrateAnalyzeReview.ts +2 -1
  137. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
  138. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
  139. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +5 -2
  140. package/src/orchestrate/facade/createAutoBeFacadeController.ts +135 -0
  141. package/src/orchestrate/facade/{transformFacadeStateMessage.ts → structures/transformFacadeStateMessage.ts} +2 -2
  142. package/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.ts +1 -0
  143. package/src/orchestrate/interface/orchestrateInterface.ts +17 -6
  144. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +2 -1
  145. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +2 -1
  146. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +3 -2
  147. package/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.ts +3 -4
  148. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +2 -1
  149. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +2 -1
  150. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +2 -1
  151. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +2 -1
  152. package/src/orchestrate/interface/orchestrateInterfaceSchemaRename.ts +2 -1
  153. package/src/orchestrate/interface/orchestrateInterfaceSchemaReview.ts +10 -15
  154. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +2 -1
  155. package/src/orchestrate/prisma/orchestratePrisma.ts +2 -1
  156. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +2 -1
  157. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +2 -1
  158. package/src/orchestrate/prisma/orchestratePrismaReview.ts +2 -1
  159. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +2 -1
  160. package/src/orchestrate/realize/orchestrateRealize.ts +3 -2
  161. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +2 -1
  162. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +2 -1
  163. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +3 -2
  164. package/src/orchestrate/realize/orchestrateRealizeCorrectCasting.ts +6 -5
  165. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +2 -1
  166. package/src/orchestrate/realize/utils/replaceImportStatements.ts +0 -90
  167. package/src/orchestrate/test/orchestrateTest.ts +3 -2
  168. package/src/orchestrate/test/orchestrateTestCorrect.ts +3 -1
  169. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +3 -2
  170. package/src/orchestrate/test/orchestrateTestScenario.ts +2 -1
  171. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +2 -1
  172. package/src/orchestrate/test/orchestrateTestWrite.ts +2 -1
  173. package/src/utils/TokenUsageComputer.ts +35 -0
  174. package/lib/context/IAutoBeFacadeApplication.js.map +0 -1
  175. package/lib/context/IAutoBeFacadeApplicationProps.js.map +0 -1
  176. package/lib/context/IAutoBeFacadeApplicationResult.js.map +0 -1
  177. package/lib/factory/createAutoBeApplication.js.map +0 -1
  178. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +0 -1
  179. package/src/factory/createAutoBeApplication.ts +0 -123
  180. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplication.d.ts +0 -0
  181. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplication.js +0 -0
  182. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationProps.d.ts +0 -0
  183. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationProps.js +0 -0
  184. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationResult.d.ts +0 -0
  185. /package/lib/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationResult.js +0 -0
  186. /package/lib/orchestrate/facade/{transformFacadeStateMessage.js → structures/transformFacadeStateMessage.js} +0 -0
  187. /package/src/{context → orchestrate/facade/histories}/IAutoBeFacadeApplication.ts +0 -0
  188. /package/src/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationProps.ts +0 -0
  189. /package/src/{context → orchestrate/facade/histories}/IAutoBeFacadeApplicationResult.ts +0 -0
@@ -0,0 +1,135 @@
1
+ import { IAgenticaController } from "@agentica/core";
2
+ import {
3
+ AutoBeAnalyzeHistory,
4
+ AutoBeAssistantMessageEvent,
5
+ AutoBeAssistantMessageHistory,
6
+ AutoBeInterfaceHistory,
7
+ AutoBePrismaHistory,
8
+ AutoBeRealizeHistory,
9
+ AutoBeTestHistory,
10
+ } from "@autobe/interface";
11
+ import { StringUtil } from "@autobe/utils";
12
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
13
+ import typia from "typia";
14
+
15
+ import { AutoBeContext } from "../../context/AutoBeContext";
16
+ import { assertSchemaModel } from "../../context/assertSchemaModel";
17
+ import { orchestrateAnalyze } from "../analyze/orchestrateAnalyze";
18
+ import { orchestrateInterface } from "../interface/orchestrateInterface";
19
+ import { orchestratePrisma } from "../prisma/orchestratePrisma";
20
+ import { orchestrateRealize } from "../realize/orchestrateRealize";
21
+ import { orchestrateTest } from "../test/orchestrateTest";
22
+ import { IAutoBeFacadeApplication } from "./histories/IAutoBeFacadeApplication";
23
+
24
+ export const createAutoBeFacadeController = <
25
+ Model extends ILlmSchema.Model,
26
+ >(props: {
27
+ model: Model;
28
+ context: AutoBeContext<Model>;
29
+ }): IAgenticaController.IClass<Model> => {
30
+ assertSchemaModel(props.model);
31
+ const application: ILlmApplication<Model> = collection[
32
+ props.model
33
+ ] satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
34
+ return {
35
+ protocol: "class",
36
+ name: "autobe",
37
+ application,
38
+ execute: {
39
+ analyze: async () => {
40
+ const history: AutoBeAssistantMessageHistory | AutoBeAnalyzeHistory =
41
+ await orchestrateAnalyze(props.context);
42
+ if (history.type === "assistantMessage")
43
+ return {
44
+ type: "in-progress",
45
+ description: StringUtil.trim`
46
+ Requirements are not yet fully elicited,
47
+ therefore additional questions will be made to the user.
48
+ `,
49
+ };
50
+ return {
51
+ type: "success",
52
+ description:
53
+ "Analysis completed successfully, and report has been published.",
54
+ };
55
+ },
56
+ prisma: async (next) => {
57
+ const history: AutoBeAssistantMessageHistory | AutoBePrismaHistory =
58
+ await orchestratePrisma(props.context, next);
59
+ if (history.type === "assistantMessage")
60
+ return {
61
+ type: "prerequisites-not-satisfied",
62
+ description: "Requirement analysis is not yet completed.",
63
+ };
64
+ return {
65
+ type: history.compiled.type,
66
+ description:
67
+ history.compiled.type === "success"
68
+ ? "Prisma schemas have been generated successfully."
69
+ : history.result.success === false ||
70
+ history.compiled.type === "failure"
71
+ ? "Prisma schemas are generated, but compilation failed."
72
+ : "Unexpected error occurred while generating Prisma schemas.",
73
+ };
74
+ },
75
+ interface: async (next) => {
76
+ const history: AutoBeAssistantMessageEvent | AutoBeInterfaceHistory =
77
+ await orchestrateInterface(props.context)(next);
78
+ if (history.type === "assistantMessage")
79
+ return {
80
+ type: "prerequisites-not-satisfied",
81
+ description: "Prisma schemas are not yet completed.",
82
+ };
83
+ return {
84
+ type: "success",
85
+ description: "API interfaces have been designed successfully.",
86
+ };
87
+ },
88
+ test: async (next) => {
89
+ const history: AutoBeAssistantMessageHistory | AutoBeTestHistory =
90
+ await orchestrateTest(props.context)(next);
91
+ if (history.type === "assistantMessage")
92
+ return {
93
+ type: "prerequisites-not-satisfied",
94
+ description: "API interfaces are not yet completed.",
95
+ };
96
+ return {
97
+ type: history.compiled.type,
98
+ description:
99
+ history.compiled.type === "success"
100
+ ? "Test functions have been generated successfully."
101
+ : history.compiled.type === "failure"
102
+ ? "Test functions are written, but compilation failed."
103
+ : "Unexpected error occurred while writing test functions.",
104
+ };
105
+ },
106
+ realize: async (next) => {
107
+ const history: AutoBeAssistantMessageHistory | AutoBeRealizeHistory =
108
+ await orchestrateRealize(props.context)(next);
109
+ if (history.type === "assistantMessage")
110
+ return {
111
+ type: "prerequisites-not-satisfied",
112
+ description: "API interfaces are not yet completed.",
113
+ };
114
+ return {
115
+ type: history.compiled.type,
116
+ description:
117
+ history.compiled.type === "success"
118
+ ? "API implementation codes have been generated successfully."
119
+ : history.compiled.type === "failure"
120
+ ? "Implementation codes are composed, but compilation failed."
121
+ : "Unexpected error occurred while writing implementation codes.",
122
+ };
123
+ },
124
+ } satisfies IAutoBeFacadeApplication,
125
+ };
126
+ };
127
+
128
+ const claude = typia.llm.application<IAutoBeFacadeApplication, "claude">();
129
+ const collection = {
130
+ chatgpt: typia.llm.application<IAutoBeFacadeApplication, "chatgpt">(),
131
+ claude,
132
+ llama: claude,
133
+ deepseek: claude,
134
+ "3.1": claude,
135
+ };
@@ -1,7 +1,7 @@
1
1
  import { StringUtil } from "@autobe/utils";
2
2
 
3
- import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
4
- import { AutoBeState } from "../../context/AutoBeState";
3
+ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
4
+ import { AutoBeState } from "../../../context/AutoBeState";
5
5
 
6
6
  export function transformFacadeStateMessage(state: AutoBeState): string {
7
7
  const currentState: ICurrentState = getCurrentState(state);
@@ -24,6 +24,7 @@ export const transformInterfaceEndpointsReviewHistories = (
24
24
  type: "assistantMessage",
25
25
  text: [
26
26
  "Below are endpoints generated by your request.",
27
+ "",
27
28
  "```json",
28
29
  JSON.stringify(endpoints),
29
30
  "```",
@@ -5,6 +5,7 @@ import {
5
5
  AutoBeInterfaceGroupEvent,
6
6
  AutoBeInterfaceHistory,
7
7
  AutoBeOpenApi,
8
+ AutoBeProgressEventBase,
8
9
  } from "@autobe/interface";
9
10
  import { AutoBeInterfacePrerequisite } from "@autobe/interface/src/histories/contents/AutoBeInterfacePrerequisite";
10
11
  import {
@@ -16,10 +17,11 @@ import { ILlmSchema } from "@samchon/openapi";
16
17
  import { HashMap, Pair } from "tstl";
17
18
  import { v7 } from "uuid";
18
19
 
20
+ import { AutoBeConfigConstant } from "../../constants/AutoBeConfigConstant";
19
21
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
20
22
  import { AutoBeContext } from "../../context/AutoBeContext";
21
- import { IAutoBeFacadeApplicationProps } from "../../context/IAutoBeFacadeApplicationProps";
22
23
  import { predicateStateMessage } from "../../utils/predicateStateMessage";
24
+ import { IAutoBeFacadeApplicationProps } from "../facade/histories/IAutoBeFacadeApplicationProps";
23
25
  import { orchestrateInterfaceAuthorizations } from "./orchestrateInterfaceAuthorizations";
24
26
  import { orchestrateInterfaceComplement } from "./orchestrateInterfaceComplement";
25
27
  import { orchestrateInterfaceEndpoints } from "./orchestrateInterfaceEndpoints";
@@ -130,19 +132,26 @@ export const orchestrateInterface =
130
132
  );
131
133
  await complement();
132
134
 
135
+ const reviewProgress: AutoBeProgressEventBase = {
136
+ completed: 0,
137
+ total: Math.ceil(
138
+ Object.keys(document.components.schemas).length /
139
+ AutoBeConfigConstant.INTERFACE_CAPACITY,
140
+ ),
141
+ };
133
142
  for (const config of [
134
143
  {
135
- type: "interfaceSchemaSecurityReview" as const,
144
+ kind: "security" as const,
136
145
  systemPrompt:
137
146
  AutoBeSystemPromptConstant.INTERFACE_SCHEMA_SECURITY_REVIEW,
138
147
  },
139
148
  {
140
- type: "interfaceSchemaRelationReview" as const,
149
+ kind: "relation" as const,
141
150
  systemPrompt:
142
151
  AutoBeSystemPromptConstant.INTERFACE_SCHEMA_RELATION_REVIEW,
143
152
  },
144
153
  {
145
- type: "interfaceSchemaContentReview" as const,
154
+ kind: "content" as const,
146
155
  systemPrompt:
147
156
  AutoBeSystemPromptConstant.INTERFACE_SCHEMA_CONTENT_REVIEW,
148
157
  },
@@ -151,6 +160,7 @@ export const orchestrateInterface =
151
160
  await orchestrateInterfaceSchemaReview(ctx, config, {
152
161
  instruction: props.instruction,
153
162
  document,
163
+ progress: reviewProgress,
154
164
  }),
155
165
  );
156
166
  if (missedOpenApiSchemas(document).length !== 0) await complement();
@@ -181,8 +191,9 @@ export const orchestrateInterface =
181
191
  document,
182
192
  missed: missedOpenApiSchemas(document),
183
193
  authorizations,
184
- created_at: new Date().toISOString(),
185
- elapsed: new Date().getTime() - start.getTime(),
194
+ aggregates: ctx.getCurrentAggregates("interface"),
186
195
  step: ctx.state().analyze?.step ?? 0,
196
+ elapsed: new Date().getTime() - start.getTime(),
197
+ created_at: new Date().toISOString(),
187
198
  } satisfies AutoBeInterfaceCompleteEvent);
188
199
  };
@@ -62,7 +62,7 @@ async function process<Model extends ILlmSchema.Model>(
62
62
  {
63
63
  value: null,
64
64
  };
65
- const { tokenUsage } = await ctx.conversate({
65
+ const { metric, tokenUsage } = await ctx.conversate({
66
66
  source: "interfaceAuthorization",
67
67
  histories: transformInterfaceAuthorizationsHistories({
68
68
  state: ctx.state(),
@@ -88,6 +88,7 @@ async function process<Model extends ILlmSchema.Model>(
88
88
  id: v7(),
89
89
  operations: pointer.value.operations,
90
90
  completed: ++props.progress.completed,
91
+ metric,
91
92
  tokenUsage,
92
93
  created_at: new Date().toISOString(),
93
94
  step: ctx.state().analyze?.step ?? 0,
@@ -50,7 +50,7 @@ async function step<Model extends ILlmSchema.Model>(
50
50
  > | null> = {
51
51
  value: null,
52
52
  };
53
- const { tokenUsage } = await ctx.conversate({
53
+ const { metric, tokenUsage } = await ctx.conversate({
54
54
  source: "interfaceComplement",
55
55
  histories: transformInterfaceComplementHistories({
56
56
  state: ctx.state(),
@@ -86,6 +86,7 @@ async function step<Model extends ILlmSchema.Model>(
86
86
  id: v7(),
87
87
  missed,
88
88
  schemas: pointer.value,
89
+ metric,
89
90
  tokenUsage,
90
91
  step: ctx.state().analyze?.step ?? 0,
91
92
  created_at: new Date().toISOString(),
@@ -53,7 +53,7 @@ export async function orchestrateInterfaceEndpoints<
53
53
  AutoBeOpenApiEndpointComparator.hashCode,
54
54
  AutoBeOpenApiEndpointComparator.equals,
55
55
  ).toJSON();
56
- return orchestrateInterfaceEndpointsReview(ctx, deduplicated);
56
+ return await orchestrateInterfaceEndpointsReview(ctx, deduplicated);
57
57
  }
58
58
 
59
59
  async function process<Model extends ILlmSchema.Model>(
@@ -71,7 +71,7 @@ async function process<Model extends ILlmSchema.Model>(
71
71
  const pointer: IPointer<AutoBeOpenApi.IEndpoint[] | null> = {
72
72
  value: null,
73
73
  };
74
- const { tokenUsage } = await ctx.conversate({
74
+ const { metric, tokenUsage } = await ctx.conversate({
75
75
  source: "interfaceEndpoint",
76
76
  histories: transformInterfaceEndpointHistories({
77
77
  state: ctx.state(),
@@ -100,6 +100,7 @@ async function process<Model extends ILlmSchema.Model>(
100
100
  AutoBeOpenApiEndpointComparator.hashCode,
101
101
  AutoBeOpenApiEndpointComparator.equals,
102
102
  ).toJSON(),
103
+ metric,
103
104
  tokenUsage,
104
105
  created_at: start.toISOString(),
105
106
  step: ctx.state().analyze?.step ?? 0,
@@ -22,7 +22,7 @@ export async function orchestrateInterfaceEndpointsReview<
22
22
  value: null,
23
23
  };
24
24
 
25
- const { tokenUsage } = await ctx.conversate({
25
+ const { metric, tokenUsage } = await ctx.conversate({
26
26
  source: "interfaceEndpointReview",
27
27
  histories: transformInterfaceEndpointsReviewHistories(
28
28
  ctx.state(),
@@ -43,7 +43,6 @@ export async function orchestrateInterfaceEndpointsReview<
43
43
  }
44
44
 
45
45
  const response = pointer.value?.endpoints ?? [];
46
-
47
46
  ctx.dispatch({
48
47
  id: v7(),
49
48
  type: "interfaceEndpointReview",
@@ -52,13 +51,13 @@ export async function orchestrateInterfaceEndpointsReview<
52
51
  created_at: new Date().toISOString(),
53
52
  review: pointer.value?.review,
54
53
  step: ctx.state().analyze?.step ?? 0,
54
+ metric,
55
55
  tokenUsage,
56
56
  });
57
-
58
57
  return response;
59
58
  }
60
59
 
61
- export function createController<Model extends ILlmSchema.Model>(props: {
60
+ function createController<Model extends ILlmSchema.Model>(props: {
62
61
  model: Model;
63
62
  build: (props: IAutoBeInterfaceEndpointsReviewApplication.IProps) => void;
64
63
  }): IAgenticaController.IClass<Model> {
@@ -23,7 +23,7 @@ export async function orchestrateInterfaceGroups<
23
23
  const pointer: IPointer<IAutoBeInterfaceGroupApplication.IProps | null> = {
24
24
  value: null,
25
25
  };
26
- const { tokenUsage } = await ctx.conversate({
26
+ const { metric, tokenUsage } = await ctx.conversate({
27
27
  source: "interfaceGroup",
28
28
  histories: transformInterfaceGroupHistories({
29
29
  state: ctx.state(),
@@ -44,6 +44,7 @@ export async function orchestrateInterfaceGroups<
44
44
  id: v7(),
45
45
  created_at: start.toISOString(),
46
46
  groups: pointer.value.groups,
47
+ metric,
47
48
  tokenUsage,
48
49
  step: ctx.state().analyze?.step ?? 0,
49
50
  } satisfies AutoBeInterfaceGroupEvent;
@@ -119,7 +119,7 @@ async function process<Model extends ILlmSchema.Model>(
119
119
  const pointer: IPointer<AutoBeOpenApi.IOperation[] | null> = {
120
120
  value: null,
121
121
  };
122
- const { tokenUsage } = await ctx.conversate({
122
+ const { metric, tokenUsage } = await ctx.conversate({
123
123
  source: "interfaceOperation",
124
124
  histories: transformInterfaceOperationHistories({
125
125
  state: ctx.state(),
@@ -181,6 +181,7 @@ async function process<Model extends ILlmSchema.Model>(
181
181
  type: "interfaceOperation",
182
182
  id: v7(),
183
183
  operations: pointer.value,
184
+ metric,
184
185
  tokenUsage,
185
186
  ...props.progress,
186
187
  step: ctx.state().analyze?.step ?? 0,
@@ -28,7 +28,7 @@ export async function orchestrateInterfaceOperationsReview<
28
28
  {
29
29
  value: null,
30
30
  };
31
- const { tokenUsage } = await ctx.conversate({
31
+ const { metric, tokenUsage } = await ctx.conversate({
32
32
  source: "interfaceOperationReview",
33
33
  histories: transformInterfaceOperationsReviewHistories(ctx, operations),
34
34
  controller: createReviewController({
@@ -60,6 +60,7 @@ export async function orchestrateInterfaceOperationsReview<
60
60
  review: pointer.value.think.review,
61
61
  plan: pointer.value.think.plan,
62
62
  content,
63
+ metric,
63
64
  tokenUsage,
64
65
  created_at: new Date().toISOString(),
65
66
  step: ctx.state().analyze?.step ?? 0,
@@ -107,7 +107,7 @@ async function divideAndConquer<Model extends ILlmSchema.Model>(
107
107
  };
108
108
 
109
109
  try {
110
- const { tokenUsage } = await ctx.conversate({
110
+ const { metric, tokenUsage } = await ctx.conversate({
111
111
  source: "interfacePrerequisite",
112
112
  controller: createController({
113
113
  model: ctx.model,
@@ -134,6 +134,7 @@ async function divideAndConquer<Model extends ILlmSchema.Model>(
134
134
  type: "interfacePrerequisite",
135
135
  id: v7(),
136
136
  created_at: new Date().toISOString(),
137
+ metric,
137
138
  tokenUsage,
138
139
  operations: pointer.value,
139
140
  total: props.progress.total,
@@ -157,7 +157,7 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
157
157
  {
158
158
  value: null,
159
159
  };
160
- const { tokenUsage } = await ctx.conversate({
160
+ const { metric, tokenUsage } = await ctx.conversate({
161
161
  source: "interfaceSchemaRename",
162
162
  controller: createController<Model>(
163
163
  ctx.model,
@@ -180,6 +180,7 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
180
180
  refactors: pointer.value.refactors,
181
181
  total: props.progress.total,
182
182
  completed: (props.progress.completed += props.typeNames.length),
183
+ metric,
183
184
  tokenUsage,
184
185
  created_at: new Date().toISOString(),
185
186
  } satisfies AutoBeInterfaceSchemaRenameEvent);
@@ -1,5 +1,6 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
2
  import { AutoBeOpenApi, AutoBeProgressEventBase } from "@autobe/interface";
3
+ import { AutoBeInterfaceSchemaReviewEvent } from "@autobe/interface/src/events/AutoBeInterfaceSchemaReviewEvent";
3
4
  import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
4
5
  import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
5
6
  import { IPointer } from "tstl";
@@ -19,10 +20,7 @@ import { JsonSchemaValidator } from "./utils/JsonSchemaValidator";
19
20
  import { fulfillJsonSchemaErrorMessages } from "./utils/fulfillJsonSchemaErrorMessages";
20
21
 
21
22
  interface IConfig {
22
- type:
23
- | "interfaceSchemaContentReview"
24
- | "interfaceSchemaSecurityReview"
25
- | "interfaceSchemaRelationReview";
23
+ kind: AutoBeInterfaceSchemaReviewEvent["kind"];
26
24
  systemPrompt: string;
27
25
  }
28
26
 
@@ -34,19 +32,14 @@ export async function orchestrateInterfaceSchemaReview<
34
32
  props: {
35
33
  document: AutoBeOpenApi.IDocument;
36
34
  instruction: string;
35
+ progress: AutoBeProgressEventBase;
37
36
  },
38
- capacity: number = AutoBeConfigConstant.INTERFACE_CAPACITY,
39
37
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
40
38
  const typeNames: string[] = Object.keys(props.document.components.schemas);
41
39
  const matrix: string[][] = divideArray({
42
40
  array: typeNames,
43
- capacity,
41
+ capacity: AutoBeConfigConstant.INTERFACE_CAPACITY,
44
42
  });
45
- const progress: AutoBeProgressEventBase = {
46
- total: matrix.length,
47
- completed: 0,
48
- };
49
-
50
43
  const x: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
51
44
  for (const y of await executeCachedBatch(
52
45
  matrix.map((it) => async (promptCacheKey) => {
@@ -68,7 +61,7 @@ export async function orchestrateInterfaceSchemaReview<
68
61
  },
69
62
  {} as Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
70
63
  ),
71
- progress,
64
+ progress: props.progress,
72
65
  promptCacheKey,
73
66
  });
74
67
  return row;
@@ -97,8 +90,8 @@ async function divideAndConquer<Model extends ILlmSchema.Model>(
97
90
  {
98
91
  value: null,
99
92
  };
100
- const { tokenUsage } = await ctx.conversate({
101
- source: "interfaceSchemaContentReview",
93
+ const { metric, tokenUsage } = await ctx.conversate({
94
+ source: "interfaceSchemaReview",
102
95
  controller: createController({
103
96
  model: ctx.model,
104
97
  pointer,
@@ -127,12 +120,14 @@ async function divideAndConquer<Model extends ILlmSchema.Model>(
127
120
  ).schemas ?? {}) as Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
128
121
 
129
122
  ctx.dispatch({
130
- type: config.type,
123
+ type: "interfaceSchemaReview",
124
+ kind: config.kind,
131
125
  id: v7(),
132
126
  schemas: props.reviewSchemas,
133
127
  review: pointer.value.think.review,
134
128
  plan: pointer.value.think.plan,
135
129
  content,
130
+ metric,
136
131
  tokenUsage,
137
132
  step: ctx.state().analyze?.step ?? 0,
138
133
  total: props.progress.total,
@@ -133,7 +133,7 @@ async function process<Model extends ILlmSchema.Model>(
133
133
  > | null> = {
134
134
  value: null,
135
135
  };
136
- const { tokenUsage } = await ctx.conversate({
136
+ const { metric, tokenUsage } = await ctx.conversate({
137
137
  source: "interfaceSchema",
138
138
  histories: transformInterfaceSchemaHistories({
139
139
  state: ctx.state(),
@@ -187,6 +187,7 @@ async function process<Model extends ILlmSchema.Model>(
187
187
  type: "interfaceSchema",
188
188
  id: v7(),
189
189
  schemas,
190
+ metric,
190
191
  tokenUsage,
191
192
  completed: (props.progress.completed += Object.keys(schemas).length),
192
193
  total: (props.progress.total += Object.keys(schemas).filter(
@@ -13,8 +13,8 @@ import { ILlmSchema } from "@samchon/openapi";
13
13
  import { v7 } from "uuid";
14
14
 
15
15
  import { AutoBeContext } from "../../context/AutoBeContext";
16
- import { IAutoBeFacadeApplicationProps } from "../../context/IAutoBeFacadeApplicationProps";
17
16
  import { predicateStateMessage } from "../../utils/predicateStateMessage";
17
+ import { IAutoBeFacadeApplicationProps } from "../facade/histories/IAutoBeFacadeApplicationProps";
18
18
  import { orchestratePrismaComponents } from "./orchestratePrismaComponent";
19
19
  import { orchestratePrismaCorrect } from "./orchestratePrismaCorrect";
20
20
  import { orchestratePrismaReview } from "./orchestratePrismaReview";
@@ -104,6 +104,7 @@ export const orchestratePrisma = async <Model extends ILlmSchema.Model>(
104
104
  compiled: await compiler.prisma.compile({
105
105
  files: finalSchemas,
106
106
  }),
107
+ aggregates: ctx.getCurrentAggregates("prisma"),
107
108
  step: ctx.state().analyze?.step ?? 0,
108
109
  elapsed: new Date().getTime() - start.getTime(),
109
110
  created_at: new Date().toISOString(),
@@ -22,7 +22,7 @@ export async function orchestratePrismaComponents<
22
22
  value: null,
23
23
  };
24
24
  const prefix: string | null = ctx.state().analyze?.prefix ?? null;
25
- const { tokenUsage } = await ctx.conversate({
25
+ const { metric, tokenUsage } = await ctx.conversate({
26
26
  source: "prismaComponent",
27
27
  histories: transformPrismaComponentsHistories(ctx.state(), {
28
28
  prefix,
@@ -47,6 +47,7 @@ export async function orchestratePrismaComponents<
47
47
  review: pointer.value.review,
48
48
  decision: pointer.value.decision,
49
49
  components: pointer.value.components,
50
+ metric,
50
51
  tokenUsage,
51
52
  step: ctx.state().analyze?.step ?? 0,
52
53
  };
@@ -116,7 +116,7 @@ async function execute<Model extends ILlmSchema.Model>(
116
116
  const pointer: IPointer<IAutoBePrismaCorrectApplication.IProps | null> = {
117
117
  value: null,
118
118
  };
119
- const { tokenUsage } = await ctx.conversate({
119
+ const { metric, tokenUsage } = await ctx.conversate({
120
120
  source: "prismaCorrect",
121
121
  histories: transformPrismaCorrectHistories(failure),
122
122
  controller: createController({
@@ -149,6 +149,7 @@ async function execute<Model extends ILlmSchema.Model>(
149
149
  failure,
150
150
  planning: pointer.value.planning,
151
151
  correction: correction,
152
+ metric,
152
153
  tokenUsage,
153
154
  step: ctx.state().analyze?.step ?? 0,
154
155
  created_at: new Date().toISOString(),
@@ -56,7 +56,7 @@ async function step<Model extends ILlmSchema.Model>(
56
56
  const pointer: IPointer<IAutoBePrismaReviewApplication.IProps | null> = {
57
57
  value: null,
58
58
  };
59
- const { tokenUsage } = await ctx.conversate({
59
+ const { metric, tokenUsage } = await ctx.conversate({
60
60
  source: "prismaReview",
61
61
  histories: transformPrismaReviewHistories({
62
62
  analysis:
@@ -90,6 +90,7 @@ async function step<Model extends ILlmSchema.Model>(
90
90
  review: pointer.value.review,
91
91
  plan: pointer.value.plan,
92
92
  modifications: pointer.value.modifications,
93
+ metric,
93
94
  tokenUsage,
94
95
  completed: ++props.progress.completed,
95
96
  total: props.progress.total,
@@ -59,7 +59,7 @@ async function process<Model extends ILlmSchema.Model>(
59
59
  const pointer: IPointer<IAutoBePrismaSchemaApplication.IProps | null> = {
60
60
  value: null,
61
61
  };
62
- const { tokenUsage } = await ctx.conversate({
62
+ const { metric, tokenUsage } = await ctx.conversate({
63
63
  source: "prismaSchema",
64
64
  histories: transformPrismaSchemaHistories({
65
65
  analysis:
@@ -97,6 +97,7 @@ async function process<Model extends ILlmSchema.Model>(
97
97
  namespace: props.component.namespace,
98
98
  models: pointer.value.models,
99
99
  },
100
+ metric,
100
101
  tokenUsage,
101
102
  completed: (props.completed.value += props.component.tables.length),
102
103
  total: props.total,
@@ -13,9 +13,9 @@ import { ILlmSchema } from "@samchon/openapi";
13
13
  import { v7 } from "uuid";
14
14
 
15
15
  import { AutoBeContext } from "../../context/AutoBeContext";
16
- import { IAutoBeFacadeApplicationProps } from "../../context/IAutoBeFacadeApplicationProps";
17
16
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
18
17
  import { predicateStateMessage } from "../../utils/predicateStateMessage";
18
+ import { IAutoBeFacadeApplicationProps } from "../facade/histories/IAutoBeFacadeApplicationProps";
19
19
  import { compileRealizeFiles } from "./internal/compileRealizeFiles";
20
20
  import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
21
21
  import { orchestrateRealizeCorrect } from "./orchestrateRealizeCorrect";
@@ -189,13 +189,14 @@ export const orchestrateRealize =
189
189
  return ctx.dispatch({
190
190
  type: "realizeComplete",
191
191
  id: v7(),
192
- created_at: new Date().toISOString(),
193
192
  functions: bucket.corrected,
194
193
  authorizations,
195
194
  controllers,
196
195
  compiled: bucket.validate.result,
196
+ aggregates: ctx.getCurrentAggregates("realize"),
197
197
  step: ctx.state().analyze?.step ?? 0,
198
198
  elapsed: new Date().getTime() - start.getTime(),
199
+ created_at: new Date().toISOString(),
199
200
  });
200
201
  };
201
202
 
@@ -80,7 +80,7 @@ async function process<Model extends ILlmSchema.Model>(
80
80
  {
81
81
  value: null,
82
82
  };
83
- const { tokenUsage } = await ctx.conversate({
83
+ const { metric, tokenUsage } = await ctx.conversate({
84
84
  source: "realizeAuthorizationWrite",
85
85
  histories: transformRealizeAuthorizationHistories(ctx, actor),
86
86
  controller: createController({
@@ -129,6 +129,7 @@ async function process<Model extends ILlmSchema.Model>(
129
129
  id: v7(),
130
130
  created_at: new Date().toISOString(),
131
131
  authorization: authorization,
132
+ metric,
132
133
  tokenUsage,
133
134
  completed: ++progress.completed,
134
135
  total: progress.total,
@@ -76,7 +76,7 @@ export async function orchestrateRealizeAuthorizationCorrect<
76
76
  {
77
77
  value: null,
78
78
  };
79
- const { tokenUsage } = await ctx.conversate({
79
+ const { metric, tokenUsage } = await ctx.conversate({
80
80
  source: "realizeAuthorizationCorrect",
81
81
  histories: transformRealizeAuthorizationCorrectHistories(
82
82
  ctx,
@@ -126,6 +126,7 @@ export async function orchestrateRealizeAuthorizationCorrect<
126
126
  created_at: new Date().toISOString(),
127
127
  authorization: result,
128
128
  result: compiled,
129
+ metric,
129
130
  tokenUsage,
130
131
  step: ctx.state().test?.step ?? 0,
131
132
  });