@indra.ai/deva 1.6.103 β†’ 1.7.2

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
  }
@@ -1055,13 +1164,19 @@ class Deva {
1055
1164
  return this.Done(resolve, reject);
1056
1165
  }).then(() => {
1057
1166
  const hasOnInit = this.onInit && typeof this.onInit === 'function';
1167
+ this.belief('vedic', `init:${data.id.uid}`);
1058
1168
  if (hasOnInit) {
1059
1169
  this.action('onfunc', `hasOnInit:${data.id.uid}`); // state set to watch onInit
1060
1170
  this.state('onfunc', `hasOnInit:${data.id.uid}`); // state set to watch onInit
1171
+ this.intent('good', `onInit:${data.id.uid}`); // state set to watch onInit
1172
+ this.action('return', `onInit:${data.id.uid}`);
1173
+ return this.onInit(data, resolve);
1061
1174
  }
1175
+ this.intent('good', `init:${data.id.uid}`); // state set to watch onInit
1062
1176
  this.action('return', `init:${data.id.uid}`);
1063
- return hasOnInit ? this.onInit(data, resolve) : this.start(data, resolve);
1177
+ return this.start(data, resolve);
1064
1178
  }).catch(err => {
1179
+ this.intent('bad', `init:${data.id.uid}`); // state set to watch onInit
1065
1180
  this.state('catch', `init:${data.id.uid}`);
1066
1181
  return this.err(err, client, reject);
1067
1182
  });
@@ -1110,10 +1225,14 @@ class Deva {
1110
1225
  if (hasOnStart) {
1111
1226
  this.action('onfunc', `hasOnStart:${data.id.uid}`); // set action to onfunc
1112
1227
  this.state('onfunc', `hasOnStart:${data.id.uid}`); // set state to onfunc
1228
+ this.intent('good', `onStart:${data.id.uid}`); // set the good intent
1229
+ this.action('return', `onStart:${data.id.uid}`); // return action finish
1230
+ return this.onStart(data, resolve)
1113
1231
  }
1114
-
1232
+
1233
+ this.intent('good', `start:${data.id.uid}`); // set the good intent
1115
1234
  this.action('return', `start:${data.id.uid}`); // return action finish
1116
- return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
1235
+ return this.enter(data, resolve)
1117
1236
  }
1118
1237
 
