cbrowser 7.4.18 → 7.4.19
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/dist/browser.d.ts +26 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +127 -4
- package/dist/browser.js.map +1 -1
- package/dist/cli.js +136 -6
- package/dist/cli.js.map +1 -1
- package/dist/mcp-server-remote.d.ts.map +1 -1
- package/dist/mcp-server-remote.js +20 -6
- package/dist/mcp-server-remote.js.map +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +18 -4
- package/dist/mcp-server.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1768,9 +1768,13 @@ Documentation: https://github.com/alexandriashai/cbrowser/wiki
|
|
|
1768
1768
|
console.error("Error: Session name required");
|
|
1769
1769
|
process.exit(1);
|
|
1770
1770
|
}
|
|
1771
|
-
const
|
|
1772
|
-
if (
|
|
1771
|
+
const loadResult = await browser.loadSession(name);
|
|
1772
|
+
if (loadResult.success) {
|
|
1773
1773
|
console.log(`✓ Session loaded: ${name}`);
|
|
1774
|
+
console.log(` Cookies: ${loadResult.cookiesRestored}, localStorage: ${loadResult.localStorageKeysRestored}, sessionStorage: ${loadResult.sessionStorageKeysRestored}`);
|
|
1775
|
+
if (loadResult.warning) {
|
|
1776
|
+
console.log(` ⚠️ ${loadResult.warning}`);
|
|
1777
|
+
}
|
|
1774
1778
|
}
|
|
1775
1779
|
else {
|
|
1776
1780
|
console.error(`✗ Session not found: ${name}`);
|
|
@@ -1779,15 +1783,133 @@ Documentation: https://github.com/alexandriashai/cbrowser/wiki
|
|
|
1779
1783
|
break;
|
|
1780
1784
|
}
|
|
1781
1785
|
case "list": {
|
|
1782
|
-
const sessions = browser.
|
|
1786
|
+
const sessions = browser.listSessionsDetailed();
|
|
1783
1787
|
if (sessions.length === 0) {
|
|
1784
1788
|
console.log("No saved sessions");
|
|
1785
1789
|
}
|
|
1786
1790
|
else {
|
|
1787
1791
|
console.log("\n📋 Saved Sessions:\n");
|
|
1788
|
-
|
|
1789
|
-
|
|
1792
|
+
// Table header
|
|
1793
|
+
const nameW = Math.max(16, ...sessions.map((s) => s.name.length)) + 2;
|
|
1794
|
+
const domainW = Math.max(16, ...sessions.map((s) => s.domain.length)) + 2;
|
|
1795
|
+
console.log(` ${"Name".padEnd(nameW)}${"Domain".padEnd(domainW)}${"Created".padEnd(22)}${"Cookies".padEnd(10)}${"Size".padEnd(10)}`);
|
|
1796
|
+
console.log(` ${"─".repeat(nameW)}${"─".repeat(domainW)}${"─".repeat(22)}${"─".repeat(10)}${"─".repeat(10)}`);
|
|
1797
|
+
for (const s of sessions) {
|
|
1798
|
+
const created = new Date(s.created).toLocaleString("en-US", {
|
|
1799
|
+
month: "short", day: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit",
|
|
1800
|
+
});
|
|
1801
|
+
const size = s.sizeBytes < 1024
|
|
1802
|
+
? `${s.sizeBytes} B`
|
|
1803
|
+
: `${(s.sizeBytes / 1024).toFixed(1)} KB`;
|
|
1804
|
+
console.log(` ${s.name.padEnd(nameW)}${s.domain.padEnd(domainW)}${created.padEnd(22)}${String(s.cookies).padEnd(10)}${size.padEnd(10)}`);
|
|
1790
1805
|
}
|
|
1806
|
+
console.log();
|
|
1807
|
+
}
|
|
1808
|
+
break;
|
|
1809
|
+
}
|
|
1810
|
+
case "show": {
|
|
1811
|
+
if (!name) {
|
|
1812
|
+
console.error("Error: Session name required");
|
|
1813
|
+
process.exit(1);
|
|
1814
|
+
}
|
|
1815
|
+
const details = browser.getSessionDetails(name);
|
|
1816
|
+
if (!details) {
|
|
1817
|
+
console.error(`✗ Session not found: ${name}`);
|
|
1818
|
+
process.exit(1);
|
|
1819
|
+
}
|
|
1820
|
+
const fs = await import("fs");
|
|
1821
|
+
const path = await import("path");
|
|
1822
|
+
const sessionPath = path.join(browser["paths"].sessionsDir, `${name}.json`);
|
|
1823
|
+
const fileSize = fs.statSync(sessionPath).size;
|
|
1824
|
+
console.log(`\n📋 Session: ${name}\n`);
|
|
1825
|
+
console.log(` Domain: ${details.domain}`);
|
|
1826
|
+
console.log(` URL: ${details.url}`);
|
|
1827
|
+
console.log(` Created: ${new Date(details.created).toLocaleString()}`);
|
|
1828
|
+
console.log(` Last Used: ${new Date(details.lastUsed).toLocaleString()}`);
|
|
1829
|
+
console.log(` Viewport: ${details.viewport.width}x${details.viewport.height}`);
|
|
1830
|
+
console.log(` File Size: ${(fileSize / 1024).toFixed(1)} KB`);
|
|
1831
|
+
console.log(`\n Cookies (${details.cookies.length}):`);
|
|
1832
|
+
if (details.cookies.length > 0) {
|
|
1833
|
+
const domains = [...new Set(details.cookies.map((c) => c.domain))];
|
|
1834
|
+
for (const d of domains) {
|
|
1835
|
+
const count = details.cookies.filter((c) => c.domain === d).length;
|
|
1836
|
+
console.log(` ${d}: ${count}`);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
console.log(`\n localStorage (${Object.keys(details.localStorage).length} keys):`);
|
|
1840
|
+
for (const key of Object.keys(details.localStorage).slice(0, 10)) {
|
|
1841
|
+
const val = details.localStorage[key];
|
|
1842
|
+
const preview = val.length > 60 ? val.substring(0, 60) + "..." : val;
|
|
1843
|
+
console.log(` ${key}: ${preview}`);
|
|
1844
|
+
}
|
|
1845
|
+
if (Object.keys(details.localStorage).length > 10) {
|
|
1846
|
+
console.log(` ... and ${Object.keys(details.localStorage).length - 10} more`);
|
|
1847
|
+
}
|
|
1848
|
+
console.log(`\n sessionStorage (${Object.keys(details.sessionStorage).length} keys):`);
|
|
1849
|
+
for (const key of Object.keys(details.sessionStorage).slice(0, 10)) {
|
|
1850
|
+
const val = details.sessionStorage[key];
|
|
1851
|
+
const preview = val.length > 60 ? val.substring(0, 60) + "..." : val;
|
|
1852
|
+
console.log(` ${key}: ${preview}`);
|
|
1853
|
+
}
|
|
1854
|
+
if (Object.keys(details.sessionStorage).length > 10) {
|
|
1855
|
+
console.log(` ... and ${Object.keys(details.sessionStorage).length - 10} more`);
|
|
1856
|
+
}
|
|
1857
|
+
if (details.testCredentials) {
|
|
1858
|
+
console.log(`\n Test Credentials: ${details.testCredentials.email} @ ${details.testCredentials.baseUrl}`);
|
|
1859
|
+
}
|
|
1860
|
+
console.log();
|
|
1861
|
+
break;
|
|
1862
|
+
}
|
|
1863
|
+
case "cleanup": {
|
|
1864
|
+
const olderThan = parseInt(options["older-than"] || "30", 10);
|
|
1865
|
+
if (isNaN(olderThan) || olderThan <= 0) {
|
|
1866
|
+
console.error("Error: --older-than must be a positive number of days");
|
|
1867
|
+
process.exit(1);
|
|
1868
|
+
}
|
|
1869
|
+
const result = browser.cleanupSessions(olderThan);
|
|
1870
|
+
if (result.deleted.length === 0) {
|
|
1871
|
+
console.log(`No sessions older than ${olderThan} days`);
|
|
1872
|
+
}
|
|
1873
|
+
else {
|
|
1874
|
+
console.log(`\n🧹 Cleaned up ${result.deleted.length} session(s):\n`);
|
|
1875
|
+
for (const d of result.deleted) {
|
|
1876
|
+
console.log(` ✓ Deleted: ${d}`);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
console.log(` ${result.kept.length} session(s) kept`);
|
|
1880
|
+
break;
|
|
1881
|
+
}
|
|
1882
|
+
case "export": {
|
|
1883
|
+
if (!name) {
|
|
1884
|
+
console.error("Error: Session name required");
|
|
1885
|
+
process.exit(1);
|
|
1886
|
+
}
|
|
1887
|
+
const output = options.output || `${name}.json`;
|
|
1888
|
+
const exported = browser.exportSession(name, output);
|
|
1889
|
+
if (exported) {
|
|
1890
|
+
console.log(`✓ Session exported: ${name} → ${output}`);
|
|
1891
|
+
}
|
|
1892
|
+
else {
|
|
1893
|
+
console.error(`✗ Session not found: ${name}`);
|
|
1894
|
+
process.exit(1);
|
|
1895
|
+
}
|
|
1896
|
+
break;
|
|
1897
|
+
}
|
|
1898
|
+
case "import": {
|
|
1899
|
+
// args[0] = "import", args[1] = file path
|
|
1900
|
+
const filePath = args[1];
|
|
1901
|
+
if (!filePath) {
|
|
1902
|
+
console.error("Error: File path required");
|
|
1903
|
+
process.exit(1);
|
|
1904
|
+
}
|
|
1905
|
+
const importName = options.name || filePath.replace(/\.json$/, "").split("/").pop();
|
|
1906
|
+
const imported = browser.importSession(filePath, importName);
|
|
1907
|
+
if (imported) {
|
|
1908
|
+
console.log(`✓ Session imported: ${filePath} → ${importName}`);
|
|
1909
|
+
}
|
|
1910
|
+
else {
|
|
1911
|
+
console.error(`✗ Failed to import session from: ${filePath}`);
|
|
1912
|
+
process.exit(1);
|
|
1791
1913
|
}
|
|
1792
1914
|
break;
|
|
1793
1915
|
}
|
|
@@ -1806,7 +1928,15 @@ Documentation: https://github.com/alexandriashai/cbrowser/wiki
|
|
|
1806
1928
|
break;
|
|
1807
1929
|
}
|
|
1808
1930
|
default:
|
|
1809
|
-
console.error("Usage: cbrowser session [save|load|list|delete] <name>");
|
|
1931
|
+
console.error("Usage: cbrowser session [save|load|list|show|delete|cleanup|export|import] <name>");
|
|
1932
|
+
console.error("\n save <name> Save current session");
|
|
1933
|
+
console.error(" load <name> Load a saved session");
|
|
1934
|
+
console.error(" list List all sessions with metadata");
|
|
1935
|
+
console.error(" show <name> Show detailed session info");
|
|
1936
|
+
console.error(" delete <name> Delete a session");
|
|
1937
|
+
console.error(" cleanup --older-than <days> Delete old sessions");
|
|
1938
|
+
console.error(" export <name> --output <file> Export session to file");
|
|
1939
|
+
console.error(" import <file> --name <name> Import session from file");
|
|
1810
1940
|
}
|
|
1811
1941
|
break;
|
|
1812
1942
|
}
|