@indra.ai/deva 1.1.83 → 1.1.85
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 +9 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,6 +61,7 @@ class Deva {
|
|
|
61
61
|
this._messages = {
|
|
62
62
|
notext: 'NO TEXT WAS PROVIDED',
|
|
63
63
|
nopacket: 'NO PACKET WAS PROVIDED',
|
|
64
|
+
method_not_found: 'METHOD NOT FOUND',
|
|
64
65
|
}; // set the messages from config
|
|
65
66
|
|
|
66
67
|
// then here we are going to loop the messages config to make sure custom values are set
|
|
@@ -772,7 +773,7 @@ class Deva {
|
|
|
772
773
|
packet.q.meta.hash = this.hash(packet.q);
|
|
773
774
|
|
|
774
775
|
this.action(_action);
|
|
775
|
-
this.talk(config.events.question, this.copy(packet));
|
|
776
|
+
this.talk(config.events.question, this.copy(packet)); // global question event make sure to copy data.
|
|
776
777
|
|
|
777
778
|
if (isAsk) { // isAsk check if the question isAsk and talk
|
|
778
779
|
this.state('ask');
|
|
@@ -851,7 +852,7 @@ class Deva {
|
|
|
851
852
|
|
|
852
853
|
|
|
853
854
|
this.action('answer_talk');
|
|
854
|
-
this.talk(config.events.answer, this.copy(packet));
|
|
855
|
+
this.talk(config.events.answer, this.copy(packet)); // global talk event
|
|
855
856
|
|
|
856
857
|
return resolve(this.copy(packet)); // resolve the packet to the caller.
|
|
857
858
|
}).catch(err => { // catch any errors in the method
|
|
@@ -880,8 +881,8 @@ class Deva {
|
|
|
880
881
|
this.state('ask');
|
|
881
882
|
this.action('ask');
|
|
882
883
|
|
|
883
|
-
const agent = this.agent()
|
|
884
|
-
const client = this.client()
|
|
884
|
+
const agent = this.agent();
|
|
885
|
+
const client = this.client();
|
|
885
886
|
// build the answer packet from this model
|
|
886
887
|
packet.a = {
|
|
887
888
|
agent,
|
|
@@ -901,8 +902,7 @@ class Deva {
|
|
|
901
902
|
if (typeof this.methods[packet.q.meta.method] !== 'function') {
|
|
902
903
|
return setImmediate(() => {
|
|
903
904
|
this.action('invalid')
|
|
904
|
-
|
|
905
|
-
this.talk(`${this._agent.key}:ask:${packet.id}`, packet);
|
|
905
|
+
this.talk(`${this._agent.key}:ask:${packet.id}`, this._methodNotFound(packet));
|
|
906
906
|
});
|
|
907
907
|
}
|
|
908
908
|
|
|
@@ -918,16 +918,16 @@ class Deva {
|
|
|
918
918
|
packet.a.text = result;
|
|
919
919
|
}
|
|
920
920
|
this.action('ask_answer');
|
|
921
|
-
this.talk(`${
|
|
921
|
+
this.talk(`${agent.key}:ask:${packet.id}`, packet);
|
|
922
922
|
}).catch(err => {
|
|
923
923
|
this.action('error');
|
|
924
|
-
this.talk(`${
|
|
924
|
+
this.talk(`${agent.key}:ask:${packet.id}`, {error:err});
|
|
925
925
|
return this.error(err, packet);
|
|
926
926
|
})
|
|
927
927
|
}
|
|
928
928
|
catch (e) {
|
|
929
929
|
this.action('error');
|
|
930
|
-
this.talk(`${
|
|
930
|
+
this.talk(`${agent.key}:ask:${packet.id}`, {error:e});
|
|
931
931
|
return this.error(e, packet)
|
|
932
932
|
}
|
|
933
933
|
// now when we ask the meta params[0] should be the method
|