1119
1238
  /**************
@@ -1158,10 +1277,14 @@ class Deva {
1158
1277
  if (hasOnEnter) {
1159
1278
  this.action('onfunc', `hasOnEnter:${data.id.uid}`); // action onfunc set
1160
1279
  this.state('onfunc', `hasOnEnter:${data.id.uid}`); // state onfunc set
1280
+ this.intent('good', `onEnter:${data.id.uid}`); // set good intent on enter
1281
+ this.action('return', `onEnter:${data.id.uid}`); // set return actions
1282
+ return this.onEnter(data, resolve); // set return on enter.
1161
1283
  }
1162
1284
 
1285
+ this.intent('good', `enter:${data.id.uid}`); // set good intent enter
1163
1286
  this.action('return', `enter:${data.id.uid}`); // return action finish
1164
- return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
1287
+ return this.done(data, resolve)
1165
1288
  }
1166
1289
 
1167
1290
  /**************
@@ -1206,10 +1329,14 @@ class Deva {
1206
1329
  if (hasOnDone) {
1207
1330
  this.action('onfunc', `hasOnDone:${data.id.uid}`); // state onfunc
1208
1331
  this.state('onfunc', `hasOnDone:${data.id.uid}`); // state onfunc
1332
+ this.intent('good', `onDone:${data.id.uid}`); // set the onDone intent
1333
+ this.action('return', `onDone:${data.id.uid}`); // set the return action
1334
+ return this.onDone(data, resolve);
1209
1335
  }
1210
1336
 
1337
+ this.intent('good', `done:${data.id.uid}`); // set done intent
1211
1338
  this.action('return', `done:${data.id.uid}`); // return action finish
1212
- return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
1339
+ return this.ready(data, resolve);
1213
1340
  }
1214
1341
 
1215
1342
  /**************
@@ -1266,10 +1393,14 @@ class Deva {
1266
1393
  if (hasOnReady) {
1267
1394
  this.action('onfunc', `hasOnReady:${data.id.uid}`); // action onfunc
1268
1395
  this.state('onfunc', `hasOnReady:${data.id.uid}`); // state onfunc
1396
+ this.intent('good', `onReady:${data.id.uis}`); // set ready intent
1397
+ this.action('return', `onReady:${data.id.uid}`); // set action onReady return
1398
+ return this.onReady(data, resolve);
1269
1399
  }
1270
1400
 
1401
+ this.intent('good', `ready:${data.id.uid}`); // set read intent good
1271
1402
  this.action('resolve', `ready:${data.id.uid}`); // return action ready
1272
- return hasOnReady ? this.onReady(data, resolve) : resolve(data);
1403
+ return resolve(data);
1273
1404
  }
1274
1405
 
1275
1406
  /**************
@@ -1503,75 +1634,92 @@ class Deva {
1503
1634
 
1504
1635
  ////////////////////////////
1505
1636
 
1637
+
1506
1638
  /**************
1507
- func: state
1639
+ func: context
1508
1640
  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.
1641
+ - value: The context flag to set for the Deva that matches to this._contexts
1642
+ - extra: Any extra text that is sent with the context value.
1643
+ describe
1511
1644
  ***************/
1512
- state(value=false, extra=false) {
1513
- if (!this._active) return this._messages.offline;
1645
+ context(value=false, extra=false) {
1646
+ if (!this._active) return this._messages.offline; // check the active status
1514
1647
  const id = this.uid();
1515
- const key = 'state';
1516
1648
  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.
1649
+ if (!value) return;
1650
+ this._context = value;
1651
+ const lookup = this.vars.context[value] || value;
1652
+ const text = extra ? `${lookup} ${extra}` : lookup;
1653
+
1654
+ const data = {
1655
+ id,
1656
+ agent: this.agent(),
1657
+ client: this.client(),
1658
+ key: 'context',
1659
+ value,
1660
+ text,
1661
+ created: Date.now(),
1529
1662
  };
1530
-
1663
+
1531
1664
  data.md5 = this.hash(data, 'md5');
1532
1665
  data.sha256 = this.hash(data, 'sha256');
1533
1666
  data.sha512 = this.hash(data, 'sha512');
1534
-
1535
- this.talk(this._events.state, data); // broadcast the state event
1667
+
1668
+ this.talk(this._events.context, data);
1536
1669
  return data;
1537
- } catch (e) { // catch any errors
1538
- return this.err(e); // return if an error happens
1670
+ } catch (e) {
1671
+ this.state('catch', `context:${value}:${id.uid}`);
1672
+ return this.err(e, value);
1539
1673
  }
1540
1674
  }
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';
1675
+
1676
+ contexts() {
1677
+ if (!this._active) return this._messages.offline; // check the active status
1678
+ const id = this.uid();
1679
+ const key = 'contexts';
1551
1680
  this.action(key, id.uid);
1552
-
1553
- // set the data packet for the states
1681
+
1554
1682
  this.state('data', `${key}:${id.uid}`);
1555
1683
  const data = {
1556
1684
  id,
1557
1685
  key,
1558
- value: this._states,
1686
+ value: this.vars.context || false,
1559
1687
  agent: this.agent(),
1560
1688
  client: this.client(),
1561
1689
  created: Date.now(),
1562
- }
1563
-
1690
+ };
1691
+
1564
1692
  this.action('hash', `${data.key}:md5:${data.id.uid}`);
1565
1693
  data.md5 = this.hash(data, 'md5');
