@autobe/agent 0.25.0 → 0.25.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 (184) hide show
  1. package/lib/AutoBeAgent.js +11 -1
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/AutoBeMockAgent.js +1 -0
  4. package/lib/AutoBeMockAgent.js.map +1 -1
  5. package/lib/constants/AutoBeSystemPromptConstant.d.ts +13 -13
  6. package/lib/factory/createAutoBeContext.js +1 -0
  7. package/lib/factory/createAutoBeContext.js.map +1 -1
  8. package/lib/index.mjs +2250 -806
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  11. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  12. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
  13. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  14. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
  15. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
  16. package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
  17. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
  18. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +2 -2
  19. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  20. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +3 -3
  21. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  22. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
  23. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
  24. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
  25. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  26. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  27. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  28. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  29. package/lib/orchestrate/interface/orchestrateInterface.js +25 -9
  30. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  31. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +260 -29
  32. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  33. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +56 -64
  34. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  35. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -3
  36. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  37. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +2 -2
  38. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +4 -5
  39. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  40. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +260 -29
  41. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  42. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
  43. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
  44. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
  45. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +47 -35
  46. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  47. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +41 -7
  48. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  49. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
  50. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
  51. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
  52. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js +3 -0
  53. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
  54. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
  55. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
  56. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +105 -5
  57. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  58. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +20 -1
  59. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  60. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
  61. package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
  62. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  63. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +9 -10
  64. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -1
  65. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
  66. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  67. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
  68. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
  69. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  70. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
  71. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  72. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
  73. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +103 -40
  74. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  75. package/lib/orchestrate/realize/orchestrateRealize.js +81 -45
  76. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  77. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +117 -87
  78. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  79. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
  80. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
  81. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  82. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
  83. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
  84. package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
  85. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
  86. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
  87. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
  88. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  89. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
  90. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
  91. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  92. package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
  93. package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
  94. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
  95. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
  96. package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -55
  97. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  98. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  99. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  100. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  101. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  102. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +10 -79
  103. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  104. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +15 -65
  105. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  106. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  107. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  108. package/lib/orchestrate/test/orchestrateTestCorrect.js +32 -17
  109. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  110. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
  111. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  112. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  113. package/lib/orchestrate/test/orchestrateTestScenario.js +5 -5
  114. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  115. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +1 -1
  116. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  117. package/lib/orchestrate/test/orchestrateTestWrite.js +37 -21
  118. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  119. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
  120. package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
  121. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
  122. package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
  123. package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
  124. package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
  125. package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
  126. package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
  127. package/package.json +5 -5
  128. package/src/AutoBeAgent.ts +17 -1
  129. package/src/AutoBeMockAgent.ts +1 -0
  130. package/src/constants/AutoBeSystemPromptConstant.ts +13 -13
  131. package/src/factory/createAutoBeContext.ts +1 -0
  132. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
  133. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
  134. package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
  135. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +4 -2
  136. package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
  137. package/src/orchestrate/interface/orchestrateInterface.ts +43 -17
  138. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +12 -33
  139. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +5 -5
  140. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +7 -6
  141. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
  142. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +1 -1
  143. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
  144. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
  145. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
  146. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
  147. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
  148. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
  149. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +19 -1
  150. package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
  151. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +9 -10
  152. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
  153. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
  154. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
  155. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
  156. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +84 -17
  157. package/src/orchestrate/realize/orchestrateRealize.ts +125 -74
  158. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +33 -6
  159. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
  160. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
  161. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
  162. package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
  163. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
  164. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
  165. package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
  166. package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -102
  167. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +18 -91
  168. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +17 -90
  169. package/src/orchestrate/test/orchestrateTestCorrect.ts +7 -6
  170. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
  171. package/src/orchestrate/test/orchestrateTestScenario.ts +12 -6
  172. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +3 -3
  173. package/src/orchestrate/test/orchestrateTestWrite.ts +7 -6
  174. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
  175. package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
  176. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
  177. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
  178. package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
  179. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
  180. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
  181. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
  182. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
  183. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
  184. package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
