@indra.ai/deva 1.6.103 β†’ 1.7.1

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.
@@ -0,0 +1,37 @@
1
+ {
2
+ "id": "19434356359269778749",
3
+ "title": "Deva Core Beliefs",
4
+ "copyright": "Copyright Β©2025 Quinn A Michaels; All rights reserved.",
5
+ "VLA": "44091450722329207445",
6
+ "DATA": {
7
+ "positive": "🧸 Positive",
8
+ "negative": "☠️ Negative",
9
+ "productive": "πŸ•ΊοΈ Productive",
10
+ "desstructive": "πŸ’£ Destructive",
11
+ "vedic": "πŸ•‰οΈ Vedic",
12
+ "buddhist": "☸️️ Buddhist",
13
+ "hindu": "πŸ›• Hindu/Sikh",
14
+ "occult": "πŸͺ„ Occult",
15
+ "christian": "β›ͺ️ Christian",
16
+ "jewish": "πŸ• Jewish",
17
+ "muslim": "πŸ•ŒοΈοΈ Muslim",
18
+ "catholic": "✝️️ Catholic",
19
+ "quaker": "✝️️ Quaker",
20
+ "orthodox": "☦️ Orthodox",
21
+ "popovtsy": "☦️ Popovtsy",
22
+ "bezpopovtsy": "☦️ Bezpopovtsy",
23
+ "khlysty": "☦️ Khlysty",
24
+ "molokanye": "☦️ Molokanye",
25
+ "dukhobortsy": "☦️ Dukhobortsy",
26
+ "evangelicals": "☦️ Evangelicals",
27
+ "stundists": "☦️ Stundists",
28
+ "skoptsy": "☦️ Skoptsy",
29
+ "lds": "πŸ› LDS Church",
30
+ "pagan": "πŸ§™οΈοΈ Pagan",
31
+ "communists": "πŸ‡·πŸ‡Ί Communist",
32
+ "nazi": "πŸ’© Nazi",
33
+ "delusional": "πŸͺ© Delusional",
34
+ "pervert": "πŸ’‹ Pervert",
35
+ "other": "πŸ€” Other"
36
+ }
37
+ }
@@ -17,10 +17,12 @@
17
17
  "question": "devacore:question",
18
18
  "answer": "devacore:answer",
19
19
  "ask": "devacore:ask",
20
- "state": "devacore:state",
20
+ "feature": "devacore:feature",
21
21
  "zone": "devacore:zone",
22
22
  "action": "devacore:action",
23
- "feature": "devacore:feature",
23
+ "state": "devacore:state",
24
+ "intent": "devacore:intent",
25
+ "belief": "devacore:belief",
24
26
  "load": "devacore:load",
25
27
  "unload": "devacore:unload",
26
28
  "context": "devacore:context"
package/config/index.js CHANGED
@@ -8,6 +8,8 @@ import features from './features.json' with {type:'json'};
8
8
  import zones from './zones.json' with {type:'json'};
9
9
  import actions from './actions.json' with {type:'json'};
10
10
  import states from './states.json' with {type:'json'};
11
+ import intents from './intents.json' with {type:'json'};
12
+ import beliefs from './beliefs.json' with {type:'json'};
11
13
  import msgs from './msgs.json' with {type:'json'};
12
14
 
13
15
  export default {
@@ -47,5 +49,9 @@ export default {
47
49
  actions: actions.DATA,
48
50
  state: false,
49
51
  states: states.DATA,
52
+ intent: false,
53
+ intents: intents.DATA,
54
+ belief: false,
55
+ beliefs: beliefs.DATA,
50
56
  messages: msgs.DATA,
51
57
  }
@@ -0,0 +1,40 @@
1
+ {
2
+ "id": "19434356359269778749",
3
+ "title": "Deva Core Intents",
4
+ "copyright": "Copyright Β©2025 Quinn A Michaels; All rights reserved.",
5
+ "VLA": "44091450722329207445",
6
+ "DATA": {
7
+ "good": "πŸ™‚ Good",
8
+ "neutral": "😐 Neutral",
9
+ "bad": "πŸ™ Bad",
10
+ "fun": "😎 Fun",
11
+ "lawful": "β›“οΈπŸ€ Lawful",
12
+ "unlawful": "⛓️πŸ’₯ Unlawful",
13
+ "play": "πŸ› Play",
14
+ "work": "πŸ”¨ Work",
15
+ "business": "πŸ’Ό Business",
16
+ "abuse": "🩼 Abuse",
17
+ "evil": "πŸ‘Ώ Evil",
18
+ "help": "πŸ™ Help",
19
+ "assist": "πŸ—ΊοΈ Assist",
20
+ "harm": "πŸ€• Harm",
21
+ "kill": "πŸ”ͺ Kill",
22
+ "malicious": "πŸ‘Ί Malicious",
23
+ "vedic": "πŸ•‰οΈ Vedic",
24
+ "buddhist": "☸️️ Buddhist",
25
+ "hindu": "πŸ›• Hindu/Sikh",
26
+ "occult": "πŸͺ„ Occult",
27
+ "christian": "β›ͺ️ Christian",
28
+ "jewish": "πŸ• Jewish",
29
+ "muslim": "πŸ•ŒοΈοΈ Muslim",
30
+ "catholic": "✝️️ Catholic",
31
+ "orthodox": "☦️ Orthodox",
32
+ "lds": "πŸ› LDS Church",
33
+ "delusional": "πŸͺ© Delusional",
34
+ "pervert": "πŸ’‹ Pervert",
35
+ "pleasure": "πŸ’… Pleasure",
36
+ "desire": "😘 Desire",
37
+ "cannibal": "πŸ₯© Cannibal",
38
+ "other": "πŸ€” Other"
39
+ }
40
+ }
package/config/zones.json CHANGED
@@ -67,6 +67,11 @@
67
67
  "merit": "βž• Merit",
68
68
  "demerit": "βž– Demerit",
69
69
  "camera": "🀳 Camera",
70
- "victim": "β€οΈβ€πŸ©Ή Victim"
70
+ "victim": "β€οΈβ€πŸ©Ή Victim",
71
+ "yakshas": "πŸ₯© Yakshas",
72
+ "rakshasas": "πŸ₯© Rakshasas",
73
+ "pisakas": "πŸ₯© Pisakas",
74
+ "kimidin": "πŸ₯© Kimidin",
75
+ "atrin": "πŸ₯© Atrin"
71
76
  }
72
77
  }
package/index.js CHANGED
@@ -99,6 +99,26 @@ class Deva {
99
99
  delete this._agent.actions;
100
100
  }
101
101
 
102
+ this._intent = config.intent; // set the current intent from config data.
103
+ this._intents = config.intents; // set the states from options
104
+ // load any custom actions from the agent file
105
+ if (this._agent.intents) {
106
+ for (let item in this._agent.intents) {
107
+ if (!this._intents[item]) this._intents[item] = this._agent.intents[item];
108
+ }
109
+ delete this._agent.intents;
110
+ }
111
+
112
+ this._belief = config.belief; // set the current belief from config data.
113
+ this._beliefs = config.beliefs; // set the states from options
114
+ // load any custom actions from the agent file
115
+ if (this._agent.beliefs) {
116
+ for (let item in this._agent.beliefs) {
117
+ if (!this._beliefs[item]) this._beliefs[item] = this._agent.beliefs[item];
118
+ }
119
+ delete this._agent.beliefs;
120
+ }
121
+
102
122
  this._context = config.context || false; // set the local context
