@indra.ai/deva 1.5.53 β 1.5.54
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 +41 -7
- package/lib/index.js +12 -10
- package/package.json +20 -9
- package/tests/agent.json +14 -3
- package/tests/client.json +5 -0
- package/tests/index.js +44 -9
package/index.js
CHANGED
|
@@ -18,6 +18,8 @@ class Deva {
|
|
|
18
18
|
this._client = {}; // this will be set on init.
|
|
19
19
|
this._active = false; // the active/birth date.
|
|
20
20
|
this._vector = false; // inherited Vector features.
|
|
21
|
+
this._veda = false; // inherited Veda features.
|
|
22
|
+
this._king = false; // inherited King features.
|
|
21
23
|
this._treasury = false; // inherited Vector features.
|
|
22
24
|
this._security = false; // inherited Security features.
|
|
23
25
|
this._guard = false; // inherited Guard features.
|
|
@@ -298,6 +300,17 @@ class Deva {
|
|
|
298
300
|
/**************
|
|
299
301
|
func: Vector
|
|
300
302
|
params: resolve, reject
|
|
303
|
+
describe:
|
|
304
|
+
The Vector feature sets the correct variables and necessary rules for the
|
|
305
|
+
client presented data.
|
|
306
|
+
***************/
|
|
307
|
+
Vector(resolve, reject) {
|
|
308
|
+
return this.Feature('vector', resolve, reject);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**************
|
|
312
|
+
func: Veda
|
|
313
|
+
params: resolve, reject
|
|
301
314
|
describe:
|
|
302
315
|
The Veda feature sets the correct variables and necessary rules for the
|
|
303
316
|
client presented data.
|
|
@@ -307,14 +320,14 @@ class Deva {
|
|
|
307
320
|
}
|
|
308
321
|
|
|
309
322
|
/**************
|
|
310
|
-
func:
|
|
323
|
+
func: King
|
|
311
324
|
params: resolve, reject
|
|
312
325
|
describe:
|
|
313
|
-
The
|
|
326
|
+
The King feature sets the correct variables and necessary rules for the
|
|
314
327
|
client presented data.
|
|
315
328
|
***************/
|
|
316
|
-
|
|
317
|
-
return this.Feature('
|
|
329
|
+
King(resolve, reject) {
|
|
330
|
+
return this.Feature('king', resolve, reject);
|
|
318
331
|
}
|
|
319
332
|
|
|
320
333
|
/**************
|
|
@@ -835,10 +848,12 @@ class Deva {
|
|
|
835
848
|
this.action('init');
|
|
836
849
|
this.state('init');
|
|
837
850
|
return this.Client(client, resolve, reject);
|
|
851
|
+
}).then(() => {
|
|
852
|
+
return this.Vector(resolve, reject);
|
|
838
853
|
}).then(() => {
|
|
839
854
|
return this.Veda(resolve, reject);
|
|
840
855
|
}).then(() => {
|
|
841
|
-
return this.
|
|
856
|
+
return this.King(resolve, reject);
|
|
842
857
|
}).then(() => {
|
|
843
858
|
return this.Treasury(resolve, reject);
|
|
844
859
|
}).then(() => {
|
|
@@ -910,15 +925,16 @@ class Deva {
|
|
|
910
925
|
const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
|
|
911
926
|
|
|
912
927
|
this.state('start', data.id);
|
|
928
|
+
this.talk(config.events.start, data);
|
|
913
929
|
return hasOnStart ? this.onStart(data, resolve) : this.enter(data, resolve)
|
|
914
930
|
}
|
|
915
931
|
|
|
916
932
|
/**************
|
|
917
933
|
func: enter
|
|
918
934
|
params:
|
|
919
|
-
- msg:
|
|
935
|
+
- msg: the message from the caller incase need to use in calls
|
|
920
936
|
describe:
|
|
921
|
-
The
|
|
937
|
+
The enter function will check the active status of the Deva and set it to
|
|
922
938
|
offline or enter.
|
|
923
939
|
|
|
924
940
|
If the Deva is offline it will return the offline message.
|
|
@@ -942,6 +958,7 @@ class Deva {
|
|
|
942
958
|
data.sha512 = this.lib.hash(data, 'sha512');
|
|
943
959
|
|
|
944
960
|
this.state('enter', data.id);
|
|
961
|
+
this.talk(config.events.enter, data);
|
|
945
962
|
return hasOnEnter ? this.onEnter(data, resolve) : this.done(data, resolve)
|
|
946
963
|
}
|
|
947
964
|
|
|
@@ -974,6 +991,7 @@ class Deva {
|
|
|
974
991
|
data.sha512 = this.lib.hash(data, 'sha512');
|
|
975
992
|
|
|
976
993
|
this.state('done', data.id);
|
|
994
|
+
this.talk(config.events.done, data);
|
|
977
995
|
return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
|
|
978
996
|
}
|
|
979
997
|
|
|
@@ -1003,6 +1021,7 @@ class Deva {
|
|
|
1003
1021
|
data.sha512 = this.lib.hash(data, 'sha512');
|
|
1004
1022
|
|
|
1005
1023
|
this.state('ready', data.id);
|
|
1024
|
+
this.talk(config.events.ready, data);
|
|
1006
1025
|
return hasOnReady ? this.onReady(data, resolve) : resolve(data);
|
|
1007
1026
|
}
|
|
1008
1027
|
|
|
@@ -1034,6 +1053,7 @@ class Deva {
|
|
|
1034
1053
|
data.sha512 = this.lib.hash(data, 'sha512');
|
|
1035
1054
|
|
|
1036
1055
|
this.state('finish', data.id); // set finish state
|
|
1056
|
+
this.talk(config.events.finish, data);
|
|
1037
1057
|
return hasOnFinish ? this.onFinish(data, resolve) : this.complete(data, resolve);
|
|
1038
1058
|
}
|
|
1039
1059
|
|
|
@@ -1063,6 +1083,7 @@ class Deva {
|
|
|
1063
1083
|
data.sha512 = this.lib.hash(data, 'sha512');
|
|
1064
1084
|
|
|
1065
1085
|
this.state('complete', data.id);
|
|
1086
|
+
this.talk(config.events.complete, data);
|
|
1066
1087
|
return hasOnComplete ? this.onComplete(data, resolve) : resolve(data);
|
|
1067
1088
|
}
|
|
1068
1089
|
|
|
@@ -1103,6 +1124,7 @@ class Deva {
|
|
|
1103
1124
|
// has stop function then set hasOnStop variable
|
|
1104
1125
|
// if: has on stop then run on stop function or return exit function.
|
|
1105
1126
|
this.state('stop', id); // set the state to stop
|
|
1127
|
+
this.talk(config.events.stop, data);
|
|
1106
1128
|
return hasOnStop ? this.onStop(data) : this.exit()
|
|
1107
1129
|
}
|
|
1108
1130
|
|
|
@@ -1138,6 +1160,8 @@ class Deva {
|
|
|
1138
1160
|
data.sha512 = this.lib.hash(data, 'sha512');
|
|
1139
1161
|
|
|
1140
1162
|
this.state('exit', id); // set the state to stop
|
|
1163
|
+
this.talk(config.events.exit, data);
|
|
1164
|
+
|
|
1141
1165
|
// clear memory
|
|
1142
1166
|
this._active = false;
|
|
1143
1167
|
this._client = false;
|
|
@@ -1515,6 +1539,16 @@ class Deva {
|
|
|
1515
1539
|
return this._getFeature('veda', this._vector);
|
|
1516
1540
|
}
|
|
1517
1541
|
|
|
1542
|
+
/**************
|
|
1543
|
+
func: king
|
|
1544
|
+
params: none
|
|
1545
|
+
describe: basic king features available in a Deva.
|
|
1546
|
+
usage: this.king()
|
|
1547
|
+
***************/
|
|
1548
|
+
king() {
|
|
1549
|
+
return this._getFeature('king', this._vector);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1518
1552
|
/**************
|
|
1519
1553
|
func: vector
|
|
1520
1554
|
params: none
|
package/lib/index.js
CHANGED
|
@@ -49,21 +49,23 @@ class LIB {
|
|
|
49
49
|
The uid function can create two types of id for you.
|
|
50
50
|
1. random GUID - this is good for when you need a uinique record id returned
|
|
51
51
|
2. transport id - The transport id is a number generated to provide a
|
|
52
|
-
numerical number used for transporting records
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
secure numerical number used for transporting records
|
|
53
|
+
across networks without collision or needing to store system uuid.
|
|
54
|
+
copyright: 2025 Quinn A Michaels. All rights reserved.
|
|
55
55
|
***************/
|
|
56
|
-
uid(guid=false) {
|
|
57
|
-
|
|
56
|
+
uid(guid=false) {
|
|
57
|
+
const time = Date.now();
|
|
58
58
|
if (guid) {
|
|
59
|
-
|
|
59
|
+
const guid = randomUUID(); // set guid into local variable for testing.
|
|
60
|
+
return guid; // return the guid.
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
62
|
-
const min =
|
|
63
|
-
const max =
|
|
64
|
-
|
|
63
|
+
const min = Math.floor(time - (time / Math.PI)); // generate min time from Math.PI divisor.
|
|
64
|
+
const max = Math.ceil(time + (time * Math.PI)); // generate max time form Math.PI multiplier.
|
|
65
|
+
const begin_random = Math.floor(Math.random() * (max - min) + min); // generate random number between min and max.
|
|
66
|
+
const end_random = Math.ceil(Math.random() * (99999 - 10000) + 10000); // generate the 5 digit end salt on the number for added randomness.
|
|
67
|
+
return `${begin_random}${end_random}`; // return the complete random uid.
|
|
65
68
|
}
|
|
66
|
-
return id;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
/**************
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "9f0bc743-d720-4320-832e-cf5edc3b7cf",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.54",
|
|
5
5
|
"description": "The Deva Core",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"copyright": "(c)2025 Quinn Michaels; All rights reserved.",
|
|
@@ -68,6 +68,14 @@
|
|
|
68
68
|
"events": {
|
|
69
69
|
"prompt": "devacore:prompt",
|
|
70
70
|
"error": "devacore:error",
|
|
71
|
+
"start": "devacore:start",
|
|
72
|
+
"enter": "devacore:enter",
|
|
73
|
+
"done": "devacore:done",
|
|
74
|
+
"ready": "devacore:ready",
|
|
75
|
+
"finish": "devacore:finish",
|
|
76
|
+
"complete": "devacore:complete",
|
|
77
|
+
"stop": "devacore:stop",
|
|
78
|
+
"exit": "devacore:exit",
|
|
71
79
|
"question": "devacore:question",
|
|
72
80
|
"answer": "devacore:answer",
|
|
73
81
|
"ask": "devacore:ask",
|
|
@@ -90,7 +98,7 @@
|
|
|
90
98
|
"init": "π Init",
|
|
91
99
|
"start": "π’ Start",
|
|
92
100
|
"enter": "πͺ Enter",
|
|
93
|
-
"done": "
|
|
101
|
+
"done": "βοΈ Done",
|
|
94
102
|
"ready": "βοΈ Ready",
|
|
95
103
|
"finish": "π Finish",
|
|
96
104
|
"complete": "β
Complete",
|
|
@@ -99,8 +107,9 @@
|
|
|
99
107
|
"deva": "β‘οΈ Deva",
|
|
100
108
|
"agent": "π€ Agent",
|
|
101
109
|
"client": "π¨ Client",
|
|
102
|
-
"veda": "ποΈ Veda",
|
|
103
110
|
"vector": "π€οΈ Vector",
|
|
111
|
+
"veda": "ποΈ Veda",
|
|
112
|
+
"king": "ποΈ King",
|
|
104
113
|
"treasury": "π¦οΈ Treasury",
|
|
105
114
|
"security": "π¨ Security",
|
|
106
115
|
"guard": "π Guard",
|
|
@@ -141,7 +150,7 @@
|
|
|
141
150
|
"init": "π Init",
|
|
142
151
|
"start": "π’ Start",
|
|
143
152
|
"enter": "πͺ Enter",
|
|
144
|
-
"done": "
|
|
153
|
+
"done": "βοΈ Done",
|
|
145
154
|
"ready": "βοΈ Ready",
|
|
146
155
|
"finish": "π Finish",
|
|
147
156
|
"complete": "β
Complete",
|
|
@@ -175,7 +184,7 @@
|
|
|
175
184
|
"help": "π Help",
|
|
176
185
|
"authorized": "π Authorized",
|
|
177
186
|
"unauthorized": "π΄ββ οΈ Unauthorized",
|
|
178
|
-
"Done": "βοΈ
|
|
187
|
+
"Done": "βοΈ Done",
|
|
179
188
|
"glitch": "π‘ Glitch",
|
|
180
189
|
"intruder": "π¦ΉββοΈ Intruder",
|
|
181
190
|
"snooper": "π Snooper",
|
|
@@ -200,8 +209,9 @@
|
|
|
200
209
|
"actions": {
|
|
201
210
|
"client": "π¨ Client",
|
|
202
211
|
"agent": "π΅οΈββοΈ Agent",
|
|
203
|
-
"veda": "ποΈ Veda",
|
|
204
212
|
"vector": "π½ Vector",
|
|
213
|
+
"veda": "ποΈ Veda",
|
|
214
|
+
"king": "ποΈ King",
|
|
205
215
|
"security": "π¨ Security",
|
|
206
216
|
"guard": "π Guard",
|
|
207
217
|
"shield": "π‘οΈ Shield",
|
|
@@ -243,7 +253,7 @@
|
|
|
243
253
|
"status": "π₯ Status",
|
|
244
254
|
"error": "π£ Error",
|
|
245
255
|
"help": "π Help",
|
|
246
|
-
"done": "
|
|
256
|
+
"done": "βοΈ Done",
|
|
247
257
|
"ready": "βοΈ Ready",
|
|
248
258
|
"complete": "β
Complete"
|
|
249
259
|
},
|
|
@@ -252,8 +262,9 @@
|
|
|
252
262
|
"init": "π Init",
|
|
253
263
|
"agent": "π¦Ύ Agent",
|
|
254
264
|
"client": "πͺ Client",
|
|
255
|
-
"veda": "ποΈ Veda",
|
|
256
265
|
"vector": "π€οΈ Vector",
|
|
266
|
+
"veda": "ποΈ Veda",
|
|
267
|
+
"king": "ποΈ King",
|
|
257
268
|
"treasury": "π¦ Treasury",
|
|
258
269
|
"security": "π¨ Security",
|
|
259
270
|
"guard": "π Guard",
|
|
@@ -274,7 +285,7 @@
|
|
|
274
285
|
"init": "π INIT",
|
|
275
286
|
"start": "π’ START",
|
|
276
287
|
"enter": "π΅ ENTER",
|
|
277
|
-
"done": "
|
|
288
|
+
"done": "βοΈ DONE",
|
|
278
289
|
"ready": "βοΈ READY",
|
|
279
290
|
"stop": "π΄ STOP",
|
|
280
291
|
"exit": "πͺ EXIT",
|
package/tests/agent.json
CHANGED
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
"gender": "M"
|
|
31
31
|
},
|
|
32
32
|
"features": {
|
|
33
|
+
"vector": {
|
|
34
|
+
"label": "π€οΈVECTOR",
|
|
35
|
+
"name": "@VECTOR",
|
|
36
|
+
"tag": "#VECTOR",
|
|
37
|
+
"loc": "$VECTOR"
|
|
38
|
+
},
|
|
33
39
|
"security": {
|
|
34
40
|
"label": "π¨SECURITY",
|
|
35
41
|
"name": "@SECURITY",
|
|
@@ -88,11 +94,16 @@
|
|
|
88
94
|
"vars": {
|
|
89
95
|
"hello": "Hellow World",
|
|
90
96
|
"context": {
|
|
91
|
-
"
|
|
97
|
+
"start": "ποΈ Start",
|
|
98
|
+
"enter": "πͺοΈ Enter",
|
|
99
|
+
"done": "β
Done",
|
|
100
|
+
"ready": "π Ready",
|
|
101
|
+
"finish": "π Finish",
|
|
102
|
+
"complete": "π€ Complete",
|
|
92
103
|
"test": "πΏ Test Data",
|
|
93
104
|
"prompt": "π» Prompt",
|
|
94
|
-
"feature": "πΏ
|
|
95
|
-
"zone": "π»
|
|
105
|
+
"feature": "πΏ Feature",
|
|
106
|
+
"zone": "π» Zone"
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
}
|
package/tests/client.json
CHANGED
package/tests/index.js
CHANGED
|
@@ -57,6 +57,24 @@ const DevaTest = new Deva({
|
|
|
57
57
|
'devacore:question'(packet) {
|
|
58
58
|
console.log(`πββοΈοΈ question: ${packet.text}`);
|
|
59
59
|
},
|
|
60
|
+
'devacore:start'(packet) {
|
|
61
|
+
console.log(`π’ start: ${packet.text}`);
|
|
62
|
+
},
|
|
63
|
+
'devacore:enter'(packet) {
|
|
64
|
+
console.log(`πͺ enter: ${packet.text}`);
|
|
65
|
+
},
|
|
66
|
+
'devacore:done'(packet) {
|
|
67
|
+
console.log(`βοΈ done: ${packet.text}`);
|
|
68
|
+
},
|
|
69
|
+
'devacore:ready'(packet) {
|
|
70
|
+
console.log(`βοΈ ready: ${packet.text}`);
|
|
71
|
+
},
|
|
72
|
+
'devacore:finish'(packet) {
|
|
73
|
+
console.log(`π finish: ${packet.text}`);
|
|
74
|
+
},
|
|
75
|
+
'devacore:complete'(packet) {
|
|
76
|
+
console.log(`β
complete: ${packet.text}`);
|
|
77
|
+
},
|
|
60
78
|
'devacore:answer'(packet) {
|
|
61
79
|
console.log(`π¨βπ¬ answer: ${packet.text}`);
|
|
62
80
|
},
|
|
@@ -73,12 +91,11 @@ const DevaTest = new Deva({
|
|
|
73
91
|
console.log(`π₯ action: ${packet.text}`);
|
|
74
92
|
},
|
|
75
93
|
'devacore:feature'(packet) {
|
|
76
|
-
console.log(`---`);
|
|
77
94
|
this.context('feature');
|
|
78
95
|
console.log(`πΏ feature: ${packet.text}`);
|
|
79
96
|
},
|
|
80
97
|
'devacore:context'(packet) {
|
|
81
|
-
console.log(
|
|
98
|
+
console.log(`\nπΉ context: ${packet.text}`);
|
|
82
99
|
},
|
|
83
100
|
'devacore:error'(packet) {
|
|
84
101
|
console.log(`β error: ${packet.text}`);
|
|
@@ -89,13 +106,8 @@ const DevaTest = new Deva({
|
|
|
89
106
|
func: {
|
|
90
107
|
test(packet) {
|
|
91
108
|
const text = this._state
|
|
92
|
-
const id = this.lib.uid();
|
|
93
|
-
const uid = this.lib.uid(true);
|
|
94
109
|
const core = this.core();
|
|
95
110
|
const info = this.info();
|
|
96
|
-
const date = Date.now();
|
|
97
|
-
const hashstr = `${id}${uid}${date}`;
|
|
98
|
-
const proxy = this.proxy(hashstr);
|
|
99
111
|
const data = [
|
|
100
112
|
'π§ͺ TEST RESULTS',
|
|
101
113
|
`::BEGIN:CORE:${core.id}`,
|
|
@@ -117,9 +129,32 @@ const DevaTest = new Deva({
|
|
|
117
129
|
return this.func.test(packet);
|
|
118
130
|
}
|
|
119
131
|
},
|
|
132
|
+
onStart(data, resolve) {
|
|
133
|
+
this.context('start', data.id);
|
|
134
|
+
return this.enter(data, resolve);
|
|
135
|
+
},
|
|
136
|
+
onEnter(data, resolve) {
|
|
137
|
+
this.context('enter', data.id);
|
|
138
|
+
return this.done(data, resolve);
|
|
139
|
+
},
|
|
140
|
+
onDone(data, resolve) {
|
|
141
|
+
this.context('done', data.id);
|
|
142
|
+
return this.ready(data, resolve);
|
|
143
|
+
},
|
|
120
144
|
onReady(data, resolve) {
|
|
121
|
-
this.context('ready');
|
|
122
|
-
this.
|
|
145
|
+
this.context('ready', data.id);
|
|
146
|
+
const test = this.methods.test(data);
|
|
147
|
+
this.prompt(test.text);
|
|
148
|
+
setTimeout(() => {
|
|
149
|
+
return resolve(data);
|
|
150
|
+
}, 10000);
|
|
151
|
+
},
|
|
152
|
+
onFinish(data, resolve) {
|
|
153
|
+
this.context('finish', data.id);
|
|
154
|
+
return this.complete(data, resolve);
|
|
155
|
+
},
|
|
156
|
+
onComplete(data, resolve) {
|
|
157
|
+
this.context('complete', data.id);
|
|
123
158
|
return resolve(data);
|
|
124
159
|
},
|
|
125
160
|
onError(e) {
|