@indra.ai/deva 1.55.0 → 1.56.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.
package/config/msgs.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "nokey": "⛔️ NO KEY PROVIDED",
20
20
  "invalidkey": "⛔️ INVALID KEY PROVIDED",
21
21
  "asktimeout": "⛔️ ASK TIMEOUT",
22
- "noask": "⛔️ NO ASK PROVIDED",
22
+ "noask": "⛔️ ASK TARGET NOT FOUND",
23
23
  "method_not_found": "⛔️ METHOD NOT FOUND",
24
24
  "help_not_found": "⛔️ HELP NOT FOUND",
25
25
  "invalid_agent": "⛔️ Agent Hash Invalid",
package/index.js CHANGED
@@ -859,52 +859,50 @@ class Deva {
859
859
  // if: isAsk wait for the once event which is key'd to the packet ID for specified responses
860
860
  this.action('ask', `${key}:${id.uid}`);
861
861
  this.intent('good', `ask:${key}:${id.uid}`);
862
- this.once(`${key}:ask:${packet.id.uid}`, answer => {
863
- const evt = `${key}:ask:${packet.id.uid}`; // the once event keyed to this packet.
864
- const pending = {evt, handler: false, timer: false}; // tracked so shutdown can clean up.
865
-
866
- // single place to release the listener, the timer, and the pending record.
867
- const release = () => {
868
- clearTimeout(pending.timer);
869
- this._pending.delete(pending);
870
- if (this.events) this.ignore(evt, pending.handler);
871
- };
872
-
873
- pending.handler = answer => {
874
- clearTimeout(pending.timer); // an answer arrived so cancel the timeout.
875
- this._pending.delete(pending);
876
- this.action('talk', `${this._events.ask}:${id.uid}`);
877
- this.intent('good', `${this._events.ask}:${id.uid}`);
878
- this.talk(this._events.ask, this.lib.copy(answer));
879
- this.action('return', `finish:${key}:ask:${id.uid}`);
880
- this.intent('good', `finish:${method}:${id.uid}`);
881
- return this.finish(answer, resolve); // if:isAsk resolve the answer from the call
882
- };
883
-
884
- this._pending.add(pending);
885
- this.once(evt, pending.handler);
886
-
887
- // timeout so a silent Deva cannot hang the caller. 0 disables it.
888
- const wait = this._config.timeout.ask;
889
- if (wait > 0) {
890
- pending.timer = setTimeout(() => {
891
- if (!this._active) return; // shutdown already cleaned up.
892
- release();
893
- this.state('abort', `${key}:${method}:${id.uid}`);
894
- this.intent('bad', `ask:${key}:${id.uid}`);
895
- return resolve(this._messages.asktimeout);
896
- }, wait);
897
- }
898
-
899
- // talk returns false when nobody is listening so fail fast instead of waiting.
900
- const heard = this.talk(`${key}:ask`, this.lib.copy(packet));
901
- if (!heard) {
862
+ const evt = `${key}:ask:${packet.id.uid}`; // the once event keyed to this packet.
863
+ const pending = {evt, handler: false, timer: false}; // tracked so shutdown can clean up.
864
+
865
+ // single place to release the listener, the timer, and the pending record.
866
+ const release = () => {
867
+ clearTimeout(pending.timer);
868
+ this._pending.delete(pending);
869
+ if (this.events) this.ignore(evt, pending.handler);
870
+ };
871
+
872
+ pending.handler = answer => {
873
+ clearTimeout(pending.timer); // an answer arrived so cancel the timeout.
874
+ this._pending.delete(pending);
875
+ this.action('talk', `${this._events.ask}:${id.uid}`);
876
+ this.intent('good', `${this._events.ask}:${id.uid}`);
877
+ this.talk(this._events.ask, this.lib.copy(answer));
878
+ this.action('return', `finish:${key}:ask:${id.uid}`);
879
+ this.intent('good', `finish:${method}:${id.uid}`);
880
+ return this.finish(answer, resolve); // if:isAsk resolve the answer from the call
881
+ };
882
+
883
+ this._pending.add(pending);
884
+ this.once(evt, pending.handler);
885
+
886
+ // timeout so a silent Deva cannot hang the caller. 0 disables it.
887
+ const wait = this._config.timeout.ask;
888
+ if (wait > 0) {
889
+ pending.timer = setTimeout(() => {
890
+ if (!this._active) return; // shutdown already cleaned up.
902
891
  release();
903
- this.state('invalid', `${key}:${method}:${id.uid}`);
892
+ this.state('abort', `${key}:${method}:${id.uid}`);
904
893
  this.intent('bad', `ask:${key}:${id.uid}`);
905
- return resolve(this._messages.noask);
906
- }
907
- });
894
+ return resolve(this._messages.asktimeout);
895
+ }, wait);
896
+ }
897
+
898
+ // talk returns false when nobody is listening so fail fast instead of waiting.
899
+ const heard = this.talk(`${key}:ask`, this.lib.copy(packet));
900
+ if (!heard) {
901
+ release();
902
+ this.state('invalid', `${key}:${method}:${id.uid}`);
903
+ this.intent('bad', `ask:${key}:${id.uid}`);
904
+ return resolve(this._messages.noask);
905
+ }
908
906
  }
909
907
  else { // else: answer the question locally
910
908
  this.state('answer', `${method}:${id.uid}`); //set the answer state to the method
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "23221940810208468106",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.55.0",
4
+ "version": "1.56.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:23221940810208468106 LICENSE.md",