@indra.ai/deva 1.7.1 β 1.8.1
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/actions.json +3 -1
- package/config/beliefs.json +2 -0
- package/config/index.js +53 -3
- package/config/intents.json +11 -1
- package/config/states.json +4 -2
- package/config/zones.json +6 -1
- package/index.js +142 -221
- package/package.json +1 -1
- package/tests/index.js +0 -1
package/config/actions.json
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"answer": "π‘ Answer",
|
|
40
40
|
"ask": "π£ Ask",
|
|
41
41
|
"call": "π Call",
|
|
42
|
+
"wait": "βοΈ Wait",
|
|
42
43
|
"init": "π Init",
|
|
43
44
|
"start": "π’ Start",
|
|
44
45
|
"enter": "πͺ Enter",
|
|
@@ -102,6 +103,7 @@
|
|
|
102
103
|
"target": "π― Target",
|
|
103
104
|
"mature": "π§ Mature",
|
|
104
105
|
"immature": "π§ Immature",
|
|
105
|
-
"hash": "#οΈβ£ Hash"
|
|
106
|
+
"hash": "#οΈβ£ Hash",
|
|
107
|
+
"romance": "πΉ Romance"
|
|
106
108
|
}
|
|
107
109
|
}
|
package/config/beliefs.json
CHANGED
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
"skoptsy": "β¦οΈ Skoptsy",
|
|
29
29
|
"lds": "π LDS Church",
|
|
30
30
|
"pagan": "π§οΈοΈ Pagan",
|
|
31
|
+
"american": "πΊπΈ American",
|
|
31
32
|
"communists": "π·πΊ Communist",
|
|
32
33
|
"nazi": "π© Nazi",
|
|
33
34
|
"delusional": "πͺ© Delusional",
|
|
34
35
|
"pervert": "π Pervert",
|
|
36
|
+
"romance": "πΉ Romance",
|
|
35
37
|
"other": "π€ Other"
|
|
36
38
|
}
|
|
37
39
|
}
|
package/config/index.js
CHANGED
|
@@ -39,6 +39,56 @@ export default {
|
|
|
39
39
|
"func",
|
|
40
40
|
"methods"
|
|
41
41
|
],
|
|
42
|
+
invoke: {
|
|
43
|
+
start: {
|
|
44
|
+
key: 'start',
|
|
45
|
+
prev_key: 'init',
|
|
46
|
+
next_key: 'enter',
|
|
47
|
+
onfunc: 'onStart',
|
|
48
|
+
},
|
|
49
|
+
enter: {
|
|
50
|
+
key: 'enter',
|
|
51
|
+
prev_key: 'start',
|
|
52
|
+
next_key: 'done',
|
|
53
|
+
onfunc: 'onEnter',
|
|
54
|
+
},
|
|
55
|
+
done: {
|
|
56
|
+
key: 'done',
|
|
57
|
+
prev_key: 'enter',
|
|
58
|
+
next_key: 'ready',
|
|
59
|
+
onfunc: 'onDone',
|
|
60
|
+
},
|
|
61
|
+
ready: {
|
|
62
|
+
key: 'ready',
|
|
63
|
+
prev_key: 'done',
|
|
64
|
+
next_key: false,
|
|
65
|
+
onfunc: 'onReady',
|
|
66
|
+
},
|
|
67
|
+
finish: {
|
|
68
|
+
key: 'finish',
|
|
69
|
+
prev_key: 'answer',
|
|
70
|
+
next_key: 'complete',
|
|
71
|
+
onfunc: 'onFinish',
|
|
72
|
+
},
|
|
73
|
+
complete: {
|
|
74
|
+
key: 'complete',
|
|
75
|
+
prev_key: 'finish',
|
|
76
|
+
next_key: false,
|
|
77
|
+
onfunc: 'onComplete',
|
|
78
|
+
},
|
|
79
|
+
stop: {
|
|
80
|
+
key: 'stop',
|
|
81
|
+
prev_key: false,
|
|
82
|
+
next_key: 'exit',
|
|
83
|
+
onfunc: 'onStop',
|
|
84
|
+
},
|
|
85
|
+
exit: {
|
|
86
|
+
key: 'exit',
|
|
87
|
+
prev_key: 'stop',
|
|
88
|
+
next_key: false,
|
|
89
|
+
onfunc: 'onExit',
|
|
90
|
+
}
|
|
91
|
+
},
|
|
42
92
|
context: false,
|
|
43
93
|
events: events.DATA,
|
|
44
94
|
feature: false,
|
|
@@ -47,11 +97,11 @@ export default {
|
|
|
47
97
|
zones: zones.DATA,
|
|
48
98
|
action: false,
|
|
49
99
|
actions: actions.DATA,
|
|
50
|
-
state:
|
|
100
|
+
state: 'offline',
|
|
51
101
|
states: states.DATA,
|
|
52
|
-
intent:
|
|
102
|
+
intent: 'neutral',
|
|
53
103
|
intents: intents.DATA,
|
|
54
|
-
belief:
|
|
104
|
+
belief: 'vedic',
|
|
55
105
|
beliefs: beliefs.DATA,
|
|
56
106
|
messages: msgs.DATA,
|
|
57
107
|
}
|
package/config/intents.json
CHANGED
|
@@ -34,7 +34,17 @@
|
|
|
34
34
|
"pervert": "π Pervert",
|
|
35
35
|
"pleasure": "π
Pleasure",
|
|
36
36
|
"desire": "π Desire",
|
|
37
|
+
"romance": "πΉ Romance",
|
|
37
38
|
"cannibal": "π₯© Cannibal",
|
|
38
|
-
"other": "π€ Other"
|
|
39
|
+
"other": "π€ Other",
|
|
40
|
+
"init": "π Init",
|
|
41
|
+
"start": "π’ Start",
|
|
42
|
+
"enter": "πͺ Enter",
|
|
43
|
+
"done": "βοΈ Done",
|
|
44
|
+
"ready": "βοΈ Ready",
|
|
45
|
+
"finish": "π Finish",
|
|
46
|
+
"complete": "β
Complete",
|
|
47
|
+
"stop": "π΄ Stop",
|
|
48
|
+
"exit": "πͺ Exit"
|
|
39
49
|
}
|
|
40
50
|
}
|
package/config/states.json
CHANGED
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"question": "π¬ Question",
|
|
16
16
|
"cmd": "πͺ Command",
|
|
17
17
|
"answer": "π‘ Answer",
|
|
18
|
-
"wait": "β³
|
|
18
|
+
"wait": "β³ Wait",
|
|
19
19
|
"pause": "βΈοΈ Pause",
|
|
20
20
|
"resume": "π Resume",
|
|
21
|
+
"pending": "β³ Pending",
|
|
21
22
|
"connect": "π³ Connect",
|
|
22
23
|
"disconnect": "π΄ Disconnect",
|
|
23
24
|
"send": "π¬ Send",
|
|
@@ -116,6 +117,7 @@
|
|
|
116
117
|
"mature": "π§ Mature",
|
|
117
118
|
"immature": "π§ Immature",
|
|
118
119
|
"consent": "βοΈ Consent",
|
|
119
|
-
"onfunc": "ποΈ onFunction"
|
|
120
|
+
"onfunc": "ποΈ onFunction",
|
|
121
|
+
"romance": "πΉ Romance"
|
|
120
122
|
}
|
|
121
123
|
}
|
package/config/zones.json
CHANGED
|
@@ -72,6 +72,11 @@
|
|
|
72
72
|
"rakshasas": "π₯© Rakshasas",
|
|
73
73
|
"pisakas": "π₯© Pisakas",
|
|
74
74
|
"kimidin": "π₯© Kimidin",
|
|
75
|
-
"atrin": "π₯© Atrin"
|
|
75
|
+
"atrin": "π₯© Atrin",
|
|
76
|
+
"romance": "πΉ Romance",
|
|
77
|
+
"porn": "π Pornography",
|
|
78
|
+
"prostitute": "π Prostitute",
|
|
79
|
+
"friend": "π€ Friend",
|
|
80
|
+
"enemy": "π¨ Enemy"
|
|
76
81
|
}
|
|
77
82
|
}
|
package/index.js
CHANGED
|
@@ -1106,10 +1106,12 @@ class Deva {
|
|
|
1106
1106
|
}).then(() => {
|
|
1107
1107
|
return this._assignListeners();
|
|
1108
1108
|
}).then(() => {
|
|
1109
|
+
this.belief('vedic', `init:${data.id.uid}`);
|
|
1109
1110
|
this.feature('init', data.id.uid);
|
|
1110
1111
|
this.zone('init', data.id.uid);
|
|
1111
1112
|
this.action('init', data.id.uid);
|
|
1112
1113
|
this.state('init', data.id.uid);
|
|
1114
|
+
this.intent('init', data.id.uid);
|
|
1113
1115
|
}).then(() => {
|
|
1114
1116
|
return this.Client(client, resolve, reject);
|
|
1115
1117
|
}).then(() => {
|
|
@@ -1171,12 +1173,13 @@ class Deva {
|
|
|
1171
1173
|
this.action('return', `onInit:${data.id.uid}`);
|
|
1172
1174
|
return this.onInit(data, resolve);
|
|
1173
1175
|
}
|
|
1174
|
-
this.intent('good', `init:${data.id.uid}`); // state set to watch onInit
|
|
1175
1176
|
this.action('return', `init:${data.id.uid}`);
|
|
1177
|
+
this.state('valid', `init:${data.id.uid}`); // state set to watch onInit
|
|
1178
|
+
this.intent('good', `init:${data.id.uid}`); // state set to watch onInit
|
|
1176
1179
|
return this.start(data, resolve);
|
|
1177
1180
|
}).catch(err => {
|
|
1178
|
-
this.intent('bad', `init:${data.id.uid}`); // state set to watch onInit
|
|
1179
1181
|
this.state('catch', `init:${data.id.uid}`);
|
|
1182
|
+
this.intent('bad', `init:${data.id.uid}`); // state set to watch onInit
|
|
1180
1183
|
return this.err(err, client, reject);
|
|
1181
1184
|
});
|
|
1182
1185
|
});
|
|
@@ -1194,44 +1197,19 @@ class Deva {
|
|
|
1194
1197
|
***************/
|
|
1195
1198
|
start(data, resolve) {
|
|
1196
1199
|
if (!this._active) return resolve(this._messages.offline);
|
|
1197
|
-
|
|
1198
|
-
this.
|
|
1199
|
-
this.
|
|
1200
|
-
this.
|
|
1201
|
-
|
|
1202
|
-
this.
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
data.value = 'start';
|
|
1211
|
-
|
|
1212
|
-
this.action('hash', `start:md5:${data.id.uid}`);
|
|
1213
|
-
data.md5 = this.hash(data, 'md5');
|
|
1214
|
-
this.action('hash', `start:sha256:${data.id.uid}`)
|
|
1215
|
-
data.sha256 = this.hash(data, 'sha256');
|
|
1216
|
-
this.action('hash', `start:sha512:${data.id.uid}`)
|
|
1217
|
-
data.sha512 = this.hash(data, 'sha512');
|
|
1218
|
-
|
|
1219
|
-
// setup the finish talk event
|
|
1220
|
-
this.action('talk', `${this._events.start}:${data.id.uid}`);
|
|
1221
|
-
this.talk(this._events.start, data);
|
|
1222
|
-
|
|
1223
|
-
const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
|
|
1224
|
-
if (hasOnStart) {
|
|
1225
|
-
this.action('onfunc', `hasOnStart:${data.id.uid}`); // set action to onfunc
|
|
1226
|
-
this.state('onfunc', `hasOnStart:${data.id.uid}`); // set state to onfunc
|
|
1227
|
-
this.intent('good', `onStart:${data.id.uid}`); // set the good intent
|
|
1228
|
-
this.action('return', `onStart:${data.id.uid}`); // return action finish
|
|
1229
|
-
return this.onStart(data, resolve)
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
this.intent('good', `start:${data.id.uid}`); // set the good intent
|
|
1233
|
-
this.action('return', `start:${data.id.uid}`); // return action finish
|
|
1234
|
-
return this.enter(data, resolve)
|
|
1200
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.enter;
|
|
1201
|
+
this.context(key, data.id.uid);
|
|
1202
|
+
this.zone(key, data.id.uid);
|
|
1203
|
+
this.action(key, data.id.uid);
|
|
1204
|
+
this.state(key, data.id.uid);
|
|
1205
|
+
this.intent(key, data.id.uid);
|
|
1206
|
+
return this._invoke({
|
|
1207
|
+
key,
|
|
1208
|
+
prev_key,
|
|
1209
|
+
next_key,
|
|
1210
|
+
onfunc,data,
|
|
1211
|
+
resolve
|
|
1212
|
+
});
|
|
1235
1213
|
}
|
|
1236
1214
|
|
|
1237
1215
|
/**************
|
|
@@ -1247,43 +1225,19 @@ class Deva {
|
|
|
1247
1225
|
***************/
|
|
1248
1226
|
enter(data, resolve) {
|
|
1249
1227
|
if (!this._active) return resolve(this._messages.offline);
|
|
1250
|
-
|
|
1251
|
-
this.
|
|
1252
|
-
this.
|
|
1253
|
-
this.
|
|
1254
|
-
|
|
1255
|
-
this.
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
data.value = 'enter';
|
|
1264
|
-
|
|
1265
|
-
this.action('hash', `enter:md5:${data.id.uid}`);
|
|
1266
|
-
data.md5 = this.hash(data, 'md5');
|
|
1267
|
-
this.action('hash', `enter:sha256:${data.id.uid}`)
|
|
1268
|
-
data.sha256 = this.hash(data, 'sha256');
|
|
1269
|
-
this.action('hash', `enter:sha512:${data.id.uid}`)
|
|
1270
|
-
data.sha512 = this.hash(data, 'sha512');
|
|
1271
|
-
|
|
1272
|
-
this.action('talk', `${this._events.enter}:${data.id.uid}`);
|
|
1273
|
-
this.talk(this._events.enter, data);
|
|
1274
|
-
|
|
1275
|
-
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
1276
|
-
if (hasOnEnter) {
|
|
1277
|
-
this.action('onfunc', `hasOnEnter:${data.id.uid}`); // action onfunc set
|
|
1278
|
-
this.state('onfunc', `hasOnEnter:${data.id.uid}`); // state onfunc set
|
|
1279
|
-
this.intent('good', `onEnter:${data.id.uid}`); // set good intent on enter
|
|
1280
|
-
this.action('return', `onEnter:${data.id.uid}`); // set return actions
|
|
1281
|
-
return this.onEnter(data, resolve); // set return on enter.
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
this.intent('good', `enter:${data.id.uid}`); // set good intent enter
|
|
1285
|
-
this.action('return', `enter:${data.id.uid}`); // return action finish
|
|
1286
|
-
return this.done(data, resolve)
|
|
1228
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.enter;
|
|
1229
|
+
this.context(key, data.id.uid);
|
|
1230
|
+
this.zone(key, data.id.uid);
|
|
1231
|
+
this.action(key, data.id.uid);
|
|
1232
|
+
this.state(key, data.id.uid);
|
|
1233
|
+
this.intent(key, data.id.uid);
|
|
1234
|
+
return this._invoke({
|
|
1235
|
+
key,
|
|
1236
|
+
prev_key,
|
|
1237
|
+
next_key,
|
|
1238
|
+
onfunc,data,
|
|
1239
|
+
resolve
|
|
1240
|
+
});
|
|
1287
1241
|
}
|
|
1288
1242
|
|
|
1289
1243
|
/**************
|
|
@@ -1299,43 +1253,19 @@ class Deva {
|
|
|
1299
1253
|
***************/
|
|
1300
1254
|
done(data, resolve) {
|
|
1301
1255
|
if (!this._active) return resolve(this._messages.offline);
|
|
1302
|
-
|
|
1303
|
-
this.
|
|
1304
|
-
this.
|
|
1305
|
-
this.
|
|
1306
|
-
|
|
1307
|
-
this.
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
data.value = 'done';
|
|
1316
|
-
|
|
1317
|
-
this.action('hash', `done:md5:${data.id.uid}`);
|
|
1318
|
-
data.md5 = this.hash(data, 'md5');
|
|
1319
|
-
this.action('hash', `done:sha256:${data.id.uid}`)
|
|
1320
|
-
data.sha256 = this.hash(data, 'sha256');
|
|
1321
|
-
this.action('hash', `done:sha512:${data.id.uid}`)
|
|
1322
|
-
data.sha512 = this.hash(data, 'sha512');
|
|
1323
|
-
|
|
1324
|
-
this.action('talk', `${this._events.done}:${data.id.uid}`);
|
|
1325
|
-
this.talk(this._events.done, data);
|
|
1326
|
-
|
|
1327
|
-
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
1328
|
-
if (hasOnDone) {
|
|
1329
|
-
this.action('onfunc', `hasOnDone:${data.id.uid}`); // state onfunc
|
|
1330
|
-
this.state('onfunc', `hasOnDone:${data.id.uid}`); // state onfunc
|
|
1331
|
-
this.intent('good', `onDone:${data.id.uid}`); // set the onDone intent
|
|
1332
|
-
this.action('return', `onDone:${data.id.uid}`); // set the return action
|
|
1333
|
-
return this.onDone(data, resolve);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
this.intent('good', `done:${data.id.uid}`); // set done intent
|
|
1337
|
-
this.action('return', `done:${data.id.uid}`); // return action finish
|
|
1338
|
-
return this.ready(data, resolve);
|
|
1256
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.done;
|
|
1257
|
+
this.context(key, data.id.uid);
|
|
1258
|
+
this.zone(key, data.id.uid);
|
|
1259
|
+
this.action(key, data.id.uid);
|
|
1260
|
+
this.state(key, data.id.uid);
|
|
1261
|
+
this.intent(key, data.id.uid);
|
|
1262
|
+
return this._invoke({
|
|
1263
|
+
key,
|
|
1264
|
+
prev_key,
|
|
1265
|
+
next_key,
|
|
1266
|
+
onfunc,data,
|
|
1267
|
+
resolve
|
|
1268
|
+
});
|
|
1339
1269
|
}
|
|
1340
1270
|
|
|
1341
1271
|
/**************
|
|
@@ -1348,26 +1278,15 @@ class Deva {
|
|
|
1348
1278
|
***************/
|
|
1349
1279
|
ready(data, resolve) {
|
|
1350
1280
|
if (!this._active) return resolve(this._messages.offline);
|
|
1351
|
-
|
|
1352
|
-
this.
|
|
1353
|
-
this.
|
|
1354
|
-
this.
|
|
1281
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.ready;
|
|
1282
|
+
this.context(key, data.id.uid);
|
|
1283
|
+
this.zone(key, data.id.uid);
|
|
1284
|
+
this.action(key, data.id.uid);
|
|
1285
|
+
this.state(key, data.id.uid);
|
|
1286
|
+
this.intent(key, data.id.uid);
|
|
1355
1287
|
|
|
1356
|
-
const agent = this.agent();
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
// Delete previous data hashes
|
|
1360
|
-
this.action('delete', `done:md5:${data.id.uid}`);
|
|
1361
|
-
delete data.md5;
|
|
1362
|
-
this.action('delete', `done:sha256:${data.id.uid}`);
|
|
1363
|
-
delete data.sha256;
|
|
1364
|
-
this.action('delete', `done:sha512:${data.id.uid}`);
|
|
1365
|
-
delete data.sha512;
|
|
1366
|
-
|
|
1367
|
-
this.state('set', `data:value:ready:${data.id.uid}`); // state set to watch OnFinish
|
|
1368
|
-
data.value = 'ready';
|
|
1369
|
-
|
|
1370
|
-
this.state('set', `config:hash:${data.id.uid}`); // state set to watch OnFinish
|
|
1288
|
+
const agent = this.agent();
|
|
1289
|
+
this.state('set', `${key}:config:hash:${data.id.uid}`); // state set to watch OnFinish
|
|
1371
1290
|
this.config.hash[agent.key] = {};
|
|
1372
1291
|
for (let item of this._config.ready_hash) {
|
|
1373
1292
|
if (this[item]) {
|
|
@@ -1376,30 +1295,14 @@ class Deva {
|
|
|
1376
1295
|
this.config.hash[agent.key][item] = this.hash(this_item, 'sha256');
|
|
1377
1296
|
}
|
|
1378
1297
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
this.action('talk', `${this._events.ready}:${data.id.uid}`);
|
|
1388
|
-
this.talk(this._events.ready, data);
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
const hasOnReady = this.onReady && typeof this.onReady === 'function';
|
|
1392
|
-
if (hasOnReady) {
|
|
1393
|
-
this.action('onfunc', `hasOnReady:${data.id.uid}`); // action onfunc
|
|
1394
|
-
this.state('onfunc', `hasOnReady:${data.id.uid}`); // state onfunc
|
|
1395
|
-
this.intent('good', `onReady:${data.id.uis}`); // set ready intent
|
|
1396
|
-
this.action('return', `onReady:${data.id.uid}`); // set action onReady return
|
|
1397
|
-
return this.onReady(data, resolve);
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
this.intent('good', `ready:${data.id.uid}`); // set read intent good
|
|
1401
|
-
this.action('resolve', `ready:${data.id.uid}`); // return action ready
|
|
1402
|
-
return resolve(data);
|
|
1298
|
+
return this._invoke({
|
|
1299
|
+
key,
|
|
1300
|
+
prev_key,
|
|
1301
|
+
next_key,
|
|
1302
|
+
onfunc,
|
|
1303
|
+
data,
|
|
1304
|
+
resolve,
|
|
1305
|
+
});
|
|
1403
1306
|
}
|
|
1404
1307
|
|
|
1405
1308
|
/**************
|
|
@@ -1411,41 +1314,22 @@ class Deva {
|
|
|
1411
1314
|
usage: this.finish(data, resolve)
|
|
1412
1315
|
***************/
|
|
1413
1316
|
finish(data, resolve) {
|
|
1414
|
-
if (!this._active) return resolve(this._messages.offline);
|
|
1415
|
-
|
|
1416
|
-
this.
|
|
1417
|
-
this.
|
|
1418
|
-
this.
|
|
1419
|
-
|
|
1420
|
-
this.
|
|
1421
|
-
delete data.md5;
|
|
1422
|
-
this.action('delete', `answer:sha256:${data.id.uid}`);
|
|
1423
|
-
delete data.sha256;
|
|
1424
|
-
this.action('delete', `answer:sha512:${data.id.uid}`);
|
|
1425
|
-
delete data.sha512;
|
|
1426
|
-
|
|
1427
|
-
data.finish = Date.now(); // set the finish timestamp
|
|
1428
|
-
this.state('set', `data:finish:${data.finish}:${data.id.uid}`)
|
|
1429
|
-
|
|
1430
|
-
this.action('hash', `finish:md5:${data.id.uid}`);
|
|
1431
|
-
data.md5 = this.hash(data, 'md5');
|
|
1432
|
-
this.action('hash', `finish:sha256:${data.id.uid}`)
|
|
1433
|
-
data.sha256 = this.hash(data, 'sha256');
|
|
1434
|
-
this.action('hash', `finish:sha512:${data.id.uid}`)
|
|
1435
|
-
data.sha512 = this.hash(data, 'sha512');
|
|
1317
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1318
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.finish;
|
|
1319
|
+
this.context(key, data.id.uid);
|
|
1320
|
+
this.zone(key, data.id.uid); // enter finish zone
|
|
1321
|
+
this.action(key, data.id.uid); // start finish action
|
|
1322
|
+
this.state(key, data.id.uid); // set finish state
|
|
1323
|
+
this.intent(key, data.id.uid); // set finish state
|
|
1436
1324
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
this.action('return', `finish:${data.id.uid}`); // return action finish
|
|
1448
|
-
return hasOnFinish ? this.onFinish(data, resolve) : this.complete(data, resolve);
|
|
1325
|
+
return this._invoke({
|
|
1326
|
+
key,
|
|
1327
|
+
prev_key,
|
|
1328
|
+
next_key,
|
|
1329
|
+
onfunc,
|
|
1330
|
+
data,
|
|
1331
|
+
resolve,
|
|
1332
|
+
});
|
|
1449
1333
|
}
|
|
1450
1334
|
|
|
1451
1335
|
/**************
|
|
@@ -1459,42 +1343,78 @@ class Deva {
|
|
|
1459
1343
|
***************/
|
|
1460
1344
|
complete(data, resolve) {
|
|
1461
1345
|
if (!this._active) return resolve(this._messages.offline);
|
|
1462
|
-
|
|
1463
|
-
this.
|
|
1464
|
-
this.
|
|
1465
|
-
this.
|
|
1346
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.complete;
|
|
1347
|
+
this.context(key, data.id.uid);
|
|
1348
|
+
this.zone(key, data.id.uid);
|
|
1349
|
+
this.action(key, data.id.uid);
|
|
1350
|
+
this.state(key, data.id.uid);
|
|
1351
|
+
|
|
1352
|
+
return this._invoke({
|
|
1353
|
+
key,
|
|
1354
|
+
prev_key,
|
|
1355
|
+
next_key,
|
|
1356
|
+
onfunc,
|
|
1357
|
+
data,
|
|
1358
|
+
resolve,
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
/**************
|
|
1362
|
+
func: _invoke
|
|
1363
|
+
params:
|
|
1364
|
+
- data: the data to pass to the resolve
|
|
1365
|
+
- resolve: the complete resolve to pass back
|
|
1366
|
+
describe: The _invoke function is used for the recursion over
|
|
1367
|
+
init, start, enter, done ready, finish, complete
|
|
1368
|
+
usage: this.complete(data, resolve)
|
|
1369
|
+
***************/
|
|
1370
|
+
_invoke(opts) {
|
|
1371
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1372
|
+
const {key, prev_key, next_key, onfunc, data, resolve} = opts;
|
|
1373
|
+
this.context(key, data.id.uid);
|
|
1374
|
+
this.zone(key, data.id.uid);
|
|
1375
|
+
this.action(key, data.id.uid);
|
|
1376
|
+
this.state(key, data.id.uid);
|
|
1466
1377
|
|
|
1467
|
-
this.action('delete',
|
|
1378
|
+
this.action('delete', `${key}:md5:${data.id.uid}`);
|
|
1468
1379
|
delete data.md5;
|
|
1469
|
-
|
|
1380
|
+
|
|
1381
|
+
this.action('delete', `${key}:sha256:${data.id.uid}`);
|
|
1470
1382
|
delete data.sha256;
|
|
1471
|
-
|
|
1383
|
+
|
|
1384
|
+
this.action('delete', `${key}:sha512:${data.id.uid}`);
|
|
1472
1385
|
delete data.sha512;
|
|
1473
1386
|
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
this.action('hash',
|
|
1387
|
+
this.state('data', `${key}:date:${data.id.uid}`);
|
|
1388
|
+
data[key] = Date.now();// set the complete date on the whole data.
|
|
1389
|
+
|
|
1390
|
+
this.action('hash', `${key}:md5:${data.id.uid}`);
|
|
1478
1391
|
data.md5 = this.hash(data, 'md5');
|
|
1479
|
-
|
|
1392
|
+
|
|
1393
|
+
this.action('hash', `${key}:sha256:${data.id.uid}`)
|
|
1480
1394
|
data.sha256 = this.hash(data, 'sha256');
|
|
1481
1395
|
|
|
1482
|
-
this.action('hash',
|
|
1396
|
+
this.action('hash', `${key}:sha512:${data.id.uid}`)
|
|
1483
1397
|
data.sha512 = this.hash(data, 'sha512');
|
|
1484
1398
|
|
|
1485
1399
|
// setup the complete talk event
|
|
1486
|
-
this.action('talk', `${this._events
|
|
1487
|
-
this.talk(this._events
|
|
1400
|
+
this.action('talk', `${this._events[key]}:${data.id.uid}`); // action talk for the event.
|
|
1401
|
+
this.talk(this._events[key], data); // talk the complete event
|
|
1488
1402
|
|
|
1489
1403
|
// determine if there is an onComplete function for the entity.
|
|
1490
|
-
const
|
|
1491
|
-
if (
|
|
1492
|
-
this.action('onfunc',
|
|
1493
|
-
this.state('onfunc',
|
|
1404
|
+
const hasOnFunc = this[onfunc] && typeof this[onfunc] === 'function';
|
|
1405
|
+
if (hasOnFunc) {
|
|
1406
|
+
this.action('onfunc', `${key}:has:${onfunc}:${data.id.uid}`); // action onfunc
|
|
1407
|
+
this.state('onfunc', `${key}:has:${onfunc}:${data.id.uid}`); // state onfunc
|
|
1408
|
+
this.action('return', `${onfunc}:${data.id.uid}`); // action return
|
|
1409
|
+
this.state('valid', `${onfunc}:${data.id.uid}`); // state valid
|
|
1410
|
+
this.intent('good', `${onfunc}:${data.id.uid}`); // intent good
|
|
1411
|
+
return this[onfunc](data, resolve);
|
|
1494
1412
|
}
|
|
1495
1413
|
|
|
1496
|
-
this.action('return',
|
|
1497
|
-
|
|
1414
|
+
this.action('return', `${key}:${data.id.uid}`); // return action complete
|
|
1415
|
+
this.state('valid', `${key}:${data.id.uid}`); // return state valid
|
|
1416
|
+
this.intent('good', `${key}:${data.id.uid}`); // return intent good
|
|
1417
|
+
return next_key ? this[next_key](data, resolve) : resolve(data);
|
|
1498
1418
|
}
|
|
1499
1419
|
|
|
1500
1420
|
/**************
|
|
@@ -1512,26 +1432,27 @@ class Deva {
|
|
|
1512
1432
|
***************/
|
|
1513
1433
|
stop() {
|
|
1514
1434
|
if (!this._active) return this._messages.offline;
|
|
1435
|
+
const {key, prev_key, next_key, onfunc} = config.invoke.stop;
|
|
1515
1436
|
const id = this.uid();
|
|
1516
|
-
const key = 'stop';
|
|
1517
1437
|
this.context(key, id.uid);
|
|
1518
1438
|
this.zone(key, id.uid);
|
|
1519
1439
|
this.action(key, id.uid);
|
|
1520
1440
|
this.state(key, id.uid); // set the state to stop
|
|
1521
1441
|
|
|
1522
1442
|
this.state('set', `${key}:agent:${id.uid}`); // state stop agent
|
|
1523
|
-
const agent = this.agent(); // get the current agent
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1443
|
+
const agent = this.agent().sha256; // get the current agent
|
|
1444
|
+
const value = agent.key;
|
|
1445
|
+
|
|
1446
|
+
this.state('set', `${key}:client:${id.uid}`); // state stop agent
|
|
1447
|
+
const client = this.client().sha256; // set the current client
|
|
1527
1448
|
|
|
1528
|
-
this.state('data',
|
|
1449
|
+
this.state('data', `${key}:${id.uid}`);
|
|
1529
1450
|
const data = { // build the stop data
|
|
1530
1451
|
id, // set the id
|
|
1531
1452
|
key, // set the key
|
|
1532
|
-
value
|
|
1533
|
-
agent
|
|
1534
|
-
client
|
|
1453
|
+
value, // set the value
|
|
1454
|
+
agent, // set the agent
|
|
1455
|
+
client, // set the client
|
|
1535
1456
|
stop: Date.now(), // set the created date
|
|
1536
1457
|
}
|
|
1537
1458
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "44091450722329207445",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.1",
|
|
5
5
|
"description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "VLA:44091450722329207445 LICENSE.md",
|