@indra.ai/deva 1.8.2 → 1.8.4
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 +1 -0
- package/config/events.json +5 -2
- package/config/index.js +33 -11
- package/config/zones.json +11 -2
- package/index.js +163 -237
- package/package.json +1 -1
package/config/actions.json
CHANGED
package/config/events.json
CHANGED
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
"finish": "devacore:finish",
|
|
14
14
|
"complete": "devacore:complete",
|
|
15
15
|
"stop": "devacore:stop",
|
|
16
|
+
"close": "devacore:leave",
|
|
17
|
+
"leave": "devacore:leave",
|
|
16
18
|
"exit": "devacore:exit",
|
|
19
|
+
"shutdown": "devacore:shutdown",
|
|
17
20
|
"question": "devacore:question",
|
|
18
21
|
"answer": "devacore:answer",
|
|
19
22
|
"ask": "devacore:ask",
|
|
23
|
+
"context": "devacore:context",
|
|
20
24
|
"feature": "devacore:feature",
|
|
21
25
|
"zone": "devacore:zone",
|
|
22
26
|
"action": "devacore:action",
|
|
@@ -24,7 +28,6 @@
|
|
|
24
28
|
"intent": "devacore:intent",
|
|
25
29
|
"belief": "devacore:belief",
|
|
26
30
|
"load": "devacore:load",
|
|
27
|
-
"unload": "devacore:unload"
|
|
28
|
-
"context": "devacore:context"
|
|
31
|
+
"unload": "devacore:unload"
|
|
29
32
|
}
|
|
30
33
|
}
|
package/config/index.js
CHANGED
|
@@ -41,54 +41,64 @@ export default {
|
|
|
41
41
|
],
|
|
42
42
|
invoke: {
|
|
43
43
|
start: {
|
|
44
|
-
key: 'start',
|
|
45
44
|
prev_key: 'init',
|
|
46
45
|
next_key: 'enter',
|
|
47
46
|
onfunc: 'onStart',
|
|
47
|
+
clear: false,
|
|
48
48
|
},
|
|
49
49
|
enter: {
|
|
50
|
-
key: 'enter',
|
|
51
50
|
prev_key: 'start',
|
|
52
51
|
next_key: 'done',
|
|
53
52
|
onfunc: 'onEnter',
|
|
53
|
+
clear: false,
|
|
54
54
|
},
|
|
55
55
|
done: {
|
|
56
|
-
key: 'done',
|
|
57
56
|
prev_key: 'enter',
|
|
58
57
|
next_key: 'ready',
|
|
59
58
|
onfunc: 'onDone',
|
|
59
|
+
clear: false,
|
|
60
60
|
},
|
|
61
61
|
ready: {
|
|
62
|
-
key: 'ready',
|
|
63
62
|
prev_key: 'done',
|
|
64
63
|
next_key: false,
|
|
65
64
|
onfunc: 'onReady',
|
|
65
|
+
clear: false,
|
|
66
66
|
},
|
|
67
67
|
finish: {
|
|
68
|
-
key: 'finish',
|
|
69
68
|
prev_key: 'answer',
|
|
70
69
|
next_key: 'complete',
|
|
71
70
|
onfunc: 'onFinish',
|
|
71
|
+
clear: false,
|
|
72
72
|
},
|
|
73
73
|
complete: {
|
|
74
|
-
key: 'complete',
|
|
75
74
|
prev_key: 'finish',
|
|
76
75
|
next_key: false,
|
|
77
76
|
onfunc: 'onComplete',
|
|
77
|
+
clear: false,
|
|
78
78
|
},
|
|
79
79
|
stop: {
|
|
80
|
-
key: 'stop',
|
|
81
80
|
prev_key: false,
|
|
82
|
-
next_key: '
|
|
81
|
+
next_key: 'close',
|
|
83
82
|
onfunc: 'onStop',
|
|
83
|
+
clear: false,
|
|
84
|
+
},
|
|
85
|
+
close: {
|
|
86
|
+
prev_key: 'stop',
|
|
87
|
+
next_key: 'leave',
|
|
88
|
+
onfunc: 'onClose',
|
|
89
|
+
clear: false,
|
|
90
|
+
},
|
|
91
|
+
leave: {
|
|
92
|
+
prev_key: 'close',
|
|
93
|
+
next_key: 'exit',
|
|
94
|
+
onfunc: 'onClose',
|
|
95
|
+
clear: false,
|
|
84
96
|
},
|
|
85
97
|
exit: {
|
|
86
|
-
key: 'exit',
|
|
87
98
|
prev_key: 'stop',
|
|
88
|
-
next_key:
|
|
99
|
+
next_key: 'shutdown',
|
|
89
100
|
onfunc: 'onExit',
|
|
90
101
|
clear: [
|
|
91
|
-
'_active',
|
|
92
102
|
'_indra',
|
|
93
103
|
'_veda',
|
|
94
104
|
'_license',
|
|
@@ -112,6 +122,18 @@ export default {
|
|
|
112
122
|
'_systems',
|
|
113
123
|
'_networks',
|
|
114
124
|
]
|
|
125
|
+
},
|
|
126
|
+
shutdown: {
|
|
127
|
+
prev_key: 'exit',
|
|
128
|
+
next_key: false,
|
|
129
|
+
onfunc: 'onShutdown',
|
|
130
|
+
clear: [
|
|
131
|
+
'modules'
|
|
132
|
+
'listeners'
|
|
133
|
+
'events',
|
|
134
|
+
'_config',
|
|
135
|
+
'_active',
|
|
136
|
+
],
|
|
115
137
|
}
|
|
116
138
|
},
|
|
117
139
|
context: false,
|
package/config/zones.json
CHANGED
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"crisis": "😱 Crisis",
|
|
65
65
|
"private": "🤫 Private",
|
|
66
66
|
"public": "😀 Public",
|
|
67
|
+
"industry": "🏭 Industry",
|
|
67
68
|
"merit": "➕ Merit",
|
|
68
69
|
"demerit": "➖ Demerit",
|
|
69
70
|
"camera": "🤳 Camera",
|
|
70
|
-
"victim": "❤️🩹 Victim",
|
|
71
71
|
"yakshas": "🥩 Yakshas",
|
|
72
72
|
"rakshasas": "🥩 Rakshasas",
|
|
73
73
|
"pisakas": "🥩 Pisakas",
|
|
@@ -77,6 +77,15 @@
|
|
|
77
77
|
"porn": "👙 Pornography",
|
|
78
78
|
"prostitute": "💃 Prostitute",
|
|
79
79
|
"friend": "🤝 Friend",
|
|
80
|
-
"enemy": "
|
|
80
|
+
"enemy": "🚨👿 Enemy",
|
|
81
|
+
"suspect": "🚨🥸 Suspect",
|
|
82
|
+
"culprit": "🚨😤 Culprit",
|
|
83
|
+
"criminal": "🚨🤬 Criminal",
|
|
84
|
+
"felon": "🚨🙅 Felon",
|
|
85
|
+
"victim": "🚨🩼 Victim",
|
|
86
|
+
"hostage": "🚨🙊 Hostage",
|
|
87
|
+
"court": "🏛️🧑⚖️ Court",
|
|
88
|
+
"jail": "⛓️🔏 Jail",
|
|
89
|
+
"prison": "⛓️🔐 Prison"
|
|
81
90
|
}
|
|
82
91
|
}
|
package/index.js
CHANGED
|
@@ -291,6 +291,74 @@ class Deva {
|
|
|
291
291
|
return this.err(e);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
/**************
|
|
296
|
+
func: _invoke
|
|
297
|
+
params:
|
|
298
|
+
- data: the data to pass to the resolve
|
|
299
|
+
- resolve: the complete resolve to pass back
|
|
300
|
+
describe: The _invoke function is used for the recursion over
|
|
301
|
+
init, start, enter, done ready, finish, complete
|
|
302
|
+
usage: this.complete(data, resolve)
|
|
303
|
+
***************/
|
|
304
|
+
_invoke(opts) {
|
|
305
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
306
|
+
const {key, data, resolve} = opts;
|
|
307
|
+
const {prev_key, next_key, onfunc, clear} = config.invoke[key];
|
|
308
|
+
this.action('invoke', `${key}:${data.id.uid}`);
|
|
309
|
+
this.context(key, data.id.uid);
|
|
310
|
+
this.zone(key, data.id.uid);
|
|
311
|
+
this.action(key, data.id.uid);
|
|
312
|
+
this.state(key, data.id.uid);
|
|
313
|
+
|
|
314
|
+
this.action('delete', `${key}:md5:${data.id.uid}`);
|
|
315
|
+
delete data.md5;
|
|
316
|
+
|
|
317
|
+
this.action('delete', `${key}:sha256:${data.id.uid}`);
|
|
318
|
+
delete data.sha256;
|
|
319
|
+
|
|
320
|
+
this.action('delete', `${key}:sha512:${data.id.uid}`);
|
|
321
|
+
delete data.sha512;
|
|
322
|
+
|
|
323
|
+
this.state('data', `${key}:date:${data.id.uid}`);
|
|
324
|
+
data[key] = Date.now();// set the complete date on the whole data.
|
|
325
|
+
|
|
326
|
+
this.action('hash', `${key}:md5:${data.id.uid}`);
|
|
327
|
+
data.md5 = this.hash(data, 'md5');
|
|
328
|
+
|
|
329
|
+
this.action('hash', `${key}:sha256:${data.id.uid}`)
|
|
330
|
+
data.sha256 = this.hash(data, 'sha256');
|
|
331
|
+
|
|
332
|
+
this.action('hash', `${key}:sha512:${data.id.uid}`)
|
|
333
|
+
data.sha512 = this.hash(data, 'sha512');
|
|
334
|
+
|
|
335
|
+
// setup the complete talk event
|
|
336
|
+
this.action('talk', `${this._events[key]}:${data.id.uid}`); // action talk for the event.
|
|
337
|
+
this.talk(this._events[key], data); // talk the complete event
|
|
338
|
+
|
|
339
|
+
if (clear) {
|
|
340
|
+
this.state('loop', `${key}:clear:${data.id.uid}`);
|
|
341
|
+
for (let item of config.invoke.exit.clear) {
|
|
342
|
+
this[item] = false;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// determine if there is an onComplete function for the entity.
|
|
347
|
+
const hasOnFunc = this[onfunc] && typeof this[onfunc] === 'function';
|
|
348
|
+
if (hasOnFunc) {
|
|
349
|
+
this.action('onfunc', `${key}:has:${onfunc}:${data.id.uid}`); // action onfunc
|
|
350
|
+
this.state('onfunc', `${key}:has:${onfunc}:${data.id.uid}`); // state onfunc
|
|
351
|
+
this.action('return', `${onfunc}:${data.id.uid}`); // action return
|
|
352
|
+
this.state('valid', `${onfunc}:${data.id.uid}`); // state valid
|
|
353
|
+
this.intent('good', `${onfunc}:${data.id.uid}`); // intent good
|
|
354
|
+
return this[onfunc](data, resolve);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
this.action('return', `${key}:${data.id.uid}`); // return action complete
|
|
358
|
+
this.state('valid', `${key}:${data.id.uid}`); // return state valid
|
|
359
|
+
this.intent('good', `${key}:${data.id.uid}`); // return intent good
|
|
360
|
+
return next_key ? this[next_key](data, resolve) : resolve(data);
|
|
361
|
+
}
|
|
294
362
|
|
|
295
363
|
/**************
|
|
296
364
|
func: Client
|
|
@@ -878,7 +946,7 @@ class Deva {
|
|
|
878
946
|
this.state('set', `${key}:${method}:data:${id.uid}`);
|
|
879
947
|
const data = typeof result === 'object' ? result.data : false;
|
|
880
948
|
|
|
881
|
-
this.state('data', `${key}:${method}:${
|
|
949
|
+
this.state('data', `${key}:${method}:${subkey}:${id.uid}`);
|
|
882
950
|
const packet_answer = { // setup the packet.a container
|
|
883
951
|
id,
|
|
884
952
|
agent, // set the agent who answered the question
|
|
@@ -894,16 +962,16 @@ class Deva {
|
|
|
894
962
|
created: Date.now(), // set the created date for the answer
|
|
895
963
|
};
|
|
896
964
|
// create a hash for the answer and insert into answer meta.
|
|
897
|
-
this.action('hash', `${key}:${method}:${
|
|
965
|
+
this.action('hash', `${key}:${method}:${subkey}:md5:${id.uid}`);
|
|
898
966
|
packet_answer.md5 = this.hash(packet_answer, 'md5');
|
|
899
967
|
|
|
900
|
-
this.action('hash', `${key}:${method}:${
|
|
968
|
+
this.action('hash', `${key}:${method}:${subkey}:sha256:${id.uid}`);
|
|
901
969
|
packet_answer.sha256 = this.hash(packet_answer, 'sha256');
|
|
902
970
|
|
|
903
|
-
this.action('hash', `${key}:${method}:${
|
|
971
|
+
this.action('hash', `${key}:${method}:${subkey}:sha512:${id.uid}`);
|
|
904
972
|
packet_answer.sha512 = this.hash(packet_answer, 'sha512');
|
|
905
973
|
|
|
906
|
-
this.state('set', `${key}:${method}:${
|
|
974
|
+
this.state('set', `${key}:${method}:${subkey}:${id.uid}`);
|
|
907
975
|
packet.a = packet_answer; // set the packet.a to the packet_answer
|
|
908
976
|
|
|
909
977
|
this.action('talk', `${this._events.answer}:${id.uid}`);
|
|
@@ -1187,29 +1255,22 @@ class Deva {
|
|
|
1187
1255
|
|
|
1188
1256
|
/**************
|
|
1189
1257
|
func: start
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
function
|
|
1196
|
-
|
|
1258
|
+
usage: this.start(data, resolve);
|
|
1259
|
+
params: data, resolve
|
|
1260
|
+
- data: The data packet that is passed through the invoke chain.
|
|
1261
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1262
|
+
describe:
|
|
1263
|
+
The start() function initiates the Invoke Recursion Framework phase for the
|
|
1264
|
+
current Deva context. It first checks for active runtime status, retrieves
|
|
1265
|
+
invocation parameters (key-chain mapping, lifecycle handlers) from
|
|
1266
|
+
config.invoke.start, declares the invoke action, and then delegates control
|
|
1267
|
+
to _invoke(), ensuring consistent recursion through the start-enter-done
|
|
1268
|
+
sequence. This design preserves language-agnostic interoperability and
|
|
1269
|
+
deterministic state transitions across Deva systems.
|
|
1197
1270
|
***************/
|
|
1198
1271
|
start(data, resolve) {
|
|
1199
1272
|
if (!this._active) return resolve(this._messages.offline);
|
|
1200
|
-
|
|
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
|
-
});
|
|
1273
|
+
return this._invoke({key:'start',data,resolve});
|
|
1213
1274
|
}
|
|
1214
1275
|
|
|
1215
1276
|
/**************
|
|
@@ -1225,19 +1286,7 @@ class Deva {
|
|
|
1225
1286
|
***************/
|
|
1226
1287
|
enter(data, resolve) {
|
|
1227
1288
|
if (!this._active) return resolve(this._messages.offline);
|
|
1228
|
-
|
|
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
|
-
});
|
|
1289
|
+
return this._invoke({key:'enter',data,resolve});
|
|
1241
1290
|
}
|
|
1242
1291
|
|
|
1243
1292
|
/**************
|
|
@@ -1253,19 +1302,7 @@ class Deva {
|
|
|
1253
1302
|
***************/
|
|
1254
1303
|
done(data, resolve) {
|
|
1255
1304
|
if (!this._active) return resolve(this._messages.offline);
|
|
1256
|
-
|
|
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
|
-
});
|
|
1305
|
+
return this._invoke({key:'done',data,resolve});
|
|
1269
1306
|
}
|
|
1270
1307
|
|
|
1271
1308
|
/**************
|
|
@@ -1278,16 +1315,15 @@ class Deva {
|
|
|
1278
1315
|
***************/
|
|
1279
1316
|
ready(data, resolve) {
|
|
1280
1317
|
if (!this._active) return resolve(this._messages.offline);
|
|
1281
|
-
const
|
|
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);
|
|
1318
|
+
const key = 'ready';
|
|
1287
1319
|
|
|
1320
|
+
this.state('set', `${key}:agent:${data.id.uid}`);
|
|
1288
1321
|
const agent = this.agent();
|
|
1322
|
+
|
|
1289
1323
|
this.state('set', `${key}:config:hash:${data.id.uid}`); // state set to watch OnFinish
|
|
1290
1324
|
this.config.hash[agent.key] = {};
|
|
1325
|
+
|
|
1326
|
+
this.state('loop', `${key}:config:ready:hash:${data.id.uid}`);
|
|
1291
1327
|
for (let item of this._config.ready_hash) {
|
|
1292
1328
|
if (this[item]) {
|
|
1293
1329
|
const this_item = this[item];
|
|
@@ -1295,14 +1331,7 @@ class Deva {
|
|
|
1295
1331
|
this.config.hash[agent.key][item] = this.hash(this_item, 'sha256');
|
|
1296
1332
|
}
|
|
1297
1333
|
}
|
|
1298
|
-
return this._invoke({
|
|
1299
|
-
key,
|
|
1300
|
-
prev_key,
|
|
1301
|
-
next_key,
|
|
1302
|
-
onfunc,
|
|
1303
|
-
data,
|
|
1304
|
-
resolve,
|
|
1305
|
-
});
|
|
1334
|
+
return this._invoke({key,data,resolve});
|
|
1306
1335
|
}
|
|
1307
1336
|
|
|
1308
1337
|
/**************
|
|
@@ -1315,21 +1344,7 @@ class Deva {
|
|
|
1315
1344
|
***************/
|
|
1316
1345
|
finish(data, resolve) {
|
|
1317
1346
|
if (!this._active) return resolve(this._messages.offline);
|
|
1318
|
-
|
|
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
|
|
1324
|
-
|
|
1325
|
-
return this._invoke({
|
|
1326
|
-
key,
|
|
1327
|
-
prev_key,
|
|
1328
|
-
next_key,
|
|
1329
|
-
onfunc,
|
|
1330
|
-
data,
|
|
1331
|
-
resolve,
|
|
1332
|
-
});
|
|
1347
|
+
return this._invoke({key:'finish',data,resolve});
|
|
1333
1348
|
}
|
|
1334
1349
|
|
|
1335
1350
|
/**************
|
|
@@ -1343,101 +1358,23 @@ class Deva {
|
|
|
1343
1358
|
***************/
|
|
1344
1359
|
complete(data, resolve) {
|
|
1345
1360
|
if (!this._active) return resolve(this._messages.offline);
|
|
1346
|
-
|
|
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);
|
|
1377
|
-
|
|
1378
|
-
this.action('delete', `${key}:md5:${data.id.uid}`);
|
|
1379
|
-
delete data.md5;
|
|
1380
|
-
|
|
1381
|
-
this.action('delete', `${key}:sha256:${data.id.uid}`);
|
|
1382
|
-
delete data.sha256;
|
|
1383
|
-
|
|
1384
|
-
this.action('delete', `${key}:sha512:${data.id.uid}`);
|
|
1385
|
-
delete data.sha512;
|
|
1386
|
-
|
|
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}`);
|
|
1391
|
-
data.md5 = this.hash(data, 'md5');
|
|
1392
|
-
|
|
1393
|
-
this.action('hash', `${key}:sha256:${data.id.uid}`)
|
|
1394
|
-
data.sha256 = this.hash(data, 'sha256');
|
|
1395
|
-
|
|
1396
|
-
this.action('hash', `${key}:sha512:${data.id.uid}`)
|
|
1397
|
-
data.sha512 = this.hash(data, 'sha512');
|
|
1398
|
-
|
|
1399
|
-
// setup the complete talk event
|
|
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
|
|
1402
|
-
|
|
1403
|
-
// determine if there is an onComplete function for the entity.
|
|
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);
|
|
1412
|
-
}
|
|
1413
|
-
|
|
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);
|
|
1361
|
+
return this._invoke({key:'complete',data,resolve});
|
|
1418
1362
|
}
|
|
1419
|
-
|
|
1363
|
+
|
|
1420
1364
|
/**************
|
|
1421
1365
|
func: stop
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
If the deva is offline it will return the offline message.
|
|
1430
|
-
usage:
|
|
1431
|
-
this.stop()
|
|
1366
|
+
usage: this.stop(data, resolve);
|
|
1367
|
+
params: data, resolve
|
|
1368
|
+
- data: The data packet that is passed through the closing invoke chain.
|
|
1369
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1370
|
+
describe:
|
|
1371
|
+
The stop() function initiates the egress stop aspect of the Invoke
|
|
1372
|
+
Recursion Framework.
|
|
1432
1373
|
***************/
|
|
1433
1374
|
stop() {
|
|
1434
|
-
if (!this._active) return this._messages.offline;
|
|
1435
|
-
const
|
|
1436
|
-
const id = this.uid();
|
|
1437
|
-
this.context(key, id.uid);
|
|
1438
|
-
this.zone(key, id.uid);
|
|
1439
|
-
this.action(key, id.uid);
|
|
1440
|
-
this.state(key, id.uid); // set the state to stop
|
|
1375
|
+
if (!this._active) return this._messages.offline; // check for active status
|
|
1376
|
+
const key = 'stop'; // set the stop key
|
|
1377
|
+
const id = this.uid(); // generate the stop uid
|
|
1441
1378
|
|
|
1442
1379
|
this.state('set', `${key}:agent:${id.uid}`); // state stop agent
|
|
1443
1380
|
const agent = this.agent().sha256; // get the current agent
|
|
@@ -1455,30 +1392,65 @@ class Deva {
|
|
|
1455
1392
|
client, // set the client
|
|
1456
1393
|
stop: Date.now(), // set the created date
|
|
1457
1394
|
}
|
|
1395
|
+
|
|
1396
|
+
this.action('return', `${key}:invoke:${data.id.uid}`);
|
|
1397
|
+
this.state('valid', `${key}:invoke:${data.id.uid}`);
|
|
1398
|
+
this.intent('good', `${key}:invoke:${data.id.uid}`);
|
|
1399
|
+
return this._invoke({
|
|
1400
|
+
key,
|
|
1401
|
+
data,
|
|
1402
|
+
resolve: Promise.resolve(),
|
|
1403
|
+
})
|
|
1404
|
+
}
|
|
1458
1405
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
data
|
|
1406
|
+
/**************
|
|
1407
|
+
func: close
|
|
1408
|
+
usage: this.close(data, resolve);
|
|
1409
|
+
params: data, resolve
|
|
1410
|
+
- data: The data packet that is passed through the closing invoke chain.
|
|
1411
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1412
|
+
describe:
|
|
1413
|
+
The close() function initiates the close aspect of the Invoke Recursion Framework.
|
|
1414
|
+
***************/
|
|
1415
|
+
close(data, resolve) {
|
|
1416
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1417
|
+
return this._invoke({key:'close',data,resolve});
|
|
1418
|
+
}
|
|
1465
1419
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1420
|
+
/**************
|
|
1421
|
+
func: leave
|
|
1422
|
+
usage: this.leave(data, resolve);
|
|
1423
|
+
params: data, resolve
|
|
1424
|
+
- data: The data packet that is passed through the closing invoke chain.
|
|
1425
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1426
|
+
describe:
|
|
1427
|
+
The leave() function initiates the leave aspect of the Invoke Recursion
|
|
1428
|
+
Framework.
|
|
1429
|
+
***************/
|
|
1430
|
+
leave(data, resolve) {
|
|
1431
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1432
|
+
return this._invoke({key:'leave',data,resolve});
|
|
1478
1433
|
}
|
|
1479
1434
|
|
|
1480
1435
|
/**************
|
|
1481
1436
|
func: exit
|
|
1437
|
+
usage: this.exit(data, resolve);
|
|
1438
|
+
params: data, resolve
|
|
1439
|
+
- data: The data packet that is passed through the egress invoke chain.
|
|
1440
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1441
|
+
describe:
|
|
1442
|
+
The exit() function initiates the exit aspect of the Invoke Recursion
|
|
1443
|
+
Framework.
|
|
1444
|
+
***************/
|
|
1445
|
+
exit(data, resolve) {
|
|
1446
|
+
if (!this._active) return this._messages.offline;
|
|
1447
|
+
const key = 'exit';
|
|
1448
|
+
data.key = key;
|
|
1449
|
+
return this._invoke({key, data, resolve})
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
/**************
|
|
1453
|
+
func: shutdown
|
|
1482
1454
|
params:
|
|
1483
1455
|
- msg: hte message from the caller incase need to use in calls
|
|
1484
1456
|
describe:
|
|
@@ -1487,57 +1459,11 @@ class Deva {
|
|
|
1487
1459
|
The return will check for a custom onExit function or run the done
|
|
1488
1460
|
function.
|
|
1489
1461
|
***************/
|
|
1490
|
-
|
|
1462
|
+
shutdown(data, resolve) {
|
|
1491
1463
|
if (!this._active) return this._messages.offline;
|
|
1492
|
-
const
|
|
1464
|
+
const key = 'shutdown';
|
|
1493
1465
|
data.key = key;
|
|
1494
|
-
|
|
1495
|
-
this.context(key, data.id.uid);
|
|
1496
|
-
this.zone(key, data.id.uid);
|
|
1497
|
-
this.action(key, data.id.uid);
|
|
1498
|
-
this.state(key, data.id.uid); // set the state to stop
|
|
1499
|
-
|
|
1500
|
-
this.action('delete', `${prev_key}:md5:${data.id.uid}`);
|
|
1501
|
-
delete data.md5;
|
|
1502
|
-
this.action('delete', `${prev_key}:sha256:${data.id.uid}`);
|
|
1503
|
-
delete data.sha256;
|
|
1504
|
-
this.action('delete', `${prev_key}:sha512:${data.id.uid}`);
|
|
1505
|
-
delete data.sha512;
|
|
1506
|
-
|
|
1507
|
-
this.state('data', `${key}:time:${data.id.uid}`); // state stop agent
|
|
1508
|
-
data.exit = Date.now();
|
|
1509
|
-
|
|
1510
|
-
this.action('hash', `${key}:md5:${data.id.uid}`);
|
|
1511
|
-
data.md5 = this.hash(data, 'md5');
|
|
1512
|
-
this.action('hash', `${key}:sha256:${data.id.uid}`)
|
|
1513
|
-
data.sha256 = this.hash(data, 'sha256');
|
|
1514
|
-
this.action('hash', `${key}:sha512:${data.id.uid}`)
|
|
1515
|
-
data.sha512 = this.hash(data, 'sha512');
|
|
1516
|
-
|
|
1517
|
-
// clear memory from config.invoke.exit.clear
|
|
1518
|
-
|
|
1519
|
-
this.state('loop', `${key}:clear:${data.id.uid}`);
|
|
1520
|
-
for (let item of config.invoke.exit.clear) {
|
|
1521
|
-
this[item] = false;
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
this.action('talk', `${this._events.stop}:${data.id.uid}`); // action talk for the event.
|
|
1525
|
-
this.talk(this._events.exit, data);
|
|
1526
|
-
|
|
1527
|
-
const hasOnExit = this.onExit && typeof this.onExit === 'function';
|
|
1528
|
-
if (hasOnExit) {
|
|
1529
|
-
this.action('onfunc', `${onfunc}:${data.id.uid}`); // action onfunc
|
|
1530
|
-
this.state('onfunc', `${onfunc}:${data.id.uid}`); // state onfunc
|
|
1531
|
-
this.action('return', `${onfunc}:${data.id.uid}`); // state onfunc
|
|
1532
|
-
this.state('valid', `${onfunc}:${data.id.uid}`); // state onfunc
|
|
1533
|
-
this.intent('good', `${onfunc}:${data.id.uid}`); // state onfunc
|
|
1534
|
-
return this[onfunc](data);
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
this.action('resolve', `${key}:${data.uid}`);
|
|
1538
|
-
this.state('valid', `${key}:${data.uid}`);
|
|
1539
|
-
this.intent('good', `${key}:${data.uid}`);
|
|
1540
|
-
return Promise.resolve(data)
|
|
1466
|
+
return this._invoke({key, data, resolve})
|
|
1541
1467
|
}
|
|
1542
1468
|
|
|
1543
1469
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "44091450722329207445",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.4",
|
|
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",
|