@@ -318,6 +318,7 @@ const createDispatch = (props: {
318
318
  instruction: interfaceStart?.reason ?? "",
319
319
  authorizations: event.authorizations,
320
320
  document: event.document,
321
+ missed: event.missed,
321
322
  created_at: interfaceStart?.created_at ?? new Date().toISOString(),
322
323
  completed_at: new Date().toISOString(),
323
324
  step: event.step,
@@ -120,7 +120,7 @@ const correct = async <
120
120
  think: pointer.value.think,
121
121
  draft: pointer.value.draft,
122
122
  review: pointer.value.revise.review,
123
- final: pointer.value.revise.final,
123
+ final: pointer.value.revise.final ?? undefined,
124
124
  tokenUsage,
125
125
  }),
126
126
  );
@@ -129,7 +129,7 @@ const correct = async <
129
129
  factory,
130
130
  [...failures, event],
131
131
  script,
132
- await factory.validate(pointer.value.revise.final),
132
+ await factory.validate(pointer.value.revise.final ?? pointer.value.draft),
133
133
  life - 1,
134
134
  );
135
135
  };
@@ -1,44 +1,22 @@
1
- /**
2
- * Function calling interface for fixing TypeScript type casting and assignment errors.
3
- *
4
- * This interface is used by the CommonCorrectCasting agent to fix TypeScript
5
- * compilation errors related to type casting and type assignment incompatibilities
6
- * in any TypeScript code, not limited to e2e tests.
7
- *
8
- * The agent handles various type casting issues including:
9
- *
10
- * - **Typia tag type incompatibilities**: Format tag mismatches (e.g., Format<"uuid">
11
- * vs Pattern<...>), type constraint incompatibilities (e.g., Type<"int32"> vs
12
- * Type<"int32"> & Minimum<0>), nullable type conversions with tags
13
- * - **Date to string conversions**: Date to string, Date to string & Format<"date-time">,
14
- * nullable Date handling
15
- * - **Nullable and undefined type assignments**: Exhaustive type narrowing for
16
- * T | null | undefined patterns
17
- * - **String to literal type assignments**: Converting general string to literal
18
- * union types (e.g., "pending" | "approved" | "rejected")
19
- * - **Optional chaining with union types**: Handling boolean | undefined results
20
- * from array methods like includes()
21
- * - **Type narrowing "no overlap" errors**: Removing redundant comparisons after
22
- * TypeScript's control flow analysis
23
- *
24
- * @author Samchon
25
- */
26
1
  export interface IAutoBeCommonCorrectCastingApplication {
27
2
  /**
28
3
  * Rewrite function to fix type casting and assignment errors.
29
4
  *
30
- * This function is called when the agent detects any type casting or assignment
31
- * related compilation error patterns.
5
+ * This function is called when the agent detects any type casting or
6
+ * assignment related compilation error patterns.
32
7
  *
33
8
  * The agent applies various fix strategies based on the error type:
34
9
  *
35
- * - **Typia tag incompatibilities**: Uses `satisfies ... as ...` pattern to strip
36
- * incompatible tags, or `typia.assert<T>()` as a last resort
37
- * - **Date conversions**: Uses `.toISOString()` method for Date to string conversions
38
- * - **Nullable type narrowing**: Applies exhaustive checks (e.g., !== null && !== undefined)
39
- * - **typia.assert vs assertGuard**: Uses assert for value assignment, assertGuard
40
- * for type narrowing
41
- * - **Literal type conversions**: Uses `typia.assert<T>()` for runtime validation
10
+ * - **Typia tag incompatibilities**: Uses `satisfies ... as ...` pattern to
11
+ * strip incompatible tags, or `typia.assert<T>()` as a last resort
12
+ * - **Date conversions**: Uses `.toISOString()` method for Date to string
13
+ * conversions
14
+ * - **Nullable type narrowing**: Applies exhaustive checks (e.g., !== null &&
15
+ * !== undefined)
16
+ * - **typia.assert vs assertGuard**: Uses assert for value assignment,
17
+ * assertGuard for type narrowing
18
+ * - **Literal type conversions**: Uses `typia.assert<T>()` for runtime
19
+ * validation
42
20
  * - **Optional chaining results**: Uses `=== true` or `??` operators
43
21
  * - **"No overlap" errors**: Removes redundant comparisons
44
22
  *
@@ -52,24 +30,20 @@ export interface IAutoBeCommonCorrectCastingApplication {
52
30
  /**
53
31
  * Reject function when error is not related to type casting or assignment.
54
32
  *
55
- * This function is called when the compilation error is unrelated to type
56
- * casting issues (e.g., missing imports, syntax errors, undefined variables),
33
+ * This function is called when the compilation error is unrelated to type
34
+ * casting issues (e.g., missing imports, syntax errors, undefined variables),
57
35
  * indicating the error should be handled by a different agent.
58
36
  */
59
37
  reject(): void;
60
38
  }
61
39
  export namespace IAutoBeCommonCorrectCastingApplication {
62
- /**
63
- * Properties for the rewrite function containing the type casting error
64
- * analysis and correction workflow.
65
- */
66
40
  export interface IProps {
67
41
  /**
68
42
  * Initial analysis of the type casting or assignment error.
69
43
  *
70
44
  * Contains the agent's analysis of the specific type mismatch pattern:
71
45
  *
72
- * - Type of casting error (tag incompatibility, nullable assignment, literal
46
+ * - Type of casting error (tag incompatibility, nullable assignment, literal
73
47
  * type conversion, etc.)
74
48
  * - Whether nullable or undefined types are involved
75
49
  * - If Date to string conversions are needed
@@ -94,12 +68,12 @@ export namespace IAutoBeCommonCorrectCastingApplication {
94
68
  * Review and finalization of type casting corrections.
95
69
  *
96
70
  * Contains the review of applied corrections and the final code with all
97
- * type casting issues resolved while preserving type safety and validation intent.
71
+ * type casting issues resolved while preserving type safety and validation
72
+ * intent.
98
73
  */
99
74
  revise: IReviseProps;
100
75
  }
101
76
 
102
- /** Properties for the revision phase of type casting corrections. */
103
77
  export interface IReviseProps {
104
78
  /**
105
79
  * Review of the type casting correction patterns applied.
@@ -120,8 +94,14 @@ export namespace IAutoBeCommonCorrectCastingApplication {
120
94
  *
121
95
  * The complete code ready for TypeScript compilation, with all type casting
122
96
  * and assignment errors properly fixed using appropriate patterns while
123
- * maintaining type safety and the original validation logic.
97
+ * maintaining type safety and the original validation logic. When the draft
98
+ * already successfully resolves all type casting issues with no problems
99
+ * found during review, this value can be null, indicating no further
100
+ * refinements are necessary.
101
+ *
102
+ * A `null` value signifies the draft corrections were already optimal and
103
+ * require no additional modifications.
124
104
  */
125
- final: string;
105
+ final: string | null;
126
106
  }
127
107
  }
@@ -3,7 +3,7 @@ import { v7 } from "uuid";
3
3
 
4
4
  import { AutoBeState } from "../../../context/AutoBeState";
5
5
 
6
- export const transformInterfacePrerequisiteHistories = (
6
+ export const transformInterfaceCommonPrerequisiteHistories = (
7
7
  state: AutoBeState,
8
8
  ): Array<
9
9
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
@@ -5,7 +5,7 @@ import { v7 } from "uuid";
5
5
  import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
6
6
  import { AutoBeState } from "../../../context/AutoBeState";
7
7
  import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
8
- import { transformInterfacePrerequisiteHistories } from "./transformInterfacePrerequisiteHistories";
8
+ import { transformInterfaceCommonPrerequisiteHistories } from "./transformInterfaceCommonPrerequisiteHistories";
9
9
 
10
10
  export const transformInterfaceGroupHistories = (props: {
11
11
  state: AutoBeState;
@@ -13,7 +13,9 @@ export const transformInterfaceGroupHistories = (props: {
13
13
  }): Array<
14
14
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
15
  > => {
16
- const prerequisite = transformInterfacePrerequisiteHistories(props.state);
16
+ const prerequisite = transformInterfaceCommonPrerequisiteHistories(
17
+ props.state,
18
+ );
17
19
  if (prerequisite !== null) return prerequisite;
18
20
 
19
21
  return [
@@ -0,0 +1,118 @@
1
+ import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { AutoBeOpenApi } from "@autobe/interface";
3
+ import { StringUtil } from "@autobe/utils";
4
+ import { OpenApiTypeChecker } from "@samchon/openapi";
5
+ import { v7 } from "uuid";
6
+
7
+ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
8
+ import { getReferenceIds } from "../../test/utils/getReferenceIds";
9
+
10
+ export const transformInterfacePrerequisitesHistories = (
11
+ document: AutoBeOpenApi.IDocument,
12
+ include: AutoBeOpenApi.IOperation[],
13
+ ): Array<
14
+ IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
15
+ > => {
16
+ const domainSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
17
+ {};
18
+ const visit = (key: string) =>
19
+ OpenApiTypeChecker.visit({
20
+ schema: {
21
+ $ref: `#/components/schemas/${key}`,
22
+ },
23
+ components: document.components,
24
+ closure: (next) => {
25
+ if (OpenApiTypeChecker.isReference(next))
26
+ domainSchemas[next.$ref.split("/").pop()!] =
27
+ document.components.schemas[next.$ref.split("/").pop()!];
28
+ },
29
+ });
30
+ for (const op of include) {
31
+ if (op.requestBody) visit(op.requestBody.typeName);
32
+ if (op.responseBody) visit(op.responseBody.typeName);
33
+ }
34
+
35
+ return [
36
+ {
37
+ type: "systemMessage",
38
+ id: v7(),
39
+ created_at: new Date().toISOString(),
40
+ text: AutoBeSystemPromptConstant.INTERFACE_PREREQUISITE,
41
+ },
42
+ {
43
+ type: "assistantMessage",
44
+ id: v7(),
45
+ created_at: new Date().toISOString(),
46
+ text: StringUtil.trim`
47
+ ## Document Overview
48
+
49
+ ### Entire API Operations
50
+
51
+ All operations in this project for prerequisite references.
52
+
53
+ These are the complete list of API endpoints that can be used
54
+ as prerequisites. You should select appropriate operations from
55
+ this list when establishing dependency chains.
56
+
57
+ \`\`\`json
58
+ ${JSON.stringify({
59
+ operations: document.operations
60
+ .filter(
61
+ (op) => op.authorizationType === null && op.method === "post",
62
+ )
63
+ .map((op) => {
64
+ return {
65
+ ...op,
66
+ prerequisites: undefined,
67
+ };
68
+ }),
69
+ })}
70
+ \`\`\`
71
+
72
+ ### Entire Schema Definitions
73
+
74
+ Data structure definitions to understand entity relationships.
75
+
76
+ Use these schemas to identify parent-child relationships and
77
+ data dependencies between operations.
78
+
79
+ \`\`\`json
80
+ ${JSON.stringify({
81
+ components: {
82
+ schemas: document.components.schemas,
83
+ },
84
+ })}
85
+ \`\`\`
86
+
87
+ ## Target Operations and Schemas
88
+
89
+ ### Target Operations
90
+
91
+ Operations requiring prerequisite analysis.
92
+
93
+ For each of these operations, analyze if they need any prerequisites
94
+ from the available operations above. Add prerequisites only when there
95
+ are genuine dependencies like resource existence checks or state validations.
96
+
97
+ \`\`\`json
98
+ ${JSON.stringify(
99
+ include.map((op) => {
100
+ return {
101
+ ...op,
102
+ requiredIds: getReferenceIds({ document, operation: op }),
103
+ };
104
+ }),
105
+ )}
106
+ \`\`\`
107
+
108
+ ### Domain Schemas
109
+
110
+ Schema definitions for the target operations.
111
+
112
+ \`\`\`json
113
+ ${JSON.stringify(domainSchemas)}
114
+ \`\`\`
115
+ `,
116
+ },
117
+ ];
118
+ };
@@ -6,7 +6,12 @@ import {
6
6
  AutoBeInterfaceHistory,
7
7
  AutoBeOpenApi,
8
8
  } from "@autobe/interface";
9
- import { AutoBeEndpointComparator } from "@autobe/utils";
9
+ import { AutoBeInterfacePrerequisite } from "@autobe/interface/src/histories/contents/AutoBeInterfacePrerequisite";
10
+ import {
11
+ AutoBeOpenApiEndpointComparator,
12
+ missedOpenApiSchemas,
13
+ revertOpenApiAccessor,
14
+ } from "@autobe/utils";
10
15
  import { ILlmSchema } from "@samchon/openapi";
11
16
  import { HashMap, Pair } from "tstl";
12
17
  import { v7 } from "uuid";
@@ -19,8 +24,10 @@ import { orchestrateInterfaceComplement } from "./orchestrateInterfaceComplement
19
24
  import { orchestrateInterfaceEndpoints } from "./orchestrateInterfaceEndpoints";
20
25
  import { orchestrateInterfaceGroups } from "./orchestrateInterfaceGroups";
21
26
  import { orchestrateInterfaceOperations } from "./orchestrateInterfaceOperations";
27
+ import { orchestrateInterfacePrerequisites } from "./orchestrateInterfacePrerequisites";
22
28
  import { orchestrateInterfaceSchemas } from "./orchestrateInterfaceSchemas";
23
29
  import { orchestrateInterfaceSchemasReview } from "./orchestrateInterfaceSchemasReview";
30
+ import { JsonSchemaFactory } from "./utils/JsonSchemaFactory";
24
31
 
25
32
  export const orchestrateInterface =
26
33
  <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
@@ -91,8 +98,8 @@ export const orchestrateInterface =
91
98
  o, // early inserted be kept
92
99
  ),
93
100
  ),
94
- AutoBeEndpointComparator.hashCode,
95
- AutoBeEndpointComparator.equals,
101
+ AutoBeOpenApiEndpointComparator.hashCode,
102
+ AutoBeOpenApiEndpointComparator.equals,
96
103
  )
97
104
  .toJSON()
98
105
  .map((it) => it.second);
@@ -109,31 +116,50 @@ export const orchestrateInterface =
109
116
  },
110
117
  };
