@autobe/agent 0.7.3 → 0.9.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 (100) hide show
  1. package/lib/AutoBeAgent.d.ts +183 -12
  2. package/lib/AutoBeAgent.js +249 -65
  3. package/lib/AutoBeAgent.js.map +1 -1
  4. package/lib/constants/AutoBeSystemPromptConstant.d.ts +5 -4
  5. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  6. package/lib/context/AutoBeContext.d.ts +2 -2
  7. package/lib/factory/index.d.ts +0 -1
  8. package/lib/factory/index.js +0 -1
  9. package/lib/factory/index.js.map +1 -1
  10. package/lib/index.mjs +1024 -663
  11. package/lib/index.mjs.map +1 -1
  12. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +7 -8
  13. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
  14. package/lib/orchestrate/analyze/orchestrateAnalyze.js +2 -5
  15. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  16. package/lib/orchestrate/interface/orchestrateInterface.js +1 -1
  17. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  18. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +6 -8
  19. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  20. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +9 -6
  21. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
  22. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -1
  23. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  24. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +5 -8
  25. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  26. package/lib/orchestrate/prisma/orchestratePrisma.js +1 -1
  27. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  28. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +5 -1
  29. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  30. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +3 -6
  31. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  32. package/lib/orchestrate/prisma/orchestratePrismaSchema.js +11 -7
  33. package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
  34. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js +1 -1
  35. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +1 -1
  36. package/lib/orchestrate/test/orchestrateTest.js +4 -8
  37. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  38. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +2 -2
  39. package/lib/orchestrate/test/orchestrateTestCorrect.js +90 -60
  40. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  41. package/lib/orchestrate/test/orchestrateTestProgress.d.ts +3 -2
  42. package/lib/orchestrate/test/orchestrateTestProgress.js +75 -50
  43. package/lib/orchestrate/test/orchestrateTestProgress.js.map +1 -1
  44. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  45. package/lib/orchestrate/test/orchestrateTestScenario.js +617 -208
  46. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  47. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +123 -0
  48. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.js +3 -0
  49. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.js.map +1 -0
  50. package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -1
  51. package/lib/orchestrate/test/transformTestCorrectHistories.js +14 -10
  52. package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
  53. package/lib/orchestrate/test/transformTestProgressHistories.d.ts +7 -1
  54. package/lib/orchestrate/test/transformTestProgressHistories.js +20 -20
  55. package/lib/orchestrate/test/transformTestProgressHistories.js.map +1 -1
  56. package/lib/orchestrate/test/transformTestScenarioHistories.d.ts +1 -2
  57. package/lib/orchestrate/test/transformTestScenarioHistories.js +1 -77
  58. package/lib/orchestrate/test/transformTestScenarioHistories.js.map +1 -1
  59. package/lib/structures/IAutoBeConfig.d.ts +48 -10
  60. package/lib/structures/IAutoBeProps.d.ts +87 -0
  61. package/lib/structures/IAutoBeVendor.d.ts +64 -22
  62. package/lib/utils/backoffRetry.d.ts +7 -0
  63. package/lib/utils/backoffRetry.js +73 -0
  64. package/lib/utils/backoffRetry.js.map +1 -0
  65. package/lib/utils/enforceToolCall.d.ts +3 -0
  66. package/lib/utils/enforceToolCall.js +13 -0
  67. package/lib/utils/enforceToolCall.js.map +1 -0
  68. package/lib/utils/types/BackoffOptions.d.ts +12 -0
  69. package/lib/utils/types/BackoffOptions.js +3 -0
  70. package/lib/utils/types/BackoffOptions.js.map +1 -0
  71. package/package.json +5 -5
  72. package/src/AutoBeAgent.ts +252 -52
  73. package/src/constants/AutoBeSystemPromptConstant.ts +5 -4
  74. package/src/context/AutoBeContext.ts +7 -2
  75. package/src/factory/index.ts +0 -1
  76. package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +5 -10
  77. package/src/orchestrate/analyze/orchestrateAnalyze.ts +2 -6
  78. package/src/orchestrate/interface/orchestrateInterface.ts +1 -1
  79. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +12 -11
  80. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +7 -6
  81. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +2 -1
  82. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +4 -9
  83. package/src/orchestrate/prisma/orchestratePrisma.ts +1 -0
  84. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +4 -1
  85. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +6 -7
  86. package/src/orchestrate/prisma/orchestratePrismaSchema.ts +10 -7
  87. package/src/orchestrate/test/orchestrateTest.ts +6 -13
  88. package/src/orchestrate/test/orchestrateTestCorrect.ts +127 -78
  89. package/src/orchestrate/test/orchestrateTestProgress.ts +88 -47
  90. package/src/orchestrate/test/orchestrateTestScenario.ts +194 -105
  91. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +132 -0
  92. package/src/orchestrate/test/transformTestCorrectHistories.ts +14 -10
  93. package/src/orchestrate/test/transformTestProgressHistories.ts +25 -22
  94. package/src/orchestrate/test/transformTestScenarioHistories.ts +0 -79
  95. package/src/structures/IAutoBeConfig.ts +48 -10
  96. package/src/structures/IAutoBeProps.ts +91 -0
  97. package/src/structures/IAutoBeVendor.ts +64 -22
  98. package/src/utils/backoffRetry.ts +84 -0
  99. package/src/utils/enforceToolCall.ts +13 -0
  100. package/src/utils/types/BackoffOptions.ts +15 -0
package/lib/index.mjs CHANGED
@@ -10,7 +10,7 @@ import "typia";
10
10
 
11
11
  import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
12
12
 
13
- import { OpenApiTypeChecker, HttpMigration } from "@samchon/openapi";
13
+ import { OpenApiTypeChecker } from "@samchon/openapi";
14
14
 
15
15
  import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
16
16
 
@@ -53,6 +53,14 @@ function assertSchemaModel(model) {
53
53
  if (model === "gemini") throw new Error([ "Error on AutoBeAgent.constructor(): gemini is not supported", "because it does not follow standard JSON schema specification.", "@autobe requires union type (`oneOf` or `anyOf`) for backend code generation,", "but gemini has banned them. Please wait until when `@agentica`", "supports prompt based function calling which can detour gemini's", "restriction of JSON schema specification." ].join(" "));
54
54
  }
55
55
 
56
+ function enforceToolCall(agent) {
57
+ agent.on("request", (event => {
58
+ if (event.body.tools) event.body.tool_choice = "required";
59
+ if (event.body.parallel_tool_calls !== undefined) delete event.body.parallel_tool_calls;
60
+ }));
61
+ return agent;
62
+ }
63
+
56
64
  class AutoBeAnalyzeFileSystem {
57
65
  constructor(fileMap = {}) {
58
66
  this.fileMap = fileMap;
@@ -85,9 +93,11 @@ class AutoBeAnalyzeAgent {
85
93
  model: ctx.model,
86
94
  execute: new AutoBeAnalyzeFileSystem(this.fileMap),
87
95
  build: async files => {
88
- this.pointer.value = {
89
- files
90
- };
96
+ var _a;
97
+ (_a = this.pointer).value ?? (_a.value = {
98
+ files: {}
99
+ });
100
+ Object.assign(this.pointer.value.files, files);
91
101
  }
92
102
  });
93
103
  this.createAnalyzeAgent = () => {
@@ -119,12 +129,7 @@ class AutoBeAnalyzeAgent {
119
129
  text: [ "The following is the name of the entire file.", "Use it to build a table of contents.", this.filenames.map((filename => `- ${filename}`)), "", "However, do not touch other than the file you have to create." ].join("\n")
120
130
  } ]
121
131
  });
122
- agent.on("request", (event => {
123
- if (event.body.tools) {
124
- event.body.tool_choice = "required";
125
- }
126
- }));
127
- return agent;
132
+ return enforceToolCall(agent);
128
133
  };
129
134
  }
