@indra.ai/deva 1.2.31 → 1.2.32
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 -19
- package/index.js +60 -56
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"enter": "🏡 Enter",
|
|
39
39
|
"exit": "🚪 Exit",
|
|
40
40
|
"finish": "🏁 Finish",
|
|
41
|
-
"deva": "
|
|
41
|
+
"deva": "⚡️ Deva",
|
|
42
42
|
"client": "👨💼 Client",
|
|
43
43
|
"agent": "🤖 Agent",
|
|
44
44
|
"security": "🔐 Security",
|
|
@@ -124,23 +124,23 @@
|
|
|
124
124
|
},
|
|
125
125
|
"action": false,
|
|
126
126
|
"actions": {
|
|
127
|
-
"client": "👨💼
|
|
128
|
-
"agent": "🕵️♂️
|
|
129
|
-
"wait": "⏳
|
|
130
|
-
"start": "🎬
|
|
131
|
-
"enter": "🏡
|
|
132
|
-
"exit": "🚪
|
|
133
|
-
"stop": "🛑
|
|
134
|
-
"load": "📦
|
|
135
|
-
"unload": "🥡
|
|
136
|
-
"done": "📝
|
|
137
|
-
"finish": "🏁
|
|
138
|
-
"complete": "👍
|
|
139
|
-
"ready": "✅
|
|
140
|
-
"question": "🙋
|
|
141
|
-
"talk": "📢
|
|
142
|
-
"context": "
|
|
143
|
-
"prompt": "🐚
|
|
127
|
+
"client": "👨💼 client",
|
|
128
|
+
"agent": "🕵️♂️ agent",
|
|
129
|
+
"wait": "⏳ waiting",
|
|
130
|
+
"start": "🎬 start",
|
|
131
|
+
"enter": "🏡 enter",
|
|
132
|
+
"exit": "🚪 exit",
|
|
133
|
+
"stop": "🛑 stop",
|
|
134
|
+
"load": "📦 load",
|
|
135
|
+
"unload": "🥡 unload",
|
|
136
|
+
"done": "📝 done",
|
|
137
|
+
"finish": "🏁 finish",
|
|
138
|
+
"complete": "👍 complete",
|
|
139
|
+
"ready": "✅ ready",
|
|
140
|
+
"question": "🙋 question",
|
|
141
|
+
"talk": "📢 talk",
|
|
142
|
+
"context": "📇 context",
|
|
143
|
+
"prompt": "🐚 prompt",
|
|
144
144
|
"issue": "🎫 Issue",
|
|
145
145
|
"find": "🔎 Find",
|
|
146
146
|
"parse": "🏘️ Parse",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"info": "💁♂️ Information",
|
|
152
152
|
"status": "🚥 Status",
|
|
153
153
|
"func": "🔦 Function",
|
|
154
|
-
"method": "
|
|
154
|
+
"method": "❤️🔥 Method",
|
|
155
155
|
"list": "📋 List items",
|
|
156
156
|
"reply": "📮 Reply",
|
|
157
157
|
"write": "️📝 Write",
|
package/index.js
CHANGED
|
@@ -235,10 +235,10 @@ class Deva {
|
|
|
235
235
|
personal: security.devas[this._agent.key], // Client personal features and rules.
|
|
236
236
|
};
|
|
237
237
|
delete this._client.features.security; // make a copy the clinet data.
|
|
238
|
-
return
|
|
238
|
+
return Promise.resolve(); // goto Support when done with Security
|
|
239
239
|
}
|
|
240
240
|
} catch (e) {
|
|
241
|
-
this.state('reject', '
|
|
241
|
+
this.state('reject', 'Security');
|
|
242
242
|
return this.error(e); // run error handling if an error is caught
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -255,7 +255,7 @@ class Deva {
|
|
|
255
255
|
this.action('Support');
|
|
256
256
|
const _cl = this.client(); // set the local client variable
|
|
257
257
|
try {
|
|
258
|
-
if (!_cl.features.support) return
|
|
258
|
+
if (!_cl.features.support) return Promise.resolve() // move to Services if no support feature
|
|
259
259
|
else {
|
|
260
260
|
this.state('set', 'Support');
|
|
261
261
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
@@ -269,7 +269,7 @@ class Deva {
|
|
|
269
269
|
personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
|
|
270
270
|
};
|
|
271
271
|
delete this._client.features.support; // delete the support key from the client
|
|
272
|
-
return
|
|
272
|
+
return Promise.resolve(); // when done move to Services
|
|
273
273
|
}
|
|
274
274
|
} catch (e) {
|
|
275
275
|
this.state('reject', 'Services');
|
|
@@ -289,7 +289,7 @@ class Deva {
|
|
|
289
289
|
this.action('Services');
|
|
290
290
|
const _cl = this.client(); // set local client
|
|
291
291
|
try {
|
|
292
|
-
if (!_cl.features.services) return
|
|
292
|
+
if (!_cl.features.services) return Promise.resolve(); // move to Done if no Services feature
|
|
293
293
|
else {
|
|
294
294
|
this.state('set', 'Services');
|
|
295
295
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
@@ -303,7 +303,7 @@ class Deva {
|
|
|
303
303
|
personal: services.devas[this._agent.key], // Client personal features and rules.
|
|
304
304
|
};
|
|
305
305
|
delete this._client.features.services; // delete the services key for isolation
|
|
306
|
-
return
|
|
306
|
+
return Promise.resolve(); // go to Done
|
|
307
307
|
}
|
|
308
308
|
} catch (e) {
|
|
309
309
|
this.state('reject', 'Services');
|
|
@@ -323,7 +323,7 @@ class Deva {
|
|
|
323
323
|
this.action('Systems');
|
|
324
324
|
const _cl = this.client(); // set local client
|
|
325
325
|
try {
|
|
326
|
-
if (!_cl.features.services) return
|
|
326
|
+
if (!_cl.features.services) return Promise.resolve(); // move to Done if no Systems feature
|
|
327
327
|
else {
|
|
328
328
|
this.state('set', 'Systems');
|
|
329
329
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
@@ -337,7 +337,7 @@ class Deva {
|
|
|
337
337
|
personal: services.devas[this._agent.key], // Client personal features and rules.
|
|
338
338
|
};
|
|
339
339
|
delete this._client.features.services; // delete the services key for isolation
|
|
340
|
-
return
|
|
340
|
+
return Promise.resolve(); // go to Done
|
|
341
341
|
}
|
|
342
342
|
} catch (e) {
|
|
343
343
|
this.state('reject', 'Systems');
|
|
@@ -350,13 +350,13 @@ class Deva {
|
|
|
350
350
|
params: none
|
|
351
351
|
describe: The end of the workflow Client Feature Workflow
|
|
352
352
|
***************/
|
|
353
|
-
Done(
|
|
353
|
+
Done() {
|
|
354
354
|
this.action('Done');
|
|
355
355
|
return new Promise((resolve, reject) => {
|
|
356
356
|
try {
|
|
357
357
|
this.state('Done');
|
|
358
358
|
delete this._client.features; // delete the features key when done.
|
|
359
|
-
return resolve(client); // resolve an empty pr
|
|
359
|
+
return resolve(this.client()); // resolve an empty pr
|
|
360
360
|
} catch (e) {
|
|
361
361
|
this.state('reject', 'Done');
|
|
362
362
|
return this.error(e, false, reject);
|
|
@@ -453,7 +453,7 @@ class Deva {
|
|
|
453
453
|
|
|
454
454
|
return new Promise((resolve, reject) => {
|
|
455
455
|
// resolve with the no text message if the client says nothing.
|
|
456
|
-
if (!TEXT) return
|
|
456
|
+
if (!TEXT) return resolve(this._messages.notext, resolve);
|
|
457
457
|
try { // try to answer the question
|
|
458
458
|
if (isAsk) { // determine if hte question isAsk
|
|
459
459
|
// if:isAsk split the agent key and remove first command character
|
|
@@ -565,7 +565,7 @@ class Deva {
|
|
|
565
565
|
packet.a = packet_answer; // set the packet.a to the packet_answer
|
|
566
566
|
this.action('talk', config.events.answer)
|
|
567
567
|
this.talk(config.events.answer, this.copy(packet)); // global talk event
|
|
568
|
-
this.state('resovle', 'answer')
|
|
568
|
+
this.state('resovle', 'answer');
|
|
569
569
|
return this.finish(packet, resolve); // resolve the packet to the caller.
|
|
570
570
|
}).catch(err => { // catch any errors in the method
|
|
571
571
|
this.state('reject', 'answer');
|
|
@@ -679,7 +679,6 @@ class Deva {
|
|
|
679
679
|
created: Date.now(),
|
|
680
680
|
}
|
|
681
681
|
_data.hash = this.hash(_data);
|
|
682
|
-
|
|
683
682
|
return new Promise((resolve, reject) => {
|
|
684
683
|
this.events.setMaxListeners(this.maxListeners);
|
|
685
684
|
this._assignInherit().then(() => {
|
|
@@ -690,12 +689,18 @@ class Deva {
|
|
|
690
689
|
return this.Client(client);
|
|
691
690
|
}).then(() => {
|
|
692
691
|
return this.Security();
|
|
692
|
+
}).then(() => {
|
|
693
|
+
return this.Services();
|
|
694
|
+
}).then(() => {
|
|
695
|
+
return this.Support();
|
|
696
|
+
}).then(() => {
|
|
697
|
+
return this.Systems();
|
|
698
|
+
}).then(() => {
|
|
699
|
+
return this.Done();
|
|
693
700
|
}).then(() => {
|
|
694
701
|
this.zone('init');
|
|
695
702
|
const hasOnInit = this.onInit && typeof this.onInit === 'function';
|
|
696
|
-
return hasOnInit ? this.onInit(_data) : this.start(_data);
|
|
697
|
-
}).then(done => {
|
|
698
|
-
return resolve(done);
|
|
703
|
+
return hasOnInit ? this.onInit(_data) : this.start(_data, resolve);
|
|
699
704
|
}).catch(err => {
|
|
700
705
|
return this.error(err, client, reject);
|
|
701
706
|
});
|
|
@@ -712,7 +717,7 @@ class Deva {
|
|
|
712
717
|
function or running the enter function.
|
|
713
718
|
usage: this.start('msg')
|
|
714
719
|
***************/
|
|
715
|
-
start(data) {
|
|
720
|
+
start(data, resolve) {
|
|
716
721
|
this.zone('start');
|
|
717
722
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
718
723
|
this.action('start');
|
|
@@ -721,7 +726,7 @@ class Deva {
|
|
|
721
726
|
data.hash = this.hash(data);
|
|
722
727
|
const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
|
|
723
728
|
this.state('start');
|
|
724
|
-
return hasOnStart ? this.onStart(data) : this.enter(data)
|
|
729
|
+
return hasOnStart ? this.onStart(data) : this.enter(data, resolve)
|
|
725
730
|
}
|
|
726
731
|
|
|
727
732
|
/**************
|
|
@@ -735,7 +740,7 @@ class Deva {
|
|
|
735
740
|
If the Deva is offline it will return the offline message.
|
|
736
741
|
usage: this.enter('msg')
|
|
737
742
|
***************/
|
|
738
|
-
enter(data) {
|
|
743
|
+
enter(data, resolve) {
|
|
739
744
|
this.zone('deva');
|
|
740
745
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
741
746
|
this.action('enter');
|
|
@@ -744,7 +749,7 @@ class Deva {
|
|
|
744
749
|
data.hash = this.hash(data);
|
|
745
750
|
this.state('enter');
|
|
746
751
|
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
747
|
-
return hasOnEnter ? this.onEnter(data) : this.done(data)
|
|
752
|
+
return hasOnEnter ? this.onEnter(data) : this.done(data, resolve)
|
|
748
753
|
}
|
|
749
754
|
|
|
750
755
|
/**************
|
|
@@ -758,7 +763,7 @@ class Deva {
|
|
|
758
763
|
If the deva is offline it will return the offline message.
|
|
759
764
|
usage: this.done('msg')
|
|
760
765
|
***************/
|
|
761
|
-
done(data) {
|
|
766
|
+
done(data, resolve) {
|
|
762
767
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
763
768
|
this.action('done');
|
|
764
769
|
data.value = 'done';
|
|
@@ -766,8 +771,34 @@ class Deva {
|
|
|
766
771
|
data.hash = this.hash(data);
|
|
767
772
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
768
773
|
this.state('done');
|
|
769
|
-
return hasOnDone ? this.onDone(data) : this.
|
|
774
|
+
return hasOnDone ? this.onDone(data) : this.ready(data, resolve);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**************
|
|
778
|
+
func: ready
|
|
779
|
+
params:
|
|
780
|
+
- packet: the data to pass to the resolve
|
|
781
|
+
- resolve: the complete resolve to pass back
|
|
782
|
+
describe: This function is use to relay the Agent ito a complete state when
|
|
783
|
+
resolving a question or data.
|
|
784
|
+
usage: this.complete(data, resolve)
|
|
785
|
+
***************/
|
|
786
|
+
ready(packet, resolve) {
|
|
787
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
788
|
+
this.action('ready'); // set the complete action
|
|
789
|
+
|
|
790
|
+
packet.hash = this.hash(packet);// hash the entire packet before completeing.
|
|
791
|
+
// check for agent on complete function in agent
|
|
792
|
+
const hasOnReady = this.onReady && typeof this.onReady === 'function';
|
|
793
|
+
|
|
794
|
+
// if: agent has on complete then return on complete
|
|
795
|
+
this.state('ready'); // set the finish state
|
|
796
|
+
|
|
797
|
+
// return the provided resolve function or a promise resolve.
|
|
798
|
+
return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
|
|
770
799
|
}
|
|
800
|
+
|
|
801
|
+
|
|
771
802
|
|
|
772
803
|
/**************
|
|
773
804
|
func: finish
|
|
@@ -781,7 +812,6 @@ class Deva {
|
|
|
781
812
|
finish(packet, resolve) {
|
|
782
813
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
783
814
|
this.action('finish'); // set the finish action
|
|
784
|
-
|
|
785
815
|
packet.hash = this.hash(packet);// hash the entire packet before finishing.
|
|
786
816
|
// check for agent on finish function in agent
|
|
787
817
|
const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
|
|
@@ -790,7 +820,7 @@ class Deva {
|
|
|
790
820
|
this.state('finish'); // set the finish state
|
|
791
821
|
|
|
792
822
|
// return the provided resolve function or a promise resolve.
|
|
793
|
-
return hasOnFinish ? this.onFinish(packet) : this.complete(packet);
|
|
823
|
+
return hasOnFinish ? this.onFinish(packet) : this.complete(packet, resolve);
|
|
794
824
|
}
|
|
795
825
|
|
|
796
826
|
/**************
|
|
@@ -812,36 +842,10 @@ class Deva {
|
|
|
812
842
|
|
|
813
843
|
// if: agent has on complete then return on complete
|
|
814
844
|
this.state('complete'); // set the finish state
|
|
815
|
-
|
|
816
|
-
// return the provided resolve function or a promise resolve.
|
|
817
|
-
return hasOnComplete ? this.onComplete(packet) : this.ready(packet);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/**************
|
|
821
|
-
func: ready
|
|
822
|
-
params:
|
|
823
|
-
- packet: the data to pass to the resolve
|
|
824
|
-
- resolve: the complete resolve to pass back
|
|
825
|
-
describe: This function is use to relay the Agent ito a complete state when
|
|
826
|
-
resolving a question or data.
|
|
827
|
-
usage: this.complete(data, resolve)
|
|
828
|
-
***************/
|
|
829
|
-
ready(packet, resolve) {
|
|
830
|
-
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
831
|
-
this.action('ready'); // set the complete action
|
|
832
|
-
|
|
833
|
-
packet.hash = this.hash(packet);// hash the entire packet before completeing.
|
|
834
|
-
// check for agent on complete function in agent
|
|
835
|
-
const hasOnReady = this.onReady && typeof this.onReady === 'function';
|
|
836
|
-
|
|
837
|
-
// if: agent has on complete then return on complete
|
|
838
|
-
this.state('ready'); // set the finish state
|
|
839
|
-
|
|
840
845
|
// return the provided resolve function or a promise resolve.
|
|
841
|
-
return
|
|
846
|
+
return hasOnComplete ? this.onComplete(packet) : resolve(packet);
|
|
842
847
|
}
|
|
843
848
|
|
|
844
|
-
|
|
845
849
|
/**************
|
|
846
850
|
func: stop
|
|
847
851
|
params:
|
|
@@ -955,7 +959,7 @@ class Deva {
|
|
|
955
959
|
params: none
|
|
956
960
|
describe: returns the avaiable staets values.
|
|
957
961
|
***************/
|
|
958
|
-
|
|
962
|
+
states() {
|
|
959
963
|
this.action('func', 'states');
|
|
960
964
|
this.state('return', 'states');
|
|
961
965
|
return {
|
|
@@ -1001,7 +1005,7 @@ class Deva {
|
|
|
1001
1005
|
params: none
|
|
1002
1006
|
describe: returns a listing of zones currently in the system.
|
|
1003
1007
|
***************/
|
|
1004
|
-
|
|
1008
|
+
zones() {
|
|
1005
1009
|
this.action('func', 'zones');
|
|
1006
1010
|
this.state('return', 'zones');
|
|
1007
1011
|
return {
|
|
@@ -1053,7 +1057,7 @@ class Deva {
|
|
|
1053
1057
|
params: none
|
|
1054
1058
|
describe: Returns a list of available actions in the system.
|
|
1055
1059
|
***************/
|
|
1056
|
-
|
|
1060
|
+
actions() {
|
|
1057
1061
|
this.action('func', 'actions');
|
|
1058
1062
|
this.state('return', 'actions');
|
|
1059
1063
|
return {
|
|
@@ -1102,7 +1106,7 @@ class Deva {
|
|
|
1102
1106
|
params: none
|
|
1103
1107
|
describe: return a list of features that are available to the system.
|
|
1104
1108
|
***************/
|
|
1105
|
-
|
|
1109
|
+
features() {
|
|
1106
1110
|
this.state('return', 'features');
|
|
1107
1111
|
return { // return the data object
|
|
1108
1112
|
id: this.uid(true), // set the object id
|
|
@@ -1146,7 +1150,7 @@ class Deva {
|
|
|
1146
1150
|
}
|
|
1147
1151
|
}
|
|
1148
1152
|
|
|
1149
|
-
|
|
1153
|
+
contexts() {
|
|
1150
1154
|
if (!this._active) return this._messages.offline; // check the active status
|
|
1151
1155
|
this.state('return', 'contexts');
|
|
1152
1156
|
return {
|