111
118
 
112
- const complementedSchemas: Record<
113
- string,
114
- AutoBeOpenApi.IJsonSchemaDescriptive
115
- > = await orchestrateInterfaceComplement(ctx, {
116
- instruction: props.instruction,
117
- document,
118
- });
119
- Object.assign(document.components.schemas, complementedSchemas);
119
+ const complement = async () =>
120
+ Object.assign(
121
+ document.components.schemas,
122
+ await orchestrateInterfaceComplement(ctx, {
123
+ instruction: props.instruction,
124
+ document,
125
+ }),
126
+ );
127
+ await complement();
120
128
 
121
- const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
129
+ Object.assign(
130
+ document.components.schemas,
122
131
  await orchestrateInterfaceSchemasReview(
123
132
  ctx,
124
133
  operations,
125
134
  document.components.schemas,
126
- );
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];
135
+ ),
136
+ );
137
+ if (missedOpenApiSchemas(document).length !== 0) await complement();
138
+
139
+ JsonSchemaFactory.finalize({
140
+ document,
141
+ application: ctx.state().prisma!.result.data,
142
+ });
143
+
144
+ // CONNECT PRE-REQUISITES
145
+ const prerequisites: AutoBeInterfacePrerequisite[] =
146
+ await orchestrateInterfacePrerequisites(ctx, document);
147
+ document.operations.forEach((op) => {
148
+ op.prerequisites =
149
+ prerequisites.find(
150
+ (p) => p.endpoint.method === op.method && p.endpoint.path === op.path,
151
+ )?.prerequisites ?? [];
152
+ });
153
+
154
+ // NORMALIZE ACCESSORS
155
+ revertOpenApiAccessor(document);
131
156
 
132
157
  // DO COMPILE
