dank-ai 1.0.35 → 1.0.37

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
@@ -533,22 +533,7 @@ agent
533
533
  }
534
534
  ```
535
535
 
536
- **Tool HTTP Event Data:**
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
 
package/lib/agent.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  const Joi = require('joi');
9
+ const { validate: validateUUID } = require('uuid');
9
10
  const { DEFAULT_CONFIG, SUPPORTED_LLMS, DOCKER_CONFIG, INSTANCE_TYPES } = require('./constants');
10
11
  const { ToolRegistry, ToolExecutor } = require('./tools');
11
12
  const builtinTools = require('./tools/builtin');
@@ -15,7 +16,8 @@ class DankAgent {
15
16
  this.name = name;
16
17
  this.config = this._validateConfig(config);
17
18
  this.handlers = new Map();
18
- this.id = this._generateId();
19
+ // id is required and must be set via setId() - validated in _validateConfig
20
+ this.id = this.config.id;
19
21
  this.status = 'defined'; // defined, building, running, stopped, error
20
22
  this.containerId = null;
21
23
  this.createdAt = new Date().toISOString();
@@ -51,6 +53,33 @@ class DankAgent {
51
53
  return this;
52
54
  }
53
55
 
56
+ /**
57
+ * Set the unique ID for this agent (required, must be UUIDv4)
58
+ * @param {string} id - UUIDv4 string that must be unique and never used before
59
+ */
60
+ setId(id) {
61
+ if (!id || typeof id !== 'string') {
62
+ throw new Error('Agent ID must be a non-empty string');
63
+ }
64
+
65
+ const trimmedId = id.trim();
66
+
67
+ // Validate UUIDv4 format
68
+ if (!validateUUID(trimmedId)) {
69
+ throw new Error(`Agent ID must be a valid UUIDv4. Received: ${trimmedId}`);
70
+ }
71
+
72
+ // Check if it's actually v4 (UUIDv4 has '4' in the version position)
73
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
74
+ if (!uuidRegex.test(trimmedId)) {
75
+ throw new Error(`Agent ID must be a valid UUIDv4. Received: ${trimmedId}`);
76
+ }
77
+
78
+ this.config.id = trimmedId;
79
+ this.id = trimmedId;
80
+ return this;
81
+ }
82
+
54
83
  /**
55
84
  * Set the system prompt for the agent
56
85
  */
@@ -611,7 +640,29 @@ class DankAgent {
611
640
  * Validate agent configuration
612
641
  */
613
642
  _validateConfig(config) {
643
+ // Validate ID separately (must be UUIDv4)
644
+ if (!config.id) {
645
+ throw new Error('Agent ID is required. Use .setId(uuidv4) to set a unique UUIDv4 identifier.');
646
+ }
647
+
648
+ if (typeof config.id !== 'string') {
649
+ throw new Error('Agent ID must be a string');
650
+ }
651
+
652
+ const trimmedId = config.id.trim();
653
+ if (!validateUUID(trimmedId)) {
654
+ throw new Error(`Agent ID must be a valid UUIDv4. Received: ${trimmedId}`);
655
+ }
656
+
657
+ // Check if it's actually v4 (UUIDv4 has '4' in the version position)
658
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
659
+ if (!uuidRegex.test(trimmedId)) {
660
+ throw new Error(`Agent ID must be a valid UUIDv4. Received: ${trimmedId}`);
661
+ }
662
+
614
663
  const schema = Joi.object({
664
+ id: Joi.string().required(), // Required UUIDv4 - validated above
665
+
615
666
  llm: Joi.object({
616
667
  provider: Joi.string().valid(...SUPPORTED_LLMS).required(),
617
668
  apiKey: Joi.string().allow('').default(''),
@@ -686,12 +737,6 @@ class DankAgent {
686
737
  return value;
687
738
  }
688
739
 
689
- /**
690
- * Generate a unique ID
691
- */
692
- _generateId() {
693
- return `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
694
- }
695
740
 
