dank-ai 1.0.34 → 1.0.36
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/README.md +38 -148
- package/docker/entrypoint.js +568 -67
- package/lib/agent.js +3 -29
- package/lib/cli/build.js +1 -1
- package/lib/cli/clean.js +1 -0
- package/lib/cli/init.js +2 -1
- package/lib/cli/production-build.js +5 -1
- package/lib/cli/run.js +6 -1
- package/lib/cli/stop.js +1 -0
- package/lib/docker/manager.js +86 -7
- package/lib/project.js +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
Dank is a powerful Node.js service that allows you to define, deploy, and manage AI agents using Docker containers. Each agent runs in its own isolated environment with configurable resources, LLM providers, and custom handlers. Built for production with comprehensive CI/CD support and Docker registry integration.
|
|
10
10
|
|
|
11
11
|
🌐 **Website**: [https://dank-ai.xyz](https://dank-ai.xyz)
|
|
12
|
-
📦 **NPM Package**: [https://www.npmjs.com/package/dank-ai](https://www.npmjs.com/package/dank-ai)
|
|
12
|
+
📦 **NPM Package**: [https://www.npmjs.com/package/dank-ai](https://www.npmjs.com/package/dank-ai)
|
|
13
|
+
☁️ **Cloud Deployment**: [https://cloud.dank-ai.xyz](https://cloud.dank-ai.xyz) - **Serverless for AI Agents**
|
|
14
|
+
|
|
15
|
+
## ☁️ Deploy to the Cloud
|
|
16
|
+
|
|
17
|
+
**Serverless for AI Agents** - Deploy your Dank agents seamlessly to the cloud with zero infrastructure management.
|
|
18
|
+
|
|
19
|
+
👉 **[https://cloud.dank-ai.xyz](https://cloud.dank-ai.xyz)** - The seamless cloud deployment management serverless solution for Dank. Scale your AI agents automatically, pay only for what you use, and focus on building great agents instead of managing servers.
|
|
13
20
|
|
|
14
21
|
## ✨ Features
|
|
15
22
|
|
|
@@ -88,10 +95,7 @@ module.exports = {
|
|
|
88
95
|
temperature: 0.7
|
|
89
96
|
})
|
|
90
97
|
.setPrompt('You are a helpful assistant that responds with enthusiasm!')
|
|
91
|
-
.
|
|
92
|
-
memory: '512m',
|
|
93
|
-
cpu: 1
|
|
94
|
-
})
|
|
98
|
+
.setInstanceType('small')
|
|
95
99
|
.addHandler('output', (data) => {
|
|
96
100
|
console.log('Assistant says:', data);
|
|
97
101
|
})
|
|
@@ -212,11 +216,7 @@ const agent = createAgent('my-agent')
|
|
|
212
216
|
authentication: false,
|
|
213
217
|
maxConnections: 50
|
|
214
218
|
})
|
|
215
|
-
.
|
|
216
|
-
memory: '1g',
|
|
217
|
-
cpu: 2,
|
|
218
|
-
timeout: 60000
|
|
219
|
-
});
|
|
219
|
+
.setInstanceType('medium');
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
### Adding HTTP Routes
|
|
@@ -533,22 +533,7 @@ agent
|
|
|
533
533
|
}
|
|
534
534
|
```
|
|
535
535
|
|
|
536
|
-
|
|
537
|
-
```javascript
|
|
538
|
-
{
|
|
539
|
-
requestId: "unique-request-id",
|
|
540
|
-
method: "POST",
|
|
541
|
-
path: "/api/chat",
|
|
542
|
-
headers: { "content-type": "application/json" },
|
|
543
|
-
body: { message: "Hello" },
|
|
544
|
-
query: {},
|
|
545
|
-
params: {},
|
|
546
|
-
statusCode: 200,
|
|
547
|
-
responseData: { response: "Hi there!" },
|
|
548
|
-
processingTime: 45,
|
|
549
|
-
timestamp: "2024-01-15T10:30:00.000Z"
|
|
550
|
-
}
|
|
551
|
-
```
|
|
536
|
+
npm
|
|
552
537
|
|
|
553
538
|
#### 🎛️ **Communication Method Control**
|
|
554
539
|
|
|
@@ -580,14 +565,15 @@ createAgent('flexible-agent')
|
|
|
580
565
|
Configure container resources:
|
|
581
566
|
|
|
582
567
|
```javascript
|
|
583
|
-
.
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
})
|
|
568
|
+
.setInstanceType('small') // Options: 'small', 'medium', 'large', 'xlarge'
|
|
569
|
+
// small: 512m, 1 CPU
|
|
570
|
+
// medium: 1g, 2 CPU
|
|
571
|
+
// large: 2g, 2 CPU
|
|
572
|
+
// xlarge: 4g, 4 CPU
|
|
589
573
|
```
|
|
590
574
|
|
|
575
|
+
**Note:** `setInstanceType()` is only used during deployments to Dank Cloud services. When running agents locally with `dank run`, this setting is disregarded and containers run without resource limits.
|
|
576
|
+
|
|
591
577
|
### Agent Image Configuration
|
|
592
578
|
|
|
593
579
|
Configure Docker image naming and registry settings for agent builds:
|
|
@@ -634,11 +620,7 @@ module.exports = {
|
|
|
634
620
|
authentication: true,
|
|
635
621
|
maxConnections: 100
|
|
636
622
|
})
|
|
637
|
-
.
|
|
638
|
-
memory: '1g',
|
|
639
|
-
cpu: 2,
|
|
640
|
-
timeout: 60000
|
|
641
|
-
})
|
|
623
|
+
.setInstanceType('medium')
|
|
642
624
|
// Agent image configuration
|
|
643
625
|
.setAgentImageConfig({
|
|
644
626
|
registry: 'ghcr.io',
|
|
@@ -663,11 +645,7 @@ module.exports = {
|
|
|
663
645
|
authentication: false,
|
|
664
646
|
maxConnections: 50
|
|
665
647
|
})
|
|
666
|
-
.
|
|
667
|
-
memory: '2g',
|
|
668
|
-
cpu: 4,
|
|
669
|
-
timeout: 120000
|
|
670
|
-
})
|
|
648
|
+
.setInstanceType('large')
|
|
671
649
|
// Different agent image configuration
|
|
672
650
|
.setAgentImageConfig({
|
|
673
651
|
registry: 'docker.io',
|
|
@@ -1192,7 +1170,7 @@ module.exports = {
|
|
|
1192
1170
|
- Resolve customer issues quickly
|
|
1193
1171
|
- Escalate complex problems appropriately
|
|
1194
1172
|
`)
|
|
1195
|
-
.
|
|
1173
|
+
.setInstanceType('small')
|
|
1196
1174
|
.addHandler('output', (data) => {
|
|
1197
1175
|
console.log('[Customer Service]:', data);
|
|
1198
1176
|
// Add your business logic here
|
|
@@ -1211,7 +1189,7 @@ module.exports = {
|
|
|
1211
1189
|
- Provide statistical insights
|
|
1212
1190
|
- Create actionable recommendations
|
|
1213
1191
|
`)
|
|
1214
|
-
.
|
|
1192
|
+
.setInstanceType('medium')
|
|
1215
1193
|
.addHandler('output', (data) => {
|
|
1216
1194
|
console.log('[Analyst]:', data);
|
|
1217
1195
|
// Save analysis results to database
|
|
@@ -1229,7 +1207,7 @@ module.exports = {
|
|
|
1229
1207
|
- Adapt tone to target audience
|
|
1230
1208
|
- Follow brand guidelines
|
|
1231
1209
|
`)
|
|
1232
|
-
.
|
|
1210
|
+
.setInstanceType('small')
|
|
1233
1211
|
.addHandler('output', (data) => {
|
|
1234
1212
|
console.log('[Content Creator]:', data);
|
|
1235
1213
|
// Process and publish content
|
|
@@ -1319,11 +1297,7 @@ createAgent('data-processor')
|
|
|
1319
1297
|
3. Provide actionable insights
|
|
1320
1298
|
4. Format results as JSON
|
|
1321
1299
|
`)
|
|
1322
|
-
.
|
|
1323
|
-
memory: '2g', // More memory for data processing
|
|
1324
|
-
cpu: 2, // More CPU for complex calculations
|
|
1325
|
-
timeout: 120000 // Longer timeout for large datasets
|
|
1326
|
-
})
|
|
1300
|
+
.setInstanceType('large') // More memory for data processing
|
|
1327
1301
|
.addHandler('output', (analysis) => {
|
|
1328
1302
|
try {
|
|
1329
1303
|
const results = JSON.parse(analysis);
|
|
@@ -1406,10 +1380,7 @@ module.exports = {
|
|
|
1406
1380
|
model: isDevelopment ? 'gpt-3.5-turbo' : 'gpt-4',
|
|
1407
1381
|
temperature: isDevelopment ? 0.9 : 0.7
|
|
1408
1382
|
})
|
|
1409
|
-
.
|
|
1410
|
-
memory: isDevelopment ? '256m' : '1g',
|
|
1411
|
-
cpu: isDevelopment ? 0.5 : 2
|
|
1412
|
-
})
|
|
1383
|
+
.setInstanceType(isDevelopment ? 'small' : 'medium')
|
|
1413
1384
|
.addHandler('output', (data) => {
|
|
1414
1385
|
if (isDevelopment) {
|
|
1415
1386
|
console.log('DEV:', data);
|
|
@@ -1422,63 +1393,7 @@ module.exports = {
|
|
|
1422
1393
|
};
|
|
1423
1394
|
```
|
|
1424
1395
|
|
|
1425
|
-
### 🔧 Advanced Usage
|
|
1426
|
-
|
|
1427
|
-
#### Environment Variables
|
|
1428
|
-
```bash
|
|
1429
|
-
export OPENAI_API_KEY="your-key"
|
|
1430
|
-
export ANTHROPIC_API_KEY="your-key"
|
|
1431
|
-
export LOG_LEVEL="debug"
|
|
1432
|
-
export DOCKER_HOST="unix:///var/run/docker.sock"
|
|
1433
|
-
export NODE_ENV="production"
|
|
1434
|
-
```
|
|
1435
1396
|
|
|
1436
|
-
#### Integration with Existing Applications
|
|
1437
|
-
```javascript
|
|
1438
|
-
// In your existing Node.js application
|
|
1439
|
-
const { spawn } = require('child_process');
|
|
1440
|
-
|
|
1441
|
-
// Start Dank agents programmatically
|
|
1442
|
-
function startAgents() {
|
|
1443
|
-
const dankProcess = spawn('dank', ['run', '--detached'], {
|
|
1444
|
-
stdio: 'inherit',
|
|
1445
|
-
env: { ...process.env, NODE_ENV: 'production' }
|
|
1446
|
-
});
|
|
1447
|
-
|
|
1448
|
-
dankProcess.on('close', (code) => {
|
|
1449
|
-
console.log(`Dank agents exited with code ${code}`);
|
|
1450
|
-
});
|
|
1451
|
-
|
|
1452
|
-
return dankProcess;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
// Stop agents gracefully
|
|
1456
|
-
function stopAgents() {
|
|
1457
|
-
spawn('dank', ['stop', '--all'], { stdio: 'inherit' });
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
// Check agent status
|
|
1461
|
-
async function getAgentStatus() {
|
|
1462
|
-
return new Promise((resolve) => {
|
|
1463
|
-
const statusProcess = spawn('dank', ['status', '--json'], {
|
|
1464
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
1465
|
-
});
|
|
1466
|
-
|
|
1467
|
-
let output = '';
|
|
1468
|
-
statusProcess.stdout.on('data', (data) => {
|
|
1469
|
-
output += data.toString();
|
|
1470
|
-
});
|
|
1471
|
-
|
|
1472
|
-
statusProcess.on('close', () => {
|
|
1473
|
-
try {
|
|
1474
|
-
resolve(JSON.parse(output));
|
|
1475
|
-
} catch {
|
|
1476
|
-
resolve(null);
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
```
|
|
1482
1397
|
|
|
1483
1398
|
### 🚨 Troubleshooting
|
|
1484
1399
|
|
|
@@ -1534,18 +1449,16 @@ echo "OPENAI_API_KEY=sk-your-actual-key-here" > .env
|
|
|
1534
1449
|
```bash
|
|
1535
1450
|
# Error: Base image 'deltadarkly/dank-agent-base' not found
|
|
1536
1451
|
# Solution: The base image is pulled automatically, but you can build it manually
|
|
1452
|
+
# ty also pulling manually when docker is running via docker pull <image name>
|
|
1537
1453
|
dank build --base
|
|
1538
1454
|
```
|
|
1539
1455
|
|
|
1540
1456
|
**4. Container Resource Issues**
|
|
1541
1457
|
```bash
|
|
1542
1458
|
# Error: Container exits with code 137 (out of memory)
|
|
1543
|
-
# Solution: Increase memory allocation
|
|
1459
|
+
# Solution: Increase memory allocation (On cloud service, on local agents run with given resources)
|
|
1544
1460
|
createAgent('my-agent')
|
|
1545
|
-
.
|
|
1546
|
-
memory: '1g', // Increase from 512m to 1g
|
|
1547
|
-
cpu: 2
|
|
1548
|
-
})
|
|
1461
|
+
.setInstanceType('medium') // Increase from 'small' to 'medium'
|
|
1549
1462
|
```
|
|
1550
1463
|
|
|
1551
1464
|
**5. Agent Not Starting**
|
|
@@ -1566,17 +1479,10 @@ docker logs container-id
|
|
|
1566
1479
|
```javascript
|
|
1567
1480
|
// Good: Appropriate resource allocation
|
|
1568
1481
|
createAgent('light-agent')
|
|
1569
|
-
.
|
|
1570
|
-
memory: '256m', // Light tasks
|
|
1571
|
-
cpu: 0.5
|
|
1572
|
-
});
|
|
1482
|
+
.setInstanceType('small'); // Light tasks
|
|
1573
1483
|
|
|
1574
1484
|
createAgent('heavy-agent')
|
|
1575
|
-
.
|
|
1576
|
-
memory: '2g', // Heavy processing
|
|
1577
|
-
cpu: 2,
|
|
1578
|
-
timeout: 120000 // Longer timeout
|
|
1579
|
-
});
|
|
1485
|
+
.setInstanceType('large'); // Heavy processing
|
|
1580
1486
|
```
|
|
1581
1487
|
|
|
1582
1488
|
#### 2. Error Handling
|
|
@@ -1630,8 +1536,7 @@ createAgent('environment-aware')
|
|
|
1630
1536
|
model: settings.model,
|
|
1631
1537
|
temperature: 0.7
|
|
1632
1538
|
})
|
|
1633
|
-
.
|
|
1634
|
-
memory: settings.memory
|
|
1539
|
+
.setInstanceType(settings.instanceType || 'small')
|
|
1635
1540
|
});
|
|
1636
1541
|
```
|
|
1637
1542
|
|
|
@@ -1682,37 +1587,25 @@ createAgent('secure-agent')
|
|
|
1682
1587
|
});
|
|
1683
1588
|
```
|
|
1684
1589
|
|
|
1685
|
-
### 📊 Performance Optimization
|
|
1686
|
-
|
|
1687
|
-
#### 1. Resource Tuning
|
|
1688
|
-
```bash
|
|
1689
|
-
# Monitor resource usage
|
|
1690
|
-
dank status --watch
|
|
1691
|
-
|
|
1692
|
-
# Check container stats
|
|
1693
|
-
docker stats $(docker ps -f name=dank- -q)
|
|
1694
|
-
|
|
1695
|
-
# Optimize based on usage patterns
|
|
1696
|
-
```
|
|
1697
1590
|
|
|
1698
|
-
####
|
|
1591
|
+
#### 1. Parallel Agent Management
|
|
1699
1592
|
```javascript
|
|
1700
1593
|
// Good: Balanced agent distribution
|
|
1701
1594
|
module.exports = {
|
|
1702
1595
|
agents: [
|
|
1703
1596
|
// CPU-intensive agents
|
|
1704
|
-
createAgent('analyzer').
|
|
1597
|
+
createAgent('analyzer').setInstanceType('medium'),
|
|
1705
1598
|
|
|
1706
1599
|
// Memory-intensive agents
|
|
1707
|
-
createAgent('processor').
|
|
1600
|
+
createAgent('processor').setInstanceType('large'),
|
|
1708
1601
|
|
|
1709
1602
|
// Light agents
|
|
1710
|
-
createAgent('notifier').
|
|
1603
|
+
createAgent('notifier').setInstanceType('small')
|
|
1711
1604
|
]
|
|
1712
1605
|
};
|
|
1713
1606
|
```
|
|
1714
1607
|
|
|
1715
|
-
####
|
|
1608
|
+
#### 2. Efficient Prompt Design
|
|
1716
1609
|
```javascript
|
|
1717
1610
|
// Good: Clear, specific prompts
|
|
1718
1611
|
.setPrompt(`
|
|
@@ -1741,7 +1634,7 @@ dank stop --all
|
|
|
1741
1634
|
dank run --build # Rebuild if needed
|
|
1742
1635
|
|
|
1743
1636
|
# 4. Test with reduced resources
|
|
1744
|
-
createAgent('dev-agent').
|
|
1637
|
+
createAgent('dev-agent').setInstanceType('small')
|
|
1745
1638
|
```
|
|
1746
1639
|
|
|
1747
1640
|
#### 2. Testing Agents
|
|
@@ -1822,10 +1715,7 @@ ISC License - see LICENSE file for details.
|
|
|
1822
1715
|
|
|
1823
1716
|
## 🆘 Support
|
|
1824
1717
|
|
|
1825
|
-
- **Documentation**: [Wiki](https://github.com/your-org/dank/wiki)
|
|
1826
1718
|
- **Issues**: [GitHub Issues](https://github.com/your-org/dank/issues)
|
|
1827
1719
|
- **Discussions**: [GitHub Discussions](https://github.com/your-org/dank/discussions)
|
|
1828
1720
|
|
|
1829
|
-
---
|
|
1830
|
-
|
|
1831
|
-
**Built with 💯 energy for the AI agent revolution!** 🚀
|
|
1721
|
+
---
|