@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.
- package/index.js +56 -63
- 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', '
|
|
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(
|
|
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
|
-
|
|
789
|
-
delete
|
|
790
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
-
|
|
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(
|
|
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.
|
|
838
|
-
|
|
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
|
-
-
|
|
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.
|
|
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
|
-
-
|
|
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
|
-
|
|
878
|
-
this.
|
|
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
|
-
-
|
|
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.
|
|
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.
|
|
922
|
-
this.
|
|
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.
|
|
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": "
|
|
91
|
-
"stop": "π Stop",
|
|
90
|
+
"start": "π’ Start",
|
|
92
91
|
"enter": "π‘ Enter",
|
|
93
|
-
"
|
|
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": "
|
|
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": "
|
|
213
|
+
"start": "π’ Start",
|
|
211
214
|
"enter": "π‘ Enter",
|
|
212
|
-
"done": "βοΈ Done",
|
|
213
|
-
"ready": "π’ Ready",
|
|
214
215
|
"finish": "π Finish",
|
|
215
|
-
"
|
|
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": {
|