@indra.ai/deva 1.1.98 → 1.1.100
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/config.json +19 -9
- package/index.js +68 -59
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"unload": "unloading",
|
|
43
43
|
"invalid": "invalid state",
|
|
44
44
|
"done": "done state",
|
|
45
|
-
"
|
|
45
|
+
"finish": "finish state",
|
|
46
|
+
"error": "error state",
|
|
47
|
+
"help": "help state"
|
|
46
48
|
},
|
|
47
49
|
"zone": false,
|
|
48
50
|
"zones": {
|
|
@@ -58,11 +60,13 @@
|
|
|
58
60
|
"party": "Party Zone",
|
|
59
61
|
"invalid": "Invalid Invalid",
|
|
60
62
|
"done": "Done Zone",
|
|
61
|
-
"error": "Error Zone"
|
|
63
|
+
"error": "Error Zone",
|
|
64
|
+
"help": "Help Zone"
|
|
62
65
|
},
|
|
63
66
|
"action": false,
|
|
64
67
|
"actions": {
|
|
65
|
-
"wait": "
|
|
68
|
+
"wait": "::agent.name:: is waiting",
|
|
69
|
+
"help": "::agent.name:: giving help",
|
|
66
70
|
"start": "::agent.name:: has started",
|
|
67
71
|
"enter": "::agent.name:: has entered deva.world",
|
|
68
72
|
"exit": "::agent.name:: has exited deva.world",
|
|
@@ -116,6 +120,7 @@
|
|
|
116
120
|
"Mind": "Mind Feature",
|
|
117
121
|
"client_data": "client configure",
|
|
118
122
|
"invalid": "Invalid",
|
|
123
|
+
"finish": "Finished",
|
|
119
124
|
"error": "Error",
|
|
120
125
|
"done": "Done"
|
|
121
126
|
},
|
|
@@ -164,8 +169,10 @@
|
|
|
164
169
|
"load": "::agent.name:: is loading",
|
|
165
170
|
"unload": "::agent.name:: is is unloading",
|
|
166
171
|
"invalid": "::agent.name:: seems to be invalid",
|
|
167
|
-
"
|
|
168
|
-
"
|
|
172
|
+
"finish": "::agent.name:: finish state",
|
|
173
|
+
"done": "::agent.name:: is done",
|
|
174
|
+
"error": "::agent.name:: appears to have had an error",
|
|
175
|
+
"help": "::agent.name:: is getting help"
|
|
169
176
|
},
|
|
170
177
|
"zones": {
|
|
171
178
|
"deva": "::agent.name:: is in the Deva Zone",
|
|
@@ -178,7 +185,8 @@
|
|
|
178
185
|
"danger": "::agent.name:: is in the Danger Zone",
|
|
179
186
|
"invalid": "::agent.name:: is in the Invalid Zone",
|
|
180
187
|
"done": "::agent.name:: is in the Done Zone",
|
|
181
|
-
"error": "::agent.name:: is in the Error Zone"
|
|
188
|
+
"error": "::agent.name:: is in the Error Zone",
|
|
189
|
+
"help": "::agent.name:: is in the Help Zone"
|
|
182
190
|
},
|
|
183
191
|
"actions": {
|
|
184
192
|
"wait": "::agent.name:: is waiting",
|
|
@@ -226,9 +234,11 @@
|
|
|
226
234
|
"mind": "::agent.name:: is accessing the #mind feature",
|
|
227
235
|
"Mind": "::agent.name:: is loading the Mind Feature",
|
|
228
236
|
"client_data": "::agent.name:: configure",
|
|
229
|
-
"invalid": "invalid",
|
|
230
|
-
"
|
|
231
|
-
"
|
|
237
|
+
"invalid": "::agent.name:: invalid",
|
|
238
|
+
"finish": "::agent.name:: has finished the action",
|
|
239
|
+
"done": "::agent.name:: done",
|
|
240
|
+
"error": "::agent.name:: error",
|
|
241
|
+
"help": "::agent.name:: providing help"
|
|
232
242
|
},
|
|
233
243
|
"features": {
|
|
234
244
|
"security": "security feature",
|
package/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// Distributed under the MIT software license, see the accompanying
|
|
3
3
|
// file LICENSE.md or http://www.opensource.org/licenses/mit-license.php.
|
|
4
4
|
const {EventEmitter} = require('events');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
5
8
|
const { createHash, randomUUID, createCipheriv, createDecipheriv, randomBytes } = require('crypto');
|
|
6
9
|
const config = require('./config.json').DATA // load the deva core configuration data.
|
|
7
10
|
class Deva {
|
|
@@ -262,24 +265,24 @@ class Deva {
|
|
|
262
265
|
client presented data.
|
|
263
266
|
***************/
|
|
264
267
|
Support() {
|
|
265
|
-
this.feature('Support');
|
|
266
|
-
const _cl = this.client();
|
|
268
|
+
this.feature('Support'); // set state to support setting
|
|
269
|
+
const _cl = this.client(); // set the local client variable
|
|
267
270
|
try {
|
|
268
|
-
if (!_cl.features.support) return this.Services()
|
|
271
|
+
if (!_cl.features.support) return this.Services() // move to Services if no support feature
|
|
269
272
|
else {
|
|
270
273
|
this.action('Support');
|
|
271
|
-
const {id, features, profile} = _cl;
|
|
272
|
-
const {support} = features;
|
|
273
|
-
this._support = {
|
|
274
|
-
id: this.uid(true),
|
|
275
|
-
client_id: id,
|
|
276
|
-
client_name: profile.name,
|
|
277
|
-
concerns: support.concerns,
|
|
278
|
-
global: support.global,
|
|
279
|
-
personal: support.devas[this._agent.key]
|
|
274
|
+
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
275
|
+
const {support} = features; // set support from features const
|
|
276
|
+
this._support = { // set this_support with data
|
|
277
|
+
id: this.uid(true), // uuid of the support feature
|
|
278
|
+
client_id: id, // client id for reference
|
|
279
|
+
client_name: profile.name, // client name for personalization
|
|
280
|
+
concerns: support.concerns, // any concerns for client
|
|
281
|
+
global: support.global, // the global policies for client
|
|
282
|
+
personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
|
|
280
283
|
};
|
|
281
|
-
delete this._client.features.support
|
|
282
|
-
return this.Services();
|
|
284
|
+
delete this._client.features.support // delete the support key from the client
|
|
285
|
+
return this.Services(); // when done move to Services
|
|
283
286
|
}
|
|
284
287
|
} catch (e) {
|
|
285
288
|
this.action('error'); // set the action to error
|
|
@@ -296,24 +299,24 @@ class Deva {
|
|
|
296
299
|
client presented data.
|
|
297
300
|
***************/
|
|
298
301
|
Services() {
|
|
299
|
-
this.feature('Services');
|
|
300
|
-
const _cl = this.client();
|
|
302
|
+
this.feature('Services'); // set state to security setting
|
|
303
|
+
const _cl = this.client(); // set local client
|
|
301
304
|
try {
|
|
302
|
-
if (!_cl.features.services) return this.Systems();
|
|
305
|
+
if (!_cl.features.services) return this.Systems(); // move to Systems if no Services feature
|
|
303
306
|
else {
|
|
304
307
|
this.action('Services')
|
|
305
308
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
306
|
-
const {services} = features;
|
|
307
|
-
this._services = {
|
|
308
|
-
id: this.uid(true),
|
|
309
|
-
client_id: id,
|
|
310
|
-
client_name: profile.name,
|
|
311
|
-
concerns: services.concerns,
|
|
312
|
-
global: services.global,
|
|
313
|
-
personal: services.devas[this._agent.key]
|
|
309
|
+
const {services} = features; // set services from features const
|
|
310
|
+
this._services = { // set this_services with data
|
|
311
|
+
id: this.uid(true), // uuid of the services feature
|
|
312
|
+
client_id: id, // client id for reference
|
|
313
|
+
client_name: profile.name, // client name for personalization
|
|
314
|
+
concerns: services.concerns, // any concerns for client
|
|
315
|
+
global: services.global, // the global policies for client
|
|
316
|
+
personal: services.devas[this._agent.key], // Client personal features and rules.
|
|
314
317
|
};
|
|
315
|
-
delete this._client.features.services
|
|
316
|
-
return this.Systems()
|
|
318
|
+
delete this._client.features.services // delete the services key for isolation
|
|
319
|
+
return this.Systems() // go to Systems when done
|
|
317
320
|
}
|
|
318
321
|
} catch (e) {
|
|
319
322
|
this.action('error'); // set the action to error
|
|
@@ -333,18 +336,18 @@ class Deva {
|
|
|
333
336
|
this.feature('Systems'); // set state to systems setting
|
|
334
337
|
const _cl = this.client();
|
|
335
338
|
try {
|
|
336
|
-
if (!_cl.features.systems) return this.Solutions();
|
|
339
|
+
if (!_cl.features.systems) return this.Solutions(); // move to Solutions if no systems feature
|
|
337
340
|
else {
|
|
338
341
|
this.action('Systems');
|
|
339
342
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
340
|
-
const {systems} = features;
|
|
341
|
-
this._systems = {
|
|
342
|
-
id: this.uid(true),
|
|
343
|
-
client_id: id,
|
|
344
|
-
client_name: profile.name,
|
|
345
|
-
concerns: systems.concerns,
|
|
346
|
-
global: systems.global,
|
|
347
|
-
personal: systems.devas[this._agent.key]
|
|
343
|
+
const {systems} = features; // set systems from features const
|
|
344
|
+
this._systems = { // set this_systems with data
|
|
345
|
+
id: this.uid(true), // uuid of the systems feature
|
|
346
|
+
client_id: id, // client id for reference
|
|
347
|
+
client_name: profile.name, // client name for personalization
|
|
348
|
+
concerns: systems.concerns, // any concerns for client
|
|
349
|
+
global: systems.global, // the global policies for client
|
|
350
|
+
personal: systems.devas[this._agent.key], // Client personal features and rules.
|
|
348
351
|
};
|
|
349
352
|
delete this._client.features.systems
|
|
350
353
|
return this.Solutions()
|
|
@@ -367,7 +370,7 @@ class Deva {
|
|
|
367
370
|
this.feature('Solutions'); // set state to solutions setting
|
|
368
371
|
const _cl = this.client();
|
|
369
372
|
try {
|
|
370
|
-
if (!_cl.features.solutions) return this.Research();
|
|
373
|
+
if (!_cl.features.solutions) return this.Research(); // moe to research if no solutions
|
|
371
374
|
else {
|
|
372
375
|
this.action('Solutions');
|
|
373
376
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
@@ -500,12 +503,12 @@ class Deva {
|
|
|
500
503
|
client presented data.
|
|
501
504
|
***************/
|
|
502
505
|
Legal() {
|
|
503
|
-
this.feature('Legal');
|
|
504
|
-
const _cl = this.client();
|
|
506
|
+
this.feature('Legal'); // set state to legal setting
|
|
507
|
+
const _cl = this.client(); // set hte local client variable
|
|
505
508
|
try {
|
|
506
|
-
if (!_cl.features.legal) this.Assistant();
|
|
509
|
+
if (!_cl.features.legal) this.Assistant(); // if no legal feature then move to assistant
|
|
507
510
|
else {
|
|
508
|
-
this.action('Legal');
|
|
511
|
+
this.action('Legal'); // set the action to legal
|
|
509
512
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
510
513
|
const {legal} = features; // set legal from features const
|
|
511
514
|
this._legal = { // set this_legal with data
|
|
@@ -516,8 +519,8 @@ class Deva {
|
|
|
516
519
|
global: legal.global, // the global policies for client
|
|
517
520
|
personal: legal.devas[this._agent.key], // Client personal features and rules.
|
|
518
521
|
};
|
|
519
|
-
delete this._client.features.legal;
|
|
520
|
-
return this.Assistant();
|
|
522
|
+
delete this._client.features.legal; // remove the legal key from the client data
|
|
523
|
+
return this.Assistant(); // when done goto Assis
|
|
521
524
|
}
|
|
522
525
|
} catch (e) {
|
|
523
526
|
this.action('error'); // set the action to error
|
|
@@ -738,9 +741,9 @@ class Deva {
|
|
|
738
741
|
|
|
739
742
|
return new Promise((resolve, reject) => {
|
|
740
743
|
// resolve with the no text message if the client says nothing.
|
|
741
|
-
if (!TEXT) return
|
|
744
|
+
if (!TEXT) return this.finish(this._messages.notext, resolve);
|
|
742
745
|
// reject question if Deva offline
|
|
743
|
-
if (!this._active) return
|
|
746
|
+
if (!this._active) return this.finish(this._messages.states.offline, resolve);
|
|
744
747
|
let _action = 'question_method'
|
|
745
748
|
try { // try to answer the question
|
|
746
749
|
if (isAsk) { // determine if hte question isAsk
|
|
@@ -857,7 +860,7 @@ class Deva {
|
|
|
857
860
|
this.action('answer_talk');
|
|
858
861
|
this.talk(config.events.answer, this.copy(packet)); // global talk event
|
|
859
862
|
|
|
860
|
-
return
|
|
863
|
+
return this.finish(packet, resolve) // resolve the packet to the caller.
|
|
861
864
|
}).catch(err => { // catch any errors in the method
|
|
862
865
|
this.action('error');
|
|
863
866
|
return this.error(err, packet, reject); // return this.error with err, packet, reject
|
|
@@ -1066,20 +1069,19 @@ class Deva {
|
|
|
1066
1069
|
/**************
|
|
1067
1070
|
func: finish
|
|
1068
1071
|
params:
|
|
1069
|
-
-
|
|
1072
|
+
- packet: the data to pass to the resolve
|
|
1070
1073
|
- resolve: the finish resolve to pass back
|
|
1071
|
-
|
|
1072
|
-
|
|
1074
|
+
describe:
|
|
1075
|
+
This function is use to relay the Agent ito a finish state when resolving a
|
|
1076
|
+
question or data.
|
|
1077
|
+
usage:
|
|
1078
|
+
this.finish(data, resolve)
|
|
1073
1079
|
***************/
|
|
1074
|
-
|
|
1080
|
+
finish(packet, resolve) {
|
|
1075
1081
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1076
1082
|
this.state('finish');
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
data.hash = this.hash(data);
|
|
1080
|
-
this.action(data.value)
|
|
1081
|
-
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
1082
|
-
return hasOnDone ? this.onDone(data) : Promise.resolve(data);
|
|
1083
|
+
this.action('finish');
|
|
1084
|
+
return resolve(packet);
|
|
1083
1085
|
}
|
|
1084
1086
|
|
|
1085
1087
|
/**************
|
|
@@ -1552,7 +1554,7 @@ class Deva {
|
|
|
1552
1554
|
key,
|
|
1553
1555
|
created: Date.now(),
|
|
1554
1556
|
});
|
|
1555
|
-
return
|
|
1557
|
+
return this.finish(this._messages.states.load, resolve);
|
|
1556
1558
|
}).catch(err => {
|
|
1557
1559
|
return this.error(err, deva, reject);
|
|
1558
1560
|
})
|
|
@@ -1573,7 +1575,7 @@ class Deva {
|
|
|
1573
1575
|
delete this.devas[key];
|
|
1574
1576
|
this.talk(config.events.unload, key);
|
|
1575
1577
|
});
|
|
1576
|
-
return
|
|
1578
|
+
return this.finish(this._messages.states.unload, resolve);
|
|
1577
1579
|
} catch (e) {
|
|
1578
1580
|
return this.error(e, this.devas[key], reject)
|
|
1579
1581
|
}
|
|
@@ -1875,14 +1877,21 @@ class Deva {
|
|
|
1875
1877
|
***************/
|
|
1876
1878
|
help(msg, help_dir) {
|
|
1877
1879
|
return new Promise((resolve, reject) => {
|
|
1880
|
+
if (!this._active) return resolve(this._messages.states.offline);
|
|
1881
|
+
this.state('help');
|
|
1882
|
+
this.zone('help');
|
|
1883
|
+
this.action('help');
|
|
1878
1884
|
const params = msg.split(' ');
|
|
1879
1885
|
let helpFile = 'main';
|
|
1880
1886
|
if (params[0]) helpFile = params[0];
|
|
1881
1887
|
if (params[1]) helpFile = `${params[0]}_${params[1]}`;
|
|
1882
1888
|
helpFile = path.join(help_dir, 'help', `${helpFile}.feecting`);
|
|
1883
1889
|
try {
|
|
1884
|
-
return
|
|
1890
|
+
return this.finish(fs.readFileSync(helpFile, 'utf8'), resolve)
|
|
1885
1891
|
} catch (e) {
|
|
1892
|
+
this.action('help');
|
|
1893
|
+
this.zone('help');
|
|
1894
|
+
this.state('help');
|
|
1886
1895
|
return reject(e)
|
|
1887
1896
|
}
|
|
1888
1897
|
});
|