@indra.ai/deva 1.1.92 → 1.1.94
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/config.json +6 -0
- package/index.js +175 -147
- package/package.json +3 -3
package/config.json
CHANGED
|
@@ -182,6 +182,12 @@
|
|
|
182
182
|
},
|
|
183
183
|
"actions": {
|
|
184
184
|
"wait": "::agent.name:: is waiting",
|
|
185
|
+
"start": "::agent.name:: has started",
|
|
186
|
+
"enter": "::agent.name:: has entered deva.world",
|
|
187
|
+
"exit": "::agent.name:: has exited deva.world",
|
|
188
|
+
"stop": "::agent.name:: is stopped",
|
|
189
|
+
"load": "::agent.name:: is loaded",
|
|
190
|
+
"unload": "::agent.name:: is unloaded",
|
|
185
191
|
"question": "::agent.name:: received a question",
|
|
186
192
|
"question_ask": "::agent.name:: is asking another Deva",
|
|
187
193
|
"question_ask_answer": "::agent.name:: answered what they were asked",
|
package/index.js
CHANGED
|
@@ -75,6 +75,132 @@ class Deva {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**************
|
|
79
|
+
func: _assignBind
|
|
80
|
+
params: none
|
|
81
|
+
describe:
|
|
82
|
+
The assign bind function will bind the translate functions and parse functions
|
|
83
|
+
of the agent and bind their functionality to the state machine.
|
|
84
|
+
***************/
|
|
85
|
+
_assignBind() {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
try {
|
|
88
|
+
this.bind.forEach(bind => { // loop over the bind items func, method, listener...
|
|
89
|
+
if (this[bind]) for (let x in this[bind]) { // if the root has a bind func, method, listener
|
|
90
|
+
if (typeof this[bind][x] === 'function') { // check to make sure object is a fucntion
|
|
91
|
+
this[bind][x] = this[bind][x].bind(this); // bind the item from the bind object
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
// bind translate
|
|
96
|
+
const translate = this._agent && this._agent.translate && typeof this._agent.translate === 'function';
|
|
97
|
+
if (translate) this._agent.translate = this._agent.translate.bind(this);
|
|
98
|
+
// bind parser
|
|
99
|
+
const parse = this._agent && this._agent.parse && typeof this._agent.parse === 'function';
|
|
100
|
+
if (parse) this._agent.parse = this._agent.parse.bind(this);
|
|
101
|
+
// bind process
|
|
102
|
+
const process = this._agent && this._agent.process && typeof this._agent.process === 'function';
|
|
103
|
+
if (process) this._agent.process = this._agent.process.bind(this);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
return this.error(e, false, reject); // trigger the this.error for errors
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
return resolve(); // when the configuration is complete then return an empty resolve.
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**************
|
|
115
|
+
func: _assignListeners
|
|
116
|
+
params: none
|
|
117
|
+
describe:
|
|
118
|
+
Assign listeners will take the this.lisners objects and assign the appropriate
|
|
119
|
+
lisnter values for the event bus.
|
|
120
|
+
***************/
|
|
121
|
+
_assignListeners() {
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
try {
|
|
124
|
+
// set the default listeners for the states of the agent.
|
|
125
|
+
|
|
126
|
+
for (let state in this._states) {
|
|
127
|
+
if (typeof this[state] === 'function') {
|
|
128
|
+
this.events.on(`${this._agent.key}:${state}`, packet => {
|
|
129
|
+
return this[state](packet);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// set the assigned listeners for the agent.
|
|
135
|
+
for (let listener in this.listeners) {
|
|
136
|
+
this.events.on(listener, packet => {
|
|
137
|
+
return this.listeners[listener](packet);
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
return resolve();
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
return this.error(e, false, reject);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Some elements will inherit the data of the parent. this object will loop over
|
|
149
|
+
// any children data that theis deva has and assign the inherited information.
|
|
150
|
+
/**************
|
|
151
|
+
func: _assignInherit
|
|
152
|
+
params: none
|
|
153
|
+
describe:
|
|
154
|
+
The assign inherit will make sure the Devas in the current Deva have all the
|
|
155
|
+
inherited properties all setup to collaborate efficiently.
|
|
156
|
+
***************/
|
|
157
|
+
_assignInherit() {
|
|
158
|
+
return new Promise((resolve, reject) => {
|
|
159
|
+
try {
|
|
160
|
+
for (let d in this.devas) {
|
|
161
|
+
this.inherit.forEach(inherit => {
|
|
162
|
+
this.devas[d][inherit] = this[inherit];
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return resolve();
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
return this.error(e, false, reject);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// General handler for when a method is NOT found from a user command.
|
|
174
|
+
/**************
|
|
175
|
+
func: _methodNotFound
|
|
176
|
+
params:
|
|
177
|
+
- packet: The packet to relay when a method is not found.
|
|
178
|
+
describe:
|
|
179
|
+
The _methodNotFound function allows for additional security by firing
|
|
180
|
+
a specfici program functon every single time a interaction happens wehre a
|
|
181
|
+
method is not located. This assits in security and support by identifying
|
|
182
|
+
troubls or users who may be attemptng to explit features.
|
|
183
|
+
|
|
184
|
+
Then we talk a security event that watches all methods and return the packet.
|
|
185
|
+
|
|
186
|
+
This will return a not found text string preventing any furhter processing.
|
|
187
|
+
***************/
|
|
188
|
+
_methodNotFound(packet) {
|
|
189
|
+
packet.a = {
|
|
190
|
+
id: this.uid(),
|
|
191
|
+
agent: this.agent() || false,
|
|
192
|
+
client: this.client() || false,
|
|
193
|
+
text: `${this._messages.method_not_found}`,
|
|
194
|
+
meta: {
|
|
195
|
+
key: this._agent.key,
|
|
196
|
+
method: packet.q.meta.method,
|
|
197
|
+
},
|
|
198
|
+
created: Date.now(),
|
|
199
|
+
};
|
|
200
|
+
this.state('method_not_found');
|
|
201
|
+
return packet;
|
|
202
|
+
}
|
|
203
|
+
|
|
78
204
|
/**************
|
|
79
205
|
func: Client
|
|
80
206
|
params: client - client provided data.
|
|
@@ -520,131 +646,6 @@ class Deva {
|
|
|
520
646
|
}
|
|
521
647
|
});
|
|
522
648
|
}
|
|
523
|
-
/**************
|
|
524
|
-
func: _assignBind
|
|
525
|
-
params: none
|
|
526
|
-
describe:
|
|
527
|
-
The assign bind function will bind the translate functions and parse functions
|
|
528
|
-
of the agent and bind their functionality to the state machine.
|
|
529
|
-
***************/
|
|
530
|
-
_assignBind() {
|
|
531
|
-
return new Promise((resolve, reject) => {
|
|
532
|
-
try {
|
|
533
|
-
this.bind.forEach(bind => { // loop over the bind items func, method, listener...
|
|
534
|
-
if (this[bind]) for (let x in this[bind]) { // if the root has a bind func, method, listener
|
|
535
|
-
if (typeof this[bind][x] === 'function') { // check to make sure object is a fucntion
|
|
536
|
-
this[bind][x] = this[bind][x].bind(this); // bind the item from the bind object
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
// bind translate
|
|
541
|
-
const translate = this._agent && this._agent.translate && typeof this._agent.translate === 'function';
|
|
542
|
-
if (translate) this._agent.translate = this._agent.translate.bind(this);
|
|
543
|
-
// bind parser
|
|
544
|
-
const parse = this._agent && this._agent.parse && typeof this._agent.parse === 'function';
|
|
545
|
-
if (parse) this._agent.parse = this._agent.parse.bind(this);
|
|
546
|
-
// bind process
|
|
547
|
-
const process = this._agent && this._agent.process && typeof this._agent.process === 'function';
|
|
548
|
-
if (process) this._agent.process = this._agent.process.bind(this);
|
|
549
|
-
}
|
|
550
|
-
catch (e) {
|
|
551
|
-
return this.error(e, false, reject); // trigger the this.error for errors
|
|
552
|
-
}
|
|
553
|
-
finally {
|
|
554
|
-
return resolve(); // when the configuration is complete then return an empty resolve.
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**************
|
|
560
|
-
func: _assignListeners
|
|
561
|
-
params: none
|
|
562
|
-
describe:
|
|
563
|
-
Assign listeners will take the this.lisners objects and assign the appropriate
|
|
564
|
-
lisnter values for the event bus.
|
|
565
|
-
***************/
|
|
566
|
-
_assignListeners() {
|
|
567
|
-
return new Promise((resolve, reject) => {
|
|
568
|
-
try {
|
|
569
|
-
// set the default listeners for the states of the agent.
|
|
570
|
-
|
|
571
|
-
for (let state in this._states) {
|
|
572
|
-
if (typeof this[state] === 'function') {
|
|
573
|
-
this.events.on(`${this._agent.key}:${state}`, packet => {
|
|
574
|
-
return this[state](packet);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// set the assigned listeners for the agent.
|
|
580
|
-
for (let listener in this.listeners) {
|
|
581
|
-
this.events.on(listener, packet => {
|
|
582
|
-
return this.listeners[listener](packet);
|
|
583
|
-
})
|
|
584
|
-
}
|
|
585
|
-
return resolve();
|
|
586
|
-
}
|
|
587
|
-
catch (e) {
|
|
588
|
-
return this.error(e, false, reject);
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
// Some elements will inherit the data of the parent. this object will loop over
|
|
594
|
-
// any children data that theis deva has and assign the inherited information.
|
|
595
|
-
/**************
|
|
596
|
-
func: _assignInherit
|
|
597
|
-
params: none
|
|
598
|
-
describe:
|
|
599
|
-
The assign inherit will make sure the Devas in the current Deva have all the
|
|
600
|
-
inherited properties all setup to collaborate efficiently.
|
|
601
|
-
***************/
|
|
602
|
-
_assignInherit() {
|
|
603
|
-
return new Promise((resolve, reject) => {
|
|
604
|
-
try {
|
|
605
|
-
for (let d in this.devas) {
|
|
606
|
-
this.inherit.forEach(inherit => {
|
|
607
|
-
this.devas[d][inherit] = this[inherit];
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
return resolve();
|
|
611
|
-
}
|
|
612
|
-
catch (e) {
|
|
613
|
-
return this.error(e, false, reject);
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// General handler for when a method is NOT found from a user command.
|
|
619
|
-
/**************
|
|
620
|
-
func: _methodNotFound
|
|
621
|
-
params:
|
|
622
|
-
- packet: The packet to relay when a method is not found.
|
|
623
|
-
describe:
|
|
624
|
-
The _methodNotFound function allows for additional security by firing
|
|
625
|
-
a specfici program functon every single time a interaction happens wehre a
|
|
626
|
-
method is not located. This assits in security and support by identifying
|
|
627
|
-
troubls or users who may be attemptng to explit features.
|
|
628
|
-
|
|
629
|
-
Then we talk a security event that watches all methods and return the packet.
|
|
630
|
-
|
|
631
|
-
This will return a not found text string preventing any furhter processing.
|
|
632
|
-
***************/
|
|
633
|
-
_methodNotFound(packet) {
|
|
634
|
-
packet.a = {
|
|
635
|
-
id: this.uid(),
|
|
636
|
-
agent: this.agent() || false,
|
|
637
|
-
client: this.client() || false,
|
|
638
|
-
text: `${this._messages.method_not_found}`,
|
|
639
|
-
meta: {
|
|
640
|
-
key: this._agent.key,
|
|
641
|
-
method: packet.q.meta.method,
|
|
642
|
-
},
|
|
643
|
-
created: Date.now(),
|
|
644
|
-
};
|
|
645
|
-
this.state('method_not_found');
|
|
646
|
-
return packet;
|
|
647
|
-
}
|
|
648
649
|
|
|
649
650
|
/**************
|
|
650
651
|
func: talk
|
|
@@ -848,7 +849,7 @@ class Deva {
|
|
|
848
849
|
};
|
|
849
850
|
|
|
850
851
|
// create a hash for the answer and insert into answer meta.
|
|
851
|
-
packet_answer.meta.hash = this.hash(
|
|
852
|
+
packet_answer.meta.hash = this.hash(packet_answer);
|
|
852
853
|
|
|
853
854
|
packet.a = this.copy(packet_answer);
|
|
854
855
|
packet.hash = this.hash(packet); // hash the entire packet.
|
|
@@ -974,6 +975,9 @@ class Deva {
|
|
|
974
975
|
usage: this.init(client_object)
|
|
975
976
|
***************/
|
|
976
977
|
init(client) {
|
|
978
|
+
// set client
|
|
979
|
+
this._active = Date.now();
|
|
980
|
+
|
|
977
981
|
const _data = {
|
|
978
982
|
id: this.uid(true),
|
|
979
983
|
key: 'return',
|
|
@@ -985,8 +989,6 @@ class Deva {
|
|
|
985
989
|
}
|
|
986
990
|
_data.hash = this.hash(_data);
|
|
987
991
|
|
|
988
|
-
// set client
|
|
989
|
-
this._active = Date.now();
|
|
990
992
|
return new Promise((resolve, reject) => {
|
|
991
993
|
this.events.setMaxListeners(this.maxListeners);
|
|
992
994
|
this._assignInherit().then(() => {
|
|
@@ -1026,7 +1028,7 @@ class Deva {
|
|
|
1026
1028
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1027
1029
|
data.value = 'start';
|
|
1028
1030
|
delete data.hash;
|
|
1029
|
-
data.hash = this.hash(
|
|
1031
|
+
data.hash = this.hash(data);
|
|
1030
1032
|
|
|
1031
1033
|
if (this.info) {
|
|
1032
1034
|
const _info = this.info(data.id);
|
|
@@ -1054,7 +1056,7 @@ class Deva {
|
|
|
1054
1056
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1055
1057
|
data.value = 'enter';
|
|
1056
1058
|
delete data.hash;
|
|
1057
|
-
data.hash = this.hash(
|
|
1059
|
+
data.hash = this.hash(data);
|
|
1058
1060
|
this.action(data.value);
|
|
1059
1061
|
const hasOnEnter = this.onEnter && typeof this.onEnter === 'function' ? true : false;
|
|
1060
1062
|
return hasOnEnter ? this.onEnter(data) : this.done(data)
|
|
@@ -1076,7 +1078,7 @@ class Deva {
|
|
|
1076
1078
|
if (!this._active) return Promise.resolve(this._messages.states.offline);
|
|
1077
1079
|
data.value = 'done';
|
|
1078
1080
|
delete data.hash;
|
|
1079
|
-
data.hash = this.hash(
|
|
1081
|
+
data.hash = this.hash(data);
|
|
1080
1082
|
this.action(data.value)
|
|
1081
1083
|
const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
|
|
1082
1084
|
return hasOnDone ? this.onDone(data) : Promise.resolve(data);
|
|
@@ -1107,7 +1109,7 @@ class Deva {
|
|
|
1107
1109
|
text: this._messages.states.stop,
|
|
1108
1110
|
created: Date.now(),
|
|
1109
1111
|
}
|
|
1110
|
-
data.hash = this.hash(
|
|
1112
|
+
data.hash = this.hash(data);
|
|
1111
1113
|
this.action(data.value);
|
|
1112
1114
|
const hasOnStop = this.onStop && typeof this.onStop === 'function';
|
|
1113
1115
|
return hasOnStop ? this.onStop(data) : this.exit(data)
|
|
@@ -1133,7 +1135,7 @@ class Deva {
|
|
|
1133
1135
|
this._active = false;
|
|
1134
1136
|
data.value = 'exit';
|
|
1135
1137
|
delete data.hash;
|
|
1136
|
-
data.hash = this.hash(
|
|
1138
|
+
data.hash = this.hash(data);
|
|
1137
1139
|
|
|
1138
1140
|
// clear memory
|
|
1139
1141
|
this._active = false;
|
|
@@ -1174,7 +1176,7 @@ class Deva {
|
|
|
1174
1176
|
text,
|
|
1175
1177
|
created: Date.now(),
|
|
1176
1178
|
};
|
|
1177
|
-
_data.hash = this.hash(
|
|
1179
|
+
_data.hash = this.hash(_data);
|
|
1178
1180
|
this.talk(config.events.state, _data);
|
|
1179
1181
|
} catch (e) {
|
|
1180
1182
|
return this.error(e);
|
|
@@ -1210,7 +1212,7 @@ class Deva {
|
|
|
1210
1212
|
data,
|
|
1211
1213
|
created: Date.now(),
|
|
1212
1214
|
};
|
|
1213
|
-
_data.hash = this.hash(
|
|
1215
|
+
_data.hash = this.hash(_data);
|
|
1214
1216
|
this.talk(config.events.zone, _data);
|
|
1215
1217
|
} catch (e) {
|
|
1216
1218
|
return this.error(e);
|
|
@@ -1237,7 +1239,7 @@ class Deva {
|
|
|
1237
1239
|
text,
|
|
1238
1240
|
created: Date.now(),
|
|
1239
1241
|
};
|
|
1240
|
-
_data.hash = this.hash(
|
|
1242
|
+
_data.hash = this.hash(_data);
|
|
1241
1243
|
this.talk(config.events.action, _data);
|
|
1242
1244
|
} catch (e) {
|
|
1243
1245
|
return this.error(e)
|
|
@@ -1264,7 +1266,7 @@ class Deva {
|
|
|
1264
1266
|
data,
|
|
1265
1267
|
created: Date.now(),
|
|
1266
1268
|
};
|
|
1267
|
-
_data.hash = this.hash(
|
|
1269
|
+
_data.hash = this.hash(_data);
|
|
1268
1270
|
this.talk(config.events.feature, _data);
|
|
1269
1271
|
} catch (e) {
|
|
1270
1272
|
return this.error(e);
|
|
@@ -1277,19 +1279,19 @@ class Deva {
|
|
|
1277
1279
|
- st: The context flag to set for the Deva that matches to this._contexts
|
|
1278
1280
|
describe
|
|
1279
1281
|
***************/
|
|
1280
|
-
context(
|
|
1282
|
+
context(value) {
|
|
1281
1283
|
try {
|
|
1282
|
-
this._context =
|
|
1284
|
+
this._context = value;
|
|
1283
1285
|
const _data = {
|
|
1284
1286
|
id: this.uid(true),
|
|
1285
1287
|
key: 'context',
|
|
1286
|
-
value
|
|
1288
|
+
value,
|
|
1287
1289
|
agent: this.agent(),
|
|
1288
1290
|
client: this.client(),
|
|
1289
|
-
text,
|
|
1291
|
+
text: this.vars.context[value] || value,
|
|
1290
1292
|
created: Date.now(),
|
|
1291
1293
|
};
|
|
1292
|
-
_data.hash = this.hash(
|
|
1294
|
+
_data.hash = this.hash(_data);
|
|
1293
1295
|
this.talk(config.events.context, _data);
|
|
1294
1296
|
} catch (e) {
|
|
1295
1297
|
return this.error(e);
|
|
@@ -1606,7 +1608,6 @@ class Deva {
|
|
|
1606
1608
|
const max = Math.floor(Date.now() + (Date.now() * Math.PI));
|
|
1607
1609
|
id = Math.floor(Math.random() * (max - min)) + min;
|
|
1608
1610
|
}
|
|
1609
|
-
this.action('uid');
|
|
1610
1611
|
return id;
|
|
1611
1612
|
}
|
|
1612
1613
|
|
|
@@ -1625,7 +1626,6 @@ class Deva {
|
|
|
1625
1626
|
const the_hash = createHash(algo);
|
|
1626
1627
|
the_hash.update(str.toString());
|
|
1627
1628
|
const _digest = the_hash.digest('base64');
|
|
1628
|
-
this.action('hash');
|
|
1629
1629
|
return `${algo}:${_digest}`;
|
|
1630
1630
|
}
|
|
1631
1631
|
|
|
@@ -1648,7 +1648,7 @@ class Deva {
|
|
|
1648
1648
|
const _cipher = createCipheriv(algorithm, key_in_bytes, iv);
|
|
1649
1649
|
const encrypted = _cipher.update(String(str), 'utf8', 'hex') + _cipher.final('hex');
|
|
1650
1650
|
|
|
1651
|
-
|
|
1651
|
+
|
|
1652
1652
|
return {
|
|
1653
1653
|
iv: iv.toString('base64'),
|
|
1654
1654
|
key,
|
|
@@ -1665,7 +1665,6 @@ class Deva {
|
|
|
1665
1665
|
const decipher = createDecipheriv( algorithm, key_in_bytes, iv);
|
|
1666
1666
|
const decrypted = decipher.update(encrypted);
|
|
1667
1667
|
const final = Buffer.concat([decrypted, decipher.final()]);
|
|
1668
|
-
this.action('decipher');
|
|
1669
1668
|
return final.toString();
|
|
1670
1669
|
}
|
|
1671
1670
|
|
|
@@ -1688,7 +1687,6 @@ class Deva {
|
|
|
1688
1687
|
// create the text msg string
|
|
1689
1688
|
let text = `${this._agent.profile.name} active since ${dateFormat}`;
|
|
1690
1689
|
if (msg) text = text + `\n${msg}`; // append the msg string if msg true.
|
|
1691
|
-
this.action('status');
|
|
1692
1690
|
return Promise.resolve(text); // return final text string
|
|
1693
1691
|
}
|
|
1694
1692
|
|
|
@@ -1831,6 +1829,11 @@ class Deva {
|
|
|
1831
1829
|
return splitter.slice(0, maxwords).join(' ');
|
|
1832
1830
|
}
|
|
1833
1831
|
|
|
1832
|
+
/**************
|
|
1833
|
+
func: dupes
|
|
1834
|
+
params: dupers
|
|
1835
|
+
describe: remove duplicees from an array.
|
|
1836
|
+
***************/
|
|
1834
1837
|
dupes(dupers) {
|
|
1835
1838
|
if (!Array.isArray(dupers)) return dupers;
|
|
1836
1839
|
const check = [];
|
|
@@ -1842,6 +1845,31 @@ class Deva {
|
|
|
1842
1845
|
});
|
|
1843
1846
|
}
|
|
1844
1847
|
|
|
1848
|
+
/**************
|
|
1849
|
+
func: help
|
|
1850
|
+
params:
|
|
1851
|
+
- msg: the help msg to search against
|
|
1852
|
+
- help_dir: base directory of the deva help files.
|
|
1853
|
+
describe:
|
|
1854
|
+
the help utility makes it easy to create help files for your deva. the utility
|
|
1855
|
+
checks the existence of a help file in the passed in directory then if
|
|
1856
|
+
one exists it will then present it based on the users request text input.
|
|
1857
|
+
***************/
|
|
1858
|
+
help(msg, help_dir) {
|
|
1859
|
+
return new Promise((resolve, reject) => {
|
|
1860
|
+
const params = msg.split(' ');
|
|
1861
|
+
let helpFile = 'main';
|
|
1862
|
+
if (params[0]) helpFile = params[0];
|
|
1863
|
+
if (params[1]) helpFile = `${params[0]}_${params[1]}`;
|
|
1864
|
+
helpFile = path.join(help_dir, 'help', `${helpFile}.feecting`);
|
|
1865
|
+
try {
|
|
1866
|
+
return resolve(fs.readFileSync(helpFile, 'utf8'))
|
|
1867
|
+
} catch (e) {
|
|
1868
|
+
return reject(e)
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1845
1873
|
/**************
|
|
1846
1874
|
func: error
|
|
1847
1875
|
params:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indra.ai/deva",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.94",
|
|
4
4
|
"description": "The Deva Core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
|
-
"npm": ">=
|
|
31
|
-
"node": ">=
|
|
30
|
+
"npm": ">=9.5.1",
|
|
31
|
+
"node": ">=18.16.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {}
|
|
34
34
|
}
|