@lov3kaizen/agentsea-crews 0.5.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 lovekaizen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # @lov3kaizen/agentsea-crews
2
+
3
+ A TypeScript-native multi-agent orchestration framework for building AI agent teams. Inspired by CrewAI and AutoGen, this package provides role-based agent coordination, task delegation strategies, workflow building capabilities, and pre-built crew templates.
4
+
5
+ ## Features
6
+
7
+ - **Role-Based Agents**: Define agents with specific roles, capabilities, and goals
8
+ - **Multiple Delegation Strategies**: Round-robin, best-match, auction, hierarchical, and consensus
9
+ - **Workflow Builder**: Fluent API for building complex workflows with DAG execution
10
+ - **Memory Systems**: Shared memory, conversation history, and knowledge base
11
+ - **Monitoring & Debug**: Real-time dashboard and step-through debugging
12
+ - **Pre-built Templates**: Research, writing, code review, and customer support crews
13
+ - **NestJS Integration**: Decorators and dynamic modules for NestJS apps
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @lov3kaizen/agentsea-crews
19
+ # or
20
+ pnpm add @lov3kaizen/agentsea-crews
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ### Basic Crew
26
+
27
+ ```typescript
28
+ import {
29
+ createCrew,
30
+ type CrewConfig,
31
+ type RoleConfig,
32
+ } from '@lov3kaizen/agentsea-crews';
33
+
34
+ // Define a role
35
+ const researcherRole: RoleConfig = {
36
+ name: 'Researcher',
37
+ description: 'Expert at finding and synthesizing information',
38
+ capabilities: [
39
+ { name: 'web-search', proficiency: 'expert' },
40
+ { name: 'analysis', proficiency: 'advanced' },
41
+ ],
42
+ systemPrompt: 'You are a skilled researcher...',
43
+ goals: ['Find accurate information'],
44
+ };
45
+
46
+ // Create crew configuration
47
+ const config: CrewConfig = {
48
+ name: 'my-crew',
49
+ agents: [
50
+ {
51
+ name: 'researcher',
52
+ role: researcherRole,
53
+ model: 'claude-sonnet-4-20250514',
54
+ provider: 'anthropic',
55
+ },
56
+ ],
57
+ delegationStrategy: 'best-match',
58
+ };
59
+
60
+ // Create and run the crew
61
+ const crew = createCrew(config);
62
+
63
+ crew.addTask({
64
+ description: 'Research AI trends',
65
+ expectedOutput: 'Summary of AI trends',
66
+ priority: 'high',
67
+ });
68
+
69
+ const result = await crew.kickoff();
70
+ console.log(result.finalOutput);
71
+ ```
72
+
73
+ ### Using Templates
74
+
75
+ ```typescript
76
+ import { createResearchCrew, ResearchTasks } from '@lov3kaizen/agentsea-crews';
77
+
78
+ // Create a research crew with pre-configured agents
79
+ const crew = createResearchCrew({
80
+ depth: 'deep',
81
+ includeWriter: true,
82
+ });
83
+
84
+ // Add tasks using templates
85
+ crew.addTask(ResearchTasks.research('electric vehicles', 'deep'));
86
+ crew.addTask(ResearchTasks.writeReport('EV Market Analysis', 'executive'));
87
+
88
+ const result = await crew.kickoff();
89
+ ```
90
+
91
+ ### Workflow Builder
92
+
93
+ ```typescript
94
+ import {
95
+ workflow,
96
+ createDAGExecutor,
97
+ createDAGFromSteps,
98
+ } from '@lov3kaizen/agentsea-crews';
99
+
100
+ const workflowDef = workflow('data-pipeline')
101
+ .addStep('fetch', async (ctx) => {
102
+ // Fetch data
103
+ return { output: 'data', success: true };
104
+ })
105
+ .parallel(
106
+ { name: 'validate', handler: validateFn },
107
+ { name: 'transform', handler: transformFn },
108
+ )
109
+ .when((ctx) => ctx.getVariable('needsReview'))
110
+ .then((b) => b.addStep('review', reviewFn))
111
+ .otherwise((b) => b.addStep('auto-approve', approveFn))
112
+ .endBranch()
113
+ .build();
114
+
115
+ const dag = createDAGFromSteps(workflowDef.steps, workflowDef.handlers);
116
+ const executor = createDAGExecutor(dag, workflowDef.handlers);
117
+ const result = await executor.execute(context);
118
+ ```
119
+
120
+ ## Core Concepts
121
+
122
+ ### Roles & Capabilities
123
+
124
+ Roles define what an agent is and what it can do:
125
+
126
+ ```typescript
127
+ const role: RoleConfig = {
128
+ name: 'Security Analyst',
129
+ description: 'Expert at identifying security vulnerabilities',
130
+ capabilities: [
131
+ { name: 'vulnerability-detection', proficiency: 'expert' },
132
+ { name: 'secure-coding', proficiency: 'advanced' },
133
+ ],
134
+ systemPrompt: 'You are a security expert...',
135
+ goals: ['Identify vulnerabilities', 'Ensure secure code'],
136
+ constraints: ['Flag all security concerns'],
137
+ };
138
+ ```
139
+
140
+ ### Delegation Strategies
141
+
142
+ Choose how tasks are assigned to agents:
143
+
144
+ - **round-robin**: Cycle through agents sequentially
145
+ - **best-match**: Match tasks to agents by capabilities
146
+ - **auction**: Agents bid on tasks based on confidence
147
+ - **hierarchical**: Manager delegates to workers
148
+ - **consensus**: Multi-agent voting for task assignment
149
+
150
+ ```typescript
151
+ const crew = createCrew({
152
+ delegationStrategy: 'consensus',
153
+ // ...
154
+ });
155
+ ```
156
+
157
+ ### Memory Systems
158
+
159
+ Share state and knowledge across agents:
160
+
161
+ ```typescript
162
+ import {
163
+ createSharedMemory,
164
+ createKnowledgeBase,
165
+ } from '@lov3kaizen/agentsea-crews';
166
+
167
+ // Shared memory for crew-wide state
168
+ const memory = createSharedMemory();
169
+ memory.setShared('key', 'value');
170
+
171
+ // Knowledge base for persistent knowledge
172
+ const kb = createKnowledgeBase();
173
+ kb.addFact('title', 'content', ['tag1', 'tag2']);
174
+ const results = kb.search('query');
175
+ ```
176
+
177
+ ### Monitoring
178
+
179
+ Monitor crew execution in real-time:
180
+
181
+ ```typescript
182
+ import { createDashboard, createDebugMode } from '@lov3kaizen/agentsea-crews';
183
+
184
+ // Dashboard for monitoring
185
+ const dashboard = createDashboard(crew);
186
+ dashboard.subscribe((update) => {
187
+ console.log('Progress:', dashboard.getProgress());
188
+ });
189
+
190
+ // Debug mode for step-through debugging
191
+ const debug = createDebugMode(crew);
192
+ debug.setBreakpoint('task:completed');
193
+ debug.enable();
194
+
195
+ const stepResult = await debug.step();
196
+ ```
197
+
198
+ ## Pre-built Templates
199
+
200
+ ### Research Crew
201
+
202
+ ```typescript
203
+ import { createResearchCrew, ResearchTasks } from '@lov3kaizen/agentsea-crews';
204
+
205
+ const crew = createResearchCrew({
206
+ depth: 'standard', // 'shallow' | 'standard' | 'deep'
207
+ });
208
+ ```
209
+
210
+ ### Writing Crew
211
+
212
+ ```typescript
213
+ import { createWritingCrew, WritingTasks } from '@lov3kaizen/agentsea-crews';
214
+
215
+ const crew = createWritingCrew({
216
+ contentType: 'blog', // 'blog' | 'technical' | 'marketing'
217
+ });
218
+ ```
219
+
220
+ ### Code Review Crew
221
+
222
+ ```typescript
223
+ import {
224
+ createCodeReviewCrew,
225
+ CodeReviewTasks,
226
+ } from '@lov3kaizen/agentsea-crews';
227
+
228
+ const crew = createCodeReviewCrew({
229
+ languages: ['typescript', 'python'],
230
+ strictness: 'strict',
231
+ });
232
+ ```
233
+
234
+ ### Customer Support Crew
235
+
236
+ ```typescript
237
+ import {
238
+ createCustomerSupportCrew,
239
+ CustomerSupportTasks,
240
+ } from '@lov3kaizen/agentsea-crews';
241
+
242
+ const crew = createCustomerSupportCrew({
243
+ productName: 'MyApp',
244
+ supportStyle: 'friendly',
245
+ });
246
+ ```
247
+
248
+ ## NestJS Integration
249
+
250
+ ```typescript
251
+ import { Module } from '@nestjs/common';
252
+ import {
253
+ CrewsModule,
254
+ CrewsService,
255
+ InjectCrew,
256
+ OnCrewEvent,
257
+ } from '@lov3kaizen/agentsea-crews/nestjs';
258
+
259
+ @Module({
260
+ imports: [
261
+ CrewsModule.forRoot({
262
+ crews: [myCrewConfig],
263
+ enableMonitoring: true,
264
+ }),
265
+ ],
266
+ })
267
+ export class AppModule {}
268
+
269
+ @Injectable()
270
+ export class MyService {
271
+ constructor(
272
+ private readonly crewsService: CrewsService,
273
+ @InjectCrew('my-crew') private readonly myCrew: Crew,
274
+ ) {}
275
+
276
+ @OnCrewEvent('task:completed')
277
+ handleTaskCompleted(event: CrewEvent) {
278
+ console.log('Task completed:', event);
279
+ }
280
+ }
281
+ ```
282
+
283
+ ## API Reference
284
+
285
+ ### Core Classes
286
+
287
+ - `Crew` - Main orchestrator for multi-agent crews
288
+ - `Role` - Agent role definitions
289
+ - `Task` - Task lifecycle management
290
+ - `TaskQueue` - Priority-based task queue
291
+ - `ExecutionContext` - Shared execution context
292
+
293
+ ### Agents
294
+
295
+ - `CrewAgent` - Enhanced agent with crew capabilities
296
+ - `AgentCapabilities` - Capability matching utilities
297
+ - `AgentRegistry` - Agent discovery and management
298
+
299
+ ### Coordination
300
+
301
+ - `DelegationCoordinator` - Manages delegation strategies
302
+ - `CollaborationManager` - Agent-to-agent communication
303
+ - `ConflictResolver` - Handles disagreements
304
+
305
+ ### Workflows
306
+
307
+ - `WorkflowBuilder` - Fluent API for workflows
308
+ - `DAGExecutor` - DAG execution engine
309
+ - `ParallelExecutor` - Concurrent task execution
310
+ - `CheckpointManager` - Workflow state persistence
311
+
312
+ ### Memory
313
+
314
+ - `SharedMemory` - Crew-wide shared state
315
+ - `ConversationHistory` - Multi-agent conversation tracking
316
+ - `KnowledgeBase` - Persistent knowledge store
317
+
318
+ ### Monitoring
319
+
320
+ - `CrewDashboard` - Real-time monitoring
321
+ - `DebugMode` - Step-through debugging
322
+
323
+ ## License
324
+
325
+ MIT