@indra.ai/deva 1.1.111 → 1.1.113

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 +2 -2
  2. package/index.js +20 -10
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -9,9 +9,9 @@
9
9
  "bind": [
10
10
  "listeners",
11
11
  "methods",
12
+ "utils",
12
13
  "func",
13
- "lib",
14
- "_agent"
14
+ "lib"
15
15
  ],
16
16
  "events": {
17
17
  "prompt": "devacore:prompt",
package/index.js CHANGED
@@ -29,6 +29,7 @@ class Deva {
29
29
  this._artist = false; // inherited artist features.
30
30
  this.events = opts.events || new EventEmitter({}); // Event Bus
31
31
  this.lib = opts.lib || {}; // used for loading library functions
32
+ this.utils = opts.util || {}; // parse function
32
33
  this.devas = opts.devas || {}; // Devas which are loaded
33
34
  this.vars = opts.vars || {}; // Variables object
34
35
  this.listeners = opts.listeners || {}; // local Listeners
@@ -95,15 +96,6 @@ class Deva {
95
96
  }
96
97
  }
97
98
  });
98
- // bind translate
99
- const translate = this._agent && this._agent.translate && typeof this._agent.translate === 'function';
100
- if (translate) this._agent.translate = this._agent.translate.bind(this);
101
- // bind parser
102
- const parse = this._agent && this._agent.parse && typeof this._agent.parse === 'function';
103
- if (parse) this._agent.parse = this._agent.parse.bind(this);
104
- // bind process
105
- const process = this._agent && this._agent.process && typeof this._agent.process === 'function';
106
- if (process) this._agent.process = this._agent.process.bind(this);
107
99
  }
108
100
  catch (e) {
109
101
  return this.error(e, false, reject); // trigger the this.error for errors
@@ -216,6 +208,16 @@ class Deva {
216
208
  ***************/
217
209
  Client(client) {
218
210
  this.action('Client');
211
+
212
+ // setup any custom methods for the features
213
+ for (const x in client.features) {
214
+ const methods = client.features[x].methods || false;
215
+ if (methods) for (const y in methods) {
216
+ const isMethod = typeof methods[x] === 'function' && !this.methods[y];
217
+ if (isMethod) this.methods[y] = methods[y].bind(this);
218
+ }
219
+ }
220
+ // console.log('CLINET BEFORE COPY', client);
219
221
  const _client = this.copy(client); // copy the client parameter
220
222
  this._client = _client; // set local _client to this scope
221
223
  return Promise.resolve();
@@ -300,6 +302,7 @@ class Deva {
300
302
  this.action('Services')
301
303
  const {id, features, profile} = _cl; // set the local consts from client copy
302
304
  const {services} = features; // set services from features const
305
+ console.log('SETTING UP GLOBA SERVICE FUNCTIONS', services);
303
306
  this._services = { // set this_services with data
304
307
  id: this.uid(true), // uuid of the services feature
305
308
  client_id: id, // client id for reference
@@ -308,6 +311,13 @@ class Deva {
308
311
  global: services.global, // the global policies for client
309
312
  personal: services.devas[this._agent.key], // Client personal features and rules.
310
313
  };
314
+
315
+ // setup any global methods from the services feature
316
+ for (const x in this._services.global) {
317
+ const isFunc = typeof this._services.global[x] === 'function' ? true :false;
318
+ if (isFunc) this.methods[x] = this._services.global[x].bind(this);
319
+ }
320
+
311
321
  delete this._client.features.services // delete the services key for isolation
312
322
  return this.Systems() // go to Systems when done
313
323
  }
@@ -887,7 +897,7 @@ class Deva {
887
897
  key: 'init',
888
898
  value: agent.key,
889
899
  agent,
890
- client: this.copy(client),
900
+ client,
891
901
  text: this._messages.states.start,
892
902
  created: Date.now(),
893
903
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.111",
3
+ "version": "1.1.113",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {