@indra.ai/deva 1.6.90 → 1.6.92

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 +200 -97
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -959,23 +959,6 @@ class Deva {
959
959
  ***************/
960
960
  init(client) {
961
961
  // set client
962
- this._active = Date.now();
963
-
964
- const agent = this.agent();
965
-
966
- const data = {
967
- id: this.uid(),
968
- key: 'init',
969
- value: agent.key,
970
- agent,
971
- client,
972
- text: this._messages.init,
973
- created: Date.now(),
974
- }
975
- data.md5 = this.hash(data);
976
- data.sha256 = this.hash(data, 'sha256');
977
- data.sha512 = this.hash(data, 'sha512');
978
-
979
962
  return new Promise((resolve, reject) => {
980
963
 
981
964
  const license_check = this.license_check(client.VLA, this._core.VLA);
@@ -983,6 +966,30 @@ class Deva {
983
966
  this.prompt(this._messages.client_license_invalid);
984
967
  return resolve(this._messages.client_license_invalid); // return if} license check fails
985
968
  }
969
+
970
+ this._active = Date.now();
971
+ const id = this.uid();
972
+ const agent = this.agent();
973
+
974
+ this.state('data', `init:${id.uid}`);
975
+ const data = {
976
+ id,
977
+ key: agent.key,
978
+ value: 'init',
979
+ agent,
980
+ client,
981
+ text: this._messages.init,
982
+ created: Date.now(),
983
+ }
984
+
985
+ this.action('hash', `start:md5:${data.id.uid}`);
986
+ data.md5 = this.hash(data);
987
+
988
+ this.action('hash', `start:sha256:${data.id.uid}`)
989
+ data.sha256 = this.hash(data, 'sha256');
990
+
991
+ this.action('hash', `start:sha512:${data.id.uid}`)
992
+ data.sha512 = this.hash(data, 'sha512');
986
993
 
987
994
  this.events.setMaxListeners(this.maxListeners);
988
995
  this._assignInherit().then(() => {
@@ -990,10 +997,10 @@ class Deva {
990
997
  }).then(() => {
991
998
  return this._assignListeners();
992
999
  }).then(() => {
993
- this.feature('init');
994
- this.zone('init');
995
- this.action('init');
996
- this.state('init');
1000
+ this.feature('init', data.id.uid);
1001
+ this.zone('init', data.id.uid);
1002
+ this.action('init', data.id.uid);
1003
+ this.state('init', data.id.uid);
997
1004
  }).then(() => {
998
1005
  return this.Client(client, resolve, reject);
999
1006
  }).then(() => {
@@ -1048,7 +1055,8 @@ class Deva {
1048
1055
  return this.Done(resolve, reject);
1049
1056
  }).then(() => {
1050
1057
  const hasOnInit = this.onInit && typeof this.onInit === 'function';
1051
- this.state('return', `init:${data.id.uid}`);
1058
+ if (hasOnInit) this.state('set', `hasOnInit:${data.id.uid}`); // state set to watch onInit
1059
+ this.action('return', `init:${data.id.uid}`);
1052
1060
  return hasOnInit ? this.onInit(data, resolve) : this.start(data, resolve);
1053
1061
  }).catch(err => {
1054
1062
  this.state('catch', `init:${data.id.uid}`);
@@ -1068,27 +1076,37 @@ class Deva {
1068
1076
  usage: this.start('msg')
1069
1077
  ***************/
1070
1078
  start(data, resolve) {
1079
+ if (!this._active) return resolve(this._messages.offline);
1071
1080
  this.context('start', data.id.uid);
1072
1081
  this.zone('start', data.id.uid);
1073
- if (!this._active) return resolve(this._messages.offline);
1074
-
1075
1082
  this.action('start', data.id.uid);
1076
- const id = this.uid();
1083
+ this.state('start', data.id.uid);
1077
1084
 
1085
+ this.action('delete', `init:md5:${data.id.uid}`);
1078
1086
  delete data.md5;
1087
+ this.action('delete', `init:sha256:${data.id.uid}`);
1079
1088
  delete data.sha256;
1089
+ this.action('delete', `init:sha512:${data.id.uid}`);
1080
1090
  delete data.sha512;
1081
1091
 
1092
+ this.state('set', `data:value:start:${data.id.uid}`); // state set to watch OnFinish
1082
1093
  data.value = 'start';
1083
1094
 
1095
+ this.action('hash', `start:md5:${data.id.uid}`);
1084
1096
  data.md5 = this.hash(data);
1097
+ this.action('hash', `start:sha256:${data.id.uid}`)
1085
1098
  data.sha256 = this.hash(data, 'sha256');
1099
+ this.action('hash', `start:sha512:${data.id.uid}`)
1086
1100
  data.sha512 = this.hash(data, 'sha512');
1087
1101
 
1088
- const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
1089
-
1090
- this.state('start', data.id.uid);
1102
+ // setup the finish talk event
1103
+ this.action('talk', `${this._events.start}:${data.id.uid}`);
1091
1104
  this.talk(this._events.start, data);
1105
+
1106
+ const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
1107
+ if (hasOnStart) this.state('set', `hasOnStart:${data.id.uid}`); // state set to watch OnFinish
1108
+
1109
+ this.action('return', `start:${data.id.uid}`); // return action finish
1092
1110
  return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
1093
1111
  }
1094
1112
 
@@ -1104,25 +1122,36 @@ class Deva {
1104
1122
  usage: this.enter('msg')
1105
1123
  ***************/
1106
1124
  enter(data, resolve) {
1125
+ if (!this._active) return resolve(this._messages.offline);
1107
1126
  this.context('enter', data.id.uid);
1108
1127
  this.zone('enter', data.id.uid);
1109
- if (!this._active) return resolve(this._messages.offline);
1110
-
1111
1128
  this.action('enter', data.id.uid);
1112
- const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
1129
+ this.state('enter', data.id.uid);
1113
1130
 
1131
+ this.action('delete', `start:md5:${data.id.uid}`);
1114
1132
  delete data.md5;
1133
+ this.action('delete', `start:sha256:${data.id.uid}`);
1115
1134
  delete data.sha256;
1135
+ this.action('delete', `start:sha512:${data.id.uid}`);
1116
1136
  delete data.sha512;
1117
1137
 
1138
+ this.state('set', `data:value:enter:${data.id.uid}`); // state set to watch OnFinish
1118
1139
  data.value = 'enter';
1119
1140
 
1141
+ this.action('hash', `enter:md5:${data.id.uid}`);
1120
1142
  data.md5 = this.hash(data);
1143
+ this.action('hash', `enter:sha256:${data.id.uid}`)
1121
1144
  data.sha256 = this.hash(data, 'sha256');
1145
+ this.action('hash', `enter:sha512:${data.id.uid}`)
1122
1146
  data.sha512 = this.hash(data, 'sha512');
1123
1147
 
1124
- this.state('enter', data.id.uid);
1148
+ this.action('talk', `${this._events.enter}:${data.id.uid}`);
1125
1149
  this.talk(this._events.enter, data);
1150
+
1151
+ const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
1152
+ if (hasOnEnter) this.state('set', `hasOnEnter:${data.id.uid}`); // state set to watch OnFinish
1153
+
1154
+ this.action('return', `enter:${data.id.uid}`); // return action finish
1126
1155
  return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
1127
1156
  }
1128
1157
 
@@ -1138,25 +1167,36 @@ class Deva {
1138
1167
  usage: this.done('msg')
1139
1168
  ***************/
1140
1169
  done(data, resolve) {
1170
+ if (!this._active) return resolve(this._messages.offline);
1141
1171
  this.context('done', data.id.uid);
1142
1172
  this.zone('done', data.id.uid);
1143
- if (!this._active) return resolve(this._messages.offline);
1144
-
1145
1173
  this.action('done', data.id.uid);
1146
- const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
1174
+ this.state('done', data.id.uid);
1147
1175
 
1176
+ this.action('delete', `enter:md5:${data.id.uid}`);
1148
1177
  delete data.md5;
1178
+ this.action('delete', `enter:sha256:${data.id.uid}`);
1149
1179
  delete data.sha256;
1180
+ this.action('delete', `enter:sha512:${data.id.uid}`);
1150
1181
  delete data.sha512;
1151
1182
 
1183
+ this.state('set', `data:value:done:${data.id.uid}`); // state set to watch OnFinish
1152
1184
  data.value = 'done';
1153
1185
 
1186
+ this.action('hash', `done:md5:${data.id.uid}`);
1154
1187
  data.md5 = this.hash(data);
1188
+ this.action('hash', `done:sha256:${data.id.uid}`)
1155
1189
  data.sha256 = this.hash(data, 'sha256');
1190
+ this.action('hash', `done:sha512:${data.id.uid}`)
1156
1191
  data.sha512 = this.hash(data, 'sha512');
1157
1192
 
1158
- this.state('done', data.id.uid);
1193
+ this.action('talk', `${this._events.done}:${data.id.uid}`);
1159
1194
  this.talk(this._events.done, data);
1195
+
1196
+ const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
1197
+ if (hasOnDone) this.state('set', `hasOnDone:${data.id.uid}`); // state set to watch OnFinish
1198
+
1199
+ this.action('return', `done:${data.id.uid}`); // return action finish
1160
1200
  return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
1161
1201
  }
1162
1202
 
@@ -1169,27 +1209,37 @@ class Deva {
1169
1209
  usage: this.ready(data, resolve)
1170
1210
  ***************/
1171
1211
  ready(data, resolve) {
1212
+ if (!this._active) return resolve(this._messages.offline);
1172
1213
  this.context('ready', data.id.uid);
1173
1214
  this.zone('ready', data.id.uid);
1174
- if (!this._active) return resolve(this._messages.offline);
1175
-
1176
1215
  this.action('ready', data.id.uid);
1177
- const hasOnReady = this.onReady && typeof this.onReady === 'function';
1216
+ this.state('ready', data.id.uid);
1178
1217
 
1179
1218
  // Delete previous data hashes
1219
+ this.action('delete', `done:md5:${data.id.uid}`);
1180
1220
  delete data.md5;
1221
+ this.action('delete', `done:sha256:${data.id.uid}`);
1181
1222
  delete data.sha256;
1223
+ this.action('delete', `done:sha512:${data.id.uid}`);
1182
1224
  delete data.sha512;
1183
1225
 
1226
+ this.state('set', `data:value:ready:${data.id.uid}`); // state set to watch OnFinish
1184
1227
  data.value = 'ready';
1185
1228
 
1229
+ this.action('hash', `ready:md5:${data.id.uid}`);
1186
1230
  data.md5 = this.hash(data);
1231
+ this.action('hash', `ready:sha256:${data.id.uid}`)
1187
1232
  data.sha256 = this.hash(data, 'sha256');
1233
+ this.action('hash', `ready:sha512:${data.id.uid}`)
1188
1234
  data.sha512 = this.hash(data, 'sha512');
1189
1235
 
1190
- this.state('ready', data.id.uid);
1236
+ this.action('talk', `${this._events.ready}:${data.id.uid}`);
1191
1237
  this.talk(this._events.ready, data);
1192
- this.zone('home', `client:home:${data.id.uid}`);
1238
+
1239
+ const hasOnReady = this.onReady && typeof this.onReady === 'function';
1240
+ if (hasOnReady) this.state('set', `hasOnReady:${data.id.uid}`); // state set to watch OnFinish
1241
+
1242
+ this.action('resolve', `ready:${data.id.uid}`); // return action ready
1193
1243
  return hasOnReady ? this.onReady(data, resolve) : resolve(data);
1194
1244
  }
1195
1245
 
@@ -1205,22 +1255,34 @@ class Deva {
1205
1255
  if (!this._active) return resolve(this._messages.offline); //
1206
1256
  this.context('finish', data.id.uid);
1207
1257
  this.zone('finish', data.id.uid); // enter finish zone
1208
-
1209
1258
  this.action('finish', data.id.uid); // start finish action
1210
- const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
1259
+ this.state('finish', data.id.uid); // set finish state
1211
1260
 
1261
+ this.action('delete', `answer:md5:${data.id.uid}`);
1212
1262
  delete data.md5;
1263
+ this.action('delete', `answer:sha256:${data.id.uid}`);
1213
1264
  delete data.sha256;
1265
+ this.action('delete', `answer:sha512:${data.id.uid}`);
1214
1266
  delete data.sha512;
1215
1267
 
1216
1268
  data.finish = Date.now(); // set the finish timestamp
1269
+ this.state('set', `data:finish:${data.finish}:${data.id.uid}`)
1217
1270
 
1271
+ this.action('hash', `finish:md5:${data.id.uid}`);
1218
1272
  data.md5 = this.hash(data);
1273
+ this.action('hash', `finish:sha256:${data.id.uid}`)
1219
1274
  data.sha256 = this.hash(data, 'sha256');
1275
+ this.action('hash', `finish:sha512:${data.id.uid}`)
1220
1276
  data.sha512 = this.hash(data, 'sha512');
1221
1277
 
1222
- this.state('finish', data.id.uid); // set finish state
1223
- this.talk(this._events.finish, data);
1278
+ // setup the finish talk event
1279
+ this.action('talk', `${this._events.finish}:${data.id.uid}`);
1280
+ this.talk(this._events.finish, data);
1281
+
1282
+ const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
1283
+ if (hasOnFinish) this.state('set', `hasOnFinish:${data.id.uid}`); // state set to watch OnFinish
1284
+
1285
+ this.action('return', `finish:${data.id.uid}`); // return action finish
1224
1286
  return hasOnFinish ? this.onFinish(data, resolve) : this.complete(data, resolve);
1225
1287
  }
1226
1288
 
@@ -1237,21 +1299,36 @@ class Deva {
1237
1299
  if (!this._active) return Promise.resolve(this._messages.offline);
1238
1300
  this.context('complete', data.id.uid);
1239
1301
  this.zone('complete', data.id.uid);
1240
-
1241
1302
  this.action('complete', data.id.uid);
1242
- const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
1303
+ this.state('complete', data.id.uid);
1243
1304
 
1305
+ this.action('delete', `finish:md5:${data.id.uid}`);
1244
1306
  delete data.md5;
1307
+ this.action('delete', `finish:sha256:${data.id.uid}`);
1245
1308
  delete data.sha256;
1309
+ this.action('delete', `finish:sha512:${data.id.uid}`);
1246
1310
  delete data.sha512;
1247
1311
 
1248
1312
  data.complete = Date.now();// set the complete date on the whole data.
1313
+ this.state('set', `data:complete:${data.complete}:${data.id.uid}`)
1314
+
1315
+ this.action('hash', `complete:md5:${data.id.uid}`);
1249
1316
  data.md5 = this.hash(data);
1317
+ this.action('hash', `complete:sha256:${data.id.uid}`)
1250
1318
  data.sha256 = this.hash(data, 'sha256');
1319
+
1320
+ this.action('hash', `complete:sha512:${data.id.uid}`)
1251
1321
  data.sha512 = this.hash(data, 'sha512');
1252
-
1253
- this.state('complete', data.id.uid);
1254
- this.talk(this._events.complete, data);
1322
+
1323
+ // setup the complete talk event
1324
+ this.action('talk', `${this._events.complete}:${data.id.uid}`); // action talk for the event.
1325
+ this.talk(this._events.complete, data); // talk the complete event
1326
+
1327
+ // determine if there is an onComplete function for the entity.
1328
+ const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
1329
+ if (hasOnComplete) this.state('set', `hasOnComplete:${data.id.uid}`); // state set to watch OnFinish
1330
+
1331
+ this.action('return', `complete:${data.id.uid}`); // return action complete
1255
1332
  return hasOnComplete ? this.onComplete(data, resolve) : resolve(data);
1256
1333
  }
1257
1334
 
@@ -1271,30 +1348,44 @@ class Deva {
1271
1348
  stop() {
1272
1349
  if (!this._active) return Promise.resolve(this._messages.offline);
1273
1350
  const id = this.uid();
1274
- this.context('stop', id);
1275
- this.zone('stop', id);
1351
+ this.context('stop', id.uid);
1352
+ this.zone('stop', id.uid);
1353
+ this.action('stop', id.uid);
1354
+ this.state('stop', id.uid); // set the state to stop
1355
+
1356
+ this.state('set', `stop:agent:${id.uid}`); // state stop agent
1357
+ const agent = this.agent(); // get the current agent
1276
1358
 
1277
- this.action('stop', id);
1278
- const hasOnStop = this.onStop && typeof this.onStop === 'function';
1359
+ this.state('set', `stop:client:${id.uid}`); // state stop agent
1360
+ const client = this.client(); // set the current client
1279
1361
 
1362
+ this.state('data', `stop:${id.uid}`);
1280
1363
  const data = { // build the stop data
1281
1364
  id, // set the id
1282
- key: 'stop', // set the key
1283
- value: this._messages.stop, // set the value
1365
+ key: agent.key, // set the key
1366
+ value: 'stop', // set the value
1284
1367
  agent: this.agent(), // set the agent
1285
1368
  client: this.client(), // set the client
1286
- created: Date.now(), // set the created date
1369
+ stop: Date.now(), // set the created date
1287
1370
  }
1288
1371
 
1372
+ this.action('hash', `stop:md5:${data.id.uid}`);
1289
1373
  data.md5 = this.hash(data);
1290
- data.sha256 = this.hash(data, 'sha256');
1374
+ this.action('hash', `stop:sha256:${data.id.uid}`)
1375
+ data.sha256 = this.hash(data, 'sha256');
1376
+ this.action('hash', `stop:sha512:${data.id.uid}`)
1291
1377
  data.sha512 = this.hash(data, 'sha512');
1292
1378
 
1293
1379
  // has stop function then set hasOnStop variable
1294
1380
  // if: has on stop then run on stop function or return exit function.
1295
- this.state('stop', id); // set the state to stop
1381
+ this.action('talk', `${this._events.stop}:${data.id.uid}`); // action talk for the event.
1296
1382
  this.talk(this._events.stop, data);
1297
- return hasOnStop ? this.onStop(data) : this.exit()
1383
+
1384
+ // determine if there is an onComplete function for the entity.
1385
+ const hasOnStop = this.onStop && typeof this.onStop === 'function';
1386
+ if (hasOnStop) this.state('set', `hasOnStop:${data.id.uid}`); // state set to watch OnFinish
1387
+
1388
+ return hasOnStop ? this.onStop(data) : this.exit(data)
1298
1389
  }
1299
1390
 
1300
1391
  /**************
@@ -1307,50 +1398,62 @@ class Deva {
1307
1398
  The return will check for a custom onExit function or run the done
1308
1399
  function.
1309
1400
  ***************/
1310
- exit() {
1401
+ exit(data) {
1311
1402
  if (!this._active) return Promise.resolve(this._messages.offline);
1312
- const id = this.uid();
1313
- this.context('exit', id);
1314
- this.zone('exit', id);
1315
-
1316
- this.action('exit', id);
1317
- const hasOnExit = this.onExit && typeof this.onExit === 'function';
1403
+ this.context('exit', data.id.uid);
1404
+ this.zone('exit', data.id.uid);
1405
+ this.action('exit', data.id.uid);
1406
+ this.state('exit', data.id.uid); // set the state to stop
1318
1407
 
1319
- const data = {
1320
- id,
1321
- key: 'exit',
1322
- value: this._messages.exit,
1323
- agent: this.agent(),
1324
- client: this.client(),
1325
- created: Date.now(),
1326
- }
1408
+ this.action('delete', `stop:md5:${data.id.uid}`);
1409
+ delete data.md5;
1410
+ this.action('delete', `stop:sha256:${data.id.uid}`);
1411
+ delete data.sha256;
1412
+ this.action('delete', `stop:sha512:${data.id.uid}`);
1413
+ delete data.sha512;
1327
1414
 
1415
+ this.state('set', `exit:time:${id.uid}`); // state stop agent
1416
+ data.exit = Date.now();
1417
+
1418
+ this.action('hash', `stop:md5:${data.id.uid}`);
1328
1419
  data.md5 = this.hash(data);
1329
- data.sha256 = this.hash(data, 'sha256');
1420
+ this.action('hash', `stop:sha256:${data.id.uid}`)
1421
+ data.sha256 = this.hash(data, 'sha256');
1422
+ this.action('hash', `stop:sha512:${data.id.uid}`)
1330
1423
  data.sha512 = this.hash(data, 'sha512');
1331
-
1332
- this.state('exit', id); // set the state to stop
1333
- this.talk(this._events.exit, data);
1334
1424
 
1335
1425
  // clear memory
1336
- this._active = false;
1337
- this._client = false;
1338
- this._vector = false;
1339
- this._data = false;
1340
- this._treasury = false;
1341
- this._security = false;
1342
- this._guard = false;
1343
- this._defense = false;
1344
- this._wall = false;
1345
- this._shield = false;
1346
- this._proxy = false;
1347
- this._legal = false;
1348
- this._authority = false;
1349
- this._justice = false;
1350
- this._support = false;
1351
- this._services = false;
1352
- this._systems = false;
1353
- this._networks = false;
1426
+ this._active = false; // the active/birth date.
1427
+ this._indra = false; // inherited Indra features.
1428
+ this._veda = false; // inherited Veda features.
1429
+ this._license = false; // inherited License features.
1430
+ this._data = false; // inherited Data features.
1431
+ this._error = false; // inherited Error features.
1432
+ this._log = false; // inherited Log features.
1433
+ this._report = false; // inherited Report features.
1434
+ this._vector = false; // inherited Vector features.
1435
+ this._king = false; // inherited King features.
1436
+ this._treasury = false; // inherited Vector features.
1437
+ this._security = false; // inherited Security features.
1438
+ this._guard = false; // inherited Guard features.
1439
+ this._defense = false; // inherited Security features.
1440
+ this._wall = false; // inherited Wall features.
1441
+ this._proxy = false; // inherited Proxy features.
1442
+ this._legal = false; // inherited Legal features.
1443
+ this._authority = false; // inherited Justice features.
1444
+ this._justice = false; // inherited Justice features.
1445
+ this._support = false; // inherited Support features.
1446
+ this._services = false; // inherited Service features.
1447
+ this._systems = false; // inherited Systems features.
1448
+ this._networks = false; // inherited Systems features.
1449
+
1450
+ this.action('talk', `${this._events.stop}:${data.id.uid}`); // action talk for the event.
1451
+ this.talk(this._events.exit, data);
1452
+
1453
+ const hasOnExit = this.onExit && typeof this.onExit === 'function';
1454
+ if (hasOnExit) this.state('set', `hasOnExit:${data.id.uid}`); // state set to watch OnFinish
1455
+
1456
+ this.action('return', `exit:${data.uid}`);
1354
1457
  return hasOnExit ? this.onExit(data) : Promise.resolve(data)
1355
1458
  }
1356
1459
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "44091450722329207445",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.6.90",
4
+ "version": "1.6.92",
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",