@indra.ai/deva 1.5.9 → 1.5.11
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 +13 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -407,9 +407,9 @@ class Deva {
|
|
|
407
407
|
to and make a response. talk events can be then returned with a talk even id
|
|
408
408
|
to create seamless collaboration between Devas.
|
|
409
409
|
***************/
|
|
410
|
-
talk(evt,
|
|
411
|
-
this.action('talk', evt);
|
|
412
|
-
return this.events.emit(evt,
|
|
410
|
+
talk(evt, packet=false) {
|
|
411
|
+
this.action('talk', `${evt}:${packet.id}`);
|
|
412
|
+
return this.events.emit(evt, packet);
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
/**************
|
|
@@ -633,12 +633,12 @@ class Deva {
|
|
|
633
633
|
ask(packet) {
|
|
634
634
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
635
635
|
const {method, params} = packet.q.meta;
|
|
636
|
-
this.zone('ask', method);
|
|
636
|
+
this.zone('ask', `${method}:${packet.id}`);
|
|
637
637
|
|
|
638
638
|
const agent = this.agent();
|
|
639
639
|
const client = this.client();
|
|
640
640
|
// build the answer packet from this model
|
|
641
|
-
this.state('set', `ask:${method}:packet_answer`);
|
|
641
|
+
this.state('set', `ask:${method}:packet_answer:${packet.id}`);
|
|
642
642
|
const packet_answer = {
|
|
643
643
|
id: this.lib.uid(),
|
|
644
644
|
agent,
|
|
@@ -654,11 +654,11 @@ class Deva {
|
|
|
654
654
|
created: Date.now(),
|
|
655
655
|
};
|
|
656
656
|
|
|
657
|
-
this.state('try', `ask:${method}`);
|
|
657
|
+
this.state('try', `ask:${method}:${packet.id}`);
|
|
658
658
|
try {
|
|
659
659
|
if (typeof this.methods[method] !== 'function') {
|
|
660
660
|
return setImmediate(() => {
|
|
661
|
-
this.state('invalid', method);
|
|
661
|
+
this.state('invalid', `${method}:${packet.id}`);
|
|
662
662
|
this.talk(`${this._agent.key}:ask:${packet.id}`, this._methodNotFound(packet));
|
|
663
663
|
});
|
|
664
664
|
}
|
|
@@ -681,12 +681,12 @@ class Deva {
|
|
|
681
681
|
this.talk(`${agent.key}:ask:${packet.id}`, packet);
|
|
682
682
|
}).catch(err => {
|
|
683
683
|
this.talk(`${agent.key}:ask:${packet.id}`, {error:err});
|
|
684
|
-
this.state('catch', `ask:${method}`);
|
|
684
|
+
this.state('catch', `ask:${method}:${packet.id}`);
|
|
685
685
|
return this.error(err, packet);
|
|
686
686
|
})
|
|
687
687
|
}
|
|
688
688
|
catch (e) {
|
|
689
|
-
this.state('catch', `ask:${method}`);
|
|
689
|
+
this.state('catch', `ask:${method}:${packet.id}`);
|
|
690
690
|
this.talk(`${agent.key}:ask:${packet.id}`, {error:e});
|
|
691
691
|
return this.error(e, packet)
|
|
692
692
|
}
|
|
@@ -871,7 +871,7 @@ class Deva {
|
|
|
871
871
|
// check for agent on finish function in agent
|
|
872
872
|
const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
|
|
873
873
|
// return the provided resolve function or a promise resolve.
|
|
874
|
-
this.state('finish', id); // set the finish state
|
|
874
|
+
this.state('finish', packet.id); // set the finish state
|
|
875
875
|
return hasOnFinish ? this.onFinish(packet, resolve) : this.complete(packet, resolve);
|
|
876
876
|
}
|
|
877
877
|
|
|
@@ -1206,8 +1206,8 @@ class Deva {
|
|
|
1206
1206
|
***************/
|
|
1207
1207
|
context(value=false, extra=false) {
|
|
1208
1208
|
const id = this.lib.uid();
|
|
1209
|
-
this.action('context', value);
|
|
1210
|
-
this.state('try', `context:${value}`);
|
|
1209
|
+
this.action('context', `${value}:${id}`);
|
|
1210
|
+
this.state('try', `context:${value}:${id}`);
|
|
1211
1211
|
try {
|
|
1212
1212
|
if (!value) return;
|
|
1213
1213
|
this.state('set', `context:${value}:${id}`);
|
|
@@ -1226,7 +1226,7 @@ class Deva {
|
|
|
1226
1226
|
};
|
|
1227
1227
|
data.hash = this.lib.hash(data);
|
|
1228
1228
|
this.talk(config.events.context, data);
|
|
1229
|
-
this.state('return', `context:${value}:${
|
|
1229
|
+
this.state('return', `context:${value}:${id}`);
|
|
1230
1230
|
return data;
|
|
1231
1231
|
} catch (e) {
|
|
1232
1232
|
this.state('catch', `context:${value}:${id}`);
|