@autobe/agent 0.14.5 → 0.15.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 (178) hide show
  1. package/lib/AutoBeMockAgent.js +1 -1
  2. package/lib/AutoBeMockAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +11 -9
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/index.mjs +3557 -2635
  6. package/lib/index.mjs.map +1 -1
  7. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +4 -9
  8. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
  9. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -8
  10. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  11. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js +1 -1
  12. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js.map +1 -1
  13. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js +1 -1
  14. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js.map +1 -1
  15. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.d.ts +3 -0
  16. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +65 -0
  17. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -0
  18. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +4 -0
  19. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +62 -0
  20. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -0
  21. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +4 -0
  22. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +28 -0
  23. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -0
  24. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +3 -0
  25. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +28 -0
  26. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -0
  27. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +4 -0
  28. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +28 -0
  29. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -0
  30. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +3 -0
  31. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js +63 -0
  32. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +1 -0
  33. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +4 -0
  34. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +28 -0
  35. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -0
  36. package/lib/orchestrate/interface/orchestrateInterface.js +14 -9
  37. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  38. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  39. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +13 -40
  40. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  41. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +3 -2
  42. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +52 -32
  43. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  44. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -0
  45. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +350 -0
  46. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -0
  47. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +252 -226
  48. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  49. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +4 -0
  50. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +411 -0
  51. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -0
  52. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +55 -0
  53. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js +3 -0
  54. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js.map +1 -0
  55. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.d.ts +23 -0
  56. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js +3 -0
  57. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js.map +1 -0
  58. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +108 -0
  59. package/lib/orchestrate/{realize/structures/IAutoBeRealizeDecoratorApplication.js → interface/structures/IAutoBeInterfaceGroupApplication.js} +1 -1
  60. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js.map +1 -0
  61. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +122 -0
  62. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js +3 -0
  63. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js.map +1 -0
  64. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +75 -0
  65. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js +3 -0
  66. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js.map +1 -0
  67. package/lib/orchestrate/interface/{OpenApiEndpointComparator.d.ts → utils/OpenApiEndpointComparator.d.ts} +1 -0
  68. package/lib/orchestrate/interface/{OpenApiEndpointComparator.js → utils/OpenApiEndpointComparator.js} +6 -0
  69. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +1 -0
  70. package/lib/orchestrate/realize/orchestrateRealize.js +17 -3
  71. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  72. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +81 -88
  73. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  74. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.d.ts +4 -0
  75. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +513 -0
  76. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -0
  77. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +3 -2
  78. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
  79. package/lib/orchestrate/realize/structures/{IAutoBeRealizeDecoratorApplication.d.ts → IAutoBeRealizeAuthorizationApplication.d.ts} +9 -9
  80. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.js +3 -0
  81. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.js.map +1 -0
  82. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +33 -0
  83. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.js +3 -0
  84. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.js.map +1 -0
  85. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +34 -13
  86. package/lib/orchestrate/realize/transformRealizeAuthorization.d.ts +4 -0
  87. package/lib/orchestrate/realize/transformRealizeAuthorization.js +43 -0
  88. package/lib/orchestrate/realize/transformRealizeAuthorization.js.map +1 -0
  89. package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.d.ts +5 -0
  90. package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js +71 -0
  91. package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js.map +1 -0
  92. package/lib/orchestrate/realize/transformRealizeCoderHistories.js +5 -5
  93. package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
  94. package/lib/orchestrate/realize/utils/InternalFileSystem.d.ts +8 -0
  95. package/lib/orchestrate/realize/utils/InternalFileSystem.js +17 -0
  96. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -0
  97. package/lib/orchestrate/realize/utils/ProviderFileSystem.d.ts +3 -0
  98. package/lib/orchestrate/realize/utils/ProviderFileSystem.js +8 -0
  99. package/lib/orchestrate/realize/utils/ProviderFileSystem.js.map +1 -0
  100. package/lib/orchestrate/realize/utils/replaceImportStatements.js +2 -2
  101. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  102. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +36 -36
  103. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
  104. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +1 -0
  105. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  106. package/lib/orchestrate/test/orchestrateTestCorrect.js +2 -0
  107. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  108. package/lib/orchestrate/test/orchestrateTestScenario.js +29 -13
  109. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  110. package/lib/orchestrate/test/orchestrateTestWrite.js +2 -0
  111. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  112. package/lib/orchestrate/test/transformTestWriteHistories.js +3 -2
  113. package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
  114. package/lib/utils/arrayToRecord.d.ts +17 -0
  115. package/lib/utils/arrayToRecord.js +19 -0
  116. package/lib/utils/arrayToRecord.js.map +1 -0
  117. package/lib/utils/backoffRetry.js +0 -1
  118. package/lib/utils/backoffRetry.js.map +1 -1
  119. package/package.json +6 -5
  120. package/src/AutoBeMockAgent.ts +1 -1
  121. package/src/constants/AutoBeSystemPromptConstant.ts +11 -9
  122. package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +1 -3
  123. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +1 -3
  124. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +75 -0
  125. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +69 -0
  126. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +34 -0
  127. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +32 -0
  128. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +34 -0
  129. package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.ts +66 -0
  130. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +34 -0
  131. package/src/orchestrate/interface/orchestrateInterface.ts +17 -8
  132. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +22 -97
  133. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +48 -55
  134. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +109 -0
  135. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +83 -120
  136. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +197 -0
  137. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +58 -0
  138. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.ts +24 -0
  139. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +112 -0
  140. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +125 -0
  141. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +76 -0
  142. package/src/orchestrate/interface/{OpenApiEndpointComparator.ts → utils/OpenApiEndpointComparator.ts} +8 -0
  143. package/src/orchestrate/realize/orchestrateRealize.ts +25 -3
  144. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +45 -54
  145. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +179 -0
  146. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +3 -6
  147. package/src/orchestrate/realize/structures/{IAutoBeRealizeDecoratorApplication.ts → IAutoBeRealizeAuthorizationApplication.ts} +11 -9
  148. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +40 -0
  149. package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +42 -24
  150. package/src/orchestrate/realize/{transformRealizeDecorator.ts → transformRealizeAuthorization.ts} +13 -2
  151. package/src/orchestrate/realize/{transformRealizeDecoratorCorrectHistories.ts → transformRealizeAuthorizationCorrectHistories.ts} +15 -7
  152. package/src/orchestrate/realize/transformRealizeCoderHistories.ts +4 -4
  153. package/src/orchestrate/realize/utils/InternalFileSystem.ts +12 -0
  154. package/src/orchestrate/realize/utils/ProviderFileSystem.ts +4 -0
  155. package/src/orchestrate/realize/utils/replaceImportStatements.ts +2 -2
  156. package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +59 -53
  157. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +1 -0
  158. package/src/orchestrate/test/orchestrateTestCorrect.ts +3 -0
  159. package/src/orchestrate/test/orchestrateTestScenario.ts +4 -2
  160. package/src/orchestrate/test/orchestrateTestWrite.ts +8 -1
  161. package/src/utils/arrayToRecord.ts +49 -0
  162. package/src/utils/backoffRetry.ts +0 -1
  163. package/lib/orchestrate/interface/OpenApiEndpointComparator.js.map +0 -1
  164. package/lib/orchestrate/interface/orchestrateInterfaceComponents.d.ts +0 -4
  165. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +0 -473
  166. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +0 -1
  167. package/lib/orchestrate/interface/transformInterfaceHistories.d.ts +0 -3
  168. package/lib/orchestrate/interface/transformInterfaceHistories.js +0 -149
  169. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +0 -1
  170. package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.js.map +0 -1
  171. package/lib/orchestrate/realize/transformRealizeDecorator.d.ts +0 -4
  172. package/lib/orchestrate/realize/transformRealizeDecorator.js +0 -32
  173. package/lib/orchestrate/realize/transformRealizeDecorator.js.map +0 -1
  174. package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.d.ts +0 -5
  175. package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js +0 -62
  176. package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js.map +0 -1
  177. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +0 -292
  178. package/src/orchestrate/interface/transformInterfaceHistories.ts +0 -152
@@ -8,9 +8,8 @@ import { v4 } from "uuid";
8
8
 
9
9
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
10
10
  import { AutoBeContext } from "../../context/AutoBeContext";
11
- import { IAutoBeRealizeDecoratorApplication } from "./structures/IAutoBeRealizeDecoratorApplication";
12
11
 
13
- export const transformRealizeDecoratorCorrectHistories = (
12
+ export const transformRealizeAuthorizationCorrectHistories = (
14
13
  ctx: AutoBeContext<ILlmSchema.Model>,
15
14
  auth: AutoBeRealizeAuthorization,
16
15
  templateFiles: Record<string, string>,
@@ -23,7 +22,13 @@ export const transformRealizeDecoratorCorrectHistories = (
23
22
  id: v4(),
24
23
  created_at: new Date().toISOString(),
25
24
  type: "systemMessage",
26
- text: AutoBeSystemPromptConstant.REALIZE_DECORATOR_CORRECT,
25
+ text: AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION,
26
+ },
27
+ {
28
+ id: v4(),
29
+ created_at: new Date().toISOString(),
30
+ type: "systemMessage",
31
+ text: AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT,
27
32
  },
28
33
  {
29
34
  id: v4(),
@@ -36,18 +41,21 @@ export const transformRealizeDecoratorCorrectHistories = (
36
41
  `${JSON.stringify(
37
42
  {
38
43
  provider: {
44
+ location: auth.provider.location,
39
45
  name: auth.provider.name,
40
- code: auth.provider.content,
46
+ content: auth.provider.content,
41
47
  },
42
48
  decorator: {
49
+ location: auth.decorator.location,
43
50
  name: auth.decorator.name,
44
- code: auth.decorator.content,
51
+ content: auth.decorator.content,
45
52
  },
46
53
  payload: {
54
+ location: auth.payload.location,
47
55
  name: auth.payload.name,
48
- code: auth.payload.content,
56
+ content: auth.payload.content,
49
57
  },
50
- } satisfies IAutoBeRealizeDecoratorApplication.IProps,
58
+ } satisfies Omit<AutoBeRealizeAuthorization, "role">,
51
59
  null,
52
60
  2,
53
61
  )}`,
@@ -101,12 +101,12 @@ export const transformRealizeCoderHistories = (
101
101
  `- Decorator implementation: decorators/${props.decoratorEvent.decorator.name}.ts`,
102
102
  ` - NestJS parameter decorator`,
103
103
  ` - When importing from providers folder, use: '../decorators/${props.decoratorEvent.decorator.name}'`,
104
- `- Authentication provider: authentications/${props.decoratorEvent.provider.name}.ts`,
104
+ `- Authentication provider: decorators/${props.decoratorEvent.provider.name}.ts`,
105
105
  ` - Contains JWT validation, role checking, and authorization logic`,
106
- ` - When importing from providers folder, use: '../authentications/${props.decoratorEvent.provider.name}'`,
107
- `- Type definition: authentications/types/${props.decoratorEvent.payload.name}.ts`,
106
+ ` - When importing from providers folder, use: '../decorators/${props.decoratorEvent.provider.name}'`,
107
+ `- Type definition: decorators/payload/${props.decoratorEvent.payload.name}.ts`,
108
108
  ` - TypeScript interface for authenticated user payload`,
109
- ` - When importing from providers folder, use: '../authentications/types/${props.decoratorEvent.payload.name}'`,
109
+ ` - When importing from providers folder, use: '../decorators/payload/${props.decoratorEvent.payload.name}'`,
110
110
  ].join("\n")
111
111
  : "",
112
112
  },
@@ -0,0 +1,12 @@
1
+ export namespace InternalFileSystem {
2
+ /**
3
+ * Get template files for all of realize agents
4
+ *
5
+ * @returns Template file paths
6
+ */
7
+ export const DEFAULT = [
8
+ "src/providers/authorize/jwtAuthorize.ts",
9
+ "src/MyGlobal.ts",
10
+ "src/util/toISOStringSafe.ts",
11
+ ];
12
+ }
@@ -0,0 +1,4 @@
1
+ export namespace RealizeFileSystem {
2
+ export const providerPath = (filename: string): string =>
3
+ `src/providers/${filename}.ts`;
4
+ }
@@ -38,7 +38,7 @@ export function replaceImportStatements<Model extends ILlmSchema.Model>(
38
38
  // Remove any existing decoratorType imports if LLM mistakenly added them
39
39
  if (decoratorType) {
40
40
  const decoratorTypeRegex = new RegExp(
41
- `import\\s*{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/authentications\/types\/${decoratorType}["']\\s*;?\\s*`,
41
+ `import\\s*{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
42
42
  "gm",
43
43
  );
44
44
  code = code.replace(decoratorTypeRegex, "");
@@ -56,7 +56,7 @@ export function replaceImportStatements<Model extends ILlmSchema.Model>(
56
56
  // Only add decoratorType import if it exists
57
57
  if (decoratorType) {
58
58
  imports.push(
59
- `import { ${decoratorType} } from "../authentications/types/${decoratorType}"`,
59
+ `import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`,
60
60
  );
61
61
  }
62
62
 
@@ -5,15 +5,15 @@ import {
5
5
  IAutoBeTypeScriptCompileResult,
6
6
  } from "@autobe/interface";
7
7
  import { ILlmSchema } from "@samchon/openapi";
8
- import { readFile } from "fs/promises";
9
- import path from "path";
10
8
 
11
9
  import { AutoBeContext } from "../../context/AutoBeContext";
10
+ import { arrayToRecord } from "../../utils/arrayToRecord";
12
11
  import { pipe } from "./RealizePipe";
13
12
  import { orchestrateRealizeCoder } from "./orchestrateRealizeCoder";
14
13
  import { orchestrateRealizePlanner } from "./orchestrateRealizePlanner";
15
14
  import { IAutoBeRealizeCompile } from "./structures/IAutoBeRealizeCompile";
16
15
  import { FAILED } from "./structures/IAutoBeRealizeFailedSymbol";
16
+ import { RealizeFileSystem } from "./utils/ProviderFileSystem";
17
17
 
18
18
  export async function writeCodeUntilCompilePassed<
19
19
  Model extends ILlmSchema.Model,
@@ -23,26 +23,20 @@ export async function writeCodeUntilCompilePassed<
23
23
  authorizations: AutoBeRealizeAuthorization[],
24
24
  retry: number,
25
25
  ): Promise<AutoBeRealizeFunction[]> {
26
- const payloads = authorizations
27
- .map((el) => {
28
- return {
29
- [el.payload.location]: el.payload.content,
30
- };
31
- })
32
- .reduce<Record<string, string>>((acc, cur) => Object.assign(acc, cur), {});
33
-
34
- const files = Object.entries(await ctx.files({ dbms: "postgres" }))
35
- .filter(([key]) => {
36
- return key.startsWith("src");
37
- })
38
- .reduce(
39
- (acc, [filename, content]) => Object.assign(acc, { [filename]: content }),
40
- {},
41
- );
26
+ const payloads = arrayToRecord(
27
+ authorizations.map((el) => el.payload),
28
+ "location",
29
+ "content",
30
+ );
31
+
32
+ const files = arrayToRecord(
33
+ Object.entries(await ctx.files({ dbms: "postgres" })).filter(([key]) =>
34
+ key.startsWith("src"),
35
+ ),
36
+ );
42
37
 
43
- const templateFiles = ["src/MyGlobal.ts", "src/util/toISOStringSafe.ts"];
44
38
  const entireCodes: IAutoBeRealizeCompile.FileContentMap = {
45
- ...(await loadTemplateFiles(templateFiles)),
39
+ ...(await loadTemplateFiles(ctx)),
46
40
  };
47
41
 
48
42
  let diagnostics: IAutoBeRealizeCompile.CompileDiagnostics = {
@@ -91,16 +85,12 @@ export async function writeCodeUntilCompilePassed<
91
85
  ...payloads,
92
86
  ...files,
93
87
  ...nodeModules,
94
- ...Object.entries(entireCodes)
95
- .map(([filename, { content }]) => {
96
- return {
97
- [filename]: content,
98
- };
99
- })
100
- .reduce<Record<string, string>>(
101
- (acc, cur) => Object.assign(acc, cur),
102
- {},
103
- ),
88
+ ...arrayToRecord(
89
+ Object.entries(entireCodes).map(([filename, { content }]) => [
90
+ filename,
91
+ content,
92
+ ]),
93
+ ),
104
94
  },
105
95
  });
106
96
 
@@ -121,35 +111,33 @@ export async function writeCodeUntilCompilePassed<
121
111
  }
122
112
  }
123
113
 
124
- return Object.entries(entireCodes)
125
- .filter(([filename]) => filename.startsWith("src/providers")) // filter only provider files
126
- .map(([filename, value]) => {
127
- return {
128
- filename,
129
- content: value.content,
130
- endpoint: value.endpoint!,
131
- location: value.location!,
132
- name: value.name!,
133
- role: value.role!,
134
- };
135
- });
114
+ return (
115
+ Object.entries(entireCodes)
116
+ // .filter(([filename]) => filename.startsWith("src/providers")) // filter only provider files
117
+ .map(([filename, value]) => {
118
+ return {
119
+ filename,
120
+ content: value.content,
121
+ endpoint: value.endpoint!,
122
+ location: value.location!,
123
+ name: value.name!,
124
+ role: value.role!,
125
+ };
126
+ })
127
+ );
136
128
  }
137
129
 
138
- async function loadTemplateFiles(
139
- templateFiles: string[],
130
+ async function loadTemplateFiles<Model extends ILlmSchema.Model>(
131
+ ctx: AutoBeContext<Model>,
140
132
  ): Promise<IAutoBeRealizeCompile.FileContentMap> {
141
- const templateBasePath = path.join(
142
- __dirname,
143
- "../../../../../internals/template/realize",
144
- );
133
+ const templateFiles = await (await ctx.compiler()).realize.getTemplate();
134
+ const targets = ["src/MyGlobal.ts", "src/util/toISOStringSafe.ts"];
145
135
 
146
136
  const result: IAutoBeRealizeCompile.FileContentMap = {};
147
137
 
148
- for (const filePath of templateFiles) {
138
+ for (const filePath of targets) {
149
139
  result[filePath] = {
150
- content: await readFile(path.join(templateBasePath, filePath), {
151
- encoding: "utf-8",
152
- }),
140
+ content: templateFiles[filePath],
153
141
  result: "success",
154
142
  location: filePath,
155
143
  role: null,
@@ -171,7 +159,7 @@ async function process<Model extends ILlmSchema.Model>(
171
159
  op,
172
160
  (op) => orchestrateRealizePlanner(ctx, op, decorator),
173
161
  async (p) => {
174
- const filename = `src/providers/${p.functionName}.ts` as const;
162
+ const filename = RealizeFileSystem.providerPath(p.functionName);
175
163
  const t = diagnostics.total.filter((el) => el.file === filename);
176
164
 
177
165
  const d = diagnostics.current.filter((el) => el.file === filename);
@@ -204,6 +192,16 @@ async function process<Model extends ILlmSchema.Model>(
204
192
  return { type: "success", op: op, result } as const;
205
193
  }
206
194
 
195
+ /**
196
+ * Determines whether an operation should be processed in the current iteration.
197
+ * In the initial case (no errors), all operations are processed. When errors
198
+ * exist, only operations with compilation errors are targeted for reprocessing
199
+ * in the next iteration.
200
+ *
201
+ * @param op - The operation to check
202
+ * @param currentDiagnostics - Current compilation errors
203
+ * @returns True if the operation should be processed
204
+ */
207
205
  function shouldProcessOperation(
208
206
  op: AutoBeOpenApi.IOperation,
209
207
  currentDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[],
@@ -219,6 +217,14 @@ function shouldProcessOperation(
219
217
  );
220
218
  }
221
219
 
220
+ /**
221
+ * Generates a provider filename for an operation. Converts the operation's HTTP
222
+ * method and path into a valid TypeScript filename. The filename serves as both
223
+ * the function name and the file identifier.
224
+ *
225
+ * @param op - The operation to generate a filename for
226
+ * @returns The generated provider filename with path
227
+ */
222
228
  function generateProviderFilename(op: AutoBeOpenApi.IOperation): string {
223
229
  return `src/providers/${op.method}_${op.path
224
230
  .replaceAll("/", "_")
@@ -52,6 +52,7 @@ function filterDocument(
52
52
  ),
53
53
  );
54
54
  const components: AutoBeOpenApi.IComponents = {
55
+ authorization: document.components.authorization,
55
56
  schemas: {},
56
57
  };
57
58
  const visit = (typeName: string) => {
@@ -136,6 +136,9 @@ const correct = async <Model extends ILlmSchema.Model>(
136
136
  });
137
137
  if (pointer.value === null) throw new Error("Failed to modify test code.");
138
138
 
139
+ const compiler: IAutoBeCompiler = await ctx.compiler();
140
+ pointer.value.final = await compiler.typescript.beautify(pointer.value.final);
141
+
139
142
  ctx.dispatch({
140
143
  type: "testCorrect",
141
144
  created_at: new Date().toISOString(),
@@ -150,9 +150,11 @@ const execute = async <Model extends ILlmSchema.Model>(
150
150
  ctx.usage().record(tokenUsage, ["test"]);
151
151
  });
152
152
  if (pointer.value.length === 0) {
153
- throw new Error("Failed to create test plans.");
153
+ console.error("Failed to create test plans. No function called.");
154
+ return [];
155
+ // @todo
156
+ // throw new Error("Failed to create test plans.");
154
157
  }
155
-
156
158
  return pointer.value;
157
159
  };
158
160
 
@@ -1,5 +1,9 @@
1
1
  import { IAgenticaController, MicroAgentica } from "@agentica/core";
2
- import { AutoBeTestScenario, AutoBeTestWriteEvent } from "@autobe/interface";
2
+ import {
3
+ AutoBeTestScenario,
4
+ AutoBeTestWriteEvent,
5
+ IAutoBeCompiler,
6
+ } from "@autobe/interface";
3
7
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
4
8
  import { IPointer } from "tstl";
5
9
  import typia from "typia";
@@ -106,6 +110,9 @@ async function process<Model extends ILlmSchema.Model>(
106
110
  ctx.usage().record(tokenUsage, ["test"]);
107
111
  });
108
112
  if (pointer.value === null) throw new Error("Failed to create test code.");
113
+
114
+ const compiler: IAutoBeCompiler = await ctx.compiler();
115
+ pointer.value.final = await compiler.typescript.beautify(pointer.value.final);
109
116
  return pointer.value;
110
117
  }
111
118
 
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Converts an array of key-value pairs (entries) into a Record.
3
+ *
4
+ * @param entries - Array of [key, value] tuples
5
+ * @returns Record object from the entries
6
+ */
7
+ export function arrayToRecord<V>(
8
+ entries: Array<[string, V]>,
9
+ ): Record<string, V>;
10
+
11
+ /**
12
+ * Converts an array of objects into a Record using specified key and value
13
+ * properties.
14
+ *
15
+ * @param items - Array of items to convert
16
+ * @param keyProp - Property name to use as the key
17
+ * @param valueProp - Property name to use as the value
18
+ * @returns Record object with the extracted key-value pairs
19
+ */
20
+ export function arrayToRecord<T, K extends keyof T, V extends keyof T>(
21
+ items: T[],
22
+ keyProp: K,
23
+ valueProp: V,
24
+ ): Record<string, T[V]>;
25
+
26
+ export function arrayToRecord<T, K extends keyof T, V extends keyof T>(
27
+ items: T[] | Array<[string, any]>,
28
+ keyProp?: K,
29
+ valueProp?: V,
30
+ ): Record<string, any> {
31
+ // Handle entries format [string, value][]
32
+ if (items.length > 0 && Array.isArray(items[0]) && items[0].length === 2) {
33
+ return (items as Array<[string, any]>).reduce(
34
+ (acc, [key, value]) => Object.assign(acc, { [key]: value }),
35
+ {},
36
+ );
37
+ }
38
+
39
+ // Handle object array format with key and value properties
40
+ if (keyProp !== undefined && valueProp !== undefined) {
41
+ return (items as T[])
42
+ .map((item) => ({
43
+ [String(item[keyProp])]: item[valueProp],
44
+ }))
45
+ .reduce((acc, cur) => Object.assign(acc, cur), {});
46
+ }
47
+
48
+ throw new Error("Invalid arguments for arrayToRecord");
49
+ }
@@ -57,7 +57,6 @@ export function randomBackoffStrategy(props: {
57
57
  count: number;
58
58
  error: unknown;
59
59
  }): number {
60
- console.log("randomBackoffStrategy");
61
60
  const { count, error } = props;
62
61
  if (count > 5) {
63
62
  throw error;
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpenApiEndpointComparator.js","sourceRoot":"","sources":["../../../src/orchestrate/interface/OpenApiEndpointComparator.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAE5B,IAAiB,yBAAyB,CAWzC;AAXD,WAAiB,yBAAyB;IACxC,SAAgB,QAAQ,CAAC,CAA0B;QACjD,OAAO,IAAA,WAAI,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAFe,kCAAQ,WAEvB,CAAA;IAED,SAAgB,MAAM,CACpB,CAA0B,EAC1B,CAA0B;QAE1B,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;IALe,gCAAM,SAKrB,CAAA;AACH,CAAC,EAXgB,yBAAyB,yCAAzB,yBAAyB,QAWzC"}
@@ -1,4 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { ILlmSchema } from "@samchon/openapi";
3
- import { AutoBeContext } from "../../context/AutoBeContext";
4
- export declare function orchestrateInterfaceComponents<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, operations: AutoBeOpenApi.IOperation[], capacity?: number): Promise<AutoBeOpenApi.IComponents>;