@autobe/agent 0.25.4 → 0.25.6

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 (148) hide show
  1. package/lib/AutoBeMockAgent.js +1 -1
  2. package/lib/AutoBeMockAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +12 -13
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/context/AutoBeTokenUsage.d.ts +2 -2
  6. package/lib/context/AutoBeTokenUsage.js.map +1 -1
  7. package/lib/context/{IAutoBeApplication.d.ts → IAutoBeFacadeApplication.d.ts} +15 -83
  8. package/lib/context/{IAutoBeApplicationProps.js → IAutoBeFacadeApplication.js} +1 -1
  9. package/lib/context/IAutoBeFacadeApplication.js.map +1 -0
  10. package/lib/context/{IAutoBeApplicationProps.d.ts → IAutoBeFacadeApplicationProps.d.ts} +1 -1
  11. package/lib/context/{IAutoBeApplication.js → IAutoBeFacadeApplicationProps.js} +1 -1
  12. package/lib/context/IAutoBeFacadeApplicationProps.js.map +1 -0
  13. package/lib/context/{IAutoBeApplicationResult.d.ts → IAutoBeFacadeApplicationResult.d.ts} +1 -1
  14. package/lib/context/{IAutoBeApplicationResult.js → IAutoBeFacadeApplicationResult.js} +1 -1
  15. package/lib/context/IAutoBeFacadeApplicationResult.js.map +1 -0
  16. package/lib/factory/createAgenticaHistory.js +3 -1
  17. package/lib/factory/createAgenticaHistory.js.map +1 -1
  18. package/lib/factory/createAutoBeApplication.js +38 -76
  19. package/lib/factory/createAutoBeApplication.js.map +1 -1
  20. package/lib/factory/createAutoBeContext.js +10 -11
  21. package/lib/factory/createAutoBeContext.js.map +1 -1
  22. package/lib/index.mjs +2109 -1667
  23. package/lib/index.mjs.map +1 -1
  24. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +0 -1
  25. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  26. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
  27. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +3 -18
  28. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  29. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +0 -1
  30. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -13
  31. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  32. package/lib/orchestrate/analyze/orchestrateAnalyze.d.ts +1 -2
  33. package/lib/orchestrate/analyze/orchestrateAnalyze.js +2 -4
  34. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  35. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
  36. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
  37. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  38. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +0 -1
  39. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  40. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.d.ts +1 -0
  41. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +370 -275
  42. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  43. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  44. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  45. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +0 -4
  46. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  47. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +10 -7
  48. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  49. package/lib/orchestrate/interface/histories/transformInterfaceCommonHistories.d.ts +3 -0
  50. package/lib/orchestrate/interface/histories/{transformInterfaceCommonPrerequisiteHistories.js → transformInterfaceCommonHistories.js} +4 -4
  51. package/lib/orchestrate/interface/histories/transformInterfaceCommonHistories.js.map +1 -0
  52. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +12 -9
  53. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  54. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +10 -7
  55. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  56. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
  57. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  58. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +13 -10
  59. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  60. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +10 -7
  61. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  62. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
  63. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  64. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +10 -7
  65. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  66. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +1 -1
  67. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  68. package/lib/orchestrate/interface/orchestrateInterface.d.ts +2 -2
  69. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  70. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +10 -5
  71. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  72. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  73. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  74. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +9 -6
  75. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  76. package/lib/orchestrate/prisma/orchestratePrisma.d.ts +2 -2
  77. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  78. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +370 -275
  79. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  80. package/lib/orchestrate/realize/orchestrateRealize.d.ts +2 -2
  81. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  82. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +304 -221
  83. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  84. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +303 -220
  85. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  86. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +8 -5
  87. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  88. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +8 -5
  89. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  90. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +8 -5
  91. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  92. package/lib/orchestrate/test/orchestrateTest.d.ts +2 -2
  93. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  94. package/lib/orchestrate/test/orchestrateTestCorrect.js +17 -22
  95. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  96. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +372 -277
  97. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  98. package/lib/orchestrate/test/orchestrateTestWrite.js +322 -350
  99. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  100. package/lib/utils/validateEmptyCode.d.ts +8 -0
  101. package/lib/utils/validateEmptyCode.js +35 -0
  102. package/lib/utils/validateEmptyCode.js.map +1 -0
  103. package/package.json +6 -6
  104. package/src/AutoBeMockAgent.ts +1 -1
  105. package/src/constants/AutoBeSystemPromptConstant.ts +12 -13
  106. package/src/context/AutoBeTokenUsage.ts +2 -2
  107. package/src/context/{IAutoBeApplication.ts → IAutoBeFacadeApplication.ts} +15 -83
  108. package/src/context/{IAutoBeApplicationProps.ts → IAutoBeFacadeApplicationProps.ts} +1 -1
  109. package/src/context/{IAutoBeApplicationResult.ts → IAutoBeFacadeApplicationResult.ts} +1 -1
  110. package/src/factory/createAgenticaHistory.ts +5 -4
  111. package/src/factory/createAutoBeApplication.ts +6 -6
  112. package/src/factory/createAutoBeContext.ts +2 -3
  113. package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +0 -1
  114. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +0 -16
  115. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +0 -13
  116. package/src/orchestrate/analyze/orchestrateAnalyze.ts +71 -74
  117. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +1 -2
  118. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +0 -1
  119. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +52 -10
  120. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +0 -4
  121. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +9 -6
  122. package/src/orchestrate/interface/histories/{transformInterfaceCommonPrerequisiteHistories.ts → transformInterfaceCommonHistories.ts} +1 -1
  123. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +9 -6
  124. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +9 -6
  125. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +11 -10
  126. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +9 -6
  127. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +9 -6
  128. package/src/orchestrate/interface/orchestrateInterface.ts +2 -2
  129. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +9 -4
  130. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +8 -5
  131. package/src/orchestrate/prisma/orchestratePrisma.ts +2 -2
  132. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +58 -17
  133. package/src/orchestrate/realize/orchestrateRealize.ts +2 -2
  134. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +51 -15
  135. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +46 -12
  136. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +8 -5
  137. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +8 -5
  138. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +8 -5
  139. package/src/orchestrate/test/orchestrateTest.ts +2 -2
  140. package/src/orchestrate/test/orchestrateTestCorrect.ts +17 -24
  141. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +57 -10
  142. package/src/orchestrate/test/orchestrateTestWrite.ts +41 -10
  143. package/src/utils/validateEmptyCode.ts +41 -0
  144. package/lib/context/IAutoBeApplication.js.map +0 -1
  145. package/lib/context/IAutoBeApplicationProps.js.map +0 -1
  146. package/lib/context/IAutoBeApplicationResult.js.map +0 -1
  147. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +0 -3
  148. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +0 -1
@@ -48,16 +48,19 @@ export async function transformTestWriteHistories<
48
48
 
49
49
  ## Instructions
50
50
 
51
- The following e2e-test-specific instructions were extracted by AI from
51
+ The following e2e-test-specific instructions were extracted from
52
52
  the user's requirements and conversations. These instructions focus
53
53
  exclusively on test-related aspects such as test data generation strategies,
54
54
  assertion patterns, error handling approaches, and specific validation logic
55
55
  that should be implemented in the test code.
56
56
 
57
- Apply these instructions when implementing the e2e test function to ensure
58
- the test code aligns with the user's testing requirements and expectations.
59
- If any instructions are not relevant to the target test scenario,
60
- you may ignore them.
57
+ Follow these instructions when implementing the e2e test function.
58
+ Carefully distinguish between:
59
+ - Suggestions or recommendations (consider these as guidance)
60
+ - Direct specifications or explicit commands (these must be followed exactly)
61
+
62
+ When instructions contain direct specifications or explicit design decisions,
63
+ follow them precisely even if you believe you have better alternatives.
61
64
 
62
65
  ${props.instruction}
63
66
 
@@ -11,7 +11,7 @@ import { ILlmSchema } from "@samchon/openapi";
11
11
  import { v7 } from "uuid";
12
12
 
