@louloulinx/metagpt 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/.eslintrc.json +23 -0
  2. package/.prettierrc +7 -0
  3. package/LICENSE +21 -0
  4. package/README-CN.md +754 -0
  5. package/README.md +238 -0
  6. package/bun.lock +1023 -0
  7. package/doc/TutorialAssistant.md +114 -0
  8. package/doc/VercelLLMProvider.md +164 -0
  9. package/eslint.config.js +55 -0
  10. package/examples/data-interpreter-example.ts +173 -0
  11. package/examples/qwen-direct-example.ts +60 -0
  12. package/examples/qwen-example.ts +62 -0
  13. package/examples/tutorial-assistant-example.ts +97 -0
  14. package/jest.config.ts +22 -0
  15. package/output/tutorials/Go/350/257/255/350/250/200/347/274/226/347/250/213/346/225/231/347/250/213_2025-02-25T09-35-15-436Z.md +2208 -0
  16. package/output/tutorials/Rust/346/225/231/347/250/213_2025-02-25T08-27-27-632Z.md +1967 -0
  17. package/output/tutorials//345/246/202/344/275/225/344/275/277/347/224/250TypeScript/345/274/200/345/217/221Node.js/345/272/224/347/224/250_2025-02-25T08-14-39-605Z.md +1721 -0
  18. package/output/tutorials//346/225/260/345/255/227/347/273/217/346/265/216/345/255/246/346/225/231/347/250/213_2025-02-25T10-45-03-605Z.md +902 -0
  19. package/output/tutorials//346/232/250/345/215/227/345/244/247/345/255/246/346/225/260/345/255/227/347/273/217/346/265/216/345/255/246/345/244/215/350/257/225/350/265/204/346/226/231_2025-02-25T11-16-59-133Z.md +719 -0
  20. package/package.json +58 -0
  21. package/plan-cn.md +321 -0
  22. package/plan.md +154 -0
  23. package/src/actions/analyze-task.ts +65 -0
  24. package/src/actions/base-action.ts +103 -0
  25. package/src/actions/di/execute-nb-code.ts +247 -0
  26. package/src/actions/di/write-analysis-code.ts +234 -0
  27. package/src/actions/write-tutorial.ts +232 -0
  28. package/src/config/browser.ts +33 -0
  29. package/src/config/config.ts +345 -0
  30. package/src/config/embedding.ts +26 -0
  31. package/src/config/llm.ts +36 -0
  32. package/src/config/mermaid.ts +37 -0
  33. package/src/config/omniparse.ts +25 -0
  34. package/src/config/redis.ts +34 -0
  35. package/src/config/s3.ts +33 -0
  36. package/src/config/search.ts +30 -0
  37. package/src/config/workspace.ts +20 -0
  38. package/src/index.ts +40 -0
  39. package/src/management/team.ts +168 -0
  40. package/src/memory/longterm.ts +218 -0
  41. package/src/memory/manager.ts +160 -0
  42. package/src/memory/types.ts +100 -0
  43. package/src/memory/working.ts +154 -0
  44. package/src/monitoring/system.ts +413 -0
  45. package/src/monitoring/types.ts +230 -0
  46. package/src/plugin/manager.ts +79 -0
  47. package/src/plugin/types.ts +114 -0
  48. package/src/provider/vercel-llm.ts +314 -0
  49. package/src/rag/base-rag.ts +194 -0
  50. package/src/rag/document-qa.ts +102 -0
  51. package/src/roles/base-role.ts +155 -0
  52. package/src/roles/data-interpreter.ts +360 -0
  53. package/src/roles/engineer.ts +1 -0
  54. package/src/roles/tutorial-assistant.ts +217 -0
  55. package/src/skills/base-skill.ts +144 -0
  56. package/src/skills/code-review.ts +120 -0
  57. package/src/tools/base-tool.ts +155 -0
  58. package/src/tools/file-system.ts +204 -0
  59. package/src/tools/tool-recommend.d.ts +14 -0
  60. package/src/tools/tool-recommend.ts +31 -0
  61. package/src/types/action.ts +38 -0
  62. package/src/types/config.ts +129 -0
  63. package/src/types/document.ts +354 -0
  64. package/src/types/llm.ts +64 -0
  65. package/src/types/memory.ts +36 -0
  66. package/src/types/message.ts +193 -0
  67. package/src/types/rag.ts +86 -0
  68. package/src/types/role.ts +67 -0
  69. package/src/types/skill.ts +71 -0
  70. package/src/types/task.ts +32 -0
  71. package/src/types/team.ts +55 -0
  72. package/src/types/tool.ts +77 -0
  73. package/src/types/workflow.ts +133 -0
  74. package/src/utils/common.ts +73 -0
  75. package/src/utils/yaml.ts +67 -0
  76. package/src/websocket/browser-client.ts +187 -0
  77. package/src/websocket/client.ts +186 -0
  78. package/src/websocket/server.ts +169 -0
  79. package/src/websocket/types.ts +125 -0
  80. package/src/workflow/executor.ts +193 -0
  81. package/src/workflow/executors/action-executor.ts +72 -0
  82. package/src/workflow/executors/condition-executor.ts +118 -0
  83. package/src/workflow/executors/parallel-executor.ts +201 -0
  84. package/src/workflow/executors/role-executor.ts +76 -0
  85. package/src/workflow/executors/sequence-executor.ts +196 -0
  86. package/tests/actions.test.ts +105 -0
  87. package/tests/benchmark/performance.test.ts +147 -0
  88. package/tests/config/config.test.ts +115 -0
  89. package/tests/config.test.ts +106 -0
  90. package/tests/e2e/setup.ts +74 -0
  91. package/tests/e2e/workflow.test.ts +88 -0
  92. package/tests/llm.test.ts +84 -0
  93. package/tests/memory/memory.test.ts +164 -0
  94. package/tests/memory.test.ts +63 -0
  95. package/tests/monitoring/monitoring.test.ts +225 -0
  96. package/tests/plugin/plugin.test.ts +183 -0
  97. package/tests/provider/bailian-llm.test.ts +98 -0
  98. package/tests/rag.test.ts +162 -0
  99. package/tests/roles.test.ts +88 -0
  100. package/tests/skills.test.ts +166 -0
  101. package/tests/team.test.ts +143 -0
  102. package/tests/tools.test.ts +170 -0
  103. package/tests/types/document.test.ts +181 -0
  104. package/tests/types/message.test.ts +122 -0
  105. package/tests/utils/yaml.test.ts +110 -0
  106. package/tests/utils.test.ts +74 -0
  107. package/tests/websocket/browser-client.test.ts +1 -0
  108. package/tests/websocket/websocket.test.ts +42 -0
  109. package/tests/workflow/parallel-executor.test.ts +224 -0
  110. package/tests/workflow/sequence-executor.test.ts +207 -0
  111. package/tests/workflow.test.ts +290 -0
  112. package/tsconfig.json +27 -0
  113. package/typedoc.json +25 -0
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # MetaGPT.TS
2
+
3
+ > A TypeScript-based multi-agent collaboration framework that transforms large language models into efficient agents, building a collaborative software development team.
4
+
5
+
6
+ ## 📖 文档 | Documentation
7
+
8
+ **[中文文档](README-CN.md)** | [English](README.md)
9
+
10
+ ## Introduction
11
+
12
+ MetaGPT.TS is a modern TypeScript framework for building multi-agent systems. It transforms large language models (LLMs) into efficient agents that can collaborate as a software development team.
13
+
14
+ ### Key Features
15
+ - **Agent Collaboration**: Built-in roles like Product Manager, Architect, and Engineer collaborate through standardized processes to complete complex tasks
16
+ - **End-to-End Support**: Intelligent support for the entire process from requirement analysis and system design to code implementation
17
+ - **High-Performance Architecture**: Based on modern TypeScript stack, providing efficient and type-safe development experience
18
+ - **Extensibility**: Support for custom roles, actions, and workflows to adapt to different application scenarios
19
+
20
+ ## Quick Start
21
+
22
+ ```bash
23
+ # Install with bun
24
+ bun install @louloulinx/metagpt
25
+
26
+ # Or with npm
27
+ npm install @louloulinx/metagpt
28
+ ```
29
+
30
+ ### Basic Configuration
31
+
32
+ ```typescript
33
+ // Configure LLM provider
34
+ import { config } from "@louloulinx/metagpt/config";
35
+
36
+ config.OPENAI_API_KEY = "sk-..."; // Your API key
37
+ ```
38
+
39
+ ### Simple Example
40
+
41
+ ```typescript
42
+ import { Team, ProductManager, Architect, Engineer } from "@louloulinx/metagpt/roles";
43
+
44
+ // Create a team
45
+ const team = new Team();
46
+ team.hire([new ProductManager(), new Architect(), new Engineer()]);
47
+
48
+ // Execute project
49
+ await team.runProject("Implement a simple todo management application");
50
+ ```
51
+
52
+ ## Core Concepts
53
+
54
+ - **Role**: Task execution units with specific skills (Product Manager/Architect/Engineer)
55
+ - **Action**: Atomic operation units of agents
56
+ - **Team**: Organization of multiple roles working together
57
+ - **Memory**: Long-term memory storage with vector retrieval support
58
+
59
+ ## Application Scenarios
60
+
61
+ - Agent-assisted development
62
+ - Automated workflow orchestration
63
+ - Complex task decomposition and execution
64
+ - AI team simulation and optimization
65
+ - Enterprise application intelligence transformation
66
+
67
+ ## Core Features
68
+
69
+ 1. **Multi-Role Collaboration** - Pre-configured roles including Product Manager, Architect, Engineer, etc.
70
+ 2. **Automated Workflow** - Support for the entire process from requirement analysis to system design and code implementation
71
+ 3. **Type Safety** - Strict TypeScript type checking
72
+ 4. **Reactive Architecture** - Message pipeline processing based on RxJS
73
+ 5. **Observability** - Built-in comprehensive logging and monitoring support
74
+
75
+ ## Supported Models
76
+
77
+ | Provider | Supported Versions | Config Name |
78
+ |-----------|------------------------|-------------------|
79
+ | OpenAI | gpt-4/gpt-3.5-turbo | OPENAI_API_KEY |
80
+ | Anthropic | Claude-2 | ANTHROPIC_API_KEY |
81
+ | Azure | GPT-4 | AZURE_API_KEY |
82
+
83
+ ## Project Structure
84
+
85
+ ```
86
+ metagpt/
87
+ ├── src/
88
+ │ ├── actions/ # Action definitions and implementations
89
+ │ ├── roles/ # Role definitions and behaviors
90
+ │ ├── utils/ # Utility functions and helper classes
91
+ │ ├── config/ # Configuration management
92
+ │ ├── memory/ # Memory and state management
93
+ │ ├── provider/ # LLM provider integration
94
+ │ ├── tools/ # External tool integration
95
+ │ ├── skills/ # Skill implementations
96
+ │ ├── rag/ # Retrieval-augmented generation
97
+ │ ├── document/ # Document processing and management
98
+ │ └── types/ # TypeScript type definitions
99
+ ├── tests/ # Test files
100
+ ├── examples/ # Example implementations
101
+ └── package.json # Project dependencies and scripts
102
+ ```
103
+
104
+ ## Environment Configuration
105
+
106
+ MetaGPT.TS supports environment variable configuration through `.env` files for easy management of API keys and other configuration items.
107
+
108
+ 1. Create a `.env` file in the project root directory:
109
+
110
+ ```
111
+ # LLM provider configuration
112
+ OPENAI_API_KEY=sk-your-openai-api-key
113
+ OPENAI_API_MODEL=gpt-4-turbo
114
+ OPENAI_API_BASE=https://api.openai.com/v1
115
+
116
+ # Optional other LLM providers
117
+ ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
118
+ AZURE_API_KEY=your-azure-api-key
119
+ AZURE_API_BASE=your-azure-endpoint
120
+
121
+ # Vector storage configuration
122
+ QDRANT_URL=http://localhost:6333
123
+ QDRANT_API_KEY=your-qdrant-api-key
124
+
125
+ # Logging configuration
126
+ LOG_LEVEL=info # debug, info, warn, error
127
+
128
+ # Application settings
129
+ MAX_TOKENS=4000
130
+ TEMPERATURE=0.7
131
+ PROJECT_ROOT=./workspace
132
+ ```
133
+
134
+ 2. Or configure directly in code (not recommended):
135
+
136
+ ```typescript
137
+ // Configure LLM provider (OpenAI example)
138
+ import { config } from "@louloulinx/metagpt/config";
139
+
140
+ config.OPENAI_API_KEY = "sk-..."; // Your API key
141
+ config.OPENAI_API_MODEL = "gpt-4-1106-preview"; // Model version
142
+ ```
143
+
144
+ ## Basic Usage Example (Coming Soon)
145
+
146
+ ```typescript
147
+ import { Team, ProductManager, Architect, Engineer } from "@louloulinx/metagpt/roles";
148
+ import { Message } from "@louloulinx/metagpt/types";
149
+
150
+ async function startup(idea: string) {
151
+ // Initialize team
152
+ const company = new Team();
153
+
154
+ // Build team
155
+ company.hire([
156
+ new ProductManager(),
157
+ new Architect(),
158
+ new Engineer(),
159
+ ]);
160
+
161
+ // Set initial parameters
162
+ company.invest(3.0); // Set budget (virtual currency)
163
+
164
+ // Run project
165
+ const messages: Message[] = await company.runProject(
166
+ idea,
167
+ { maxRounds: 5 }
168
+ );
169
+
170
+ return messages;
171
+ }
172
+
173
+ // Execute example
174
+ await startup("Implement a command-line Reversi game");
175
+ ```
176
+
177
+ ## Technical Stack
178
+
179
+ ### Core Technology Stack
180
+ 1. Runtime & Package Manager
181
+ - Bun.js: High-performance JavaScript runtime with built-in package manager
182
+ - Node.js 18+ compatibility support
183
+
184
+ 2. Development Language and Framework
185
+ - TypeScript 5.0+: Strong type support
186
+ - Zod: Runtime type validation
187
+ - XState: State machine management
188
+ - RxJS: Reactive programming
189
+
190
+ 3. Testing and Development Tools
191
+ - bun:test: Unit testing framework
192
+ - ESLint + Prettier: Code standards
193
+ - TypeDoc: API documentation generation
194
+
195
+ 4. Core Dependencies
196
+ - Vercel AI SDK
197
+ - Qdrant Node Client: Vector storage
198
+ - Winston: Log management
199
+
200
+ ## Roadmap
201
+
202
+ ### Core Architecture Evolution
203
+ 1. Strengthen Type System
204
+ - Implement runtime type validation
205
+ - Enhance generic support
206
+ - Improve pattern matching mechanism
207
+
208
+ 2. Performance Optimization
209
+ - Message pipeline performance benchmarking
210
+ - Memory management optimization
211
+ - Asynchronous task scheduling improvements
212
+
213
+ 3. Extensibility Enhancement
214
+ - Modular architecture refactoring
215
+ - Dynamic plugin loading mechanism
216
+ - Hot update support
217
+
218
+ ### Ecosystem Building
219
+ 1. Developer Toolchain
220
+ - CLI tool enhancement
221
+ - Visual debugger
222
+ - Performance analysis tools
223
+
224
+ 2. Templates and Examples
225
+ - Create common scenario templates
226
+ - Add enterprise-level examples
227
+ - Build example library
228
+
229
+ 3. Integration Support
230
+ - Mainstream frontend framework adaptation
231
+ - Node.js runtime optimization
232
+ - Deno/Bun deep integration
233
+
234
+ ## Acknowledgements
235
+
236
+ The design of metagpt.ts references the implementation logic of [MetaGPT](https://github.com/geekan/MetaGPT), for which we are grateful.
237
+
238
+