@autobe/agent 0.24.0 → 0.24.2

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 (65) hide show
  1. package/lib/AutoBeMockAgent.js +1 -0
  2. package/lib/AutoBeMockAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +4 -3
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/factory/createAutoBeContext.js +3 -3
  6. package/lib/factory/getAutoBeGenerated.js +4 -1
  7. package/lib/factory/getAutoBeGenerated.js.map +1 -1
  8. package/lib/factory/getAutoBeRealizeGenerated.d.ts +2 -1
  9. package/lib/factory/getAutoBeRealizeGenerated.js +1 -1
  10. package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -1
  11. package/lib/factory/getCriticalCompiler.js +1 -1
  12. package/lib/factory/getCriticalCompiler.js.map +1 -1
  13. package/lib/index.mjs +1092 -139
  14. package/lib/index.mjs.map +1 -1
  15. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +67 -8
  16. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  17. package/lib/orchestrate/interface/utils/OperationValidator.js +2 -1
  18. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  19. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +1 -1
  20. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  21. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +1 -1
  22. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  23. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +1 -1
  24. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  25. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +3 -1
  26. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  27. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +4 -1
  28. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  29. package/lib/orchestrate/realize/orchestrateRealize.js +15 -5
  30. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  31. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +3 -1
  32. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  33. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +4 -3
  34. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  35. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +1 -0
  36. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  37. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +5 -0
  38. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +113 -0
  39. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -0
  40. package/lib/orchestrate/test/orchestrateTestScenario.js +8 -2
  41. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  42. package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -0
  43. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +847 -0
  44. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -0
  45. package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.d.ts +47 -0
  46. package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js +3 -0
  47. package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js.map +1 -0
  48. package/package.json +6 -6
  49. package/src/AutoBeMockAgent.ts +1 -0
  50. package/src/constants/AutoBeSystemPromptConstant.ts +4 -3
  51. package/src/factory/getAutoBeGenerated.ts +3 -0
  52. package/src/factory/getAutoBeRealizeGenerated.ts +3 -1
  53. package/src/factory/getCriticalCompiler.ts +2 -1
  54. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +68 -8
  55. package/src/orchestrate/interface/utils/OperationValidator.ts +2 -1
  56. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +3 -1
  57. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +4 -1
  58. package/src/orchestrate/realize/orchestrateRealize.ts +44 -37
  59. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +5 -1
  60. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +20 -14
  61. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +1 -0
  62. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +156 -0
  63. package/src/orchestrate/test/orchestrateTestScenario.ts +13 -3
  64. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +185 -0
  65. package/src/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.ts +52 -0
@@ -104,6 +104,9 @@ export async function getAutoBeGenerated(
104
104
  document: state.interface!.document,
105
105
  authorizations: state.realize.authorizations,
106
106
  functions: state.realize.functions,
107
+ options: {
108
+ dbms: options?.dbms ?? "postgres",
109
+ },
107
110
  }),
108
111
  );
109
112
  if (options?.stage === "test") return ret;
@@ -3,6 +3,7 @@ import {
3
3
  AutoBeRealizeAuthorization,
4
4
  AutoBeRealizeFunction,
5
5
  IAutoBeCompiler,
6
+ IAutoBeGetFilesOptions,
6
7
  } from "@autobe/interface";
7
8
 