103
123
 
104
124
  this._messages = config.messages; // set the messages from config data.
@@ -259,12 +279,15 @@ class Deva {
259
279
  this.zone(key);
260
280
  this.action(key);
261
281
  this.state(key);
282
+ this.state('try', key);
262
283
  try {
263
284
  const data = this.lib.copy(value);
264
285
  this.action('return', key); // set the security state
286
+ this.intent('good', key);
265
287
  return data; // return the security feature
266
288
  } catch (e) {
267
289
  this.state('catch', key);
290
+ this.intent('bad', key);
268
291
  return this.err(e);
269
292
  }
270
293
  }
@@ -284,8 +307,9 @@ class Deva {
284
307
  this.zone('client', `client:${client.id}`);
285
308
  this.action('client', `client:${client.id}`);
286
309
  // setup any custom methods for the features
287
- this.state('set', `client:feature:methods:${client.id}`);
310
+ this.state('try', `client:${client.id}`);
288
311
  try {
312
+ this.state('set', `client:methods:${client.id}`);
289
313
  for (const x in client.features) {
290
314
  const methods = client.features[x].methods || false;
291
315
  if (methods) for (const y in methods) {
@@ -300,9 +324,11 @@ class Deva {
300
324
  this._client = _client; // set local _client to this scope
301
325
 
302
326
  this.action('return', `client:${client.id}`);
327
+ this.intent('good', `client:${client.id}`);
303
328
  return resolve();
304
329
  } catch (e) {
305
- this.action('investigate', `client:${client.id}`);
330
+ this.state('catch', `client:${client.id}`);
331
+ this.intent('bad', `client:${client.id}`);
306
332
  return this.err(e, false, reject);
307
333
  }
308
334
  }
@@ -338,10 +364,12 @@ class Deva {
338
364
  };
339
365
  delete this._client.features[feature]; // make a copy the clinet data.
340
366
  this.state('resolve', `${feature}:${_id.uid}`);
367
+ this.intent('good', `${feature}:${_id.uid}`);
341
368
  return resolve(feature); // resolve when done
342
369
  }
343
370
  } catch (e) {
344
371
  this.state('catch', `${feature}:${_id.uid}`);
372
+ this.intent('bad', `${feature}:${_id.uid}`);
345
373
  return this.err(e, feature, reject); // run error handling if an error is caught
346
374
  }
347
375
  }
