@indra.ai/deva.vector 0.0.6 → 0.0.7
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/feature/methods.js +59 -12
- package/index.js +3 -42
- package/package.json +1 -1
package/feature/methods.js
CHANGED
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
|
|
6
6
|
this.zone('vector', transport); // set the current zone to guard
|
|
7
7
|
this.feature('vector', transport); // set the Guard feature.
|
|
8
|
-
this.context('
|
|
8
|
+
this.context('vector', transport); // set the agent context to proxy.
|
|
9
9
|
this.action('method', `proxy:${transport}`); // set the action method to proxy.
|
|
10
10
|
|
|
11
11
|
this.state('set', `uid:${transport}`); //set the uid state for the proxy
|
|
@@ -65,8 +65,8 @@ export default {
|
|
|
65
65
|
message,
|
|
66
66
|
caseid: client.profile.caseid,
|
|
67
67
|
opts: opts.length? `:${opts.join(':')}` : '',
|
|
68
|
-
agent:
|
|
69
|
-
client:
|
|
68
|
+
agent: agent_hash,
|
|
69
|
+
client: client_hash,
|
|
70
70
|
name: client.profile.name,
|
|
71
71
|
emojis: client.profile.emojis,
|
|
72
72
|
company: client.profile.company,
|
|
@@ -80,30 +80,30 @@ export default {
|
|
|
80
80
|
copyright: client.profile.copyright,
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
this.state('hash', `md5:${transport}`); // set state to secure hashing
|
|
83
|
+
this.state('hash', `vector:md5:${transport}`); // set state to secure hashing
|
|
84
84
|
data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
|
|
85
85
|
|
|
86
|
-
this.state('hash', `sha256:${transport}`); // set state to secure hashing
|
|
86
|
+
this.state('hash', `vector:sha256:${transport}`); // set state to secure hashing
|
|
87
87
|
data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
|
|
88
88
|
|
|
89
|
-
this.state('hash', `sha512:${transport}`); // set state to secure hashing
|
|
89
|
+
this.state('hash', `vector:sha512:${transport}`); // set state to secure hashing
|
|
90
90
|
data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
|
|
91
91
|
|
|
92
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.
|
|
93
|
+
this.state('set', `vector:text:${transport}`); // set state to text for output formatting.
|
|
94
94
|
const text = [
|
|
95
|
-
|
|
95
|
+
`::::`,
|
|
96
96
|
`::BEGIN:${data.write}:${data.transport}`,
|
|
97
|
-
`#
|
|
97
|
+
`#Vector${data.opts} ${data.message}`,
|
|
98
98
|
`::begin:vector:guard:proxy:${transport}:${data.emojis}`,
|
|
99
99
|
`transport: ${data.transport}`,
|
|
100
100
|
`time: ${data.time}`,
|
|
101
101
|
`caseid: ${data.caseid}`,
|
|
102
102
|
`agent: ${data.agent}`,
|
|
103
103
|
`client: ${data.client}`,
|
|
104
|
+
`token: ${data.token}`,
|
|
104
105
|
`name: ${data.name}`,
|
|
105
106
|
`company: ${data.company}`,
|
|
106
|
-
`token: ${data.token}`,
|
|
107
107
|
`warning: ${data.warning}`,
|
|
108
108
|
`created: ${data.created}`,
|
|
109
109
|
`copyright: ${data.copyright}`,
|
|
@@ -112,17 +112,64 @@ export default {
|
|
|
112
112
|
`sha512: ${data.sha512}`,
|
|
113
113
|
`::end:vector:guard:proxy:${data.transport}:${data.emojis}`,
|
|
114
114
|
`::END:${data.write}:${data.transport}`,
|
|
115
|
+
`::::`
|
|
115
116
|
].join('\n').trim();
|
|
116
117
|
|
|
117
118
|
// 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
|
+
this.action('question', `vector:feecting:parse:${transport}`); // action set to feecting parse
|
|
119
120
|
const feecting = await this.question(`${this.askChr}feecting parse:${transport} ${text}`); // parse with feecting agent.
|
|
120
121
|
|
|
121
|
-
this.state('return', `
|
|
122
|
+
this.state('return', `vector:${transport}`); // set the state to return proxy
|
|
122
123
|
return {
|
|
123
124
|
text: feecting.a.text,
|
|
124
125
|
html: feecting.a.html,
|
|
125
126
|
data,
|
|
126
127
|
}
|
|
127
128
|
},
|
|
129
|
+
echo(key, type, opts) {
|
|
130
|
+
const {id, agent, client, text, created, md5, sha256, sha512} = opts;
|
|
131
|
+
|
|
132
|
+
this.prompt('ECHO ECHO ECHO')
|
|
133
|
+
this.state('set', `${key}:echo:${type}:time:${id}`);
|
|
134
|
+
const echo_time = Date.now();
|
|
135
|
+
|
|
136
|
+
this.action('func', `${key}:echo:${type}:${id}`);
|
|
137
|
+
|
|
138
|
+
this.state('set', `${key}:echo:${type}:keystr:${id}`);
|
|
139
|
+
const keystr = `${key.toUpperCase()}:${type.toUpperCase()}:${id}`;
|
|
140
|
+
|
|
141
|
+
this.state('set', `${key}:echo:${type}:data:${id}`);
|
|
142
|
+
const echo_data = [
|
|
143
|
+
`::::`
|
|
144
|
+
`::BEGIN:${keystr}`,
|
|
145
|
+
`key: ${key}`,
|
|
146
|
+
`type: ${type}`,
|
|
147
|
+
`transport: ${id}`,
|
|
148
|
+
`created: ${created}`,
|
|
149
|
+
`echo: ${echo_time}`,
|
|
150
|
+
`message: ${text}`,
|
|
151
|
+
`agent: ${this.lib.hash(agent, 'sha256')}`,
|
|
152
|
+
`client: ${this.lib.hash(client, 'sha256')}`,
|
|
153
|
+
`md5: ${md5}`,
|
|
154
|
+
`sha256:${sha256}`,
|
|
155
|
+
`sha512:${sha512}`,
|
|
156
|
+
`::END:${keystr}`,
|
|
157
|
+
'::::',
|
|
158
|
+
].join('\n');
|
|
159
|
+
|
|
160
|
+
// stub for later features right now just echo into the system process for SIGINT monitoring.
|
|
161
|
+
const echo = this.lib.spawn('echo', [echo_data])
|
|
162
|
+
echo.stdout.on('data', data => {
|
|
163
|
+
this.state('data', `${key}:echo:${type}:stdout:${id}`);
|
|
164
|
+
});
|
|
165
|
+
echo.stderr.on('data', err => {
|
|
166
|
+
this.state('error', `${key}:echo:${type}:stderr:${id}`);
|
|
167
|
+
this.error(err, opts);
|
|
168
|
+
});
|
|
169
|
+
echo.on('close', data => {
|
|
170
|
+
this.state('close', `${key}:echo:${type}:close:${id}`);
|
|
171
|
+
});
|
|
172
|
+
this.state('return', `${key}:echo:${type}:return:${id}`);
|
|
173
|
+
return echo_data;
|
|
174
|
+
}
|
|
128
175
|
};
|
package/index.js
CHANGED
|
@@ -35,54 +35,15 @@ const VECTOR = new Deva({
|
|
|
35
35
|
},
|
|
36
36
|
listeners: {
|
|
37
37
|
'devacore:question'(packet) {
|
|
38
|
-
|
|
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.
|
|
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);
|