claude-chrome-android 1.4.0 → 1.5.0
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 +33 -1
- package/dist/claude-code-bridge.crx +0 -0
- package/dist/cli.js +350 -109
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ npx claude-chrome-android
|
|
|
26
26
|
claude-chrome-android # start the bridge server
|
|
27
27
|
claude-chrome-android --mcp # MCP server mode (spawned by Claude Code)
|
|
28
28
|
claude-chrome-android --stop # stop a running bridge
|
|
29
|
-
claude-chrome-android --setup #
|
|
29
|
+
claude-chrome-android --setup # full setup: MCP + url-opener + Edge/extension
|
|
30
|
+
claude-chrome-android --setup-edge # browser-side only: install Edge, patch, sideload extension
|
|
30
31
|
claude-chrome-android --version # show version
|
|
31
32
|
claude-chrome-android --help # show help
|
|
32
33
|
```
|
|
@@ -52,6 +53,30 @@ Claude Code session N ─→ cli.js --mcp ─┘
|
|
|
52
53
|
2. **Creates `~/bin/termux-url-opener`** — handles `cfcbridge://start` URLs to auto-start the bridge
|
|
53
54
|
3. **Installs CRX extension** — serves the bundled CRX over HTTP and opens Edge for installation (requires ADB)
|
|
54
55
|
|
|
56
|
+
## First-run setup
|
|
57
|
+
|
|
58
|
+
The bridge is only useful once a privacy-patched Edge with the CFC extension is
|
|
59
|
+
running. The **first time you run `claude-chrome-android` in a terminal**, if
|
|
60
|
+
the browser side isn't wired up it walks you through setup before starting the
|
|
61
|
+
bridge — so a bare `bunx claude-chrome-android` is enough to get going. You can
|
|
62
|
+
re-run just the browser-side setup any time with `--setup-edge`.
|
|
63
|
+
|
|
64
|
+
Setup checks each piece over ADB and offers to fix what's missing:
|
|
65
|
+
|
|
66
|
+
- **ADB device connected** — required for everything below
|
|
67
|
+
- **Edge installed** — detects Canary/Dev/Beta/stable; if absent it opens the
|
|
68
|
+
Play Store listing for Edge Canary via deeplink so it's one tap to install
|
|
69
|
+
(Play has no silent-install API), then waits and re-checks
|
|
70
|
+
- **Edge privacy-patched** — heuristic: the `AD_ID` tracking permission is stripped;
|
|
71
|
+
if not, offers to build + install a patched Edge from your installed copy via
|
|
72
|
+
`edge-fix/build-from-device.sh` (no data wipe on re-sign)
|
|
73
|
+
- **CFC extension sideloaded** — files in `/data/local/tmp/cfc-ext` + `--load-extension` flag set
|
|
74
|
+
- **Extension connected to bridge** — live WebSocket client count from `/health`
|
|
75
|
+
|
|
76
|
+
It never silently installs base Edge (no Play/APKMirror API — you tap Install)
|
|
77
|
+
and never touches the signing keystore. Non-interactive launches (e.g. spawned
|
|
78
|
+
by `termux-url-opener`) skip the prompts and just print a one-line hint.
|
|
79
|
+
|
|
55
80
|
## Important
|
|
56
81
|
|
|
57
82
|
The bridge **must be running before** starting a Claude Code session. MCP tools are registered at session startup — if the bridge is down, the tools won't appear.
|
|
@@ -72,6 +97,13 @@ The bridge serves the CRX at `http://127.0.0.1:18963/ext/crx` — open this URL
|
|
|
72
97
|
|
|
73
98
|
## Changelog
|
|
74
99
|
|
|
100
|
+
### 1.5.0
|
|
101
|
+
|
|
102
|
+
- 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
|
|
103
|
+
- Add `--setup-edge` (alias `--doctor`): probes ADB, Edge install, privacy-patch status (AD_ID stripped), extension sideload, and live bridge connection, and offers to fix each
|
|
104
|
+
- Install Edge Canary via Play Store deeplink when missing; offer the `build-from-device.sh` privacy-patch build (no data wipe on re-sign)
|
|
105
|
+
- Stop publishing the CRX signing key (`dist/edge-claude-ext.pem`) and stale versioned CRX builds to npm via `files` allowlist negation
|
|
106
|
+
|
|
75
107
|
### 1.2.2
|
|
76
108
|
|
|
77
109
|
- Fix CDP pending commands hanging on WebSocket close (reject immediately)
|
|
Binary file
|
package/dist/cli.js
CHANGED
|
@@ -809,6 +809,10 @@ var require_receiver = __commonJS({
|
|
|
809
809
|
* extensions
|
|
810
810
|
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
811
811
|
* client or server mode
|
|
812
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
813
|
+
* buffered data chunks
|
|
814
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
815
|
+
* fragments
|
|
812
816
|
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
813
817
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
814
818
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -819,6 +823,8 @@ var require_receiver = __commonJS({
|
|
|
819
823
|
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
820
824
|
this._extensions = options.extensions || {};
|
|
821
825
|
this._isServer = !!options.isServer;
|
|
826
|
+
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
827
|
+
this._maxFragments = options.maxFragments | 0;
|
|
822
828
|
this._maxPayload = options.maxPayload | 0;
|
|
823
829
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
824
830
|
this[kWebSocket] = void 0;
|
|
@@ -848,6 +854,18 @@ var require_receiver = __commonJS({
|
|
|
848
854
|
*/
|
|
849
855
|
_write(chunk, encoding, cb) {
|
|
850
856
|
if (this._opcode === 8 && this._state == GET_INFO) return cb();
|
|
857
|
+
if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
858
|
+
cb(
|
|
859
|
+
this.createError(
|
|
860
|
+
RangeError,
|
|
861
|
+
"Too many buffered chunks",
|
|
862
|
+
false,
|
|
863
|
+
1008,
|
|
864
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
865
|
+
)
|
|
866
|
+
);
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
851
869
|
this._bufferedBytes += chunk.length;
|
|
852
870
|
this._buffers.push(chunk);
|
|
853
871
|
this.startLoop(cb);
|
|
@@ -1177,6 +1195,17 @@ var require_receiver = __commonJS({
|
|
|
1177
1195
|
return;
|
|
1178
1196
|
}
|
|
1179
1197
|
if (data.length) {
|
|
1198
|
+
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1199
|
+
const error = this.createError(
|
|
1200
|
+
RangeError,
|
|
1201
|
+
"Too many message fragments",
|
|
1202
|
+
false,
|
|
1203
|
+
1008,
|
|
1204
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1205
|
+
);
|
|
1206
|
+
cb(error);
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1180
1209
|
this._messageLength = this._totalPayloadLength;
|
|
1181
1210
|
this._fragments.push(data);
|
|
1182
1211
|
}
|
|
@@ -1206,6 +1235,17 @@ var require_receiver = __commonJS({
|
|
|
1206
1235
|
cb(error);
|
|
1207
1236
|
return;
|
|
1208
1237
|
}
|
|
1238
|
+
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1239
|
+
const error = this.createError(
|
|
1240
|
+
RangeError,
|
|
1241
|
+
"Too many message fragments",
|
|
1242
|
+
false,
|
|
1243
|
+
1008,
|
|
1244
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1245
|
+
);
|
|
1246
|
+
cb(error);
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1209
1249
|
this._fragments.push(buf);
|
|
1210
1250
|
}
|
|
1211
1251
|
this.dataMessage(cb);
|
|
@@ -2416,6 +2456,10 @@ var require_websocket = __commonJS({
|
|
|
2416
2456
|
* multiple times in the same tick
|
|
2417
2457
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
2418
2458
|
* masking key
|
|
2459
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
2460
|
+
* buffered data chunks
|
|
2461
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
2462
|
+
* fragments
|
|
2419
2463
|
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
2420
2464
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
2421
2465
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -2427,6 +2471,8 @@ var require_websocket = __commonJS({
|
|
|
2427
2471
|
binaryType: this.binaryType,
|
|
2428
2472
|
extensions: this._extensions,
|
|
2429
2473
|
isServer: this._isServer,
|
|
2474
|
+
maxBufferedChunks: options.maxBufferedChunks,
|
|
2475
|
+
maxFragments: options.maxFragments,
|
|
2430
2476
|
maxPayload: options.maxPayload,
|
|
2431
2477
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2432
2478
|
});
|
|
@@ -2726,6 +2772,8 @@ var require_websocket = __commonJS({
|
|
|
2726
2772
|
autoPong: true,
|
|
2727
2773
|
closeTimeout: CLOSE_TIMEOUT,
|
|
2728
2774
|
protocolVersion: protocolVersions[1],
|
|
2775
|
+
maxBufferedChunks: 1024 * 1024,
|
|
2776
|
+
maxFragments: 128 * 1024,
|
|
2729
2777
|
maxPayload: 100 * 1024 * 1024,
|
|
2730
2778
|
skipUTF8Validation: false,
|
|
2731
2779
|
perMessageDeflate: true,
|
|
@@ -2968,6 +3016,8 @@ var require_websocket = __commonJS({
|
|
|
2968
3016
|
websocket.setSocket(socket, head, {
|
|
2969
3017
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
2970
3018
|
generateMask: opts.generateMask,
|
|
3019
|
+
maxBufferedChunks: opts.maxBufferedChunks,
|
|
3020
|
+
maxFragments: opts.maxFragments,
|
|
2971
3021
|
maxPayload: opts.maxPayload,
|
|
2972
3022
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
2973
3023
|
});
|
|
@@ -3313,6 +3363,10 @@ var require_websocket_server = __commonJS({
|
|
|
3313
3363
|
* called
|
|
3314
3364
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
3315
3365
|
* @param {String} [options.host] The hostname where to bind the server
|
|
3366
|
+
* @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
|
|
3367
|
+
* buffered data chunks
|
|
3368
|
+
* @param {Number} [options.maxFragments=131072] The maximum number of message
|
|
3369
|
+
* fragments
|
|
3316
3370
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3317
3371
|
* size
|
|
3318
3372
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
@@ -3334,6 +3388,8 @@ var require_websocket_server = __commonJS({
|
|
|
3334
3388
|
options = {
|
|
3335
3389
|
allowSynchronousEvents: true,
|
|
3336
3390
|
autoPong: true,
|
|
3391
|
+
maxBufferedChunks: 1024 * 1024,
|
|
3392
|
+
maxFragments: 128 * 1024,
|
|
3337
3393
|
maxPayload: 100 * 1024 * 1024,
|
|
3338
3394
|
skipUTF8Validation: false,
|
|
3339
3395
|
perMessageDeflate: false,
|
|
@@ -3613,6 +3669,8 @@ var require_websocket_server = __commonJS({
|
|
|
3613
3669
|
socket.removeListener("error", socketOnError);
|
|
3614
3670
|
ws.setSocket(socket, head, {
|
|
3615
3671
|
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
3672
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
3673
|
+
maxFragments: this.options.maxFragments,
|
|
3616
3674
|
maxPayload: this.options.maxPayload,
|
|
3617
3675
|
skipUTF8Validation: this.options.skipUTF8Validation
|
|
3618
3676
|
});
|
|
@@ -3863,14 +3921,15 @@ function createNodeServer(config) {
|
|
|
3863
3921
|
reqInit.body = body;
|
|
3864
3922
|
}
|
|
3865
3923
|
const request = new Request(url, reqInit);
|
|
3866
|
-
|
|
3867
|
-
|
|
3924
|
+
let httpUpgradeRequested = false;
|
|
3925
|
+
const upgrade = (_data) => {
|
|
3926
|
+
httpUpgradeRequested = true;
|
|
3868
3927
|
return true;
|
|
3869
3928
|
};
|
|
3870
3929
|
try {
|
|
3871
3930
|
const response = await config.fetch(request, upgrade);
|
|
3872
|
-
if (response === void 0 ||
|
|
3873
|
-
if (
|
|
3931
|
+
if (response === void 0 || httpUpgradeRequested) {
|
|
3932
|
+
if (!httpUpgradeRequested) {
|
|
3874
3933
|
nodeRes.writeHead(500);
|
|
3875
3934
|
nodeRes.end("WebSocket upgrade not triggered");
|
|
3876
3935
|
}
|
|
@@ -4724,7 +4783,7 @@ function shutdown() {
|
|
|
4724
4783
|
log("info", "Bridge stopped");
|
|
4725
4784
|
process.exit(0);
|
|
4726
4785
|
}
|
|
4727
|
-
var import_path, import_node_zlib, SCRIPT_DIR, MANIFEST_PATH, BRIDGE_VERSION, WS_PORT, WS_HOST, BRIDGE_TOKEN, MAX_MESSAGE_SIZE, RECONNECT_DELAY_MS, HEARTBEAT_INTERVAL_MS, TERMUX_PREFIX, TERMUX_BIN, ADB_PATH, _adbSerial, _adbSerialTs, ADB_SERIAL_TTL_MS,
|
|
4786
|
+
var import_path, import_node_zlib, SCRIPT_DIR, MANIFEST_PATH, BRIDGE_VERSION, WS_PORT, WS_HOST, BRIDGE_TOKEN, MAX_MESSAGE_SIZE, RECONNECT_DELAY_MS, HEARTBEAT_INTERVAL_MS, TERMUX_PREFIX, TERMUX_BIN, ADB_PATH, _adbSerial, _adbSerialTs, ADB_SERIAL_TTL_MS, NATIVE_HOST_WRAPPER, BUN_GLOBAL_CLI, NPM_GLOBAL_CLI, CLI_PATH, RUNTIME_PATH, LOG_LEVEL, LOG_PRIORITY, NativeMessageDecoder, CDP_PORT, CDP_PID_CHECK_INTERVAL_MS, CDP_MAX_BACKOFF_ATTEMPTS, CDP_TARGET_CACHE_TTL_MS, CDP_TIMEOUT_MS, CdpManager, cdpManager, crc32Table, toolRequestCounter, pendingToolMap, busyTabs, HTTP_TOOL_TIMEOUT_MS, lastToolName, lastToolTime, nativeHost, nativeHostKillTimer, stdoutDecoder, wsClients, server, TEST_PAGE_HTML;
|
|
4728
4787
|
var init_claude_chrome_bridge = __esm({
|
|
4729
4788
|
"../claude-chrome-bridge.ts"() {
|
|
4730
4789
|
init_import_meta_shim();
|
|
@@ -4754,7 +4813,10 @@ var init_claude_chrome_bridge = __esm({
|
|
|
4754
4813
|
_adbSerial = "";
|
|
4755
4814
|
_adbSerialTs = 0;
|
|
4756
4815
|
ADB_SERIAL_TTL_MS = 3e4;
|
|
4757
|
-
|
|
4816
|
+
NATIVE_HOST_WRAPPER = (0, import_path.resolve)(
|
|
4817
|
+
process.env.HOME ?? "~",
|
|
4818
|
+
".claude/chrome/chrome-native-host"
|
|
4819
|
+
);
|
|
4758
4820
|
BUN_GLOBAL_CLI = (0, import_path.resolve)(
|
|
4759
4821
|
process.env.HOME ?? "~",
|
|
4760
4822
|
".bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js"
|
|
@@ -4764,8 +4826,16 @@ var init_claude_chrome_bridge = __esm({
|
|
|
4764
4826
|
".npm/lib/node_modules/@anthropic-ai/claude-code/cli.js"
|
|
4765
4827
|
);
|
|
4766
4828
|
CLI_PATH = (() => {
|
|
4767
|
-
const { existsSync: existsSync2 } = require("fs");
|
|
4768
|
-
|
|
4829
|
+
const { existsSync: existsSync2, readFileSync: readFileSync2 } = require("fs");
|
|
4830
|
+
if (existsSync2(NATIVE_HOST_WRAPPER)) {
|
|
4831
|
+
try {
|
|
4832
|
+
const wrapper = readFileSync2(NATIVE_HOST_WRAPPER, "utf-8");
|
|
4833
|
+
const m = wrapper.match(/"([^"]*cli\.js)"\s+--chrome-native-host/);
|
|
4834
|
+
if (m && existsSync2(m[1])) return m[1];
|
|
4835
|
+
} catch {
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
for (const p of [BUN_GLOBAL_CLI, NPM_GLOBAL_CLI]) {
|
|
4769
4839
|
if (existsSync2(p)) return p;
|
|
4770
4840
|
}
|
|
4771
4841
|
const result = runSync(["which", "claude"]);
|
|
@@ -6100,6 +6170,69 @@ async function isBridgeAlive() {
|
|
|
6100
6170
|
return false;
|
|
6101
6171
|
}
|
|
6102
6172
|
}
|
|
6173
|
+
async function bridgeClientCount() {
|
|
6174
|
+
try {
|
|
6175
|
+
const res = await fetchWithTimeout(HEALTH_URL, { timeout: 2e3 });
|
|
6176
|
+
if (!res.ok) return null;
|
|
6177
|
+
const d = await res.json();
|
|
6178
|
+
return typeof d.clients === "number" ? d.clients : 0;
|
|
6179
|
+
} catch {
|
|
6180
|
+
return null;
|
|
6181
|
+
}
|
|
6182
|
+
}
|
|
6183
|
+
var EDGE_PACKAGES = [
|
|
6184
|
+
"com.microsoft.emmx.canary",
|
|
6185
|
+
"com.microsoft.emmx.dev",
|
|
6186
|
+
"com.microsoft.emmx.beta",
|
|
6187
|
+
"com.microsoft.emmx"
|
|
6188
|
+
];
|
|
6189
|
+
var EXT_DEST = "/data/local/tmp/cfc-ext";
|
|
6190
|
+
var FLAGS_FILE = "/data/local/tmp/chrome-command-line";
|
|
6191
|
+
function selfDir() {
|
|
6192
|
+
return typeof __dirname !== "undefined" ? __dirname : (0, import_path2.dirname)(new URL(import_meta_url).pathname);
|
|
6193
|
+
}
|
|
6194
|
+
function findExtDir() {
|
|
6195
|
+
const dir = selfDir();
|
|
6196
|
+
const candidates = [
|
|
6197
|
+
(0, import_path2.resolve)(dir, "../../edge-claude-ext"),
|
|
6198
|
+
// running from source repo
|
|
6199
|
+
(0, import_path2.resolve)(dir, "edge-claude-ext")
|
|
6200
|
+
// npm package dist/edge-claude-ext/
|
|
6201
|
+
];
|
|
6202
|
+
return candidates.find((d) => (0, import_fs.existsSync)((0, import_path2.resolve)(d, "manifest.json")));
|
|
6203
|
+
}
|
|
6204
|
+
function findBuildScript() {
|
|
6205
|
+
const home = process.env.HOME ?? "/data/data/com.termux/files/home";
|
|
6206
|
+
const candidates = [
|
|
6207
|
+
(0, import_path2.resolve)(selfDir(), "../../../edge-fix/build-from-device.sh"),
|
|
6208
|
+
(0, import_path2.resolve)(home, "git/termux-tools/edge-fix/build-from-device.sh")
|
|
6209
|
+
];
|
|
6210
|
+
return candidates.find((p) => (0, import_fs.existsSync)(p));
|
|
6211
|
+
}
|
|
6212
|
+
function adbOnline(sp) {
|
|
6213
|
+
const r = sp("adb", ["devices"], { stdio: "pipe", encoding: "utf-8" });
|
|
6214
|
+
return r.status === 0 && /\tdevice\b/.test(r.stdout ?? "");
|
|
6215
|
+
}
|
|
6216
|
+
function detectEdgePkg(sp) {
|
|
6217
|
+
for (const pkg of EDGE_PACKAGES) {
|
|
6218
|
+
const r = sp("adb", ["shell", "pm", "list", "packages", pkg], { stdio: "pipe", encoding: "utf-8" });
|
|
6219
|
+
if (r.stdout?.includes(`package:${pkg}`)) return pkg;
|
|
6220
|
+
}
|
|
6221
|
+
return "";
|
|
6222
|
+
}
|
|
6223
|
+
function extPushed(sp) {
|
|
6224
|
+
const r = sp("adb", ["shell", "ls", `${EXT_DEST}/manifest.json`], { stdio: "pipe", encoding: "utf-8" });
|
|
6225
|
+
return r.status === 0 && (r.stdout ?? "").includes("manifest.json");
|
|
6226
|
+
}
|
|
6227
|
+
function flagsLoadExt(sp) {
|
|
6228
|
+
const r = sp("adb", ["shell", "cat", FLAGS_FILE], { stdio: "pipe", encoding: "utf-8" });
|
|
6229
|
+
return (r.stdout ?? "").includes(EXT_DEST);
|
|
6230
|
+
}
|
|
6231
|
+
function edgeIsPatched(sp, pkg) {
|
|
6232
|
+
const r = sp("adb", ["shell", "dumpsys", "package", pkg], { stdio: "pipe", encoding: "utf-8" });
|
|
6233
|
+
if (r.status !== 0 || !r.stdout) return null;
|
|
6234
|
+
return !r.stdout.includes("com.google.android.gms.permission.AD_ID");
|
|
6235
|
+
}
|
|
6103
6236
|
function cmdVersion() {
|
|
6104
6237
|
console.log(`claude-chrome-android v${PKG_VERSION}`);
|
|
6105
6238
|
}
|
|
@@ -6112,7 +6245,8 @@ Usage:
|
|
|
6112
6245
|
claude-chrome-android Start the bridge server
|
|
6113
6246
|
claude-chrome-android --mcp MCP server mode (spawned by Claude Code)
|
|
6114
6247
|
claude-chrome-android --stop Stop a running bridge
|
|
6115
|
-
claude-chrome-android --setup
|
|
6248
|
+
claude-chrome-android --setup Full setup: register MCP + create url-opener + Edge/extension
|
|
6249
|
+
claude-chrome-android --setup-edge Browser-side setup only: install Edge, patch, sideload extension
|
|
6116
6250
|
claude-chrome-android --version Print version
|
|
6117
6251
|
claude-chrome-android --help Show this help
|
|
6118
6252
|
|
|
@@ -6266,17 +6400,40 @@ esac
|
|
|
6266
6400
|
(0, import_fs.writeFileSync)(urlOpenerPath, urlOpenerScript);
|
|
6267
6401
|
(0, import_fs.chmodSync)(urlOpenerPath, 493);
|
|
6268
6402
|
console.log(`${urlOpenerExists ? "Updated" : "Created"} ${urlOpenerPath}`);
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6403
|
+
await runEdgeSetup(spawnSync2, Boolean(process.stdin.isTTY));
|
|
6404
|
+
console.log(`
|
|
6405
|
+
Setup complete!
|
|
6406
|
+
|
|
6407
|
+
Next steps:
|
|
6408
|
+
1. Start the bridge: npx claude-chrome-android
|
|
6409
|
+
2. Open Edge \u2014 the extension loads automatically via --load-extension
|
|
6410
|
+
3. Open a new Claude Code session \u2014 browser tools (mcp__cfc-bridge__*) will be available
|
|
6411
|
+
4. Use ToolSearch to find and load cfc-bridge tools
|
|
6412
|
+
|
|
6413
|
+
To re-run just the browser-side setup later:
|
|
6414
|
+
npx claude-chrome-android --setup-edge (Edge + patch + extension)
|
|
6415
|
+
`);
|
|
6416
|
+
}
|
|
6417
|
+
async function installExtension(sp) {
|
|
6418
|
+
const extDir = findExtDir();
|
|
6419
|
+
const hasAdb = adbOnline(sp);
|
|
6420
|
+
if (!extDir) {
|
|
6421
|
+
console.log("\nExtension source not found. Skipping extension install.");
|
|
6422
|
+
console.log("To install manually, clone the repo and run push-extension.sh.");
|
|
6423
|
+
return false;
|
|
6424
|
+
}
|
|
6425
|
+
if (!hasAdb) {
|
|
6426
|
+
console.log("\nADB not available. Extension install requires ADB connection.");
|
|
6427
|
+
console.log("Connect via: adb tcpip 5555 && adb connect <device-ip>");
|
|
6428
|
+
return false;
|
|
6429
|
+
}
|
|
6430
|
+
const extVersion = (() => {
|
|
6431
|
+
try {
|
|
6432
|
+
return JSON.parse((0, import_fs.readFileSync)((0, import_path2.resolve)(extDir, "manifest.json"), "utf-8")).version;
|
|
6433
|
+
} catch {
|
|
6434
|
+
return PKG_VERSION;
|
|
6435
|
+
}
|
|
6436
|
+
})();
|
|
6280
6437
|
const EXT_FILES = [
|
|
6281
6438
|
"manifest.json",
|
|
6282
6439
|
"background.js",
|
|
@@ -6289,102 +6446,163 @@ esac
|
|
|
6289
6446
|
"icon48.png",
|
|
6290
6447
|
"icon128.png"
|
|
6291
6448
|
];
|
|
6292
|
-
const
|
|
6293
|
-
|
|
6294
|
-
if (!extDir) {
|
|
6295
|
-
console.log("\nExtension source not found. Skipping extension install.");
|
|
6296
|
-
console.log("To install manually, clone the repo and run push-extension.sh.");
|
|
6297
|
-
} else if (!hasAdb) {
|
|
6298
|
-
console.log("\nADB not available. Extension install requires ADB connection.");
|
|
6299
|
-
console.log("Connect via: adb tcpip 5555 && adb connect <device-ip>");
|
|
6300
|
-
} else {
|
|
6301
|
-
const extVersion = (() => {
|
|
6302
|
-
try {
|
|
6303
|
-
return JSON.parse((0, import_fs.readFileSync)((0, import_path2.resolve)(extDir, "manifest.json"), "utf-8")).version;
|
|
6304
|
-
} catch {
|
|
6305
|
-
return PKG_VERSION;
|
|
6306
|
-
}
|
|
6307
|
-
})();
|
|
6308
|
-
console.log(`
|
|
6449
|
+
const LOAD_EXT_FLAG = `--load-extension=${EXT_DEST}`;
|
|
6450
|
+
console.log(`
|
|
6309
6451
|
Installing CFC extension v${extVersion} via --load-extension...`);
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
encoding: "utf-8"
|
|
6318
|
-
});
|
|
6319
|
-
if (result.status === 0) pushed++;
|
|
6320
|
-
}
|
|
6452
|
+
sp("adb", ["shell", "mkdir", "-p", EXT_DEST], { stdio: "pipe" });
|
|
6453
|
+
let pushed = 0;
|
|
6454
|
+
for (const f of EXT_FILES) {
|
|
6455
|
+
const src = (0, import_path2.resolve)(extDir, f);
|
|
6456
|
+
if ((0, import_fs.existsSync)(src)) {
|
|
6457
|
+
const r = sp("adb", ["push", src, `${EXT_DEST}/${f}`], { stdio: "pipe", encoding: "utf-8" });
|
|
6458
|
+
if (r.status === 0) pushed++;
|
|
6321
6459
|
}
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6460
|
+
}
|
|
6461
|
+
console.log(` Pushed ${pushed}/${EXT_FILES.length} files to ${EXT_DEST}`);
|
|
6462
|
+
const flagsResult = sp("adb", ["shell", "cat", FLAGS_FILE], { stdio: "pipe", encoding: "utf-8" });
|
|
6463
|
+
let currentFlags = flagsResult.stdout?.trim() || "";
|
|
6464
|
+
if (!currentFlags.includes("--load-extension=")) {
|
|
6465
|
+
currentFlags = currentFlags ? `${currentFlags} ${LOAD_EXT_FLAG}` : `_ ${LOAD_EXT_FLAG}`;
|
|
6466
|
+
sp("adb", ["shell", `echo '${currentFlags}' > ${FLAGS_FILE}`], { stdio: "pipe" });
|
|
6467
|
+
console.log(" Added --load-extension flag to chrome-command-line");
|
|
6468
|
+
} else if (!currentFlags.includes(EXT_DEST)) {
|
|
6469
|
+
currentFlags = currentFlags.replace(/--load-extension=\S+/, LOAD_EXT_FLAG);
|
|
6470
|
+
sp("adb", ["shell", `echo '${currentFlags}' > ${FLAGS_FILE}`], { stdio: "pipe" });
|
|
6471
|
+
console.log(" Updated --load-extension path in chrome-command-line");
|
|
6472
|
+
} else {
|
|
6473
|
+
console.log(" --load-extension flag already set");
|
|
6474
|
+
}
|
|
6475
|
+
const edgePkg = detectEdgePkg(sp);
|
|
6476
|
+
if (edgePkg) {
|
|
6477
|
+
sp("adb", ["shell", "settings", "put", "global", "debug_app", edgePkg], { stdio: "pipe" });
|
|
6478
|
+
console.log(` Set debug_app=${edgePkg} for flag reading`);
|
|
6479
|
+
sp("adb", ["shell", "am", "force-stop", edgePkg], { stdio: "pipe" });
|
|
6480
|
+
console.log(` Restarted ${edgePkg} to apply changes`);
|
|
6481
|
+
} else {
|
|
6482
|
+
console.log(" WARNING: No Edge browser found. Install Edge Canary from the Play Store.");
|
|
6483
|
+
}
|
|
6484
|
+
console.log(" Extension will load automatically when Edge starts.");
|
|
6485
|
+
return true;
|
|
6486
|
+
}
|
|
6487
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
6488
|
+
function ask(question) {
|
|
6489
|
+
return new Promise((res) => {
|
|
6490
|
+
const rl = require("readline").createInterface({ input: process.stdin, output: process.stdout });
|
|
6491
|
+
rl.question(question, (answer) => {
|
|
6492
|
+
rl.close();
|
|
6493
|
+
res(answer.trim().toLowerCase());
|
|
6326
6494
|
});
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6495
|
+
});
|
|
6496
|
+
}
|
|
6497
|
+
var isYes = (a) => a === "" || a === "y" || a === "yes";
|
|
6498
|
+
var EDGE_CANARY = "com.microsoft.emmx.canary";
|
|
6499
|
+
async function ensureEdgeInstalled(sp, interactive) {
|
|
6500
|
+
let pkg = detectEdgePkg(sp);
|
|
6501
|
+
if (pkg) return pkg;
|
|
6502
|
+
const listing = `https://play.google.com/store/apps/details?id=${EDGE_CANARY}`;
|
|
6503
|
+
if (!interactive) {
|
|
6504
|
+
console.log(`
|
|
6505
|
+
Edge not installed. Install Edge Canary, then re-run:
|
|
6506
|
+
${listing}`);
|
|
6507
|
+
return "";
|
|
6508
|
+
}
|
|
6509
|
+
const a = await ask("\nEdge isn't installed. Open the Play Store to install Edge Canary now? [Y/n] ");
|
|
6510
|
+
if (!isYes(a)) {
|
|
6511
|
+
console.log("Skipped Edge install.");
|
|
6512
|
+
return "";
|
|
6513
|
+
}
|
|
6514
|
+
sp("adb", ["shell", `am start -a android.intent.action.VIEW -d 'market://details?id=${EDGE_CANARY}'`], { stdio: "pipe" });
|
|
6515
|
+
console.log("Opened the Play Store on your device. Tap Install, wait for it to finish, then return here.");
|
|
6516
|
+
await ask("Press Enter once Edge Canary has finished installing... ");
|
|
6517
|
+
for (let i = 0; i < 5 && !pkg; i++) {
|
|
6518
|
+
pkg = detectEdgePkg(sp);
|
|
6519
|
+
if (!pkg) await sleep(2e3);
|
|
6520
|
+
}
|
|
6521
|
+
if (pkg) console.log(`Detected ${pkg}.`);
|
|
6522
|
+
else console.log("Still don't see Edge installed \u2014 skipping the rest of setup.");
|
|
6523
|
+
return pkg;
|
|
6524
|
+
}
|
|
6525
|
+
async function probeEdge(sp) {
|
|
6526
|
+
const hasAdb = adbOnline(sp);
|
|
6527
|
+
const edgePkg = hasAdb ? detectEdgePkg(sp) : "";
|
|
6528
|
+
return {
|
|
6529
|
+
hasAdb,
|
|
6530
|
+
edgePkg,
|
|
6531
|
+
patched: hasAdb && edgePkg ? edgeIsPatched(sp, edgePkg) : null,
|
|
6532
|
+
extPushed: hasAdb ? extPushed(sp) : false,
|
|
6533
|
+
flagsLoadExt: hasAdb ? flagsLoadExt(sp) : false,
|
|
6534
|
+
clients: await bridgeClientCount()
|
|
6535
|
+
};
|
|
6536
|
+
}
|
|
6537
|
+
function printEdgeStatus(s) {
|
|
6538
|
+
const mark = (ok) => ok === null ? "?" : ok ? "OK" : "MISSING";
|
|
6539
|
+
console.log("CFC environment check:");
|
|
6540
|
+
console.log(` [${mark(s.hasAdb)}] ADB device connected`);
|
|
6541
|
+
console.log(` [${s.edgePkg ? "OK" : "MISSING"}] Edge installed${s.edgePkg ? ` (${s.edgePkg})` : ""}`);
|
|
6542
|
+
console.log(` [${mark(s.patched)}] Edge privacy-patched (AD_ID stripped)`);
|
|
6543
|
+
console.log(` [${mark(s.extPushed && s.flagsLoadExt)}] CFC extension sideloaded + flag set`);
|
|
6544
|
+
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)"}`);
|
|
6545
|
+
}
|
|
6546
|
+
async function offerPatchBuild(sp, edgePkg, interactive) {
|
|
6547
|
+
const script = findBuildScript();
|
|
6548
|
+
if (!script) {
|
|
6549
|
+
console.log("\nTo build a privacy-patched Edge from your installed copy:");
|
|
6550
|
+
console.log(" git clone https://github.com/tribixbite/termux-tools");
|
|
6551
|
+
console.log(" cd termux-tools/edge-fix && ./build-from-device.sh --install");
|
|
6552
|
+
console.log("(needs apktool, zipalign/apksigner, java, python3 + the tool jars in tools/)");
|
|
6553
|
+
return;
|
|
6554
|
+
}
|
|
6555
|
+
if (!interactive) {
|
|
6556
|
+
console.log(`
|
|
6557
|
+
Run the self-build to patch Edge (no data wipe on re-sign):`);
|
|
6558
|
+
console.log(` ${script} --install`);
|
|
6559
|
+
return;
|
|
6560
|
+
}
|
|
6561
|
+
const a = await ask(`
|
|
6562
|
+
Build + install a privacy-patched ${edgePkg} now via build-from-device.sh? [Y/n] `);
|
|
6563
|
+
if (!isYes(a)) {
|
|
6564
|
+
console.log("Skipped patch build.");
|
|
6565
|
+
return;
|
|
6566
|
+
}
|
|
6567
|
+
console.log("\nRunning build-from-device.sh --install (this takes a few minutes)...\n");
|
|
6568
|
+
const r = sp("bash", [script, "--install"], { stdio: "inherit" });
|
|
6569
|
+
if (r.status === 0) console.log("\nPatched Edge installed.");
|
|
6570
|
+
else console.log(`
|
|
6571
|
+
build-from-device.sh exited ${r.status}. See output above.`);
|
|
6572
|
+
}
|
|
6573
|
+
async function runEdgeSetup(sp, interactive) {
|
|
6574
|
+
const s = await probeEdge(sp);
|
|
6575
|
+
printEdgeStatus(s);
|
|
6576
|
+
if (!s.hasAdb) {
|
|
6577
|
+
console.log("\nNo ADB device. Connect with: adb tcpip 5555 && adb connect <device-ip>");
|
|
6578
|
+
return false;
|
|
6579
|
+
}
|
|
6580
|
+
const edgePkg = s.edgePkg || await ensureEdgeInstalled(sp, interactive);
|
|
6581
|
+
if (!edgePkg) return false;
|
|
6582
|
+
const patched = s.edgePkg ? s.patched : edgeIsPatched(sp, edgePkg);
|
|
6583
|
+
if (patched !== true) {
|
|
6584
|
+
if (patched === false) console.log("\nYour Edge still ships tracking permissions.");
|
|
6585
|
+
await offerPatchBuild(sp, edgePkg, interactive);
|
|
6586
|
+
}
|
|
6587
|
+
const reProbe = await probeEdge(sp);
|
|
6588
|
+
if (!reProbe.extPushed || !reProbe.flagsLoadExt || reProbe.clients === 0) {
|
|
6589
|
+
if (interactive) {
|
|
6590
|
+
const a = await ask("\nSideload the CFC extension into Edge now? [Y/n] ");
|
|
6591
|
+
if (isYes(a)) await installExtension(sp);
|
|
6592
|
+
else console.log("Skipped extension install.");
|
|
6371
6593
|
} else {
|
|
6372
|
-
console.log("
|
|
6594
|
+
console.log("\nInstall the CFC extension with: claude-chrome-android --setup");
|
|
6373
6595
|
}
|
|
6374
|
-
console.log(" Extension will load automatically when Edge starts.");
|
|
6375
6596
|
}
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
2. Open Edge \u2014 the extension loads automatically via --load-extension
|
|
6382
|
-
3. Open a new Claude Code session \u2014 browser tools (mcp__cfc-bridge__*) will be available
|
|
6383
|
-
4. Use ToolSearch to find and load cfc-bridge tools
|
|
6384
|
-
|
|
6385
|
-
To update the extension later:
|
|
6386
|
-
npx claude-chrome-android --setup (re-pushes latest files)
|
|
6597
|
+
const final = await probeEdge(sp);
|
|
6598
|
+
return Boolean(final.edgePkg && final.patched === true && final.extPushed && final.flagsLoadExt);
|
|
6599
|
+
}
|
|
6600
|
+
async function cmdSetupEdge() {
|
|
6601
|
+
console.log(`claude-chrome-android v${PKG_VERSION} \u2014 Edge setup
|
|
6387
6602
|
`);
|
|
6603
|
+
const { spawnSync: spawnSync2 } = await import("child_process");
|
|
6604
|
+
await runEdgeSetup(spawnSync2, Boolean(process.stdin.isTTY));
|
|
6605
|
+
console.log("\nDone. Start the bridge with: claude-chrome-android");
|
|
6388
6606
|
}
|
|
6389
6607
|
async function cmdStart() {
|
|
6390
6608
|
if (await isBridgeAlive()) {
|
|
@@ -6392,6 +6610,25 @@ async function cmdStart() {
|
|
|
6392
6610
|
console.log("Use --stop to stop it first, or --help for more options.");
|
|
6393
6611
|
process.exit(0);
|
|
6394
6612
|
}
|
|
6613
|
+
const interactive = Boolean(process.stdin.isTTY);
|
|
6614
|
+
try {
|
|
6615
|
+
const { spawnSync: spawnSync2 } = await import("child_process");
|
|
6616
|
+
if (adbOnline(spawnSync2)) {
|
|
6617
|
+
const edgePkg = detectEdgePkg(spawnSync2);
|
|
6618
|
+
const ready = edgePkg && extPushed(spawnSync2) && flagsLoadExt(spawnSync2);
|
|
6619
|
+
if (!ready) {
|
|
6620
|
+
if (interactive) {
|
|
6621
|
+
console.log("First-time setup: let's get Edge + the CFC extension ready.\n");
|
|
6622
|
+
await runEdgeSetup(spawnSync2, true);
|
|
6623
|
+
console.log("");
|
|
6624
|
+
} else {
|
|
6625
|
+
console.log("\nHeads up: Edge + CFC extension don't look fully set up.");
|
|
6626
|
+
console.log("Run `claude-chrome-android --setup-edge` to finish setup.\n");
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
} catch {
|
|
6631
|
+
}
|
|
6395
6632
|
console.log(`Starting CFC Bridge v${PKG_VERSION} on ws://${WS_HOST2}:${WS_PORT2}...`);
|
|
6396
6633
|
try {
|
|
6397
6634
|
await Promise.resolve().then(() => (init_claude_chrome_bridge(), claude_chrome_bridge_exports));
|
|
@@ -6766,6 +7003,10 @@ switch (command) {
|
|
|
6766
7003
|
case "--setup":
|
|
6767
7004
|
cmdSetup();
|
|
6768
7005
|
break;
|
|
7006
|
+
case "--setup-edge":
|
|
7007
|
+
case "--doctor":
|
|
7008
|
+
cmdSetupEdge();
|
|
7009
|
+
break;
|
|
6769
7010
|
case "--mcp":
|
|
6770
7011
|
cmdMcp();
|
|
6771
7012
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-chrome-android",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Claude Code Browser Bridge for Android — connects Claude Code CLI to Chrome/Edge via WebSocket",
|
|
5
5
|
"author": "willstone",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist/",
|
|
16
|
+
"!dist/*.pem",
|
|
17
|
+
"!dist/claude-code-bridge-v*.crx",
|
|
16
18
|
"README.md"
|
|
17
19
|
],
|
|
18
20
|
"scripts": {
|