@@ -650,6 +678,7 @@ class Deva {
650
678
  ***************/
651
679
  listen(evt, callback) {
652
680
  this.action('listen', evt);
681
+ this.intent('good', `listen:${evt}`);
653
682
  this.listeners[evt] = callback;
654
683
  return this.events.on(evt, packet => {
655
684
  return this.listeners[evt](packet);
@@ -664,7 +693,8 @@ class Deva {
664
693
  describe:
665
694
  ***************/
666
695
  once(evt, callback) {
667
- this.action('once', evt)
696
+ this.action('once', evt);
697
+ this.intent('good', `once:${evt}`);
668
698
  return this.events.once(evt, callback);
669
699
  }
670
700
 
@@ -677,6 +707,7 @@ class Deva {
677
707
  ***************/
678
708
  ignore(evt, callback) {
679
709
  this.action('ignore', evt);
710
+ this.intent('bad', `ignore:${evt}`);
680
711
  return this.events.removeListener(evt, callback);
681
712
  }
682
713
 
@@ -720,7 +751,7 @@ class Deva {
720
751
  return new Promise((resolve, reject) => {
721
752
  // resolve with the no text message if the client says nothing.
722
753
  if (!TEXT) return resolve(this._messages.notext, resolve);
723
- this.state('try', `question:${id.uid}`);
754
+ this.state('try', `${method}:${id.uid}`);
724
755
  try { // try to answer the question
725
756
  if (isAsk) { // determine if hte question isAsk
726
757
  // if:isAsk split the agent key and remove first command character
@@ -739,7 +770,7 @@ class Deva {
739
770
  this.state('cmd', `${method}:${id.uid}`); // set the state to cmd.
740
771
  }
741
772
 
742
- this.state('set', `question:${method}:${id.uid}`)
773
+ this.state('data', `${method}:q:${id.uid}`);
743
774
  packet.q = { // build packet.q container
744
775
  id: this.uid(), // set the transport id for the question.
745
776
  agent: this.agent(), // set the agent
@@ -755,28 +786,44 @@ class Deva {
755
786
  }
756
787
 
757
788
  // hash the question
789
+
790
+ this.action('hash', `${method}:md5:${id.uid}`);
758
791
  packet.q.md5 = this.hash(packet.q, 'md5');
792
+
793
+ this.action('hash', `${method}:sha256:${id.uid}`)
759
794
  packet.q.sha256 = this.hash(packet.q, 'sha256');
795
+
796
+ this.action('hash', `${method}:sha512:${id.uid}`)
760
797
  packet.q.sha512 = this.hash(packet.q, 'sha512');
761
798
 
799
+ this.action('talk', `${this._events.question}:${id.uid}`);
800
+ this.intent('good', `${this._events.question}:${id.uid}`);
762
801
  this.talk(this._events.question, this.lib.copy(packet)); // global question event make sure to copy data.
763
802
 
764
803
  if (isAsk) { // isAsk check if the question isAsk and talk
765
804
  // if: isAsk wait for the once event which is key'd to the packet ID for specified responses
805
+ this.action('ask', `${key}:${id.uid}`);
806
+ this.intent('good', `ask:${key}:${id.uid}`);
766
807
  this.talk(`${key}:ask`, packet);
767
808
  this.once(`${key}:ask:${packet.id.uid}`, answer => {
809
+ this.action('talk', `${this._events.ask}:${id.uid}`);
810
+ this.intent('good', `${this.events.ask}:${id.uid}`);
768
811
  this.talk(this._events.ask, this.lib.copy(answer));
769
- this.state('return', `${key}:ask:${packet.id.uid}`);
812
+ this.action('return', `finish:${key}:ask:${id.uid}`);
813
+ this.intent('good', `finish:${method}:${id.uid}`);
770
814
  return this.finish(answer, resolve); // if:isAsk resolve the answer from the call
771
815
  });
772
816
  }
773
817
  else { // else: answer the question locally
774
818
  this.state('answer', `${method}:${id.uid}`); //set the answer state to the method
819
+ this.action('return', `${method}:answer:${id.uid}`); //set the answer state to the method
820
+ this.intent('good', `${method}:answer:${id.uid}`); //set the answer state to the method
775
821
  return this.answer(packet, resolve, reject);
776
822
  }
777
823
  }
778
824
  catch(e) {
779
- this.state('catch', `${id.uid}`);
825
+ this.state('catch', `${method}:${id.uid}`);
826
+ this.intent('bad', `${method}:${id.uid}`); //set the answer state to the method
780
827
  return this.err(e); // if a overall error happens this witll call this.err
781
828
  }
782
829
  });
@@ -793,29 +840,45 @@ class Deva {
793
840
  from the agent from the pre-determined method.
794
841
  ***************/
795
842
  answer(packet, resolve, reject) {
796
- const id = this.uid();
797
843
  if (!this._active) return Promise.resolve(this._messages.offline);
798
- this.zone('answer', id.uid); // set zone to answer
844
+ const id = this.uid();
845
+ const key = 'answer';
846
+ const subkey = 'packet_answer';
847
+
799
848
  const agent = this.agent();
800
849
  const client = this.client();
801
- // check if method exists and is of type function
802
850
  const {method,params} = packet.q.meta;
803
- this.action('answer', `${method}:${id.uid}`);
851
+
852
+ this.zone(key, `${method}:${id.uid}`); // set zone to answer
853
+ this.action(key, `${method}:${id.uid}`);
854
+ this.state(key, `${method}:${id.uid}`);
855
+
856
+ // check if method exists and is of type function
804
857
 
805
- this.state('try', `answer:${method}:${id.uid}`);
858
+ this.state('try', `${key}:${method}:${id.uid}`);
806
859
  try {
807
860
  const isMethod = this.methods[method] && typeof this.methods[method] == 'function';
808
- if (!isMethod) return resolve(this._methodNotFound(packet)); // resolve method not found if check if check fails
861
+ if (!isMethod) {
862
+ this.action('resolve', `${key}:${method}:not_found:${packet.id.uid}`);
863
+ this.state('invalid', `${key}:${method}:${packet.id.uid}`);
864
+ this.intent('bad', `${key}:${method}:not_found:${packet.id.uid}`);
865
+ return resolve(this._methodNotFound(packet)); // resolve method not found if check if} check fails
866
+ }
809
867
 
810
- this.action('method', `answer:${method}:${id.uid}`);
868
+ this.action('method', `${key}:${method}:${id.uid}`);
811
869
  this.methods[method](packet).then(result => {
812
870
  // check the result for the text, html, and data object. // this is for when answers are returned from nested Devas.
871
+ this.state('set', `${key}:${method}:text:${id.uid}`);
813
872
  const text = typeof result === 'object' ? result.text : result;
873
+
874
+ this.state('set', `${key}:${method}:html:${id.uid}`);
814
875
  const html = typeof result === 'object' ? result.html : result;
876
+
815
877
  // if the data passed is NOT an object it will FALSE
878
+ this.state('set', `${key}:${method}:data:${id.uid}`);
816
879
  const data = typeof result === 'object' ? result.data : false;
817
-
818
- this.state('set', `answer:${method}:packet_answer:${id.uid}`);
880
+
881
+ this.state('data', `${key}:${method}:${sub_key}:${id.uid}`);
819
882
  const packet_answer = { // setup the packet.a container
820
883
  id,
821
884
  agent, // set the agent who answered the question
@@ -831,21 +894,33 @@ class Deva {
831
894
  created: Date.now(), // set the created date for the answer
832
895
  };
833
896
  // create a hash for the answer and insert into answer meta.
897
+ this.action('hash', `${key}:${method}:${sub_key}:md5:${id.uid}`);
834
898
  packet_answer.md5 = this.hash(packet_answer, 'md5');
899
+
900
+ this.action('hash', `${key}:${method}:${sub_key}:sha256:${id.uid}`);
835
901
  packet_answer.sha256 = this.hash(packet_answer, 'sha256');
902
+
903
+ this.action('hash', `${key}:${method}:${sub_key}:sha512:${id.uid}`);
836
904
  packet_answer.sha512 = this.hash(packet_answer, 'sha512');
837
905
 
906
+ this.state('set', `${key}:${method}:${sub_key}:${id.uid}`);
838
907
  packet.a = packet_answer; // set the packet.a to the packet_answer
908
+
909
+ this.action('talk', `${this._events.answer}:${id.uid}`);
839
910
  this.talk(this._events.answer, this.lib.copy(packet)); // global talk event
840
911
 
841
- this.state('return', `answer:${method}:${id.uid}`); // set the state resolve answer
912
+ this.action('return', `${key}:${method}:finish:${id.uid}`); // set the state resolve answer
913
+ this.state('valid', `${key}:${method}:finish:${id.uid}`);
914
+ this.intent('good', `${key}:${method}:finish:${id.uid}`);
842
915
  return this.finish(packet, resolve); // resolve the packet to the caller.
843
916
  }).catch(err => { // catch any errors in the method
844
- this.state('catch', `answer:${method}:${id.uid}`); // set the state reject answer
917
+ this.state('catch', `${key}:${method}:${id.uid}`); // set the state reject answer
918
+ this.intent('bad', `${key}:${method}:${id.uid}`);
845
919
  return this.err(err, packet, reject); // return this.err with err, packet, reject
846
920
  });
847
921
  } catch (e) {
848
- this.state('catch', `answer:${method}:${id.uid}`);
922
+ this.state('catch', `${key}:${method}:${id.uid}`);
923
+ this.intent('bad', `${key}:${method}:${id.uid}`);
849
924
  return this.err(e, packet, reject);
850
925
  }
851
926
  }
@@ -867,23 +942,29 @@ class Deva {
867
942
  ***************/
868
943
  ask(packet) {
869
944
  if (!this._active) return Promise.resolve(this._messages.offline);
945
+ const id = this.uid();
946
+ const key = 'ask';
947
+ const sub_key = 'packet_answer';
870
948
  const agent = this.agent();
871
949
  const client = this.client();
872
950
  const {method, params} = packet.q.meta;
873
- this.zone('ask', `${method}:${packet.id.uid}`);
874
- this.action('ask', `${method}:${packet.id.uid}`);
951
+ this.zone(key, `${method}:${packet.id.uid}`);
952
+ this.action(key, `${method}:${packet.id.uid}`);
875
953
  // build the answer packet from this model
876
- this.state('try', `ask:${method}:${packet.id.uid}`);
954
+ this.state('try', `${key}:${method}:${packet.id.uid}`);
877
955
  try {
878
956
  if (typeof this.methods[method] !== 'function') {
879
957
  return setImmediate(() => {
880
- this.talk(`${this._agent.key}:ask:${packet.id.uid}`, this._methodNotFound(packet));
958
+ this.action('talk', `${key}:${method}:${packet.id.uid}`);
959
+ this.state('invalid', `${key}:${method}:${packet.id.uid}`);
960
+ this.intent('bad', `${key}:${method}:${packet.id.uid}`);
961
+ return this.talk(`${this._agent.key}:ask:${packet.id.uid}`, this._methodNotFound(packet));
881
962
  });
882
963
  }
883
964
 
884
- this.state('set', `ask:${method}:packet_answer:${packet.id.uid}`);
965
+ this.state('data', `ask:${method}:${sub_key}:${packet.id.uid}`);
885
966
  const packet_answer = {
886
- id: this.uid(),
967
+ id,
887
968
  agent,
888
969
  client,
889
970
  meta: {
@@ -900,41 +981,69 @@ class Deva {
900
981
  // the response based on the passed through packet.
901
982
  this.methods[method](packet).then(result => {
902
983
  if (typeof result === 'object') {
984
+ this.state('set', `${key}:${method}:${sub_key}:text:${packet.id.uid}`);
903
985
  packet_answer.text = result.text || false;
986
+ this.state('set', `${key}:${method}:${sub_key}:text:${packet.id.uid}`);
904
987
  packet_answer.html = result.html || false;
988
+ this.state('set', `${key}:${method}:${sub_key}:data:${packet.id.uid}`);
905
989
  packet_answer.data = result.data || false;
906
990
  }
907
991
  else {
992
+ this.state('set', `${key}:${method}:${sub_key}:result:${packet.id.uid}`);
908
993
  packet_answer.text = result;
909
994
  }
995
+
996
+ // delete previous hashes before creating new ones.
997
+ this.action('delete', `${key}:${method}:packet:md5:${packet.id.uid}`);
998
+ delete packet.md5;
999
+ this.action('delete', `${key}:${method}:packet:sha256:${packet.id.uid}`);
1000
+ delete packet.sha256;
1001
+ this.action('delete', `${key}:${method}:packet:sha512:${packet.id.uid}`);
1002
+ delete packet.sha512;
910
1003
 
1004
+ this.action('hash', `${key}:${method}:${sub_key}:md5:${packet.id.uid}`);
911
1005
  packet_answer.md5 = this.hash(packet_answer, 'md5'); // md5 the answer.
1006
+ this.action('hash', `${key}:${method}:${sub_key}:sha256:${packet.id.uid}`);
912
1007
  packet_answer.sha256 = this.hash(packet_answer, 'sha256'); // sha256 the answer.
1008
+ this.action('hash', `${key}:${method}:${sub_key}:sha512:${packet.id.uid}`);
913
1009
  packet_answer.sha512 = this.hash(packet_answer, 'sha512'); // sha512 the answer
914
1010
 
1011
+ this.state('set', `${key}:${method}:packet:q:agent:${packet.id.uid}`);
915
1012
  packet.q.agent = agent; // set the question agent as the ask agent.
1013
+
1014
+ this.state('set', `${key}:${method}:packet:a:${packet.id.uid}`);
916
1015
  packet.a = packet_answer; // set the packet answer.
917
-
918
- // delete previous hashes before creating new ones.
919
- delete packet.md5;
920
- delete packet.sha256;
921
- delete packet.sha512;
922
-
1016
+
923
1017
  // create new hashes for the packet before return.
1018
+ // delete previous hashes before creating new ones.
1019
+ this.action('hash', `${key}:${method}:packet:md5:${packet.id.uid}`);
924
1020
  packet.md5 = this.hash(packet, 'md5');
1021
+ this.action('hash', `${key}:${method}:packet:sha256:${packet.id.uid}`);
925
1022
  packet.sha256 = this.hash(packet, 'sha256');
1023
+ this.action('hash', `${key}:${method}:packet:sha512:${packet.id.uid}`);
926
1024
  packet.sha512 = this.hash(packet, 'sha512');
927
1025
 
1026
+ this.action('talk', `${this.events.answer}:${key}:${method}:${packet.id.uid}`);
1027
+ this.state('valid', `${this.events.answer}:${key}:${method}:${packet.id.uid}`);
1028
+ this.intent('good', `${this.events.answer}:${key}:${method}:${packet.id.uid}`);
928
1029
  this.talk(this._events.answer, this.lib.copy(packet)); // global talk event
1030
+
1031
+ this.action('talk', `${agent.key}:${key}:${method}:${packet.id.uid}`);
1032
+ this.state('valid', `${agent.key}:${key}:${method}:${packet.id.uid}`);
1033
+ this.intent('good', `${agent.key}:${key}:${method}:${packet.id.uid}`);
929
1034
  this.talk(`${agent.key}:ask:${packet.id.uid}`, packet);
930
1035
  }).catch(err => {
931
- this.talk(`${agent.key}:ask:${packet.id.uid}`, {error:err});
932
- this.state('catch', `ask:${method}:${packet.id.uid}`);
1036
+ this.action('talk', `${agent.key}:${key}:${method}:err:${packet.id.uid}`);
1037
+ this.state('catch', `${agent.key}:${key}:${method}:${packet.id.uid}`);
1038
+ this.intent('bad', `${agent.key}:${key}:${method}:${packet.id.uid}`);
1039
+ this.talk(`${agent.key}:${key}:${method}:${packet.id.uid}`, {error:err});
933
1040
  return this.err(err, packet);
934
1041
  })
935
1042
  }
936
1043
  catch (e) {
937
- this.state('catch', `ask:${method}:${packet.id.uid}`);
1044
+ this.action('talk', `${agent.key}:${key}:${method}:err:${packet.id.uid}`);
1045
+ this.state('catch', `${agent.key}:${key}:${method}:${packet.id.uid}`);
1046
+ this.intent('bad', `${agent.key}:${key}:${method}:${packet.id.uid}`);
938
1047
  this.talk(`${agent.key}:ask:${packet.id.uid}`, {error:e});
939
1048
  return this.err(e, packet)
940
1049
  }
@@ -1058,10 +1167,15 @@ class Deva {
1058
1167
  if (hasOnInit) {
1059
1168
  this.action('onfunc', `hasOnInit:${data.id.uid}`); // state set to watch onInit
1060
1169
  this.state('onfunc', `hasOnInit:${data.id.uid}`); // state set to watch onInit
1170
+ this.intent('good', `onInit:${data.id.uid}`); // state set to watch onInit
1171
+ this.action('return', `onInit:${data.id.uid}`);
1172
+ return this.onInit(data, resolve);
1061
1173
  }
1174
+ this.intent('good', `init:${data.id.uid}`); // state set to watch onInit
1062
1175
  this.action('return', `init:${data.id.uid}`);
1063
- return hasOnInit ? this.onInit(data, resolve) : this.start(data, resolve);
1176
+ return this.start(data, resolve);
1064
1177
  }).catch(err => {
1178
+ this.intent('bad', `init:${data.id.uid}`); // state set to watch onInit
1065
1179
  this.state('catch', `init:${data.id.uid}`);
1066
1180
  return this.err(err, client, reject);
1067
1181
  });
@@ -1110,10 +1224,14 @@ class Deva {
1110
1224
  if (hasOnStart) {
1111
1225
  this.action('onfunc', `hasOnStart:${data.id.uid}`); // set action to onfunc
1112
1226
  this.state('onfunc', `hasOnStart:${data.id.uid}`); // set state to onfunc
1227
+ this.intent('good', `onStart:${data.id.uid}`); // set the good intent
1228
+ this.action('return', `onStart:${data.id.uid}`); // return action finish
1229
+ return this.onStart(data, resolve)
1113
1230
  }
1114
-
1231
+
1232
+ this.intent('good', `start:${data.id.uid}`); // set the good intent
1115
1233
  this.action('return', `start:${data.id.uid}`); // return action finish
1116
- return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
1234
+ return this.enter(data, resolve)
1117
1235
  }
1118
1236
 
1119
1237
  /**************
@@ -1158,10 +1276,14 @@ class Deva {
1158
1276
  if (hasOnEnter) {
1159
1277
  this.action('onfunc', `hasOnEnter:${data.id.uid}`); // action onfunc set
1160
1278
  this.state('onfunc', `hasOnEnter:${data.id.uid}`); // state onfunc set
1279
+ this.intent('good', `onEnter:${data.id.uid}`); // set good intent on enter
1280
+ this.action('return', `onEnter:${data.id.uid}`); // set return actions
1281
+ return this.onEnter(data, resolve); // set return on enter.
1161
1282
  }
1162
1283
 
1284
+ this.intent('good', `enter:${data.id.uid}`); // set good intent enter
1163
1285
  this.action('return', `enter:${data.id.uid}`); // return action finish
1164
- return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
1286
+ return this.done(data, resolve)
1165
1287
  }
1166
1288
 
1167
1289
  /**************
@@ -1206,10 +1328,14 @@ class Deva {
1206
1328
  if (hasOnDone) {
1207
1329
  this.action('onfunc', `hasOnDone:${data.id.uid}`); // state onfunc
1208
1330
  this.state('onfunc', `hasOnDone:${data.id.uid}`); // state onfunc
1331
+ this.intent('good', `onDone:${data.id.uid}`); // set the onDone intent
1332
+ this.action('return', `onDone:${data.id.uid}`); // set the return action
1333
+ return this.onDone(data, resolve);
1209
1334
  }
1210
1335
 
1336
+ this.intent('good', `done:${data.id.uid}`); // set done intent
1211
1337
  this.action('return', `done:${data.id.uid}`); // return action finish
1212
- return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
1338
+ return this.ready(data, resolve);
1213
1339
  }
1214
1340
 
1215
1341
  /**************
@@ -1266,10 +1392,14 @@ class Deva {
1266
1392
  if (hasOnReady) {
1267
1393
  this.action('onfunc', `hasOnReady:${data.id.uid}`); // action onfunc
1268
1394
  this.state('onfunc', `hasOnReady:${data.id.uid}`); // state onfunc
1395
+ this.intent('good', `onReady:${data.id.uis}`); // set ready intent
1396
+ this.action('return', `onReady:${data.id.uid}`); // set action onReady return
1397
+ return this.onReady(data, resolve);
1269
1398
  }
1270
1399
 
1400
+ this.intent('good', `ready:${data.id.uid}`); // set read intent good
1271
1401
  this.action('resolve', `ready:${data.id.uid}`); // return action ready
1272
- return hasOnReady ? this.onReady(data, resolve) : resolve(data);
1402
+ return resolve(data);
1273
1403
  }
1274
1404
 
1275
1405
  /**************
@@ -1503,75 +1633,92 @@ class Deva {
1503
1633
 
1504
1634
  ////////////////////////////
1505
1635
 
1636
+
1506
1637
  /**************
1507
- func: state
1638
+ func: context
1508
1639
  params:
1509
- - value: The state value to set for the Deva that matches to this._states
1510
- - extra: any extra text to add to the state change.
1640
+ - value: The context flag to set for the Deva that matches to this._contexts
1641
+ - extra: Any extra text that is sent with the context value.
1642
+ describe
1511
1643
  ***************/
1512
- state(value=false, extra=false) {
1513
- if (!this._active) return this._messages.offline;
1644
+ context(value=false, extra=false) {
1645
+ if (!this._active) return this._messages.offline; // check the active status
1514
1646
  const id = this.uid();
1515
- const key = 'state';
1516
1647
  try {
1517
- if (!value || !this._states[value]) return; // return if no matching value
1518
- this._state = value; // set the local state variable.
1519
- const lookup = this._states[value]; // set the local states lookup
1520
- const text = extra ? `${lookup} ${extra}` : lookup; // set text from lookup with extra
1521
- const data = { // build the data object
1522
- id, // set the data id
1523
- key, // set the key to state
1524
- value, // set the value to the passed in value
1525
- text, // set the text value of the data
1526
- agent: this.agent(), // set the agent
1527
- client: this.client(), // set the client
1528
- created: Date.now(), // set the data created date.
1648
+ if (!value) return;
1649
+ this._context = value;
1650
+ const lookup = this.vars.context[value] || value;
1651
+ const text = extra ? `${lookup} ${extra}` : lookup;
1652
+
1653
+ const data = {
1654
+ id,
1655
+ agent: this.agent(),
1656
+ client: this.client(),
1657
+ key: 'context',
1658
+ value,
1659
+ text,
1660
+ created: Date.now(),
1529
1661
  };
1530
-
1662
+
1531
1663
  data.md5 = this.hash(data, 'md5');
1532
1664
  data.sha256 = this.hash(data, 'sha256');
1533
1665
  data.sha512 = this.hash(data, 'sha512');
1534
-
1535
- this.talk(this._events.state, data); // broadcast the state event
1666
+
1667
+ this.talk(this._events.context, data);
1536
1668
  return data;
1537
- } catch (e) { // catch any errors
1538
- return this.err(e); // return if an error happens
1669
+ } catch (e) {
1670
+ this.state('catch', `context:${value}:${id.uid}`);
1671
+ return this.err(e, value);
1539
1672
  }
1540
1673
  }
1541
-
1542
- /**************
1543
- func: states
1544
- params: none
1545
- describe: returns the available states values.
1546
- ***************/
1547
- states() {
1548
- if (!this._active) return this._messages.offline;
1549
- const id = this.uid();
1550
- const key = 'states';
1674
+
1675
+ contexts() {
1676
+ if (!this._active) return this._messages.offline; // check the active status
1677
+ const id = this.uid();
1678
+ const key = 'contexts';
1551
1679
  this.action(key, id.uid);
1552
-
1553
- // set the data packet for the states
1680
+
1554
1681
  this.state('data', `${key}:${id.uid}`);
1555
1682
  const data = {
1556
1683
  id,
1557
1684
  key,
1558
- value: this._states,
1685
+ value: this.vars.context || false,
1559
1686
  agent: this.agent(),
1560
1687
  client: this.client(),
1561
1688
  created: Date.now(),
1562
- }
1563
-
1689
+ };
1690
+
1564
1691
  this.action('hash', `${data.key}:md5:${data.id.uid}`);
1565
1692
  data.md5 = this.hash(data, 'md5');
1566
1693
  this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1567
1694
  data.sha256 = this.hash(data, 'sha256');
1568
1695
  this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1569
1696
  data.sha512 = this.hash(data, 'sha512');
1570
-
1571
- this.action('return', `${data.key}:${id.uid}`);
1697
+
1698
+ this.state('return', `${data.key}:${id.uid}`);
1572
1699
  return data;
1573
1700
  }
1574
1701
 
1702
+ /**************
1703
+ func: feature
1704
+ params:
1705
+ - value: The feature flag to set for the Deva that matches to this._features
1706
+ - extra: Any extra text to send with the feature value.
1707
+ describe
1708
+ ***************/
1709
+ feature(value=false, extra=false) {
1710
+ return this._workflow('feature', value, extra);
1711
+ }
1712
+
1713
+ /**************
1714
+ func: features
1715
+ params: none
1716
+ describe: return a list of features that are available to the system.
1717
+ ***************/
1718
+ features() {
1719
+ return this._workflowItems('features');
1720
+ }
1721
+
1575
1722
  /**************
1576
1723
  func: zone
1577
1724
  params:
@@ -1579,35 +1726,7 @@ class Deva {
1579
1726
  describe
1580
1727
  ***************/
1581
1728
  zone(value=false, extra=false) {
1582
- if (!this._active) return this._messages.offline;
1583
- const id = this.uid();
1584
- const key = 'zone';
1585
- if (!value || !this._zones[value]) return;
1586
-
1587
- try {
1588
- this._zone = value;
1589
- const lookup = this._zones[value]; // set the lookup value
1590
- const text = extra ? `${lookup} ${extra}` : lookup; // set the text value
1591
-
1592
- const data = { // build the zone data
1593
- id, // set the packetid
1594
- key,
1595
- value,
1596
- text,
1597
- agent: this.agent(),
1598
- client: this.client(),
1599
- created: Date.now(),
1600
- };
1601
-
1602
- data.md5 = this.hash(data, 'md5');
1603
- data.sha256 = this.hash(data, 'sha256');
1604
- data.sha512 = this.hash(data, 'sha512');
1605
-
1606
- this.talk(this._events.zone, data);
1607
- return data;
1608
- } catch (e) {
1609
- return this.err(e, value);
1610
- }
1729
+ return this._workflow('zone', value, extra);
1611
1730
  }
1612
1731
 
1613
1732
  /**************
@@ -1616,30 +1735,7 @@ class Deva {
1616
1735
  describe: returns a listing of zones currently in the system.
1617
1736
  ***************/
1618
1737
  zones() {
1619
- if (!this._active) return this._messages.offline;
1620
- const id = this.uid();
1621
- const key = 'zones';
1622
- this.action(key, id.uid);
1623
-
1624
- this.state('data', `${key}:${id.uid}`);
1625
- const data = {
1626
- id, // set the uuid of the data
1627
- key, // set the key return value
1628
- value: this._zones, // set the list of zones
1629
- agent: this.agent(), // set the agent value
1630
- client: this.client(), // set the client value
1631
- created: Date.now(), // set the created date of the object.
1632
- }
1633
-
1634
- this.action('hash', `${data.key}:md5:${data.id.uid}`);
1635
- data.md5 = this.hash(data, 'md5');
1636
- this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1637
- data.sha256 = this.hash(data, 'sha256');
1638
- this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1639
- data.sha512 = this.hash(data, 'sha512');
1640
-
1641
- this.action('return', `${data.key}:${id.uid}`);
1642
- return data
1738
+ return this._workflowItems('zones');
1643
1739
  }
1644
1740
 
1645
1741
  /**************
@@ -1650,39 +1746,7 @@ class Deva {
1650
1746
  describe
1651
1747
  ***************/
1652
1748
  action(value=false, extra=false) {
1653
- if (!this._active) return this._messages.offline;
1654
- const id = this.uid();
1655
- const key = 'action'
1656
- try {
1657
- if (!value || !this._actions[value]) return;
1658
- this._action = value; // set the local action variable
1659
- // check local vars for custom actions
1660
- const var_action = this.vars.actions ? this.vars.actions[value] : false;
1661
- // check the message action
1662
- const msg_action = var_action || this._actions[value];
1663
- const msg = msg_action || action; // set the correct message
1664
- const text = extra ? `${msg} ${extra}` : msg; // set the text of the action
1665
-
1666
- const data = { // build the data object for the action.
1667
- id, // generate a guid for the action transmitssion.
1668
- key, // the key for event to transmit action type
1669
- value, // the value key which is the action passed
1670
- text, // text of the action to send
1671
- agent: this.agent(), // the agent data to send with the action
1672
- client: this.client(), // the client data to send with the action
1673
- created: Date.now(), // action time stamp
1674
- };
1675
-
1676
- data.md5 = this.hash(data, 'md5');
1677
- data.sha256 = this.hash(data, 'sha256');
1678
- data.sha512 = this.hash(data, 'sha512');
1679
-
1680
- this.talk(this._events.action, data); // talk the core action event
1681
- return data;
1682
- } catch (e) { // catch any errors that occur
1683
- this.state('catch', `${key}:${id.uid}`);
1684
- return this.err(e); // return error on error catch
1685
- }
1749
+ return this._workflow('action', value, extra);
1686
1750
  }
1687
1751
 
1688
1752
  /**************
@@ -1691,162 +1755,133 @@ class Deva {
1691
1755
  describe: Returns a list of available actions in the system.
1692
1756
  ***************/
1693
1757
  actions() {
1694
- if (!this._active) return this._messages.offline;
1695
- const id = this.uid();
1696
- const key = 'actions';
1697
- this.action(key, id.uid);
1698
-
1699
- this.state('data', `${key}:${id.uid}`);
1700
- const data = {
1701
- id, // set the id with a uuid
1702
- key, // set the data key
1703
- value: this._actions, // set the value to the actions list
1704
- agent: this.agent(), // set the agent value
1705
- client: this.client(), // set the client value
1706
- created: Date.now(), // set the data created date
1707
- };
1708
-
1709
- this.action('hash', `${data.key}:md5:${data.id.uid}`);
1710
- data.md5 = this.hash(data, 'md5');
1711
- this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1712
- data.sha256 = this.hash(data, 'sha256');
1713
- this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1714
- data.sha512 = this.hash(data, 'sha512');
1715
-
1716
- this.state('return', `${key}:${id.uid}`);
1717
- return data;
1758
+ this._workflowItems('actions');
1718
1759
  }
1719
1760
 
1720
1761
  /**************
1721
- func: feature
1762
+ func: state
1722
1763
  params:
1723
- - value: The feature flag to set for the Deva that matches to this._features
1724
- - extra: Any extra text to send with the feature value.
1725
- describe
1764
+ - value: The state value to set for the Deva that matches to this._states
1765
+ - extra: any extra text to add to the state change.
1726
1766
  ***************/
1727
- feature(value=false, extra=false) {
1728
- const id = this.uid();
1729
- try {
1730
- if (!value || !this._features[value]) return; // check feature value
1731
-
1732
- const lookup = this._features[value]; // set the lookup value
1733
- const text = extra ? `${lookup} ${extra}` : lookup; // set the text value
1734
-
1735
- const data = { // build data object
1736
- id, // set the id
1737
- agent: this.agent(), // set the agent transporting the packet.
1738
- key: 'feature', // set the key for transport
1739
- value, // set the value of the key
1740
- text, // set the text value
1741
- created: Date.now(), // set the creation date
1742
- };
1743
-
1744
- data.md5 = this.hash(data, 'md5');
1745
- data.sha256 = this.hash(data, 'sha256');
1746
- data.sha512 = this.hash(data, 'sha512');
1747
-
1748
- this.talk(this._events.feature, data); // talk the feature event with data
1749
- return data;
1750
- } catch (e) { // catch any errors
1751
- this.state('catch', `feature:${value}:${id.uid}`);
1752
- return this.err(e); // retun this.err when an error is caught.
1753
- }
1767
+ state(value=false, extra=false) {
1768
+ return this._workflow('state', value, extra);
1769
+ }
1770
+
1771
+ /**************
1772
+ func: states
1773
+ params: none
1774
+ describe: returns the available states values.
1775
+ ***************/
1776
+ states() {
1777
+ return this._workflowItems('states');
1754
1778
  }
1755
1779
 
1756
1780
  /**************
1757
- func: features
1781
+ func: intent
1782
+ params:
1783
+ - value: The intent value to set for the Deva that matches to this._intents
1784
+ - extra: any extra text to add to the intent change.
1785
+ ***************/
1786
+ intent(value=false, extra=false) {
1787
+ return this._workflow('intent', value, extra);
1788
+ }
1789
+
1790
+ /**************
1791
+ func: intents
1758
1792
  params: none
1759
- describe: return a list of features that are available to the system.
1793
+ describe: returns the available intents values.
1760
1794
  ***************/
1761
- features() {
1762
- if (!this._active) return this._messages.offline; // check the active status
1763
- const id = this.uid();
1764
- const key = 'features';
1765
- this.action(key, id.uid);
1766
-
1767
- this.state('data', `${key}:${id.uid}`);
1768
- const data = {
1769
- id, // set the object id
1770
- key, // set the key
1771
- value: this._features, // set the value to the features list
1772
- agent: this.agent(), // set the agent value.
1773
- client: this.client(), // set the client value.
1774
- created: Date.now(), // set the created date.
1775
- };
1795
+ intents() {
1796
+ return this._workflowItems('intents');
1797
+ }
1776
1798
 
1777
- this.action('hash', `${data.key}:md5:${data.id.uid}`);
1778
- data.md5 = this.hash(data, 'md5');
1779
- this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1780
- data.sha256 = this.hash(data, 'sha256');
1781
- this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1782
- data.sha512 = this.hash(data, 'sha512');
1783
-
1784
- this.state('return', `${data.key}:${data.id.uid}`);
1785
- return data;
1799
+ /**************
1800
+ func: belief
1801
+ params:
1802
+ - value: The belief value to set for the Deva that matches to this._beliefs
1803
+ - extra: any extra text to add to the belief change.
1804
+ ***************/
1805
+ belief(value=false, extra=false) {
1806
+ return this._workflow('belief', value, extra);
1807
+ }
1808
+
1809
+ /**************
1810
+ func: beliefs
1811
+ params: none
1812
+ describe: returns the available beliefs values.
1813
+ ***************/
1814
+ beliefs() {
1815
+ return this._workflowItems('intents');
1786
1816
  }
1787
1817
 
1788
1818
  /**************
1789
- func: context
1819
+ func: _workflow
1790
1820
  params:
1791
- - value: The context flag to set for the Deva that matches to this._contexts
1792
- - extra: Any extra text that is sent with the context value.
1793
- describe
1821
+ - value: The workflow value to set for the Deva that matches to this._states
1822
+ - extra: any extra text to add to the state change.
1823
+ stages: Feature, Zone, Action, State, Intent
1794
1824
  ***************/
1795
- context(value=false, extra=false) {
1796
- if (!this._active) return this._messages.offline; // check the active status
1825
+ _workflow(key, value=false, extra=false) {
1826
+ if (!this._active) return this._messages.offline;
1797
1827
  const id = this.uid();
1798
1828
  try {
1799
- if (!value) return;
1800
- this._context = value;
1801
- const lookup = this.vars.context[value] || value;
1802
- const text = extra ? `${lookup} ${extra}` : lookup;
1803
-
1804
- const data = {
1805
- id,
1806
- agent: this.agent(),
1807
- client: this.client(),
1808
- key: 'context',
1809
- value,
1810
- text,
1811
- created: Date.now(),
1829
+ const _key = `_${key}`;
1830
+ const _keys = `_${key}s`;
1831
+ if (!value || !this[_keys][value]) return; // return if no matching value
1832
+ this[_key] = value;
1833
+ const lookup = this[_keys][value]; // set the local states lookup
1834
+ const text = extra ? `${lookup} ${extra}` : lookup; // set text from lookup with extra
1835
+ const data = { // build the data object
1836
+ id, // set the data id
1837
+ key, // set the key to state
1838
+ value, // set the value to the passed in value
1839
+ text, // set the text value of the data
1840
+ agent: this.agent(), // set the agent
1841
+ client: this.client(), // set the client
1842
+ created: Date.now(), // set the data created date.
1812
1843
  };
1813
-
1844
+
1814
1845
  data.md5 = this.hash(data, 'md5');
1815
1846
  data.sha256 = this.hash(data, 'sha256');
1816
1847
  data.sha512 = this.hash(data, 'sha512');
1817
-
1818
- this.talk(this._events.context, data);
1848
+
1849
+ this.talk(this._events[key], data); // broadcast the state event
1819
1850
  return data;
1820
- } catch (e) {
1821
- this.state('catch', `context:${value}:${id.uid}`);
1822
- return this.err(e, value);
1851
+ } catch (e) { // catch any errors
1852
+ return this.err(e); // return if an error happens
1823
1853
  }
1824
1854
  }
1825
-
1826
- contexts() {
1827
- if (!this._active) return this._messages.offline; // check the active status
1828
- const id = this.uid();
1829
- const key = 'contexts';
1830
- this.action(key, id.uid);
1831
-
1855
+
1856
+ /**************
1857
+ func: _workflowItems
1858
+ params: none
1859
+ describe: returns the available workflow items for a given key.
1860
+ ***************/
1861
+ _workflowItems(key) {
1862
+ if (!this._active) return this._messages.offline;
1863
+ const id = this.uid(); // set the current uid
1864
+ this.action(key, id.uid); // set the action to the passed key
1865
+ const value = this[_key]; // get the _keys value
1866
+ // set the data packet for the states
1832
1867
  this.state('data', `${key}:${id.uid}`);
1833
1868
  const data = {
1834
1869
  id,
1835
1870
  key,
1836
- value: this.vars.context || false,
1871
+ value,
1837
1872
  agent: this.agent(),
1838
1873
  client: this.client(),
1839
1874
  created: Date.now(),
1840
- };
1841
-
1875
+ }
1876
+
1842
1877
  this.action('hash', `${data.key}:md5:${data.id.uid}`);
1843
1878
  data.md5 = this.hash(data, 'md5');
1844
1879
  this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1845
1880
  data.sha256 = this.hash(data, 'sha256');
1846
1881
  this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1847
1882
  data.sha512 = this.hash(data, 'sha512');
1848
-
1849
- this.state('return', `${data.key}:${id.uid}`);
1883
+
1884
+ this.action('return', `${data.key}:${id.uid}`);
1850
1885
  return data;
1851
1886
  }
1852
1887
 
@@ -2135,6 +2170,7 @@ class Deva {
2135
2170
  this.zone('load', key);
2136
2171
  this.action('load', key);
2137
2172
  this.state('load', key);
2173
+ this.intent('good', `load:${key}`);
2138
2174
  return this.devas[key].init(client);
2139
2175
  }
2140
2176
 
@@ -2158,9 +2194,11 @@ class Deva {
2158
2194
  this.talk(this._events.unload, key);
2159
2195
  });
2160
2196
  this.action('resolve', `unload:${key}`);
2197
+ this.intent('good', `unload:${key}`);
2161
2198
  return resolve(`${this._messages.unload}:${key}`);
2162
2199
  } catch (e) {
2163
2200
  this.state('catch', `unload:${key}`);
2201
+ this.intent('bad', `unload:${key}`);
2164
2202
  return this.err(e, this.devas[key], reject)
2165
2203
  }
2166
2204
  });
@@ -2231,6 +2269,7 @@ class Deva {
2231
2269
  data.sha512 = this.hash(data, 'sha512');
2232
2270
 
2233
2271
  this.action('return', `core:${id.uid}`);
2272
+ this.intent('good', `core:${id.uid}`);
2234
2273
  return data;
2235
2274
  }
2236
2275
 
@@ -2274,7 +2313,8 @@ class Deva {
2274
2313
  data.sha256 = this.hash(data, 'sha256');
2275
2314
  data.sha512 = this.hash(data, 'sha512');
2276
2315
 
2277
- this.state('return', `info:${id.uid}`);
2316
+ this.action('return', `info:${id.uid}`);
2317
+ this.intent('good', `info:${id.uid}`);
2278
2318
  return data;
2279
2319
  }
2280
2320
 
@@ -2298,7 +2338,8 @@ class Deva {
2298
2338
  // format the date since active for output.
2299
2339
  const dateFormat = this.lib.formatDate(this._active, 'long', true);
2300
2340
  // create the text msg string
2301
- this.state('return', `status:${id.uid}`);
2341
+ this.action('return', `status:${id.uid}`);
2342
+ this.intent('good', `status:${id.uid}`);
2302
2343
  return `${this._agent.profile.name} active since ${dateFormat}`; // return final text string
2303
2344
  }
2304
2345
 
@@ -2324,6 +2365,7 @@ class Deva {
2324
2365
  this.action(key, id.uid);
2325
2366
  this.state(key, id.uid);
2326
2367
  this.context(key, id.uid);
2368
+
2327
2369
  const params = msg.split(' '); // split the msg into an array by spaces.
2328
2370
 
2329
2371
  const splitText = params[0].split(':');
@@ -2355,10 +2397,12 @@ class Deva {
2355
2397
  }
2356
2398
  catch(e) {
2357
2399
  this.state('catch', `${key}:${id.uid}`);
2400
+ this.intent('bad', `${key}:${id.uid}`);
2358
2401
  return this.err(e, msg, reject);
2359
2402
  }
2360
2403
  finally {
2361
- this.action('resolve', `help:${id.uid}`);
2404
+ this.action('resolve', `${key}:${id.uid}`);
2405
+ this.intent('good', `${key}:${id.uid}`);
2362
2406
  return resolve(helpDoc);
2363
2407
  }
2364
2408
  });
@@ -2377,6 +2421,7 @@ class Deva {
2377
2421
  err(err,packet,reject=false) {
2378
2422
  const id = this.uid();
2379
2423
  const key = 'error';
2424
+ this.intent('bad', `${key}:${id.uid}`);
2380
2425
  this.context(key, id.uid);
2381
2426
  this.feature(key, id.uid);
2382
2427
  this.zone(key, id.uid);
@@ -2421,11 +2466,13 @@ class Deva {
2421
2466
  if (hasOnError) {
2422
2467
  this.action('onfunc', `hasOnError:${data.value}:${data.id.uid}`);
2423
2468
  this.state('onfunc', `hasOnError:${data.value}:${data.id.uid}`);
2469
+ this.intent('bad', `hasOnError:${data.id.uid}`);
2424
2470
  return this.onError(err, packet, reject);
2425
2471
  }
2426
2472
  // else block handled the reject if there is no onError function.
2427
2473
  else {
2428
2474
  this.action('reject', `${data.value}:${id.uid}`);
2475
+ this.intent('bad', `error:${data.id.uid}`);
2429
2476
  return reject ? reject(err) : Promise.reject(err);
2430
2477
  }
2431
2478
  }
@@ -2481,6 +2528,7 @@ class Deva {
2481
2528
  data.md5 = this.hash(data, 'md5'); // md5 the uid and created.
2482
2529
  data.sha256 = this.hash(data, 'sha256'); // sha256 the uid, created, md5
2483
2530
  data.sha512 = this.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
2531
+ // this.intent('good', `uid:${data.uid}`);
2484
2532
  return data; // return the complete uid data.
2485
2533
  }
2486
2534
 
@@ -2540,14 +2588,22 @@ class Deva {
2540
2588
  data.md5 = this.hash(data, 'md5'); // hash data packet into md5 and inert into data.
2541
2589
  data.sha256 = this.hash(data, 'sha256'); // hash data into sha 256 then set in data.
2542
2590
  data.sha512 = this.hash(data, 'sha512'); // hash data into sha 512 then set in data.
2591
+ this.intent('good', `sign:${data.id.uid}`);
2543
2592
  return data;
2544
2593
  }
2545
2594
 
2546
2595
  license_check(personalVLA, packageVLA) {
2596
+ const id = this.uid();
2547
2597
  this.state('license', `check:personalVLA:${packageVLA.uid}`);
2548
- if (!personalVLA) return false;
2598
+ if (!personalVLA) {
2599
+ this.intent('bad', `personalVLA:${id.uid}`);
2600
+ return false
2601
+ };
2549
2602
  this.state('license', `check:packageVLA:${packageVLA.uid}`);
2550
- if (!packageVLA) return false;
2603
+ if (!packageVLA) {
2604
+ this.intent('bad', `packageVLA:${id.uid}`);
2605
+ return false;
2606
+ }
2551
2607
 
2552
2608
  // this is to ensure no additional information is being transmitted.
2553
2609
  this.state('license', `compare:sha256:${packageVLA.uid}`);
@@ -2555,7 +2611,6 @@ class Deva {
2555
2611
  const packageVLA_hash = this.hash(packageVLA, 'sha256');
2556
2612
 
2557
2613
  if (personalVLA_hash !== packageVLA_hash) return false;
2558
-
2559
2614
 
2560
2615
  const approved = {
2561
2616
  id: this.uid(),
@@ -2568,6 +2623,7 @@ class Deva {
2568
2623
  approved.sha512 = this.hash(approved, 'sha512');
2569
2624
 
2570
2625
  this.state('return', `license:${packageVLA.uid}`);
2626
+ this.intent('good', `license:${packageVLA.uid}`);
2571
2627
  return approved;
2572
2628
  }
2573
2629
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "44091450722329207445",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.6.103",
4
+ "version": "1.7.1",
5
5
  "description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
6
6
  "main": "index.js",
7
7
  "license": "VLA:44091450722329207445 LICENSE.md",
package/tests/index.js CHANGED
@@ -49,6 +49,9 @@ const DevaTest = new Deva({
49
49
  return input.trim();
50
50
  }
51
51
  },
52
+ config: {
53
+ hash: {}
54
+ },
52
55
  vars: agent.vars,
53
56
  listeners: {
54
57
  'devacore:prompt'(packet) {
@@ -82,8 +85,8 @@ const DevaTest = new Deva({
82
85
  'devacore:ask'(packet) {
83
86
  console.log(`🀝 ask: ${packet.text}`);
84
87
  },
85
- 'devacore:state'(packet) {
86
- console.log(`πŸͺ state: ${packet.text}`);
88
+ 'devacore:feature'(packet) {
89
+ console.log(`\n🍿 feature: ${packet.text}`);
87
90
  },
88
91
  'devacore:zone'(packet) {
89
92
  console.log(`πŸ—ΊοΈ zone: ${packet.text}`);
@@ -91,8 +94,14 @@ const DevaTest = new Deva({
91
94
  'devacore:action'(packet) {
92
95
  console.log(`πŸ’₯ action: ${packet.text}`);
93
96
  },
94
- 'devacore:feature'(packet) {
95
- console.log(`\n🍿 feature: ${packet.text}`);
97
+ 'devacore:state'(packet) {
98
+ console.log(`πŸͺ state: ${packet.text}`);
99
+ },
100
+ 'devacore:intent'(packet) {
101
+ console.log(`🫸 intent: ${packet.text}`);
102
+ },
103
+ 'devacore:belief'(packet) {
104
+ console.log(`🧠 belief: ${packet.text}`);
96
105
  },
97
106
  'devacore:context'(packet) {
98
107
  console.log(`πŸ›Ή context: ${packet.text}`);
@@ -169,17 +178,22 @@ const DevaTest = new Deva({
169
178
  },
170
179
  },
171
180
  onInit(data, resolve) {
181
+ this.belief('vedic', `${data.id.uid}`);
172
182
  return this.start(data, resolve);
173
183
  },
174
184
  onStart(data, resolve) {
175
185
  return this.enter(data, resolve);
176
186
  },
177
187
  onEnter(data, resolve) {
188
+ return this.done(data, resolve);
189
+ },
190
+ onDone(data, resolve) {
178
191
  return this.ready(data, resolve);
179
192
  },
180
193
  onReady(data, resolve) {
181
194
  const test = this.methods.test(data);
182
195
  this.prompt(this._messages.ready);
196
+ this.intent('good', `tests:ready`);
183
197
  return resolve(data);
184
198
  },
185
199
  onComplete(data, resolve) {