@indra.ai/deva 1.2.7 → 1.2.9
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 +77 -51
- package/index.js +46 -46
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -27,9 +27,15 @@
|
|
|
27
27
|
"unload": "devacore:unload",
|
|
28
28
|
"context": "devacore:context"
|
|
29
29
|
},
|
|
30
|
+
"context": false,
|
|
30
31
|
"zone": "deva",
|
|
31
32
|
"zones": {
|
|
32
33
|
"deva": "#Deva",
|
|
34
|
+
"client": "#Client",
|
|
35
|
+
"agent": "#Agent",
|
|
36
|
+
"question": "#Question",
|
|
37
|
+
"answer": "#Answer",
|
|
38
|
+
"ask": "#Ask",
|
|
33
39
|
"security": "#Security",
|
|
34
40
|
"support": "#Support",
|
|
35
41
|
"services": "#Services",
|
|
@@ -37,15 +43,16 @@
|
|
|
37
43
|
"done": "#Done",
|
|
38
44
|
"config": "#Config",
|
|
39
45
|
"school": "#School",
|
|
40
|
-
"work": "#
|
|
41
|
-
"fun": "Fun
|
|
42
|
-
"adventure": "Adventure
|
|
43
|
-
"party": "Party
|
|
44
|
-
"finish": "Finish
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
46
|
+
"work": "#Work",
|
|
47
|
+
"fun": "#Fun",
|
|
48
|
+
"adventure": "#Adventure",
|
|
49
|
+
"party": "#Party",
|
|
50
|
+
"finish": "#Finish",
|
|
51
|
+
"init": "#Init",
|
|
52
|
+
"start": "#Start",
|
|
53
|
+
"stop": "#Stop",
|
|
54
|
+
"help": "#Help",
|
|
55
|
+
"error": "#Error"
|
|
49
56
|
},
|
|
50
57
|
"state": "offline",
|
|
51
58
|
"states": {
|
|
@@ -54,19 +61,22 @@
|
|
|
54
61
|
"active": "Active",
|
|
55
62
|
"inactive": "Inactive",
|
|
56
63
|
"idle": "Idle",
|
|
57
|
-
"talk": "
|
|
58
|
-
"listen": "
|
|
59
|
-
"ask": "
|
|
64
|
+
"talk": "Talk",
|
|
65
|
+
"listen": "Listen",
|
|
66
|
+
"ask": "Ask",
|
|
60
67
|
"question": "Question",
|
|
61
68
|
"answer": "Answer",
|
|
62
69
|
"ready": "Ready",
|
|
63
70
|
"wait": "Waiting",
|
|
64
71
|
"pause": "Pause",
|
|
65
|
-
"resume": "
|
|
66
|
-
"connect": "
|
|
67
|
-
"disconnect": "
|
|
68
|
-
"send": "
|
|
69
|
-
"receive": "
|
|
72
|
+
"resume": "Resume",
|
|
73
|
+
"connect": "Connect",
|
|
74
|
+
"disconnect": "Disconnect",
|
|
75
|
+
"send": "Send",
|
|
76
|
+
"receive": "Receive",
|
|
77
|
+
"return": "Return",
|
|
78
|
+
"resolve": "Resolve",
|
|
79
|
+
"reject": "Reject",
|
|
70
80
|
"init": "Initialize",
|
|
71
81
|
"forward": "Forward",
|
|
72
82
|
"backward": "Backward",
|
|
@@ -84,6 +94,14 @@
|
|
|
84
94
|
"data": "Data",
|
|
85
95
|
"finish": "Finish",
|
|
86
96
|
"complete": "Complete",
|
|
97
|
+
"create": "Create",
|
|
98
|
+
"destroy": "Destroy",
|
|
99
|
+
"save": "Save",
|
|
100
|
+
"delete": "Delete",
|
|
101
|
+
"get": "Get",
|
|
102
|
+
"put": "Put",
|
|
103
|
+
"push": "Push",
|
|
104
|
+
"pull": "Pull",
|
|
87
105
|
"invalid": "INVALID!",
|
|
88
106
|
"abort": "ABORT!",
|
|
89
107
|
"error": "ERROR!",
|
|
@@ -91,56 +109,64 @@
|
|
|
91
109
|
},
|
|
92
110
|
"action": false,
|
|
93
111
|
"actions": {
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
112
|
+
"client": "get Client",
|
|
113
|
+
"agent": "get Agent",
|
|
114
|
+
"wait": "Waiting",
|
|
115
|
+
"start": "Start",
|
|
116
|
+
"enter": "Enter",
|
|
117
|
+
"exit": "Exit",
|
|
118
|
+
"stop": "Stop",
|
|
119
|
+
"load": "Load",
|
|
120
|
+
"unload": "Unload",
|
|
121
|
+
"done": "Done",
|
|
122
|
+
"question": "Question",
|
|
123
|
+
"context": "Context",
|
|
124
|
+
"prompt": "Prompt",
|
|
125
|
+
"issue": "Issue",
|
|
126
|
+
"info": "Information",
|
|
127
|
+
"status": "Status",
|
|
128
|
+
"func": "Function",
|
|
129
|
+
"list": "List items",
|
|
107
130
|
|
|
108
|
-
"question_ask": "
|
|
109
|
-
"question_ask_answer": "
|
|
110
|
-
"question_cmd": "command",
|
|
111
|
-
"question_method": "method",
|
|
112
|
-
"question_talk": "talk
|
|
113
|
-
"question_answer": "answer
|
|
114
|
-
"question_done": "
|
|
115
|
-
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
131
|
+
"question_ask": "Question ask",
|
|
132
|
+
"question_ask_answer": "Question ask answer",
|
|
133
|
+
"question_cmd": "Question command",
|
|
134
|
+
"question_method": "Question method",
|
|
135
|
+
"question_talk": "Question talk",
|
|
136
|
+
"question_answer": "Question answer",
|
|
137
|
+
"question_done": "Question done",
|
|
138
|
+
|
|
139
|
+
"answer": "Answer",
|
|
140
|
+
"answer_talk": "Answer talk",
|
|
141
|
+
"ask": "Ask",
|
|
142
|
+
"ask_answer": "Ask answer",
|
|
119
143
|
|
|
120
144
|
"security": "SECURITY",
|
|
121
145
|
"support": "SUPPORT",
|
|
122
146
|
"systems": "SYSTMS",
|
|
123
147
|
"services": "SERVICES",
|
|
124
148
|
|
|
125
|
-
"Client": "
|
|
126
|
-
"Security": "
|
|
127
|
-
"Support": "
|
|
128
|
-
"Systems": "
|
|
129
|
-
"Services": "
|
|
149
|
+
"Client": "Set client",
|
|
150
|
+
"Security": "Set Security",
|
|
151
|
+
"Support": "Set Support",
|
|
152
|
+
"Systems": "Set Systems",
|
|
153
|
+
"Services": "Set Services",
|
|
130
154
|
"Done": "Done",
|
|
131
155
|
|
|
132
|
-
"invalid": "
|
|
133
|
-
"states": "
|
|
134
|
-
"actions": "
|
|
135
|
-
"zones": "
|
|
156
|
+
"invalid": "Invalid",
|
|
157
|
+
"states": "States",
|
|
158
|
+
"actions": "Actions",
|
|
159
|
+
"zones": "Zones",
|
|
136
160
|
"features": "Getting features",
|
|
137
161
|
"contexts": "Getting contexts",
|
|
138
|
-
"finish": "
|
|
162
|
+
"finish": "Finished action",
|
|
139
163
|
"help": "Giving some HELP!",
|
|
140
164
|
"error": "We have an ERROR!"
|
|
141
165
|
},
|
|
142
166
|
"feature": false,
|
|
143
167
|
"features": {
|
|
168
|
+
"client": "Client",
|
|
169
|
+
"agent": "Agent",
|
|
144
170
|
"security": "Security",
|
|
145
171
|
"support": "Support",
|
|
146
172
|
"services": "Services",
|
package/index.js
CHANGED
|
@@ -77,7 +77,7 @@ class Deva {
|
|
|
77
77
|
|
|
78
78
|
this._context = opts.context || false; // set the local context
|
|
79
79
|
|
|
80
|
-
this._message = config.message; // current
|
|
80
|
+
this._message = config.message; // current message of agent.
|
|
81
81
|
this._messages = config.messages; // set the messages from config
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -443,6 +443,7 @@ class Deva {
|
|
|
443
443
|
describe:
|
|
444
444
|
***************/
|
|
445
445
|
question(TEXT=false, DATA=false) {
|
|
446
|
+
this.zone('question');
|
|
446
447
|
// check the active status
|
|
447
448
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
448
449
|
|
|
@@ -545,6 +546,7 @@ class Deva {
|
|
|
545
546
|
from the agent from the pre-determined method.
|
|
546
547
|
***************/
|
|
547
548
|
answer(packet, resolve, reject) {
|
|
549
|
+
this.zone('answer');
|
|
548
550
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
549
551
|
this.state('answer');
|
|
550
552
|
// check if method exists and is of type function
|
|
@@ -608,7 +610,9 @@ class Deva {
|
|
|
608
610
|
so the event is specific to the talk.
|
|
609
611
|
***************/
|
|
610
612
|
ask(packet) {
|
|
613
|
+
this.zone('ask');
|
|
611
614
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
615
|
+
|
|
612
616
|
this.state('ask');
|
|
613
617
|
|
|
614
618
|
const agent = this.agent();
|
|
@@ -683,7 +687,7 @@ class Deva {
|
|
|
683
687
|
usage: this.init(client_object)
|
|
684
688
|
***************/
|
|
685
689
|
init(client) {
|
|
686
|
-
this.
|
|
690
|
+
this.zone('init');
|
|
687
691
|
// set client
|
|
688
692
|
this._active = Date.now();
|
|
689
693
|
const agent = this.agent();
|
|
@@ -698,6 +702,7 @@ class Deva {
|
|
|
698
702
|
}
|
|
699
703
|
_data.hash = this.hash(_data);
|
|
700
704
|
|
|
705
|
+
this.state('init');
|
|
701
706
|
return new Promise((resolve, reject) => {
|
|
702
707
|
this.events.setMaxListeners(this.maxListeners);
|
|
703
708
|
this._assignInherit().then(() => {
|
|
@@ -1073,14 +1078,11 @@ class Deva {
|
|
|
1073
1078
|
return {
|
|
1074
1079
|
id: this.uid(true),
|
|
1075
1080
|
key: 'contexts',
|
|
1076
|
-
value: this.
|
|
1077
|
-
messages: this.vars.context || false,
|
|
1081
|
+
value: this.vars.context || false,
|
|
1078
1082
|
created: Date.now(),
|
|
1079
1083
|
}
|
|
1080
1084
|
}
|
|
1081
1085
|
|
|
1082
|
-
|
|
1083
|
-
///////////////
|
|
1084
1086
|
/**************
|
|
1085
1087
|
func: client
|
|
1086
1088
|
params: none
|
|
@@ -1091,10 +1093,7 @@ class Deva {
|
|
|
1091
1093
|
***************/
|
|
1092
1094
|
client() {
|
|
1093
1095
|
if (!this._active) return this._messages.offline; // check the active status
|
|
1094
|
-
this.state('client_data'); // set the client state
|
|
1095
1096
|
const client_copy = this.copy(this._client);
|
|
1096
|
-
// delete client_copy.parse;
|
|
1097
|
-
// delete client_copy.translate;
|
|
1098
1097
|
return client_copy; // return the client feature
|
|
1099
1098
|
}
|
|
1100
1099
|
|
|
@@ -1108,11 +1107,7 @@ class Deva {
|
|
|
1108
1107
|
***************/
|
|
1109
1108
|
agent() {
|
|
1110
1109
|
if (!this._active) return this._messages.offline;
|
|
1111
|
-
this.state('agent_data');
|
|
1112
1110
|
const agent_copy = this.copy(this._agent);
|
|
1113
|
-
delete agent_copy.parse;
|
|
1114
|
-
delete agent_copy.translate;
|
|
1115
|
-
delete agent_copy.process;
|
|
1116
1111
|
return agent_copy;
|
|
1117
1112
|
}
|
|
1118
1113
|
|
|
@@ -1124,14 +1119,14 @@ class Deva {
|
|
|
1124
1119
|
usage: this.security()
|
|
1125
1120
|
***************/
|
|
1126
1121
|
security() {
|
|
1127
|
-
|
|
1128
|
-
this.
|
|
1122
|
+
this.feature('security'); // set the security state
|
|
1123
|
+
this.zone('security');
|
|
1124
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1125
|
+
this.state('data'); // set the security state
|
|
1129
1126
|
try {
|
|
1130
|
-
this.action('security');
|
|
1131
|
-
return this.copy(this._security);
|
|
1132
|
-
} catch (e) {
|
|
1133
|
-
return this.error(e);
|
|
1134
|
-
}
|
|
1127
|
+
this.action('security'); // set the security state
|
|
1128
|
+
return this.copy(this._security); // return the security feature
|
|
1129
|
+
} catch (e) {return this.error(e);}
|
|
1135
1130
|
}
|
|
1136
1131
|
|
|
1137
1132
|
/**************
|
|
@@ -1141,14 +1136,14 @@ class Deva {
|
|
|
1141
1136
|
usage: this.support()
|
|
1142
1137
|
***************/
|
|
1143
1138
|
support() {
|
|
1144
|
-
|
|
1145
|
-
this.
|
|
1139
|
+
this.feature('support'); // set the support state
|
|
1140
|
+
this.zone('support'); // set the support state
|
|
1141
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1142
|
+
this.state('data');
|
|
1146
1143
|
try {
|
|
1147
1144
|
this.action('support');
|
|
1148
|
-
return this.copy(this._support);
|
|
1149
|
-
} catch (e) {
|
|
1150
|
-
return this.error(e);
|
|
1151
|
-
}
|
|
1145
|
+
return this.copy(this._support); // return the support feature
|
|
1146
|
+
} catch (e) {return this.error(e);}
|
|
1152
1147
|
}
|
|
1153
1148
|
|
|
1154
1149
|
/**************
|
|
@@ -1158,14 +1153,14 @@ class Deva {
|
|
|
1158
1153
|
usage: this.services()
|
|
1159
1154
|
***************/
|
|
1160
1155
|
services(opts) {
|
|
1161
|
-
|
|
1162
|
-
this.
|
|
1156
|
+
this.feature('services'); // set the support state
|
|
1157
|
+
this.zone('services'); // set the support state
|
|
1158
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1159
|
+
this.state('data'); // set the services state
|
|
1163
1160
|
try {
|
|
1164
|
-
this.action('services');
|
|
1165
|
-
return this.copy(this._services);
|
|
1166
|
-
} catch (e) {
|
|
1167
|
-
return this.error(e);
|
|
1168
|
-
}
|
|
1161
|
+
this.action('services'); // set the services state
|
|
1162
|
+
return this.copy(this._services); // return the services feature
|
|
1163
|
+
} catch (e) {return this.error(e);}
|
|
1169
1164
|
}
|
|
1170
1165
|
|
|
1171
1166
|
/**************
|
|
@@ -1175,14 +1170,14 @@ class Deva {
|
|
|
1175
1170
|
usage: this.systems()
|
|
1176
1171
|
***************/
|
|
1177
1172
|
systems(opts) {
|
|
1178
|
-
|
|
1179
|
-
this.
|
|
1173
|
+
this.feature('systems'); // set the systems state
|
|
1174
|
+
this.zone('systems'); // set the systems state
|
|
1175
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1176
|
+
this.state('data');
|
|
1180
1177
|
try {
|
|
1181
|
-
this.action('systems');
|
|
1182
|
-
return this.copy(this._systems);
|
|
1183
|
-
} catch (e) {
|
|
1184
|
-
return this.error(e)
|
|
1185
|
-
}
|
|
1178
|
+
this.action('systems'); // set the systems state
|
|
1179
|
+
return this.copy(this._systems); // return the systems feature
|
|
1180
|
+
} catch (e) {return this.error(e);}
|
|
1186
1181
|
}
|
|
1187
1182
|
|
|
1188
1183
|
/**************
|
|
@@ -1310,6 +1305,7 @@ class Deva {
|
|
|
1310
1305
|
usage: this.prompt('text')
|
|
1311
1306
|
***************/
|
|
1312
1307
|
prompt(text) {
|
|
1308
|
+
this.action('prompt');
|
|
1313
1309
|
// Talk a global prompt event for the client
|
|
1314
1310
|
const agent = this.agent();
|
|
1315
1311
|
const client = this.client();
|
|
@@ -1349,6 +1345,7 @@ class Deva {
|
|
|
1349
1345
|
with no time value for the current day.
|
|
1350
1346
|
***************/
|
|
1351
1347
|
getToday(d) {
|
|
1348
|
+
this.action('gettoday');
|
|
1352
1349
|
d = d ? d : Date.now();
|
|
1353
1350
|
const today = new Date(d);
|
|
1354
1351
|
today.setHours(0);
|
|
@@ -1447,6 +1444,7 @@ class Deva {
|
|
|
1447
1444
|
describe: remove duplicees from an array.
|
|
1448
1445
|
***************/
|
|
1449
1446
|
dupes(dupers) {
|
|
1447
|
+
this.action('dupes');
|
|
1450
1448
|
if (!Array.isArray(dupers)) return dupers;
|
|
1451
1449
|
const check = [];
|
|
1452
1450
|
return dupers.filter(dupe => {
|
|
@@ -1463,8 +1461,9 @@ class Deva {
|
|
|
1463
1461
|
describe: return info data.
|
|
1464
1462
|
***************/
|
|
1465
1463
|
info() {
|
|
1464
|
+
this.zone('support');
|
|
1466
1465
|
// check the active status
|
|
1467
|
-
if (!this._active) return Promise.resolve(this._messages.
|
|
1466
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
1468
1467
|
this.action('info');
|
|
1469
1468
|
return this._info;
|
|
1470
1469
|
}
|
|
@@ -1481,12 +1480,13 @@ class Deva {
|
|
|
1481
1480
|
usage: this.status('msg')
|
|
1482
1481
|
***************/
|
|
1483
1482
|
status(msg=false) {
|
|
1483
|
+
this.zone('support');
|
|
1484
1484
|
// check the active status
|
|
1485
1485
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1486
|
-
this.action('status');
|
|
1487
1486
|
// format the date since active for output.
|
|
1488
1487
|
const dateFormat = this.formatDate(this._active, 'long', true);
|
|
1489
1488
|
// create the text msg string
|
|
1489
|
+
this.action('status');
|
|
1490
1490
|
let text = `${this._agent.profile.name} active since ${dateFormat}`;
|
|
1491
1491
|
if (msg) text = text + `\n${msg}`; // append the msg string if msg true.
|
|
1492
1492
|
return text; // return final text string
|
|
@@ -1503,10 +1503,10 @@ class Deva {
|
|
|
1503
1503
|
one exists it will then present it based on the users request text input.
|
|
1504
1504
|
***************/
|
|
1505
1505
|
help(msg, help_dir) {
|
|
1506
|
-
this.
|
|
1506
|
+
this.zone('help');
|
|
1507
1507
|
return new Promise((resolve, reject) => {
|
|
1508
1508
|
if (!this._active) return resolve(this._messages.states.offline);
|
|
1509
|
-
this.
|
|
1509
|
+
this.state('data');
|
|
1510
1510
|
const params = msg.split(' ');
|
|
1511
1511
|
let helpFile = 'main';
|
|
1512
1512
|
if (params[0]) helpFile = params[0];
|
|
@@ -1532,7 +1532,7 @@ class Deva {
|
|
|
1532
1532
|
usage: this.error(err, data, reject);
|
|
1533
1533
|
***************/
|
|
1534
1534
|
error(err,data=false,reject=false) {
|
|
1535
|
-
this.
|
|
1535
|
+
this.zone('error');
|
|
1536
1536
|
// check fo rthe custom onError function in the agent.
|
|
1537
1537
|
console.log('\n::BEGIN:ERROR\n');
|
|
1538
1538
|
console.log(err);
|
|
@@ -1544,7 +1544,7 @@ class Deva {
|
|
|
1544
1544
|
console.log('\n::END:DATA\n');
|
|
1545
1545
|
}
|
|
1546
1546
|
|
|
1547
|
-
this.
|
|
1547
|
+
this.state('error')
|
|
1548
1548
|
const agent = this.agent();
|
|
1549
1549
|
const client = this.client();
|
|
1550
1550
|
const _data = {
|