bb-browser 0.4.1 → 0.4.2
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/cli.js +39 -8
- package/dist/cli.js.map +1 -1
- package/dist/mcp.js +60 -14
- package/dist/mcp.js.map +1 -1
- package/extension/background.js +700 -543
- package/extension/background.js.map +1 -1
- package/extension/dist/manifest.json +1 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -31,7 +31,14 @@ async function sendCommand(request) {
|
|
|
31
31
|
return {
|
|
32
32
|
id: request.id,
|
|
33
33
|
success: false,
|
|
34
|
-
error:
|
|
34
|
+
error: [
|
|
35
|
+
"Chrome extension not connected.",
|
|
36
|
+
"",
|
|
37
|
+
"1. Download extension: https://github.com/epiral/bb-browser/releases/latest",
|
|
38
|
+
"2. Unzip the downloaded file",
|
|
39
|
+
"3. Open chrome://extensions/ \u2192 Enable Developer Mode",
|
|
40
|
+
'4. Click "Load unpacked" \u2192 select the unzipped folder'
|
|
41
|
+
].join("\n")
|
|
35
42
|
};
|
|
36
43
|
}
|
|
37
44
|
return {
|
|
@@ -52,7 +59,15 @@ async function sendCommand(request) {
|
|
|
52
59
|
};
|
|
53
60
|
}
|
|
54
61
|
if (error.message.includes("fetch failed") || error.message.includes("ECONNREFUSED")) {
|
|
55
|
-
throw new Error(
|
|
62
|
+
throw new Error([
|
|
63
|
+
"Cannot connect to daemon.",
|
|
64
|
+
"",
|
|
65
|
+
"Start the daemon first:",
|
|
66
|
+
" bb-browser daemon",
|
|
67
|
+
"",
|
|
68
|
+
"Then load the Chrome extension:",
|
|
69
|
+
" chrome://extensions/ \u2192 Developer Mode \u2192 Load unpacked \u2192 node_modules/bb-browser/extension/"
|
|
70
|
+
].join("\n"));
|
|
56
71
|
}
|
|
57
72
|
throw error;
|
|
58
73
|
}
|
|
@@ -1845,9 +1860,13 @@ async function siteRun(name, args, options) {
|
|
|
1845
1860
|
const evalReq = { id: generateId(), action: "eval", script, tabId: targetTabId };
|
|
1846
1861
|
const evalResp = await sendCommand(evalReq);
|
|
1847
1862
|
if (!evalResp.success) {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1863
|
+
const hint = site.domain ? `Open https://${site.domain} in your browser, make sure you are logged in, then retry.` : void 0;
|
|
1864
|
+
if (options.json) {
|
|
1865
|
+
console.log(JSON.stringify({ id: evalReq.id, success: false, error: evalResp.error || "eval failed", hint }));
|
|
1866
|
+
} else {
|
|
1867
|
+
console.error(`[error] site ${name}: ${evalResp.error || "eval failed"}`);
|
|
1868
|
+
if (hint) console.error(` Hint: ${hint}`);
|
|
1869
|
+
}
|
|
1851
1870
|
process.exit(1);
|
|
1852
1871
|
}
|
|
1853
1872
|
const result = evalResp.data?.result;
|
|
@@ -1867,11 +1886,18 @@ async function siteRun(name, args, options) {
|
|
|
1867
1886
|
}
|
|
1868
1887
|
if (typeof parsed === "object" && parsed !== null && "error" in parsed) {
|
|
1869
1888
|
const errObj = parsed;
|
|
1889
|
+
const checkText = `${errObj.error} ${errObj.hint || ""}`;
|
|
1890
|
+
const isAuthError = /401|403|unauthorized|forbidden|not.?logged|login.?required|sign.?in|auth/i.test(checkText);
|
|
1891
|
+
const loginHint = isAuthError && site.domain ? `Please log in to https://${site.domain} in your browser first, then retry.` : void 0;
|
|
1892
|
+
const hint = loginHint || errObj.hint;
|
|
1893
|
+
const reportHint = `If this is an adapter bug, report via: gh issue create --repo epiral/bb-sites --title "[${name}] <description>" OR: bb-browser site github/issue-create epiral/bb-sites --title "[${name}] <description>"`;
|
|
1870
1894
|
if (options.json) {
|
|
1871
|
-
console.log(JSON.stringify({ id: evalReq.id, success: false, error: errObj.error, hint
|
|
1895
|
+
console.log(JSON.stringify({ id: evalReq.id, success: false, error: errObj.error, hint, reportHint }));
|
|
1872
1896
|
} else {
|
|
1873
1897
|
console.error(`[error] site ${name}: ${errObj.error}`);
|
|
1874
|
-
if (
|
|
1898
|
+
if (hint) console.error(` Hint: ${hint}`);
|
|
1899
|
+
console.error(` Report: gh issue create --repo epiral/bb-sites --title "[${name}] ..."`);
|
|
1900
|
+
console.error(` or: bb-browser site github/issue-create epiral/bb-sites --title "[${name}] ..."`);
|
|
1875
1901
|
}
|
|
1876
1902
|
process.exit(1);
|
|
1877
1903
|
}
|
|
@@ -1902,7 +1928,12 @@ async function siteCommand(args, options = {}) {
|
|
|
1902
1928
|
bb-browser site list
|
|
1903
1929
|
bb-browser site reddit/thread https://www.reddit.com/r/LocalLLaMA/comments/...
|
|
1904
1930
|
bb-browser site twitter/user yan5xu
|
|
1905
|
-
bb-browser site search reddit
|
|
1931
|
+
bb-browser site search reddit
|
|
1932
|
+
|
|
1933
|
+
Adapter \u7ED3\u679C\u4E0D\u7B26\u5408\u9884\u671F\uFF1F\u62A5\u544A\u95EE\u9898\uFF1A
|
|
1934
|
+
gh issue create --repo epiral/bb-sites --title "[adapter-name] \u63CF\u8FF0"
|
|
1935
|
+
\u6216: https://github.com/epiral/bb-sites/issues
|
|
1936
|
+
\u8D21\u732E\u65B0 adapter: https://github.com/epiral/bb-sites`);
|
|
1906
1937
|
return;
|
|
1907
1938
|
}
|
|
1908
1939
|
switch (subCommand) {
|