@indra.ai/deva 1.1.49 → 1.1.51
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/index.js +86 -83
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -76,8 +76,12 @@ class Deva {
|
|
|
76
76
|
config: 'Configuration Zone',
|
|
77
77
|
features: 'Feature Zone',
|
|
78
78
|
idle: 'Idle Zone',
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
training: 'Training Zone',
|
|
80
|
+
school: 'School Zone',
|
|
81
|
+
work: 'Work Zone',
|
|
82
|
+
fun: 'Fun Zone',
|
|
83
|
+
adventure: 'Adventure Zone',
|
|
84
|
+
party: 'Party Zone',
|
|
81
85
|
invalid: 'Invalid Invalid',
|
|
82
86
|
done: 'Done Zone',
|
|
83
87
|
error: 'Error Zone',
|
|
@@ -92,14 +96,16 @@ class Deva {
|
|
|
92
96
|
question_cmd: 'question:cmd',
|
|
93
97
|
question_method: 'question:method',
|
|
94
98
|
question_talk: 'question:talk',
|
|
95
|
-
question_hash: 'question:hash',
|
|
96
99
|
question_answer: 'question:answer',
|
|
97
100
|
question_done: 'question:done',
|
|
98
101
|
answer: 'answer',
|
|
99
|
-
answer_hash: 'hashing the answer',
|
|
100
102
|
answer_talk: 'sharing the answer',
|
|
101
103
|
ask: 'asking',
|
|
102
104
|
ask_answer: 'answering',
|
|
105
|
+
uid: 'create unique id',
|
|
106
|
+
hash: 'create hash',
|
|
107
|
+
cipher: 'encrypt data',
|
|
108
|
+
decipher: 'dencrypt data',
|
|
103
109
|
security: 'SECURITY',
|
|
104
110
|
Security: 'Security Feature',
|
|
105
111
|
support: 'SUPPORT',
|
|
@@ -130,63 +136,61 @@ class Deva {
|
|
|
130
136
|
|
|
131
137
|
this._feature = false;
|
|
132
138
|
this._features = {
|
|
133
|
-
security: '
|
|
134
|
-
Security: '
|
|
135
|
-
support: '
|
|
136
|
-
Support: '
|
|
137
|
-
services: '
|
|
138
|
-
Services: '
|
|
139
|
-
solutions: '
|
|
140
|
-
Solutions: '
|
|
141
|
-
systems: '
|
|
142
|
-
Systems: '
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
139
|
+
security: 'Security',
|
|
140
|
+
Security: 'SECURITY Feature',
|
|
141
|
+
support: 'Support',
|
|
142
|
+
Support: 'SUPPORT Feature',
|
|
143
|
+
services: 'Services',
|
|
144
|
+
Services: 'SERVICES',
|
|
145
|
+
solutions: 'Solutions',
|
|
146
|
+
Solutions: 'SOLUTIONS Feature',
|
|
147
|
+
systems: 'Systems',
|
|
148
|
+
Systems: 'SYSTEMS Feature',
|
|
149
|
+
research: 'Research',
|
|
150
|
+
Research: 'RESEARCH Feature',
|
|
151
|
+
development: 'Development',
|
|
152
|
+
Development: 'DEVELOPMENT Feature',
|
|
153
|
+
business: 'Business',
|
|
154
|
+
Business: 'BUSINESS Feature',
|
|
155
|
+
legal:'Legal',
|
|
156
|
+
Legal:'LEGAL Feature',
|
|
157
|
+
assistant: 'Assistant',
|
|
158
|
+
Assistant: 'ASSISTANT Feature',
|
|
159
|
+
story: 'Story',
|
|
160
|
+
Story: 'STORY Feature',
|
|
161
|
+
mind: 'Story',
|
|
162
|
+
Mind: 'MIND Feature',
|
|
155
163
|
error: 'Feature Error',
|
|
156
|
-
done: '
|
|
164
|
+
done: 'Features Done',
|
|
157
165
|
};
|
|
158
166
|
|
|
159
167
|
this._messages = {
|
|
160
168
|
states: {
|
|
161
|
-
offline:
|
|
162
|
-
online:
|
|
169
|
+
offline: `🛌 ${this._agent.profile.name} ${this._states.offline}`,
|
|
170
|
+
online: `🌞 ${this._agent.profile.name} ${this._states.online}`,
|
|
163
171
|
ask: `😎 ${this._agent.profile.name} ${this._states.ask}`,
|
|
164
172
|
question: `🎙️ ${this._agent.profile.name} ${this._states.question}`,
|
|
165
173
|
answer: `🎟️ ${this._agent.profile.name} ${this._states.answer}`,
|
|
166
|
-
offline: `${this._agent.profile.name} ${this._states.offline}`,
|
|
167
|
-
online: `${this._agent.profile.name} ${this._states.online}`,
|
|
168
174
|
init: `🚀 ${this._agent.profile.name} ${this._states.init}`,
|
|
169
|
-
start:
|
|
170
|
-
enter:
|
|
175
|
+
start: `🚙 ${this._agent.profile.name} ${this._states.start}`,
|
|
176
|
+
enter: `🪐 ${this._agent.profile.name} ${this._states.enter}`,
|
|
171
177
|
stop: `✋ ${this._agent.profile.name} ${this._states.stop}`,
|
|
172
178
|
exit: `🚪 ${this._agent.profile.name} ${this._states.exit}`,
|
|
173
179
|
load: `📫 ${this._agent.profile.name} is ${this._states.load}`,
|
|
174
180
|
unload: `📭 ${this._agent.profile.name} is ${this._states.unload}`,
|
|
175
|
-
uid:
|
|
176
|
-
hash: `${this._agent.profile.name} ${this._states.hash}`,
|
|
177
|
-
cipher: `${this._agent.profile.name} ${this._states.cipher}`,
|
|
178
|
-
decipher: `${this._agent.profile.name} ${this._states.decipher}`,
|
|
181
|
+
uid: `🔑 ${this._agent.profile.name} ${this._states.uid}`,
|
|
179
182
|
invalid: `⚠️ ${this._agent.profile.name} ${this._states.invalid}`,
|
|
180
183
|
done: `✅ ${this._agent.profile.name} ${this._states.done}`,
|
|
181
184
|
error: `❌ ${this._states.error}`,
|
|
182
185
|
},
|
|
183
186
|
zones: {
|
|
184
187
|
deva: `🎉 ${this._agent.profile.name} ${this._zones.deva}`,
|
|
185
|
-
config:
|
|
188
|
+
config: `🦾 ${this._agent.profile.name} ${this._zones.config}`,
|
|
186
189
|
features: `🍿 ${this._agent.profile.name} ${this._zones.features}`,
|
|
187
|
-
idle:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
idle: `😜 ${this._agent.profile.name} ${this._zones.idle}`,
|
|
191
|
+
training: `🥋 ${this._agent.profile.name} ${this._zones.train}`,
|
|
192
|
+
school: `👨🏫 ${this._agent.profile.name} ${this._zones.work}`,
|
|
193
|
+
work: `🗂️ ${this._agent.profile.name} ${this._zones.work}`,
|
|
190
194
|
invalid: `⚠️ ${this._agent.profile.name} ${this._zones.invalid}`,
|
|
191
195
|
done: `✅ ${this._agent.profile.name} ${this._zones.done}`,
|
|
192
196
|
error: `❌ ${this._agent.profile.name} ${this._zones.error}`,
|
|
@@ -199,7 +203,6 @@ class Deva {
|
|
|
199
203
|
question_cmd: `🎮 ${this._agent.profile.name} issue command`,
|
|
200
204
|
question_method: `🏄♂️ ${this._agent.profile.name} ${this._actions.question_method}`,
|
|
201
205
|
question_talk: `📢 ${this._agent.profile.name} ${this._actions.question_talk}`,
|
|
202
|
-
question_hash: `#️⃣ ${this._agent.profile.name} hash question`,
|
|
203
206
|
question_answer: `🎙️ ${this._agent.profile.name} ${this._actions.question_answer}`,
|
|
204
207
|
question_done: `👍 ${this._agent.profile.name} ${this._actions.question_done}`,
|
|
205
208
|
answer: `🎟️ ${this._agent.profile.name} gave an ${this._actions.answer}`,
|
|
@@ -207,27 +210,34 @@ class Deva {
|
|
|
207
210
|
ask: `👥 ${this._agent.profile.name} asking`,
|
|
208
211
|
ask_answer: `🎟️ ${this._agent.profile.name} answering ask`,
|
|
209
212
|
|
|
213
|
+
uid: `🆔 ${this._agent.profile.name} ${this._actions.uid}`,
|
|
214
|
+
hash: `🔏 ${this._agent.profile.name} ${this._actions.hash}`,
|
|
215
|
+
cipher: `🔒 ${this._agent.profile.name} ${this._actions.cipher}`,
|
|
216
|
+
decipher: `🔓 ${this._agent.profile.name} ${this._actions.decipher}`,
|
|
217
|
+
|
|
210
218
|
security: `${this._features.security} action`,
|
|
211
219
|
Security: `${this._features.Security} ready`,
|
|
212
220
|
support: `${this._features.support} action`,
|
|
213
221
|
Support: `${this._features.Support} ready`,
|
|
214
|
-
services: `${this._features.
|
|
222
|
+
services: `${this._features.services} action`,
|
|
215
223
|
Services: `${this._features.Services} ready`,
|
|
216
224
|
solutions: `${this._features.solutions} action`,
|
|
217
225
|
Solutions: `${this._features.Solutions} ready`,
|
|
218
|
-
|
|
226
|
+
systems: `${this._features.systems} action`,
|
|
219
227
|
Systems: `${this._features.Systems} ready`,
|
|
228
|
+
research: `${this._features.research} action`,
|
|
229
|
+
Research: `${this._features.Research} ready`,
|
|
220
230
|
development: `${this._features.Development} action`,
|
|
221
231
|
Development: `${this._features.Development} ready`,
|
|
222
|
-
business: `${this._features.
|
|
232
|
+
business: `${this._features.business} action`,
|
|
223
233
|
Business: `${this._features.Business} ready`,
|
|
224
|
-
legal: `${this._features.
|
|
234
|
+
legal: `${this._features.legal} action`,
|
|
225
235
|
Legal: `${this._features.Legal} ready`,
|
|
226
|
-
assistant: `${this._features.
|
|
236
|
+
assistant: `${this._features.assistant} action`,
|
|
227
237
|
Assistant: `${this._features.Assistant} ready`,
|
|
228
|
-
story: `${this._features.
|
|
238
|
+
story: `${this._features.story} action`,
|
|
229
239
|
Story: `${this._features.Story} ready`,
|
|
230
|
-
mind: `${this._features.
|
|
240
|
+
mind: `${this._features.mind} action`,
|
|
231
241
|
Mind: `${this._features.Mind} ready`,
|
|
232
242
|
client_data: `📂 ${this._agent.profile.name} configure`,
|
|
233
243
|
invalid: `${this._actions.invalid}`,
|
|
@@ -235,27 +245,29 @@ class Deva {
|
|
|
235
245
|
error: `${this._action.error}`,
|
|
236
246
|
},
|
|
237
247
|
features: {
|
|
238
|
-
security:
|
|
239
|
-
Security:
|
|
240
|
-
support:
|
|
241
|
-
Support:
|
|
242
|
-
services:
|
|
243
|
-
Services:
|
|
244
|
-
solutions:
|
|
245
|
-
Solutions:
|
|
246
|
-
systems:
|
|
247
|
-
Systems:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
248
|
+
security: `🔐 ${this._features.security} feature`,
|
|
249
|
+
Security: `🔐 ${this._features.Security} configure`,
|
|
250
|
+
support: `💼 ${this._features.support} feature`,
|
|
251
|
+
Support: `💼 ${this._features.Support} configure`,
|
|
252
|
+
services: `🛠️ ${this._features.services} feature`,
|
|
253
|
+
Services: `🛠️ ${this._features.Services} configure`,
|
|
254
|
+
solutions: `💡 ${this._features.solutions} feature`,
|
|
255
|
+
Solutions: `💡 ${this._features.Solutions} configure`,
|
|
256
|
+
systems: `🖥️ ${this._features.systems} feature`,
|
|
257
|
+
Systems: `🖥️ ${this._features.Systems} configure`,
|
|
258
|
+
research: `🔍 ${this._features.research} feature`,
|
|
259
|
+
Research: `🔍 ${this._features.Research} configure`,
|
|
260
|
+
development: `🔧 ${this._features.development} feature`,
|
|
261
|
+
Development: `🔧 ${this._features.Development} configure`,
|
|
262
|
+
business: `📊 ${this._features.business} feature`,
|
|
263
|
+
Business: `📊 ${this._features.Business} configure`,
|
|
264
|
+
legal: `⚖️ ${this._features.legal} feature`,
|
|
265
|
+
Legal: `⚖️ ${this._features.Legal} configure`,
|
|
266
|
+
assistant: `👤 ${this._features.assistant} feature`,
|
|
267
|
+
Assistant: `👤 ${this._features.Assistant} configure`,
|
|
268
|
+
story: `📚 ${this._features.story} feature`,
|
|
269
|
+
Story: `📚 ${this._features.Story} configure`,
|
|
270
|
+
mind: `${this._features.story} feature`,
|
|
259
271
|
Mind: `${this._features.Mind} configure`,
|
|
260
272
|
invalid: `⚠️ ${this._features.invalid}`,
|
|
261
273
|
done: `✅ ${this._features.done}`,
|
|
@@ -410,7 +422,6 @@ class Deva {
|
|
|
410
422
|
global: systems.global, // the global policies for client
|
|
411
423
|
personal: systems.devas[this._agent.key] // Client personal features and rules.
|
|
412
424
|
};
|
|
413
|
-
console.log('SYSTEMS FEATURE SETUP', this._systems);
|
|
414
425
|
delete this._client.features.systems
|
|
415
426
|
return this.Solutions()
|
|
416
427
|
}
|
|
@@ -938,7 +949,6 @@ class Deva {
|
|
|
938
949
|
}
|
|
939
950
|
|
|
940
951
|
// hash the question
|
|
941
|
-
this.action('question_hash'); // set the has question state
|
|
942
952
|
packet.q.meta.hash = this.hash(JSON.stringify(packet.q));
|
|
943
953
|
|
|
944
954
|
this.action(_action);
|
|
@@ -1014,11 +1024,9 @@ class Deva {
|
|
|
1014
1024
|
};
|
|
1015
1025
|
|
|
1016
1026
|
// create a hash for the answer and insert into answer meta.
|
|
1017
|
-
this.action('answer_hash');
|
|
1018
1027
|
packet_answer.meta.hash = this.hash(JSON.stringify(packet_answer));
|
|
1019
1028
|
|
|
1020
1029
|
packet.a = this.copy(packet_answer);
|
|
1021
|
-
this.action('packet_hash');
|
|
1022
1030
|
packet.hash = this.hash(JSON.stringify(packet)); // hash the entire packet.
|
|
1023
1031
|
|
|
1024
1032
|
|
|
@@ -1695,6 +1703,7 @@ class Deva {
|
|
|
1695
1703
|
is shared.
|
|
1696
1704
|
***************/
|
|
1697
1705
|
uid(guid=false) {
|
|
1706
|
+
this.action('uid');
|
|
1698
1707
|
let id;
|
|
1699
1708
|
if (guid) {
|
|
1700
1709
|
id = randomUUID()
|
|
@@ -1717,6 +1726,7 @@ class Deva {
|
|
|
1717
1726
|
The hash algorithm will take a string of text and produce a hash.
|
|
1718
1727
|
***************/
|
|
1719
1728
|
hash(str, algo=false) {
|
|
1729
|
+
this.action('hash');
|
|
1720
1730
|
algo = algo || this._security.hash || 'md5';
|
|
1721
1731
|
const the_hash = createHash(algo);
|
|
1722
1732
|
the_hash.update(str);
|
|
@@ -1732,6 +1742,7 @@ class Deva {
|
|
|
1732
1742
|
defined client security settings.
|
|
1733
1743
|
***************/
|
|
1734
1744
|
cipher(str) {
|
|
1745
|
+
this.action('cipher');
|
|
1735
1746
|
const security = this._security;
|
|
1736
1747
|
const {password, algorithm} = security.cipher;
|
|
1737
1748
|
const key = createHash('sha256').update(String(password)).digest('base64');
|
|
@@ -1742,14 +1753,6 @@ class Deva {
|
|
|
1742
1753
|
const _cipher = createCipheriv(algorithm, key_in_bytes, iv);
|
|
1743
1754
|
const encrypted = _cipher.update(String(str), 'utf8', 'hex') + _cipher.final('hex');
|
|
1744
1755
|
|
|
1745
|
-
this.state('cipher', {
|
|
1746
|
-
id: this.uid(true),
|
|
1747
|
-
iv,
|
|
1748
|
-
key,
|
|
1749
|
-
agent_id: this._agent.id,
|
|
1750
|
-
client_id: this._client.id,
|
|
1751
|
-
created: Date.now()
|
|
1752
|
-
});
|
|
1753
1756
|
|
|
1754
1757
|
return {
|
|
1755
1758
|
iv: iv.toString('base64'),
|
|
@@ -1758,6 +1761,7 @@ class Deva {
|
|
|
1758
1761
|
}
|
|
1759
1762
|
}
|
|
1760
1763
|
decipher(opt) {
|
|
1764
|
+
this.action('decipher');
|
|
1761
1765
|
const iv = Buffer.from(opt.iv, 'base64');
|
|
1762
1766
|
const encrypted = Buffer.from(opt.encrypted, 'hex');
|
|
1763
1767
|
const key_in_bytes = Buffer.from(opt.key, 'base64')
|
|
@@ -1766,7 +1770,6 @@ class Deva {
|
|
|
1766
1770
|
const decipher = createDecipheriv( algorithm, key_in_bytes, iv);
|
|
1767
1771
|
const decrypted = decipher.update(encrypted);
|
|
1768
1772
|
const final = Buffer.concat([decrypted, decipher.final()]);
|
|
1769
|
-
this.state('decipher');
|
|
1770
1773
|
return final.toString();
|
|
1771
1774
|
}
|
|
1772
1775
|
|