1566
1694
  this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1567
1695
  data.sha256 = this.hash(data, 'sha256');
1568
1696
  this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1569
1697
  data.sha512 = this.hash(data, 'sha512');
1570
-
1571
- this.action('return', `${data.key}:${id.uid}`);
1698
+
1699
+ this.state('return', `${data.key}:${id.uid}`);
1572
1700
  return data;
1573
1701
  }
1574
1702
 
1703
+ /**************
1704
+ func: feature
1705
+ params:
1706
+ - value: The feature flag to set for the Deva that matches to this._features
1707
+ - extra: Any extra text to send with the feature value.
1708
+ describe
1709
+ ***************/
1710
+ feature(value=false, extra=false) {
1711
+ return this._workflow('feature', value, extra);
1712
+ }
1713
+
1714
+ /**************
1715
+ func: features
1716
+ params: none
1717
+ describe: return a list of features that are available to the system.
1718
+ ***************/
1719
+ features() {
1720
+ return this._workflowItems('features');
1721
+ }
1722
+
1575
1723
  /**************
1576
1724
  func: zone
1577
1725
  params:
@@ -1579,35 +1727,7 @@ class Deva {
1579
1727
  describe
1580
1728
  ***************/
1581
1729
  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
- }
1730
+ return this._workflow('zone', value, extra);
1611
1731
  }
1612
1732
 
1613
1733
  /**************
@@ -1616,30 +1736,7 @@ class Deva {
1616
1736
  describe: returns a listing of zones currently in the system.
1617
1737
  ***************/
1618
1738
  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
1739
+ return this._workflowItems('zones');
1643
1740
  }
1644
1741
 
1645
1742
  /**************
@@ -1650,39 +1747,7 @@ class Deva {
1650
1747
  describe
1651
1748
  ***************/
1652
1749
  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
- }
1750
+ return this._workflow('action', value, extra);
1686
1751
  }
1687
1752
 
1688
1753
  /**************
@@ -1691,162 +1756,133 @@ class Deva {
1691
1756
  describe: Returns a list of available actions in the system.
1692
1757
  ***************/
1693
1758
  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;
1759
+ this._workflowItems('actions');
1718
1760
  }
1719
1761
 
1720
1762
  /**************
1721
- func: feature
1763
+ func: state
1722
1764
  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
1765
+ - value: The state value to set for the Deva that matches to this._states
1766
+ - extra: any extra text to add to the state change.
1726
1767
  ***************/
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
- }
1768
+ state(value=false, extra=false) {
1769
+ return this._workflow('state', value, extra);
1770
+ }
1771
+
1772
+ /**************
1773
+ func: states
1774
+ params: none
1775
+ describe: returns the available states values.
1776
+ ***************/
1777
+ states() {
1778
+ return this._workflowItems('states');
1754
1779
  }
1755
1780
 
1756
1781
  /**************
1757
- func: features
1782
+ func: intent
1783
+ params:
1784
+ - value: The intent value to set for the Deva that matches to this._intents
1785
+ - extra: any extra text to add to the intent change.
1786
+ ***************/
1787
+ intent(value=false, extra=false) {
1788
+ return this._workflow('intent', value, extra);
1789
+ }
1790
+
1791
+ /**************
1792
+ func: intents
1758
1793
  params: none
1759
- describe: return a list of features that are available to the system.
1794
+ describe: returns the available intents values.
1760
1795
  ***************/
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
- };
1796
+ intents() {
1797
+ return this._workflowItems('intents');
1798
+ }
1776
1799
 
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;
1800
+ /**************
1801
+ func: belief
1802
+ params:
1803
+ - value: The belief value to set for the Deva that matches to this._beliefs
1804
+ - extra: any extra text to add to the belief change.
1805
+ ***************/
1806
+ belief(value=false, extra=false) {
1807
+ return this._workflow('belief', value, extra);
1808
+ }
1809
+
1810
+ /**************
1811
+ func: beliefs
1812
+ params: none
1813
+ describe: returns the available beliefs values.
1814
+ ***************/
1815
+ beliefs() {
1816
+ return this._workflowItems('intents');
1786
1817
  }
1787
1818
 
1788
1819
  /**************
1789
- func: context
1820
+ func: _workflow
1790
1821
  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
1822
+ - value: The workflow value to set for the Deva that matches to this._states
1823
+ - extra: any extra text to add to the state change.
1824
+ stages: Feature, Zone, Action, State, Intent
1794
1825
  ***************/
1795
- context(value=false, extra=false) {
1796
- if (!this._active) return this._messages.offline; // check the active status
1826
+ _workflow(key, value=false, extra=false) {
1827
+ if (!this._active) return this._messages.offline;
1797
1828
  const id = this.uid();
1798
1829
  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(),
1830
+ const _key = `_${key}`;
1831
+ const _keys = `_${key}s`;
1832
+ if (!value || !this[_keys][value]) return; // return if no matching value
1833
+ this[_key] = value;
1834
+ const lookup = this[_keys][value]; // set the local states lookup
1835
+ const text = extra ? `${lookup} ${extra}` : lookup; // set text from lookup with extra
1836
+ const data = { // build the data object
1837
+ id, // set the data id
1838
+ key, // set the key to state
1839
+ value, // set the value to the passed in value
1840
+ text, // set the text value of the data
1841
+ agent: this.agent(), // set the agent
1842
+ client: this.client(), // set the client
1843
+ created: Date.now(), // set the data created date.
1812
1844
  };
1813
-
1845
+
1814
1846
  data.md5 = this.hash(data, 'md5');
1815
1847
  data.sha256 = this.hash(data, 'sha256');
1816
1848
  data.sha512 = this.hash(data, 'sha512');
1817
-
1818
- this.talk(this._events.context, data);
1849
+
1850
+ this.talk(this._events[key], data); // broadcast the state event
1819
1851
  return data;
1820
- } catch (e) {
1821
- this.state('catch', `context:${value}:${id.uid}`);
1822
- return this.err(e, value);
1852
+ } catch (e) { // catch any errors
1853
+ return this.err(e); // return if an error happens
1823
1854
  }
1824
1855
  }
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
-
1856
+
1857
+ /**************
1858
+ func: _workflowItems
1859
+ params: none
1860
+ describe: returns the available workflow items for a given key.
1861
+ ***************/
1862
+ _workflowItems(key) {
1863
+ if (!this._active) return this._messages.offline;
1864
+ const id = this.uid(); // set the current uid
1865
+ this.action(key, id.uid); // set the action to the passed key
1866
+ const value = this[_key]; // get the _keys value
1867
+ // set the data packet for the states
1832
1868
  this.state('data', `${key}:${id.uid}`);
1833
1869
  const data = {
1834
1870
  id,
1835
1871
  key,
1836
- value: this.vars.context || false,
1872
+ value,
1837
1873
  agent: this.agent(),
1838
1874
  client: this.client(),
1839
1875
  created: Date.now(),
1840
- };
1841
-
1876
+ }
1877
+
1842
1878
  this.action('hash', `${data.key}:md5:${data.id.uid}`);
1843
1879
  data.md5 = this.hash(data, 'md5');
1844
1880
  this.action('hash', `${data.key}:sha256:${data.id.uid}`);
1845
1881
  data.sha256 = this.hash(data, 'sha256');
1846
1882
  this.action('hash', `${data.key}:sha512:${data.id.uid}`);
1847
1883
  data.sha512 = this.hash(data, 'sha512');
1848
-
1849
- this.state('return', `${data.key}:${id.uid}`);
1884
+
1885
+ this.action('return', `${data.key}:${id.uid}`);
1850
1886
  return data;
1851
1887
  }
