@indra.ai/deva.vector 0.0.4 → 0.0.6

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 (3) hide show
  1. package/feature/methods.js +128 -0
  2. package/index.js +30 -21
  3. package/package.json +11 -11
@@ -0,0 +1,128 @@
1
+ export default {
2
+ async vector(packet) {
3
+ this.state('set', `vector:transport:${packet.id}`);
4
+ const transport = packet.id; // set the transport id from the packet id.
5
+
6
+ this.zone('vector', transport); // set the current zone to guard
7
+ this.feature('vector', transport); // set the Guard feature.
8
+ this.context('proxy', transport); // set the agent context to proxy.
9
+ this.action('method', `proxy:${transport}`); // set the action method to proxy.
10
+
11
+ this.state('set', `uid:${transport}`); //set the uid state for the proxy
12
+ const uid = this.lib.uid(true); // The UID for the proxy
13
+ this.state('set', `time:${transport}`); //set the time state for the proxy
14
+ const time = Date.now(); // current timestamp
15
+ this.state('created', `created:${transport}`); //set the uid state for the proxy
16
+ const created = this.lib.formatDate(time, 'long', true); // Formatted created date.
17
+
18
+ this.state('set', `vector:${transport}`); //set the guard state for the proxy
19
+ const vector = this.guard(); // load the Guard profile
20
+ const {concerns} = vector; // load concerns from client guard profile.
21
+
22
+ this.state('set', `vector:agent:${transport}`); //set the agent state for the proxy
23
+ const agent = this.agent(); // the agent processing the proxy
24
+
25
+ this.state('set', `vector:client:${transport}`); //set the client state for the proxy
26
+ const client = this.client(); // the client requesting the proxy
27
+
28
+ this.state('set', `vector:meta:${transport}`); //set the meta state for the proxy
29
+ const {meta} = packet.q; // set the meta information from the packet question.
30
+
31
+ this.state('set', `vector:params:${transport}`); //set the meta state for the proxy
32
+ const {params} = meta; // set params from the meta information.
33
+
34
+ this.state('set', `vector:opts:${transport}`); //set the opts state for the proxy
35
+ const opts = this.lib.copy(params); // copy the params and set as opts.
36
+
37
+ this.state('set', `vector:command:${transport}`); //set the opts state for the proxy
38
+ const command = opts.shift(); // extract the command first array item out of opts.
39
+
40
+ this.state('set', `vector:message:${transport}`); //set the message state for the proxy
41
+ const message = packet.q.text; // set packet.q.text as the message of the proxy.
42
+
43
+ this.state('set', `vector:write:${transport}`); //set the message state for the proxy
44
+ const write = `OM:VECTOR:${client.profile.write.split(' ').join(':').toUpperCase()}`; // set proxy write string.
45
+
46
+ // hash the agent profile for security
47
+ this.state('hash', `vector:agent:hash:${transport}`);
48
+ const agent_hash = this.lib.hash(agent, 'sha256');
49
+
50
+ // hash the agent profile for security
51
+ this.state('hash', `vector:client:hash:${transport}`);
52
+ const client_hash = this.lib.hash(client, 'sha256');
53
+
54
+ // hash the agent profile for security
55
+ this.state('hash', `vector:token:${transport}`);
56
+ const token = this.lib.hash(`VECTOR ${client.profile.token} ${transport}`, 'sha256');
57
+
58
+ this.state('set', `vector:data:${transport}`); // set the state to set data
59
+ // data packet
60
+ const data = {
61
+ uid,
62
+ transport,
63
+ time,
64
+ write,
65
+ message,
66
+ caseid: client.profile.caseid,
67
+ opts: opts.length? `:${opts.join(':')}` : '',
68
+ agent: agent_profile,
69
+ client: client_profile,
70
+ name: client.profile.name,
71
+ emojis: client.profile.emojis,
72
+ company: client.profile.company,
73
+ warning: client.profile.warning,
74
+ token,
75
+ concerns,
76
+ meta,
77
+ params,
78
+ command,
79
+ created,
80
+ copyright: client.profile.copyright,
81
+ };
82
+
83
+ this.state('hash', `md5:${transport}`); // set state to secure hashing
84
+ data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
85
+
86
+ this.state('hash', `sha256:${transport}`); // set state to secure hashing
87
+ data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
88
+
89
+ this.state('hash', `sha512:${transport}`); // set state to secure hashing
90
+ data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
91
+
92
+ // Text data that is joined by line breaks and then trimmed.
93
+ this.state('set', `text:${transport}`); // set state to text for output formatting.
94
+ const text = [
95
+ `:::`,
96
+ `::BEGIN:${data.write}:${data.transport}`,
97
+ `#VectorGuardProxy${data.opts} ${data.message}`,
98
+ `::begin:vector:guard:proxy:${transport}:${data.emojis}`,
99
+ `transport: ${data.transport}`,
100
+ `time: ${data.time}`,
101
+ `caseid: ${data.caseid}`,
102
+ `agent: ${data.agent}`,
103
+ `client: ${data.client}`,
104
+ `name: ${data.name}`,
105
+ `company: ${data.company}`,
106
+ `token: ${data.token}`,
107
+ `warning: ${data.warning}`,
108
+ `created: ${data.created}`,
109
+ `copyright: ${data.copyright}`,
110
+ `md5: ${data.md5}`,
111
+ `sha256: ${data.sha256}`,
112
+ `sha512: ${data.sha512}`,
113
+ `::end:vector:guard:proxy:${data.transport}:${data.emojis}`,
114
+ `::END:${data.write}:${data.transport}`,
115
+ ].join('\n').trim();
116
+
117
+ // send the text data to #feecting to parse and return valid text, html, and data.
118
+ this.action('question', `feecting:parse:${transport}`); // action set to feecting parse
119
+ const feecting = await this.question(`${this.askChr}feecting parse:${transport} ${text}`); // parse with feecting agent.
120
+
121
+ this.state('return', `proxy:${transport}`); // set the state to return proxy
122
+ return {
123
+ text: feecting.a.text,
124
+ html: feecting.a.html,
125
+ data,
126
+ }
127
+ },
128
+ };
package/index.js CHANGED
@@ -5,8 +5,6 @@ import Deva from '@indra.ai/deva';
5
5
  import pkg from './package.json' with {type:'json'};
6
6
  const {agent,vars} = pkg.data;
7
7
 
8
- import {exec, spawn} from 'node:child_process';
9
-
10
8
  // set the __dirname
11
9
  import {dirname} from 'node:path';
12
10
  import {fileURLToPath} from 'node:url';
@@ -37,42 +35,53 @@ const VECTOR = new Deva({
37
35
  },
38
36
  listeners: {
39
37
  'devacore:question'(packet) {
40
- this.func.echostr(packet.q);
38
+ console.log(packet);
39
+ this.func.echo('question', packet.q);
41
40
  },
42
41
  'devacore:answer'(packet) {
43
- this.func.echostr(packet.a);
42
+ this.func.echo('answer', packet.a);
44
43
  }
45
44
  },
46
45
  modules: {},
47
46
  devas: {},
48
47
  func: {
49
- echostr(opts) {
50
- const {id, agent, client, md5, sha256, sha512} = opts;
48
+ echo(type, opts) {
49
+ const {id, agent, client, text, md5, sha256, sha512} = opts;
51
50
  const created = Date.now();
52
-
53
- this.action('func', `echostr:${id}`);
54
- this.state('set', `echostr:${id}`);
55
- const echostr = [
56
- `::begin:vector:${id}`,
51
+
52
+ this.action('func', `echo:${type}:${id}`);
53
+ this.state('set', `echo:data:${type}:${id}`);
54
+
55
+ const echo_data = [
56
+ `\n::begin:vector:${type}:${id}`,
57
57
  `transport: ${id}`,
58
- `client: ${client.profile.id}`,
59
- `agent: ${agent.profile.id}`,
60
58
  `created: ${created}`,
59
+ `message: ${text}`,
60
+ `agent: ${this.lib.hash(agent, 'sha256')}`,
61
+ `client: ${this.lib.hash(client, 'sha256')}`,
61
62
  `md5: ${md5}`,
62
63
  `sha256:${sha256}`,
63
64
  `sha512:${sha512}`,
64
- `::end:vector:${id}`,
65
- ].join('\nliek');
66
-
65
+ `::end:vector:${type}:${id}`,
66
+ '::::',
67
+ ].join('\n');
68
+
67
69
  // stub for later features right now just echo into the system process for SIGINT monitoring.
68
- const echo = spawn('echo', [echostr])
70
+ const echo = this.lib.spawn('echo', [echo_data])
71
+ echo.stdout.on('data', data => {
72
+ console.log(data.toString());
73
+ this.state('data', `echo:stdout:${type}:${id}`);
74
+ });
69
75
  echo.stderr.on('data', err => {
76
+ this.state('error', `echo:stderr:${type}:${id}`);
70
77
  this.error(err, opts);
71
78
  });
72
-
73
- this.state('return', `echostr:${id}`);
74
- return echostr;
75
- }
79
+ echo.on('close', data => {
80
+ this.state('close', `echo:close:${type}:${id}`);
81
+ });
82
+ this.state('return', `echo:return:${type}:${id}`);
83
+ return echo_data;
84
+ }
76
85
  },
77
86
  methods: {},
78
87
  onReady(data, resolve) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "33555f8a-707d-4fc9-ae19-ba09036473d4",
3
3
  "name": "@indra.ai/deva.vector",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "author": "Quinn Michaels",
6
6
  "license": "MIT",
7
7
  "copyright": "2025",
@@ -26,9 +26,9 @@
26
26
  "bugs": {
27
27
  "url": "https://github.com/indraai/deva.vector/issues"
28
28
  },
29
- "homepage": "https://deva.space/devas/wall",
29
+ "homepage": "https://deva.space/devas/vector",
30
30
  "dependencies": {
31
- "@indra.ai/deva": "^1.5.43"
31
+ "@indra.ai/deva": "^1.5.46"
32
32
  },
33
33
  "data": {
34
34
  "agent": {
@@ -94,14 +94,14 @@
94
94
  "history": []
95
95
  },
96
96
  "context": {
97
- "uid": "Wall is creating a uid",
98
- "status": "Wall is viewing the status",
99
- "help": "Wall is viewing the help",
100
- "artist": "Wall creating",
101
- "live": "Wall livechat",
102
- "ask": "Wall asking",
103
- "reply": "Wall reply",
104
- "comment": "Wall comment"
97
+ "uid": "Vector is creating a uid",
98
+ "status": "Vector is viewing the status",
99
+ "help": "Vector is viewing the help",
100
+ "artist": "Vector creating",
101
+ "live": "Vector livechat",
102
+ "ask": "Vector asking",
103
+ "reply": "Vector reply",
104
+ "comment": "Vector comment"
105
105
  }
106
106
  }
107
107
  }