@indra.ai/deva 1.1.97 → 1.1.99

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 +19 -9
  2. package/index.js +70 -66
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -42,7 +42,9 @@
42
42
  "unload": "unloading",
43
43
  "invalid": "invalid state",
44
44
  "done": "done state",
45
- "error": "error state"
45
+ "finish": "finish state",
46
+ "error": "error state",
47
+ "help": "help state"
46
48
  },
47
49
  "zone": false,
48
50
  "zones": {
@@ -58,11 +60,13 @@
58
60
  "party": "Party Zone",
59
61
  "invalid": "Invalid Invalid",
60
62
  "done": "Done Zone",
61
- "error": "Error Zone"
63
+ "error": "Error Zone",
64
+ "help": "Help Zone"
62
65
  },
63
66
  "action": false,
64
67
  "actions": {
65
- "wait": "wait",
68
+ "wait": "::agent.name:: is waiting",
69
+ "help": "::agent.name:: giving help",
66
70
  "start": "::agent.name:: has started",
67
71
  "enter": "::agent.name:: has entered deva.world",
68
72
  "exit": "::agent.name:: has exited deva.world",
@@ -116,6 +120,7 @@
116
120
  "Mind": "Mind Feature",
117
121
  "client_data": "client configure",
118
122
  "invalid": "Invalid",
123
+ "finish": "Finished",
119
124
  "error": "Error",
120
125
  "done": "Done"
121
126
  },
@@ -164,8 +169,10 @@
164
169
  "load": "::agent.name:: is loading",
165
170
  "unload": "::agent.name:: is is unloading",
166
171
  "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"
172
+ "finish": "::agent.name:: finish state",
173
+ "done": "::agent.name:: is done",
174
+ "error": "::agent.name:: appears to have had an error",
175
+ "help": "::agent.name:: is getting help"
169
176
  },
170
177
  "zones": {
171
178
  "deva": "::agent.name:: is in the Deva Zone",
@@ -178,7 +185,8 @@
178
185
  "danger": "::agent.name:: is in the Danger Zone",
179
186
  "invalid": "::agent.name:: is in the Invalid Zone",
180
187
  "done": "::agent.name:: is in the Done Zone",
181
- "error": "::agent.name:: is in the Error Zone"
188
+ "error": "::agent.name:: is in the Error Zone",
189
+ "help": "::agent.name:: is in the Help Zone"
182
190
  },
183
191
  "actions": {
184
192
  "wait": "::agent.name:: is waiting",
@@ -226,9 +234,11 @@
226
234
  "mind": "::agent.name:: is accessing the #mind feature",
227
235
  "Mind": "::agent.name:: is loading the Mind Feature",
228
236
  "client_data": "::agent.name:: configure",
229
- "invalid": "invalid",
230
- "done": "done",
231
- "error": "this._action.erro"
237
+ "invalid": "::agent.name:: invalid",
238
+ "finish": "::agent.name:: has finished the action",
239
+ "done": "::agent.name:: done",
240
+ "error": "::agent.name:: error",
241
+ "help": "::agent.name:: providing help"
232
242
  },
