Event Handling
undefined
import { AutoBeAgent } from "@autobe/agent";
import { AutoBeCompiler } from "@autobe/compiler";
import OpenAI from "openai";
const agent = new AutoBeAgent({
vendor: {
api: new OpenAI({ apiKey: "********" }),
model: "gpt-4.1",
},
compiler: new AutoBeCompiler(),
});
agent.on("userMessage", (event) => {
console.log("User message contents:", event.contents);
});
agent.on("assistantMessage", (event) => {
console.log("Assistant message:", event.text);
});
agent.on("analyzeComplete", (event) => {
console.log("Analyze complete:", event.files);
});
agent.on("databaseComplete", (event) => {
console.log(
"Database complete:",
event.schemas,
event.compiled.type === "success" ? event.compiled.document : null,
);
});
agent.on("interfaceComplete", (event) => {
console.log("Interface complete:", event.document, event.files);
});
agent.on("testComplete", (event) => {
console.log("Test complete:", event.files);
});
await agent.conversate(`
I want to create a political/economic discussion board.
Since I'm not familiar with programming,
please write a requirements analysis report as you see fit.
`);The AutoBeAgent provides real-time event notifications throughout the development process.
These events allow you to monitor progress, handle intermediate states, and respond to completion events. All event types in @autobe are collected into the AutoBeEvent type as a union, providing comprehensive coverage of the agentβs activities.
Events in AutoBE can be categorized into two main types:
- Message Events: Track conversation flow between user and assistant
- Development Events: Monitor progress through various development phases
Message Events
undefined
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeUserConversateContent } from "./contents/AutoBeUserConversateContent";
/**
* Event fired when a user sends a message during the conversation flow.
*
* This event represents real-time user input in the vibe coding conversation,
* capturing the multimodal communication from users that drives the development
* process. User messages can include text descriptions, visual references,
* document uploads, and voice input that provide the requirements, feedback,
* and guidance necessary for the AI agents to generate accurate software
* solutions.
*
* The user message events serve as the primary input source for the entire vibe
* coding pipeline, enabling users to express their needs through multiple
* modalities and maintain interactive control over the automated development
* process as it progresses through different phases.
*
* @author Samchon
*/
export interface AutoBeUserMessageEvent extends AutoBeEventBase<"userMessage"> {
/**
* Array of multimodal content items that comprise the user's message.
*
* Contains the diverse {@link AutoBeUserConversateContent} elements that make
* up the user's communication, which can include text descriptions, images
* for visual references, document files for specifications, and audio for
* voice input. Each content item represents a different modality or
* attachment within the same message.
*
* The multimodal array structure allows users to combine multiple content
* types in a single message, such as text requirements accompanied by
* reference images or documents. This comprehensive input approach provides
* rich context for the AI agents to better understand user intentions and
* generate more accurate development artifacts throughout the vibe coding
* process.
*/
contents: AutoBeUserConversateContent[];
}Message events are fired whenever thereβs communication between the user and the assistant.
The AutoBeUserMessageEvent is triggered when users send messages. For users, multimodal capabilities are supported, allowing not only text but also image/document file attachments and voice input, which results in different content types. The AutoBeAssistantMessageEvent is fired when the assistant responds. The assistant communicates only through text, so its content type is limited to string in the message property.
These events are essential for building interactive interfaces, logging conversations, or implementing custom message processing logic.
Development Events
Analyze Events
start
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Analyze agent begins the requirements analysis process.
*
* This event marks the initiation of the structured requirements analysis
* workflow, signaling that the agent is starting to draft the comprehensive
* analysis report. The start event represents the beginning of the critical
* foundation phase that transforms user conversations and business needs into
* structured documentation for the entire vibe coding pipeline.
*
* The analysis process that begins with this event will proceed through
* drafting, reviewing, and finalizing phases to produce the authoritative
* requirements documentation that guides all subsequent development activities
* including database design, API specification, and implementation.
*
* @author Kakasoo
*/
export interface AutoBeAnalyzeStartEvent
extends AutoBeEventBase<"analyzeStart"> {
/**
* Iteration number of the requirements analysis being started.
*
* Indicates which revision of the requirements analysis is beginning. A value
* of 0 means this is the initial requirements analysis, while higher values
* represent subsequent revisions being initiated based on user feedback,
* additional requirements, or refinement needs.
*
* This step number helps track the iterative nature of requirements
* development and provides context for understanding the evolution of project
* requirements throughout the development process.
*/
step: number;
}Analyze events track the requirements analysis process, which follows a structured workflow from initial drafting to final completion.
The AutoBeAnalyzeStartEvent event is fired when the agent begins drafting the requirements analysis. The AutoBeAnalyzeWriteEvent event occurs during the writing phase, followed by AutoBeAnalyzeReviewEvent during the review and amendment process. Finally, AutoBeAnalyzeCompleteEvent is fired when the requirements analysis report is finalized.
AutoBeAnalyzeCompleteEvent is generated when the @autobe agent and user have completed all discussions regarding requirements, and a report has been issued. The report consists of multiple markdown documents, which are stored in the files property.
The step property indicates which iteration of the requirements analysis report this represents. If this value is not 0, it means the requirements analysis report has been revised that many times. If the step value of other events is lower than AutoBeAnalyzeCompleteEvent.step, it means those events have not been reflected in the latest requirements analysis report.
Database Events
Database Events
//----------------------------------------
// File: AutoBeDatabaseStartEvent.ts
//----------------------------------------
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Database agent begins the database design process.
*
* This event marks the initiation of the sophisticated three-tier compiler
* infrastructure that transforms business requirements into validated database
* architectures through AST manipulation. The Database agent start represents the
* beginning of the foundational data layer development that will support all
* subsequent application functionality.
*
* The database design process that begins with this event will proceed through
* component organization, schema creation, validation, and compilation to
* produce production-ready Prisma schemas that maintain perfect semantic
* integrity and syntactic correctness while accurately reflecting business
* requirements.
*
* @author Samchon
*/
export interface AutoBeDatabaseStartEvent extends AutoBeEventBase<"databaseStart"> {
/**
* Reason why the Database agent was activated through function calling.
*
* Explains the specific circumstances that triggered the AI chatbot to invoke
* the Database agent via function calling. This could include reasons such as
* initial database design after requirements analysis completion, updating
* database schemas due to requirement changes, regenerating data models to
* reflect modified business logic, or creating additional database structures
* for new functionality.
*
* Understanding the activation reason provides context for the database
* design scope and helps stakeholders understand whether this represents
* initial development, schema refinement, or expansion of existing data
* architecture.
*/
reason: string;
/**
* Iteration number of the requirements analysis this database design is being
* started for.
*
* Indicates which version of the requirements analysis this database design
* will reflect. This step number ensures that the Database agent works with the
* current requirements and helps track the evolution of database schemas as
* business requirements and data needs change.
*
* The step value enables proper synchronization between database design
* activities and the underlying requirements, ensuring that the data
* architecture remains aligned with the current project scope and business
* objectives throughout the iterative development process.
*/
step: number;
}
//----------------------------------------
// File: AutoBeDatabaseComponentEvent.ts
//----------------------------------------
import { AutoBeDatabaseComponent } from "../histories/contents";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Database agent completes table design for a single
* database component during the database design process.
*
* This event occurs when the Database agent has taken a component skeleton
* (namespace and filename already determined by the DATABASE_GROUP phase) and
* filled in all the table designs for that specific component. Each event
* represents the completion of ONE component's table design.
*
* Multiple events of this type are emitted in sequence as the Database agent
* processes each component skeleton from the group, enabling real-time progress
* tracking for component-by-component table generation.
*
* @author Samchon
*/
export interface AutoBeDatabaseComponentEvent
extends
AutoBeEventBase<"databaseComponent">,
AutoBeAggregateEventBase,
AutoBeProgressEventBase {
/**
* Analysis of the component's scope and table requirements.
*
* Documents the agent's understanding of this component's domain, including
* what the component's business purpose is, what entities from the
* requirements belong to this component, what relationships exist between
* these entities, and what normalization patterns were identified.
*/
analysis: string;
/**
* Rationale for the table design decisions.
*
* Explains why tables were designed this way, including why each table was
* created, why certain entities were kept separate vs combined, what
* normalization principles were applied, and how the tables fulfill the
* component's rationale.
*/
rationale: string;
/**
* The completed database component with its table designs.
*
* Contains the single database component that was completed in this event.
* The component skeleton (namespace, filename, thinking, review, rationale)
* was provided by the DATABASE_GROUP phase, and this event represents the
* completion of filling in the tables array for that component.
*
* The component includes:
*
* - namespace: Business domain namespace (from skeleton)
* - filename: Prisma schema filename (from skeleton)
* - thinking: Initial reasoning about component purpose (from skeleton)
* - review: Review of component scope (from skeleton)
* - rationale: Final justification for component (from skeleton)
* - tables: Array of complete table designs (FILLED IN by this agent)
*
* Each table in the tables array includes:
* - name: snake_case plural table name
* - description: Purpose and contents of the table
*/
component: AutoBeDatabaseComponent;
/**
* Iteration number of the requirements analysis this component organization
* was performed for.
*
* Indicates which version of the requirements analysis this table
* organization reflects. This step number ensures that the database component
* structure is aligned with the current requirements and helps track the
* evolution of database architecture as business requirements change.
*
* The step value enables proper synchronization between database organization
* and the underlying requirements, ensuring that the schema structure remains
* relevant to the current project scope and business objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeDatabaseSchemaEvent.ts
//----------------------------------------
import { AutoBeDatabase } from "../database";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Database agent generates a single database table model
* during the database design process.
*
* This event occurs when the Database agent has successfully designed and
* generated ONE specific database table within a business domain. The agent
* follows a systematic 2-step process: strategic planning (plan) and model
* generation (model), producing a production-ready database table model that
* maintains data integrity and business logic accuracy. The generated model
* will be reviewed by a separate review agent.
*
* Each event represents the completion of a single table within a namespace.
* Multiple events are emitted for each namespace, one per table, enabling
* fine-grained progress tracking and parallel generation of tables within the
* same business domain.
*
* @author Samchon
*/
export interface AutoBeDatabaseSchemaEvent
extends
AutoBeEventBase<"databaseSchema">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Strategic database design analysis and planning phase for the target table.
*
* Contains the AI agent's comprehensive analysis of the specific table being
* designed and its database design strategy. The agent evaluates the table's
* structure, relationships with other tables, normalization requirements, and
* performance considerations to create a well-architected table model that
* aligns with business objectives and technical best practices.
*
* This planning phase establishes the foundation for the single table design,
* ensuring proper field organization, relationship mapping, and adherence to
* database normalization principles while considering future scalability and
* maintainability requirements.
*/
plan: string;
/**
* Business domain namespace where this database table belongs.
*
* Identifies the logical business domain or functional area that this
* database table is part of. The namespace follows domain-driven design
* principles, grouping related tables together to maintain coherent schema
* organization and clear separation of concerns across different business
* areas.
*
* The namespace determines which Prisma schema file this table will be
* written to, enabling systematic development and maintainable database
* architecture. Each namespace typically corresponds to a major business
* domain such as "Actors", "Sales", or "Systematic".
*/
namespace: string;
/**
* Single Prisma schema model generated based on the strategic plan.
*
* Contains the production-ready AST representation of a single Prisma schema
* model generated following the strategic plan. This model implements the
* planned table structure, relationships, and constraints using the
* AutoBeDatabase.IModel interface. The model is designed to be
* production-ready from the start.
*
* The model includes the exact table name from requirements, proper UUID
* primary field, foreign key relationships, business fields with appropriate
* types, strategic indexes, and comprehensive English-only descriptions.
*/
model: AutoBeDatabase.IModel;
/**
* Iteration number of the requirements analysis this schema was generated
* for.
*
* Tracks which version of the business requirements this database schema
* reflects, ensuring alignment between the evolving requirements and the
* generated data models. As requirements change through iterations, this step
* number helps maintain traceability and version consistency across the
* database architecture development process.
*/
step: number;
}
//----------------------------------------
// File: AutoBeDatabaseValidateEvent.ts
//----------------------------------------
import { IAutoBePrismaCompileResult } from "../compiler/IAutoBePrismaCompileResult";
import { IAutoBeDatabaseValidation } from "../database/IAutoBeDatabaseValidation";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Database agent validates the constructed database design
* and encounters validation failures that need correction.
*
* This event occurs when the custom Database compiler processes the generated AST
* structure and detects validation errors that prevent successful schema
* compilation. The validation process represents a critical quality gate in the
* vibe coding pipeline, ensuring that only semantically correct and
* business-aligned database designs proceed to final generation.
*
* The validation event triggers the feedback loop that enables AI
* self-correction, providing detailed error information that helps the Database
* agent understand what needs to be fixed and how to improve the database
* design quality.
*
* @author Samchon
*/
export interface AutoBeDatabaseValidateEvent extends AutoBeEventBase<"databaseValidate"> {
/**
* The validation failure details describing what errors were detected.
*
* Contains the specific {@link IAutoBeDatabaseValidation.IFailure} information
* that describes the validation errors found in the database design. This
* includes details about relationship issues, constraint violations, naming
* problems, performance concerns, or other semantic errors that prevent the
* design from meeting quality standards.
*
* The failure information provides comprehensive diagnostic details necessary
* for the AI to understand the validation problems and formulate appropriate
* corrections to resolve the identified issues.
*/
result: IAutoBeDatabaseValidation.IFailure;
/**
* Results of attempting to compile the current database design.
*
* Contains the {@link IAutoBePrismaCompileResult} from the compilation attempt
* that revealed the validation issues. Even when validation fails, the
* compiler may provide partial results or additional diagnostic information
* that helps understand the scope and nature of the problems.
*
* The compilation results offer additional context beyond the validation
* failure, potentially including information about which parts of the design
* are working correctly and which specific areas need attention.
*/
compiled: IAutoBePrismaCompileResult;
/**
* Generated schema files that failed validation as key-value pairs.
*
* Contains the Prisma schema files that were generated but failed to pass
* validation. Each key represents the filename and each value contains the
* schema content that contains the validation errors. These schemas provide
* context for understanding what was attempted and where the problems
* occurred.
*
* Having access to the failing schemas enables detailed analysis of the
* validation issues and helps in formulating precise corrections that address
* the specific problems without disrupting working portions of the design.
*/
schemas: Record<string, string>;
/**
* Iteration number of the requirements analysis this validation was performed
* for.
*
* Indicates which version of the requirements analysis this database
* validation reflects. This step number ensures that the validation feedback
* is aligned with the current requirements and helps track the quality
* improvement process as validation issues are identified and resolved.
*
* The step value enables proper synchronization between validation activities
* and the underlying requirements, ensuring that validation efforts remain
* relevant to the current project scope and business objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeDatabaseCorrectEvent.ts
//----------------------------------------
import { AutoBeDatabase } from "../database/AutoBeDatabase";
import { IAutoBeDatabaseValidation } from "../database/IAutoBeDatabaseValidation";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Database agent corrects validation failures in the
* database design.
*
* This event occurs when the custom Database compiler detects validation errors
* in the constructed AST structure and the Database agent receives feedback to
* correct compilation issues. The correction process represents the
* sophisticated feedback loop that enables AI self-correction, ensuring that
* only valid and semantically correct database designs proceed to final
* generation.
*
* The correction mechanism is essential for maintaining the reliability of the
* vibe coding pipeline, allowing the system to iteratively refine database
* designs until they meet all validation requirements and business
* constraints.
*
* @author Samchon
*/
export interface AutoBeDatabaseCorrectEvent
extends AutoBeEventBase<"databaseCorrect">, AutoBeAggregateEventBase {
/**
* The validation failure details that triggered the correction process.
*
* Contains the specific {@link IAutoBeDatabaseValidation.IFailure} information
* that describes what validation errors were detected in the database design.
* This includes details about relationship issues, constraint violations,
* naming problems, or other semantic errors that prevented successful
* validation.
*
* The failure information provides the diagnostic context necessary for the
* AI to understand what went wrong and make appropriate corrections to the
* database design.
*/
failure: IAutoBeDatabaseValidation.IFailure;
/**
* The corrected AST application structure addressing the validation failures.
*
* Contains the revised {@link AutoBeDatabase.IApplication} structure that
* attempts to resolve the validation issues identified in the failure. The
* correction incorporates the feedback from the validation process to address
* relationship problems, fix constraint violations, resolve naming conflicts,
* or correct other structural issues.
*
* This corrected structure will undergo validation again to ensure that the
* modifications successfully resolve the identified problems while
* maintaining the integrity of the overall database design.
*/
correction: AutoBeDatabase.IApplication;
/**
* Explanation of the correction strategy and changes being made.
*
* Describes the AI's analysis of the validation failure and the specific
* approach being taken to resolve the issues. This planning explanation
* provides transparency into the correction process, helping stakeholders
* understand what changes are being made and why they are necessary.
*
* The planning commentary helps track the iterative improvement process and
* provides insights into how the AI learns from validation feedback to
* improve database design quality.
*/
planning: string;
/**
* Iteration number of the requirements analysis this correction was performed
* for.
*
* Indicates which version of the requirements analysis this database
* correction reflects. This step number ensures that the correction efforts
* are aligned with the current requirements and helps track the evolution of
* database design quality as validation feedback is incorporated.
*
* The step value enables proper synchronization between correction activities
* and the underlying requirements, ensuring that design improvements remain
* relevant to the current project scope and business objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeDatabaseCompleteEvent.ts
//----------------------------------------
import { IAutoBePrismaCompileResult } from "../compiler/IAutoBePrismaCompileResult";
import { IAutoBeDatabaseValidation } from "../database/IAutoBeDatabaseValidation";
import { AutoBeCompleteEventBase } from "./base/AutoBeCompleteEventBase";
/**
* Event fired when the Database agent completes the database design process and
* successfully generates validated schema files.
*
* This event represents the successful completion of the sophisticated
* three-tier compiler infrastructure that transforms business requirements into
* validated database architectures. The completion marks the transition from
* requirements analysis to a concrete database implementation that maintains
* perfect semantic integrity and syntactic correctness.
*
* The Database agent's completion ensures that the database design accurately
* reflects business needs while providing the foundation for subsequent API
* development and application implementation phases.
*
* @author Samchon
*/
export interface AutoBeDatabaseCompleteEvent extends AutoBeCompleteEventBase<"databaseComplete"> {
/**
* The validated AST application structure containing the complete database
* design.
*
* Contains the finalized {@link AutoBeDatabase.IApplication} structure that
* represents the complete database architecture as validated AST data. This
* application includes all models, relationships, constraints, and business
* rules that have passed through the comprehensive validation process
* including relationship graph analysis, business logic validation, and
* performance optimization.
*
* The application structure serves as the authoritative source of database
* design that has been verified for semantic correctness and business
* alignment before code generation.
*/
result: IAutoBeDatabaseValidation;
/**
* Generated Prisma schema files as key-value pairs.
*
* Contains the production-ready schema files generated through deterministic
* code generation from the validated AST structure. Each key represents the
* filename (following the pattern `schema-{number}-{domain}.prisma`) and each
* value contains the actual Prisma schema content organized by business
* domains.
*
* The schemas include comprehensive documentation, optimal indexes, proper
* constraints, and all optimizations derived from the AST analysis, ready for
* immediate deployment to the target database environment.
*/
schemas: Record<string, string>;
/**
* Results of compiling the generated Prisma schema files.
*
* Contains the {@link IAutoBePrismaCompileResult} from processing the
* generated schemas through the Database compiler. This should always indicate
* successful compilation since the schemas are generated from pre-validated
* AST structures. The compilation results include documentation, diagrams,
* and dependency files ready for deployment.
*
* Successful compilation confirms that the generated schemas will work
* correctly in the target database environment and integrate properly with
* the broader development ecosystem.
*/
compiled: IAutoBePrismaCompileResult;
}Database events monitor the database design process. Database design in @autobe begins with the AutoBeDatabaseStartEvent, followed by AutoBeDatabaseComponentEvent which lists all tables that @autobe will design and their categorized groups. The AutoBeDatabaseSchemaEvent event is fired each time tables within a category group are completed.
Once all schema designs are completed, the AutoBeDatabaseValidateEvent event is triggered, and @autobeβs built-in Prisma compiler validates the table designs. If validation succeeds, @autobe fires the AutoBeDatabaseCompleteEvent event. Conversely, if validation fails, the AutoBeDatabaseCorrectEvent event is triggered, requesting the AI to fix the compilation errors. The AutoBeDatabaseValidateEvent event is then fired again, repeating this cycle.
AutoBeDatabaseCompleteEvent is generated when @autobe analyzes the requirements specification and completes the database design.
@autobe constructs data of type AutoBeDatabase.IApplication through AI function calling, validates it, and then generates prisma schema files. The validation results are stored in the result property as type IAutoBeDatabaseValidation, and the results of converting this to prisma schema files (code generation) are stored in the schemas property.
Note that @autobe generally creates valid AutoBeDatabase.IApplication data through a validation feedback process. However, when using very small AI models, the IAutoBeDatabaseValidation result might have success := false. Additionally, the results of compiling the prisma schema files are stored in the compiled property as type IAutoBePrismaCompileResult, which should always compile successfully. If compilation fails, it would be a bug in @autobe, so please report it as an issue.
The step property indicates which requirements analysis report iteration the database design was performed for. If the AutoBeDatabaseCompleteEvent.step value is lower than AutoBeAnalyzeCompleteEvent.step, it means the database design has not yet been updated to reflect the latest requirements.
Interface Events
Interface Events
//----------------------------------------
// File: AutoBeInterfaceStartEvent.ts
//----------------------------------------
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Interface agent begins the RESTful API design process.
*
* This event marks the initiation of the sophisticated multi-stage
* transformation pipeline that converts validated AST structures into
* comprehensive API specifications. The Interface agent start represents a
* critical transition point where database schemas and requirements analysis
* are transformed into API contracts that bridge data storage and application
* functionality.
*
* The API design process that begins with this event will proceed through
* endpoint creation, operation definition, component specification, and final
* code generation to produce production-ready NestJS applications with complete
* type safety and business logic integration.
*
* @author Samchon
*/
export interface AutoBeInterfaceStartEvent
extends AutoBeEventBase<"interfaceStart"> {
/**
* Reason why the Interface agent was activated through function calling.
*
* Explains the specific circumstances that triggered the AI chatbot to invoke
* the Interface agent via function calling. This could include reasons such
* as completing initial API design after database schema creation, updating
* API specifications due to requirement changes, regenerating interfaces to
* reflect modified data models, or creating new API endpoints for additional
* functionality.
*
* Understanding the activation reason provides context for the API design
* scope and helps stakeholders understand whether this represents new
* development, refinement of existing specifications, or integration with
* updated database schemas.
*/
reason: string;
/**
* Iteration number of the requirements analysis this API design is being
* started for.
*
* Indicates which version of the requirements analysis this API design will
* reflect. This step number ensures that the Interface agent works with the
* current requirements and helps track the evolution of API specifications as
* requirements and database schemas change.
*
* The step value enables proper synchronization between API design activities
* and the underlying requirements, ensuring that the API development remains
* aligned with the current project scope and business objectives throughout
* the iterative development process.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceEndpointEvent.ts
//----------------------------------------
import { AutoBeInterfaceEndpointDesign } from "../histories/contents/AutoBeInterfaceEndpointDesign";
import { AutoBeOpenApi } from "../openapi/AutoBeOpenApi";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Interface agent creates the complete list of API
* endpoints during the RESTful API design process.
*
* This event occurs early in the API design workflow, after the Interface agent
* has analyzed the requirements and database schema to determine what API
* endpoints are needed for the application. The endpoint creation establishes
* the fundamental structure of the API surface area before detailed operation
* definitions and schema components are developed.
*
* The endpoints list provides the architectural foundation for the API design,
* ensuring comprehensive coverage of the business functionality while
* maintaining RESTful principles and consistency with the underlying data
* model.
*
* @author Samchon
*/
export interface AutoBeInterfaceEndpointEvent
extends
AutoBeEventBase<"interfaceEndpoint">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Type discriminator for the endpoint event.
*
* Specifies the type of endpoint event that occurred:
*
* - `"base"`: Base CRUD endpoint event (at, index, create, update, erase)
* - `"action"`: Action endpoint event (analytics, dashboard, search, reports)
*/
kind: "base" | "action";
group: string;
/**
* Analysis of the requirements and database schema for endpoint design.
*
* Documents the agent's understanding of business requirements needing API
* coverage, database entities and relationships, CRUD operations needed,
* and special operations beyond basic CRUD.
*/
analysis: string;
/**
* Rationale for the endpoint design decisions.
*
* Explains why paths and methods were chosen, how endpoints map to
* requirements and entities, what RESTful conventions were followed, and
* what was excluded.
*/
rationale: string;
/**
* Array of API endpoints that have been defined for the application.
*
* Contains the complete list of {@link AutoBeOpenApi.IEndpoint} definitions
* that establish the API surface area for the application. Each endpoint
* represents a specific URL path and HTTP method combination that will be
* available in the final API, covering all necessary business operations and
* data access patterns.
*
* The endpoints are designed to provide comprehensive coverage of the
* business functionality while following RESTful conventions and maintaining
* consistency with the database schema. This foundational structure guides
* the subsequent development of detailed operation specifications and schema
* definitions.
*/
designs: AutoBeInterfaceEndpointDesign[];
/**
* Iteration number of the requirements analysis this endpoint creation was
* performed for.
*
* Indicates which version of the requirements analysis this endpoint design
* reflects. This step number ensures that the API endpoints are aligned with
* the current requirements and helps track the evolution of the API surface
* area as requirements change.
*
* The step value enables proper synchronization between endpoint definitions
* and the underlying requirements, ensuring that the API structure remains
* relevant to the current project scope and business objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceOperationEvent.ts
//----------------------------------------
import { AutoBeOpenApi } from "../openapi/AutoBeOpenApi";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Interface agent defines API operations for an endpoint
* during the RESTful API specification process.
*
* This event occurs when the Interface agent creates detailed operation
* specifications for a single endpoint. Each endpoint may generate multiple
* operations when different authorization actors are specified (e.g., one
* endpoint with ["admin", "user"] actors generates two operations with
* different path prefixes).
*
* Operations include comprehensive business logic definitions, parameter
* specifications, response schemas, error handling, and security requirements
* that transform an endpoint definition into fully functional API contracts.
*
* The operation definition process ensures that the endpoint has complete
* behavioral specifications, proper documentation, and clear contracts that
* enable accurate code generation and reliable client integration.
*
* @author Samchon
*/
export interface AutoBeInterfaceOperationEvent
extends
AutoBeEventBase<"interfaceOperation">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Analysis of the endpoint's purpose and context.
*
* Documents the agent's understanding of what the endpoint is for, what
* business requirement it fulfills, database entities and fields involved,
* parameters and body types needed, and authorization considerations.
*/
analysis: string;
/**
* Rationale for the operation design decisions.
*
* Explains why specific parameters and body types were chosen, authorization
* actor selection, how the operation fulfills endpoint description, and what
* was excluded from the design.
*/
rationale: string;
/**
* Array of API operations generated for the endpoint.
*
* Contains the detailed {@link AutoBeOpenApi.IOperation} specifications
* generated for a single endpoint. Multiple operations are created when
* different authorization actors are specified - each actor generates a
* separate operation with its own path prefix (e.g., "/admin/users" and
* "/user/users" from a single "/users" endpoint).
*
* Each operation includes comprehensive documentation, request/response
* schemas, error handling specifications, and security requirements that
* transform the basic endpoint into complete API contracts.
*/
operations: AutoBeOpenApi.IOperation[];
/**
* Iteration number of the requirements analysis this operation definition was
* performed for.
*
* Indicates which version of the requirements analysis this operation design
* reflects. This step number ensures that the API operations are aligned with
* the current requirements and helps track the evolution of API functionality
* as business requirements change.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceOperationReviewEvent.ts
//----------------------------------------
import { AutoBeOpenApi } from "../openapi";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired during the review and validation phase of a single API operation.
*
* This event occurs when the Interface agent reviews and validates a generated
* API operation against business requirements, technical specifications, and
* OpenAPI standards. The review phase ensures that the operation properly
* implements the required functionality with correct request/response schemas,
* authentication, error handling, and documentation.
*
* The review process involves systematic validation where the agent evaluates
* operation completeness, parameter correctness, response accuracy, and API
* design consistency. If the operation fails validation or violates
* architectural principles, it may be corrected or removed (content set to
* null).
*
* @author Kakasoo
*/
export interface AutoBeInterfaceOperationReviewEvent
extends
AutoBeEventBase<"interfaceOperationReview">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Original API operation submitted for review.
*
* The operation generated by the Interface Operations Agent that requires
* validation for security compliance, schema alignment, logical consistency,
* and adherence to AutoBE standards. This is the operation being evaluated
* for potential issues and improvements.
*/
operation: AutoBeOpenApi.IOperation;
/**
* Detailed review feedback from the Interface Operations Review Agent.
*
* Contains comprehensive assessment results including:
*
* - Security vulnerability analysis
* - Schema compliance validation
* - Logical consistency verification
* - Standard adherence evaluation
* - Identified critical issues and recommendations
*/
review: string;
/**
* Amendment plan based on the review feedback.
*
* Structured action plan outlining specific corrections needed for:
*
* - Security issues (password exposure, authorization bypasses)
* - Logic errors (mismatched return types, incorrect HTTP semantics)
* - Schema violations (missing fields, type mismatches)
*
* If operations are perfect, explicitly states no changes are required.
*/
plan: string;
/**
* Revised operation based on the amendment plan, or null if removed.
*
* The final corrected API operation after applying all fixes from the
* improvement plan. If no issues were found during review, this contains the
* original operation unchanged. If the operation violates fundamental
* architectural principles or should be removed entirely, this is null. The
* enhanced operation is ready for schema generation and subsequent
* implementation phases.
*/
content: AutoBeOpenApi.IOperation | null;
/**
* Current iteration number of the operation review process.
*
* Indicates which revision cycle of the API operation review is currently
* being executed. This step number helps track the iterative validation
* process and provides context for understanding how many review cycles have
* been completed to achieve the desired operation quality.
*
* The step value increments with each major review iteration, allowing
* stakeholders to monitor the progressive refinement of API operations and
* understand the validation rigor applied to the interface design.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceSchemaEvent.ts
//----------------------------------------
import { AutoBeOpenApi } from "../openapi/AutoBeOpenApi";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Interface agent defines schema definitions during the
* API specification process.
*
* This event occurs when the Interface agent is creating the reusable schema
* definitions that will be used throughout the API specification. Schema
* definitions include data transfer objects (DTOs), request/response schemas,
* and other type definitions that provide the structural foundation for API
* operations and ensure type safety across the entire application.
*
* The schema creation process ensures that all data structures used in API
* operations are properly defined, validated, and documented, enabling
* consistent data handling and robust type checking throughout the generated
* application.
*
* @author Samchon
*/
export interface AutoBeInterfaceSchemaEvent
extends
AutoBeEventBase<"interfaceSchema">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Type name of the schema being defined.
*
* Represents the unique identifier for the schema definition being created in
* the OpenAPI specification. This type name will be used as the key in the
* OpenAPI components.schemas object and referenced throughout the API
* specification for type consistency and reusability.
*
* The type name follows TypeScript naming conventions and should be
* descriptive of the data structure it represents, enabling clear
* understanding of the schema's purpose in the API contract.
*/
typeName: string;
/**
* Analysis of the type's purpose and context.
*
* Documents the agent's understanding of the schema before designing it,
* including the type's purpose, related database entities or operations,
* expected fields based on variant type, and structural hints from related
* types.
*/
analysis: string;
/**
* Rationale for the schema design decisions.
*
* Explains why the schema was designed with specific properties, required vs
* optional field choices, $ref usage decisions, and what was excluded (e.g.,
* auto-generated fields for ICreate variants).
*/
rationale: string;
/**
* Schema definitions being defined for the API specification.
*
* Contains the schema record that defines reusable schema definitions for the
* OpenAPI specification. These schemas serve as the building blocks for API
* operations, providing consistent type definitions and ensuring that data
* structures are properly validated and documented.
*
* The schemas maintain perfect alignment with the database schema while
* providing the appropriate level of abstraction for API consumers, including
* proper validation rules, descriptive documentation, and type safety
* throughout the application stack.
*/
schema: AutoBeOpenApi.IJsonSchemaDescriptive;
/**
* Iteration number of the requirements analysis this schema creation was
* performed for.
*
* Indicates which version of the requirements analysis this schema design
* reflects. This step number ensures that the schema definitions are aligned
* with the current requirements and helps track the evolution of data
* structures as requirements change.
*
* The step value enables proper synchronization between schema definitions
* and the underlying requirements, ensuring that the API schemas remain
* relevant to the current project scope and business objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceSchemaReviewEvent.ts
//----------------------------------------
import { AutoBeInterfaceSchemaPropertyRevise } from "../histories/contents/AutoBeInterfaceSchemaPropertyRevise";
import { AutoBeOpenApi } from "../openapi/AutoBeOpenApi";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired during the multi-dimensional review and validation phase of
* OpenAPI schema generation process.
*
* This event represents the unified validation activity of specialized
* Interface Schema Review Agents, which ensure schemas are secure, structurally
* sound, and complete. The event supports three distinct review kinds executed
* sequentially: security, relation, and content validation.
*
* The Interface Schema Review Agents perform comprehensive validation
* including:
*
* - **Security** (`kind: "security"`): Authentication context removal,
* password/token field protection, phantom field detection, system-managed
* field protection
* - **Relation** (`kind: "relation"`): Relation classification, foreign key to
* object transformation, actor reversal prohibition, $ref extraction
* - **Content** (`kind: "content"`): Field completeness, type accuracy, required
* field alignment, cross-variant consistency
*
* Review execution order:
*
* 1. Security review removes dangerous fields and prevents vulnerabilities
* 2. Relation review structures relationships between clean schemas
* 3. Content review validates completeness of secure, well-structured schemas
*
* Each review kind focuses on its specialized domain while contributing to
* production-ready, type-safe OpenAPI schemas that accurately model the
* business domain.
*
* @author Samchon
*/
export interface AutoBeInterfaceSchemaReviewEvent
extends
AutoBeEventBase<"interfaceSchemaReview">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Review dimension discriminator.
*
* Specifies which specialized agent is performing validation:
*
* - `"security"`: Security validation for authentication and data protection
* - `"relation"`: Relation validation for DTO relationships and structure
* - `"content"`: Content validation for field completeness and accuracy
*/
kind: "security" | "relation" | "content" | "phantom";
/**
* Type name of the schema being reviewed.
*
* Specifies the specific DTO type name that is being validated in this
* review. Examples: "IUser.ICreate", "IProduct.ISummary", "IBbsArticle"
*/
typeName: string;
/**
* Original schema submitted for review.
*
* Contains the OpenAPI schema requiring validation according to the review
* kind. The schema is the full descriptive JSON schema structure with
* AutoBE-specific metadata.
*/
schema: AutoBeOpenApi.IJsonSchemaDescriptive;
/**
* Violation findings from the review.
*
* Documents all issues discovered during validation, categorized by severity
* or type according to the review kind:
*
* - **Security**: CRITICAL/HIGH/MEDIUM/LOW severity violations
* - **Relation**: CRITICAL/HIGH/MEDIUM/LOW relation issues
* - **Content**: Field completeness, type accuracy, description quality issues
*
* Each finding includes the affected schema, specific problem, and correction
* justification.
*/
review: string;
revises: AutoBeInterfaceSchemaPropertyRevise[];
/**
* Current iteration number of the schema generation being reviewed.
*
* Indicates which version of the schemas is undergoing validation, helping
* track the iterative refinement process.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceComplementEvent.ts
//----------------------------------------
import { AutoBeOpenApi } from "../openapi/AutoBeOpenApi";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Interface agent supplements missing types and schemas
* during the API specification process.
*
* This event occurs when the Interface agent identifies that additional type
* definitions or schema components are needed to complete the API
* specification. The complement phase ensures that all necessary types used in
* API operations are properly defined, including nested objects, utility types,
* and supporting data structures that may have been initially overlooked.
*
* The complement process is essential for creating complete and self-contained
* OpenAPI specifications that can generate fully functional NestJS applications
* without missing dependencies or incomplete type definitions.
*
* @author Samchon
*/
export interface AutoBeInterfaceComplementEvent
extends
AutoBeEventBase<"interfaceComplement">,
AutoBeAggregateEventBase,
AutoBeProgressEventBase {
/**
* Type name of the schema being created.
*
* Specifies the specific DTO type name that is being generated to fill the
* gap. This will be the same as the `missed` field.
*/
typeName: string;
/**
* Analysis of the missing type's purpose and context.
*
* Documents the agent's understanding of why this type is referenced, where
* it is referenced from ($ref locations), what the reference context reveals
* about expected structure, and similar types that provide structural hints.
*/
analysis: string;
/**
* Rationale for the schema design decisions.
*
* Explains why the schema was designed with specific properties, required
* vs optional field choices, how it satisfies referencing schemas'
* expectations, and what patterns from existing schemas were followed.
*/
rationale: string;
/**
* Additional schema definition being added to complement the API
* specification.
*
* Contains the newly created schema definition that fills the gap identified
* as the missing type. The schema contains the complete
* {@link AutoBeOpenApi.IJsonSchemaDescriptive} definition with proper typing,
* validation rules, and descriptive documentation.
*
* This complementary schema ensures that the type referenced throughout the
* API specification is properly defined, enabling successful code generation
* and maintaining type safety across the entire application.
*/
schema: AutoBeOpenApi.IJsonSchemaDescriptive;
/**
* Iteration number of the requirements analysis this API complement was
* performed for.
*
* Indicates which version of the requirements analysis this schema complement
* activity reflects. This step number ensures that the complementary types
* are aligned with the current requirements and helps track the evolution of
* the API specification as requirements change.
*
* The step value enables proper synchronization between the API design and
* the underlying requirements, ensuring that schema additions remain relevant
* to the current project scope and objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeInterfaceCompleteEvent.ts
//----------------------------------------
import { AutoBeInterfaceAuthorization } from "../histories";
import { AutoBeOpenApi } from "../openapi/AutoBeOpenApi";
import { AutoBeCompleteEventBase } from "./base/AutoBeCompleteEventBase";
/**
* Event fired when the Interface agent completes the RESTful API design process
* and generates the complete NestJS application.
*
* This event represents the successful completion of the sophisticated
* multi-stage transformation pipeline that converts validated AST structures
* into comprehensive API specifications and production-ready NestJS code. The
* completion marks the transition from API design to implementation-ready
* artifacts that maintain perfect alignment with business requirements and
* database schemas.
*
* The Interface agent's completion ensures that API designs are syntactically
* perfect and semantically aligned with business requirements, ready for
* immediate deployment or further customization in the development workflow.
*
* @author Samchon
*/
export interface AutoBeInterfaceCompleteEvent
extends AutoBeCompleteEventBase<"interfaceComplete"> {
/**
* The complete OpenAPI document containing the finalized API specification.
*
* Contains the validated {@link AutoBeOpenApi.IDocument} AST structure that
* defines all API endpoints, operations, schemas, and business logic. This
* document represents the culmination of the API design process,
* incorporating comprehensive business logic integration, type safety bridges
* with Prisma schemas, and security pattern validation.
*
* The document serves as the authoritative API specification that has been
* converted from the internal AST format to formal OpenAPI standards, ready
* for code generation and integration with the broader development
* ecosystem.
*/
document: AutoBeOpenApi.IDocument;
/**
* JWT-based authentication and authorization operations generated for each
* user role.
*
* Contains role-specific authentication API operations including essential
* flows (join, login, validate, changePassword, refresh) plus additional
* operations based on Prisma schema capabilities like email verification and
* password reset. These operations are generated by analyzing the database
* schema to determine which authentication features are supported for each
* role.
*/
authorizations: AutoBeInterfaceAuthorization[];
/**
* Array of schema type names that are referenced but not yet implemented in
* components.schemas.
*
* When this array is not empty, it indicates critical missing type
* definitions that will cause cascading failures throughout the entire
* compilation pipeline:
*
* - Interface compilation will fail due to unresolved type references
* - Test code generation will fail due to missing DTO types
* - Realize agent cannot implement endpoints without proper type definitions
* - TypeScript compilation will ultimately fail with "Cannot find name" errors
*
* This represents a fundamental incompleteness in the OpenAPI specification
* that must be resolved before any subsequent development phases can proceed.
* The Interface agent will attempt to automatically generate these missing
* schemas through the complement process.
*/
missed: string[];
}Interface events track the RESTful API design process.
When @autobe designs RESTful APIs, it first fires the AutoBeInterfaceStartEvent event to signal the start of the interface agent. Then it triggers the AutoBeInterfaceEndpointEvent event to create the API endpoint list, followed by AutoBeInterfaceOperationEvent which defines the role of each API function and AutoBeInterfaceSchemaEvent which defines the types they use. Additionally, the AutoBeInterfaceComplementEvent event may be fired to supplement any missing types used in API operations or to provide necessary types as nested objects.
Finally, when all API design is complete, the AutoBeInterfaceCompleteEvent event is fired.
AutoBeInterfaceCompleteEvent is generated when the RESTful API design is completed based on the previous requirements analysis report and database design.
@autobe constructs data of type AutoBeOpenApi.IDocument through AI function calling, validates it, and stores it in the document property. This is then converted to a formal OpenAPI document (OpenApi.IDocument), and NestJS API controllers, DTOs, and e2e test code are generated (code generation), with the results stored in the files property.
The step property indicates which requirements analysis report iteration the API design was performed for. If the AutoBeInterfaceCompleteEvent.step value is lower than AutoBeAnalyzeCompleteEvent.step, it means the API design has not yet been updated to reflect the latest requirements.
Test Events
Test Events
//----------------------------------------
// File: AutoBeTestStartEvent.ts
//----------------------------------------
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Test agent begins the e2e test code generation process.
*
* This event marks the initiation of comprehensive test suite creation based on
* the previous requirements analysis, database design, and RESTful API
* specification. The Test agent start represents the beginning of the
* validation layer development that ensures the generated application functions
* correctly under realistic operational conditions and properly implements
* business requirements.
*
* The test generation process that begins with this event will conceive
* multiple use case scenarios for each API endpoint and implement them as test
* programs, providing thorough coverage of both technical functionality and
* business logic validation throughout the application ecosystem.
*
* @author Samchon
*/
export interface AutoBeTestStartEvent extends AutoBeEventBase<"testStart"> {
/**
* Reason why the Test agent was activated through function calling.
*
* Explains the specific circumstances that triggered the AI chatbot to invoke
* the Test agent via function calling. This could include reasons such as
* initial test suite generation after API specification completion, updating
* test scenarios due to API changes, regenerating tests to reflect modified
* business requirements or database schemas, or creating additional test
* coverage for new functionality.
*
* Understanding the activation reason provides context for the test
* generation scope and helps stakeholders understand whether this represents
* initial test development, refinement of existing test scenarios, or
* expansion of validation coverage.
*/
reason: string;
/**
* Iteration number of the requirements analysis this test generation is being
* started for.
*
* Indicates which version of the requirements analysis this test suite will
* validate. This step number ensures that the Test agent works with the
* current requirements and helps track the evolution of test scenarios as
* business requirements, database schemas, and API specifications change.
*
* The step value enables proper synchronization between test generation
* activities and the underlying requirements, ensuring that the test suite
* remains aligned with the current project scope and validation objectives
* throughout the iterative development process.
*/
step: number;
}
//----------------------------------------
// File: AutoBeTestScenarioEvent.ts
//----------------------------------------
import { AutoBeTestScenario } from "../histories/contents/AutoBeTestScenario";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Test agent generates e2e test scenarios for specific API
* endpoints.
*
* This event occurs when the Test agent analyzes API endpoints and creates test
* scenarios that include the main function to test and any dependency functions
* that need to be called first. The event provides visibility into the test
* generation progress and the structure of generated test cases.
*
* Each scenario includes draft test code and a clear dependency chain that
* ensures tests can execute successfully with proper data setup and
* prerequisites.
*
* @author Kakasoo
*/
export interface AutoBeTestScenarioEvent
extends
AutoBeEventBase<"testScenario">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* List of test scenarios generated for the target endpoints.
*
* Each scenario contains the endpoint to test, generated test code draft, and
* any dependency functions that must be called before the main test. The
* scenarios represent complete test cases ready for compilation and
* execution.
*/
scenarios: AutoBeTestScenario[];
/**
* Current step in the test generation workflow.
*
* Tracks progress through the test creation process, helping coordinate with
* other pipeline stages and maintain synchronization with the current
* requirements iteration.
*/
step: number;
}
//----------------------------------------
// File: AutoBeTestWriteEvent.ts
//----------------------------------------
import { AutoBeTestFunction } from "../histories";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
import { AutoBeProgressEventBase } from "./base/AutoBeProgressEventBase";
/**
* Event fired when the Test agent writes and completes individual test scenario
* files.
*
* This event provides real-time visibility into the test file creation process
* as the Test agent systematically writes test scenarios for each API endpoint.
* Each write event represents the completion of a specific test file that
* implements use case scenarios, ensuring comprehensive coverage of API
* functionality and business logic validation.
*
* The write events enable stakeholders to monitor the test suite development
* and understand how comprehensive validation coverage is being built to ensure
* the generated application functions correctly under realistic operational
* conditions and properly implements business requirements.
*
* @author Michael
*/
export interface AutoBeTestWriteEvent<
Function extends AutoBeTestFunction = AutoBeTestFunction,
> extends AutoBeEventBase<"testWrite">,
AutoBeProgressEventBase,
AutoBeAggregateEventBase {
/**
* Function type indicating the specific test writing operation performed.
*
* This discriminated union represents different stages and types of test code
* generation that occur during the test writing process:
*
* - `AutoBeTestPrepareFunction`: Generates test data preparation functions that
* create mock DTO objects required by API endpoints
* - `AutoBeTestGenerationFunction`: Creates resource generation functions that
* produce test data and utilities needed by test scenarios
* - `AutoBeTestAuthorizationFunction`: Implements authentication and
* authorization functions for different actors (login, signup, token
* refresh)
* - `AutoBeTestOperationFunction`: Writes the actual E2E test scenario files
* with complete test implementations
*
* Each function type serves a specific purpose in building comprehensive test
* suites, from data preparation through authentication to actual scenario
* validation. The discriminated union pattern enables type-safe handling of
* different test writing stages while providing detailed progress tracking.
*/
function: Function;
/**
* Iteration number of the requirements analysis this test writing reflects.
*
* Indicates which version of the requirements analysis this test file
* creation work is based on. This step number ensures that the test scenarios
* are aligned with the current requirements and helps track the development
* of validation coverage as business requirements and API specifications
* evolve.
*
* The step value enables proper synchronization between test writing
* activities and the underlying requirements, ensuring that the test suite
* remains relevant to the current project scope and validation objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeTestValidateEvent.ts
//----------------------------------------
import { IAutoBeTypeScriptCompileResult } from "../compiler";
import { AutoBeTestFunction } from "../histories";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Test agent validates the generated test code using the
* embedded TypeScript compiler.
*
* This event occurs when the Test agent submits a generated test file to the
* TypeScript compiler for validation, ensuring that the test code compiles
* correctly and integrates properly with the API specifications and database
* schemas. The validation process serves as a quality gate that ensures test
* scenarios are syntactically correct and semantically valid.
*
* The validation results determine whether the test generation process can
* proceed to completion or whether correction feedback is needed to resolve
* compilation issues and improve test code quality through the iterative
* self-correction mechanism.
*
* @author Michael
*/
export interface AutoBeTestValidateEvent<
Function extends AutoBeTestFunction = AutoBeTestFunction,
> extends AutoBeEventBase<"testValidate"> {
/**
* Function type indicating the specific test writing operation performed.
*
* This discriminated union represents different stages and types of test code
* generation that occur during the test writing process:
*
* - `AutoBeTestPrepareFunction`: Generates test data preparation functions that
* create mock DTO objects required by API endpoints
* - `AutoBeTestGenerationFunction`: Creates resource generation functions that
* produce test data and utilities needed by test scenarios
* - `AutoBeTestAuthorizationFunction`: Implements authentication and
* authorization functions for different actors (login, signup, token
* refresh)
* - `AutoBeTestWriteFunction`: Writes the actual E2E test scenario files with
* complete test implementations
*
* Each function type serves a specific purpose in building comprehensive test
* suites, from data preparation through authentication to actual scenario
* validation. The discriminated union pattern enables type-safe handling of
* different test writing stages while providing detailed progress tracking.
*/
function: Function;
/**
* Compilation result indicating success, failure, or exception during
* validation.
*
* Contains the complete {@link IAutoBeTypeScriptCompileResult} from the
* validation process, which can be:
*
* - {@link IAutoBeTypeScriptCompileResult.ISuccess} for successful compilation
* - {@link IAutoBeTypeScriptCompileResult.IFailure} for compilation errors
* - {@link IAutoBeTypeScriptCompileResult.IException} for unexpected runtime
* errors
*
* Success results indicate that the test suite is ready for completion, while
* failure or exception results trigger the correction feedback loop to
* improve test code quality and resolve integration issues with the
* application architecture.
*/
result: IAutoBeTypeScriptCompileResult;
/**
* Iteration number of the requirements analysis this test validation was
* performed for.
*
* Indicates which version of the requirements analysis this test validation
* reflects. This step number ensures that the validation process is aligned
* with the current requirements and helps track the quality assurance process
* as test scenarios are validated and refined.
*
* The step value enables proper synchronization between validation activities
* and the underlying requirements, ensuring that test validation efforts
* remain relevant to the current project scope and validation objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeTestCorrectEvent.ts
//----------------------------------------
import { IAutoBeTypeScriptCompileResult } from "../compiler";
import { AutoBeTestFunction } from "../histories";
import { AutoBeAggregateEventBase } from "./base/AutoBeAggregateEventBase";
import { AutoBeEventBase } from "./base/AutoBeEventBase";
/**
* Event fired when the Test agent corrects compilation failures in the
* generated test code through the AI self-correction feedback process.
*
* This event occurs when the embedded TypeScript compiler detects compilation
* errors in the test code and the Test agent receives detailed error feedback
* to correct the issues. The correction process demonstrates the sophisticated
* feedback loop that enables AI to learn from compilation errors and improve
* test code quality iteratively.
*
* The correction mechanism ensures that test code not only compiles
* successfully but also properly validates API functionality while maintaining
* consistency with the established API contracts and business requirements.
*
* @author Samchon
*/
export interface AutoBeTestCorrectEvent
extends AutoBeEventBase<"testCorrect">,
AutoBeAggregateEventBase {
kind: "casting" | "overall" | "request";
/**
* The test function that contained compilation errors.
*
* Contains the specific test function object that failed compilation,
* including its metadata, location, and source code. This can be any type of
* test function: prepare, generation, authorization, or main test write
* function. The function type determines which specialized correction
* strategy will be applied.
*/
function: AutoBeTestFunction;
/**
* The compilation failure details that triggered the correction process.
*
* Contains the specific {@link IAutoBeTypeScriptCompileResult.IFailure}
* information describing the compilation errors that were detected in the
* test code. This includes error messages, file locations, type issues, or
* other compilation problems that prevented successful test code validation.
*
* The failure information provides the diagnostic foundation for the AI's
* understanding of what went wrong and guides the correction strategy.
*/
result: IAutoBeTypeScriptCompileResult.IFailure;
/**
* Iteration number of the requirements analysis this test correction was
* performed for.
*
* Indicates which version of the requirements analysis this test correction
* reflects. This step number ensures that the correction efforts are aligned
* with the current requirements and helps track the quality improvement
* process as compilation issues are resolved through iterative feedback.
*
* The step value enables proper synchronization between test correction
* activities and the underlying requirements, ensuring that test improvements
* remain relevant to the current project scope and validation objectives.
*/
step: number;
}
//----------------------------------------
// File: AutoBeTestCompleteEvent.ts
//----------------------------------------
import { IAutoBeTypeScriptCompileResult } from "../compiler/IAutoBeTypeScriptCompileResult";
import { AutoBeTestFunction } from "../histories";
import { AutoBeCompleteEventBase } from "./base/AutoBeCompleteEventBase";
/**
* Event fired when the Test agent completes the e2e test code generation
* process for all API endpoints and scenarios.
*
* This event represents the successful completion of comprehensive test suite
* creation that validates both technical functionality and business rule
* implementation across all API operations. The Test agent's completion ensures
* that every API endpoint has multiple use case scenarios implemented as test
* programs that provide thorough coverage of the application functionality.
*
* The completion of test generation creates a robust validation framework that
* ensures the generated APIs work correctly under realistic operational
* conditions and properly implement all business requirements established in
* the analysis phase.
*
* @author Samchon
*/
export interface AutoBeTestCompleteEvent
extends AutoBeCompleteEventBase<"testComplete"> {
/**
* Generated e2e test files as key-value pairs representing the complete test
* suite.
*
* Contains the final set of TypeScript test files with each key representing
* the file path and each value containing the actual test code. Each test
* file includes standalone functions that implement specific use case
* scenarios for API endpoints, providing comprehensive end-to-end testing
* coverage that validates both technical functionality and business logic
* implementation.
*
* The test files are designed to work under realistic operational conditions,
* ensuring that the generated APIs not only compile and execute correctly but
* also properly implement the business requirements and handle edge cases
* appropriately. These tests serve as both validation tools and documentation
* of expected system behavior.
*/
functions: AutoBeTestFunction[];
/**
* Results of compiling the generated e2e test TypeScript files through the
* TypeScript compiler.
*
* Contains the {@link IAutoBeTypeScriptCompileResult} from processing the
* generated test files through the TypeScript compilation pipeline. This
* compilation result validates test code syntax, type safety, framework
* integration, and dependency resolution to ensure that all generated test
* scenarios are syntactically correct and ready for execution.
*
* Through the Test agent's internal compiler feedback process, this result is
* typically successful as the agent iteratively refines the generated code
* based on compilation diagnostics. However, in rare cases where the compiler
* feedback iteration limit is exceeded, the result may indicate failure
* despite the agent's correction attempts. Such failure occurrences are
* extremely infrequent due to the sophisticated feedback mechanisms built
* into the Test agent's code generation process.
*
* Successful compilation indicates that the generated test suite is
* production-ready and can be executed immediately to validate the
* corresponding API implementations without any syntax or integration
* issues.
*/
compiled: IAutoBeTypeScriptCompileResult;
}Test events monitor the e2e test code generation process.
When @autobe writes e2e test code, it first fires the AutoBeTestStartEvent event to signal the start of the test agent. Then it triggers the AutoBeTestScenarioEvent event to create test scenarios. Subsequently, it writes each scenario in TypeScript code and fires AutoBeTestWriteEvent events to report the progress of test code writing.
Next, the AutoBeTestValidateEvent event is triggered to validate the written test code using the TypeScript compiler. If compilation fails, the AutoBeTestCorrectEvent event is fired to provide feedback to the AI for fixing compilation errors. The AutoBeTestValidateEvent event is then triggered again, repeating this cycle.
Once all test code writing is complete, the AutoBeTestCompleteEvent event is fired.
AutoBeTestCompleteEvent is generated when e2e test code is written based on the previous requirements analysis, database design, and RESTful API specification.
@autobe conceives multiple use case scenarios for each API endpoint and implements them as test programs. These test programs are composed of one TypeScript file and a standalone function for each scenario, stored in the files property. These are then built using the TypeScript compiler embedded in @autobe, with the results stored in the compiled property.
When the AI occasionally writes incorrect TypeScript code, @autobe provides compilation error messages as feedback, allowing the AI to self-correct. This feedback process usually works correctly, so test code written by AI almost always compiles successfully. However, when using very small AI models, the IAutoBeTypeScriptCompileResult result might have success := false.
The step property indicates which requirements analysis report iteration the test code was written for. If the AutoBeTestCompleteEvent.step value is lower than AutoBeAnalyzeCompleteEvent.step, it means the test code has not yet been updated to reflect the latest requirements.
Realize Events
Not implemented yet.