@indra.ai/deva 1.3.8 → 1.3.10

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/config.json CHANGED
@@ -49,6 +49,7 @@
49
49
  "legal": "🏛️ Legal",
50
50
  "authority": "🚔 Authority",
51
51
  "justice": "⚖️ Justice",
52
+ "defense": "🪖 Defense",
52
53
  "help": "💚 Help",
53
54
  "error": "❌ Error!"
54
55
  },
@@ -122,7 +123,8 @@
122
123
  "official": "🫡 Official",
123
124
  "unofficial": "🤥 Unofficial",
124
125
  "approved": "🎖️ Approved",
125
- "denied": "🖕 Denied"
126
+ "denied": "🖕 Denied",
127
+ "secure": "🔏 Secure"
126
128
  },
127
129
  "action": false,
128
130
  "actions": {
@@ -139,9 +141,9 @@
139
141
  "done": "☑️ Done",
140
142
  "ready": "🟢 Ready",
141
143
  "question": "🙋 Question",
142
- "talk": "📢 talk",
143
- "context": "📇 context",
144
- "prompt": "🐚 prompt",
144
+ "talk": "📢 Talk",
145
+ "context": "📇 Context",
146
+ "prompt": "🐚 Prompt",
145
147
  "issue": "🎫 Issue",
146
148
  "find": "🔎 Find",
147
149
  "parse": "🏘️ Parse",
@@ -153,7 +155,7 @@
153
155
  "status": "🚥 Status",
154
156
  "func": "🔦 Function",
155
157
  "method": "❤️‍🔥 Method",
156
- "list": "📋 List items",
158
+ "list": "📋 List",
157
159
  "reply": "📮 Reply",
158
160
  "write": "️📝 Write",
159
161
  "set": "🍽️ Set",
@@ -175,21 +177,22 @@
175
177
  "client": "👨 Client",
176
178
  "agent": "🕵️‍♂️ Agent",
177
179
  "security": "🔐 Security",
178
- "support": "🩹 Support",
180
+ "support": "🩹 Support",
179
181
  "services": "🛠️ Services",
180
182
  "systems": "🖥️ Systems",
181
183
  "networks": "📡 Networks",
182
184
  "legal": "🗃️ Legal",
183
185
  "justice": "🗄️ Justice",
184
186
  "authority": "👮 Authority",
187
+ "defense": "🪖 Defense",
185
188
 
186
189
  "invalid": "❌ Invalid",
187
190
  "states": "🛻 States",
188
191
  "actions": "🏎️ Actions",
189
192
  "zones": "Zones",
190
193
  "feature": "🎥 Feature",
191
- "features": "🎥 Getting features",
192
- "contexts": "🌈 Getting contexts",
194
+ "features": "🎥 Features",
195
+ "contexts": "🌈 Contexts",
193
196
  "help": "💜 Help",
194
197
  "error": "🔴 ERROR!",
195
198
  "lawful": "🚓 Lawful",
@@ -215,6 +218,7 @@
215
218
  "legal": "🗂️️️ Legal",
216
219
  "justice": "🏛️️ Justice",
217
220
  "authority": "🚓️️ Authority",
221
+ "defense": "🪖️️ Defense",
218
222
  "cipher": "🔒 Cipher",
219
223
  "decipher": "🔓 Decipher",
220
224
  "promp": "🪵 Prompt",
package/index.js CHANGED
@@ -24,7 +24,8 @@ class Deva {
24
24
  this._networks = false; // inherited Systems features.
25
25
  this._legal = false; // inherited Legal features.
26
26
  this._justice = false; // inherited Justice features.
27
- this._authority = false; // inherited Justice features.
27
+ this._authority = false; // inherited Authority features.
28
+ this._defense = false; // inherited Defense features.
28
29
  this.events = opts.events || new EventEmitter({}); // Event Bus
29
30
  this.lib = new lib({}); // used for loading library functions
30
31
  this.utils = opts.utils || {}; // parse function
@@ -342,16 +343,28 @@ class Deva {
342
343
  return this.Feature('authority', resolve, reject);
343
344
  }
344
345
 
346
+ /**************
347
+ func: Defense
348
+ params: client: false
349
+ describe:
350
+ The Defense feature sets the correct variables and necessary rules for the
351
+ client presented data.
352
+ ***************/
353
+ Defense(resolve, reject) {
354
+ return this.Feature('defense', resolve, reject);
355
+ }
356
+
345
357
  /**************
346
358
  func: Done
347
359
  params: none
348
360
  describe: The end of the workflow Client Feature Workflow
349
361
  ***************/
350
362
  Done(resolve, reject) {
351
- this.action('done');
363
+ this.action('done', 'init');
352
364
  try {
353
- this.state('Done');
365
+ this.state('secure', 'data');
354
366
  delete this._client.features; // delete the features key when done.
367
+ this.state('resolve', 'init');
355
368
  return resolve(this.client()); // resolve an empty pr
356
369
  } catch (e) {
357
370
  this.state('reject', 'Done');
@@ -681,28 +694,46 @@ class Deva {
681
694
  }).then(() => {
682
695
  return this._assignListeners();
683
696
  }).then(() => {
684
- this.feature('init');
685
- this.zone('init');
686
- this.action('init');
687
- this.state('init');
688
697
  return this.Client(client, resolve, reject);
689
- }).then(() => {
698
+ }).then(part => {
699
+ this.state('done', 'client');
700
+ this.action('done', 'client');
690
701
  return this.Security(resolve, reject);
691
- }).then(() => {
702
+ }).then(part => {
703
+ this.state('done', 'security');
704
+ this.action('done', 'security');
692
705
  return this.Support(resolve, reject);
693
706
  }).then(() => {
707
+ this.state('done', 'support');
708
+ this.action('done', 'support');
694
709
  return this.Services(resolve, reject);
695
710
  }).then(() => {
711
+ this.state('done', 'services');
712
+ this.action('done', 'services');
696
713
  return this.Systems(resolve, reject);
697
714
  }).then(() => {
715
+ this.state('done', 'systems');
716
+ this.action('done', 'systems');
698
717
  return this.Networks(resolve, reject);
699
718
  }).then(() => {
719
+ this.state('done', 'networks');
720
+ this.action('done', 'networks');
700
721
  return this.Legal(resolve, reject);
701
722
  }).then(() => {
723
+ this.state('done', 'legal');
724
+ this.action('done', 'legal');
725
+ return this.Authority(resolve, reject);
726
+ }).then(() => {
727
+ this.state('done', 'authority');
728
+ this.action('done', 'authority');
702
729
  return this.Justice(resolve, reject);
703
730
  }).then(() => {
704
- return this.Authority(resolve, reject);
731
+ this.state('done', 'justice');
732
+ this.action('done', 'justice');
733
+ return this.Defense(resolve, reject);
705
734
  }).then(() => {
735
+ this.state('done', 'defense');
736
+ this.action('done', 'defense');
706
737
  return this.Done(resolve, reject);
707
738
  }).then(() => {
708
739
  const hasOnInit = this.onInit && typeof this.onInit === 'function';
@@ -747,7 +778,7 @@ class Deva {
747
778
  usage: this.enter('msg')
748
779
  ***************/
749
780
  enter(data, resolve) {
750
- this.zone('deva');
781
+ this.zone('enter');
751
782
  if (!this._active) return Promise.resolve(this._messages.offline);
752
783
  this.action('enter');
753
784
  data.value = 'enter';
@@ -777,35 +808,9 @@ class Deva {
777
808
  data.hash = this.lib.hash(data);
778
809
  const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
779
810
  this.state('done');
780
- return hasOnDone ? this.onDone(data, resolve) : this.ready(data, resolve);
811
+ return hasOnDone ? this.onDone(data, resolve) : this.finish(data, resolve);
781
812
  }
782
813
 
783
- /**************
784
- func: ready
785
- params:
786
- - packet: the data to pass to the resolve
787
- - resolve: the complete resolve to pass back
788
- describe: This function is use to relay the Agent ito a complete state when
789
- resolving a question or data.
790
- usage: this.complete(data, resolve)
791
- ***************/
792
- ready(packet, resolve) {
793
- if (!this._active) return Promise.resolve(this._messages.offline);
794
- this.action('ready'); // set the complete action
795
-
796
- packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
797
- // check for agent on complete function in agent
798
- const hasOnReady = this.onReady && typeof this.onReady === 'function';
799
-
800
- // if: agent has on complete then return on complete
801
- this.state('ready'); // set the finish state
802
-
803
- // return the provided resolve function or a promise resolve.
804
- return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
805
- }
806
-
807
-
808
-
809
814
  /**************
810
815
  func: finish
811
816
  params:
@@ -849,9 +854,33 @@ class Deva {
849
854
  // if: agent has on complete then return on complete
850
855
  this.state('complete'); // set the finish state
851
856
  // return the provided resolve function or a promise resolve.
852
- return hasOnComplete ? this.onComplete(packet) : resolve(packet);
857
+ return hasOnComplete ? this.onComplete(packet) : this.ready(packet, resolve);
853
858
  }
854
859
 
860
+ /**************
861
+ func: ready
862
+ params:
863
+ - packet: the data to pass to the resolve
864
+ - resolve: the complete resolve to pass back
865
+ describe: This function is use to relay the Agent ito a complete state when
866
+ resolving a question or data.
867
+ usage: this.complete(data, resolve)
868
+ ***************/
869
+ ready(packet, resolve) {
870
+ if (!this._active) return Promise.resolve(this._messages.offline);
871
+ this.action('ready'); // set the complete action
872
+
873
+ packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
874
+ // check for agent on complete function in agent
875
+ const hasOnReady = this.onReady && typeof this.onReady === 'function';
876
+
877
+ // if: agent has on complete then return on complete
878
+ this.state('ready'); // set the finish state
879
+
880
+ // return the provided resolve function or a promise resolve.
881
+ return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
882
+ }
883
+
855
884
  /**************
856
885
  func: stop
857
886
  params:
@@ -1265,11 +1294,29 @@ class Deva {
1265
1294
  }
1266
1295
  }
1267
1296
 
1297
+ /**************
1298
+ func: networks
1299
+ params: none
1300
+ describe: basic networks features available in a Deva.
1301
+ usage: this.networks()
1302
+ ***************/
1303
+ networks() {
1304
+ if (!this._active) return this._messages.offline; // check the active status
1305
+ this.zone('networks');
1306
+ this.feature('networks'); // set the support state
1307
+ try {
1308
+ this.state('return', 'networks'); // set the networks state
1309
+ return this.lib.copy(this._networks); // return the systems feature
1310
+ } catch (e) {
1311
+ return this.error(e); // return this.error when error catch
1312
+ }
1313
+ }
1314
+
1268
1315
  /**************
1269
1316
  func: legal
1270
1317
  params: none
1271
1318
  describe: basic legal features available in a Deva.
1272
- usage: this.systems()
1319
+ usage: this.legal()
1273
1320
  ***************/
1274
1321
  legal() {
1275
1322
  if (!this._active) return this._messages.offline; // check the active status
@@ -1287,7 +1334,7 @@ class Deva {
1287
1334
  func: justice
1288
1335
  params: none
1289
1336
  describe: basic justice features available in a Deva.
1290
- usage: this.systems()
1337
+ usage: this.justice()
1291
1338
  ***************/
1292
1339
  justice() {
1293
1340
  if (!this._active) return this._messages.offline; // check the active status
@@ -1305,7 +1352,7 @@ class Deva {
1305
1352
  func: authority
1306
1353
  params: none
1307
1354
  describe: basic authority features available in a Deva.
1308
- usage: this.systems()
1355
+ usage: this.authority()
1309
1356
  ***************/
1310
1357
  authority() {
1311
1358
  if (!this._active) return this._messages.offline; // check the active status
@@ -1319,6 +1366,24 @@ class Deva {
1319
1366
  }
1320
1367
  }
1321
1368
 
1369
+ /**************
1370
+ func: defense
1371
+ params: none
1372
+ describe: basic defense features available in a Deva.
1373
+ usage: this.defense()
1374
+ ***************/
1375
+ defense() {
1376
+ if (!this._active) return this._messages.offline; // check the active status
1377
+ this.zone('defense');
1378
+ this.feature('defense'); // set the support state
1379
+ try {
1380
+ this.state('return', 'defense'); // set the systems state
1381
+ return this.lib.copy(this._defense); // return the systems feature
1382
+ } catch (e) {
1383
+ return this.error(e); // return this.error when error catch
1384
+ }
1385
+ }
1386
+
1322
1387
  /**************
1323
1388
  func: load
1324
1389
  params:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/tests/agent.json CHANGED
@@ -21,10 +21,6 @@
21
21
  }
22
22
  }
23
23
  },
24
- "voice": {
25
- "speech": "Alex",
26
- "speed": 1
27
- },
28
24
  "profile": {
29
25
  "name": "Deva",
30
26
  "describe": "The Indra interface into deva.world.",
@@ -75,10 +71,23 @@
75
71
  "name": "@JUSTICE",
76
72
  "tag": "#JUSTICE",
77
73
  "loc": "$JUSTICE"
74
+ },
75
+ "defense": {
76
+ "label": "🪖DEFENSE",
77
+ "name": "@DEFENSE",
78
+ "tag": "#DEFENSE",
79
+ "loc": "$DEFENSE"
78
80
  }
79
81
  },
80
82
  "vars": {
81
- "hello": "Hellow World"
83
+ "hello": "Hellow World",
84
+ "context": {
85
+ "ready": "🤝 Everything is ready!",
86
+ "test": "💿 Test Data",
87
+ "prompt": "💻 Prompt",
88
+ "feature": "🍿 Accessing Feature",
89
+ "zone": "🗻 Accessing Zone"
90
+ }
82
91
  }
83
92
  }
84
93
  }
package/tests/client.json CHANGED
@@ -86,6 +86,11 @@
86
86
  "concerns": [],
87
87
  "global": [],
88
88
  "devas": {}
89
+ },
90
+ "defense": {
91
+ "concerns": [],
92
+ "global": [],
93
+ "devas": {}
89
94
  }
90
95
  }
91
96
  }
package/tests/index.js CHANGED
@@ -9,11 +9,7 @@ const agent = Agent.DATA;
9
9
 
10
10
  import Deva from '../index.js';
11
11
 
12
- const HelloWorld = new Deva({
13
- client: {
14
- id: 100,
15
- key: 'hello',
16
- },
12
+ const DevaTest = new Deva({
17
13
  agent: {
18
14
  id: agent.id,
19
15
  key: agent.key,
@@ -26,11 +22,15 @@ const HelloWorld = new Deva({
26
22
  },
27
23
  parse(input) {
28
24
  return input.trim();
25
+ },
26
+ process(input) {
27
+ return input.trim();
29
28
  }
30
29
  },
31
30
  vars: agent.vars,
32
31
  listeners: {
33
32
  'devacore:prompt'(packet) {
33
+ this.context('prompt');
34
34
  console.log(`👔 prompt: ${packet.text}`);
35
35
  },
36
36
  'devacore:question'(packet) {
@@ -53,8 +53,12 @@ const HelloWorld = new Deva({
53
53
  },
54
54
  'devacore:feature'(packet) {
55
55
  console.log(`---`);
56
+ this.context('feature');
56
57
  console.log(`🍿 feature: ${packet.text}`);
57
58
  },
59
+ 'devacore:context'(packet) {
60
+ console.log(`🛹 context: ${packet.text}`);
61
+ },
58
62
  'devacore:error'(packet) {
59
63
  console.log(`❌ error: ${packet.text}`);
60
64
  },
@@ -64,43 +68,41 @@ const HelloWorld = new Deva({
64
68
  func: {
65
69
  test(packet) {
66
70
  const text = this._state
67
- const id = this.uid();
68
- const uuid = this.uid(true);
69
-
70
- const cipher = this.cipher(JSON.stringify(packet));
71
- const decipher = this.decipher(cipher);
72
-
73
- const data = {
74
- id,
75
- uuid,
76
- text,
77
- hash: {
78
- md5: this.hash(JSON.stringify(packet)),
79
- sha256: this.hash(JSON.stringify(packet), 'sha256'),
80
- sha512: this.hash(JSON.stringify(packet), 'sha512'),
81
- created: this.formatDate(Date.now(), 'long'),
82
- },
83
- cipher,
84
- decipher
85
- }
86
- console.log(data)
87
- return Promise.resolve({
88
- text: packet.a.text,
71
+ const id = this.lib.uid();
72
+ const uid = this.lib.uid(true);
73
+ const data = [
74
+ `::BEGIN:DATA:${id}`,
75
+ `id: ${id}`,
76
+ `uid: ${uid}`,
77
+ `md5: ${this.lib.hash(packet)}`,
78
+ `sha256: ${this.lib.hash(packet, 'sha256')}`,
79
+ `sha512: ${this.lib.hash(packet, 'sha512')}`,
80
+ `date: ${this.lib.formatDate(Date.now(), 'long', true)}`,
81
+ `::END:DATA:${this.lib.hash(packet)}`,
82
+ ];
83
+ return {
84
+ text: data.join('\n'),
89
85
  data,
90
- });
86
+ };
91
87
  }
92
88
  },
93
89
  methods: {
94
90
  test(packet) {
91
+ this.context('test');
95
92
  return this.func.test(packet);
96
93
  }
97
94
  },
95
+ onReady(data, resolve) {
96
+ this.context('ready');
97
+ this.prompt(this.methods.test(data).text);
98
+ return resolve(data);
99
+ },
98
100
  onError(e) {
99
101
  console.log(e);
100
102
  }
101
103
  });
102
104
 
103
- HelloWorld.init(client);
105
+ DevaTest.init(client);
104
106
 
105
107
 
106
108
  // HelloWorld.question('/hello hello there').then(hello => {