1852
1888
 
@@ -2135,6 +2171,7 @@ class Deva {
2135
2171
  this.zone('load', key);
2136
2172
  this.action('load', key);
2137
2173
  this.state('load', key);
2174
+ this.intent('good', `load:${key}`);
2138
2175
  return this.devas[key].init(client);
2139
2176
  }
2140
2177
 
@@ -2158,9 +2195,11 @@ class Deva {
2158
2195
  this.talk(this._events.unload, key);
2159
2196
  });
2160
2197
  this.action('resolve', `unload:${key}`);
2198
+ this.intent('good', `unload:${key}`);
2161
2199
  return resolve(`${this._messages.unload}:${key}`);
2162
2200
  } catch (e) {
2163
2201
  this.state('catch', `unload:${key}`);
2202
+ this.intent('bad', `unload:${key}`);
2164
2203
  return this.err(e, this.devas[key], reject)
2165
2204
  }
2166
2205
  });
@@ -2231,6 +2270,7 @@ class Deva {
2231
2270
  data.sha512 = this.hash(data, 'sha512');
2232
2271
 
2233
2272
  this.action('return', `core:${id.uid}`);
2273
+ this.intent('good', `core:${id.uid}`);
2234
2274
  return data;
2235
2275
  }
2236
2276
 
@@ -2274,7 +2314,8 @@ class Deva {
2274
2314
  data.sha256 = this.hash(data, 'sha256');
2275
2315
  data.sha512 = this.hash(data, 'sha512');
2276
2316
 
2277
- this.state('return', `info:${id.uid}`);
2317
+ this.action('return', `info:${id.uid}`);
2318
+ this.intent('good', `info:${id.uid}`);
2278
2319
  return data;
2279
2320
  }
2280
2321
 
@@ -2298,7 +2339,8 @@ class Deva {
2298
2339
  // format the date since active for output.
2299
2340
  const dateFormat = this.lib.formatDate(this._active, 'long', true);
2300
2341
  // create the text msg string
2301
- this.state('return', `status:${id.uid}`);
2342
+ this.action('return', `status:${id.uid}`);
2343
+ this.intent('good', `status:${id.uid}`);
2302
2344
  return `${this._agent.profile.name} active since ${dateFormat}`; // return final text string
2303
2345
  }
2304
2346
 
@@ -2324,6 +2366,7 @@ class Deva {
2324
2366
  this.action(key, id.uid);
2325
2367
  this.state(key, id.uid);
2326
2368
  this.context(key, id.uid);
2369
+
2327
2370
  const params = msg.split(' '); // split the msg into an array by spaces.
2328
2371
 
2329
2372
  const splitText = params[0].split(':');
@@ -2355,10 +2398,12 @@ class Deva {
2355
2398
  }
2356
2399
  catch(e) {
2357
2400
  this.state('catch', `${key}:${id.uid}`);
2401
+ this.intent('bad', `${key}:${id.uid}`);
2358
2402
  return this.err(e, msg, reject);
2359
2403
  }
2360
2404
  finally {
2361
- this.action('resolve', `help:${id.uid}`);
2405
+ this.action('resolve', `${key}:${id.uid}`);
2406
+ this.intent('good', `${key}:${id.uid}`);
2362
2407
  return resolve(helpDoc);
2363
2408
  }
2364
2409
  });
