@indra.ai/deva 1.1.91 → 1.1.93
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 +13 -7
- package/index.js +16 -18
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -153,8 +153,8 @@
|
|
|
153
153
|
"states": {
|
|
154
154
|
"offline": "::agent.name:: is offline",
|
|
155
155
|
"online": "::agent.name:: is online",
|
|
156
|
-
"ask": "::agent.name::
|
|
157
|
-
"question": "::agent.name::
|
|
156
|
+
"ask": "::agent.name:: asked a question",
|
|
157
|
+
"question": "::agent.name:: received a question",
|
|
158
158
|
"answer": "::agent.name:: answered the question",
|
|
159
159
|
"init": "::agent.name:: is initializing",
|
|
160
160
|
"start": "::agent.name:: is starting",
|
|
@@ -182,12 +182,18 @@
|
|
|
182
182
|
},
|
|
183
183
|
"actions": {
|
|
184
184
|
"wait": "::agent.name:: is waiting",
|
|
185
|
-
"
|
|
186
|
-
"
|
|
187
|
-
"
|
|
185
|
+
"start": "::agent.name:: has started",
|
|
186
|
+
"enter": "::agent.name:: has entered deva.world",
|
|
187
|
+
"exit": "::agent.name:: has exited deva.world",
|
|
188
|
+
"stop": "::agent.name:: is stopped",
|
|
189
|
+
"load": "::agent.name:: is loaded",
|
|
190
|
+
"unload": "::agent.name:: is unloaded",
|
|
191
|
+
"question": "::agent.name:: received a question",
|
|
192
|
+
"question_ask": "::agent.name:: is asking another Deva",
|
|
193
|
+
"question_ask_answer": "::agent.name:: answered what they were asked",
|
|
188
194
|
"question_cmd": "::agent.name:: is running a command",
|
|
189
|
-
"question_method": "::agent.name:: is
|
|
190
|
-
"question_talk": "::agent.name:: is
|
|
195
|
+
"question_method": "::agent.name:: is running a method",
|
|
196
|
+
"question_talk": "::agent.name:: is broadcasting the question",
|
|
191
197
|
"question_answer": "::agent.name:: answered the question",
|
|
192
198
|
"question_done": "::agent.name:: the question is done",
|
|
193
199
|
"answer": "::agent.name:: is generating an answer",
|
package/index.js
CHANGED
|
@@ -848,7 +848,7 @@ class Deva {
|
|
|
848
848
|
};
|
|
849
849
|
|
|
850
850
|
// create a hash for the answer and insert into answer meta.
|
|
851
|
-
packet_answer.meta.hash = this.hash(
|
|
851
|
+
packet_answer.meta.hash = this.hash(packet_answer);
|
|
852
852
|
|
|
853
853
|
packet.a = this.copy(packet_answer);
|
|
854
854
|
packet.hash = this.hash(packet); // hash the entire packet.
|
|
@@ -974,6 +974,9 @@ class Deva {
|
|
|
974
974
|
usage: this.init(client_object)
|
|
975
975
|
***************/
|
|
976
976
|
init(client) {
|
|
977
|
+
// set client
|
|
978
|
+
this._active = Date.now();
|
|
979
|
+
|
|
977
980
|
const _data = {
|
|
978
981
|
id: this.uid(true),
|
|
979
982
|
key: 'return',
|
|
@@ -985,8 +988,6 @@ class Deva {
|
|
|
985
988
|
}
|
|
986
989
|
_data.hash = this.hash(_data);
|
|
987
990
|
|
|
988
|
-
// set client
|
|
989
|
-
this._active = Date.now();
|
|
990
991
|
return new Promise((resolve, reject) => {
|
|
991
992
|
this.events.setMaxListeners(this.maxListeners);
|
|
992
993
|
this._assignInherit().then(() => {
|
|
@@ -1026,7 +1027,7 @@ class Deva {
|
|
|
1026
1027
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1027
1028
|
data.value = 'start';
|
|
1028
1029
|
delete data.hash;
|
|
1029
|
-
data.hash = this.hash(
|
|
1030
|
+
data.hash = this.hash(data);
|
|
1030
1031
|
|
|
1031
1032
|
if (this.info) {
|
|
1032
1033
|
const _info = this.info(data.id);
|
|
@@ -1054,7 +1055,7 @@ class Deva {
|
|
|
1054
1055
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1055
1056
|
data.value = 'enter';
|
|
1056
1057
|
delete data.hash;
|
|
1057
|
-
data.hash = this.hash(
|
|
1058
|
+
data.hash = this.hash(data);
|
|
1058
1059
|
this.action(data.value);
|
|
1059
1060
|
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
1060
1061
|
return hasOnEnter ? this.onEnter(data) : this.done(data)
|
|
@@ -1076,7 +1077,7 @@ class Deva {
|
|
|
1076
1077
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1077
1078
|
data.value = 'done';
|
|
1078
1079
|
delete data.hash;
|
|
1079
|
-
data.hash = this.hash(
|
|
1080
|
+
data.hash = this.hash(data);
|
|
1080
1081
|
this.action(data.value)
|
|
1081
1082
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
1082
1083
|
return hasOnDone ? this.onDone(data) : Promise.resolve(data);
|
|
@@ -1107,7 +1108,7 @@ class Deva {
|
|
|
1107
1108
|
text: this._messages.states.stop,
|
|
1108
1109
|
created: Date.now(),
|
|
1109
1110
|
}
|
|
1110
|
-
data.hash = this.hash(
|
|
1111
|
+
data.hash = this.hash(data);
|
|
1111
1112
|
this.action(data.value);
|
|
1112
1113
|
const hasOnStop = this.onStop && typeof this.onStop === 'function';
|
|
1113
1114
|
return hasOnStop ? this.onStop(data) : this.exit(data)
|
|
@@ -1133,7 +1134,7 @@ class Deva {
|
|
|
1133
1134
|
this._active = false;
|
|
1134
1135
|
data.value = 'exit';
|
|
1135
1136
|
delete data.hash;
|
|
1136
|
-
data.hash = this.hash(
|
|
1137
|
+
data.hash = this.hash(data);
|
|
1137
1138
|
|
|
1138
1139
|
// clear memory
|
|
1139
1140
|
this._active = false;
|
|
@@ -1161,6 +1162,7 @@ class Deva {
|
|
|
1161
1162
|
describe
|
|
1162
1163
|
***************/
|
|
1163
1164
|
state(state) {
|
|
1165
|
+
console.log('STATE', state);
|
|
1164
1166
|
try {
|
|
1165
1167
|
if (!this._states[state]) return;
|
|
1166
1168
|
this._state = state;
|
|
@@ -1174,7 +1176,7 @@ class Deva {
|
|
|
1174
1176
|
text,
|
|
1175
1177
|
created: Date.now(),
|
|
1176
1178
|
};
|
|
1177
|
-
_data.hash = this.hash(
|
|
1179
|
+
_data.hash = this.hash(_data);
|
|
1178
1180
|
this.talk(config.events.state, _data);
|
|
1179
1181
|
} catch (e) {
|
|
1180
1182
|
return this.error(e);
|
|
@@ -1210,7 +1212,7 @@ class Deva {
|
|
|
1210
1212
|
data,
|
|
1211
1213
|
created: Date.now(),
|
|
1212
1214
|
};
|
|
1213
|
-
_data.hash = this.hash(
|
|
1215
|
+
_data.hash = this.hash(_data);
|
|
1214
1216
|
this.talk(config.events.zone, _data);
|
|
1215
1217
|
} catch (e) {
|
|
1216
1218
|
return this.error(e);
|
|
@@ -1237,7 +1239,7 @@ class Deva {
|
|
|
1237
1239
|
text,
|
|
1238
1240
|
created: Date.now(),
|
|
1239
1241
|
};
|
|
1240
|
-
_data.hash = this.hash(
|
|
1242
|
+
_data.hash = this.hash(_data);
|
|
1241
1243
|
this.talk(config.events.action, _data);
|
|
1242
1244
|
} catch (e) {
|
|
1243
1245
|
return this.error(e)
|
|
@@ -1264,7 +1266,7 @@ class Deva {
|
|
|
1264
1266
|
data,
|
|
1265
1267
|
created: Date.now(),
|
|
1266
1268
|
};
|
|
1267
|
-
_data.hash = this.hash(
|
|
1269
|
+
_data.hash = this.hash(_data);
|
|
1268
1270
|
this.talk(config.events.feature, _data);
|
|
1269
1271
|
} catch (e) {
|
|
1270
1272
|
return this.error(e);
|
|
@@ -1289,7 +1291,7 @@ class Deva {
|
|
|
1289
1291
|
text,
|
|
1290
1292
|
created: Date.now(),
|
|
1291
1293
|
};
|
|
1292
|
-
_data.hash = this.hash(
|
|
1294
|
+
_data.hash = this.hash(_data);
|
|
1293
1295
|
this.talk(config.events.context, _data);
|
|
1294
1296
|
} catch (e) {
|
|
1295
1297
|
return this.error(e);
|
|
@@ -1606,7 +1608,6 @@ class Deva {
|
|
|
1606
1608
|
const max = Math.floor(Date.now() + (Date.now() * Math.PI));
|
|
1607
1609
|
id = Math.floor(Math.random() * (max - min)) + min;
|
|
1608
1610
|
}
|
|
1609
|
-
this.action('uid');
|
|
1610
1611
|
return id;
|
|
1611
1612
|
}
|
|
1612
1613
|
|
|
@@ -1625,7 +1626,6 @@ class Deva {
|
|
|
1625
1626
|
const the_hash = createHash(algo);
|
|
1626
1627
|
the_hash.update(str.toString());
|
|
1627
1628
|
const _digest = the_hash.digest('base64');
|
|
1628
|
-
this.action('hash');
|
|
1629
1629
|
return `${algo}:${_digest}`;
|
|
1630
1630
|
}
|
|
1631
1631
|
|
|
@@ -1648,7 +1648,7 @@ class Deva {
|
|
|
1648
1648
|
const _cipher = createCipheriv(algorithm, key_in_bytes, iv);
|
|
1649
1649
|
const encrypted = _cipher.update(String(str), 'utf8', 'hex') + _cipher.final('hex');
|
|
1650
1650
|
|
|
1651
|
-
|
|
1651
|
+
|
|
1652
1652
|
return {
|
|
1653
1653
|
iv: iv.toString('base64'),
|
|
1654
1654
|
key,
|
|
@@ -1665,7 +1665,6 @@ class Deva {
|
|
|
1665
1665
|
const decipher = createDecipheriv( algorithm, key_in_bytes, iv);
|
|
1666
1666
|
const decrypted = decipher.update(encrypted);
|
|
1667
1667
|
const final = Buffer.concat([decrypted, decipher.final()]);
|
|
1668
|
-
this.action('decipher');
|
|
1669
1668
|
return final.toString();
|
|
1670
1669
|
}
|
|
1671
1670
|
|
|
@@ -1688,7 +1687,6 @@ class Deva {
|
|
|
1688
1687
|
// create the text msg string
|
|
1689
1688
|
let text = `${this._agent.profile.name} active since ${dateFormat}`;
|
|
1690
1689
|
if (msg) text = text + `\n${msg}`; // append the msg string if msg true.
|
|
1691
|
-
this.action('status');
|
|
1692
1690
|
return Promise.resolve(text); // return final text string
|
|
1693
1691
|
}
|
|
1694
1692
|
|