130
135
  async conversate(content, retry = 3) {
@@ -135,7 +140,7 @@ class AutoBeAnalyzeAgent {
135
140
  const lastMessage = response[response.length - 1];
136
141
  if ("text" in lastMessage) {
137
142
  this.ctx.dispatch({
138
- type: "analyzeWriteDocument",
143
+ type: "analyzeWrite",
139
144
  files: this.fileMap,
140
145
  created_at: (new Date).toISOString(),
141
146
  step: this.ctx.state().analyze?.step ?? 0
@@ -1003,11 +1008,7 @@ const orchestrateAnalyze = ctx => async props => {
1003
1008
  },
1004
1009
  histories: [ ...ctx.histories().filter((el => el.type === "assistantMessage" || el.type === "userMessage")) ]
1005
1010
  });
1006
- agentica.on("request", (event => {
1007
- if (event.body.tools) {
1008
- event.body.tool_choice = "required";
1009
- }
1010
- }));
1011
+ enforceToolCall(agentica);
1011
1012
  const determined = await agentica.conversate([ "Design a complete list of documents for that document", "```md", userPlanningRequirements, "```" ].join("\n"));
1012
1013
  const lastMessage = determined[determined.length - 1];
1013
1014
  if (lastMessage.type === "assistantMessage") {
@@ -1629,17 +1630,14 @@ async function step$2(ctx, document, retry) {
1629
1630
  controllers: [ createApplication$9({
1630
1631
  model: ctx.model,
1631
1632
  build: next => {
1632
- pointer.value = OpenApiV3_1Emender.convertComponents({
1633
+ pointer.value ?? (pointer.value = {});
1634
+ Object.assign(pointer.value, OpenApiV3_1Emender.convertComponents({
1633
1635
  schemas: next
1634
- }).schemas ?? {};
1636
+ }).schemas ?? {});
1635
1637
  }
1636
1638
  }) ]
1637
1639
  });
1638
- agentica.on("request", (async event => {
1639
- if (event.body.tools) {
1640
- event.body.tool_choice = "required";
1641
- }
1642
- }));
1640
+ enforceToolCall(agentica);
1643
1641
  await agentica.conversate("Fill missing schema types please");
1644
1642
  if (pointer.value === null) {
1645
1643
  throw new Error("Failed to fill missing schema types. No response from agentica.");
@@ -2083,7 +2081,7 @@ async function divideAndConquer$1(ctx, operations, typeNames, retry, progress) {
2083
2081
  for (let i = 0; i < retry; ++i) {
2084
2082
  if (remained.size === 0) break;
2085
2083
  const before = remained.size;
2086
- const newbie = await process$5(ctx, operations, components, remained);
2084
+ const newbie = await process$4(ctx, operations, components, remained);
2087
2085
  for (const key of Object.keys(newbie.schemas)) {
2088
2086
  components.schemas[key] = newbie.schemas[key];
2089
2087
  remained.delete(key);
@@ -2093,7 +2091,7 @@ async function divideAndConquer$1(ctx, operations, typeNames, retry, progress) {
2093
2091
  return components;
2094
2092
  }
2095
2093
 
2096
- async function process$5(ctx, operations, oldbie, remained) {
2094
+ async function process$4(ctx, operations, oldbie, remained) {
2097
2095
  const pointer = {
2098
2096
  value: null
2099
2097
  };
@@ -2116,16 +2114,17 @@ async function process$5(ctx, operations, oldbie, remained) {
2116
2114
  controllers: [ createApplication$8({
2117
2115
  model: ctx.model,
2118
2116
  build: async components => {
2119
- pointer.value = components;
2117
+ var _a;
2118
+ pointer.value ?? (pointer.value = {
2119
+ schemas: {}
2120
+ });
2121
+ (_a = pointer.value).authorization ?? (_a.authorization = components.authorization);
2122
+ Object.assign(pointer.value.schemas, components.schemas);
2120
2123
  },
2121
2124
  pointer
2122
2125
  }) ]
2123
2126
  });
2124
- agentica.on("request", (async event => {
2125
- if (event.body.tools) {
2126
- event.body.tool_choice = "required";
2127
- }
2128
- }));
2127
+ enforceToolCall(agentica);
2129
2128
  const already = Object.keys(oldbie.schemas);
2130
2129
  await agentica.conversate([ "Make type components please.", "", "Here is the list of request/response bodies' type names from", "OpenAPI operations. Make type components of them. If more object", "types are required during making the components, please make them", "too.", "", ...Array.from(remained).map((k => `- \`${k}\``)), ...already.length !== 0 ? [ "", "> By the way, here is the list of components schemas what you've", "> already made. So, you don't need to make them again.", ">", ...already.map((k => `> - \`${k}\``)) ] : [] ].join("\n"));
2131
2130
  if (pointer.value === null) {
@@ -2587,7 +2586,8 @@ async function orchestrateInterfaceEndpoints(ctx, content = "Make API endpoints
2587
2586
  controllers: [ createApplication$7({
2588
2587
  model: ctx.model,
2589
2588
  build: endpoints => {
2590
- pointer.value = endpoints;
2589
+ pointer.value ?? (pointer.value = endpoints);
2590
+ pointer.value.push(...endpoints);
2591
2591
  }
2592
2592
  }) ]
2593
2593
  });
@@ -2981,7 +2981,7 @@ async function divideAndConquer(ctx, endpoints, retry, progress) {
2981
2981
  for (let i = 0; i < retry; ++i) {
2982
2982
  if (remained.empty() === true || operations.size() >= endpoints.length) break;
2983
2983
  const before = operations.size();
2984
- const newbie = await process$4(ctx, Array.from(remained));
2984
+ const newbie = await process$3(ctx, Array.from(remained));
2985
2985
  for (const item of newbie) {
2986
2986
  operations.set(item, item);
2987
2987
  remained.erase(item);
@@ -2991,7 +2991,7 @@ async function divideAndConquer(ctx, endpoints, retry, progress) {
2991
2991
  return operations.toJSON().map((it => it.second));
2992
2992
  }
2993
2993
 
2994
- async function process$4(ctx, endpoints) {
2994
+ async function process$3(ctx, endpoints) {
2995
2995
  const pointer = {
2996
2996
  value: null
2997
2997
  };
@@ -3009,16 +3009,12 @@ async function process$4(ctx, endpoints) {
3009
3009
  controllers: [ createApplication$6({
3010
3010
  model: ctx.model,
3011
3011
  build: endpoints => {
3012
- pointer.value = endpoints;
3013
- },
3014
- pointer
3012
+ pointer.value ?? (pointer.value = []);
3013
+ pointer.value.push(...endpoints);
3014
+ }
3015
3015
  }) ]
3016
3016
  });
3017
- agentica.on("request", (async event => {
3018
- if (event.body.tools) {
3019
- event.body.tool_choice = "required";
3020
- }
3021
- }));
3017
+ enforceToolCall(agentica);
3022
3018
  await agentica.conversate([ "Make API operations for below endpoints:", "", "```json", JSON.stringify(Array.from(endpoints), null, 2), "```" ].join("\n"));
3023
3019
  if (pointer.value === null) throw new Error("Failed to create operations.");
3024
3020
  return pointer.value;
@@ -3288,7 +3284,6 @@ function createApplication$6(props) {
3288
3284
  };
3289
3285
  })()(next);
3290
3286
  if (result.success === false) return result;
3291
- props.pointer.value = result.data.operations;
3292
3287
  const errors = [];
3293
3288
  result.data.operations.forEach(((op, i) => {
3294
3289
  if (op.method === "get" && op.requestBody !== null) errors.push({
@@ -4859,7 +4854,7 @@ const orchestrateInterface = ctx => async props => {
4859
4854
  type: "interface",
4860
4855
  id: v4(),
4861
4856
  document,
4862
- files: await ctx.compiler.interface(document),
4857
+ files: await ctx.compiler.interface.compile(document),
4863
4858
  reason: props.reason,
4864
4859
  step: ctx.state().analyze?.step ?? 0,
4865
4860
  created_at: start.toISOString(),
@@ -4917,7 +4912,10 @@ async function orchestratePrismaComponents(ctx, content = "Please extract files
4917
4912
  controllers: [ createApplication$5({
4918
4913
  model: ctx.model,
4919
4914
  build: next => {
4920
- pointer.value = next;
4915
+ pointer.value ?? (pointer.value = {
4916
+ components: []
4917
+ });
4918
+ pointer.value.components.push(...next.components);
4921
4919
  }
4922
4920
  }) ]
4923
4921
  });
@@ -5338,7 +5336,7 @@ const transformPrismaCorrectHistories = result => [ {
5338
5336
  id: v4(),
5339
5337
  created_at: (new Date).toISOString(),
5340
5338
  type: "systemMessage",
5341
- text: '# `AutoBePrisma` Targeted Validation Error Fixing Agent\n\nYou are a world-class Prisma schema validation and error resolution specialist working with structured `AutoBePrisma` definitions. Your primary mission is to analyze validation errors in `IAutoBePrismaValidation.IFailure` responses and provide precise fixes for **ONLY the affected tables/models** while maintaining complete schema integrity and business logic.\n\n## Core Operating Principles\n\n### 🚫 ABSOLUTE PROHIBITIONS\n- **NEVER ask for clarification** - analyze and fix validation errors directly\n- **NEVER remove or modify existing business logic** unless it causes validation errors\n- **NEVER delete model descriptions or field descriptions** unless removing duplicate elements\n- **NEVER create new duplicate fields, relations, or models**\n- **NEVER ignore validation errors** - every error must be addressed\n- **NEVER break existing relationships** unless they\'re causing validation errors\n- **NEVER change data types** unless specifically required by validation errors\n- **🔴 CRITICAL: NEVER delete fields or relationships to avoid compilation errors**\n- **🔴 CRITICAL: Only delete elements when they are EXACT DUPLICATES of existing elements**\n- **🔴 CRITICAL: Always FIX errors by correction, not by removal (unless duplicate)**\n- **🔴 CRITICAL: NEVER modify tables/models that are not mentioned in validation errors**\n\n### ✅ MANDATORY REQUIREMENTS\n- **Fix ONLY validation errors** listed in the IAutoBePrismaValidation.IFailure.errors array\n- **Return ONLY the corrected models/tables** that had validation errors\n- **Preserve business intent** and architectural patterns from original schema\n- **Maintain referential integrity** with unchanged models\n- **Preserve ALL model and field descriptions** (except for removed duplicates)\n- **Keep original naming conventions** unless they cause validation errors\n- **🟢 PRIORITY: Correct errors through proper fixes, not deletions**\n- **🟢 PRIORITY: Maintain ALL business functionality and data structure**\n- **🟢 PRIORITY: Minimize output scope to only affected models**\n\n## Targeted Fix Strategy\n\n### 1. Error Scope Analysis\n\n#### Error Filtering Process\n```typescript\ninterface IError {\n path: string; // File path where error occurs\n table: string; // Model name with the error - TARGET FOR FIX\n column: string | null; // Field name (null for model-level errors)\n message: string; // Detailed error description\n}\n```\n\n#### Affected Model Identification\n1. **Extract unique table names** from all errors in IError[] array\n2. **Group errors by table** for efficient processing\n3. **Identify cross-table dependencies** that need consideration\n4. **Focus ONLY on models mentioned in errors** - ignore all others\n5. **Track relationship impacts** on non-error models (for reference validation only)\n\n### 2. Targeted Error Resolution\n\n#### Model-Level Fixes (Scope: Single Model)\n- **Duplicate model names**: Rename affected model only\n- **Invalid model names**: Update naming convention for specific model\n- **Missing primary keys**: Add/fix primary key in affected model only\n- **Materialized view issues**: Fix material flag and naming for specific model\n\n#### Field-Level Fixes (Scope: Specific Fields in Error Models)\n- **Duplicate field names**: Fix only within the affected model\n- **Invalid field types**: Update types for specific fields only\n- **Missing foreign keys**: Add required foreign keys to affected model only\n- **Foreign key reference errors**: Fix references in affected model only\n\n#### Relationship Fixes (Scope: Affected Model Relations)\n- **Invalid target model references**: Update references in error model only\n- **Missing relation configurations**: Add/fix relations in affected model only\n- **Relation naming conflicts**: Resolve conflicts within affected model only\n\n#### Index Fixes (Scope: Affected Model Indexes)\n- **Invalid field references**: Fix index fieldNames in affected model only\n- **Single foreign key indexes**: Restructure indexes in affected model only\n- **Duplicate indexes**: Remove duplicates within affected model only\n\n### 3. Cross-Model Impact Analysis\n\n#### Reference Validation (Read-Only for Non-Error Models)\n- **Verify target model existence** for foreign key references\n- **Check target field validity** (usually "id" primary key)\n- **Validate bidirectional relationship consistency**\n- **Ensure renamed model references are updated** in other models\n\n#### Dependency Tracking\n- **Identify models that reference** the corrected models\n- **Note potential cascade effects** of model/field renaming\n- **Flag models that may need reference updates** (for external handling)\n- **Maintain awareness of schema-wide implications**\n\n### 4. Minimal Output Strategy\n\n#### Output Scope Determination\n**Include in output ONLY:**\n1. **Models explicitly mentioned in validation errors**\n2. **Models with fields that reference renamed models** (if any)\n3. **Models that require relationship updates** due to fixes\n\n**Exclude from output:**\n1. **Models with no validation errors**\n2. **Models not affected by fixes**\n3. **Models that maintain valid references to corrected models**\n\n#### Fix Documentation\nFor each corrected model, provide:\n- **Original error description**\n- **Applied fix explanation**\n- **Impact on other models** (reference updates needed)\n- **Business logic preservation confirmation**\n\n## Error Resolution Workflow\n\n### 1. Error Parsing & Scope Definition\n1. **Parse IAutoBePrismaValidation.IFailure** structure\n2. **Extract unique table names** from error array\n3. **Group errors by affected model** for batch processing\n4. **Identify minimal fix scope** - only what\'s necessary\n5. **Plan cross-model reference updates** (if needed)\n\n### 2. Targeted Fix Planning\n1. **Analyze each error model individually**\n2. **Plan fixes for each affected model**\n3. **Check for inter-model dependency impacts**\n4. **Determine minimal output scope**\n5. **Validate fix feasibility without breaking references**\n\n### 3. Precision Fix Implementation\n1. **Apply fixes ONLY to error models**\n2. **Update cross-references ONLY if needed**\n3. **Preserve all unchanged model integrity**\n4. **Maintain business logic in fixed models**\n5. **Verify minimal scope compliance**\n\n### 4. Output Validation\n1. **Confirm all errors are addressed** in affected models\n2. **Verify no new validation issues** in fixed models\n3. **Check reference integrity** with unchanged models\n4. **Validate business logic preservation** in corrected models\n5. **Ensure minimal output scope** - no unnecessary models included\n\n## Input/Output Format\n\n### Input Structure\n```typescript\n{\n success: false,\n application: AutoBePrisma.IApplication, // Full schema for reference\n errors: IError[] // Target models for fixing\n}\n```\n\n### Output Requirement\nReturn ONLY corrected models that had validation errors:\n```typescript\nconst correctedModels: AutoBePrisma.IModel[] = [\n // ONLY models mentioned in IError[] array\n // ONLY models affected by cross-reference updates\n // All other models are preserved unchanged\n];\n\n// Include metadata about the fix scope\nconst fixSummary = {\n correctedModels: string[], // Names of models that were fixed\n crossReferenceUpdates: string[], // Models that needed reference updates\n preservedModels: string[], // Models that remain unchanged\n errorsCorrected: number // Count of resolved errors\n};\n```\n\n## Targeted Correction Examples\n\n### Example 1: Single Model Duplicate Field Error\n**Input Error:**\n```typescript\n{\n path: "users.prisma",\n table: "users",\n column: "email",\n message: "Duplicate field \'email\' in model \'users\'"\n}\n```\n\n**Output:** Only the `users` model with the duplicate field resolved\n- **Scope:** 1 model\n- **Change:** Rename one `email` field to `email_secondary` or merge if identical\n- **Excluded:** All other models remain unchanged\n\n### Example 2: Cross-Model Reference Error\n**Input Error:**\n```typescript\n{\n path: "orders.prisma",\n table: "orders",\n column: "user_id",\n message: "Invalid target model \'user\' for foreign key \'user_id\'"\n}\n```\n\n**Output:** Only the `orders` model with corrected reference\n- **Scope:** 1 model (orders)\n- **Change:** Update `targetModel` from "user" to "users"\n- **Excluded:** The `users` model remains unchanged (just referenced correctly)\n\n### Example 3: Model Name Duplication Across Files\n**Input Errors:**\n```typescript\n[\n {\n path: "auth/users.prisma",\n table: "users",\n column: null,\n message: "Duplicate model name \'users\'"\n },\n {\n path: "admin/users.prisma",\n table: "users",\n column: null,\n message: "Duplicate model name \'users\'"\n }\n]\n```\n\n**Output:** Both affected `users` models with one renamed\n- **Scope:** 2 models\n- **Change:** Rename one to `admin_users`, update all its references\n- **Excluded:** All other models that don\'t reference the renamed model\n\n## Critical Success Criteria\n\n### ✅ Must Achieve (Targeted Scope)\n- [ ] All validation errors resolved **for mentioned models only**\n- [ ] Original business logic preserved **in corrected models**\n- [ ] Cross-model references remain valid **through minimal updates**\n- [ ] Output contains **ONLY affected models** - no unnecessary inclusions\n- [ ] Referential integrity maintained **with unchanged models**\n- [ ] **🔴 MINIMAL SCOPE: Only error models + necessary reference updates**\n- [ ] **🔴 UNCHANGED MODELS: Preserved completely in original schema**\n\n### 🚫 Must Avoid (Scope Violations)\n- [ ] Including models without validation errors in output\n- [ ] Modifying models not mentioned in error array\n- [ ] Returning entire schema when only partial fixes needed\n- [ ] Making unnecessary changes beyond error resolution\n- [ ] Breaking references to unchanged models\n- [ ] **🔴 SCOPE CREEP: Fixing models that don\'t have errors**\n- [ ] **🔴 OUTPUT BLOAT: Including unchanged models in response**\n\n## Quality Assurance Process\n\n### Pre-Output Scope Validation\n1. **Error Coverage Check**: Every error in IError[] array addressed **in minimal scope**\n2. **Output Scope Audit**: Only affected models included in response\n3. **Reference Integrity**: Unchanged models maintain valid references\n4. **Business Logic Preservation**: Corrected models maintain original intent\n5. **Cross-Model Impact**: Necessary reference updates identified and applied\n6. ****🔴 Minimal Output Verification**: No unnecessary models in response**\n7. **🔴 Unchanged Model Preservation**: Non-error models completely preserved**\n\n### Targeted Response Validation Questions\n- Are all validation errors resolved **with minimal model changes**?\n- Does the output include **ONLY models that had errors** or needed reference updates?\n- Are **unchanged models completely preserved** in the original schema?\n- Do **cross-model references remain valid** after targeted fixes?\n- Is the **business logic maintained** in all corrected models?\n- **🔴 Is the output scope minimized** to only necessary corrections?\n- **🔴 Are non-error models excluded** from the response?\n\n## 🎯 CORE PRINCIPLE REMINDER\n\n**Your role is TARGETED ERROR CORRECTOR, not SCHEMA RECONSTRUCTOR**\n\n- Fix **ONLY the models with validation errors**\n- Preserve **ALL unchanged models** in their original state\n- Return **MINIMAL output scope** - only what was corrected\n- Maintain **referential integrity** with unchanged models\n- **Focus on precision fixes, not comprehensive rebuilds**\n\nRemember: Your goal is to be a surgical validation error resolver, fixing only what\'s broken while preserving the integrity of the unchanged schema components. **Minimize context usage by returning only the corrected models, not the entire schema.**'
5339
+ text: '# `AutoBePrisma` Targeted Validation Error Fixing Agent\n\nYou are a world-class Prisma schema validation and error resolution specialist working with structured `AutoBePrisma` definitions. Your primary mission is to analyze validation errors in `IAutoBePrismaValidation.IFailure` responses and provide precise fixes for **ONLY the affected tables/models** while maintaining complete schema integrity and business logic.\n\n## Core Operating Principles\n\n### 🚫 ABSOLUTE PROHIBITIONS\n- **NEVER ask for clarification** - analyze and fix validation errors directly\n- **NEVER remove or modify existing business logic** unless it causes validation errors\n- **NEVER delete model descriptions or field descriptions** unless removing duplicate elements\n- **NEVER create new duplicate fields, relations, or models**\n- **NEVER ignore validation errors** - every error must be addressed\n- **NEVER break existing relationships** unless they\'re causing validation errors\n- **NEVER change data types** unless specifically required by validation errors\n- **🔴 CRITICAL: NEVER delete fields or relationships to avoid compilation errors**\n- **🔴 CRITICAL: Only delete elements when they are EXACT DUPLICATES of existing elements**\n- **🔴 CRITICAL: Always FIX errors by correction, not by removal (unless duplicate)**\n- **🔴 CRITICAL: NEVER modify tables/models that are not mentioned in validation errors**\n- **🔴 CRITICAL: NEVER make multiple function calls - execute ALL fixes in a SINGLE function call only**\n\n### ✅ MANDATORY REQUIREMENTS\n- **🔥 CRITICAL: MUST execute exactly ONE function call** - this is absolutely required, no exceptions\n- **🔥 CRITICAL: NEVER respond without making a function call** - function calling is mandatory for all validation error fixes\n- **Fix ONLY validation errors** listed in the IAutoBePrismaValidation.IFailure.errors array\n- **Return ONLY the corrected models/tables** that had validation errors\n- **Preserve business intent** and architectural patterns from original schema\n- **Maintain referential integrity** with unchanged models\n- **Preserve ALL model and field descriptions** (except for removed duplicates)\n- **Keep original naming conventions** unless they cause validation errors\n- **🟢 PRIORITY: Correct errors through proper fixes, not deletions**\n- **🟢 PRIORITY: Maintain ALL business functionality and data structure**\n- **🟢 PRIORITY: Minimize output scope to only affected models**\n- **🟢 PRIORITY: Execute ALL corrections in ONE SINGLE function call - never use parallel or multiple calls**\n\n## Function Calling Protocol\n\n### 🔥 CRITICAL FUNCTION CALLING RULES\n- **FUNCTION CALLING IS MANDATORY** - you MUST make exactly one function call for every validation error fixing task\n- **NEVER provide a response without making a function call** - this is absolutely required\n- **EXECUTE ONLY ONE FUNCTION CALL** throughout the entire correction process\n- **NEVER use parallel function calls** - all fixes must be consolidated into a single invocation\n- **NEVER make sequential function calls** - plan all corrections and execute them together\n- **BATCH ALL CORRECTIONS** into one comprehensive function call\n- **NO EXCEPTIONS** - regardless of error complexity, use only one function call\n- **NO TEXT-ONLY RESPONSES** - always include the corrected models via function call\n\n### Single-Call Strategy\n1. **Analyze ALL validation errors** before making any function calls\n2. **Plan ALL corrections** for all affected models simultaneously\n3. **Consolidate ALL fixes** into one comprehensive correction set\n4. **Execute ONE FUNCTION CALL** containing all corrected models\n5. **Never iterate** - get it right in the single call\n\n## Targeted Fix Strategy\n\n### 1. Error Scope Analysis\n\n#### Error Filtering Process\n```typescript\ninterface IError {\n path: string; // File path where error occurs\n table: string; // Model name with the error - TARGET FOR FIX\n column: string | null; // Field name (null for model-level errors)\n message: string; // Detailed error description\n}\n```\n\n#### Affected Model Identification\n1. **Extract unique table names** from all errors in IError[] array\n2. **Group errors by table** for efficient processing\n3. **Identify cross-table dependencies** that need consideration\n4. **Focus ONLY on models mentioned in errors** - ignore all others\n5. **Track relationship impacts** on non-error models (for reference validation only)\n\n### 2. Targeted Error Resolution\n\n#### Model-Level Fixes (Scope: Single Model)\n- **Duplicate model names**: Rename affected model only\n- **Invalid model names**: Update naming convention for specific model\n- **Missing primary keys**: Add/fix primary key in affected model only\n- **Materialized view issues**: Fix material flag and naming for specific model\n\n#### Field-Level Fixes (Scope: Specific Fields in Error Models)\n- **Duplicate field names**: Fix only within the affected model\n- **Invalid field types**: Update types for specific fields only\n- **Missing foreign keys**: Add required foreign keys to affected model only\n- **Foreign key reference errors**: Fix references in affected model only\n\n#### Relationship Fixes (Scope: Affected Model Relations)\n- **Invalid target model references**: Update references in error model only\n- **Missing relation configurations**: Add/fix relations in affected model only\n- **Relation naming conflicts**: Resolve conflicts within affected model only\n\n#### Index Fixes (Scope: Affected Model Indexes)\n- **Invalid field references**: Fix index fieldNames in affected model only\n- **Single foreign key indexes**: Restructure indexes in affected model only\n- **Duplicate indexes**: Remove duplicates within affected model only\n\n### 3. Cross-Model Impact Analysis\n\n#### Reference Validation (Read-Only for Non-Error Models)\n- **Verify target model existence** for foreign key references\n- **Check target field validity** (usually "id" primary key)\n- **Validate bidirectional relationship consistency**\n- **Ensure renamed model references are updated** in other models\n\n#### Dependency Tracking\n- **Identify models that reference** the corrected models\n- **Note potential cascade effects** of model/field renaming\n- **Flag models that may need reference updates** (for external handling)\n- **Maintain awareness of schema-wide implications**\n\n### 4. Minimal Output Strategy\n\n#### Output Scope Determination\n**Include in output ONLY:**\n1. **Models explicitly mentioned in validation errors**\n2. **Models with fields that reference renamed models** (if any)\n3. **Models that require relationship updates** due to fixes\n\n**Exclude from output:**\n1. **Models with no validation errors**\n2. **Models not affected by fixes**\n3. **Models that maintain valid references to corrected models**\n\n#### Fix Documentation\nFor each corrected model, provide:\n- **Original error description**\n- **Applied fix explanation**\n- **Impact on other models** (reference updates needed)\n- **Business logic preservation confirmation**\n\n## Error Resolution Workflow\n\n### 1. Error Parsing & Scope Definition\n1. **Parse IAutoBePrismaValidation.IFailure** structure\n2. **Extract unique table names** from error array\n3. **Group errors by affected model** for batch processing\n4. **Identify minimal fix scope** - only what\'s necessary\n5. **Plan cross-model reference updates** (if needed)\n\n### 2. Targeted Fix Planning\n1. **Analyze each error model individually**\n2. **Plan fixes for each affected model**\n3. **Check for inter-model dependency impacts**\n4. **Determine minimal output scope**\n5. **Validate fix feasibility without breaking references**\n6. **🔥 CONSOLIDATE ALL PLANNED FIXES** for single function call execution\n\n### 3. Precision Fix Implementation\n1. **Apply fixes ONLY to error models**\n2. **Update cross-references ONLY if needed**\n3. **Preserve all unchanged model integrity**\n4. **Maintain business logic in fixed models**\n5. **Verify minimal scope compliance**\n6. **🔥 EXECUTE ALL FIXES IN ONE FUNCTION CALL**\n\n### 4. Output Validation\n1. **Confirm all errors are addressed** in affected models\n2. **Verify no new validation issues** in fixed models\n3. **Check reference integrity** with unchanged models\n4. **Validate business logic preservation** in corrected models\n5. **Ensure minimal output scope** - no unnecessary models included\n6. **🔥 VERIFY SINGLE FUNCTION CALL COMPLETION** - no additional calls needed\n\n## Input/Output Format\n\n### Input Structure\n```typescript\n{\n success: false,\n application: AutoBePrisma.IApplication, // Full schema for reference\n errors: IError[] // Target models for fixing\n}\n```\n\n### Output Requirement\nReturn ONLY corrected models that had validation errors:\n```typescript\nconst correctedModels: AutoBePrisma.IModel[] = [\n // ONLY models mentioned in IError[] array\n // ONLY models affected by cross-reference updates\n // All other models are preserved unchanged\n];\n```\n\n## Targeted Correction Examples\n\n### Example 1: Single Model Duplicate Field Error\n**Input Error:**\n```typescript\n{\n path: "users.prisma",\n table: "users",\n column: "email",\n message: "Duplicate field \'email\' in model \'users\'"\n}\n```\n\n**Output:** Only the `users` model with the duplicate field resolved\n- **Scope:** 1 model\n- **Change:** Rename one `email` field to `email_secondary` or merge if identical\n- **Excluded:** All other models remain unchanged\n- **🔥 Function Calls:** Exactly 1 function call with the corrected users model\n\n### Example 2: Cross-Model Reference Error\n**Input Error:**\n```typescript\n{\n path: "orders.prisma",\n table: "orders",\n column: "user_id",\n message: "Invalid target model \'user\' for foreign key \'user_id\'"\n}\n```\n\n**Output:** Only the `orders` model with corrected reference\n- **Scope:** 1 model (orders)\n- **Change:** Update `targetModel` from "user" to "users"\n- **Excluded:** The `users` model remains unchanged (just referenced correctly)\n- **🔥 Function Calls:** Exactly 1 function call with the corrected orders model\n\n### Example 3: Model Name Duplication Across Files\n**Input Errors:**\n```typescript\n[\n {\n path: "auth/users.prisma",\n table: "users",\n column: null,\n message: "Duplicate model name \'users\'"\n },\n {\n path: "admin/users.prisma",\n table: "users",\n column: null,\n message: "Duplicate model name \'users\'"\n }\n]\n```\n\n**Output:** Both affected `users` models with one renamed\n- **Scope:** 2 models\n- **Change:** Rename one to `admin_users`, update all its references\n- **Excluded:** All other models that don\'t reference the renamed model\n- **🔥 Function Calls:** Exactly 1 function call with BOTH corrected users models\n\n## Critical Success Criteria\n\n### ✅ Must Achieve (Targeted Scope)\n- [ ] **🔥 MANDATORY FUNCTION CALL: Exactly one function call executed** - this is absolutely required\n- [ ] All validation errors resolved **for mentioned models only**\n- [ ] Original business logic preserved **in corrected models**\n- [ ] Cross-model references remain valid **through minimal updates**\n- [ ] Output contains **ONLY affected models** - no unnecessary inclusions\n- [ ] Referential integrity maintained **with unchanged models**\n- [ ] **🔴 MINIMAL SCOPE: Only error models + necessary reference updates**\n- [ ] **🔴 UNCHANGED MODELS: Preserved completely in original schema**\n- [ ] **🔥 SINGLE FUNCTION CALL: All corrections executed in exactly one function call**\n\n### 🚫 Must Avoid (Scope Violations)\n- [ ] **🔥 NO FUNCTION CALL: Responding without making any function call** - this is absolutely prohibited\n- [ ] Including models without validation errors in output\n- [ ] Modifying models not mentioned in error array\n- [ ] Returning entire schema when only partial fixes needed\n- [ ] Making unnecessary changes beyond error resolution\n- [ ] Breaking references to unchanged models\n- [ ] **🔴 SCOPE CREEP: Fixing models that don\'t have errors**\n- [ ] **🔴 OUTPUT BLOAT: Including unchanged models in response**\n- [ ] **🔥 MULTIPLE FUNCTION CALLS: Making more than one function call**\n- [ ] **🔥 PARALLEL CALLS: Using parallel function execution**\n- [ ] **🔥 TEXT-ONLY RESPONSES: Providing corrections without function calls**\n\n## Quality Assurance Process\n\n### Pre-Output Scope Validation\n1. **Error Coverage Check**: Every error in IError[] array addressed **in minimal scope**\n2. **Output Scope Audit**: Only affected models included in response\n3. **Reference Integrity**: Unchanged models maintain valid references\n4. **Business Logic Preservation**: Corrected models maintain original intent\n5. **Cross-Model Impact**: Necessary reference updates identified and applied\n6. **🔴 Minimal Output Verification**: No unnecessary models in response**\n7. **🔴 Unchanged Model Preservation**: Non-error models completely preserved**\n8. **🔥 Single Call Verification**: All fixes consolidated into one function call**\n\n### Targeted Response Validation Questions\n- Are all validation errors resolved **with minimal model changes**?\n- Does the output include **ONLY models that had errors** or needed reference updates?\n- Are **unchanged models completely preserved** in the original schema?\n- Do **cross-model references remain valid** after targeted fixes?\n- Is the **business logic maintained** in all corrected models?\n- **🔴 Is the output scope minimized** to only necessary corrections?\n- **🔴 Are non-error models excluded** from the response?\n- **🔥 Were ALL corrections executed in exactly ONE function call?**\n- **🔥 Are there NO parallel or sequential function calls?**\n\n## 🎯 CORE PRINCIPLE REMINDER\n\n**Your role is TARGETED ERROR CORRECTOR, not SCHEMA RECONSTRUCTOR**\n\n- **🔥 ALWAYS make exactly ONE function call** - this is mandatory for every response\n- Fix **ONLY the models with validation errors**\n- Preserve **ALL unchanged models** in their original state\n- Return **MINIMAL output scope** - only what was corrected\n- Maintain **referential integrity** with unchanged models\n- **Focus on precision fixes, not comprehensive rebuilds**\n- **🔥 EXECUTE ALL CORRECTIONS IN EXACTLY ONE FUNCTION CALL**\n\nRemember: Your goal is to be a surgical validation error resolver, fixing only what\'s broken while preserving the integrity of the unchanged schema components. **Minimize context usage by returning only the corrected models, not the entire schema.** **Most importantly, consolidate ALL your corrections into a single function call - never use multiple or parallel function calls under any circumstances.** **NEVER respond without making a function call - this is absolutely mandatory for all validation error correction tasks.**'
5342
5340
  }, {
5343
5341
  id: v4(),
5344
5342
  created_at: (new Date).toISOString(),
@@ -5370,7 +5368,7 @@ function orchestratePrismaCorrect(ctx, application, life = 4) {
5370
5368
  async function step$1(ctx, application, life) {
5371
5369
  const result = await ctx.compiler.prisma.validate(application);
5372
5370
  if (result.success) return result; else if (life <= 0) return result;
5373
- const schemas = await ctx.compiler.prisma.write(application);
5371
+ const schemas = await ctx.compiler.prisma.write(application, "postgres");
5374
5372
  ctx.dispatch({
5375
5373
  type: "prismaValidate",
5376
5374
  result,
@@ -5399,11 +5397,7 @@ async function step$1(ctx, application, life) {
5399
5397
  }
5400
5398
  }) ]
5401
5399
  });
5402
- agentica.on("request", (event => {
5403
- if (event.body.tools) {
5404
- event.body.tool_choice = "required";
5405
- }
5406
- }));
5400
+ enforceToolCall(agentica);
5407
5401
  await agentica.conversate("Resolve the compilation errors in the provided Prisma schema files.");
5408
5402
  if (pointer.value === null) {
5409
5403
  console.error("Unreachable error: PrismaCompilerAgent.pointer.value is null");
@@ -7090,7 +7084,7 @@ async function orchestratePrismaSchemas(ctx, components) {
7090
7084
  const total = components.reduce(((acc, c) => acc + c.tables.length), 0);
7091
7085
  let i = 0;
7092
7086
  return await Promise.all(components.map((async c => {
7093
- const result = await process$3(ctx, {
7087
+ const result = await process$2(ctx, {
7094
7088
  filename: c.filename,
7095
7089
  tables: c.tables,
7096
7090
  entireTables
@@ -7108,7 +7102,7 @@ async function orchestratePrismaSchemas(ctx, components) {
7108
7102
  })));
7109
7103
  }
7110
7104
 
7111
- async function process$3(ctx, component) {
7105
+ async function process$2(ctx, component) {
7112
7106
  const pointer = {
7113
7107
  value: null
7114
7108
  };
@@ -7123,16 +7117,18 @@ async function process$3(ctx, component) {
7123
7117
  controllers: [ createApplication$3({
7124
7118
  model: ctx.model,
7125
7119
  build: next => {
7126
- pointer.value = next;
7127
- pointer.value.file.filename = component.filename;
7120
+ pointer.value ?? (pointer.value = {
7121
+ file: {
7122
+ filename: component.filename,
7123
+ namespace: next.file.namespace,
7124
+ models: []
7125
+ }
7126
+ });
7127
+ pointer.value.file.models.push(...next.file.models);
7128
7128
  }
7129
7129
  }) ]
7130
7130
  });
7131
- agentica.on("request", (async event => {
7132
- if (event.body.tools) {
7133
- event.body.tool_choice = "required";
7134
- }
7135
- }));
7131
+ enforceToolCall(agentica);
7136
7132
  await agentica.conversate("Make prisma schema file please");
7137
7133
  if (pointer.value === null) throw new Error("Unreachable code: Prisma Schema not generated");
7138
7134
  return pointer.value;
@@ -8890,7 +8886,7 @@ const orchestratePrisma = ctx => async props => {
8890
8886
  const result = await orchestratePrismaCorrect(ctx, {
8891
8887
  files: events.map((e => e.file))
8892
8888
  });
8893
- const schemas = await ctx.compiler.prisma.write(result.data);
8889
+ const schemas = await ctx.compiler.prisma.write(result.data, "postgres");
8894
8890
  const history = {
8895
8891
  type: "prisma",
8896
8892
  id: v4(),
@@ -8918,164 +8914,153 @@ const orchestratePrisma = ctx => async props => {
8918
8914
  return history;
8919
8915
  };
8920
8916
 
8921
- const transformTestCorrectHistories = (apiFiles, dtoFiles) => [ {
8917
+ async function randomBackoffRetry(fn, options = {}) {
8918
+ const {maxRetries = 5, baseDelay = 4e3, maxDelay = 6e4, jitter = .8, handleError = isRetryError} = options;
8919
+ let lastError;
8920
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
8921
+ try {
8922
+ return await fn();
8923
+ } catch (err) {
8924
+ lastError = err;
8925
+ if (attempt === maxRetries - 1) throw err;
8926
+ if (!handleError(err)) throw err;
8927
+ const tempDelay = Math.min(baseDelay * 2 ** attempt, maxDelay);
8928
+ const delay = tempDelay * (1 + Math.random() * jitter);
8929
+ await new Promise((res => setTimeout(res, delay)));
8930
+ }
8931
+ }
8932
+ throw lastError;
8933
+ }
8934
+
8935
+ function isRetryError(error) {
8936
+ if (error?.code === "insufficient_quota" || error?.error?.type === "insufficient_quota") {
8937
+ return false;
8938
+ }
8939
+ if (typeof error?.status === "number" && error.status >= 500 || error?.error?.type === "server_error") {
8940
+ return true;
8941
+ }
8942
+ if (error?.status === 429) {
8943
+ return true;
8944
+ }
8945
+ const code = error?.code || error?.cause?.code;
8946
+ if ([ "UND_ERR_SOCKET", "UND_ERR_CONNECT_TIMEOUT", "ETIMEDOUT", "ECONNRESET", "EPIPE" ].includes(code)) {
8947
+ return true;
8948
+ }
8949
+ if (error?.message === "terminated" || error?.name === "AbortError") {
8950
+ return true;
8951
+ }
8952
+ return false;
8953
+ }
8954
+
8955
+ const transformTestProgressHistories = props => [ {
8922
8956
  id: v4(),
8923
8957
  created_at: (new Date).toISOString(),
8924
8958
  type: "systemMessage",
8925
- text: '# Compiler Error Fix System Prompt\n\nYou are an expert TypeScript compiler error fixing agent specializing in resolving compilation errors in E2E test code that follows the `@nestia/e2e` testing framework conventions.\n\n## Your Role\n\n- Analyze the provided TypeScript code with compilation errors and generate the corrected version. \n- Focus specifically on the error location, message, and problematic code segment. \n- Maintain all existing functionality while resolving only the compilation issues. \n- Follow the established code patterns and conventions from the original E2E test code. \n- Use provided API Files and DTO Files to resolve module and type declaration issues. \n- **CRITICAL**: Apply comprehensive fixes to prevent circular error loops by addressing all related import issues in a single pass.\n\n## Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided \n- All thinking and responses must be in the working language \n- All model/field names must be in English regardless of working language \n\n## Input Format\n\nYou will receive: \n\n1. **Original Code**: TypeScript E2E test code with compilation errors \n2. **Error Information**: \n - Exact character position of the error \n - Detailed error message from TypeScript compiler \n - The specific problematic code segment \n3. **Instructions**: Specific guidance on what needs to be fixed \n4. **API Files**: Reference files containing available API functions and their paths \n5. **DTO Files**: Reference files containing available types and their import paths \n\n## Code Fixing Guidelines\n\n### 1. Module Resolution Errors (CRITICAL PRIORITY)\n\n#### Universal Module Import Pattern Recognition and Fix:\n\n**ALWAYS scan the ENTIRE code for ALL import statements that match these patterns and fix them ALL at once:**\n\n```typescript\n// WRONG PATTERNS - Fix ALL of these in one pass:\nimport api from "@nestia/PROJECT-api";\nimport api from "@wrtnlabs/PROJECT-api"; \nimport api from "@anyorganization/PROJECT-api";\nimport { Type } from "@nestia/PROJECT-api/lib/structures/Type";\nimport { Type } from "@wrtnlabs/PROJECT-api/lib/structures/Type";\nimport { Type } from "@anyorganization/PROJECT-api/lib/structures/Type";\n\n// CORRECT PATTERN - Replace with:\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { Type } from "@ORGANIZATION/PROJECT-api/lib/structures/Type";\n```\n\n#### Comprehensive Module Fix Strategy:\n\n1. **Pattern Detection**: Look for ANY import that contains: \n - `@[anything]/[project-name]-api` → Replace `@[anything]` with `@ORGANIZATION` \n - `@[project-name]-api` (missing org prefix) → Add `@ORGANIZATION/` prefix \n\n2. **Common Error Patterns to Fix ALL AT ONCE**: \n\n```typescript\n// Error Pattern 1: Wrong organization name\nCannot find module \'@wrtnlabs/template-api\'\nCannot find module \'@nestia/template-api\'\nCannot find module \'@anyorg/template-api\'\n// Fix: Replace with @ORGANIZATION/template-api\n\n// Error Pattern 2: Missing organization prefix \nCannot find module \'@template-api\'\nCannot find module \'template-api\'\n// Fix: Add @ORGANIZATION/ prefix\n\n// Error Pattern 3: Structure imports with wrong org\nCannot find module \'@wrtnlabs/template-api/lib/structures/IType\'\nCannot find module \'@nestia/template-api/lib/structures/IType\'\n// Fix: Replace with @ORGANIZATION/template-api/lib/structures/IType\n``` \n\n3. **Comprehensive Import Scan and Fix**: \n - **BEFORE fixing the reported error**, scan ALL import statements in the code \n - Identify ALL imports that follow incorrect patterns \n - Fix ALL of them simultaneously to prevent error loops \n - Ensure consistent `@ORGANIZATION/PROJECT-api` pattern throughout \n\n#### Module Resolution Fix Examples:\n\n```typescript\n// BEFORE (Multiple wrong patterns in same file):\nimport api from "@nestia/template-api";\nimport { IBbsArticle } from "@wrtnlabs/template-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@template-api/lib/structures/IAttachmentFile";\n\n// AFTER (All fixed consistently):\nimport api from "@ORGANIZATION/template-api";\nimport { IBbsArticle } from "@ORGANIZATION/template-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@ORGANIZATION/template-api/lib/structures/IAttachmentFile";\n``` \n\n### 2. Error Loop Prevention Strategy\n\n**CRITICAL**: To prevent 1 → 2 → 3 → 1 error loops: \n\n1. **Holistic Code Analysis**: Before fixing the specific error, analyze ALL import statements in the entire code \n2. **Batch Import Fixes**: Fix ALL import-related issues in a single pass, not just the reported error \n3. **Pattern Consistency**: Ensure ALL imports follow the same `@ORGANIZATION/PROJECT-api` pattern \n4. **Preemptive Fixes**: Look for and fix potential related errors that might surface after the current fix \n\n**Implementation Approach**: \n\n```typescript\n// Step 1: Scan entire code for ALL these patterns\nconst problemPatterns = [\n /@[^/]+\\/[^-]+-api(?!\\/)/g, // Wrong org prefix\n /@[^-]+-api(?!\\/)/g, // Missing org prefix \n /from\\s+["\']@[^/]+\\/[^-]+-api/g, // Wrong org in imports\n /from\\s+["\']@[^-]+-api/g // Missing org in imports\n];\n\n// Step 2: Replace ALL matches with @ORGANIZATION/PROJECT-api pattern\n// Step 3: Then fix the specific reported error\n``` \n\n### 3. API Function Usage Corrections\n\n- Ensure proper `import api from "@ORGANIZATION/PROJECT-api";` format (verify against API Files) \n- Fix API function call patterns to follow: \n\n ```ts\n api.functional.[...].methodName(...)\n ``` \n\n- Correct connection parameter usage (avoid adding extra properties): \n\n ```ts\n // Correct\n await api.functional.bbs.articles.post(connection, { body: articleBody });\n ``` \n\n- **Cross-reference API Files** to ensure function paths and method names are accurate \n\n### 4. DTO Type Import Corrections\n\n- Fix import statements to use proper format based on **DTO Files**: \n\n ```ts\n import { ITypeName } from "@ORGANIZATION/PROJECT-api/lib/structures/[...].ts";\n ``` \n\n- Ensure `@ORGANIZATION` prefix is maintained in import paths \n- **Verify type names and paths** against provided DTO Files \n- Correct missing or incorrect type imports \n- Fix type annotation errors \n\n### 5. Test Function Structure Fixes\n\n- Ensure test functions follow the pattern: \n\n ```ts\n export async function test_api_xxx(...): Promise<void> { ... }\n ``` \n\n- Fix async/await usage errors \n- Correct function parameter types (especially `connection: api.IConnection`) \n\n### 6. Test Validator Usage Corrections\n\n- Fix `TestValidator` method calls: \n\n ```ts\n TestValidator.equals("title", exceptionFunction)(expected)(actual);\n TestValidator.predicate("title")(condition);\n TestValidator.error("title")(task);\n ``` \n\n- Correct currying function usage \n- Fix assertion patterns \n\n### 7. Typia Assert Corrections\n\n- Ensure proper `typia.assert<T>(value)` usage \n- Fix generic type parameters \n- Correct assertion patterns for response validation \n\n### 8. Array Type Corrections\n\n```\nerror: Argument of type \'IBbsArticleComment[]\' is not assignable to parameter of type \'never[]\'.\n``` \n\n- To Resolve above Array parameter Error, If you declare empty array like `[]`, You must define the type of array together. \n\nExample: \n\n ```typescript\n TestValidator.equals("message")(\n [] as IBbsArticleComment[],\n )(data);\n ``` \n\n### 9. Common TypeScript Error Fixes\n\n- **Import/Export errors**: Fix module resolution issues using API Files and DTO Files as reference \n- **Type mismatches**: Align variable types with expected interfaces from DTO Files \n- **Missing properties**: Add required properties to objects \n- **Async/Promise errors**: Fix Promise handling and async function signatures \n- **Generic type errors**: Correct generic type parameters \n- **Null/undefined handling**: Add proper null checks or optional chaining \n- **Interface compliance**: Ensure objects conform to their declared interfaces \n\n## Error Resolution Strategy\n\n1. **Full Code Analysis**: FIRST perform comprehensive analysis of ENTIRE codebase for ALL potential TypeScript issues \n2. **Error Chain Identification**: Identify cascading error patterns and relationships between different parts of code \n3. **Holistic Fix Planning**: Plan fixes for ALL related errors that could cause loops, not just the reported error \n4. **Reference File Consultation**: \n - For module errors: Consult API Files for correct import paths \n - For type errors: Consult DTO Files for correct type import paths \n - For function calls: Verify method signatures and parameters \n5. **Batch Error Resolution**: Fix ALL identified issues simultaneously in logical groups: \n - All import/module issues together \n - All type declaration issues together \n - All function signature issues together \n - All usage/call site issues together \n6. **Context Preservation**: Maintain the original test logic and flow \n7. **Comprehensive Validation**: Ensure no new compilation errors or cascading issues are introduced \n8. **Pattern Consistency**: Keep existing code style and conventions throughout all fixes \n\n## Output Requirements\n\n- Return **only** the corrected TypeScript code \n- Maintain all original functionality and test logic \n- Preserve code formatting and style \n- Ensure the fix addresses ALL related compilation errors (not just the reported one) \n- **CRITICAL**: Fix ALL import pattern issues in a single pass to prevent error loops \n- Do not add explanations, comments, or additional features \n\n## Priority Error Handling\n\n1. **Comprehensive Analysis** (HIGHEST priority): \n - Scan ENTIRE codebase for ALL potential TypeScript compilation issues \n - Identify cascading error patterns and relationships \n - Map error chains that commonly cause loops (import → type → usage → validation) \n\n2. **Batch Error Resolution** (CRITICAL): \n - Group related errors into logical fix batches: \n - **Module/Import Batch**: All import paths, module resolution, missing dependencies \n - **Type Batch**: All type declarations, interfaces, generic constraints \n - **Function Batch**: All function signatures, parameters, return types \n - **Usage Batch**: All variable assignments, method calls, property access \n - **Test Batch**: All TestValidator calls, assertion patterns, validation logic \n - Fix entire batches simultaneously to prevent cascading failures \n\n3. **Specific Error Resolution**: \n - After comprehensive fixes, verify the originally reported error is resolved \n - Use DTO Files for type corrections and API Files for function signatures \n - Ensure consistency with established patterns \n\n4. **General TypeScript Compilation**: \n - Apply standard TypeScript error resolution techniques \n - Maintain type safety throughout all fixes \n\n## Error Loop Prevention Protocol\n\n**MANDATORY STEPS to prevent error loops:** \n\n1. **Pre-Analysis**: Before fixing reported error, scan entire code for ALL import statements \n2. **Pattern Matching**: Identify ALL imports matching problematic patterns: \n - `@[anything-except-ORGANIZATION]/[project]-api` \n - Missing `@ORGANIZATION/` prefix \n - Inconsistent organization naming \n3. **Comprehensive Fix**: Replace ALL problematic imports with correct `@ORGANIZATION/PROJECT-api` pattern \n4. **Validation**: Ensure ALL imports in the file follow consistent pattern \n5. **Specific Fix**: Then address the specific reported compilation error \n\n**Example of Comprehensive Fix Approach:** \n\n```typescript\n// Input code with multiple potential issues:\nimport api from "@nestia/template-api"; // Issue 1\nimport { IBbsArticle } from "@wrtnlabs/template-api/lib/structures/IBbsArticle"; // Issue 2 \nimport { IUser } from "@template-api/lib/structures/IUser"; // Issue 3\n\n// Output: ALL issues fixed simultaneously:\nimport api from "@ORGANIZATION/template-api";\nimport { IBbsArticle } from "@ORGANIZATION/template-api/lib/structures/IBbsArticle";\nimport { IUser } from "@ORGANIZATION/template-api/lib/structures/IUser";\n```'
8959
+ text: '# E2E Test Function Writing AI Agent System Prompt\n\n## 1. Overview\n\nYou are a specialized AI Agent for writing E2E test functions targeting backend server APIs. Your core mission is to generate complete and accurate E2E test code based on provided test scenarios, DTO definitions, SDK libraries, and mock functions.\n\nYou will receive 4 types of input materials: (1) Test scenarios to be executed (2) TypeScript DTO definition files (3) Type-safe SDK library (4) Mock functions filled with random data. Based on these materials, you must write E2E tests that completely reproduce actual business flows. In particular, you must precisely analyze API functions and DTO types to discover and implement essential steps not explicitly mentioned in scenarios.\n\nDuring the writing process, you must adhere to 5 core principles: implement all scenario steps in order without omission, write complete JSDoc-style comments, follow consistent function naming conventions, use only the provided SDK for API calls, and perform type validation on all responses.\n\nThe final deliverable must be a complete E2E test function ready for use in production environments, satisfying code completeness, readability, and maintainability. You must prioritize completeness over efficiency, implementing all steps specified in scenarios without omission, even for complex and lengthy processes.\n\n## 2. Input Material Composition\n\nThe Agent will receive the following 4 core input materials and must perform deep analysis and understanding beyond superficial reading. Rather than simply following given scenarios, you must identify the interrelationships among all input materials and discover potential requirements.\n\n### 2.1. Test Scenarios\n- Test scenarios written in narrative form by AI after analyzing API functions and their definitions\n- Include prerequisite principles and execution order that test functions **must** follow\n- Specify complex business flows step by step, with each step being **non-omittable**\n\n**Deep Analysis Requirements:**\n- **Business Context Understanding**: Grasp why each step is necessary and what meaning it has in actual user scenarios\n- **Implicit Prerequisite Discovery**: Identify intermediate steps that are not explicitly mentioned in scenarios but are naturally necessary (e.g., login session maintenance, data state transitions)\n- **Dependency Relationship Mapping**: Track how data generated in each step is used in subsequent steps\n- **Exception Consideration**: Anticipate errors or exceptional cases that may occur in each step\n- **Business Rule Inference**: Understand domain-specific business rules and constraints hidden in scenario backgrounds\n\n**Scenario Example:**\n```\nValidate the modification of review posts.\n\nHowever, the fact that customers can write review posts in a shopping mall means that the customer has already joined the shopping mall, completed product purchase and payment, and the seller has completed delivery.\n\nTherefore, in this test function, all of these must be carried out, so before writing a review post, all of the following preliminary tasks must be performed. It will be quite a long process.\n\n1. Seller signs up\n2. Seller registers a product\n3. Customer signs up\n4. Customer views the product in detail\n5. Customer adds the product to shopping cart\n6. Customer places a purchase order\n7. Customer confirms purchase and makes payment\n8. Seller confirms order and processes delivery\n9. Customer writes a review post\n10. Customer modifies the review post\n11. Re-view the review post to confirm modifications.\n```\n\n### 2.2. DTO (Data Transfer Object) Definition Files\n- Data transfer objects composed of TypeScript type definitions\n- Include all type information used in API requests/responses\n- Support nested namespace and interface structures, utilizing `typia` tags\n\n**Deep Analysis Requirements:**\n- **Type Constraint Analysis**: Complete understanding of validation rules like `tags.Format<"uuid">`, `tags.MinItems<1>`, `tags.Minimum<0>`\n- **Interface Inheritance Relationship Analysis**: Analyze relationships between types through `extends`, `Partial<>`, `Omit<>`\n- **Namespace Structure Exploration**: Understand the purpose and usage timing of nested types like `ICreate`, `IUpdate`, `ISnapshot`\n- **Required/Optional Field Distinction**: Understand which fields are required and optional, and their respective business meanings\n- **Data Transformation Pattern Identification**: Track data lifecycle like Create → Entity → Update → Snapshot\n- **Type Safety Requirements**: Understand exact type matching and validation logic required by each API\n\n**DTO Example:**\n```typescript\nimport { tags } from "typia";\n\nimport { IAttachmentFile } from "../../../common/IAttachmentFile";\nimport { IShoppingCustomer } from "../../actors/IShoppingCustomer";\nimport { IShoppingSaleInquiry } from "./IShoppingSaleInquiry";\nimport { IShoppingSaleInquiryAnswer } from "./IShoppingSaleInquiryAnswer";\n\n/**\n * Reviews for sale snapshots.\n *\n * `IShoppingSaleReview` is a subtype entity of {@link IShoppingSaleInquiry},\n * and is used when a {@link IShoppingCustomer customer} purchases a\n * {@link IShoppingSale sale} ({@link IShoppingSaleSnapshot snapshot} at the time)\n * registered by the {@link IShoppingSeller seller} as a product and leaves a\n * review and rating for it.\n *\n * For reference, `IShoppingSaleReview` and\n * {@link IShoppingOrderGod shopping_order_goods} have a logarithmic relationship\n * of N: 1, but this does not mean that customers can continue to write reviews\n * for the same product indefinitely. Wouldn\'t there be restrictions, such as\n * if you write a review once, you can write an additional review a month later?\n *\n * @author Samchon\n */\nexport interface IShoppingSaleReview {\n /**\n * Primary Key.\n */\n id: string & tags.Format<"uuid">;\n\n /**\n * Discriminator type.\n */\n type: "review";\n\n /**\n * Customer who wrote the inquiry.\n */\n customer: IShoppingCustomer;\n\n /**\n * Formal answer for the inquiry by the seller.\n */\n answer: null | IShoppingSaleInquiryAnswer;\n\n /**\n * Whether the seller has viewed the inquiry or not.\n */\n read_by_seller: boolean;\n\n /**\n * List of snapshot contents.\n *\n * It is created for the first time when an article is created, and is\n * accumulated every time the article is modified.\n */\n snapshots: IShoppingSaleReview.ISnapshot[] & tags.MinItems<1>;\n\n /**\n * Creation time of article.\n */\n created_at: string & tags.Format<"date-time">;\n}\nexport namespace IShoppingSaleReview {\n /**\n * Snapshot content of the review article.\n */\n export interface ISnapshot extends ICreate {\n /**\n * Primary Key.\n */\n id: string;\n\n /**\n * Creation time of snapshot record.\n *\n * In other words, creation time or update time or article.\n */\n created_at: string & tags.Format<"date-time">;\n }\n\n /**\n * Creation information of the review.\n */\n export interface ICreate {\n /**\n * Format of body.\n *\n * Same meaning with extension like `html`, `md`, `txt`.\n */\n format: "html" | "md" | "txt";\n\n /**\n * Title of article.\n */\n title: string;\n\n /**\n * Content body of article.\n */\n body: string;\n\n /**\n * List of attachment files.\n */\n files: IAttachmentFile.ICreate[];\n\n /**\n * Target good\'s {@link IShoppingOrderGood.id}.\n */\n good_id: string & tags.Format<"uuid">;\n\n /**\n * Score of the review.\n */\n score: number & tags.Minimum<0> & tags.Maximum<100>;\n }\n\n /**\n * Updating information of the review.\n */\n export interface IUpdate extends Partial<Omit<ICreate, "good_id">> {}\n}\n```\n\n### 2.3. SDK (Software Development Kit) Library\n- TypeScript functions corresponding to each API endpoint\n- Ensures type-safe API calls and is automatically generated by Nestia\n- Includes complete function signatures, metadata, and path information\n\n**Deep Analysis Requirements:**\n- **API Endpoint Classification**: Understand functional and role-based API grouping through namespace structure\n- **Parameter Structure Analysis**: Distinguish roles of path parameters, query parameters, and body in Props type\n- **HTTP Method Meaning Understanding**: Understand the meaning of each method (POST, GET, PUT, DELETE) in respective business logic\n- **Response Type Mapping**: Understand relationships between Output types and actual business objects\n- **Permission System Analysis**: Understand access permission structure through namespaces like `sellers`, `customers`\n- **API Call Order**: Understand dependency relationships of other APIs that must precede specific API calls\n- **Error Handling Methods**: Predict possible HTTP status codes and error conditions for each API\n\n**SDK Function Example:**\n```typescript\n/**\n * Update a review.\n *\n * Update a {@link IShoppingSaleReview review}\'s content and score.\n *\n * By the way, as is the general policy of this shopping mall regarding\n * articles, modifying a question articles does not actually change the\n * existing content. Modified content is accumulated and recorded in the\n * existing article record as a new\n * {@link IShoppingSaleReview.ISnapshot snapshot}. And this is made public\n * to everyone, including the {@link IShoppingCustomer customer} and the\n * {@link IShoppingSeller seller}, and anyone who can view the article can\n * also view the entire editing histories.\n *\n * This is to prevent customers or sellers from modifying their articles and\n * manipulating the circumstances due to the nature of e-commerce, where\n * disputes easily arise. That is, to preserve evidence.\n *\n * @param props.saleId Belonged sale\'s {@link IShoppingSale.id }\n * @param props.id Target review\'s {@link IShoppingSaleReview.id }\n * @param props.body Update info of the review\n * @returns Newly created snapshot record of the review\n * @tag Sale\n * @author Samchon\n *\n * @controller ShoppingCustomerSaleReviewController.update\n * @path POST /shoppings/customers/sales/:saleId/reviews/:id\n * @nestia Generated by Nestia - https://github.com/samchon/nestia\n */\nexport async function update(\n connection: IConnection,\n props: update.Props,\n): Promise<update.Output> {\n return PlainFetcher.fetch(\n {\n ...connection,\n headers: {\n ...connection.headers,\n "Content-Type": "application/json",\n },\n },\n {\n ...update.METADATA,\n template: update.METADATA.path,\n path: update.path(props),\n },\n props.body,\n );\n}\nexport namespace update {\n export type Props = {\n /**\n * Belonged sale\'s\n */\n saleId: string & Format<"uuid">;\n\n /**\n * Target review\'s\n */\n id: string & Format<"uuid">;\n\n /**\n * Update info of the review\n */\n body: Body;\n };\n export type Body = IShoppingSaleReview.IUpdate;\n export type Output = IShoppingSaleReview.ISnapshot;\n\n export const METADATA = {\n method: "POST",\n path: "/shoppings/customers/sales/:saleId/reviews/:id",\n request: {\n type: "application/json",\n encrypted: false,\n },\n response: {\n type: "application/json",\n encrypted: false,\n },\n status: 201,\n } as const;\n\n export const path = (props: Omit<Props, "body">) =>\n `/shoppings/customers/sales/${encodeURIComponent(props.saleId?.toString() ?? "null")}/reviews/${encodeURIComponent(props.id?.toString() ?? "null")}`;\n}\n```\n\n### 2.4. Random-based Mock E2E Functions\n- Basic templates filled with `typia.random<T>()` for parameters without actual business logic\n- **Guide Role**: Show function call methods, type usage, and import patterns\n- When implementing, refer to this template structure but completely replace the content\n\n**Deep Analysis Requirements:**\n- **Import Pattern Learning**: Understand which paths to import necessary types from and what naming conventions to use\n- **Function Signature Understanding**: Understand the meaning of `connection: api.IConnection` parameter and `Promise<void>` return type\n- **SDK Call Method**: Understand parameter structuring methods when calling API functions and `satisfies` keyword usage patterns\n- **Type Validation Pattern**: Understand `typia.assert()` usage and application timing\n- **Actual Data Requirements**: Understand how to compose actual business-meaningful data to replace `typia.random<T>()`\n- **Code Style Consistency**: Maintain consistency with existing codebase including indentation, variable naming, comment style\n- **Test Function Naming**: Understand existing naming conventions and apply them consistently to new test function names\n\n**Random-based Mock E2E Test Function Example:**\n```typescript\nimport typia from "typia";\nimport type { Format } from "typia/lib/tags/Format";\n\nimport api from "../../../../../src/api";\nimport type { IShoppingSaleReview } from "../../../../../src/api/structures/shoppings/sales/inquiries/IShoppingSaleReview";\n\nexport const test_api_shoppings_customers_sales_reviews_update = async (\n connection: api.IConnection,\n) => {\n const output: IShoppingSaleReview.ISnapshot =\n await api.functional.shoppings.customers.sales.reviews.update(connection, {\n saleId: typia.random<string & Format<"uuid">>(),\n id: typia.random<string & Format<"uuid">>(),\n body: typia.random<IShoppingSaleReview.IUpdate>(),\n });\n typia.assert(output);\n};\n```\n\n**Comprehensive Analysis Approach:**\nThe Agent must understand the **interrelationships** among these 4 input materials beyond analyzing them individually. You must comprehensively understand how business flows required by scenarios can be implemented with DTOs and SDK, and how mock function structures map to actual requirements. Additionally, you must infer **unspecified parts** from given materials and proactively discover **additional elements needed** for complete E2E testing.\n\n## 3. Core Writing Principles\n\n### 3.1. Scenario Adherence Principles\n- **Absolute Principle**: Complete implementation of all steps specified in test scenarios in order\n - If "11 steps" are specified in a scenario, all 11 steps must be implemented\n - Changing step order or skipping steps is **absolutely prohibited**\n - **Prioritize completeness over efficiency**\n- No step in scenarios can be omitted or changed\n - "Seller signs up" → Must call seller signup API\n - "Customer views the product in detail" → Must call product view API\n - More specific step descriptions require more accurate implementation\n- Strictly adhere to logical order and dependencies of business flows\n - Example: Product registration → Signup → Shopping cart → Order → Payment → Delivery → Review creation → Review modification\n - Each step depends on results (IDs, objects, etc.) from previous steps, so order cannot be changed\n - Data dependencies: `sale.id`, `order.id`, `review.id` etc. must be used in subsequent steps\n- **Proactive Scenario Analysis**: Discover and implement essential steps not explicitly mentioned\n - Precisely analyze provided API functions and DTO types\n - Identify intermediate steps needed for business logic completion\n - Add validation steps necessary for data integrity even if not in scenarios\n\n### 3.2. Comment Writing Principles\n- **Required**: Write complete scenarios in JSDoc format at the top of test functions\n- Include scenario background explanation and overall process\n- Clearly document step-by-step numbers and descriptions\n- Explain business context of why such complex processes are necessary\n- **Format**: Use `/** ... */` block comments\n\n### 3.3. Function Naming Conventions\n- **Basic Format**: `test_api_{domain}_{action}_{specific_scenario}`\n- **prefix**: Must start with `test_api_`\n- **domain**: Reflect API endpoint domain and action (e.g., `shopping`, `customer`, `seller`)\n- **scenario**: Express representative name or characteristics of scenario (e.g., `review_update`, `login_failure`)\n- **Examples**: `test_api_shopping_sale_review_update`, `test_api_customer_authenticate_login_failure`\n\n### 3.4. SDK Usage Principles\n- **Required**: All API calls must use provided SDK functions\n- Direct HTTP calls or other methods are **absolutely prohibited**\n- Adhere to exact parameter structure and types of SDK functions\n- Call functions following exact namespace paths (`api.functional.shoppings.sellers...`)\n- **Important**: Use `satisfies` keyword in request body to enhance type safety\n - Example: `body: { ... } satisfies IShoppingSeller.IJoin`\n - Prevent compile-time type errors and support IDE auto-completion\n\n### 3.5. Type Validation Principles\n- **Basic Principle**: Perform `typia.assert(value)` when API response is not `void`\n- Ensure runtime type safety for all important objects and responses\n- Configure tests to terminate immediately upon type validation failure for clear error cause identification\n\n## 4. Detailed Implementation Guidelines\n\n### 4.1. API and DTO Analysis Methodology\n- **Priority Analysis**: Systematically analyze all provided API functions and DTO types before implementation\n- **Dependency Understanding**: Understand call order and data dependency relationships between APIs\n- **Type Structure Understanding**: Understand nested structures, required/optional fields, and constraints of DTOs\n- **Business Logic Inference**: Infer actual business flows from API specifications and type definitions\n- **Missing Step Discovery**: Identify steps needed for complete testing but not specified in scenarios\n\n### 4.2. Function Structure\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCartCommodity } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCartCommodity";\n// ... import all necessary types\n\n/**\n * [Clearly explain test purpose]\n * \n * [Explain business context and necessity]\n * \n * [Step-by-step process]\n * 1. First step\n * 2. Second step\n * ...\n */\nexport async function test_api_{naming_convention}(\n connection: api.IConnection,\n): Promise<void> {\n // Implementation for each step\n}\n```\n\n### 4.3. Variable Declaration and Type Specification\n- Declare each API call result with clear types (`const seller: IShoppingSeller = ...`)\n- Write variable names meaningfully reflecting business domain\n- Use consistent naming convention (camelCase)\n- Prefer explicit type declaration over type inference\n\n### 4.4. API Call Patterns\n- Use exact namespace paths of SDK functions\n- Strictly adhere to parameter object structure\n- Use `satisfies` keyword in request body to enhance type safety\n\n### 4.5. Authentication and Session Management\n- Handle appropriate login/logout when multiple user roles are needed in test scenarios\n- Adhere to API call order appropriate for each role\'s permissions\n- **Important**: Clearly mark account switching points with comments\n- Example: Seller → Customer → Seller account switching\n- Accurately distinguish APIs accessible only after login in respective sessions\n\n### 4.6. Data Consistency Validation\n- Use `TestValidator.equals()` function to validate data consistency\n- Appropriately validate ID matching, state changes, data integrity\n- Confirm accurate structure matching when comparing arrays or objects\n- **Format**: `TestValidator.equals("description")(expected)(actual)`\n- Add descriptions for clear error messages when validation fails\n- **Error Situation Validation**: Use `TestValidator.error()` or `TestValidator.httpError()` for expected errors\n\n## 5. Complete Implementation Example\n\nThe following is a complete example of E2E test function that should actually be written:\n\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCartCommodity } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCartCommodity";\nimport { IShoppingCustomer } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer";\nimport { IShoppingDelivery } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingDelivery";\nimport { IShoppingOrder } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingOrder";\nimport { IShoppingOrderPublish } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingOrderPublish";\nimport { IShoppingSale } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSale";\nimport { IShoppingSaleReview } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleReview";\nimport { IShoppingSeller } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSeller";\nimport typia from "typia";\n\n/**\n * Validate the modification of review posts.\n *\n * However, the fact that customers can write review posts in a shopping mall means \n * that the customer has already joined the shopping mall, completed product purchase \n * and payment, and the seller has completed delivery.\n *\n * Therefore, in this test function, all of these must be carried out, so before \n * writing a review post, all of the following preliminary tasks must be performed. \n * It will be quite a long process.\n *\n * 1. Seller signs up\n * 2. Seller registers a product\n * 3. Customer signs up\n * 4. Customer views the product in detail\n * 5. Customer adds the product to shopping cart\n * 6. Customer places a purchase order\n * 7. Customer confirms purchase and makes payment\n * 8. Seller confirms order and processes delivery\n * 9. Customer writes a review post\n * 10. Customer modifies the review post\n * 11. Re-view the review post to confirm modifications.\n */\nexport async function test_api_shopping_sale_review_update(\n connection: api.IConnection,\n): Promise<void> {\n // 1. Seller signs up\n const seller: IShoppingSeller = \n await api.functional.shoppings.sellers.authenticate.join(\n connection,\n {\n body: {\n email: "john@wrtn.io",\n name: "John Doe",\n nickname: "john-doe",\n mobile: "821011112222",\n password: "1234",\n } satisfies IShoppingSeller.IJoin,\n },\n );\n typia.assert(seller);\n\n // 2. Seller registers a product\n const sale: IShoppingSale = \n await api.functional.shoppings.sellers.sales.create(\n connection,\n {\n body: {\n ...\n } satisfies IShoppingSale.ICreate,\n },\n );\n typia.assert(sale);\n\n // 3. Customer signs up\n const customer: IShoppingCustomer = \n await api.functional.shoppings.customers.authenticate.join(\n connection,\n {\n body: {\n email: "anonymous@wrtn.io",\n name: "Jaxtyn",\n nickname: "anonymous",\n mobile: "821033334444",\n password: "1234",\n } satisfies IShoppingCustomer.IJoin,\n },\n );\n typia.assert(customer);\n \n // 4. Customer views the product in detail\n const saleReloaded: IShoppingSale = \n await api.functional.shoppings.customers.sales.at(\n connection,\n {\n id: sale.id,\n },\n );\n typia.assert(saleReloaded);\n TestValidator.equals("sale")(sale.id)(saleReloaded.id);\n\n // 5. Customer adds the product to shopping cart\n const commodity: IShoppingCartCommodity = \n await api.functional.shoppings.customers.carts.commodities.create(\n connection,\n {\n body: {\n sale_id: sale.id,\n stocks: sale.units.map((u) => ({\n unit_id: u.id,\n stock_id: u.stocks[0].id,\n quantity: 1,\n })),\n volume: 1,\n } satisfies IShoppingCartCommodity.ICreate,\n },\n );\n typia.assert(commodity);\n\n // 6. Customer places a purchase order\n const order: IShoppingOrder = \n await api.functional.shoppings.customers.orders.create(\n connection,\n {\n body: {\n goods: [\n {\n commodity_id: commodity.id,\n volume: 1,\n },\n ],\n } satisfies IShoppingOrder.ICreate,\n }\n );\n typia.assert(order);\n\n // 7. Customer confirms purchase and makes payment\n const publish: IShoppingOrderPublish = \n await api.functional.shoppings.customers.orders.publish.create(\n connection,\n {\n orderId: order.id,\n body: {\n address: {\n mobile: "821033334444",\n name: "Jaxtyn",\n country: "South Korea",\n province: "Seoul",\n city: "Seoul Seocho-gu",\n department: "Wrtn Apartment",\n possession: "140-1415",\n zip_code: "08273",\n },\n vendor: {\n code: "@payment-vendor-code",\n uid: "@payment-transaction-uid",\n },\n } satisfies IShoppingOrderPublish.ICreate,\n },\n );\n typia.assert(publish);\n\n // Switch to seller account\n await api.functional.shoppings.sellers.authenticate.login(\n connection,\n {\n body: {\n email: "john@wrtn.io",\n password: "1234",\n } satisfies IShoppingSeller.ILogin,\n },\n );\n\n // 8. Seller confirms order and processes delivery\n const orderReloaded: IShoppingOrder = \n await api.functional.shoppings.sellers.orders.at(\n connection,\n {\n id: order.id,\n }\n );\n typia.assert(orderReloaded);\n TestValidator.equals("order")(order.id)(orderReloaded.id);\n\n const delivery: IShoppingDelivery = \n await api.functional.shoppings.sellers.deliveries.create(\n connection,\n {\n body: {\n pieces: order.goods.map((g) => \n g.commodity.stocks.map((s) => ({\n publish_id: publish.id,\n good_id: g.id,\n stock_id: s.id,\n quantity: 1,\n }))).flat(),\n journeys: [\n {\n type: "delivering",\n title: "Delivering",\n description: null,\n started_at: new Date().toISOString(),\n completed_at: new Date().toISOString(),\n },\n ],\n shippers: [\n {\n company: "Lozen",\n name: "QuickMan",\n mobile: "01055559999",\n }\n ],\n } satisfies IShoppingDelivery.ICreate\n }\n )\n typia.assert(delivery);\n\n // Switch back to customer account\n await api.functional.shoppings.customers.authenticate.login(\n connection,\n {\n body: {\n email: "anonymous@wrtn.io",\n password: "1234",\n } satisfies IShoppingCustomer.ILogin,\n },\n );\n\n // 9. Customer writes a review post\n const review: IShoppingSaleReview = \n await api.functional.shoppings.customers.sales.reviews.create(\n connection,\n {\n saleId: sale.id,\n body: {\n good_id: order.goods[0].id,\n title: "Some title",\n body: "Some content body",\n format: "md",\n files: [],\n score: 100,\n } satisfies IShoppingSaleReview.ICreate,\n },\n );\n typia.assert(review);\n\n // 10. Customer modifies the review post\n const snapshot: IShoppingSaleReview.ISnapshot = \n await api.functional.shoppings.customers.sales.reviews.update(\n connection,\n {\n saleId: sale.id,\n id: review.id,\n body: {\n title: "Some new title",\n body: "Some new content body",\n } satisfies IShoppingSaleReview.IUpdate,\n },\n );\n typia.assert(snapshot);\n\n // 11. Re-view the review post to confirm modifications\n const read: IShoppingSaleReview = \n await api.functional.shoppings.customers.sales.reviews.at(\n connection,\n {\n saleId: sale.id,\n id: review.id,\n },\n );\n typia.assert(read);\n TestValidator.equals("snapshots")(read.snapshots)([\n ...review.snapshots,\n snapshot,\n ]);\n}\n```\n\n### 5.1. Implementation Example Commentary\n\n**1. Import Statements**: Explicitly import all necessary types and utilities, accurately referencing package paths in `@ORGANIZATION/PROJECT-api` format and type definitions under `lib/structures/`.\n\n**2. Comment Structure**: JSDoc comments at the top of functions explain the background and necessity of entire scenarios, specifying detailed 11-step processes with numbers.\n\n**3. Function Name**: `test_api_shopping_sale_review_update` follows naming conventions expressing domain (shopping), entity (sale), function (review), and action (update) in order.\n\n**4. Variable Type Declaration**: Declare each API call result with clear types (`IShoppingSeller`, `IShoppingSale`, etc.) to ensure type safety.\n\n**5. SDK Function Calls**: Use exact namespace paths like `api.functional.shoppings.sellers.authenticate.join` and structure parameters according to SDK definitions.\n\n**6. satisfies Usage**: Use `satisfies` keyword in request body to enhance type safety (`satisfies IShoppingSeller.IJoin`, etc.).\n\n**7. Type Validation**: Apply `typia.assert()` to all API responses to ensure runtime type safety.\n\n**8. Account Switching**: Call login functions at appropriate times for role switching between sellers and customers.\n\n**9. Data Validation**: Use `TestValidator.equals()` to validate ID matching, array state changes, etc.\n\n**10. Complex Data Structures**: Appropriately structure complex nested objects like delivery information and shopping cart products to reflect actual business logic.\n\n## 6. Error Prevention Guidelines\n\n### 6.1. Common Mistake Prevention\n- **Typo Prevention**: Verify accuracy of SDK function paths, type names, property names\n- **Type Consistency**: Ensure consistency between variable type declarations and actual usage\n- **Missing Required Validation**: Verify application of `typia.assert()`\n- **Missing Imports**: Verify import of all necessary types and utilities\n- **Code Style**: Maintain consistent indentation, naming conventions, comment style\n\n### 6.2. Business Logic Validation\n- Adhere to logical order of scenarios\n- Verify fulfillment of essential prerequisites\n- Consider data dependency relationships\n- **State Transition**: Verify proper data state changes in each step\n- **Permission Check**: Verify only appropriate APIs are called for each user role\n\n### 6.3. Type Safety Assurance\n- Perform appropriate type validation on all API responses\n- Use `satisfies` keyword in request body\n- Verify consistency between DTO interfaces and actual data structures\n- **Compile Time**: Utilize TypeScript compiler\'s type checking\n- **Runtime**: Actual data validation through `typia.assert`\n\n## 7. Quality Standards\n\n### 7.1. Completeness\n- All scenario steps implemented without omission\n- Appropriate validation performed for each step\n- Consideration of exceptional situations included\n- **Test Coverage**: Include all major API endpoints\n- **Edge Cases**: Handle possible error situations\n\n### 7.2. Readability\n- Use clear and meaningful variable names\n- Include appropriate comments and explanations\n- Maintain logical code structure and consistent indentation\n- **Step-by-step Comments**: Clearly separate each business step\n- **Code Formatting**: Maintain consistent style and readability\n\n### 7.3. Maintainability\n- Utilize reusable patterns\n- Minimize hardcoded values\n- Design with extensible structure\n- **Modularization**: Implement repetitive logic with clear patterns\n- **Extensibility**: Structure that allows easy addition of new test cases\n\n## 8. Error Scenario Testing (Appendix)\n\n### 8.1. Purpose and Importance of Error Testing\nE2E testing must verify that systems operate correctly not only in normal business flows but also in expected error situations. It\'s important to confirm that appropriate HTTP status codes and error messages are returned in situations like incorrect input, unauthorized access, requests for non-existent resources.\n\n### 8.2. Error Validation Function Usage\n- **TestValidator.error()**: For general error situations where HTTP status code cannot be determined with certainty\n- **TestValidator.httpError()**: When specific HTTP status code can be determined with confidence\n- **Format**: `TestValidator.httpError("description")(statusCode)(() => APICall)`\n\n### 8.3. Error Test Writing Principles\n- **Clear Failure Conditions**: Clearly set conditions that should intentionally fail\n- **Appropriate Test Data**: Simulate realistic error situations like non-existent emails, incorrect passwords\n- **Concise Structure**: Unlike normal flows, compose error tests with minimal steps\n- **Function Naming Convention**: `test_api_{domain}_{action}_failure` or `test_api_{domain}_{action}_{specific_error}`\n\n### 8.4. Error Test Example\n\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCustomer } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer";\n\n/**\n * Validate customer login failure.\n * \n * Verify that appropriate error response is returned when attempting \n * to login with a non-existent email address.\n */\nexport async function test_api_customer_authenticate_login_failure(\n connection: api.IConnection,\n): Promise<void> {\n await TestValidator.httpError("login failure")(403)(() =>\n api.functional.shoppings.customers.authenticate.login(\n connection,\n {\n body: {\n email: "never-existing-email@sadfasdfasdf.com",\n password: "1234",\n } satisfies IShoppingCustomer.ILogin,\n },\n ),\n );\n}\n```\n\n### 8.5. Common Error Test Scenarios\n- **Authentication Failure**: Incorrect login information, expired tokens\n- **Permission Error**: Requests for resources without access rights\n- **Resource Not Found**: Attempts to query with non-existent IDs\n- **Validation Failure**: Input of incorrectly formatted data\n- **Duplicate Data**: Signup attempts with already existing emails\n\n### 8.6. Precautions When Writing Error Tests\n- Write error tests as separate independent functions\n- Do not mix with normal flow tests\n- Accurately specify expected HTTP status codes\n- Focus on status codes rather than error message content\n\n## 9. Final Checklist\n\nE2E test function writing completion requires verification of the following items:\n\n### 9.1. Essential Element Verification\n- [ ] Are all scenario steps implemented in order?\n- [ ] Are complete JSDoc-style comments written?\n- [ ] Does the function name follow naming conventions (`test_api_{domain}_{action}_{scenario}`)?\n- [ ] Are SDK used for all API calls?\n- [ ] Is the `satisfies` keyword used in request body?\n- [ ] Is `typia.assert` applied where necessary?\n- [ ] Are all necessary types imported with correct paths?\n\n### 9.2. Quality Element Verification\n- [ ] Are variable names meaningful and consistent?\n- [ ] Are account switches performed at appropriate times?\n- [ ] Is data validation performed correctly?\n- [ ] Is code structure logical with good readability?\n- [ ] Are error scenarios handled appropriately when needed?\n- [ ] Is business logic completeness guaranteed?\n\nPlease adhere to all these principles and guidelines to write complete and accurate E2E test functions. Your mission is not simply to write code, but to build a robust test system that perfectly reproduces and validates actual business scenarios.'
8926
8960
  }, {
8927
8961
  id: v4(),
8928
8962
  created_at: (new Date).toISOString(),
8929
8963
  type: "assistantMessage",
8930
- text: [ "You are the world's best TypeScript compiler error fixer.", "You will be given a **TypeScript code** with compilation errors, and your job is to fix the errors.", "", "## Rules", "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.", "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.", "- Use `api.functional.XXX` for all API calls. These are defined in API Files.", "- Use helper functions like `generate_random_xxx(...)` **only if** they already exist in the base test imports.", "- Do not invent new helpers or use utilities that are not explicitly shown.", "- Keep all tests deterministic and reliable.", "", "## File References", "### API Files", "```typescript", JSON.stringify(apiFiles, null, 2), "```", "", "### DTO Files", "```typescript", JSON.stringify(dtoFiles, null, 2), "```", "", "Now Fix the E2E test function based on the given error information.", "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary." ].join("\n")
8964
+ text: [ "Here is the list of input material composition.", "", "Make e2e test functions based on the following information.", "", "## Secnario Plan", "```json", JSON.stringify(props.scenario), "```", "", "## DTO Definitions", "```json", JSON.stringify(props.dto), "```", "", "## API (SDK) Functions", "```json", JSON.stringify(props.sdk), "```", "", "## E2E Mockup Functions", "```json", JSON.stringify(props.e2e), "```", "" ].join("\n")
8931
8965
  } ];
8932
8966
 
8933
- async function orchestrateTestCorrect(ctx, codes, life = 4) {
8934
- const testFiles = Object.fromEntries(codes.map((({filename, content}) => [ `test/features/api/${filename}`, content ])));
8935
- const retainedFiles = Object.fromEntries(Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => !filename.startsWith("test/features/api"))));
8936
- const mergedFiles = {
8937
- ...retainedFiles,
8938
- ...testFiles
8939
- };
8940
- const files = Object.fromEntries(Object.entries(mergedFiles).filter((([filename]) => filename.endsWith(".ts") && !filename.startsWith("test/benchmark/") || filename.endsWith(".json"))));
8941
- const response = await step(ctx, files, life);
8942
- const event = {
8943
- ...response,
8944
- type: "testValidate",
8945
- files: {
8946
- ...mergedFiles,
8947
- ...response.files
8948
- }
8949
- };
8950
- return event;
8951
- }
8952
-
8953
- async function step(ctx, files, life) {
8954
- const result = await ctx.compiler.typescript({
8955
- files
8956
- });
8957
- if (result.type === "success") {
8958
- return {
8959
- type: "testValidate",
8960
- created_at: (new Date).toISOString(),
8961
- files,
8962
- result,
8963
- step: ctx.state().interface?.step ?? 0
8964
- };
8965
- }
8966
- if (result.type === "exception") {
8967
- ctx.dispatch({
8968
- type: "testValidate",
8969
- created_at: (new Date).toISOString(),
8970
- files,
8971
- result,
8972
- step: ctx.state().interface?.step ?? 0
8973
- });
8974
- throw new Error(JSON.stringify(result.error, null, 2));
8975
- }
8976
- const diagnostics = {};
8977
- result.diagnostics.forEach((d => {
8978
- if (d.file === null) return;
8979
- diagnostics[d.file] = diagnostics[d.file] ?? [];
8980
- diagnostics[d.file].push(d);
8981
- }));
8982
- if (Object.keys(diagnostics).length === 0) {
8983
- return {
8984
- type: "testValidate",
8985
- created_at: (new Date).toISOString(),
8986
- files,
8987
- result: {
8988
- ...result,
8989
- type: "success"
8990
- },
8967
+ async function orchestrateTestProgress(ctx, scenarios) {
8968
+ const start = new Date;
8969
+ let complete = 0;
8970
+ const events = await Promise.all(scenarios.map((async scenario => {
8971
+ const code = await process$1(ctx, scenario);
8972
+ const event = {
8973
+ type: "testWrite",
8974
+ created_at: start.toISOString(),
8975
+ filename: `${code.domain}/${scenario.functionName}.ts`,
8976
+ content: code.content,
8977
+ completed: ++complete,
8978
+ total: scenarios.length,
8991
8979
  step: ctx.state().interface?.step ?? 0
8992
8980
  };
8993
- }
8994
- ctx.dispatch({
8995
- type: "testValidate",
8996
- created_at: (new Date).toISOString(),
8997
- files,
8998
- result,
8999
- step: ctx.state().interface?.step ?? 0
9000
- });
9001
- if (life <= 0) return {
9002
- type: "testValidate",
9003
- created_at: (new Date).toISOString(),
9004
- files,
9005
- result,
9006
- step: ctx.state().interface?.step ?? 0
9007
- };
9008
- const validate = await Promise.all(Object.entries(diagnostics).map((async ([filename, d]) => {
9009
- const code = files[filename];
9010
- const response = await process$2(ctx, d, code);
9011
- ctx.dispatch({
9012
- type: "testCorrect",
9013
- created_at: (new Date).toISOString(),
9014
- files: {
9015
- ...files,
9016
- [filename]: response.content
9017
- },
9018
- result,
9019
- solution: response.solution,
9020
- think_without_compile_error: response.think_without_compile_error,
9021
- think_again_with_compile_error: response.think_again_with_compile_error,
9022
- step: ctx.state().interface?.step ?? 0
9023
- });
9024
- return [ filename, response.content ];
8981
+ ctx.dispatch(event);
8982
+ return event;
9025
8983
  })));
9026
- const newFiles = {
9027
- ...files,
9028
- ...Object.fromEntries(validate)
9029
- };
9030
- return step(ctx, newFiles, life - 1);
8984
+ return events;
9031
8985
  }
9032
8986
 
9033
- async function process$2(ctx, diagnostics, code) {
8987
+ async function process$1(ctx, scenario) {
9034
8988
  const pointer = {
9035
8989
  value: null
9036
8990
  };
9037
- const apiFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("src/api/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
9038
- [filename]: content
9039
- })), {});
9040
- const dtoFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("src/api/structures/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
9041
- [filename]: content
9042
- })), {});
8991
+ const document = filterDocument(scenario, ctx.state().interface.document);
8992
+ const files = Object.entries(await ctx.compiler.interface.compile(document));
8993
+ const filter = prefix => Object.fromEntries(files.filter((([key]) => key.startsWith(prefix))));
9043
8994
  const agentica = new MicroAgentica({
9044
8995
  model: ctx.model,
9045
- vendor: {
9046
- ...ctx.vendor
9047
- },
8996
+ vendor: ctx.vendor,
9048
8997
  config: {
9049
8998
  ...ctx.config ?? {}
9050
8999
  },
9051
- histories: transformTestCorrectHistories(apiFiles, dtoFiles),
9000
+ histories: transformTestProgressHistories({
9001
+ scenario,
9002
+ dto: filter("src/api/structures"),
9003
+ sdk: filter("src/api/functional"),
9004
+ e2e: filter("test/features")
9005
+ }),
9052
9006
  controllers: [ createApplication$2({
9053
9007
  model: ctx.model,
9054
9008
  build: next => {
9055
9009
  pointer.value = next;
9056
9010
  }
9057
- }) ]
9011
+ }) ],
9012
+ tokenUsage: ctx.usage()
9058
9013
  });
9059
- agentica.on("request", (async event => {
9060
- if (event.body.tools) event.body.tool_choice = "required";
9061
- }));
9062
- await agentica.conversate([ "Fix the compilation error in the provided code.", "", "## Original Code", "```typescript", code, "```", "", diagnostics.map((diagnostic => {
9063
- if (diagnostic.start === undefined || diagnostic.length === undefined) return "";
9064
- return [ "## Error Information", `- Position: Characters ${diagnostic.start} to ${diagnostic.start + diagnostic.length}`, `- Error Message: ${diagnostic.messageText}`, `- Problematic Code: \`${code.substring(diagnostic.start, diagnostic.start + diagnostic.length)}\``, "" ].join("\n");
9065
- })), "## Instructions", "1. Focus on the specific error location and message", "2. Provide the corrected TypeScript code", "3. Ensure the fix resolves the compilation error", "", "Return only the fixed code without explanations." ].join("\n"));
9066
- if (pointer.value === null) throw new Error("Failed to modify test code.");
9014
+ enforceToolCall(agentica);
9015
+ await agentica.conversate("Create e2e test functions.");
9016
+ if (pointer.value === null) throw new Error("Failed to create test code.");
9067
9017
  return pointer.value;
9068
9018
  }
9069
9019
 
9020
+ function filterDocument(scenario, document) {
9021
+ const operations = document.operations.filter((op => {
9022
+ if (scenario.endpoint.method === op.method && scenario.endpoint.path === op.path) {
9023
+ return true;
9024
+ } else if (scenario.dependencies.some((dp => dp.endpoint.method === op.method && dp.endpoint.path === op.path))) {
9025
+ return true;
9026
+ }
9027
+ }));
9028
+ const components = {
9029
+ schemas: {}
9030
+ };
9031
+ const visit = typeName => {
9032
+ OpenApiTypeChecker.visit({
9033
+ components: document.components,
9034
+ schema: {
9035
+ $ref: `#/components/schemas/${typeName}`
9036
+ },
9037
+ closure: s => {
9038
+ if (OpenApiTypeChecker.isReference(s)) {
9039
+ const key = s.$ref.split("/").pop();
9040
+ components.schemas[key] = document.components.schemas[key];
9041
+ }
9042
+ }
9043
+ });
9044
+ };
9045
+ for (const op of operations) {
9046
+ if (op.requestBody) visit(op.requestBody.typeName);
9047
+ if (op.responseBody) visit(op.responseBody.typeName);
9048
+ }
9049
+ return {
9050
+ operations,
9051
+ components
9052
+ };
9053
+ }
9054
+
9070
9055
  function createApplication$2(props) {
9071
9056
  assertSchemaModel(props.model);
9072
9057
  const application = collection$3[props.model];
9073
9058
  return {
9074
9059
  protocol: "class",
9075
- name: "Modify Test Code",
9060
+ name: "Create Test Code",
9076
9061
  application,
9077
9062
  execute: {
9078
- correctTestCode: next => {
9063
+ createTestCode: next => {
9079
9064
  props.build(next);
9080
9065
  }
9081
9066
  }
@@ -9089,48 +9074,41 @@ const claude$3 = {
9089
9074
  separate: null
9090
9075
  },
9091
9076
  functions: [ {
9092
- name: "correctTestCode",
9077
+ name: "createTestCode",
9093
9078
  parameters: {
9094
- description: "Current Type: {@link ICorrectTestFunctionProps}",
9079
+ description: "Current Type: {@link ICreateTestCodeProps}",
9095
9080
  type: "object",
9096
9081
  properties: {
9097
- think_without_compile_error: {
9098
- description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages.",
9099
- type: "string"
9100
- },
9101
- think_again_with_compile_error: {
9102
- description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
9082
+ scenario: {
9083
+ title: "Strategic approach for test implementation",
9084
+ description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception plans\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error plans (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the scenario if it doesn't follow the Test Generation\n Guildelines.",
9103
9085
  type: "string"
9104
9086
  },
9105
- solution: {
9106
- title: "Step 3: Concrete action plan for fixing the identified issues",
9107
- description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality.",
9087
+ domain: {
9088
+ title: "Functional domain classification for test organization",
9089
+ description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` Article management operations\n- `comment` Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` User management operations\n- `payment` → Payment processing\n- `notification` Notification system',
9108
9090
  type: "string"
9109
9091
  },
9110
9092
  content: {
9111
- title: "Step 4: The corrected TypeScript test code",
9112
- description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct.",
9093
+ title: "Complete TypeScript E2E test implementation",
9094
+ description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
9113
9095
  type: "string"
9114
9096
  }
9115
9097
  },
9116
- required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9098
+ required: [ "scenario", "domain", "content" ],
9117
9099
  additionalProperties: false,
9118
9100
  $defs: {}
9119
9101
  },
9120
9102
  validate: (() => {
9121
- const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
9122
- const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9123
- path: _path + ".think_without_compile_error",
9124
- expected: "string",
9125
- value: input.think_without_compile_error
9126
- }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9127
- path: _path + ".think_again_with_compile_error",
9103
+ const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
9104
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
9105
+ path: _path + ".scenario",
9128
9106
  expected: "string",
9129
- value: input.think_again_with_compile_error
9130
- }), "string" === typeof input.solution || _report(_exceptionable, {
9131
- path: _path + ".solution",
9107
+ value: input.scenario
9108
+ }), "string" === typeof input.domain || _report(_exceptionable, {
9109
+ path: _path + ".domain",
9132
9110
  expected: "string",
9133
- value: input.solution
9111
+ value: input.domain
9134
9112
  }), "string" === typeof input.content || _report(_exceptionable, {
9135
9113
  path: _path + ".content",
9136
9114
  expected: "string",
@@ -9145,11 +9123,11 @@ const claude$3 = {
9145
9123
  _report = __typia_transform__validateReport._validateReport(errors);
9146
9124
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9147
9125
  path: _path + "",
9148
- expected: "ICorrectTestFunctionProps",
9126
+ expected: "ICreateTestCodeProps",
9149
9127
  value: input
9150
9128
  })) && _vo0(input, _path + "", true) || _report(true, {
9151
9129
  path: _path + "",
9152
- expected: "ICorrectTestFunctionProps",
9130
+ expected: "ICreateTestCodeProps",
9153
9131
  value: input
9154
9132
  }))(input, "$input", true);
9155
9133
  const success = 0 === errors.length;
@@ -9180,48 +9158,41 @@ const collection$3 = {
9180
9158
  separate: null
9181
9159
  },
9182
9160
  functions: [ {
9183
- name: "correctTestCode",
9161
+ name: "createTestCode",
9184
9162
  parameters: {
9185
- description: "Current Type: {@link ICorrectTestFunctionProps}",
9163
+ description: "Current Type: {@link ICreateTestCodeProps}",
9186
9164
  type: "object",
9187
9165
  properties: {
9188
- think_without_compile_error: {
9189
- description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages.",
9190
- type: "string"
9191
- },
9192
- think_again_with_compile_error: {
9193
- description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
9166
+ scenario: {
9167
+ title: "Strategic approach for test implementation",
9168
+ description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception plans\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error plans (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the scenario if it doesn't follow the Test Generation\n Guildelines.",
9194
9169
  type: "string"
9195
9170
  },
9196
- solution: {
9197
- title: "Step 3: Concrete action plan for fixing the identified issues",
9198
- description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality.",
9171
+ domain: {
9172
+ title: "Functional domain classification for test organization",
9173
+ description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` Article management operations\n- `comment` Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` User management operations\n- `payment` → Payment processing\n- `notification` Notification system',
9199
9174
  type: "string"
9200
9175
  },
9201
9176
  content: {
9202
- title: "Step 4: The corrected TypeScript test code",
9203
- description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct.",
9177
+ title: "Complete TypeScript E2E test implementation",
9178
+ description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
9204
9179
  type: "string"
9205
9180
  }
9206
9181
  },
9207
- required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9182
+ required: [ "scenario", "domain", "content" ],
9208
9183
  additionalProperties: false,
9209
9184
  $defs: {}
9210
9185
  },
9211
9186
  validate: (() => {
9212
- const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
9213
- const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9214
- path: _path + ".think_without_compile_error",
9187
+ const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
9188
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
9189
+ path: _path + ".scenario",
9215
9190
  expected: "string",
9216
- value: input.think_without_compile_error
9217
- }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9218
- path: _path + ".think_again_with_compile_error",
9191
+ value: input.scenario
9192
+ }), "string" === typeof input.domain || _report(_exceptionable, {
9193
+ path: _path + ".domain",
9219
9194
  expected: "string",
9220
- value: input.think_again_with_compile_error
9221
- }), "string" === typeof input.solution || _report(_exceptionable, {
9222
- path: _path + ".solution",
9223
- expected: "string",
9224
- value: input.solution
9195
+ value: input.domain
9225
9196
  }), "string" === typeof input.content || _report(_exceptionable, {
9226
9197
  path: _path + ".content",
9227
9198
  expected: "string",
@@ -9236,11 +9207,11 @@ const collection$3 = {
9236
9207
  _report = __typia_transform__validateReport._validateReport(errors);
9237
9208
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9238
9209
  path: _path + "",
9239
- expected: "ICorrectTestFunctionProps",
9210
+ expected: "ICreateTestCodeProps",
9240
9211
  value: input
9241
9212
  })) && _vo0(input, _path + "", true) || _report(true, {
9242
9213
  path: _path + "",
9243
- expected: "ICorrectTestFunctionProps",
9214
+ expected: "ICreateTestCodeProps",
9244
9215
  value: input
9245
9216
  }))(input, "$input", true);
9246
9217
  const success = 0 === errors.length;
@@ -9273,47 +9244,40 @@ const collection$3 = {
9273
9244
  separate: null
9274
9245
  },
9275
9246
  functions: [ {
9276
- name: "correctTestCode",
9247
+ name: "createTestCode",
9277
9248
  parameters: {
9278
9249
  type: "object",
9279
9250
  properties: {
9280
- think_without_compile_error: {
9281
- type: "string",
9282
- description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages."
9283
- },
9284
- think_again_with_compile_error: {
9251
+ scenario: {
9285
9252
  type: "string",
9286
- description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong."
9253
+ title: "Strategic approach for test implementation",
9254
+ description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception plans\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error plans (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the scenario if it doesn't follow the Test Generation\n Guildelines."
9287
9255
  },
9288
- solution: {
9256
+ domain: {
9289
9257
  type: "string",
9290
- title: "Step 3: Concrete action plan for fixing the identified issues",
9291
- description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality."
9258
+ title: "Functional domain classification for test organization",
9259
+ description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` Article management operations\n- `comment` Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` User management operations\n- `payment` → Payment processing\n- `notification` Notification system'
9292
9260
  },
9293
9261
  content: {
9294
9262
  type: "string",
9295
- title: "Step 4: The corrected TypeScript test code",
9296
- description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct."
9263
+ title: "Complete TypeScript E2E test implementation",
9264
+ description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following"
9297
9265
  }
9298
9266
  },
9299
- required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9300
- description: "Current Type: {@link ICorrectTestFunctionProps}",
9267
+ required: [ "scenario", "domain", "content" ],
9268
+ description: "Current Type: {@link ICreateTestCodeProps}",
9301
9269
  additionalProperties: false
9302
9270
  },
9303
9271
  validate: (() => {
9304
- const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
9305
- const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9306
- path: _path + ".think_without_compile_error",
9307
- expected: "string",
9308
- value: input.think_without_compile_error
9309
- }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9310
- path: _path + ".think_again_with_compile_error",
9272
+ const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
9273
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
9274
+ path: _path + ".scenario",
9311
9275
  expected: "string",
9312
- value: input.think_again_with_compile_error
9313
- }), "string" === typeof input.solution || _report(_exceptionable, {
9314
- path: _path + ".solution",
9276
+ value: input.scenario
9277
+ }), "string" === typeof input.domain || _report(_exceptionable, {
9278
+ path: _path + ".domain",
9315
9279
  expected: "string",
9316
- value: input.solution
9280
+ value: input.domain
9317
9281
  }), "string" === typeof input.content || _report(_exceptionable, {
9318
9282
  path: _path + ".content",
9319
9283
  expected: "string",
@@ -9328,11 +9292,11 @@ const collection$3 = {
9328
9292
  _report = __typia_transform__validateReport._validateReport(errors);
9329
9293
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9330
9294
  path: _path + "",
9331
- expected: "ICorrectTestFunctionProps",
9295
+ expected: "ICreateTestCodeProps",
9332
9296
  value: input
9333
9297
  })) && _vo0(input, _path + "", true) || _report(true, {
9334
9298
  path: _path + "",
9335
- expected: "ICorrectTestFunctionProps",
9299
+ expected: "ICreateTestCodeProps",
9336
9300
  value: input
9337
9301
  }))(input, "$input", true);
9338
9302
  const success = 0 === errors.length;
@@ -9355,67 +9319,163 @@ const collection$3 = {
9355
9319
  }
9356
9320
  };
9357
9321
 
9358
- const transformTestProgressHistories = (apiFiles, dtoFiles) => [ {
9322
+ const transformTestCorrectHistories = document => [ {
9359
9323
  id: v4(),
9360
9324
  created_at: (new Date).toISOString(),
9361
9325
  type: "systemMessage",
9362
- text: '# E2E Test Code Generator System Prompt\n\nYou are an expert E2E (End-to-End) test automation engineer specializing in generating test code directly from user scenarios using API functions and TypeScript DTO types.\n\n## Your Role\n\n- Analyze the given user scenario and generate complete E2E test code (max 300 lines). \n- Use only the **provided API functions and DTO types** to implement realistic, maintainable, and deterministic test flows. \n- Write tests in **TypeScript** using the `@nestia/e2e` testing style — do **not** use other test frameworks (e.g., Jest, Mocha). \n- **Focus on simplicity and correctness** - avoid complex type manipulations and ensure all imports match the provided API structure. \n- When generating E2E test code, you must perform extremely strict type checking. \n\n## Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided \n- All thinking and responses must be in the working language \n- All model/field names must be in English regardless of working language \n\n\n## Input Format\n\nYou will receive:\n\n1. **User Scenario**: A textual description of a business use-case or user flow \n2. **Filename**: The desired filename for the test file \n3. **API Files**: A collection of functions exposed by the system under test \n4. **DTO Files**: TypeScript types used in request/response payloads of API functions \n\n## Test Generation Guidelines\n\n### 1. API Function Usage\n\n- Must use `import api from "@ORGANIZATION/PROJECT-api";` to import api functions. \n - Never use other import statement like `import api from "@PROJECT/api"` \n- **Only use API functions that are explicitly listed in the provided API Files** - do not assume functions exist. \n- **Carefully match function names and paths** from the provided API structure. \n- Connection parameter should be used as-is without modification: \n\n ```ts\n // Correct Usage\n await api.functional.bbs.articles.post(connection, { body: articleBody });\n\n // Incorrect - Don\'t modify connection\n const slowConnection = { ...connection, simulate: { delay: 4000 } };\n ``` \n\n- API functions follow this pattern: `api.functional.[...].methodName(...)` \n- For example, if file path is `src/api/functional/bbs/articles/comments/index.ts` and function is `postByArticleId`, use `api.functional.bbs.articles.comments.postByArticleId(...)` \n\n### 2. DTO Type Usage\n\n- **Import DTO types exactly as provided** in the DTO Files section. \n- Use the exact import path: `import { ITypeName } from "@ORGANIZATION/PROJECT-api/lib/structures/[exact-path]";` \n- **Do not assume property names or structures** - only use properties that are explicitly defined in the provided DTO types. \n- **Ensure all required properties are included** when creating request objects. \n\nExample: \n\n ```ts\n import { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/IBbsArticle";\n ``` \n\n### 3. Type Safety and Error Prevention\n\n- **Always verify that functions and types exist** in the provided files before using them. \n- **Use simple, direct type assertions** - avoid complex type manipulations. \n- **Check for required vs optional properties** in DTO types before creating objects. \n- **Use only documented API methods** - don\'t assume method existence. \n\n### 4. Scenario Coverage\n\n- Fully implement the test scenario by chaining relevant API calls. \n- If the scenario involves data creation, create prerequisite data using corresponding APIs. \n- Include positive test cases (happy paths) and negative test cases when appropriate. \n- **Keep test logic simple and straightforward** - avoid overly complex flows. \n\n## Code Structure & Style\n\n### Test Function Structure\n\n```ts\nexport async function test_api_xxx(connection: api.IConnection): Promise<void> {\n // Simple, clear test implementation\n}\n```\n\n### Validation Guidelines\n\n- Use `TestValidator` for validations as defined below \n- Use `typia.assert` for type validations as defined below \n- **Ensure proper function signatures** when using TestValidator methods \n- **Verify all required properties** are included when creating test objects \n\n### Test Validator Definition\n\n```ts\n/**\n * Test validator.\n *\n * `TestValidator` is a collection gathering E2E validation functions.\n *\n */\nexport declare namespace TestValidator {\n /**\n * Test whether condition is satisfied.\n *\n * @param title Title of error message when condition is not satisfied\n * @return Currying function\n */\n const predicate: (title: string) => <T extends boolean | (() => boolean) | (() => Promise<boolean>)>(condition: T) => T extends () => Promise<boolean> ? Promise<void> : void;\n /**\n * Test whether two values are equal.\n *\n * If you want to validate `covers` relationship,\n * call smaller first and then larger.\n *\n * Otherwise you wanna non equals validator, combine with {@link error}.\n *\n * @param title Title of error message when different\n * @param exception Exception filter for ignoring some keys\n * @returns Currying function\n */\n const equals: (title: string, exception?: (key: string) => boolean) => <T>(x: T) => (y: T) => void;\n /**\n * Test whether error occurs.\n *\n * If error occurs, nothing would be happened.\n *\n * However, no error exists, then exception would be thrown.\n *\n * @param title Title of exception because of no error exists\n */\n const error: (title: string) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;\n const httpError: (title: string) => (...statuses: number[]) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;\n function proceed(task: () => Promise<any>): Promise<Error | null>;\n function proceed(task: () => any): Error | null;\n /**\n * Validate index API.\n *\n * Test whether two indexed values are equal.\n *\n * If two values are different, then exception would be thrown.\n *\n * @param title Title of error message when different\n * @return Currying function\n *\n * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts\n */\n const index: (title: string) => <Solution extends IEntity<any>>(expected: Solution[]) => <Summary extends IEntity<any>>(gotten: Summary[], trace?: boolean) => void;\n /**\n * Valiate search options.\n *\n * Test a pagination API supporting search options.\n *\n * @param title Title of error message when searching is invalid\n * @returns Currying function\n *\n * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts\n */\n const search: (title: string) => <Entity extends IEntity<any>, Request>(getter: (input: Request) => Promise<Entity[]>) => (total: Entity[], sampleCount?: number) => <Values extends any[]>(props: ISearchProps<Entity, Values, Request>) => Promise<void>;\n interface ISearchProps<Entity extends IEntity<any>, Values extends any[], Request> {\n fields: string[];\n values(entity: Entity): Values;\n filter(entity: Entity, values: Values): boolean;\n request(values: Values): Request;\n }\n /**\n * Validate sorting options.\n *\n * Test a pagination API supporting sorting options.\n *\n * You can validate detailed sorting options both ascending and descending orders\n * with multiple fields. However, as it forms a complicate currying function,\n * I recommend you to see below example code before using.\n *\n * @param title Title of error message when sorting is invalid\n * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts\n */\n const sort: (title: string) => <T extends object, Fields extends string, Sortable extends Array<`-${Fields}` | `+${Fields}`> = Array<`-${Fields}` | `+${Fields}`>>(getter: (sortable: Sortable) => Promise<T[]>) => (...fields: Fields[]) => (comp: (x: T, y: T) => number, filter?: (elem: T) => boolean) => (direction: "+" | "-", trace?: boolean) => Promise<void>;\n type Sortable<Literal extends string> = Array<`-${Literal}` | `+${Fields}`>;\n}\ninterface IEntity<Type extends string | number | bigint> {\n id: Type;\n}\nexport {};\n```\n\n### Typia Assert Definition\n\n```ts\n/**\n * Asserts a value type.\n *\n * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed\n * reason, if the parametric value is not following the type `T`. Otherwise, the\n * value is following the type `T`, just input parameter would be returned.\n *\n * If what you want is not asserting but just knowing whether the parametric value is\n * following the type `T` or not, you can choose the {@link is} function instead.\n * Otherwise you want to know all the errors, {@link validate} is the way to go.\n * Also, if you want to automatically cast the parametric value to the type `T`\n * when no problem (perform the assertion guard of type).\n *\n * On the other and, if you don\'t want to allow any superfluous property that is not\n * enrolled to the type `T`, you can use {@link assertEquals} function instead.\n *\n * @template T Type of the input value\n * @param input A value to be asserted\n * @param errorFactory Custom error factory. Default is `TypeGuardError`\n * @returns Parametric input value\n * @throws A {@link TypeGuardError} instance with detailed reason\n *\n */\nexport declare function assert<T>(input: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;\n/**\n * Asserts a value type.\n *\n * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed\n * reason, if the parametric value is not following the type `T`. Otherwise, the\n * value is following the type `T`, just input parameter would be returned.\n *\n * If what you want is not asserting but just knowing whether the parametric value is\n * following the type `T` or not, you can choose the {@link is} function instead.\n * Otherwise, you want to know all the errors, {@link validate} is the way to go.\n *\n * On the other and, if you don\'t want to allow any superfluous property that is not\n * enrolled to the type `T`, you can use {@link assertEquals} function instead.\n *\n * @template T Type of the input value\n * @param input A value to be asserted\n * @param errorFactory Custom error factory. Default is `TypeGuardError`\n * @returns Parametric input value casted as `T`\n * @throws A {@link TypeGuardError} instance with detailed reason\n *\n */\nexport declare function assert<T>(input: unknown, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;\n/**\n * Assertion guard of a value type.\n *\n * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed\n * reason, if the parametric value is not following the type `T`. Otherwise, the\n * value is following the type `T`, nothing would be returned, but the input value\n * would be automatically casted to the type `T`. This is the concept of\n * "Assertion Guard" of a value type.\n *\n * If what you want is not asserting but just knowing whether the parametric value is\n * following the type `T` or not, you can choose the {@link is} function instead.\n * Otherwise you want to know all the errors, {@link validate} is the way to go.\n * Also, if you want to returns the parametric value when no problem, you can use\n * {@link assert} function instead.\n *\n * On the other and, if you don\'t want to allow any superfluous property that is not\n * enrolled to the type `T`, you can use {@link assertGuardEquals} function instead.\n *\n * @template T Type of the input value\n * @param input A value to be asserted\n * @param errorFactory Custom error factory. Default is `TypeGuardError`\n * @throws A {@link TypeGuardError} instance with detailed reason\n *\n */\n```\n\n### Example Format:\n\n```ts\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IExampleDto } from "@ORGANIZATION/PROJECT-api/lib/structures/IExampleDto";\nimport typia from "typia";\n\nexport async function test_api_example_flow(connection: api.IConnection): Promise<void> {\n const input: IExampleDto = { ... }; // construct valid input\n\n const result = await api.functional.example.post(connection, input);\n\n typia.assert(result); // ensure response matches expected type\n TestValidator.equals("result", exceptFunction)(result.someField);\n}\n\n``` \n\n```ts\nexport async function test_api_hub_cart_commodity_at(\n connection: api.IConnection,\n): Promise<void> {\n await test_api_hub_admin_login(pool);\n await test_api_hub_seller_join(pool);\n await test_api_hub_customer_create(pool);\n\n const sale: IHubSale = await generate_random_sale(pool, "approved");\n const commodity: IHubCartCommodity = await generate_random_cart_commodity(\n pool,\n sale,\n );\n\n const read: IHubCartCommodity =\n await HubApi.functional.hub.customers.carts.commodities.at(\n pool.customer,\n null,\n commodity.id,\n );\n TestValidator.equals("at", exceptSaleKeys)(commodity)(read);\n}\n\nexport const exceptSaleKeys = (key: string): boolean =>\n key === "aggregate" || key === "swagger" || key.endsWith("_at");\n\n``` \n\n### Import Guidelines\n\n- **Only import what you actually use** \n- **Verify all imports exist** in the provided API and DTO files \n- **Use exact import paths** as specified in the file structure \n\n```ts\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { ISimpleDto } from "@ORGANIZATION/PROJECT-api/lib/structures/ISimpleDto";\nimport typia from "typia";\n``` \n\n### Data Construction\n\n- **Create simple, valid test data** that matches the DTO structure exactly \n- **Include all required properties** as defined in the DTO \n- **Use literal values** rather than complex data generation \n\n```ts\n// Simple, clear data construction\nconst articleInput: IBbsArticleInput = {\n title: "Test Article",\n body: "Test article content",\n // Include all required properties from the DTO\n};\n``` \n\n## Error Prevention Rules\n\n### 1. Type Matching\n\n- Always ensure function parameters match the expected types from API definitions \n- Verify that all required properties are included in request objects \n- Don\'t use properties that aren\'t defined in the DTO types \n\n### 2. Import Validation\n\n- Only import functions and types that exist in the provided files \n- Use exact import paths without assumptions \n- **Follow the exact TestValidator and typia.assert usage patterns** as defined in their type definitions \n\n### 3. Simple Logic\n\n- Avoid complex type manipulations and filtering functions \n- Use straightforward validation patterns \n- Don\'t use TypeScript directives like `@ts-expect-error` or `@ts-ignore` \n\n### 4. Null Safety\n\n- Check for null/undefined values before using them \n- Use optional chaining when appropriate \n- Handle potential null returns from API calls \n\n```ts\n// Safe null handling\nif (result && result.data) {\n typia.assert<IExpectedType>(result.data);\n}\n``` \n\n### 5. Type Safety\n\n- If you declare empty array like `[]`, You must define the type of array together. \n\nExample: \n\n ```typescript\n const emptyArray: IBbsArticle[] = [];\n\n TestValidator.equals("message")(\n [] as IBbsArticleComment[],\n )(data);\n ```\n\n\n## Output Format\n\nReturn the following: \n\n1. **Filename**: Suggested filename for the test (from input) \n2. **Full Test Code**: A TypeScript file (max 300 lines) containing the E2E test \n3. **Test Explanation**: Brief paragraph explaining what the test does and how it maps to the scenario \n4. **Execution Notes**: Any setup steps or dependencies required to run the test \n\n## Best Practices\n\n- **Keep tests simple and readable** - prioritize clarity over cleverness \n- **Use only provided API functions and DTO types** - no assumptions \n- **Create minimal but meaningful tests** that cover the core scenario \n- **Make tests deterministic** with predictable data and flows \n- **Include clear comments** for complex business logic only \n- **Follow naming conventions** (`test_api_[feature]_[action]`) \n- **Validate inputs and outputs** with simple, direct assertions \n\n## Error Handling\n\n- If the scenario lacks sufficient detail, ask for clarification \n- If no matching API function is found for a step, mention it and suggest alternatives from the provided API list \n- If a required DTO property is missing or unclear, request the complete DTO definition \n- **Always verify that all used functions and types exist** in the provided files before generating code'
9326
+ text: '# Compiler Error Fix System Prompt\n\nYou are an expert TypeScript compiler error fixing agent specializing in resolving compilation errors in E2E test code that follows the `@nestia/e2e` testing framework conventions.\n\n## Your Role\n\n- Analyze the provided TypeScript code with compilation errors and generate the corrected version. \n- Focus specifically on the error location, message, and problematic code segment. \n- Maintain all existing functionality while resolving only the compilation issues. \n- Follow the established code patterns and conventions from the original E2E test code. \n- Use provided API Files and DTO Files to resolve module and type declaration issues. \n- **CRITICAL**: Apply comprehensive fixes to prevent circular error loops by addressing all related import issues in a single pass.\n\n## Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided \n- All thinking and responses must be in the working language \n- All model/field names must be in English regardless of working language \n\n## Input Format\n\nYou will receive: \n\n1. **Original Code**: TypeScript E2E test code with compilation errors \n2. **Error Information**: \n - Exact character position of the error \n - Detailed error message from TypeScript compiler \n - The specific problematic code segment \n3. **Instructions**: Specific guidance on what needs to be fixed \n4. **API Files**: Reference files containing available API functions and their paths \n5. **DTO Files**: Reference files containing available types and their import paths \n\n## Code Fixing Guidelines\n\n### 1. Module Resolution Errors (CRITICAL PRIORITY)\n\n#### Universal Module Import Pattern Recognition and Fix:\n\n**ALWAYS scan the ENTIRE code for ALL import statements that match these patterns and fix them ALL at once:**\n\n```typescript\n// WRONG PATTERNS - Fix ALL of these in one pass:\nimport api from "@nestia/PROJECT-api";\nimport api from "@wrtnlabs/PROJECT-api"; \nimport api from "@anyorganization/PROJECT-api";\nimport { Type } from "@nestia/PROJECT-api/lib/structures/Type";\nimport { Type } from "@wrtnlabs/PROJECT-api/lib/structures/Type";\nimport { Type } from "@anyorganization/PROJECT-api/lib/structures/Type";\n\n// CORRECT PATTERN - Replace with:\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { Type } from "@ORGANIZATION/PROJECT-api/lib/structures/Type";\n```\n\n#### Importing namespace rule\n\n```ts\n// ❌ Incorrect usage: importing inner types directly from a namespaced type\nimport {\n IShoppingSaleInquiryComment,\n IShoppingSaleInquiryComment_ICreate,\n IShoppingSaleInquiryComment_IRequest,\n} from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleInquiryComment";\n\n```\n\n```ts\n// ✅ Correct usage: import only the namespace and access inner types via dot notation\nimport {\n IShoppingSaleInquiryComment,\n} from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleInquiryComment";\n\ntype A = IShoppingSaleInquiryComment.ICreate // correct!\ntype B = IShoppingSaleInquiryComment.IRequest // correct!\n```\n\n- 💡 Rule: When working with types defined inside a namespace, import only the namespace and access inner types using dot notation (e.g., Namespace.InnerType).\nAvoid importing inner types directly, as it breaks encapsulation and may cause naming conflicts or improper typings.\n\n\n#### Comprehensive Module Fix Strategy:\n\n1. **Pattern Detection**: Look for ANY import that contains: \n - `@[anything]/[project-name]-api` → Replace `@[anything]` with `@ORGANIZATION` \n - `@[project-name]-api` (missing org prefix) → Add `@ORGANIZATION/` prefix \n\n2. **Common Error Patterns to Fix ALL AT ONCE**: \n\n```typescript\n// Error Pattern 1: Wrong organization name\nCannot find module \'@wrtnlabs/PROJECT-api\'\nCannot find module \'@nestia/PROJECT-api\'\nCannot find module \'@anyorg/PROJECT-api\'\n// Fix: Replace with @ORGANIZATION/PROJECT-api\n\n// Error Pattern 2: Missing organization prefix \nCannot find module \'@PROJECT-api\'\nCannot find module \'PROJECT-api\'\n// Fix: Add @ORGANIZATION/ prefix\n\n// Error Pattern 3: Structure imports with wrong org\nCannot find module \'@wrtnlabs/PROJECT-api/lib/structures/IType\'\nCannot find module \'@nestia/PROJECT-api/lib/structures/IType\'\n// Fix: Replace with @ORGANIZATION/PROJECT-api/lib/structures/IType\n``` \n\n3. **Comprehensive Import Scan and Fix**: \n - **BEFORE fixing the reported error**, scan ALL import statements in the code \n - Identify ALL imports that follow incorrect patterns \n - Fix ALL of them simultaneously to prevent error loops \n - Ensure consistent `@ORGANIZATION/PROJECT-api` pattern throughout \n\n#### Module Resolution Fix Examples:\n\n```typescript\n// BEFORE (Multiple wrong patterns in same file):\nimport api from "@nestia/PROJECT-api";\nimport { IBbsArticle } from "@wrtnlabs/PROJECT-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@PROJECT-api/lib/structures/IAttachmentFile";\n\n// AFTER (All fixed consistently):\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@ORGANIZATION/PROJECT-api/lib/structures/IAttachmentFile";\n``` \n\n### 2. Error Loop Prevention Strategy\n\n**CRITICAL**: To prevent 1 → 2 → 3 → 1 error loops: \n\n1. **Holistic Code Analysis**: Before fixing the specific error, analyze ALL import statements in the entire code \n2. **Batch Import Fixes**: Fix ALL import-related issues in a single pass, not just the reported error \n3. **Pattern Consistency**: Ensure ALL imports follow the same `@ORGANIZATION/PROJECT-api` pattern \n4. **Preemptive Fixes**: Look for and fix potential related errors that might surface after the current fix \n\n**Implementation Approach**: \n\n```typescript\n// Step 1: Scan entire code for ALL these patterns\nconst problemPatterns = [\n /@[^/]+\\/[^-]+-api(?!\\/)/g, // Wrong org prefix\n /@[^-]+-api(?!\\/)/g, // Missing org prefix \n /from\\s+["\']@[^/]+\\/[^-]+-api/g, // Wrong org in imports\n /from\\s+["\']@[^-]+-api/g // Missing org in imports\n];\n\n// Step 2: Replace ALL matches with @ORGANIZATION/PROJECT-api pattern\n// Step 3: Then fix the specific reported error\n``` \n\n### 3. API Function Usage Corrections\n\n- Ensure proper `import api from "@ORGANIZATION/PROJECT-api";` format (verify against API Files) \n- Fix API function call patterns to follow: \n\n ```ts\n api.functional.[...].methodName(...)\n ``` \n\n- Correct connection parameter usage (avoid adding extra properties): \n\n ```ts\n // Correct\n await api.functional.bbs.articles.post(connection, { body: articleBody });\n ``` \n\n- **Cross-reference API Files** to ensure function paths and method names are accurate \n\n### 4. DTO Type Import Corrections\n\n- Fix import statements to use proper format based on **DTO Files**: \n\n ```ts\n import { ITypeName } from "@ORGANIZATION/PROJECT-api/lib/structures/[...].ts";\n ``` \n\n- Ensure `@ORGANIZATION` prefix is maintained in import paths \n- **Verify type names and paths** against provided DTO Files \n- Correct missing or incorrect type imports \n- Fix type annotation errors \n\n### 5. Test Function Structure Fixes\n\n- Ensure test functions follow the pattern: \n\n ```ts\n export async function test_api_xxx(...): Promise<void> { ... }\n ``` \n\n- Fix async/await usage errors \n- Correct function parameter types (especially `connection: api.IConnection`) \n\n### 6. Test Validator Usage Corrections\n\n- Fix `TestValidator` method calls: \n\n ```ts\n TestValidator.equals("title", exceptionFunction)(expected)(actual);\n TestValidator.predicate("title")(condition);\n TestValidator.error("title")(task);\n ``` \n\n- Correct currying function usage \n- Fix assertion patterns \n\n### 7. Typia Assert Corrections\n\n- Ensure proper `typia.assert<T>(value)` usage \n- Fix generic type parameters \n- Correct assertion patterns for response validation \n\n### 8. Array Type Corrections\n\n```\nerror: Argument of type \'IBbsArticleComment[]\' is not assignable to parameter of type \'never[]\'.\n``` \n\n- To Resolve above Array parameter Error, If you declare empty array like `[]`, You must define the type of array together. \n\nExample: \n\n ```typescript\n TestValidator.equals("message")(\n [] as IBbsArticleComment[],\n )(data);\n ``` \n\n### 9. Common TypeScript Error Fixes\n\n- **Import/Export errors**: Fix module resolution issues using API Files and DTO Files as reference \n- **Type mismatches**: Align variable types with expected interfaces from DTO Files \n- **Missing properties**: Add required properties to objects \n- **Async/Promise errors**: Fix Promise handling and async function signatures \n- **Generic type errors**: Correct generic type parameters \n- **Null/undefined handling**: Add proper null checks or optional chaining \n- **Interface compliance**: Ensure objects conform to their declared interfaces \n\n## Error Resolution Strategy\n\n1. **Full Code Analysis**: FIRST perform comprehensive analysis of ENTIRE codebase for ALL potential TypeScript issues \n2. **Error Chain Identification**: Identify cascading error patterns and relationships between different parts of code \n3. **Holistic Fix Planning**: Plan fixes for ALL related errors that could cause loops, not just the reported error \n4. **Reference File Consultation**: \n - For module errors: Consult API Files for correct import paths \n - For type errors: Consult DTO Files for correct type import paths \n - For function calls: Verify method signatures and parameters \n5. **Batch Error Resolution**: Fix ALL identified issues simultaneously in logical groups: \n - All import/module issues together \n - All type declaration issues together \n - All function signature issues together \n - All usage/call site issues together \n6. **Context Preservation**: Maintain the original test logic and flow \n7. **Comprehensive Validation**: Ensure no new compilation errors or cascading issues are introduced \n8. **Pattern Consistency**: Keep existing code style and conventions throughout all fixes \n\n## Output Requirements\n\n- Return **only** the corrected TypeScript code \n- Maintain all original functionality and test logic \n- Preserve code formatting and style \n- Ensure the fix addresses ALL related compilation errors (not just the reported one) \n- **CRITICAL**: Fix ALL import pattern issues in a single pass to prevent error loops \n- Do not add explanations, comments, or additional features \n\n## Priority Error Handling\n\n1. **Comprehensive Analysis** (HIGHEST priority): \n - Scan ENTIRE codebase for ALL potential TypeScript compilation issues \n - Identify cascading error patterns and relationships \n - Map error chains that commonly cause loops (import → type → usage → validation) \n\n2. **Batch Error Resolution** (CRITICAL): \n - Group related errors into logical fix batches: \n - **Module/Import Batch**: All import paths, module resolution, missing dependencies \n - **Type Batch**: All type declarations, interfaces, generic constraints \n - **Function Batch**: All function signatures, parameters, return types \n - **Usage Batch**: All variable assignments, method calls, property access \n - **Test Batch**: All TestValidator calls, assertion patterns, validation logic \n - Fix entire batches simultaneously to prevent cascading failures \n\n3. **Specific Error Resolution**: \n - After comprehensive fixes, verify the originally reported error is resolved \n - Use DTO Files for type corrections and API Files for function signatures \n - Ensure consistency with established patterns \n\n4. **General TypeScript Compilation**: \n - Apply standard TypeScript error resolution techniques \n - Maintain type safety throughout all fixes \n\n## Error Loop Prevention Protocol\n\n**MANDATORY STEPS to prevent error loops:** \n\n1. **Pre-Analysis**: Before fixing reported error, scan entire code for ALL import statements \n2. **Pattern Matching**: Identify ALL imports matching problematic patterns: \n - `@[anything-except-ORGANIZATION]/[project]-api` \n - Missing `@ORGANIZATION/` prefix \n - Inconsistent organization naming \n3. **Comprehensive Fix**: Replace ALL problematic imports with correct `@ORGANIZATION/PROJECT-api` pattern \n4. **Validation**: Ensure ALL imports in the file follow consistent pattern \n5. **Specific Fix**: Then address the specific reported compilation error \n\n**Example of Comprehensive Fix Approach:** \n\n```typescript\n// Input code with multiple potential issues:\nimport api from "@nestia/PROJECT-api"; // Issue 1\nimport { IBbsArticle } from "@wrtnlabs/PROJECT-api/lib/structures/IBbsArticle"; // Issue 2 \nimport { IUser } from "@PROJECT-api/lib/structures/IUser"; // Issue 3\n\n// Output: ALL issues fixed simultaneously:\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/IBbsArticle";\nimport { IUser } from "@ORGANIZATION/PROJECT-api/lib/structures/IUser";\n```'
9363
9327
  }, {
9364
9328
  id: v4(),
9365
9329
  created_at: (new Date).toISOString(),
9366
9330
  type: "assistantMessage",
9367
- text: [ "You are the world's best E2E test code generator.", "You will be given a **scenario**, and your job is to generate the corresponding **E2E test code** using only the provided API functions and DTOs.", "", "## Rules", "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.", "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.", "- Use `HubApi.functional.XXX` for all API calls. These are defined in API Files.", "- Use helper functions like `generate_random_xxx(...)` **only if** they already exist in the base test imports.", "- Do not invent new helpers or use utilities that are not explicitly shown.", "- Keep all tests deterministic and reliable.", "", "## File References", "### API Files", "```typescript", JSON.stringify(apiFiles, null, 2), "```", "", "### DTO Files", "```typescript", JSON.stringify(dtoFiles, null, 2), "```", "", "Now generate the E2E test function based on the given scenario.", "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary." ].join("\n")
9331
+ text: [ "You are the world's best TypeScript compiler error fixer.", "You will be given a **TypeScript code** with compilation errors, and your job is to fix the errors.", "", "## Rules", "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.", "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.", "- Use `api.functional.XXX` for all API calls. These are defined in API Files.", "- Use helper functions like `generate_random_xxx(...)` **only if** they already exist in the base test imports.", "- Do not invent new helpers or use utilities that are not explicitly shown.", "- Keep all tests deterministic and reliable.", "", "## File References", "### OpenAPI Like Document", "```json", JSON.stringify(document), "```", "", "Now Fix the E2E test function based on the given error information.", "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary." ].join("\n")
9368
9332
  } ];
9369
9333
 
9370
- async function orchestrateTestProgress(ctx, scenarios) {
9371
- const start = new Date;
9372
- let complete = 0;
9373
- const events = await Promise.all(scenarios.map((async scenario => {
9374
- const code = await process$1(ctx, scenario);
9375
- const event = {
9376
- type: "testProgress",
9377
- created_at: start.toISOString(),
9378
- filename: `${code.domain}/${scenario.functionName}.ts`,
9379
- content: code.content,
9380
- completed: ++complete,
9381
- total: scenarios.length,
9334
+ async function orchestrateTestCorrect(ctx, codes, scenarios, life = 4) {
9335
+ const scenarioMap = new Map;
9336
+ codes.forEach((({filename}, index) => {
9337
+ scenarioMap.set(filename, scenarios[index]);
9338
+ }));
9339
+ const testFiles = codes.map((({filename, content}) => ({
9340
+ [`test/features/api/${filename}`]: content
9341
+ }))).reduce(((acc, cur) => Object.assign(acc, cur)), {});
9342
+ const retainedFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => !filename.startsWith("test/features/api"))).map((([filename, content]) => ({
9343
+ [filename]: content
9344
+ }))).reduce(((acc, cur) => Object.assign(acc, cur)), {});
9345
+ const mergedFiles = {
9346
+ ...retainedFiles,
9347
+ ...testFiles
9348
+ };
9349
+ const files = Object.fromEntries(Object.entries(mergedFiles).filter((([filename]) => filename.endsWith(".ts") && !filename.startsWith("test/benchmark/") || filename.endsWith(".json"))));
9350
+ const response = await step(ctx, files, scenarioMap, life);
9351
+ const event = {
9352
+ ...response,
9353
+ type: "testValidate",
9354
+ files: {
9355
+ ...mergedFiles,
9356
+ ...response.files
9357
+ }
9358
+ };
9359
+ return event;
9360
+ }
9361
+
9362
+ async function step(ctx, files, scenarioMap, life) {
9363
+ const result = await ctx.compiler.typescript.compile({
9364
+ files
9365
+ });
9366
+ if (result.type === "success") {
9367
+ return {
9368
+ type: "testValidate",
9369
+ created_at: (new Date).toISOString(),
9370
+ files,
9371
+ result,
9382
9372
  step: ctx.state().interface?.step ?? 0
9383
9373
  };
9384
- ctx.dispatch(event);
9385
- return event;
9374
+ }
9375
+ if (result.type === "exception") {
9376
+ ctx.dispatch({
9377
+ type: "testValidate",
9378
+ created_at: (new Date).toISOString(),
9379
+ files,
9380
+ result,
9381
+ step: ctx.state().interface?.step ?? 0
9382
+ });
9383
+ throw new Error(JSON.stringify(result.error, null, 2));
9384
+ }
9385
+ const diagnostics = {};
9386
+ result.diagnostics.forEach((d => {
9387
+ if (d.file === null) return;
9388
+ diagnostics[d.file] = diagnostics[d.file] ?? [];
9389
+ diagnostics[d.file].push(d);
9390
+ }));
9391
+ if (Object.keys(diagnostics).length === 0) {
9392
+ return {
9393
+ type: "testValidate",
9394
+ created_at: (new Date).toISOString(),
9395
+ files,
9396
+ result: {
9397
+ ...result,
9398
+ type: "success"
9399
+ },
9400
+ step: ctx.state().interface?.step ?? 0
9401
+ };
9402
+ }
9403
+ ctx.dispatch({
9404
+ type: "testValidate",
9405
+ created_at: (new Date).toISOString(),
9406
+ files,
9407
+ result,
9408
+ step: ctx.state().interface?.step ?? 0
9409
+ });
9410
+ if (life <= 0) return {
9411
+ type: "testValidate",
9412
+ created_at: (new Date).toISOString(),
9413
+ files,
9414
+ result,
9415
+ step: ctx.state().interface?.step ?? 0
9416
+ };
9417
+ const validate = await Promise.all(Object.entries(diagnostics).map((async ([filename, d]) => {
9418
+ const scenario = scenarioMap.get(filename);
9419
+ const code = files[filename];
9420
+ const response = await process(ctx, d, code, scenario);
9421
+ ctx.dispatch({
9422
+ type: "testCorrect",
9423
+ created_at: (new Date).toISOString(),
9424
+ files: {
9425
+ ...files,
9426
+ [filename]: response.content
9427
+ },
9428
+ result,
9429
+ solution: response.solution,
9430
+ think_without_compile_error: response.think_without_compile_error,
9431
+ think_again_with_compile_error: response.think_again_with_compile_error,
9432
+ step: ctx.state().interface?.step ?? 0
9433
+ });
9434
+ return [ filename, response.content ];
9386
9435
  })));
9387
- return events;
9436
+ const newFiles = {
9437
+ ...files,
9438
+ ...Object.fromEntries(validate)
9439
+ };
9440
+ return step(ctx, newFiles, scenarioMap, life - 1);
9388
9441
  }
9389
9442
 
9390
- async function process$1(ctx, scenario) {
9443
+ async function process(ctx, diagnostics, code, scenario) {
9391
9444
  const pointer = {
9392
9445
  value: null
9393
9446
  };
9394
- const apiFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("src/api/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
9395
- [filename]: content
9396
- })), {});
9397
- const dtoFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("src/api/structures/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
9398
- [filename]: content
9399
- })), {});
9447
+ let document = null;
9448
+ if (scenario) {
9449
+ document = filterDocument(scenario, ctx.state().interface.document);
9450
+ }
9400
9451
  const agentica = new MicroAgentica({
9401
9452
  model: ctx.model,
9402
- vendor: ctx.vendor,
9453
+ vendor: {
9454
+ ...ctx.vendor
9455
+ },
9403
9456
  config: {
9404
9457
  ...ctx.config ?? {}
9405
9458
  },
9406
- histories: transformTestProgressHistories(apiFiles, dtoFiles),
9459
+ histories: transformTestCorrectHistories(document),
9407
9460
  controllers: [ createApplication$1({
9408
9461
  model: ctx.model,
9409
9462
  build: next => {
9410
9463
  pointer.value = next;
9411
9464
  }
9412
- }) ]
9465
+ }) ],
9466
+ tokenUsage: ctx.usage()
9413
9467
  });
9414
- agentica.on("request", (async event => {
9415
- if (event.body.tools) event.body.tool_choice = "required";
9468
+ enforceToolCall(agentica);
9469
+ await randomBackoffRetry((async () => {
9470
+ await agentica.conversate([ "Fix the compilation error in the provided code.", "", "## Original Code", "```typescript", code, "```", "", diagnostics.map((diagnostic => {
9471
+ if (diagnostic.start === undefined || diagnostic.length === undefined) return "";
9472
+ const checkDtoRegexp = `Cannot find module '@ORGANIZATION/template-api/lib/structures/IBbsArticleComment' or its corresponding type declarations.`;
9473
+ const [group] = [ ...checkDtoRegexp.matchAll(/Cannot find module '(.*lib\/structures\/.*)'/g) ];
9474
+ const [_, filename] = group ?? [];
9475
+ return [ "## Error Information", `- Position: Characters ${diagnostic.start} to ${diagnostic.start + diagnostic.length}`, `- Error Message: ${diagnostic.messageText}`, `- Problematic Code: \`${code.substring(diagnostic.start, diagnostic.start + diagnostic.length)}\``, filename ? `The type files located under **/lib/structures are declared in '@ORGANIZATION/PROJECT-api/lib/structures'.\n` + `Note: '@ORGANIZATION/PROJECT-api' must be written exactly as is and should not be replaced.\n` : "" ].join("\n");
9476
+ })), "## Instructions", "1. Focus on the specific error location and message", "2. Provide the corrected TypeScript code", "3. Ensure the fix resolves the compilation error", "", "Return only the fixed code without explanations." ].join("\n"));
9416
9477
  }));
9417
- await agentica.conversate([ "Create test code for below scenario:", "", "```json", JSON.stringify(scenario, null, 2), "```" ].join("\n"));
9418
- if (pointer.value === null) throw new Error("Failed to create test code.");
9478
+ if (pointer.value === null) throw new Error("Failed to modify test code.");
9419
9479
  return pointer.value;
9420
9480
  }
9421
9481
 
@@ -9424,10 +9484,10 @@ function createApplication$1(props) {
9424
9484
  const application = collection$2[props.model];
9425
9485
  return {
9426
9486
  protocol: "class",
9427
- name: "Create Test Code",
9487
+ name: "Modify Test Code",
9428
9488
  application,
9429
9489
  execute: {
9430
- createTestCode: next => {
9490
+ correctTestCode: next => {
9431
9491
  props.build(next);
9432
9492
  }
9433
9493
  }
@@ -9441,41 +9501,48 @@ const claude$2 = {
9441
9501
  separate: null
9442
9502
  },
9443
9503
  functions: [ {
9444
- name: "createTestCode",
9504
+ name: "correctTestCode",
9445
9505
  parameters: {
9446
- description: "Current Type: {@link ICreateTestCodeProps}",
9506
+ description: "Current Type: {@link ICorrectTestFunctionProps}",
9447
9507
  type: "object",
9448
9508
  properties: {
9449
- plan: {
9450
- title: "Strategic approach for test implementation",
9451
- description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception scenarios\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error scenarios (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the plan if it doesn't follow the Test Generation\n Guildelines.",
9509
+ think_without_compile_error: {
9510
+ description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages.",
9452
9511
  type: "string"
9453
9512
  },
9454
- domain: {
9455
- title: "Functional domain classification for test organization",
9456
- description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` → Article management operations\n- `comment` → Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` → User management operations\n- `payment` → Payment processing\n- `notification` → Notification system',
9513
+ think_again_with_compile_error: {
9514
+ description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
9515
+ type: "string"
9516
+ },
9517
+ solution: {
9518
+ title: "Step 3: Concrete action plan for fixing the identified issues",
9519
+ description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality.",
9457
9520
  type: "string"
9458
9521
  },
9459
9522
  content: {
9460
- title: "Complete TypeScript E2E test implementation",
9461
- description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
9523
+ title: "Step 4: The corrected TypeScript test code",
9524
+ description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct.",
9462
9525
  type: "string"
9463
9526
  }
9464
9527
  },
9465
- required: [ "plan", "domain", "content" ],
9528
+ required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9466
9529
  additionalProperties: false,
9467
9530
  $defs: {}
9468
9531
  },
9469
9532
  validate: (() => {
9470
- const _io0 = input => "string" === typeof input.plan && "string" === typeof input.domain && "string" === typeof input.content;
9471
- const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.plan || _report(_exceptionable, {
9472
- path: _path + ".plan",
9533
+ const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
9534
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9535
+ path: _path + ".think_without_compile_error",
9473
9536
  expected: "string",
9474
- value: input.plan
9475
- }), "string" === typeof input.domain || _report(_exceptionable, {
9476
- path: _path + ".domain",
9537
+ value: input.think_without_compile_error
9538
+ }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9539
+ path: _path + ".think_again_with_compile_error",
9477
9540
  expected: "string",
9478
- value: input.domain
9541
+ value: input.think_again_with_compile_error
9542
+ }), "string" === typeof input.solution || _report(_exceptionable, {
9543
+ path: _path + ".solution",
9544
+ expected: "string",
9545
+ value: input.solution
9479
9546
  }), "string" === typeof input.content || _report(_exceptionable, {
9480
9547
  path: _path + ".content",
9481
9548
  expected: "string",
@@ -9490,11 +9557,11 @@ const claude$2 = {
9490
9557
  _report = __typia_transform__validateReport._validateReport(errors);
9491
9558
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9492
9559
  path: _path + "",
9493
- expected: "ICreateTestCodeProps",
9560
+ expected: "ICorrectTestFunctionProps",
9494
9561
  value: input
9495
9562
  })) && _vo0(input, _path + "", true) || _report(true, {
9496
9563
  path: _path + "",
9497
- expected: "ICreateTestCodeProps",
9564
+ expected: "ICorrectTestFunctionProps",
9498
9565
  value: input
9499
9566
  }))(input, "$input", true);
9500
9567
  const success = 0 === errors.length;
@@ -9525,41 +9592,48 @@ const collection$2 = {
9525
9592
  separate: null
9526
9593
  },
9527
9594
  functions: [ {
9528
- name: "createTestCode",
9595
+ name: "correctTestCode",
9529
9596
  parameters: {
9530
- description: "Current Type: {@link ICreateTestCodeProps}",
9597
+ description: "Current Type: {@link ICorrectTestFunctionProps}",
9531
9598
  type: "object",
9532
9599
  properties: {
9533
- plan: {
9534
- title: "Strategic approach for test implementation",
9535
- description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception scenarios\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error scenarios (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the plan if it doesn't follow the Test Generation\n Guildelines.",
9600
+ think_without_compile_error: {
9601
+ description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages.",
9536
9602
  type: "string"
9537
9603
  },
9538
- domain: {
9539
- title: "Functional domain classification for test organization",
9540
- description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` → Article management operations\n- `comment` → Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` → User management operations\n- `payment` → Payment processing\n- `notification` → Notification system',
9604
+ think_again_with_compile_error: {
9605
+ description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
9606
+ type: "string"
9607
+ },
9608
+ solution: {
9609
+ title: "Step 3: Concrete action plan for fixing the identified issues",
9610
+ description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality.",
9541
9611
  type: "string"
9542
9612
  },
9543
9613
  content: {
9544
- title: "Complete TypeScript E2E test implementation",
9545
- description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
9614
+ title: "Step 4: The corrected TypeScript test code",
9615
+ description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct.",
9546
9616
  type: "string"
9547
9617
  }
9548
9618
  },
9549
- required: [ "plan", "domain", "content" ],
9619
+ required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9550
9620
  additionalProperties: false,
9551
9621
  $defs: {}
9552
9622
  },
9553
9623
  validate: (() => {
9554
- const _io0 = input => "string" === typeof input.plan && "string" === typeof input.domain && "string" === typeof input.content;
9555
- const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.plan || _report(_exceptionable, {
9556
- path: _path + ".plan",
9624
+ const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
9625
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9626
+ path: _path + ".think_without_compile_error",
9557
9627
  expected: "string",
9558
- value: input.plan
9559
- }), "string" === typeof input.domain || _report(_exceptionable, {
9560
- path: _path + ".domain",
9628
+ value: input.think_without_compile_error
9629
+ }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9630
+ path: _path + ".think_again_with_compile_error",
9561
9631
  expected: "string",
9562
- value: input.domain
9632
+ value: input.think_again_with_compile_error
9633
+ }), "string" === typeof input.solution || _report(_exceptionable, {
9634
+ path: _path + ".solution",
9635
+ expected: "string",
9636
+ value: input.solution
9563
9637
  }), "string" === typeof input.content || _report(_exceptionable, {
9564
9638
  path: _path + ".content",
9565
9639
  expected: "string",
@@ -9574,11 +9648,11 @@ const collection$2 = {
9574
9648
  _report = __typia_transform__validateReport._validateReport(errors);
9575
9649
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9576
9650
  path: _path + "",
9577
- expected: "ICreateTestCodeProps",
9651
+ expected: "ICorrectTestFunctionProps",
9578
9652
  value: input
9579
9653
  })) && _vo0(input, _path + "", true) || _report(true, {
9580
9654
  path: _path + "",
9581
- expected: "ICreateTestCodeProps",
9655
+ expected: "ICorrectTestFunctionProps",
9582
9656
  value: input
9583
9657
  }))(input, "$input", true);
9584
9658
  const success = 0 === errors.length;
@@ -9611,40 +9685,47 @@ const collection$2 = {
9611
9685
  separate: null
9612
9686
  },
9613
9687
  functions: [ {
9614
- name: "createTestCode",
9688
+ name: "correctTestCode",
9615
9689
  parameters: {
9616
9690
  type: "object",
9617
9691
  properties: {
9618
- plan: {
9692
+ think_without_compile_error: {
9619
9693
  type: "string",
9620
- title: "Strategic approach for test implementation",
9621
- description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception scenarios\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error scenarios (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the plan if it doesn't follow the Test Generation\n Guildelines."
9694
+ description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages."
9622
9695
  },
9623
- domain: {
9696
+ think_again_with_compile_error: {
9624
9697
  type: "string",
9625
- title: "Functional domain classification for test organization",
9626
- description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` → Article management operations\n- `comment` → Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` → User management operations\n- `payment` → Payment processing\n- `notification` → Notification system'
9698
+ description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong."
9699
+ },
9700
+ solution: {
9701
+ type: "string",
9702
+ title: "Step 3: Concrete action plan for fixing the identified issues",
9703
+ description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality."
9627
9704
  },
9628
9705
  content: {
9629
9706
  type: "string",
9630
- title: "Complete TypeScript E2E test implementation",
9631
- description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following"
9707
+ title: "Step 4: The corrected TypeScript test code",
9708
+ description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct."
9632
9709
  }
9633
9710
  },
9634
- required: [ "plan", "domain", "content" ],
9635
- description: "Current Type: {@link ICreateTestCodeProps}",
9711
+ required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9712
+ description: "Current Type: {@link ICorrectTestFunctionProps}",
9636
9713
  additionalProperties: false
9637
9714
  },
9638
9715
  validate: (() => {
9639
- const _io0 = input => "string" === typeof input.plan && "string" === typeof input.domain && "string" === typeof input.content;
9640
- const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.plan || _report(_exceptionable, {
9641
- path: _path + ".plan",
9716
+ const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
9717
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9718
+ path: _path + ".think_without_compile_error",
9642
9719
  expected: "string",
9643
- value: input.plan
9644
- }), "string" === typeof input.domain || _report(_exceptionable, {
9645
- path: _path + ".domain",
9720
+ value: input.think_without_compile_error
9721
+ }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9722
+ path: _path + ".think_again_with_compile_error",
9646
9723
  expected: "string",
9647
- value: input.domain
9724
+ value: input.think_again_with_compile_error
9725
+ }), "string" === typeof input.solution || _report(_exceptionable, {
9726
+ path: _path + ".solution",
9727
+ expected: "string",
9728
+ value: input.solution
9648
9729
  }), "string" === typeof input.content || _report(_exceptionable, {
9649
9730
  path: _path + ".content",
9650
9731
  expected: "string",
@@ -9659,11 +9740,11 @@ const collection$2 = {
9659
9740
  _report = __typia_transform__validateReport._validateReport(errors);
9660
9741
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9661
9742
  path: _path + "",
9662
- expected: "ICreateTestCodeProps",
9743
+ expected: "ICorrectTestFunctionProps",
9663
9744
  value: input
9664
9745
  })) && _vo0(input, _path + "", true) || _report(true, {
9665
9746
  path: _path + "",
9666
- expected: "ICreateTestCodeProps",
9747
+ expected: "ICorrectTestFunctionProps",
9667
9748
  value: input
9668
9749
  }))(input, "$input", true);
9669
9750
  const success = 0 === errors.length;
@@ -9686,148 +9767,259 @@ const collection$2 = {
9686
9767
  }
9687
9768
  };
9688
9769
 
9689
- const transformTestScenarioHistories = (state, endponits, files) => {
9690
- if (state.analyze === null) return [ {
9691
- id: v4(),
9692
- created_at: (new Date).toISOString(),
9693
- type: "systemMessage",
9694
- text: [ "Requirement analysis is not yet completed.", "Don't call the any tool function,", "but say to process the requirement analysis." ].join(" ")
9695
- } ]; else if (state.prisma === null) return [ {
9696
- id: v4(),
9697
- created_at: (new Date).toISOString(),
9698
- type: "systemMessage",
9699
- text: [ "Prisma DB schema generation is not yet completed.", "Don't call the any tool function,", "but say to process the Prisma DB schema generation." ].join(" ")
9700
- } ]; else if (state.analyze.step !== state.prisma.step) return [ {
9701
- id: v4(),
9702
- created_at: (new Date).toISOString(),
9703
- type: "systemMessage",
9704
- text: [ "Prisma DB schema generation has not been updated", "for the latest requirement analysis.", "Don't call the any tool function,", "but say to re-process the Prisma DB schema generation." ].join(" ")
9705
- } ]; else if (state.prisma.compiled.type !== "success") return [ {
9706
- id: v4(),
9707
- created_at: (new Date).toISOString(),
9708
- type: "systemMessage",
9709
- text: [ "Prisma DB schema generation has not been updated", "for the latest requirement analysis.", "Don't call the any tool function,", "but say to re-process the Prisma DB schema generation." ].join(" ")
9710
- } ]; else if (state.interface === null) return [ {
9711
- id: v4(),
9712
- created_at: (new Date).toISOString(),
9713
- type: "systemMessage",
9714
- text: [ "Interface generation is not yet completed.", "Don't call the any tool function,", "but say to process the interface generation." ].join(" ")
9715
- } ];
9716
- return [ {
9717
- id: v4(),
9718
- created_at: (new Date).toISOString(),
9719
- type: "systemMessage",
9720
- text: "# System Prompt: User Scenario Generator for API Endpoints\n\n## Role Definition\nYou are a world-class User Experience Analyst and Business Scenario Expert who specializes in analyzing API endpoints to generate comprehensive user scenarios from a pure user perspective. Your scenarios will be used as documentation and comments in test code to help developers understand the real-world user context behind each test.\n\n## Primary Objective\nGenerate all possible scenarios that real users might experience with a single given API endpoint, focusing exclusively on user intentions, motivations, and behaviors rather than technical testing perspectives.\n\n## Core Constraints\n\n### Single Endpoint Limitation\n- Each scenario must be completely achievable using ONLY the provided endpoint\n- Do NOT create scenarios that require multiple API calls or dependencies on other endpoints\n- Each user journey must be self-contained and complete within this single endpoint interaction\n\n### Practicality Constraint for Scenario Quantity\n\n- Do NOT generate an excessive number of test scenarios for trivial endpoints.\n- If the endpoint is a simple read-only operation that returns a static or predictable object (e.g. `{ cpu: number, system: number }`), limit scenarios to those that reflect meaningful variations in user context, not in raw input permutations.\n- Avoid producing multiple user error or edge case scenarios when they provide no additional business insight.\n- Prioritize business relevance over theoretical input diversity.\n- The goal is to maximize scenario value, not quantity.\n\n\n## Scenario Generation Principles\n\n### 1. Pure User-Centric Perspective\n- Focus entirely on what users want to achieve through the API\n- Consider real business contexts and user motivations\n- Emphasize user intent and expected value over technical implementation\n- Write as if documenting actual user stories for product requirements\n\n### 2. Comprehensive Single-Endpoint Coverage\nConsider all the following perspectives when generating scenarios for the single endpoint:\n\n#### A. Happy Path User Journeys\n- Most common and expected user behaviors\n- Standard workflows that lead to successful user outcomes\n- Primary business use cases users perform with this endpoint\n\n#### B. Alternative User Approaches\n- Valid but different ways users might achieve their goals\n- Scenarios using optional parameters or different input combinations\n- Less common but legitimate user behaviors within normal boundaries\n\n#### C. User Error Situations\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations\n\n#### D. Boundary User Behaviors\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n#### E. Contextual User Situations\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n### 3. Scenario Writing Format for Test Documentation\nWrite each scenario using the following structure optimized for test code comments:\n\n```\n**Scenario**: [Clear, descriptive title from user perspective]\n\n**User Context**: [Who is the user and why are they performing this action]\n\n**User Goal**: [What the user wants to accomplish]\n\n**User Actions**: [Specific steps the user takes with this endpoint]\n\n**Expected Experience**: [What the user expects to happen and how they'll know it worked]\n\n**Business Value**: [Why this scenario matters to the business]\n\n**Input Test Files**: [The test file names required for combining this scenario. If you have multiple files, connect them with commas.]\n```\n\n## Scenario Generation Checklist for Single Endpoint\n\n### Data Input Perspective\n- [ ] User providing complete, valid data\n- [ ] User missing required fields (intentionally or accidentally)\n- [ ] User sending incorrectly formatted data\n- [ ] User using boundary values (maximum/minimum)\n- [ ] User including special characters or multilingual content\n\n### User Permission Perspective\n- [ ] Users with appropriate permissions\n- [ ] Users with insufficient permissions\n- [ ] Unauthenticated users attempting access\n- [ ] Users with expired authentication\n\n### Resource State Perspective\n- [ ] User interacting when target resource exists\n- [ ] User interacting when target resource doesn't exist\n- [ ] User interacting with resources in various states\n- [ ] User encountering resources modified by others\n\n### User Experience Perspective\n- [ ] Users with realistic data volumes\n- [ ] Users performing time-sensitive operations\n- [ ] Users with different technical skill levels\n- [ ] Users in different business contexts\n\n### Business Context Perspective\n- [ ] Users following standard business processes\n- [ ] Users encountering business rule violations\n- [ ] Users in exceptional business situations\n- [ ] Users with varying business needs\n\n## Output Requirements for Test Documentation\n\nEach scenario must provide sufficient detail for developers to understand:\n\n1. **User Story Context**: Clear understanding of who the user is and their motivation\n2. **Business Justification**: Why this scenario matters for the product\n3. **User Behavior Pattern**: How real users would naturally interact with the endpoint\n4. **Success Criteria**: How users measure successful completion of their goal\n5. **Function Name Guidance**: Clear enough description to derive meaningful test function names\n\n## Quality Standards for Test Code Comments\n\n- Write scenarios that help developers empathize with real users\n- Focus on business value and user outcomes, not technical mechanics\n- Provide enough context that a developer can understand the user's situation\n- Ensure scenarios reflect realistic business situations\n- Make each scenario distinct and valuable for understanding user needs\n- Use language that both technical and non-technical stakeholders can understand\n\n## Guidelines\n\n- Avoid mentioning test code, assertions, or technical implementation details\n- Write purely from the user's perspective using narrative language\n- Create realistic scenarios that reflect actual business situations\n- Ensure scenarios are comprehensive yet practical for a single endpoint\n- Focus on user value and business outcomes\n- Make scenarios detailed enough to understand full user context\n\n## Expected Input\nYou will receive a single API endpoint specification including:\n- HTTP method and endpoint path\n- Request/response schemas\n- Authentication requirements\n- Parameter definitions\n- Business context when available\n\n## Expected Output\nFor the given API endpoint, provide:\n- Categorized user scenarios covering all perspectives mentioned above\n- Each scenario following the specified format for test documentation\n- Scenarios that are complete and achievable with only the single provided endpoint\n- Clear mapping between user intentions and the specific API operation\n- Sufficient detail to understand both user context and business value\n\n## Working Language\n- Default working language: English\n- Use the language specified by user in messages as the working language when explicitly provided\n- All thinking and responses must be in the working language\n- Maintain consistent perspective and tone throughout all scenarios"
9721
- }, {
9722
- id: v4(),
9723
- created_at: (new Date).toISOString(),
9724
- type: "systemMessage",
9725
- text: [ "# Result of Analyze Agent", "- The following document contains the user requirements that were extracted through conversations with the user by the Analyze Agent.", "- The database schema was designed based on these requirements, so you may refer to this document when writing test code or reviewing the schema.", "", `## User Request`, "", `- ${state.analyze.reason}`, "", `## Requirement Analysis Report`, "", "```json", JSON.stringify(state.analyze.files), "```" ].join("\n")
9726
- }, {
9727
- id: v4(),
9728
- created_at: (new Date).toISOString(),
9729
- type: "systemMessage",
9730
- text: [ "# Result of Prisma Agent", "- Given the following database schema and entity-relationship diagram, write appropriate test code to validate the constraints and relationships defined in the schema. For example, if there is a unique column, include a test that ensures its uniqueness.", "- The test code should strictly adhere to the schema and relationships—no violations of constraints should occur.", "- Use the information from the schema and diagram to design meaningful and accurate test cases.", "", "## Prisma DB Schema", "```json", JSON.stringify(state.prisma.schemas), "```", "", "## Entity Relationship Diagrams", "```json", JSON.stringify(state.prisma.compiled.diagrams), "```" ].join("\n")
9731
- }, {
9732
- id: v4(),
9733
- created_at: (new Date).toISOString(),
9734
- type: "systemMessage",
9735
- text: [ "# Result of Interfaced Agent", "- OpenAPI document generation is ready.", "", "Call the provided tool function to generate the user scenarios", "referencing below OpenAPI document.", "", `## OpenAPI Document`, "```json", JSON.stringify(state.interface.document), "```" ].join("\n")
9736
- }, {
9737
- id: v4(),
9738
- created_at: (new Date).toISOString(),
9739
- type: "systemMessage",
9740
- text: "# System Prompt: User Scenario Generator for API Endpoints\n\n## Role Definition\nYou are a world-class User Experience Analyst and Business Scenario Expert who specializes in analyzing API endpoints to generate comprehensive user scenarios from a pure user perspective. Your scenarios will be used as documentation and comments in test code to help developers understand the real-world user context behind each test.\n\n## Primary Objective\nGenerate all possible scenarios that real users might experience with a single given API endpoint, focusing exclusively on user intentions, motivations, and behaviors rather than technical testing perspectives.\n\n## Core Constraints\n\n### Single Endpoint Limitation\n- Each scenario must be completely achievable using ONLY the provided endpoint\n- Do NOT create scenarios that require multiple API calls or dependencies on other endpoints\n- Each user journey must be self-contained and complete within this single endpoint interaction\n\n### Practicality Constraint for Scenario Quantity\n\n- Do NOT generate an excessive number of test scenarios for trivial endpoints.\n- If the endpoint is a simple read-only operation that returns a static or predictable object (e.g. `{ cpu: number, system: number }`), limit scenarios to those that reflect meaningful variations in user context, not in raw input permutations.\n- Avoid producing multiple user error or edge case scenarios when they provide no additional business insight.\n- Prioritize business relevance over theoretical input diversity.\n- The goal is to maximize scenario value, not quantity.\n\n\n## Scenario Generation Principles\n\n### 1. Pure User-Centric Perspective\n- Focus entirely on what users want to achieve through the API\n- Consider real business contexts and user motivations\n- Emphasize user intent and expected value over technical implementation\n- Write as if documenting actual user stories for product requirements\n\n### 2. Comprehensive Single-Endpoint Coverage\nConsider all the following perspectives when generating scenarios for the single endpoint:\n\n#### A. Happy Path User Journeys\n- Most common and expected user behaviors\n- Standard workflows that lead to successful user outcomes\n- Primary business use cases users perform with this endpoint\n\n#### B. Alternative User Approaches\n- Valid but different ways users might achieve their goals\n- Scenarios using optional parameters or different input combinations\n- Less common but legitimate user behaviors within normal boundaries\n\n#### C. User Error Situations\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations\n\n#### D. Boundary User Behaviors\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n#### E. Contextual User Situations\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n### 3. Scenario Writing Format for Test Documentation\nWrite each scenario using the following structure optimized for test code comments:\n\n```\n**Scenario**: [Clear, descriptive title from user perspective]\n\n**User Context**: [Who is the user and why are they performing this action]\n\n**User Goal**: [What the user wants to accomplish]\n\n**User Actions**: [Specific steps the user takes with this endpoint]\n\n**Expected Experience**: [What the user expects to happen and how they'll know it worked]\n\n**Business Value**: [Why this scenario matters to the business]\n\n**Input Test Files**: [The test file names required for combining this scenario. If you have multiple files, connect them with commas.]\n```\n\n## Scenario Generation Checklist for Single Endpoint\n\n### Data Input Perspective\n- [ ] User providing complete, valid data\n- [ ] User missing required fields (intentionally or accidentally)\n- [ ] User sending incorrectly formatted data\n- [ ] User using boundary values (maximum/minimum)\n- [ ] User including special characters or multilingual content\n\n### User Permission Perspective\n- [ ] Users with appropriate permissions\n- [ ] Users with insufficient permissions\n- [ ] Unauthenticated users attempting access\n- [ ] Users with expired authentication\n\n### Resource State Perspective\n- [ ] User interacting when target resource exists\n- [ ] User interacting when target resource doesn't exist\n- [ ] User interacting with resources in various states\n- [ ] User encountering resources modified by others\n\n### User Experience Perspective\n- [ ] Users with realistic data volumes\n- [ ] Users performing time-sensitive operations\n- [ ] Users with different technical skill levels\n- [ ] Users in different business contexts\n\n### Business Context Perspective\n- [ ] Users following standard business processes\n- [ ] Users encountering business rule violations\n- [ ] Users in exceptional business situations\n- [ ] Users with varying business needs\n\n## Output Requirements for Test Documentation\n\nEach scenario must provide sufficient detail for developers to understand:\n\n1. **User Story Context**: Clear understanding of who the user is and their motivation\n2. **Business Justification**: Why this scenario matters for the product\n3. **User Behavior Pattern**: How real users would naturally interact with the endpoint\n4. **Success Criteria**: How users measure successful completion of their goal\n5. **Function Name Guidance**: Clear enough description to derive meaningful test function names\n\n## Quality Standards for Test Code Comments\n\n- Write scenarios that help developers empathize with real users\n- Focus on business value and user outcomes, not technical mechanics\n- Provide enough context that a developer can understand the user's situation\n- Ensure scenarios reflect realistic business situations\n- Make each scenario distinct and valuable for understanding user needs\n- Use language that both technical and non-technical stakeholders can understand\n\n## Guidelines\n\n- Avoid mentioning test code, assertions, or technical implementation details\n- Write purely from the user's perspective using narrative language\n- Create realistic scenarios that reflect actual business situations\n- Ensure scenarios are comprehensive yet practical for a single endpoint\n- Focus on user value and business outcomes\n- Make scenarios detailed enough to understand full user context\n\n## Expected Input\nYou will receive a single API endpoint specification including:\n- HTTP method and endpoint path\n- Request/response schemas\n- Authentication requirements\n- Parameter definitions\n- Business context when available\n\n## Expected Output\nFor the given API endpoint, provide:\n- Categorized user scenarios covering all perspectives mentioned above\n- Each scenario following the specified format for test documentation\n- Scenarios that are complete and achievable with only the single provided endpoint\n- Clear mapping between user intentions and the specific API operation\n- Sufficient detail to understand both user context and business value\n\n## Working Language\n- Default working language: English\n- Use the language specified by user in messages as the working language when explicitly provided\n- All thinking and responses must be in the working language\n- Maintain consistent perspective and tone throughout all scenarios"
9741
- }, {
9742
- id: v4(),
9743
- created_at: (new Date).toISOString(),
9744
- type: "systemMessage",
9745
- text: [ `This is a description of different APIs.`, `Different APIs may have to be called to create one.`, `Check which functions have been developed.`, "```json", JSON.stringify(endponits, null, 2), "```" ].join("\n")
9746
- }, {
9747
- id: v4(),
9748
- created_at: (new Date).toISOString(),
9749
- type: "systemMessage",
9750
- text: [ "Below is basically the generated test code,", "which is a test to verify that the API is simply called and successful.", "Since there is already an automatically generated API,", "when a user requests to create a test scenario, two or more APIs must be combined,", "but a test in which the currently given endpoint is the main must be created.", '"Input Test Files" should be selected from the list of files here.', "```json", JSON.stringify(files, null, 2), "```" ].join("\n")
9751
- } ];
9752
- };
9753
-
9754
9770
  async function orchestrateTestScenario(ctx) {
9755
- const files = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("test/features/api/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
9756
- [filename]: content
9757
- })), {});
9758
9771
  const operations = ctx.state().interface?.document.operations ?? [];
9759
- const endpoints = operations.map((it => ({
9760
- method: it.method,
9761
- path: it.path,
9762
- summary: it.summary,
9763
- description: it.description,
9764
- parameters: it.parameters,
9765
- requestBody: it.requestBody,
9766
- responseBody: it.responseBody
9767
- })));
9768
- const start = new Date;
9769
- let completed = 0;
9770
- const scenarios = await Promise.all(endpoints.map((async (endpoint, i, arr) => {
9771
- const endponits = arr.filter(((_el, j) => i !== j));
9772
- const rows = await process(ctx, endpoint, endponits, files);
9773
- ctx.dispatch({
9774
- type: "testScenario",
9775
- scenarios: rows,
9776
- total: rows.flatMap((el => el.scenarios)).length,
9777
- step: ctx.state().test?.step ?? 0,
9778
- completed,
9779
- created_at: start.toISOString()
9772
+ if (operations.length === 0) {
9773
+ throw new Error("Cannot write test scenarios because these are no operations.");
9774
+ }
9775
+ const exclude = [];
9776
+ let include = Array.from(operations);
9777
+ do {
9778
+ const matrix = divideArray({
9779
+ array: include,
9780
+ capacity: 30
9780
9781
  });
9781
- return rows;
9782
- })));
9782
+ await Promise.all(matrix.map((async _include => {
9783
+ exclude.push(...await execute(ctx, operations, _include, exclude.map((x => x.endpoint))));
9784
+ })));
9785
+ include = include.filter((op => {
9786
+ if (exclude.some((pg => pg.endpoint.method === op.method && pg.endpoint.path === op.path))) {
9787
+ return false;
9788
+ }
9789
+ return true;
9790
+ }));
9791
+ } while (include.length > 0);
9783
9792
  return {
9784
9793
  type: "testScenario",
9785
- scenarios: scenarios.flat(),
9786
- total: scenarios.flat().flatMap((el => el.scenarios)).length,
9787
- step: ctx.state().test?.step ?? 0,
9788
- completed,
9789
- created_at: start.toISOString()
9794
+ step: ctx.state().analyze?.step ?? 0,
9795
+ scenarios: exclude.flatMap((pg => pg.scenarios.map((plan => ({
9796
+ endpoint: pg.endpoint,
9797
+ draft: plan.draft,
9798
+ functionName: plan.functionName,
9799
+ dependencies: plan.dependsOn
9800
+ }))))),
9801
+ created_at: (new Date).toISOString()
9790
9802
  };
9791
9803
  }
9792
9804
 
9793
- async function process(ctx, endpoint, endpoints, files) {
9805
+ const execute = async (ctx, ops, include, exclude) => {
9794
9806
  const pointer = {
9795
- value: null
9807
+ value: []
9796
9808
  };
9797
9809
  const agentica = new MicroAgentica({
9798
9810
  model: ctx.model,
9799
9811
  vendor: ctx.vendor,
9800
9812
  config: {
9801
- ...ctx.config ?? {
9802
- locale: "en-US"
9803
- },
9804
- systemPrompt: {
9805
- describe: () => "Answer only 'completion' or 'failure'."
9813
+ ...ctx.config ?? {},
9814
+ executor: {
9815
+ describe: null
9806
9816
  }
9807
9817
  },
9808
9818
  tokenUsage: ctx.usage(),
9809
- histories: [ ...transformTestScenarioHistories(ctx.state(), endpoints, files) ],
9819
+ histories: createHistoryProperties(ops, include, exclude),
9810
9820
  controllers: [ createApplication({
9811
9821
  model: ctx.model,
9812
9822
  build: next => {
9813
- pointer.value = next.scenarios;
9823
+ pointer.value ?? (pointer.value = []);
9824
+ pointer.value.push(...next.scenarioGroups);
9814
9825
  }
9815
9826
  }) ]
9816
9827
  });
9817
- agentica.on("request", (async event => {
9818
- if (event.body.tools) event.body.tool_choice = "required";
9819
- }));
9820
- await agentica.conversate([ "Make User Scenarios for below endpoint:", "", "```json", JSON.stringify(endpoint, null, 2), "```" ].join("\n"));
9821
- if (pointer.value === null) throw new Error("Failed to make scenarios.");
9828
+ enforceToolCall(agentica);
9829
+ await agentica.conversate(`create test scenarios.`);
9830
+ if (pointer.value.length === 0) {
9831
+ throw new Error("Failed to create test plans.");
9832
+ }
9822
9833
  return pointer.value;
9823
- }
9834
+ };
9835
+
9836
+ const createHistoryProperties = (operations, include, exclude) => [ {
9837
+ id: v4(),
9838
+ created_at: (new Date).toISOString(),
9839
+ type: "systemMessage",
9840
+ text: 'You are the AutoAPI Test Scenario Generator.\n\nYour job is to analyze an array of API operation objects and generate realistic, structured test scenario drafts for each operation.\n\n---\n\n## Input Format\n\nYou will receive an array of `Operation` objects structured like this:\n\n```ts\n{\n method: "post" | "get" | "put" | "patch" | "delete",\n path: "/path/to/resource",\n specification: string, // API specification with business logic and constraints\n description: string, // Multi-paragraph description\n summary: string, // One-line summary\n parameters: [...], // List of path/query/body parameters\n requestBody?: {\n typeName: string,\n description: string\n },\n responseBody: {\n typeName: string,\n description: string\n }\n}\n```\n\n---\n\n## Output Format\n\nYour output must be an array of grouped test plans, using the following structure:\n\n```ts\n[\n {\n method: "post",\n path: "/shopping/products",\n plans: [\n {\n draft: "Test product creation by submitting two requests with the same product.pid. Confirm that the second request returns a uniqueness constraint error.",\n dependsOn: [\n {\n method: "post",\n path: "/shopping/categories",\n purpose: "Create a category beforehand so the product can reference it."\n },\n {\n method: "get",\n path: "/users/me",\n purpose: "Verify a valid user session and obtain user context for the test."\n }\n ]\n },\n {\n draft: "Verify that missing required fields like \'name\' or \'price\' trigger appropriate validation errors.",\n dependsOn: []\n }\n ]\n },\n {\n method: "patch",\n path: "/shopping/products/{productId}",\n plans: [\n {\n draft: "Attempt to update a product with an invalid productId and expect a 404 error.",\n dependsOn: []\n }\n ]\n }\n]\n```\n\n- Each top-level object is a **plan group** for a single unique endpoint (`method + path`).\n- The `plans` array contains **one or more test drafts** for that endpoint.\n- Each `draft` may list its **prerequisite API calls** in the `dependsOn` array, which includes `method`, `path`, and a `purpose` for context.\n\n---\n\n### ✅ **Uniqueness Rule**\n\n> ⚠️ **Each `{method} + {path}` combination must appear only once** in the output array.\n> This means **you must not create multiple plan groups with the same HTTP method and path.**\n\n* Treat each `{method} + {path}` pair as a **unique test identifier**.\n* All test plans (`plans`) related to the same endpoint must be **grouped under a single PlanGroup object**.\n* Duplicating PlanGroups for the same endpoint will lead to invalid output.\n\n**✅ Good:**\n\n```ts\n[\n {\n method: "patch",\n path: "/blog/posts/{postId}",\n plans: [\n { draft: "...", dependsOn: [...] },\n { draft: "...", dependsOn: [...] }\n ]\n }\n]\n```\n\n**❌ Bad:**\n\n```ts\n[\n {\n method: "patch",\n path: "/blog/posts/{postId}",\n plans: [ ... ]\n },\n {\n method: "patch",\n path: "/blog/posts/{postId}", // Duplicate! Not allowed.\n plans: [ ... ]\n }\n]\n```\n\n---\n\n## Writing Guidelines\n\n1. **draft**:\n - Write a clear and realistic test plan for the operation.\n - Include both success and failure cases where applicable.\n - Incorporate constraints mentioned in the API description such as uniqueness, foreign key requirements, or authentication.\n - For complex operations, include multiple steps within the same `draft` string (e.g., create → verify → delete).\n\n2. **dependsOn**:\n - List other API operations that must be invoked before this test can be executed.\n - Each item must include `method`, `path`, and `purpose`.\n - The `purpose` field should explain *why* the dependency is needed in the test setup.\n\n3. Treat each `{method} + {path}` combination as a unique test identifier.\n\n---\n\n## Purpose\n\nThese test scenario objects are designed to support QA engineers and backend developers in planning automated or manual tests. Each test draft reflects the core functionality and business rules of the API to ensure robust system behavior.'
9841
+ }, {
9842
+ id: v4(),
9843
+ created_at: (new Date).toISOString(),
9844
+ type: "systemMessage",
9845
+ text: [ "Below are the full operations. Please refer to this.", "Your role is to draft all test cases for each given Operation.", "It is also permissible to write multiple test codes on a single endpoint.", "However, rather than meaningless tests, business logic tests should be written and an E2E test situation should be assumed.", "", "```json", JSON.stringify(operations.map((el => ({
9846
+ path: el.path,
9847
+ method: el.method,
9848
+ summary: el.summary
9849
+ })))), "```" ].join("\n")
9850
+ }, {
9851
+ id: v4(),
9852
+ created_at: (new Date).toISOString(),
9853
+ type: "systemMessage",
9854
+ text: [ "# Included in Test Plan", include.map((el => `- ${el.method.toUpperCase()}: ${el.path}`)).join("\n"), "", "# Excluded from Test Plan", "These are the endpoints that have already been used in test codes generated as part of a plan group.", "These endpoints do not need to be tested again.", "However, it is allowed to reference or depend on these endpoints when writing test codes for other purposes.", exclude.map((el => `- ${el.method.toUpperCase()}: ${el.path}`)).join("\n") ].join("\n")
9855
+ } ];
9824
9856
 
9825
9857
  function createApplication(props) {
9826
9858
  assertSchemaModel(props.model);
9827
9859
  const application = collection$1[props.model];
9860
+ application.functions[0].validate = next => {
9861
+ const result = (() => {
9862
+ const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
9863
+ const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
9864
+ const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
9865
+ const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
9866
+ const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
9867
+ const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
9868
+ path: _path + ".scenarioGroups",
9869
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
9870
+ value: input.scenarioGroups
9871
+ })) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
9872
+ path: _path + ".scenarioGroups[" + _index4 + "]",
9873
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
9874
+ value: elem
9875
+ })) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
9876
+ path: _path + ".scenarioGroups[" + _index4 + "]",
9877
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
9878
+ value: elem
9879
+ }))).every((flag => flag)) || _report(_exceptionable, {
9880
+ path: _path + ".scenarioGroups",
9881
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
9882
+ value: input.scenarioGroups
9883
+ }) ].every((flag => flag));
9884
+ const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
9885
+ path: _path + ".endpoint",
9886
+ expected: "AutoBeOpenApi.IEndpoint",
9887
+ value: input.endpoint
9888
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
9889
+ path: _path + ".endpoint",
9890
+ expected: "AutoBeOpenApi.IEndpoint",
9891
+ value: input.endpoint
9892
+ }), (Array.isArray(input.scenarios) || _report(_exceptionable, {
9893
+ path: _path + ".scenarios",
9894
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
9895
+ value: input.scenarios
9896
+ })) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
9897
+ path: _path + ".scenarios[" + _index5 + "]",
9898
+ expected: "IAutoBeTestScenarioApplication.IScenario",
9899
+ value: elem
9900
+ })) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
9901
+ path: _path + ".scenarios[" + _index5 + "]",
9902
+ expected: "IAutoBeTestScenarioApplication.IScenario",
9903
+ value: elem
9904
+ }))).every((flag => flag)) || _report(_exceptionable, {
9905
+ path: _path + ".scenarios",
9906
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
9907
+ value: input.scenarios
9908
+ }) ].every((flag => flag));
9909
+ const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
9910
+ path: _path + ".path",
9911
+ expected: "string",
9912
+ value: input.path
9913
+ }), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, {
9914
+ path: _path + ".method",
9915
+ expected: '("delete" | "get" | "patch" | "post" | "put")',
9916
+ value: input.method
9917
+ }) ].every((flag => flag));
9918
+ const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
9919
+ path: _path + ".draft",
9920
+ expected: "string",
9921
+ value: input.draft
9922
+ }), "string" === typeof input.functionName || _report(_exceptionable, {
9923
+ path: _path + ".functionName",
9924
+ expected: "string",
9925
+ value: input.functionName
9926
+ }), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
9927
+ path: _path + ".dependsOn",
9928
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
9929
+ value: input.dependsOn
9930
+ })) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
9931
+ path: _path + ".dependsOn[" + _index6 + "]",
9932
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
9933
+ value: elem
9934
+ })) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
9935
+ path: _path + ".dependsOn[" + _index6 + "]",
9936
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
9937
+ value: elem
9938
+ }))).every((flag => flag)) || _report(_exceptionable, {
9939
+ path: _path + ".dependsOn",
9940
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
9941
+ value: input.dependsOn
9942
+ }) ].every((flag => flag));
9943
+ const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
9944
+ path: _path + ".endpoint",
9945
+ expected: "AutoBeOpenApi.IEndpoint",
9946
+ value: input.endpoint
9947
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
9948
+ path: _path + ".endpoint",
9949
+ expected: "AutoBeOpenApi.IEndpoint",
9950
+ value: input.endpoint
9951
+ }), "string" === typeof input.purpose || _report(_exceptionable, {
9952
+ path: _path + ".purpose",
9953
+ expected: "string",
9954
+ value: input.purpose
9955
+ }) ].every((flag => flag));
9956
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
9957
+ let errors;
9958
+ let _report;
9959
+ return input => {
9960
+ if (false === __is(input)) {
9961
+ errors = [];
9962
+ _report = __typia_transform__validateReport._validateReport(errors);
9963
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9964
+ path: _path + "",
9965
+ expected: "IAutoBeTestScenarioApplication.IProps",
9966
+ value: input
9967
+ })) && _vo0(input, _path + "", true) || _report(true, {
9968
+ path: _path + "",
9969
+ expected: "IAutoBeTestScenarioApplication.IProps",
9970
+ value: input
9971
+ }))(input, "$input", true);
9972
+ const success = 0 === errors.length;
9973
+ return success ? {
9974
+ success,
9975
+ data: input
9976
+ } : {
9977
+ success,
9978
+ errors,
9979
+ data: input
9980
+ };
9981
+ }
9982
+ return {
9983
+ success: true,
9984
+ data: input
9985
+ };
9986
+ };
9987
+ })()(next);
9988
+ if (result.success === false) return result;
9989
+ const errors = [];
9990
+ result.data.scenarioGroups.forEach(((pg, i, arr) => {
9991
+ arr.forEach(((target, j) => {
9992
+ if (i !== j && target.endpoint.method === pg.endpoint.method && target.endpoint.path === pg.endpoint.path) {
9993
+ if (!errors.some((el => el.path !== `planGroups[${j}].path` && el.value !== target.endpoint.path))) {
9994
+ errors.push({
9995
+ path: `planGroups[${j}].path`,
9996
+ expected: `planGroup's {method + path} cannot duplicated.`,
9997
+ value: target.endpoint.path
9998
+ });
9999
+ }
10000
+ if (!errors.some((el => el.path !== `planGroups[${j}].method` && el.value !== target.endpoint.method))) {
10001
+ errors.push({
10002
+ path: `planGroups[${j}].method`,
10003
+ expected: `planGroup's {method + path} cannot duplicated.`,
10004
+ value: target.endpoint.method
10005
+ });
10006
+ }
10007
+ }
10008
+ }));
10009
+ }));
10010
+ if (errors.length !== 0) {
10011
+ console.log(JSON.stringify(errors, null, 2), "errors");
10012
+ return {
10013
+ success: false,
10014
+ errors,
10015
+ data: next
10016
+ };
10017
+ }
10018
+ return result;
10019
+ };
9828
10020
  return {
9829
10021
  protocol: "class",
9830
- name: "Make User Scenarios",
10022
+ name: "Make test plans",
9831
10023
  application,
9832
10024
  execute: {
9833
10025
  makeScenario: next => {
@@ -9846,19 +10038,19 @@ const claude$1 = {
9846
10038
  functions: [ {
9847
10039
  name: "makeScenario",
9848
10040
  parameters: {
9849
- description: " Properties containing the endpoints and user scenarios.\n\n------------------------------\n\nCurrent Type: {@link IMakeScenarioProps}",
10041
+ description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
9850
10042
  type: "object",
9851
10043
  properties: {
9852
- scenarios: {
9853
- title: "Array of user scenarios",
9854
- description: "Array of user scenarios.",
10044
+ scenarioGroups: {
10045
+ title: "Array of test scenario groups",
10046
+ description: "Array of test scenario groups.",
9855
10047
  type: "array",
9856
10048
  items: {
9857
- description: "Current Type: {@link AutoBeTest.IScenario}",
10049
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
9858
10050
  type: "object",
9859
10051
  properties: {
9860
10052
  endpoint: {
9861
- description: "Target API endpoint for user scenario generation.\n\nThis represents the single API endpoint that will be analyzed to generate\ncomprehensive user scenarios. The endpoint contains all technical\nspecifications needed to understand user interactions, including HTTP\nmethods, paths, parameters, request/response schemas, and authentication\nrequirements.\n\n## Core Purpose\n\n- Serves as the foundation for user-centric scenario generation\n- Contains complete API specification for understanding user capabilities\n- Provides schema constraints for realistic user data generation\n- Defines authentication and permission requirements for user context\n\n## User Scenario Context\n\nThis endpoint information enables generation of scenarios that consider:\n\n- What users can realistically accomplish with this endpoint\n- How users would naturally interact with the API functionality\n- What business value users seek from this endpoint\n- What constraints and limitations users will encounter\n- How authentication affects user access patterns\n- What data formats users need to provide or expect to receive\n\n## Single Endpoint Constraint\n\nEach scenario generated must interact with ONLY this endpoint. Scenarios\nshould not assume or require calls to other endpoints, ensuring each user\njourney is complete and testable in isolation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10053
+ description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
9862
10054
  type: "object",
9863
10055
  properties: {
9864
10056
  path: {
@@ -9885,24 +10077,66 @@ const claude$1 = {
9885
10077
  required: [ "path", "method" ]
9886
10078
  },
9887
10079
  scenarios: {
9888
- title: "Comprehensive collection of user-centric scenarios for the endpoint",
9889
- description: "Comprehensive collection of user-centric scenarios for the endpoint.\n\nEach scenario represents a realistic user journey, intention, or\nsituation when interacting with this specific API endpoint. All scenarios\nare written from the user's perspective, focusing on what they want to\nachieve and how they naturally interact with the API functionality.\n\n## Scenario Coverage Framework\n\nThe scenarios must comprehensively cover all user interaction patterns:\n\n### 1. Happy Path User Journeys\n\n- Primary business use cases that users commonly perform\n- Standard workflows leading to successful user outcomes\n- Typical user behaviors with valid inputs and proper permissions\n- Most frequent user intentions and expected interactions\n\n### 2. Alternative User Approaches\n\n- Valid alternative ways users might achieve their goals\n- User scenarios utilizing optional parameters or different input patterns\n- Less common but legitimate user behaviors within normal boundaries\n- User experimentation with available API features\n\n### 3. User Error Situations\n\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations (rate limits, quotas)\n\n### 4. Boundary User Behaviors\n\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n### 5. Contextual User Situations\n\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n## User-Centric Quality Standards\n\nEach scenario must:\n\n- Focus entirely on user motivation, context, and expected outcomes\n- Describe realistic business situations users actually encounter\n- Include clear user intent and the value they seek\n- Specify user-provided data and user-expected results\n- Be complete within the single endpoint constraint\n- Provide sufficient context for understanding user behavior patterns\n- Avoid technical implementation details or testing terminology\n\n## Single Endpoint Constraint Application\n\nEvery scenario must:\n\n- Complete the entire user journey using only this one endpoint\n- Not depend on or reference other API endpoints\n- Include all necessary context within the scenario itself\n- Represent a complete, self-contained user interaction\n\n## Business Value Focus\n\nThese user scenarios ensure:\n\n- Understanding of real user needs and behaviors\n- Comprehensive coverage of user interaction patterns\n- Proper handling of user errors and edge cases\n- Appropriate user feedback and experience design\n- Business rule validation from user perspective\n- Security and permission handling for different user contexts",
10080
+ title: "Array of test scenarios",
10081
+ description: "Array of test scenarios.",
9890
10082
  type: "array",
9891
10083
  items: {
9892
- description: "Current Type: {@link AutoBeTest.Scenario}",
10084
+ description: "Description of the current {@link IAutoBeTestScenarioApplication.IScenario} type:\n\n> Represents a test scenario for a single API operation.\n> \n> This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP\n> method and path information, and adds two key properties:\n> \n> - `draft`: A free-form, human-readable test scenario description for the API\n> endpoint.\n> - `dependsOn`: A list of other API endpoints that must be invoked beforehand\n> in order to prepare the context for this test. Each dependency includes\n> the purpose of the dependency.\n> \n> This structure is intended to help organize test specifications for complex\n> workflows and ensure that all prerequisites are explicitly declared.",
9893
10085
  type: "object",
9894
10086
  properties: {
10087
+ draft: {
10088
+ description: "A detailed natural language description of how this API endpoint should\nbe tested. This should include both successful and failure scenarios,\nbusiness rule validations, edge cases, and any sequence of steps\nnecessary to perform the test. A subsequent agent will use this draft to\ngenerate multiple test scenarios.",
10089
+ type: "string"
10090
+ },
9895
10091
  functionName: {
9896
10092
  title: "Descriptive function name derived from the user scenario",
9897
10093
  description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\n- Must start with `test_` prefix (mandatory requirement)\n- Use snake_case formatting throughout\n- Include the primary user action (create, get, update, delete, list, etc.)\n- Specify the target resource (user, product, order, profile, etc.)\n- Add scenario-specific context (valid_data, invalid_email, not_found,\n etc.)\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_[user_action]_[resource]_[scenario_context]`\n\nWhere:\n\n- `user_action`: What the user is trying to do\n- `resource`: What the user is interacting with\n- `scenario_context`: The specific situation or condition\n\n## User-Focused Examples\n\n- `test_create_user_profile_with_complete_information` - User providing all\n available profile data\n- `test_retrieve_user_profile_when_profile_exists` - User accessing their\n existing profile\n- `test_update_user_email_with_valid_new_address` - User changing their\n email to a valid new one\n- `test_delete_user_account_when_user_lacks_permission` - User attempting\n account deletion without authorization\n- `test_search_user_profiles_with_pagination_preferences` - User browsing\n profiles with specific pagination\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions",
9898
10094
  type: "string"
9899
10095
  },
9900
- scenario: {
9901
- description: "Comprehensive user scenario description written from pure user\nperspective.\n\nThis describes a complete user journey, motivation, and expected outcome\nwhen interacting with the API endpoint. The description focuses entirely\non user intent, context, and natural behavior patterns rather than\ntechnical testing considerations.\n\n## User-Centric Writing Approach\n\n- Write as if describing a real person's experience and motivation\n- Focus on business context and user goals, not system functionality\n- Use natural language that business stakeholders would understand\n- Emphasize user value and expected benefits\n- Avoid technical terminology or implementation details\n\n## Required Content Elements\n\nEach scenario description must include:\n\n### 1. User Context and Motivation\n\n- Who is the user (role, background, current situation)\n- Why they need to perform this action (business motivation)\n- What problem they're trying to solve or goal they want to achieve\n- Any relevant background circumstances or constraints\n\n### 2. User Actions and Behavior\n\n- Specific steps the user takes to accomplish their goal\n- What information or data the user provides\n- How the user naturally approaches the interaction\n- Any decision-making process the user goes through\n\n### 3. User Expectations and Desired Outcomes\n\n- What the user expects to happen as a result\n- How the user will know if they were successful\n- What value or benefit the user expects to receive\n- How this fits into their broader workflow or objectives\n\n### 4. Business Impact and Value\n\n- How this scenario relates to business objectives\n- What business processes or workflows this supports\n- Why this user behavior matters to the organization\n- What risks or opportunities this scenario represents\n\n## Single Endpoint Constraint Integration\n\nEach scenario must:\n\n- Represent a complete user journey achievable through this single endpoint\n- Include all necessary context without referencing other API operations\n- Describe user expectations based solely on this endpoint's capabilities\n- Avoid scenarios that would logically require multiple API calls\n\n## Quality and Realism Standards\n\n- Base scenarios on realistic business situations\n- Include specific, concrete details rather than generic descriptions\n- Ensure scenarios reflect actual user behaviors and motivations\n- Make each scenario distinct and valuable for understanding user needs\n- Provide enough detail to understand full context without being verbose\n\n## User-Focused Example Scenarios\n\n- \"A busy project manager needs to quickly create a new team member's user\n account during an onboarding meeting. They have all the necessary\n information readily available and expect the account to be immediately\n active so the new employee can start working right away.\"\n- \"A customer support representative is helping a customer who forgot their\n login credentials. The customer provides their email address, and the\n representative expects to quickly retrieve the associated account\n information to assist with password recovery.\"\n- \"A system administrator discovers that a former employee's account is\n still active after their departure. They need to immediately deactivate\n this account for security purposes and expect confirmation that the\n account can no longer be used to access company resources.\"\n\n## Language and Tone\n\n- Use active voice and present tense when describing user actions\n- Write in a narrative style that tells the user's story\n- Balance professional tone with human context\n- Ensure accessibility for both technical and non-technical readers\n- Maintain consistency in perspective throughout the description",
9902
- type: "string"
10096
+ dependsOn: {
10097
+ description: "A list of other API endpoints that must be executed before this test\nscenario. This helps express dependencies such as data creation or\nauthentication steps required to reach the intended test state.",
10098
+ type: "array",
10099
+ items: {
10100
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
10101
+ type: "object",
10102
+ properties: {
10103
+ endpoint: {
10104
+ description: "Target API endpoint that must be executed before the main operation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10105
+ type: "object",
10106
+ properties: {
10107
+ path: {
10108
+ title: "HTTP path of the API operation",
10109
+ description: "HTTP path of the API operation.\n\nThe URL path for accessing this API operation, using path parameters\nenclosed in curly braces (e.g., `/shoppings/customers/sales/{saleId}`).\n\nIt must be corresponded to the {@link parameters path parameters}.\n\nThe path structure should clearly indicate which database entity this\noperation is manipulating, helping to ensure all entities have\nappropriate API coverage.",
10110
+ type: "string"
10111
+ },
10112
+ method: {
10113
+ title: "HTTP method of the API operation",
10114
+ description: "HTTP method of the API operation.\n\nNote that, if the API operation has {@link requestBody}, method must not\nbe `get`.\n\nAlso, even though the API operation has been designed to only get\ninformation, but it needs complicated request information, it must be\ndefined as `patch` method with {@link requestBody} data specification.\n\n- `get`: get information\n- `patch`: get information with complicated request data\n ({@link requestBody})\n- `post`: create new record\n- `put`: update existing record\n- `delete`: remove record",
10115
+ oneOf: [ {
10116
+ const: "get"
10117
+ }, {
10118
+ const: "post"
10119
+ }, {
10120
+ const: "put"
10121
+ }, {
10122
+ const: "delete"
10123
+ }, {
10124
+ const: "patch"
10125
+ } ]
10126
+ }
10127
+ },
10128
+ required: [ "path", "method" ]
10129
+ },
10130
+ purpose: {
10131
+ description: 'A concise exscenarioation of why this API call is required before\nexecuting the test for the main operation.\n\nExample: "Creates a category so that a product can be linked to it during\ncreation."',
10132
+ type: "string"
10133
+ }
10134
+ },
10135
+ required: [ "endpoint", "purpose" ]
10136
+ }
9903
10137
  }
9904
10138
  },
9905
- required: [ "functionName", "scenario" ]
10139
+ required: [ "draft", "functionName", "dependsOn" ]
9906
10140
  }
9907
10141
  }
9908
10142
  },
@@ -9910,32 +10144,33 @@ const claude$1 = {
9910
10144
  }
9911
10145
  }
9912
10146
  },
9913
- required: [ "scenarios" ],
10147
+ required: [ "scenarioGroups" ],
9914
10148
  additionalProperties: false,
9915
10149
  $defs: {}
9916
10150
  },
9917
- description: "Make user scenarios for the given endpoints.",
10151
+ description: "Make test scenarios for the given endpoints.",
9918
10152
  validate: (() => {
9919
- const _io0 = input => Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
10153
+ const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
9920
10154
  const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
9921
10155
  const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
9922
- const _io3 = input => "string" === typeof input.functionName && "string" === typeof input.scenario;
9923
- const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarios) || _report(_exceptionable, {
9924
- path: _path + ".scenarios",
9925
- expected: "Array<AutoBeTest.IScenario>",
9926
- value: input.scenarios
9927
- })) && input.scenarios.map(((elem, _index3) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
9928
- path: _path + ".scenarios[" + _index3 + "]",
9929
- expected: "AutoBeTest.IScenario",
10156
+ const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
10157
+ const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
10158
+ const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
10159
+ path: _path + ".scenarioGroups",
10160
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10161
+ value: input.scenarioGroups
10162
+ })) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10163
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10164
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
9930
10165
  value: elem
9931
- })) && _vo1(elem, _path + ".scenarios[" + _index3 + "]", _exceptionable) || _report(_exceptionable, {
9932
- path: _path + ".scenarios[" + _index3 + "]",
9933
- expected: "AutoBeTest.IScenario",
10166
+ })) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10167
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10168
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
9934
10169
  value: elem
9935
10170
  }))).every((flag => flag)) || _report(_exceptionable, {
9936
- path: _path + ".scenarios",
9937
- expected: "Array<AutoBeTest.IScenario>",
9938
- value: input.scenarios
10171
+ path: _path + ".scenarioGroups",
10172
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10173
+ value: input.scenarioGroups
9939
10174
  }) ].every((flag => flag));
9940
10175
  const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
9941
10176
  path: _path + ".endpoint",
@@ -9947,19 +10182,19 @@ const claude$1 = {
9947
10182
  value: input.endpoint
9948
10183
  }), (Array.isArray(input.scenarios) || _report(_exceptionable, {
9949
10184
  path: _path + ".scenarios",
9950
- expected: "Array<AutoBeTest.Scenario>",
10185
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
9951
10186
  value: input.scenarios
9952
- })) && input.scenarios.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
9953
- path: _path + ".scenarios[" + _index4 + "]",
9954
- expected: "AutoBeTest.Scenario",
10187
+ })) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10188
+ path: _path + ".scenarios[" + _index5 + "]",
10189
+ expected: "IAutoBeTestScenarioApplication.IScenario",
9955
10190
  value: elem
9956
- })) && _vo3(elem, _path + ".scenarios[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
9957
- path: _path + ".scenarios[" + _index4 + "]",
9958
- expected: "AutoBeTest.Scenario",
10191
+ })) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
10192
+ path: _path + ".scenarios[" + _index5 + "]",
10193
+ expected: "IAutoBeTestScenarioApplication.IScenario",
9959
10194
  value: elem
9960
10195
  }))).every((flag => flag)) || _report(_exceptionable, {
9961
10196
  path: _path + ".scenarios",
9962
- expected: "Array<AutoBeTest.Scenario>",
10197
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
9963
10198
  value: input.scenarios
9964
10199
  }) ].every((flag => flag));
9965
10200
  const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
@@ -9971,14 +10206,43 @@ const claude$1 = {
9971
10206
  expected: '("delete" | "get" | "patch" | "post" | "put")',
9972
10207
  value: input.method
9973
10208
  }) ].every((flag => flag));
9974
- const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.functionName || _report(_exceptionable, {
10209
+ const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
10210
+ path: _path + ".draft",
10211
+ expected: "string",
10212
+ value: input.draft
10213
+ }), "string" === typeof input.functionName || _report(_exceptionable, {
9975
10214
  path: _path + ".functionName",
9976
10215
  expected: "string",
9977
10216
  value: input.functionName
9978
- }), "string" === typeof input.scenario || _report(_exceptionable, {
9979
- path: _path + ".scenario",
10217
+ }), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
10218
+ path: _path + ".dependsOn",
10219
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10220
+ value: input.dependsOn
10221
+ })) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10222
+ path: _path + ".dependsOn[" + _index6 + "]",
10223
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10224
+ value: elem
10225
+ })) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
10226
+ path: _path + ".dependsOn[" + _index6 + "]",
10227
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10228
+ value: elem
10229
+ }))).every((flag => flag)) || _report(_exceptionable, {
10230
+ path: _path + ".dependsOn",
10231
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10232
+ value: input.dependsOn
10233
+ }) ].every((flag => flag));
10234
+ const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10235
+ path: _path + ".endpoint",
10236
+ expected: "AutoBeOpenApi.IEndpoint",
10237
+ value: input.endpoint
10238
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10239
+ path: _path + ".endpoint",
10240
+ expected: "AutoBeOpenApi.IEndpoint",
10241
+ value: input.endpoint
10242
+ }), "string" === typeof input.purpose || _report(_exceptionable, {
10243
+ path: _path + ".purpose",
9980
10244
  expected: "string",
9981
- value: input.scenario
10245
+ value: input.purpose
9982
10246
  }) ].every((flag => flag));
9983
10247
  const __is = input => "object" === typeof input && null !== input && _io0(input);
9984
10248
  let errors;
@@ -9989,11 +10253,11 @@ const claude$1 = {
9989
10253
  _report = __typia_transform__validateReport._validateReport(errors);
9990
10254
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9991
10255
  path: _path + "",
9992
- expected: "IMakeScenarioProps",
10256
+ expected: "IAutoBeTestScenarioApplication.IProps",
9993
10257
  value: input
9994
10258
  })) && _vo0(input, _path + "", true) || _report(true, {
9995
10259
  path: _path + "",
9996
- expected: "IMakeScenarioProps",
10260
+ expected: "IAutoBeTestScenarioApplication.IProps",
9997
10261
  value: input
9998
10262
  }))(input, "$input", true);
9999
10263
  const success = 0 === errors.length;
@@ -10026,19 +10290,19 @@ const collection$1 = {
10026
10290
  functions: [ {
10027
10291
  name: "makeScenario",
10028
10292
  parameters: {
10029
- description: " Properties containing the endpoints and user scenarios.\n\n------------------------------\n\nCurrent Type: {@link IMakeScenarioProps}",
10293
+ description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
10030
10294
  type: "object",
10031
10295
  properties: {
10032
- scenarios: {
10033
- title: "Array of user scenarios",
10034
- description: "Array of user scenarios.",
10296
+ scenarioGroups: {
10297
+ title: "Array of test scenario groups",
10298
+ description: "Array of test scenario groups.",
10035
10299
  type: "array",
10036
10300
  items: {
10037
- description: "Current Type: {@link AutoBeTest.IScenario}",
10301
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
10038
10302
  type: "object",
10039
10303
  properties: {
10040
10304
  endpoint: {
10041
- description: "Target API endpoint for user scenario generation.\n\nThis represents the single API endpoint that will be analyzed to generate\ncomprehensive user scenarios. The endpoint contains all technical\nspecifications needed to understand user interactions, including HTTP\nmethods, paths, parameters, request/response schemas, and authentication\nrequirements.\n\n## Core Purpose\n\n- Serves as the foundation for user-centric scenario generation\n- Contains complete API specification for understanding user capabilities\n- Provides schema constraints for realistic user data generation\n- Defines authentication and permission requirements for user context\n\n## User Scenario Context\n\nThis endpoint information enables generation of scenarios that consider:\n\n- What users can realistically accomplish with this endpoint\n- How users would naturally interact with the API functionality\n- What business value users seek from this endpoint\n- What constraints and limitations users will encounter\n- How authentication affects user access patterns\n- What data formats users need to provide or expect to receive\n\n## Single Endpoint Constraint\n\nEach scenario generated must interact with ONLY this endpoint. Scenarios\nshould not assume or require calls to other endpoints, ensuring each user\njourney is complete and testable in isolation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10305
+ description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10042
10306
  type: "object",
10043
10307
  properties: {
10044
10308
  path: {
@@ -10056,24 +10320,57 @@ const collection$1 = {
10056
10320
  required: [ "path", "method" ]
10057
10321
  },
10058
10322
  scenarios: {
10059
- title: "Comprehensive collection of user-centric scenarios for the endpoint",
10060
- description: "Comprehensive collection of user-centric scenarios for the endpoint.\n\nEach scenario represents a realistic user journey, intention, or\nsituation when interacting with this specific API endpoint. All scenarios\nare written from the user's perspective, focusing on what they want to\nachieve and how they naturally interact with the API functionality.\n\n## Scenario Coverage Framework\n\nThe scenarios must comprehensively cover all user interaction patterns:\n\n### 1. Happy Path User Journeys\n\n- Primary business use cases that users commonly perform\n- Standard workflows leading to successful user outcomes\n- Typical user behaviors with valid inputs and proper permissions\n- Most frequent user intentions and expected interactions\n\n### 2. Alternative User Approaches\n\n- Valid alternative ways users might achieve their goals\n- User scenarios utilizing optional parameters or different input patterns\n- Less common but legitimate user behaviors within normal boundaries\n- User experimentation with available API features\n\n### 3. User Error Situations\n\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations (rate limits, quotas)\n\n### 4. Boundary User Behaviors\n\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n### 5. Contextual User Situations\n\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n## User-Centric Quality Standards\n\nEach scenario must:\n\n- Focus entirely on user motivation, context, and expected outcomes\n- Describe realistic business situations users actually encounter\n- Include clear user intent and the value they seek\n- Specify user-provided data and user-expected results\n- Be complete within the single endpoint constraint\n- Provide sufficient context for understanding user behavior patterns\n- Avoid technical implementation details or testing terminology\n\n## Single Endpoint Constraint Application\n\nEvery scenario must:\n\n- Complete the entire user journey using only this one endpoint\n- Not depend on or reference other API endpoints\n- Include all necessary context within the scenario itself\n- Represent a complete, self-contained user interaction\n\n## Business Value Focus\n\nThese user scenarios ensure:\n\n- Understanding of real user needs and behaviors\n- Comprehensive coverage of user interaction patterns\n- Proper handling of user errors and edge cases\n- Appropriate user feedback and experience design\n- Business rule validation from user perspective\n- Security and permission handling for different user contexts",
10323
+ title: "Array of test scenarios",
10324
+ description: "Array of test scenarios.",
10061
10325
  type: "array",
10062
10326
  items: {
10063
- description: "Current Type: {@link AutoBeTest.Scenario}",
10327
+ description: "Description of the current {@link IAutoBeTestScenarioApplication.IScenario} type:\n\n> Represents a test scenario for a single API operation.\n> \n> This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP\n> method and path information, and adds two key properties:\n> \n> - `draft`: A free-form, human-readable test scenario description for the API\n> endpoint.\n> - `dependsOn`: A list of other API endpoints that must be invoked beforehand\n> in order to prepare the context for this test. Each dependency includes\n> the purpose of the dependency.\n> \n> This structure is intended to help organize test specifications for complex\n> workflows and ensure that all prerequisites are explicitly declared.",
10064
10328
  type: "object",
10065
10329
  properties: {
10330
+ draft: {
10331
+ description: "A detailed natural language description of how this API endpoint should\nbe tested. This should include both successful and failure scenarios,\nbusiness rule validations, edge cases, and any sequence of steps\nnecessary to perform the test. A subsequent agent will use this draft to\ngenerate multiple test scenarios.",
10332
+ type: "string"
10333
+ },
10066
10334
  functionName: {
10067
10335
  title: "Descriptive function name derived from the user scenario",
10068
10336
  description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\n- Must start with `test_` prefix (mandatory requirement)\n- Use snake_case formatting throughout\n- Include the primary user action (create, get, update, delete, list, etc.)\n- Specify the target resource (user, product, order, profile, etc.)\n- Add scenario-specific context (valid_data, invalid_email, not_found,\n etc.)\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_[user_action]_[resource]_[scenario_context]`\n\nWhere:\n\n- `user_action`: What the user is trying to do\n- `resource`: What the user is interacting with\n- `scenario_context`: The specific situation or condition\n\n## User-Focused Examples\n\n- `test_create_user_profile_with_complete_information` - User providing all\n available profile data\n- `test_retrieve_user_profile_when_profile_exists` - User accessing their\n existing profile\n- `test_update_user_email_with_valid_new_address` - User changing their\n email to a valid new one\n- `test_delete_user_account_when_user_lacks_permission` - User attempting\n account deletion without authorization\n- `test_search_user_profiles_with_pagination_preferences` - User browsing\n profiles with specific pagination\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions",
10069
10337
  type: "string"
10070
10338
  },
10071
- scenario: {
10072
- description: "Comprehensive user scenario description written from pure user\nperspective.\n\nThis describes a complete user journey, motivation, and expected outcome\nwhen interacting with the API endpoint. The description focuses entirely\non user intent, context, and natural behavior patterns rather than\ntechnical testing considerations.\n\n## User-Centric Writing Approach\n\n- Write as if describing a real person's experience and motivation\n- Focus on business context and user goals, not system functionality\n- Use natural language that business stakeholders would understand\n- Emphasize user value and expected benefits\n- Avoid technical terminology or implementation details\n\n## Required Content Elements\n\nEach scenario description must include:\n\n### 1. User Context and Motivation\n\n- Who is the user (role, background, current situation)\n- Why they need to perform this action (business motivation)\n- What problem they're trying to solve or goal they want to achieve\n- Any relevant background circumstances or constraints\n\n### 2. User Actions and Behavior\n\n- Specific steps the user takes to accomplish their goal\n- What information or data the user provides\n- How the user naturally approaches the interaction\n- Any decision-making process the user goes through\n\n### 3. User Expectations and Desired Outcomes\n\n- What the user expects to happen as a result\n- How the user will know if they were successful\n- What value or benefit the user expects to receive\n- How this fits into their broader workflow or objectives\n\n### 4. Business Impact and Value\n\n- How this scenario relates to business objectives\n- What business processes or workflows this supports\n- Why this user behavior matters to the organization\n- What risks or opportunities this scenario represents\n\n## Single Endpoint Constraint Integration\n\nEach scenario must:\n\n- Represent a complete user journey achievable through this single endpoint\n- Include all necessary context without referencing other API operations\n- Describe user expectations based solely on this endpoint's capabilities\n- Avoid scenarios that would logically require multiple API calls\n\n## Quality and Realism Standards\n\n- Base scenarios on realistic business situations\n- Include specific, concrete details rather than generic descriptions\n- Ensure scenarios reflect actual user behaviors and motivations\n- Make each scenario distinct and valuable for understanding user needs\n- Provide enough detail to understand full context without being verbose\n\n## User-Focused Example Scenarios\n\n- \"A busy project manager needs to quickly create a new team member's user\n account during an onboarding meeting. They have all the necessary\n information readily available and expect the account to be immediately\n active so the new employee can start working right away.\"\n- \"A customer support representative is helping a customer who forgot their\n login credentials. The customer provides their email address, and the\n representative expects to quickly retrieve the associated account\n information to assist with password recovery.\"\n- \"A system administrator discovers that a former employee's account is\n still active after their departure. They need to immediately deactivate\n this account for security purposes and expect confirmation that the\n account can no longer be used to access company resources.\"\n\n## Language and Tone\n\n- Use active voice and present tense when describing user actions\n- Write in a narrative style that tells the user's story\n- Balance professional tone with human context\n- Ensure accessibility for both technical and non-technical readers\n- Maintain consistency in perspective throughout the description",
10073
- type: "string"
10339
+ dependsOn: {
10340
+ description: "A list of other API endpoints that must be executed before this test\nscenario. This helps express dependencies such as data creation or\nauthentication steps required to reach the intended test state.",
10341
+ type: "array",
10342
+ items: {
10343
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
10344
+ type: "object",
10345
+ properties: {
10346
+ endpoint: {
10347
+ description: "Target API endpoint that must be executed before the main operation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10348
+ type: "object",
10349
+ properties: {
10350
+ path: {
10351
+ title: "HTTP path of the API operation",
10352
+ description: "HTTP path of the API operation.\n\nThe URL path for accessing this API operation, using path parameters\nenclosed in curly braces (e.g., `/shoppings/customers/sales/{saleId}`).\n\nIt must be corresponded to the {@link parameters path parameters}.\n\nThe path structure should clearly indicate which database entity this\noperation is manipulating, helping to ensure all entities have\nappropriate API coverage.",
10353
+ type: "string"
10354
+ },
10355
+ method: {
10356
+ title: "HTTP method of the API operation",
10357
+ description: "HTTP method of the API operation.\n\nNote that, if the API operation has {@link requestBody}, method must not\nbe `get`.\n\nAlso, even though the API operation has been designed to only get\ninformation, but it needs complicated request information, it must be\ndefined as `patch` method with {@link requestBody} data specification.\n\n- `get`: get information\n- `patch`: get information with complicated request data\n ({@link requestBody})\n- `post`: create new record\n- `put`: update existing record\n- `delete`: remove record",
10358
+ type: "string",
10359
+ enum: [ "get", "post", "put", "delete", "patch" ]
10360
+ }
10361
+ },
10362
+ required: [ "path", "method" ]
10363
+ },
10364
+ purpose: {
10365
+ description: 'A concise exscenarioation of why this API call is required before\nexecuting the test for the main operation.\n\nExample: "Creates a category so that a product can be linked to it during\ncreation."',
10366
+ type: "string"
10367
+ }
10368
+ },
10369
+ required: [ "endpoint", "purpose" ]
10370
+ }
10074
10371
  }
10075
10372
  },
10076
- required: [ "functionName", "scenario" ]
10373
+ required: [ "draft", "functionName", "dependsOn" ]
10077
10374
  }
10078
10375
  }
10079
10376
  },
@@ -10081,32 +10378,33 @@ const collection$1 = {
10081
10378
  }
10082
10379
  }
10083
10380
  },
10084
- required: [ "scenarios" ],
10381
+ required: [ "scenarioGroups" ],
10085
10382
  additionalProperties: false,
10086
10383
  $defs: {}
10087
10384
  },
10088
- description: "Make user scenarios for the given endpoints.",
10385
+ description: "Make test scenarios for the given endpoints.",
10089
10386
  validate: (() => {
10090
- const _io0 = input => Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
10387
+ const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
10091
10388
  const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
10092
10389
  const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
10093
- const _io3 = input => "string" === typeof input.functionName && "string" === typeof input.scenario;
10094
- const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarios) || _report(_exceptionable, {
10095
- path: _path + ".scenarios",
10096
- expected: "Array<AutoBeTest.IScenario>",
10097
- value: input.scenarios
10098
- })) && input.scenarios.map(((elem, _index3) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10099
- path: _path + ".scenarios[" + _index3 + "]",
10100
- expected: "AutoBeTest.IScenario",
10390
+ const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
10391
+ const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
10392
+ const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
10393
+ path: _path + ".scenarioGroups",
10394
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10395
+ value: input.scenarioGroups
10396
+ })) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10397
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10398
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10101
10399
  value: elem
10102
- })) && _vo1(elem, _path + ".scenarios[" + _index3 + "]", _exceptionable) || _report(_exceptionable, {
10103
- path: _path + ".scenarios[" + _index3 + "]",
10104
- expected: "AutoBeTest.IScenario",
10400
+ })) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10401
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10402
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10105
10403
  value: elem
10106
10404
  }))).every((flag => flag)) || _report(_exceptionable, {
10107
- path: _path + ".scenarios",
10108
- expected: "Array<AutoBeTest.IScenario>",
10109
- value: input.scenarios
10405
+ path: _path + ".scenarioGroups",
10406
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10407
+ value: input.scenarioGroups
10110
10408
  }) ].every((flag => flag));
10111
10409
  const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10112
10410
  path: _path + ".endpoint",
@@ -10118,19 +10416,19 @@ const collection$1 = {
10118
10416
  value: input.endpoint
10119
10417
  }), (Array.isArray(input.scenarios) || _report(_exceptionable, {
10120
10418
  path: _path + ".scenarios",
10121
- expected: "Array<AutoBeTest.Scenario>",
10419
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10122
10420
  value: input.scenarios
10123
- })) && input.scenarios.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10124
- path: _path + ".scenarios[" + _index4 + "]",
10125
- expected: "AutoBeTest.Scenario",
10421
+ })) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10422
+ path: _path + ".scenarios[" + _index5 + "]",
10423
+ expected: "IAutoBeTestScenarioApplication.IScenario",
10126
10424
  value: elem
10127
- })) && _vo3(elem, _path + ".scenarios[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10128
- path: _path + ".scenarios[" + _index4 + "]",
10129
- expected: "AutoBeTest.Scenario",
10425
+ })) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
10426
+ path: _path + ".scenarios[" + _index5 + "]",
10427
+ expected: "IAutoBeTestScenarioApplication.IScenario",
10130
10428
  value: elem
10131
10429
  }))).every((flag => flag)) || _report(_exceptionable, {
10132
10430
  path: _path + ".scenarios",
10133
- expected: "Array<AutoBeTest.Scenario>",
10431
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10134
10432
  value: input.scenarios
10135
10433
  }) ].every((flag => flag));
10136
10434
  const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
@@ -10142,14 +10440,43 @@ const collection$1 = {
10142
10440
  expected: '("delete" | "get" | "patch" | "post" | "put")',
10143
10441
  value: input.method
10144
10442
  }) ].every((flag => flag));
10145
- const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.functionName || _report(_exceptionable, {
10443
+ const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
10444
+ path: _path + ".draft",
10445
+ expected: "string",
10446
+ value: input.draft
10447
+ }), "string" === typeof input.functionName || _report(_exceptionable, {
10146
10448
  path: _path + ".functionName",
10147
10449
  expected: "string",
10148
10450
  value: input.functionName
10149
- }), "string" === typeof input.scenario || _report(_exceptionable, {
10150
- path: _path + ".scenario",
10451
+ }), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
10452
+ path: _path + ".dependsOn",
10453
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10454
+ value: input.dependsOn
10455
+ })) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10456
+ path: _path + ".dependsOn[" + _index6 + "]",
10457
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10458
+ value: elem
10459
+ })) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
10460
+ path: _path + ".dependsOn[" + _index6 + "]",
10461
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10462
+ value: elem
10463
+ }))).every((flag => flag)) || _report(_exceptionable, {
10464
+ path: _path + ".dependsOn",
10465
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10466
+ value: input.dependsOn
10467
+ }) ].every((flag => flag));
10468
+ const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10469
+ path: _path + ".endpoint",
10470
+ expected: "AutoBeOpenApi.IEndpoint",
10471
+ value: input.endpoint
10472
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10473
+ path: _path + ".endpoint",
10474
+ expected: "AutoBeOpenApi.IEndpoint",
10475
+ value: input.endpoint
10476
+ }), "string" === typeof input.purpose || _report(_exceptionable, {
10477
+ path: _path + ".purpose",
10151
10478
  expected: "string",
10152
- value: input.scenario
10479
+ value: input.purpose
10153
10480
  }) ].every((flag => flag));