8
9
  export const getAutoBeRealizeGenerated = async (props: {
@@ -10,6 +11,7 @@ export const getAutoBeRealizeGenerated = async (props: {
10
11
  document: AutoBeOpenApi.IDocument;
11
12
  authorizations: AutoBeRealizeAuthorization[];
12
13
  functions: AutoBeRealizeFunction[];
14
+ options: IAutoBeGetFilesOptions;
13
15
  }): Promise<Record<string, string>> => ({
14
16
  ...Object.fromEntries(props.functions.map((f) => [f.location, f.content])),
15
17
  ...Object.fromEntries(
@@ -21,7 +23,7 @@ export const getAutoBeRealizeGenerated = async (props: {
21
23
  ])
22
24
  .flat(),
23
25
  ),
24
- ...(await props.compiler.realize.getTemplate()),
26
+ ...(await props.compiler.realize.getTemplate(props.options)),
25
27
  ...(await props.compiler.realize.controller({
26
28
  document: props.document,
27
29
  functions: props.functions,
@@ -41,7 +41,8 @@ export const getCriticalCompiler = (
41
41
  realize: {
42
42
  controller: (props) => lock(() => compiler.realize.controller(props)),
43
43
  test: (props) => lock(() => compiler.realize.test(props)),
44
- getTemplate: () => lock(() => compiler.realize.getTemplate()),
44
+ getTemplate: (options) =>
45
+ lock(() => compiler.realize.getTemplate(options)),
45
46
  },
46
47
  };
47
48
  };
@@ -25,22 +25,82 @@ export namespace JsonSchemaValidator {
25
25
  path: string;
26
26
  key: string;
27
27
  }): void => {
28
- const variable: boolean = props.key.split(".").every(Escaper.variable);
29
- if (variable === false)
28
+ const elements: string[] = props.key.split(".");
29
+ if (elements.every(Escaper.variable) === false)
30
30
  props.errors.push({
31
31
  path: `${props.path}[${JSON.stringify(props.key)}]`,
32
32
  expected: "Valid variable name",
33
33
  value: props.key,
34
34
  description: StringUtil.trim`
35
- JSON schema type name must be a valid variable name.
35
+ JSON schema type name must be a valid variable name.
36
36
 
37
- Even though JSON schema type name allows dot(.) character, but
38
- each segment separated by dot(.) must be a valid variable name.
37
+ Even though JSON schema type name allows dot(.) character, but
38
+ each segment separated by dot(.) must be a valid variable name.
39
39
 
40
- Current key name ${JSON.stringify(props.key)} is not valid. Change
41
- it to a valid variable name at the next time.
42
- `,
40
+ Current key name ${JSON.stringify(props.key)} is not valid. Change
41
+ it to a valid variable name at the next time.
42
+ `,
43
43
  });
44
+ if (props.key === "IPageIRequest")
45
+ props.errors.push({
46
+ path: `${props.path}[${JSON.stringify(props.key)}]`,
47
+ expected: `"IPageIRequest" is a mistake. Use "IPage.IRequest" instead.`,
48
+ value: props.key,
49
+ description: StringUtil.trim`
50
+ You've taken a mistake that defines "IPageIRequest" as a type name.
51
+ However, as you've intended to define a pagination request type,
52
+ the correct type name is "IPage.IRequest" instead of "IPageIRequest".
53
+
54
+ Change it to "IPage.IRequest" at the next time.
55
+ `,
56
+ });
57
+ else if (
58
+ props.key.startsWith("IPage") &&
59
+ props.key.startsWith("IPageI") === false
60
+ ) {
61
+ const expected: string = `IPage${props.key
62
+ .substring(5)
63
+ .split(".")
64
+ .map((s) => (s.startsWith("I") ? s : `I${s}`))
65
+ .join(".")}`;
66
+ props.errors.push({
67
+ path: `${props.path}[${JSON.stringify(props.key)}]`,
68
+ expected: `Interface name starting with 'I' even after 'IPage': ${JSON.stringify(expected)}`,
69
+ value: props.key,
70
+ description: StringUtil.trim`
71
+ JSON schema type name must be an interface name starting with 'I'.
72
+ Even though JSON schema type name allows dot(.) character, but
73
+ each segment separated by dot(.) must be an interface name starting
74
+ with 'I'.
75
+
76
+ Even in the case of pagination response, after 'IPage' prefix,
77
+ the remaining part must be an interface name starting with 'I'.
78
+
79
+ Current key name ${JSON.stringify(props.key)} is not valid. Change
80
+ it to a valid interface name to be ${JSON.stringify(expected)},
81
+ or change it to another valid interface name at the next time.
82
+ `,
83
+ });
84
+ } else if (elements.some((s) => s.startsWith("I") === false) === true) {
85
+ const expected: string = elements
86
+ .map((s) => (s.startsWith("I") ? s : `I${s}`))
87
+ .join(".");
88
+ props.errors.push({
89
+ path: `${props.path}[${JSON.stringify(props.key)}]`,
90
+ expected: `Interface name starting with 'I': ${JSON.stringify(expected)}`,
91
+ value: props.key,
92
+ description: StringUtil.trim`
93
+ JSON schema type name must be an interface name starting with 'I'.
94
+ Even though JSON schema type name allows dot(.) character, but
95
+ each segment separated by dot(.) must be an interface name starting
96
+ with 'I'.
97
+
98
+ Current key name ${JSON.stringify(props.key)} is not valid. Change
99
+ it to a valid interface name to be ${JSON.stringify(expected)},
100
+ or change it to another valid interface name at the next time.
101
+ `,
102
+ });
103
+ }
44
104
  };
45
105
 
46
106
  const authorization = (props: IProps): void => {
@@ -48,12 +48,13 @@ export namespace OperationValidator {
48
48
  path: `${props.path}[${i}].requestBody.typeName`,
49
49
  key: op.requestBody.typeName,
50
50
  });
51
- if (op.responseBody !== null)
51
+ if (op.responseBody !== null) {
52
52
  JsonSchemaValidator.validateKey({
53
53
  errors: props.errors,
54
54
  path: `${props.path}[${i}].responseBody.typeName`,
55
55
  key: op.responseBody.typeName,
56
56
  });
57
+ }
57
58
  });
58
59
 
59
60
  // validate duplicated endpoints
@@ -23,7 +23,9 @@ export async function compileRealizeFiles<Model extends ILlmSchema.Model>(
23
23
  );
24
24
  const compiler: IAutoBeCompiler = await ctx.compiler();
25
25
  const templateFiles: Record<string, string> =
26
- await compiler.realize.getTemplate();
26
+ await compiler.realize.getTemplate({
27
+ dbms: "sqlite",
28
+ });
27
29
  const nodeModules: Record<string, string> =
28
30
  prisma?.type === "success" ? prisma.nodeModules : {};
29
31
 
@@ -166,7 +166,10 @@ const correct = async <Model extends ILlmSchema.Model>(
166
166
 
167
167
  const newValidate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
168
168
  ctx,
169
- { authorizations, functions: converted.map((c) => c.func) },
169
+ {
170
+ authorizations,
171
+ functions: converted.map((c) => c.func),
172
+ },
170
173
  );
171
174
 
172
175
  if (newValidate.result.type === "success") {
@@ -21,7 +21,6 @@ import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorizati
21
21
  import { orchestrateRealizeCorrect } from "./orchestrateRealizeCorrect";
22
22
  import { orchestrateRealizeCorrectDate } from "./orchestrateRealizeCorrectDate";
23
23
  import { orchestrateRealizeWrite } from "./orchestrateRealizeWrite";
24
- import { IAutoBeRealizeFunctionFailure } from "./structures/IAutoBeRealizeFunctionFailure";
25
24
  import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
26
25
  import { generateRealizeScenario } from "./utils/generateRealizeScenario";
27
26
 
@@ -70,22 +69,31 @@ export const orchestrateRealize =
70
69
  total: scenarios.length,
71
70
  completed: 0,
72
71
  };
73
- const writeEvents: AutoBeRealizeWriteEvent[] = await executeCachedBatch(
74
- scenarios.map((scenario) => async (promptCacheKey) => {
75
- const code = await orchestrateRealizeWrite(ctx, {
76
- totalAuthorizations: authorizations,
77
- authorization: scenario.decoratorEvent ?? null,
78
- scenario,
79
- progress: writeProgress,
80
- promptCacheKey,
81
- });
82
- return code;
83
- }),
84
- );
72
+ const writeEvents: (AutoBeRealizeWriteEvent | null)[] =
73
+ await executeCachedBatch(
74
+ scenarios.map((scenario) => async (promptCacheKey) => {
75
+ const props = {
76
+ totalAuthorizations: authorizations,
77
+ authorization: scenario.decoratorEvent ?? null,
78
+ scenario,
79
+ progress: writeProgress,
80
+ promptCacheKey,
81
+ };
82
+
83
+ const code: AutoBeRealizeWriteEvent | null =
84
+ await orchestrateRealizeWrite(ctx, props).catch(() => {
85
+ return orchestrateRealizeWrite(ctx, props).catch(() => null);
86
+ });
87
+
88
+ return code;
89
+ }),
90
+ );
85
91
 
86
92
  const functions: AutoBeRealizeFunction[] = Object.entries(
87
93
  Object.fromEntries(
88
- writeEvents.map((event) => [event.location, event.content]),
94
+ writeEvents
95
+ .filter((w) => w !== null)
96
+ .map((event) => [event.location, event.content]),
89
97
  ),
90
98
  ).map(([location, content]) => {
91
99
  const scenario = scenarios.find((el) => el.location === location)!;
@@ -100,38 +108,37 @@ export const orchestrateRealize =
100
108
  };
101
109
  });
102
110
 
103
- const reviewProgress = {
111
+ const reviewProgress: AutoBeProgressEventBase = {
104
112
  total: writeEvents.length,
105
113
  completed: writeEvents.length,
106
114
  };
107
115
 
108
- const converted: AutoBeRealizeFunction[] =
116
+ console.log("casting", reviewProgress);
117
+ const totalCorrected: AutoBeRealizeFunction[] =
109
118
  await orchestrateRealizeCorrectCasting(
110
119
  ctx,
111
120
  authorizations,
112
121
  functions,
113
122
  reviewProgress,
114
- parseInt((ctx.retry / 2).toString()),
115
- );
116
-
117
- const correctedDate: AutoBeRealizeFunction[] =
118
- await orchestrateRealizeCorrectDate(
119
- ctx,
120
- authorizations,
121
- converted,
122
- reviewProgress,
123
- parseInt((ctx.retry / 2).toString()),
124
- );
125
-
126
- const totalCorrected: AutoBeRealizeFunction[] =
127
- await orchestrateRealizeCorrect(
128
- ctx,
129
- scenarios,
130
- authorizations,
131
- correctedDate,
132
- [] satisfies IAutoBeRealizeFunctionFailure[],
133
- reviewProgress,
134
- );
123
+ ).then(async (res) => {
124
+ console.log("date", reviewProgress);
125
+ return orchestrateRealizeCorrectDate(
126
+ ctx,
127
+ authorizations,
128
+ res,
129
+ reviewProgress,
130
+ ).then(async (res) => {
131
+ console.log("correct", reviewProgress);
132
+ return orchestrateRealizeCorrect(
133
+ ctx,
134
+ scenarios,
135
+ authorizations,
136
+ res,
137
+ [],
138
+ reviewProgress,
139
+ );
140
+ });
141
+ });
135
142
 
136
143
  const compiler: IAutoBeCompiler = await ctx.compiler();
137
144
  const controllers: Record<string, string> =
@@ -41,7 +41,11 @@ export async function orchestrateRealizeAuthorization<
41
41
  total: roles.length,
42
42
  completed: 0,
43
43
  };
44
- const templateFiles = await (await ctx.compiler()).realize.getTemplate();
44
+ const templateFiles = await (
45
+ await ctx.compiler()
46
+ ).realize.getTemplate({
47
+ dbms: "sqlite",
48
+ });
45
49
  const authorizations: AutoBeRealizeAuthorization[] = await executeCachedBatch(
46
50
  roles.map(
47
51
  (role) => (promptCacheKey) =>
@@ -35,7 +35,6 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
35
35
  authorizations,
36
36
  functions,
37
37
  });
38
-
39
38
  if (event.result.type !== "failure") return functions;
40
39
  else if (life < 0) return functions;
41
40
 
@@ -130,16 +129,22 @@ async function correct<Model extends ILlmSchema.Model>(
130
129
 
131
130
  if (RealizeFunctionFailures.length && scenario) {
132
131
  try {
133
- const correctEvent = await step(ctx, {
134
- totalAuthorizations: authorizations,
135
- authorization: scenario.decoratorEvent ?? null,
136
- scenario,
137
- function: func,
138
- failures: RealizeFunctionFailures,
139
- progress: progress,
140
- });
141
-
142
- return { ...func, content: correctEvent.content };
132
+ const correctEvent: AutoBeRealizeCorrectEvent | null = await step(
133
+ ctx,
134
+ {
135
+ totalAuthorizations: authorizations,
136
+ authorization: scenario.decoratorEvent ?? null,
137
+ scenario,
138
+ function: func,
139
+ failures: RealizeFunctionFailures,
140
+ progress: progress,
141
+ },
142
+ );
143
+
144
+ return {
145
+ ...func,
146
+ content: correctEvent === null ? "" : correctEvent.content,
147
+ };
143
148
  } catch (err) {
144
149
  return func;
145
150
  }
@@ -162,7 +167,7 @@ async function step<Model extends ILlmSchema.Model>(
162
167
  failures: IAutoBeRealizeFunctionFailure[];
163
168
  progress: AutoBeProgressEventBase;
164
169
  },
165
- ): Promise<AutoBeRealizeCorrectEvent> {
170
+ ): Promise<AutoBeRealizeCorrectEvent | null> {
166
171
  const pointer: IPointer<IAutoBeRealizeCorrectApplication.IProps | null> = {
167
172
  value: null,
168
173
  };
@@ -193,8 +198,9 @@ async function step<Model extends ILlmSchema.Model>(
193
198
  `,
194
199
  });
195
200
 
196
- if (pointer.value === null)
197
- throw new Error("Failed to correct implementation code.");
201
+ if (pointer.value === null) {
202
+ return null;
203
+ }
198
204
 
199
205
  pointer.value.revise.final = await replaceImportStatements(ctx, {
200
206
  operation: props.scenario.operation,
@@ -19,6 +19,7 @@ export function getRealizeWriteImportStatements(
19
19
  'import { Prisma } from "@prisma/client";',
20
20
  'import { v4 } from "uuid";',
21
21
  'import { toISOStringSafe } from "../util/toISOStringSafe"',
22
+ 'import { HttpException } from "@nestjs/common";',
22
23
  ...typeReferences.map(
23
24
  (ref) =>
24
25
  `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
@@ -0,0 +1,156 @@
1
+ import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { AutoBeOpenApi } from "@autobe/interface";
3
+ import { StringUtil } from "@autobe/utils";
4
+ import { ILlmSchema } from "@samchon/openapi";
5
+ import { v7 } from "uuid";
6
+
7
+ import { AutoBeSystemPromptConstant } from "../../../constants/AutoBeSystemPromptConstant";
8
+ import { AutoBeContext } from "../../../context/AutoBeContext";
9
+ import { IAutoBeTestScenarioApplication } from "../structures/IAutoBeTestScenarioApplication";
10
+ import { getReferenceIds } from "../utils/getReferenceIds";
11
+
12
+ export function transformTestScenarioReviewHistories<
13
+ Model extends ILlmSchema.Model,
14
+ >(
15
+ ctx: AutoBeContext<Model>,
16
+ groups: IAutoBeTestScenarioApplication.IScenarioGroup[],
17
+ ): Array<
18
+ IAgenticaHistoryJson.ISystemMessage | IAgenticaHistoryJson.IAssistantMessage
19
+ > {
20
+ interface IRelationship {
21
+ endpoint: AutoBeOpenApi.IEndpoint;
22
+ ids: string[];
23
+ }
24
+
25
+ const document: AutoBeOpenApi.IDocument | undefined =
26
+ ctx.state().interface?.document;
27
+
28
+ if (document === undefined) {
29
+ throw new Error(
30
+ "Cannot review test scenarios because there are no operations.",
31
+ );
32
+ }
33
+
34
+ const relationships: IRelationship[] = document.operations
35
+ .map((o) => ({
36
+ endpoint: {
37
+ method: o.method,
38
+ path: o.path,
39
+ },
40
+ ids: getReferenceIds({
41
+ document,
42
+ operation: o,
43
+ }),
44
+ }))
45
+ .filter((v) => v.ids.length !== 0);
46
+
47
+ return [
48
+ {
49
+ id: v7(),
50
+ created_at: new Date().toISOString(),
51
+ type: "systemMessage",
52
+ text: AutoBeSystemPromptConstant.TEST_SCENARIO_REVIEW,
53
+ },
54
+ {
55
+ id: v7(),
56
+ created_at: new Date().toISOString(),
57
+ type: "assistantMessage",
58
+ text: StringUtil.trim`
59
+ # Available API Operations for Reference
60
+
61
+ Below are all available API operations and interface schemas for validation purposes.
62
+ Match each operation with its corresponding schema.
63
+
64
+ \`\`\`json
65
+ ${JSON.stringify({ operations: document.operations })}
66
+ \`\`\`
67
+ `,
68
+ },
69
+ {
70
+ id: v7(),
71
+ created_at: new Date().toISOString(),
72
+ type: "assistantMessage",
73
+ text: StringUtil.trim`
74
+
75
+ # Test Scenario Groups
76
+
77
+ Please review the following test scenario groups:
78
+
79
+ \`\`\`json
80
+ ${JSON.stringify(
81
+ groups.map((g) => {
82
+ return {
83
+ ...g,
84
+ scenarios: g.scenarios.map((s) => {
85
+ const requiredId: string[] = [];
86
+
87
+ s.dependencies.forEach((dep) => {
88
+ document.operations.forEach((op) => {
89
+ if (
90
+ g.endpoint.method === op.method &&
91
+ g.endpoint.path === op.path
92
+ ) {
93
+ requiredId.push(
94
+ ...getReferenceIds({ document, operation: op }),
95
+ );
96
+ }
97
+
98
+ if (
99
+ op.method === dep.endpoint.method &&
100
+ op.path === dep.endpoint.path
101
+ ) {
102
+ requiredId.push(
103
+ ...getReferenceIds({ document, operation: op }),
104
+ );
105
+ }
106
+ });
107
+ });
108
+
109
+ return {
110
+ ...s,
111
+ requiredIds:
112
+ requiredId.length > 0 ? Array.from(new Set(requiredId)) : [],
113
+ };
114
+ }),
115
+ };
116
+ }),
117
+ )}
118
+ \`\`\`
119
+ `,
120
+ },
121
+ {
122
+ id: v7(),
123
+ created_at: new Date().toISOString(),
124
+ type: "assistantMessage",
125
+ text: StringUtil.trim`
126
+ # Candidate Dependencies
127
+
128
+ List of candidate dependencies extracted from path parameters and request bodies.
129
+
130
+ Apply dependency resolution to the target endpoint from "Included in Test Plan" and to dependencies found recursively from it.
131
+ For each required ID, locate the operation that creates the resource. Include the creator only if that operation exists in the provided operations list. Do not assume or invent operations. If no creator exists, treat the ID as an external or pre-existing input.
132
+
133
+ Dependency resolution steps:
134
+ 1. Starting from the target endpoint, collect required IDs.
135
+ 2. For each ID, search for a creator operation (typically POST).
136
+ 3. If found, add it to the dependency chain in execution order and repeat for its own required IDs.
137
+ 4. Stop when no further creators exist or are needed.
138
+
139
+ For each some_entity_id pattern, use the same approach: include a creator only when it is present in the operations list.
140
+
141
+ Endpoint | Required IDs (MUST be created by other APIs)
142
+ ---------|---------------------------------------------------
143
+ ${relationships
144
+ .map((r) =>
145
+ [
146
+ `\`${r.endpoint.method} ${r.endpoint.path}\``,
147
+ r.ids.map((id) => `\`${id}\``).join(", "),
148
+ ].join(" | "),
149
+ )
150
+ .join("\n")}
151
+
152
+ Example: If an endpoint requires \`articleId\` and \`POST /articles\` exists, include it in dependencies
153
+ `,
154
+ } satisfies IAgenticaHistoryJson.IAssistantMessage,
155
+ ];
156
+ }
@@ -17,6 +17,7 @@ import { assertSchemaModel } from "../../context/assertSchemaModel";
17
17
  import { divideArray } from "../../utils/divideArray";
18
18
  import { executeCachedBatch } from "../../utils/executeCachedBatch";
19
19
  import { transformTestScenarioHistories } from "./histories/transformTestScenarioHistories";
20
+ import { orchestrateTestScenarioReview } from "./orchestrateTestScenarioReview";
20
21
  import { IAutoBeTestScenarioApplication } from "./structures/IAutoBeTestScenarioApplication";
21
22
  import { IAutoBeTestScenarioAuthorizationRole } from "./structures/IAutoBeTestScenarioAuthorizationRole";
22
23
 
@@ -31,8 +32,6 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
31
32
  );
32
33
  }
33
34
 
34
- Object.entries(document.components.schemas);
35
-
36
35
  const dict: HashMap<AutoBeOpenApi.IEndpoint, AutoBeOpenApi.IOperation> =
37
36
  new HashMap<AutoBeOpenApi.IEndpoint, AutoBeOpenApi.IOperation>(
38
37
  document.operations.map(
@@ -63,6 +62,10 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
63
62
  total: document.operations.length,
64
63
  completed: 0,
65
64
  };
65
+ const reviewProgress: AutoBeProgressEventBase = {
66
+ total: document.operations.length,
67
+ completed: 0,
68
+ };
66
69
  const exclude: IAutoBeTestScenarioApplication.IScenarioGroup[] = [];
67
70
  let include: AutoBeOpenApi.IOperation[] = [...document.operations];
68
71
  let trial: number = 0;
@@ -82,6 +85,7 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
82
85
  include,
83
86
  exclude: exclude.map((x) => x.endpoint),
84
87
  progress,
88
+ reviewProgress,
85
89
  promptCacheKey,
86
90
  })),
87
91
  );
@@ -99,6 +103,7 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
99
103
  return true;
100
104
  });
101
105
  progress.total = include.length + exclude.length;
106
+ reviewProgress.total = include.length + exclude.length;
102
107
  } while (include.length > 0 && ++trial < ctx.retry);
103
108
 
104
109
  return exclude.flatMap((pg) => {
@@ -122,6 +127,7 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
122
127
  include: AutoBeOpenApi.IOperation[];
123
128
  exclude: AutoBeOpenApi.IEndpoint[];
124
129
  progress: AutoBeProgressEventBase;
130
+ reviewProgress: AutoBeProgressEventBase;
125
131
  promptCacheKey: string;
126
132
  },
127
133
  ): Promise<IAutoBeTestScenarioApplication.IScenarioGroup[]> => {
@@ -187,7 +193,11 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
187
193
  step: ctx.state().interface?.step ?? 0,
188
194
  created_at: new Date().toISOString(),
189
195
  });
190
- return pointer.value;
196
+ return await orchestrateTestScenarioReview(
197
+ ctx,
198
+ pointer.value,
199
+ props.reviewProgress,
200
+ );
191
201
  } catch {
192
202
  return [];
193
203
  }