goblin-laboratory 4.8.0 → 4.9.1
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/lib/termux.js +60 -3
- package/package.json +3 -2
package/lib/termux.js
CHANGED
|
@@ -297,9 +297,9 @@ class Termux extends Elf.Alone {
|
|
|
297
297
|
|
|
298
298
|
async askForCompletion(input) {
|
|
299
299
|
const prompt = getPrompt(this.user);
|
|
300
|
-
const tools = Object.keys(this._tools)
|
|
301
|
-
tool.startsWith(input)
|
|
302
|
-
|
|
300
|
+
const tools = Object.keys(this._tools)
|
|
301
|
+
.filter((tool) => tool.startsWith(input))
|
|
302
|
+
.sort();
|
|
303
303
|
this.logic.askForCompletion(prompt, input, tools);
|
|
304
304
|
|
|
305
305
|
const {completion} = this.state;
|
|
@@ -451,6 +451,43 @@ class Termux extends Elf.Alone {
|
|
|
451
451
|
return '';
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
+
async metrics$tool(horde, output) {
|
|
455
|
+
const {topology} = require('xcraft-core-etc')().load('xcraft-core-horde');
|
|
456
|
+
const _xcraftRPC = topology?.[horde]?.passive;
|
|
457
|
+
|
|
458
|
+
/* FIXME: must be moved on the server side */
|
|
459
|
+
if (_xcraftRPC && this.user.rank !== 'admin') {
|
|
460
|
+
throw new Error('Forbidden');
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
let metrics = await this.quest.cmd(`bus.${horde}.xcraftMetrics`, {
|
|
464
|
+
from: this.id,
|
|
465
|
+
_xcraftRPC,
|
|
466
|
+
});
|
|
467
|
+
metrics = JSON.stringify(metrics, null, 2);
|
|
468
|
+
|
|
469
|
+
if (!output) {
|
|
470
|
+
return metrics;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const fse = require('fs-extra');
|
|
474
|
+
await fse.writeFile(output, metrics);
|
|
475
|
+
return 'Metrics saved to: ' + output;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async heapdump$tool(horde) {
|
|
479
|
+
const {topology} = require('xcraft-core-etc')().load('xcraft-core-horde');
|
|
480
|
+
const _xcraftRPC = topology?.[horde]?.passive;
|
|
481
|
+
|
|
482
|
+
/* FIXME: must be moved on the server side */
|
|
483
|
+
if (_xcraftRPC && this.user.rank !== 'admin') {
|
|
484
|
+
throw new Error('Forbidden');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const output = await this.quest.cmd(`bus.${horde}.heapdump`, {_xcraftRPC});
|
|
488
|
+
return output;
|
|
489
|
+
}
|
|
490
|
+
|
|
454
491
|
async $tool(tool) {
|
|
455
492
|
if (tool === 'man') {
|
|
456
493
|
return {
|
|
@@ -475,6 +512,26 @@ class Termux extends Elf.Alone {
|
|
|
475
512
|
return autocomp;
|
|
476
513
|
}, {});
|
|
477
514
|
}
|
|
515
|
+
if (tool === 'metrics') {
|
|
516
|
+
const {resp} = this.quest;
|
|
517
|
+
const registry = resp.getCommandsRegistry();
|
|
518
|
+
return Object.keys(registry)
|
|
519
|
+
.filter((cmd) => /^bus[.][^.]+[.]xcraftMetrics$/.test(cmd))
|
|
520
|
+
.reduce((autocomp, cmd) => {
|
|
521
|
+
autocomp[cmd.split('.')[1]] = null;
|
|
522
|
+
return autocomp;
|
|
523
|
+
}, {});
|
|
524
|
+
}
|
|
525
|
+
if (tool === 'heapdump') {
|
|
526
|
+
const {resp} = this.quest;
|
|
527
|
+
const registry = resp.getCommandsRegistry();
|
|
528
|
+
return Object.keys(registry)
|
|
529
|
+
.filter((cmd) => /^bus[.][^.]+[.]heapdump$/.test(cmd))
|
|
530
|
+
.reduce((autocomp, cmd) => {
|
|
531
|
+
autocomp[cmd.split('.')[1]] = null;
|
|
532
|
+
return autocomp;
|
|
533
|
+
}, {});
|
|
534
|
+
}
|
|
478
535
|
return {};
|
|
479
536
|
}
|
|
480
537
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goblin-laboratory",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.1",
|
|
4
4
|
"description": "Laboratory",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"fs-extra": "^11.3.3",
|
|
29
30
|
"goblin-theme": "^2.0.0",
|
|
30
31
|
"xcraft-core-goblin": "^5.0.0",
|
|
31
32
|
"xcraft-core-log": "^2.2.0",
|
|
@@ -57,4 +58,4 @@
|
|
|
57
58
|
"xcraft-traverse": "^0.7.0"
|
|
58
59
|
},
|
|
59
60
|
"prettier": "xcraft-dev-prettier"
|
|
60
|
-
}
|
|
61
|
+
}
|