233
243
  "features": {
234
244
  "security": "security feature",
package/index.js CHANGED
@@ -262,24 +262,24 @@ class Deva {
262
262
  client presented data.
263
263
  ***************/
264
264
  Support() {
265
- this.feature('Support'); // set state to support setting
266
- const _cl = this.client();
265
+ this.feature('Support'); // set state to support setting
266
+ const _cl = this.client(); // set the local client variable
267
267
  try {
268
- if (!_cl.features.support) return this.Services()
268
+ if (!_cl.features.support) return this.Services() // move to Services if no support feature
269
269
  else {
270
270
  this.action('Support');
271
- const {id, features, profile} = _cl; // set the local consts from client copy
272
- const {support} = features; // set support from features const
273
- this._support = { // set this_support with data
274
- id: this.uid(true), // uuid of the support feature
275
- client_id: id, // client id for reference
276
- client_name: profile.name, // client name for personalization
277
- concerns: support.concerns, // any concerns for client
278
- global: support.global, // the global policies for client
279
- personal: support.devas[this._agent.key] // Client personalSecurity features and rules.
271
+ const {id, features, profile} = _cl; // set the local consts from client copy
272
+ const {support} = features; // set support from features const
273
+ this._support = { // set this_support with data
274
+ id: this.uid(true), // uuid of the support feature
275
+ client_id: id, // client id for reference
276
+ client_name: profile.name, // client name for personalization
277
+ concerns: support.concerns, // any concerns for client
278
+ global: support.global, // the global policies for client
279
+ personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
280
280
  };
281
- delete this._client.features.support
282
- return this.Services();
281
+ delete this._client.features.support // delete the support key from the client
282
+ return this.Services(); // when done move to Services
283
283
  }
284
284
  } catch (e) {
285
285
  this.action('error'); // set the action to error
@@ -296,24 +296,24 @@ class Deva {
296
296
  client presented data.
297
297
  ***************/
298
298
  Services() {
299
- this.feature('Services'); // set state to security setting
300
- const _cl = this.client();
299
+ this.feature('Services'); // set state to security setting
300
+ const _cl = this.client(); // set local client
301
301
  try {
302
- if (!_cl.features.services) return this.Systems();
302
+ if (!_cl.features.services) return this.Systems(); // move to Systems if no Services feature
303
303
  else {
304
304
  this.action('Services')
305
305
  const {id, features, profile} = _cl; // set the local consts from client copy
306
- const {services} = features; // set services from features const
307
- this._services = { // set this_services with data
308
- id: this.uid(true), // uuid of the services feature
309
- client_id: id, // client id for reference
310
- client_name: profile.name, // client name for personalization
311
- concerns: services.concerns, // any concerns for client
312
- global: services.global, // the global policies for client
313
- personal: services.devas[this._agent.key] // Client personal features and rules.
306
+ const {services} = features; // set services from features const
307
+ this._services = { // set this_services with data
308
+ id: this.uid(true), // uuid of the services feature
309
+ client_id: id, // client id for reference
310
+ client_name: profile.name, // client name for personalization
311
+ concerns: services.concerns, // any concerns for client
312
+ global: services.global, // the global policies for client
313
+ personal: services.devas[this._agent.key], // Client personal features and rules.
314
314
  };
315
- delete this._client.features.services
316
- return this.Systems()
315
+ delete this._client.features.services // delete the services key for isolation
316
+ return this.Systems() // go to Systems when done
317
317
  }
318
318
  } catch (e) {
319
319
  this.action('error'); // set the action to error
@@ -333,18 +333,18 @@ class Deva {
333
333
  this.feature('Systems'); // set state to systems setting
334
334
  const _cl = this.client();
335
335
  try {
336
- if (!_cl.features.systems) return this.Solutions();
336
+ if (!_cl.features.systems) return this.Solutions(); // move to Solutions if no systems feature
337
337
  else {
338
338
  this.action('Systems');
339
339
  const {id, features, profile} = _cl; // set the local consts from client copy
340
- const {systems} = features; // set systems from features const
341
- this._systems = { // set this_systems with data
342
- id: this.uid(true), // uuid of the systems feature
343
- client_id: id, // client id for reference
344
- client_name: profile.name, // client name for personalization
345
- concerns: systems.concerns, // any concerns for client
346
- global: systems.global, // the global policies for client
347
- personal: systems.devas[this._agent.key] // Client personal features and rules.
340
+ const {systems} = features; // set systems from features const
341
+ this._systems = { // set this_systems with data
342
+ id: this.uid(true), // uuid of the systems feature
343
+ client_id: id, // client id for reference
344
+ client_name: profile.name, // client name for personalization
345
+ concerns: systems.concerns, // any concerns for client
346
+ global: systems.global, // the global policies for client
347
+ personal: systems.devas[this._agent.key], // Client personal features and rules.
348
348
  };
349
349
  delete this._client.features.systems
350
350
  return this.Solutions()
@@ -367,7 +367,7 @@ class Deva {
367
367
  this.feature('Solutions'); // set state to solutions setting
368
368
  const _cl = this.client();
369
369
  try {
370
- if (!_cl.features.solutions) return this.Research();
370
+ if (!_cl.features.solutions) return this.Research(); // moe to research if no solutions
371
371
  else {
372
372
  this.action('Solutions');
373
373
  const {id, features, profile} = _cl; // set the local consts from client copy
@@ -500,12 +500,12 @@ class Deva {
500
500
  client presented data.
501
501
  ***************/
502
502
  Legal() {
503
- this.feature('Legal'); // set state to legal setting
504
- const _cl = this.client();
503
+ this.feature('Legal'); // set state to legal setting
504
+ const _cl = this.client(); // set hte local client variable
505
505
  try {
506
- if (!_cl.features.legal) this.Assistant();
506
+ if (!_cl.features.legal) this.Assistant(); // if no legal feature then move to assistant
507
507
  else {
508
- this.action('Legal');
508
+ this.action('Legal'); // set the action to legal
509
509
  const {id, features, profile} = _cl; // set the local consts from client copy
510
510
  const {legal} = features; // set legal from features const
511
511
  this._legal = { // set this_legal with data
@@ -516,8 +516,8 @@ class Deva {
516
516
  global: legal.global, // the global policies for client
517
517
  personal: legal.devas[this._agent.key], // Client personal features and rules.
518
518
  };
519
- delete this._client.features.legal;
520
- return this.Assistant();
519
+ delete this._client.features.legal; // remove the legal key from the client data
520
+ return this.Assistant(); // when done goto Assis
521
521
  }
522
522
  } catch (e) {
523
523
  this.action('error'); // set the action to error
@@ -738,9 +738,9 @@ class Deva {
738
738
 
739
739
  return new Promise((resolve, reject) => {
740
740
  // resolve with the no text message if the client says nothing.
741
- if (!TEXT) return resolve(this._messages.notext);
741
+ if (!TEXT) return this.finish(this._messages.notext, resolve);
742
742
  // reject question if Deva offline
743
- if (!this._active) return resolve(this._messages.states.offline);
743
+ if (!this._active) return this.finish(this._messages.states.offline, resolve);
744
744
  let _action = 'question_method'
745
745
  try { // try to answer the question
746
746
  if (isAsk) { // determine if hte question isAsk
@@ -857,7 +857,7 @@ class Deva {
857
857
  this.action('answer_talk');
858
858
  this.talk(config.events.answer, this.copy(packet)); // global talk event
859
859
 
860
- return resolve(packet); // resolve the packet to the caller.
860
+ return this.finish(packet, resolve) // resolve the packet to the caller.
861
861
  }).catch(err => { // catch any errors in the method
862
862
  this.action('error');
863
863
  return this.error(err, packet, reject); // return this.error with err, packet, reject
@@ -1066,20 +1066,19 @@ class Deva {
1066
1066
  /**************
1067
1067
  func: finish
1068
1068
  params:
1069
- - data: the data to pass to the resolve
1069
+ - packet: the data to pass to the resolve
1070
1070
  - resolve: the finish resolve to pass back
1071
- If the deva is offline it will return the offline message.
1072
- usage: this.finish(data, resolve)
1071
+ describe:
1072
+ This function is use to relay the Agent ito a finish state when resolving a
1073
+ question or data.
1074
+ usage:
1075
+ this.finish(data, resolve)
1073
1076
  ***************/
1074
- done(data) {
1077
+ finish(packet, resolve) {
1075
1078
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1076
1079
  this.state('finish');
1077
- data.value = 'done';
1078
- delete data.hash;
1079
- data.hash = this.hash(data);
1080
- this.action(data.value)
1081
- const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
1082
- return hasOnDone ? this.onDone(data) : Promise.resolve(data);
1080
+ this.action('finish');
1081
+ return resolve(packet);
1083
1082
  }
1084
1083
 
1085
1084
  /**************
@@ -1196,22 +1195,21 @@ class Deva {
1196
1195
  - st: The zone flag to set for the Deva that matches to this._zones
1197
1196
  describe
1198
1197
  ***************/
1199
- zone(zone, data=false) {
1198
+ zone(zone) {
1200
1199
  try {
1201
1200
  if (!this._zones[zone]) return;
1202
1201
  this._zone = zone;
1203
1202
  const text = this._messages.zones[zone];
1204
- const data = {
1203
+ const talk = {
1205
1204
  id: this.uid(true),
1206
1205
  key: 'zone',
1207
1206
  value: zone,
1208
1207
  agent: this._agent,
1209
1208
  text,
1210
- data,
1211
1209
  created: Date.now(),
1212
1210
  };
1213
- data.hash = this.hash(data);
1214
- this.talk(config.events.zone, data);
1211
+ talk.hash = this.hash(talk);
1212
+ this.talk(config.events.zone, talk);
1215
1213
  } catch (e) {
1216
1214
  return this.error(e);
1217
1215
  }
@@ -1250,7 +1248,7 @@ class Deva {
1250
1248
  - st: The state flag to set for the Deva that matches to this._states
1251
1249
  describe
1252
1250
  ***************/
1253
- feature(feature, data=false) {
1251
+ feature(feature) {
1254
1252
  try {
1255
1253
  if (!this._features[feature]) return;
1256
1254
  this._feature = feature;
@@ -1261,7 +1259,6 @@ class Deva {
1261
1259
  value: feature,
1262
1260
  agent: this._agent,
1263
1261
  text,
1264
- data,
1265
1262
  created: Date.now(),
1266
1263
  };
1267
1264
  talk.hash = this.hash(talk);
@@ -1554,7 +1551,7 @@ class Deva {
1554
1551
  key,
1555
1552
  created: Date.now(),
1556
1553
  });
1557
- return resolve(this._messages.states.load);
1554
+ return this.finish(this._messages.states.load, resolve);
1558
1555
  }).catch(err => {
1559
1556
  return this.error(err, deva, reject);
1560
1557
  })
@@ -1575,7 +1572,7 @@ class Deva {
1575
1572
  delete this.devas[key];
1576
1573
  this.talk(config.events.unload, key);
1577
1574
  });
1578
- return resolve(this._messages.states.unload);
1575
+ return this.finish(this._messages.states.unload, resolve);
1579
1576
  } catch (e) {
1580
1577
  return this.error(e, this.devas[key], reject)
1581
1578
  }
@@ -1877,14 +1874,21 @@ class Deva {
1877
1874
  ***************/
1878
1875
  help(msg, help_dir) {
1879
1876
  return new Promise((resolve, reject) => {
1877
+ if (!this._active) return resolve(this._messages.states.offline);
1878
+ this.state('help');
1879
+ this.zone('help');
1880
+ this.action('help');
1880
1881
  const params = msg.split(' ');
1881
1882
  let helpFile = 'main';
1882
1883
  if (params[0]) helpFile = params[0];
1883
1884
  if (params[1]) helpFile = `${params[0]}_${params[1]}`;
1884
1885
  helpFile = path.join(help_dir, 'help', `${helpFile}.feecting`);
1885
1886
  try {
1886
- return resolve(fs.readFileSync(helpFile, 'utf8'))
1887
+ return this.finish(fs.readFileSync(helpFile, 'utf8'), resolve)
1887
1888
  } catch (e) {
1889
+ this.action('help');
1890
+ this.zone('help');
1891
+ this.state('help');
1888
1892
  return reject(e)
1889
1893
  }
1890
1894
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.97",
3
+ "version": "1.1.99",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {