@indra.ai/deva 1.5.17 β†’ 1.5.19

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 +56 -63
  2. package/package.json +23 -24
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,17 @@ class Deva {
781
779
  function or running the enter function.
782
780
  usage: this.start('msg')
783
781
  ***************/
784
- start(data, resolve) {
785
- this.zone('start');
782
+ start(packet, resolve) {
786
783
  if (!this._active) return Promise.resolve(this._messages.offline);
784
+ const id = this.lib.uid();
785
+ this.zone('start', data.id);
787
786
  this.action('start');
788
- data.value = 'start';
789
- delete data.hash;
790
- data.hash = this.lib.hash(data);
787
+ packet.value = 'start';
788
+ delete packet.hash;
789
+ packet.hash = this.lib.hash(packet);
791
790
  const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
792
791
  this.state('start');
793
- return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
792
+ return hasOnStart ? this.onStart(packet, resolve) : this.enter(packet, resolve)
794
793
  }
795
794
 
796
795
  /**************
@@ -804,22 +803,22 @@ class Deva {
804
803
  If the Deva is offline it will return the offline message.
805
804
  usage: this.enter('msg')
806
805
  ***************/
807
- enter(data, resolve) {
808
- this.zone('deva');
806
+ enter(packet, resolve) {
809
807
  if (!this._active) return Promise.resolve(this._messages.offline);
810
- this.action('enter');
811
- data.value = 'enter';
812
- delete data.hash;
813
- data.hash = this.lib.hash(data);
814
- this.state('enter');
815
808
  const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
816
- return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
809
+ this.zone('enter', packet.id);
810
+ this.action('enter', packet.id);
811
+ this.state('enter', packet.id);
812
+ delete packet.hash;
813
+ packet.value = 'enter';
814
+ packet.hash = this.lib.hash(packet);
815
+ return hasOnEnter ? this.onEnter(packet, resolve) : this.done(packet, resolve)
817
816
  }
818
817
 
819
818
  /**************
820
819
  func: done
821
820
  params:
822
- - msg: hte message from the caller incase need to use in calls
821
+ - data: hte message from the caller incase need to use in calls
823
822
  describe:
824
823
  When the done function is triggered the system will also set the state
825
824
  of hte Deva to done.
@@ -827,35 +826,35 @@ class Deva {
827
826
  If the deva is offline it will return the offline message.
828
827
  usage: this.done('msg')
829
828
  ***************/
830
- done(data, resolve) {
829
+ done(packet, resolve) {
831
830
  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);
836
831
  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);
832
+ this.zone('done', packet.id);
833
+ this.action('done', packet.id);
834
+ this.state('done', packet.id);
835
+ packet.value = 'done';
836
+ delete packet.hash;
837
+ packet.hash = this.lib.hash(packet);
838
+ return hasOnDone ? this.onDone(packet, resolve) : this.ready(packet, resolve);
839
839
  }
840
840
 
841
841
  /**************
842
842
  func: ready
843
843
  params:
844
- - packet: the data to pass to the resolve
844
+ - data: the data to pass to the resolve
845
845
  - resolve: the complete resolve to pass back
846
846
  describe: This function is use to relay the to the ready state.
847
847
  usage: this.ready(data, resolve)
848
848
  ***************/
849
849
  ready(packet, resolve) {
850
850
  if (!this._active) return Promise.resolve(this._messages.offline);
851
- this.action('ready', packet.id); // set the complete action
852
-
851
+ const hasOnReady = this.onReady && typeof this.onReady === 'function';
852
+ this.zone('ready', packet.id);
853
+ this.action('ready', packet.id);
854
+ this.state('ready', packet.id);
855
+ packet.value = 'ready';
856
+ delete packet.hash;
853
857
  packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
854
- // check for agent on complete function in agent
855
- const hasOnReady = this.onReady && typeof this.onReady === 'function';
856
-
857
- // return the provided resolve function or a promise resolve.
858
- this.state('ready', packet.id); // set the finish state
859
858
  return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
860
859
  }
861
860
 
@@ -864,25 +863,24 @@ class Deva {
864
863
  /**************
865
864
  func: finish
866
865
  params:
867
- - packet: the data to pass to the resolve
866
+ - data: the data to pass to the resolve
868
867
  - resolve: the finish resolve to pass back
869
868
  describe: This function is used to relay into the finish state when resolving a question or data.
870
869
  usage: this.finish(data, resolve)
871
870
  ***************/
872
871
  finish(packet, resolve) {
873
872
  if (!this._active) return Promise.resolve(this._messages.offline);
874
- this.action('finish', packet.id); // set the finish action
875
- // check for agent on finish function in agent
876
873
  const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
877
- // return the provided resolve function or a promise resolve.
878
- this.state('finish', packet.id); // set the finish state
874
+ this.zone('finish', packet.id);
875
+ this.action('finish', packet.id);
876
+ this.state('finish', packet.id);
879
877
  return hasOnFinish ? this.onFinish(packet, resolve) : this.complete(packet, resolve);
880
878
  }
881
879
 
882
880
  /**************
883
881
  func: complete
884
882
  params:
885
- - packet: the data to pass to the resolve
883
+ - data: the data to pass to the resolve
886
884
  - resolve: the complete resolve to pass back
887
885
  describe: This function is use to relay into a complete state when
888
886
  resolving a question or data.
@@ -890,15 +888,13 @@ class Deva {
890
888
  ***************/
891
889
  complete(packet, resolve) {
892
890
  if (!this._active) return Promise.resolve(this._messages.offline);
893
- this.action('complete', packet.id); // set the complete action
891
+ const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
892
+ this.zone('complete', packet.id);
893
+ this.action('complete', packet.id);
894
+ this.state('complete', packet.id);
894
895
  packet.created = Date.now();// set the complete date on the whole packet.
895
896
  delete packet.hash;
896
897
  packet.hash = this.lib.hash(packet);// hash the entire packet before complete.
897
-
898
- // check for agent on complete function in agent
899
- const hasOnComplete = this.onComplete && typeof this.onComplete === 'function';
900
- // return the provided resolve function or a promise resolve.
901
- this.state('complete', packet.id); // set the finish state
902
898
  return hasOnComplete ? this.onComplete(packet, resolve) : resolve(packet);
903
899
  }
904
900
 
@@ -916,10 +912,12 @@ class Deva {
916
912
  this.stop()
917
913
  ***************/
918
914
  stop() {
919
- const id = this.lib.uid();
920
915
  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
916
+ const id = this.lib.uid();
917
+ const hasOnStop = this.onStop && typeof this.onStop === 'function';
918
+ this.zone('stop', id);
919
+ this.action('stop', id);
920
+ this.state('stop', id); // set the state to stop
923
921
 
924
922
  const data = { // build the stop data
925
923
  id, // set the id
@@ -930,9 +928,7 @@ class Deva {
930
928
  created: Date.now(), // set the created date
931
929
  }
932
930
  // has stop function then set hasOnStop variable
933
- const hasOnStop = this.onStop && typeof this.onStop === 'function';
934
931
  // if: has on stop then run on stop function or return exit function.
935
- this.state('stop', id); // set the state to stop
936
932
  return hasOnStop ? this.onStop(data) : this.exit()
937
933
  }
938
934
 
@@ -948,10 +944,13 @@ class Deva {
948
944
  function.
949
945
  ***************/
950
946
  exit() {
947
+ if (!this._active) return Promise.resolve(this._messages.offline);
951
948
  const id = this.lib.uid();
949
+ const hasOnExit = this.onExit && typeof this.onExit === 'function';
952
950
  this.zone('exit', id);
953
951
  this.action('exit', id);
954
-
952
+ this.state('exit', id); // set the state to stop
953
+
955
954
  const data = {
956
955
  id,
957
956
  key: 'exit',
@@ -974,8 +973,6 @@ class Deva {
974
973
  this._authority = false;
975
974
  this._justice = false;
976
975
 
977
- this.state('exit', id);
978
- const hasOnExit = this.onExit && typeof this.onExit === 'function';
979
976
  return hasOnExit ? this.onExit(data) : Promise.resolve(data)
980
977
  }
981
978
 
@@ -1038,8 +1035,6 @@ class Deva {
1038
1035
  ***************/
1039
1036
  zone(value=false, extra=false) {
1040
1037
  const id = this.lib.uid();
1041
- this.action('zone', `zone:${value}:${id}`);
1042
-
1043
1038
  if (!value || !this._zones[value] || value === this._zone) return;
1044
1039
 
1045
1040
  try {
@@ -1420,7 +1415,6 @@ class Deva {
1420
1415
  ***************/
1421
1416
  prompt(text) {
1422
1417
  const id = this.lib.uid();
1423
- this.action('prompt', id);
1424
1418
  if (!this._active) return Promise.resolve(this._messages.offline);
1425
1419
  // Talk a global prompt event for the client
1426
1420
  const agent = this.agent();
@@ -1436,7 +1430,6 @@ class Deva {
1436
1430
  }
1437
1431
  data.hash = this.lib.hash(data);
1438
1432
  this.talk(config.events.prompt, data);
1439
- this.state('return', `prompt:${id}`);
1440
1433
  return data;
1441
1434
  }
1442
1435
 
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.19",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "copyright": "(c)2025 Quinn Michaels; All rights reserved.",
@@ -87,11 +87,14 @@
87
87
  "load": "πŸš› Load",
88
88
  "unload": "πŸ›» Unload",
89
89
  "init": "πŸš€ Init",
90
- "start": "🏎️ Start",
91
- "stop": "πŸ›‘ Stop",
90
+ "start": "🟒 Start",
92
91
  "enter": "🏑 Enter",
93
- "exit": "πŸšͺ Exit",
92
+ "done": "βœ… Done",
93
+ "ready": "🫑 Ready",
94
94
  "finish": "🏁 Finish",
95
+ "complete": "πŸ’― Complete",
96
+ "stop": "πŸ”΄ Stop",
97
+ "exit": "πŸšͺ Exit",
95
98
  "deva": "⚑️ Deva",
96
99
  "client": "πŸ‘¨ Client",
97
100
  "agent": "πŸ€– Agent",
@@ -121,7 +124,6 @@
121
124
  "question": "πŸ’¬ Question",
122
125
  "cmd": "πŸͺ– Command",
123
126
  "answer": "πŸ’‘ Answer",
124
- "ready": "😊 Ready",
125
127
  "wait": "⏳ Waiting",
126
128
  "pause": "⏸️ Pause",
127
129
  "resume": "πŸš™ Resume",
@@ -130,22 +132,23 @@
130
132
  "send": "πŸ“¬ Send",
131
133
  "receive": "πŸ“ͺ Receive",
132
134
  "init": "πŸš€ Init",
133
- "start": "πŸ› Start",
134
- "stop": "⏹️ Stop",
135
- "open": "πŸ₯« Open",
136
- "close": "πŸ“¦ Close",
135
+ "start": "🟒 Start",
137
136
  "enter": "🏑 Enter",
137
+ "done": "βœ… Done",
138
+ "ready": "🫑 Ready",
139
+ "finish": "🏁 Finish",
140
+ "complete": "πŸ’― Complete",
141
+ "stop": "πŸ›‘ Stop",
138
142
  "exit": "πŸšͺ Exit",
143
+ "open": "πŸ₯« Open",
144
+ "close": "πŸ“¦ Close",
139
145
  "begin": "πŸ—ΊοΈ Begin",
140
146
  "end": "🎬 End",
141
147
  "load": "🚚 Load",
142
148
  "unload": "πŸ›» Unload",
143
149
  "resolve": "🀝 Resolve",
144
150
  "reject": "🧱 Reject",
145
- "done": "πŸ‘ Done",
146
151
  "data": "πŸ“‘ Data",
147
- "finish": "🏁 Finish",
148
- "complete": "βœ… Complete",
149
152
  "create": "🎨 Create",
150
153
  "destroy": "πŸ’£ Destroy",
151
154
  "write": "πŸ“ Write",
@@ -207,32 +210,28 @@
207
210
  "answer": "πŸ’‘ Answer",
208
211
  "ask": "πŸ“£ Ask",
209
212
  "init": "πŸš€ Init",
210
- "start": "🎬 Start",
213
+ "start": "🟒 Start",
211
214
  "enter": "🏑 Enter",
212
- "done": "β˜‘οΈ Done",
213
- "ready": "🟒 Ready",
214
215
  "finish": "🏁 Finish",
215
- "complete": "βœ… Complete",
216
- "stop": "πŸ›‘ Stop",
216
+ "stop": "πŸ”΄ Stop",
217
217
  "exit": "πŸšͺ Exit",
218
+ "method": "❀️‍πŸ”₯ Method",
219
+ "func": "πŸ”¦ Func",
218
220
  "actions": "🏎️ Actions",
219
- "feature": "πŸŽ₯ Feature",
220
221
  "features": "πŸŽ₯ Features",
221
- "context": "πŸ“‡ Context",
222
222
  "contexts": "🌈 Contexts",
223
- "method": "❀️‍πŸ”₯ Method",
224
- "func": "πŸ”¦ Func",
225
- "zone": "πŸ”­ Zone",
226
223
  "zones": "πŸͺ Zones",
227
224
  "load": "πŸ“¦ Load",
228
225
  "unload": "πŸ₯‘ Unload",
229
- "prompt": "🐚 Prompt",
230
226
  "states": "🍜 States",
231
227
  "core": "🍎 Core",
232
228
  "info": "πŸ’β€β™‚οΈ Info",
233
229
  "status": "πŸš₯ Status",
234
230
  "error": "πŸ”΄ ERROR!",
235
- "help": "πŸ’œ Help"
231
+ "help": "πŸ’œ Help",
232
+ "done": "βœ… Done",
233
+ "ready": "🫑 Ready",
234
+ "complete": "πŸ’― Complete"
236
235
  },
237
236
  "feature": false,
238
237
  "features": {