@indra.ai/deva 1.6.91 → 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 +169 -95
  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
 
@@ -1174,23 +1214,32 @@ class Deva {
1174
1214
  this.zone('ready', data.id.uid);
1175
1215
  this.action('ready', data.id.uid);
1176
1216
  this.state('ready', data.id.uid);
1177
-
1178
- const hasOnReady = this.onReady && typeof this.onReady === 'function';
1179
1217
 
1180
1218
  // Delete previous data hashes
1219
+ this.action('delete', `done:md5:${data.id.uid}`);
1181
1220
  delete data.md5;
1221
+ this.action('delete', `done:sha256:${data.id.uid}`);
1182
1222
  delete data.sha256;
1223
+ this.action('delete', `done:sha512:${data.id.uid}`);
1183
1224
  delete data.sha512;
1184
1225
 
1226
+ this.state('set', `data:value:ready:${data.id.uid}`); // state set to watch OnFinish
1185
1227
  data.value = 'ready';
1186
1228
 
1229
+ this.action('hash', `ready:md5:${data.id.uid}`);
1187
1230
  data.md5 = this.hash(data);
1231
+ this.action('hash', `ready:sha256:${data.id.uid}`)
1188
1232
  data.sha256 = this.hash(data, 'sha256');
1233
+ this.action('hash', `ready:sha512:${data.id.uid}`)
1189
1234
  data.sha512 = this.hash(data, 'sha512');
1190
1235
 
1236
+ this.action('talk', `${this._events.ready}:${data.id.uid}`);
1191
1237
  this.talk(this._events.ready, data);
1192
1238
 
1193
- this.action('return', `ready:${data.id.uid}`); // return action ready
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
1194
1243
  return hasOnReady ? this.onReady(data, resolve) : resolve(data);
1195
1244
  }
1196
1245
 
@@ -1223,16 +1272,15 @@ class Deva {
1223
1272
  data.md5 = this.hash(data);
1224
1273
  this.action('hash', `finish:sha256:${data.id.uid}`)
1225
1274
  data.sha256 = this.hash(data, 'sha256');
1226
-
1227
1275
  this.action('hash', `finish:sha512:${data.id.uid}`)
1228
1276
  data.sha512 = this.hash(data, 'sha512');
1229
1277
 
1230
- const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
1231
- if (hasOnFinish) this.state('set', `hasOnFinish:${data.id.uid}`); // state set to watch OnFinish
1232
-
1233
1278
  // setup the finish talk event
1234
1279
  this.action('talk', `${this._events.finish}:${data.id.uid}`);
1235
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
1236
1284
 
1237
1285
  this.action('return', `finish:${data.id.uid}`); // return action finish
1238
1286
  return hasOnFinish ? this.onFinish(data, resolve) : this.complete(data, resolve);
@@ -1271,15 +1319,15 @@ class Deva {
1271
1319
 
1272
1320
  this.action('hash', `complete:sha512:${data.id.uid}`)
1273
1321
  data.sha512 = this.hash(data, 'sha512');
1274
-
1275
- // determine if there is an onComplete function for the entity.
1276
- const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
1277
- if (hasOnComplete) this.state('set', `hasOnComplete:${data.id.uid}`); // state set to watch OnFinish
1278
-
1322
+
1279
1323
  // setup the complete talk event
1280
1324
  this.action('talk', `${this._events.complete}:${data.id.uid}`); // action talk for the event.
1281
1325
  this.talk(this._events.complete, data); // talk the complete event
1282
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
+
1283
1331
  this.action('return', `complete:${data.id.uid}`); // return action complete
1284
1332
  return hasOnComplete ? this.onComplete(data, resolve) : resolve(data);
1285
1333
  }
@@ -1300,30 +1348,44 @@ class Deva {
1300
1348
  stop() {
1301
1349
  if (!this._active) return Promise.resolve(this._messages.offline);
1302
1350
  const id = this.uid();
1303
- this.context('stop', id);
1304
- 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
1305
1358
 
1306
- this.action('stop', id);
1307
- 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
1308
1361
 
1362
+ this.state('data', `stop:${id.uid}`);
1309
1363
  const data = { // build the stop data
1310
1364
  id, // set the id
1311
- key: 'stop', // set the key
1312
- value: this._messages.stop, // set the value
1365
+ key: agent.key, // set the key
1366
+ value: 'stop', // set the value
1313
1367
  agent: this.agent(), // set the agent
1314
1368
  client: this.client(), // set the client
1315
- created: Date.now(), // set the created date
1369
+ stop: Date.now(), // set the created date
1316
1370
  }
1317
1371
 
1372
+ this.action('hash', `stop:md5:${data.id.uid}`);
1318
1373
  data.md5 = this.hash(data);
1319
- 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}`)
1320
1377
  data.sha512 = this.hash(data, 'sha512');
1321
1378
 
1322
1379
  // has stop function then set hasOnStop variable
1323
1380
  // if: has on stop then run on stop function or return exit function.
1324
- this.state('stop', id); // set the state to stop
1381
+ this.action('talk', `${this._events.stop}:${data.id.uid}`); // action talk for the event.
1325
1382
  this.talk(this._events.stop, data);
1326
- 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)
1327
1389
  }
1328
1390
 
1329
1391
  /**************
@@ -1336,50 +1398,62 @@ class Deva {
1336
1398
  The return will check for a custom onExit function or run the done
1337
1399
  function.
1338
1400
  ***************/
1339
- exit() {
1401
+ exit(data) {
1340
1402
  if (!this._active) return Promise.resolve(this._messages.offline);
1341
- const id = this.uid();
1342
- this.context('exit', id);
1343
- this.zone('exit', id);
1344
-
1345
- this.action('exit', id);
1346
- 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
1347
1407
 
1348
- const data = {
1349
- id,
1350
- key: 'exit',
1351
- value: this._messages.exit,
1352
- agent: this.agent(),
1353
- client: this.client(),
1354
- created: Date.now(),
1355
- }
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;
1356
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}`);
1357
1419
  data.md5 = this.hash(data);
1358
- 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}`)
1359
1423
  data.sha512 = this.hash(data, 'sha512');
1360
-
1361
- this.state('exit', id); // set the state to stop
1362
- this.talk(this._events.exit, data);
1363
1424
 
1364
1425
  // clear memory
1365
- this._active = false;
1366
- this._client = false;
1367
- this._vector = false;
1368
- this._data = false;
1369
- this._treasury = false;
1370
- this._security = false;
1371
- this._guard = false;
1372
- this._defense = false;
1373
- this._wall = false;
1374
- this._shield = false;
1375
- this._proxy = false;
1376
- this._legal = false;
1377
- this._authority = false;
1378
- this._justice = false;
1379
- this._support = false;
1380
- this._services = false;
1381
- this._systems = false;
1382
- 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}`);
1383
1457
  return hasOnExit ? this.onExit(data) : Promise.resolve(data)
1384
1458
  }
1385
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.91",
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",