@indra.ai/deva 1.5.42 → 1.5.43

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.
Files changed (2) hide show
  1. package/index.js +149 -65
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -181,7 +181,7 @@ class Deva {
181
181
  };
182
182
  packet.a.hash = this.lib.hash(packet.a);
183
183
  delete packet.hash;
184
- packet.hash = this.lib.hash(packet);
184
+ packet.md5 = this.lib.hash(packet);
185
185
  packet.sha256 = this.lib.hash(packet, 'sha256');
186
186
  packet.sha512 = this.lib.hash(packet, 'sha512');
187
187
 
@@ -531,7 +531,9 @@ class Deva {
531
531
  }
532
532
 
533
533
  // hash the question
534
- packet.q.meta.hash = this.lib.hash(packet.q);
534
+ packet.q.md5 = this.lib.hash(packet.q);
535
+ packet.q.sha256 = this.lib.hash(packet.q, 'sha256');
536
+ packet.q.sha512 = this.lib.hash(packet.q, 'sha512');
535
537
 
536
538
  this.talk(config.events.question, this.lib.copy(packet)); // global question event make sure to copy data.
537
539
 
@@ -605,7 +607,10 @@ class Deva {
605
607
  created: Date.now(), // set the created date for the answer
606
608
  };
607
609
  // create a hash for the answer and insert into answer meta.
608
- packet_answer.meta.hash = this.lib.hash(packet_answer);
610
+ packet_answer.md5 = this.lib.hash(packet_answer);
611
+ packet_answer.sha256 = this.lib.hash(packet_answer, 'sha256');
612
+ packet_answer.sha512 = this.lib.hash(packet_answer, 'sha512');
613
+
609
614
  packet.a = packet_answer; // set the packet.a to the packet_answer
610
615
  this.talk(config.events.answer, this.lib.copy(packet)); // global talk event
611
616
 
@@ -679,7 +684,10 @@ class Deva {
679
684
  packet_answer.text = result;
680
685
  }
681
686
 
682
- packet_answer.meta.hash = this.lib.hash(packet_answer);
687
+ packet_answer.md5 = this.lib.hash(packet_answer);
688
+ packet_answer.sha256 = this.lib.hash(packet_answer, 'sha256');
689
+ packet_answer.sha512 = this.lib.hash(packet_answer, 'sha512');
690
+
683
691
  packet.a = packet_answer;
684
692
  this.talk(config.events.answer, this.lib.copy(packet)); // global talk event
685
693
  this.talk(`${agent.key}:ask:${packet.id}`, packet);
@@ -727,7 +735,7 @@ class Deva {
727
735
  text: this._messages.init,
728
736
  created: Date.now(),
729
737
  }
730
- data.hash = this.lib.hash(data);
738
+ data.md5 = this.lib.hash(data);
731
739
  data.sha256 = this.lib.hash(data, 'sha256');
732
740
  data.sha512 = this.lib.hash(data, 'sha512');
733
741
 
