@indra.ai/deva 1.8.2 → 1.8.3
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/index.js +20 -9
- package/index.js +143 -230
- package/package.json +1 -1
package/config/actions.json
CHANGED
package/config/index.js
CHANGED
|
@@ -41,49 +41,60 @@ 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
99
|
next_key: false,
|
|
89
100
|
onfunc: 'onExit',
|
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
|
-
});
|
|
1361
|
+
return this._invoke({key:'complete',data,resolve});
|
|
1360
1362
|
}
|
|
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);
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1363
|
+
|
|
1420
1364
|
/**************
|
|
1421
1365
|
func: stop
|
|
1422
1366
|
params:
|
|
1423
1367
|
- msg: hte message from the caller incase need to use in calls
|
|
1424
1368
|
describe:
|
|
1425
|
-
The stop function will stop the Deva by setting
|
|
1426
|
-
|
|
1427
|
-
for anything to run, or run the exit function.
|
|
1428
|
-
|
|
1429
|
-
If the deva is offline it will return the offline message.
|
|
1369
|
+
The stop function will stop the Deva by setting necessary context,
|
|
1370
|
+
zone, action, state to stop and creating the stop data packet.
|
|
1430
1371
|
usage:
|
|
1431
1372
|
this.stop()
|
|
1432
1373
|
***************/
|
|
1433
1374
|
stop() {
|
|
1434
1375
|
if (!this._active) return this._messages.offline;
|
|
1435
|
-
const
|
|
1376
|
+
const key = 'stop';
|
|
1436
1377
|
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
|
|
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,26 +1392,48 @@ class Deva {
|
|
|
1455
1392
|
client, // set the client
|
|
1456
1393
|
stop: Date.now(), // set the created date
|
|
1457
1394
|
}
|
|
1395
|
+
|
|
1396
|
+
return this._invoke({
|
|
1397
|
+
key,
|
|
1398
|
+
data,
|
|
1399
|
+
resolve: Promise.resolve(),
|
|
1400
|
+
})
|
|
1401
|
+
}
|
|
1458
1402
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
data
|
|
1403
|
+
/**************
|
|
1404
|
+
func: close
|
|
1405
|
+
usage: this.close(data, resolve);
|
|
1406
|
+
params: data, resolve
|
|
1407
|
+
- data: The data packet that is passed through the closing invoke chain.
|
|
1408
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1409
|
+
describe:
|
|
1410
|
+
The close() function initiates the closing Invoke Recursion Framework.
|
|
1411
|
+
It first checks for active runtime status, retrieves invocation parameters
|
|
1412
|
+
(chain mapping, lifecycle handlers) from config.invoke.close and then
|
|
1413
|
+
delegates control to _invoke(), ensuring consistent recursion through the
|
|
1414
|
+
start-enter-done sequence.
|
|
1415
|
+
***************/
|
|
1416
|
+
close(data, resolve) {
|
|
1417
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1418
|
+
return this._invoke({key:'close',data,resolve});
|
|
1419
|
+
}
|
|
1465
1420
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1421
|
+
/**************
|
|
1422
|
+
func: leave
|
|
1423
|
+
usage: this.leave(data, resolve);
|
|
1424
|
+
params: data, resolve
|
|
1425
|
+
- data: The data packet that is passed through the closing invoke chain.
|
|
1426
|
+
- resolve: The Promise resolver following the data through recursion.
|
|
1427
|
+
describe:
|
|
1428
|
+
The leave() function initiates the leave aspect of the Invoke Recursion
|
|
1429
|
+
Framework. It first checks for active runtime status, retrieves invocation
|
|
1430
|
+
parameters (chain mapping, lifecycle handlers) from config.invoke.close and
|
|
1431
|
+
then delegates control to _invoke(), ensuring consistent recursion through
|
|
1432
|
+
the start-enter-done sequence.
|
|
1433
|
+
***************/
|
|
1434
|
+
leave(data, resolve) {
|
|
1435
|
+
if (!this._active) return resolve(this._messages.offline);
|
|
1436
|
+
return this._invoke({key:'leave',data,resolve});
|
|
1478
1437
|
}
|
|
1479
1438
|
|
|
1480
1439
|
/**************
|
|
@@ -1487,57 +1446,11 @@ class Deva {
|
|
|
1487
1446
|
The return will check for a custom onExit function or run the done
|
|
1488
1447
|
function.
|
|
1489
1448
|
***************/
|
|
1490
|
-
exit(data) {
|
|
1449
|
+
exit(data, resolve) {
|
|
1491
1450
|
if (!this._active) return this._messages.offline;
|
|
1492
|
-
const
|
|
1451
|
+
const key = 'exit';
|
|
1493
1452
|
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)
|
|
1453
|
+
return this._invoke({key, data, resolve})
|
|
1541
1454
|
}
|
|
1542
1455
|
|
|
1543
1456
|
|
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.3",
|
|
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",
|