@autobe/agent 0.30.3 → 0.30.4-dev.20260324
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/LICENSE +661 -661
- package/README.md +261 -0
- package/lib/AutoBeMockAgent.d.ts +2 -1
- package/lib/AutoBeMockAgent.js +37 -16
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/index.mjs +32 -49
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/interface/utils/AutoBeJsonSchemaValidator.js +316 -319
- package/lib/orchestrate/interface/utils/AutoBeJsonSchemaValidator.js.map +1 -1
- package/lib/structures/IAutoBeVendor.d.ts +13 -0
- package/package.json +5 -5
- package/src/AutoBeMockAgent.ts +283 -252
- package/src/orchestrate/interface/orchestrateInterfaceSchemaRefine.ts +291 -291
- package/src/orchestrate/interface/orchestrateInterfaceSchemaReview.ts +309 -309
- package/src/orchestrate/interface/utils/AutoBeJsonSchemaValidator.ts +763 -763
- package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +237 -237
- package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +322 -322
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -52
- package/src/structures/IAutoBeVendor.ts +127 -113
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# AutoBE - AI backend builder for prototype to production
|
|
2
|
+
|
|
3
|
+
[](https://github.com/wrtnlabs/autobe/blob/master/LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/@autobe/agent)
|
|
5
|
+
[](https://www.npmjs.com/package/@autobe/agent)
|
|
6
|
+
[](https://github.com/wrtnlabs/autobe/actions?query=workflow%3Abuild)
|
|
7
|
+
[](https://autobe.dev/docs/)
|
|
8
|
+
[](https://discord.gg/aMhRmzkqCx)
|
|
9
|
+
|
|
10
|
+
Describe your backend requirements in natural language through AutoBE's chat interface.
|
|
11
|
+
|
|
12
|
+
AutoBE will analyze your requirements and build the backend application for you. The generated backend application is designed to be 100% buildable by AI-friendly compilers and ensures stability through powerful e2e test functions.
|
|
13
|
+
|
|
14
|
+
With such AutoBE, build your first backend application quickly, then maintain and extend it with AI code assistants like Claude Code for enhanced productivity and stability.
|
|
15
|
+
|
|
16
|
+
AutoBE will generate complete specifications, detailed database and API documentation, comprehensive test coverage for stability, and clean implementation logic that serves as a learning foundation for juniors while significantly improving senior developer productivity.
|
|
17
|
+
|
|
18
|
+
Check out these complete backend application examples generated by AutoBE:
|
|
19
|
+
|
|
20
|
+
https://github.com/user-attachments/assets/b995dd2a-23bd-43c9-96cb-96d5c805f19f
|
|
21
|
+
|
|
22
|
+
1. **To Do List**: [`todo`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/todo)
|
|
23
|
+
2. **Discussion Board**: [`bbs`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs)
|
|
24
|
+
3. **Reddit Community**: [`reddit](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/reddit)
|
|
25
|
+
4. **E-Commerce**: [`shopping`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping)
|
|
26
|
+
- Requirements Analysis: [Report](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/docs/analysis)
|
|
27
|
+
- Database Design: [Entity Relationship Diagram](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/docs/ERD.md) / [Prisma Schema](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/prisma/schema)
|
|
28
|
+
- API Design: [API Controllers](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/src/controllers) / [DTO Structures](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/src/api/structures)
|
|
29
|
+
- E2E Test Functions: [`test/features/api`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/test/features/api)
|
|
30
|
+
- API Implementations: [`src/providers`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/shopping/src/providers)
|
|
31
|
+
|
|
32
|
+
## Getting Started
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git clone https://github.com/wrtnlabs/autobe --depth=1
|
|
36
|
+
cd autobe
|
|
37
|
+
pnpm install
|
|
38
|
+
pnpm run playground
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To use AutoBE, clone the repository and run the playground application locally. This allows you to chat with AutoBE's AI agents, manage multiple sessions, and use various LLM providers including local models like `qwen3-next-80b-a3b-instruct`.
|
|
42
|
+
|
|
43
|
+
After installation, the playground will be available at http://localhost:5713. You can interact with AutoBE through a chat interface - simply describe what you want to build, and AutoBE will generate the backend application for you.
|
|
44
|
+
|
|
45
|
+
Here's an example conversation script that guides AutoBE to create an "Economic/Political Discussion Board":
|
|
46
|
+
|
|
47
|
+
1. **Requirements Analysis**: "I want to create an economic/political discussion board. Since I'm not familiar with programming, please write a requirements analysis report as you see fit."
|
|
48
|
+
2. **Database Design**: "Design the database schema."
|
|
49
|
+
3. **API Specification**: "Create the API interface specification."
|
|
50
|
+
4. **Testing**: "Make the e2e test functions."
|
|
51
|
+
5. **Implementation**: "Implement API functions."
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
> The playground includes a replay feature at http://localhost:5713/replay/index.html where you can view chat sessions from the AutoBE development team's testing and benchmarks.
|
|
56
|
+
|
|
57
|
+
## Documentation Resources
|
|
58
|
+
|
|
59
|
+
Find comprehensive resources at our [official website](https://autobe.dev).
|
|
60
|
+
|
|
61
|
+
### 🏠 Home
|
|
62
|
+
|
|
63
|
+
- 🙋🏻♂️ [Introduction](https://autobe.dev/docs)
|
|
64
|
+
- 📦 [Setup](https://autobe.dev/docs/setup)
|
|
65
|
+
- 🔍 Concepts
|
|
66
|
+
- [Waterfall Model](https://autobe.dev/docs/concepts/waterfall)
|
|
67
|
+
- [Compiler Strategy](https://autobe.dev/docs/concepts/compiler)
|
|
68
|
+
- [AI Function Calling](https://autobe.dev/docs/concepts/function-calling)
|
|
69
|
+
|
|
70
|
+
### 📖 Features
|
|
71
|
+
|
|
72
|
+
- 🤖 Agent Library
|
|
73
|
+
- [Facade Controller](https://autobe.dev/docs/agent/facade)
|
|
74
|
+
- [Configuration](https://autobe.dev/docs/agent/config)
|
|
75
|
+
- [Event Handling](https://autobe.dev/docs/agent/event)
|
|
76
|
+
- [Prompt Histories](https://autobe.dev/docs/agent/history)
|
|
77
|
+
- 📡 WebSocket Protocol
|
|
78
|
+
- [Remote Procedure Call](https://autobe.dev/docs/websocket/rpc)
|
|
79
|
+
- [NestJS Server](https://autobe.dev/docs/websocket/nestjs)
|
|
80
|
+
- [NodeJS Server](https://autobe.dev/docs/websocket/nodejs)
|
|
81
|
+
- [Client Application](https://autobe.dev/docs/websocket/client)
|
|
82
|
+
- 🛠️ Backend Stack
|
|
83
|
+
- [TypeScript](https://autobe.dev/docs/stack/typescript)
|
|
84
|
+
- [Prisma ORM](https://autobe.dev/docs/stack/prisma)
|
|
85
|
+
- [NestJS Framework](https://autobe.dev/docs/stack/nestjs)
|
|
86
|
+
|
|
87
|
+
### 🔗 Appendix
|
|
88
|
+
|
|
89
|
+
- 🌐 [No-Code Ecosystem](https://autobe.dev/docs/ecosystem)
|
|
90
|
+
- 📅 Roadmap
|
|
91
|
+
- [Alpha Release (done)](https://autobe.dev/docs/roadmap/alpha)
|
|
92
|
+
- [Beta Release (done)](https://autobe.dev/docs/roadmap/beta)
|
|
93
|
+
- [Gamma Release (done)](https://autobe.dev/docs/roadmap/gamma)
|
|
94
|
+
- [Delta Release (active)](https://autobe.dev/docs/roadmap/delta)
|
|
95
|
+
- 🔧 [API Documentation](https://autobe.dev/api)
|
|
96
|
+
|
|
97
|
+
## How AutoBE Works
|
|
98
|
+
|
|
99
|
+
```mermaid
|
|
100
|
+
flowchart
|
|
101
|
+
subgraph "Backend Coding Agent"
|
|
102
|
+
coder("Facade Controller")
|
|
103
|
+
end
|
|
104
|
+
subgraph "Functional Agents"
|
|
105
|
+
coder --"Requirements Analysis"--> analyze("Analyze")
|
|
106
|
+
coder --"ERD"--> database("Database")
|
|
107
|
+
coder --"API Design"--> interface("Interface")
|
|
108
|
+
coder --"Test Codes" --> test("Test")
|
|
109
|
+
coder --"Main Program" --> realize("Realize")
|
|
110
|
+
end
|
|
111
|
+
subgraph "Compiler Feedback"
|
|
112
|
+
database --"validates" --> prismaCompiler("<a href="https://github.com/wrtnlabs/autobe/blob/main/packages/interface/src/database/AutoBeDatabase.ts" target="_blank">Prisma Compiler</a>")
|
|
113
|
+
interface --"generates" --> openapiCompiler("<a href="https://github.com/wrtnlabs/autobe/blob/main/packages/interface/src/openapi/AutoBeOpenApi.ts" target="_blank">OpenAPI Compiler</a>")
|
|
114
|
+
test --"analyzes" --> testCompiler("<a href="https://github.com/wrtnlabs/autobe/blob/main/packages/interface/src/test/AutoBeTest.ts" target="_blank">Test Compiler</a>")
|
|
115
|
+
realize --"compiles" --> realizeCompiler("TypeScript Compiler")
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
AutoBE follows a waterfall methodology to generate backend applications, with 40+ specialized agents handling each phase. The agents work in coordinated teams throughout the development process.
|
|
120
|
+
|
|
121
|
+
Each waterfall stage includes AI-friendly compilers that guarantee type safety of the generated code. Rather than generating code directly, AutoBE's agents first construct language-neutral Abstract Syntax Trees using predefined schemas. Each AST node undergoes validation against type rules before any code generation occurs, catching structural errors at the conceptual level rather than during compilation.
|
|
122
|
+
|
|
123
|
+
This approach is designed to ensure that the final generated TypeScript and Prisma code is 100% buildable. Based on our testing with multiple example projects including e-commerce platforms, discussion boards, and task management systems, AutoBE maintains this compilation guarantee across diverse application types.
|
|
124
|
+
|
|
125
|
+
To illustrate this process, here are the phase outputs from our "Economic/Political Discussion Board" example:
|
|
126
|
+
|
|
127
|
+
1. **Requirements Analysis**: [Report](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/docs/analysis)
|
|
128
|
+
2. **Database Design**: [Entity Relationship Diagram](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/docs/ERD.md) / [Prisma Schema](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/prisma/schema)
|
|
129
|
+
3. **API Specification**: [API Controllers](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/src/controllers) / [DTO Structures](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/src/api/structures)
|
|
130
|
+
4. **E2E Test Functions**: [`test/features/api`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/test/features/api)
|
|
131
|
+
5. **API Implementations**: [`src/providers`](https://github.com/wrtnlabs/autobe-examples/tree/main/openai/gpt-4.1/bbs/src/providers)
|
|
132
|
+
|
|
133
|
+
Also, you don't need to use all phases - stop at any stage that fits your needs. Whether you want just requirements analysis, database design, API specification, or e2e testing, AutoBE adapts to your workflow.
|
|
134
|
+
|
|
135
|
+
Additionally, if you're skipping the full pipeline because of language preference rather than workflow needs, this capability is in development - AutoBE's language-neutral AST structure will soon support additional programming languages beyond TypeScript.
|
|
136
|
+
|
|
137
|
+
## Type-Safe Client SDK
|
|
138
|
+
|
|
139
|
+
Every AutoBE-generated backend automatically includes a type-safe client SDK, making frontend integration seamless and error-free. This SDK provides:
|
|
140
|
+
|
|
141
|
+
- **Zero Configuration**: SDK is auto-generated alongside your backend - no manual setup required
|
|
142
|
+
- **100% Type Safety**: Full TypeScript support with autocomplete and compile-time validation
|
|
143
|
+
- **Framework Agnostic**: Works with React, Vue, Angular, or any TypeScript/JavaScript project
|
|
144
|
+
- **E2E Test Integration**: Powers AI-generated test suites for comprehensive backend testing
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import api, { IPost } from "autobe-generated-sdk";
|
|
148
|
+
|
|
149
|
+
// Type-safe API calls with full autocomplete
|
|
150
|
+
const connection: api.IConnection = {
|
|
151
|
+
host: "http://localhost:1234",
|
|
152
|
+
};
|
|
153
|
+
await api.functional.users.login(connection, {
|
|
154
|
+
body: {
|
|
155
|
+
email: "user@example.com",
|
|
156
|
+
password: "secure-password",
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// TypeScript catches errors at compile time
|
|
161
|
+
const post: IPost = await api.functional.posts.create(connection, {
|
|
162
|
+
body: {
|
|
163
|
+
title: "Hello World",
|
|
164
|
+
content: "My first post",
|
|
165
|
+
// authorId: "123" <- TypeScript error if this field is missing!
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This SDK eliminates the traditional pain points of API integration - no more manual type definitions, no more runtime surprises, and no more API documentation lookups. Your frontend developers can focus on building features, not wrestling with API contracts.
|
|
171
|
+
|
|
172
|
+
**Beyond Frontend Integration**: The SDK powers both frontend development and E2E test generation. AutoBE uses the same type-safe SDK internally to generate comprehensive test suites, ensuring every API endpoint is thoroughly tested. This creates a robust feedback loop that enhances backend stability - AI writes tests using the SDK, the SDK ensures type safety, and your backend becomes more reliable with every generated test.
|
|
173
|
+
|
|
174
|
+
## Roadmap Schedule
|
|
175
|
+
|
|
176
|
+
```mermaid
|
|
177
|
+
gantt
|
|
178
|
+
dateFormat YYYY-MM-DD
|
|
179
|
+
title AutoBE Delta Roadmap Timeline (2026 Q1)
|
|
180
|
+
|
|
181
|
+
section Local LLM Benchmark
|
|
182
|
+
Qwen3 Database Phase : done, 2026-01-01, 31d
|
|
183
|
+
Qwen3 Interface Phase : done, 2026-01-16, 31d
|
|
184
|
+
Qwen3 Test Phase : done, 2026-02-01, 21d
|
|
185
|
+
Qwen3 Realize Phase : done, 2026-02-01, 59d
|
|
186
|
+
|
|
187
|
+
section Validation Logic Enhancement
|
|
188
|
+
Dynamic Function Calling Schema : done, 2026-01-01, 7d
|
|
189
|
+
Validation Feedback Stringify : done, 2026-01-08, 12d
|
|
190
|
+
JSON Schema Validator : done, 2026-01-08, 12d
|
|
191
|
+
Schema Review Validation Logic : done, 2026-01-20, 35d
|
|
192
|
+
Test Mapping Plan Enhancement : done, 2026-02-05, 24d
|
|
193
|
+
Realize Mapping Plan Enhancement : done, 2026-02-15, 45d
|
|
194
|
+
|
|
195
|
+
section RAG Optimization
|
|
196
|
+
Hybrid Search (Vector + BM25) : done, 2026-01-01, 14d
|
|
197
|
+
Dynamic K Retrieval : done, 2026-01-15, 14d
|
|
198
|
+
RAG Preliminary Prompting : done, 2026-01-15, 28d
|
|
199
|
+
RAG Benchmark & Tuning : done, 2026-02-01, 28d
|
|
200
|
+
Analyze Agent Restructuring : done, 2026-02-01, 28d
|
|
201
|
+
|
|
202
|
+
section Design Integrity
|
|
203
|
+
DB Coverage Agent : done, 2026-01-15, 28d
|
|
204
|
+
API Endpoint Coverage Agent : done, 2026-01-22, 28d
|
|
205
|
+
Schema Relation Agent : done, 2026-02-01, 28d
|
|
206
|
+
Schema Structure Agent : done, 2026-02-01, 28d
|
|
207
|
+
Schema Content Agent : done, 2026-03-01, 28d
|
|
208
|
+
|
|
209
|
+
section Multi-lingual Support
|
|
210
|
+
Java Compiler PoC : done, 2026-01-01, 30d
|
|
211
|
+
Java Database : done, 2026-01-01, 14d
|
|
212
|
+
Java Interface : done, 2026-01-15, 21d
|
|
213
|
+
Java Test : active, 2026-02-05, 28d
|
|
214
|
+
Java Realize : active, 2026-03-01, 31d
|
|
215
|
+
|
|
216
|
+
section Human Modification Support
|
|
217
|
+
Database Schema Parser : active, 2026-02-15, 28d
|
|
218
|
+
Interface Schema Parser : active, 2026-02-22, 28d
|
|
219
|
+
Requirements Sync Agent : planned, 2026-03-08, 24d
|
|
220
|
+
|
|
221
|
+
section Miscellaneous
|
|
222
|
+
System Prompt Simplification : done, 2026-02-01, 28d
|
|
223
|
+
Estimation Agent : done, 2026-02-01, 28d
|
|
224
|
+
Playground Service Enhancement : active, 2026-02-15, 28d
|
|
225
|
+
PR Articles Writing : active, 2026-02-15, 30d
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
AutoBE has successfully completed Alpha, Beta, and Gamma development phases, establishing a solid foundation with **100% compilation success rate**. The current **Delta Release** focuses on transitioning from horizontal expansion to vertical deepening.
|
|
229
|
+
|
|
230
|
+
**Strategic Shift**: In Gamma, we rapidly implemented features like RAG, Modularization, and Complementation under a "just ship it" philosophy. Delta fills the stability gaps that remained by systematically discovering and fixing hidden defects through Local LLM benchmarks.
|
|
231
|
+
|
|
232
|
+
**Key Focus Areas**:
|
|
233
|
+
|
|
234
|
+
- **Local LLM Benchmark**: Using open-source models like Qwen3 as a touchstone to discover hidden defects that commercial models mask, ensuring more robust operation across all model types
|
|
235
|
+
- **Validation Logic Enhancement**: Strengthening schemas and validation logic through dynamic function calling schemas, JSON Schema validators, and progressive validation pipelines
|
|
236
|
+
- **RAG Optimization**: Completing the Hybrid Search system (Vector + BM25) with dynamic K retrieval and comprehensive benchmark tuning
|
|
237
|
+
- **Design Integrity**: Building mechanisms to verify and ensure design consistency between Database and Interface phases through coverage and schema review agents
|
|
238
|
+
- **Multi-lingual Support**: Launching Java/Spring code generation alongside TypeScript/NestJS, with language-neutral AST structures enabling future language additions
|
|
239
|
+
- **Human Modification Support**: Enabling maintenance continuity by parsing user-modified code back into AutoBE's internal AST representation, ensuring AutoBE remains useful beyond initial generation
|
|
240
|
+
|
|
241
|
+
This roadmap prioritizes stability and depth over feature breadth, informed by real-world production experience from Gamma.
|
|
242
|
+
|
|
243
|
+
## Current Limitations
|
|
244
|
+
|
|
245
|
+
While AutoBE achieves 100% compilation success, please note these current limitations:
|
|
246
|
+
|
|
247
|
+
**Runtime Behavior**: Generated applications compile successfully, but runtime behavior may require testing and refinement. Unexpected runtime errors can occur during server execution, such as database connection issues, API endpoint failures, or business logic exceptions that weren't caught during compilation. We strongly recommend thorough testing in development environments before deploying to production. Our v1.0 release targets 100% runtime success to address these issues.
|
|
248
|
+
|
|
249
|
+
**Design Interpretation**: AutoBE's database and API designs may differ from your expectations. We recommend thoroughly reviewing generated specifications before proceeding with implementation, especially before production deployment.
|
|
250
|
+
|
|
251
|
+
**Token Consumption**: AutoBE requires significant AI token usage for complex projects. Based on our testing, projects typically consume 30M-250M+ tokens depending on complexity (simple todo apps use ~4M tokens, while complex e-commerce platforms may require 250M+ tokens). We are working on RAG optimization to reduce this overhead in future releases.
|
|
252
|
+
|
|
253
|
+
**Maintenance**: AutoBE focuses on initial generation and does not provide ongoing maintenance capabilities. Once your backend is generated, you'll need to handle bug fixes, feature additions, performance optimizations, and security updates manually. We recommend establishing a development workflow that combines the generated codebase with AI coding assistants like Claude Code for efficient ongoing development and maintenance tasks.
|
|
254
|
+
|
|
255
|
+

|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
AutoBE is licensed under the [GNU Affero General Public License v3.0 (AGPL-3.0)](LICENSE). If you modify AutoBE itself or offer it as a network service, you must make your source code available under the same license.
|
|
260
|
+
|
|
261
|
+
However, backend applications generated by AutoBE can be relicensed under any license you choose, such as MIT. This means you can freely use AutoBE-generated code in commercial projects without open source obligations, similar to how other code generation tools work.
|
package/lib/AutoBeMockAgent.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { IAutoBeCompiler, IAutoBeCompilerListener, IAutoBePlaygroundReplay } from "@autobe/interface";
|
|
1
|
+
import { AutoBeEvent, IAutoBeCompiler, IAutoBeCompilerListener, IAutoBePlaygroundReplay } from "@autobe/interface";
|
|
2
2
|
export declare namespace AutoBeMockAgent {
|
|
3
3
|
interface IProps {
|
|
4
4
|
compiler: (listener: IAutoBeCompilerListener) => IAutoBeCompiler | Promise<IAutoBeCompiler>;
|
|
5
5
|
replay: IAutoBePlaygroundReplay;
|
|
6
|
+
delay?: ((type: AutoBeEvent.Type) => number | undefined) | undefined;
|
|
6
7
|
}
|
|
7
8
|
}
|
package/lib/AutoBeMockAgent.js
CHANGED
|
@@ -47,17 +47,16 @@ class AutoBeMockAgent extends AutoBeAgentBase_1.AutoBeAgentBase {
|
|
|
47
47
|
: Array.isArray(content)
|
|
48
48
|
? content
|
|
49
49
|
: [content];
|
|
50
|
-
// THE USER-MESSAGE
|
|
51
|
-
const userMessage = {
|
|
52
|
-
id: (0, uuid_1.v7)(),
|
|
53
|
-
type: "userMessage",
|
|
54
|
-
contents: contents.map((c) => (0, createAutoBeMessageContent_1.createAutoBeUserMessageContent)({ content: c })),
|
|
55
|
-
created_at: new Date().toISOString(),
|
|
56
|
-
};
|
|
57
|
-
void this.dispatch(userMessage).catch(() => { });
|
|
58
50
|
// ALREADY REALIZED CASE
|
|
59
51
|
const state = (0, createAutoBeState_1.createAutoBeState)(this.histories_);
|
|
60
52
|
if (state.realize !== null) {
|
|
53
|
+
const userMessage = {
|
|
54
|
+
id: (0, uuid_1.v7)(),
|
|
55
|
+
type: "userMessage",
|
|
56
|
+
contents: contents.map((c) => (0, createAutoBeMessageContent_1.createAutoBeUserMessageContent)({ content: c })),
|
|
57
|
+
created_at: new Date().toISOString(),
|
|
58
|
+
};
|
|
59
|
+
void this.dispatch(userMessage).catch(() => { });
|
|
61
60
|
yield (0, tstl_1.sleep_for)(2000);
|
|
62
61
|
const assistantMessage = {
|
|
63
62
|
id: (0, uuid_1.v7)(),
|
|
@@ -75,10 +74,15 @@ class AutoBeMockAgent extends AutoBeAgentBase_1.AutoBeAgentBase {
|
|
|
75
74
|
return this.histories_;
|
|
76
75
|
}
|
|
77
76
|
const take = (type) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
var _a;
|
|
77
|
+
var _a, _b, _c, _d;
|
|
79
78
|
const snapshots = this.getEventSnapshots(type);
|
|
80
79
|
if (snapshots === null) {
|
|
81
|
-
this.histories_.push(
|
|
80
|
+
this.histories_.push({
|
|
81
|
+
id: (0, uuid_1.v7)(),
|
|
82
|
+
type: "userMessage",
|
|
83
|
+
contents: contents.map((c) => (0, createAutoBeMessageContent_1.createAutoBeUserMessageContent)({ content: c })),
|
|
84
|
+
created_at: new Date().toISOString(),
|
|
85
|
+
});
|
|
82
86
|
this.histories_.push({
|
|
83
87
|
id: (0, uuid_1.v7)(),
|
|
84
88
|
type: "assistantMessage",
|
|
@@ -92,13 +96,30 @@ class AutoBeMockAgent extends AutoBeAgentBase_1.AutoBeAgentBase {
|
|
|
92
96
|
});
|
|
93
97
|
return;
|
|
94
98
|
}
|
|
99
|
+
// Find the nearest user message that led into this phase for history
|
|
100
|
+
// tracking. There may be assistant messages between the user request
|
|
101
|
+
// and the resulting phase history, so we search backwards.
|
|
102
|
+
const phaseIndex = this.props_.replay.histories.findIndex((h) => h.type === type);
|
|
103
|
+
const originalUserMessage = phaseIndex > 0
|
|
104
|
+
? this.props_.replay.histories
|
|
105
|
+
.slice(0, phaseIndex)
|
|
106
|
+
.reverse()
|
|
107
|
+
.find((h) => h.type === "userMessage")
|
|
108
|
+
: undefined;
|
|
95
109
|
for (const s of snapshots) {
|
|
96
|
-
const time = (_a = sleepMap[s.event.type]) !== null &&
|
|
110
|
+
const time = (_d = (_c = (_b = (_a = this.props_).delay) === null || _b === void 0 ? void 0 : _b.call(_a, s.event.type)) !== null && _c !== void 0 ? _c : sleepMap[s.event.type]) !== null && _d !== void 0 ? _d : 500;
|
|
97
111
|
yield (0, tstl_1.sleep_for)((0, tstl_1.randint)(time * 0.2, time * 1.8));
|
|
98
112
|
void this.dispatch(s.event).catch(() => { });
|
|
99
113
|
this.token_usage_ = new AutoBeTokenUsage_1.AutoBeTokenUsage(s.tokenUsage);
|
|
100
114
|
}
|
|
101
|
-
this.histories_.push(userMessage
|
|
115
|
+
this.histories_.push((originalUserMessage === null || originalUserMessage === void 0 ? void 0 : originalUserMessage.type) === "userMessage"
|
|
116
|
+
? originalUserMessage
|
|
117
|
+
: {
|
|
118
|
+
id: (0, uuid_1.v7)(),
|
|
119
|
+
type: "userMessage",
|
|
120
|
+
contents: contents.map((c) => (0, createAutoBeMessageContent_1.createAutoBeUserMessageContent)({ content: c })),
|
|
121
|
+
created_at: new Date().toISOString(),
|
|
122
|
+
});
|
|
102
123
|
this.histories_.push(this.props_.replay.histories.find((h) => h.type === type));
|
|
103
124
|
});
|
|
104
125
|
if (state.analyze === null)
|
|
@@ -170,8 +191,8 @@ const sleepMap = {
|
|
|
170
191
|
analyzeStart: 1000,
|
|
171
192
|
analyzeScenario: 1000,
|
|
172
193
|
analyzeWriteModule: 500,
|
|
173
|
-
analyzeWriteUnit:
|
|
174
|
-
analyzeWriteSection:
|
|
194
|
+
analyzeWriteUnit: 250,
|
|
195
|
+
analyzeWriteSection: 200,
|
|
175
196
|
analyzeSectionReview: 300,
|
|
176
197
|
analyzeScenarioReview: 300,
|
|
177
198
|
analyzeComplete: 1000,
|
|
@@ -191,10 +212,10 @@ const sleepMap = {
|
|
|
191
212
|
// INTERFACE
|
|
192
213
|
interfaceStart: 1000,
|
|
193
214
|
interfaceGroup: 1000,
|
|
194
|
-
interfaceEndpoint:
|
|
215
|
+
interfaceEndpoint: 500,
|
|
195
216
|
interfaceEndpointReview: 1000,
|
|
196
217
|
interfaceOperation: 400,
|
|
197
|
-
interfaceOperationReview:
|
|
218
|
+
interfaceOperationReview: 500,
|
|
198
219
|
interfaceAuthorization: 400,
|
|
199
220
|
interfaceSchema: 400,
|
|
200
221
|
interfaceSchemaCasting: 400,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeMockAgent.js","sourceRoot":"","sources":["../src/AutoBeMockAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,+BAAqD;AACrD,+BAA0B;AAE1B,uDAAoD;AAEpD,iEAA8D;AAC9D,qFAAsF;AACtF,mEAAgE;AAChE,qEAAkE;AAElE,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,iCAAe;IAMlD,YAAmB,KAA6B;QAC9C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IA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AAE;IACf,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,GAAG;IACpB,yBAAyB,EAAE,IAAK;IAChC,yBAAyB,EAAE,GAAG;IAC9B,4BAA4B,EAAE,GAAG;IACjC,2BAA2B,EAAE,GAAG;IAChC,4BAA4B,EAAE,IAAK;IACnC,gBAAgB,EAAE,IAAK;IACvB,gBAAgB,EAAE,IAAK;IACvB,oBAAoB,EAAE,GAAG;IACzB,mBAAmB,EAAE,IAAK;CAC3B,CAAC"}
|
package/lib/index.mjs
CHANGED
|
@@ -2916,7 +2916,6 @@ var AutoBeJsonSchemaValidator;
|
|
|
2916
2916
|
validateReferenceId(props);
|
|
2917
2917
|
validatePropertyNames(props);
|
|
2918
2918
|
validateNumericRanges(props);
|
|
2919
|
-
validateEmptyProperties(props);
|
|
2920
2919
|
vo(props.typeName, props.schema);
|
|
2921
2920
|
AutoBeOpenApiTypeChecker.skim({
|
|
2922
2921
|
schema: props.schema,
|
|
@@ -3415,38 +3414,6 @@ var AutoBeJsonSchemaValidator;
|
|
|
3415
3414
|
}
|
|
3416
3415
|
});
|
|
3417
3416
|
};
|
|
3418
|
-
const validateEmptyProperties = props => {
|
|
3419
|
-
if (AutoBeOpenApiTypeChecker.isObject(props.schema) === false) return;
|
|
3420
|
-
if (Object.keys(props.schema.properties).length !== 0) return;
|
|
3421
|
-
if (AutoBeJsonSchemaValidator.isObjectType({
|
|
3422
|
-
operations: props.operations,
|
|
3423
|
-
typeName: props.typeName
|
|
3424
|
-
}) === false) return;
|
|
3425
|
-
props.errors.push({
|
|
3426
|
-
path: props.path,
|
|
3427
|
-
expected: "At least 1 property in properties",
|
|
3428
|
-
value: props.schema,
|
|
3429
|
-
description: StringUtil.trim`
|
|
3430
|
-
Schema ${JSON.stringify(props.typeName)} has zero properties but is used
|
|
3431
|
-
as a request body or response body in API operations.
|
|
3432
|
-
|
|
3433
|
-
Empty properties will cause TypeScript compilation errors (TS2339) in the
|
|
3434
|
-
downstream Realize stage because implementation code will try to access
|
|
3435
|
-
properties that don't exist on the type.
|
|
3436
|
-
|
|
3437
|
-
You MUST define at least one property in the schema. Load the database
|
|
3438
|
-
schema and add the appropriate properties based on the DTO type:
|
|
3439
|
-
- ICreate: User-provided business fields (exclude id, timestamps, actor FKs)
|
|
3440
|
-
- IUpdate: All mutable business fields (all optional)
|
|
3441
|
-
- ISummary: Essential display fields for list views
|
|
3442
|
-
- IEntity (root): All public fields including relations
|
|
3443
|
-
- IRequest: Pagination and filter parameters
|
|
3444
|
-
- IJoin/ILogin: Credentials and session context fields
|
|
3445
|
-
|
|
3446
|
-
Note that, this is not a recommendation, but an instruction you must follow.
|
|
3447
|
-
`
|
|
3448
|
-
});
|
|
3449
|
-
};
|
|
3450
3417
|
})(AutoBeJsonSchemaValidator || (AutoBeJsonSchemaValidator = {}));
|
|
3451
3418
|
|
|
3452
3419
|
var AutoBeInterfaceSchemaProgrammer;
|
|
@@ -71305,17 +71272,17 @@ class AutoBeMockAgent extends AutoBeAgentBase {
|
|
|
71305
71272
|
type: "text",
|
|
71306
71273
|
text: content
|
|
71307
71274
|
} ] : Array.isArray(content) ? content : [ content ];
|
|
71308
|
-
const userMessage = {
|
|
71309
|
-
id: v7(),
|
|
71310
|
-
type: "userMessage",
|
|
71311
|
-
contents: contents.map(c => createAutoBeUserMessageContent({
|
|
71312
|
-
content: c
|
|
71313
|
-
})),
|
|
71314
|
-
created_at: (new Date).toISOString()
|
|
71315
|
-
};
|
|
71316
|
-
void this.dispatch(userMessage).catch(() => {});
|
|
71317
71275
|
const state = createAutoBeState(this.histories_);
|
|
71318
71276
|
if (state.realize !== null) {
|
|
71277
|
+
const userMessage = {
|
|
71278
|
+
id: v7(),
|
|
71279
|
+
type: "userMessage",
|
|
71280
|
+
contents: contents.map(c => createAutoBeUserMessageContent({
|
|
71281
|
+
content: c
|
|
71282
|
+
})),
|
|
71283
|
+
created_at: (new Date).toISOString()
|
|
71284
|
+
};
|
|
71285
|
+
void this.dispatch(userMessage).catch(() => {});
|
|
71319
71286
|
await sleep_for(2e3);
|
|
71320
71287
|
const assistantMessage = {
|
|
71321
71288
|
id: v7(),
|
|
@@ -71331,7 +71298,14 @@ class AutoBeMockAgent extends AutoBeAgentBase {
|
|
|
71331
71298
|
const take = async type => {
|
|
71332
71299
|
const snapshots = this.getEventSnapshots(type);
|
|
71333
71300
|
if (snapshots === null) {
|
|
71334
|
-
this.histories_.push(
|
|
71301
|
+
this.histories_.push({
|
|
71302
|
+
id: v7(),
|
|
71303
|
+
type: "userMessage",
|
|
71304
|
+
contents: contents.map(c => createAutoBeUserMessageContent({
|
|
71305
|
+
content: c
|
|
71306
|
+
})),
|
|
71307
|
+
created_at: (new Date).toISOString()
|
|
71308
|
+
});
|
|
71335
71309
|
this.histories_.push({
|
|
71336
71310
|
id: v7(),
|
|
71337
71311
|
type: "assistantMessage",
|
|
@@ -71341,13 +71315,22 @@ class AutoBeMockAgent extends AutoBeAgentBase {
|
|
|
71341
71315
|
});
|
|
71342
71316
|
return;
|
|
71343
71317
|
}
|
|
71318
|
+
const phaseIndex = this.props_.replay.histories.findIndex(h => h.type === type);
|
|
71319
|
+
const originalUserMessage = phaseIndex > 0 ? this.props_.replay.histories.slice(0, phaseIndex).reverse().find(h => h.type === "userMessage") : undefined;
|
|
71344
71320
|
for (const s of snapshots) {
|
|
71345
|
-
const time = sleepMap[s.event.type] ?? 500;
|
|
71321
|
+
const time = this.props_.delay?.(s.event.type) ?? sleepMap[s.event.type] ?? 500;
|
|
71346
71322
|
await sleep_for(randint(time * .2, time * 1.8));
|
|
71347
71323
|
void this.dispatch(s.event).catch(() => {});
|
|
71348
71324
|
this.token_usage_ = new AutoBeTokenUsage(s.tokenUsage);
|
|
71349
71325
|
}
|
|
71350
|
-
this.histories_.push(userMessage
|
|
71326
|
+
this.histories_.push(originalUserMessage?.type === "userMessage" ? originalUserMessage : {
|
|
71327
|
+
id: v7(),
|
|
71328
|
+
type: "userMessage",
|
|
71329
|
+
contents: contents.map(c => createAutoBeUserMessageContent({
|
|
71330
|
+
content: c
|
|
71331
|
+
})),
|
|
71332
|
+
created_at: (new Date).toISOString()
|
|
71333
|
+
});
|
|
71351
71334
|
this.histories_.push(this.props_.replay.histories.find(h => h.type === type));
|
|
71352
71335
|
};
|
|
71353
71336
|
if (state.analyze === null) await take("analyze"); else if (state.database === null) await take("database"); else if (state.interface === null) await take("interface"); else if (state.test === null) await take("test"); else if (state.realize === null) await take("realize");
|
|
@@ -71394,8 +71377,8 @@ const sleepMap = {
|
|
|
71394
71377
|
analyzeStart: 1e3,
|
|
71395
71378
|
analyzeScenario: 1e3,
|
|
71396
71379
|
analyzeWriteModule: 500,
|
|
71397
|
-
analyzeWriteUnit:
|
|
71398
|
-
analyzeWriteSection:
|
|
71380
|
+
analyzeWriteUnit: 250,
|
|
71381
|
+
analyzeWriteSection: 200,
|
|
71399
71382
|
analyzeSectionReview: 300,
|
|
71400
71383
|
analyzeScenarioReview: 300,
|
|
71401
71384
|
analyzeComplete: 1e3,
|
|
@@ -71413,10 +71396,10 @@ const sleepMap = {
|
|
|
71413
71396
|
databaseComplete: 1e3,
|
|
71414
71397
|
interfaceStart: 1e3,
|
|
71415
71398
|
interfaceGroup: 1e3,
|
|
71416
|
-
interfaceEndpoint:
|
|
71399
|
+
interfaceEndpoint: 500,
|
|
71417
71400
|
interfaceEndpointReview: 1e3,
|
|
71418
71401
|
interfaceOperation: 400,
|
|
71419
|
-
interfaceOperationReview:
|
|
71402
|
+
interfaceOperationReview: 500,
|
|
71420
71403
|
interfaceAuthorization: 400,
|
|
71421
71404
|
interfaceSchema: 400,
|
|
71422
71405
|
interfaceSchemaCasting: 400,
|