claude-chrome-android 1.3.0 → 1.4.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/dist/claude-code-bridge.crx +0 -0
- package/dist/cli.js +278 -164
- package/dist/edge-claude-ext/background.js +1492 -0
- package/dist/edge-claude-ext/content.js +1044 -0
- package/dist/edge-claude-ext/icon128.png +0 -0
- package/dist/edge-claude-ext/icon16.png +0 -0
- package/dist/edge-claude-ext/icon48.png +0 -0
- package/dist/edge-claude-ext/launcher.html +63 -0
- package/dist/edge-claude-ext/launcher.js +98 -0
- package/dist/edge-claude-ext/manifest.json +35 -0
- package/dist/edge-claude-ext/popup.html +444 -0
- package/dist/edge-claude-ext/popup.js +637 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -204,7 +204,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
204
204
|
var kBuffers = Symbol("buffers");
|
|
205
205
|
var kError = Symbol("error");
|
|
206
206
|
var zlibLimiter;
|
|
207
|
-
var
|
|
207
|
+
var PerMessageDeflate2 = class {
|
|
208
208
|
/**
|
|
209
209
|
* Creates a PerMessageDeflate instance.
|
|
210
210
|
*
|
|
@@ -215,6 +215,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
215
215
|
* acknowledge disabling of client context takeover
|
|
216
216
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
217
217
|
* calls to zlib
|
|
218
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
219
|
+
* server or client mode
|
|
220
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
218
221
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
219
222
|
* use of a custom server window size
|
|
220
223
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -225,15 +228,12 @@ var require_permessage_deflate = __commonJS({
|
|
|
225
228
|
* deflate
|
|
226
229
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
227
230
|
* inflate
|
|
228
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
229
|
-
* client mode
|
|
230
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
231
231
|
*/
|
|
232
|
-
constructor(options
|
|
233
|
-
this._maxPayload = maxPayload | 0;
|
|
232
|
+
constructor(options) {
|
|
234
233
|
this._options = options || {};
|
|
235
234
|
this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
|
|
236
|
-
this.
|
|
235
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
236
|
+
this._isServer = !!this._options.isServer;
|
|
237
237
|
this._deflate = null;
|
|
238
238
|
this._inflate = null;
|
|
239
239
|
this.params = null;
|
|
@@ -542,7 +542,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
542
542
|
});
|
|
543
543
|
}
|
|
544
544
|
};
|
|
545
|
-
module2.exports =
|
|
545
|
+
module2.exports = PerMessageDeflate2;
|
|
546
546
|
function deflateOnData(chunk) {
|
|
547
547
|
this[kBuffers].push(chunk);
|
|
548
548
|
this[kTotalLength] += chunk.length;
|
|
@@ -779,7 +779,7 @@ var require_receiver = __commonJS({
|
|
|
779
779
|
"use strict";
|
|
780
780
|
init_import_meta_shim();
|
|
781
781
|
var { Writable } = require("stream");
|
|
782
|
-
var
|
|
782
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
783
783
|
var {
|
|
784
784
|
BINARY_TYPES,
|
|
785
785
|
EMPTY_BUFFER,
|
|
@@ -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);
|
|
@@ -946,7 +964,7 @@ var require_receiver = __commonJS({
|
|
|
946
964
|
return;
|
|
947
965
|
}
|
|
948
966
|
const compressed = (buf[0] & 64) === 64;
|
|
949
|
-
if (compressed && !this._extensions[
|
|
967
|
+
if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
|
|
950
968
|
const error = this.createError(
|
|
951
969
|
RangeError,
|
|
952
970
|
"RSV1 must be clear",
|
|
@@ -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
|
}
|
|
@@ -1190,7 +1219,7 @@ var require_receiver = __commonJS({
|
|
|
1190
1219
|
* @private
|
|
1191
1220
|
*/
|
|
1192
1221
|
decompress(data, cb) {
|
|
1193
|
-
const perMessageDeflate = this._extensions[
|
|
1222
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1194
1223
|
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
1195
1224
|
if (err) return cb(err);
|
|
1196
1225
|
if (buf.length) {
|
|
@@ -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);
|
|
@@ -1373,7 +1413,10 @@ var require_sender = __commonJS({
|
|
|
1373
1413
|
init_import_meta_shim();
|
|
1374
1414
|
var { Duplex } = require("stream");
|
|
1375
1415
|
var { randomFillSync } = require("crypto");
|
|
1376
|
-
var
|
|
1416
|
+
var {
|
|
1417
|
+
types: { isUint8Array }
|
|
1418
|
+
} = require("util");
|
|
1419
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1377
1420
|
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
|
|
1378
1421
|
var { isBlob, isValidStatusCode } = require_validation();
|
|
1379
1422
|
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
@@ -1526,8 +1569,10 @@ var require_sender = __commonJS({
|
|
|
1526
1569
|
buf.writeUInt16BE(code, 0);
|
|
1527
1570
|
if (typeof data === "string") {
|
|
1528
1571
|
buf.write(data, 2);
|
|
1529
|
-
} else {
|
|
1572
|
+
} else if (isUint8Array(data)) {
|
|
1530
1573
|
buf.set(data, 2);
|
|
1574
|
+
} else {
|
|
1575
|
+
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
1531
1576
|
}
|
|
1532
1577
|
}
|
|
1533
1578
|
const options = {
|
|
@@ -1657,7 +1702,7 @@ var require_sender = __commonJS({
|
|
|
1657
1702
|
* @public
|
|
1658
1703
|
*/
|
|
1659
1704
|
send(data, options, cb) {
|
|
1660
|
-
const perMessageDeflate = this._extensions[
|
|
1705
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1661
1706
|
let opcode = options.binary ? 2 : 1;
|
|
1662
1707
|
let rsv1 = options.compress;
|
|
1663
1708
|
let byteLength;
|
|
@@ -1781,7 +1826,7 @@ var require_sender = __commonJS({
|
|
|
1781
1826
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
1782
1827
|
return;
|
|
1783
1828
|
}
|
|
1784
|
-
const perMessageDeflate = this._extensions[
|
|
1829
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1785
1830
|
this._bufferedBytes += options[kByteLength];
|
|
1786
1831
|
this._state = DEFLATING;
|
|
1787
1832
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
@@ -2221,11 +2266,11 @@ var require_extension = __commonJS({
|
|
|
2221
2266
|
return offers;
|
|
2222
2267
|
}
|
|
2223
2268
|
function format(extensions) {
|
|
2224
|
-
return Object.keys(extensions).map((
|
|
2225
|
-
let configurations = extensions[
|
|
2269
|
+
return Object.keys(extensions).map((extension2) => {
|
|
2270
|
+
let configurations = extensions[extension2];
|
|
2226
2271
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
2227
2272
|
return configurations.map((params) => {
|
|
2228
|
-
return [
|
|
2273
|
+
return [extension2].concat(
|
|
2229
2274
|
Object.keys(params).map((k) => {
|
|
2230
2275
|
let values = params[k];
|
|
2231
2276
|
if (!Array.isArray(values)) values = [values];
|
|
@@ -2252,7 +2297,7 @@ var require_websocket = __commonJS({
|
|
|
2252
2297
|
var { randomBytes, createHash } = require("crypto");
|
|
2253
2298
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
2254
2299
|
var { URL: URL2 } = require("url");
|
|
2255
|
-
var
|
|
2300
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
2256
2301
|
var Receiver2 = require_receiver();
|
|
2257
2302
|
var Sender2 = require_sender();
|
|
2258
2303
|
var { isBlob } = require_validation();
|
|
@@ -2411,6 +2456,10 @@ var require_websocket = __commonJS({
|
|
|
2411
2456
|
* multiple times in the same tick
|
|
2412
2457
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
2413
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
|
|
2414
2463
|
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
2415
2464
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
2416
2465
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -2422,6 +2471,8 @@ var require_websocket = __commonJS({
|
|
|
2422
2471
|
binaryType: this.binaryType,
|
|
2423
2472
|
extensions: this._extensions,
|
|
2424
2473
|
isServer: this._isServer,
|
|
2474
|
+
maxBufferedChunks: options.maxBufferedChunks,
|
|
2475
|
+
maxFragments: options.maxFragments,
|
|
2425
2476
|
maxPayload: options.maxPayload,
|
|
2426
2477
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2427
2478
|
});
|
|
@@ -2460,8 +2511,8 @@ var require_websocket = __commonJS({
|
|
|
2460
2511
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2461
2512
|
return;
|
|
2462
2513
|
}
|
|
2463
|
-
if (this._extensions[
|
|
2464
|
-
this._extensions[
|
|
2514
|
+
if (this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2515
|
+
this._extensions[PerMessageDeflate2.extensionName].cleanup();
|
|
2465
2516
|
}
|
|
2466
2517
|
this._receiver.removeAllListeners();
|
|
2467
2518
|
this._readyState = _WebSocket.CLOSED;
|
|
@@ -2623,7 +2674,7 @@ var require_websocket = __commonJS({
|
|
|
2623
2674
|
fin: true,
|
|
2624
2675
|
...options
|
|
2625
2676
|
};
|
|
2626
|
-
if (!this._extensions[
|
|
2677
|
+
if (!this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2627
2678
|
opts.compress = false;
|
|
2628
2679
|
}
|
|
2629
2680
|
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
@@ -2721,6 +2772,8 @@ var require_websocket = __commonJS({
|
|
|
2721
2772
|
autoPong: true,
|
|
2722
2773
|
closeTimeout: CLOSE_TIMEOUT,
|
|
2723
2774
|
protocolVersion: protocolVersions[1],
|
|
2775
|
+
maxBufferedChunks: 1024 * 1024,
|
|
2776
|
+
maxFragments: 128 * 1024,
|
|
2724
2777
|
maxPayload: 100 * 1024 * 1024,
|
|
2725
2778
|
skipUTF8Validation: false,
|
|
2726
2779
|
perMessageDeflate: true,
|
|
@@ -2749,7 +2802,7 @@ var require_websocket = __commonJS({
|
|
|
2749
2802
|
} else {
|
|
2750
2803
|
try {
|
|
2751
2804
|
parsedUrl = new URL2(address);
|
|
2752
|
-
} catch
|
|
2805
|
+
} catch {
|
|
2753
2806
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2754
2807
|
}
|
|
2755
2808
|
}
|
|
@@ -2797,13 +2850,13 @@ var require_websocket = __commonJS({
|
|
|
2797
2850
|
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
2798
2851
|
opts.timeout = opts.handshakeTimeout;
|
|
2799
2852
|
if (opts.perMessageDeflate) {
|
|
2800
|
-
perMessageDeflate = new
|
|
2801
|
-
opts.perMessageDeflate
|
|
2802
|
-
false,
|
|
2803
|
-
opts.maxPayload
|
|
2804
|
-
);
|
|
2853
|
+
perMessageDeflate = new PerMessageDeflate2({
|
|
2854
|
+
...opts.perMessageDeflate,
|
|
2855
|
+
isServer: false,
|
|
2856
|
+
maxPayload: opts.maxPayload
|
|
2857
|
+
});
|
|
2805
2858
|
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
2806
|
-
[
|
|
2859
|
+
[PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
|
|
2807
2860
|
});
|
|
2808
2861
|
}
|
|
2809
2862
|
if (protocols.length) {
|
|
@@ -2946,23 +2999,25 @@ var require_websocket = __commonJS({
|
|
|
2946
2999
|
return;
|
|
2947
3000
|
}
|
|
2948
3001
|
const extensionNames = Object.keys(extensions);
|
|
2949
|
-
if (extensionNames.length !== 1 || extensionNames[0] !==
|
|
3002
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
|
|
2950
3003
|
const message = "Server indicated an extension that was not requested";
|
|
2951
3004
|
abortHandshake(websocket, socket, message);
|
|
2952
3005
|
return;
|
|
2953
3006
|
}
|
|
2954
3007
|
try {
|
|
2955
|
-
perMessageDeflate.accept(extensions[
|
|
3008
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
|
|
2956
3009
|
} catch (err) {
|
|
2957
3010
|
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
2958
3011
|
abortHandshake(websocket, socket, message);
|
|
2959
3012
|
return;
|
|
2960
3013
|
}
|
|
2961
|
-
websocket._extensions[
|
|
3014
|
+
websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
2962
3015
|
}
|
|
2963
3016
|
websocket.setSocket(socket, head, {
|
|
2964
3017
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
2965
3018
|
generateMask: opts.generateMask,
|
|
3019
|
+
maxBufferedChunks: opts.maxBufferedChunks,
|
|
3020
|
+
maxFragments: opts.maxFragments,
|
|
2966
3021
|
maxPayload: opts.maxPayload,
|
|
2967
3022
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
2968
3023
|
});
|
|
@@ -3280,9 +3335,9 @@ var require_websocket_server = __commonJS({
|
|
|
3280
3335
|
var http2 = require("http");
|
|
3281
3336
|
var { Duplex } = require("stream");
|
|
3282
3337
|
var { createHash } = require("crypto");
|
|
3283
|
-
var
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3338
|
+
var extension2 = require_extension();
|
|
3339
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
3340
|
+
var subprotocol2 = require_subprotocol();
|
|
3286
3341
|
var WebSocket3 = require_websocket();
|
|
3287
3342
|
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();
|
|
3288
3343
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
@@ -3308,6 +3363,10 @@ var require_websocket_server = __commonJS({
|
|
|
3308
3363
|
* called
|
|
3309
3364
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
3310
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
|
|
3311
3370
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3312
3371
|
* size
|
|
3313
3372
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
@@ -3329,6 +3388,8 @@ var require_websocket_server = __commonJS({
|
|
|
3329
3388
|
options = {
|
|
3330
3389
|
allowSynchronousEvents: true,
|
|
3331
3390
|
autoPong: true,
|
|
3391
|
+
maxBufferedChunks: 1024 * 1024,
|
|
3392
|
+
maxFragments: 128 * 1024,
|
|
3332
3393
|
maxPayload: 100 * 1024 * 1024,
|
|
3333
3394
|
skipUTF8Validation: false,
|
|
3334
3395
|
perMessageDeflate: false,
|
|
@@ -3505,7 +3566,7 @@ var require_websocket_server = __commonJS({
|
|
|
3505
3566
|
let protocols = /* @__PURE__ */ new Set();
|
|
3506
3567
|
if (secWebSocketProtocol !== void 0) {
|
|
3507
3568
|
try {
|
|
3508
|
-
protocols =
|
|
3569
|
+
protocols = subprotocol2.parse(secWebSocketProtocol);
|
|
3509
3570
|
} catch (err) {
|
|
3510
3571
|
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
3511
3572
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
@@ -3515,16 +3576,16 @@ var require_websocket_server = __commonJS({
|
|
|
3515
3576
|
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
3516
3577
|
const extensions = {};
|
|
3517
3578
|
if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
|
|
3518
|
-
const perMessageDeflate = new
|
|
3519
|
-
this.options.perMessageDeflate,
|
|
3520
|
-
true,
|
|
3521
|
-
this.options.maxPayload
|
|
3522
|
-
);
|
|
3579
|
+
const perMessageDeflate = new PerMessageDeflate2({
|
|
3580
|
+
...this.options.perMessageDeflate,
|
|
3581
|
+
isServer: true,
|
|
3582
|
+
maxPayload: this.options.maxPayload
|
|
3583
|
+
});
|
|
3523
3584
|
try {
|
|
3524
|
-
const offers =
|
|
3525
|
-
if (offers[
|
|
3526
|
-
perMessageDeflate.accept(offers[
|
|
3527
|
-
extensions[
|
|
3585
|
+
const offers = extension2.parse(secWebSocketExtensions);
|
|
3586
|
+
if (offers[PerMessageDeflate2.extensionName]) {
|
|
3587
|
+
perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
|
|
3588
|
+
extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3528
3589
|
}
|
|
3529
3590
|
} catch (err) {
|
|
3530
3591
|
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
@@ -3595,10 +3656,10 @@ var require_websocket_server = __commonJS({
|
|
|
3595
3656
|
ws._protocol = protocol;
|
|
3596
3657
|
}
|
|
3597
3658
|
}
|
|
3598
|
-
if (extensions[
|
|
3599
|
-
const params = extensions[
|
|
3600
|
-
const value =
|
|
3601
|
-
[
|
|
3659
|
+
if (extensions[PerMessageDeflate2.extensionName]) {
|
|
3660
|
+
const params = extensions[PerMessageDeflate2.extensionName].params;
|
|
3661
|
+
const value = extension2.format({
|
|
3662
|
+
[PerMessageDeflate2.extensionName]: [params]
|
|
3602
3663
|
});
|
|
3603
3664
|
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
3604
3665
|
ws._extensions = extensions;
|
|
@@ -3608,6 +3669,8 @@ var require_websocket_server = __commonJS({
|
|
|
3608
3669
|
socket.removeListener("error", socketOnError);
|
|
3609
3670
|
ws.setSocket(socket, head, {
|
|
3610
3671
|
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
3672
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
3673
|
+
maxFragments: this.options.maxFragments,
|
|
3611
3674
|
maxPayload: this.options.maxPayload,
|
|
3612
3675
|
skipUTF8Validation: this.options.skipUTF8Validation
|
|
3613
3676
|
});
|
|
@@ -3666,13 +3729,16 @@ var require_websocket_server = __commonJS({
|
|
|
3666
3729
|
});
|
|
3667
3730
|
|
|
3668
3731
|
// node_modules/ws/wrapper.mjs
|
|
3669
|
-
var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server;
|
|
3732
|
+
var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server;
|
|
3670
3733
|
var init_wrapper = __esm({
|
|
3671
3734
|
"node_modules/ws/wrapper.mjs"() {
|
|
3672
3735
|
init_import_meta_shim();
|
|
3673
3736
|
import_stream = __toESM(require_stream(), 1);
|
|
3737
|
+
import_extension = __toESM(require_extension(), 1);
|
|
3738
|
+
import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
3674
3739
|
import_receiver = __toESM(require_receiver(), 1);
|
|
3675
3740
|
import_sender = __toESM(require_sender(), 1);
|
|
3741
|
+
import_subprotocol = __toESM(require_subprotocol(), 1);
|
|
3676
3742
|
import_websocket = __toESM(require_websocket(), 1);
|
|
3677
3743
|
import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
3678
3744
|
}
|
|
@@ -3708,7 +3774,8 @@ function runSync(cmd, opts) {
|
|
|
3708
3774
|
const result2 = Bun.spawnSync({
|
|
3709
3775
|
cmd,
|
|
3710
3776
|
stdout: opts?.stdout ?? "pipe",
|
|
3711
|
-
stderr: opts?.stderr ?? "pipe"
|
|
3777
|
+
stderr: opts?.stderr ?? "pipe",
|
|
3778
|
+
...opts?.timeoutMs ? { timeout: opts.timeoutMs } : {}
|
|
3712
3779
|
});
|
|
3713
3780
|
return {
|
|
3714
3781
|
success: result2.success,
|
|
@@ -3723,7 +3790,8 @@ function runSync(cmd, opts) {
|
|
|
3723
3790
|
opts?.stdout ?? "pipe",
|
|
3724
3791
|
opts?.stderr ?? "pipe"
|
|
3725
3792
|
],
|
|
3726
|
-
encoding: "buffer"
|
|
3793
|
+
encoding: "buffer",
|
|
3794
|
+
...opts?.timeoutMs ? { timeout: opts.timeoutMs, killSignal: "SIGKILL" } : {}
|
|
3727
3795
|
});
|
|
3728
3796
|
return {
|
|
3729
3797
|
success: result.status === 0,
|
|
@@ -3853,14 +3921,15 @@ function createNodeServer(config) {
|
|
|
3853
3921
|
reqInit.body = body;
|
|
3854
3922
|
}
|
|
3855
3923
|
const request = new Request(url, reqInit);
|
|
3856
|
-
|
|
3857
|
-
|
|
3924
|
+
let httpUpgradeRequested = false;
|
|
3925
|
+
const upgrade = (_data) => {
|
|
3926
|
+
httpUpgradeRequested = true;
|
|
3858
3927
|
return true;
|
|
3859
3928
|
};
|
|
3860
3929
|
try {
|
|
3861
3930
|
const response = await config.fetch(request, upgrade);
|
|
3862
|
-
if (response === void 0 ||
|
|
3863
|
-
if (
|
|
3931
|
+
if (response === void 0 || httpUpgradeRequested) {
|
|
3932
|
+
if (!httpUpgradeRequested) {
|
|
3864
3933
|
nodeRes.writeHead(500);
|
|
3865
3934
|
nodeRes.end("WebSocket upgrade not triggered");
|
|
3866
3935
|
}
|
|
@@ -3951,8 +4020,9 @@ function getAdbSerial() {
|
|
|
3951
4020
|
const now = Date.now();
|
|
3952
4021
|
if (now - _adbSerialTs < ADB_SERIAL_TTL_MS) return _adbSerial;
|
|
3953
4022
|
_adbSerialTs = now;
|
|
4023
|
+
const ADB_CALL_TIMEOUT_MS = 3e3;
|
|
3954
4024
|
try {
|
|
3955
|
-
const result = runSync([ADB_PATH, "devices"]);
|
|
4025
|
+
const result = runSync([ADB_PATH, "devices"], { timeoutMs: ADB_CALL_TIMEOUT_MS });
|
|
3956
4026
|
const lines = result.stdout.toString().trim().split("\n").filter((l) => l.endsWith(" device"));
|
|
3957
4027
|
if (lines.length <= 1) {
|
|
3958
4028
|
_adbSerial = "";
|
|
@@ -3960,7 +4030,7 @@ function getAdbSerial() {
|
|
|
3960
4030
|
}
|
|
3961
4031
|
for (const line of lines) {
|
|
3962
4032
|
const serial = line.split(" ")[0];
|
|
3963
|
-
const check = runSync([ADB_PATH, "-s", serial, "shell", "pidof", "com.microsoft.emmx.canary"]);
|
|
4033
|
+
const check = runSync([ADB_PATH, "-s", serial, "shell", "pidof", "com.microsoft.emmx.canary"], { timeoutMs: ADB_CALL_TIMEOUT_MS });
|
|
3964
4034
|
if (check.exitCode === 0 && check.stdout.toString().trim()) {
|
|
3965
4035
|
_adbSerial = serial;
|
|
3966
4036
|
return _adbSerial;
|
|
@@ -4331,6 +4401,20 @@ function sendToolRequest(requestId, requestJson) {
|
|
|
4331
4401
|
}
|
|
4332
4402
|
return sent;
|
|
4333
4403
|
}
|
|
4404
|
+
function rejectAllPendingTools(reason) {
|
|
4405
|
+
for (const [requestId, entry] of pendingToolMap) {
|
|
4406
|
+
clearTimeout(entry.timeout);
|
|
4407
|
+
entry.resolve({ type: "tool_response", error: reason, requestId });
|
|
4408
|
+
}
|
|
4409
|
+
pendingToolMap.clear();
|
|
4410
|
+
for (const queue of busyTabs.values()) {
|
|
4411
|
+
for (const entry of queue) {
|
|
4412
|
+
clearTimeout(entry.timeout);
|
|
4413
|
+
entry.resolve({ type: "tool_response", error: reason, requestId: entry.requestId });
|
|
4414
|
+
}
|
|
4415
|
+
}
|
|
4416
|
+
busyTabs.clear();
|
|
4417
|
+
}
|
|
4334
4418
|
function drainTabQueue(tabId) {
|
|
4335
4419
|
const queue = busyTabs.get(tabId);
|
|
4336
4420
|
if (!queue || queue.length === 0) {
|
|
@@ -4699,7 +4783,7 @@ function shutdown() {
|
|
|
4699
4783
|
log("info", "Bridge stopped");
|
|
4700
4784
|
process.exit(0);
|
|
4701
4785
|
}
|
|
4702
|
-
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;
|
|
4703
4787
|
var init_claude_chrome_bridge = __esm({
|
|
4704
4788
|
"../claude-chrome-bridge.ts"() {
|
|
4705
4789
|
init_import_meta_shim();
|
|
@@ -4729,7 +4813,10 @@ var init_claude_chrome_bridge = __esm({
|
|
|
4729
4813
|
_adbSerial = "";
|
|
4730
4814
|
_adbSerialTs = 0;
|
|
4731
4815
|
ADB_SERIAL_TTL_MS = 3e4;
|
|
4732
|
-
|
|
4816
|
+
NATIVE_HOST_WRAPPER = (0, import_path.resolve)(
|
|
4817
|
+
process.env.HOME ?? "~",
|
|
4818
|
+
".claude/chrome/chrome-native-host"
|
|
4819
|
+
);
|
|
4733
4820
|
BUN_GLOBAL_CLI = (0, import_path.resolve)(
|
|
4734
4821
|
process.env.HOME ?? "~",
|
|
4735
4822
|
".bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js"
|
|
@@ -4739,8 +4826,16 @@ var init_claude_chrome_bridge = __esm({
|
|
|
4739
4826
|
".npm/lib/node_modules/@anthropic-ai/claude-code/cli.js"
|
|
4740
4827
|
);
|
|
4741
4828
|
CLI_PATH = (() => {
|
|
4742
|
-
const { existsSync: existsSync2 } = require("fs");
|
|
4743
|
-
|
|
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]) {
|
|
4744
4839
|
if (existsSync2(p)) return p;
|
|
4745
4840
|
}
|
|
4746
4841
|
const result = runSync(["which", "claude"]);
|
|
@@ -5536,6 +5631,7 @@ var init_claude_chrome_bridge = __esm({
|
|
|
5536
5631
|
lastToolName = null;
|
|
5537
5632
|
lastToolTime = null;
|
|
5538
5633
|
nativeHost = null;
|
|
5634
|
+
nativeHostKillTimer = null;
|
|
5539
5635
|
stdoutDecoder = new NativeMessageDecoder();
|
|
5540
5636
|
wsClients = /* @__PURE__ */ new Set();
|
|
5541
5637
|
server = createBridgeServer({
|
|
@@ -5750,7 +5846,12 @@ var init_claude_chrome_bridge = __esm({
|
|
|
5750
5846
|
busyTabs.get(tabId).push({ requestJson: toolRequest, resolve: safeResolve, timeout, requestId, tabId });
|
|
5751
5847
|
} else {
|
|
5752
5848
|
pendingToolMap.set(requestId, { resolve: safeResolve, timeout, tabId });
|
|
5753
|
-
sendToolRequest(requestId, toolRequest);
|
|
5849
|
+
const sent = sendToolRequest(requestId, toolRequest);
|
|
5850
|
+
if (!sent) {
|
|
5851
|
+
pendingToolMap.delete(requestId);
|
|
5852
|
+
clearTimeout(timeout);
|
|
5853
|
+
safeResolve({ type: "tool_response", error: "All bridge clients disconnected before dispatch" });
|
|
5854
|
+
}
|
|
5754
5855
|
}
|
|
5755
5856
|
});
|
|
5756
5857
|
return new Response(
|
|
@@ -5781,6 +5882,10 @@ var init_claude_chrome_bridge = __esm({
|
|
|
5781
5882
|
open(ws) {
|
|
5782
5883
|
log("info", `WS client connected (total: ${wsClients.size + 1})`);
|
|
5783
5884
|
wsClients.add(ws);
|
|
5885
|
+
if (nativeHostKillTimer) {
|
|
5886
|
+
clearTimeout(nativeHostKillTimer);
|
|
5887
|
+
nativeHostKillTimer = null;
|
|
5888
|
+
}
|
|
5784
5889
|
if (!nativeHost) {
|
|
5785
5890
|
spawnNativeHost();
|
|
5786
5891
|
}
|
|
@@ -5870,9 +5975,15 @@ var init_claude_chrome_bridge = __esm({
|
|
|
5870
5975
|
close(ws) {
|
|
5871
5976
|
wsClients.delete(ws);
|
|
5872
5977
|
log("info", `WS client disconnected (remaining: ${wsClients.size})`);
|
|
5978
|
+
if (wsClients.size === 0 && (pendingToolMap.size > 0 || busyTabs.size > 0)) {
|
|
5979
|
+
log("warn", `Rejecting ${pendingToolMap.size} pending + ${busyTabs.size} queued tool request(s) \u2014 extension disconnected`);
|
|
5980
|
+
rejectAllPendingTools("Extension disconnected before tool response");
|
|
5981
|
+
}
|
|
5873
5982
|
if (wsClients.size === 0 && nativeHost) {
|
|
5983
|
+
if (nativeHostKillTimer) clearTimeout(nativeHostKillTimer);
|
|
5874
5984
|
log("info", "No clients remaining, stopping native host in 30s");
|
|
5875
|
-
setTimeout(() => {
|
|
5985
|
+
nativeHostKillTimer = setTimeout(() => {
|
|
5986
|
+
nativeHostKillTimer = null;
|
|
5876
5987
|
if (wsClients.size === 0 && nativeHost) {
|
|
5877
5988
|
log("info", "Stopping native host (no clients)");
|
|
5878
5989
|
nativeHost.kill();
|
|
@@ -6226,120 +6337,123 @@ esac
|
|
|
6226
6337
|
(0, import_fs.chmodSync)(urlOpenerPath, 493);
|
|
6227
6338
|
console.log(`${urlOpenerExists ? "Updated" : "Created"} ${urlOpenerPath}`);
|
|
6228
6339
|
const dir = typeof __dirname !== "undefined" ? __dirname : (0, import_path2.dirname)(new URL(import_meta_url).pathname);
|
|
6229
|
-
const
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
for (const p of manifestCandidates) {
|
|
6235
|
-
try {
|
|
6236
|
-
return JSON.parse((0, import_fs.readFileSync)(p, "utf-8")).version;
|
|
6237
|
-
} catch {
|
|
6238
|
-
}
|
|
6239
|
-
}
|
|
6240
|
-
return PKG_VERSION;
|
|
6241
|
-
})();
|
|
6242
|
-
const crxCandidates = [
|
|
6243
|
-
(0, import_path2.resolve)(dir, "claude-code-bridge.crx"),
|
|
6244
|
-
// npm package (bridge/dist/)
|
|
6245
|
-
(0, import_path2.resolve)(dir, `../../dist/claude-code-bridge-v${extVersion}.crx`),
|
|
6340
|
+
const EXT_DEST = "/data/local/tmp/cfc-ext";
|
|
6341
|
+
const FLAGS_FILE = "/data/local/tmp/chrome-command-line";
|
|
6342
|
+
const LOAD_EXT_FLAG = `--load-extension=${EXT_DEST}`;
|
|
6343
|
+
const extDirCandidates = [
|
|
6344
|
+
(0, import_path2.resolve)(dir, "../../edge-claude-ext"),
|
|
6246
6345
|
// source repo
|
|
6247
|
-
(0, import_path2.resolve)(dir, "
|
|
6248
|
-
//
|
|
6346
|
+
(0, import_path2.resolve)(dir, "edge-claude-ext")
|
|
6347
|
+
// npm package (dist/edge-claude-ext/)
|
|
6249
6348
|
];
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6349
|
+
const extDir = extDirCandidates.find((d) => (0, import_fs.existsSync)((0, import_path2.resolve)(d, "manifest.json")));
|
|
6350
|
+
const EXT_FILES = [
|
|
6351
|
+
"manifest.json",
|
|
6352
|
+
"background.js",
|
|
6353
|
+
"content.js",
|
|
6354
|
+
"popup.html",
|
|
6355
|
+
"popup.js",
|
|
6356
|
+
"launcher.html",
|
|
6357
|
+
"launcher.js",
|
|
6358
|
+
"icon16.png",
|
|
6359
|
+
"icon48.png",
|
|
6360
|
+
"icon128.png"
|
|
6361
|
+
];
|
|
6362
|
+
const adbCheck = spawnSync2("adb", ["devices"], { stdio: "pipe", encoding: "utf-8" });
|
|
6363
|
+
const hasAdb = adbCheck.status === 0 && adbCheck.stdout.includes(" device");
|
|
6364
|
+
if (!extDir) {
|
|
6365
|
+
console.log("\nExtension source not found. Skipping extension install.");
|
|
6366
|
+
console.log("To install manually, clone the repo and run push-extension.sh.");
|
|
6367
|
+
} else if (!hasAdb) {
|
|
6368
|
+
console.log("\nADB not available. Extension install requires ADB connection.");
|
|
6369
|
+
console.log("Connect via: adb tcpip 5555 && adb connect <device-ip>");
|
|
6263
6370
|
} else {
|
|
6264
|
-
const
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
const
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
"
|
|
6371
|
+
const extVersion = (() => {
|
|
6372
|
+
try {
|
|
6373
|
+
return JSON.parse((0, import_fs.readFileSync)((0, import_path2.resolve)(extDir, "manifest.json"), "utf-8")).version;
|
|
6374
|
+
} catch {
|
|
6375
|
+
return PKG_VERSION;
|
|
6376
|
+
}
|
|
6377
|
+
})();
|
|
6378
|
+
console.log(`
|
|
6379
|
+
Installing CFC extension v${extVersion} via --load-extension...`);
|
|
6380
|
+
spawnSync2("adb", ["shell", "mkdir", "-p", EXT_DEST], { stdio: "pipe" });
|
|
6381
|
+
let pushed = 0;
|
|
6382
|
+
for (const f of EXT_FILES) {
|
|
6383
|
+
const src = (0, import_path2.resolve)(extDir, f);
|
|
6384
|
+
if ((0, import_fs.existsSync)(src)) {
|
|
6385
|
+
const result = spawnSync2("adb", ["push", src, `${EXT_DEST}/${f}`], {
|
|
6386
|
+
stdio: "pipe",
|
|
6387
|
+
encoding: "utf-8"
|
|
6281
6388
|
});
|
|
6282
|
-
|
|
6389
|
+
if (result.status === 0) pushed++;
|
|
6390
|
+
}
|
|
6391
|
+
}
|
|
6392
|
+
console.log(` Pushed ${pushed}/${EXT_FILES.length} files to ${EXT_DEST}`);
|
|
6393
|
+
const flagsResult = spawnSync2("adb", ["shell", "cat", FLAGS_FILE], {
|
|
6394
|
+
stdio: "pipe",
|
|
6395
|
+
encoding: "utf-8"
|
|
6396
|
+
});
|
|
6397
|
+
let currentFlags = flagsResult.stdout?.trim() || "";
|
|
6398
|
+
if (!currentFlags.includes("--load-extension=")) {
|
|
6399
|
+
if (!currentFlags) {
|
|
6400
|
+
currentFlags = `_ ${LOAD_EXT_FLAG}`;
|
|
6401
|
+
} else {
|
|
6402
|
+
currentFlags = `${currentFlags} ${LOAD_EXT_FLAG}`;
|
|
6403
|
+
}
|
|
6404
|
+
spawnSync2("adb", ["shell", `echo '${currentFlags}' > ${FLAGS_FILE}`], {
|
|
6405
|
+
stdio: "pipe"
|
|
6283
6406
|
});
|
|
6284
|
-
|
|
6285
|
-
|
|
6407
|
+
console.log(" Added --load-extension flag to chrome-command-line");
|
|
6408
|
+
} else if (!currentFlags.includes(EXT_DEST)) {
|
|
6409
|
+
currentFlags = currentFlags.replace(/--load-extension=\S+/, LOAD_EXT_FLAG);
|
|
6410
|
+
spawnSync2("adb", ["shell", `echo '${currentFlags}' > ${FLAGS_FILE}`], {
|
|
6411
|
+
stdio: "pipe"
|
|
6286
6412
|
});
|
|
6287
|
-
console.log(
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
`${pkg}/com.microsoft.ruby.Main`
|
|
6307
|
-
], { stdio: "pipe", encoding: "utf-8" });
|
|
6308
|
-
if (result.status === 0 && !result.stderr.includes("Error")) {
|
|
6309
|
-
console.log(`Opened CRX download in ${pkg}`);
|
|
6310
|
-
opened = true;
|
|
6311
|
-
break;
|
|
6312
|
-
}
|
|
6413
|
+
console.log(" Updated --load-extension path in chrome-command-line");
|
|
6414
|
+
} else {
|
|
6415
|
+
console.log(" --load-extension flag already set");
|
|
6416
|
+
}
|
|
6417
|
+
const edgePackages = [
|
|
6418
|
+
"com.microsoft.emmx.canary",
|
|
6419
|
+
"com.microsoft.emmx.dev",
|
|
6420
|
+
"com.microsoft.emmx.beta",
|
|
6421
|
+
"com.microsoft.emmx"
|
|
6422
|
+
];
|
|
6423
|
+
let edgePkg = "";
|
|
6424
|
+
for (const pkg of edgePackages) {
|
|
6425
|
+
const check = spawnSync2("adb", ["shell", "pm", "list", "packages", pkg], {
|
|
6426
|
+
stdio: "pipe",
|
|
6427
|
+
encoding: "utf-8"
|
|
6428
|
+
});
|
|
6429
|
+
if (check.stdout?.includes(pkg)) {
|
|
6430
|
+
edgePkg = pkg;
|
|
6431
|
+
break;
|
|
6313
6432
|
}
|
|
6314
|
-
if (!opened) {
|
|
6315
|
-
console.log("Could not open Edge automatically.");
|
|
6316
|
-
console.log(`Open this URL in Edge: http://127.0.0.1:${INSTALL_PORT}/ext.crx`);
|
|
6317
|
-
}
|
|
6318
|
-
console.log("Waiting 15s for download...");
|
|
6319
|
-
await new Promise((r) => setTimeout(r, 15e3));
|
|
6320
|
-
crxServer.close();
|
|
6321
|
-
spawnSync2("adb", [
|
|
6322
|
-
"shell",
|
|
6323
|
-
"am",
|
|
6324
|
-
"start",
|
|
6325
|
-
"-a",
|
|
6326
|
-
"android.intent.action.VIEW",
|
|
6327
|
-
"-d",
|
|
6328
|
-
"edge://extensions",
|
|
6329
|
-
"-n",
|
|
6330
|
-
"com.microsoft.emmx.canary/com.google.android.apps.chrome.IntentDispatcher"
|
|
6331
|
-
], { stdio: "ignore" });
|
|
6332
|
-
console.log("Opened edge://extensions \u2014 verify the extension is listed.");
|
|
6333
|
-
console.log("Note: if prompted, tap 'Add extension' in the download notification.");
|
|
6334
6433
|
}
|
|
6434
|
+
if (edgePkg) {
|
|
6435
|
+
spawnSync2("adb", ["shell", "settings", "put", "global", "debug_app", edgePkg], {
|
|
6436
|
+
stdio: "pipe"
|
|
6437
|
+
});
|
|
6438
|
+
console.log(` Set debug_app=${edgePkg} for flag reading`);
|
|
6439
|
+
spawnSync2("adb", ["shell", "am", "force-stop", edgePkg], { stdio: "pipe" });
|
|
6440
|
+
console.log(` Restarted ${edgePkg} to apply changes`);
|
|
6441
|
+
} else {
|
|
6442
|
+
console.log(" WARNING: No Edge browser found. Install Edge Canary from the Play Store.");
|
|
6443
|
+
}
|
|
6444
|
+
console.log(" Extension will load automatically when Edge starts.");
|
|
6335
6445
|
}
|
|
6336
6446
|
console.log(`
|
|
6337
6447
|
Setup complete!
|
|
6338
6448
|
|
|
6339
6449
|
Next steps:
|
|
6340
6450
|
1. Start the bridge: npx claude-chrome-android
|
|
6341
|
-
2. Open
|
|
6342
|
-
3.
|
|
6451
|
+
2. Open Edge \u2014 the extension loads automatically via --load-extension
|
|
6452
|
+
3. Open a new Claude Code session \u2014 browser tools (mcp__cfc-bridge__*) will be available
|
|
6453
|
+
4. Use ToolSearch to find and load cfc-bridge tools
|
|
6454
|
+
|
|
6455
|
+
To update the extension later:
|
|
6456
|
+
npx claude-chrome-android --setup (re-pushes latest files)
|
|
6343
6457
|
`);
|
|
6344
6458
|
}
|
|
6345
6459
|
async function cmdStart() {
|