@indra.ai/deva 1.5.17 → 1.5.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.
Files changed (2) hide show
  1. package/index.js +29 -45
  2. package/package.json +3 -13
package/index.js CHANGED
@@ -179,6 +179,9 @@ class Deva {
179
179
  },
180
180
  created: Date.now(),
181
181
  };
182
+ delete packet.hash;
183
+ packet.hash = this.lib.hash(packet);
184
+ this.state('invalid', `${method}:${packet.id}`);
182
185
  return packet;
183
186
  }
184
187
 
@@ -386,13 +389,11 @@ class Deva {
386
389
  describe: The end of the workflow Client Feature Workflow
387
390
  ***************/
388
391
  Done(resolve, reject) {
389
- this.action('done');
390
392
  try {
391
- this.state('done');
392
393
  delete this._client.features; // delete the features key when done.
393
394
  return resolve(this.client()); // resolve an empty pr
394
395
  } catch (e) {
395
- this.state('catch', 'done');
396
+ this.state('catch', 'Done');
396
397
  return this.error(e, false, reject);
397
398
  }
398
399
  }
@@ -633,19 +634,16 @@ class Deva {
633
634
  ***************/
634
635
  ask(packet) {
635
636
  if (!this._active) return Promise.resolve(this._messages.offline);
636
- const {method, params} = packet.q.meta;
637
- this.zone('ask', `${method}:${packet.id}`);
638
-
639
637
  const agent = this.agent();
640
638
  const client = this.client();
639
+ const {method, params} = packet.q.meta;
640
+ this.zone('ask', `${method}:${packet.id}`);
641
+ this.action('ask', `${method}:${packet.id}`);
641
642
  // build the answer packet from this model
642
-
643
643
  this.state('try', `ask:${method}:${packet.id}`);
644
644
  try {
645
-
646
645
  if (typeof this.methods[method] !== 'function') {
647
646
  return setImmediate(() => {
648
- this.state('invalid', `${method}:${packet.id}`);
649
647
  this.talk(`${this._agent.key}:ask:${packet.id}`, this._methodNotFound(packet));
650
648
  });
651
649
  }
@@ -781,16 +779,16 @@ class Deva {
781
779
  function or running the enter function.
782
780
  usage: this.start('msg')
783
781
  ***************/
784
- start(data, resolve) {
782
+ start(packet, resolve) {
785
783
  this.zone('start');
786
784
  if (!this._active) return Promise.resolve(this._messages.offline);
787
785
  this.action('start');
788
- data.value = 'start';
789
- delete data.hash;
790
- data.hash = this.lib.hash(data);
786
+ packet.value = 'start';
787
+ delete packet.hash;
788
+ packet.hash = this.lib.hash(packet);
791
789
  const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
792
790
  this.state('start');
793
- return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
791
+ return hasOnStart ? this.onStart(packet, resolve) : this.enter(packet, resolve)
794
792
  }
795
793
 
796
794
  /**************
@@ -804,22 +802,22 @@ class Deva {
804
802
  If the Deva is offline it will return the offline message.
805
803
  usage: this.enter('msg')
806
804
  ***************/
807
- enter(data, resolve) {
805
+ enter(packet, resolve) {
808
806
  this.zone('deva');
809
807
  if (!this._active) return Promise.resolve(this._messages.offline);
810
808
  this.action('enter');
811
- data.value = 'enter';
812
- delete data.hash;
813
- data.hash = this.lib.hash(data);
809
+ packet.value = 'enter';
810
+ delete packet.hash;
811
+ packet.hash = this.lib.hash(packet);
814
812
  this.state('enter');
815
813
  const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
816
- return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
814
+ return hasOnEnter ? this.onEnter(packet, resolve) : this.done(packet, resolve)
817
815
  }
818
816
 
819
817
  /**************
820
818
  func: done
821
819
  params:
822
- - msg: hte message from the caller incase need to use in calls
820
+ - data: hte message from the caller incase need to use in calls
823
821
  describe:
824
822
  When the done function is triggered the system will also set the state
825
823
  of hte Deva to done.
@@ -827,33 +825,30 @@ class Deva {
827
825
  If the deva is offline it will return the offline message.
828
826
  usage: this.done('msg')
829
827
  ***************/
830
- done(data, resolve) {
828
+ done(packet, resolve) {
831
829
  if (!this._active) return Promise.resolve(this._messages.offline);
832
- this.action('done');
833
- data.value = 'done';
834
- delete data.hash;
835
- data.hash = this.lib.hash(data);
830
+ packet.value = 'done';
831
+ delete packet.hash;
832
+ packet.hash = this.lib.hash(packet);
836
833
  const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
837
- this.state('done');
838
- return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
834
+ this.state('done', packet.id);
835
+ return hasOnDone ? this.onDone(packet, resolve) : this.ready(packet, resolve);
839
836
  }
840
837
 
841
838
  /**************
842
839
  func: ready
843
840
  params:
844
- - packet: the data to pass to the resolve
841
+ - data: the data to pass to the resolve
845
842
  - resolve: the complete resolve to pass back
846
843
  describe: This function is use to relay the to the ready state.
847
844
  usage: this.ready(data, resolve)
848
845
  ***************/
849
846
  ready(packet, resolve) {
850
847
  if (!this._active) return Promise.resolve(this._messages.offline);
851
- this.action('ready', packet.id); // set the complete action
852
-
848
+ delete packet.hash;
853
849
  packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
854
850
  // check for agent on complete function in agent
855
- const hasOnReady = this.onReady && typeof this.onReady === 'function';
856
-
851
+ const hasOnReady = this.onReady && typeof this.onReady === 'function';
857
852
  // return the provided resolve function or a promise resolve.
858
853
  this.state('ready', packet.id); // set the finish state
859
854
  return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
@@ -864,14 +859,13 @@ class Deva {
864
859
  /**************
865
860
  func: finish
866
861
  params:
867
- - packet: the data to pass to the resolve
862
+ - data: the data to pass to the resolve
868
863
  - resolve: the finish resolve to pass back
869
864
  describe: This function is used to relay into the finish state when resolving a question or data.
870
865
  usage: this.finish(data, resolve)
871
866
  ***************/
872
867
  finish(packet, resolve) {
873
868
  if (!this._active) return Promise.resolve(this._messages.offline);
874
- this.action('finish', packet.id); // set the finish action
875
869
  // check for agent on finish function in agent
876
870
  const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
877
871
  // return the provided resolve function or a promise resolve.
@@ -882,7 +876,7 @@ class Deva {
882
876
  /**************
883
877
  func: complete
884
878
  params:
885
- - packet: the data to pass to the resolve
879
+ - data: the data to pass to the resolve
886
880
  - resolve: the complete resolve to pass back
887
881
  describe: This function is use to relay into a complete state when
888
882
  resolving a question or data.
@@ -890,7 +884,6 @@ class Deva {
890
884
  ***************/
891
885
  complete(packet, resolve) {
892
886
  if (!this._active) return Promise.resolve(this._messages.offline);
893
- this.action('complete', packet.id); // set the complete action
894
887
  packet.created = Date.now();// set the complete date on the whole packet.
895
888
  delete packet.hash;
896
889
  packet.hash = this.lib.hash(packet);// hash the entire packet before complete.
@@ -918,8 +911,6 @@ class Deva {
918
911
  stop() {
919
912
  const id = this.lib.uid();
920
913
  if (!this._active) return Promise.resolve(this._messages.offline);
921
- this.zone('stop', id); // set the zone to stop
922
- this.action('stop', id); // set the stop action
923
914
 
924
915
  const data = { // build the stop data
925
916
  id, // set the id
@@ -949,9 +940,6 @@ class Deva {
949
940
  ***************/
950
941
  exit() {
951
942
  const id = this.lib.uid();
952
- this.zone('exit', id);
953
- this.action('exit', id);
954
-
955
943
  const data = {
956
944
  id,
957
945
  key: 'exit',
@@ -1038,8 +1026,6 @@ class Deva {
1038
1026
  ***************/
1039
1027
  zone(value=false, extra=false) {
1040
1028
  const id = this.lib.uid();
1041
- this.action('zone', `zone:${value}:${id}`);
1042
-
1043
1029
  if (!value || !this._zones[value] || value === this._zone) return;
1044
1030
 
1045
1031
  try {
@@ -1420,7 +1406,6 @@ class Deva {
1420
1406
  ***************/
1421
1407
  prompt(text) {
1422
1408
  const id = this.lib.uid();
1423
- this.action('prompt', id);
1424
1409
  if (!this._active) return Promise.resolve(this._messages.offline);
1425
1410
  // Talk a global prompt event for the client
1426
1411
  const agent = this.agent();
@@ -1436,7 +1421,6 @@ class Deva {
1436
1421
  }
1437
1422
  data.hash = this.lib.hash(data);
1438
1423
  this.talk(config.events.prompt, data);
1439
- this.state('return', `prompt:${id}`);
1440
1424
  return data;
1441
1425
  }
1442
1426
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.5.17",
3
+ "version": "1.5.18",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "copyright": "(c)2025 Quinn Michaels; All rights reserved.",
@@ -88,9 +88,7 @@
88
88
  "unload": "🛻 Unload",
89
89
  "init": "🚀 Init",
90
90
  "start": "🏎️ Start",
91
- "stop": "🛑 Stop",
92
91
  "enter": "🏡 Enter",
93
- "exit": "🚪 Exit",
94
92
  "finish": "🏁 Finish",
95
93
  "deva": "⚡️ Deva",
96
94
  "client": "👨 Client",
@@ -209,24 +207,16 @@
209
207
  "init": "🚀 Init",
210
208
  "start": "🎬 Start",
211
209
  "enter": "🏡 Enter",
212
- "done": "☑️ Done",
213
- "ready": "🟢 Ready",
214
210
  "finish": "🏁 Finish",
215
- "complete": "✅ Complete",
216
211
  "stop": "🛑 Stop",
217
- "exit": "🚪 Exit",
212
+ "method": "❤️‍🔥 Method",
213
+ "func": "🔦 Func",
218
214
  "actions": "🏎️ Actions",
219
- "feature": "🎥 Feature",
220
215
  "features": "🎥 Features",
221
- "context": "📇 Context",
222
216
  "contexts": "🌈 Contexts",
223
- "method": "❤️‍🔥 Method",
224
- "func": "🔦 Func",
225
- "zone": "🔭 Zone",
226
217
  "zones": "🪐 Zones",
227
218
  "load": "📦 Load",
228
219
  "unload": "🥡 Unload",
229
- "prompt": "🐚 Prompt",
230
220
  "states": "🍜 States",
231
221
  "core": "🍎 Core",
232
222
  "info": "💁‍♂️ Info",