@indra.ai/deva 1.2.16 → 1.2.18
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 +2 -2
- package/index.js +9 -78
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"scifi": "SciFi",
|
|
54
54
|
"finish": "Finish",
|
|
55
55
|
"help": "Help",
|
|
56
|
-
"error": "
|
|
56
|
+
"error": "ERROR!"
|
|
57
57
|
},
|
|
58
58
|
"state": "offline",
|
|
59
59
|
"states": {
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"contexts": "Getting contexts",
|
|
171
171
|
"finish": "Finished action",
|
|
172
172
|
"help": "Giving some HELP!",
|
|
173
|
-
"error": "
|
|
173
|
+
"error": "ERROR!"
|
|
174
174
|
},
|
|
175
175
|
"feature": false,
|
|
176
176
|
"features": {
|
package/index.js
CHANGED
|
@@ -20,26 +20,16 @@ class Deva {
|
|
|
20
20
|
this._security = false; // inherited Security features.
|
|
21
21
|
this._support = false; // inherited Support features.
|
|
22
22
|
this._services = false; // inherited Service features.
|
|
23
|
-
this._systems = false; // inherited Systems features.
|
|
24
23
|
this.os = require('os'); // It is used to provide basic operating system related utility functions.
|
|
25
|
-
this.buffer = require('buffer'); // It is used to provide basic operating system related utility functions.
|
|
26
|
-
this.util = require('util'); // The supports the needs of internal APIs.
|
|
27
|
-
this.querystring = require('querystring'); // Provides utilities for parsing and formatting URL query strings.
|
|
28
24
|
this.fs = require('fs'); // this is so file system functions are in the core.
|
|
29
25
|
this.path = require('path'); // this is so we can get path in the system.
|
|
30
26
|
this.crypto = require('crypto'); // It is used to support cryptography for encryption and decryption.
|
|
31
27
|
this.zlib = require('zlib'); // provides compression functionality using Gzip, Deflate/Inflate, and Brotli.
|
|
32
|
-
this.console = require('console'); // It is used to write data to console.
|
|
33
|
-
this.readline = require('readline/promises'); // It is used to write data to console.
|
|
34
28
|
this.dns = require('dns'); // It is used to lookup and resolve on domain names.
|
|
35
29
|
this.net = require('net'); // It used to create TCP server/client communicate using TCP protocol.
|
|
36
30
|
this.http = require('http'); // It is used to create Http server and Http client.
|
|
37
31
|
this.https = require('https'); // It is used to create Http server and Http client.
|
|
38
|
-
this.stream = require('stream/promises'); // It is used to stream data between two entities.
|
|
39
32
|
this.url = require('url'); // It is used for URL resolution and parsing.
|
|
40
|
-
this.vm = require('vm'); // It provides an access to virtual machine to compile and execute code.
|
|
41
|
-
this.inspector = require('inspector'); // It is used to stream data between two entities.
|
|
42
|
-
this.cluster = require('cluster'); // used to take advantage of multi-core systems.
|
|
43
33
|
this.assert = require('assert'); // It is used for testing itself.
|
|
44
34
|
this.events = opts.events || new EventEmitter({}); // Event Bus
|
|
45
35
|
this.libs = opts.libs || {}; // used for loading library functions
|
|
@@ -303,7 +293,7 @@ class Deva {
|
|
|
303
293
|
this.zone('services')
|
|
304
294
|
const _cl = this.client(); // set local client
|
|
305
295
|
try {
|
|
306
|
-
if (!_cl.features.services) return this.
|
|
296
|
+
if (!_cl.features.services) return this.Done(); // move to Done if no Services feature
|
|
307
297
|
else {
|
|
308
298
|
this.state('data');
|
|
309
299
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
@@ -318,47 +308,13 @@ class Deva {
|
|
|
318
308
|
};
|
|
319
309
|
delete this._client.features.services; // delete the services key for isolation
|
|
320
310
|
this.action('Services');
|
|
321
|
-
return this.
|
|
311
|
+
return this.Done(); // go to Done
|
|
322
312
|
}
|
|
323
313
|
} catch (e) {
|
|
324
314
|
return this.error(e); // run error handling if an error is caught
|
|
325
315
|
}
|
|
326
316
|
}
|
|
327
317
|
|
|
328
|
-
/**************
|
|
329
|
-
func: Systems
|
|
330
|
-
params: client: false
|
|
331
|
-
describe:
|
|
332
|
-
The Systems feature sets the correct variables and necessary rules for the
|
|
333
|
-
client presented data.
|
|
334
|
-
***************/
|
|
335
|
-
Systems() {
|
|
336
|
-
this.zone('systems');
|
|
337
|
-
const _cl = this.client();
|
|
338
|
-
try {
|
|
339
|
-
if (!_cl.features.systems) return this.Done(); // move to Done if no systems feature
|
|
340
|
-
else {
|
|
341
|
-
this.state('data');
|
|
342
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
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.
|
|
351
|
-
};
|
|
352
|
-
delete this._client.features.systems;
|
|
353
|
-
this.action('Systems');
|
|
354
|
-
return this.Done();
|
|
355
|
-
}
|
|
356
|
-
} catch (e) {
|
|
357
|
-
return this.error(e); // run error handling if an error is caught
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
318
|
/**************
|
|
363
319
|
func: Done
|
|
364
320
|
params: none
|
|
@@ -676,8 +632,8 @@ class Deva {
|
|
|
676
632
|
2. Assign the Interited Properties
|
|
677
633
|
3. Assign binding functions and methods to 'this' scoe.
|
|
678
634
|
4. Assign any listeners for additional functionality.
|
|
679
|
-
5. run the onInit custom function if preset or the
|
|
680
|
-
6. The
|
|
635
|
+
5. run the onInit custom function if preset or the start function.
|
|
636
|
+
6. The start function will create a chain reaction of states that load.
|
|
681
637
|
7. If there is an error the init function rejects the call.
|
|
682
638
|
usage: this.init(client_object)
|
|
683
639
|
***************/
|
|
@@ -723,7 +679,7 @@ class Deva {
|
|
|
723
679
|
describe:
|
|
724
680
|
The start function begins the process by setting the state to start setting
|
|
725
681
|
the active to the current datetime and then checking for a custom onStart
|
|
726
|
-
function or running the
|
|
682
|
+
function or running the enter function.
|
|
727
683
|
usage: this.start('msg')
|
|
728
684
|
***************/
|
|
729
685
|
start(data) {
|
|
@@ -810,7 +766,7 @@ class Deva {
|
|
|
810
766
|
describe:
|
|
811
767
|
The stop function will stop the Deva by setting the active status to false,
|
|
812
768
|
and the state to stop. From here it will check for a custom onStop function
|
|
813
|
-
for anything to run, or run the
|
|
769
|
+
for anything to run, or run the exit function.
|
|
814
770
|
|
|
815
771
|
If the deva is offline it will return the offline message.
|
|
816
772
|
usage:
|
|
@@ -847,7 +803,7 @@ class Deva {
|
|
|
847
803
|
The exit state function is triggered when the Deva is exiting it's online
|
|
848
804
|
status and setting the state to exit for things like security check.
|
|
849
805
|
|
|
850
|
-
The return will check for a custom onExit function or run the
|
|
806
|
+
The return will check for a custom onExit function or run the done
|
|
851
807
|
function.
|
|
852
808
|
|
|
853
809
|
If the deva is offline it will return the offline message.
|
|
@@ -974,7 +930,7 @@ class Deva {
|
|
|
974
930
|
this._action = action; // set the local action variable
|
|
975
931
|
// check local vars for custom actions
|
|
976
932
|
const var_action = this.vars.actions ? this.vars.actions[action] : false;
|
|
977
|
-
// check
|
|
933
|
+
// check action messages
|
|
978
934
|
const msg_action = this._actions[action] || var_action;
|
|
979
935
|
const text = msg_action || action; // set the text of the action
|
|
980
936
|
const data = { // build the data object for the action.
|
|
@@ -1155,27 +1111,11 @@ class Deva {
|
|
|
1155
1111
|
} catch (e) {return this.error(e);}
|
|
1156
1112
|
}
|
|
1157
1113
|
|
|
1158
|
-
/**************
|
|
1159
|
-
func: systems
|
|
1160
|
-
params: opts
|
|
1161
|
-
describe: basic systems features available in a Deva.
|
|
1162
|
-
usage: this.systems()
|
|
1163
|
-
***************/
|
|
1164
|
-
systems(opts) {
|
|
1165
|
-
this.feature('systems'); // set the systems state
|
|
1166
|
-
if (!this._active) return this._messages.offline; // check the active status
|
|
1167
|
-
this.state('data');
|
|
1168
|
-
try {
|
|
1169
|
-
this.action('systems'); // set the systems state
|
|
1170
|
-
return this.copy(this._systems); // return the systems feature
|
|
1171
|
-
} catch (e) {return this.error(e);}
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
1114
|
/**************
|
|
1175
1115
|
func: load
|
|
1176
1116
|
params:
|
|
1177
1117
|
-deva: The Deva model to load.
|
|
1178
|
-
describe: This function will enable fast loading of Deva into
|
|
1118
|
+
describe: This function will enable fast loading of Deva into the system.
|
|
1179
1119
|
***************/
|
|
1180
1120
|
load(key, client) {
|
|
1181
1121
|
this.state('load');
|
|
@@ -1522,15 +1462,6 @@ class Deva {
|
|
|
1522
1462
|
***************/
|
|
1523
1463
|
error(err,data=false,reject=false) {
|
|
1524
1464
|
this.zone('error');
|
|
1525
|
-
// check fo rthe custom onError function in the agent.
|
|
1526
|
-
console.log('\n::BEGIN:ERROR\n');
|
|
1527
|
-
console.log(err);
|
|
1528
|
-
console.log('\n::END:ERROR\n');
|
|
1529
|
-
if (data) {
|
|
1530
|
-
console.log('\n::BEGIN:DATA\n');
|
|
1531
|
-
console.log(JSON.stringify(data, null, 2));
|
|
1532
|
-
console.log('\n::END:DATA\n');
|
|
1533
|
-
}
|
|
1534
1465
|
|
|
1535
1466
|
this.state('error')
|
|
1536
1467
|
const agent = this.agent();
|