@indra.ai/deva 1.1.41 → 1.1.42

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 +22 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -8,6 +8,7 @@ class Deva {
8
8
  constructor(opts) {
9
9
  opts = opts || {};
10
10
  this._id = randomUUID(); // the unique id assigned to the agent at load
11
+ this._info = opts.info || false; // the deva information from the package file.
11
12
  this._config = opts.config || {}; // local Config Object
12
13
  this._agent = opts.agent || false; // Agent profile object
13
14
  this._client = {}; // this will be set on init.
@@ -919,8 +920,6 @@ class Deva {
919
920
  method = t_split[0].substring(1); // if:isCmd use the 0 index as the command
920
921
  text = t_split.slice(1).join(' ').trim(); // if:isCmd rejoin the string on the space after removing first index
921
922
  }
922
- else {
923
- }
924
923
 
925
924
  packet.q = { // build packet.q container
926
925
  id: this.uid(),
@@ -1158,6 +1157,25 @@ class Deva {
1158
1157
  });
1159
1158
  }
1160
1159
 
1160
+ info(id=false) {
1161
+ id = id || this._id;
1162
+ const agent = this.agent();
1163
+ if (this._info) {
1164
+ const _info = [
1165
+ `::begin:info:${id}`,
1166
+ `## ${this._agent.profile.name} (#${agent.key})`,
1167
+ ];
1168
+ for (let x in this._info) {
1169
+ _info.push(`- ${x}: ${this._info[x]}`);
1170
+ }
1171
+ _info.push(`::end:info:${this.hash(JSON.stringify(this._info))}`);
1172
+ return _info.join('\n');
1173
+ }
1174
+ else {
1175
+ return '';
1176
+ }
1177
+ }
1178
+
1161
1179
  /**************
1162
1180
  func: start
1163
1181
  params:
@@ -1176,8 +1194,7 @@ class Deva {
1176
1194
  data.hash = this.hash(JSON.stringify(data));
1177
1195
 
1178
1196
  if (this.info) {
1179
- const _info = JSON.stringify(this.info, null, 2).replace(/\{/g, '::BEGIN:INFO')
1180
- .replace(/\"|\,/g, '').replace(/\}/g, '::END:INFO').trim()
1197
+ const _info = this.info(data.id);
1181
1198
  this.prompt(_info);
1182
1199
  }
1183
1200
 
@@ -1698,7 +1715,7 @@ class Deva {
1698
1715
  const the_hash = createHash(algo);
1699
1716
  the_hash.update(str);
1700
1717
  const _digest = the_hash.digest('base64');
1701
- return _digest;
1718
+ return `${algo}:${_digest}`;
1702
1719
  }
1703
1720
 
1704
1721
  /**************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.41",
3
+ "version": "1.1.42",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {