claude-chrome-android 1.4.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.
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
- const upgrade = (data) => {
3867
- pendingUpgradeData = data ?? {};
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 || pendingUpgradeData !== null) {
3873
- if (pendingUpgradeData === null) {
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, REPO_CLI, 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;
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
- REPO_CLI = (0, import_path.resolve)(SCRIPT_DIR, "cli.js");
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
- for (const p of [REPO_CLI, BUN_GLOBAL_CLI, NPM_GLOBAL_CLI]) {
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"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-chrome-android",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
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",