@indra.ai/deva 1.3.8 → 1.3.9
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 +12 -8
- package/index.js +107 -38
- package/package.json +1 -1
- package/tests/agent.json +14 -5
- package/tests/client.json +5 -0
- package/tests/index.js +31 -29
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": "📢
|
|
143
|
-
"context": "📇
|
|
144
|
-
"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
|
|
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": "🩹
|
|
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": "🎥
|
|
192
|
-
"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
|
|
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('
|
|
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');
|
|
@@ -686,23 +699,45 @@ class Deva {
|
|
|
686
699
|
this.action('init');
|
|
687
700
|
this.state('init');
|
|
688
701
|
return this.Client(client, resolve, reject);
|
|
689
|
-
}).then(
|
|
702
|
+
}).then(part => {
|
|
703
|
+
this.state('done', 'client');
|
|
704
|
+
this.action('done', 'client');
|
|
690
705
|
return this.Security(resolve, reject);
|
|
691
|
-
}).then(
|
|
706
|
+
}).then(part => {
|
|
707
|
+
this.state('done', 'security');
|
|
708
|
+
this.action('done', 'security');
|
|
692
709
|
return this.Support(resolve, reject);
|
|
693
710
|
}).then(() => {
|
|
711
|
+
this.state('done', 'support');
|
|
712
|
+
this.action('done', 'support');
|
|
694
713
|
return this.Services(resolve, reject);
|
|
695
714
|
}).then(() => {
|
|
715
|
+
this.state('done', 'services');
|
|
716
|
+
this.action('done', 'services');
|
|
696
717
|
return this.Systems(resolve, reject);
|
|
697
718
|
}).then(() => {
|
|
719
|
+
this.state('done', 'systems');
|
|
720
|
+
this.action('done', 'systems');
|
|
698
721
|
return this.Networks(resolve, reject);
|
|
699
722
|
}).then(() => {
|
|
723
|
+
this.state('done', 'networks');
|
|
724
|
+
this.action('done', 'networks');
|
|
700
725
|
return this.Legal(resolve, reject);
|
|
701
726
|
}).then(() => {
|
|
727
|
+
this.state('done', 'legal');
|
|
728
|
+
this.action('done', 'legal');
|
|
729
|
+
return this.Authority(resolve, reject);
|
|
730
|
+
}).then(() => {
|
|
731
|
+
this.state('done', 'authority');
|
|
732
|
+
this.action('done', 'authority');
|
|
702
733
|
return this.Justice(resolve, reject);
|
|
703
734
|
}).then(() => {
|
|
704
|
-
|
|
735
|
+
this.state('done', 'justice');
|
|
736
|
+
this.action('done', 'justice');
|
|
737
|
+
return this.Defense(resolve, reject);
|
|
705
738
|
}).then(() => {
|
|
739
|
+
this.state('done', 'defense');
|
|
740
|
+
this.action('done', 'defense');
|
|
706
741
|
return this.Done(resolve, reject);
|
|
707
742
|
}).then(() => {
|
|
708
743
|
const hasOnInit = this.onInit && typeof this.onInit === 'function';
|
|
@@ -747,7 +782,7 @@ class Deva {
|
|
|
747
782
|
usage: this.enter('msg')
|
|
748
783
|
***************/
|
|
749
784
|
enter(data, resolve) {
|
|
750
|
-
this.zone('
|
|
785
|
+
this.zone('enter');
|
|
751
786
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
752
787
|
this.action('enter');
|
|
753
788
|
data.value = 'enter';
|
|
@@ -777,35 +812,9 @@ class Deva {
|
|
|
777
812
|
data.hash = this.lib.hash(data);
|
|
778
813
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
779
814
|
this.state('done');
|
|
780
|
-
return hasOnDone ? this.onDone(data, resolve) : this.
|
|
815
|
+
return hasOnDone ? this.onDone(data, resolve) : this.finish(data, resolve);
|
|
781
816
|
}
|
|
782
817
|
|
|
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
818
|
/**************
|
|
810
819
|
func: finish
|
|
811
820
|
params:
|
|
@@ -849,9 +858,33 @@ class Deva {
|
|
|
849
858
|
// if: agent has on complete then return on complete
|
|
850
859
|
this.state('complete'); // set the finish state
|
|
851
860
|
// return the provided resolve function or a promise resolve.
|
|
852
|
-
return hasOnComplete ? this.onComplete(packet) :
|
|
861
|
+
return hasOnComplete ? this.onComplete(packet) : this.ready(packet, resolve);
|
|
853
862
|
}
|
|
854
863
|
|
|
864
|
+
/**************
|
|
865
|
+
func: ready
|
|
866
|
+
params:
|
|
867
|
+
- packet: the data to pass to the resolve
|
|
868
|
+
- resolve: the complete resolve to pass back
|
|
869
|
+
describe: This function is use to relay the Agent ito a complete state when
|
|
870
|
+
resolving a question or data.
|
|
871
|
+
usage: this.complete(data, resolve)
|
|
872
|
+
***************/
|
|
873
|
+
ready(packet, resolve) {
|
|
874
|
+
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
875
|
+
this.action('ready'); // set the complete action
|
|
876
|
+
|
|
877
|
+
packet.hash = this.lib.hash(packet);// hash the entire packet before completeing.
|
|
878
|
+
// check for agent on complete function in agent
|
|
879
|
+
const hasOnReady = this.onReady && typeof this.onReady === 'function';
|
|
880
|
+
|
|
881
|
+
// if: agent has on complete then return on complete
|
|
882
|
+
this.state('ready'); // set the finish state
|
|
883
|
+
|
|
884
|
+
// return the provided resolve function or a promise resolve.
|
|
885
|
+
return hasOnReady ? this.onReady(packet, resolve) : resolve(packet);
|
|
886
|
+
}
|
|
887
|
+
|
|
855
888
|
/**************
|
|
856
889
|
func: stop
|
|
857
890
|
params:
|
|
@@ -1265,11 +1298,29 @@ class Deva {
|
|
|
1265
1298
|
}
|
|
1266
1299
|
}
|
|
1267
1300
|
|
|
1301
|
+
/**************
|
|
1302
|
+
func: networks
|
|
1303
|
+
params: none
|
|
1304
|
+
describe: basic networks features available in a Deva.
|
|
1305
|
+
usage: this.networks()
|
|
1306
|
+
***************/
|
|
1307
|
+
networks() {
|
|
1308
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1309
|
+
this.zone('networks');
|
|
1310
|
+
this.feature('networks'); // set the support state
|
|
1311
|
+
try {
|
|
1312
|
+
this.state('return', 'networks'); // set the networks state
|
|
1313
|
+
return this.lib.copy(this._networks); // return the systems feature
|
|
1314
|
+
} catch (e) {
|
|
1315
|
+
return this.error(e); // return this.error when error catch
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1268
1319
|
/**************
|
|
1269
1320
|
func: legal
|
|
1270
1321
|
params: none
|
|
1271
1322
|
describe: basic legal features available in a Deva.
|
|
1272
|
-
usage: this.
|
|
1323
|
+
usage: this.legal()
|
|
1273
1324
|
***************/
|
|
1274
1325
|
legal() {
|
|
1275
1326
|
if (!this._active) return this._messages.offline; // check the active status
|
|
@@ -1287,7 +1338,7 @@ class Deva {
|
|
|
1287
1338
|
func: justice
|
|
1288
1339
|
params: none
|
|
1289
1340
|
describe: basic justice features available in a Deva.
|
|
1290
|
-
usage: this.
|
|
1341
|
+
usage: this.justice()
|
|
1291
1342
|
***************/
|
|
1292
1343
|
justice() {
|
|
1293
1344
|
if (!this._active) return this._messages.offline; // check the active status
|
|
@@ -1305,7 +1356,7 @@ class Deva {
|
|
|
1305
1356
|
func: authority
|
|
1306
1357
|
params: none
|
|
1307
1358
|
describe: basic authority features available in a Deva.
|
|
1308
|
-
usage: this.
|
|
1359
|
+
usage: this.authority()
|
|
1309
1360
|
***************/
|
|
1310
1361
|
authority() {
|
|
1311
1362
|
if (!this._active) return this._messages.offline; // check the active status
|
|
@@ -1319,6 +1370,24 @@ class Deva {
|
|
|
1319
1370
|
}
|
|
1320
1371
|
}
|
|
1321
1372
|
|
|
1373
|
+
/**************
|
|
1374
|
+
func: defense
|
|
1375
|
+
params: none
|
|
1376
|
+
describe: basic defense features available in a Deva.
|
|
1377
|
+
usage: this.defense()
|
|
1378
|
+
***************/
|
|
1379
|
+
defense() {
|
|
1380
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1381
|
+
this.zone('defense');
|
|
1382
|
+
this.feature('defense'); // set the support state
|
|
1383
|
+
try {
|
|
1384
|
+
this.state('return', 'defense'); // set the systems state
|
|
1385
|
+
return this.lib.copy(this._defense); // return the systems feature
|
|
1386
|
+
} catch (e) {
|
|
1387
|
+
return this.error(e); // return this.error when error catch
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1322
1391
|
/**************
|
|
1323
1392
|
func: load
|
|
1324
1393
|
params:
|
package/package.json
CHANGED
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
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
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
105
|
+
DevaTest.init(client);
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
// HelloWorld.question('/hello hello there').then(hello => {
|