696
741
  /**
697
742
  * Serialize handlers for storage (functions can't be serialized)
package/lib/cli/init.js CHANGED
@@ -93,6 +93,11 @@ async function initCommand(projectName, options) {
93
93
  console.log(chalk.gray(' 2. Run "npm install" to install dependencies'));
94
94
  console.log(chalk.gray(' 3. Edit dank.config.js to configure your agents'));
95
95
  console.log(chalk.gray(' 4. Run "dank run" to start your agents'));
96
+ console.log(chalk.yellow('\nšŸ“ Note about Agent IDs:'));
97
+ console.log(chalk.gray(' - Unique UUIDv4 IDs have been generated for each agent'));
98
+ console.log(chalk.gray(' - These IDs are stored in dank.config.js as AGENT_IDS constants'));
99
+ console.log(chalk.gray(' - Once agents register with Dank Cloud, these IDs become locked to your account'));
100
+ console.log(chalk.gray(' - You can generate new UUIDs if needed: require(\'uuid\').v4()'));
96
101
  console.log(chalk.gray('\nFor more information, visit: https://github.com/your-org/dank'));
97
102
 
98
103
  process.exit(0);
@@ -334,6 +339,16 @@ Handle agent lifecycle and errors:
334
339
  })
335
340
  \`\`\`
336
341
 
342
+ ## Agent IDs (UUIDv4)
343
+
344
+ Each agent in your project has a unique UUIDv4 identifier that is automatically generated when you initialize your project. These IDs are stored in \`dank.config.js\` as constants in the \`AGENT_IDS\` object.
345
+
346
+ **Important Notes:**
347
+ - Agent IDs are generated automatically during project initialization
348
+ - These IDs uniquely identify your agents across deployments
349
+ - Once agents register with Dank Cloud services, these IDs become locked to your account
350
+ - You can generate new UUIDs if needed: \`require('uuid').v4()\`
351
+
337
352
  ## Configuration
338
353
 
339
354
  Edit \`dank.config.js\` to:
@@ -343,6 +358,7 @@ Edit \`dank.config.js\` to:
343
358
  - Configure event handlers
344
359
  - Set Docker and resource limits
345
360
  - Enable/disable communication features
361
+ - Manage agent IDs (UUIDv4 identifiers)
346
362
 
347
363
  ## Documentation
348
364
 
@@ -91,6 +91,7 @@ function extractAgentMetadata(agent, buildOptions, imageName) {
91
91
  };
92
92
 
93
93
  return {
94
+ id: agent.id, // Agent UUIDv4 identifier from setId()
94
95
  name: agent.name,
95
96
  imageName: imageName,
96
97
  baseImage: {
package/lib/project.js CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  const fs = require('fs-extra');
8
8
  const path = require('path');
9
+ const { v4: uuidv4 } = require('uuid');
9
10
 
10
11
  class DankProject {
11
12
  constructor(name, options = {}) {
@@ -56,15 +57,33 @@ class DankProject {
56
57
 
57
58
  const requirePath = isDevelopment ? '../lib/index.js' : 'dank-ai';
58
59
 
60
+ // Generate UUIDv4 IDs for each agent in the template
61
+ const promptAgentId = uuidv4();
62
+
59
63
  return `/**
60
64
  * Dank Agent Configuration
61
65
  *
62
66
  * This file defines your AI agents and their configurations.
63
67
  * Run 'dank run' to start all defined agents.
68
+ *
69
+ * IMPORTANT: Agent IDs (UUIDv4)
70
+ * ==============================
71
+ * Each agent has a unique UUIDv4 identifier that is generated when you initialize
72
+ * your project. These IDs are used to identify and track your agents.
73
+ *
74
+ * - You can generate new UUIDv4s if needed (use: require('uuid').v4())
75
+ * - Once agents register with Dank Cloud services using these IDs, they become
76
+ * locked in and owned by your account
64
77
  */
65
78
 
66
79
  const { createAgent } = require('${requirePath}');
67
80
 
81
+ // Agent IDs - Generated UUIDv4 identifiers for each agent
82
+ // These IDs are used to uniquely identify your agents across deployments
83
+ const AGENT_IDS = {
84
+ PROMPT_AGENT: '${promptAgentId}'
85
+ };
86
+
68
87
  module.exports = {
69
88
  // Project configuration
70
89
  name: '${this.name}',
@@ -74,6 +93,7 @@ module.exports = {
74
93
  agents: [
75
94
  // Example 1: Direct Prompting Agent with Event Handlers
76
95
  createAgent('prompt-agent')
96
+ .setId(AGENT_IDS.PROMPT_AGENT) // Required: Unique UUIDv4 identifier
77
97
  .setLLM('openai', {
78
98
  apiKey: process.env.OPENAI_API_KEY,
79
99
  model: 'gpt-3.5-turbo',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dank-ai",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Dank Agent Service - Docker-based AI agent orchestration platform",
5
5
  "main": "lib/index.js",
6
6
  "exports": {