133
158
  return ctx.dispatch({
134
159
  type: "interfaceComplete",
135
160
  id: v7(),
136
161
  document,
162
+ missed: missedOpenApiSchemas(document),
137
163
  authorizations,
138
164
  created_at: new Date().toISOString(),
139
165
  elapsed: new Date().getTime() - start.getTime(),
@@ -1,11 +1,7 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
2
  import { AutoBeOpenApi } from "@autobe/interface";
3
- import {
4
- ILlmApplication,
5
- ILlmSchema,
6
- IValidation,
7
- OpenApiTypeChecker,
8
- } from "@samchon/openapi";
3
+ import { missedOpenApiSchemas } from "@autobe/utils";
4
+ import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
9
5
  import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
10
6
  import { IPointer } from "tstl";
11
7
  import typia from "typia";
@@ -27,7 +23,7 @@ export function orchestrateInterfaceComplement<Model extends ILlmSchema.Model>(
27
23
  document: AutoBeOpenApi.IDocument;
28
24
  },
29
25
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
30
- return step(ctx, props, 8);
26
+ return step(ctx, props, false);
31
27
  }
32
28
 
33
29
  async function step<Model extends ILlmSchema.Model>(
@@ -36,10 +32,10 @@ async function step<Model extends ILlmSchema.Model>(
36
32
  instruction: string;
37
33
  document: AutoBeOpenApi.IDocument;
38
34
  },
39
- life: number,
35
+ wasEmpty: boolean,
40
36
  ): Promise<Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>> {
41
- const missed: string[] = getMissed(props.document);
42
- if (missed.length === 0 || life < 0) return props.document.components.schemas;
37
+ const missed: string[] = missedOpenApiSchemas(props.document);
38
+ if (missed.length === 0) return props.document.components.schemas;
43
39
 
44
40
  const pointer: IPointer<Record<
45
41
  string,
@@ -88,6 +84,10 @@ async function step<Model extends ILlmSchema.Model>(
88
84
  created_at: new Date().toISOString(),
89
85
  });
90
86
 
87
+ const empty: boolean = Object.keys(pointer.value).length === 0;
88
+ if (empty === true && wasEmpty === true)
89
+ return props.document.components.schemas;
90
+
91
91
  const newSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {
92
92
  ...pointer.value,
93
93
  ...props.document.components.schemas,
@@ -105,31 +105,10 @@ async function step<Model extends ILlmSchema.Model>(
105
105
  },
106
106
  },
107
107
  },
108
- life - 1,
108
+ empty,
109
109
  );
110
110
  }
111
111
 
