@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 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: Vector
323
+ func: King
311
324
  params: resolve, reject
312
325
  describe:
313
- The Vector feature sets the correct variables and necessary rules for the
326
+ The King feature sets the correct variables and necessary rules for the
314
327
  client presented data.
315
328
  ***************/
316
- Vector(resolve, reject) {
317
- return this.Feature('vector', resolve, reject);
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.Vector(resolve, reject);
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: hte message from the caller incase need to use in calls
935
+ - msg: the message from the caller incase need to use in calls
920
936
  describe:
921
- The ener function will check the actie status of the Deva and set it to
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 to places
53
- like social networks, email, other networks where informaton
54
- is shared.
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
- let id;
56
+ uid(guid=false) {
57
+ const time = Date.now();
58
58
  if (guid) {
59
- id = randomUUID()
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 = `${Math.floor(Date.now() - (Date.now() / Math.PI))}00000`;
63
- const max = `${Math.ceil(Date.now() + (Date.now() * Math.PI))}99999`;
64
- id = Math.floor(Math.random() * (Number(max) - Number(min))) + Number(min);
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.53",
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": "🟣 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": "🟣 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": "β˜‘οΈ 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": "🟣 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": "🟣 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
- "ready": "🀝 Everything is ready!",
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": "🍿 Accessing Feature",
95
- "zone": "πŸ—» Accessing Zone"
105
+ "feature": "🍿 Feature",
106
+ "zone": "πŸ—» Zone"
96
107
  }
97
108
  }
98
109
  }
package/tests/client.json CHANGED
@@ -39,6 +39,11 @@
39
39
  "global": [],
40
40
  "devas": {}
41
41
  },
42
+ "king": {
43
+ "concerns": [],
44
+ "global": [],
45
+ "devas": {}
46
+ },
42
47
  "vector": {
43
48
  "concerns": [],
44
49
  "global": [],
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(`πŸ›Ή context: ${packet.text}`);
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.prompt(this.methods.test(data).text);
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) {