glidercli 0.4.19 → 0.4.31
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/README.md +18 -6
- package/bin/glider.js +378 -61
- package/docs/setup.json +6 -2
- package/docs/tab-identity.scorched.json +2042 -0
- package/lib/bwindow.js +8 -6
- package/lib/cookie-jar.js +233 -0
- package/lib/paths.js +25 -0
- package/lib/tab-catalog.js +67 -10
- package/lib/tab-map.js +282 -0
- package/lib/tab-tui.js +179 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<img src="https://raw.githubusercontent.com/vdutts7/squircle/main/webp/ralph-wiggum.webp?v=1791987543" alt="ralph" width="80" height="80" />
|
|
7
7
|
|
|
8
8
|
<h1 align="center">glider CLI</h1>
|
|
9
|
-
<p align="center"><i>
|
|
9
|
+
<p align="center"><i><b>Browser automation CLI- directly drive authenticated tabs via CDP + WebSocket relay (agent-native)</b></i></p>
|
|
10
10
|
|
|
11
11
|
<a href="https://github.com/vdutts7/glidercli"><img src="./assets/badges/github.badge.svg?v=1791987543" alt="GitHub" height="40" /></a>
|
|
12
12
|
<a href="https://www.npmjs.com/package/glidercli"><img src="./assets/badges/npm.badge.svg?v=1791987543" alt="glidercli on npm" height="40" /></a>
|
|
@@ -91,15 +91,17 @@ Not supported today: Firefox/Safari/WebKit/Gecko, DuckDuckGo, browsers without C
|
|
|
91
91
|
|
|
92
92
|
### Browser config
|
|
93
93
|
|
|
94
|
-
CLI
|
|
94
|
+
via CLI:
|
|
95
95
|
|
|
96
96
|
```bash
|
|
97
97
|
glider config browser chrome
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
via `$GLIDER/config/browser.json`:
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
```json
|
|
103
|
+
{ "use": "chrome" }
|
|
104
|
+
```
|
|
103
105
|
|
|
104
106
|
---
|
|
105
107
|
|
|
@@ -133,6 +135,16 @@ glider loop hn-scrape.yaml
|
|
|
133
135
|
| domain index | `~/.glider/config/domains.json` |
|
|
134
136
|
| per-host intel | `~/.glider/warch/HOST/glider.json` |
|
|
135
137
|
| explore cache | `~/.glider/bexplore/HOST/` |
|
|
138
|
+
| cookie jar | `~/.glider/cookies/HOST/header.txt` (+ `domains.json` index) |
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
glider connect
|
|
142
|
+
glider cookie-jar add chat.example.com
|
|
143
|
+
glider cookie-jar sync chat.example.com
|
|
144
|
+
glider cookie-jar read chat.example.com
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Offline curl: `COOKIE_FILE=~/.glider/cookies/HOST/header.txt`. Index: `glider cookie-jar rebuild` scans `$GLIDER/warch/**/glider.json` for `cookie_jar.enabled`. Optional extra tree: set `GLIDER_EXTRA_WARCH_ROOT` (path-separated).
|
|
136
148
|
|
|
137
149
|
| Env | Default | Role |
|
|
138
150
|
|-----|---------|------|
|
|
@@ -144,14 +156,14 @@ Copy `config/domains.template.json` into `~/.glider/config/domains.json` to seed
|
|
|
144
156
|
|
|
145
157
|
## Tabs
|
|
146
158
|
|
|
147
|
-
`glider tabs` is the visible Helium rail, not the debugger map.
|
|
159
|
+
`glider tabs` is the visible Helium rail, not the debugger map. TUI (0.4.28): `[n]` is the handle. One field per line under each tab (`url:`, `status:`, `tabId:`, `active:`, `sessionId:`, `targetId:`, …). Empty identity values print `-`. `glider tabs` writes `$GLIDER/state/tab-map.json`. Chain: `--current` `--incognito` `--window` `--index` `--handle` `--tab` `--target` `--session` `--iframe` `--context` then `pin` (or `use-session <id>`). `--json tabs` is the full catalog.
|
|
148
160
|
|
|
149
161
|
1. current window `chrome.tabs` (live title/url, including `chrome://newtab`)
|
|
150
162
|
2. other windows
|
|
151
163
|
3. attached: CDP session not in `chrome.tabs`
|
|
152
164
|
4. stale: `tabId` gone from `chrome.tabs`; dropped from the relay map
|
|
153
165
|
|
|
154
|
-
Incognito is Chromium `windows.Window.incognito` and `tabs.Tab.incognito` only. TUI: `window N
|
|
166
|
+
Incognito is Chromium `windows.Window.incognito` and `tabs.Tab.incognito` only. TUI: `window N [current] [incognito]`. Enable Allow in Incognito on the extension. CDP `browserContextId` is not that flag.
|
|
155
167
|
|
|
156
168
|
`glider targets` stays the raw CDP session list.
|
|
157
169
|
|
package/bin/glider.js
CHANGED
|
@@ -37,8 +37,78 @@ const DEBUG_URL = `http://127.0.0.1:${DEBUG_PORT}`;
|
|
|
37
37
|
const LIB_DIR = path.join(__dirname, '..', 'lib');
|
|
38
38
|
const REGISTRY_FILE = path.join(LIB_DIR, 'registry.json');
|
|
39
39
|
|
|
40
|
-
// Active CDP session (multi-tab). Env or
|
|
40
|
+
// Active CDP session (multi-tab). Env or window>index>tab>handle>target>session chain.
|
|
41
41
|
let activeSessionId = process.env.GLIDER_SESSION_ID || null;
|
|
42
|
+
let wantCurrent = false;
|
|
43
|
+
let wantIncognito = false;
|
|
44
|
+
let wantIframe = false;
|
|
45
|
+
let wantWindowId = null;
|
|
46
|
+
let wantIndex = null;
|
|
47
|
+
let wantHandle = null;
|
|
48
|
+
let wantTabId = null;
|
|
49
|
+
let wantTargetId = null;
|
|
50
|
+
let wantSessionId = null;
|
|
51
|
+
let wantContextId = null;
|
|
52
|
+
let wantActive = false;
|
|
53
|
+
let wantAttached = false;
|
|
54
|
+
let wantDiscarded = false;
|
|
55
|
+
let wantHighlighted = false;
|
|
56
|
+
let wantPinned = false;
|
|
57
|
+
let wantStatus = null;
|
|
58
|
+
let wantTitle = null;
|
|
59
|
+
let wantFocusedWindowId = null;
|
|
60
|
+
let wantOpenerTabId = null;
|
|
61
|
+
let wantGroupId = null;
|
|
62
|
+
let wantCookieStoreId = null;
|
|
63
|
+
|
|
64
|
+
function chainOpts() {
|
|
65
|
+
return {
|
|
66
|
+
current: wantCurrent,
|
|
67
|
+
incognito: wantIncognito,
|
|
68
|
+
windowId: wantWindowId,
|
|
69
|
+
index: wantIndex,
|
|
70
|
+
handle: wantHandle,
|
|
71
|
+
tabId: wantTabId,
|
|
72
|
+
targetId: wantTargetId,
|
|
73
|
+
sessionId: wantSessionId,
|
|
74
|
+
browserContextId: wantContextId,
|
|
75
|
+
iframe: wantIframe,
|
|
76
|
+
active: wantActive,
|
|
77
|
+
attached: wantAttached,
|
|
78
|
+
discarded: wantDiscarded,
|
|
79
|
+
highlighted: wantHighlighted,
|
|
80
|
+
pinned: wantPinned,
|
|
81
|
+
status: wantStatus,
|
|
82
|
+
title: wantTitle,
|
|
83
|
+
focusedWindowId: wantFocusedWindowId,
|
|
84
|
+
openerTabId: wantOpenerTabId,
|
|
85
|
+
groupId: wantGroupId,
|
|
86
|
+
cookieStoreId: wantCookieStoreId,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function chainArmed() {
|
|
91
|
+
const o = chainOpts();
|
|
92
|
+
return !!(o.current || o.incognito || o.iframe || o.windowId || o.index
|
|
93
|
+
|| o.handle || o.tabId || o.targetId || o.sessionId || o.browserContextId
|
|
94
|
+
|| o.active || o.attached || o.discarded || o.highlighted || o.pinned
|
|
95
|
+
|| o.status || o.title || o.focusedWindowId || o.openerTabId || o.groupId || o.cookieStoreId);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function chainOnlySessionId() {
|
|
99
|
+
if (!wantSessionId) return false;
|
|
100
|
+
return chainOnlySessionIdMerged({ ...chainOpts(), sessionId: wantSessionId });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function chainOnlySessionIdMerged(chain) {
|
|
104
|
+
if (!chain || !chain.sessionId) return false;
|
|
105
|
+
return !(
|
|
106
|
+
chain.current || chain.incognito || chain.iframe || chain.windowId || chain.index
|
|
107
|
+
|| chain.handle || chain.tabId || chain.targetId || chain.browserContextId
|
|
108
|
+
|| chain.active || chain.attached || chain.discarded || chain.highlighted || chain.pinned
|
|
109
|
+
|| chain.status || chain.title || chain.focusedWindowId || chain.openerTabId || chain.groupId || chain.cookieStoreId
|
|
110
|
+
);
|
|
111
|
+
}
|
|
42
112
|
let jsonOutput = false;
|
|
43
113
|
let allowedDomainList = null;
|
|
44
114
|
const { configPath, gliderHome, stateDir, capturesDir, scratchDir } = require(path.join(LIB_DIR, 'paths.js'));
|
|
@@ -80,6 +150,8 @@ const { resolveDomain } = require(path.join(LIB_DIR, 'domain-resolve.js'));
|
|
|
80
150
|
const pinMachine = require(path.join(LIB_DIR, 'pin-machine.js'));
|
|
81
151
|
const relayHeal = require(path.join(LIB_DIR, 'relay-heal.js'));
|
|
82
152
|
const { npmIsNewer } = require(path.join(LIB_DIR, 'pkg-update.js'));
|
|
153
|
+
const { formatCatalogTui } = require(path.join(LIB_DIR, 'tab-tui.js'));
|
|
154
|
+
const tabMap = require(path.join(LIB_DIR, 'tab-map.js'));
|
|
83
155
|
|
|
84
156
|
// Domain extensions - load from ~/.glider/config/domains.json
|
|
85
157
|
const DOMAIN_CONFIG_PATHS = configPath('domains.json');
|
|
@@ -527,6 +599,7 @@ function httpGet(urlPath) {
|
|
|
527
599
|
|
|
528
600
|
function loadPersistedSession() {
|
|
529
601
|
if (activeSessionId) return;
|
|
602
|
+
if (chainArmed()) return;
|
|
530
603
|
const pin = readPinStore();
|
|
531
604
|
if (pin.sessionId) activeSessionId = pin.sessionId;
|
|
532
605
|
}
|
|
@@ -619,18 +692,106 @@ function parseGlobalFlags(argv) {
|
|
|
619
692
|
const cliDomains = [];
|
|
620
693
|
for (let i = 0; i < argv.length; i++) {
|
|
621
694
|
const a = argv[i];
|
|
622
|
-
const equals = a.match(/^(--(?:session|session-id|allowed-domains))=(.*)$/);
|
|
695
|
+
const equals = a.match(/^(--(?:session|session-id|window|tab|handle|index|target|context|browserContextId|focusedWindowId|openerTabId|groupId|cookieStoreId|status|title|allowed-domains))=(.*)$/);
|
|
623
696
|
if (equals) {
|
|
624
697
|
if (equals[2] === '') throw new Error(`${equals[1]} requires a value`);
|
|
625
698
|
if (equals[1] === '--allowed-domains') {
|
|
626
699
|
cliDomains.push(...equals[2].split(',').map((s) => s.trim()).filter(Boolean));
|
|
700
|
+
} else if (equals[1] === '--window') {
|
|
701
|
+
wantWindowId = equals[2];
|
|
702
|
+
} else if (equals[1] === '--tab') {
|
|
703
|
+
wantTabId = equals[2];
|
|
704
|
+
} else if (equals[1] === '--handle') {
|
|
705
|
+
wantHandle = equals[2];
|
|
706
|
+
} else if (equals[1] === '--index') {
|
|
707
|
+
wantIndex = equals[2];
|
|
708
|
+
} else if (equals[1] === '--target') {
|
|
709
|
+
wantTargetId = equals[2];
|
|
710
|
+
} else if (equals[1] === '--context' || equals[1] === '--browserContextId') {
|
|
711
|
+
wantContextId = equals[2];
|
|
712
|
+
} else if (equals[1] === '--focusedWindowId') {
|
|
713
|
+
wantFocusedWindowId = equals[2];
|
|
714
|
+
} else if (equals[1] === '--openerTabId') {
|
|
715
|
+
wantOpenerTabId = equals[2];
|
|
716
|
+
} else if (equals[1] === '--groupId') {
|
|
717
|
+
wantGroupId = equals[2];
|
|
718
|
+
} else if (equals[1] === '--cookieStoreId') {
|
|
719
|
+
wantCookieStoreId = equals[2];
|
|
720
|
+
} else if (equals[1] === '--status') {
|
|
721
|
+
wantStatus = equals[2];
|
|
722
|
+
} else if (equals[1] === '--title') {
|
|
723
|
+
wantTitle = equals[2];
|
|
627
724
|
} else {
|
|
628
|
-
|
|
725
|
+
wantSessionId = equals[2];
|
|
629
726
|
}
|
|
630
727
|
} else if (a === '--session' || a === '--session-id') {
|
|
631
728
|
const value = argv[i + 1];
|
|
632
729
|
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
633
|
-
|
|
730
|
+
wantSessionId = argv[++i];
|
|
731
|
+
} else if (a === '--window') {
|
|
732
|
+
const value = argv[i + 1];
|
|
733
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
734
|
+
wantWindowId = argv[++i];
|
|
735
|
+
} else if (a === '--tab') {
|
|
736
|
+
const value = argv[i + 1];
|
|
737
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
738
|
+
wantTabId = argv[++i];
|
|
739
|
+
} else if (a === '--handle') {
|
|
740
|
+
const value = argv[i + 1];
|
|
741
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
742
|
+
wantHandle = argv[++i];
|
|
743
|
+
} else if (a === '--index') {
|
|
744
|
+
const value = argv[i + 1];
|
|
745
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
746
|
+
wantIndex = argv[++i];
|
|
747
|
+
} else if (a === '--target') {
|
|
748
|
+
const value = argv[i + 1];
|
|
749
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
750
|
+
wantTargetId = argv[++i];
|
|
751
|
+
} else if (a === '--context' || a === '--browserContextId') {
|
|
752
|
+
const value = argv[i + 1];
|
|
753
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
754
|
+
wantContextId = argv[++i];
|
|
755
|
+
} else if (a === '--focusedWindowId') {
|
|
756
|
+
const value = argv[i + 1];
|
|
757
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
758
|
+
wantFocusedWindowId = argv[++i];
|
|
759
|
+
} else if (a === '--openerTabId') {
|
|
760
|
+
const value = argv[i + 1];
|
|
761
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
762
|
+
wantOpenerTabId = argv[++i];
|
|
763
|
+
} else if (a === '--groupId') {
|
|
764
|
+
const value = argv[i + 1];
|
|
765
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
766
|
+
wantGroupId = argv[++i];
|
|
767
|
+
} else if (a === '--cookieStoreId') {
|
|
768
|
+
const value = argv[i + 1];
|
|
769
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
770
|
+
wantCookieStoreId = argv[++i];
|
|
771
|
+
} else if (a === '--status') {
|
|
772
|
+
const value = argv[i + 1];
|
|
773
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
774
|
+
wantStatus = argv[++i];
|
|
775
|
+
} else if (a === '--title') {
|
|
776
|
+
const value = argv[i + 1];
|
|
777
|
+
if (!value || value.startsWith('-')) throw new Error(`${a} requires a value`);
|
|
778
|
+
wantTitle = argv[++i];
|
|
779
|
+
} else if (a === '--active') {
|
|
780
|
+
wantActive = true;
|
|
781
|
+
} else if (a === '--attached') {
|
|
782
|
+
wantAttached = true;
|
|
783
|
+
} else if (a === '--discarded') {
|
|
784
|
+
wantDiscarded = true;
|
|
785
|
+
} else if (a === '--highlighted') {
|
|
786
|
+
wantHighlighted = true;
|
|
787
|
+
} else if (a === '--pinned') {
|
|
788
|
+
wantPinned = true;
|
|
789
|
+
} else if (a === '--current') {
|
|
790
|
+
wantCurrent = true;
|
|
791
|
+
} else if (a === '--incognito') {
|
|
792
|
+
wantIncognito = true;
|
|
793
|
+
} else if (a === '--iframe') {
|
|
794
|
+
wantIframe = true;
|
|
634
795
|
} else if (a === '--json') {
|
|
635
796
|
jsonOutput = true;
|
|
636
797
|
} else if (a === '--allowed-domains') {
|
|
@@ -642,6 +803,17 @@ function parseGlobalFlags(argv) {
|
|
|
642
803
|
}
|
|
643
804
|
}
|
|
644
805
|
allowedDomainList = resolveAllowedDomains(cliDomains);
|
|
806
|
+
if (wantSessionId) activeSessionId = wantSessionId;
|
|
807
|
+
if (chainArmed()) {
|
|
808
|
+
const hit = tabMap.resolveChain(chainOpts());
|
|
809
|
+
if (hit.row) {
|
|
810
|
+
activeSessionId = hit.row.sessionId || null;
|
|
811
|
+
} else if (chainOnlySessionId()) {
|
|
812
|
+
activeSessionId = wantSessionId;
|
|
813
|
+
} else if (hit.error && hit.error !== 'empty' && hit.error !== 'ambiguous') {
|
|
814
|
+
throw new Error(`no tab-map row for ${hit.via} (${hit.error}); run glider tabs`);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
645
817
|
return rest;
|
|
646
818
|
}
|
|
647
819
|
|
|
@@ -2371,53 +2543,48 @@ async function cmdTabs() {
|
|
|
2371
2543
|
process.exitCode = 1;
|
|
2372
2544
|
return;
|
|
2373
2545
|
}
|
|
2546
|
+
const map = tabMap.writeMap(catalog);
|
|
2374
2547
|
if (jsonOutput) {
|
|
2375
|
-
emitJson(true, { ...catalog, activeSessionId });
|
|
2548
|
+
emitJson(true, { ...catalog, activeSessionId, map });
|
|
2376
2549
|
return;
|
|
2377
2550
|
}
|
|
2378
|
-
|
|
2379
|
-
console.log(`${GREEN}${winCount}${NC} tab(s) in ${catalog.windows.length} window(s)\n`);
|
|
2380
|
-
let n = 0;
|
|
2381
|
-
for (const w of catalog.windows) {
|
|
2382
|
-
const tag = [w.current ? 'current' : 'other', w.incognito ? 'incognito' : null].filter(Boolean).join(', ');
|
|
2383
|
-
console.log(`${CYAN}window ${w.windowId}${NC} ${DIM}(${tag})${NC}`);
|
|
2384
|
-
for (const t of w.tabs || []) {
|
|
2385
|
-
n += 1;
|
|
2386
|
-
const mark = t.sessionId && t.sessionId === activeSessionId ? `${GREEN}*${NC} ` : ' ';
|
|
2387
|
-
const att = t.attached ? `${DIM} attached${NC}` : '';
|
|
2388
|
-
const disc = t.discarded ? `${DIM} discarded${NC}` : '';
|
|
2389
|
-
console.log(`${mark}${CYAN}[${n}]${NC} ${t.title || t.url}${att}${disc}`);
|
|
2390
|
-
console.log(` ${DIM}${t.url}${NC}`);
|
|
2391
|
-
}
|
|
2392
|
-
console.log();
|
|
2393
|
-
}
|
|
2394
|
-
if ((catalog.attached || []).length) {
|
|
2395
|
-
console.log(`${CYAN}attached${NC} ${DIM}(debugger, not in chrome.tabs)${NC}`);
|
|
2396
|
-
catalog.attached.forEach((t, i) => {
|
|
2397
|
-
console.log(` ${CYAN}[A${i + 1}]${NC} ${t.title || t.url}`);
|
|
2398
|
-
console.log(` ${DIM}${t.url}${NC}`);
|
|
2399
|
-
});
|
|
2400
|
-
console.log();
|
|
2401
|
-
}
|
|
2402
|
-
if ((catalog.stale || []).length) {
|
|
2403
|
-
console.log(`${YELLOW}stale${NC} ${DIM}(dropped from map)${NC}`);
|
|
2404
|
-
catalog.stale.forEach((t, i) => {
|
|
2405
|
-
console.log(` ${CYAN}[S${i + 1}]${NC} ${t.title || t.url}`);
|
|
2406
|
-
console.log(` ${DIM}${t.url}${NC}`);
|
|
2407
|
-
});
|
|
2408
|
-
}
|
|
2551
|
+
console.log(formatCatalogTui(catalog, activeSessionId));
|
|
2409
2552
|
}
|
|
2410
2553
|
|
|
2411
2554
|
async function cmdWindow(args) {
|
|
2555
|
+
const subcmd = args[0] || 'list';
|
|
2556
|
+
if (subcmd === 'list') {
|
|
2557
|
+
let catalog = await fetchCatalogQuiet();
|
|
2558
|
+
if (!catalog || catalog.listTabsOk === false) {
|
|
2559
|
+
await autoHealRelay();
|
|
2560
|
+
catalog = await fetchCatalogQuiet();
|
|
2561
|
+
}
|
|
2562
|
+
if (!catalog || catalog.error || !Array.isArray(catalog.windows)) {
|
|
2563
|
+
if (jsonOutput) {
|
|
2564
|
+
emitJson(false, null, 'catalog unavailable');
|
|
2565
|
+
process.exitCode = 1;
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
log.fail('catalog unavailable');
|
|
2569
|
+
process.exitCode = 1;
|
|
2570
|
+
return;
|
|
2571
|
+
}
|
|
2572
|
+
const map = tabMap.writeMap(catalog);
|
|
2573
|
+
if (jsonOutput) {
|
|
2574
|
+
emitJson(true, { ...catalog, activeSessionId, map });
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
console.log(formatCatalogTui(catalog, activeSessionId));
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2412
2581
|
const { WindowManager } = require(path.join(LIB_DIR, 'bwindow.js'));
|
|
2413
2582
|
const wm = new WindowManager();
|
|
2414
|
-
|
|
2583
|
+
|
|
2415
2584
|
try {
|
|
2416
2585
|
await wm.connect();
|
|
2417
2586
|
await wm.init();
|
|
2418
|
-
|
|
2419
|
-
const subcmd = args[0] || 'list';
|
|
2420
|
-
|
|
2587
|
+
|
|
2421
2588
|
switch (subcmd) {
|
|
2422
2589
|
case 'new': {
|
|
2423
2590
|
const url = args[1] || 'about:blank';
|
|
@@ -2476,20 +2643,9 @@ async function cmdWindow(args) {
|
|
|
2476
2643
|
break;
|
|
2477
2644
|
}
|
|
2478
2645
|
|
|
2479
|
-
case 'list':
|
|
2480
2646
|
default: {
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
log.warn('No windows/tabs tracked');
|
|
2484
|
-
} else {
|
|
2485
|
-
console.log(`${GREEN}${targets.length}${NC} target(s):\n`);
|
|
2486
|
-
targets.forEach((t, i) => {
|
|
2487
|
-
const marker = t.createdByGlider ? `${GREEN}●${NC}` : `${DIM}○${NC}`;
|
|
2488
|
-
console.log(` ${marker} ${CYAN}${t.targetId.substring(0, 16)}...${NC}`);
|
|
2489
|
-
console.log(` ${DIM}${t.url || 'unknown'}${NC}`);
|
|
2490
|
-
});
|
|
2491
|
-
}
|
|
2492
|
-
break;
|
|
2647
|
+
log.fail(`Unknown window subcommand: ${subcmd}`);
|
|
2648
|
+
process.exit(1);
|
|
2493
2649
|
}
|
|
2494
2650
|
}
|
|
2495
2651
|
} catch (err) {
|
|
@@ -2680,10 +2836,58 @@ async function cmdTargets() {
|
|
|
2680
2836
|
|
|
2681
2837
|
async function cmdUseSession(arg, opts = []) {
|
|
2682
2838
|
const argv = [arg, ...opts].filter((value) => value !== undefined);
|
|
2683
|
-
const parsed = parseFlags(argv, {
|
|
2684
|
-
|
|
2839
|
+
const parsed = parseFlags(argv, {
|
|
2840
|
+
url: { type: 'string' },
|
|
2841
|
+
window: { type: 'string' },
|
|
2842
|
+
tab: { type: 'string' },
|
|
2843
|
+
session: { type: 'string' },
|
|
2844
|
+
handle: { type: 'string' },
|
|
2845
|
+
index: { type: 'string' },
|
|
2846
|
+
target: { type: 'string' },
|
|
2847
|
+
context: { type: 'string' },
|
|
2848
|
+
current: { type: 'boolean' },
|
|
2849
|
+
incognito: { type: 'boolean' },
|
|
2850
|
+
iframe: { type: 'boolean' },
|
|
2851
|
+
});
|
|
2852
|
+
const token = parsed._[0] || null;
|
|
2853
|
+
const handle = parsed.handle || wantHandle || (token && tabMap.lookslikeHandle(token) ? token : null);
|
|
2854
|
+
const sessionFromPos = token && !tabMap.lookslikeHandle(token) ? token : '';
|
|
2855
|
+
const chain = {
|
|
2856
|
+
...chainOpts(),
|
|
2857
|
+
windowId: parsed.window || wantWindowId,
|
|
2858
|
+
tabId: parsed.tab || wantTabId,
|
|
2859
|
+
sessionId: parsed.session || sessionFromPos || wantSessionId,
|
|
2860
|
+
index: parsed.index || wantIndex,
|
|
2861
|
+
targetId: parsed.target || wantTargetId,
|
|
2862
|
+
browserContextId: parsed.context || wantContextId,
|
|
2863
|
+
handle,
|
|
2864
|
+
current: parsed.current || wantCurrent,
|
|
2865
|
+
incognito: parsed.incognito || wantIncognito,
|
|
2866
|
+
iframe: parsed.iframe || wantIframe,
|
|
2867
|
+
};
|
|
2868
|
+
let requestedSession = '';
|
|
2869
|
+
if (chainArmed() || handle || chain.sessionId || parsed.window || parsed.tab || parsed.session || parsed.handle || parsed.index
|
|
2870
|
+
|| parsed.target || parsed.context || parsed.current || parsed.incognito || parsed.iframe) {
|
|
2871
|
+
const hit = tabMap.resolveChain(chain);
|
|
2872
|
+
if (hit.row) {
|
|
2873
|
+
if (!hit.row.sessionId) {
|
|
2874
|
+
const message = `not attached (${hit.via || 'ref'})`;
|
|
2875
|
+
if (jsonOutput) emitJson(false, hit.row, message);
|
|
2876
|
+
log.fail(message);
|
|
2877
|
+
process.exit(1);
|
|
2878
|
+
}
|
|
2879
|
+
requestedSession = hit.row.sessionId;
|
|
2880
|
+
} else if (chainOnlySessionIdMerged(chain)) {
|
|
2881
|
+
requestedSession = chain.sessionId;
|
|
2882
|
+
} else {
|
|
2883
|
+
const message = `no tab-map row for ${hit.via || 'ref'} (${hit.error || 'empty'}); run glider tabs`;
|
|
2884
|
+
if (jsonOutput) emitJson(false, null, message);
|
|
2885
|
+
log.fail(message);
|
|
2886
|
+
process.exit(1);
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2685
2889
|
if (!requestedSession && !parsed.url) {
|
|
2686
|
-
log.fail('Usage: glider
|
|
2890
|
+
log.fail('Usage: glider [--current] [--incognito] [--window W] [--index N] [--handle n] [--tab T] [--target id] [--session S] [--iframe] pin');
|
|
2687
2891
|
process.exit(1);
|
|
2688
2892
|
}
|
|
2689
2893
|
const raw = await httpGet('/targets');
|
|
@@ -3244,6 +3448,114 @@ function maskCookieValue(v) {
|
|
|
3244
3448
|
return s.slice(0, 12) + '...(' + (s.length - 20) + ' chars)...' + s.slice(-6);
|
|
3245
3449
|
}
|
|
3246
3450
|
|
|
3451
|
+
async function fetchExtensionCookieHeaderLine(host) {
|
|
3452
|
+
const url = /^https?:\/\//i.test(host) ? host : `https://${host}/`;
|
|
3453
|
+
if (!await ensureConnected()) process.exit(1);
|
|
3454
|
+
const payload = await httpPost('/extension', {
|
|
3455
|
+
method: 'getCookies',
|
|
3456
|
+
params: { url },
|
|
3457
|
+
});
|
|
3458
|
+
if (!payload || payload.error) {
|
|
3459
|
+
throw new Error(payload?.error || 'no response from extension');
|
|
3460
|
+
}
|
|
3461
|
+
let cookies = payload.data || payload.result?.cookies || payload.cookies || [];
|
|
3462
|
+
if (!Array.isArray(cookies)) throw new Error('unexpected response shape from extension');
|
|
3463
|
+
const nowSec = Math.floor(Date.now() / 1000);
|
|
3464
|
+
const line = cookies
|
|
3465
|
+
.filter((c) => !c.expirationDate || c.expirationDate >= nowSec)
|
|
3466
|
+
.map((c) => `${c.name}=${c.value}`)
|
|
3467
|
+
.join('; ');
|
|
3468
|
+
return line;
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3471
|
+
async function cmdCookieJar(opts = []) {
|
|
3472
|
+
const cj = require(path.join(LIB_DIR, 'cookie-jar.js'));
|
|
3473
|
+
const sub = opts[0] || 'sync';
|
|
3474
|
+
const arg = opts[1];
|
|
3475
|
+
const fetchLive = (domain) => fetchExtensionCookieHeaderLine(domain);
|
|
3476
|
+
|
|
3477
|
+
if (sub === '--help' || sub === '-h' || sub === 'help') {
|
|
3478
|
+
console.log('Usage: glider cookie-jar sync [domain] | read <domain> | age <domain> | list | add <domain> | rm <domain> | rebuild');
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3481
|
+
|
|
3482
|
+
const needsRelay = new Set(['sync', 'read']);
|
|
3483
|
+
if (needsRelay.has(sub)) {
|
|
3484
|
+
if (!await checkServer()) {
|
|
3485
|
+
log.info('Server not running, starting...');
|
|
3486
|
+
await cmdStart({ render: false });
|
|
3487
|
+
}
|
|
3488
|
+
if (!await ensureConnected()) process.exit(1);
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
try {
|
|
3492
|
+
if (sub === 'sync') {
|
|
3493
|
+
if (arg) {
|
|
3494
|
+
const r = await cj.syncOne(arg, fetchLive);
|
|
3495
|
+
log.ok(`${r.domain}: ${r.count} cookies synced`);
|
|
3496
|
+
} else {
|
|
3497
|
+
const r = await cj.syncAll(fetchLive);
|
|
3498
|
+
console.log(`synced ${r.ok}, failed ${r.fail}`);
|
|
3499
|
+
if (r.fail) process.exitCode = 1;
|
|
3500
|
+
}
|
|
3501
|
+
return;
|
|
3502
|
+
}
|
|
3503
|
+
if (sub === 'read') {
|
|
3504
|
+
if (!arg) {
|
|
3505
|
+
log.fail('Usage: glider cookie-jar read <domain>');
|
|
3506
|
+
process.exit(1);
|
|
3507
|
+
}
|
|
3508
|
+
const line = await cj.readDomain(arg, fetchLive, (msg) => log.warn(msg));
|
|
3509
|
+
console.log(line);
|
|
3510
|
+
return;
|
|
3511
|
+
}
|
|
3512
|
+
if (sub === 'age') {
|
|
3513
|
+
if (!arg) {
|
|
3514
|
+
log.fail('Usage: glider cookie-jar age <domain>');
|
|
3515
|
+
process.exit(1);
|
|
3516
|
+
}
|
|
3517
|
+
console.log(cj.ageDomain(arg));
|
|
3518
|
+
return;
|
|
3519
|
+
}
|
|
3520
|
+
if (sub === 'list') {
|
|
3521
|
+
console.log(`${'DOMAIN'.padEnd(30)} ${'AGE(s)'.padStart(8)} ${'STALE'.padStart(6)}`);
|
|
3522
|
+
for (const row of cj.listJars()) {
|
|
3523
|
+
console.log(`${row.domain.padEnd(30)} ${row.age.padStart(8)} ${row.stale.padStart(6)}`);
|
|
3524
|
+
}
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
if (sub === 'add') {
|
|
3528
|
+
if (!arg) {
|
|
3529
|
+
log.fail('Usage: glider cookie-jar add <domain>');
|
|
3530
|
+
process.exit(1);
|
|
3531
|
+
}
|
|
3532
|
+
const r = cj.addDomain(arg);
|
|
3533
|
+
console.log(r.added ? `added ${r.domain}` : `${r.domain} already tracked`);
|
|
3534
|
+
return;
|
|
3535
|
+
}
|
|
3536
|
+
if (sub === 'rm') {
|
|
3537
|
+
if (!arg) {
|
|
3538
|
+
log.fail('Usage: glider cookie-jar rm <domain>');
|
|
3539
|
+
process.exit(1);
|
|
3540
|
+
}
|
|
3541
|
+
const r = cj.rmDomain(arg);
|
|
3542
|
+
console.log(r.removed ? `removed ${r.domain}` : `${r.domain} not tracked`);
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
if (sub === 'rebuild') {
|
|
3546
|
+
const r = cj.rebuildDomains();
|
|
3547
|
+
console.log(`rebuilt ${r.path}: ${r.count} domain(s)`);
|
|
3548
|
+
return;
|
|
3549
|
+
}
|
|
3550
|
+
log.fail(`unknown: ${sub}. try: sync|read|age|list|add|rm|rebuild`);
|
|
3551
|
+
process.exit(1);
|
|
3552
|
+
} catch (e) {
|
|
3553
|
+
if (e.code === 'SYNC_EMPTY' || e.code === 'READ_MISS') log.fail(e.message);
|
|
3554
|
+
else log.fail(e.message);
|
|
3555
|
+
process.exit(1);
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3247
3559
|
// Spawn multiple tabs
|
|
3248
3560
|
async function cmdSpawn(urls) {
|
|
3249
3561
|
if (!urls || urls.length === 0) {
|
|
@@ -3859,7 +4171,7 @@ function showHelp() {
|
|
|
3859
4171
|
showBanner();
|
|
3860
4172
|
console.log(`
|
|
3861
4173
|
${B5}USAGE${NC}
|
|
3862
|
-
glider [--session <id>] [--json] [--allowed-domains 'host,*'] <command> [args]
|
|
4174
|
+
glider [--current] [--incognito] [--window <id>] [--index N] [--handle n] [--tab <tabId>] [--target id] [--session <id>] [--iframe] [--json] [--allowed-domains 'host,*'] <command> [args]
|
|
3863
4175
|
${DIM}GLIDER_SESSION_ID=session-N${NC} ${DIM}pin tab for all /cdp commands${NC}
|
|
3864
4176
|
|
|
3865
4177
|
${B5}SETUP${NC}
|
|
@@ -3891,7 +4203,7 @@ ${B5}PAGE INFO${NC}
|
|
|
3891
4203
|
${BW}html${NC} [selector] Get HTML
|
|
3892
4204
|
${BW}title${NC} Get page title
|
|
3893
4205
|
${BW}url${NC} Get current URL
|
|
3894
|
-
${BW}tabs${NC} chrome.tabs by window
|
|
4206
|
+
${BW}tabs${NC} chrome.tabs by window; status under URL ${DIM}(--json for agents)${NC}
|
|
3895
4207
|
|
|
3896
4208
|
${B5}MULTI-WINDOW${NC}
|
|
3897
4209
|
${BW}window new${NC} [url] Create new browser window ${DIM}(closeable)${NC}
|
|
@@ -3903,7 +4215,7 @@ ${B5}MULTI-WINDOW${NC}
|
|
|
3903
4215
|
|
|
3904
4216
|
${B5}MULTI-TAB${NC}
|
|
3905
4217
|
${BW}targets${NC} List targets ${DIM}(sessionId, title, url)${NC}
|
|
3906
|
-
${BW}use-session${NC}
|
|
4218
|
+
${BW}use${NC} / ${BW}use-session${NC} Pin window→tab→session (handle n, --url)
|
|
3907
4219
|
${BW}fetch${NC} <url> Fetch URL with browser session ${DIM}(auth)${NC}
|
|
3908
4220
|
${BW}spawn${NC} <urls...> Open multiple tabs
|
|
3909
4221
|
${BW}extract${NC} [opts] Extract from all tabs
|
|
@@ -4034,6 +4346,7 @@ ${YELLOW}DOMAIN EXTENSIONS:${NC}
|
|
|
4034
4346
|
console.log(` ${GREEN}${'emulate'.padEnd(16)}${NC} ${DIM}tz | geo | viewport | offline | ua | color-scheme${NC}`);
|
|
4035
4347
|
console.log(` ${GREEN}${'storage'.padEnd(16)}${NC} ${DIM}get | set | delete | keys | jar (localStorage)${NC}`);
|
|
4036
4348
|
console.log(` ${GREEN}${'cookies'.padEnd(16)}${NC} ${DIM}(read: no flags) | --set NAME=VAL --host H | --delete NAME --host H${NC}`);
|
|
4349
|
+
console.log(` ${GREEN}${'cookie-jar'.padEnd(16)}${NC} ${DIM}sync [domain] | read | age | list | add | rm | rebuild${NC}`);
|
|
4037
4350
|
console.log(` ${GREEN}${'history'.padEnd(16)}${NC} ${DIM}back | forward | reload${NC}`);
|
|
4038
4351
|
console.log(` ${GREEN}${'dialog'.padEnd(16)}${NC} ${DIM}dialog auto accept|dismiss${NC}`);
|
|
4039
4352
|
console.log(` ${GREEN}${'console'.padEnd(16)}${NC} ${DIM}tail | dump (partial: exits 2 until event streaming lands)${NC}`);
|
|
@@ -5395,7 +5708,7 @@ async function main() {
|
|
|
5395
5708
|
|
|
5396
5709
|
const relayIndependent = new Set([
|
|
5397
5710
|
'help', '--help', '-h', 'update', 'version', '-v', '--version',
|
|
5398
|
-
'config', 'domains', 'resolve',
|
|
5711
|
+
'config', 'domains', 'resolve', 'cookie-jar',
|
|
5399
5712
|
]);
|
|
5400
5713
|
if (relayConfigError && !relayIndependent.has(cmd)) {
|
|
5401
5714
|
throw relayConfigError;
|
|
@@ -5413,7 +5726,7 @@ async function main() {
|
|
|
5413
5726
|
'start', 'stop', 'restart', 'status', 'test', 'doctor', 'heal', 'connect',
|
|
5414
5727
|
'install', 'uninstall', 'config',
|
|
5415
5728
|
'help', '--help', '-h', 'update', 'version', '-v', '--version',
|
|
5416
|
-
'domains', 'resolve',
|
|
5729
|
+
'domains', 'resolve', 'cookie-jar',
|
|
5417
5730
|
]);
|
|
5418
5731
|
if (!noRelayPreflight.has(cmd)) {
|
|
5419
5732
|
if (!await checkServer()) {
|
|
@@ -5481,6 +5794,7 @@ async function main() {
|
|
|
5481
5794
|
case 'targets':
|
|
5482
5795
|
await cmdTargets();
|
|
5483
5796
|
break;
|
|
5797
|
+
case 'pin':
|
|
5484
5798
|
case 'use-session':
|
|
5485
5799
|
await cmdUseSessionV2(args[1], args.slice(2));
|
|
5486
5800
|
break;
|
|
@@ -5625,6 +5939,9 @@ async function main() {
|
|
|
5625
5939
|
await cmdCookies(args.slice(1));
|
|
5626
5940
|
}
|
|
5627
5941
|
break;
|
|
5942
|
+
case 'cookie-jar':
|
|
5943
|
+
await cmdCookieJar(args.slice(1));
|
|
5944
|
+
break;
|
|
5628
5945
|
case 'spawn':
|
|
5629
5946
|
await cmdSpawn(args.slice(1));
|
|
5630
5947
|
break;
|
package/docs/setup.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"project": "glidercli",
|
|
4
|
-
"updated": "2026-
|
|
4
|
+
"updated": "2026-11-03"
|
|
5
5
|
},
|
|
6
6
|
"architecture": {
|
|
7
7
|
"flow": "glidercli -> bserve (localhost relay) -> Chromium extension -> chrome.debugger -> tab",
|
|
@@ -43,7 +43,11 @@
|
|
|
43
43
|
"registry_base": "$GLIDER",
|
|
44
44
|
"resolve": "glider resolve <url> --json",
|
|
45
45
|
"browser": "$GLIDER/config/browser.json",
|
|
46
|
-
"daemon_log": "$GLIDER/daemon.log"
|
|
46
|
+
"daemon_log": "$GLIDER/daemon.log",
|
|
47
|
+
"cookies_jar": "$GLIDER/cookies/<host>/header.txt",
|
|
48
|
+
"cookies_index": "$GLIDER/cookies/domains.json",
|
|
49
|
+
"cookie_jar_verb": "glider cookie-jar sync|read|list|add|rm|rebuild",
|
|
50
|
+
"cookie_jar_extra_warch": "GLIDER_EXTRA_WARCH_ROOT (optional, path-separated) for rebuild scan"
|
|
47
51
|
},
|
|
48
52
|
"discovery": "glider --help"
|
|
49
53
|
}
|