13
13
  import { AutoBeContext } from "../../context/AutoBeContext";
14
- import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
14
+ import { IAutoBeFacadeApplicationProps } from "../../context/IAutoBeFacadeApplicationProps";
15
15
  import { predicateStateMessage } from "../../utils/predicateStateMessage";
16
16
  import { orchestrateTestCorrect } from "./orchestrateTestCorrect";
17
17
  import { orchestrateTestScenario } from "./orchestrateTestScenario";
@@ -21,7 +21,7 @@ import { IAutoBeTestWriteResult } from "./structures/IAutoBeTestWriteResult";
21
21
  export const orchestrateTest =
22
22
  <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
23
23
  async (
24
- props: IAutoBeApplicationProps,
24
+ props: IAutoBeFacadeApplicationProps,
25
25
  ): Promise<AutoBeAssistantMessageHistory | AutoBeTestHistory> => {
26
26
  // PREDICATION
27
27
  const start: Date = new Date();
@@ -14,6 +14,7 @@ import { v7 } from "uuid";
14
14
  import { AutoBeContext } from "../../context/AutoBeContext";
15
15
  import { assertSchemaModel } from "../../context/assertSchemaModel";
16
16
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
17
+ import { validateEmptyCode } from "../../utils/validateEmptyCode";
17
18
  import { orchestrateCommonCorrectCasting } from "../common/orchestrateCommonCorrectCasting";
18
19
  import { completeTestCode } from "./compile/completeTestCode";
19
20
  import { transformTestCorrectHistories } from "./histories/transformTestCorrectHistories";
@@ -66,6 +67,7 @@ export const orchestrateTestCorrect = async <Model extends ILlmSchema.Model>(
66
67
  step: ctx.state().analyze?.step ?? 0,
67
68
  }) satisfies AutoBeTestCorrectEvent,
68
69
  script: (event) => event.file.content,
70
+ functionName: w.scenario.functionName,
69
71
  },
70
72
  x.file.content,
71
73
  );
@@ -163,6 +165,7 @@ const correct = async <Model extends ILlmSchema.Model>(
163
165
  }),
