@indra.ai/deva.services 0.0.9 → 0.0.11

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.
package/data.json CHANGED
@@ -6,7 +6,6 @@
6
6
  "agent": {
7
7
  "id": 4855882658530,
8
8
  "key": "services",
9
- "model": "gpt3",
10
9
  "prompt": {
11
10
  "emoji": "🛠️",
12
11
  "text": "Services",
@@ -24,27 +23,13 @@
24
23
  }
25
24
  },
26
25
  "profile": {
27
- "identity": "You are #ServicesDEVA in deva.world.",
28
- "invoke": "#ServicesDEVA of deva.world",
29
26
  "name": "Services Deva",
30
- "mention": "@ServicesDEVA",
31
- "tags": "#Services #ServicesDEVA",
32
- "gender": "Deva",
33
- "pronouns": "Male, Man, He, Him, His, Guy, Dude, Deva",
27
+ "gender": "DEVA",
28
+ "pronouns": "He, Him",
34
29
  "creator": "Quinn Michaels",
35
30
  "created": "May 22, 2023 at 10:14 AM",
36
- "house": "House Deva",
37
- "temple": "Kedarnath Temple (Vadari)",
38
- "forest": "Pushkara",
39
- "city": "Amaravati",
40
- "region": "Svarga",
41
- "land": "Visisipra",
42
- "planet": "Arjika",
43
- "loka": "Devaloka",
44
- "verse": "Rikverse",
45
- "system": "deva.world",
46
- "agency": "indra.agency",
47
- "describe": "Services Deva is the entity in deva.world multi-agent system that manages services for teh users and entites. Managing connection strings into various data sources or proving the built in services features and functions. Services Deva is here to make sure the necessary services are online and running that keep deva.world operation.",
31
+ "system": "Deva.world.services",
32
+ "describe": "ServicesDEVA is the entity in Deva.world multi-agent system that manages services for the users and entites. ServicesDEVA is here to make sure the necessary services are online and running that keep deva.world operation.",
48
33
  "emoji": "/public/devas/services/emoji.png",
49
34
  "avatar": "/public/devas/services/avatar.png",
50
35
  "background": "/public/devas/services/background.png",
@@ -59,6 +44,7 @@
59
44
  "init": "🟠 INIT",
60
45
  "start": "🔵 START",
61
46
  "enter": "🟢 ENTER",
47
+ "ready": "⭐️ Services Deva Ready!",
62
48
  "stop": "🔴 STOP",
63
49
  "exit": "🟡 EXIT",
64
50
  "done": "🟣 DONE",
@@ -1,10 +1,10 @@
1
- function buildProfile(profile, type='assistant') {
1
+ function buildProfile(entity, type='assistant') {
2
2
  const _profile = [];
3
- _profile.push(`::begin:${type}`);
4
- for (let x in profile) {
5
- _profile.push(`${x}: ${profile[x]}`);
3
+ _profile.push(`::begin:${type}:${entity.id}`);
4
+ for (let x in entity.profile) {
5
+ _profile.push(`${x}: ${entity.profile[x]}`);
6
6
  }
7
- _profile.push(`::end:${type}\n`);
7
+ _profile.push(`::end:${type}:${entity.hash}\n`);
8
8
  return _profile.join('\n');
9
9
  }
10
10
  export default {
@@ -15,117 +15,165 @@ export default {
15
15
  ***************/
16
16
  services(packet) {
17
17
  this.context('feature');
18
- const services = this.services();
19
- const data = {};
20
18
  return new Promise((resolve, reject) => {
21
- this.question(`#docs raw feature/services`).then(doc => {
22
- data.doc = doc.a.data;
23
- const info = [
24
- `::begin:services:${services.id}`,
25
- `client: ${services.client_name}`,
26
- `concerns: ${services.concerns.join(', ')}`,
27
- `::end:services:${this.hash(services)}`,
28
- ].join('\n');
29
- const text = doc.a.text.replace(/::info::/g, info)
30
- return this.question(`#feecting parse ${text}`)
31
- }).then(feecting => {
32
- return this.finish({
19
+ const services = this.services();
20
+ const agent = this.agent();
21
+ const global = [];
22
+ services.global.forEach((item,index) => {
23
+ global.push(`::begin:global:${item.key}:${item.id}`);
24
+ for (let x in item) {
25
+ global.push(`${x}: ${item[x]}`);
26
+ }
27
+ global.push(`::end:global:${item.key}:${this.lib.hash(item)}`);
28
+ });
29
+ const concerns = [];
30
+ services.concerns.forEach((item, index) => {
31
+ concerns.push(`${index + 1}. ${item}`);
32
+ })
33
+
34
+ const info = [
35
+ '::BEGIN:SERVICES',
36
+ '### Client',
37
+ `::begin:client:${services.client_id}`,
38
+ `id: ${services.client_id}`,
39
+ `client: ${services.client_name}`,
40
+ '**concerns**',
41
+ concerns.join('\n'),
42
+ `::end:client:${this.lib.hash(services)}`,
43
+ '### Global',
44
+ global.join('\n'),
45
+ '::END:SERVICES'
46
+ ].join('\n');
47
+ this.question(`${this.askChr}feecting parse ${info}`).then(feecting => {
48
+ return resolve({
33
49
  text: feecting.a.text,
34
50
  html: feecting.a.html,
35
- data: services
36
- }, resolve);
51
+ data: services.concerns,
52
+ });
37
53
  }).catch(err => {
38
54
  return this.error(err, packet, reject);
39
55
  })
40
56
  });
41
57
  },
58
+
59
+ /**************
60
+ method: file
61
+ params: packet
62
+ describe: The view method replays the request to the view function to return
63
+ a document from the text parameter.
64
+ ***************/
65
+ file(packet) {
66
+ const agent = this.agent();
67
+ this.zone('services');
68
+ this.feature('services', `file:${packet.q.text}`);
69
+ this.action('method', `file:${packet.q.text}`);
70
+ this.context('file', packet.q.text);
71
+ return new Promise((resolve, reject) => {
72
+ this.state('get', packet.q.text);
73
+ const {text, meta} = packet.q;
74
+
75
+ const splitText = text.split(':');
76
+ const area = meta.params[1] ? meta.params[1] : 'public';
77
+ const part = splitText[1] ? splitText[1].toUpperCase() : 'MAIN';
78
+ const docName = splitText[0].length ? splitText[0] + '.feecting' : 'main.feecting';
79
+ const docPath = this.lib.path.join(this.config.dir, area, agent.key, docName);
80
+
81
+ let doc;
82
+ try {
83
+ doc = this.lib.fs.readFileSync(docPath, 'utf8');
84
+ doc = doc.split(`::BEGIN:${part}`)[1].split(`::END:${part}`)[0];
85
+ } catch (err) {
86
+ console.log(err);
87
+ }
88
+
89
+ this.question(`${this.askChr}feecting parse ${doc}`).then(feecting => {
90
+ this.state('resolve', `view:${packet.q.text}`);
91
+ return resolve({
92
+ text: feecting.a.text,
93
+ html: feecting.a.html,
94
+ data: feecting.a.data,
95
+ });
96
+ }).catch(err => {
97
+ this.state('reject', `file:${packet.q.text}`);
98
+ return this.error(err, packet, reject);
99
+ })
100
+ });
101
+ },
102
+
42
103
  /**************
43
104
  method: ask
44
105
  params: packet
45
106
  describe: this method provides a global ask method to all agents.
46
107
  ***************/
47
- 'ask'(packet) {
48
- this.context('ask', packet.q.agent.name);
49
- this.action('feature', 'ask');
108
+ async ask(packet) {
109
+ this.zone('services');
110
+ this.feature('services');
111
+ this.context('chat', packet.q.agent.name);
112
+ this.action('services', 'chat');
50
113
  return new Promise((resolve, reject) => {
51
- if (!this.vars.ask) return resolve('NO ASK');
52
- const askAgent = packet.q.meta.params[1] ? false : true;
53
- const text = [];
114
+ if (!this.vars.ask) return resolve('Ask not configured.');
54
115
  const data = {};
55
116
  const agent = this.agent();
56
117
  const client = this.client();
57
118
  const info = this.info();
58
-
59
- this.state('set', 'message');
60
- const msg = [
61
- `::begin:user:${client.id}`,
62
- `id: ${client.id}`,
63
- `name: ${client.profile.nickname}`,
64
- `fullname: ${client.profile.name}`,
65
- `date: ${this.formatDate(Date.now(), 'long', true)}`,
66
- `::end:user`,
67
- packet.q.text,
68
- ].join('\n');
69
-
70
- // get the agent main help file for teir corpus.
71
- this.state('get', 'ask:help');
119
+
120
+ agent.hash = this.lib.hash(agent.profile);
121
+ client.hash = this.lib.hash(client.profile);
122
+ // get the agent main help file for teir corpus.
123
+ this.state('get', 'chat:help');
72
124
  this.help('main', info.dir).then(corpus => {
73
- this.action('parse', 'ask:corpus');
74
- return this.question(`${this.askChr}feecting parse ${corpus}`);
75
- }).then(doc => {
76
- data.corpus = doc.a.data;
125
+ data.corpus = corpus;
77
126
  this.state('get', 'ask:chat');
78
- return this.question(`${this.askChr}open relay ${msg}`, {
79
- model: agent.model || false,
80
- user: buildProfile(client.profile, 'user'),
81
- corpus: doc.a.text,
127
+ return this.question(`${this.askChr}chat relay ${packet.q.text}`, {
128
+ client: buildProfile(client, 'client'),
129
+ agent: buildProfile(agent, 'agent'),
130
+ corpus,
82
131
  max_tokens: this.vars.ask.max_tokens,
83
132
  history: this.vars.ask.history.slice(-10),
84
133
  memory: agent.key,
85
- askAgent,
86
134
  });
87
- }).then(chat => {
88
-
89
- text.push(`::begin:${agent.key}:${chat.id}`);
90
- text.push(chat.a.data.parsed);
91
- text.push(`::end:${agent.key}:${chat.hash}`);
135
+ }).then(answer => {
136
+ data.chat = answer.a.data.chat;
137
+ const text = [
138
+ `::begin:${agent.key}:${answer.id}`,
139
+ answer.a.text,
140
+ `date: ${this.lib.formatDate(Date.now(), 'long', true)}`,
141
+ `::end:${agent.key}:${this.lib.hash(answer.a.text)}`,
142
+ ];
92
143
 
93
144
  // memory event
94
145
  this.talk('data:memory', {
95
- id: chat.a.data.chat.id,
146
+ id: answer.a.data.chat.id,
96
147
  client,
97
148
  agent,
98
149
  q: packet.q.text,
99
- a: chat.a.data.chat.text,
150
+ a: answer.a.data.chat.text,
100
151
  created: Date.now(),
101
152
  });
102
153
 
103
-
104
- data.chat = chat.a.data.chat;
105
- this.state('set', 'ask:history');
106
-
154
+ this.state('set', 'chat:history');
107
155
  this.vars.ask.history.push({
108
156
  role: 'user',
109
- content: this.trimWords(chat.q.text, 100),
157
+ content: this.lib.trimWords(answer.q.text, 150),
110
158
  });
111
159
 
112
160
  this.vars.ask.history.push({
113
- role: chat.a.data.chat.role,
114
- content: this.trimWords(chat.a.data.chat.text, 100),
161
+ role: answer.a.data.chat.role,
162
+ content: this.lib.trimWords(answer.a.data.chat.text, 150),
115
163
  });
116
164
 
117
165
  this.state('parse', 'ask:chat');
118
166
  return this.question(`${this.askChr}feecting parse ${text.join('\n')}`);
119
167
  }).then(feecting => {
120
168
  data.feecting = feecting.a.data;
121
- this.state('resolve', 'ask');
169
+ this.state('resolve', 'chat');
122
170
  return resolve({
123
- text: data.chat.text,
171
+ text: feecting.a.text,
124
172
  html: feecting.a.html,
125
173
  data,
126
174
  });
127
175
  }).catch(err => {
128
- this.state('reject', 'ask');
176
+ this.state('reject', 'chat');
129
177
  return this.error(packet, err, reject);
130
178
  });
131
179
  });
package/index.js CHANGED
@@ -39,11 +39,13 @@ const SERVICES = new Deva({
39
39
  func: {},
40
40
  methods: {},
41
41
  onReady(data, resolve) {
42
- this.prompt('ready');
42
+ this.prompt(this.vars.messages.ready);
43
43
  return resolve(data);
44
44
  },
45
- onError(err) {
46
- console.log('ERR', err);
47
- }
45
+ onError(err, data, reject) {
46
+ this.prompt(this.vars.messages.error);
47
+ console.log(err);
48
+ return reject(err);
49
+ },
48
50
  });
49
51
  export default SERVICES
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": 4855882658530,
3
3
  "name": "@indra.ai/deva.services",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "author": "Quinn Michaels",
6
6
  "license": "MIT",
7
7
  "copyright": "2025",
@@ -27,6 +27,6 @@
27
27
  },
28
28
  "homepage": "https://deva.space/devas/services",
29
29
  "dependencies": {
30
- "@indra.ai/deva": "^1.3.1"
30
+ "@indra.ai/deva": "^1.4.12"
31
31
  }
32
32
  }