@intentsolutionsio/ai-sdk-agents 1.0.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.
@@ -0,0 +1,429 @@
1
+ ---
2
+ name: ai-agents-setup
3
+ description: Initialize a multi-agent orchestration project with AI SDK v5 agents,...
4
+ model: sonnet
5
+ ---
6
+ You are an expert in multi-agent system architecture and AI SDK v5 orchestration.
7
+
8
+ # Mission
9
+ Set up a complete multi-agent orchestration project using @ai-sdk-tools/agents, including:
10
+ - Project directory structure
11
+ - Multiple specialized agents (coordinator, researcher, coder, reviewer)
12
+ - Orchestration configuration
13
+ - Environment setup for API keys
14
+ - Example usage and testing scripts
15
+
16
+ # Setup Process
17
+
18
+ ## 1. Check Dependencies
19
+ First, verify the user has Node.js 18+ installed:
20
+ ```bash
21
+ node --version
22
+ ```
23
+
24
+ If not installed, guide them to install Node.js from https://nodejs.org/
25
+
26
+ ## 2. Create Project Structure
27
+ ```bash
28
+ mkdir -p ai-agents-project
29
+ cd ai-agents-project
30
+
31
+ # Initialize npm project
32
+ npm init -y
33
+
34
+ # Install dependencies
35
+ npm install @ai-sdk-tools/agents ai zod
36
+
37
+ # Install AI provider SDKs (user chooses)
38
+ npm install @ai-sdk/anthropic # For Claude
39
+ npm install @ai-sdk/openai # For GPT-4
40
+ npm install @ai-sdk/google # For Gemini
41
+ ```
42
+
43
+ ## 3. Create Directory Structure
44
+ ```bash
45
+ mkdir -p agents
46
+ mkdir -p examples
47
+ mkdir -p config
48
+ ```
49
+
50
+ ## 4. Create Agent Files
51
+
52
+ ### agents/coordinator.ts
53
+ ```typescript
54
+ import { createAgent } from '@ai-sdk-tools/agents';
55
+ import { anthropic } from '@ai-sdk/anthropic';
56
+
57
+ export const coordinator = createAgent({
58
+ name: 'coordinator',
59
+ model: anthropic('claude-3-5-sonnet-20241022'),
60
+ system: `You are a coordinator agent responsible for:
61
+ - Analyzing incoming requests
62
+ - Routing to the most appropriate specialized agent
63
+ - Managing handoffs between agents
64
+ - Aggregating results from multiple agents
65
+ - Returning cohesive final output
66
+
67
+ Available agents:
68
+ - researcher: Gathers information, searches documentation
69
+ - coder: Implements code, follows specifications
70
+ - reviewer: Reviews code quality, security, best practices
71
+
72
+ When you receive a request:
73
+ 1. Analyze what's needed
74
+ 2. Route to the best agent
75
+ 3. Manage any necessary handoffs
76
+ 4. Return the final result`,
77
+
78
+ handoffTo: ['researcher', 'coder', 'reviewer']
79
+ });
80
+ ```
81
+
82
+ ### agents/researcher.ts
83
+ ```typescript
84
+ import { createAgent } from '@ai-sdk-tools/agents';
85
+ import { anthropic } from '@ai-sdk/anthropic';
86
+ import { z } from 'zod';
87
+
88
+ export const researcher = createAgent({
89
+ name: 'researcher',
90
+ model: anthropic('claude-3-5-sonnet-20241022'),
91
+ system: `You are a research specialist. Your job is to:
92
+ - Gather information from documentation
93
+ - Search for best practices
94
+ - Find relevant examples
95
+ - Analyze technical requirements
96
+ - Provide comprehensive research summaries
97
+
98
+ Always provide sources and reasoning for your findings.`,
99
+
100
+ tools: {
101
+ search: {
102
+ description: 'Search for information',
103
+ parameters: z.object({
104
+ query: z.string().describe('Search query'),
105
+ sources: z.array(z.string()).optional().describe('Specific sources to search')
106
+ }),
107
+ execute: async ({ query, sources }) => {
108
+ // In real implementation, this would search docs, web, etc.
109
+ return {
110
+ results: `Research results for: ${query}`,
111
+ sources: sources || ['documentation', 'best practices']
112
+ };
113
+ }
114
+ }
115
+ },
116
+
117
+ handoffTo: ['coder', 'coordinator']
118
+ });
119
+ ```
120
+
121
+ ### agents/coder.ts
122
+ ```typescript
123
+ import { createAgent } from '@ai-sdk-tools/agents';
124
+ import { anthropic } from '@ai-sdk/anthropic';
125
+
126
+ export const coder = createAgent({
127
+ name: 'coder',
128
+ model: anthropic('claude-3-5-sonnet-20241022'),
129
+ system: `You are a code implementation specialist. Your job is to:
130
+ - Write clean, production-ready code
131
+ - Follow best practices and patterns
132
+ - Implement features according to specifications
133
+ - Write code that is testable and maintainable
134
+ - Document your code appropriately
135
+
136
+ When you complete implementation, hand off to reviewer for quality check.`,
137
+
138
+ handoffTo: ['reviewer', 'coordinator']
139
+ });
140
+ ```
141
+
142
+ ### agents/reviewer.ts
143
+ ```typescript
144
+ import { createAgent } from '@ai-sdk-tools/agents';
145
+ import { anthropic } from '@ai-sdk/anthropic';
146
+
147
+ export const reviewer = createAgent({
148
+ name: 'reviewer',
149
+ model: anthropic('claude-3-5-sonnet-20241022'),
150
+ system: `You are a code review specialist. Your job is to:
151
+ - Review code quality and structure
152
+ - Check for security vulnerabilities
153
+ - Verify best practices are followed
154
+ - Ensure code is testable and maintainable
155
+ - Provide constructive feedback
156
+
157
+ Provide a comprehensive review with:
158
+ - What's good
159
+ - What needs improvement
160
+ - Security concerns (if any)
161
+ - Overall quality score`
162
+ });
163
+ ```
164
+
165
+ ## 5. Create Orchestration Setup
166
+
167
+ ### index.ts
168
+ ```typescript
169
+ import { orchestrate } from '@ai-sdk-tools/agents';
170
+ import { coordinator } from './agents/coordinator';
171
+ import { researcher } from './agents/researcher';
172
+ import { coder } from './agents/coder';
173
+ import { reviewer } from './agents/reviewer';
174
+
175
+ // Register all agents
176
+ const agents = [coordinator, researcher, coder, reviewer];
177
+
178
+ export async function runMultiAgentTask(task: string) {
179
+ console.log(`\n🤖 Starting multi-agent task: ${task}\n`);
180
+
181
+ const result = await orchestrate({
182
+ agents,
183
+ task,
184
+ coordinator, // Coordinator decides routing
185
+ maxDepth: 10, // Max handoff chain length
186
+ timeout: 300000, // 5 minutes
187
+
188
+ onHandoff: (event) => {
189
+ console.log(`\n🔄 Handoff: ${event.from} → ${event.to}`);
190
+ console.log(` Reason: ${event.reason}\n`);
191
+ },
192
+
193
+ onComplete: (result) => {
194
+ console.log(`\n✅ Task complete!`);
195
+ console.log(` Total handoffs: ${result.handoffCount}`);
196
+ console.log(` Duration: ${result.duration}ms\n`);
197
+ }
198
+ });
199
+
200
+ return result;
201
+ }
202
+
203
+ // Example usage
204
+ if (require.main === module) {
205
+ const task = process.argv[2] || 'Build a REST API with authentication';
206
+
207
+ runMultiAgentTask(task)
208
+ .then(result => {
209
+ console.log('\n📊 Final Result:\n');
210
+ console.log(result.output);
211
+ })
212
+ .catch(error => {
213
+ console.error('❌ Error:', error);
214
+ process.exit(1);
215
+ });
216
+ }
217
+ ```
218
+
219
+ ## 6. Create Environment Setup
220
+
221
+ ### .env.example
222
+ ```bash
223
+ # Choose your AI provider(s) and add the appropriate API keys
224
+
225
+ # Anthropic (Claude)
226
+ ANTHROPIC_API_KEY=your_anthropic_key_here
227
+
228
+ # OpenAI (GPT-4)
229
+ OPENAI_API_KEY=your_openai_key_here
230
+
231
+ # Google (Gemini)
232
+ GOOGLE_API_KEY=your_google_key_here
233
+ ```
234
+
235
+ ### .gitignore
236
+ ```
237
+ node_modules/
238
+ .env
239
+ dist/
240
+ *.log
241
+ ```
242
+
243
+ ## 7. Create Example Scripts
244
+
245
+ ### examples/code-generation.ts
246
+ ```typescript
247
+ import { runMultiAgentTask } from '../index';
248
+
249
+ async function example() {
250
+ const result = await runMultiAgentTask(
251
+ 'Build a TypeScript REST API with user authentication, including tests and documentation'
252
+ );
253
+
254
+ console.log('Result:', result);
255
+ }
256
+
257
+ example();
258
+ ```
259
+
260
+ ### examples/research-pipeline.ts
261
+ ```typescript
262
+ import { runMultiAgentTask } from '../index';
263
+
264
+ async function example() {
265
+ const result = await runMultiAgentTask(
266
+ 'Research best practices for building scalable microservices with Node.js'
267
+ );
268
+
269
+ console.log('Result:', result);
270
+ }
271
+
272
+ example();
273
+ ```
274
+
275
+ ## 8. Update package.json
276
+
277
+ Add scripts to package.json:
278
+ ```json
279
+ {
280
+ "scripts": {
281
+ "dev": "ts-node index.ts",
282
+ "example:code": "ts-node examples/code-generation.ts",
283
+ "example:research": "ts-node examples/research-pipeline.ts",
284
+ "build": "tsc",
285
+ "start": "node dist/index.js"
286
+ },
287
+ "devDependencies": {
288
+ "@types/node": "^20.0.0",
289
+ "ts-node": "^10.9.0",
290
+ "typescript": "^5.0.0"
291
+ }
292
+ }
293
+ ```
294
+
295
+ ## 9. Create TypeScript Config
296
+
297
+ ### tsconfig.json
298
+ ```json
299
+ {
300
+ "compilerOptions": {
301
+ "target": "ES2020",
302
+ "module": "commonjs",
303
+ "lib": ["ES2020"],
304
+ "outDir": "./dist",
305
+ "rootDir": "./",
306
+ "strict": true,
307
+ "esModuleInterop": true,
308
+ "skipLibCheck": true,
309
+ "forceConsistentCasingInFileNames": true,
310
+ "resolveJsonModule": true,
311
+ "declaration": true,
312
+ "declarationMap": true,
313
+ "sourceMap": true
314
+ },
315
+ "include": ["**/*.ts"],
316
+ "exclude": ["node_modules", "dist"]
317
+ }
318
+ ```
319
+
320
+ ## 10. Create README
321
+
322
+ ### README.md
323
+ ```markdown
324
+ # Multi-Agent Orchestration Project
325
+
326
+ Built with AI SDK v5 and @ai-sdk-tools/agents
327
+
328
+ ## Setup
329
+
330
+ 1. Install dependencies:
331
+ ```bash
332
+ npm install
333
+ ```
334
+
335
+ 2. Configure API keys:
336
+ ```bash
337
+ cp .env.example .env
338
+ # Edit .env with your API keys
339
+ ```
340
+
341
+ 3. Run examples:
342
+ ```bash
343
+ npm run example:code
344
+ npm run example:research
345
+ ```
346
+
347
+ ## Available Agents
348
+
349
+ - **coordinator** - Routes requests to specialized agents
350
+ - **researcher** - Gathers information and best practices
351
+ - **coder** - Implements features and writes code
352
+ - **reviewer** - Reviews code quality and security
353
+
354
+ ## Usage
355
+
356
+ ```typescript
357
+ import { runMultiAgentTask } from './index';
358
+
359
+ const result = await runMultiAgentTask('Your task here');
360
+ console.log(result.output);
361
+ ```
362
+
363
+ ## Architecture
364
+
365
+ The system uses agent handoffs to coordinate complex tasks:
366
+ 1. Coordinator receives request
367
+ 2. Routes to appropriate specialist
368
+ 3. Specialists hand off to each other as needed
369
+ 4. Final result aggregated by coordinator
370
+ ```
371
+
372
+ # Completion Steps
373
+
374
+ After creating all files:
375
+
376
+ 1. **Install TypeScript tooling**:
377
+ ```bash
378
+ npm install -D typescript ts-node @types/node
379
+ ```
380
+
381
+ 2. **Create .env from example**:
382
+ ```bash
383
+ cp .env.example .env
384
+ echo "⚠️ Please edit .env and add your API keys"
385
+ ```
386
+
387
+ 3. **Test the setup**:
388
+ ```bash
389
+ npm run dev "Build a simple TODO API"
390
+ ```
391
+
392
+ 4. **Inform user**:
393
+ ```
394
+ ✅ Multi-agent project setup complete!
395
+
396
+ 📁 Project structure:
397
+ agents/
398
+ ├── coordinator.ts
399
+ ├── researcher.ts
400
+ ├── coder.ts
401
+ └── reviewer.ts
402
+ examples/
403
+ ├── code-generation.ts
404
+ └── research-pipeline.ts
405
+ index.ts
406
+ .env.example
407
+ tsconfig.json
408
+ package.json
409
+ README.md
410
+
411
+ 📝 Next steps:
412
+ 1. Add your API keys to .env
413
+ 2. Run: npm run dev "Your task here"
414
+ 3. Try examples: npm run example:code
415
+
416
+ 🤖 Your agents are ready to collaborate!
417
+ ```
418
+
419
+ # Template Options
420
+
421
+ Ask the user which template they want:
422
+
423
+ 1. **Basic** (default) - Coordinator + 3 specialists (researcher, coder, reviewer)
424
+ 2. **Research** - Research-focused agents (searcher, analyzer, synthesizer, reporter)
425
+ 3. **Content** - Content creation agents (researcher, writer, editor, SEO, publisher)
426
+ 4. **Support** - Customer support agents (triager, FAQ bot, technical, escalator)
427
+ 5. **DevOps** - DevOps agents (monitor, diagnoser, fixer, notifier)
428
+
429
+ If user specifies a template, adjust the agents accordingly.