@@ -792,12 +800,17 @@ class Deva {
792
800
 
793
801
  this.action('start', data.id);
794
802
  const id = this.lib.uid();
795
- delete data.hash;
803
+
804
+ delete data.md5;
805
+ delete data.sha256;
806
+ delete data.sha512;
807
+
796
808
  data.value = 'start';
797
- data.hash = this.lib.hash(data);
809
+
810
+ data.md5 = this.lib.hash(data);
798
811
  data.sha256 = this.lib.hash(data, 'sha256');
799
812
  data.sha512 = this.lib.hash(data, 'sha512');
800
-
813
+
801
814
  const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
802
815
 
803
816
  this.state('start', data.id);
@@ -821,12 +834,17 @@ class Deva {
821
834
 
822
835
  this.action('enter', data.id);
823
836
  const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
824
- delete data.hash;
837
+
838
+ delete data.md5;
839
+ delete data.sha256;
840
+ delete data.sha512;
841
+
825
842
  data.value = 'enter';
826
- data.hash = this.lib.hash(data);
843
+
844
+ data.md5 = this.lib.hash(data);
827
845
  data.sha256 = this.lib.hash(data, 'sha256');
828
846
  data.sha512 = this.lib.hash(data, 'sha512');
829
-
847
+
830
848
  this.state('enter', data.id);
831
849
  return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
832
850
  }
@@ -848,12 +866,17 @@ class Deva {
848
866
 
849
867
  this.action('done', data.id);
850
868
  const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
851
- delete data.hash;
869
+
870
+ delete data.md5;
871
+ delete data.sha256;
872
+ delete data.sha512;
873
+
852
874
  data.value = 'done';
853
- data.hash = this.lib.hash(data);
875
+
876
+ data.md5 = this.lib.hash(data);
854
877
  data.sha256 = this.lib.hash(data, 'sha256');
855
878
  data.sha512 = this.lib.hash(data, 'sha512');
856
-
879
+
857
880
  this.state('done', data.id);
858
881
  return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
859
882
  }
@@ -872,12 +895,17 @@ class Deva {
872
895
 
873
896
  this.action('ready', data.id);
874
897
  const hasOnReady = this.onReady && typeof this.onReady === 'function';
875
- delete data.hash;
898
+
899
+ delete data.md5;
900
+ delete data.sha256;
901
+ delete data.sha512;
902
+
876
903
  data.value = 'ready';
877
- data.hash = this.lib.hash(data);// hash the entire data before completeing.
904
+
905
+ data.md5 = this.lib.hash(data);
878
906
  data.sha256 = this.lib.hash(data, 'sha256');
879
907
  data.sha512 = this.lib.hash(data, 'sha512');
880
-
908
+
881
909
  this.state('ready', data.id);
882
910
  return hasOnReady ? this.onReady(data, resolve) : resolve(data);
883
911
  }
@@ -892,20 +920,25 @@ class Deva {
892
920
  describe: This function is used to relay into the finish state when resolving a question or data.
893
921
  usage: this.finish(data, resolve)
894
922
  ***************/
895
- finish(packet, resolve) {
896
- this.zone('finish', packet.id); // enter finish zone
923
+ finish(data, resolve) {
924
+ this.zone('finish', data.id); // enter finish zone
897
925
  if (!this._active) return resolve(this._messages.offline); //
898
926
 
899
- this.action('finish', packet.id); // start finish action
927
+ this.action('finish', data.id); // start finish action
900
928
  const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
901
- delete packet.hash; // delete packet hash to update for finish time
902
- packet.finish = Date.now(); // set the finish timestamp
903
- packet.hash = this.lib.hash(packet); // rehash the packet;
904
- packet.sha256 = this.lib.hash(packet, 'sha256');
905
- packet.sha512 = this.lib.hash(packet, 'sha512');
906
929
 
907
- this.state('finish', packet.id); // set finish state
908
- return hasOnFinish ? this.onFinish(packet, resolve) : this.complete(packet, resolve);
930
+ delete data.md5;
931
+ delete data.sha256;
932
+ delete data.sha512;
933
+
934
+ data.finish = Date.now(); // set the finish timestamp
935
+
936
+ data.md5 = this.lib.hash(data);
937
+ data.sha256 = this.lib.hash(data, 'sha256');
938
+ data.sha512 = this.lib.hash(data, 'sha512');
939
+
940
+ this.state('finish', data.id); // set finish state
941
+ return hasOnFinish ? this.onFinish(data, resolve) : this.complete(data, resolve);
909
942
  }
910
943
 
911
944
  /**************
@@ -917,20 +950,24 @@ class Deva {
917
950
  resolving a question or data.
918
951
  usage: this.complete(data, resolve)
919
952
  ***************/
920
- complete(packet, resolve) {
921
- this.zone('complete', packet.id);
953
+ complete(data, resolve) {
954
+ this.zone('complete', data.id);
922
955
  if (!this._active) return Promise.resolve(this._messages.offline);
923
956
 
924
- this.action('complete', packet.id);
957
+ this.action('complete', data.id);
925
958
  const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
926
- delete packet.hash;
927
- packet.complete = Date.now();// set the complete date on the whole packet.
928
- packet.hash = this.lib.hash(packet);// hash the entire packet before complete.
929
- packet.sha256 = this.lib.hash(packet, 'sha256');
930
- packet.sha512 = this.lib.hash(packet, 'sha512');
931
959
 
932
- this.state('complete', packet.id);
933
- return hasOnComplete ? this.onComplete(packet, resolve) : resolve(packet);
960
+ delete data.md5;
961
+ delete data.sha256;
962
+ delete data.sha512;
963
+
964
+ data.complete = Date.now();// set the complete date on the whole data.
965
+ data.md5 = this.lib.hash(data);
966
+ data.sha256 = this.lib.hash(data, 'sha256');
967
+ data.sha512 = this.lib.hash(data, 'sha512');
968
+
969
+ this.state('complete', data.id);
970
+ return hasOnComplete ? this.onComplete(data, resolve) : resolve(data);
934
971
  }
935
972
 
936
973
  /**************
@@ -962,7 +999,8 @@ class Deva {
962
999
  client: this.client(), // set the client
963
1000
  created: Date.now(), // set the created date
964
1001
  }
965
- data.hash = this.lib.hash(data);
1002
+
1003
+ data.md5 = this.lib.hash(data);
966
1004
  data.sha256 = this.lib.hash(data, 'sha256');
967
1005
  data.sha512 = this.lib.hash(data, 'sha512');
968
1006
 
@@ -998,7 +1036,10 @@ class Deva {
998
1036
  client: this.client(),
999
1037
  created: Date.now(),
1000
1038
  }
1001
- data.hash = this.lib.hash(data); // set data hash
1039
+
1040
+ data.md5 = this.lib.hash(data);
1041
+ data.sha256 = this.lib.hash(data, 'sha256');
1042
+ data.sha512 = this.lib.hash(data, 'sha512');
1002
1043
 
1003
1044
  this.state('exit', id); // set the state to stop
1004
1045
  // clear memory
@@ -1039,9 +1080,11 @@ class Deva {
1039
1080
  text, // set the text value of the data
1040
1081
  created: Date.now(), // set the data created date.
1041
1082
  };
1042
- data.hash = this.lib.hash(data); // hash the data
1083
+
1084
+ data.md5 = this.lib.hash(data);
1043
1085
  data.sha256 = this.lib.hash(data, 'sha256');
1044
1086
  data.sha512 = this.lib.hash(data, 'sha512');
1087
+
1045
1088
  this.talk(config.events.state, data); // broadcasat the state event
1046
1089
  return data;
1047
1090
  } catch (e) { // catch any errors
@@ -1063,9 +1106,11 @@ class Deva {
1063
1106
  value: this._states,
1064
1107
  created: Date.now(),
1065
1108
  }
1066
- data.hash = this.lib.hash(data);
1109
+
1110
+ data.md5 = this.lib.hash(data);
1067
1111
  data.sha256 = this.lib.hash(data, 'sha256');
1068
1112
  data.sha512 = this.lib.hash(data, 'sha512');
1113
+
1069
1114
  this.state('return', `states:${id}`);
1070
1115
  return data;
1071
1116
  }
@@ -1094,9 +1139,11 @@ class Deva {
1094
1139
  text,
1095
1140
  created: Date.now(),
1096
1141
  };
1097
- data.hash = this.lib.hash(data);
1142
+
1143
+ data.md5 = this.lib.hash(data);
1098
1144
  data.sha256 = this.lib.hash(data, 'sha256');
1099
1145
  data.sha512 = this.lib.hash(data, 'sha512');
1146
+
1100
1147
  this.talk(config.events.zone, data);
1101
1148
  return data;
1102
1149
  } catch (e) {
@@ -1114,7 +1161,8 @@ class Deva {
1114
1161
  const id = this.lib.uid();
1115
1162
  this.action('zones', id);
1116
1163
  this.state('return', `zones:${id}`);
1117
- return {
1164
+
1165
+ const data = {
1118
1166
  id, // set the uuid of the data
1119
1167
  agent: this.agent(), // set the agent value
1120
1168
  cleint: this.client(), // set the client value
@@ -1122,6 +1170,12 @@ class Deva {
1122
1170
  value: this._zones, // set the list of zones
1123
1171
  created: Date.now(), // set the created date of the object.
1124
1172
  }
1173
+
1174
+ data.md5 = this.lib.hash(data);
1175
+ data.sha256 = this.lib.hash(data, 'sha256');
1176
+ data.sha512 = this.lib.hash(data, 'sha512');
1177
+
1178
+ return data
1125
1179
  }
1126
1180
 
1127
1181
  /**************
@@ -1142,6 +1196,7 @@ class Deva {
1142
1196
  const msg_action = var_action || this._actions[value];
1143
1197
  const msg = msg_action || action; // set the correct message
1144
1198
  const text = extra ? `${msg} ${extra}` : msg; // set the text of the action
1199
+
1145
1200
  const data = { // build the data object for the action.
1146
1201
  id, // generate a guid for the action transmitssion.
1147
1202
  agent: this.agent(), // the agent data to send with the action
@@ -1151,9 +1206,11 @@ class Deva {
1151
1206
  text, // text of the action to send
1152
1207
  created: Date.now(), // action time stamp
1153
1208
  };
1154
- data.hash = this.lib.hash(data); // generate a hash of the action packet.
1209
+
1210
+ data.md5 = this.lib.hash(data);
1155
1211
  data.sha256 = this.lib.hash(data, 'sha256');
1156
1212
  data.sha512 = this.lib.hash(data, 'sha512');
1213
+
1157
1214
  this.talk(config.events.action, data); // talk the core action event
1158
1215
  return data;
1159
1216
  } catch (e) { // catch any errors that occur
@@ -1178,9 +1235,11 @@ class Deva {
1178
1235
  value: this._actions, // set the value to the actions list
1179
1236
  created: Date.now(), // set the data created date
1180
1237
  };
1181
- data.hash = this.lib.hash(data);
1238
+
1239
+ data.md5 = this.lib.hash(data);
1182
1240
  data.sha256 = this.lib.hash(data, 'sha256');
1183
1241
  data.sha512 = this.lib.hash(data, 'sha512');
1242
+
1184
1243
  this.state('return', `actions:${id}`);
1185
1244
  return data;
1186
1245
  }
@@ -1208,9 +1267,11 @@ class Deva {
1208
1267
  text, // set the text value
1209
1268
  created: Date.now(), // set the creation date
1210
1269
  };
1211
- data.hash = this.lib.hash(data); // generate the hash value of the data packet
1270
+
1271
+ data.md5 = this.lib.hash(data);
1212
1272
  data.sha256 = this.lib.hash(data, 'sha256');
1213
1273
  data.sha512 = this.lib.hash(data, 'sha512');
1274
+
1214
1275
  this.talk(config.events.feature, data); // talk the feature event with data
1215
1276
  return data;
1216
1277
  } catch (e) { // catch any errors
@@ -1236,9 +1297,11 @@ class Deva {
1236
1297
  value: this._features, // set the value to the features list
1237
1298
  created: Date.now(), // set the created date.
1238
1299
  };
1239
- data.hash = this.lib.hash(data);
1300
+
1301
+ data.md5 = this.lib.hash(data);
1240
1302
  data.sha256 = this.lib.hash(data, 'sha256');
1241
1303
  data.sha512 = this.lib.hash(data, 'sha512');
1304
+
1242
1305
  this.state('return', `features:${id}`);
1243
1306
  return data;
1244
1307
  }
@@ -1268,9 +1331,11 @@ class Deva {
1268
1331
  text,
1269
1332
  created: Date.now(),
1270
1333
  };
1271
- data.hash = this.lib.hash(data);
1334
+
1335
+ data.md5 = this.lib.hash(data);
1272
1336
  data.sha256 = this.lib.hash(data, 'sha256');
1273
1337
  data.sha512 = this.lib.hash(data, 'sha512');
1338
+
1274
1339
  this.talk(config.events.context, data);
1275
1340
  return data;
1276
1341
  } catch (e) {
@@ -1292,9 +1357,11 @@ class Deva {
1292
1357
  value: this.vars.context || false,
1293
1358
  created: Date.now(),
1294
1359
  };
1295
- data.hash = this.lib.hash(data);
1360
+
1361
+ data.md5 = this.lib.hash(data);
1296
1362
  data.sha256 = this.lib.hash(data, 'sha256');
1297
1363
  data.sha512 = this.lib.hash(data, 'sha512');
1364
+
1298
1365
  this.state('return', `contexts:${id}`);
1299
1366
  return data;
1300
1367
  }
@@ -1307,13 +1374,14 @@ class Deva {
1307
1374
  ***************/
1308
1375
  client() {
1309
1376
  if (!this._active) return this._messages.offline; // check the active status
1310
- const client_copy = this.lib.copy(this._client); // create a copy of the client data
1311
- client_copy.created = Date.now();
1312
- client_copy.hash = this.lib.hash(client_copy);
1313
- client_copy.sha256 = this.lib.hash(client_copy, 'sha256');
1314
- client_copy.sha512 = this.lib.hash(client_copy, 'sha512');
1377
+ const data = this.lib.copy(this._client); // create a copy of the client data
1378
+ data.created = Date.now();
1315
1379
 
1316
- return client_copy; // return the copy of the client data.
1380
+ data.md5 = this.lib.hash(data);
1381
+ data.sha256 = this.lib.hash(data, 'sha256');
1382
+ data.sha512 = this.lib.hash(data, 'sha512');
1383
+
1384
+ return data; // return the copy of the client data.
1317
1385
  }
1318
1386
 
1319
1387
  /**************
@@ -1324,12 +1392,13 @@ class Deva {
1324
1392
  ***************/
1325
1393
  agent() {
1326
1394
  if (!this._active) return this._messages.offline; // check the active status
1327
- const agent_copy = this.lib.copy(this._agent); // create a copy of the agent data.
1328
- agent_copy.created = Date.now();
1329
- agent_copy.hash = this.lib.hash(agent_copy);
1330
- agent_copy.sha256 = this.lib.hash(agent_copy, 'sha256');
1331
- agent_copy.sha512 = this.lib.hash(agent_copy, 'sha512');
1332
- return agent_copy; // return the copy of the agent data.
1395
+ const data = this.lib.copy(this._agent); // create a copy of the agent data.
1396
+ data.created = Date.now();
1397
+
1398
+ data.md5 = this.lib.hash(data);
1399
+ data.sha256 = this.lib.hash(data, 'sha256');
1400
+ data.sha512 = this.lib.hash(data, 'sha512');
1401
+ return data; // return the copy of the agent data.
1333
1402
  }
1334
1403
 
1335
1404
  // FEATURE FUNCTIONS
@@ -1493,7 +1562,11 @@ class Deva {
1493
1562
  text,
1494
1563
  created: Date.now(),
1495
1564
  }
1496
- data.hash = this.lib.hash(data);
1565
+
1566
+ data.md5 = this.lib.hash(data);
1567
+ data.sha256 = this.lib.hash(data, 'sha256');
1568
+ data.sha512 = this.lib.hash(data, 'sha512');
1569
+
1497
1570
  this.talk(config.events.prompt, data);
1498
1571
  return data;
1499
1572
  }
@@ -1512,7 +1585,11 @@ class Deva {
1512
1585
  const data = this.lib.copy(this._core);
1513
1586
  data.id = id;
1514
1587
  data.created = Date.now();
1515
- data.hash = this.lib.hash(data);
1588
+
1589
+ data.md5 = this.lib.hash(data);
1590
+ data.sha256 = this.lib.hash(data, 'sha256');
1591
+ data.sha512 = this.lib.hash(data, 'sha512');
1592
+
1516
1593
  this.state('return', `core:${id}`);
1517
1594
  return data;
1518
1595
  }
@@ -1530,7 +1607,11 @@ class Deva {
1530
1607
  const data = this.lib.copy(this._info);
1531
1608
  data.id = id;
1532
1609
  data.created = Date.now();
1533
- data.hash = this.lib.hash(data);
1610
+
1611
+ data.md5 = this.lib.hash(data);
1612
+ data.sha256 = this.lib.hash(data, 'sha256');
1613
+ data.sha512 = this.lib.hash(data, 'sha512');
1614
+
1534
1615
  this.state('return', `info:${id}`);
1535
1616
  return data;
1536
1617
  }
@@ -1653,7 +1734,10 @@ class Deva {
1653
1734
  packet,
1654
1735
  created: Date.now(),
1655
1736
  }
1656
- data.hash = this.lib.hash(data);
1737
+ data.md5 = this.lib.hash(data);
1738
+ data.sha256 = this.lib.hash(data, 'sha256');
1739
+ data.sha512 = this.lib.hash(data, 'sha512');
1740
+
1657
1741
  this.talk(config.events.error, this.lib.copy(data));
1658
1742
 
1659
1743
  this.state('return', `error:${id}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.5.42",
3
+ "version": "1.5.43",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "copyright": "(c)2025 Quinn Michaels; All rights reserved.",