@indra.ai/deva
Version:
The Deva Core
95 lines (88 loc) β’ 2.37 kB
JavaScript
// Copyright (c)2025 Quinn Michaels
// Distributed under the MIT software license, see the accompanying
// file LICENSE.md or http://www.opensource.org/licenses/mit-license.php.
const client = require('./client.json').DATA;
const agent = require('./agent.json').DATA;
const Deva = require('../index');
const HelloWorld = new Deva({
client: {
id: 100,
key: 'hello',
},
agent: {
id: agent.id,
key: agent.key,
prompt: agent.prompt,
voice: agent.voice,
profile: agent.profile,
features: agent.features,
translate(input) {
return input.trim();
},
parse(input) {
return input.trim();
}
},
vars: agent.vars,
listeners: {
'devacore:prompt'(packet) {
console.log(`p: @${packet.agent.key}:${packet.text}`);
},
'devacore:state'(packet) {
console.log(`πͺ state > ${packet.text}`);
},
'devacore:zone'(packet) {
console.log(`πΊοΈ zone > ${packet.agent.profile.name} is in the ${packet.text} zone`);
},
'devacore:action'(packet) {
console.log(`π₯ action > ${packet.agent.profile.name} get ${packet.text}`);
},
'devacore:feature'(packet) {
console.log(`πΏ feature > ${packet.agent.profile.name} ${packet.text}`);
},
'devacore:error'(packet) {
console.log(`β error > ${packet.agent.profile.name} ${packet.text}`);
},
},
devas: {},
modules: {},
func: {
test(packet) {
const text = this._state
const id = this.uid();
const uuid = this.uid(true);
const cipher = this.cipher(JSON.stringify(packet));
const decipher = this.decipher(cipher);
const data = {
id,
uuid,
text,
hash: {
md5: this.hash(JSON.stringify(packet)),
sha256: this.hash(JSON.stringify(packet), 'sha256'),
sha512: this.hash(JSON.stringify(packet), 'sha512'),
created: this.formatDate(Date.now(), 'long'),
},
cipher,
decipher
}
console.log(data)
return Promise.resolve({
text: packet.a.text,
data,
});
}
},
methods: {
test(packet) {
return this.func.test(packet);
}
},
onError(e) {
console.log(e);
}
});
HelloWorld.init(client);
// HelloWorld.question('/hello hello there').then(hello => {
// console.log('hello', hello);
// });