@indra.ai/deva 1.1.36 → 1.1.38

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 (2) hide show
  1. package/index.js +91 -73
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -54,7 +54,7 @@ class Deva {
54
54
  offline: 'offline',
55
55
  online: 'online',
56
56
 
57
- init: 'init',
57
+ init: 'initialize',
58
58
  start: 'start',
59
59
  enter: 'enter',
60
60
  stop: 'stop',
@@ -74,15 +74,15 @@ class Deva {
74
74
 
75
75
  this._zone = false; // current state of agent.
76
76
  this._zones = {
77
- deva: 'deva',
78
- config: 'config',
79
- features: 'features',
80
- idle: 'idle',
81
- train: 'training',
82
- work: 'working',
83
- invalid: 'invalid',
84
- done: 'done',
85
- error: 'error',
77
+ deva: 'deva.world',
78
+ config: 'Configuration Zone',
79
+ features: 'Features Zone',
80
+ idle: 'Idle Zone',
81
+ train: 'Training Zone',
82
+ work: 'Working Zone',
83
+ invalid: 'Invalid Zone',
84
+ done: 'Done Zone',
85
+ error: 'Error Zone',
86
86
  }; // states object
87
87
 
88
88
  this._action = false;
@@ -132,64 +132,64 @@ class Deva {
132
132
  this._feature = false;
133
133
  this._features = {
134
134
  security: 'security',
135
- Security: '@SECURITY',
135
+ Security: 'SECURITY FEATURE',
136
136
  support: 'support',
137
- Support: '@SUPPORT',
137
+ Support: 'SUPPORT FEATURE',
138
138
  services: 'services',
139
- Services: '@SERVICES',
139
+ Services: 'SERVICES FEATURE',
140
140
  solutions: 'solutions',
141
- Solutions: '@SOLUTIONS',
141
+ Solutions: 'SOLUTIONS FEATURE',
142
142
  systems: 'systems',
143
- Systems: '@SYSTEMS',
143
+ Systems: 'SYSTEMS FEATURE',
144
144
  development: 'development',
145
- Development: '@DEVELOPMENT',
145
+ Development: 'DEVELOPMENT FEATURE',
146
146
  business: 'business',
147
- Business: '@BUSINESS',
147
+ Business: 'BUSINESS FEATURE',
148
148
  legal:'legal',
149
- Legal:'@LEGAL',
149
+ Legal:'LEGAL FEATURE',
150
150
  assistant: 'assistant',
151
- Assistant: '@ASSISTANT',
151
+ Assistant: 'ASSISTANT FEATURE',
152
152
  story: 'story',
153
- Story: '@STORY',
153
+ Story: 'STORY FEATURE',
154
154
  mind: 'mind',
155
- Mind: '@MIND',
155
+ Mind: 'MIND FEATURE',
156
156
  error: 'error',
157
157
  done: 'done',
158
158
  };
159
159
 
160
160
  this._messages = {
161
161
  states: {
162
- offline: `${this._agent.profile.name} ofline`,
163
- online: `${this._agent.profile.name} online`,
164
- ask: `:${this._state.ask}`,
165
- question: `${this._states.quesiton}`,
166
- offline: `${this._states.offline}`,
167
- online: `${this._states.online}`,
168
- init: `${this._agent.profile.name} initialize`,
169
- start: `${this._agent.profile.name} start`,
170
- enter: `${this._agent.profile.name} enter`,
171
- stop: `${this._agent.profile.name} stop`,
172
- exit: `${this._agent.profile.name} exit`,
173
- load: `${this._agent.profile.name} load`,
174
- unload: `${this._agent.profile.name} unload`,
175
- uid: `${this._states.uid}`,
176
- hash: `${this._states.hash}`,
177
- cipher: `${this._states.cipher}`,
178
- decipher: `${this._states.decipher}`,
179
- invalid: `${this._states.invalid}`,
180
- done: `${this._agent.profile.name} is Done`,
162
+ offline: `${this._agent.profile.name} ${this._states.offline}`,
163
+ online: `${this._agent.profile.name} ${this._states.online}`,
164
+ ask: `${this._agent.profile.name} ${this._state.ask}`,
165
+ question: `${this._agent.profile.name} ${this._states.quesiton}`,
166
+ offline: `${this._agent.profile.name} ${this._states.offline}`,
167
+ online: `${this._agent.profile.name} ${this._states.online}`,
168
+ init: `${this._agent.profile.name} ${this._states.init}`,
169
+ start: `${this._agent.profile.name} ${this._states.start}`,
170
+ enter: `${this._agent.profile.name} ${this._states.enter}`,
171
+ stop: `${this._agent.profile.name} ${this._states.stop}`,
172
+ exit: `${this._agent.profile.name} ${this._states.exit}`,
173
+ load: `${this._agent.profile.name} ${this._states.load}`,
174
+ unload: `${this._agent.profile.name} ${this._states.unload}`,
175
+ uid: `${this._agent.profile.name} ${this._states.uid}`,
176
+ hash: `${this._agent.profile.name} ${this._states.hash}`,
177
+ cipher: `${this._agent.profile.name} ${this._states.cipher}`,
178
+ decipher: `${this._agent.profile.name} ${this._states.decipher}`,
179
+ invalid: `${this._agent.profile.name} ${this._states.invalid}`,
180
+ done: `${this._agent.profile.name} ${this._states.done}`,
181
181
  error: `${this._states.error}`,
182
182
  },
183
183
  zones: {
184
- deva: 'Deva',
185
- config: 'Configuration',
186
- features: 'Features',
187
- idle: 'Idle',
188
- train: `${this._zones.train}`,
189
- work: `${this._zones.work}`,
190
- invalid: `${this._zones.invalid}`,
191
- done: `${this._zones.done}`,
192
- error: `${this._zones.error}`,
184
+ deva: `${this._agent.profile.name} enter ${this._zones.deva}`,
185
+ config: `${this._agent.profile.name} ${this._zones.config}`,
186
+ features: `${this._agent.profile.name} ${this._zones.features}`,
187
+ idle: `${this._agent.profile.name} ${this._zones.idle}`,
188
+ train: `${this._agent.profile.name} ${this._zones.train}`,
189
+ work: `${this._agent.profile.name} ${this._zones.work}`,
190
+ invalid: `${this._agent.profile.name} ${this._zones.invalid}`,
191
+ done: `${this._agent.profile.name} ${this._zones.done}`,
192
+ error: `${this._agent.profile.name} ${this._zones.error}`,
193
193
  },
194
194
  actions: {
195
195
  wait: `${this._agent.profile.name} ${this._actions.wait}`,
@@ -207,28 +207,28 @@ class Deva {
207
207
  ask: `${this._agent.profile.name} ${this._actions.ask}`,
208
208
  ask_answer: `${this._agent.profile.name} ${this._actions.ask_answer}`,
209
209
  security: `${this._actions.security} is responding`,
210
- Security: `${this._actions.Security} is guarding`,
210
+ Security: `${this._actions.Security} is ready`,
211
211
  support: `${this._actions.support} is responding`,
212
- Support: `${this._actions.Support} is caring`,
212
+ Support: `${this._actions.Support} is ready`,
213
213
  services: `${this._actions.Services} is responding`,
214
- Services: `${this._actions.Services} is servicing`,
214
+ Services: `${this._actions.Services} is ready`,
215
215
  solutions: `${this._actions.solutions} is responding`,
216
- Solutions: `${this._actions.Solutions} is providing`,
216
+ Solutions: `${this._actions.Solutions} is ready`,
217
217
  solutions: `${this._actions.Systems} is responding`,
218
- Systems: `${this._actions.Systems} is delivering`,
218
+ Systems: `${this._actions.Systems} is ready`,
219
219
  development: `${this._actions.Development} is responding`,
220
- Development: `${this._actions.Development} is building`,
220
+ Development: `${this._actions.Development} is ready`,
221
221
  business: `${this._actions.Business} is responding`,
222
- Business: `${this._actions.Business} is successful`,
222
+ Business: `${this._actions.Business} is ready`,
223
223
  legal: `${this._actions.Legal} is responding`,
224
- Legal: `${this._actions.Legal} is doing their job`,
224
+ Legal: `${this._actions.Legal} is ready`,
225
225
  assistant: `${this._actions.Assistant} is responding`,
226
- Assistant: `${this._actions.Assistant} is helping`,
226
+ Assistant: `${this._actions.Assistant} is ready`,
227
227
  story: `${this._actions.Story} is responding`,
228
- Story: `${this._actions.Story} is inspiring`,
228
+ Story: `${this._actions.Story} is ready`,
229
229
  mind: `${this._actions.Mind} is responding`,
230
- Mind: `${this._actions.Mind} is thinking and pondering`,
231
- client_data: `Client Data`,
230
+ Mind: `${this._actions.Mind} is ready`,
231
+ client_data: `${this._agent.profile.name} setting Client Data`,
232
232
  invalid: `${this._actions.invalid}`,
233
233
  done: `${this._actions.done}`,
234
234
  error: `${this._action.error}`,
@@ -291,7 +291,7 @@ class Deva {
291
291
  Security() {
292
292
  this.feature('Security');
293
293
  try {
294
- if (!this._client.features.security) return this.Support();
294
+ if (this._client.features.security) return this.Support();
295
295
  else {
296
296
  this.action('Security');
297
297
  const {id, profile, features} = this._client; // make a copy the clinet data.
@@ -1082,6 +1082,16 @@ class Deva {
1082
1082
  usage: this.init(client_object)
1083
1083
  ***************/
1084
1084
  init(client) {
1085
+ const _data = {
1086
+ id: this.uid(),
1087
+ key: 'init',
1088
+ value: 'init',
1089
+ agent: this._agent,
1090
+ client: this.copy(client),
1091
+ text: this._messages.states.start,
1092
+ created: Date.now(),
1093
+ }
1094
+
1085
1095
  // set client
1086
1096
  this._active = Date.now();
1087
1097
  return new Promise((resolve, reject) => {
@@ -1100,7 +1110,10 @@ class Deva {
1100
1110
  return this.Security();
1101
1111
  }).then(() => {
1102
1112
  this.zone('deva');
1103
- return this.start(this._messages.deva_init);
1113
+
1114
+ _data.hash = this.hash(JSON.stringify(_data));
1115
+ const hasOnInit = this.onInit && typeof this.onInit === 'function';
1116
+ return hasOnInit ? this.onInit(_data) : this.start(_data)
1104
1117
  }).catch(err => {
1105
1118
  return this.error(err, client, reject);
1106
1119
  });
@@ -1145,7 +1158,7 @@ class Deva {
1145
1158
  function or running the system enter function.
1146
1159
  usage: this.start('msg')
1147
1160
  ***************/
1148
- start(text = false) {
1161
+ start(data=false) {
1149
1162
  this.state('start');
1150
1163
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1151
1164
  const _data = {
@@ -1153,12 +1166,13 @@ class Deva {
1153
1166
  key: 'start',
1154
1167
  value: 'start',
1155
1168
  agent: this._agent,
1169
+ client: data.client || this._client,
1156
1170
  text: this._messages.states.start,
1157
1171
  created: Date.now(),
1158
1172
  }
1159
1173
  _data.hash = this.hash(JSON.stringify(_data));
1160
- const hasOnExit = this.onExit && typeof this.onExit === 'function';
1161
- return hasOnExit ? this.onExit(_data) : Promise.resolve(_data)
1174
+ const hasOnStart = this.onStart && typeof this.onStart === 'function';
1175
+ return hasOnStart ? this.onStart(_data) : this.enter(_data)
1162
1176
  }
1163
1177
 
1164
1178
  /**************
@@ -1174,7 +1188,7 @@ class Deva {
1174
1188
  usage:
1175
1189
  this.stop('msg')
1176
1190
  ***************/
1177
- stop(text=false) {
1191
+ stop(data=false) {
1178
1192
  this.state('stop');
1179
1193
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1180
1194
  const _data = {
@@ -1182,6 +1196,7 @@ class Deva {
1182
1196
  key: 'stop',
1183
1197
  value: 'stop',
1184
1198
  agent: this._agent,
1199
+ client: data.client || this._client,
1185
1200
  text: this._messages.states.stop,
1186
1201
  created: Date.now(),
1187
1202
  }
@@ -1201,7 +1216,7 @@ class Deva {
1201
1216
  If the Deva is offline it will return the offline message.
1202
1217
  usage: this.enter('msg')
1203
1218
  ***************/
1204
- enter(text=false) {
1219
+ enter(data=false) {
1205
1220
  this.state('enter');
1206
1221
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1207
1222
  const _data = {
@@ -1209,12 +1224,13 @@ class Deva {
1209
1224
  type: 'enter',
1210
1225
  value: 'enter',
1211
1226
  agent: this._agent,
1227
+ client: data.client || this._client,
1212
1228
  text: this._messages.states.enter,
1213
1229
  created: Date.now(),
1214
1230
  }
1215
1231
  _data.hash = this.hash(JSON.stringify(_data));
1216
1232
  const hasOnEnter = this.onEnter && typeof this.onEnter === 'function';
1217
- return hasOnEnter ? this.onExit(_data) : Promise.resolve(_data)
1233
+ return hasOnEnter ? this.onEnter(_data) : this.done(_data)
1218
1234
  }
1219
1235
 
1220
1236
  /**************
@@ -1231,7 +1247,7 @@ class Deva {
1231
1247
  If the deva is offline it will return the offline message.
1232
1248
  usage: this.exit('msg')
1233
1249
  ***************/
1234
- exit(text=false) {
1250
+ exit(data=false) {
1235
1251
  this.state('exit');
1236
1252
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1237
1253
  this._active = false;
@@ -1240,6 +1256,7 @@ class Deva {
1240
1256
  key: 'exit',
1241
1257
  value: 'exit',
1242
1258
  agent: this._agent,
1259
+ client: this._client || this._client,
1243
1260
  text: this._messages.states.exit,
1244
1261
  created: Date.now(),
1245
1262
  }
@@ -1259,7 +1276,7 @@ class Deva {
1259
1276
  If the deva is offline it will return the offline message.
1260
1277
  usage: this.done('msg')
1261
1278
  ***************/
1262
- done(text=false) {
1279
+ done(data=false) {
1263
1280
  this.state('done');
1264
1281
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1265
1282
  this._active = false;
@@ -1268,12 +1285,13 @@ class Deva {
1268
1285
  key: 'done',
1269
1286
  value: 'done',
1270
1287
  agent: this._agent,
1288
+ client: data.client || this._client,
1271
1289
  text: this._messages.states.exit,
1272
1290
  created: Date.now(),
1273
1291
  }
1274
1292
  _data.hash = this.hash(JSON.stringify(_data));
1275
- const hasOnExit = this.onExit && typeof this.onExit === 'function';
1276
- return hasOnExit ? this.onExit(_data) : Promise.resolve(_data)
1293
+ const hasOnDone = this.onDone && typeof this.onDone === 'function';
1294
+ return hasOnDone ? this.onDone(_data) : Promise.resolve(_data)
1277
1295
  }
1278
1296
 
1279
1297
  ////////////////////////////
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {