@autobe/agent 0.11.1 → 0.12.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.
- package/lib/AutoBeAgent.d.ts +3 -146
- package/lib/AutoBeAgent.js +6 -180
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/AutoBeAgentBase.d.ts +18 -0
- package/lib/AutoBeAgentBase.js +54 -0
- package/lib/AutoBeAgentBase.js.map +1 -0
- package/lib/AutoBeMockAgent.d.ts +14 -0
- package/lib/AutoBeMockAgent.js +135 -0
- package/lib/AutoBeMockAgent.js.map +1 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +8 -4
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/factory/getAutoBeGenerated.d.ts +3 -4
- package/lib/factory/getAutoBeGenerated.js +6 -250
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +906 -413
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +6 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.d.ts +4 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js +6 -2
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +11 -2
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +46 -15
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeDecorator.d.ts +10 -0
- package/lib/orchestrate/realize/orchestrateRealizeDecorator.js +545 -0
- package/lib/orchestrate/realize/orchestrateRealizeDecorator.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +12 -9
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.d.ts +85 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.js +3 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +1 -1
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +24 -30
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeDecorator.d.ts +4 -0
- package/lib/orchestrate/realize/transformRealizeDecorator.js +32 -0
- package/lib/orchestrate/realize/transformRealizeDecorator.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.d.ts +6 -0
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js +49 -0
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js.map +1 -0
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +30 -11
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +24 -15
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/utils/backoffRetry.d.ts +18 -0
- package/lib/utils/backoffRetry.js +38 -0
- package/lib/utils/backoffRetry.js.map +1 -1
- package/package.json +8 -8
- package/src/AutoBeAgent.ts +10 -203
- package/src/AutoBeAgentBase.ts +78 -0
- package/src/AutoBeMockAgent.ts +163 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +8 -4
- package/src/factory/getAutoBeGenerated.ts +8 -13
- package/src/index.ts +3 -1
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +7 -1
- package/src/orchestrate/analyze/writeDocumentUntilReviewPassed.ts +8 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +11 -0
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +26 -4
- package/src/orchestrate/realize/orchestrateRealizeDecorator.ts +286 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +12 -9
- package/src/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.ts +94 -0
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +22 -29
- package/src/orchestrate/realize/transformRealizeDecorator.ts +37 -0
- package/src/orchestrate/realize/transformRealizeDecoratorCorrectHistories.ts +58 -0
- package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +34 -9
- package/src/orchestrate/test/orchestrateTest.ts +1 -0
- package/src/orchestrate/test/orchestrateTestCorrect.ts +26 -20
- package/src/orchestrate/test/orchestrateTestWrite.ts +1 -1
- package/src/utils/backoffRetry.ts +56 -0
package/lib/AutoBeAgent.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AutoBeHistory, AutoBeUserMessageContent, IAutoBeAgent } from "@autobe/interface";
|
|
2
2
|
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
import { AutoBeAgentBase } from "./AutoBeAgentBase";
|
|
3
4
|
import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
|
|
4
5
|
import { IAutoBeProps } from "./structures/IAutoBeProps";
|
|
5
6
|
/**
|
|
@@ -26,7 +27,7 @@ import { IAutoBeProps } from "./structures/IAutoBeProps";
|
|
|
26
27
|
*
|
|
27
28
|
* @author Samchon
|
|
28
29
|
*/
|
|
29
|
-
export declare class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
30
|
+
export declare class AutoBeAgent<Model extends ILlmSchema.Model> extends AutoBeAgentBase implements IAutoBeAgent {
|
|
30
31
|
/**
|
|
31
32
|
* Initializes a new AutoBeAgent instance with the specified configuration.
|
|
32
33
|
*
|
|
@@ -45,151 +46,7 @@ export declare class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
|
45
46
|
* histories for session continuation
|
|
46
47
|
*/
|
|
47
48
|
constructor(props: IAutoBeProps<Model>);
|
|
48
|
-
/**
|
|
49
|
-
* Engages in conversation with the agent to drive the vibe coding process.
|
|
50
|
-
*
|
|
51
|
-
* Accepts user input in multiple formats including simple text strings,
|
|
52
|
-
* single multimodal content items, or arrays of content supporting text,
|
|
53
|
-
* images, file uploads, and audio input. The conversation serves as the
|
|
54
|
-
* primary interface for expressing requirements, providing feedback, and
|
|
55
|
-
* guiding the development process through natural language interaction.
|
|
56
|
-
*
|
|
57
|
-
* The agent analyzes the conversation context to determine appropriate
|
|
58
|
-
* actions, potentially activating specialized agents (Analyze, Prisma,
|
|
59
|
-
* Interface, Test, Realize) through function calling based on user needs.
|
|
60
|
-
* Real-time progress events are fired through registered listeners while the
|
|
61
|
-
* conversation processes.
|
|
62
|
-
*
|
|
63
|
-
* Returns all history records generated during this conversation turn,
|
|
64
|
-
* including user messages, assistant responses, and any development
|
|
65
|
-
* activities triggered by the interaction. This enables clients to track both
|
|
66
|
-
* conversational flow and development progress.
|
|
67
|
-
*
|
|
68
|
-
* @param content User input as text, single content item, or multimodal array
|
|
69
|
-
* @returns Promise resolving to array of history records from this
|
|
70
|
-
* conversation
|
|
71
|
-
*/
|
|
72
49
|
conversate(content: string | AutoBeUserMessageContent | AutoBeUserMessageContent[]): Promise<AutoBeHistory[]>;
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves all generated files from the current development session.
|
|
75
|
-
*
|
|
76
|
-
* Transforms the complete conversation-driven development process into a
|
|
77
|
-
* comprehensive collection of deployable artifacts, including requirements
|
|
78
|
-
* documentation, database schemas, API specifications, NestJS implementation
|
|
79
|
-
* code, and test suites. The generated files represent a fully functional
|
|
80
|
-
* backend application ready for immediate deployment or further
|
|
81
|
-
* customization.
|
|
82
|
-
*
|
|
83
|
-
* The method produces a meticulously organized project structure that
|
|
84
|
-
* reflects professional software development standards. Requirements analysis
|
|
85
|
-
* documents capture and formalize your conversational input into structured
|
|
86
|
-
* technical specifications, providing clear traceability from user intent to
|
|
87
|
-
* final implementation. Database artifacts include Prisma schemas with
|
|
88
|
-
* precise type definitions, relationships, and constraints, along with
|
|
89
|
-
* migration files for proper database initialization and evolution.
|
|
90
|
-
*
|
|
91
|
-
* The API layer emerges through comprehensive OpenAPI specifications
|
|
92
|
-
* documenting every endpoint, request format, response structure, and error
|
|
93
|
-
* condition. Generated NestJS controllers, DTOs, and service classes
|
|
94
|
-
* implement these specifications with TypeScript's strong typing system
|
|
95
|
-
* providing compile-time safety. Quality assurance is embedded throughout
|
|
96
|
-
* with complete test suites covering both unit and end-to-end scenarios.
|
|
97
|
-
*
|
|
98
|
-
* The database configuration specified through the `dbms` option
|
|
99
|
-
* fundamentally shapes the entire generated codebase. PostgreSQL
|
|
100
|
-
* configuration produces production-ready code with robust connection pooling
|
|
101
|
-
* and enterprise-grade optimizations, while SQLite generates lightweight code
|
|
102
|
-
* perfect for local development and rapid prototyping without external
|
|
103
|
-
* dependencies.
|
|
104
|
-
*
|
|
105
|
-
* All artifacts maintain perfect consistency across the chosen database
|
|
106
|
-
* system, from Prisma configurations and connection strings to Docker compose
|
|
107
|
-
* files and environment templates. This deep integration ensures immediate
|
|
108
|
-
* deployment compatibility without manual configuration adjustments.
|
|
109
|
-
*
|
|
110
|
-
* @param options Configuration specifying the target database management
|
|
111
|
-
* system and other code generation preferences that influence the structure
|
|
112
|
-
* and characteristics of the generated project files
|
|
113
|
-
* @returns Promise resolving to key-value pairs mapping logical file paths to
|
|
114
|
-
* complete file contents for all generated development artifacts, ready for
|
|
115
|
-
* immediate file system operations, build integration, or deployment
|
|
116
|
-
* workflows
|
|
117
|
-
*/
|
|
118
|
-
getFiles(options?: Partial<IAutoBeGetFilesOptions>): Promise<Record<string, string>>;
|
|
119
|
-
/**
|
|
120
|
-
* Retrieves the complete conversation and development history.
|
|
121
|
-
*
|
|
122
|
-
* Returns the chronologically ordered record of all events from the current
|
|
123
|
-
* session including user messages, assistant responses, development phase
|
|
124
|
-
* activities, progress events, and completion notifications. This
|
|
125
|
-
* comprehensive history enables conversation replay, development process
|
|
126
|
-
* analysis, and understanding of how requirements evolved into working
|
|
127
|
-
* software.
|
|
128
|
-
*
|
|
129
|
-
* The history provides complete transparency into the vibe coding process,
|
|
130
|
-
* showing both conversational interactions and behind-the-scenes development
|
|
131
|
-
* activities. This information is valuable for debugging, process
|
|
132
|
-
* improvement, and educational purposes to understand the agent's
|
|
133
|
-
* decision-making process.
|
|
134
|
-
*
|
|
135
|
-
* @returns Chronologically ordered array of all history records including
|
|
136
|
-
* messages, events, and development activities
|
|
137
|
-
*/
|
|
138
50
|
getHistories(): AutoBeHistory[];
|
|
139
|
-
/**
|
|
140
|
-
* Retrieves comprehensive AI token usage statistics for the current session.
|
|
141
|
-
*
|
|
142
|
-
* Returns detailed breakdown of token consumption across all specialized
|
|
143
|
-
* agents and processing phases, enabling cost monitoring, performance
|
|
144
|
-
* analysis, and optimization of AI resource utilization. Statistics include
|
|
145
|
-
* aggregate totals and component-specific breakdowns with input/output
|
|
146
|
-
* categorization, caching analysis, and reasoning token tracking.
|
|
147
|
-
*
|
|
148
|
-
* Token usage data is essential for understanding the computational costs of
|
|
149
|
-
* different development phases and optimizing AI efficiency. The breakdown
|
|
150
|
-
* helps identify which agents or operations consume the most resources,
|
|
151
|
-
* enabling targeted optimization efforts while maintaining development
|
|
152
|
-
* quality.
|
|
153
|
-
*
|
|
154
|
-
* @returns Comprehensive token usage statistics with detailed breakdowns by
|
|
155
|
-
* agent, operation type, and consumption category
|
|
156
|
-
*/
|
|
157
51
|
getTokenUsage(): AutoBeTokenUsage;
|
|
158
|
-
/**
|
|
159
|
-
* Registers an event listener for specific development phase events.
|
|
160
|
-
*
|
|
161
|
-
* Enables client applications to receive real-time notifications about
|
|
162
|
-
* conversation flow, development progress, and completion events throughout
|
|
163
|
-
* the vibe coding pipeline. Event listeners provide visibility into agent
|
|
164
|
-
* activities and enable responsive user interfaces that can display progress,
|
|
165
|
-
* handle artifacts, and provide feedback.
|
|
166
|
-
*
|
|
167
|
-
* The type-safe event system ensures that listeners receive properly typed
|
|
168
|
-
* events corresponding to their registration type, enabling robust event
|
|
169
|
-
* handling without runtime type issues. Multiple listeners can be registered
|
|
170
|
-
* for the same event type to support complex notification requirements.
|
|
171
|
-
*
|
|
172
|
-
* @param type Event type to listen for (e.g., "analyzeComplete",
|
|
173
|
-
* "prismaStart")
|
|
174
|
-
* @param listener Callback function that receives the typed event when fired
|
|
175
|
-
* @returns The agent instance for method chaining
|
|
176
|
-
*/
|
|
177
|
-
on<Type extends AutoBeEvent.Type>(type: Type, listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void): this;
|
|
178
|
-
/**
|
|
179
|
-
* Unregisters a previously registered event listener.
|
|
180
|
-
*
|
|
181
|
-
* Removes the specified event listener from the agent's notification system,
|
|
182
|
-
* stopping further event notifications for that particular listener function.
|
|
183
|
-
* This is useful for cleanup, dynamic listener management, or when components
|
|
184
|
-
* no longer need to receive specific event notifications.
|
|
185
|
-
*
|
|
186
|
-
* The listener function reference must exactly match the function that was
|
|
187
|
-
* originally registered with {@link on} for successful removal. If no matching
|
|
188
|
-
* listener is found, the operation has no effect.
|
|
189
|
-
*
|
|
190
|
-
* @param type Event type the listener was registered for
|
|
191
|
-
* @param listener The exact listener function reference to remove
|
|
192
|
-
* @returns The agent instance for method chaining
|
|
193
|
-
*/
|
|
194
|
-
off<Type extends AutoBeEvent.Type>(type: Type, listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void): this;
|
|
195
52
|
}
|
package/lib/AutoBeAgent.js
CHANGED
|
@@ -13,14 +13,13 @@ exports.AutoBeAgent = void 0;
|
|
|
13
13
|
const core_1 = require("@agentica/core");
|
|
14
14
|
const tstl_1 = require("tstl");
|
|
15
15
|
const uuid_1 = require("uuid");
|
|
16
|
+
const AutoBeAgentBase_1 = require("./AutoBeAgentBase");
|
|
16
17
|
const AutoBeTokenUsage_1 = require("./context/AutoBeTokenUsage");
|
|
17
18
|
const createAgenticaHistory_1 = require("./factory/createAgenticaHistory");
|
|
18
19
|
const createAutoBeApplication_1 = require("./factory/createAutoBeApplication");
|
|
19
20
|
const createAutoBeState_1 = require("./factory/createAutoBeState");
|
|
20
|
-
const getAutoBeGenerated_1 = require("./factory/getAutoBeGenerated");
|
|
21
21
|
const transformFacadeStateMessage_1 = require("./orchestrate/facade/transformFacadeStateMessage");
|
|
22
22
|
const backoffRetry_1 = require("./utils/backoffRetry");
|
|
23
|
-
const emplaceMap_1 = require("./utils/emplaceMap");
|
|
24
23
|
/**
|
|
25
24
|
* Main agent class that orchestrates the entire vibe coding pipeline through
|
|
26
25
|
* conversation-driven development.
|
|
@@ -45,7 +44,7 @@ const emplaceMap_1 = require("./utils/emplaceMap");
|
|
|
45
44
|
*
|
|
46
45
|
* @author Samchon
|
|
47
46
|
*/
|
|
48
|
-
class AutoBeAgent {
|
|
47
|
+
class AutoBeAgent extends AutoBeAgentBase_1.AutoBeAgentBase {
|
|
49
48
|
/* -----------------------------------------------------------
|
|
50
49
|
CONSTRUCTOR
|
|
51
50
|
----------------------------------------------------------- */
|
|
@@ -69,10 +68,13 @@ class AutoBeAgent {
|
|
|
69
68
|
constructor(props) {
|
|
70
69
|
var _a, _b, _c, _d, _e;
|
|
71
70
|
// INITIALIZE MEMBERS
|
|
71
|
+
super({
|
|
72
|
+
compiler: () => this.context_.compiler(),
|
|
73
|
+
state: () => this.state_,
|
|
74
|
+
});
|
|
72
75
|
this.props_ = props;
|
|
73
76
|
this.histories_ = (_b = (_a = props.histories) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
74
77
|
this.state_ = (0, createAutoBeState_1.createAutoBeState)(this.histories_);
|
|
75
|
-
this.listeners_ = new Map();
|
|
76
78
|
this.usage_ =
|
|
77
79
|
props.tokenUsage instanceof AutoBeTokenUsage_1.AutoBeTokenUsage
|
|
78
80
|
? props.tokenUsage
|
|
@@ -152,30 +154,6 @@ class AutoBeAgent {
|
|
|
152
154
|
/* -----------------------------------------------------------
|
|
153
155
|
ACCESSORS
|
|
154
156
|
----------------------------------------------------------- */
|
|
155
|
-
/**
|
|
156
|
-
* Engages in conversation with the agent to drive the vibe coding process.
|
|
157
|
-
*
|
|
158
|
-
* Accepts user input in multiple formats including simple text strings,
|
|
159
|
-
* single multimodal content items, or arrays of content supporting text,
|
|
160
|
-
* images, file uploads, and audio input. The conversation serves as the
|
|
161
|
-
* primary interface for expressing requirements, providing feedback, and
|
|
162
|
-
* guiding the development process through natural language interaction.
|
|
163
|
-
*
|
|
164
|
-
* The agent analyzes the conversation context to determine appropriate
|
|
165
|
-
* actions, potentially activating specialized agents (Analyze, Prisma,
|
|
166
|
-
* Interface, Test, Realize) through function calling based on user needs.
|
|
167
|
-
* Real-time progress events are fired through registered listeners while the
|
|
168
|
-
* conversation processes.
|
|
169
|
-
*
|
|
170
|
-
* Returns all history records generated during this conversation turn,
|
|
171
|
-
* including user messages, assistant responses, and any development
|
|
172
|
-
* activities triggered by the interaction. This enables clients to track both
|
|
173
|
-
* conversational flow and development progress.
|
|
174
|
-
*
|
|
175
|
-
* @param content User input as text, single content item, or multimodal array
|
|
176
|
-
* @returns Promise resolving to array of history records from this
|
|
177
|
-
* conversation
|
|
178
|
-
*/
|
|
179
157
|
conversate(content) {
|
|
180
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
159
|
const index = this.histories_.length;
|
|
@@ -200,96 +178,9 @@ class AutoBeAgent {
|
|
|
200
178
|
return this.histories_.slice(index);
|
|
201
179
|
});
|
|
202
180
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Retrieves all generated files from the current development session.
|
|
205
|
-
*
|
|
206
|
-
* Transforms the complete conversation-driven development process into a
|
|
207
|
-
* comprehensive collection of deployable artifacts, including requirements
|
|
208
|
-
* documentation, database schemas, API specifications, NestJS implementation
|
|
209
|
-
* code, and test suites. The generated files represent a fully functional
|
|
210
|
-
* backend application ready for immediate deployment or further
|
|
211
|
-
* customization.
|
|
212
|
-
*
|
|
213
|
-
* The method produces a meticulously organized project structure that
|
|
214
|
-
* reflects professional software development standards. Requirements analysis
|
|
215
|
-
* documents capture and formalize your conversational input into structured
|
|
216
|
-
* technical specifications, providing clear traceability from user intent to
|
|
217
|
-
* final implementation. Database artifacts include Prisma schemas with
|
|
218
|
-
* precise type definitions, relationships, and constraints, along with
|
|
219
|
-
* migration files for proper database initialization and evolution.
|
|
220
|
-
*
|
|
221
|
-
* The API layer emerges through comprehensive OpenAPI specifications
|
|
222
|
-
* documenting every endpoint, request format, response structure, and error
|
|
223
|
-
* condition. Generated NestJS controllers, DTOs, and service classes
|
|
224
|
-
* implement these specifications with TypeScript's strong typing system
|
|
225
|
-
* providing compile-time safety. Quality assurance is embedded throughout
|
|
226
|
-
* with complete test suites covering both unit and end-to-end scenarios.
|
|
227
|
-
*
|
|
228
|
-
* The database configuration specified through the `dbms` option
|
|
229
|
-
* fundamentally shapes the entire generated codebase. PostgreSQL
|
|
230
|
-
* configuration produces production-ready code with robust connection pooling
|
|
231
|
-
* and enterprise-grade optimizations, while SQLite generates lightweight code
|
|
232
|
-
* perfect for local development and rapid prototyping without external
|
|
233
|
-
* dependencies.
|
|
234
|
-
*
|
|
235
|
-
* All artifacts maintain perfect consistency across the chosen database
|
|
236
|
-
* system, from Prisma configurations and connection strings to Docker compose
|
|
237
|
-
* files and environment templates. This deep integration ensures immediate
|
|
238
|
-
* deployment compatibility without manual configuration adjustments.
|
|
239
|
-
*
|
|
240
|
-
* @param options Configuration specifying the target database management
|
|
241
|
-
* system and other code generation preferences that influence the structure
|
|
242
|
-
* and characteristics of the generated project files
|
|
243
|
-
* @returns Promise resolving to key-value pairs mapping logical file paths to
|
|
244
|
-
* complete file contents for all generated development artifacts, ready for
|
|
245
|
-
* immediate file system operations, build integration, or deployment
|
|
246
|
-
* workflows
|
|
247
|
-
*/
|
|
248
|
-
getFiles(options) {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
return (0, getAutoBeGenerated_1.getAutoBeGenerated)(yield this.getContext(), this.histories_, this.usage_, options);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Retrieves the complete conversation and development history.
|
|
255
|
-
*
|
|
256
|
-
* Returns the chronologically ordered record of all events from the current
|
|
257
|
-
* session including user messages, assistant responses, development phase
|
|
258
|
-
* activities, progress events, and completion notifications. This
|
|
259
|
-
* comprehensive history enables conversation replay, development process
|
|
260
|
-
* analysis, and understanding of how requirements evolved into working
|
|
261
|
-
* software.
|
|
262
|
-
*
|
|
263
|
-
* The history provides complete transparency into the vibe coding process,
|
|
264
|
-
* showing both conversational interactions and behind-the-scenes development
|
|
265
|
-
* activities. This information is valuable for debugging, process
|
|
266
|
-
* improvement, and educational purposes to understand the agent's
|
|
267
|
-
* decision-making process.
|
|
268
|
-
*
|
|
269
|
-
* @returns Chronologically ordered array of all history records including
|
|
270
|
-
* messages, events, and development activities
|
|
271
|
-
*/
|
|
272
181
|
getHistories() {
|
|
273
182
|
return this.histories_;
|
|
274
183
|
}
|
|
275
|
-
/**
|
|
276
|
-
* Retrieves comprehensive AI token usage statistics for the current session.
|
|
277
|
-
*
|
|
278
|
-
* Returns detailed breakdown of token consumption across all specialized
|
|
279
|
-
* agents and processing phases, enabling cost monitoring, performance
|
|
280
|
-
* analysis, and optimization of AI resource utilization. Statistics include
|
|
281
|
-
* aggregate totals and component-specific breakdowns with input/output
|
|
282
|
-
* categorization, caching analysis, and reasoning token tracking.
|
|
283
|
-
*
|
|
284
|
-
* Token usage data is essential for understanding the computational costs of
|
|
285
|
-
* different development phases and optimizing AI efficiency. The breakdown
|
|
286
|
-
* helps identify which agents or operations consume the most resources,
|
|
287
|
-
* enabling targeted optimization efforts while maintaining development
|
|
288
|
-
* quality.
|
|
289
|
-
*
|
|
290
|
-
* @returns Comprehensive token usage statistics with detailed breakdowns by
|
|
291
|
-
* agent, operation type, and consumption category
|
|
292
|
-
*/
|
|
293
184
|
getTokenUsage() {
|
|
294
185
|
return this.usage_;
|
|
295
186
|
}
|
|
@@ -297,71 +188,6 @@ class AutoBeAgent {
|
|
|
297
188
|
getContext() {
|
|
298
189
|
return this.context_;
|
|
299
190
|
}
|
|
300
|
-
/* -----------------------------------------------------------
|
|
301
|
-
EVENT HANDLERS
|
|
302
|
-
----------------------------------------------------------- */
|
|
303
|
-
/**
|
|
304
|
-
* Registers an event listener for specific development phase events.
|
|
305
|
-
*
|
|
306
|
-
* Enables client applications to receive real-time notifications about
|
|
307
|
-
* conversation flow, development progress, and completion events throughout
|
|
308
|
-
* the vibe coding pipeline. Event listeners provide visibility into agent
|
|
309
|
-
* activities and enable responsive user interfaces that can display progress,
|
|
310
|
-
* handle artifacts, and provide feedback.
|
|
311
|
-
*
|
|
312
|
-
* The type-safe event system ensures that listeners receive properly typed
|
|
313
|
-
* events corresponding to their registration type, enabling robust event
|
|
314
|
-
* handling without runtime type issues. Multiple listeners can be registered
|
|
315
|
-
* for the same event type to support complex notification requirements.
|
|
316
|
-
*
|
|
317
|
-
* @param type Event type to listen for (e.g., "analyzeComplete",
|
|
318
|
-
* "prismaStart")
|
|
319
|
-
* @param listener Callback function that receives the typed event when fired
|
|
320
|
-
* @returns The agent instance for method chaining
|
|
321
|
-
*/
|
|
322
|
-
on(type, listener) {
|
|
323
|
-
(0, emplaceMap_1.emplaceMap)(this.listeners_, type, () => new Set()).add(listener);
|
|
324
|
-
return this;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Unregisters a previously registered event listener.
|
|
328
|
-
*
|
|
329
|
-
* Removes the specified event listener from the agent's notification system,
|
|
330
|
-
* stopping further event notifications for that particular listener function.
|
|
331
|
-
* This is useful for cleanup, dynamic listener management, or when components
|
|
332
|
-
* no longer need to receive specific event notifications.
|
|
333
|
-
*
|
|
334
|
-
* The listener function reference must exactly match the function that was
|
|
335
|
-
* originally registered with {@link on} for successful removal. If no matching
|
|
336
|
-
* listener is found, the operation has no effect.
|
|
337
|
-
*
|
|
338
|
-
* @param type Event type the listener was registered for
|
|
339
|
-
* @param listener The exact listener function reference to remove
|
|
340
|
-
* @returns The agent instance for method chaining
|
|
341
|
-
*/
|
|
342
|
-
off(type, listener) {
|
|
343
|
-
const set = this.listeners_.get(type);
|
|
344
|
-
if (set === undefined)
|
|
345
|
-
return this;
|
|
346
|
-
set.delete(listener);
|
|
347
|
-
if (set.size === 0)
|
|
348
|
-
this.listeners_.delete(type);
|
|
349
|
-
return this;
|
|
350
|
-
}
|
|
351
|
-
/** @internal */
|
|
352
|
-
dispatch(event) {
|
|
353
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
354
|
-
const set = this.listeners_.get(event.type);
|
|
355
|
-
if (set === undefined)
|
|
356
|
-
return;
|
|
357
|
-
yield Promise.all(Array.from(set).map((listener) => __awaiter(this, void 0, void 0, function* () {
|
|
358
|
-
try {
|
|
359
|
-
yield listener(event);
|
|
360
|
-
}
|
|
361
|
-
catch (_a) { }
|
|
362
|
-
})));
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
191
|
}
|
|
366
192
|
exports.AutoBeAgent = AutoBeAgent;
|
|
367
193
|
//# sourceMappingURL=AutoBeAgent.js.map
|
package/lib/AutoBeAgent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeAgent.js","sourceRoot":"","sources":["../src/AutoBeAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAgE;
|
|
1
|
+
{"version":3,"file":"AutoBeAgent.js","sourceRoot":"","sources":["../src/AutoBeAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAgE;AAUhE,+BAA4C;AAC5C,+BAA0B;AAE1B,uDAAoD;AAGpD,iEAA8D;AAC9D,2EAAwE;AACxE,+EAA2E;AAC3E,mEAAgE;AAChE,kGAA+F;AAE/F,uDAA6D;AAE7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,WACX,SAAQ,iCAAe;IAqBvB;;kEAE8D;IAC9D;;;;;;;;;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I,CAAC,UAAU,CAAC,MAAM,CAAC;YAC7C,MAAM,kBAAkB,GAA6B;gBACnD,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,IAAI,EAAE,aAAa;gBACnB,QAAQ,EACN,OAAO,OAAO,KAAK,QAAQ;oBACzB,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,OAAO;yBACd;qBACF;oBACH,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;wBACtB,CAAC,CAAC,OAAO;wBACT,CAAC,CAAC,CAAC,OAAO,CAAC;gBACjB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACrC,CAAC;YACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAElD,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;KAAA;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,gBAAgB;IACT,UAAU;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAhMD,kCAgMC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AutoBeEvent, AutoBeHistory, IAutoBeCompiler, IAutoBeGetFilesOptions } from "@autobe/interface";
|
|
2
|
+
import { AutoBeState } from "./context/AutoBeState";
|
|
3
|
+
import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
|
|
4
|
+
export declare abstract class AutoBeAgentBase {
|
|
5
|
+
private readonly asset;
|
|
6
|
+
constructor(asset: AutoBeAgentBase.IAsset);
|
|
7
|
+
getFiles(options?: Partial<IAutoBeGetFilesOptions>): Promise<Record<string, string>>;
|
|
8
|
+
abstract getHistories(): AutoBeHistory[];
|
|
9
|
+
abstract getTokenUsage(): AutoBeTokenUsage;
|
|
10
|
+
on<Type extends AutoBeEvent.Type>(type: Type, listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void): this;
|
|
11
|
+
off<Type extends AutoBeEvent.Type>(type: Type, listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void): this;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace AutoBeAgentBase {
|
|
14
|
+
interface IAsset {
|
|
15
|
+
compiler: () => Promise<IAutoBeCompiler>;
|
|
16
|
+
state: () => AutoBeState;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AutoBeAgentBase = void 0;
|
|
13
|
+
const getAutoBeGenerated_1 = require("./factory/getAutoBeGenerated");
|
|
14
|
+
const emplaceMap_1 = require("./utils/emplaceMap");
|
|
15
|
+
class AutoBeAgentBase {
|
|
16
|
+
constructor(asset) {
|
|
17
|
+
this.asset = asset;
|
|
18
|
+
this.listeners_ = new Map();
|
|
19
|
+
}
|
|
20
|
+
getFiles(options) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return (0, getAutoBeGenerated_1.getAutoBeGenerated)(yield this.asset.compiler(), this.asset.state(), this.getHistories(), this.getTokenUsage(), options);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
on(type, listener) {
|
|
26
|
+
(0, emplaceMap_1.emplaceMap)(this.listeners_, type, () => new Set()).add(listener);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
off(type, listener) {
|
|
30
|
+
const set = this.listeners_.get(type);
|
|
31
|
+
if (set === undefined)
|
|
32
|
+
return this;
|
|
33
|
+
set.delete(listener);
|
|
34
|
+
if (set.size === 0)
|
|
35
|
+
this.listeners_.delete(type);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
dispatch(event) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const set = this.listeners_.get(event.type);
|
|
42
|
+
if (set === undefined)
|
|
43
|
+
return;
|
|
44
|
+
yield Promise.all(Array.from(set).map((listener) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
yield listener(event);
|
|
47
|
+
}
|
|
48
|
+
catch (_a) { }
|
|
49
|
+
})));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AutoBeAgentBase = AutoBeAgentBase;
|
|
54
|
+
//# sourceMappingURL=AutoBeAgentBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoBeAgentBase.js","sourceRoot":"","sources":["../src/AutoBeAgentBase.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,qEAAkE;AAClE,mDAAgD;AAEhD,MAAsB,eAAe;IAOnC,YAAoC,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;QAC/D,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;I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AAC,CAAA,CAAC,CACH,CAAC;QACJ,CAAC;KAAA;CACF;AA3DD,0CA2DC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AutoBeEventSnapshot, AutoBeHistory, IAutoBeCompiler, IAutoBeCompilerListener } from "@autobe/interface";
|
|
2
|
+
export declare namespace AutoBeMockAgent {
|
|
3
|
+
interface IProps {
|
|
4
|
+
compiler: (listener: IAutoBeCompilerListener) => IAutoBeCompiler | Promise<IAutoBeCompiler>;
|
|
5
|
+
preset: IPreset;
|
|
6
|
+
}
|
|
7
|
+
interface IPreset {
|
|
8
|
+
histories: AutoBeHistory[];
|
|
9
|
+
analyze: AutoBeEventSnapshot[];
|
|
10
|
+
prisma: AutoBeEventSnapshot[];
|
|
11
|
+
interface: AutoBeEventSnapshot[];
|
|
12
|
+
test: AutoBeEventSnapshot[];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AutoBeMockAgent = void 0;
|
|
13
|
+
const tstl_1 = require("tstl");
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
15
|
+
const AutoBeAgentBase_1 = require("./AutoBeAgentBase");
|
|
16
|
+
const AutoBeTokenUsage_1 = require("./context/AutoBeTokenUsage");
|
|
17
|
+
const createAutoBeState_1 = require("./factory/createAutoBeState");
|
|
18
|
+
/** @internal */
|
|
19
|
+
class AutoBeMockAgent extends AutoBeAgentBase_1.AutoBeAgentBase {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super({
|
|
22
|
+
compiler: () => this.compiler_.get(),
|
|
23
|
+
state: () => (0, createAutoBeState_1.createAutoBeState)(this.histories_),
|
|
24
|
+
});
|
|
25
|
+
this.props_ = props;
|
|
26
|
+
this.histories_ = [];
|
|
27
|
+
this.compiler_ = new tstl_1.Singleton(() => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return props.compiler({
|
|
29
|
+
realize: {
|
|
30
|
+
test: {
|
|
31
|
+
onOperation: () => __awaiter(this, void 0, void 0, function* () { }),
|
|
32
|
+
onReset: () => __awaiter(this, void 0, void 0, function* () { }),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}));
|
|
37
|
+
this.token_usage_ = new AutoBeTokenUsage_1.AutoBeTokenUsage();
|
|
38
|
+
}
|
|
39
|
+
conversate(content) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
// THE USER-MESSAGE
|
|
42
|
+
const userMessage = {
|
|
43
|
+
id: (0, uuid_1.v4)(),
|
|
44
|
+
type: "userMessage",
|
|
45
|
+
contents: typeof content === "string"
|
|
46
|
+
? [
|
|
47
|
+
{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: content,
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
: Array.isArray(content)
|
|
53
|
+
? content
|
|
54
|
+
: [content],
|
|
55
|
+
created_at: new Date().toISOString(),
|
|
56
|
+
};
|
|
57
|
+
void this.dispatch(userMessage).catch(() => { });
|
|
58
|
+
// ALREADY REALIZED CASE
|
|
59
|
+
const state = (0, createAutoBeState_1.createAutoBeState)(this.histories_);
|
|
60
|
+
if (state.test !== null) {
|
|
61
|
+
const assistantMessage = {
|
|
62
|
+
id: (0, uuid_1.v4)(),
|
|
63
|
+
type: "assistantMessage",
|
|
64
|
+
text: [
|
|
65
|
+
"You've reached to the test agent.",
|
|
66
|
+
"",
|
|
67
|
+
"The realize agent would be developed until 2025-08-31.",
|
|
68
|
+
"",
|
|
69
|
+
"Thanks for using AutoBE!",
|
|
70
|
+
].join("\n"),
|
|
71
|
+
created_at: new Date().toISOString(),
|
|
72
|
+
completed_at: new Date().toISOString(),
|
|
73
|
+
};
|
|
74
|
+
void this.dispatch(assistantMessage).catch(() => { });
|
|
75
|
+
this.histories_.push(userMessage, assistantMessage);
|
|
76
|
+
return this.histories_;
|
|
77
|
+
}
|
|
78
|
+
const take = (type) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
var _a;
|
|
80
|
+
for (const s of this.getEventSnapshots(type)) {
|
|
81
|
+
void this.dispatch(s.event).catch(() => { });
|
|
82
|
+
this.token_usage_ = new AutoBeTokenUsage_1.AutoBeTokenUsage(s.tokenUsage);
|
|
83
|
+
yield (0, tstl_1.sleep_for)((_a = sleepMap[s.event.type]) !== null && _a !== void 0 ? _a : 500);
|
|
84
|
+
}
|
|
85
|
+
this.histories_.push(userMessage);
|
|
86
|
+
this.histories_.push(this.props_.preset.histories.find((h) => h.type === type));
|
|
87
|
+
});
|
|
88
|
+
if (state.analyze === null)
|
|
89
|
+
yield take("analyze");
|
|
90
|
+
else if (state.prisma === null)
|
|
91
|
+
yield take("prisma");
|
|
92
|
+
else if (state.interface === null)
|
|
93
|
+
yield take("interface");
|
|
94
|
+
else if (state.test === null)
|
|
95
|
+
yield take("test");
|
|
96
|
+
return this.histories_;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
getHistories() {
|
|
100
|
+
return this.histories_;
|
|
101
|
+
}
|
|
102
|
+
getTokenUsage() {
|
|
103
|
+
return this.token_usage_;
|
|
104
|
+
}
|
|
105
|
+
getEventSnapshots(state) {
|
|
106
|
+
return this.props_.preset[state];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.AutoBeMockAgent = AutoBeMockAgent;
|
|
110
|
+
const sleepMap = {
|
|
111
|
+
analyzeStart: 1000,
|
|
112
|
+
analyzeWrite: 500,
|
|
113
|
+
analyzeReview: 500,
|
|
114
|
+
analyzeComplete: 500,
|
|
115
|
+
prismaStart: 1000,
|
|
116
|
+
prismaComponents: 1000,
|
|
117
|
+
prismaSchemas: 500,
|
|
118
|
+
prismaValidate: 2500,
|
|
119
|
+
prismaCorrect: 500,
|
|
120
|
+
prismaInsufficient: 1000,
|
|
121
|
+
prismaComplete: 500,
|
|
122
|
+
interfaceStart: 1000,
|
|
123
|
+
interfaceEndpoints: 1000,
|
|
124
|
+
interfaceOperations: 500,
|
|
125
|
+
interfaceComponents: 500,
|
|
126
|
+
interfaceComplement: 2500,
|
|
127
|
+
interfaceComplete: 500,
|
|
128
|
+
testStart: 1000,
|
|
129
|
+
testScenario: 1000,
|
|
130
|
+
testWrite: 50,
|
|
131
|
+
testValidate: 100,
|
|
132
|
+
testCorrect: 250,
|
|
133
|
+
testComplete: 500,
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=AutoBeMockAgent.js.map
|