Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework
npm install @indra.ai/devaThe Deva module is a JavaScript library for building multi-agent systems that can communicate with each other and with external services. It provides a unified API for creating agents and defining their behaviors, and includes tools for handling communication between agents and for integrating with third-party APIs. The Deva module is designed to be flexible and customizable, allowing developers to easily create complex systems that can perform a wide range of tasks, from data collection and analysis to chatbot interactions and image generation. The module is written in JavaScript and can be used with Node.js, making it easy to integrate with other JavaScript libraries and tools.
1. Security Feature
2. Guard Feature
3. Defense Feature
4. Support Feature
5. Services Feature
6. Systems Feature
7. Networks Feature
8. Legal Feature
9. Justice Feature
10. Authority Feature
These core features work together to provide a comprehensive and robust platform for users, covering essential aspects such as security, support, services, Legal, Authority, and more.
1. Class Structure: The code follows an object-oriented programming approach by defining a Deva class. This allows for encapsulation of properties and methods related to the agent.
2. State Management: The Deva class has a state management system represented by the _state property and the _states object. It allows the agent to transition between different states and perform actions based on the current state.
3. Event System: The code utilizes an event system by extending the EventEmitter class and creating an events object. This enables communication and collaboration between different components of the agent and other entities in the system.
4. Modularity and Inheritance: The code demonstrates modularity by separating functionalities into different objects such as config, lib, methods, and listeners. It also showcases inheritance by assigning inherited properties to child Deva instances.
5. Error Handling: The code includes an error handling mechanism through the error method. It allows for uniform error reporting and the execution of custom error handling logic.
6. Promises: Promises are used in several asynchronous operations, such as initializing the agent, loading Deva models, and handling method calls. Promises ensure that the code can handle asynchronous operations in a structured and controlled manner.
7. Event-driven Architecture: The code follows an event-driven architecture where different events trigger specific actions or callbacks. This enables loose coupling and flexibility in the agent's behavior and interactions with other components.
8. Extensibility: The code provides hooks for custom logic through methods like onInit, onStart, onStop, onEnter, onExit, and onDone. These allow developers to extend the functionality of the agent by adding custom code at specific stages of its lifecycle.
9. Messaging and Communication: The talk and listen methods facilitate messaging and communication between agents. Agents can ask questions (ask method) and receive responses, enabling interaction and collaboration.
10. Utility Functions: The code includes utility functions like generating unique IDs (uid method), hashing data (hash method), and handling event listeners (listen, once, ignore methods).
deva.agent object stores the Agent Profile.this.vars object.deva can add modules to add to their functionality.deva the internal functionality is written here.deva abilities to external commands/calls.deva is doing things.deva there are utility functions available to make actions easier like getting a unique id or status.bash
$ npm i @indra.ai/deva --save
`structure
`javascript
import Deva from '@indra.ai/deva';
import pkg from './package.json' with {type:'json'};
const {agent,vars} = pkg.data;// set the __dirname
import {dirname} from 'node:path';
import {fileURLToPath} from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const info = {
id: pkg.id,
name: pkg.name,
describe: pkg.description,
version: pkg.version,
url: pkg.homepage,
dir: __dirname,
git: pkg.repository.url,
bugs: pkg.bugs.url,
author: pkg.author,
license: pkg.license,
copyright: pkg.copyright,
};
const DEVA = new Deva({
info, // info packet to store entity meta information.
agent, // the agent profile from the package data.
vars, // the variables the agent uses from the package data.
utils: {
translate(input) {return input.trim();},
parse(input) {return input.trim();},
process(input) {return input.trim();}
},
listeners: {},
modules: {},
deva: {},
func: {
list(opts) {
return [
"test 1",
"test 2",
"test 3",
]
}
},
methods: {
list(packet) {
this.context('list', packet.id);
this.action('method',
list:${packet.id});
return new Promise((resolve, reject) => {
try {
const data = this.func.data(packet.q);
return resolve({
text: See Data,
html: See Data,
data,
});
} catch (err) {
return this.error(err, packet, reject);
}
});
}
},
onReady(data, resolve) {
this.prompt(this.vars.messages.ready);
return resolve(data);
},
onError(err, data, reject) {
this.prompt(this.vars.messages.error);
console.log(err);
return reject(err);
}
});
export default DEVA
`agent
`javascript
this.agent();
`$3
- id: The Agent id generated by
this.uid().
- key: The key to reference the agent by on the network.
- prompt: The prompt configuration for the entity.
- emoji: The emoji the for the agent.
- text: Algorithm,
- colors: The colors for the agent on the prompt. As each agent can set custom prompt colors.
- label: The label colors for the agent prompt.
- R: The red value 0 to 255.
- G: The green value 0 to 255.
- B: The blue value 0 to 255.
- text: The text colors for the agent prompt.
- R: The red value 0 to 255.
- G: The green value 0 to 255.
- B: The blue value 0 to 255.
- profile: The Agent profile configuration data.
- name: The name of the agent.
- hashtag: The hashtag to reference the agent by.
- title: Title of the Agent for media display.
- subtitle: Subtitle of the agent for extra context.
- describe: Short description of the agent to build from.
- tweet: The tweet/post that the agent will share about itself.
- hashtags: Comma list of hashtags to add when posting tweets/posts.
- pronouns: The pronounds the agent will be going by.
- gender: The gender of the agent as pronouns are how they identify and gender is their orientation.
- style: The personal style that reflects the agent/entity.
- voice: The voice profile the entity will use when speaking.
- system: The system the entity/agent is assigned to.
- layout: The display layout templte the entity uses for their personal presentation.
- color: The text color for the presentation layer.
- bgcolor: The background color for the entity presentatino layer.
- emoji: A graphic that represents the entity personal emoji.
- avatar: A graphic that represents the entity/agent personal avatar.
- image: A graphic that represents the entity overall image.
- background: The background graphic for the presentation layer.
- owner: The name of the owner of the agent/entity.
- creator: The name of the creator of the agent/entity.
- created: The date and time the entity/agent was created.vars
`javascript
this.vars
`The vars can be use to set local variables for the deva that need to be used in your program.
There are no default variables, so the scope is for you and your imagination to figure out.
$3
`javascript
vars: {
foo: 'bar',
steps: 10,
strings: 'Some variable string',
adding: 1 + 9 + 11,
objects: {
key: 'key value'
},
arrays: [
'value 1',
'value 2',
]
}
`listeners
Listeners are what you setup that allow your Deva to communicate with other Deva or parts of your application/system.`javascript
this.listeners
`$3
Each Deva comes with a set of default listeners to provide basic functionality.
$3
This will trigger an event to start the Deva.`javascript
this.talk(agent_key:start);
`$3
This will trigger an event to stop the Deva.`javascript
this.talk(agent_key:stop);
`$3
This will trigger an event to broadcast the Deva status.`javascript
this.talk(agent_key:status);
`devas
`javascript
this.devas
`The main object for Deva that are bwlow this Deva.
modules
The external modules that your Deva might require to function.
`javascript
this.modules
`func
The functions that your deva uses to operate. Functions are not exposed through
the api to public access.`javascript
this.func
`$3
`javascript
this.methods
`The methods are exposed publicly through the question event that parses a string
and sends a request to the question method that then interacts with functions, modules, and variables.
states
Provided are a set of state functions that trigger when a Deva is at various states of starting/stopping.$3
The
onStart() function runs after the start function has completed.`javascript
this.onStart() {
// some code to run when the deva starts.
}
`$3
The
onStop() function runs after the stop function has completed.`javascript
this.onStop() {
// some code to run when the deva stops
}
`$3
The
onEnter() function runs after the enter event has fired.`javascript
this.onEnter() {
// some code to run when the deva is loaded
}
`$3
The
onExit()function runs after the exit event has fired.`javascript
this.onExit() {
// some code to run when the deva logs out.
}
`$3
The
onDone()function runs after the done event has fired.`javascript
this.onDone() {
// some code to run when the deva logs out.
}
`$3
The
onInit() function runs after the init() function has completed.`javascript
this.onInit() {
// some code to run when the Deva initializes.
}
`utility
$3
The question event is the functionality that exposes the methods to the outside world. When a deva asks a question the string is parsed into a question format so that commands to access various methods can be exposed.
The
question(packet) function is a default function that allows the system to ask questions of itself or other Deva.The function checks the beginning of a string for a
# to determine wether to issue a command to run a specific method.See Question Listener for usage.
`javascript
// async await
const question = await this.question('#agent_key method:params question string');// promises
this.question('#agent_key method:params question string').then(response => {
...
}).catch(err => {
...
})
`$3
Generates a unique ID that is used in packet transfer and other various ways.`javascript
this.uid() // inside the object// example
this.vars.id = this.uid()
`$3
The
talk() function is used when your Deva needs to broadcast an event that other Deva
or functions would be listening for.`javascript
this.talk('event', resource); // inside the object
deva.talk('event', resource); // outside the object// example
const evt_id = this.uid();
const evt_data = {
task_id: 1,
task_name: 'this is blank data',
task_contact: 'joe@schmo.com',
};
this.talk('big-event', {
id: evt_id,
key: this.me.key,
q: {
bot: this.me,
text: 'text to send to the event',
data: evt_data,
},
created: Date.now(),
});
`$3
The
listen function can assign listeners to the Deva and designate which callback
function to run when an event is fired.Listeners can be set up individually this way or also added to the listeners object
independently.
`javascript
this.listen('some-event', this.func.listener);this.func.listenter = packet => {
console.log('some-event-fired');
};
`$3
The
once() function can assign a one-time listener to a function. This is useful when returning data with an id that one Deva has submitted to another Deva. Also very useful for submit responses that are unique to the request.`javascript
this.once(some-once-event, this.func.listener)
this.func.listener = packet => {
console.log('some-once-event-fired');
}`$3
The
ignore() function removes a listener from the designated event. This is useful for adding and removing events dynamically or as needed.`javascript
this.ignore('ignore-event', this.func.listener);
this.func.listener = packet => {
console.log('ignore-event-fired');
}
`
$3
To add a Deva dynamically use the
load() function. This can be utilized to add Deva to an existing Deva after the object has already been created.`javascript
const opts = {
agent: {...},
vars: {...},
listeners: {...},
deva: {...},
func: {...},
onStart() {},
onStop() {},
onEnter() {},
onExit() {},
}
this.load('deva-name', opts);
`$3
To delete a Deva for any reason use unload(). This will delete the Deva and all it's parts from the current Deva.`javascriptthis.unload('deva-key');
`$3
The status() function will return the running status of the current Deva.$3
The start() function will start the Deva and run the onStart() state function.$3
The stop() function will stop the Deva and run the onStop() state function.$3
The init() function will initialize the Deva and run the onInit()` state function.---
Copyright ©2000-2026 Quinn A Michaels; All rights reserved.
Legal Signature Required For Lawful Use.
Distributed under VLA:71393644869653248038 LICENSE.md
Saturday, January 3, 2026 - 3:53:46 PM