@indra.ai/deva 1.1.123 → 1.1.125

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.
Files changed (3) hide show
  1. package/config.json +1 -0
  2. package/index.js +20 -17
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -18,6 +18,7 @@
18
18
  "error": "devacore:error",
19
19
  "question": "devacore:question",
20
20
  "answer": "devacore:answer",
21
+ "ask": "devacore:ask",
21
22
  "state": "devacore:state",
22
23
  "zone": "devacore:zone",
23
24
  "action": "devacore:action",
package/index.js CHANGED
@@ -687,8 +687,8 @@ class Deva {
687
687
  this.talk(`${key}:ask`, packet);
688
688
  this.once(`${key}:ask:${packet.id}`, answer => {
689
689
  this.action('question_ask_answer');
690
-
691
- this.talk(config.events.answer, this.copy(answer));
690
+
691
+ this.talk(config.events.ask, this.copy(answer));
692
692
  return this.finish(answer, resolve); // if:isAsk resolve the answer from the call
693
693
  });
694
694
  }
@@ -1140,22 +1140,25 @@ class Deva {
1140
1140
  ***************/
1141
1141
  action(action) {
1142
1142
  try {
1143
- if (!this._actions[action]) return;
1144
- this._action = action;
1145
- const text = this._messages.actions[action];
1146
- const data = {
1147
- id: this.uid(true),
1148
- key: 'action',
1149
- value: action,
1150
- agent: this.agent(),
1151
- client: this.client(),
1152
- text,
1153
- created: Date.now(),
1143
+ this._action = action; // set the local action variable
1144
+ // check local vars for custom actions
1145
+ const var_action = this.vars.actions ? this.vars.actions[action] : false;
1146
+ // check system action messages
1147
+ const msg_action = this._messages.actions[action] || var_action;
1148
+ const text = msg_action || action; // set the text of the action
1149
+ const data = { // build the data object for the action.
1150
+ id: this.uid(true), // generate a guid for the action transmitssion.
1151
+ key: 'action', // the key for event to transmit action type
1152
+ value: action, // the value key which is the action passed
1153
+ agent: this.agent(), // the agent data to send with the action
1154
+ client: this.client(), // the client data to send with the action
1155
+ text, // text of the action to send
1156
+ created: Date.now(), // action time stamp
1154
1157
  };
1155
- data.hash = this.hash(data);
1156
- this.talk(config.events.action, data);
1157
- } catch (e) {
1158
- return this.error(e)
1158
+ data.hash = this.hash(data); // generate a hash of the action packet.
1159
+ this.talk(config.events.action, data); // talk the core action event
1160
+ } catch (e) { // catch any errors that occur
1161
+ return this.error(e); // return error on error catch
1159
1162
  }
1160
1163
  }
1161
1164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.123",
3
+ "version": "1.1.125",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {