dank-ai 1.0.34 → 1.0.35
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 +37 -132
- 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
|
|
@@ -580,14 +580,15 @@ createAgent('flexible-agent')
|
|
|
580
580
|
Configure container resources:
|
|
581
581
|
|
|
582
582
|
```javascript
|
|
583
|
-
.
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
})
|
|
583
|
+
.setInstanceType('small') // Options: 'small', 'medium', 'large', 'xlarge'
|
|
584
|
+
// small: 512m, 1 CPU
|
|
585
|
+
// medium: 1g, 2 CPU
|
|
586
|
+
// large: 2g, 2 CPU
|
|
587
|
+
// xlarge: 4g, 4 CPU
|
|
589
588
|
```
|
|
590
589
|
|
|
590
|
+
**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.
|
|
591
|
+
|
|
591
592
|
### Agent Image Configuration
|
|
592
593
|
|
|
593
594
|
Configure Docker image naming and registry settings for agent builds:
|
|
@@ -634,11 +635,7 @@ module.exports = {
|
|
|
634
635
|
authentication: true,
|
|
635
636
|
maxConnections: 100
|
|
636
637
|
})
|
|
637
|
-
.
|
|
638
|
-
memory: '1g',
|
|
639
|
-
cpu: 2,
|
|
640
|
-
timeout: 60000
|
|
641
|
-
})
|
|
638
|
+
.setInstanceType('medium')
|
|
642
639
|
// Agent image configuration
|
|
643
640
|
.setAgentImageConfig({
|
|
644
641
|
registry: 'ghcr.io',
|
|
@@ -663,11 +660,7 @@ module.exports = {
|
|
|
663
660
|
authentication: false,
|
|
664
661
|
maxConnections: 50
|
|
665
662
|
})
|
|
666
|
-
.
|
|
667
|
-
memory: '2g',
|
|
668
|
-
cpu: 4,
|
|
669
|
-
timeout: 120000
|
|
670
|
-
})
|
|
663
|
+
.setInstanceType('large')
|
|
671
664
|
// Different agent image configuration
|
|
672
665
|
.setAgentImageConfig({
|
|
673
666
|
registry: 'docker.io',
|
|
@@ -1192,7 +1185,7 @@ module.exports = {
|
|
|
1192
1185
|
- Resolve customer issues quickly
|
|
1193
1186
|
- Escalate complex problems appropriately
|
|
1194
1187
|
`)
|
|
1195
|
-
.
|
|
1188
|
+
.setInstanceType('small')
|
|
1196
1189
|
.addHandler('output', (data) => {
|
|
1197
1190
|
console.log('[Customer Service]:', data);
|
|
1198
1191
|
// Add your business logic here
|
|
@@ -1211,7 +1204,7 @@ module.exports = {
|
|
|
1211
1204
|
- Provide statistical insights
|
|
1212
1205
|
- Create actionable recommendations
|
|
1213
1206
|
`)
|
|
1214
|
-
.
|
|
1207
|
+
.setInstanceType('medium')
|
|
1215
1208
|
.addHandler('output', (data) => {
|
|
1216
1209
|
console.log('[Analyst]:', data);
|
|
1217
1210
|
// Save analysis results to database
|
|
@@ -1229,7 +1222,7 @@ module.exports = {
|
|
|
1229
1222
|
- Adapt tone to target audience
|
|
1230
1223
|
- Follow brand guidelines
|
|
1231
1224
|
`)
|
|
1232
|
-
.
|
|
1225
|
+
.setInstanceType('small')
|
|
1233
1226
|
.addHandler('output', (data) => {
|
|
1234
1227
|
console.log('[Content Creator]:', data);
|
|
1235
1228
|
// Process and publish content
|
|
@@ -1319,11 +1312,7 @@ createAgent('data-processor')
|
|
|
1319
1312
|
3. Provide actionable insights
|
|
1320
1313
|
4. Format results as JSON
|
|
1321
1314
|
`)
|
|
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
|
-
})
|
|
1315
|
+
.setInstanceType('large') // More memory for data processing
|
|
1327
1316
|
.addHandler('output', (analysis) => {
|
|
1328
1317
|
try {
|
|
1329
1318
|
const results = JSON.parse(analysis);
|
|
@@ -1406,10 +1395,7 @@ module.exports = {
|
|
|
1406
1395
|
model: isDevelopment ? 'gpt-3.5-turbo' : 'gpt-4',
|
|
1407
1396
|
temperature: isDevelopment ? 0.9 : 0.7
|
|
1408
1397
|
})
|
|
1409
|
-
.
|
|
1410
|
-
memory: isDevelopment ? '256m' : '1g',
|
|
1411
|
-
cpu: isDevelopment ? 0.5 : 2
|
|
1412
|
-
})
|
|
1398
|
+
.setInstanceType(isDevelopment ? 'small' : 'medium')
|
|
1413
1399
|
.addHandler('output', (data) => {
|
|
1414
1400
|
if (isDevelopment) {
|
|
1415
1401
|
console.log('DEV:', data);
|
|
@@ -1422,63 +1408,7 @@ module.exports = {
|
|
|
1422
1408
|
};
|
|
1423
1409
|
```
|
|
1424
1410
|
|
|
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
|
-
|
|
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
1411
|
|
|
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
1412
|
|
|
1483
1413
|
### 🚨 Troubleshooting
|
|
1484
1414
|
|
|
@@ -1534,18 +1464,16 @@ echo "OPENAI_API_KEY=sk-your-actual-key-here" > .env
|
|
|
1534
1464
|
```bash
|
|
1535
1465
|
# Error: Base image 'deltadarkly/dank-agent-base' not found
|
|
1536
1466
|
# Solution: The base image is pulled automatically, but you can build it manually
|
|
1467
|
+
# ty also pulling manually when docker is running via docker pull <image name>
|
|
1537
1468
|
dank build --base
|
|
1538
1469
|
```
|
|
1539
1470
|
|
|
1540
1471
|
**4. Container Resource Issues**
|
|
1541
1472
|
```bash
|
|
1542
1473
|
# Error: Container exits with code 137 (out of memory)
|
|
1543
|
-
# Solution: Increase memory allocation
|
|
1474
|
+
# Solution: Increase memory allocation (On cloud service, on local agents run with given resources)
|
|
1544
1475
|
createAgent('my-agent')
|
|
1545
|
-
.
|
|
1546
|
-
memory: '1g', // Increase from 512m to 1g
|
|
1547
|
-
cpu: 2
|
|
1548
|
-
})
|
|
1476
|
+
.setInstanceType('medium') // Increase from 'small' to 'medium'
|
|
1549
1477
|
```
|
|
1550
1478
|
|
|
1551
1479
|
**5. Agent Not Starting**
|
|
@@ -1566,17 +1494,10 @@ docker logs container-id
|
|
|
1566
1494
|
```javascript
|
|
1567
1495
|
// Good: Appropriate resource allocation
|
|
1568
1496
|
createAgent('light-agent')
|
|
1569
|
-
.
|
|
1570
|
-
memory: '256m', // Light tasks
|
|
1571
|
-
cpu: 0.5
|
|
1572
|
-
});
|
|
1497
|
+
.setInstanceType('small'); // Light tasks
|
|
1573
1498
|
|
|
1574
1499
|
createAgent('heavy-agent')
|
|
1575
|
-
.
|
|
1576
|
-
memory: '2g', // Heavy processing
|
|
1577
|
-
cpu: 2,
|
|
1578
|
-
timeout: 120000 // Longer timeout
|
|
1579
|
-
});
|
|
1500
|
+
.setInstanceType('large'); // Heavy processing
|
|
1580
1501
|
```
|
|
1581
1502
|
|
|
1582
1503
|
#### 2. Error Handling
|
|
@@ -1630,8 +1551,7 @@ createAgent('environment-aware')
|
|
|
1630
1551
|
model: settings.model,
|
|
1631
1552
|
temperature: 0.7
|
|
1632
1553
|
})
|
|
1633
|
-
.
|
|
1634
|
-
memory: settings.memory
|
|
1554
|
+
.setInstanceType(settings.instanceType || 'small')
|
|
1635
1555
|
});
|
|
1636
1556
|
```
|
|
1637
1557
|
|
|
@@ -1682,37 +1602,25 @@ createAgent('secure-agent')
|
|
|
1682
1602
|
});
|
|
1683
1603
|
```
|
|
1684
1604
|
|
|
1685
|
-
### 📊 Performance Optimization
|
|
1686
|
-
|
|
1687
|
-
#### 1. Resource Tuning
|
|
1688
|
-
```bash
|
|
1689
|
-
# Monitor resource usage
|
|
1690
|
-
dank status --watch
|
|
1691
1605
|
|
|
1692
|
-
|
|
1693
|
-
docker stats $(docker ps -f name=dank- -q)
|
|
1694
|
-
|
|
1695
|
-
# Optimize based on usage patterns
|
|
1696
|
-
```
|
|
1697
|
-
|
|
1698
|
-
#### 2. Parallel Agent Management
|
|
1606
|
+
#### 1. Parallel Agent Management
|
|
1699
1607
|
```javascript
|
|
1700
1608
|
// Good: Balanced agent distribution
|
|
1701
1609
|
module.exports = {
|
|
1702
1610
|
agents: [
|
|
1703
1611
|
// CPU-intensive agents
|
|
1704
|
-
createAgent('analyzer').
|
|
1612
|
+
createAgent('analyzer').setInstanceType('medium'),
|
|
1705
1613
|
|
|
1706
1614
|
// Memory-intensive agents
|
|
1707
|
-
createAgent('processor').
|
|
1615
|
+
createAgent('processor').setInstanceType('large'),
|
|
1708
1616
|
|
|
1709
1617
|
// Light agents
|
|
1710
|
-
createAgent('notifier').
|
|
1618
|
+
createAgent('notifier').setInstanceType('small')
|
|
1711
1619
|
]
|
|
1712
1620
|
};
|
|
1713
1621
|
```
|
|
1714
1622
|
|
|
1715
|
-
####
|
|
1623
|
+
#### 2. Efficient Prompt Design
|
|
1716
1624
|
```javascript
|
|
1717
1625
|
// Good: Clear, specific prompts
|
|
1718
1626
|
.setPrompt(`
|
|
@@ -1741,7 +1649,7 @@ dank stop --all
|
|
|
1741
1649
|
dank run --build # Rebuild if needed
|
|
1742
1650
|
|
|
1743
1651
|
# 4. Test with reduced resources
|
|
1744
|
-
createAgent('dev-agent').
|
|
1652
|
+
createAgent('dev-agent').setInstanceType('small')
|
|
1745
1653
|
```
|
|
1746
1654
|
|
|
1747
1655
|
#### 2. Testing Agents
|
|
@@ -1822,10 +1730,7 @@ ISC License - see LICENSE file for details.
|
|
|
1822
1730
|
|
|
1823
1731
|
## 🆘 Support
|
|
1824
1732
|
|
|
1825
|
-
- **Documentation**: [Wiki](https://github.com/your-org/dank/wiki)
|
|
1826
1733
|
- **Issues**: [GitHub Issues](https://github.com/your-org/dank/issues)
|
|
1827
1734
|
- **Discussions**: [GitHub Discussions](https://github.com/your-org/dank/discussions)
|
|
1828
1735
|
|
|
1829
|
-
---
|
|
1830
|
-
|
|
1831
|
-
**Built with 💯 energy for the AI agent revolution!** 🚀
|
|
1736
|
+
---
|