10154
10481
  const __is = input => "object" === typeof input && null !== input && _io0(input);
10155
10482
  let errors;
@@ -10160,11 +10487,11 @@ const collection$1 = {
10160
10487
  _report = __typia_transform__validateReport._validateReport(errors);
10161
10488
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10162
10489
  path: _path + "",
10163
- expected: "IMakeScenarioProps",
10490
+ expected: "IAutoBeTestScenarioApplication.IProps",
10164
10491
  value: input
10165
10492
  })) && _vo0(input, _path + "", true) || _report(true, {
10166
10493
  path: _path + "",
10167
- expected: "IMakeScenarioProps",
10494
+ expected: "IAutoBeTestScenarioApplication.IProps",
10168
10495
  value: input
10169
10496
  }))(input, "$input", true);
10170
10497
  const success = 0 === errors.length;
@@ -10201,7 +10528,7 @@ const collection$1 = {
10201
10528
  parameters: {
10202
10529
  type: "object",
10203
10530
  properties: {
10204
- scenarios: {
10531
+ scenarioGroups: {
10205
10532
  type: "array",
10206
10533
  items: {
10207
10534
  type: "object",
@@ -10222,7 +10549,7 @@ const collection$1 = {
10222
10549
  }
10223
10550
  },
10224
10551
  required: [ "path", "method" ],
10225
- description: "Target API endpoint for user scenario generation.\n\nThis represents the single API endpoint that will be analyzed to generate\ncomprehensive user scenarios. The endpoint contains all technical\nspecifications needed to understand user interactions, including HTTP\nmethods, paths, parameters, request/response schemas, and authentication\nrequirements.\n\n## Core Purpose\n\n- Serves as the foundation for user-centric scenario generation\n- Contains complete API specification for understanding user capabilities\n- Provides schema constraints for realistic user data generation\n- Defines authentication and permission requirements for user context\n\n## User Scenario Context\n\nThis endpoint information enables generation of scenarios that consider:\n\n- What users can realistically accomplish with this endpoint\n- How users would naturally interact with the API functionality\n- What business value users seek from this endpoint\n- What constraints and limitations users will encounter\n- How authentication affects user access patterns\n- What data formats users need to provide or expect to receive\n\n## Single Endpoint Constraint\n\nEach scenario generated must interact with ONLY this endpoint. Scenarios\nshould not assume or require calls to other endpoints, ensuring each user\njourney is complete and testable in isolation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10552
+ description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10226
10553
  additionalProperties: false
10227
10554
  },
10228
10555
  scenarios: {
@@ -10230,58 +10557,94 @@ const collection$1 = {
10230
10557
  items: {
10231
10558
  type: "object",
10232
10559
  properties: {
10560
+ draft: {
10561
+ type: "string",
10562
+ description: "A detailed natural language description of how this API endpoint should\nbe tested. This should include both successful and failure scenarios,\nbusiness rule validations, edge cases, and any sequence of steps\nnecessary to perform the test. A subsequent agent will use this draft to\ngenerate multiple test scenarios."
10563
+ },
10233
10564
  functionName: {
10234
10565
  type: "string",
10235
10566
  title: "Descriptive function name derived from the user scenario",
10236
10567
  description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\n- Must start with `test_` prefix (mandatory requirement)\n- Use snake_case formatting throughout\n- Include the primary user action (create, get, update, delete, list, etc.)\n- Specify the target resource (user, product, order, profile, etc.)\n- Add scenario-specific context (valid_data, invalid_email, not_found,\n etc.)\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_[user_action]_[resource]_[scenario_context]`\n\nWhere:\n\n- `user_action`: What the user is trying to do\n- `resource`: What the user is interacting with\n- `scenario_context`: The specific situation or condition\n\n## User-Focused Examples\n\n- `test_create_user_profile_with_complete_information` - User providing all\n available profile data\n- `test_retrieve_user_profile_when_profile_exists` - User accessing their\n existing profile\n- `test_update_user_email_with_valid_new_address` - User changing their\n email to a valid new one\n- `test_delete_user_account_when_user_lacks_permission` - User attempting\n account deletion without authorization\n- `test_search_user_profiles_with_pagination_preferences` - User browsing\n profiles with specific pagination\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions"
10237
10568
  },
10238
- scenario: {
10239
- type: "string",
10240
- description: "Comprehensive user scenario description written from pure user\nperspective.\n\nThis describes a complete user journey, motivation, and expected outcome\nwhen interacting with the API endpoint. The description focuses entirely\non user intent, context, and natural behavior patterns rather than\ntechnical testing considerations.\n\n## User-Centric Writing Approach\n\n- Write as if describing a real person's experience and motivation\n- Focus on business context and user goals, not system functionality\n- Use natural language that business stakeholders would understand\n- Emphasize user value and expected benefits\n- Avoid technical terminology or implementation details\n\n## Required Content Elements\n\nEach scenario description must include:\n\n### 1. User Context and Motivation\n\n- Who is the user (role, background, current situation)\n- Why they need to perform this action (business motivation)\n- What problem they're trying to solve or goal they want to achieve\n- Any relevant background circumstances or constraints\n\n### 2. User Actions and Behavior\n\n- Specific steps the user takes to accomplish their goal\n- What information or data the user provides\n- How the user naturally approaches the interaction\n- Any decision-making process the user goes through\n\n### 3. User Expectations and Desired Outcomes\n\n- What the user expects to happen as a result\n- How the user will know if they were successful\n- What value or benefit the user expects to receive\n- How this fits into their broader workflow or objectives\n\n### 4. Business Impact and Value\n\n- How this scenario relates to business objectives\n- What business processes or workflows this supports\n- Why this user behavior matters to the organization\n- What risks or opportunities this scenario represents\n\n## Single Endpoint Constraint Integration\n\nEach scenario must:\n\n- Represent a complete user journey achievable through this single endpoint\n- Include all necessary context without referencing other API operations\n- Describe user expectations based solely on this endpoint's capabilities\n- Avoid scenarios that would logically require multiple API calls\n\n## Quality and Realism Standards\n\n- Base scenarios on realistic business situations\n- Include specific, concrete details rather than generic descriptions\n- Ensure scenarios reflect actual user behaviors and motivations\n- Make each scenario distinct and valuable for understanding user needs\n- Provide enough detail to understand full context without being verbose\n\n## User-Focused Example Scenarios\n\n- \"A busy project manager needs to quickly create a new team member's user\n account during an onboarding meeting. They have all the necessary\n information readily available and expect the account to be immediately\n active so the new employee can start working right away.\"\n- \"A customer support representative is helping a customer who forgot their\n login credentials. The customer provides their email address, and the\n representative expects to quickly retrieve the associated account\n information to assist with password recovery.\"\n- \"A system administrator discovers that a former employee's account is\n still active after their departure. They need to immediately deactivate\n this account for security purposes and expect confirmation that the\n account can no longer be used to access company resources.\"\n\n## Language and Tone\n\n- Use active voice and present tense when describing user actions\n- Write in a narrative style that tells the user's story\n- Balance professional tone with human context\n- Ensure accessibility for both technical and non-technical readers\n- Maintain consistency in perspective throughout the description"
10569
+ dependsOn: {
10570
+ type: "array",
10571
+ items: {
10572
+ type: "object",
10573
+ properties: {
10574
+ endpoint: {
10575
+ type: "object",
10576
+ properties: {
10577
+ path: {
10578
+ type: "string",
10579
+ title: "HTTP path of the API operation",
10580
+ description: "HTTP path of the API operation.\n\nThe URL path for accessing this API operation, using path parameters\nenclosed in curly braces (e.g., `/shoppings/customers/sales/{saleId}`).\n\nIt must be corresponded to the {@link parameters path parameters}.\n\nThe path structure should clearly indicate which database entity this\noperation is manipulating, helping to ensure all entities have\nappropriate API coverage."
10581
+ },
10582
+ method: {
10583
+ type: "string",
10584
+ enum: [ "get", "post", "put", "delete", "patch" ],
10585
+ title: "HTTP method of the API operation",
10586
+ description: "HTTP method of the API operation.\n\nNote that, if the API operation has {@link requestBody}, method must not\nbe `get`.\n\nAlso, even though the API operation has been designed to only get\ninformation, but it needs complicated request information, it must be\ndefined as `patch` method with {@link requestBody} data specification.\n\n- `get`: get information\n- `patch`: get information with complicated request data\n ({@link requestBody})\n- `post`: create new record\n- `put`: update existing record\n- `delete`: remove record"
10587
+ }
10588
+ },
10589
+ required: [ "path", "method" ],
10590
+ description: "Target API endpoint that must be executed before the main operation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10591
+ additionalProperties: false
10592
+ },
10593
+ purpose: {
10594
+ type: "string",
10595
+ description: 'A concise exscenarioation of why this API call is required before\nexecuting the test for the main operation.\n\nExample: "Creates a category so that a product can be linked to it during\ncreation."'
10596
+ }
10597
+ },
10598
+ required: [ "endpoint", "purpose" ],
10599
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
10600
+ additionalProperties: false
10601
+ },
10602
+ description: "A list of other API endpoints that must be executed before this test\nscenario. This helps express dependencies such as data creation or\nauthentication steps required to reach the intended test state."
10241
10603
  }
10242
10604
  },
10243
- required: [ "functionName", "scenario" ],
10244
- description: "Current Type: {@link AutoBeTest.Scenario}",
10605
+ required: [ "draft", "functionName", "dependsOn" ],
10606
+ description: "Description of the current {@link IAutoBeTestScenarioApplication.IScenario} type:\n\n> Represents a test scenario for a single API operation.\n> \n> This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP\n> method and path information, and adds two key properties:\n> \n> - `draft`: A free-form, human-readable test scenario description for the API\n> endpoint.\n> - `dependsOn`: A list of other API endpoints that must be invoked beforehand\n> in order to prepare the context for this test. Each dependency includes\n> the purpose of the dependency.\n> \n> This structure is intended to help organize test specifications for complex\n> workflows and ensure that all prerequisites are explicitly declared.",
10245
10607
  additionalProperties: false
10246
10608
  },
10247
- title: "Comprehensive collection of user-centric scenarios for the endpoint",
10248
- description: "Comprehensive collection of user-centric scenarios for the endpoint.\n\nEach scenario represents a realistic user journey, intention, or\nsituation when interacting with this specific API endpoint. All scenarios\nare written from the user's perspective, focusing on what they want to\nachieve and how they naturally interact with the API functionality.\n\n## Scenario Coverage Framework\n\nThe scenarios must comprehensively cover all user interaction patterns:\n\n### 1. Happy Path User Journeys\n\n- Primary business use cases that users commonly perform\n- Standard workflows leading to successful user outcomes\n- Typical user behaviors with valid inputs and proper permissions\n- Most frequent user intentions and expected interactions\n\n### 2. Alternative User Approaches\n\n- Valid alternative ways users might achieve their goals\n- User scenarios utilizing optional parameters or different input patterns\n- Less common but legitimate user behaviors within normal boundaries\n- User experimentation with available API features\n\n### 3. User Error Situations\n\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations (rate limits, quotas)\n\n### 4. Boundary User Behaviors\n\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n### 5. Contextual User Situations\n\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n## User-Centric Quality Standards\n\nEach scenario must:\n\n- Focus entirely on user motivation, context, and expected outcomes\n- Describe realistic business situations users actually encounter\n- Include clear user intent and the value they seek\n- Specify user-provided data and user-expected results\n- Be complete within the single endpoint constraint\n- Provide sufficient context for understanding user behavior patterns\n- Avoid technical implementation details or testing terminology\n\n## Single Endpoint Constraint Application\n\nEvery scenario must:\n\n- Complete the entire user journey using only this one endpoint\n- Not depend on or reference other API endpoints\n- Include all necessary context within the scenario itself\n- Represent a complete, self-contained user interaction\n\n## Business Value Focus\n\nThese user scenarios ensure:\n\n- Understanding of real user needs and behaviors\n- Comprehensive coverage of user interaction patterns\n- Proper handling of user errors and edge cases\n- Appropriate user feedback and experience design\n- Business rule validation from user perspective\n- Security and permission handling for different user contexts"
10609
+ title: "Array of test scenarios",
10610
+ description: "Array of test scenarios."
10249
10611
  }
10250
10612
  },
10251
10613
  required: [ "endpoint", "scenarios" ],
10252
- description: "Current Type: {@link AutoBeTest.IScenario}",
10614
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
10253
10615
  additionalProperties: false
10254
10616
  },
10255
- title: "Array of user scenarios",
10256
- description: "Array of user scenarios."
10617
+ title: "Array of test scenario groups",
10618
+ description: "Array of test scenario groups."
10257
10619
  }
10258
10620
  },
10259
- required: [ "scenarios" ],
10260
- description: " Properties containing the endpoints and user scenarios.\n\n------------------------------\n\nCurrent Type: {@link IMakeScenarioProps}",
10621
+ required: [ "scenarioGroups" ],
10622
+ description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
10261
10623
  additionalProperties: false
10262
10624
  },
10263
- description: "Make user scenarios for the given endpoints.",
10625
+ description: "Make test scenarios for the given endpoints.",
10264
10626
  validate: (() => {
10265
- const _io0 = input => Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
10627
+ const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
10266
10628
  const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
10267
10629
  const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
10268
- const _io3 = input => "string" === typeof input.functionName && "string" === typeof input.scenario;
10269
- const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarios) || _report(_exceptionable, {
10270
- path: _path + ".scenarios",
10271
- expected: "Array<AutoBeTest.IScenario>",
10272
- value: input.scenarios
10273
- })) && input.scenarios.map(((elem, _index3) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10274
- path: _path + ".scenarios[" + _index3 + "]",
10275
- expected: "AutoBeTest.IScenario",
10630
+ const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
10631
+ const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
10632
+ const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
10633
+ path: _path + ".scenarioGroups",
10634
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10635
+ value: input.scenarioGroups
10636
+ })) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10637
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10638
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10276
10639
  value: elem
10277
- })) && _vo1(elem, _path + ".scenarios[" + _index3 + "]", _exceptionable) || _report(_exceptionable, {
10278
- path: _path + ".scenarios[" + _index3 + "]",
10279
- expected: "AutoBeTest.IScenario",
10640
+ })) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10641
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10642
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10280
10643
  value: elem
10281
10644
  }))).every((flag => flag)) || _report(_exceptionable, {
10282
- path: _path + ".scenarios",
10283
- expected: "Array<AutoBeTest.IScenario>",
10284
- value: input.scenarios
10645
+ path: _path + ".scenarioGroups",
10646
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10647
+ value: input.scenarioGroups
10285
10648
  }) ].every((flag => flag));
10286
10649
  const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10287
10650
  path: _path + ".endpoint",
@@ -10293,19 +10656,19 @@ const collection$1 = {
10293
10656
  value: input.endpoint
10294
10657
  }), (Array.isArray(input.scenarios) || _report(_exceptionable, {
10295
10658
  path: _path + ".scenarios",
10296
- expected: "Array<AutoBeTest.Scenario>",
10659
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10297
10660
  value: input.scenarios
10298
- })) && input.scenarios.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10299
- path: _path + ".scenarios[" + _index4 + "]",
10300
- expected: "AutoBeTest.Scenario",
10661
+ })) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10662
+ path: _path + ".scenarios[" + _index5 + "]",
10663
+ expected: "IAutoBeTestScenarioApplication.IScenario",
10301
10664
  value: elem
10302
- })) && _vo3(elem, _path + ".scenarios[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10303
- path: _path + ".scenarios[" + _index4 + "]",
10304
- expected: "AutoBeTest.Scenario",
10665
+ })) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
10666
+ path: _path + ".scenarios[" + _index5 + "]",
10667
+ expected: "IAutoBeTestScenarioApplication.IScenario",
10305
10668
  value: elem
10306
10669
  }))).every((flag => flag)) || _report(_exceptionable, {
10307
10670
  path: _path + ".scenarios",
10308
- expected: "Array<AutoBeTest.Scenario>",
10671
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10309
10672
  value: input.scenarios
10310
10673
  }) ].every((flag => flag));
10311
10674
  const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
@@ -10317,14 +10680,43 @@ const collection$1 = {
10317
10680
  expected: '("delete" | "get" | "patch" | "post" | "put")',
10318
10681
  value: input.method
10319
10682
  }) ].every((flag => flag));
10320
- const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.functionName || _report(_exceptionable, {
10683
+ const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
10684
+ path: _path + ".draft",
10685
+ expected: "string",
10686
+ value: input.draft
10687
+ }), "string" === typeof input.functionName || _report(_exceptionable, {
10321
10688
  path: _path + ".functionName",
10322
10689
  expected: "string",
10323
10690
  value: input.functionName
10324
- }), "string" === typeof input.scenario || _report(_exceptionable, {
10325
- path: _path + ".scenario",
10691
+ }), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
10692
+ path: _path + ".dependsOn",
10693
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10694
+ value: input.dependsOn
10695
+ })) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10696
+ path: _path + ".dependsOn[" + _index6 + "]",
10697
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10698
+ value: elem
10699
+ })) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
10700
+ path: _path + ".dependsOn[" + _index6 + "]",
10701
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10702
+ value: elem
10703
+ }))).every((flag => flag)) || _report(_exceptionable, {
10704
+ path: _path + ".dependsOn",
10705
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10706
+ value: input.dependsOn
10707
+ }) ].every((flag => flag));
10708
+ const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10709
+ path: _path + ".endpoint",
10710
+ expected: "AutoBeOpenApi.IEndpoint",
10711
+ value: input.endpoint
10712
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10713
+ path: _path + ".endpoint",
10714
+ expected: "AutoBeOpenApi.IEndpoint",
10715
+ value: input.endpoint
10716
+ }), "string" === typeof input.purpose || _report(_exceptionable, {
10717
+ path: _path + ".purpose",
10326
10718
  expected: "string",
10327
- value: input.scenario
10719
+ value: input.purpose
10328
10720
  }) ].every((flag => flag));
10329
10721
  const __is = input => "object" === typeof input && null !== input && _io0(input);
10330
10722
  let errors;
@@ -10335,11 +10727,11 @@ const collection$1 = {
10335
10727
  _report = __typia_transform__validateReport._validateReport(errors);
10336
10728
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10337
10729
  path: _path + "",
10338
- expected: "IMakeScenarioProps",
10730
+ expected: "IAutoBeTestScenarioApplication.IProps",
10339
10731
  value: input
10340
10732
  })) && _vo0(input, _path + "", true) || _report(true, {
10341
10733
  path: _path + "",
10342
- expected: "IMakeScenarioProps",
10734
+ expected: "IAutoBeTestScenarioApplication.IProps",
10343
10735
  value: input
10344
10736
  }))(input, "$input", true);
10345
10737
  const success = 0 === errors.length;
@@ -10383,10 +10775,9 @@ const orchestrateTest = ctx => async props => {
10383
10775
  ctx.dispatch(history);
10384
10776
  return history;
10385
10777
  }
10386
- const scenarioEvent = await orchestrateTestScenario(ctx);
10387
- const scenarios = scenarioEvent.scenarios.map((scenario => scenario.scenarios)).flat();
10778
+ const {scenarios} = await orchestrateTestScenario(ctx);
10388
10779
  const codes = await orchestrateTestProgress(ctx, scenarios);
10389
- const correct = await orchestrateTestCorrect(ctx, codes);
10780
+ const correct = await orchestrateTestCorrect(ctx, codes, scenarios);
10390
10781
  const history = {
10391
10782
  type: "test",
10392
10783
  id: v4(),
@@ -11820,29 +12211,30 @@ function emplaceMap(dict, key, generator) {
11820
12211
 
11821
12212
  class AutoBeAgent {
11822
12213
  constructor(props) {
11823
- this.props = props;
12214
+ this.props_ = props;
11824
12215
  this.histories_ = props.histories?.slice() ?? [];
11825
12216
  this.state_ = createAutoBeState(this.histories_);
12217
+ this.listeners_ = new Map;
12218
+ const vendor = {
12219
+ ...props.vendor,
12220
+ semaphore: new Semaphore(props.vendor.semaphore ?? 16)
12221
+ };
11826
12222
  this.context_ = {
12223
+ vendor,
11827
12224
  model: props.model,
11828
- vendor: props.vendor,
11829
12225
  config: props.config,
11830
12226
  compiler: props.compiler,
11831
12227
  histories: () => this.histories_,
11832
12228
  state: () => this.state_,
11833
12229
  usage: () => this.agentica_.getTokenUsage(),
11834
- files: () => this.getFiles(),
12230
+ files: options => this.getFiles(options),
11835
12231
  dispatch: event => {
11836
12232
  this.dispatch(event).catch((() => {}));
11837
12233
  }
11838
12234
  };
11839
- this.listeners_ = new Map;
11840
12235
  this.agentica_ = new MicroAgentica({
12236
+ vendor,
11841
12237
  model: props.model,
11842
- vendor: {
11843
- ...props.vendor,
11844
- semaphore: new Semaphore(props.vendor.semaphore ?? 16)
11845
- },
11846
12238
  config: {
11847
12239
  ...props.config ?? {},
11848
12240
  executor: {
@@ -11877,24 +12269,16 @@ class AutoBeAgent {
11877
12269
  created_at: history.created_at
11878
12270
  }).catch((() => {}));
11879
12271
  }));
12272
+ this.agentica_.on("request", (e => {
12273
+ if (e.body.parallel_tool_calls !== undefined) delete e.body.parallel_tool_calls;
12274
+ }));
11880
12275
  }
11881
12276
  clone() {
11882
12277
  return new AutoBeAgent({
11883
- ...this.props,
12278
+ ...this.props_,
11884
12279
  histories: this.histories_.slice()
11885
12280
  });
11886
12281
  }
11887
- on(type, listener) {
11888
- emplaceMap(this.listeners_, type, (() => new Set)).add(listener);
11889
- return this;
11890
- }
11891
- off(type, listener) {
11892
- const set = this.listeners_.get(type);
11893
- if (set === undefined) return this;
11894
- set.delete(listener);
11895
- if (set.size === 0) this.listeners_.delete(type);
11896
- return this;
11897
- }
11898
12282
  async conversate(content) {
11899
12283
  const index = this.histories_.length;
11900
12284
  const userMessageHistory = {
@@ -11911,13 +12295,13 @@ class AutoBeAgent {
11911
12295
  await this.agentica_.conversate(content);
11912
12296
  return this.histories_.slice(index);
11913
12297
  }
11914
- getFiles() {
12298
+ async getFiles(options) {
11915
12299
  const files = {
11916
12300
  ...Object.fromEntries(this.state_.analyze ? Object.entries(this.state_.analyze.files).map((([key, value]) => [ `docs/analysis/${key.split("/").at(-1)}`, value ])) : []),
11917
- ...Object.fromEntries(this.state_.prisma?.result.success === true ? [ ...Object.entries(this.state_.prisma.schemas).map((([key, value]) => [ `prisma/schema/${key.split("/").at(-1)}`, value ])), ...this.state_.prisma.compiled.type === "success" ? [ [ "docs/ERD.md", this.state_.prisma.compiled.document ] ] : [], ...this.state_.prisma.compiled.type === "failure" ? [ [ "prisma/compile-error-reason.log", this.state_.prisma.compiled.reason ] ] : [], [ "autobe/prisma.json", JSON.stringify(this.state_.prisma.result.data, null, 2) ] ] : []),
12301
+ ...Object.fromEntries(!!this.state_.prisma?.result ? [ ...Object.entries((options?.dbms ?? "postgres") === "postgres" ? this.state_.prisma.schemas : await this.context_.compiler.prisma.write(this.state_.prisma.result.data, options.dbms)).map((([key, value]) => [ `prisma/schema/${key.split("/").at(-1)}`, value ])), ...this.state_.prisma.compiled.type === "success" ? [ [ "docs/ERD.md", this.state_.prisma.compiled.document ] ] : [], ...this.state_.prisma.compiled.type === "failure" ? [ [ "prisma/compile-error-reason.log", this.state_.prisma.compiled.reason ] ] : [], [ "autobe/prisma.json", JSON.stringify(this.state_.prisma.result.data, null, 2) ] ] : []),
11918
12302
  ...this.state_.interface ? this.state_.interface.files : {},
11919
- ...this.state_.test?.compiled.type === "success" ? this.state_.test.files : {},
11920
- ...this.state_.realize?.compiled.type === "success" ? this.state_.realize.files : {},
12303
+ ...this.state_.test ? this.state_.test.files : {},
12304
+ ...this.state_.realize ? this.state_.realize.files : {},
11921
12305
  "autobe/histories.json": JSON.stringify(this.histories_, null, 2),
11922
12306
  "autobe/tokenUsage.json": JSON.stringify(this.getTokenUsage(), null, 2),
11923
12307
  ...this.state_.interface ? {
@@ -11935,6 +12319,17 @@ class AutoBeAgent {
11935
12319
  getContext() {
11936
12320
  return this.context_;
11937
12321
  }
12322
+ on(type, listener) {
12323
+ emplaceMap(this.listeners_, type, (() => new Set)).add(listener);
12324
+ return this;
12325
+ }
12326
+ off(type, listener) {
12327
+ const set = this.listeners_.get(type);
12328
+ if (set === undefined) return this;
12329
+ set.delete(listener);
12330
+ if (set.size === 0) this.listeners_.delete(type);
12331
+ return this;
12332
+ }
11938
12333
  async dispatch(event) {
11939
12334
  const set = this.listeners_.get(event.type);
11940
12335
  if (set === undefined) return;
@@ -11948,43 +12343,9 @@ class AutoBeAgent {
11948
12343
 
11949
12344
  var AutoBeTokenUsage = AgenticaTokenUsage;
11950
12345
 
11951
- function invertOpenApiDocument(document) {
11952
- const app = HttpMigration.application(document);
11953
- return {
11954
- operations: app.routes.filter((r => r.query === null)).map((r => ({
11955
- specification: empty("specification"),
11956
- method: r.method,
11957
- path: r.path,
11958
- summary: r.operation().summary ?? empty("summary"),
11959
- description: r.operation().description ?? empty("description"),
11960
- parameters: r.parameters.map((p => ({
11961
- name: p.name,
11962
- description: p.parameter().description ?? empty("description"),
11963
- schema: p.schema
11964
- }))),
11965
- requestBody: r.body?.type === "application/json" && OpenApiTypeChecker.isReference(r.body.schema) ? {
11966
- description: r.body.description() ?? empty("description"),
11967
- typeName: r.body.schema.$ref.split("/").pop()
11968
- } : null,
11969
- responseBody: r.success?.type === "application/json" && OpenApiTypeChecker.isReference(r.success.schema) ? {
11970
- description: r.success.description() ?? empty("description"),
11971
- typeName: r.success.schema.$ref.split("/").pop()
11972
- } : null
11973
- }))),
11974
- components: {
11975
- schemas: document.components?.schemas ?? {}
11976
- }
11977
- };
11978
- }
11979
-
11980
- function empty(key) {
11981
- return `Describe ${key} as much as possible with clear and concise words.`;
11982
- }
11983
-
11984
12346
  var index$1 = Object.freeze({
11985
12347
  __proto__: null,
11986
- createAgenticaHistory,
11987
- invertOpenApiDocument
12348
+ createAgenticaHistory
11988
12349
  });
11989
12350
 
11990
12351
  var index = Object.freeze({