@indra.ai/deva 1.1.88 → 1.1.89

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 +96 -83
  2. package/index.js +50 -14
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -23,7 +23,8 @@
23
23
  "action": "devacore:action",
24
24
  "feature": "devacore:feature",
25
25
  "load": "devacore:load",
26
- "unload": "devacore:unload"
26
+ "unload": "devacore:unload",
27
+ "context": "devacore:context"
27
28
  },
28
29
  "state": "offline",
29
30
  "states": {
@@ -33,7 +34,7 @@
33
34
  "offline": "offline",
34
35
  "online": "online",
35
36
  "init": "initializing",
36
- "start": "starting journey",
37
+ "start": "starting",
37
38
  "enter": "entering deva.world",
38
39
  "stop": "stopping",
39
40
  "exit": "exiting deva.world",
@@ -62,22 +63,33 @@
62
63
  "action": false,
63
64
  "actions": {
64
65
  "wait": "wait",
65
- "question": "question",
66
- "question_ask": "question:ask",
67
- "question_ask_answer": "returned with an answer",
68
- "question_cmd": "question:cmd",
69
- "question_method": "question:method",
70
- "question_talk": "question:talk",
71
- "question_answer": "question:answer",
72
- "question_done": "question:done",
73
- "answer": "answer",
74
- "answer_talk": "sharing the answer",
75
- "ask": "asking",
76
- "ask_answer": "answering",
77
- "uid": "create unique id",
78
- "hash": "create hash",
79
- "cipher": "encrypt data",
80
- "decipher": "dencrypt data",
66
+ "start": "::agent.name:: has started",
67
+ "enter": "::agent.name:: has entered deva.world",
68
+ "exit": "::agent.name:: has exited deva.world",
69
+ "stop": "::agent.name:: is stopped",
70
+ "load": "::agent.name:: is loaded",
71
+ "unload": "::agent.name:: is unloaded",
72
+ "question": "::agent.name:: was received a question",
73
+ "context": "::agent.name:: context change",
74
+ "question_ask": "::agent.name:: was asked a question",
75
+ "question_ask_answer": "::agent.name:: answered the question that was asked",
76
+ "question_cmd": "::agent.name:: processed a command",
77
+ "question_method": "::agent.name:: processed a method",
78
+ "question_talk": "::agent.name:: broadcasted the question",
79
+ "question_answer": "::agent.name:: has answered the question",
80
+ "question_done": "::agent.name:: is done with the question",
81
+ "answer": "::agent.name:: has given an answer",
82
+ "answer_talk": "::agent.name:: broadcasted the answer",
83
+ "ask": "::agent.name:: is being asked a question",
84
+ "ask_answer": "::agent.name:: is answering the question that was asked",
85
+ "status": "::agent.name:: returned their status",
86
+ "get-today": "::agent.name:: getting the value of today",
87
+ "format-date": "::agent.name:: format date",
88
+ "format-time": "::agent.name:: format time",
89
+ "format-currency": "::agent.name:: format currency",
90
+ "format-percent": "::agent.name:: format percent",
91
+ "trimmer": "::agent.name:: is trimming a word count",
92
+ "dupes": "::agent.name:: is removing duplicates",
81
93
  "security": "SECURITY",
82
94
  "Security": "Security Feature",
83
95
  "support": "SUPPORT",
@@ -103,9 +115,9 @@
103
115
  "mind": "MIND",
104
116
  "Mind": "Mind Feature",
105
117
  "client_data": "client configure",
106
- "invalid": "Actin Invalid",
107
- "error": "Action Error",
108
- "done": "Action Done"
118
+ "invalid": "Invalid",
119
+ "error": "Error",
120
+ "done": "Done"
109
121
  },
110
122
  "feature": false,
111
123
  "features": {
@@ -139,73 +151,74 @@
139
151
  "message": "offline",
140
152
  "messages": {
141
153
  "states": {
142
- "offline": "🛌 ::agent.name:: offline state",
143
- "online": "🌞 ::agent.name:: online state",
144
- "ask": "😎 ::agent.name:: ask state",
145
- "question": "🎙️ ::agent.name:: question state",
146
- "answer": "🎟️ ::agent.name:: answer state",
147
- "init": "🚀 ::agent.name:: init state",
148
- "start": "🚙 ::agent.name:: start state",
149
- "enter": "🪐 ::agent.name:: enter state",
150
- "stop": "✋ ::agent.name:: stop state",
151
- "exit": "🚪 ::agent.name:: exit state",
152
- "load": "📫 ::agent.name:: load state",
153
- "unload": "📭 ::agent.name:: is this._states.unload",
154
- "invalid": "⚠️ ::agent.name:: invalid state",
155
- "done": "✅ ::agent.name:: done state",
156
- "error": "❌ ::agent.name:: error state"
154
+ "offline": "🛌 ::agent.name:: is offline",
155
+ "online": "🌞 ::agent.name:: is online",
156
+ "ask": "😎 ::agent.name:: is asking a question",
157
+ "question": "🎙️ ::agent.name:: has received a question",
158
+ "answer": "🎟️ ::agent.name:: answered the question",
159
+ "init": "🚀 ::agent.name:: is initializing",
160
+ "start": "🚙 ::agent.name:: is starting",
161
+ "enter": "🪐 ::agent.name:: has entered deva.world",
162
+ "stop": "✋ ::agent.name:: is stopping",
163
+ "exit": "🚪 ::agent.name:: has exited deva.world",
164
+ "load": "📫 ::agent.name:: is loading",
165
+ "unload": "📭 ::agent.name:: is is unloading",
166
+ "invalid": "⚠️ ::agent.name:: seems to be invalid",
167
+ "done": "✅ ::agent.name:: is done with their task",
168
+ "error": "❌ ::agent.name:: appears to have had an error"
157
169
  },
158
170
  "zones": {
159
- "deva": "🎉 ::agent.name:: deva zone",
160
- "config": "🦾 ::agent.name:: config zone",
161
- "features": "🍿 ::agent.name:: features zone",
162
- "idle": "😜 ::agent.name:: idle zone",
163
- "training": "🥋 ::agent.name:: train zone",
164
- "school": "👨‍🏫 ::agent.name:: work zone",
165
- "work": "‍🗂️ ::agent.name:: work zone",
166
- "invalid": "⚠️ ::agent.name:: invalid zone",
167
- "done": " ::agent.name:: done zone",
168
- "error": " ::agent.name:: erro zone"
171
+ "deva": "🎉 ::agent.name:: is in the Deva Zone",
172
+ "config": "🦾 ::agent.name:: is in the Config Zone",
173
+ "features": "🍿 ::agent.name:: is in the Features Zone",
174
+ "idle": "😜 ::agent.name:: is in the Idle Zone",
175
+ "training": "🥋 ::agent.name:: is in the Training Zone",
176
+ "school": "👨‍🏫 ::agent.name:: is in the School Zone",
177
+ "work": "‍🗂️ ::agent.name:: is in the Work Zone",
178
+ "danger": "⛔️ ::agent.name:: is in the Danger Zone",
179
+ "invalid": "⚠️ ::agent.name:: is in the Invalid Zone",
180
+ "done": " ::agent.name:: is in the Done Zone",
181
+ "error": "❌ ::agent.name:: is in the Error Zone"
169
182
  },
170
183
  "actions": {
171
- "wait": "😵‍💫 ::agent.name:: wait action",
172
- "question": "👀 ::agent.name:: question action",
173
- "question_ask": "👥 ::agent.name:: question_ask action",
174
- "question_ask_answer": "📣 ::agent.name:: question_ask_answer action",
175
- "question_cmd": "🎮 ::agent.name:: question_cmd action",
176
- "question_method": "🏄‍♂️ ::agent.name:: question_method action",
177
- "question_talk": "📢 ::agent.name:: question_talk action",
178
- "question_answer": "🎙️ ::agent.name:: question_answer action",
179
- "question_done": "👍 ::agent.name:: question_done action",
180
- "answer": "🎟️ ::agent.name:: answer action",
181
- "answer_talk": "🎟️ ::agent.name:: answer_talk action",
182
- "ask": "👥 ::agent.name:: answer.ask action",
183
- "ask_answer": "🎟️ ::agent.name:: ask_answer action",
184
+ "wait": " ::agent.name:: is waiting",
185
+ "question": "💬 ::agent.name:: was asked a question",
186
+ "question_ask": "🗣️ ::agent.name:: is asking the question to another Deva",
187
+ "question_ask_answer": "👥 ::agent.name:: answered the question they were asked",
188
+ "question_cmd": "🚀 ::agent.name:: is running a command",
189
+ "question_method": "🚗 ::agent.name:: is asking a question",
190
+ "question_talk": "🎙️ ::agent.name:: is talking the question",
191
+ "question_answer": "📨 ::agent.name:: answered the question",
192
+ "question_done": " ::agent.name:: the question is done",
193
+ "answer": "📨 ::agent.name:: is generating an answer",
194
+ "answer_talk": "🎙️ ::agent.name:: is talking an answer",
195
+ "ask": "🗣️ ::agent.name:: is asking a question",
196
+ "ask_answer": "📨 ::agent.name:: is answering a question",
184
197
 
185
- "security": "👮‍♀️ security actio",
186
- "Security": "👮‍♂️ Security read",
187
- "support": "👩‍⚕️ support actio",
188
- "Support": "👨‍⚕️ Support read",
189
- "services": "👩‍🔧 services actio",
190
- "Services": "👨‍🔧 Services read",
191
- "solutions": "👩‍🚀 solutions actio",
192
- "Solutions": "👨‍🚀 Solutions read",
193
- "systems": "👷‍♀️ systems actio",
194
- "Systems": "👷‍♂️ Systems read",
195
- "research": "👩‍🔬 research actio",
196
- "Research": "👨‍🔬 Research read",
197
- "development": "👩‍💻 development actio",
198
- "Development": "👨‍💻 Development read",
199
- "business": "👩‍💼 business actio",
200
- "Business": "👨‍💼 Business read",
201
- "legal": "👩‍⚖️ legal actio",
202
- "Legal": "👩‍⚖️ Legal read",
203
- "assistant": "👩 assistant actio",
204
- "Assistant": "👨 Assistant read",
205
- "story": "👩‍🏫 story actio",
206
- "Story": "👨‍🏫 Story read",
207
- "mind": "🧘‍♀️ mind actio",
208
- "Mind": "🧘‍♂️ Mind read",
198
+ "security": "👮‍♀️ ::agent.name:: is accessing the #security feature",
199
+ "Security": "👮‍♂️ ::agent.name:: is loading the Security Feature",
200
+ "support": "👩‍⚕️ ::agent.name:: is accessing the #support feature",
201
+ "Support": "👨‍⚕️ ::agent.name:: is loading the Support Feature",
202
+ "services": "👩‍🔧 ::agent.name:: is accessing the #services feature",
203
+ "Services": "👨‍🔧 ::agent.name:: is loading the Services Feature",
204
+ "solutions": "👩‍🚀 ::agent.name:: is accessing the #services feature",
205
+ "Solutions": "👨‍🚀 ::agent.name:: is loading the Services Feature",
206
+ "systems": "👷‍♀️ ::agent.name:: is accing #systems",
207
+ "Systems": "👷‍♂️ ::agent.name:: is loading the Systems Feature",
208
+ "research": "👩‍🔬 ::agent.name:: is accessing the #research feature",
209
+ "Research": "👨‍🔬 ::agent.name:: is loading the Research Feature",
210
+ "development": "👩‍💻 ::agent.name:: is accessing the #development feature",
211
+ "Development": "👨‍💻 ::agent.name:: is loading the Development Feature",
212
+ "business": "👩‍💼 ::agent.name:: is accessing the #business feature",
213
+ "Business": "👨‍💼 ::agent.name:: is loading the Business Feature",
214
+ "legal": "👩‍⚖️ ::agent.name:: is accessing the #legal feature",
215
+ "Legal": "👩‍⚖️ ::agent.name:: is loading the Legal Feature",
216
+ "assistant": "👩 ::agent.name:: is accessing the #assistant feature",
217
+ "Assistant": "👨 ::agent.name:: is loading the Assistant Feature",
218
+ "story": "👩‍🏫 ::agent.name:: is accessing the #story feature",
219
+ "Story": "👨‍🏫 ::agent.name:: is loading the Story Feature",
220
+ "mind": "🧘‍♀️ ::agent.name:: is accessing the #mind feature",
221
+ "Mind": "🧘‍♂️ ::agent.name:: is loading the Mind Feature",
209
222
  "client_data": "📂 ::agent.name:: configure",
210
223
  "invalid": "⚠️ invalid",
211
224
  "done": "✅ done",
package/index.js CHANGED
@@ -57,6 +57,8 @@ class Deva {
57
57
  this._feature = config.feature; // set the feature from config
58
58
  this._features = config.features; // set the features from config
59
59
 
60
+ this._context = opts.context || false; // set the local context
61
+
60
62
  this._message = config.message; // current state of agent.
61
63
  this._messages = {
62
64
  notext: 'NO TEXT WAS PROVIDED',
@@ -1024,13 +1026,14 @@ class Deva {
1024
1026
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1025
1027
  data.value = 'start';
1026
1028
  delete data.hash;
1027
- data.hash = this.hash(data);
1029
+ data.hash = this.hash(JSON.stringify(data));
1028
1030
 
1029
1031
  if (this.info) {
1030
1032
  const _info = this.info(data.id);
1031
1033
  this.prompt(_info);
1032
1034
  }
1033
1035
 
1036
+ this.action(data.value);
1034
1037
  const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
1035
1038
  return hasOnStart ? this.onStart(data) : this.enter(data)
1036
1039
  }
@@ -1051,7 +1054,8 @@ class Deva {
1051
1054
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1052
1055
  data.value = 'enter';
1053
1056
  delete data.hash;
1054
- data.hash = this.hash(data);
1057
+ data.hash = this.hash(JSON.stringify(data));
1058
+ this.action(data.value);
1055
1059
  const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
1056
1060
  return hasOnEnter ? this.onEnter(data) : this.done(data)
1057
1061
  }
@@ -1072,7 +1076,8 @@ class Deva {
1072
1076
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1073
1077
  data.value = 'done';
1074
1078
  delete data.hash;
1075
- data.hash = this.hash(data);
1079
+ data.hash = this.hash(JSON.stringify(data));
1080
+ this.action(data.value)
1076
1081
  const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
1077
1082
  return hasOnDone ? this.onDone(data) : Promise.resolve(data);
1078
1083
  }
@@ -1093,7 +1098,7 @@ class Deva {
1093
1098
  stop() {
1094
1099
  this.state('stop');
1095
1100
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1096
- const _data = {
1101
+ const data = {
1097
1102
  id: this.uid(true),
1098
1103
  key: 'return',
1099
1104
  value: 'stop',
@@ -1102,9 +1107,10 @@ class Deva {
1102
1107
  text: this._messages.states.stop,
1103
1108
  created: Date.now(),
1104
1109
  }
1105
- _data.hash = this.hash(_data);
1110
+ data.hash = this.hash(JSON.stringify(data));
1111
+ this.action(data.value);
1106
1112
  const hasOnStop = this.onStop && typeof this.onStop === 'function';
1107
- return hasOnStop ? this.onStop(_data) : this.exit(_data)
1113
+ return hasOnStop ? this.onStop(data) : this.exit(data)
1108
1114
  }
1109
1115
 
1110
1116
 
@@ -1122,12 +1128,12 @@ class Deva {
1122
1128
  If the deva is offline it will return the offline message.
1123
1129
  usage: this.exit('msg')
1124
1130
  ***************/
1125
- exit(data=false) {
1131
+ exit(data) {
1126
1132
  this.state('exit');
1127
1133
  this._active = false;
1128
1134
  data.value = 'exit';
1129
1135
  delete data.hash;
1130
- data.hash = this.hash(data);
1136
+ data.hash = this.hash(JSON.stringify(data));
1131
1137
 
1132
1138
  // clear memory
1133
1139
  this._active = false;
@@ -1140,6 +1146,7 @@ class Deva {
1140
1146
  this._legal = false;
1141
1147
  this._story = false;
1142
1148
 
1149
+ this.action(data.value);
1143
1150
  const hasOnExit = this.onExit && typeof this.onExit === 'function';
1144
1151
  return hasOnExit ? this.onExit(data) : Promise.resolve(data)
1145
1152
  }
@@ -1167,7 +1174,7 @@ class Deva {
1167
1174
  text,
1168
1175
  created: Date.now(),
1169
1176
  };
1170
- _data.hash = this.hash(_data);
1177
+ _data.hash = this.hash(JSON.stringify(_data));
1171
1178
  this.talk(config.events.state, _data);
1172
1179
  } catch (e) {
1173
1180
  return this.error(e);
@@ -1203,8 +1210,8 @@ class Deva {
1203
1210
  data,
1204
1211
  created: Date.now(),
1205
1212
  };
1206
- _data.hash = this.hash(_data);
1207
- this.talk('', _data);
1213
+ _data.hash = this.hash(JSON.stringify(_data));
1214
+ this.talk(config.events.zone, _data);
1208
1215
  } catch (e) {
1209
1216
  return this.error(e);
1210
1217
  }
@@ -1230,7 +1237,7 @@ class Deva {
1230
1237
  text,
1231
1238
  created: Date.now(),
1232
1239
  };
1233
- _data.hash = this.hash(_data);
1240
+ _data.hash = this.hash(JSON.stringify(_data));
1234
1241
  this.talk(config.events.action, _data);
1235
1242
  } catch (e) {
1236
1243
  return this.error(e)
@@ -1257,13 +1264,38 @@ class Deva {
1257
1264
  data,
1258
1265
  created: Date.now(),
1259
1266
  };
1260
- _data.hash = this.hash(_data);
1267
+ _data.hash = this.hash(JSON.stringify(_data));
1261
1268
  this.talk(config.events.feature, _data);
1262
1269
  } catch (e) {
1263
1270
  return this.error(e);
1264
1271
  }
1265
1272
  }
1266
1273
 
1274
+ /**************
1275
+ func: context
1276
+ params:
1277
+ - st: The context flag to set for the Deva that matches to this._contexts
1278
+ describe
1279
+ ***************/
1280
+ context(text) {
1281
+ try {
1282
+ this._context = text;
1283
+ const _data = {
1284
+ id: this.uid(true),
1285
+ key: 'context',
1286
+ value: 'context',
1287
+ agent: this.agent(),
1288
+ client: this.client(),
1289
+ text,
1290
+ created: Date.now(),
1291
+ };
1292
+ _data.hash = this.hash(JSON.stringify(_data));
1293
+ this.talk(config.events.context, _data);
1294
+ } catch (e) {
1295
+ return this.error(e);
1296
+ }
1297
+ }
1298
+
1267
1299
 
1268
1300
  ///////////////////////////
1269
1301
 
@@ -1574,6 +1606,7 @@ class Deva {
1574
1606
  const max = Math.floor(Date.now() + (Date.now() * Math.PI));
1575
1607
  id = Math.floor(Math.random() * (max - min)) + min;
1576
1608
  }
1609
+ this.action('uid');
1577
1610
  return id;
1578
1611
  }
1579
1612
 
@@ -1592,6 +1625,7 @@ class Deva {
1592
1625
  const the_hash = createHash(algo);
1593
1626
  the_hash.update(str.toString());
1594
1627
  const _digest = the_hash.digest('base64');
1628
+ this.action('hash');
1595
1629
  return `${algo}:${_digest}`;
1596
1630
  }
1597
1631
 
@@ -1614,7 +1648,7 @@ class Deva {
1614
1648
  const _cipher = createCipheriv(algorithm, key_in_bytes, iv);
1615
1649
  const encrypted = _cipher.update(String(str), 'utf8', 'hex') + _cipher.final('hex');
1616
1650
 
1617
-
1651
+ this.action('cipher');
1618
1652
  return {
1619
1653
  iv: iv.toString('base64'),
1620
1654
  key,
@@ -1631,6 +1665,7 @@ class Deva {
1631
1665
  const decipher = createDecipheriv( algorithm, key_in_bytes, iv);
1632
1666
  const decrypted = decipher.update(encrypted);
1633
1667
  const final = Buffer.concat([decrypted, decipher.final()]);
1668
+ this.action('decipher');
1634
1669
  return final.toString();
1635
1670
  }
1636
1671
 
@@ -1653,6 +1688,7 @@ class Deva {
1653
1688
  // create the text msg string
1654
1689
  let text = `${this._agent.profile.name} active since ${dateFormat}`;
1655
1690
  if (msg) text = text + `\n${msg}`; // append the msg string if msg true.
1691
+ this.actino('status');
1656
1692
  return Promise.resolve(text); // return final text string
1657
1693
  }
1658
1694
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.88",
3
+ "version": "1.1.89",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {