@indra.ai/deva 1.1.10 → 1.1.11

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 +19 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -7,18 +7,24 @@ const { createHash, randomUUID } = require('crypto');
7
7
  class Deva {
8
8
  constructor(opts) {
9
9
  opts = opts || {};
10
- this._uid = this.uid(); // the unique id assigned to the agent at load
10
+ this._id = randomUUID(); // the unique id assigned to the agent at load
11
11
  this._state = 'OFFLINE'; // current state of agent.
12
12
  this._states = { // The available states to work with.
13
13
  offline: 'OFFLINE',
14
+ online: 'ONLINE',
14
15
  init: 'INIT',
15
16
  start: 'START',
16
- stop: 'STOP',
17
17
  enter: 'ENTER',
18
+ stop: 'STOP',
18
19
  exit: 'EXIT',
19
20
  done: 'DONE',
20
- loading: 'LOADING DEVAS',
21
- unloading: 'UNLOADING DEVAS',
21
+ devas_start: 'DEVAS STARTING',
22
+ devas_ready: 'DEVAS READY',
23
+ devas_stop: 'DEVAS STOPPING',
24
+ devas_stopped: 'DEVAS STOPPED',
25
+ deva_load: 'DEVA LOAD',
26
+ deva_loaded: 'DEVA LOADED',
27
+ deva_unloaded: 'DEVA UNLOADED',
22
28
  wait: 'WAITING',
23
29
  data: 'DATA',
24
30
  ask: 'ASK',
@@ -61,8 +67,6 @@ class Deva {
61
67
  this.bind = ["listeners", "methods", "func", "lib", "security", "agent", "client"];
62
68
  this.messages = {
63
69
  offline: 'AGENT OFFLINE',
64
- loading: 'DEVAS LOADING',
65
- loaded: 'DEVAS LOADED',
66
70
  stopped: 'DEVAS STOPPED',
67
71
  notext: 'NO TEXT',
68
72
  notfound: 'NOT FOUND',
@@ -290,11 +294,13 @@ class Deva {
290
294
  This function will enable fast loading of Deva into a system.
291
295
  ***************/
292
296
  load(deva) {
297
+ this.state('deva_load');
293
298
  this.devas[deva.key] = deva;
294
299
  // inherit the data to the new deva.
295
300
  this.inherit.forEach(inherit => {
296
301
  this.devas[deva.key][inherit] = this[inherit];
297
302
  });
303
+ this.state('deva_loaded');
298
304
  return Promise.resolve();
299
305
  }
300
306
 
@@ -306,7 +312,9 @@ class Deva {
306
312
  describe: Unload a currently loaded Deva.
307
313
  ***************/
308
314
  unload(deva) {
315
+ this.state('deva_unload');
309
316
  delete this.devas[deva];
317
+ this.state('deva_unloaded');
310
318
  return Promise.resolve(`unload:${deva} `);
311
319
  }
312
320
 
@@ -682,7 +690,7 @@ class Deva {
682
690
  Start Devas will initialize the Deva agents inside this curent Deva.
683
691
  ***************/
684
692
  startDevas() {
685
- this.state('loading');
693
+ this.state('devas_start');
686
694
  return new Promise((resolve, reject) => {
687
695
  this.prompt
688
696
  const devas = [];
@@ -690,8 +698,8 @@ class Deva {
690
698
  devas.push(this.devas[x].init());
691
699
  }
692
700
  Promise.all(devas).then(() => {
693
- this.state('done');
694
- return resolve(this.messages.loaded);
701
+ this.state('devas_ready');
702
+ return resolve(this._state);
695
703
  }).catch(reject);
696
704
  });
697
705
  }
@@ -702,12 +710,14 @@ class Deva {
702
710
  stopDevas will stop all the devas running in the current Deva.
703
711
  ***************/
704
712
  stopDevas() {
713
+ this.state('devas_stop');
705
714
  return new Promise((resolve, reject) => {
706
715
  const devas = [];
707
716
  for (let x in this.devas) {
708
717
  devas.push(this.devas[x].stop());
709
718
  }
710
719
  Promise.all(devas).then(() => {
720
+ this.state('devas_stoped');
711
721
  return resolve(this.messages.stopped);
712
722
  }).catch(reject);
713
723
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {