glidercli 0.3.18 → 0.3.20

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 CHANGED
@@ -1445,25 +1445,40 @@ async function cmdCorsFetch(url, opts = []) {
1445
1445
  }
1446
1446
 
1447
1447
  try {
1448
- const result = await httpPost('/extension', {
1449
- method: 'corsFetch',
1450
- params: {
1451
- url,
1452
- options: { method, body, headers: { 'Accept': 'application/json' } }
1453
- }
1454
- });
1455
-
1448
+ // Browser-typical Accept by default (unlocks Yammer-family 406-strict endpoints).
1449
+ const defaultAccept = 'application/json, text/plain, */*';
1450
+ async function doFetch(acceptHeader) {
1451
+ return httpPost('/extension', {
1452
+ method: 'corsFetch',
1453
+ params: {
1454
+ url,
1455
+ options: { method, body, headers: { 'Accept': acceptHeader } }
1456
+ }
1457
+ });
1458
+ }
1459
+
1460
+ let result = await doFetch(defaultAccept);
1461
+ // /extension response envelope varies (flat vs wrapped); normalize
1462
+ let payload = result?.result ?? result;
1463
+ // 2-shot Accept fallback: if server returns 406 on the loose Accept, retry strict
1464
+ if (payload?.status === 406) {
1465
+ result = await doFetch('application/json');
1466
+ payload = result?.result ?? result;
1467
+ }
1468
+
1456
1469
  if (result?.error) {
1457
1470
  log.fail(`Fetch error: ${result.error}`);
1458
1471
  process.exit(1);
1459
1472
  }
1460
-
1461
- const data = result?.result?.data;
1462
- const output = typeof data === 'object' ? JSON.stringify(data, null, 2) : data;
1473
+
1474
+ // cli_gap: cfetch_empty_response_crash - data may be undefined/null on empty bodies
1475
+ let data = payload?.data;
1476
+ if (data === undefined || data === null) data = '';
1477
+ const output = typeof data === 'object' ? JSON.stringify(data, null, 2) : String(data);
1463
1478
 
1464
1479
  if (outputFile) {
1465
1480
  fs.writeFileSync(outputFile, output);
1466
- log.ok(`Saved to ${outputFile} (status: ${result?.result?.status})`);
1481
+ log.ok(`Saved to ${outputFile} (status: ${payload?.status})`);
1467
1482
  } else {
1468
1483
  console.log(output);
1469
1484
  }
package/lib/bexplore.js CHANGED
@@ -822,7 +822,22 @@ class SiteExplorer {
822
822
  console.error(`[explore] HAR saved: ${this.harFile}`);
823
823
  }
824
824
 
825
- close() {
825
+ async close() {
826
+ // F1: detach the CDP session before closing WS so the extension's chrome.debugger
827
+ // registry doesn't leak an attached target. Without this, every explore run leaves
828
+ // a phantom attach subscription that eventually saturates the relay and causes
829
+ // future Target.setAutoAttach calls to time out for ALL subsequent runs.
830
+ try {
831
+ if (this.ws && this.ws.readyState === 1 && this.sessionId) {
832
+ await Promise.race([
833
+ this.send('Target.detachFromTarget', { sessionId: this.sessionId }, { noWait: false })
834
+ .catch(() => {}),
835
+ new Promise((r) => setTimeout(r, 1500)),
836
+ ]);
837
+ }
838
+ } catch (_e) {
839
+ // best-effort; never let cleanup itself throw
840
+ }
826
841
  if (this.ws) this.ws.close();
827
842
  }
828
843
  }
@@ -939,7 +954,7 @@ Examples:
939
954
  }
940
955
  process.exit(1);
941
956
  } finally {
942
- explorer.close();
957
+ await explorer.close();
943
958
  }
944
959
  }
945
960
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glidercli",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
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": {