@indra.ai/deva.services 0.0.8 → 0.0.10
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 +5 -19
- package/feature/methods.js +116 -66
- package/index.js +7 -5
- package/package.json +2 -2
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
|
-
"
|
|
31
|
-
"
|
|
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
|
-
"
|
|
37
|
-
"
|
|
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",
|
package/feature/methods.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function buildProfile(
|
|
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,167 @@ 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.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
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('
|
|
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();
|
|
119
|
+
|
|
120
|
+
agent.hash = this.lib.hash(agent.profile);
|
|
121
|
+
client.hash = this.lib.hash(client.profile);
|
|
58
122
|
|
|
59
|
-
|
|
60
|
-
|
|
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');
|
|
123
|
+
// get the agent main help file for teir corpus.
|
|
124
|
+
this.state('get', 'chat:help');
|
|
72
125
|
this.help('main', info.dir).then(corpus => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}).then(doc => {
|
|
76
|
-
data.corpus = doc.a.data;
|
|
126
|
+
console.log('CORPUS', corpus);
|
|
127
|
+
data.corpus = corpus;
|
|
77
128
|
this.state('get', 'ask:chat');
|
|
78
|
-
return this.question(`${this.askChr}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
corpus
|
|
129
|
+
return this.question(`${this.askChr}chat relay ${packet.q.text}`, {
|
|
130
|
+
client: buildProfile(client, 'client'),
|
|
131
|
+
agent: buildProfile(agent, 'agent'),
|
|
132
|
+
corpus,
|
|
82
133
|
max_tokens: this.vars.ask.max_tokens,
|
|
83
134
|
history: this.vars.ask.history.slice(-10),
|
|
84
135
|
memory: agent.key,
|
|
85
|
-
askAgent,
|
|
86
136
|
});
|
|
87
|
-
}).then(
|
|
88
|
-
|
|
89
|
-
text
|
|
90
|
-
|
|
91
|
-
|
|
137
|
+
}).then(answer => {
|
|
138
|
+
data.chat = answer.a.data.chat;
|
|
139
|
+
const text = [
|
|
140
|
+
`::begin:${agent.key}:${answer.id}`,
|
|
141
|
+
answer.a.text,
|
|
142
|
+
`date: ${this.lib.formatDate(Date.now(), 'long', true)}`,
|
|
143
|
+
`::end:${agent.key}:${this.lib.hash(answer.a.text)}`,
|
|
144
|
+
];
|
|
92
145
|
|
|
93
146
|
// memory event
|
|
94
147
|
this.talk('data:memory', {
|
|
95
|
-
id:
|
|
148
|
+
id: answer.a.data.chat.id,
|
|
96
149
|
client,
|
|
97
150
|
agent,
|
|
98
151
|
q: packet.q.text,
|
|
99
|
-
a:
|
|
152
|
+
a: answer.a.data.chat.text,
|
|
100
153
|
created: Date.now(),
|
|
101
154
|
});
|
|
102
155
|
|
|
103
|
-
|
|
104
|
-
data.chat = chat.a.data.chat;
|
|
105
|
-
this.state('set', 'ask:history');
|
|
106
|
-
|
|
156
|
+
this.state('set', 'chat:history');
|
|
107
157
|
this.vars.ask.history.push({
|
|
108
158
|
role: 'user',
|
|
109
|
-
content: this.trimWords(
|
|
159
|
+
content: this.lib.trimWords(answer.q.text, 150),
|
|
110
160
|
});
|
|
111
161
|
|
|
112
162
|
this.vars.ask.history.push({
|
|
113
|
-
role:
|
|
114
|
-
content: this.trimWords(
|
|
163
|
+
role: answer.a.data.chat.role,
|
|
164
|
+
content: this.lib.trimWords(answer.a.data.chat.text, 150),
|
|
115
165
|
});
|
|
116
166
|
|
|
117
167
|
this.state('parse', 'ask:chat');
|
|
118
168
|
return this.question(`${this.askChr}feecting parse ${text.join('\n')}`);
|
|
119
169
|
}).then(feecting => {
|
|
120
170
|
data.feecting = feecting.a.data;
|
|
121
|
-
this.state('resolve', '
|
|
171
|
+
this.state('resolve', 'chat');
|
|
122
172
|
return resolve({
|
|
123
|
-
text:
|
|
173
|
+
text: feecting.a.text,
|
|
124
174
|
html: feecting.a.html,
|
|
125
175
|
data,
|
|
126
176
|
});
|
|
127
177
|
}).catch(err => {
|
|
128
|
-
this.state('reject', '
|
|
178
|
+
this.state('reject', 'chat');
|
|
129
179
|
return this.error(packet, err, reject);
|
|
130
180
|
});
|
|
131
181
|
});
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c)2025 Quinn Michaels
|
|
2
2
|
// Services Deva
|
|
3
|
-
//
|
|
3
|
+
// Manages various Services in Deva.space, Deva.cloud, and Deva.world.
|
|
4
4
|
import Deva from '@indra.ai/deva';
|
|
5
5
|
import pkg from './package.json' with {type:'json'};
|
|
6
6
|
|
|
@@ -39,11 +39,13 @@ const SERVICES = new Deva({
|
|
|
39
39
|
func: {},
|
|
40
40
|
methods: {},
|
|
41
41
|
onReady(data, resolve) {
|
|
42
|
-
this.prompt(
|
|
42
|
+
this.prompt(this.vars.messages.ready);
|
|
43
43
|
return resolve(data);
|
|
44
44
|
},
|
|
45
|
-
onError(err) {
|
|
46
|
-
|
|
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.
|
|
4
|
+
"version": "0.0.10",
|
|
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.
|
|
30
|
+
"@indra.ai/deva": "^1.4.10"
|
|
31
31
|
}
|
|
32
32
|
}
|