164
166
  controller: createController({
165
167
  model: ctx.model,
168
+ functionName: props.function.scenario.functionName,
166
169
  failure: props.validate.result,
167
170
  build: (next) => {
168
171
  pointer.value = next;
@@ -233,6 +236,7 @@ const correct = async <Model extends ILlmSchema.Model>(
233
236
 
234
237
  const createController = <Model extends ILlmSchema.Model>(props: {
235
238
  model: Model;
239
+ functionName: string;
236
240
  failure: IAutoBeTypeScriptCompileResult.IFailure;
237
241
  build: (next: IAutoBeTestCorrectApplication.IProps) => void;
238
242
  }): IAgenticaController.IClass<Model> => {
@@ -243,30 +247,19 @@ const createController = <Model extends ILlmSchema.Model>(props: {
243
247
  ): IValidation<IAutoBeTestCorrectApplication.IProps> => {
244
248
  const result: IValidation<IAutoBeTestCorrectApplication.IProps> =
245
249
  typia.validate<IAutoBeTestCorrectApplication.IProps>(input);
246
- // if (result.success === false) return result;
247
-
248
- // const expected: number = props.failure.diagnostics.length;
249
- // const actual: number = result.data.think.analyses.length;
250
- // if (expected !== actual)
251
- // return {
252
- // success: false,
253
- // errors: [
254
- // {
255
- // path: "$input.think.analyses",
256
- // expected: `Array<IValidation<IAutoBeTypeScriptCompileResult.IDiagnostic>> & MinItems<${expected}> & MaxItems<${expected}>`,
257
- // value: result.data.think.analyses,
258
- // description: StringUtil.trim`
259
- // The 'think.analyses' must contain all the compilation errors.
260
-
261
- // Therefore, the length of the 'think.analyses' must be not
262
- // ${actual}, but exactly ${expected}, which is equal to the length of
263
- // the 'diagnostics' of the compilation failure.
264
- // `,
265
- // },
266
- // ],
267
- // data: input,
268
- // };
269
- return result;
250
+ if (result.success === false) return result;
251
+ const errors: IValidation.IError[] = validateEmptyCode({
252
+ functionName: props.functionName,
253
+ draft: result.data.draft,
254
+ revise: result.data.revise,
255
+ });
256
+ return errors.length
257
+ ? {
258
+ success: false,
259
+ errors,
260
+ data: result.data,
261
+ }
262
+ : result;
270
263
  };
271
264
  const application: ILlmApplication<Model> = collection[
272
265
  props.model === "chatgpt" ? "chatgpt" : "claude"
@@ -3,13 +3,19 @@ import {
3
3
  AutoBeTestValidateEvent,
4
4
  } from "@autobe/interface";
5
5
  import { StringUtil } from "@autobe/utils";
6
- import { ILlmApplication, ILlmController, ILlmSchema } from "@samchon/openapi";
6
+ import {
7
+ ILlmApplication,
8
+ ILlmController,
9
+ ILlmSchema,
10
+ IValidation,
11
+ } from "@samchon/openapi";
7
12
  import { IPointer } from "tstl";
8
13
  import typia from "typia";
9
14
  import { v7 } from "uuid";
10
15
 
11
16
  import { AutoBeContext } from "../../context/AutoBeContext";
12
17
  import { assertSchemaModel } from "../../context/assertSchemaModel";
18
+ import { validateEmptyCode } from "../../utils/validateEmptyCode";
13
19
  import { completeTestCode } from "./compile/completeTestCode";
14
20
  import { transformTestCorrectInvalidRequestHistories } from "./histories/transformTestCorrectInvalidRequestHistories";
15
21
  import { IAutoBeTestCorrectInvalidRequestApplication } from "./structures/IAutoBeTestCorrectInvalidRequestApplication";
@@ -65,6 +71,7 @@ const correct = async <Model extends ILlmSchema.Model>(
65
71
  ),
66
72
  controller: createController({
67
73
  model: ctx.model,
74
+ functionName: write.scenario.functionName,
68
75
  then: (next) => {
69
76
  pointer.value = next;
70
77
  },
@@ -123,13 +130,31 @@ const correct = async <Model extends ILlmSchema.Model>(
123
130
 
124
131
  const createController = <Model extends ILlmSchema.Model>(props: {
125
132
  model: Model;
133
+ functionName: string;
126
134
  then: (next: IAutoBeTestCorrectInvalidRequestApplication.IProps) => void;
127
135
  reject: () => void;
128
136
  }): ILlmController<Model> => {
129
137
  assertSchemaModel(props.model);
138
+ const validate: Validator = (input) => {
139
+ const result: IValidation<IAutoBeTestCorrectInvalidRequestApplication.IProps> =
140
+ typia.validate<IAutoBeTestCorrectInvalidRequestApplication.IProps>(input);
141
+ if (result.success === false) return result;
142
+ const errors: IValidation.IError[] = validateEmptyCode({
143
+ functionName: props.functionName,
144
+ draft: result.data.draft,
145
+ revise: result.data.revise,
146
+ });
147
+ return errors.length
148
+ ? {
149
+ success: false,
150
+ errors,
151
+ data: result.data,
152
+ }
153
+ : result;
154
+ };
130
155
  const application = collection[
131
156
  props.model === "chatgpt" ? "chatgpt" : "claude"
132
- ] satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
157
+ ](validate) satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
133
158
  return {
134
159
  protocol: "class",
135
160
  name: "correctInvalidRequest",
@@ -146,12 +171,34 @@ const createController = <Model extends ILlmSchema.Model>(props: {
146
171
  };
147
172
 
148
173
  const collection = {
149
- chatgpt: typia.llm.application<
150
- IAutoBeTestCorrectInvalidRequestApplication,
151
- "chatgpt"
152
- >(),
153
- claude: typia.llm.application<
154
- IAutoBeTestCorrectInvalidRequestApplication,
155
- "claude"
156
- >(),
174
+ chatgpt: (validate: Validator) =>
175
+ typia.llm.application<
176
+ IAutoBeTestCorrectInvalidRequestApplication,
177
+ "chatgpt"
178
+ >({
179
+ validate: {
180
+ rewrite: validate,
181
+ reject: () => ({
182
+ success: true,
183
+ data: undefined,
184
+ }),
185
+ },
186
+ }),
187
+ claude: (validate: Validator) =>
188
+ typia.llm.application<
189
+ IAutoBeTestCorrectInvalidRequestApplication,
190
+ "claude"
191
+ >({
192
+ validate: {
193
+ rewrite: validate,
194
+ reject: () => ({
195
+ success: true,
196
+ data: undefined,
197
+ }),
198
+ },
199
+ }),
157
200
  };
201
+
202
+ type Validator = (
203
+ input: unknown,
204
+ ) => IValidation<IAutoBeTestCorrectInvalidRequestApplication.IProps>;
@@ -4,7 +4,7 @@ import {
4
4
  AutoBeTestScenario,
5
5
  AutoBeTestWriteEvent,
6
6
  } from "@autobe/interface";
7
- import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
7
+ import { ILlmApplication, ILlmSchema, IValidation } from "@samchon/openapi";
8
8
  import { IPointer } from "tstl";
9
9
  import typia from "typia";
10
10
  import { NamingConvention } from "typia/lib/utils/NamingConvention";
@@ -13,6 +13,7 @@ import { v7 } from "uuid";
13
13
  import { AutoBeContext } from "../../context/AutoBeContext";
14
14
  import { assertSchemaModel } from "../../context/assertSchemaModel";
15
15
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
16
+ import { validateEmptyCode } from "../../utils/validateEmptyCode";
16
17
  import { completeTestCode } from "./compile/completeTestCode";
17
18
  import { getTestScenarioArtifacts } from "./compile/getTestScenarioArtifacts";
18
19
  import { transformTestWriteHistories } from "./histories/transformTestWriteHistories";
@@ -85,6 +86,7 @@ async function process<Model extends ILlmSchema.Model>(
85
86
  }),
86
87
  controller: createController({
87
88
  model: ctx.model,
89
+ functionName: props.scenario.functionName,
88
90
  build: (next) => {
89
91
  next.domain = NamingConvention.snake(next.domain);
90
92
  pointer.value = next;
@@ -129,13 +131,33 @@ async function process<Model extends ILlmSchema.Model>(
129
131
 
130
132
  function createController<Model extends ILlmSchema.Model>(props: {
131
133
  model: Model;
134
+ functionName: string;
132
135
  build: (next: IAutoBeTestWriteApplication.IProps) => void;
133
136
  }): IAgenticaController.IClass<Model> {
134
137
  assertSchemaModel(props.model);
135
138
 
139
+ const validate: Validator = (input) => {
140
+ const result: IValidation<IAutoBeTestWriteApplication.IProps> =
141
+ typia.validate<IAutoBeTestWriteApplication.IProps>(input);
142
+ if (result.success === false) return result;
143
+ const errors: IValidation.IError[] = validateEmptyCode({
144
+ functionName: props.functionName,
145
+ draft: result.data.draft,
146
+ revise: result.data.revise,
147
+ });
148
+ return errors.length
149
+ ? {
150
+ success: false,
151
+ errors,
152
+ data: result.data,
153
+ }
154
+ : result;
155
+ };
136
156
  const application: ILlmApplication<Model> = collection[
137
- props.model
138
- ] satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
157
+ props.model === "chatgpt" ? "chatgpt" : "claude"
158
+ ](
159
+ validate,
160
+ ) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
139
161
  return {
140
162
  protocol: "class",
141
163
  name: "Create Test Code",
@@ -148,12 +170,21 @@ function createController<Model extends ILlmSchema.Model>(props: {
148
170
  };
149
171
  }
150
172
 
151
- const claude = typia.llm.application<IAutoBeTestWriteApplication, "claude">();
152
173
  const collection = {
153
- chatgpt: typia.llm.application<IAutoBeTestWriteApplication, "chatgpt">(),
154
- claude,
155
- llama: claude,
156
- deepseek: claude,
157
- "3.1": claude,
158
- "3.0": typia.llm.application<IAutoBeTestWriteApplication, "3.0">(),
174
+ chatgpt: (validate: Validator) =>
175
+ typia.llm.application<IAutoBeTestWriteApplication, "chatgpt">({
176
+ validate: {
177
+ write: validate,
178
+ },
179
+ }),
180
+ claude: (validate: Validator) =>
181
+ typia.llm.application<IAutoBeTestWriteApplication, "claude">({
182
+ validate: {
183
+ write: validate,
184
+ },
185
+ }),
159
186
  };
187
+
188
+ type Validator = (
189
+ input: unknown,
190
+ ) => IValidation<IAutoBeTestWriteApplication.IProps>;
@@ -0,0 +1,41 @@
1
+ import { StringUtil } from "@autobe/utils";
2
+ import { IValidation } from "typia";
3
+
4
+ export const validateEmptyCode = (props: {
5
+ functionName: string;
6
+ draft: string;
7
+ revise: {
8
+ final: string | null;
9
+ };
10
+ }): IValidation.IError[] => {
11
+ const errors: IValidation.IError[] = [];
12
+ if (props.draft.includes(props.functionName) === false)
13
+ errors.push({
14
+ path: "$input.draft",
15
+ expected: `string (including function named '${props.functionName}')`,
16
+ value: props.draft,
17
+ description: description(props.functionName),
18
+ });
19
+ if (
20
+ props.revise.final !== null &&
21
+ props.revise.final.includes(props.functionName) === false
22
+ )
23
+ errors.push({
24
+ path: "$input.revise.final",
25
+ expected: `string (including function named '${props.functionName}')`,
26
+ value: props.revise.final,
27
+ description: description(props.functionName),
28
+ });
29
+ return errors;
30
+ };
31
+
32
+ const description = (func: string): string => StringUtil.trim`
33
+ The function ${func} does not exist in the provided code snippet.
34
+
35
+ The first reason of the non-existence is that the code snippet is empty,
36
+ and the second reason is that AI has written different function name
37
+ by mistake.
38
+
39
+ Please make sure that the code snippet includes the function ${func}.
40
+ Note that, you never have to write empty code or different function name.
41
+ `;
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAutoBeApplication.js","sourceRoot":"","sources":["../../src/context/IAutoBeApplication.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAutoBeApplicationProps.js","sourceRoot":"","sources":["../../src/context/IAutoBeApplicationProps.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAutoBeApplicationResult.js","sourceRoot":"","sources":["../../src/context/IAutoBeApplicationResult.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { IAgenticaHistoryJson } from "@agentica/core";
2
- import { AutoBeState } from "../../../context/AutoBeState";
3
- export declare const transformInterfaceCommonPrerequisiteHistories: (state: AutoBeState) => Array<IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage> | null;
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformInterfaceCommonPrerequisiteHistories.js","sourceRoot":"","sources":["../../../../src/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.ts"],"names":[],"mappings":";;;AACA,+BAA0B;AAInB,MAAM,6CAA6C,GAAG,CAC3D,KAAkB,EAGX,EAAE;IACT,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QACxB,OAAO;YACL;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,4CAA4C;oBAC5C,mCAAmC;oBACnC,8CAA8C;iBAC/C,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;SACC,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAC5B,OAAO;YACL;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,mDAAmD;oBACnD,mCAAmC;oBACnC,qDAAqD;iBACtD,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;SACC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,CAAC,IAAI;QAC/C,OAAO;YACL;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,kDAAkD;oBAClD,sCAAsC;oBACtC,mCAAmC;oBACnC,wDAAwD;iBACzD,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;SACC,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC/C,OAAO;YACL;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,kDAAkD;oBAClD,sCAAsC;oBACtC,mCAAmC;oBACnC,wDAAwD;iBACzD,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;IACJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AA5DW,QAAA,6CAA6C,iDA4DxD"}