@tongil_kim/clautunnel 1.7.2 → 1.7.3

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/index.js CHANGED
@@ -251,7 +251,7 @@ var require_dist = __commonJS({
251
251
 
252
252
  // src/index.ts
253
253
  import { config } from "dotenv";
254
- import { resolve as resolve2, dirname as dirname3 } from "path";
254
+ import { resolve as resolve3, dirname as dirname3 } from "path";
255
255
  import { readFileSync as readFileSync6 } from "fs";
256
256
  import { fileURLToPath } from "url";
257
257
 
@@ -431,19 +431,19 @@ import { EventEmitter } from "events";
431
431
  // src/realtime/utils.ts
432
432
  var DEFAULT_TIMEOUT = 1e4;
433
433
  function subscribeWithTimeout(channel, channelName, timeout = DEFAULT_TIMEOUT) {
434
- return new Promise((resolve3) => {
434
+ return new Promise((resolve4) => {
435
435
  let lastStatus = "unknown";
436
436
  const timer = setTimeout(() => {
437
437
  console.warn(
438
438
  `[WARN] Realtime subscription timeout for ${channelName} (last status: ${lastStatus}).`
439
439
  );
440
- resolve3(false);
440
+ resolve4(false);
441
441
  }, timeout);
442
442
  channel.subscribe((status, err) => {
443
443
  lastStatus = status;
444
444
  if (status === "SUBSCRIBED") {
445
445
  clearTimeout(timer);
446
- resolve3(true);
446
+ resolve4(true);
447
447
  } else if (status === "CHANNEL_ERROR" || status === "CLOSED" || status === "TIMED_OUT") {
448
448
  clearTimeout(timer);
449
449
  console.warn(
@@ -452,7 +452,7 @@ function subscribeWithTimeout(channel, channelName, timeout = DEFAULT_TIMEOUT) {
452
452
  if (err) {
453
453
  console.warn(`[WARN] Error details: ${err.message || err}`);
454
454
  }
455
- resolve3(false);
455
+ resolve4(false);
456
456
  }
457
457
  });
458
458
  });
@@ -1196,8 +1196,8 @@ var SdkSession = class extends EventEmitter2 {
1196
1196
  this.pendingQuestionData = questionData;
1197
1197
  this.emit("user-question", questionData);
1198
1198
  const answers = await new Promise(
1199
- (resolve3, reject) => {
1200
- const pendingRequest = { resolve: resolve3, reject };
1199
+ (resolve4, reject) => {
1200
+ const pendingRequest = { resolve: resolve4, reject };
1201
1201
  this.pendingAnswerRequest = pendingRequest;
1202
1202
  options.signal.addEventListener("abort", () => {
1203
1203
  if (this.pendingAnswerRequest === pendingRequest) {
@@ -1255,9 +1255,9 @@ var SdkSession = class extends EventEmitter2 {
1255
1255
  };
1256
1256
  this.pendingPermissionData = requestData;
1257
1257
  this.emit("permission-request", requestData);
1258
- return new Promise((resolve3, reject) => {
1258
+ return new Promise((resolve4, reject) => {
1259
1259
  this.pendingPermissionRequests.set(requestId, {
1260
- resolve: resolve3,
1260
+ resolve: resolve4,
1261
1261
  reject,
1262
1262
  signal: options.signal,
1263
1263
  toolInput: input
@@ -2910,10 +2910,10 @@ async function promptYesNo(question) {
2910
2910
  input: process.stdin,
2911
2911
  output: process.stdout
2912
2912
  });
2913
- return new Promise((resolve3) => {
2913
+ return new Promise((resolve4) => {
2914
2914
  rl.question(question, (answer) => {
2915
2915
  rl.close();
2916
- resolve3(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
2916
+ resolve4(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
2917
2917
  });
2918
2918
  });
2919
2919
  }
@@ -3013,6 +3013,10 @@ function getFullDiskAccessStatus(enabled, terminalApp) {
3013
3013
  };
3014
3014
  }
3015
3015
 
3016
+ // src/commands/start.ts
3017
+ import { existsSync as existsSync6 } from "fs";
3018
+ import { join as join7, resolve } from "path";
3019
+
3016
3020
  // src/mobile/mobile-server.ts
3017
3021
  import { spawn as spawn2, execSync as execSync2 } from "child_process";
3018
3022
  import {
@@ -3251,7 +3255,7 @@ var MobileServerManager = class {
3251
3255
  });
3252
3256
  this.expoProcess.on("error", () => {
3253
3257
  });
3254
- return new Promise((resolve3) => {
3258
+ return new Promise((resolve4) => {
3255
3259
  let ready = false;
3256
3260
  let resolved = false;
3257
3261
  let qrActive = false;
@@ -3260,7 +3264,7 @@ var MobileServerManager = class {
3260
3264
  resolved = true;
3261
3265
  this.expoProcess?.stdout?.pipe(this.expoLogStream);
3262
3266
  this.expoProcess?.stderr?.pipe(this.expoLogStream);
3263
- resolve3(false);
3267
+ resolve4(false);
3264
3268
  }
3265
3269
  }, 6e4);
3266
3270
  this.expoProcess?.stdout?.on("data", (data) => {
@@ -3284,7 +3288,7 @@ var MobileServerManager = class {
3284
3288
  clearTimeout(timeout);
3285
3289
  this.expoProcess?.stdout?.pipe(this.expoLogStream);
3286
3290
  this.expoProcess?.stderr?.pipe(this.expoLogStream);
3287
- resolve3(true);
3291
+ resolve4(true);
3288
3292
  }
3289
3293
  } else {
3290
3294
  this.expoLogStream?.write(line + "\n");
@@ -3296,7 +3300,7 @@ var MobileServerManager = class {
3296
3300
  if (!resolved) {
3297
3301
  resolved = true;
3298
3302
  clearTimeout(timeout);
3299
- resolve3(false);
3303
+ resolve4(false);
3300
3304
  }
3301
3305
  });
3302
3306
  });
@@ -3386,7 +3390,7 @@ var MobileServerManager = class {
3386
3390
  return line.includes("Metro waiting on") || line.includes("Logs for your project");
3387
3391
  }
3388
3392
  getNgrokTunnelUrl() {
3389
- return new Promise((resolve3) => {
3393
+ return new Promise((resolve4) => {
3390
3394
  const req = get("http://localhost:4040/api/tunnels", (res) => {
3391
3395
  let data = "";
3392
3396
  res.on("data", (chunk) => data += chunk);
@@ -3396,16 +3400,16 @@ var MobileServerManager = class {
3396
3400
  const httpsTunnel = tunnels?.find(
3397
3401
  (t) => t.proto === "https"
3398
3402
  );
3399
- resolve3(httpsTunnel?.public_url ?? null);
3403
+ resolve4(httpsTunnel?.public_url ?? null);
3400
3404
  } catch {
3401
- resolve3(null);
3405
+ resolve4(null);
3402
3406
  }
3403
3407
  });
3404
3408
  });
3405
- req.on("error", () => resolve3(null));
3409
+ req.on("error", () => resolve4(null));
3406
3410
  req.setTimeout(2e3, () => {
3407
3411
  req.destroy();
3408
- resolve3(null);
3412
+ resolve4(null);
3409
3413
  });
3410
3414
  });
3411
3415
  }
@@ -3447,7 +3451,7 @@ var MobileServerManager = class {
3447
3451
  }
3448
3452
  }
3449
3453
  sleep(ms) {
3450
- return new Promise((resolve3) => setTimeout(resolve3, ms));
3454
+ return new Promise((resolve4) => setTimeout(resolve4, ms));
3451
3455
  }
3452
3456
  };
3453
3457
 
@@ -3727,7 +3731,13 @@ function createStartCommand() {
3727
3731
  process.exit(1);
3728
3732
  }
3729
3733
  const pairingCode = pairingData.code;
3730
- const mobileProjectPath = config2.getMobileProjectPath();
3734
+ let mobileProjectPath = config2.getMobileProjectPath();
3735
+ if (!mobileProjectPath) {
3736
+ const siblingMobile = resolve(process.cwd(), "..", "mobile");
3737
+ if (existsSync6(join7(siblingMobile, "package.json"))) {
3738
+ mobileProjectPath = siblingMobile;
3739
+ }
3740
+ }
3731
3741
  mobileServer = new MobileServerManager({
3732
3742
  mobileProjectPath,
3733
3743
  supabaseUrl: config2.getSupabaseUrl(),
@@ -3967,7 +3977,7 @@ function createStopCommand() {
3967
3977
  let attempts = 0;
3968
3978
  let pidFileRemoved = false;
3969
3979
  while (attempts < 10) {
3970
- await new Promise((resolve3) => setTimeout(resolve3, 500));
3980
+ await new Promise((resolve4) => setTimeout(resolve4, 500));
3971
3981
  if (!pidFileExists()) {
3972
3982
  pidFileRemoved = true;
3973
3983
  break;
@@ -4064,10 +4074,10 @@ function prompt(question) {
4064
4074
  input: process.stdin,
4065
4075
  output: process.stdout
4066
4076
  });
4067
- return new Promise((resolve3) => {
4077
+ return new Promise((resolve4) => {
4068
4078
  rl.question(question, (answer) => {
4069
4079
  rl.close();
4070
- resolve3(answer);
4080
+ resolve4(answer);
4071
4081
  });
4072
4082
  });
4073
4083
  }
@@ -4076,7 +4086,7 @@ function promptHidden(question) {
4076
4086
  input: process.stdin,
4077
4087
  output: process.stdout
4078
4088
  });
4079
- return new Promise((resolve3) => {
4089
+ return new Promise((resolve4) => {
4080
4090
  process.stdout.write(question);
4081
4091
  if (process.stdin.isTTY) {
4082
4092
  process.stdin.setRawMode(true);
@@ -4091,7 +4101,7 @@ function promptHidden(question) {
4091
4101
  }
4092
4102
  process.stdout.write("\n");
4093
4103
  rl.close();
4094
- resolve3(password);
4104
+ resolve4(password);
4095
4105
  } else if (c === "") {
4096
4106
  process.exit(0);
4097
4107
  } else if (c === "\x7F" || c === "\b") {
@@ -4340,8 +4350,8 @@ function createSetupCommand() {
4340
4350
 
4341
4351
  // src/commands/mobile-setup.ts
4342
4352
  import { Command as Command8 } from "commander";
4343
- import { existsSync as existsSync6, writeFileSync as writeFileSync4 } from "fs";
4344
- import { join as join7, resolve } from "path";
4353
+ import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
4354
+ import { join as join8, resolve as resolve2 } from "path";
4345
4355
  function createMobileSetupCommand() {
4346
4356
  const command = new Command8("mobile-setup");
4347
4357
  command.description("Generate mobile app .env file from CLI credentials").action(async () => {
@@ -4351,8 +4361,8 @@ function createMobileSetupCommand() {
4351
4361
  config2.requireConfiguration();
4352
4362
  const supabaseUrl = config2.getSupabaseUrl();
4353
4363
  const supabaseAnonKey = config2.getSupabaseAnonKey();
4354
- const mobileDir = resolve(process.cwd(), "apps", "mobile");
4355
- if (!existsSync6(mobileDir)) {
4364
+ const mobileDir = resolve2(process.cwd(), "apps", "mobile");
4365
+ if (!existsSync7(mobileDir)) {
4356
4366
  logger.error("Could not find apps/mobile directory.");
4357
4367
  logger.error("");
4358
4368
  logger.error("Make sure you run this command from the ClauTunnel project root:");
@@ -4360,8 +4370,8 @@ function createMobileSetupCommand() {
4360
4370
  logger.error(" clautunnel mobile-setup");
4361
4371
  process.exit(1);
4362
4372
  }
4363
- const envPath = join7(mobileDir, ".env");
4364
- if (existsSync6(envPath)) {
4373
+ const envPath = join8(mobileDir, ".env");
4374
+ if (existsSync7(envPath)) {
4365
4375
  logger.warn("apps/mobile/.env already exists and will be overwritten.");
4366
4376
  }
4367
4377
  const envContent = [
@@ -4428,7 +4438,7 @@ function createResetCommand() {
4428
4438
  try {
4429
4439
  process.kill(pid, "SIGTERM");
4430
4440
  logger.info(` - clautunnel daemon stopped (PID ${pid})`);
4431
- await new Promise((resolve3) => setTimeout(resolve3, 1e3));
4441
+ await new Promise((resolve4) => setTimeout(resolve4, 1e3));
4432
4442
  } catch {
4433
4443
  logger.info(" - could not stop daemon");
4434
4444
  }
@@ -4626,9 +4636,9 @@ async function cleanSupabaseDb(logger) {
4626
4636
  // src/index.ts
4627
4637
  var __filename = fileURLToPath(import.meta.url);
4628
4638
  var __dirname = dirname3(__filename);
4629
- config({ path: resolve2(__dirname, "../.env"), quiet: true });
4639
+ config({ path: resolve3(__dirname, "../.env"), quiet: true });
4630
4640
  var packageJson = JSON.parse(
4631
- readFileSync6(resolve2(__dirname, "../package.json"), "utf-8")
4641
+ readFileSync6(resolve3(__dirname, "../package.json"), "utf-8")
4632
4642
  );
4633
4643
  var version = packageJson.version || "0.0.0";
4634
4644
  var program = new Command10();