@indra.ai/deva 1.2.5 → 1.2.7
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 +81 -149
- package/index.js +80 -364
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -27,53 +27,84 @@
|
|
|
27
27
|
"unload": "devacore:unload",
|
|
28
28
|
"context": "devacore:context"
|
|
29
29
|
},
|
|
30
|
+
"zone": "deva",
|
|
31
|
+
"zones": {
|
|
32
|
+
"deva": "#Deva",
|
|
33
|
+
"security": "#Security",
|
|
34
|
+
"support": "#Support",
|
|
35
|
+
"services": "#Services",
|
|
36
|
+
"systems": "#Systems",
|
|
37
|
+
"done": "#Done",
|
|
38
|
+
"config": "#Config",
|
|
39
|
+
"school": "#School",
|
|
40
|
+
"work": "#WorkZone",
|
|
41
|
+
"fun": "Fun Zone",
|
|
42
|
+
"adventure": "Adventure Zone",
|
|
43
|
+
"party": "Party Zone",
|
|
44
|
+
"finish": "Finish Zone",
|
|
45
|
+
"start": "Start Zone",
|
|
46
|
+
"stop": "Stop Zone",
|
|
47
|
+
"help": "Help Zone",
|
|
48
|
+
"error": "Error Zone"
|
|
49
|
+
},
|
|
30
50
|
"state": "offline",
|
|
31
51
|
"states": {
|
|
52
|
+
"online": "Online",
|
|
53
|
+
"offline": "Offline",
|
|
54
|
+
"active": "Active",
|
|
55
|
+
"inactive": "Inactive",
|
|
56
|
+
"idle": "Idle",
|
|
57
|
+
"talk": "Talking",
|
|
58
|
+
"listen": "Listening",
|
|
32
59
|
"ask": "asking another",
|
|
33
|
-
"question": "
|
|
34
|
-
"answer": "
|
|
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
|
-
"help": "
|
|
60
|
+
"question": "Question",
|
|
61
|
+
"answer": "Answer",
|
|
62
|
+
"ready": "Ready",
|
|
63
|
+
"wait": "Waiting",
|
|
64
|
+
"pause": "Pause",
|
|
65
|
+
"resume": "resume",
|
|
66
|
+
"connect": "Connecting",
|
|
67
|
+
"disconnect": "Disconnecting",
|
|
68
|
+
"send": "Sending",
|
|
69
|
+
"receive": "receiving",
|
|
70
|
+
"init": "Initialize",
|
|
71
|
+
"forward": "Forward",
|
|
72
|
+
"backward": "Backward",
|
|
73
|
+
"start": "Start",
|
|
74
|
+
"stop": "Stop",
|
|
75
|
+
"open": "Open",
|
|
76
|
+
"close": "Close",
|
|
77
|
+
"enter": "Enter",
|
|
78
|
+
"exit": "Exit",
|
|
79
|
+
"begin": "Begin",
|
|
80
|
+
"end": "End",
|
|
81
|
+
"load": "Load",
|
|
82
|
+
"unload": "Unload",
|
|
83
|
+
"done": "Done",
|
|
84
|
+
"data": "Data",
|
|
85
|
+
"finish": "Finish",
|
|
86
|
+
"complete": "Complete",
|
|
87
|
+
"invalid": "INVALID!",
|
|
88
|
+
"abort": "ABORT!",
|
|
89
|
+
"error": "ERROR!",
|
|
90
|
+
"help": "HELP!"
|
|
64
91
|
},
|
|
65
92
|
"action": false,
|
|
66
93
|
"actions": {
|
|
67
94
|
"wait": "waiting",
|
|
68
|
-
"help": "giving help",
|
|
69
95
|
"start": "has started",
|
|
70
96
|
"enter": "has entered deva.world",
|
|
71
97
|
"exit": "has exited deva.world",
|
|
72
98
|
"stop": "stopped",
|
|
73
99
|
"load": "loaded",
|
|
74
100
|
"unload": "unloaded",
|
|
101
|
+
"done": "done",
|
|
75
102
|
"question": "received a question",
|
|
76
103
|
"context": "context change",
|
|
104
|
+
"issue": "new issue",
|
|
105
|
+
"info": "get info",
|
|
106
|
+
"status": "get status",
|
|
107
|
+
|
|
77
108
|
"question_ask": "asked a question",
|
|
78
109
|
"question_ask_answer": "answered the ask",
|
|
79
110
|
"question_cmd": "command",
|
|
@@ -90,31 +121,23 @@
|
|
|
90
121
|
"support": "SUPPORT",
|
|
91
122
|
"systems": "SYSTMS",
|
|
92
123
|
"services": "SERVICES",
|
|
93
|
-
|
|
94
|
-
"research": "RESEARCH",
|
|
95
|
-
"development": "DEVELOPMENT",
|
|
96
|
-
"business": "BUSINESS",
|
|
97
|
-
"legal": "LEGAL",
|
|
98
|
-
"assistant": "ASSISTANT",
|
|
124
|
+
|
|
99
125
|
"Client": "configure client",
|
|
100
|
-
"Security": "
|
|
101
|
-
"Support": "
|
|
102
|
-
"Systems": "
|
|
103
|
-
"Services": "
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
"Development": "configure development",
|
|
107
|
-
"Legal": "configure legal",
|
|
108
|
-
"Business": "configure business",
|
|
109
|
-
"Assistant": "configure assistant",
|
|
110
|
-
"Done": "configure done",
|
|
126
|
+
"Security": "set Security",
|
|
127
|
+
"Support": "set Support",
|
|
128
|
+
"Systems": "set Systems",
|
|
129
|
+
"Services": "set Services",
|
|
130
|
+
"Done": "Done",
|
|
131
|
+
|
|
111
132
|
"invalid": "invalid",
|
|
112
133
|
"states": "getting states",
|
|
113
134
|
"actions": "getting actions",
|
|
114
135
|
"zones": "getting zones",
|
|
115
136
|
"features": "Getting features",
|
|
116
|
-
"
|
|
117
|
-
"finish": "finished"
|
|
137
|
+
"contexts": "Getting contexts",
|
|
138
|
+
"finish": "finished",
|
|
139
|
+
"help": "Giving some HELP!",
|
|
140
|
+
"error": "We have an ERROR!"
|
|
118
141
|
},
|
|
119
142
|
"feature": false,
|
|
120
143
|
"features": {
|
|
@@ -122,107 +145,16 @@
|
|
|
122
145
|
"support": "Support",
|
|
123
146
|
"services": "Services",
|
|
124
147
|
"solutions": "Solutions",
|
|
125
|
-
"systems": "Systems"
|
|
126
|
-
"research": "Research",
|
|
127
|
-
"development": "Development",
|
|
128
|
-
"business": "Business",
|
|
129
|
-
"legal": "Legal",
|
|
130
|
-
"assistant": "Assistant"
|
|
148
|
+
"systems": "Systems"
|
|
131
149
|
},
|
|
132
150
|
"message": "offline",
|
|
133
151
|
"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": "Accessing Security",
|
|
216
|
-
"support": "Accessing Support",
|
|
217
|
-
"services": "Accessing Services",
|
|
218
|
-
"solutions": "Accessing Solutions",
|
|
219
|
-
"systems": "Accessing Systems",
|
|
220
|
-
"research": "Accessing Research",
|
|
221
|
-
"development": "Accessing Development",
|
|
222
|
-
"business": "Accessing Business",
|
|
223
|
-
"legal": "Accessing Legal",
|
|
224
|
-
"assistant": "Accessing Assistant"
|
|
225
|
-
}
|
|
152
|
+
"init": "Initializing Deva",
|
|
153
|
+
"offline": "The Deva is OFFLINE.",
|
|
154
|
+
"notext": "NO TEXT WAS PROVIDED",
|
|
155
|
+
"nopacket": "NO PACKET WAS PROVIDED",
|
|
156
|
+
"method_not_found": "METHOD NOT FOUND",
|
|
157
|
+
"stop": "Stop Deva."
|
|
226
158
|
}
|
|
227
159
|
}
|
|
228
160
|
}
|
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.
|
|
@@ -84,19 +78,7 @@ class Deva {
|
|
|
84
78
|
this._context = opts.context || false; // set the local context
|
|
85
79
|
|
|
86
80
|
this._message = config.message; // current state of agent.
|
|
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
|
-
}
|
|
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
|
|
459
|
-
}
|
|
460
|
-
} catch (e) {
|
|
461
|
-
return this.error(e); // run error handling if an error is caught
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
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
|
|
352
|
+
delete this._client.features.systems;
|
|
353
|
+
this.action('Systems');
|
|
354
|
+
return this.Done();
|
|
521
355
|
}
|
|
522
356
|
} catch (e) {
|
|
523
357
|
return this.error(e); // run error handling if an error is caught
|
|
524
358
|
}
|
|
525
359
|
}
|
|
526
360
|
|
|
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
|
}
|
|
@@ -635,7 +444,8 @@ class Deva {
|
|
|
635
444
|
***************/
|
|
636
445
|
question(TEXT=false, DATA=false) {
|
|
637
446
|
// check the active status
|
|
638
|
-
if (!this._active) return Promise.resolve(this._messages.
|
|
447
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
448
|
+
|
|
639
449
|
this.state('question');
|
|
640
450
|
const id = this.uid(); // generate a unique id for transport.
|
|
641
451
|
const t_split = TEXT.split(' '); // split the text on spaces to get words.
|
|
@@ -664,7 +474,7 @@ class Deva {
|
|
|
664
474
|
// resolve with the no text message if the client says nothing.
|
|
665
475
|
if (!TEXT) return this.finish(this._messages.notext, resolve);
|
|
666
476
|
// reject question if Deva offline
|
|
667
|
-
if (!this._active) return this.finish(this._messages.
|
|
477
|
+
if (!this._active) return this.finish(this._messages.offline, resolve);
|
|
668
478
|
let _action = 'question'
|
|
669
479
|
try { // try to answer the question
|
|
670
480
|
if (isAsk) { // determine if hte question isAsk
|
|
@@ -735,7 +545,7 @@ class Deva {
|
|
|
735
545
|
from the agent from the pre-determined method.
|
|
736
546
|
***************/
|
|
737
547
|
answer(packet, resolve, reject) {
|
|
738
|
-
if (!this._active) return Promise.resolve(this._messages.
|
|
548
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
739
549
|
this.state('answer');
|
|
740
550
|
// check if method exists and is of type function
|
|
741
551
|
const {method,params} = packet.q.meta;
|
|
@@ -798,9 +608,8 @@ class Deva {
|
|
|
798
608
|
so the event is specific to the talk.
|
|
799
609
|
***************/
|
|
800
610
|
ask(packet) {
|
|
801
|
-
if (!this._active) return Promise.resolve(this._messages.
|
|
611
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
802
612
|
this.state('ask');
|
|
803
|
-
this.action('ask');
|
|
804
613
|
|
|
805
614
|
const agent = this.agent();
|
|
806
615
|
const client = this.client();
|
|
@@ -830,6 +639,7 @@ class Deva {
|
|
|
830
639
|
|
|
831
640
|
// The method is parsed and depending on what method is asked for it returns
|
|
832
641
|
// the response based on the passed through packet.
|
|
642
|
+
this.action('ask');
|
|
833
643
|
this.methods[packet.q.meta.method](packet).then(result => {
|
|
834
644
|
if (typeof result === 'object') {
|
|
835
645
|
packet_answer.text = result.text || false;
|
|
@@ -873,6 +683,7 @@ class Deva {
|
|
|
873
683
|
usage: this.init(client_object)
|
|
874
684
|
***************/
|
|
875
685
|
init(client) {
|
|
686
|
+
this.state('init');
|
|
876
687
|
// set client
|
|
877
688
|
this._active = Date.now();
|
|
878
689
|
const agent = this.agent();
|
|
@@ -882,7 +693,7 @@ class Deva {
|
|
|
882
693
|
value: agent.key,
|
|
883
694
|
agent,
|
|
884
695
|
client,
|
|
885
|
-
text: this._messages.
|
|
696
|
+
text: this._messages.init,
|
|
886
697
|
created: Date.now(),
|
|
887
698
|
}
|
|
888
699
|
_data.hash = this.hash(_data);
|
|
@@ -894,14 +705,10 @@ class Deva {
|
|
|
894
705
|
}).then(() => {
|
|
895
706
|
return this._assignListeners();
|
|
896
707
|
}).then(() => {
|
|
897
|
-
this.state('init');
|
|
898
|
-
this.zone('config');
|
|
899
708
|
return this.Client(client);
|
|
900
709
|
}).then(() => {
|
|
901
|
-
this.zone('features');
|
|
902
710
|
return this.Security();
|
|
903
711
|
}).then(() => {
|
|
904
|
-
this.zone('deva');
|
|
905
712
|
const hasOnInit = this.onInit && typeof this.onInit === 'function';
|
|
906
713
|
return hasOnInit ? this.onInit(_data) : this.start(_data)
|
|
907
714
|
}).catch(err => {
|
|
@@ -921,14 +728,14 @@ class Deva {
|
|
|
921
728
|
usage: this.start('msg')
|
|
922
729
|
***************/
|
|
923
730
|
start(data) {
|
|
924
|
-
|
|
731
|
+
this.zone('start');
|
|
732
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
925
733
|
this.state('start');
|
|
926
734
|
data.value = 'start';
|
|
927
735
|
delete data.hash;
|
|
928
736
|
data.hash = this.hash(data);
|
|
929
|
-
|
|
930
|
-
this.action(data.value);
|
|
931
737
|
const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
|
|
738
|
+
this.action('start');
|
|
932
739
|
return hasOnStart ? this.onStart(data) : this.enter(data)
|
|
933
740
|
}
|
|
934
741
|
|
|
@@ -944,12 +751,13 @@ class Deva {
|
|
|
944
751
|
usage: this.enter('msg')
|
|
945
752
|
***************/
|
|
946
753
|
enter(data) {
|
|
947
|
-
|
|
754
|
+
this.zone('enter');
|
|
755
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
948
756
|
this.state('enter');
|
|
949
757
|
data.value = 'enter';
|
|
950
758
|
delete data.hash;
|
|
951
759
|
data.hash = this.hash(data);
|
|
952
|
-
this.action(
|
|
760
|
+
this.action('enter');
|
|
953
761
|
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
954
762
|
return hasOnEnter ? this.onEnter(data) : this.done(data)
|
|
955
763
|
}
|
|
@@ -966,13 +774,14 @@ class Deva {
|
|
|
966
774
|
usage: this.done('msg')
|
|
967
775
|
***************/
|
|
968
776
|
done(data) {
|
|
969
|
-
|
|
777
|
+
this.zone('done');
|
|
778
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
970
779
|
this.state('done');
|
|
971
780
|
data.value = 'done';
|
|
972
781
|
delete data.hash;
|
|
973
782
|
data.hash = this.hash(data);
|
|
974
|
-
this.action(data.value)
|
|
975
783
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
784
|
+
this.action('done')
|
|
976
785
|
return hasOnDone ? this.onDone(data) : Promise.resolve(data);
|
|
977
786
|
}
|
|
978
787
|
|
|
@@ -988,15 +797,14 @@ class Deva {
|
|
|
988
797
|
this.finish(data, resolve)
|
|
989
798
|
***************/
|
|
990
799
|
finish(packet, resolve) {
|
|
991
|
-
|
|
992
|
-
this.
|
|
800
|
+
this.zone('finish');
|
|
801
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
802
|
+
this.state('finish');
|
|
993
803
|
packet.hash = this.hash(packet);// hash the entire packet before finishing.
|
|
994
804
|
const hasOnFinish = this.onFinish && typeof this.onFinish === 'function' ? true : false;
|
|
995
805
|
|
|
996
|
-
this.state('ready');
|
|
997
806
|
if (hasOnFinish) return this.onFinish(packet, resolve);
|
|
998
|
-
|
|
999
|
-
else return Promise.resolve(packet)
|
|
807
|
+
this.action('finish');
|
|
1000
808
|
return resolve ? resolve(packet) : Promise.resolve(packet);
|
|
1001
809
|
}
|
|
1002
810
|
|
|
@@ -1014,22 +822,27 @@ class Deva {
|
|
|
1014
822
|
this.stop('msg')
|
|
1015
823
|
***************/
|
|
1016
824
|
stop() {
|
|
1017
|
-
|
|
825
|
+
this.zone('stop');
|
|
826
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
827
|
+
|
|
1018
828
|
this.state('stop');
|
|
1019
829
|
const agent = this.agent();
|
|
1020
830
|
const client = this.client();
|
|
831
|
+
|
|
1021
832
|
const data = {
|
|
1022
833
|
id: this.uid(true),
|
|
1023
834
|
key: 'stop',
|
|
1024
835
|
value: agent.key,
|
|
1025
836
|
agent,
|
|
1026
837
|
client,
|
|
1027
|
-
text: this._messages.
|
|
838
|
+
text: this._messages.stop,
|
|
1028
839
|
created: Date.now(),
|
|
1029
840
|
}
|
|
841
|
+
|
|
1030
842
|
data.hash = this.hash(data);
|
|
1031
|
-
this.action(data.value);
|
|
1032
843
|
const hasOnStop = this.onStop && typeof this.onStop === 'function';
|
|
844
|
+
|
|
845
|
+
this.action('stop');
|
|
1033
846
|
return hasOnStop ? this.onStop(data) : this.exit(data)
|
|
1034
847
|
}
|
|
1035
848
|
|
|
@@ -1049,12 +862,13 @@ class Deva {
|
|
|
1049
862
|
usage: this.exit('msg')
|
|
1050
863
|
***************/
|
|
1051
864
|
exit(data) {
|
|
1052
|
-
this.
|
|
865
|
+
this.zone('exit');
|
|
1053
866
|
this._active = false;
|
|
1054
867
|
data.value = 'exit';
|
|
1055
868
|
delete data.hash;
|
|
1056
869
|
data.hash = this.hash(data);
|
|
1057
870
|
|
|
871
|
+
this.state('exit');
|
|
1058
872
|
// clear memory
|
|
1059
873
|
this._active = false;
|
|
1060
874
|
this._client = false;
|
|
@@ -1066,7 +880,7 @@ class Deva {
|
|
|
1066
880
|
this._legal = false;
|
|
1067
881
|
this._assistant = false;
|
|
1068
882
|
|
|
1069
|
-
this.action(
|
|
883
|
+
this.action('exit');
|
|
1070
884
|
const hasOnExit = this.onExit && typeof this.onExit === 'function';
|
|
1071
885
|
return hasOnExit ? this.onExit(data) : Promise.resolve(data)
|
|
1072
886
|
}
|
|
@@ -1084,7 +898,7 @@ class Deva {
|
|
|
1084
898
|
try {
|
|
1085
899
|
if (!this._states[state]) return;
|
|
1086
900
|
this._state = state;
|
|
1087
|
-
const text = this.
|
|
901
|
+
const text = this._states[state];
|
|
1088
902
|
const data = {
|
|
1089
903
|
id: this.uid(true),
|
|
1090
904
|
key: 'state',
|
|
@@ -1112,7 +926,6 @@ class Deva {
|
|
|
1112
926
|
id: this.uid(true),
|
|
1113
927
|
key: 'states',
|
|
1114
928
|
value: this._states,
|
|
1115
|
-
messages: this._messages.states,
|
|
1116
929
|
created: Date.now(),
|
|
1117
930
|
}
|
|
1118
931
|
}
|
|
@@ -1127,7 +940,7 @@ class Deva {
|
|
|
1127
940
|
if (!this._zones[value] || value === this._zone) return;
|
|
1128
941
|
try {
|
|
1129
942
|
this._zone = value;
|
|
1130
|
-
const text = this.
|
|
943
|
+
const text = this._zones[value];
|
|
1131
944
|
const data = {
|
|
1132
945
|
id: this.uid(true),
|
|
1133
946
|
key: 'zone',
|
|
@@ -1149,7 +962,6 @@ class Deva {
|
|
|
1149
962
|
id: this.uid(true),
|
|
1150
963
|
key: 'zones',
|
|
1151
964
|
value: this._zones,
|
|
1152
|
-
messages: this._messages.zones,
|
|
1153
965
|
created: Date.now(),
|
|
1154
966
|
}
|
|
1155
967
|
}
|
|
@@ -1165,7 +977,7 @@ class Deva {
|
|
|
1165
977
|
// check local vars for custom actions
|
|
1166
978
|
const var_action = this.vars.actions ? this.vars.actions[action] : false;
|
|
1167
979
|
// check system action messages
|
|
1168
|
-
const msg_action = this.
|
|
980
|
+
const msg_action = this._actions[action] || var_action;
|
|
1169
981
|
const text = msg_action || action; // set the text of the action
|
|
1170
982
|
const data = { // build the data object for the action.
|
|
1171
983
|
id: this.uid(true), // generate a guid for the action transmitssion.
|
|
@@ -1189,7 +1001,6 @@ class Deva {
|
|
|
1189
1001
|
id: this.uid(true),
|
|
1190
1002
|
key: 'actions',
|
|
1191
1003
|
value: this._actions,
|
|
1192
|
-
messages: this._messages.actions,
|
|
1193
1004
|
created: Date.now(),
|
|
1194
1005
|
}
|
|
1195
1006
|
}
|
|
@@ -1201,10 +1012,11 @@ class Deva {
|
|
|
1201
1012
|
describe
|
|
1202
1013
|
***************/
|
|
1203
1014
|
feature(feature) {
|
|
1015
|
+
this.action('feature');
|
|
1204
1016
|
try {
|
|
1205
1017
|
if (!this._features[feature]) return;
|
|
1206
1018
|
this._feature = feature;
|
|
1207
|
-
const text = this.
|
|
1019
|
+
const text = this._features[feature] ;
|
|
1208
1020
|
const talk = {
|
|
1209
1021
|
id: this.uid(true),
|
|
1210
1022
|
key: 'feature',
|
|
@@ -1226,7 +1038,6 @@ class Deva {
|
|
|
1226
1038
|
id: this.uid(true),
|
|
1227
1039
|
key: 'features',
|
|
1228
1040
|
value: this._features,
|
|
1229
|
-
messages: this._messages.features,
|
|
1230
1041
|
created: Date.now(),
|
|
1231
1042
|
}
|
|
1232
1043
|
}
|
|
@@ -1269,8 +1080,7 @@ class Deva {
|
|
|
1269
1080
|
}
|
|
1270
1081
|
|
|
1271
1082
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1083
|
+
///////////////
|
|
1274
1084
|
/**************
|
|
1275
1085
|
func: client
|
|
1276
1086
|
params: none
|
|
@@ -1280,7 +1090,7 @@ class Deva {
|
|
|
1280
1090
|
usage: this.client();
|
|
1281
1091
|
***************/
|
|
1282
1092
|
client() {
|
|
1283
|
-
if (!this._active) return this._messages.
|
|
1093
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1284
1094
|
this.state('client_data'); // set the client state
|
|
1285
1095
|
const client_copy = this.copy(this._client);
|
|
1286
1096
|
// delete client_copy.parse;
|
|
@@ -1297,7 +1107,7 @@ class Deva {
|
|
|
1297
1107
|
usage: this.agent()
|
|
1298
1108
|
***************/
|
|
1299
1109
|
agent() {
|
|
1300
|
-
if (!this._active) return this._messages.
|
|
1110
|
+
if (!this._active) return this._messages.offline;
|
|
1301
1111
|
this.state('agent_data');
|
|
1302
1112
|
const agent_copy = this.copy(this._agent);
|
|
1303
1113
|
delete agent_copy.parse;
|
|
@@ -1314,7 +1124,7 @@ class Deva {
|
|
|
1314
1124
|
usage: this.security()
|
|
1315
1125
|
***************/
|
|
1316
1126
|
security() {
|
|
1317
|
-
if (!this._active) return this._messages.
|
|
1127
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1318
1128
|
this.feature('security'); // set the security state
|
|
1319
1129
|
try {
|
|
1320
1130
|
this.action('security'); // set the security state
|
|
@@ -1331,7 +1141,7 @@ class Deva {
|
|
|
1331
1141
|
usage: this.support()
|
|
1332
1142
|
***************/
|
|
1333
1143
|
support() {
|
|
1334
|
-
if (!this._active) return this._messages.
|
|
1144
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1335
1145
|
this.feature('support'); // set the support state
|
|
1336
1146
|
try {
|
|
1337
1147
|
this.action('support');
|
|
@@ -1348,7 +1158,7 @@ class Deva {
|
|
|
1348
1158
|
usage: this.services()
|
|
1349
1159
|
***************/
|
|
1350
1160
|
services(opts) {
|
|
1351
|
-
if (!this._active) return this._messages.
|
|
1161
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1352
1162
|
this.feature('services'); // set the services state
|
|
1353
1163
|
try {
|
|
1354
1164
|
this.action('services'); // set the services state
|
|
@@ -1365,7 +1175,7 @@ class Deva {
|
|
|
1365
1175
|
usage: this.systems()
|
|
1366
1176
|
***************/
|
|
1367
1177
|
systems(opts) {
|
|
1368
|
-
if (!this._active) return this._messages.
|
|
1178
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1369
1179
|
this.feature('systems'); // set the systems state
|
|
1370
1180
|
try {
|
|
1371
1181
|
this.action('systems'); // set the systems state
|
|
@@ -1375,109 +1185,11 @@ class Deva {
|
|
|
1375
1185
|
}
|
|
1376
1186
|
}
|
|
1377
1187
|
|
|
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
|
|
1435
|
-
try {
|
|
1436
|
-
this.action('business');
|
|
1437
|
-
return this.copy(this._business); // return business feature
|
|
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
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
1188
|
/**************
|
|
1476
1189
|
func: load
|
|
1477
1190
|
params:
|
|
1478
|
-
-deva:
|
|
1479
|
-
describe:
|
|
1480
|
-
This function will enable fast loading of Deva into a system.
|
|
1191
|
+
-deva: The Deva model to load.
|
|
1192
|
+
describe: This function will enable fast loading of Deva into a system.
|
|
1481
1193
|
***************/
|
|
1482
1194
|
load(key, client) {
|
|
1483
1195
|
this.state('load');
|
|
@@ -1487,8 +1199,8 @@ class Deva {
|
|
|
1487
1199
|
/**************
|
|
1488
1200
|
func: unload
|
|
1489
1201
|
params:
|
|
1490
|
-
- deva:
|
|
1491
|
-
describe:
|
|
1202
|
+
- deva: The deva key to unload
|
|
1203
|
+
describe: Unload a currently loaded Deva.
|
|
1492
1204
|
***************/
|
|
1493
1205
|
unload(key) {
|
|
1494
1206
|
return new Promise((resolve, reject) => {
|
|
@@ -1498,7 +1210,7 @@ class Deva {
|
|
|
1498
1210
|
delete this.devas[key];
|
|
1499
1211
|
this.talk(config.events.unload, key);
|
|
1500
1212
|
});
|
|
1501
|
-
return resolve(this.
|
|
1213
|
+
return resolve(this._states.unload);
|
|
1502
1214
|
} catch (e) {
|
|
1503
1215
|
return this.error(e, this.devas[key], reject)
|
|
1504
1216
|
}
|
|
@@ -1574,6 +1286,7 @@ class Deva {
|
|
|
1574
1286
|
encrypted,
|
|
1575
1287
|
}
|
|
1576
1288
|
}
|
|
1289
|
+
|
|
1577
1290
|
decipher(opt) {
|
|
1578
1291
|
// this.action('decipher');
|
|
1579
1292
|
const iv = Buffer.from(opt.iv, 'base64');
|
|
@@ -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.state('help');
|
|
1793
1507
|
return new Promise((resolve, reject) => {
|
|
1794
1508
|
if (!this._active) return resolve(this._messages.states.offline);
|
|
1795
1509
|
this.zone('help');
|
|
1796
|
-
this.action('help');
|
|
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)
|
|
@@ -1830,6 +1544,7 @@ class Deva {
|
|
|
1830
1544
|
console.log('\n::END:DATA\n');
|
|
1831
1545
|
}
|
|
1832
1546
|
|
|
1547
|
+
this.zone('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
|
}
|