@indra.ai/deva.vector 0.0.6 → 0.0.8

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,61 +1,69 @@
1
1
  export default {
2
2
  async vector(packet) {
3
- this.state('set', `vector:transport:${packet.id}`);
3
+ const vector = await this.methods.sign('vector', 'default', packet);
4
+ return vector;
5
+ },
6
+
7
+ async sign(key, type, packet) {
8
+ this.state('set', `${key}:sign:${type}:${packet.id}`);
4
9
  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
10
+
11
+ this.prompt(`sign ${key}`);
12
+
13
+ this.zone(key, `${key}:sign:${type}:${transport}`); // set the zone
14
+ this.feature(key, `${key}:sign:${type}:${transport}`); // set the feature
15
+ this.context(key, `${key}:sign:${type}:${transport}`); // set the agent context to proxy.
16
+ this.action('method', `${key}:sign:${type}:${transport}`); // set the action method to proxy.
17
+
18
+ this.state('set', `${key}:sign:${type}:uid:${transport}`); //set the uid state
19
+ const uid = this.lib.uid(true); // The UID
20
+
21
+ this.state('set', `${key}:sign:${type}:time:${transport}`); //set the time state
14
22
  const time = Date.now(); // current timestamp
15
- this.state('created', `created:${transport}`); //set the uid state for the proxy
23
+
24
+ this.state('created', `${key}:sign:${type}:created:${transport}`); //set the created state
16
25
  const created = this.lib.formatDate(time, 'long', true); // Formatted created date.
17
26
 
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.
27
+ this.state('set', `${key}:sign:${type}:concerns:${transport}`); //set the concerns
28
+ const {concerns} = this[key](); // load the Guard profile
21
29
 
22
- this.state('set', `vector:agent:${transport}`); //set the agent state for the proxy
30
+ this.state('set', `${key}:sign:${type}:agent:${transport}`); //set the agent state
23
31
  const agent = this.agent(); // the agent processing the proxy
24
32
 
25
- this.state('set', `vector:client:${transport}`); //set the client state for the proxy
33
+ this.state('set', `${key}:sign:${type}:client:${transport}`); //set the client state
26
34
  const client = this.client(); // the client requesting the proxy
27
35
 
28
- this.state('set', `vector:meta:${transport}`); //set the meta state for the proxy
36
+ this.state('set', `${key}:sign:${type}:meta:${transport}`); //set the meta state
29
37
  const {meta} = packet.q; // set the meta information from the packet question.
30
38
 
31
- this.state('set', `vector:params:${transport}`); //set the meta state for the proxy
39
+ this.state('set', `${key}:sign:${type}:params:${transport}`); //set the meta state
32
40
  const {params} = meta; // set params from the meta information.
33
41
 
34
- this.state('set', `vector:opts:${transport}`); //set the opts state for the proxy
42
+ this.state('set', `${key}:sign:${type}:opts:${transport}`); //set the opts state
35
43
  const opts = this.lib.copy(params); // copy the params and set as opts.
36
44
 
37
- this.state('set', `vector:command:${transport}`); //set the opts state for the proxy
45
+ this.state('set', `${key}:sign:${type}:command:${transport}`); //set the opts state
38
46
  const command = opts.shift(); // extract the command first array item out of opts.
39
47
 
40
- this.state('set', `vector:message:${transport}`); //set the message state for the proxy
48
+ this.state('set', `${key}:sign:${type}:message:${transport}`); //set the message state
41
49
  const message = packet.q.text; // set packet.q.text as the message of the proxy.
42
50
 
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.
51
+ this.state('set', `${key}:sign:${type}:write:${transport}`); //set the message state
52
+ const write = `OM:${key.toUpperCase()}:${client.profile.write.split(' ').join(':').toUpperCase()}`; // set proxy write string.
45
53
 
46
54
  // hash the agent profile for security
47
- this.state('hash', `vector:agent:hash:${transport}`);
55
+ this.state('hash', `${key}:sign:${type}:write:${transport}`);
48
56
  const agent_hash = this.lib.hash(agent, 'sha256');
49
57
 
50
58
  // hash the agent profile for security
51
- this.state('hash', `vector:client:hash:${transport}`);
59
+ this.state('hash', `${key}:sign:${type}:write:${transport}`);
52
60
  const client_hash = this.lib.hash(client, 'sha256');
53
61
 
54
62
  // 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');
63
+ this.state('hash', `${key}:sign:${type}:write:${transport}`);
64
+ const token = this.lib.hash(`${key} ${client.profile.token} ${transport}`, 'sha256');
57
65
 
58
- this.state('set', `vector:data:${transport}`); // set the state to set data
66
+ this.state('set', `${key}:sign:${type}:write:${transport}`); // set the state to set data
59
67
  // data packet
60
68
  const data = {
61
69
  uid,
@@ -65,8 +73,8 @@ export default {
65
73
  message,
66
74
  caseid: client.profile.caseid,
67
75
  opts: opts.length? `:${opts.join(':')}` : '',
68
- agent: agent_profile,
69
- client: client_profile,
76
+ agent: agent_hash,
77
+ client: client_hash,
70
78
  name: client.profile.name,
71
79
  emojis: client.profile.emojis,
72
80
  company: client.profile.company,
@@ -80,49 +88,106 @@ export default {
80
88
  copyright: client.profile.copyright,
81
89
  };
82
90
 
83
- this.state('hash', `md5:${transport}`); // set state to secure hashing
91
+ this.state('hash', `${key}:sign:${type}:md5:${transport}`); // set state to secure hashing
84
92
  data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
85
93
 
86
- this.state('hash', `sha256:${transport}`); // set state to secure hashing
94
+ this.state('hash', `${key}:sign:${type}:sha256:${transport}`); // set state to secure hashing
87
95
  data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
88
96
 
89
- this.state('hash', `sha512:${transport}`); // set state to secure hashing
97
+ this.state('hash', `${key}:sign:${type}:sha512:${transport}`); // set state to secure hashing
90
98
  data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
91
99
 
92
100
  // Text data that is joined by line breaks and then trimmed.
93
- this.state('set', `text:${transport}`); // set state to text for output formatting.
101
+ this.state('set', `${key}:sign:${type}:text:${transport}`); // set state to text for output formatting.
94
102
  const text = [
95
- `:::`,
103
+ `::::`,
96
104
  `::BEGIN:${data.write}:${data.transport}`,
97
- `#VectorGuardProxy${data.opts} ${data.message}`,
98
- `::begin:vector:guard:proxy:${transport}:${data.emojis}`,
105
+ `#${key}:${type}${data.opts} ${data.message}`,
106
+ `::begin:${key}:${transport}:${data.emojis}`,
99
107
  `transport: ${data.transport}`,
100
108
  `time: ${data.time}`,
101
109
  `caseid: ${data.caseid}`,
102
110
  `agent: ${data.agent}`,
103
111
  `client: ${data.client}`,
112
+ `token: ${data.token}`,
104
113
  `name: ${data.name}`,
105
114
  `company: ${data.company}`,
106
- `token: ${data.token}`,
107
115
  `warning: ${data.warning}`,
108
116
  `created: ${data.created}`,
109
117
  `copyright: ${data.copyright}`,
110
118
  `md5: ${data.md5}`,
111
119
  `sha256: ${data.sha256}`,
112
120
  `sha512: ${data.sha512}`,
113
- `::end:vector:guard:proxy:${data.transport}:${data.emojis}`,
121
+ `::end:${key}:${type}${data.transport}:${data.emojis}`,
114
122
  `::END:${data.write}:${data.transport}`,
123
+ `::::`
115
124
  ].join('\n').trim();
116
125
 
117
126
  // 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
127
+ this.action('question', `${key}:sign:${type}:write:${transport}`); // action set to feecting parse
119
128
  const feecting = await this.question(`${this.askChr}feecting parse:${transport} ${text}`); // parse with feecting agent.
120
129
 
121
- this.state('return', `proxy:${transport}`); // set the state to return proxy
130
+ this.state('return', `${key}:sign:${type}:return:${transport}`); // set the state to return proxy
122
131
  return {
123
132
  text: feecting.a.text,
124
133
  html: feecting.a.html,
125
134
  data,
126
135
  }
136
+
127
137
  },
138
+
139
+ async echo(key, type, opts) {
140
+ const {id, agent, client, text, created, md5, sha256, sha512} = opts;
141
+
142
+ this.state('set', `${key}:echo:${type}:time:${id}`);
143
+ const echo_time = Date.now();
144
+
145
+ this.action('func', `${key}:echo:${type}:${id}`);
146
+
147
+ this.state('hash', `${key}:echo:${type}:hash:message:${id}`);
148
+ const message_hash = this.lib.hash(text || 'blank', 'sha256');
149
+
150
+ this.state('hash', `${key}:echo:${type}:hash:agent:${id}`);
151
+ const agent_hash = this.lib.hash(agent, 'sha256');
152
+
153
+ this.state('hash', `${key}:echo:${type}:hash:client:${id}`);
154
+ const client_hash = this.lib.hash(client, 'sha256');
155
+
156
+ this.state('set', `${key}:echo:${type}:keystr:${id}`);
157
+ const keystr = `${key.toUpperCase()}:${type.toUpperCase()}:${id}`;
158
+
159
+ this.state('set', `${key}:echo:${type}:data:${id}`);
160
+ const echo_data = [
161
+ `::::`,
162
+ `::BEGIN:${keystr}`,
163
+ `key: ${key}`,
164
+ `type: ${type}`,
165
+ `transport: ${id}`,
166
+ `created: ${created}`,
167
+ `echo: ${echo_time}`,
168
+ `message: ${message_hash}`,
169
+ `agent: ${agent_hash}`,
170
+ `client: ${client_hash}`,
171
+ `md5: ${md5}`,
172
+ `sha256:${sha256}`,
173
+ `sha512:${sha512}`,
174
+ `::END:${keystr}`,
175
+ '::::',
176
+ ].join('\n');
177
+
178
+ // stub for later features right now just echo into the system process for SIGINT monitoring.
179
+ const echo = this.lib.spawn('echo', [echo_data])
180
+ echo.stdout.on('data', data => {
181
+ this.state('data', `${key}:echo:${type}:stdout:${id}`);
182
+ });
183
+ echo.stderr.on('data', err => {
184
+ this.state('error', `${key}:echo:${type}:stderr:${id}`);
185
+ this.error(err, opts);
186
+ });
187
+ echo.on('close', data => {
188
+ this.state('close', `${key}:echo:${type}:close:${id}`);
189
+ });
190
+ this.state('return', `${key}:echo:${type}:return:${id}`);
191
+ return echo_data;
192
+ }
128
193
  };
package/index.js CHANGED
@@ -35,54 +35,15 @@ const VECTOR = new Deva({
35
35
  },
36
36
  listeners: {
37
37
  'devacore:question'(packet) {
38
- console.log(packet);
39
- this.func.echo('question', packet.q);
38
+ const echo = this.methods.echo('vector', 'question', packet.q);
40
39
  },
41
40
  'devacore:answer'(packet) {
42
- this.func.echo('answer', packet.a);
41
+ const echo = this.methods.echo('vector', 'answer', packet.a);
43
42
  }
44
43
  },
45
44
  modules: {},
46
45
  devas: {},
47
- func: {
48
- echo(type, opts) {
49
- const {id, agent, client, text, md5, sha256, sha512} = opts;
50
- const created = Date.now();
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
- `transport: ${id}`,
58
- `created: ${created}`,
59
- `message: ${text}`,
60
- `agent: ${this.lib.hash(agent, 'sha256')}`,
61
- `client: ${this.lib.hash(client, 'sha256')}`,
62
- `md5: ${md5}`,
63
- `sha256:${sha256}`,
64
- `sha512:${sha512}`,
65
- `::end:vector:${type}:${id}`,
66
- '::::',
67
- ].join('\n');
68
-
69
- // stub for later features right now just echo into the system process for SIGINT monitoring.
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
- });
75
- echo.stderr.on('data', err => {
76
- this.state('error', `echo:stderr:${type}:${id}`);
77
- this.error(err, opts);
78
- });
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
- }
85
- },
46
+ func: {},
86
47
  methods: {},
87
48
  onReady(data, resolve) {
88
49
  this.prompt(this.vars.messages.ready);
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.6",
4
+ "version": "0.0.8",
5
5
  "author": "Quinn Michaels",
6
6
  "license": "MIT",
7
7
  "copyright": "2025",