@indra.ai/deva 1.1.43 → 1.1.44
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 +24 -20
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1022,7 +1022,7 @@ class Deva {
|
|
|
1022
1022
|
|
|
1023
1023
|
|
|
1024
1024
|
this.action('answer_talk');
|
|
1025
|
-
this.talk('devacore:answer', packet); // talk the answer with a copy of the data
|
|
1025
|
+
this.talk('devacore:answer', this.copy(packet)); // talk the answer with a copy of the data
|
|
1026
1026
|
|
|
1027
1027
|
return resolve(packet); // resolve the packet to the caller.
|
|
1028
1028
|
}).catch(err => { // catch any errors in the method
|
|
@@ -1073,7 +1073,7 @@ class Deva {
|
|
|
1073
1073
|
return setImmediate(() => {
|
|
1074
1074
|
this.action('invalid')
|
|
1075
1075
|
packet.a.text = `INVALID METHOD (${packet.q.meta.method})`;
|
|
1076
|
-
this.talk(`${this._agent.key}:ask:${packet.id}`, packet);
|
|
1076
|
+
this.talk(`${this._agent.key}:ask:${packet.id}`, this.copy(packet));
|
|
1077
1077
|
});
|
|
1078
1078
|
}
|
|
1079
1079
|
|
|
@@ -1092,13 +1092,13 @@ class Deva {
|
|
|
1092
1092
|
this.talk(`${this._agent.key}:ask:${packet.id}`, this.copy(packet));
|
|
1093
1093
|
}).catch(err => {
|
|
1094
1094
|
this.action('error');
|
|
1095
|
-
this.talk(`${this._agent.key}:ask:${packet.id}`, {error:err
|
|
1095
|
+
this.talk(`${this._agent.key}:ask:${packet.id}`, {error:err});
|
|
1096
1096
|
return this.error(err, packet);
|
|
1097
1097
|
})
|
|
1098
1098
|
}
|
|
1099
1099
|
catch (e) {
|
|
1100
1100
|
this.action('error');
|
|
1101
|
-
this.talk(`${this._agent.key}:ask:${packet.id}`, {error:e
|
|
1101
|
+
this.talk(`${this._agent.key}:ask:${packet.id}`, {error:e});
|
|
1102
1102
|
return this.error(e, packet)
|
|
1103
1103
|
}
|
|
1104
1104
|
// now when we ask the meta params[0] should be the method
|
|
@@ -1363,7 +1363,7 @@ class Deva {
|
|
|
1363
1363
|
created: Date.now(),
|
|
1364
1364
|
};
|
|
1365
1365
|
_data.hash = this.hash(JSON.stringify(_data));
|
|
1366
|
-
this.talk('zone', _data);
|
|
1366
|
+
this.talk('devacore:zone', this.copy(_data));
|
|
1367
1367
|
} catch (e) {
|
|
1368
1368
|
return this.error(e);
|
|
1369
1369
|
}
|
|
@@ -1417,7 +1417,7 @@ class Deva {
|
|
|
1417
1417
|
created: Date.now(),
|
|
1418
1418
|
};
|
|
1419
1419
|
_data.hash = this.hash(JSON.stringify(_data));
|
|
1420
|
-
this.talk('devacore:feature', _data);
|
|
1420
|
+
this.talk('devacore:feature', this.copy(_data));
|
|
1421
1421
|
} catch (e) {
|
|
1422
1422
|
return this.error(e);
|
|
1423
1423
|
}
|
|
@@ -1643,6 +1643,7 @@ class Deva {
|
|
|
1643
1643
|
this.state('load');
|
|
1644
1644
|
this.devas[key].init(client).then(loaded => {
|
|
1645
1645
|
this.talk(`devacore:load`, {
|
|
1646
|
+
id:this.uid(true),
|
|
1646
1647
|
key,
|
|
1647
1648
|
created: Date.now(),
|
|
1648
1649
|
});
|
|
@@ -1663,14 +1664,17 @@ class Deva {
|
|
|
1663
1664
|
return new Promise((resolve, reject) => {
|
|
1664
1665
|
try {
|
|
1665
1666
|
this.state('uload');
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1667
|
+
this.devas[key].stop().then(exit => {
|
|
1668
|
+
delete this.devas[key];
|
|
1669
|
+
this.talk(`devacore:unload`, {
|
|
1670
|
+
id:this.uid(true),
|
|
1671
|
+
key,
|
|
1672
|
+
created: Date.now(),
|
|
1673
|
+
});
|
|
1670
1674
|
});
|
|
1671
1675
|
return resolve(this._messages.states.unload);
|
|
1672
1676
|
} catch (e) {
|
|
1673
|
-
return
|
|
1677
|
+
return this.error(e, this.devas[key], reject)
|
|
1674
1678
|
}
|
|
1675
1679
|
});
|
|
1676
1680
|
}
|
|
@@ -1798,15 +1802,16 @@ class Deva {
|
|
|
1798
1802
|
***************/
|
|
1799
1803
|
prompt(text) {
|
|
1800
1804
|
// Talk a global prompt event for the client
|
|
1801
|
-
|
|
1802
|
-
id: this.uid(),
|
|
1805
|
+
const _data = {
|
|
1806
|
+
id: this.uid(true),
|
|
1803
1807
|
key: 'return',
|
|
1804
1808
|
value: 'prompt',
|
|
1805
1809
|
agent: this.agent(),
|
|
1806
1810
|
client: this.client(),
|
|
1807
1811
|
text,
|
|
1808
1812
|
created: Date.now(),
|
|
1809
|
-
}
|
|
1813
|
+
}
|
|
1814
|
+
return this.talk('devacore:prompt', this.copy(_data));
|
|
1810
1815
|
}
|
|
1811
1816
|
|
|
1812
1817
|
|
|
@@ -1940,22 +1945,21 @@ class Deva {
|
|
|
1940
1945
|
console.log('\n::END:DATA\n');
|
|
1941
1946
|
}
|
|
1942
1947
|
|
|
1943
|
-
|
|
1948
|
+
const _data = {
|
|
1944
1949
|
id: this.uid(true),
|
|
1945
1950
|
key: 'return',
|
|
1946
1951
|
value: 'error',
|
|
1947
1952
|
agent: this.agent(),
|
|
1948
1953
|
client: this.client(),
|
|
1949
|
-
|
|
1954
|
+
error: err,
|
|
1950
1955
|
data,
|
|
1951
1956
|
created: Date.now(),
|
|
1952
|
-
}
|
|
1957
|
+
}
|
|
1958
|
+
this.talk('devacore:error', this.copy(_data));
|
|
1953
1959
|
|
|
1954
1960
|
const hasOnError = this.onError && typeof this.onError === 'function' ? true : false;
|
|
1955
1961
|
if (hasOnError) return this.onError(err, data, reject);
|
|
1956
|
-
else
|
|
1957
|
-
return reject ? reject(err) : err;
|
|
1958
|
-
}
|
|
1962
|
+
else return reject ? reject(err) : err;
|
|
1959
1963
|
}
|
|
1960
1964
|
|
|
1961
1965
|
}
|