@indra.ai/deva 1.28.2 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +25 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1391,7 +1391,7 @@ class Deva {
1391
1391
  describe: This function is use to relay the to the ready state.
1392
1392
  usage: this.ready(data, resolve)
1393
1393
  ***************/
1394
- ready(data, resolve) {
1394
+ async ready(data, resolve) {
1395
1395
  if (!this._active) return resolve(this._messages.offline);
1396
1396
  const key = 'ready';
1397
1397
 
@@ -1409,7 +1409,28 @@ class Deva {
1409
1409
  this.config.hash[agent.key][item] = this.hash(this_item, 'sha256');
1410
1410
  }
1411
1411
  }
1412
- return this._invoke({key,data,resolve});
1412
+ // check if the entity has devas to load after everything is ready.
1413
+ // load the devas
1414
+ let deva;
1415
+ try {
1416
+ if (this.devas && Object.keys(this.devas).length) {
1417
+ for (deva in this.devas) {
1418
+ await this.load(deva, data.client);
1419
+ // after the deva loads talk the event to set asset directory.
1420
+ const id = this.devas[deva].uid();
1421
+ const {dir} = this.devas[deva].info();
1422
+ const {key} = this.devas[deva].agent();
1423
+ this.talk(`deva:dir`, {id, key,dir});
1424
+ }
1425
+ }
1426
+ }
1427
+ catch (err) {
1428
+ return this.err(err, deva);
1429
+ }
1430
+ finally {
1431
+ // return the invoke in a set immediate so it runs after the loop
1432
+ return this._invoke({key,data,resolve});
1433
+ }
1413
1434
  }
1414
1435
 
1415
1436
  /**************
@@ -2137,12 +2158,12 @@ class Deva {
2137
2158
  -deva: The Deva model to load.
2138
2159
  describe: This function will enable fast loading of Deva into the system.
2139
2160
  ***************/
2140
- load(key, client) {
2161
+ async load(key, client) {
2141
2162
  this.zone('load', key);
2142
2163
  this.action('load', key);
2143
2164
  this.state('load', key);
2144
2165
  this.intent('good', `load:${key}`);
2145
- return this.devas[key].init(client);
2166
+ return await this.devas[key].init(client);
2146
2167
  }
2147
2168
 
2148
2169
  /**************
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "38159520729793885324",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.28.2",
4
+ "version": "1.29.1",
5
5
  "description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
6
6
  "main": "index.js",
7
7
  "license": "VLA:38159520729793885324 LICENSE.md",