@indra.ai/deva 1.54.0 → 1.54.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/index.js +29 -15
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -151,13 +151,11 @@ class Deva {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
|
+
return resolve(); // when the configuration is complete then return an empty resolve.
|
|
154
155
|
}
|
|
155
156
|
catch (e) {
|
|
156
157
|
return this.err(e, false, reject); // trigger the this.err for errors
|
|
157
158
|
}
|
|
158
|
-
finally {
|
|
159
|
-
return resolve(); // when the configuration is complete then return an empty resolve.
|
|
160
|
-
}
|
|
161
159
|
});
|
|
162
160
|
}
|
|
163
161
|
|
|
@@ -186,13 +184,11 @@ class Deva {
|
|
|
186
184
|
return this.listeners[listener](packet); // return the listener function
|
|
187
185
|
})
|
|
188
186
|
}
|
|
187
|
+
return resolve(); // resolve the function after everything is done.
|
|
189
188
|
}
|
|
190
189
|
catch (e) {
|
|
191
190
|
return this.err(e, false, reject); // pass errors to this.err
|
|
192
191
|
}
|
|
193
|
-
finally {
|
|
194
|
-
return resolve(); // resolve the function after everything is done.
|
|
195
|
-
}
|
|
196
192
|
});
|
|
197
193
|
}
|
|
198
194
|
|
|
@@ -309,7 +305,7 @@ class Deva {
|
|
|
309
305
|
if (!config.invoke[key]) return resolve (this._messages.invalidkey);
|
|
310
306
|
if (!data) return resolve (this._messages.nodata);
|
|
311
307
|
|
|
312
|
-
const {
|
|
308
|
+
const {next_key, onfunc, clear} = config.invoke[key];
|
|
313
309
|
this.action('invoke', `${key}:${data.id.uid}`);
|
|
314
310
|
this.context(key, data.id.uid);
|
|
315
311
|
this.zone(key, data.id.uid);
|
|
@@ -738,9 +734,10 @@ class Deva {
|
|
|
738
734
|
describe:
|
|
739
735
|
***************/
|
|
740
736
|
question(TEXT=false, DATA=false) {
|
|
737
|
+
if (!this._active) return Promise.resolve(this._messages.offline); // resolve with offline message when not active.
|
|
738
|
+
if (!TEXT || typeof TEXT !== 'string') return Promise.resolve(this._messages.notext); // resolve with the no text message if the client says nothing.
|
|
739
|
+
|
|
741
740
|
const id = this.uid(); // generate a unique id for transport.
|
|
742
|
-
// check the active status
|
|
743
|
-
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
744
741
|
this.zone('question', id.uid);
|
|
745
742
|
this.action('question', id.uid);
|
|
746
743
|
const t_split = TEXT.split(' '); // split the text on spaces to get words.
|
|
@@ -766,9 +763,8 @@ class Deva {
|
|
|
766
763
|
key = this.agent().key; // set a temporary key from the agent key.
|
|
767
764
|
|
|
768
765
|
return new Promise((resolve, reject) => {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
this.state('try', `${method}:${id.uid}`);
|
|
766
|
+
|
|
767
|
+
this.state('try', `${method}:${id.uid}`); // set state to try for process.
|
|
772
768
|
try { // try to answer the question
|
|
773
769
|
if (isAsk) { // determine if hte question isAsk
|
|
774
770
|
// if:isAsk split the agent key and remove first command character
|
|
@@ -1089,6 +1085,10 @@ class Deva {
|
|
|
1089
1085
|
init(client) {
|
|
1090
1086
|
// set client
|
|
1091
1087
|
return new Promise((resolve, reject) => {
|
|
1088
|
+
// set the core hashes
|
|
1089
|
+
this._core.md5 = this.hash(this._core, 'md5'); // md5 the core and created.
|
|
1090
|
+
this._core.sha256 = this.hash(this._core, 'sha256'); // sha256 the core, created, md5
|
|
1091
|
+
this._core.sha512 = this.hash(this._core, 'sha512'); // sha512 the core, created, md5, sha256.
|
|
1092
1092
|
|
|
1093
1093
|
const license_check = this.license_check(client.VLA, this._core.VLA);
|
|
1094
1094
|
if (!license_check) {
|
|
@@ -1110,7 +1110,8 @@ class Deva {
|
|
|
1110
1110
|
text: this._messages.init,
|
|
1111
1111
|
created: Date.now(),
|
|
1112
1112
|
}
|
|
1113
|
-
|
|
1113
|
+
|
|
1114
|
+
|
|
1114
1115
|
this.action('hash', `start:md5:${data.id.uid}`);
|
|
1115
1116
|
data.md5 = this.hash(data, 'md5');
|
|
1116
1117
|
|
|
@@ -1184,6 +1185,7 @@ class Deva {
|
|
|
1184
1185
|
this.action('return', `init:${data.id.uid}`);
|
|
1185
1186
|
this.state('valid', `init:${data.id.uid}`); // state set to watch onInit
|
|
1186
1187
|
this.intent('good', `init:${data.id.uid}`); // state set to watch onInit
|
|
1188
|
+
|
|
1187
1189
|
return this.start(data, resolve);
|
|
1188
1190
|
}).catch(err => {
|
|
1189
1191
|
this.state('catch', `init:${data.id.uid}`);
|
|
@@ -2013,7 +2015,11 @@ class Deva {
|
|
|
2013
2015
|
const data = this.lib.copy(this._core);
|
|
2014
2016
|
data.id = id;
|
|
2015
2017
|
data.created = Date.now();
|
|
2016
|
-
|
|
2018
|
+
|
|
2019
|
+
delete data.md5; // delete old md5 hash
|
|
2020
|
+
delete data.sha256; // delete old sha256 hash
|
|
2021
|
+
delete data.sha512; // delete old sha512 hash
|
|
2022
|
+
|
|
2017
2023
|
data.md5 = this.hash(data, 'md5');
|
|
2018
2024
|
data.sha256 = this.hash(data, 'sha256');
|
|
2019
2025
|
data.sha512 = this.hash(data, 'sha512');
|
|
@@ -2166,7 +2172,15 @@ class Deva {
|
|
|
2166
2172
|
- reject: An associated promise reject if the caller requires.
|
|
2167
2173
|
describe:
|
|
2168
2174
|
The err function provides the consistent error manage of the system.
|
|
2175
|
+
|
|
2176
|
+
If the agent defines an onError function, err hands it (err, packet, reject)
|
|
2177
|
+
and returns its result. In that case the agent owns the outcome: onError must
|
|
2178
|
+
call reject to fail the caller's promise, or the promise will stay pending.
|
|
2179
|
+
If there is no onError function, err calls reject(err) itself.
|
|
2180
|
+
|
|
2169
2181
|
usage: this.err(err, data, reject);
|
|
2182
|
+
|
|
2183
|
+
|
|
2170
2184
|
***************/
|
|
2171
2185
|
err(err,packet,reject=false) {
|
|
2172
2186
|
const id = this.uid();
|
|
@@ -2251,7 +2265,7 @@ class Deva {
|
|
|
2251
2265
|
const {profile} = agent;
|
|
2252
2266
|
const machine = this.machine(); // get the machine hash
|
|
2253
2267
|
|
|
2254
|
-
const core_hash = this.
|
|
2268
|
+
const core_hash = this._core.sha256; // get the core sha256 hash
|
|
2255
2269
|
|
|
2256
2270
|
const warning = this._agent.profile.warning || this._messages.warning; // agent or default warning
|
|
2257
2271
|
const notice = this._agent.profile.notice || this._messages.notice; // agent or default notice
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "23221940810208468106",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.54.
|
|
4
|
+
"version": "1.54.10",
|
|
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:23221940810208468106 LICENSE.md",
|
|
@@ -84,6 +84,6 @@
|
|
|
84
84
|
},
|
|
85
85
|
"engines": {
|
|
86
86
|
"npm": ">=9.5.1",
|
|
87
|
-
"node": ">=
|
|
87
|
+
"node": ">=22"
|
|
88
88
|
}
|
|
89
89
|
}
|