@indra.ai/deva 1.1.81 → 1.1.83

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 (3) hide show
  1. package/config.json +12 -0
  2. package/index.js +12 -16
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -13,6 +13,18 @@
13
13
  "lib",
14
14
  "_agent"
15
15
  ],
16
+ "events": {
17
+ "prompt": "devacore:prompt",
18
+ "error": "devacore:error",
19
+ "question": "devacore:question",
20
+ "answer": "devacore:answer",
21
+ "state": "devacore:state",
22
+ "zone": "devacore:zone",
23
+ "action": "devacore:action",
24
+ "feature": "devacore:feature",
25
+ "load": "devacore:load",
26
+ "unload": "devacore:unload"
27
+ },
16
28
  "state": "offline",
17
29
  "states": {
18
30
  "ask": "asking another",
package/index.js CHANGED
@@ -772,7 +772,7 @@ class Deva {
772
772
  packet.q.meta.hash = this.hash(packet.q);
773
773
 
774
774
  this.action(_action);
775
- this.talk('devacore:question', this.copy(packet)); // global question event make sure to copy data.
775
+ this.talk(config.events.question, this.copy(packet)); // global question event make sure to copy data.
776
776
 
777
777
  if (isAsk) { // isAsk check if the question isAsk and talk
778
778
  this.state('ask');
@@ -851,7 +851,7 @@ class Deva {
851
851
 
852
852
 
853
853
  this.action('answer_talk');
854
- this.talk('devacore:answer', this.copy(packet)); // talk the answer with a copy of the data
854
+ this.talk(config.events.answer, this.copy(packet)); // talk the answer with a copy of the data
855
855
 
856
856
  return resolve(this.copy(packet)); // resolve the packet to the caller.
857
857
  }).catch(err => { // catch any errors in the method
@@ -1166,7 +1166,7 @@ class Deva {
1166
1166
  created: Date.now(),
1167
1167
  };
1168
1168
  _data.hash = this.hash(_data);
1169
- this.talk('devacore:state', _data);
1169
+ this.talk(config.events.state, _data);
1170
1170
  } catch (e) {
1171
1171
  return this.error(e);
1172
1172
  }
@@ -1202,7 +1202,7 @@ class Deva {
1202
1202
  created: Date.now(),
1203
1203
  };
1204
1204
  _data.hash = this.hash(_data);
1205
- this.talk('devacore:zone', _data);
1205
+ this.talk('', _data);
1206
1206
  } catch (e) {
1207
1207
  return this.error(e);
1208
1208
  }
@@ -1229,7 +1229,7 @@ class Deva {
1229
1229
  created: Date.now(),
1230
1230
  };
1231
1231
  _data.hash = this.hash(_data);
1232
- this.talk('devacore:action', _data);
1232
+ this.talk(config.events.action, _data);
1233
1233
  } catch (e) {
1234
1234
  return this.error(e)
1235
1235
  }
@@ -1256,7 +1256,7 @@ class Deva {
1256
1256
  created: Date.now(),
1257
1257
  };
1258
1258
  _data.hash = this.hash(_data);
1259
- this.talk('devacore:feature', _data);
1259
+ this.talk(config.events.feature, _data);
1260
1260
  } catch (e) {
1261
1261
  return this.error(e);
1262
1262
  }
@@ -1515,7 +1515,7 @@ class Deva {
1515
1515
  return new Promise((resolve, reject) => {
1516
1516
  this.state('load');
1517
1517
  this.devas[key].init(client).then(loaded => {
1518
- this.talk(`devacore:load`, {
1518
+ this.talk(config.events.load, {
1519
1519
  id:this.uid(true),
1520
1520
  key,
1521
1521
  created: Date.now(),
@@ -1539,11 +1539,7 @@ class Deva {
1539
1539
  this.state('uload');
1540
1540
  this.devas[key].stop().then(exit => {
1541
1541
  delete this.devas[key];
1542
- this.talk(`devacore:unload`, {
1543
- id:this.uid(true),
1544
- key,
1545
- created: Date.now(),
1546
- });
1542
+ this.talk(config.events.unload, key);
1547
1543
  });
1548
1544
  return resolve(this._messages.states.unload);
1549
1545
  } catch (e) {
@@ -1678,7 +1674,7 @@ class Deva {
1678
1674
  text,
1679
1675
  created: Date.now(),
1680
1676
  }
1681
- return this.talk('devacore:prompt', _data);
1677
+ return this.talk(config.events.prompt, _data);
1682
1678
  }
1683
1679
 
1684
1680
 
@@ -1795,7 +1791,7 @@ class Deva {
1795
1791
  const splitter = text.split(' ');
1796
1792
  if (splitter < maxwords) return text;
1797
1793
  return splitter.slice(0, maxwords).join(' ');
1798
- },
1794
+ }
1799
1795
 
1800
1796
  dupes(dupers) {
1801
1797
  if (!Array.isArray(dupers)) return dupers;
@@ -1806,7 +1802,7 @@ class Deva {
1806
1802
  return dupe;
1807
1803
  }
1808
1804
  });
1809
- },
1805
+ }
1810
1806
 
1811
1807
  /**************
1812
1808
  func: error
@@ -1841,7 +1837,7 @@ class Deva {
1841
1837
  data,
1842
1838
  created: Date.now(),
1843
1839
  }
1844
- this.talk('devacore:error', this.copy(_data));
1840
+ this.talk(config.events.error, this.copy(_data));
1845
1841
 
1846
1842
  const hasOnError = this.onError && typeof this.onError === 'function' ? true : false;
1847
1843
  if (hasOnError) return this.onError(err, data, reject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.81",
3
+ "version": "1.1.83",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {