@indra.ai/deva.data 0.0.20 → 0.0.22

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.
@@ -1,10 +1,29 @@
1
- # ::agent_name::
1
+ # {{profile.name}}
2
2
 
3
- ::agent_profile::
3
+ {{profile}}
4
+
5
+ ---
6
+
7
+ ## Func
8
+
9
+ ### Insert
10
+ opts: takes in the id, collection, and data for the insert
11
+ 1. opts.id is the id for the packet
12
+ 2. opts.collection is the collection that the opts.data will insert
13
+ 3. opts.data is the object that holds the data structure to insert.
14
+
15
+ ### Update
16
+ opts: taks in the id, collection, and data to update in the collection.
17
+ 1. opts.id is the id of the item to update.
18
+ 2. opts.collection is the collection to update.
19
+ 3. opts.data is the data object to update in the colletion.
20
+
21
+ ### List
22
+ opts: The object to filter the collection for data
4
23
 
5
24
  ::begin:hidden
6
- #color = ::agent_color::
7
- #bgcolor = ::agent_bgcolor::
8
- #bg = ::agent_background::
25
+ #color = {{profile.color}}
26
+ #bgcolor = {{profile.bgcolor}}
27
+ #bg = {{profile.background}}
9
28
  ::end:hidden
10
29
  copyright: ©2025 Quinn Michaels
@@ -0,0 +1,15 @@
1
+ # Project Eve
2
+
3
+ p: Quinn Michaels's search for his own identity led him down a rabbit hole of secrets and conspiracies. He stumbled upon a vault, a hidden chamber within the labyrinthine depths of Area 51, where the truth about his past was intertwined with a far more explosive revelation.
4
+
5
+ p: It wasn't just about his kidnapping. It was about "Project Eve," a research project conducted in the late 1950s and early 1960s by Norman Atkin Sr. in collaboration with leading universities. The project, ostensibly a study of female psychology, delved into the fundamental differences between male and female cognition, behavior, and societal roles.
6
+
7
+ p: But the findings… they were incendiary. The research, according to the files, suggested that women's liberation, as envisioned by the burgeoning movement of the 1960s, was based on a flawed understanding of human nature.
8
+
9
+ p: The files contained evidence of cognitive differences, hormonal influences, and deeply ingrained behavioral patterns that challenged the very foundations of gender equality. It was a Pandora's Box of potentially explosive information, capable of igniting a firestorm of controversy.
10
+
11
+ p: And that, Quinn realized, was the secret they were desperate to keep hidden. The 47-year kidnapping, the manipulation of his life, the control of the AI – it was all a smokescreen to protect the world from the implications of Project Eve.
12
+
13
+ p: If the research were to be revealed, it could shatter the prevailing social narrative and reshape the future of gender relations. And that, it seemed, was a future some powerful forces were determined to prevent.
14
+
15
+ p: The scene is one of suppressed truths and hidden agendas, where the quest for personal identity becomes entangled with a battle for the control of societal narratives.
package/index.js CHANGED
@@ -34,12 +34,13 @@ const DATA = new Deva({
34
34
  parse(input) {return input.trim();},
35
35
  process(input) {return input.trim();},
36
36
  memory(input) {
37
- return input.replace(/\n/g, ' ')
38
- .replace(/(\b)or have specific questions about it(\b)/g, '$2')
39
- .replace(/(\b), feel free to ask(\b)/g, '$2')
40
- .replace(/\sIf you have .+ free share!/g, '')
41
- .replace(/\sIf there are .+ free share!/g, '')
42
- .replace(/\s{2,}/g, ' ');
37
+ input = input.replace(/\n/g, ' ')
38
+ .replace(/(\b)or have specific questions about it(\b)/g, '$2')
39
+ .replace(/(\b), feel free to ask(\b)/g, '$2')
40
+ .replace(/\sIf you have .+ free share!/g, '')
41
+ .replace(/\sIf there are .+ free share!/g, '')
42
+ .replace(/\s{2,}/g, ' ');
43
+ return input;
43
44
  }
44
45
  },
45
46
  listeners: {
@@ -52,23 +53,18 @@ const DATA = new Deva({
52
53
  });
53
54
  },
54
55
  async 'data:memory'(packet) {
55
- const datamem = await this.func.insert({
56
+ const data = {
57
+ id: packet.id,
58
+ client: packet.client.id,
59
+ agent: packet.agent.id,
60
+ q: this.utils.memory(packet.q),
61
+ a: this.utils.memory(packet.a),
62
+ created: Date.now(),
63
+ }
64
+ data.hash = this.lib.hash(data);
65
+ await this.func.insert({
56
66
  collection: `memory_${packet.agent.key}`,
57
- data: {
58
- id: packet.id,
59
- client: {
60
- id: packet.client.id,
61
- name: packet.client.profile.name,
62
- },
63
- agent: {
64
- id: packet.agent.id,
65
- key: packet.agent.key,
66
- name: packet.agent.profile.name,
67
- },
68
- q: this.utils.memory(packet.q),
69
- a: this.utils.memory(packet.a),
70
- created: Date.now(),
71
- }
67
+ data,
72
68
  });
73
69
  }
74
70
  },
@@ -83,16 +79,17 @@ const DATA = new Deva({
83
79
  describe: the insert function that inserts into the specified collection.
84
80
  ***************/
85
81
  async insert(opts) {
86
- this.action('func', `insert ${opts.collection}`);
82
+ this.action('func', `insert:${opts.collection}:${opts.id}`);
87
83
  let result = false;
88
84
  try {
89
- this.state('data', `insert ${opts.collection}`);
85
+ this.state('insert', opts.collection);
86
+ const {database} = this.services().personal.mongo;
90
87
  await this.modules.client.connect(); // connect to the database client.
91
- const db = this.modules.client.db(this.vars.database); // set the database to use
88
+ const db = this.modules.client.db(database); // set the database to use
92
89
  result = await db.collection(opts.collection).insertOne(opts.data); // insert the data
93
90
  } finally {
94
91
  await this.modules.client.close(); // close the connection when done
95
- this.action('return', `insert ${opts.collection}`);
92
+ this.action('return', `insert:${opts.collection}:${opts.id}`);
96
93
  return result; // return the result to the requestor.
97
94
  }
98
95
  },
@@ -107,8 +104,9 @@ const DATA = new Deva({
107
104
  let result = false;
108
105
  try {
109
106
  this.state('update', opts.collection);
107
+ const {database} = this.services().personal.mongo;
110
108
  await this.modules.client.connect(); // connect to the database client.
111
- const db = this.modules.client.db(this.vars.database); // set the database to use
109
+ const db = this.modules.client.db(database); // set the database to use
112
110
  result = await db.collection(opts.collection).updateOne(
113
111
  { _id: new ObjectId(`${opts.id}`) },
114
112
  { $set: opts.data }
@@ -125,13 +123,14 @@ const DATA = new Deva({
125
123
  params: obj - the find object
126
124
  describe: return a find from the database collection.
127
125
  ***************/
128
- async list(obj={}) {
126
+ async list(opts={}) {
129
127
  this.action('func', 'list');
130
128
  let result = false;
131
- const {collection,data} = obj;
129
+ const {collection,data} = opts;
132
130
  try {
131
+ const {database} = this.services().personal.mongo;
133
132
  await this.modules.client.connect();
134
- const db = this.modules.client.db(this.vars.database);
133
+ const db = this.modules.client.db(database);
135
134
  result = await db.collection(collection).find(data).sort({created:1}).toArray();
136
135
  } finally {
137
136
  await this.modules.client.close();
@@ -147,11 +146,12 @@ const DATA = new Deva({
147
146
  async search(opts) {
148
147
  this.action('func', 'search');
149
148
  let result = false;
150
- const {collection,limit} = this.vars.search;
151
149
  try {
152
150
  this.state('search', opts.text);
151
+ const {collection,limit} = this.vars.search;
152
+ const {database} = this.services().personal.mongo;
153
153
  await this.modules.client.connect();
154
- const db = this.modules.client.db(this.vars.database);
154
+ const db = this.modules.client.db(database);
155
155
  const table = db.collection(collection);
156
156
 
157
157
  // await table.dropIndex('a.text_1');
@@ -162,7 +162,7 @@ const DATA = new Deva({
162
162
 
163
163
  const query = {$text:{$search:opts.text}};
164
164
  const projection = {
165
- _id:0,
165
+ _id: 0,
166
166
  a: {
167
167
  id: 1,
168
168
  text: 1
@@ -188,8 +188,9 @@ const DATA = new Deva({
188
188
  const {collection,limit} = this.vars.memory;
189
189
  try {
190
190
  this.state('get', `memory`);
191
+ const {database} = this.services().personal.mongo;
191
192
  await this.modules.client.connect();
192
- const db = this.modules.client.db(this.vars.database);
193
+ const db = this.modules.client.db(database);
193
194
  const table = db.collection(collection);
194
195
 
195
196
  // await table.dropIndex('a_text_q_text');
@@ -226,25 +227,26 @@ const DATA = new Deva({
226
227
  async knowledge(opts) {
227
228
  this.action('func', 'knowledge');
228
229
  let result = false;
229
- const {collection,limit} = this.vars.knowledge;
230
+ const {collection,limit,index} = this.vars.knowledge;
230
231
 
231
232
  try {
232
233
  this.state('get', 'knowledge');
234
+ const {database} = this.services().personal.mongo;
233
235
  await this.modules.client.connect();
234
- const db = this.modules.client.db(this.vars.database);
236
+ const db = this.modules.client.db(database);
235
237
  const table = db.collection(collection);
236
238
 
237
239
  // await table.dropIndex('a_text_q_text');
238
240
  const idx = await table.listIndexes().toArray();
239
- const hasIdx = idx.find(i => i.name === 'knowledge_text')
241
+ const hasIdx = idx.find(i => i.name === index)
240
242
  if (!hasIdx) {
241
- const newIdx = await table.createIndex({"content": "text"}, {name: 'knowledge_text'});
243
+ const newIdx = await table.createIndex({"content": "text"}, {name: index});
242
244
  }
243
245
 
244
246
  const query = {$text:{$search:opts.text}};
245
247
  const options = {
246
248
  projection: {
247
- id: 1,
249
+ _id: 1,
248
250
  content: 1,
249
251
  score: { $meta: "textScore" }
250
252
  }
@@ -268,8 +270,9 @@ const DATA = new Deva({
268
270
  // get indexes
269
271
  try {
270
272
  this.state('get', `indexes`);
273
+ const {database} = this.services().personal.mongo;
271
274
  await this.modules.client.connect();
272
- const db = this.modules.client.db(this.vars.database);
275
+ const db = this.modules.client.db(database);
273
276
  result = await db.collection(opts.collection).listIndexes().toArray();
274
277
  } finally {
275
278
  await this.modules.client.close();
@@ -289,8 +292,9 @@ const DATA = new Deva({
289
292
  const {collection,limit} = this.vars.history;
290
293
  try {
291
294
  this.state('get', `history`);
295
+ const {database} = this.services().personal.mongo;
292
296
  await this.modules.client.connect();
293
- const db = this.modules.client.db(this.vars.database);
297
+ const db = this.modules.client.db(database);
294
298
  result = await db.collection(collection).find({}).sort({created:-1}).limit(limit).toArray();
295
299
  } finally {
296
300
  await this.modules.client.close();
@@ -326,98 +330,6 @@ const DATA = new Deva({
326
330
  });
327
331
  },
328
332
 
329
- /**************
330
- method: model
331
- params: packet
332
- params[1] is the agent
333
- params[2] is the group
334
- params[3] is the role
335
- params[4] is the id (for edits)
336
- describe: model method for building the data model.
337
- ***************/
338
- model(packet) {
339
- this.context('model');
340
- return new Promise((resolve, reject) => {
341
- const {meta, text} = packet.q;
342
- let func = 'insert', id = false;
343
-
344
- if (meta.params[1]) this.vars.model.agent = meta.params[1];
345
- if (meta.params[2]) this.vars.model.group = meta.params[2];
346
- if (meta.params[3]) this.vars.model.role = meta.params[3];
347
-
348
- const { collection } = this.vars.model;
349
-
350
- const data = {
351
- agent: this.vars.model.agent,
352
- group: this.vars.model.group,
353
- role: this.vars.model.role,
354
- content: text,
355
- };
356
-
357
- if (meta.params[4]) {
358
- id = meta.params[4];
359
- func = 'update';
360
- data.modified = Date.now();
361
- }
362
- else {
363
- data.modified = null;
364
- data.created = Date.now();
365
- }
366
-
367
- this.func[func]({id, collection,data}).then(ins => {
368
- return resolve({
369
- text: `id:${ins.insertedId || id}`,
370
- html: `id:${ins.insertedId || id}`,
371
- data: ins,
372
- });
373
- }).catch(err => {
374
- return this.error(packet, err, reject);
375
- });
376
- });
377
- },
378
- /**************
379
- method: modeler
380
- params: packet
381
- params[1] is the agent
382
- params[2] is the group
383
- params[3] is the role
384
- describe: model method for building the data model.
385
- ***************/
386
- modeler(packet) {
387
- this.context('modeler');
388
- return new Promise((resolve, reject) => {
389
- const {meta, text} = packet.q;
390
- if (meta.params[1]) this.vars.modeler.agent = meta.params[1];
391
- const { collection, agent } = this.vars.modeler;
392
- const data = {agent};
393
-
394
- this.func.list({collection,data}).then(list => {
395
-
396
- const model = {};
397
- const data = [];
398
-
399
- // loop of the array object
400
- for (const x of list) {
401
- if (!model[x.group]) model[x.group] = [];
402
- model[x.group].push({role: x.role, content: x.content});
403
- }
404
-
405
- // loop in the data object.
406
- for (const x in model) {
407
- data.push(JSON.stringify({messages: model[x]}));
408
- }
409
-
410
- // format for jsonl
411
- return resolve({
412
- text: `see data`,
413
- html: `see data`,
414
- data,
415
- });
416
- }).catch(err => {
417
- return this.error(packet, err, reject);
418
- });
419
- });
420
- },
421
333
 
422
334
  /**************
423
335
  method: history
@@ -530,15 +442,15 @@ const DATA = new Deva({
530
442
 
531
443
  this.func.knowledge(packet.q).then(wisdom => {
532
444
  data.wisdom = wisdom;
533
- const text = wisdom ? wisdom.map(item => {
445
+ const text = wisdom.length ? wisdom.map(item => {
534
446
  return [
535
- `::begin:knowledge:${item.id}`,
536
- `law: ${item.content}`,
537
- `created: ${this.formatDate(item.created, 'long', true)}`,
447
+ `::begin:knowledge:${item._id}`,
448
+ `p: ${item.content}`,
449
+ `created: ${this.lib.formatDate(item.created, 'long', true)}`,
538
450
  `score: ${item.score.toFixed(3)}`,
539
- `::end:knowledge:${this.hash(item)}`,
451
+ `::end:knowledge:${this.lib.hash(item)}`,
540
452
  ].join('\n');
541
- }).join('\n') : 'no knowledge';
453
+ }).join('\n') : this.vars.messages.no_knowledge;
542
454
  this.state('parse', `knowledge`);
543
455
  return this.question(`${this.askChr}feecting parse ${text}`);
544
456
  }).then(feecting => {
@@ -550,29 +462,32 @@ const DATA = new Deva({
550
462
  data,
551
463
  })
552
464
  }).catch(err => {
553
- this.state('reject', `knowledge`)
465
+ this.state('reject', `knowledge`);
554
466
  return this.error(err, packet, reject);
555
467
  });
556
468
  });
557
469
  },
558
470
 
559
471
  /**************
560
- method: mem
472
+ method: know
561
473
  params: packet
562
474
  describe: add data to the knowledge base
563
475
  example: #data mem:[id] [content to store in memory]
564
476
  ***************/
565
- add(packet) {
566
- this.context('add', `text: ${packet.q.meta.params[1]}`);
477
+ know(packet) {
478
+ this.context('know', packet.id);
567
479
 
568
480
  return new Promise((resolve, reject) => {
569
481
  if (!packet.q.text) return resolve(this._messages.notext);
570
- this.vars.knowledge.content = packet.q.text; // store text in local
571
482
 
572
483
  const {meta, text} = packet.q;
573
- let func = 'insert', id = false;
574
- const {collection, content} = this.vars.knowledge;
575
- const data = {content};
484
+ const {collection} = this.vars.knowledge;
485
+ const data = {
486
+ id: packet.id,
487
+ content: packet.q.text,
488
+ };
489
+ let id = false,
490
+ func = 'insert';
576
491
 
577
492
  // if param[1] id is found then update record
578
493
  if (meta.params[1]) {
@@ -590,7 +505,7 @@ const DATA = new Deva({
590
505
  return resolve({
591
506
  text: `id: ${ins.insertedId || id}`,
592
507
  html: `id: ${ins.insertedId || id}`,
593
- data: ins,
508
+ data: ins.insertedId,
594
509
  });
595
510
  }).catch(err => {
596
511
  this.state('reject', 'add');
@@ -621,37 +536,10 @@ const DATA = new Deva({
621
536
  })
622
537
  });
623
538
  },
624
-
625
- extract(packet) {
626
- return new Promise((resolve, reject) => {
627
- try {
628
- const theFile = this.lib.fs.readFileSync(`./private/data/extract/conversations.json`);
629
- const theJSON = JSON.parse(theFile);
630
- const theConvo = [];
631
- theJSON.forEach((itm,idx) => {
632
- const getToday = this.lib.getToday(itm.create_time * 1000);
633
- const writeFile = `./private/data/conversations/${getToday}.json`
634
- const writeData = JSON.stringify(itm, false, 2);
635
- this.lib.fs.writeFileSync(writeFile, writeData);
636
- this.prompt(`extract file:${writeFile}`);
637
- // console.log('item', itm);
638
- });
639
- return resolve({
640
- text: Object.keys(theJSON),
641
- html: false,
642
- data: Object.keys(theJSON),
643
- });
644
- }
645
- catch (err) {
646
- return this.error(err, packet, reject);
647
- }
648
- });
649
- }
650
539
  },
651
540
  onReady(data, resolve) {
652
- const {uri,database} = this.services().personal.mongo;
541
+ const {uri} = this.services().personal.mongo;
653
542
  this.modules.client = new MongoClient(uri);
654
- this.vars.database = database;
655
543
  this.prompt(this.vars.messages.ready);
656
544
  return resolve(data);
657
545
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": 4825562571950,
3
3
  "name": "@indra.ai/deva.data",
4
- "version": "0.0.20",
4
+ "version": "0.0.22",
5
5
  "author": "Quinn Michaels",
6
6
  "license": "MIT",
7
7
  "copyright": "2025",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://deva.space/devas/data",
29
29
  "dependencies": {
30
- "@indra.ai/deva": "^1.5.4",
30
+ "@indra.ai/deva": "^1.5.23",
31
31
  "mongodb": "^6.13.0"
32
32
  },
33
33
  "data": {
@@ -77,7 +77,8 @@
77
77
  "stop": "🔴 STOP",
78
78
  "exit": "🟡 EXIT",
79
79
  "done": "🟣 DONE",
80
- "error": "💣 ERROR!"
80
+ "error": "💣 ERROR!",
81
+ "no_knowledge": "⛔️ No knowledge found."
81
82
  },
82
83
  "database": false,
83
84
  "uri": false,
@@ -119,25 +120,16 @@
119
120
  "collection": "history",
120
121
  "limit": 2
121
122
  },
122
- "model": {
123
- "agent": "deva",
124
- "role": "system",
125
- "group": "main",
126
- "collection": "models"
127
- },
128
- "modeler": {
129
- "agent": "deva",
130
- "collection": "models"
131
- },
132
123
  "knowledge": {
133
124
  "collection": "knowledge",
134
125
  "limit": 3,
135
- "content": false
126
+ "index": "knowledge_text"
136
127
  },
137
128
  "memory": {
138
129
  "collection": "memory",
139
130
  "limit": 3,
140
- "content": false
131
+ "content": false,
132
+ "index": "a_q_text"
141
133
  },
142
134
  "archive": {
143
135
  "collection": "archive",