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