claude-chrome-android 1.5.0 → 1.5.1
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 +4 -0
- package/dist/claude-code-bridge.crx +0 -0
- package/dist/cli.js +68 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,6 +97,10 @@ The bridge serves the CRX at `http://127.0.0.1:18963/ext/crx` — open this URL
|
|
|
97
97
|
|
|
98
98
|
## Changelog
|
|
99
99
|
|
|
100
|
+
### 1.5.1
|
|
101
|
+
|
|
102
|
+
- Fix setup-edge probes failing with "more than one device/emulator" when multiple ADB devices are listed (e.g. a stale offline one): resolve and pin a single serial (`ADB_SERIAL`/`BRIDGE_ADB_SERIAL`, else the sole online device) on every adb call; status output shows the targeted serial
|
|
103
|
+
|
|
100
104
|
### 1.5.0
|
|
101
105
|
|
|
102
106
|
- First-run setup: `claude-chrome-android` in a terminal now walks through Edge/extension setup before starting the bridge when the browser side isn't wired up
|
|
Binary file
|
package/dist/cli.js
CHANGED
|
@@ -6209,27 +6209,43 @@ function findBuildScript() {
|
|
|
6209
6209
|
];
|
|
6210
6210
|
return candidates.find((p) => (0, import_fs.existsSync)(p));
|
|
6211
6211
|
}
|
|
6212
|
-
function
|
|
6212
|
+
function listAdbDevices(sp) {
|
|
6213
6213
|
const r = sp("adb", ["devices"], { stdio: "pipe", encoding: "utf-8" });
|
|
6214
|
-
|
|
6214
|
+
if (r.status !== 0) return [];
|
|
6215
|
+
return (r.stdout ?? "").split("\n").slice(1).map((l) => l.trim()).filter(Boolean).map((l) => {
|
|
6216
|
+
const [serial, state] = l.split(/\s+/);
|
|
6217
|
+
return { serial, state: state ?? "" };
|
|
6218
|
+
}).filter((d) => d.serial && d.state);
|
|
6215
6219
|
}
|
|
6216
|
-
function
|
|
6220
|
+
function resolveAdbSerial(sp) {
|
|
6221
|
+
const online = listAdbDevices(sp).filter((d) => d.state === "device");
|
|
6222
|
+
const env = process.env.ADB_SERIAL || process.env.BRIDGE_ADB_SERIAL || "";
|
|
6223
|
+
if (env && online.some((d) => d.serial === env)) return env;
|
|
6224
|
+
if (online.length === 1) return online[0].serial;
|
|
6225
|
+
if (online.length > 1) return env || online[0].serial;
|
|
6226
|
+
return "";
|
|
6227
|
+
}
|
|
6228
|
+
function runAdb(sp, serial, args2) {
|
|
6229
|
+
const base = serial ? ["-s", serial] : [];
|
|
6230
|
+
return sp("adb", [...base, ...args2], { stdio: "pipe", encoding: "utf-8" });
|
|
6231
|
+
}
|
|
6232
|
+
function detectEdgePkg(sp, serial) {
|
|
6217
6233
|
for (const pkg of EDGE_PACKAGES) {
|
|
6218
|
-
const r = sp
|
|
6234
|
+
const r = runAdb(sp, serial, ["shell", "pm", "list", "packages", pkg]);
|
|
6219
6235
|
if (r.stdout?.includes(`package:${pkg}`)) return pkg;
|
|
6220
6236
|
}
|
|
6221
6237
|
return "";
|
|
6222
6238
|
}
|
|
6223
|
-
function extPushed(sp) {
|
|
6224
|
-
const r = sp
|
|
6239
|
+
function extPushed(sp, serial) {
|
|
6240
|
+
const r = runAdb(sp, serial, ["shell", "ls", `${EXT_DEST}/manifest.json`]);
|
|
6225
6241
|
return r.status === 0 && (r.stdout ?? "").includes("manifest.json");
|
|
6226
6242
|
}
|
|
6227
|
-
function flagsLoadExt(sp) {
|
|
6228
|
-
const r = sp
|
|
6243
|
+
function flagsLoadExt(sp, serial) {
|
|
6244
|
+
const r = runAdb(sp, serial, ["shell", "cat", FLAGS_FILE]);
|
|
6229
6245
|
return (r.stdout ?? "").includes(EXT_DEST);
|
|
6230
6246
|
}
|
|
6231
|
-
function edgeIsPatched(sp, pkg) {
|
|
6232
|
-
const r = sp
|
|
6247
|
+
function edgeIsPatched(sp, serial, pkg) {
|
|
6248
|
+
const r = runAdb(sp, serial, ["shell", "dumpsys", "package", pkg]);
|
|
6233
6249
|
if (r.status !== 0 || !r.stdout) return null;
|
|
6234
6250
|
return !r.stdout.includes("com.google.android.gms.permission.AD_ID");
|
|
6235
6251
|
}
|
|
@@ -6414,15 +6430,15 @@ To re-run just the browser-side setup later:
|
|
|
6414
6430
|
npx claude-chrome-android --setup-edge (Edge + patch + extension)
|
|
6415
6431
|
`);
|
|
6416
6432
|
}
|
|
6417
|
-
async function installExtension(sp) {
|
|
6433
|
+
async function installExtension(sp, serial) {
|
|
6418
6434
|
const extDir = findExtDir();
|
|
6419
|
-
const
|
|
6435
|
+
const adbSerial = serial ?? resolveAdbSerial(sp);
|
|
6420
6436
|
if (!extDir) {
|
|
6421
6437
|
console.log("\nExtension source not found. Skipping extension install.");
|
|
6422
6438
|
console.log("To install manually, clone the repo and run push-extension.sh.");
|
|
6423
6439
|
return false;
|
|
6424
6440
|
}
|
|
6425
|
-
if (!
|
|
6441
|
+
if (!adbSerial) {
|
|
6426
6442
|
console.log("\nADB not available. Extension install requires ADB connection.");
|
|
6427
6443
|
console.log("Connect via: adb tcpip 5555 && adb connect <device-ip>");
|
|
6428
6444
|
return false;
|
|
@@ -6449,34 +6465,34 @@ async function installExtension(sp) {
|
|
|
6449
6465
|
const LOAD_EXT_FLAG = `--load-extension=${EXT_DEST}`;
|
|
6450
6466
|
console.log(`
|
|
6451
6467
|
Installing CFC extension v${extVersion} via --load-extension...`);
|
|
6452
|
-
sp
|
|
6468
|
+
runAdb(sp, adbSerial, ["shell", "mkdir", "-p", EXT_DEST]);
|
|
6453
6469
|
let pushed = 0;
|
|
6454
6470
|
for (const f of EXT_FILES) {
|
|
6455
6471
|
const src = (0, import_path2.resolve)(extDir, f);
|
|
6456
6472
|
if ((0, import_fs.existsSync)(src)) {
|
|
6457
|
-
const r = sp
|
|
6473
|
+
const r = runAdb(sp, adbSerial, ["push", src, `${EXT_DEST}/${f}`]);
|
|
6458
6474
|
if (r.status === 0) pushed++;
|
|
6459
6475
|
}
|
|
6460
6476
|
}
|
|
6461
6477
|
console.log(` Pushed ${pushed}/${EXT_FILES.length} files to ${EXT_DEST}`);
|
|
6462
|
-
const flagsResult = sp
|
|
6478
|
+
const flagsResult = runAdb(sp, adbSerial, ["shell", "cat", FLAGS_FILE]);
|
|
6463
6479
|
let currentFlags = flagsResult.stdout?.trim() || "";
|
|
6464
6480
|
if (!currentFlags.includes("--load-extension=")) {
|
|
6465
6481
|
currentFlags = currentFlags ? `${currentFlags} ${LOAD_EXT_FLAG}` : `_ ${LOAD_EXT_FLAG}`;
|
|
6466
|
-
sp
|
|
6482
|
+
runAdb(sp, adbSerial, ["shell", `echo '${currentFlags}' > ${FLAGS_FILE}`]);
|
|
6467
6483
|
console.log(" Added --load-extension flag to chrome-command-line");
|
|
6468
6484
|
} else if (!currentFlags.includes(EXT_DEST)) {
|
|
6469
6485
|
currentFlags = currentFlags.replace(/--load-extension=\S+/, LOAD_EXT_FLAG);
|
|
6470
|
-
sp
|
|
6486
|
+
runAdb(sp, adbSerial, ["shell", `echo '${currentFlags}' > ${FLAGS_FILE}`]);
|
|
6471
6487
|
console.log(" Updated --load-extension path in chrome-command-line");
|
|
6472
6488
|
} else {
|
|
6473
6489
|
console.log(" --load-extension flag already set");
|
|
6474
6490
|
}
|
|
6475
|
-
const edgePkg = detectEdgePkg(sp);
|
|
6491
|
+
const edgePkg = detectEdgePkg(sp, adbSerial);
|
|
6476
6492
|
if (edgePkg) {
|
|
6477
|
-
sp
|
|
6493
|
+
runAdb(sp, adbSerial, ["shell", "settings", "put", "global", "debug_app", edgePkg]);
|
|
6478
6494
|
console.log(` Set debug_app=${edgePkg} for flag reading`);
|
|
6479
|
-
sp
|
|
6495
|
+
runAdb(sp, adbSerial, ["shell", "am", "force-stop", edgePkg]);
|
|
6480
6496
|
console.log(` Restarted ${edgePkg} to apply changes`);
|
|
6481
6497
|
} else {
|
|
6482
6498
|
console.log(" WARNING: No Edge browser found. Install Edge Canary from the Play Store.");
|
|
@@ -6496,8 +6512,8 @@ function ask(question) {
|
|
|
6496
6512
|
}
|
|
6497
6513
|
var isYes = (a) => a === "" || a === "y" || a === "yes";
|
|
6498
6514
|
var EDGE_CANARY = "com.microsoft.emmx.canary";
|
|
6499
|
-
async function ensureEdgeInstalled(sp, interactive) {
|
|
6500
|
-
let pkg = detectEdgePkg(sp);
|
|
6515
|
+
async function ensureEdgeInstalled(sp, serial, interactive) {
|
|
6516
|
+
let pkg = detectEdgePkg(sp, serial);
|
|
6501
6517
|
if (pkg) return pkg;
|
|
6502
6518
|
const listing = `https://play.google.com/store/apps/details?id=${EDGE_CANARY}`;
|
|
6503
6519
|
if (!interactive) {
|
|
@@ -6511,11 +6527,11 @@ Edge not installed. Install Edge Canary, then re-run:
|
|
|
6511
6527
|
console.log("Skipped Edge install.");
|
|
6512
6528
|
return "";
|
|
6513
6529
|
}
|
|
6514
|
-
sp
|
|
6530
|
+
runAdb(sp, serial, ["shell", `am start -a android.intent.action.VIEW -d 'market://details?id=${EDGE_CANARY}'`]);
|
|
6515
6531
|
console.log("Opened the Play Store on your device. Tap Install, wait for it to finish, then return here.");
|
|
6516
6532
|
await ask("Press Enter once Edge Canary has finished installing... ");
|
|
6517
6533
|
for (let i = 0; i < 5 && !pkg; i++) {
|
|
6518
|
-
pkg = detectEdgePkg(sp);
|
|
6534
|
+
pkg = detectEdgePkg(sp, serial);
|
|
6519
6535
|
if (!pkg) await sleep(2e3);
|
|
6520
6536
|
}
|
|
6521
6537
|
if (pkg) console.log(`Detected ${pkg}.`);
|
|
@@ -6523,39 +6539,47 @@ Edge not installed. Install Edge Canary, then re-run:
|
|
|
6523
6539
|
return pkg;
|
|
6524
6540
|
}
|
|
6525
6541
|
async function probeEdge(sp) {
|
|
6526
|
-
const
|
|
6527
|
-
const
|
|
6542
|
+
const serial = resolveAdbSerial(sp);
|
|
6543
|
+
const hasAdb = serial !== "";
|
|
6544
|
+
const multiOnline = listAdbDevices(sp).filter((d) => d.state === "device").length > 1;
|
|
6545
|
+
const edgePkg = hasAdb ? detectEdgePkg(sp, serial) : "";
|
|
6528
6546
|
return {
|
|
6529
6547
|
hasAdb,
|
|
6548
|
+
serial,
|
|
6549
|
+
multiOnline,
|
|
6530
6550
|
edgePkg,
|
|
6531
|
-
patched: hasAdb && edgePkg ? edgeIsPatched(sp, edgePkg) : null,
|
|
6532
|
-
extPushed: hasAdb ? extPushed(sp) : false,
|
|
6533
|
-
flagsLoadExt: hasAdb ? flagsLoadExt(sp) : false,
|
|
6551
|
+
patched: hasAdb && edgePkg ? edgeIsPatched(sp, serial, edgePkg) : null,
|
|
6552
|
+
extPushed: hasAdb ? extPushed(sp, serial) : false,
|
|
6553
|
+
flagsLoadExt: hasAdb ? flagsLoadExt(sp, serial) : false,
|
|
6534
6554
|
clients: await bridgeClientCount()
|
|
6535
6555
|
};
|
|
6536
6556
|
}
|
|
6537
6557
|
function printEdgeStatus(s) {
|
|
6538
6558
|
const mark = (ok) => ok === null ? "?" : ok ? "OK" : "MISSING";
|
|
6539
6559
|
console.log("CFC environment check:");
|
|
6540
|
-
console.log(` [${mark(s.hasAdb)}] ADB device connected`);
|
|
6560
|
+
console.log(` [${mark(s.hasAdb)}] ADB device connected${s.serial ? ` (${s.serial})` : ""}`);
|
|
6541
6561
|
console.log(` [${s.edgePkg ? "OK" : "MISSING"}] Edge installed${s.edgePkg ? ` (${s.edgePkg})` : ""}`);
|
|
6542
6562
|
console.log(` [${mark(s.patched)}] Edge privacy-patched (AD_ID stripped)`);
|
|
6543
6563
|
console.log(` [${mark(s.extPushed && s.flagsLoadExt)}] CFC extension sideloaded + flag set`);
|
|
6544
6564
|
console.log(` [${s.clients === null ? "\u2014" : s.clients > 0 ? "OK" : "MISSING"}] Extension connected to bridge${s.clients !== null ? ` (${s.clients} client${s.clients === 1 ? "" : "s"})` : " (bridge not running)"}`);
|
|
6565
|
+
if (s.multiOnline) {
|
|
6566
|
+
console.log(` note: multiple devices online \u2014 targeting ${s.serial}; set ADB_SERIAL to override`);
|
|
6567
|
+
}
|
|
6545
6568
|
}
|
|
6546
|
-
async function offerPatchBuild(sp, edgePkg, interactive) {
|
|
6569
|
+
async function offerPatchBuild(sp, serial, edgePkg, interactive) {
|
|
6547
6570
|
const script = findBuildScript();
|
|
6571
|
+
const serialArgs = serial ? ["-s", serial] : [];
|
|
6548
6572
|
if (!script) {
|
|
6549
6573
|
console.log("\nTo build a privacy-patched Edge from your installed copy:");
|
|
6550
6574
|
console.log(" git clone https://github.com/tribixbite/termux-tools");
|
|
6551
|
-
console.log(
|
|
6575
|
+
console.log(` cd termux-tools/edge-fix && ./build-from-device.sh ${serialArgs.join(" ")} --install`.replace(/\s+/g, " "));
|
|
6552
6576
|
console.log("(needs apktool, zipalign/apksigner, java, python3 + the tool jars in tools/)");
|
|
6553
6577
|
return;
|
|
6554
6578
|
}
|
|
6555
6579
|
if (!interactive) {
|
|
6556
6580
|
console.log(`
|
|
6557
6581
|
Run the self-build to patch Edge (no data wipe on re-sign):`);
|
|
6558
|
-
console.log(` ${script} --install
|
|
6582
|
+
console.log(` ${script} ${serialArgs.join(" ")} --install`.replace(/\s+$/, ""));
|
|
6559
6583
|
return;
|
|
6560
6584
|
}
|
|
6561
6585
|
const a = await ask(`
|
|
@@ -6565,7 +6589,7 @@ Build + install a privacy-patched ${edgePkg} now via build-from-device.sh? [Y/n]
|
|
|
6565
6589
|
return;
|
|
6566
6590
|
}
|
|
6567
6591
|
console.log("\nRunning build-from-device.sh --install (this takes a few minutes)...\n");
|
|
6568
|
-
const r = sp("bash", [script, "--install"], { stdio: "inherit" });
|
|
6592
|
+
const r = sp("bash", [script, ...serialArgs, "--install"], { stdio: "inherit" });
|
|
6569
6593
|
if (r.status === 0) console.log("\nPatched Edge installed.");
|
|
6570
6594
|
else console.log(`
|
|
6571
6595
|
build-from-device.sh exited ${r.status}. See output above.`);
|
|
@@ -6577,18 +6601,19 @@ async function runEdgeSetup(sp, interactive) {
|
|
|
6577
6601
|
console.log("\nNo ADB device. Connect with: adb tcpip 5555 && adb connect <device-ip>");
|
|
6578
6602
|
return false;
|
|
6579
6603
|
}
|
|
6580
|
-
const
|
|
6604
|
+
const serial = s.serial;
|
|
6605
|
+
const edgePkg = s.edgePkg || await ensureEdgeInstalled(sp, serial, interactive);
|
|
6581
6606
|
if (!edgePkg) return false;
|
|
6582
|
-
const patched = s.edgePkg ? s.patched : edgeIsPatched(sp, edgePkg);
|
|
6607
|
+
const patched = s.edgePkg ? s.patched : edgeIsPatched(sp, serial, edgePkg);
|
|
6583
6608
|
if (patched !== true) {
|
|
6584
6609
|
if (patched === false) console.log("\nYour Edge still ships tracking permissions.");
|
|
6585
|
-
await offerPatchBuild(sp, edgePkg, interactive);
|
|
6610
|
+
await offerPatchBuild(sp, serial, edgePkg, interactive);
|
|
6586
6611
|
}
|
|
6587
6612
|
const reProbe = await probeEdge(sp);
|
|
6588
6613
|
if (!reProbe.extPushed || !reProbe.flagsLoadExt || reProbe.clients === 0) {
|
|
6589
6614
|
if (interactive) {
|
|
6590
6615
|
const a = await ask("\nSideload the CFC extension into Edge now? [Y/n] ");
|
|
6591
|
-
if (isYes(a)) await installExtension(sp);
|
|
6616
|
+
if (isYes(a)) await installExtension(sp, serial);
|
|
6592
6617
|
else console.log("Skipped extension install.");
|
|
6593
6618
|
} else {
|
|
6594
6619
|
console.log("\nInstall the CFC extension with: claude-chrome-android --setup");
|
|
@@ -6613,9 +6638,10 @@ async function cmdStart() {
|
|
|
6613
6638
|
const interactive = Boolean(process.stdin.isTTY);
|
|
6614
6639
|
try {
|
|
6615
6640
|
const { spawnSync: spawnSync2 } = await import("child_process");
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
const
|
|
6641
|
+
const serial = resolveAdbSerial(spawnSync2);
|
|
6642
|
+
if (serial) {
|
|
6643
|
+
const edgePkg = detectEdgePkg(spawnSync2, serial);
|
|
6644
|
+
const ready = edgePkg && extPushed(spawnSync2, serial) && flagsLoadExt(spawnSync2, serial);
|
|
6619
6645
|
if (!ready) {
|
|
6620
6646
|
if (interactive) {
|
|
6621
6647
|
console.log("First-time setup: let's get Edge + the CFC extension ready.\n");
|
package/package.json
CHANGED