@indra.ai/deva 1.2.6 → 1.2.8
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 +128 -175
- package/index.js +118 -402
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -27,202 +27,155 @@
|
|
|
27
27
|
"unload": "devacore:unload",
|
|
28
28
|
"context": "devacore:context"
|
|
29
29
|
},
|
|
30
|
+
"context": false,
|
|
31
|
+
"zone": "deva",
|
|
32
|
+
"zones": {
|
|
33
|
+
"deva": "#Deva",
|
|
34
|
+
"client": "#Client",
|
|
35
|
+
"agent": "#Agent",
|
|
36
|
+
"question": "#Question",
|
|
37
|
+
"answer": "#Answer",
|
|
38
|
+
"ask": "#Ask",
|
|
39
|
+
"security": "#Security",
|
|
40
|
+
"support": "#Support",
|
|
41
|
+
"services": "#Services",
|
|
42
|
+
"systems": "#Systems",
|
|
43
|
+
"done": "#Done",
|
|
44
|
+
"config": "#Config",
|
|
45
|
+
"school": "#School",
|
|
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"
|
|
56
|
+
},
|
|
30
57
|
"state": "offline",
|
|
31
58
|
"states": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
59
|
+
"online": "Online",
|
|
60
|
+
"offline": "Offline",
|
|
61
|
+
"active": "Active",
|
|
62
|
+
"inactive": "Inactive",
|
|
63
|
+
"idle": "Idle",
|
|
64
|
+
"talk": "Talking",
|
|
65
|
+
"listen": "Listening",
|
|
66
|
+
"ask": "Asking",
|
|
67
|
+
"question": "Question",
|
|
68
|
+
"answer": "Answer",
|
|
69
|
+
"ready": "Ready",
|
|
70
|
+
"wait": "Waiting",
|
|
71
|
+
"pause": "Pause",
|
|
72
|
+
"resume": "Resume",
|
|
73
|
+
"connect": "Connecting",
|
|
74
|
+
"disconnect": "Disconnecting",
|
|
75
|
+
"send": "Sending",
|
|
76
|
+
"receive": "Receiving",
|
|
77
|
+
"init": "Initialize",
|
|
78
|
+
"forward": "Forward",
|
|
79
|
+
"backward": "Backward",
|
|
80
|
+
"start": "Start",
|
|
81
|
+
"stop": "Stop",
|
|
82
|
+
"open": "Open",
|
|
83
|
+
"close": "Close",
|
|
84
|
+
"enter": "Enter",
|
|
85
|
+
"exit": "Exit",
|
|
86
|
+
"begin": "Begin",
|
|
87
|
+
"end": "End",
|
|
88
|
+
"load": "Load",
|
|
89
|
+
"unload": "Unload",
|
|
90
|
+
"done": "Done",
|
|
91
|
+
"data": "Data",
|
|
92
|
+
"finish": "Finish",
|
|
93
|
+
"complete": "Complete",
|
|
94
|
+
"create": "Create",
|
|
95
|
+
"destroy": "Destroy",
|
|
96
|
+
"save": "Save",
|
|
97
|
+
"delete": "Delete",
|
|
98
|
+
"get": "Get",
|
|
99
|
+
"put": "Put",
|
|
100
|
+
"push": "Push",
|
|
101
|
+
"pull": "Pull",
|
|
102
|
+
"invalid": "INVALID!",
|
|
103
|
+
"abort": "ABORT!",
|
|
104
|
+
"error": "ERROR!",
|
|
105
|
+
"help": "HELP!"
|
|
64
106
|
},
|
|
65
107
|
"action": false,
|
|
66
108
|
"actions": {
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
109
|
+
"client": "get Client",
|
|
110
|
+
"agent": "get Agent",
|
|
111
|
+
"wait": "Waiting",
|
|
112
|
+
"start": "Start",
|
|
113
|
+
"enter": "Enter",
|
|
114
|
+
"exit": "Exit",
|
|
115
|
+
"stop": "Stop",
|
|
116
|
+
"load": "Load",
|
|
117
|
+
"unload": "Unload",
|
|
118
|
+
"done": "Done",
|
|
119
|
+
"question": "Question",
|
|
120
|
+
"context": "Context",
|
|
121
|
+
"prompt": "Prompt",
|
|
122
|
+
"issue": "Issue",
|
|
123
|
+
"info": "Information",
|
|
124
|
+
"status": "Status",
|
|
125
|
+
|
|
126
|
+
"question_ask": "Question ask",
|
|
127
|
+
"question_ask_answer": "Question ask answer",
|
|
128
|
+
"question_cmd": "Question command",
|
|
129
|
+
"question_method": "Question method",
|
|
130
|
+
"question_talk": "Question talk",
|
|
131
|
+
"question_answer": "Question answer",
|
|
132
|
+
"question_done": "Question done",
|
|
133
|
+
|
|
134
|
+
"answer": "Answer",
|
|
135
|
+
"answer_talk": "Answer talk",
|
|
136
|
+
"ask": "Ask",
|
|
137
|
+
"ask_answer": "Ask answer",
|
|
88
138
|
|
|
89
139
|
"security": "SECURITY",
|
|
90
140
|
"support": "SUPPORT",
|
|
91
141
|
"systems": "SYSTMS",
|
|
92
142
|
"services": "SERVICES",
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"Research": "configure research",
|
|
106
|
-
"Development": "configure development",
|
|
107
|
-
"Legal": "configure legal",
|
|
108
|
-
"Business": "configure business",
|
|
109
|
-
"Assistant": "configure assistant",
|
|
110
|
-
"Done": "configure done",
|
|
111
|
-
"invalid": "invalid",
|
|
112
|
-
"states": "getting states",
|
|
113
|
-
"actions": "getting actions",
|
|
114
|
-
"zones": "getting zones",
|
|
143
|
+
|
|
144
|
+
"Client": "Set client",
|
|
145
|
+
"Security": "Set Security",
|
|
146
|
+
"Support": "Set Support",
|
|
147
|
+
"Systems": "Set Systems",
|
|
148
|
+
"Services": "Set Services",
|
|
149
|
+
"Done": "Done",
|
|
150
|
+
|
|
151
|
+
"invalid": "Invalid",
|
|
152
|
+
"states": "States",
|
|
153
|
+
"actions": "Actions",
|
|
154
|
+
"zones": "Zones",
|
|
115
155
|
"features": "Getting features",
|
|
116
|
-
"
|
|
117
|
-
"finish": "
|
|
156
|
+
"contexts": "Getting contexts",
|
|
157
|
+
"finish": "Finished action",
|
|
158
|
+
"help": "Giving some HELP!",
|
|
159
|
+
"error": "We have an ERROR!"
|
|
118
160
|
},
|
|
119
161
|
"feature": false,
|
|
120
162
|
"features": {
|
|
163
|
+
"client": "Client",
|
|
164
|
+
"agent": "Agent",
|
|
121
165
|
"security": "Security",
|
|
122
166
|
"support": "Support",
|
|
123
167
|
"services": "Services",
|
|
124
168
|
"solutions": "Solutions",
|
|
125
|
-
"systems": "Systems"
|
|
126
|
-
"research": "Research",
|
|
127
|
-
"development": "Development",
|
|
128
|
-
"business": "Business",
|
|
129
|
-
"legal": "Legal",
|
|
130
|
-
"assistant": "Assistant"
|
|
169
|
+
"systems": "Systems"
|
|
131
170
|
},
|
|
132
171
|
"message": "offline",
|
|
133
172
|
"messages": {
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"init": "initializing",
|
|
141
|
-
"start": "starting",
|
|
142
|
-
"enter": "has entered deva.world",
|
|
143
|
-
"stop": "stopping",
|
|
144
|
-
"exit": "has exited deva.world",
|
|
145
|
-
"load": "loading",
|
|
146
|
-
"unload": "is unloading",
|
|
147
|
-
"invalid": "seems to be invalid",
|
|
148
|
-
"done": "done",
|
|
149
|
-
"error": "appears to have had an error",
|
|
150
|
-
"help": "getting help"
|
|
151
|
-
},
|
|
152
|
-
"zones": {
|
|
153
|
-
"deva": "The Deva Zone",
|
|
154
|
-
"config": "The Config Zone",
|
|
155
|
-
"features": "The Features Zone",
|
|
156
|
-
"learn": "The Learning Zone",
|
|
157
|
-
"personal": "The Personal Zone",
|
|
158
|
-
"work": "The Work Zone",
|
|
159
|
-
"danger": "The Danger Zone",
|
|
160
|
-
"help": "The Help Zone"
|
|
161
|
-
},
|
|
162
|
-
"actions": {
|
|
163
|
-
"wait": "waiting",
|
|
164
|
-
"start": "started",
|
|
165
|
-
"enter": "entered deva.world",
|
|
166
|
-
"exit": "exited deva.world",
|
|
167
|
-
"stop": "stopped",
|
|
168
|
-
"load": "loaded",
|
|
169
|
-
"unload": "unloaded",
|
|
170
|
-
"question": "received a question",
|
|
171
|
-
"question_ask": "asking another Deva",
|
|
172
|
-
"question_ask_answer": "answered what they were asked",
|
|
173
|
-
"question_cmd": "running a command",
|
|
174
|
-
"question_method": "running a method",
|
|
175
|
-
"question_talk": "broadcasting the question",
|
|
176
|
-
"question_answer": "answered the question",
|
|
177
|
-
"question_done": "the question is done",
|
|
178
|
-
"answer": "generating an answer",
|
|
179
|
-
"answer_talk": "talking an answer",
|
|
180
|
-
"ask": "asking a question",
|
|
181
|
-
"ask_answer": "answering a question",
|
|
182
|
-
|
|
183
|
-
"security": "security feature action",
|
|
184
|
-
"Security": "loading the Security Feature",
|
|
185
|
-
"support": "support feature action",
|
|
186
|
-
"Support": "loading the Support Feature",
|
|
187
|
-
"services": "services feature action",
|
|
188
|
-
"Services": "loading the Services Feature",
|
|
189
|
-
"solutions": "solutions feature action",
|
|
190
|
-
"Solutions": "loading the Services Feature",
|
|
191
|
-
"systems": "systems feature action",
|
|
192
|
-
"Systems": "loading the Systems Feature",
|
|
193
|
-
"research": "research feature action",
|
|
194
|
-
"Research": "loading the Research Feature",
|
|
195
|
-
"development": "development feature action",
|
|
196
|
-
"Development": "loading the Development Feature",
|
|
197
|
-
"business": "business feature action",
|
|
198
|
-
"Business": "loading the Business Feature",
|
|
199
|
-
"legal": "legal feature action",
|
|
200
|
-
"Legal": "loading the Legal Feature",
|
|
201
|
-
"assistant": "assistant feature action",
|
|
202
|
-
"Assistant": "loading the Assistant Feature",
|
|
203
|
-
"client_data": "configure client data",
|
|
204
|
-
"invalid": "invalid action",
|
|
205
|
-
"finish": "finished",
|
|
206
|
-
"done": "done",
|
|
207
|
-
"help": "providing help",
|
|
208
|
-
"states": "listing the states",
|
|
209
|
-
"actions": "listing the actions",
|
|
210
|
-
"zones": "listing the zones",
|
|
211
|
-
"features": "listing the features",
|
|
212
|
-
"contexts": "listing the contexts"
|
|
213
|
-
},
|
|
214
|
-
"features": {
|
|
215
|
-
"security": "Security",
|
|
216
|
-
"support": "Support",
|
|
217
|
-
"services": "Services",
|
|
218
|
-
"solutions": "Solutions",
|
|
219
|
-
"systems": "Systems",
|
|
220
|
-
"research": "Research",
|
|
221
|
-
"development": "Development",
|
|
222
|
-
"business": "Business",
|
|
223
|
-
"legal": "Legal",
|
|
224
|
-
"assistant": "Assistant"
|
|
225
|
-
}
|
|
173
|
+
"init": "Initializing Deva",
|
|
174
|
+
"offline": "The Deva is OFFLINE.",
|
|
175
|
+
"notext": "NO TEXT WAS PROVIDED",
|
|
176
|
+
"nopacket": "NO PACKET WAS PROVIDED",
|
|
177
|
+
"method_not_found": "METHOD NOT FOUND",
|
|
178
|
+
"stop": "Stop Deva."
|
|
226
179
|
}
|
|
227
180
|
}
|
|
228
181
|
}
|
package/index.js
CHANGED
|
@@ -21,12 +21,6 @@ class Deva {
|
|
|
21
21
|
this._support = false; // inherited Support features.
|
|
22
22
|
this._services = false; // inherited Service features.
|
|
23
23
|
this._systems = false; // inherited Systems features.
|
|
24
|
-
this._solutions = false; // inherited Solutions features.
|
|
25
|
-
this._research = false; // inherited Research features.
|
|
26
|
-
this._development = false; // inherited Development features.
|
|
27
|
-
this._business = false; // inherited Business features.
|
|
28
|
-
this._legal = false; // inherited Legal features.
|
|
29
|
-
this._assistant = false; // inherited Assistant features.
|
|
30
24
|
this.os = require('os'); // It is used to provide basic operating system related utility functions.
|
|
31
25
|
this.buffer = require('buffer'); // It is used to provide basic operating system related utility functions.
|
|
32
26
|
this.util = require('util'); // The supports the needs of internal APIs.
|
|
@@ -83,20 +77,8 @@ class Deva {
|
|
|
83
77
|
|
|
84
78
|
this._context = opts.context || false; // set the local context
|
|
85
79
|
|
|
86
|
-
this._message = config.message; // current
|
|
87
|
-
this._messages =
|
|
88
|
-
notext: 'NO TEXT WAS PROVIDED',
|
|
89
|
-
nopacket: 'NO PACKET WAS PROVIDED',
|
|
90
|
-
method_not_found: 'METHOD NOT FOUND',
|
|
91
|
-
}; // set the messages from config
|
|
92
|
-
|
|
93
|
-
// then here we are going to loop the messages config to make sure custom values are set
|
|
94
|
-
for (let x in config.messages) {
|
|
95
|
-
this._messages[x] = {};
|
|
96
|
-
for (let y in config.messages[x]) {
|
|
97
|
-
this._messages[x][y] = config.messages[x][y].replace('::agent.name::', opts.agent.profile.name);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
80
|
+
this._message = config.message; // current message of agent.
|
|
81
|
+
this._messages = config.messages; // set the messages from config
|
|
100
82
|
}
|
|
101
83
|
|
|
102
84
|
/**************
|
|
@@ -201,7 +183,6 @@ class Deva {
|
|
|
201
183
|
This will return a not found text string preventing any furhter processing.
|
|
202
184
|
***************/
|
|
203
185
|
_methodNotFound(packet) {
|
|
204
|
-
this.action('invalid');
|
|
205
186
|
packet.a = {
|
|
206
187
|
id: this.uid(),
|
|
207
188
|
agent: this.agent() || false,
|
|
@@ -251,11 +232,12 @@ class Deva {
|
|
|
251
232
|
client presented data.
|
|
252
233
|
***************/
|
|
253
234
|
Security() {
|
|
235
|
+
this.zone('security');
|
|
254
236
|
const _cl = this.client(); // set local copy of client data
|
|
255
237
|
try {
|
|
256
238
|
if (!_cl.features.security) return this.Support(); // if no security feature goto Support
|
|
257
239
|
else {
|
|
258
|
-
this.
|
|
240
|
+
this.state('data');
|
|
259
241
|
const {id, profile, features} = _cl; // make a copy the clinet data.
|
|
260
242
|
const {security} = features; // make a copy the clinet data.
|
|
261
243
|
this._security = { // set this_security with data
|
|
@@ -269,6 +251,7 @@ class Deva {
|
|
|
269
251
|
personal: security.devas[this._agent.key], // Client personal features and rules.
|
|
270
252
|
};
|
|
271
253
|
delete this._client.features.security; // make a copy the clinet data.
|
|
254
|
+
this.action('Security'); // set action to Security
|
|
272
255
|
return this.Support(); // goto Support when done with Security
|
|
273
256
|
}
|
|
274
257
|
} catch (e) {
|
|
@@ -284,11 +267,12 @@ class Deva {
|
|
|
284
267
|
client presented data.
|
|
285
268
|
***************/
|
|
286
269
|
Support() {
|
|
270
|
+
this.zone('support');
|
|
287
271
|
const _cl = this.client(); // set the local client variable
|
|
288
272
|
try {
|
|
289
273
|
if (!_cl.features.support) return this.Services() // move to Services if no support feature
|
|
290
274
|
else {
|
|
291
|
-
this.
|
|
275
|
+
this.state('data');
|
|
292
276
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
293
277
|
const {support} = features; // set support from features const
|
|
294
278
|
this._support = { // set this_support with data
|
|
@@ -299,7 +283,8 @@ class Deva {
|
|
|
299
283
|
global: support.global, // the global policies for client
|
|
300
284
|
personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
|
|
301
285
|
};
|
|
302
|
-
delete this._client.features.support // delete the support key from the client
|
|
286
|
+
delete this._client.features.support; // delete the support key from the client
|
|
287
|
+
this.action('Support');
|
|
303
288
|
return this.Services(); // when done move to Services
|
|
304
289
|
}
|
|
305
290
|
} catch (e) {
|
|
@@ -315,11 +300,12 @@ class Deva {
|
|
|
315
300
|
client presented data.
|
|
316
301
|
***************/
|
|
317
302
|
Services() {
|
|
303
|
+
this.zone('services')
|
|
318
304
|
const _cl = this.client(); // set local client
|
|
319
305
|
try {
|
|
320
306
|
if (!_cl.features.services) return this.Systems(); // move to Systems if no Services feature
|
|
321
307
|
else {
|
|
322
|
-
this.
|
|
308
|
+
this.state('data');
|
|
323
309
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
324
310
|
const {services} = features; // set services from features const
|
|
325
311
|
this._services = { // set this_services with data
|
|
@@ -330,8 +316,9 @@ class Deva {
|
|
|
330
316
|
global: services.global, // the global policies for client
|
|
331
317
|
personal: services.devas[this._agent.key], // Client personal features and rules.
|
|
332
318
|
};
|
|
333
|
-
delete this._client.features.services // delete the services key for isolation
|
|
334
|
-
|
|
319
|
+
delete this._client.features.services; // delete the services key for isolation
|
|
320
|
+
this.action('Services');
|
|
321
|
+
return this.Systems(); // go to Systems when done
|
|
335
322
|
}
|
|
336
323
|
} catch (e) {
|
|
337
324
|
return this.error(e); // run error handling if an error is caught
|
|
@@ -346,11 +333,12 @@ class Deva {
|
|
|
346
333
|
client presented data.
|
|
347
334
|
***************/
|
|
348
335
|
Systems() {
|
|
336
|
+
this.zone('systems');
|
|
349
337
|
const _cl = this.client();
|
|
350
338
|
try {
|
|
351
|
-
if (!_cl.features.systems) return this.
|
|
339
|
+
if (!_cl.features.systems) return this.Done(); // move to Solutions if no systems feature
|
|
352
340
|
else {
|
|
353
|
-
this.
|
|
341
|
+
this.state('data');
|
|
354
342
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
355
343
|
const {systems} = features; // set systems from features const
|
|
356
344
|
this._systems = { // set this_systems with data
|
|
@@ -361,199 +349,15 @@ class Deva {
|
|
|
361
349
|
global: systems.global, // the global policies for client
|
|
362
350
|
personal: systems.devas[this._agent.key], // Client personal features and rules.
|
|
363
351
|
};
|
|
364
|
-
delete this._client.features.systems
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
} catch (e) {
|
|
368
|
-
return this.error(e); // run error handling if an error is caught
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**************
|
|
373
|
-
func: Solutions
|
|
374
|
-
params: client: false
|
|
375
|
-
describe:
|
|
376
|
-
The Solutions feature sets the correct variables and necessary rules for the
|
|
377
|
-
client presented data.
|
|
378
|
-
***************/
|
|
379
|
-
Solutions() {
|
|
380
|
-
const _cl = this.client();
|
|
381
|
-
try {
|
|
382
|
-
if (!_cl.features.solutions) return this.Research(); // moe to research if no solutions
|
|
383
|
-
else {
|
|
384
|
-
this.action('Solutions');
|
|
385
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
386
|
-
const {solutions} = features; // set solutions from features const
|
|
387
|
-
this._solutions = { // set this_solutions with data
|
|
388
|
-
id: this.uid(true), // uuid of the solutions feature
|
|
389
|
-
client_id: id, // client id for reference
|
|
390
|
-
client_name: profile.name, // client name for personalization
|
|
391
|
-
concerns: solutions.concerns, // any concerns for client
|
|
392
|
-
global: solutions.global, // the global policies for client
|
|
393
|
-
personal: solutions.devas[this._agent.key], // Client personal features and rules.
|
|
394
|
-
};
|
|
395
|
-
delete this._client.features.solutions
|
|
396
|
-
return this.Research()
|
|
397
|
-
}
|
|
398
|
-
} catch (e) {
|
|
399
|
-
return this.error(e); // run error handling if an error is caught
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**************
|
|
404
|
-
func: Research
|
|
405
|
-
params: client: false
|
|
406
|
-
describe:
|
|
407
|
-
The Research feature sets the correct variables and necessary rules for the
|
|
408
|
-
client presented data.
|
|
409
|
-
***************/
|
|
410
|
-
Research() {
|
|
411
|
-
const _cl = this.client(); // set local client variable
|
|
412
|
-
try {
|
|
413
|
-
if (!_cl.features.research) return this.Development(); // if no research goto Business
|
|
414
|
-
else {
|
|
415
|
-
this.action('Research'); // set the action to Research
|
|
416
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
417
|
-
const {research} = features; // set research from features const
|
|
418
|
-
this._research = { // set this_research with data
|
|
419
|
-
id: this.uid(true), // uuid of the research feature
|
|
420
|
-
client_id: id, // client id for reference
|
|
421
|
-
client_name: profile.name, // client name for personalization
|
|
422
|
-
concerns: research.concerns, // any concerns for client
|
|
423
|
-
global: research.global, // the global policies for client
|
|
424
|
-
personal: research.devas[this._agent.key] // Client personal features and rules.
|
|
425
|
-
};
|
|
426
|
-
delete this._client.features.research // delete the research key from client features
|
|
427
|
-
return this.Development(); // goto Development.
|
|
428
|
-
}
|
|
429
|
-
} catch (e) {
|
|
430
|
-
return this.error(e); // run error handling if an error is caught
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**************
|
|
435
|
-
func: Development
|
|
436
|
-
params: client: false
|
|
437
|
-
describe:
|
|
438
|
-
The Development feature sets the correct variables and necessary rules for the
|
|
439
|
-
client presented data.
|
|
440
|
-
***************/
|
|
441
|
-
Development() {
|
|
442
|
-
const _cl = this.client(); // get hte client data to local variable
|
|
443
|
-
try {
|
|
444
|
-
if (!_cl.features.development) return this.Business(); // if no development goto Business
|
|
445
|
-
else {
|
|
446
|
-
this.action('Development'); // set the action to Development
|
|
447
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
448
|
-
const {development} = features; // set development from features const
|
|
449
|
-
this._development = { // set this_development with data
|
|
450
|
-
id: this.uid(true), // uuid of the development feature
|
|
451
|
-
client_id: id, // client id for reference
|
|
452
|
-
client_name: profile.name, // client name for personalization
|
|
453
|
-
concerns: development.concerns, // any concerns for client
|
|
454
|
-
global: development.global, // the global policies for client
|
|
455
|
-
personal: development.devas[this._agent.key], // Client personal features and rules.
|
|
456
|
-
};
|
|
457
|
-
delete this._client.features.development; // delete the development key from client features.
|
|
458
|
-
return this.Business(); // goto business when development is done
|
|
352
|
+
delete this._client.features.systems;
|
|
353
|
+
this.action('Systems');
|
|
354
|
+
return this.Done();
|
|
459
355
|
}
|
|
460
356
|
} catch (e) {
|
|
461
357
|
return this.error(e); // run error handling if an error is caught
|
|
462
358
|
}
|
|
463
359
|
}
|
|
464
360
|
|
|
465
|
-
/**************
|
|
466
|
-
func: Business
|
|
467
|
-
params: client: false
|
|
468
|
-
describe:
|
|
469
|
-
The Business feature sets the correct variables and necessary rules for the
|
|
470
|
-
client presented data.
|
|
471
|
-
***************/
|
|
472
|
-
Business() {
|
|
473
|
-
const _cl = this.client(); // set client into local variable.
|
|
474
|
-
try {
|
|
475
|
-
if (!_cl.features.business) return this.Legal(); // if no business hten goto legal
|
|
476
|
-
else {
|
|
477
|
-
this.action('Business'); // set action to Business
|
|
478
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
479
|
-
const {business} = features; // set business from features const
|
|
480
|
-
this._business = { // set this_business with data
|
|
481
|
-
id: this.uid(true), // uuid of the business feature
|
|
482
|
-
client_id: id, // client id for reference
|
|
483
|
-
client_name: profile.name, // client name for personalization
|
|
484
|
-
concerns: business.concerns, // any concerns for client
|
|
485
|
-
global: business.global, // the global policies for client
|
|
486
|
-
personal: business.devas[this._agent.key] // Client personal features and rules.
|
|
487
|
-
};
|
|
488
|
-
delete this._client.features.business; // delete the business key from the client features
|
|
489
|
-
return this.Legal(); // go to Legal when Business is done.
|
|
490
|
-
}
|
|
491
|
-
} catch (e) {
|
|
492
|
-
return this.error(e); // run error handling if an error is caught
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**************
|
|
497
|
-
func: Legal
|
|
498
|
-
params: client: false
|
|
499
|
-
describe:
|
|
500
|
-
The Legal feature sets the correct variables and necessary rules for the
|
|
501
|
-
client presented data.
|
|
502
|
-
***************/
|
|
503
|
-
Legal() {
|
|
504
|
-
const _cl = this.client(); // set hte local client variable
|
|
505
|
-
try {
|
|
506
|
-
if (!_cl.features.legal) this.Assistant(); // if no legal feature then move to assistant
|
|
507
|
-
else {
|
|
508
|
-
this.action('Legal'); // set the action to legal
|
|
509
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
510
|
-
const {legal} = features; // set legal from features const
|
|
511
|
-
this._legal = { // set this_legal with data
|
|
512
|
-
id: this.uid(true), // uuid of the legal feature
|
|
513
|
-
client_id: id, // client id for reference
|
|
514
|
-
client_name: profile.name, // client name for personalization
|
|
515
|
-
concerns: legal.concerns, // any concerns for client
|
|
516
|
-
global: legal.global, // the global policies for client
|
|
517
|
-
personal: legal.devas[this._agent.key], // Client personal features and rules.
|
|
518
|
-
};
|
|
519
|
-
delete this._client.features.legal; // remove the legal key from the client data
|
|
520
|
-
return this.Assistant(); // when done goto Assis
|
|
521
|
-
}
|
|
522
|
-
} catch (e) {
|
|
523
|
-
return this.error(e); // run error handling if an error is caught
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**************
|
|
528
|
-
func: Assistant
|
|
529
|
-
params: client: false
|
|
530
|
-
describe:
|
|
531
|
-
The Assistant feature sets the correct variables and necessary rules for the
|
|
532
|
-
client presented data.
|
|
533
|
-
***************/
|
|
534
|
-
Assistant() {
|
|
535
|
-
const _cl = this.client(); // set the client into a local variable
|
|
536
|
-
try {
|
|
537
|
-
if (!_cl.features.assistant) return this.Done(); // if no Assistant then goto Done
|
|
538
|
-
else {
|
|
539
|
-
this.action('Assistant'); // set action to Assistant
|
|
540
|
-
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
541
|
-
const {assistant} = features; // set assistant from features const
|
|
542
|
-
this._assistant = { // set this_assistant with data
|
|
543
|
-
id: this.uid(true), // uuid of the assistant feature
|
|
544
|
-
client_id: id, // client id for reference
|
|
545
|
-
client_name: profile.name, // client name for personalization
|
|
546
|
-
concerns: assistant.concerns, // any concerns for client
|
|
547
|
-
global: assistant.global, // the global policies for client
|
|
548
|
-
personal: assistant.devas[this._agent.key] // Client personal features and rules.
|
|
549
|
-
};
|
|
550
|
-
delete this._client.features.assistant; // delete the assistant key from client features
|
|
551
|
-
return this.Done(); // when assistant is done goto Done.
|
|
552
|
-
}
|
|
553
|
-
} catch (e) {
|
|
554
|
-
return this.error(e); // run error handling if an error is caught
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
361
|
|
|
558
362
|
/**************
|
|
559
363
|
func: Done
|
|
@@ -561,11 +365,16 @@ class Deva {
|
|
|
561
365
|
describe: The end of the workflow Client Feature Workflow
|
|
562
366
|
***************/
|
|
563
367
|
Done(client) {
|
|
368
|
+
this.zone('done'); // set state to assistant setting
|
|
369
|
+
this.state('done');
|
|
370
|
+
this.action('done');
|
|
564
371
|
return new Promise((resolve, reject) => {
|
|
565
372
|
try {
|
|
566
373
|
delete this._client.features; // delete the features key when done.
|
|
567
|
-
this.
|
|
568
|
-
|
|
374
|
+
this.zone('deva'); // put the agent back in the deva zone.
|
|
375
|
+
this.state('ready');
|
|
376
|
+
this.action('wait');
|
|
377
|
+
return resolve(client); // resolve an empty pr
|
|
569
378
|
} catch (e) {
|
|
570
379
|
return this.error(e, false, reject);
|
|
571
380
|
}
|
|
@@ -634,8 +443,10 @@ class Deva {
|
|
|
634
443
|
describe:
|
|
635
444
|
***************/
|
|
636
445
|
question(TEXT=false, DATA=false) {
|
|
446
|
+
this.zone('question');
|
|
637
447
|
// check the active status
|
|
638
|
-
if (!this._active) return Promise.resolve(this._messages.
|
|
448
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
449
|
+
|
|
639
450
|
this.state('question');
|
|
640
451
|
const id = this.uid(); // generate a unique id for transport.
|
|
641
452
|
const t_split = TEXT.split(' '); // split the text on spaces to get words.
|
|
@@ -664,7 +475,7 @@ class Deva {
|
|
|
664
475
|
// resolve with the no text message if the client says nothing.
|
|
665
476
|
if (!TEXT) return this.finish(this._messages.notext, resolve);
|
|
666
477
|
// reject question if Deva offline
|
|
667
|
-
if (!this._active) return this.finish(this._messages.
|
|
478
|
+
if (!this._active) return this.finish(this._messages.offline, resolve);
|
|
668
479
|
let _action = 'question'
|
|
669
480
|
try { // try to answer the question
|
|
670
481
|
if (isAsk) { // determine if hte question isAsk
|
|
@@ -735,7 +546,8 @@ class Deva {
|
|
|
735
546
|
from the agent from the pre-determined method.
|
|
736
547
|
***************/
|
|
737
548
|
answer(packet, resolve, reject) {
|
|
738
|
-
|
|
549
|
+
this.zone('answer');
|
|
550
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
739
551
|
this.state('answer');
|
|
740
552
|
// check if method exists and is of type function
|
|
741
553
|
const {method,params} = packet.q.meta;
|
|
@@ -798,9 +610,10 @@ class Deva {
|
|
|
798
610
|
so the event is specific to the talk.
|
|
799
611
|
***************/
|
|
800
612
|
ask(packet) {
|
|
801
|
-
|
|
613
|
+
this.zone('ask');
|
|
614
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
615
|
+
|
|
802
616
|
this.state('ask');
|
|
803
|
-
this.action('ask');
|
|
804
617
|
|
|
805
618
|
const agent = this.agent();
|
|
806
619
|
const client = this.client();
|
|
@@ -830,6 +643,7 @@ class Deva {
|
|
|
830
643
|
|
|
831
644
|
// The method is parsed and depending on what method is asked for it returns
|
|
832
645
|
// the response based on the passed through packet.
|
|
646
|
+
this.action('ask');
|
|
833
647
|
this.methods[packet.q.meta.method](packet).then(result => {
|
|
834
648
|
if (typeof result === 'object') {
|
|
835
649
|
packet_answer.text = result.text || false;
|
|
@@ -873,6 +687,7 @@ class Deva {
|
|
|
873
687
|
usage: this.init(client_object)
|
|
874
688
|
***************/
|
|
875
689
|
init(client) {
|
|
690
|
+
this.zone('init');
|
|
876
691
|
// set client
|
|
877
692
|
this._active = Date.now();
|
|
878
693
|
const agent = this.agent();
|
|
@@ -882,11 +697,12 @@ class Deva {
|
|
|
882
697
|
value: agent.key,
|
|
883
698
|
agent,
|
|
884
699
|
client,
|
|
885
|
-
text: this._messages.
|
|
700
|
+
text: this._messages.init,
|
|
886
701
|
created: Date.now(),
|
|
887
702
|
}
|
|
888
703
|
_data.hash = this.hash(_data);
|
|
889
704
|
|
|
705
|
+
this.state('init');
|
|
890
706
|
return new Promise((resolve, reject) => {
|
|
891
707
|
this.events.setMaxListeners(this.maxListeners);
|
|
892
708
|
this._assignInherit().then(() => {
|
|
@@ -894,14 +710,10 @@ class Deva {
|
|
|
894
710
|
}).then(() => {
|
|
895
711
|
return this._assignListeners();
|
|
896
712
|
}).then(() => {
|
|
897
|
-
this.state('init');
|
|
898
|
-
this.zone('config');
|
|
899
713
|
return this.Client(client);
|
|
900
714
|
}).then(() => {
|
|
901
|
-
this.zone('features');
|
|
902
715
|
return this.Security();
|
|
903
716
|
}).then(() => {
|
|
904
|
-
this.zone('deva');
|
|
905
717
|
const hasOnInit = this.onInit && typeof this.onInit === 'function';
|
|
906
718
|
return hasOnInit ? this.onInit(_data) : this.start(_data)
|
|
907
719
|
}).catch(err => {
|
|
@@ -921,14 +733,14 @@ class Deva {
|
|
|
921
733
|
usage: this.start('msg')
|
|
922
734
|
***************/
|
|
923
735
|
start(data) {
|
|
924
|
-
|
|
736
|
+
this.zone('start');
|
|
737
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
925
738
|
this.state('start');
|
|
926
739
|
data.value = 'start';
|
|
927
740
|
delete data.hash;
|
|
928
741
|
data.hash = this.hash(data);
|
|
929
|
-
|
|
930
|
-
this.action(data.value);
|
|
931
742
|
const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
|
|
743
|
+
this.action('start');
|
|
932
744
|
return hasOnStart ? this.onStart(data) : this.enter(data)
|
|
933
745
|
}
|
|
934
746
|
|
|
@@ -944,12 +756,13 @@ class Deva {
|
|
|
944
756
|
usage: this.enter('msg')
|
|
945
757
|
***************/
|
|
946
758
|
enter(data) {
|
|
947
|
-
|
|
759
|
+
this.zone('enter');
|
|
760
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
948
761
|
this.state('enter');
|
|
949
762
|
data.value = 'enter';
|
|
950
763
|
delete data.hash;
|
|
951
764
|
data.hash = this.hash(data);
|
|
952
|
-
this.action(
|
|
765
|
+
this.action('enter');
|
|
953
766
|
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
954
767
|
return hasOnEnter ? this.onEnter(data) : this.done(data)
|
|
955
768
|
}
|
|
@@ -966,13 +779,14 @@ class Deva {
|
|
|
966
779
|
usage: this.done('msg')
|
|
967
780
|
***************/
|
|
968
781
|
done(data) {
|
|
969
|
-
|
|
782
|
+
this.zone('done');
|
|
783
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
970
784
|
this.state('done');
|
|
971
785
|
data.value = 'done';
|
|
972
786
|
delete data.hash;
|
|
973
787
|
data.hash = this.hash(data);
|
|
974
|
-
this.action(data.value)
|
|
975
788
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
789
|
+
this.action('done')
|
|
976
790
|
return hasOnDone ? this.onDone(data) : Promise.resolve(data);
|
|
977
791
|
}
|
|
978
792
|
|
|
@@ -988,15 +802,14 @@ class Deva {
|
|
|
988
802
|
this.finish(data, resolve)
|
|
989
803
|
***************/
|
|
990
804
|
finish(packet, resolve) {
|
|
991
|
-
|
|
992
|
-
this.
|
|
805
|
+
this.zone('finish');
|
|
806
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
807
|
+
this.state('finish');
|
|
993
808
|
packet.hash = this.hash(packet);// hash the entire packet before finishing.
|
|
994
809
|
const hasOnFinish = this.onFinish && typeof this.onFinish === 'function' ? true : false;
|
|
995
810
|
|
|
996
|
-
this.state('ready');
|
|
997
811
|
if (hasOnFinish) return this.onFinish(packet, resolve);
|
|
998
|
-
|
|
999
|
-
else return Promise.resolve(packet)
|
|
812
|
+
this.action('finish');
|
|
1000
813
|
return resolve ? resolve(packet) : Promise.resolve(packet);
|
|
1001
814
|
}
|
|
1002
815
|
|
|
@@ -1014,22 +827,27 @@ class Deva {
|
|
|
1014
827
|
this.stop('msg')
|
|
1015
828
|
***************/
|
|
1016
829
|
stop() {
|
|
1017
|
-
|
|
830
|
+
this.zone('stop');
|
|
831
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
832
|
+
|
|
1018
833
|
this.state('stop');
|
|
1019
834
|
const agent = this.agent();
|
|
1020
835
|
const client = this.client();
|
|
836
|
+
|
|
1021
837
|
const data = {
|
|
1022
838
|
id: this.uid(true),
|
|
1023
839
|
key: 'stop',
|
|
1024
840
|
value: agent.key,
|
|
1025
841
|
agent,
|
|
1026
842
|
client,
|
|
1027
|
-
text: this._messages.
|
|
843
|
+
text: this._messages.stop,
|
|
1028
844
|
created: Date.now(),
|
|
1029
845
|
}
|
|
846
|
+
|
|
1030
847
|
data.hash = this.hash(data);
|
|
1031
|
-
this.action(data.value);
|
|
1032
848
|
const hasOnStop = this.onStop && typeof this.onStop === 'function';
|
|
849
|
+
|
|
850
|
+
this.action('stop');
|
|
1033
851
|
return hasOnStop ? this.onStop(data) : this.exit(data)
|
|
1034
852
|
}
|
|
1035
853
|
|
|
@@ -1049,12 +867,13 @@ class Deva {
|
|
|
1049
867
|
usage: this.exit('msg')
|
|
1050
868
|
***************/
|
|
1051
869
|
exit(data) {
|
|
1052
|
-
this.
|
|
870
|
+
this.zone('exit');
|
|
1053
871
|
this._active = false;
|
|
1054
872
|
data.value = 'exit';
|
|
1055
873
|
delete data.hash;
|
|
1056
874
|
data.hash = this.hash(data);
|
|
1057
875
|
|
|
876
|
+
this.state('exit');
|
|
1058
877
|
// clear memory
|
|
1059
878
|
this._active = false;
|
|
1060
879
|
this._client = false;
|
|
@@ -1066,7 +885,7 @@ class Deva {
|
|
|
1066
885
|
this._legal = false;
|
|
1067
886
|
this._assistant = false;
|
|
1068
887
|
|
|
1069
|
-
this.action(
|
|
888
|
+
this.action('exit');
|
|
1070
889
|
const hasOnExit = this.onExit && typeof this.onExit === 'function';
|
|
1071
890
|
return hasOnExit ? this.onExit(data) : Promise.resolve(data)
|
|
1072
891
|
}
|
|
@@ -1084,7 +903,7 @@ class Deva {
|
|
|
1084
903
|
try {
|
|
1085
904
|
if (!this._states[state]) return;
|
|
1086
905
|
this._state = state;
|
|
1087
|
-
const text = this.
|
|
906
|
+
const text = this._states[state];
|
|
1088
907
|
const data = {
|
|
1089
908
|
id: this.uid(true),
|
|
1090
909
|
key: 'state',
|
|
@@ -1112,7 +931,6 @@ class Deva {
|
|
|
1112
931
|
id: this.uid(true),
|
|
1113
932
|
key: 'states',
|
|
1114
933
|
value: this._states,
|
|
1115
|
-
messages: this._messages.states,
|
|
1116
934
|
created: Date.now(),
|
|
1117
935
|
}
|
|
1118
936
|
}
|
|
@@ -1127,7 +945,7 @@ class Deva {
|
|
|
1127
945
|
if (!this._zones[value] || value === this._zone) return;
|
|
1128
946
|
try {
|
|
1129
947
|
this._zone = value;
|
|
1130
|
-
const text = this.
|
|
948
|
+
const text = this._zones[value];
|
|
1131
949
|
const data = {
|
|
1132
950
|
id: this.uid(true),
|
|
1133
951
|
key: 'zone',
|
|
@@ -1149,7 +967,6 @@ class Deva {
|
|
|
1149
967
|
id: this.uid(true),
|
|
1150
968
|
key: 'zones',
|
|
1151
969
|
value: this._zones,
|
|
1152
|
-
messages: this._messages.zones,
|
|
1153
970
|
created: Date.now(),
|
|
1154
971
|
}
|
|
1155
972
|
}
|
|
@@ -1165,7 +982,7 @@ class Deva {
|
|
|
1165
982
|
// check local vars for custom actions
|
|
1166
983
|
const var_action = this.vars.actions ? this.vars.actions[action] : false;
|
|
1167
984
|
// check system action messages
|
|
1168
|
-
const msg_action = this.
|
|
985
|
+
const msg_action = this._actions[action] || var_action;
|
|
1169
986
|
const text = msg_action || action; // set the text of the action
|
|
1170
987
|
const data = { // build the data object for the action.
|
|
1171
988
|
id: this.uid(true), // generate a guid for the action transmitssion.
|
|
@@ -1189,7 +1006,6 @@ class Deva {
|
|
|
1189
1006
|
id: this.uid(true),
|
|
1190
1007
|
key: 'actions',
|
|
1191
1008
|
value: this._actions,
|
|
1192
|
-
messages: this._messages.actions,
|
|
1193
1009
|
created: Date.now(),
|
|
1194
1010
|
}
|
|
1195
1011
|
}
|
|
@@ -1201,10 +1017,11 @@ class Deva {
|
|
|
1201
1017
|
describe
|
|
1202
1018
|
***************/
|
|
1203
1019
|
feature(feature) {
|
|
1020
|
+
this.action('feature');
|
|
1204
1021
|
try {
|
|
1205
1022
|
if (!this._features[feature]) return;
|
|
1206
1023
|
this._feature = feature;
|
|
1207
|
-
const text = this.
|
|
1024
|
+
const text = this._features[feature] ;
|
|
1208
1025
|
const talk = {
|
|
1209
1026
|
id: this.uid(true),
|
|
1210
1027
|
key: 'feature',
|
|
@@ -1226,7 +1043,6 @@ class Deva {
|
|
|
1226
1043
|
id: this.uid(true),
|
|
1227
1044
|
key: 'features',
|
|
1228
1045
|
value: this._features,
|
|
1229
|
-
messages: this._messages.features,
|
|
1230
1046
|
created: Date.now(),
|
|
1231
1047
|
}
|
|
1232
1048
|
}
|
|
@@ -1262,15 +1078,11 @@ class Deva {
|
|
|
1262
1078
|
return {
|
|
1263
1079
|
id: this.uid(true),
|
|
1264
1080
|
key: 'contexts',
|
|
1265
|
-
value: this.
|
|
1266
|
-
messages: this.vars.context || false,
|
|
1081
|
+
value: this.vars.context || false,
|
|
1267
1082
|
created: Date.now(),
|
|
1268
1083
|
}
|
|
1269
1084
|
}
|
|
1270
1085
|
|
|
1271
|
-
|
|
1272
|
-
///////////////////////////
|
|
1273
|
-
|
|
1274
1086
|
/**************
|
|
1275
1087
|
func: client
|
|
1276
1088
|
params: none
|
|
@@ -1280,11 +1092,8 @@ class Deva {
|
|
|
1280
1092
|
usage: this.client();
|
|
1281
1093
|
***************/
|
|
1282
1094
|
client() {
|
|
1283
|
-
if (!this._active) return this._messages.
|
|
1284
|
-
this.state('client_data'); // set the client state
|
|
1095
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1285
1096
|
const client_copy = this.copy(this._client);
|
|
1286
|
-
// delete client_copy.parse;
|
|
1287
|
-
// delete client_copy.translate;
|
|
1288
1097
|
return client_copy; // return the client feature
|
|
1289
1098
|
}
|
|
1290
1099
|
|
|
@@ -1297,12 +1106,8 @@ class Deva {
|
|
|
1297
1106
|
usage: this.agent()
|
|
1298
1107
|
***************/
|
|
1299
1108
|
agent() {
|
|
1300
|
-
if (!this._active) return this._messages.
|
|
1301
|
-
this.state('agent_data');
|
|
1109
|
+
if (!this._active) return this._messages.offline;
|
|
1302
1110
|
const agent_copy = this.copy(this._agent);
|
|
1303
|
-
delete agent_copy.parse;
|
|
1304
|
-
delete agent_copy.translate;
|
|
1305
|
-
delete agent_copy.process;
|
|
1306
1111
|
return agent_copy;
|
|
1307
1112
|
}
|
|
1308
1113
|
|
|
@@ -1314,14 +1119,14 @@ class Deva {
|
|
|
1314
1119
|
usage: this.security()
|
|
1315
1120
|
***************/
|
|
1316
1121
|
security() {
|
|
1317
|
-
|
|
1318
|
-
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
|
|
1319
1126
|
try {
|
|
1320
|
-
this.action('security');
|
|
1321
|
-
return this.copy(this._security);
|
|
1322
|
-
} catch (e) {
|
|
1323
|
-
return this.error(e);
|
|
1324
|
-
}
|
|
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);}
|
|
1325
1130
|
}
|
|
1326
1131
|
|
|
1327
1132
|
/**************
|
|
@@ -1331,14 +1136,14 @@ class Deva {
|
|
|
1331
1136
|
usage: this.support()
|
|
1332
1137
|
***************/
|
|
1333
1138
|
support() {
|
|
1334
|
-
|
|
1335
|
-
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');
|
|
1336
1143
|
try {
|
|
1337
1144
|
this.action('support');
|
|
1338
|
-
return this.copy(this._support);
|
|
1339
|
-
} catch (e) {
|
|
1340
|
-
return this.error(e);
|
|
1341
|
-
}
|
|
1145
|
+
return this.copy(this._support); // return the support feature
|
|
1146
|
+
} catch (e) {return this.error(e);}
|
|
1342
1147
|
}
|
|
1343
1148
|
|
|
1344
1149
|
/**************
|
|
@@ -1348,14 +1153,14 @@ class Deva {
|
|
|
1348
1153
|
usage: this.services()
|
|
1349
1154
|
***************/
|
|
1350
1155
|
services(opts) {
|
|
1351
|
-
|
|
1352
|
-
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
|
|
1353
1160
|
try {
|
|
1354
|
-
this.action('services');
|
|
1355
|
-
return this.copy(this._services);
|
|
1356
|
-
} catch (e) {
|
|
1357
|
-
return this.error(e);
|
|
1358
|
-
}
|
|
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);}
|
|
1359
1164
|
}
|
|
1360
1165
|
|
|
1361
1166
|
/**************
|
|
@@ -1365,119 +1170,21 @@ class Deva {
|
|
|
1365
1170
|
usage: this.systems()
|
|
1366
1171
|
***************/
|
|
1367
1172
|
systems(opts) {
|
|
1368
|
-
|
|
1369
|
-
this.
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
return this.copy(this._systems); // return the systems feature
|
|
1373
|
-
} catch (e) {
|
|
1374
|
-
return this.error(e)
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
/**************
|
|
1379
|
-
func: solutions
|
|
1380
|
-
params: opts
|
|
1381
|
-
describe: basic solutions features available in a Deva.
|
|
1382
|
-
usage: this.solutions()
|
|
1383
|
-
***************/
|
|
1384
|
-
solutions(opts) {
|
|
1385
|
-
if (!this._active) return this._messages.states.offline; // check the active status
|
|
1386
|
-
this.feature('solutions'); // set the solutions state
|
|
1387
|
-
try {
|
|
1388
|
-
this.action('solutions'); // set the solutions state
|
|
1389
|
-
return this.copy(this._solutions); // return the solutions feature
|
|
1390
|
-
} catch (e) {
|
|
1391
|
-
return this.error(e);
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
/**************
|
|
1396
|
-
func: research
|
|
1397
|
-
params: opts
|
|
1398
|
-
describe: basic research features available in a Deva.
|
|
1399
|
-
***************/
|
|
1400
|
-
research(opts) {
|
|
1401
|
-
if (!this._active) return this._messages.states.offline; // chek the active status
|
|
1402
|
-
this.feature('research'); // set the research state
|
|
1403
|
-
try {
|
|
1404
|
-
this.action('research'); // set the research state
|
|
1405
|
-
return this.copy(this._research); // return research feature
|
|
1406
|
-
} catch (e) {
|
|
1407
|
-
return this.error(e);
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
/**************
|
|
1412
|
-
func: development
|
|
1413
|
-
params: opts
|
|
1414
|
-
describe: basic development features available in a Deva.
|
|
1415
|
-
***************/
|
|
1416
|
-
development(opts) {
|
|
1417
|
-
if (!this._active) return this._messages.states.offline; // chek the active status
|
|
1418
|
-
this.feature('development'); // set the development state
|
|
1419
|
-
try {
|
|
1420
|
-
this.action('development'); // set the development state
|
|
1421
|
-
return this.copy(this._development); // return development feature
|
|
1422
|
-
} catch (e) {
|
|
1423
|
-
return this.error(e);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
/**************
|
|
1428
|
-
func: business
|
|
1429
|
-
params: opts
|
|
1430
|
-
describe: basic business features available in a Deva.
|
|
1431
|
-
***************/
|
|
1432
|
-
business(opts) {
|
|
1433
|
-
if (!this._active) return this._messages.states.offline; // chek the active status
|
|
1434
|
-
this.feature('business'); // set the business state
|
|
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');
|
|
1435
1177
|
try {
|
|
1436
|
-
this.action('
|
|
1437
|
-
return this.copy(this.
|
|
1438
|
-
} catch (e) {
|
|
1439
|
-
return this.error('error');
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
/**************
|
|
1444
|
-
func: legal
|
|
1445
|
-
params: opts
|
|
1446
|
-
describe: basic legal features available in a Deva.
|
|
1447
|
-
***************/
|
|
1448
|
-
legal(opts) {
|
|
1449
|
-
if (!this._active) return this._messages.states.offline; // chek the active status
|
|
1450
|
-
this.feature('legal'); // set the legal state
|
|
1451
|
-
try {
|
|
1452
|
-
this.action('legal');
|
|
1453
|
-
return this.copy(this._legal); // return legal feature
|
|
1454
|
-
} catch (e) {
|
|
1455
|
-
return this.error(e);
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
/**************
|
|
1460
|
-
func: assistant
|
|
1461
|
-
params: opts
|
|
1462
|
-
describe: basic assistant features available in a Deva.
|
|
1463
|
-
***************/
|
|
1464
|
-
assistant(opts) {
|
|
1465
|
-
if (!this._active) return this._messages.states.offline; // chek the active status
|
|
1466
|
-
this.feature('assistant'); // set the assistant state
|
|
1467
|
-
try {
|
|
1468
|
-
this.action('assistant'); // set the assistant state
|
|
1469
|
-
return this.copy(this._assistant); // return assistant feature
|
|
1470
|
-
} catch (e) {
|
|
1471
|
-
return this.error(e);
|
|
1472
|
-
}
|
|
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);}
|
|
1473
1181
|
}
|
|
1474
1182
|
|
|
1475
1183
|
/**************
|
|
1476
1184
|
func: load
|
|
1477
1185
|
params:
|
|
1478
|
-
-deva:
|
|
1479
|
-
describe:
|
|
1480
|
-
This function will enable fast loading of Deva into a system.
|
|
1186
|
+
-deva: The Deva model to load.
|
|
1187
|
+
describe: This function will enable fast loading of Deva into a system.
|
|
1481
1188
|
***************/
|
|
1482
1189
|
load(key, client) {
|
|
1483
1190
|
this.state('load');
|
|
@@ -1487,8 +1194,8 @@ class Deva {
|
|
|
1487
1194
|
/**************
|
|
1488
1195
|
func: unload
|
|
1489
1196
|
params:
|
|
1490
|
-
- deva:
|
|
1491
|
-
describe:
|
|
1197
|
+
- deva: The deva key to unload
|
|
1198
|
+
describe: Unload a currently loaded Deva.
|
|
1492
1199
|
***************/
|
|
1493
1200
|
unload(key) {
|
|
1494
1201
|
return new Promise((resolve, reject) => {
|
|
@@ -1498,7 +1205,7 @@ class Deva {
|
|
|
1498
1205
|
delete this.devas[key];
|
|
1499
1206
|
this.talk(config.events.unload, key);
|
|
1500
1207
|
});
|
|
1501
|
-
return resolve(this.
|
|
1208
|
+
return resolve(this._states.unload);
|
|
1502
1209
|
} catch (e) {
|
|
1503
1210
|
return this.error(e, this.devas[key], reject)
|
|
1504
1211
|
}
|
|
@@ -1574,6 +1281,7 @@ class Deva {
|
|
|
1574
1281
|
encrypted,
|
|
1575
1282
|
}
|
|
1576
1283
|
}
|
|
1284
|
+
|
|
1577
1285
|
decipher(opt) {
|
|
1578
1286
|
// this.action('decipher');
|
|
1579
1287
|
const iv = Buffer.from(opt.iv, 'base64');
|
|
@@ -1597,6 +1305,7 @@ class Deva {
|
|
|
1597
1305
|
usage: this.prompt('text')
|
|
1598
1306
|
***************/
|
|
1599
1307
|
prompt(text) {
|
|
1308
|
+
this.action('prompt');
|
|
1600
1309
|
// Talk a global prompt event for the client
|
|
1601
1310
|
const agent = this.agent();
|
|
1602
1311
|
const client = this.client();
|
|
@@ -1636,6 +1345,7 @@ class Deva {
|
|
|
1636
1345
|
with no time value for the current day.
|
|
1637
1346
|
***************/
|
|
1638
1347
|
getToday(d) {
|
|
1348
|
+
this.action('gettoday');
|
|
1639
1349
|
d = d ? d : Date.now();
|
|
1640
1350
|
const today = new Date(d);
|
|
1641
1351
|
today.setHours(0);
|
|
@@ -1734,6 +1444,7 @@ class Deva {
|
|
|
1734
1444
|
describe: remove duplicees from an array.
|
|
1735
1445
|
***************/
|
|
1736
1446
|
dupes(dupers) {
|
|
1447
|
+
this.action('dupes');
|
|
1737
1448
|
if (!Array.isArray(dupers)) return dupers;
|
|
1738
1449
|
const check = [];
|
|
1739
1450
|
return dupers.filter(dupe => {
|
|
@@ -1750,8 +1461,9 @@ class Deva {
|
|
|
1750
1461
|
describe: return info data.
|
|
1751
1462
|
***************/
|
|
1752
1463
|
info() {
|
|
1464
|
+
this.zone('support');
|
|
1753
1465
|
// check the active status
|
|
1754
|
-
if (!this._active) return Promise.resolve(this._messages.
|
|
1466
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
1755
1467
|
this.action('info');
|
|
1756
1468
|
return this._info;
|
|
1757
1469
|
}
|
|
@@ -1768,12 +1480,13 @@ class Deva {
|
|
|
1768
1480
|
usage: this.status('msg')
|
|
1769
1481
|
***************/
|
|
1770
1482
|
status(msg=false) {
|
|
1483
|
+
this.zone('support');
|
|
1771
1484
|
// check the active status
|
|
1772
1485
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1773
|
-
this.action('status');
|
|
1774
1486
|
// format the date since active for output.
|
|
1775
1487
|
const dateFormat = this.formatDate(this._active, 'long', true);
|
|
1776
1488
|
// create the text msg string
|
|
1489
|
+
this.action('status');
|
|
1777
1490
|
let text = `${this._agent.profile.name} active since ${dateFormat}`;
|
|
1778
1491
|
if (msg) text = text + `\n${msg}`; // append the msg string if msg true.
|
|
1779
1492
|
return text; // return final text string
|
|
@@ -1790,16 +1503,17 @@ class Deva {
|
|
|
1790
1503
|
one exists it will then present it based on the users request text input.
|
|
1791
1504
|
***************/
|
|
1792
1505
|
help(msg, help_dir) {
|
|
1506
|
+
this.zone('help');
|
|
1793
1507
|
return new Promise((resolve, reject) => {
|
|
1794
1508
|
if (!this._active) return resolve(this._messages.states.offline);
|
|
1795
|
-
this.
|
|
1796
|
-
this.action('help');
|
|
1509
|
+
this.state('data');
|
|
1797
1510
|
const params = msg.split(' ');
|
|
1798
1511
|
let helpFile = 'main';
|
|
1799
1512
|
if (params[0]) helpFile = params[0];
|
|
1800
1513
|
if (params[1]) helpFile = `${params[0]}_${params[1]}`;
|
|
1801
1514
|
helpFile = path.join(help_dir, 'help', `${helpFile}.feecting`);
|
|
1802
1515
|
try {
|
|
1516
|
+
this.action('help');
|
|
1803
1517
|
return resolve(fs.readFileSync(helpFile, 'utf8'));
|
|
1804
1518
|
} catch (e) {
|
|
1805
1519
|
return reject(e)
|
|
@@ -1818,7 +1532,7 @@ class Deva {
|
|
|
1818
1532
|
usage: this.error(err, data, reject);
|
|
1819
1533
|
***************/
|
|
1820
1534
|
error(err,data=false,reject=false) {
|
|
1821
|
-
this.
|
|
1535
|
+
this.zone('error');
|
|
1822
1536
|
// check fo rthe custom onError function in the agent.
|
|
1823
1537
|
console.log('\n::BEGIN:ERROR\n');
|
|
1824
1538
|
console.log(err);
|
|
@@ -1830,6 +1544,7 @@ class Deva {
|
|
|
1830
1544
|
console.log('\n::END:DATA\n');
|
|
1831
1545
|
}
|
|
1832
1546
|
|
|
1547
|
+
this.state('error')
|
|
1833
1548
|
const agent = this.agent();
|
|
1834
1549
|
const client = this.client();
|
|
1835
1550
|
const _data = {
|
|
@@ -1844,6 +1559,7 @@ class Deva {
|
|
|
1844
1559
|
}
|
|
1845
1560
|
this.talk(config.events.error, this.copy(_data));
|
|
1846
1561
|
const hasOnError = this.onError && typeof this.onError === 'function' ? true : false;
|
|
1562
|
+
this.action('error');
|
|
1847
1563
|
if (hasOnError) return this.onError(err, data, reject);
|
|
1848
1564
|
else return reject ? reject(err) : err;
|
|
1849
1565
|
}
|