dank-ai 1.0.31 → 1.0.33
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 +49 -50
- package/bin/dank +1 -0
- package/docker/entrypoint.js +140 -353
- package/lib/agent.js +100 -25
- package/lib/cli/init.js +1 -14
- package/lib/cli/production-build.js +6 -8
- package/lib/config.js +32 -33
- package/lib/constants.js +23 -6
- package/lib/docker/manager.js +161 -42
- package/lib/project.js +1 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -208,7 +208,6 @@ const agent = createAgent('my-agent')
|
|
|
208
208
|
})
|
|
209
209
|
.setPrompt('Your system prompt here')
|
|
210
210
|
.setPromptingServer({
|
|
211
|
-
protocol: 'http',
|
|
212
211
|
port: 3000,
|
|
213
212
|
authentication: false,
|
|
214
213
|
maxConnections: 50
|
|
@@ -220,6 +219,45 @@ const agent = createAgent('my-agent')
|
|
|
220
219
|
});
|
|
221
220
|
```
|
|
222
221
|
|
|
222
|
+
### Adding HTTP Routes
|
|
223
|
+
|
|
224
|
+
HTTP automatically enables when you add routes. Here's a simple "Hello World" POST endpoint:
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
const agent = createAgent('hello-agent')
|
|
228
|
+
.setLLM('openai', {
|
|
229
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
230
|
+
model: 'gpt-3.5-turbo'
|
|
231
|
+
})
|
|
232
|
+
.setPromptingServer({
|
|
233
|
+
port: 3000
|
|
234
|
+
})
|
|
235
|
+
// Add a POST endpoint (HTTP auto-enables)
|
|
236
|
+
.post('/hello', (req, res) => {
|
|
237
|
+
res.json({
|
|
238
|
+
message: 'Hello, World!',
|
|
239
|
+
received: req.body,
|
|
240
|
+
timestamp: new Date().toISOString()
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Test it:**
|
|
246
|
+
```bash
|
|
247
|
+
curl -X POST http://localhost:3000/hello \
|
|
248
|
+
-H "Content-Type: application/json" \
|
|
249
|
+
-d '{"name": "User"}'
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Response:**
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"message": "Hello, World!",
|
|
256
|
+
"received": {"name": "User"},
|
|
257
|
+
"timestamp": "2024-01-15T10:30:00.000Z"
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
223
261
|
### Supported LLM Providers
|
|
224
262
|
|
|
225
263
|
#### OpenAI
|
|
@@ -287,7 +325,7 @@ Dank provides a comprehensive event system with three main sources of events. Ea
|
|
|
287
325
|
#### 🎯 **Event Handler Patterns**
|
|
288
326
|
|
|
289
327
|
##### **1. Direct Prompting Events** (`request_output`)
|
|
290
|
-
Events triggered when agents receive and respond to direct prompts via
|
|
328
|
+
Events triggered when agents receive and respond to direct prompts via HTTP:
|
|
291
329
|
|
|
292
330
|
```javascript
|
|
293
331
|
agent
|
|
@@ -405,35 +443,10 @@ Events triggered by tool usage, following the pattern `tool:<tool-name>:<action>
|
|
|
405
443
|
|
|
406
444
|
```javascript
|
|
407
445
|
agent
|
|
408
|
-
//
|
|
409
|
-
.addHandler('tool:
|
|
410
|
-
// Listen to ALL HTTP
|
|
411
|
-
console.log('HTTP
|
|
412
|
-
})
|
|
413
|
-
|
|
414
|
-
.addHandler('tool:http-server:call', (data) => {
|
|
415
|
-
// All incoming HTTP requests
|
|
416
|
-
console.log('Request:', data.method, data.path, data.body);
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
.addHandler('tool:http-server:response', (data) => {
|
|
420
|
-
// All HTTP responses
|
|
421
|
-
console.log('Response:', data.statusCode, data.processingTime);
|
|
422
|
-
})
|
|
423
|
-
|
|
424
|
-
.addHandler('tool:http-server:call:post', (data) => {
|
|
425
|
-
// Only POST requests
|
|
426
|
-
console.log('POST Request:', data.path, data.body);
|
|
427
|
-
})
|
|
428
|
-
|
|
429
|
-
.addHandler('tool:http-server:response:get', (data) => {
|
|
430
|
-
// Only GET responses
|
|
431
|
-
console.log('GET Response:', data.path, data.responseData);
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
.addHandler('tool:http-server:error', (data) => {
|
|
435
|
-
// HTTP server errors
|
|
436
|
-
console.error('HTTP Error:', data.error);
|
|
446
|
+
// Example: Tool events for built-in tools
|
|
447
|
+
.addHandler('tool:httpRequest:*', (data) => {
|
|
448
|
+
// Listen to ALL HTTP request tool events
|
|
449
|
+
console.log('HTTP Request Tool:', data);
|
|
437
450
|
});
|
|
438
451
|
```
|
|
439
452
|
|
|
@@ -441,10 +454,10 @@ agent
|
|
|
441
454
|
- `tool:<tool-name>:*` - All events for a specific tool
|
|
442
455
|
- `tool:<tool-name>:call` - Tool invocation/input events
|
|
443
456
|
- `tool:<tool-name>:response` - Tool output/result events
|
|
444
|
-
- `tool:<tool-name>:call:<method>` - Specific method calls (e.g., POST, GET)
|
|
445
|
-
- `tool:<tool-name>:response:<method>` - Specific method responses
|
|
446
457
|
- `tool:<tool-name>:error` - Tool-specific errors
|
|
447
458
|
|
|
459
|
+
**Note:** HTTP API routes (added via `.get()`, `.post()`, etc.) are part of the main HTTP server, not a separate tool. They don't emit tool events.
|
|
460
|
+
|
|
448
461
|
##### **3. System Events** (Legacy/System)
|
|
449
462
|
Traditional system-level events:
|
|
450
463
|
|
|
@@ -480,10 +493,6 @@ agent
|
|
|
480
493
|
console.log('Any tool activity:', data);
|
|
481
494
|
})
|
|
482
495
|
|
|
483
|
-
// Listen to all HTTP responses
|
|
484
|
-
.addHandler('tool:http-server:response:*', (data) => {
|
|
485
|
-
console.log('Any HTTP response:', data);
|
|
486
|
-
})
|
|
487
496
|
|
|
488
497
|
// Listen to all request outputs
|
|
489
498
|
.addHandler('request_output:*', (data) => {
|
|
@@ -517,7 +526,7 @@ agent
|
|
|
517
526
|
prompt: "User's input prompt",
|
|
518
527
|
response: "LLM's response",
|
|
519
528
|
conversationId: "unique-conversation-id",
|
|
520
|
-
context: { protocol: "
|
|
529
|
+
context: { protocol: "http" },
|
|
521
530
|
usage: { total_tokens: 150, prompt_tokens: 50, completion_tokens: 100 },
|
|
522
531
|
model: "gpt-3.5-turbo",
|
|
523
532
|
processingTime: 1250,
|
|
@@ -550,27 +559,20 @@ Each communication method can be enabled/disabled independently:
|
|
|
550
559
|
createAgent('flexible-agent')
|
|
551
560
|
// Configure direct prompting with specific settings
|
|
552
561
|
.setPromptingServer({
|
|
553
|
-
protocol: 'websocket',
|
|
554
562
|
port: 3000,
|
|
555
563
|
authentication: false,
|
|
556
564
|
maxConnections: 50
|
|
557
565
|
})
|
|
558
566
|
.disableDirectPrompting() // Disable if needed
|
|
559
567
|
|
|
560
|
-
// Enable HTTP API
|
|
561
|
-
.enableHttp({ port: 3001 })
|
|
562
|
-
|
|
563
568
|
// Listen to direct prompting events only
|
|
564
569
|
.addHandler('request_output', (data) => {
|
|
565
|
-
console.log('
|
|
570
|
+
console.log('HTTP response:', data.response);
|
|
566
571
|
})
|
|
567
572
|
|
|
568
|
-
// HTTP
|
|
573
|
+
// Add HTTP API routes (HTTP auto-enables)
|
|
569
574
|
.get('/api/status', (req, res) => {
|
|
570
575
|
res.json({ status: 'ok' });
|
|
571
|
-
})
|
|
572
|
-
.addHandler('tool:http-server:*', (data) => {
|
|
573
|
-
console.log('HTTP activity:', data);
|
|
574
576
|
});
|
|
575
577
|
```
|
|
576
578
|
|
|
@@ -629,7 +631,6 @@ module.exports = {
|
|
|
629
631
|
})
|
|
630
632
|
.setPrompt('You are a professional customer service representative.')
|
|
631
633
|
.setPromptingServer({
|
|
632
|
-
protocol: 'http',
|
|
633
634
|
port: 3000,
|
|
634
635
|
authentication: true,
|
|
635
636
|
maxConnections: 100
|
|
@@ -659,7 +660,6 @@ module.exports = {
|
|
|
659
660
|
})
|
|
660
661
|
.setPrompt('You are a data analysis expert.')
|
|
661
662
|
.setPromptingServer({
|
|
662
|
-
protocol: 'http',
|
|
663
663
|
port: 3001,
|
|
664
664
|
authentication: false,
|
|
665
665
|
maxConnections: 50
|
|
@@ -763,7 +763,6 @@ This metadata file is perfect for CI/CD pipelines to automatically configure you
|
|
|
763
763
|
"tag": "nodejs-20"
|
|
764
764
|
},
|
|
765
765
|
"promptingServer": {
|
|
766
|
-
"protocol": "http",
|
|
767
766
|
"port": 3000,
|
|
768
767
|
"authentication": false,
|
|
769
768
|
"maxConnections": 50,
|
package/bin/dank
CHANGED
|
@@ -90,6 +90,7 @@ program
|
|
|
90
90
|
.option('--registry <registry>', 'Docker registry URL (e.g., docker.io, ghcr.io)')
|
|
91
91
|
.option('--namespace <namespace>', 'Docker namespace/organization')
|
|
92
92
|
.option('--tag-by-agent', 'Use agent name as the image tag (common image name)')
|
|
93
|
+
.option('--base-image-override <image>', 'Override base image for all agents (production builds only)')
|
|
93
94
|
.option('--json', 'Output machine-readable JSON summary to stdout')
|
|
94
95
|
.option('--output-metadata <file>', 'Output deployment metadata JSON file')
|
|
95
96
|
.option('--force', 'Force rebuild without cache')
|