@indra.ai/deva 1.1.82 → 1.1.83
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 +12 -0
- package/index.js +10 -14
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -13,6 +13,18 @@
|
|
|
13
13
|
"lib",
|
|
14
14
|
"_agent"
|
|
15
15
|
],
|
|
16
|
+
"events": {
|
|
17
|
+
"prompt": "devacore:prompt",
|
|
18
|
+
"error": "devacore:error",
|
|
19
|
+
"question": "devacore:question",
|
|
20
|
+
"answer": "devacore:answer",
|
|
21
|
+
"state": "devacore:state",
|
|
22
|
+
"zone": "devacore:zone",
|
|
23
|
+
"action": "devacore:action",
|
|
24
|
+
"feature": "devacore:feature",
|
|
25
|
+
"load": "devacore:load",
|
|
26
|
+
"unload": "devacore:unload"
|
|
27
|
+
},
|
|
16
28
|
"state": "offline",
|
|
17
29
|
"states": {
|
|
18
30
|
"ask": "asking another",
|
package/index.js
CHANGED
|
@@ -772,7 +772,7 @@ class Deva {
|
|
|
772
772
|
packet.q.meta.hash = this.hash(packet.q);
|
|
773
773
|
|
|
774
774
|
this.action(_action);
|
|
775
|
-
this.talk(
|
|
775
|
+
this.talk(config.events.question, this.copy(packet)); // global question event make sure to copy data.
|
|
776
776
|
|
|
777
777
|
if (isAsk) { // isAsk check if the question isAsk and talk
|
|
778
778
|
this.state('ask');
|
|
@@ -851,7 +851,7 @@ class Deva {
|
|
|
851
851
|
|
|
852
852
|
|
|
853
853
|
this.action('answer_talk');
|
|
854
|
-
this.talk(
|
|
854
|
+
this.talk(config.events.answer, this.copy(packet)); // talk the answer with a copy of the data
|
|
855
855
|
|
|
856
856
|
return resolve(this.copy(packet)); // resolve the packet to the caller.
|
|
857
857
|
}).catch(err => { // catch any errors in the method
|
|
@@ -1166,7 +1166,7 @@ class Deva {
|
|
|
1166
1166
|
created: Date.now(),
|
|
1167
1167
|
};
|
|
1168
1168
|
_data.hash = this.hash(_data);
|
|
1169
|
-
this.talk(
|
|
1169
|
+
this.talk(config.events.state, _data);
|
|
1170
1170
|
} catch (e) {
|
|
1171
1171
|
return this.error(e);
|
|
1172
1172
|
}
|
|
@@ -1202,7 +1202,7 @@ class Deva {
|
|
|
1202
1202
|
created: Date.now(),
|
|
1203
1203
|
};
|
|
1204
1204
|
_data.hash = this.hash(_data);
|
|
1205
|
-
this.talk('
|
|
1205
|
+
this.talk('', _data);
|
|
1206
1206
|
} catch (e) {
|
|
1207
1207
|
return this.error(e);
|
|
1208
1208
|
}
|
|
@@ -1229,7 +1229,7 @@ class Deva {
|
|
|
1229
1229
|
created: Date.now(),
|
|
1230
1230
|
};
|
|
1231
1231
|
_data.hash = this.hash(_data);
|
|
1232
|
-
this.talk(
|
|
1232
|
+
this.talk(config.events.action, _data);
|
|
1233
1233
|
} catch (e) {
|
|
1234
1234
|
return this.error(e)
|
|
1235
1235
|
}
|
|
@@ -1256,7 +1256,7 @@ class Deva {
|
|
|
1256
1256
|
created: Date.now(),
|
|
1257
1257
|
};
|
|
1258
1258
|
_data.hash = this.hash(_data);
|
|
1259
|
-
this.talk(
|
|
1259
|
+
this.talk(config.events.feature, _data);
|
|
1260
1260
|
} catch (e) {
|
|
1261
1261
|
return this.error(e);
|
|
1262
1262
|
}
|
|
@@ -1515,7 +1515,7 @@ class Deva {
|
|
|
1515
1515
|
return new Promise((resolve, reject) => {
|
|
1516
1516
|
this.state('load');
|
|
1517
1517
|
this.devas[key].init(client).then(loaded => {
|
|
1518
|
-
this.talk(
|
|
1518
|
+
this.talk(config.events.load, {
|
|
1519
1519
|
id:this.uid(true),
|
|
1520
1520
|
key,
|
|
1521
1521
|
created: Date.now(),
|
|
@@ -1539,11 +1539,7 @@ class Deva {
|
|
|
1539
1539
|
this.state('uload');
|
|
1540
1540
|
this.devas[key].stop().then(exit => {
|
|
1541
1541
|
delete this.devas[key];
|
|
1542
|
-
this.talk(
|
|
1543
|
-
id:this.uid(true),
|
|
1544
|
-
key,
|
|
1545
|
-
created: Date.now(),
|
|
1546
|
-
});
|
|
1542
|
+
this.talk(config.events.unload, key);
|
|
1547
1543
|
});
|
|
1548
1544
|
return resolve(this._messages.states.unload);
|
|
1549
1545
|
} catch (e) {
|
|
@@ -1678,7 +1674,7 @@ class Deva {
|
|
|
1678
1674
|
text,
|
|
1679
1675
|
created: Date.now(),
|
|
1680
1676
|
}
|
|
1681
|
-
return this.talk(
|
|
1677
|
+
return this.talk(config.events.prompt, _data);
|
|
1682
1678
|
}
|
|
1683
1679
|
|
|
1684
1680
|
|
|
@@ -1841,7 +1837,7 @@ class Deva {
|
|
|
1841
1837
|
data,
|
|
1842
1838
|
created: Date.now(),
|
|
1843
1839
|
}
|
|
1844
|
-
this.talk(
|
|
1840
|
+
this.talk(config.events.error, this.copy(_data));
|
|
1845
1841
|
|
|
1846
1842
|
const hasOnError = this.onError && typeof this.onError === 'function' ? true : false;
|
|
1847
1843
|
if (hasOnError) return this.onError(err, data, reject);
|