@autobe/agent 0.25.3 → 0.25.5

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 (47) hide show
  1. package/lib/AutoBeAgent.js +2 -0
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/AutoBeMockAgent.js +1 -1
  4. package/lib/AutoBeMockAgent.js.map +1 -1
  5. package/lib/factory/consentFunctionCall.js +2 -0
  6. package/lib/factory/consentFunctionCall.js.map +1 -1
  7. package/lib/factory/createAutoBeContext.js +2 -0
  8. package/lib/factory/createAutoBeContext.js.map +1 -1
  9. package/lib/factory/supportMistral.d.ts +4 -0
  10. package/lib/factory/supportMistral.js +112 -0
  11. package/lib/factory/supportMistral.js.map +1 -0
  12. package/lib/index.mjs +1997 -1422
  13. package/lib/index.mjs.map +1 -1
  14. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.d.ts +1 -0
  15. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +370 -275
  16. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  17. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +1 -1
  18. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +370 -275
  19. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  20. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +304 -221
  21. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  22. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +303 -220
  23. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  24. package/lib/orchestrate/test/orchestrateTestCorrect.js +17 -22
  25. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  26. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +372 -277
  27. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  28. package/lib/orchestrate/test/orchestrateTestWrite.js +322 -350
  29. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  30. package/lib/utils/validateEmptyCode.d.ts +8 -0
  31. package/lib/utils/validateEmptyCode.js +35 -0
  32. package/lib/utils/validateEmptyCode.js.map +1 -0
  33. package/package.json +5 -5
  34. package/src/AutoBeAgent.ts +2 -0
  35. package/src/AutoBeMockAgent.ts +1 -1
  36. package/src/factory/consentFunctionCall.ts +3 -0
  37. package/src/factory/createAutoBeContext.ts +2 -0
  38. package/src/factory/supportMistral.ts +122 -0
  39. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +52 -10
  40. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -1
  41. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +58 -17
  42. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +51 -15
  43. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +46 -12
  44. package/src/orchestrate/test/orchestrateTestCorrect.ts +17 -24
  45. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +57 -10
  46. package/src/orchestrate/test/orchestrateTestWrite.ts +41 -10
  47. package/src/utils/validateEmptyCode.ts +41 -0
@@ -5,13 +5,19 @@ import {
5
5
  AutoBeRealizeWriteEvent,
6
6
  } from "@autobe/interface";
7
7
  import { StringUtil } from "@autobe/utils";
8
- import { ILlmApplication, ILlmController, ILlmSchema } from "@samchon/openapi";
8
+ import {
9
+ ILlmApplication,
10
+ ILlmController,
11
+ ILlmSchema,
12
+ IValidation,
13
+ } from "@samchon/openapi";
9
14
  import { IPointer } from "tstl";
10
15
  import typia from "typia";
11
16
  import { v7 } from "uuid";
12
17
 
13
18
  import { AutoBeContext } from "../../context/AutoBeContext";
14
19
  import { assertSchemaModel } from "../../context/assertSchemaModel";
20
+ import { validateEmptyCode } from "../../utils/validateEmptyCode";
15
21
  import { transformRealizeWriteHistories } from "./histories/transformRealizeWriteHistories";
16
22
  import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
17
23
  import { IAutoBeRealizeWriteApplication } from "./structures/IAutoBeRealizeWriteApplication";
@@ -45,6 +51,7 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
45
51
  }),
46
52
  controller: createController({
47
53
  model: ctx.model,
54
+ functionName: props.scenario.functionName,
48
55
  build: (next) => {
49
56
  pointer.value = next;
50
57
  },
@@ -102,13 +109,33 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
102
109
 
103
110
  function createController<Model extends ILlmSchema.Model>(props: {
104
111
  model: Model;
112
+ functionName: string;
105
113
  build: (next: IAutoBeRealizeWriteApplication.IProps) => void;
106
114
  }): ILlmController<Model> {
107
115
  assertSchemaModel(props.model);
108
116
 
117
+ const validate: Validator = (input) => {
118
+ const result: IValidation<IAutoBeRealizeWriteApplication.IProps> =
119
+ typia.validate<IAutoBeRealizeWriteApplication.IProps>(input);
120
+ if (result.success === false) return result;
121
+ const errors: IValidation.IError[] = validateEmptyCode({
122
+ functionName: props.functionName,
123
+ draft: result.data.draft,
124
+ revise: result.data.revise,
125
+ });
126
+ return errors.length
127
+ ? {
128
+ success: false,
129
+ errors,
130
+ data: result.data,
131
+ }
132
+ : result;
133
+ };
109
134
  const application: ILlmApplication<Model> = collection[
110
- props.model
111
- ] satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
135
+ props.model === "chatgpt" ? "chatgpt" : "claude"
136
+ ](
137
+ validate,
138
+ ) satisfies ILlmApplication<any> as unknown as ILlmApplication<Model>;
112
139
 
113
140
  return {
114
141
  protocol: "class",
@@ -122,14 +149,21 @@ function createController<Model extends ILlmSchema.Model>(props: {
122
149
  };
123
150
  }
124
151
 
125
- const claude = typia.llm.application<
126
- IAutoBeRealizeWriteApplication,
127
- "claude"
128
- >();
129
152
  const collection = {
130
- chatgpt: typia.llm.application<IAutoBeRealizeWriteApplication, "chatgpt">(),
131
- claude,
132
- llama: claude,
133
- deepseek: claude,
134
- "3.1": claude,
153
+ chatgpt: (validate: Validator) =>
154
+ typia.llm.application<IAutoBeRealizeWriteApplication, "chatgpt">({
155
+ validate: {
156
+ write: validate,
157
+ },
158
+ }),
159
+ claude: (validate: Validator) =>
160
+ typia.llm.application<IAutoBeRealizeWriteApplication, "claude">({
161
+ validate: {
162
+ write: validate,
163
+ },
164
+ }),
135
165
  };
166
+
167
+ type Validator = (
168
+ input: unknown,
169
+ ) => IValidation<IAutoBeRealizeWriteApplication.IProps>;
@@ -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
+ `;