@indra.ai/deva 1.65.11 โ 1.65.21
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/buddy.json +4 -2
- package/buddy/index.js +16 -3
- package/buddy/template/data/client.json +27 -0
- package/buddy/template/data/index.json +1 -1
- package/buddy/template/index.js +0 -6
- package/buddy/template/index.test.js +53 -1
- package/index.js +2 -0
- package/package.json +8 -1
package/_data/buddy.json
CHANGED
|
@@ -55,7 +55,9 @@
|
|
|
55
55
|
"index_updated": "โ
INDEX UPDATED:",
|
|
56
56
|
"folder": "๐",
|
|
57
57
|
"file": "๐",
|
|
58
|
-
"deva_created": "โ
DEVA CREATED:"
|
|
58
|
+
"deva_created": "โ
DEVA CREATED:",
|
|
59
|
+
"incomplete": "๐ KEY AND NAME ARE REQUIRED. NO DEVA CREATED.",
|
|
60
|
+
"exists": "๐ A DEVA ALREADY EXISTS HERE. NO DEVA CREATED:"
|
|
59
61
|
},
|
|
60
62
|
"create": {
|
|
61
63
|
"files": [],
|
|
@@ -92,7 +94,7 @@
|
|
|
92
94
|
"type": "input",
|
|
93
95
|
"name": "pronouns",
|
|
94
96
|
"message": "Pronouns",
|
|
95
|
-
"default": ""
|
|
97
|
+
"default": "they/them"
|
|
96
98
|
},
|
|
97
99
|
{
|
|
98
100
|
"type": "list",
|
package/buddy/index.js
CHANGED
|
@@ -112,6 +112,7 @@ const DevaBuddy = new Deva({
|
|
|
112
112
|
.replace(/::pronouns::/g, answers.pronouns)
|
|
113
113
|
.replace(/::vector::/g, answers.vector)
|
|
114
114
|
.replace(/::vla::/g, this.info().VLA.uid)
|
|
115
|
+
.replace(/::vla-data::/g, JSON.stringify(this.info().VLA))
|
|
115
116
|
.replace(/::date::/g, this.lib.formatDate(Date.now(), 'long', true));
|
|
116
117
|
|
|
117
118
|
// PUSH THE NEWLY CREATED FILE TO THE CREATE FILES ARRAY VARIABLE
|
|
@@ -127,6 +128,10 @@ const DevaBuddy = new Deva({
|
|
|
127
128
|
const { copy_from, copy_to } = this.vars.paths;
|
|
128
129
|
if (!copy_from) return console.log('no files to copy from');
|
|
129
130
|
if (!copy_to) return console.log('no files to copy to');
|
|
131
|
+
|
|
132
|
+
// stop when the Deva folder is already there so Buddy never writes over existing work
|
|
133
|
+
if (this.lib.fs.existsSync(copy_to)) return this.prompt(`${this.vars.messages.exists} ${copy_to}`);
|
|
134
|
+
|
|
130
135
|
console.log(this.vars.messages.que_heading);
|
|
131
136
|
console.log(`โช fr: ${copy_from}`);
|
|
132
137
|
console.log(`โช to: ${copy_to}`);
|
|
@@ -168,15 +173,23 @@ const DevaBuddy = new Deva({
|
|
|
168
173
|
default: this.lib.path.join(process.cwd(), 'devas'), // set the default path for the question
|
|
169
174
|
});
|
|
170
175
|
|
|
171
|
-
// ask each question
|
|
172
|
-
|
|
176
|
+
// ask each question and keep the default when the answer is blank
|
|
177
|
+
// lines from a pipe wait in the line queue so bots can send all answers at once
|
|
178
|
+
const piped = !process.stdin.isTTY;
|
|
179
|
+
const rl = readline.createInterface({input: process.stdin, output: process.stdout, terminal: !piped});
|
|
180
|
+
const lines = rl[Symbol.asyncIterator]();
|
|
173
181
|
const answers = {};
|
|
174
182
|
for (const question of this.vars.questions) {
|
|
175
183
|
const def = question.default ? ` (${question.default})` : '';
|
|
176
|
-
|
|
184
|
+
process.stdout.write(`${question.message}${def}: `);
|
|
185
|
+
const {value, done} = await lines.next();
|
|
186
|
+
const answer = done ? '' : value;
|
|
187
|
+
if (piped) process.stdout.write(`${answer}\n`);
|
|
177
188
|
answers[question.name] = answer.trim() || question.default || '';
|
|
178
189
|
}
|
|
179
190
|
rl.close();
|
|
191
|
+
// stop when the key or name is missing so incomplete pipes do not build a Deva
|
|
192
|
+
if (!answers.key || !answers.name) return this.prompt(this.vars.messages.incomplete);
|
|
180
193
|
|
|
181
194
|
// set the options variable to load what the BUDDY was configured with.
|
|
182
195
|
this.vars.paths = {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "::name:: Client File",
|
|
3
|
+
"describe": "Stub client for testing ::name::. Replace with your own client file and add it to .gitignore.",
|
|
4
|
+
"copyright": "Copyright ยฉ::year:: ::owner::. All rights reserved.",
|
|
5
|
+
"DATA": {
|
|
6
|
+
"id": "::id::",
|
|
7
|
+
"key": "client",
|
|
8
|
+
"VLA": ::vla-data::,
|
|
9
|
+
"prompt": {
|
|
10
|
+
"emoji": "๐งช",
|
|
11
|
+
"text": "client",
|
|
12
|
+
"colors": {
|
|
13
|
+
"label": {"R": 2, "G": 229, "B": 77},
|
|
14
|
+
"text": {"R": 2, "G": 229, "B": 77}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"profile": {
|
|
18
|
+
"id": "::id::",
|
|
19
|
+
"name": "::owner::",
|
|
20
|
+
"describe": "Test client for ::name::",
|
|
21
|
+
"lang": "en",
|
|
22
|
+
"locale": "en-US",
|
|
23
|
+
"currency": "USD"
|
|
24
|
+
},
|
|
25
|
+
"features": {}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/buddy/template/index.js
CHANGED
|
@@ -21,13 +21,7 @@ const info = {
|
|
|
21
21
|
name: pkg.name,
|
|
22
22
|
version: pkg.version,
|
|
23
23
|
author: pkg.author,
|
|
24
|
-
describe: pkg.description,
|
|
25
24
|
dir: __dirname,
|
|
26
|
-
url: pkg.homepage,
|
|
27
|
-
git: pkg.repository.url,
|
|
28
|
-
bugs: pkg.bugs.url,
|
|
29
|
-
license: pkg.license,
|
|
30
|
-
copyright: pkg.copyright,
|
|
31
25
|
VLA: pkg.VLA,
|
|
32
26
|
};
|
|
33
27
|
|
|
@@ -1,5 +1,57 @@
|
|
|
1
|
-
// ::name::
|
|
1
|
+
// ::name:: Test File
|
|
2
2
|
// Copyright ยฉ::year:: ::owner::; All rights reserved.
|
|
3
3
|
// Owner Signature Required For Lawful Use.
|
|
4
4
|
// Distributed under VLA:::vla:: LICENSE.md
|
|
5
5
|
// ::date::
|
|
6
|
+
|
|
7
|
+
// run these right after Deva Buddy builds ::name:: to make sure it is clean before you start building
|
|
8
|
+
import test from 'node:test';
|
|
9
|
+
import assert from 'node:assert/strict';
|
|
10
|
+
import Deva from '@indra.ai/deva';
|
|
11
|
+
import ::key-upper:: from './index.js';
|
|
12
|
+
import Client from './data/client.json' with {type:'json'};
|
|
13
|
+
import Data from './data/index.json' with {type:'json'};
|
|
14
|
+
|
|
15
|
+
const STAGES = ['start', 'enter', 'done', 'ready'];
|
|
16
|
+
const TIERS = ['md5', 'sha256', 'sha512'];
|
|
17
|
+
const PLACEHOLDER = /::[a-z-]+::/;
|
|
18
|
+
const client = () => structuredClone(Client.DATA);
|
|
19
|
+
|
|
20
|
+
test('::key:: builds as a Deva and waits offline before init', async () => {
|
|
21
|
+
assert.ok(::key-upper:: instanceof Deva, 'the export is a Deva');
|
|
22
|
+
assert.equal(await ::key-upper::.stop(), ::key-upper::._messages.offline, 'stop before init answers offline');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('::key:: data has no placeholders left from the build', () => {
|
|
26
|
+
assert.doesNotMatch(JSON.stringify(Data), PLACEHOLDER, 'data/index.json');
|
|
27
|
+
assert.doesNotMatch(JSON.stringify(Client), PLACEHOLDER, 'data/client.json');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('::key:: comes online and walks to ready', async () => {
|
|
31
|
+
const prompts = [];
|
|
32
|
+
::key-upper::.listen('devacore:prompt', packet => prompts.push(packet.text));
|
|
33
|
+
const data = await ::key-upper::.init(client());
|
|
34
|
+
for (const k of STAGES) assert.equal(typeof data[k], 'number', `${k} timestamp`);
|
|
35
|
+
assert.ok(data.start <= data.enter && data.enter <= data.done && data.done <= data.ready, 'stages in order');
|
|
36
|
+
assert.equal(typeof data.id.uid, 'string', 'uid');
|
|
37
|
+
for (const t of TIERS) assert.equal(typeof data[t], 'string', `${t} hash`);
|
|
38
|
+
assert.ok(prompts.includes(::key-upper::.vars.messages.ready), 'onReady prompts the ready message');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('::key:: agent matches the build', () => {
|
|
42
|
+
const agent = ::key-upper::.agent();
|
|
43
|
+
assert.equal(agent.key, '::key::');
|
|
44
|
+
assert.equal(agent.profile.name, '::name::');
|
|
45
|
+
assert.equal(agent.profile.owner, '::owner::');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('::key:: utils answer with trimmed text', () => {
|
|
49
|
+
const {translate, parse, process} = ::key-upper::.utils;
|
|
50
|
+
for (const util of [translate, parse, process]) assert.equal(util(' hello '), 'hello');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('::key:: stops through the full chain', async () => {
|
|
54
|
+
const data = await ::key-upper::.stop();
|
|
55
|
+
assert.equal(data.key, 'shutdown', 'the chain ends on shutdown');
|
|
56
|
+
assert.equal(data.value, '::key::');
|
|
57
|
+
});
|
package/index.js
CHANGED
|
@@ -187,6 +187,8 @@ class Deva {
|
|
|
187
187
|
|
|
188
188
|
// set the assigned listeners for the agent.
|
|
189
189
|
for (let listener in this.listeners) { // loop over the listeners
|
|
190
|
+
const existing = this._bound.get(listener); // already on the bus from an earlier listen
|
|
191
|
+
if (existing) this.events.removeListener(listener, existing); // take the old wrapper off first
|
|
190
192
|
const handler = packet => this.listeners[listener](packet);
|
|
191
193
|
this._bound.set(listener, handler);
|
|
192
194
|
this.events.on(listener, handler);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "31711622713594414221",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.65.
|
|
4
|
+
"version": "1.65.21",
|
|
5
5
|
"description": "Deva Core a Vedic-based Event Driven Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "VLA:31711622713594414221 LICENSE.md",
|
|
@@ -52,6 +52,13 @@
|
|
|
52
52
|
"demo": "node tests",
|
|
53
53
|
"buddy": "node buddy/index.js"
|
|
54
54
|
},
|
|
55
|
+
"bin": {
|
|
56
|
+
"deva-buddy": "buddy/index.js"
|
|
57
|
+
},
|
|
58
|
+
"exports": {
|
|
59
|
+
".": "./index.js",
|
|
60
|
+
"./*": "./*"
|
|
61
|
+
},
|
|
55
62
|
"repository": {
|
|
56
63
|
"type": "git",
|
|
57
64
|
"url": "git+https://github.com/indraai/deva.git"
|