glidercli 0.3.15 → 0.3.17
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/bin/glider.js +11 -13
- package/lib/bexplore.js +39 -7
- package/package.json +2 -2
package/bin/glider.js
CHANGED
|
@@ -91,7 +91,6 @@ for (const cfgPath of BROWSER_CONFIG_PATHS) {
|
|
|
91
91
|
|
|
92
92
|
// Browsers registry - key → { name, path, processName }. Used when browser.json has "use": "<key>"
|
|
93
93
|
const BROWSERS_REGISTRY_PATHS = [
|
|
94
|
-
path.join(os.homedir(), '.cursor', 'registry', 'browsers.json'),
|
|
95
94
|
path.join(os.homedir(), '.glider', 'config', 'browsers-registry.json'),
|
|
96
95
|
].filter(Boolean);
|
|
97
96
|
let BROWSERS_REGISTRY = {};
|
|
@@ -502,8 +501,8 @@ async function cmdGoto(url) {
|
|
|
502
501
|
method: 'Page.navigate',
|
|
503
502
|
params: { url }
|
|
504
503
|
});
|
|
505
|
-
// v0.3.15
|
|
506
|
-
// Prior code printed raw result THEN unconditionally logged '✓ Navigated'
|
|
504
|
+
// v0.3.15: detect nav errors; auto-attach after successful goto.
|
|
505
|
+
// Prior code printed raw result THEN unconditionally logged '✓ Navigated' -
|
|
507
506
|
// even when result contained {"error":"Session not found"} (stale pinned session after reload-ext).
|
|
508
507
|
// Now: detect embedded error, don't lie about success, then auto-attach the target tab.
|
|
509
508
|
const hasErr = result && (result.error || (typeof result === 'string' && result.includes('error')));
|
|
@@ -722,13 +721,12 @@ async function cmdRestart() {
|
|
|
722
721
|
await cmdStart();
|
|
723
722
|
}
|
|
724
723
|
|
|
725
|
-
//
|
|
726
|
-
|
|
727
|
-
// Bootstrap cost: one manual reload after installing this handler for the first time.
|
|
724
|
+
// reload-ext: automate extension reload + tab re-attachment so operators
|
|
725
|
+
***REMOVED***
|
|
728
726
|
async function cmdReloadExt() {
|
|
729
727
|
try {
|
|
730
728
|
const r = await postExtension({ method: 'reloadSelf', params: {} });
|
|
731
|
-
// v0.3.15
|
|
729
|
+
// v0.3.15: same response unwrap fix as attach-all - r.result was always undefined
|
|
732
730
|
const persisted = (r.result?.persisted ?? r.persisted ?? '?');
|
|
733
731
|
log.ok(`Extension reload triggered (persisted ${persisted} tab URLs).`);
|
|
734
732
|
log.info('Waiting 4s for extension to boot back up + reconnect...');
|
|
@@ -746,7 +744,7 @@ async function cmdReloadExt() {
|
|
|
746
744
|
async function cmdAttachAll(filter) {
|
|
747
745
|
try {
|
|
748
746
|
const r = await postExtension({ method: 'attachAllTabs', params: filter ? { urlSubstring: filter } : {} });
|
|
749
|
-
// v0.3.15
|
|
747
|
+
// v0.3.15: attach-all response unwrap fix -
|
|
750
748
|
// relay's sendToExtension unwraps msg.result before HTTP POST responds, so relay body is {attached, skipped, failed, total_connected} bare.
|
|
751
749
|
// Prior code read r.result.attached which was always undefined → literal '?' placeholders on every attach-all.
|
|
752
750
|
const d = r.result ?? r;
|
|
@@ -995,7 +993,7 @@ function cmdBrowser() {
|
|
|
995
993
|
}
|
|
996
994
|
console.log('');
|
|
997
995
|
console.log('Source: ~/.glider/config/browser.json { "use": "<key>" } or { name, path } → default "Google Chrome"');
|
|
998
|
-
console.log('Registry: ~/.
|
|
996
|
+
console.log('Registry: ~/.glider/config/browsers-registry.json. Keys: ' + (Object.keys(BROWSERS_REGISTRY).join(', ') || '(none loaded)'));
|
|
999
997
|
console.log('See README.md#browsers for compatibility and examples.');
|
|
1000
998
|
}
|
|
1001
999
|
|
|
@@ -2247,7 +2245,7 @@ async function main() {
|
|
|
2247
2245
|
loadPersistedSession();
|
|
2248
2246
|
let cmd = args[0];
|
|
2249
2247
|
|
|
2250
|
-
// v0.3.15
|
|
2248
|
+
// v0.3.15: reload-ext command aliases -
|
|
2251
2249
|
// Accept common natural-language variants + typos for high-frequency commands.
|
|
2252
2250
|
// Rewrites args in place so downstream switch stays clean.
|
|
2253
2251
|
const RELOAD_EXT_TWO_WORD = new Set([
|
|
@@ -2267,7 +2265,7 @@ async function main() {
|
|
|
2267
2265
|
args[0] = 'reload-ext';
|
|
2268
2266
|
}
|
|
2269
2267
|
// Typo suggest: if cmd looks like a common command with 1-2 char edit distance, hint it.
|
|
2270
|
-
// (Only checked in unknown-command branch below
|
|
2268
|
+
// (Only checked in unknown-command branch below - this block just normalizes.)
|
|
2271
2269
|
|
|
2272
2270
|
if (!cmd || cmd === '--help' || cmd === '-h') {
|
|
2273
2271
|
showHelp();
|
|
@@ -2310,7 +2308,7 @@ async function main() {
|
|
|
2310
2308
|
await cmdReloadExt();
|
|
2311
2309
|
break;
|
|
2312
2310
|
case 'attach-all':
|
|
2313
|
-
await cmdAttachAll(args[1]); // optional URL substring filter, e.g. '
|
|
2311
|
+
await cmdAttachAll(args[1]); // optional URL substring filter, e.g. 'example.com'
|
|
2314
2312
|
break;
|
|
2315
2313
|
case 'install':
|
|
2316
2314
|
await cmdInstallDaemon();
|
|
@@ -2465,7 +2463,7 @@ async function main() {
|
|
|
2465
2463
|
break;
|
|
2466
2464
|
}
|
|
2467
2465
|
log.fail(`Unknown command: ${cmd}`);
|
|
2468
|
-
// v0.3.15
|
|
2466
|
+
// v0.3.15: typo suggest (Levenshtein <=2) before dumping full help.
|
|
2469
2467
|
const KNOWN_CMDS = ['status','start','stop','restart','reload-ext','attach-all','install','uninstall',
|
|
2470
2468
|
'update','version','connect','browser','use','test','domains','resolve','goto','eval','click','type',
|
|
2471
2469
|
'screenshot','snapshot','text','html','title','url','tabs','targets','use-session','fetch','spawn',
|
package/lib/bexplore.js
CHANGED
|
@@ -576,12 +576,20 @@ class SiteExplorer {
|
|
|
576
576
|
// Initial screenshot
|
|
577
577
|
await this.screenshot('initial');
|
|
578
578
|
|
|
579
|
-
// Discover all elements
|
|
580
|
-
|
|
581
|
-
|
|
579
|
+
// Discover all elements (best-effort - heavy SPAs may throw during discovery;
|
|
580
|
+
// don't let a discovery failure abort HAR persistence)
|
|
581
|
+
let elements;
|
|
582
|
+
try {
|
|
583
|
+
elements = await this.discoverElements();
|
|
584
|
+
console.error(`[explore] Found: ${elements.tabs.length} tabs, ${elements.buttons.length} buttons, ${elements.links.length} links`);
|
|
585
|
+
} catch (e) {
|
|
586
|
+
console.error(`[explore] DOM discovery failed (${e.message}); skipping discovery, preserving HAR`);
|
|
587
|
+
elements = { tabs: [], buttons: [], links: [], forms: [], tables: [], dropdowns: [], checkboxes: [], modals: [], sidePanels: [] };
|
|
588
|
+
this.siteMap.discoveryError = e.message;
|
|
589
|
+
}
|
|
582
590
|
|
|
583
591
|
if (depth === 0) {
|
|
584
|
-
console.error('[explore] depth=0 passive
|
|
592
|
+
console.error('[explore] depth=0 passive - no clicks, scroll, or toggles');
|
|
585
593
|
} else {
|
|
586
594
|
// Click through tabs
|
|
587
595
|
for (const tab of elements.tabs.slice(0, depth)) {
|
|
@@ -648,8 +656,12 @@ class SiteExplorer {
|
|
|
648
656
|
}
|
|
649
657
|
}
|
|
650
658
|
|
|
651
|
-
// Final screenshot
|
|
652
|
-
|
|
659
|
+
// Final screenshot (best-effort)
|
|
660
|
+
try {
|
|
661
|
+
await this.screenshot('final');
|
|
662
|
+
} catch (e) {
|
|
663
|
+
console.error(`[explore] Final screenshot failed (${e.message}); continuing`);
|
|
664
|
+
}
|
|
653
665
|
|
|
654
666
|
return this.generateReport();
|
|
655
667
|
}
|
|
@@ -833,7 +845,7 @@ Options:
|
|
|
833
845
|
--session-id ID CDP session (e.g. session-6 from GET /targets)
|
|
834
846
|
--help Show this help
|
|
835
847
|
|
|
836
|
-
Depth 0 (passive): reload, discover DOM, screenshots, HAR
|
|
848
|
+
Depth 0 (passive): reload, discover DOM, screenshots, HAR - zero clicks.
|
|
837
849
|
Depth N>0: up to N tab/button/checkbox interactions per category.
|
|
838
850
|
|
|
839
851
|
The tool will:
|
|
@@ -905,6 +917,26 @@ Examples:
|
|
|
905
917
|
|
|
906
918
|
} catch (err) {
|
|
907
919
|
console.error('Error:', err.message);
|
|
920
|
+
// Salvage: even on catastrophic failure, save whatever HAR + partial report we have
|
|
921
|
+
try {
|
|
922
|
+
if (harFile && explorer.requests && explorer.requests.length > 0) {
|
|
923
|
+
explorer.saveHAR();
|
|
924
|
+
console.error(`[explore] HAR salvaged despite error (${explorer.requests.length} requests captured)`);
|
|
925
|
+
}
|
|
926
|
+
if (explorer.outputDir && fs.existsSync(explorer.outputDir)) {
|
|
927
|
+
const partialReport = {
|
|
928
|
+
error: err.message,
|
|
929
|
+
url: explorer.siteMap?.url || 'unknown',
|
|
930
|
+
requestsCaptured: explorer.requests?.length || 0,
|
|
931
|
+
responsesCaptured: explorer.responses?.length || 0,
|
|
932
|
+
partial: true
|
|
933
|
+
};
|
|
934
|
+
fs.writeFileSync(path.join(explorer.outputDir, 'report.json'), JSON.stringify(partialReport, null, 2));
|
|
935
|
+
console.error(`[explore] Partial report saved: ${explorer.outputDir}/report.json`);
|
|
936
|
+
}
|
|
937
|
+
} catch (salvageErr) {
|
|
938
|
+
console.error(`[explore] Salvage failed: ${salvageErr.message}`);
|
|
939
|
+
}
|
|
908
940
|
process.exit(1);
|
|
909
941
|
} finally {
|
|
910
942
|
explorer.close();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glidercli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Browser automation CLI. Control Chrome from terminal via CDP, run YAML task files, autonomous loops until completion.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"glider": "bin/glider.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "node bin/glider.js --help
|
|
10
|
+
"test": "node bin/glider.js --help"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"browser",
|