112
- const getMissed = (document: AutoBeOpenApi.IDocument): string[] => {
113
- const missed: Set<string> = new Set();
114
- const check = (name: string) => {
115
- if (document.components.schemas[name] === undefined) missed.add(name);
116
- };
117
- for (const op of document.operations) {
118
- if (op.requestBody !== null) check(op.requestBody.typeName);
119
- if (op.responseBody !== null) check(op.responseBody.typeName);
120
- }
121
- for (const value of Object.values(document.components.schemas))
122
- OpenApiTypeChecker.visit({
123
- components: document.components,
124
- schema: value,
125
- closure: (next) => {
126
- if (OpenApiTypeChecker.isReference(next))
127
- check(next.$ref.split("/").pop()!);
128
- },
129
- });
130
- return Array.from(missed);
131
- };
132
-
133
112
  function createController<Model extends ILlmSchema.Model>(props: {
134
113
  model: Model;
135
114
  build: (
@@ -141,7 +120,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
141
120
  const validate = (
142
121
  next: unknown,
143
122
  ): IValidation<IAutoBeInterfaceComplementApplication.IProps> => {
144
- JsonSchemaFactory.fix("schemas", next);
123
+ JsonSchemaFactory.fixPage("schemas", next);
145
124
 
146
125
  const result: IValidation<IAutoBeInterfaceComplementApplication.IProps> =
147
126
  typia.validate<IAutoBeInterfaceComplementApplication.IProps>(next);
@@ -5,6 +5,7 @@ import {
5
5
  AutoBeProgressEventBase,
6
6
  } from "@autobe/interface";
7
7
  import { AutoBeInterfaceGroup } from "@autobe/interface/src/histories/contents/AutoBeInterfaceGroup";
8
+ import { AutoBeOpenApiEndpointComparator } from "@autobe/utils";
8
9
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
9
10
  import { HashSet, IPointer } from "tstl";
10
11
  import typia from "typia";
@@ -16,7 +17,6 @@ import { executeCachedBatch } from "../../utils/executeCachedBatch";
16
17
  import { transformInterfaceEndpointHistories } from "./histories/transformInterfaceEndpointHistories";
17
18
  import { orchestrateInterfaceEndpointsReview } from "./orchestrateInterfaceEndpointsReview";
18
19
  import { IAutoBeInterfaceEndpointApplication } from "./structures/IAutoBeInterfaceEndpointApplication";
19
- import { OpenApiEndpointComparator } from "./utils/OpenApiEndpointComparator";
20
20
 
21
21
  export async function orchestrateInterfaceEndpoints<
22
22
  Model extends ILlmSchema.Model,
@@ -50,8 +50,8 @@ export async function orchestrateInterfaceEndpoints<
50
50
  ).flat();
51
51
  const deduplicated: AutoBeOpenApi.IEndpoint[] = new HashSet(
52
52
  endpoints,
53
- OpenApiEndpointComparator.hashCode,
54
- OpenApiEndpointComparator.equals,
53
+ AutoBeOpenApiEndpointComparator.hashCode,
54
+ AutoBeOpenApiEndpointComparator.equals,
55
55
  ).toJSON();
56
56
  return orchestrateInterfaceEndpointsReview(ctx, deduplicated);
57
57
  }
@@ -97,8 +97,8 @@ async function process<Model extends ILlmSchema.Model>(
97
97
  id: v7(),
98
98
  endpoints: new HashSet(
99
99
  pointer.value,
100
- OpenApiEndpointComparator.hashCode,
101
- OpenApiEndpointComparator.equals,
100
+ AutoBeOpenApiEndpointComparator.hashCode,
101
+ AutoBeOpenApiEndpointComparator.equals,
102
102
  ).toJSON(),
103
103
  tokenUsage,
104
104
  created_at: start.toISOString(),
@@ -4,7 +4,7 @@ import {
4
4
  AutoBeOpenApi,
5
5
  AutoBeProgressEventBase,
6
6
  } from "@autobe/interface";
7
- import { StringUtil } from "@autobe/utils";
7
+ import { AutoBeOpenApiEndpointComparator, StringUtil } from "@autobe/utils";
8
8
  import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
9
9
  import { HashMap, HashSet, IPointer } from "tstl";
10
10
  import typia from "typia";
@@ -19,7 +19,6 @@ import { executeCachedBatch } from "../../utils/executeCachedBatch";
19
19
  import { transformInterfaceOperationHistories } from "./histories/transformInterfaceOperationHistories";
20
20
  import { orchestrateInterfaceOperationsReview } from "./orchestrateInterfaceOperationsReview";
21
21
  import { IAutoBeInterfaceOperationApplication } from "./structures/IAutoBeInterfaceOperationApplication";
22
- import { OpenApiEndpointComparator } from "./utils/OpenApiEndpointComparator";
23
22
  import { OperationValidator } from "./utils/OperationValidator";
24
23
 
25
24
  export async function orchestrateInterfaceOperations<
@@ -72,13 +71,13 @@ async function divideAndConquer<Model extends ILlmSchema.Model>(
72
71
  ): Promise<AutoBeOpenApi.IOperation[]> {
73
72
  const remained: HashSet<AutoBeOpenApi.IEndpoint> = new HashSet(
74
73
  props.endpoints,
75
- OpenApiEndpointComparator.hashCode,
76
- OpenApiEndpointComparator.equals,
74
+ AutoBeOpenApiEndpointComparator.hashCode,
75
+ AutoBeOpenApiEndpointComparator.equals,
77
76
  );
78
77
  const unique: HashMap<AutoBeOpenApi.IEndpoint, AutoBeOpenApi.IOperation> =
79
78
  new HashMap(
80
- OpenApiEndpointComparator.hashCode,
81
- OpenApiEndpointComparator.equals,
79
+ AutoBeOpenApiEndpointComparator.hashCode,
80
+ AutoBeOpenApiEndpointComparator.equals,
82
81
  );
83
82
  for (let i: number = 0; i < ctx.retry; ++i) {
84
83
  if (remained.empty() === true || unique.size() >= props.endpoints.length)
@@ -144,6 +143,7 @@ async function process<Model extends ILlmSchema.Model>(
144
143
  .join("/"),
145
144
  authorizationRole: null,
146
145
  authorizationType: null,
146
+ prerequisites: [],
147
147
  },
148
148
  ];
149
149
  return op.authorizationRoles.map((role) => ({
@@ -155,6 +155,7 @@ async function process<Model extends ILlmSchema.Model>(
155
155
  .join("/"),
156
156
  authorizationRole: role,
157
157
  authorizationType: null,
158
+ prerequisites: [],
158
159
  }));
159
160
  });
160
161
  pointer.value.push(...matrix.flat());