@indra.ai/deva 1.1.16 → 1.1.18
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.
- package/index.js +12 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -108,6 +108,7 @@ class Deva {
|
|
|
108
108
|
data,
|
|
109
109
|
created: Date.now(),
|
|
110
110
|
};
|
|
111
|
+
this.prompt(this._state);
|
|
111
112
|
this.talk(`${this.agent.key}:state`, _data);
|
|
112
113
|
return this._state;
|
|
113
114
|
}
|
|
@@ -559,7 +560,7 @@ class Deva {
|
|
|
559
560
|
return this._assignListeners();
|
|
560
561
|
}).then(() => {
|
|
561
562
|
this.state('init');
|
|
562
|
-
return this.onInit && typeof this.onInit === 'function' ? this.onInit() : this.start(
|
|
563
|
+
return this.onInit && typeof this.onInit === 'function' ? this.onInit() : this.start();
|
|
563
564
|
}).then(started => {
|
|
564
565
|
return resolve(started)
|
|
565
566
|
}).catch(err => {
|
|
@@ -587,15 +588,15 @@ class Deva {
|
|
|
587
588
|
the active to the current datetime and then checking for a custom onStart
|
|
588
589
|
function or running the system enter function.
|
|
589
590
|
***************/
|
|
590
|
-
start() {
|
|
591
|
-
if (!this._active) return;
|
|
591
|
+
start(msg=false) {
|
|
592
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
592
593
|
this.state('start');
|
|
593
594
|
return this.onStart && typeof this.onStart === 'function' ? this.onStart() : this.enter(this._messages.start);
|
|
594
595
|
}
|
|
595
596
|
|
|
596
597
|
/**************
|
|
597
598
|
func: stop
|
|
598
|
-
params:
|
|
599
|
+
params: msg - hte message from the caller incase need to use in calls
|
|
599
600
|
describe:
|
|
600
601
|
The stop function will stop the Deva by setting the active status to false,
|
|
601
602
|
and the state to stop. From here it will check for a custom onStop function
|
|
@@ -603,7 +604,7 @@ class Deva {
|
|
|
603
604
|
|
|
604
605
|
If the deva is offline it will return the offline message.
|
|
605
606
|
***************/
|
|
606
|
-
stop() {
|
|
607
|
+
stop(msg=false) {
|
|
607
608
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
608
609
|
this.state('stop');
|
|
609
610
|
this._active = false;
|
|
@@ -612,14 +613,14 @@ class Deva {
|
|
|
612
613
|
|
|
613
614
|
/**************
|
|
614
615
|
func: enter
|
|
615
|
-
params:
|
|
616
|
+
params: msg - hte message from the caller incase need to use in calls
|
|
616
617
|
describe:
|
|
617
618
|
The ener function will check the actie status of the Deva and set it to
|
|
618
619
|
offline or enter.
|
|
619
620
|
|
|
620
621
|
If the Deva is offline it will return the offline message.
|
|
621
622
|
***************/
|
|
622
|
-
enter() {
|
|
623
|
+
enter(msg=false) {
|
|
623
624
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
624
625
|
this.state('enter');
|
|
625
626
|
return this.onEnter && typeof this.onEnter === 'function' ? this.onEnter() : this.done(this._messages.enter)
|
|
@@ -627,7 +628,7 @@ class Deva {
|
|
|
627
628
|
|
|
628
629
|
/**************
|
|
629
630
|
func: exit
|
|
630
|
-
params:
|
|
631
|
+
params: msg - hte message from the caller incase need to use in calls
|
|
631
632
|
describe:
|
|
632
633
|
The exit state function is triggered when the Deva is exiting it's online
|
|
633
634
|
status and setting the state to exit for things like security check.
|
|
@@ -637,7 +638,7 @@ class Deva {
|
|
|
637
638
|
|
|
638
639
|
If the deva is offline it will return the offline message.
|
|
639
640
|
***************/
|
|
640
|
-
exit() {
|
|
641
|
+
exit(msg=false) {
|
|
641
642
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
642
643
|
this.state('exit');
|
|
643
644
|
this._active = false;
|
|
@@ -671,12 +672,12 @@ class Deva {
|
|
|
671
672
|
|
|
672
673
|
If the deva is offline it will return the offline message.
|
|
673
674
|
***************/
|
|
674
|
-
status(
|
|
675
|
+
status(ammend=false) {
|
|
675
676
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
676
677
|
const id = this.uid();
|
|
677
678
|
const dateFormat = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium', timeStyle: 'medium' }).format(this._active);
|
|
678
679
|
let text = `${this.agent.name} is ONLINE since ${dateFormat}`;
|
|
679
|
-
if (
|
|
680
|
+
if (ammend) text = text + `\n${ammend}`;
|
|
680
681
|
return Promise.resolve({text});
|
|
681
682
|
}
|
|
682
683
|
|