dank-ai 1.0.0 → 1.0.2

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/cli/init.js CHANGED
@@ -8,9 +8,54 @@ const chalk = require('chalk');
8
8
  const { DankProject } = require('../project');
9
9
 
10
10
  async function initCommand(projectName, options) {
11
- const name = projectName || path.basename(process.cwd());
11
+ let name = projectName;
12
+ let npmProjectName = projectName;
12
13
 
13
- console.log(chalk.yellow(`šŸš€ Initializing Dank project: ${name}\\n`));
14
+ // If no project name provided, prompt for both directory name and npm project name
15
+ if (!name) {
16
+ const inquirer = await import('inquirer');
17
+ const answers = await inquirer.default.prompt([
18
+ {
19
+ type: 'input',
20
+ name: 'projectName',
21
+ message: 'What should the project directory be named?',
22
+ default: path.basename(process.cwd()),
23
+ validate: (input) => {
24
+ if (!input.trim()) {
25
+ return 'Project name is required';
26
+ }
27
+ if (!/^[a-zA-Z0-9-_]+$/.test(input)) {
28
+ return 'Project name can only contain letters, numbers, hyphens, and underscores';
29
+ }
30
+ return true;
31
+ }
32
+ },
33
+ {
34
+ type: 'input',
35
+ name: 'npmProjectName',
36
+ message: 'What should the npm package name be?',
37
+ default: (answers) => answers.projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-'),
38
+ validate: (input) => {
39
+ if (!input.trim()) {
40
+ return 'NPM project name is required';
41
+ }
42
+ if (!/^[a-z0-9-]+$/.test(input)) {
43
+ return 'NPM project name can only contain lowercase letters, numbers, and hyphens';
44
+ }
45
+ return true;
46
+ }
47
+ }
48
+ ]);
49
+
50
+ name = answers.projectName;
51
+ npmProjectName = answers.npmProjectName;
52
+ } else {
53
+ // If project name provided, use it for both directory and npm name
54
+ npmProjectName = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
55
+ }
56
+
57
+ console.log(chalk.yellow(`šŸš€ Initializing Dank project: ${name}`));
58
+ console.log(chalk.cyan(`šŸ“¦ NPM package name: ${npmProjectName}\n`));
14
59
 
15
60
  try {
16
61
  // Create project instance
@@ -22,12 +67,25 @@ async function initCommand(projectName, options) {
22
67
  // Initialize project structure
23
68
  await project.init();
24
69
 
25
- console.log(chalk.green('\\nāœ… Project initialized successfully!'));
26
- console.log(chalk.cyan('\\nNext steps:'));
27
- console.log(chalk.gray(' 1. Set your API keys in environment variables'));
28
- console.log(chalk.gray(' 2. Edit dank.config.js to configure your agents'));
29
- console.log(chalk.gray(' 3. Run "dank run" to start your agents'));
30
- console.log(chalk.gray('\\nFor more information, visit: https://github.com/your-org/dank'));
70
+ // Create package.json
71
+ await createPackageJson(npmProjectName, project.projectPath);
72
+
73
+ // Create .env.example file
74
+ await createEnvExample(project.projectPath);
75
+
76
+ // Create .gitignore
77
+ await createGitignore(project.projectPath);
78
+
79
+ // Create README.md
80
+ await createReadme(name, project.projectPath);
81
+
82
+ console.log(chalk.green('\nāœ… Project initialized successfully!'));
83
+ console.log(chalk.cyan('\nNext steps:'));
84
+ console.log(chalk.gray(' 1. Copy .env.example to .env and set your API keys'));
85
+ console.log(chalk.gray(' 2. Run "npm install" to install dependencies'));
86
+ console.log(chalk.gray(' 3. Edit dank.config.js to configure your agents'));
87
+ console.log(chalk.gray(' 4. Run "dank run" to start your agents'));
88
+ console.log(chalk.gray('\nFor more information, visit: https://github.com/your-org/dank'));
31
89
 
32
90
  } catch (error) {
33
91
  console.error(chalk.red('āŒ Initialization failed:'), error.message);
@@ -35,4 +93,273 @@ async function initCommand(projectName, options) {
35
93
  }
36
94
  }
37
95
 
96
+ /**
97
+ * Create package.json for the new project
98
+ */
99
+ async function createPackageJson(npmProjectName, projectPath) {
100
+ const packageJson = {
101
+ name: npmProjectName,
102
+ version: '1.0.0',
103
+ description: `Dank AI agents for ${npmProjectName}`,
104
+ main: 'dank.config.js',
105
+ scripts: {
106
+ start: 'dank run',
107
+ dev: 'dank run --config dank.config.js',
108
+ stop: 'dank stop',
109
+ status: 'dank status',
110
+ logs: 'dank logs',
111
+ build: 'dank build',
112
+ clean: 'dank clean'
113
+ },
114
+ dependencies: {
115
+ 'dank-ai': '^1.0.0'
116
+ },
117
+ keywords: ['dank', 'ai', 'agents', 'automation', 'llm'],
118
+ author: '',
119
+ license: 'ISC',
120
+ engines: {
121
+ node: '>=16.0.0',
122
+ npm: '>=8.0.0'
123
+ }
124
+ };
125
+
126
+ const packagePath = path.join(projectPath, 'package.json');
127
+ await fs.writeFile(packagePath, JSON.stringify(packageJson, null, 2), 'utf8');
128
+ console.log(chalk.green(`Created package.json: ${packagePath}`));
129
+ }
130
+
131
+ /**
132
+ * Create .env.example file
133
+ */
134
+ async function createEnvExample(projectPath) {
135
+ const envExample = `# Dank AI Agent Environment Variables
136
+ # Copy this file to .env and fill in your API keys
137
+
138
+ # OpenAI Configuration
139
+ OPENAI_API_KEY=your_openai_api_key_here
140
+ OPENAI_MODEL=gpt-3.5-turbo
141
+
142
+ # Anthropic Configuration (optional)
143
+ ANTHROPIC_API_KEY=your_anthropic_api_key_here
144
+ ANTHROPIC_MODEL=claude-3-sonnet-20240229
145
+
146
+ # Google AI Configuration (optional)
147
+ GOOGLE_AI_API_KEY=your_google_ai_api_key_here
148
+ GOOGLE_AI_MODEL=gemini-pro
149
+
150
+ # Agent Configuration
151
+ DANK_LOG_LEVEL=info
152
+ DANK_MAX_CONCURRENT_AGENTS=3
153
+
154
+ # Docker Configuration (optional)
155
+ DOCKER_REGISTRY=your_registry_here
156
+ DOCKER_NAMESPACE=your_namespace_here
157
+ `;
158
+
159
+ const envPath = path.join(projectPath, '.env.example');
160
+ await fs.writeFile(envPath, envExample, 'utf8');
161
+ console.log(chalk.green(`Created .env.example: ${envPath}`));
162
+ }
163
+
164
+ /**
165
+ * Create .gitignore file
166
+ */
167
+ async function createGitignore(projectPath) {
168
+ const gitignore = `# Dependencies
169
+ node_modules/
170
+ npm-debug.log*
171
+ yarn-debug.log*
172
+ yarn-error.log*
173
+
174
+ # Environment variables
175
+ .env
176
+ .env.local
177
+ .env.development.local
178
+ .env.test.local
179
+ .env.production.local
180
+
181
+ # Dank Framework specific
182
+ .dank/
183
+ agent-code/
184
+ build-contexts/
185
+ dank-agent-*
186
+ container-logs/
187
+ agent-logs/
188
+ conversation-data/
189
+ *.agent.js
190
+
191
+ # Docker
192
+ .dockerignore
193
+ *.dockerignore
194
+
195
+ # macOS
196
+ .DS_Store
197
+
198
+ # Windows
199
+ Thumbs.db
200
+ ehthumbs.db
201
+ *.stackdump
202
+
203
+ # IDEs
204
+ .vscode/
205
+ .idea/
206
+ *.sublime-project
207
+ *.sublime-workspace
208
+
209
+ # Logs
210
+ logs/
211
+ *.log
212
+
213
+ # Runtime data
214
+ pids
215
+ *.pid
216
+ *.seed
217
+ *.pid.lock
218
+
219
+ # Coverage directory
220
+ coverage/
221
+ *.lcov
222
+
223
+ # nyc test coverage
224
+ .nyc_output
225
+
226
+ # Dependency directories
227
+ jspm_packages/
228
+
229
+ # Optional npm cache directory
230
+ .npm
231
+
232
+ # Optional eslint cache
233
+ .eslintcache
234
+
235
+ # Output of 'npm pack'
236
+ *.tgz
237
+
238
+ # Yarn Integrity file
239
+ .yarn-integrity
240
+ `;
241
+
242
+ const gitignorePath = path.join(projectPath, '.gitignore');
243
+ await fs.writeFile(gitignorePath, gitignore, 'utf8');
244
+ console.log(chalk.green(`Created .gitignore: ${gitignorePath}`));
245
+ }
246
+
247
+ /**
248
+ * Create README.md for the project
249
+ */
250
+ async function createReadme(projectName, projectPath) {
251
+ const readme = `# ${projectName}
252
+
253
+ A Dank AI agent project with modern event handling and Docker orchestration.
254
+
255
+ ## Features
256
+
257
+ - šŸ¤– **AI Agents**: Powered by multiple LLM providers (OpenAI, Anthropic, Google AI)
258
+ - 🐳 **Docker Integration**: Containerized agents with automatic management
259
+ - šŸ“” **Event System**: Real-time event handling for prompts, responses, and tools
260
+ - šŸ”§ **Auto-Detection**: Automatically enables features based on usage
261
+ - šŸ“Š **Monitoring**: Built-in logging and status monitoring
262
+
263
+ ## Quick Start
264
+
265
+ 1. **Install dependencies:**
266
+ \`\`\`bash
267
+ npm install
268
+ \`\`\`
269
+
270
+ 2. **Set up environment:**
271
+ \`\`\`bash
272
+ cp .env.example .env
273
+ # Edit .env with your API keys
274
+ \`\`\`
275
+
276
+ 3. **Configure your agents:**
277
+ Edit \`dank.config.js\` to define your agents and their capabilities.
278
+
279
+ 4. **Start your agents:**
280
+ \`\`\`bash
281
+ npm start
282
+ # or
283
+ dank run
284
+ \`\`\`
285
+
286
+ ## Available Commands
287
+
288
+ - \`npm start\` - Start all agents
289
+ - \`npm run dev\` - Start in development mode
290
+ - \`npm run stop\` - Stop all agents
291
+ - \`npm run status\` - Check agent status
292
+ - \`npm run logs\` - View agent logs
293
+ - \`npm run build\` - Build agent images
294
+ - \`npm run clean\` - Clean up containers and images
295
+
296
+ ## Event Handlers
297
+
298
+ This project includes examples of the three main event types:
299
+
300
+ ### 1. Direct Prompting Events (\`request_output\`)
301
+ Handle LLM interactions and modify prompts/responses:
302
+
303
+ \`\`\`javascript
304
+ .addHandler('request_output:start', (data) => {
305
+ // Modify the prompt before sending to LLM
306
+ return { prompt: \`Enhanced: \${data.prompt}\` };
307
+ })
308
+
309
+ .addHandler('request_output:end', (data) => {
310
+ // Modify the response before sending back
311
+ return { response: \`\${data.response} [Enhanced by Dank]\` };
312
+ })
313
+ \`\`\`
314
+
315
+ ### 2. HTTP API Events (\`tool:http-server\`)
316
+ Handle HTTP requests and responses:
317
+
318
+ \`\`\`javascript
319
+ .addHandler('tool:http-server:call', (data) => {
320
+ console.log('HTTP request received:', data.method, data.path);
321
+ })
322
+
323
+ .addHandler('tool:http-server:response', (data) => {
324
+ console.log('HTTP response sent:', data.statusCode);
325
+ })
326
+ \`\`\`
327
+
328
+ ### 3. System Events
329
+ Handle agent lifecycle and errors:
330
+
331
+ \`\`\`javascript
332
+ .addHandler('output', (data) => {
333
+ console.log('Agent output:', data);
334
+ })
335
+
336
+ .addHandler('error', (error) => {
337
+ console.error('Agent error:', error);
338
+ })
339
+ \`\`\`
340
+
341
+ ## Configuration
342
+
343
+ Edit \`dank.config.js\` to:
344
+
345
+ - Define your agents and their capabilities
346
+ - Set up LLM providers and models
347
+ - Configure event handlers
348
+ - Set Docker and resource limits
349
+ - Enable/disable communication features
350
+
351
+ ## Documentation
352
+
353
+ For more information, visit the [Dank Framework Documentation](https://github.com/your-org/dank).
354
+
355
+ ## License
356
+
357
+ ISC
358
+ `;
359
+
360
+ const readmePath = path.join(projectPath, 'README.md');
361
+ await fs.writeFile(readmePath, readme, 'utf8');
362
+ console.log(chalk.green(`Created README.md: ${readmePath}`));
363
+ }
364
+
38
365
  module.exports = { initCommand };
package/lib/project.js CHANGED
@@ -206,22 +206,198 @@ module.exports = {
206
206
 
207
207
  // Define your agents
208
208
  agents: [
209
- createAgent('example-agent')
209
+ // Example 1: Direct Prompting Agent with Event Handlers
210
+ createAgent('prompt-agent')
210
211
  .setLLM('openai', {
211
212
  apiKey: process.env.OPENAI_API_KEY,
212
213
  model: 'gpt-3.5-turbo',
213
214
  temperature: 0.7
214
215
  })
215
- .setPrompt('You are a helpful assistant that responds with enthusiasm!')
216
+ .setPrompt('You are a helpful AI assistant. Be concise and friendly in your responses.')
217
+ .setBaseImage('nodejs-20')
218
+ .setPromptingServer({
219
+ protocol: 'http',
220
+ port: 3000
221
+ })
216
222
  .setResources({
217
223
  memory: '512m',
218
224
  cpu: 1
219
225
  })
226
+ // Event handlers for prompt modification and response enhancement
227
+ .addHandler('request_output:start', (data) => {
228
+ console.log('[Prompt Agent] Processing prompt:', data.conversationId);
229
+ console.log('[Prompt Agent] Original prompt:', data.prompt);
230
+
231
+ // Enhance the prompt with context
232
+ const enhancedPrompt = \`Context: You are a helpful AI assistant. Please be concise and friendly.\\n\\nUser Question: \${data.prompt}\\n\\nPlease provide a clear, helpful response.\`;
233
+
234
+ console.log('[Prompt Agent] Enhanced prompt:', enhancedPrompt);
235
+
236
+ return {
237
+ prompt: enhancedPrompt
238
+ };
239
+ })
240
+ .addHandler('request_output', (data) => {
241
+ console.log('[Prompt Agent] LLM Response:', {
242
+ prompt: data.prompt,
243
+ finalPrompt: data.finalPrompt,
244
+ promptModified: data.promptModified,
245
+ response: data.response,
246
+ conversationId: data.conversationId,
247
+ processingTime: data.processingTime,
248
+ usage: data.usage,
249
+ model: data.model
250
+ });
251
+ })
252
+ .addHandler('request_output:end', (data) => {
253
+ console.log('[Prompt Agent] Completed in:', data.processingTime + 'ms');
254
+ console.log('[Prompt Agent] Original response:', data.response ? data.response.substring(0, 50) + '...' : 'N/A');
255
+
256
+ // Enhance the response with metadata
257
+ const enhancedResponse = \`\${data.response}\\n\\n---\\nšŸ¤– Generated by Dank Framework Agent\\nā±ļø Processing time: \${data.processingTime}ms\\n\`;
258
+
259
+ console.log('[Prompt Agent] Enhanced response:', enhancedResponse.substring(0, 100) + '...');
260
+
261
+ return {
262
+ response: enhancedResponse
263
+ };
264
+ })
265
+ .addHandler('request_output:error', (data) => {
266
+ console.error('[Prompt Agent] Error processing prompt:', data.error);
267
+ })
268
+ .addHandler('output', (data) => {
269
+ console.log('[Prompt Agent] System output:', data);
270
+ })
271
+ .addHandler('error', (error) => {
272
+ console.error('[Prompt Agent] System error:', error);
273
+ }),
274
+
275
+ // Example 2: HTTP API Agent with Tool Events
276
+ createAgent('api-agent')
277
+ .setLLM('openai', {
278
+ apiKey: process.env.OPENAI_API_KEY,
279
+ model: 'gpt-4',
280
+ temperature: 0.3
281
+ })
282
+ .setPrompt('You are a specialized API assistant that helps with data processing and analysis.')
283
+ .setBaseImage('nodejs-20')
284
+ .setPromptingServer({
285
+ protocol: 'http',
286
+ port: 3001
287
+ })
288
+ .setResources({
289
+ memory: '1g',
290
+ cpu: 2
291
+ })
292
+ // HTTP API routes
293
+ .get('/health', (req, res) => {
294
+ res.json({ status: 'healthy', timestamp: new Date().toISOString() });
295
+ })
296
+ .post('/analyze', (req, res) => {
297
+ res.json({
298
+ message: 'Data analysis endpoint',
299
+ data: req.body,
300
+ timestamp: new Date().toISOString()
301
+ });
302
+ })
303
+ .get('/status', (req, res) => {
304
+ res.json({
305
+ agent: 'api-agent',
306
+ status: 'running',
307
+ uptime: process.uptime()
308
+ });
309
+ })
310
+ // Tool event handlers for HTTP requests
311
+ .addHandler('tool:http-server:call', (data) => {
312
+ console.log('[API Agent] HTTP Request:', {
313
+ method: data.method,
314
+ path: data.path,
315
+ headers: data.headers,
316
+ body: data.body,
317
+ timestamp: data.timestamp
318
+ });
319
+ })
320
+ .addHandler('tool:http-server:response', (data) => {
321
+ console.log('[API Agent] HTTP Response:', {
322
+ statusCode: data.statusCode,
323
+ headers: data.headers,
324
+ body: data.body,
325
+ processingTime: data.processingTime,
326
+ timestamp: data.timestamp
327
+ });
328
+ })
329
+ .addHandler('tool:http-server:error', (data) => {
330
+ console.error('[API Agent] HTTP Error:', {
331
+ error: data.error,
332
+ method: data.method,
333
+ path: data.path,
334
+ timestamp: data.timestamp
335
+ });
336
+ })
337
+ .addHandler('output', (data) => {
338
+ console.log('[API Agent] System output:', data);
339
+ })
340
+ .addHandler('error', (error) => {
341
+ console.error('[API Agent] System error:', error);
342
+ }),
343
+
344
+ // Example 3: Multi-Modal Agent with All Features
345
+ createAgent('multi-agent')
346
+ .setLLM('openai', {
347
+ apiKey: process.env.OPENAI_API_KEY,
348
+ model: 'gpt-4',
349
+ temperature: 0.5
350
+ })
351
+ .setPrompt('You are a versatile AI assistant that can handle both direct prompts and API requests. You excel at creative tasks and problem-solving.')
352
+ .setBaseImage('nodejs-20')
353
+ .setPromptingServer({
354
+ protocol: 'http',
355
+ port: 3002
356
+ })
357
+ .setResources({
358
+ memory: '2g',
359
+ cpu: 2
360
+ })
361
+ // HTTP API routes
362
+ .get('/creative', (req, res) => {
363
+ res.json({
364
+ message: 'Creative writing endpoint',
365
+ timestamp: new Date().toISOString()
366
+ });
367
+ })
368
+ .post('/solve', (req, res) => {
369
+ res.json({
370
+ message: 'Problem solving endpoint',
371
+ data: req.body,
372
+ timestamp: new Date().toISOString()
373
+ });
374
+ })
375
+ // Comprehensive event handling
376
+ .addHandler('request_output:start', (data) => {
377
+ console.log('[Multi Agent] Processing request:', data.conversationId);
378
+ return {
379
+ prompt: \`[Multi-Modal Assistant] \${data.prompt}\\n\\nPlease provide a comprehensive and creative response.\`
380
+ };
381
+ })
382
+ .addHandler('request_output:end', (data) => {
383
+ console.log('[Multi Agent] Response completed in:', data.processingTime + 'ms');
384
+ return {
385
+ response: \`\${data.response}\\n\\n✨ Enhanced by Multi-Modal Dank Agent\`
386
+ };
387
+ })
388
+ .addHandler('tool:http-server:*', (data) => {
389
+ console.log('[Multi Agent] HTTP Activity:', {
390
+ type: data.type,
391
+ method: data.method,
392
+ path: data.path,
393
+ timestamp: data.timestamp
394
+ });
395
+ })
220
396
  .addHandler('output', (data) => {
221
- console.log('Agent output:', data);
397
+ console.log('[Multi Agent] System output:', data);
222
398
  })
223
399
  .addHandler('error', (error) => {
224
- console.error('Agent error:', error);
400
+ console.error('[Multi Agent] System error:', error);
225
401
  })
226
402
  ]
227
403
  };
@@ -235,7 +411,7 @@ module.exports = {
235
411
  return `/**
236
412
  * Example Dank Agent
237
413
  *
238
- * This is an example of how to define a Dank agent.
414
+ * This is an example of how to define a Dank agent with modern event handling.
239
415
  * You can create multiple agent files and import them in your config.
240
416
  */
241
417
 
@@ -244,32 +420,95 @@ const { createAgent } = require('dank');
244
420
  const exampleAgent = createAgent('example-agent')
245
421
  .setLLM('openai', {
246
422
  apiKey: process.env.OPENAI_API_KEY,
247
- model: 'gpt-3.5-turbo'
423
+ model: 'gpt-3.5-turbo',
424
+ temperature: 0.7
248
425
  })
249
426
  .setPrompt(\`
250
427
  You are a helpful AI assistant with the following capabilities:
251
428
  - Answer questions clearly and concisely
252
429
  - Provide code examples when appropriate
253
430
  - Be friendly and professional
431
+ - Help with problem-solving and creative tasks
254
432
  \`)
433
+ .setBaseImage('nodejs-20')
434
+ .setPromptingServer({
435
+ protocol: 'http',
436
+ port: 3000
437
+ })
255
438
  .setResources({
256
439
  memory: '512m',
257
440
  cpu: 1,
258
441
  timeout: 30000
259
442
  })
260
- .addHandlers({
261
- output: (data) => {
262
- console.log(\`[\${new Date().toISOString()}] Agent output:\`, data);
263
- },
264
- error: (error) => {
265
- console.error(\`[\${new Date().toISOString()}] Agent error:\`, error);
266
- },
267
- start: () => {
268
- console.log('Agent started successfully');
269
- },
270
- stop: () => {
271
- console.log('Agent stopped');
272
- }
443
+ // HTTP API routes
444
+ .get('/info', (req, res) => {
445
+ res.json({
446
+ agent: 'example-agent',
447
+ status: 'running',
448
+ capabilities: ['direct-prompting', 'http-api'],
449
+ timestamp: new Date().toISOString()
450
+ });
451
+ })
452
+ .post('/chat', (req, res) => {
453
+ res.json({
454
+ message: 'Chat endpoint ready',
455
+ data: req.body,
456
+ timestamp: new Date().toISOString()
457
+ });
458
+ })
459
+ // Event handlers for prompt processing
460
+ .addHandler('request_output:start', (data) => {
461
+ console.log(\`[\${new Date().toISOString()}] Processing prompt:\`, data.conversationId);
462
+ console.log('Original prompt:', data.prompt);
463
+
464
+ // Enhance the prompt
465
+ const enhancedPrompt = \`[Enhanced] \${data.prompt}\\n\\nPlease provide a helpful and detailed response.\`;
466
+
467
+ return {
468
+ prompt: enhancedPrompt
469
+ };
470
+ })
471
+ .addHandler('request_output', (data) => {
472
+ console.log(\`[\${new Date().toISOString()}] LLM Response:\`, {
473
+ conversationId: data.conversationId,
474
+ promptModified: data.promptModified,
475
+ processingTime: data.processingTime,
476
+ model: data.model
477
+ });
478
+ })
479
+ .addHandler('request_output:end', (data) => {
480
+ console.log(\`[\${new Date().toISOString()}] Response completed in:\`, data.processingTime + 'ms');
481
+
482
+ // Enhance the response
483
+ const enhancedResponse = \`\${data.response}\\n\\n---\\nšŸ¤– Powered by Dank Framework\`;
484
+
485
+ return {
486
+ response: enhancedResponse
487
+ };
488
+ })
489
+ .addHandler('request_output:error', (data) => {
490
+ console.error(\`[\${new Date().toISOString()}] Error processing prompt:\`, data.error);
491
+ })
492
+ // HTTP tool event handlers
493
+ .addHandler('tool:http-server:call', (data) => {
494
+ console.log(\`[\${new Date().toISOString()}] HTTP Request:\`, {
495
+ method: data.method,
496
+ path: data.path,
497
+ body: data.body
498
+ });
499
+ })
500
+ .addHandler('tool:http-server:response', (data) => {
501
+ console.log(\`[\${new Date().toISOString()}] HTTP Response:\`, {
502
+ statusCode: data.statusCode,
503
+ processingTime: data.processingTime
504
+ });
505
+ })
506
+ // System event handlers
507
+ .addHandler('output', (data) => {
508
+ console.log(\`[\${new Date().toISOString()}] Agent output:\`, data);
509
+ })
510
+ .addHandler('error', (error) => {
511
+ console.error(\`[\${new Date().toISOString()}] Agent error:\`, error);
273
512
  });
274
513
 
275
514
  module.exports = exampleAgent;