@@ -2377,6 +2422,7 @@ class Deva {
2377
2422
  err(err,packet,reject=false) {
2378
2423
  const id = this.uid();
2379
2424
  const key = 'error';
2425
+ this.intent('bad', `${key}:${id.uid}`);
2380
2426
  this.context(key, id.uid);
2381
2427
  this.feature(key, id.uid);
2382
2428
  this.zone(key, id.uid);
@@ -2421,11 +2467,13 @@ class Deva {
2421
2467
  if (hasOnError) {
2422
2468
  this.action('onfunc', `hasOnError:${data.value}:${data.id.uid}`);
2423
2469
  this.state('onfunc', `hasOnError:${data.value}:${data.id.uid}`);
2470
+ this.intent('bad', `hasOnError:${data.id.uid}`);
2424
2471
  return this.onError(err, packet, reject);
2425
2472
  }
2426
2473
  // else block handled the reject if there is no onError function.
2427
2474
  else {
2428
2475
  this.action('reject', `${data.value}:${id.uid}`);
2476
+ this.intent('bad', `error:${data.id.uid}`);
2429
2477
  return reject ? reject(err) : Promise.reject(err);
2430
2478
  }
2431
2479
  }
@@ -2481,6 +2529,7 @@ class Deva {
2481
2529
  data.md5 = this.hash(data, 'md5'); // md5 the uid and created.
2482
2530
  data.sha256 = this.hash(data, 'sha256'); // sha256 the uid, created, md5
2483
2531
  data.sha512 = this.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
2532
+ // this.intent('good', `uid:${data.uid}`);
2484
2533
  return data; // return the complete uid data.
2485
2534
  }
2486
2535
 
@@ -2540,14 +2589,22 @@ class Deva {
2540
2589
  data.md5 = this.hash(data, 'md5'); // hash data packet into md5 and inert into data.
2541
2590
  data.sha256 = this.hash(data, 'sha256'); // hash data into sha 256 then set in data.
2542
2591
  data.sha512 = this.hash(data, 'sha512'); // hash data into sha 512 then set in data.
2592
+ this.intent('good', `sign:${data.id.uid}`);
2543
2593
  return data;
2544
2594
  }
2545
2595
 
2546
2596
  license_check(personalVLA, packageVLA) {
2597
+ const id = this.uid();
2547
2598
  this.state('license', `check:personalVLA:${packageVLA.uid}`);
2548
- if (!personalVLA) return false;
2599
+ if (!personalVLA) {
2600
+ this.intent('bad', `personalVLA:${id.uid}`);
2601
+ return false
2602
+ };
2549
2603
  this.state('license', `check:packageVLA:${packageVLA.uid}`);
2550
- if (!packageVLA) return false;
2604
+ if (!packageVLA) {
2605
+ this.intent('bad', `packageVLA:${id.uid}`);
2606
+ return false;
2607
+ }
2551
2608
 
2552
2609
  // this is to ensure no additional information is being transmitted.
2553
2610
  this.state('license', `compare:sha256:${packageVLA.uid}`);
@@ -2555,7 +2612,6 @@ class Deva {
2555
2612
  const packageVLA_hash = this.hash(packageVLA, 'sha256');
2556
2613
 
2557
2614
  if (personalVLA_hash !== packageVLA_hash) return false;
2558
-
2559
2615
 
2560
2616
  const approved = {
2561
2617
  id: this.uid(),
@@ -2568,6 +2624,7 @@ class Deva {
2568
2624
  approved.sha512 = this.hash(approved, 'sha512');
2569
2625
 
2570
2626
  this.state('return', `license:${packageVLA.uid}`);
2627
+ this.intent('good', `license:${packageVLA.uid}`);
2571
2628
  return approved;
2572
2629
  }
2573
2630
 
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.2",
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}`);
@@ -175,11 +184,15 @@ const DevaTest = new Deva({
175
184
  return this.enter(data, resolve);
176
185
  },
177
186
  onEnter(data, resolve) {
187
+ return this.done(data, resolve);
188
+ },
189
+ onDone(data, resolve) {
178
190
  return this.ready(data, resolve);
179
191
  },
180
192
  onReady(data, resolve) {
181
193
  const test = this.methods.test(data);
182
194
  this.prompt(this._messages.ready);
195
+ this.intent('good', `tests:ready`);
183
196
  return resolve(data);
184
197
  },
185
198
  onComplete(data, resolve) {