dank-ai 1.0.33 → 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 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
- .setResources({
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
- .setResources({
216
- memory: '1g',
217
- cpu: 2,
218
- timeout: 60000
219
- });
219
+ .setInstanceType('medium');
220
220
  ```
221
221
 
222
222
  ### Adding HTTP Routes
@@ -526,7 +526,6 @@ agent
526
526
  prompt: "User's input prompt",
527
527
  response: "LLM's response",
528
528
  conversationId: "unique-conversation-id",
529
- context: { protocol: "http" },
530
529
  usage: { total_tokens: 150, prompt_tokens: 50, completion_tokens: 100 },
531
530
  model: "gpt-3.5-turbo",
532
531
  processingTime: 1250,
@@ -581,14 +580,15 @@ createAgent('flexible-agent')
581
580
  Configure container resources:
582
581
 
583
582
  ```javascript
584
- .setResources({
585
- memory: '512m', // Memory limit (512m, 1g, etc.)
586
- cpu: 1, // CPU allocation (0.5, 1, 2, etc.)
587
- timeout: 30000, // Request timeout in ms
588
- maxRestarts: 3 // Max container restarts
589
- })
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
590
588
  ```
591
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
+
592
592
  ### Agent Image Configuration
593
593
 
594
594
  Configure Docker image naming and registry settings for agent builds:
@@ -635,11 +635,7 @@ module.exports = {
635
635
  authentication: true,
636
636
  maxConnections: 100
637
637
  })
638
- .setResources({
639
- memory: '1g',
640
- cpu: 2,
641
- timeout: 60000
642
- })
638
+ .setInstanceType('medium')
643
639
  // Agent image configuration
644
640
  .setAgentImageConfig({
645
641
  registry: 'ghcr.io',
@@ -664,11 +660,7 @@ module.exports = {
664
660
  authentication: false,
665
661
  maxConnections: 50
666
662
  })
667
- .setResources({
668
- memory: '2g',
669
- cpu: 4,
670
- timeout: 120000
671
- })
663
+ .setInstanceType('large')
672
664
  // Different agent image configuration
673
665
  .setAgentImageConfig({
674
666
  registry: 'docker.io',
@@ -737,7 +729,7 @@ dank build:prod --config production.config.js --output-metadata deployment.json
737
729
 
738
730
  The `--output-metadata` option generates a JSON file containing all deployment information needed for your backend infrastructure:
739
731
  - **Base image** used (`setBaseImage()` value)
740
- - **Prompting server** configuration (protocol, port, authentication, maxConnections)
732
+ - **Prompting server** configuration (port, authentication, maxConnections)
741
733
  - **Resource limits** (memory, CPU, timeout)
742
734
  - **Ports** that need to be opened
743
735
  - **Features enabled** (direct prompting, HTTP API, event handlers)
@@ -776,7 +768,6 @@ This metadata file is perfect for CI/CD pipelines to automatically configure you
776
768
  "ports": [
777
769
  {
778
770
  "port": 3000,
779
- "protocol": "http",
780
771
  "description": "Direct prompting server"
781
772
  }
782
773
  ],
@@ -1194,7 +1185,7 @@ module.exports = {
1194
1185
  - Resolve customer issues quickly
1195
1186
  - Escalate complex problems appropriately
1196
1187
  `)
1197
- .setResources({ memory: '512m', cpu: 1 })
1188
+ .setInstanceType('small')
1198
1189
  .addHandler('output', (data) => {
1199
1190
  console.log('[Customer Service]:', data);
1200
1191
  // Add your business logic here
@@ -1213,7 +1204,7 @@ module.exports = {
1213
1204
  - Provide statistical insights
1214
1205
  - Create actionable recommendations
1215
1206
  `)
1216
- .setResources({ memory: '1g', cpu: 2 })
1207
+ .setInstanceType('medium')
1217
1208
  .addHandler('output', (data) => {
1218
1209
  console.log('[Analyst]:', data);
1219
1210
  // Save analysis results to database
@@ -1231,7 +1222,7 @@ module.exports = {
1231
1222
  - Adapt tone to target audience
1232
1223
  - Follow brand guidelines
1233
1224
  `)
1234
- .setResources({ memory: '512m', cpu: 1 })
1225
+ .setInstanceType('small')
1235
1226
  .addHandler('output', (data) => {
1236
1227
  console.log('[Content Creator]:', data);
1237
1228
  // Process and publish content
@@ -1321,11 +1312,7 @@ createAgent('data-processor')
1321
1312
  3. Provide actionable insights
1322
1313
  4. Format results as JSON
1323
1314
  `)
1324
- .setResources({
1325
- memory: '2g', // More memory for data processing
1326
- cpu: 2, // More CPU for complex calculations
1327
- timeout: 120000 // Longer timeout for large datasets
1328
- })
1315
+ .setInstanceType('large') // More memory for data processing
1329
1316
  .addHandler('output', (analysis) => {
1330
1317
  try {
1331
1318
  const results = JSON.parse(analysis);
@@ -1408,10 +1395,7 @@ module.exports = {
1408
1395
  model: isDevelopment ? 'gpt-3.5-turbo' : 'gpt-4',
1409
1396
  temperature: isDevelopment ? 0.9 : 0.7
1410
1397
  })
1411
- .setResources({
1412
- memory: isDevelopment ? '256m' : '1g',
1413
- cpu: isDevelopment ? 0.5 : 2
1414
- })
1398
+ .setInstanceType(isDevelopment ? 'small' : 'medium')
1415
1399
  .addHandler('output', (data) => {
1416
1400
  if (isDevelopment) {
1417
1401
  console.log('DEV:', data);
@@ -1424,63 +1408,7 @@ module.exports = {
1424
1408
  };
1425
1409
  ```
1426
1410
 
1427
- ### 🔧 Advanced Usage
1428
-
1429
- #### Environment Variables
1430
- ```bash
1431
- export OPENAI_API_KEY="your-key"
1432
- export ANTHROPIC_API_KEY="your-key"
1433
- export LOG_LEVEL="debug"
1434
- export DOCKER_HOST="unix:///var/run/docker.sock"
1435
- export NODE_ENV="production"
1436
- ```
1437
-
1438
- #### Integration with Existing Applications
1439
- ```javascript
1440
- // In your existing Node.js application
1441
- const { spawn } = require('child_process');
1442
-
1443
- // Start Dank agents programmatically
1444
- function startAgents() {
1445
- const dankProcess = spawn('dank', ['run', '--detached'], {
1446
- stdio: 'inherit',
1447
- env: { ...process.env, NODE_ENV: 'production' }
1448
- });
1449
-
1450
- dankProcess.on('close', (code) => {
1451
- console.log(`Dank agents exited with code ${code}`);
1452
- });
1453
-
1454
- return dankProcess;
1455
- }
1456
-
1457
- // Stop agents gracefully
1458
- function stopAgents() {
1459
- spawn('dank', ['stop', '--all'], { stdio: 'inherit' });
1460
- }
1461
1411
 
1462
- // Check agent status
1463
- async function getAgentStatus() {
1464
- return new Promise((resolve) => {
1465
- const statusProcess = spawn('dank', ['status', '--json'], {
1466
- stdio: ['pipe', 'pipe', 'pipe']
1467
- });
1468
-
1469
- let output = '';
1470
- statusProcess.stdout.on('data', (data) => {
1471
- output += data.toString();
1472
- });
1473
-
1474
- statusProcess.on('close', () => {
1475
- try {
1476
- resolve(JSON.parse(output));
1477
- } catch {
1478
- resolve(null);
1479
- }
1480
- });
1481
- });
1482
- }
1483
- ```
1484
1412
 
1485
1413
  ### 🚨 Troubleshooting
1486
1414
 
@@ -1536,18 +1464,16 @@ echo "OPENAI_API_KEY=sk-your-actual-key-here" > .env
1536
1464
  ```bash
1537
1465
  # Error: Base image 'deltadarkly/dank-agent-base' not found
1538
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>
1539
1468
  dank build --base
1540
1469
  ```
1541
1470
 
1542
1471
  **4. Container Resource Issues**
1543
1472
  ```bash
1544
1473
  # Error: Container exits with code 137 (out of memory)
1545
- # Solution: Increase memory allocation
1474
+ # Solution: Increase memory allocation (On cloud service, on local agents run with given resources)
1546
1475
  createAgent('my-agent')
1547
- .setResources({
1548
- memory: '1g', // Increase from 512m to 1g
1549
- cpu: 2
1550
- })
1476
+ .setInstanceType('medium') // Increase from 'small' to 'medium'
1551
1477
  ```
1552
1478
 
1553
1479
  **5. Agent Not Starting**
@@ -1568,17 +1494,10 @@ docker logs container-id
1568
1494
  ```javascript
1569
1495
  // Good: Appropriate resource allocation
1570
1496
  createAgent('light-agent')
1571
- .setResources({
1572
- memory: '256m', // Light tasks
1573
- cpu: 0.5
1574
- });
1497
+ .setInstanceType('small'); // Light tasks
1575
1498
 
1576
1499
  createAgent('heavy-agent')
1577
- .setResources({
1578
- memory: '2g', // Heavy processing
1579
- cpu: 2,
1580
- timeout: 120000 // Longer timeout
1581
- });
1500
+ .setInstanceType('large'); // Heavy processing
1582
1501
  ```
1583
1502
 
1584
1503
  #### 2. Error Handling
@@ -1632,8 +1551,7 @@ createAgent('environment-aware')
1632
1551
  model: settings.model,
1633
1552
  temperature: 0.7
1634
1553
  })
1635
- .setResources({
1636
- memory: settings.memory
1554
+ .setInstanceType(settings.instanceType || 'small')
1637
1555
  });
1638
1556
  ```
1639
1557
 
@@ -1684,37 +1602,25 @@ createAgent('secure-agent')
1684
1602
  });
1685
1603
  ```
1686
1604
 
1687
- ### 📊 Performance Optimization
1688
-
1689
- #### 1. Resource Tuning
1690
- ```bash
1691
- # Monitor resource usage
1692
- dank status --watch
1693
1605
 
1694
- # Check container stats
1695
- docker stats $(docker ps -f name=dank- -q)
1696
-
1697
- # Optimize based on usage patterns
1698
- ```
1699
-
1700
- #### 2. Parallel Agent Management
1606
+ #### 1. Parallel Agent Management
1701
1607
  ```javascript
1702
1608
  // Good: Balanced agent distribution
1703
1609
  module.exports = {
1704
1610
  agents: [
1705
1611
  // CPU-intensive agents
1706
- createAgent('analyzer').setResources({ cpu: 2, memory: '1g' }),
1612
+ createAgent('analyzer').setInstanceType('medium'),
1707
1613
 
1708
1614
  // Memory-intensive agents
1709
- createAgent('processor').setResources({ cpu: 1, memory: '2g' }),
1615
+ createAgent('processor').setInstanceType('large'),
1710
1616
 
1711
1617
  // Light agents
1712
- createAgent('notifier').setResources({ cpu: 0.5, memory: '256m' })
1618
+ createAgent('notifier').setInstanceType('small')
1713
1619
  ]
1714
1620
  };
1715
1621
  ```
1716
1622
 
1717
- #### 3. Efficient Prompt Design
1623
+ #### 2. Efficient Prompt Design
1718
1624
  ```javascript
1719
1625
  // Good: Clear, specific prompts
1720
1626
  .setPrompt(`
@@ -1743,7 +1649,7 @@ dank stop --all
1743
1649
  dank run --build # Rebuild if needed
1744
1650
 
1745
1651
  # 4. Test with reduced resources
1746
- createAgent('dev-agent').setResources({ memory: '128m', cpu: 0.25 })
1652
+ createAgent('dev-agent').setInstanceType('small')
1747
1653
  ```
1748
1654
 
1749
1655
  #### 2. Testing Agents
@@ -1824,10 +1730,7 @@ ISC License - see LICENSE file for details.
1824
1730
 
1825
1731
  ## 🆘 Support
1826
1732
 
1827
- - **Documentation**: [Wiki](https://github.com/your-org/dank/wiki)
1828
1733
  - **Issues**: [GitHub Issues](https://github.com/your-org/dank/issues)
1829
1734
  - **Discussions**: [GitHub Discussions](https://github.com/your-org/dank/discussions)
1830
1735
 
1831
- ---
1832
-
1833
- **Built with 💯 energy for the AI agent revolution!** 🚀
1736
+ ---