@tongil_kim/clautunnel 1.7.1 → 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 +51 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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((
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
1200
|
-
const pendingRequest = { resolve:
|
|
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((
|
|
1258
|
+
return new Promise((resolve4, reject) => {
|
|
1259
1259
|
this.pendingPermissionRequests.set(requestId, {
|
|
1260
|
-
resolve:
|
|
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((
|
|
2913
|
+
return new Promise((resolve4) => {
|
|
2914
2914
|
rl.question(question, (answer) => {
|
|
2915
2915
|
rl.close();
|
|
2916
|
-
|
|
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 {
|
|
@@ -3110,6 +3114,11 @@ var MobileServerManager = class {
|
|
|
3110
3114
|
}
|
|
3111
3115
|
const repoDir = join5(clautunnelDir, "repo");
|
|
3112
3116
|
if (existsSync4(repoDir)) {
|
|
3117
|
+
execSync2("git checkout -- .", {
|
|
3118
|
+
cwd: repoDir,
|
|
3119
|
+
stdio: "pipe",
|
|
3120
|
+
timeout: 1e4
|
|
3121
|
+
});
|
|
3113
3122
|
execSync2("git pull --ff-only", {
|
|
3114
3123
|
cwd: repoDir,
|
|
3115
3124
|
stdio: "pipe",
|
|
@@ -3246,7 +3255,7 @@ var MobileServerManager = class {
|
|
|
3246
3255
|
});
|
|
3247
3256
|
this.expoProcess.on("error", () => {
|
|
3248
3257
|
});
|
|
3249
|
-
return new Promise((
|
|
3258
|
+
return new Promise((resolve4) => {
|
|
3250
3259
|
let ready = false;
|
|
3251
3260
|
let resolved = false;
|
|
3252
3261
|
let qrActive = false;
|
|
@@ -3255,7 +3264,7 @@ var MobileServerManager = class {
|
|
|
3255
3264
|
resolved = true;
|
|
3256
3265
|
this.expoProcess?.stdout?.pipe(this.expoLogStream);
|
|
3257
3266
|
this.expoProcess?.stderr?.pipe(this.expoLogStream);
|
|
3258
|
-
|
|
3267
|
+
resolve4(false);
|
|
3259
3268
|
}
|
|
3260
3269
|
}, 6e4);
|
|
3261
3270
|
this.expoProcess?.stdout?.on("data", (data) => {
|
|
@@ -3279,7 +3288,7 @@ var MobileServerManager = class {
|
|
|
3279
3288
|
clearTimeout(timeout);
|
|
3280
3289
|
this.expoProcess?.stdout?.pipe(this.expoLogStream);
|
|
3281
3290
|
this.expoProcess?.stderr?.pipe(this.expoLogStream);
|
|
3282
|
-
|
|
3291
|
+
resolve4(true);
|
|
3283
3292
|
}
|
|
3284
3293
|
} else {
|
|
3285
3294
|
this.expoLogStream?.write(line + "\n");
|
|
@@ -3291,7 +3300,7 @@ var MobileServerManager = class {
|
|
|
3291
3300
|
if (!resolved) {
|
|
3292
3301
|
resolved = true;
|
|
3293
3302
|
clearTimeout(timeout);
|
|
3294
|
-
|
|
3303
|
+
resolve4(false);
|
|
3295
3304
|
}
|
|
3296
3305
|
});
|
|
3297
3306
|
});
|
|
@@ -3381,7 +3390,7 @@ var MobileServerManager = class {
|
|
|
3381
3390
|
return line.includes("Metro waiting on") || line.includes("Logs for your project");
|
|
3382
3391
|
}
|
|
3383
3392
|
getNgrokTunnelUrl() {
|
|
3384
|
-
return new Promise((
|
|
3393
|
+
return new Promise((resolve4) => {
|
|
3385
3394
|
const req = get("http://localhost:4040/api/tunnels", (res) => {
|
|
3386
3395
|
let data = "";
|
|
3387
3396
|
res.on("data", (chunk) => data += chunk);
|
|
@@ -3391,16 +3400,16 @@ var MobileServerManager = class {
|
|
|
3391
3400
|
const httpsTunnel = tunnels?.find(
|
|
3392
3401
|
(t) => t.proto === "https"
|
|
3393
3402
|
);
|
|
3394
|
-
|
|
3403
|
+
resolve4(httpsTunnel?.public_url ?? null);
|
|
3395
3404
|
} catch {
|
|
3396
|
-
|
|
3405
|
+
resolve4(null);
|
|
3397
3406
|
}
|
|
3398
3407
|
});
|
|
3399
3408
|
});
|
|
3400
|
-
req.on("error", () =>
|
|
3409
|
+
req.on("error", () => resolve4(null));
|
|
3401
3410
|
req.setTimeout(2e3, () => {
|
|
3402
3411
|
req.destroy();
|
|
3403
|
-
|
|
3412
|
+
resolve4(null);
|
|
3404
3413
|
});
|
|
3405
3414
|
});
|
|
3406
3415
|
}
|
|
@@ -3442,7 +3451,7 @@ var MobileServerManager = class {
|
|
|
3442
3451
|
}
|
|
3443
3452
|
}
|
|
3444
3453
|
sleep(ms) {
|
|
3445
|
-
return new Promise((
|
|
3454
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
3446
3455
|
}
|
|
3447
3456
|
};
|
|
3448
3457
|
|
|
@@ -3722,7 +3731,13 @@ function createStartCommand() {
|
|
|
3722
3731
|
process.exit(1);
|
|
3723
3732
|
}
|
|
3724
3733
|
const pairingCode = pairingData.code;
|
|
3725
|
-
|
|
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
|
+
}
|
|
3726
3741
|
mobileServer = new MobileServerManager({
|
|
3727
3742
|
mobileProjectPath,
|
|
3728
3743
|
supabaseUrl: config2.getSupabaseUrl(),
|
|
@@ -3962,7 +3977,7 @@ function createStopCommand() {
|
|
|
3962
3977
|
let attempts = 0;
|
|
3963
3978
|
let pidFileRemoved = false;
|
|
3964
3979
|
while (attempts < 10) {
|
|
3965
|
-
await new Promise((
|
|
3980
|
+
await new Promise((resolve4) => setTimeout(resolve4, 500));
|
|
3966
3981
|
if (!pidFileExists()) {
|
|
3967
3982
|
pidFileRemoved = true;
|
|
3968
3983
|
break;
|
|
@@ -4059,10 +4074,10 @@ function prompt(question) {
|
|
|
4059
4074
|
input: process.stdin,
|
|
4060
4075
|
output: process.stdout
|
|
4061
4076
|
});
|
|
4062
|
-
return new Promise((
|
|
4077
|
+
return new Promise((resolve4) => {
|
|
4063
4078
|
rl.question(question, (answer) => {
|
|
4064
4079
|
rl.close();
|
|
4065
|
-
|
|
4080
|
+
resolve4(answer);
|
|
4066
4081
|
});
|
|
4067
4082
|
});
|
|
4068
4083
|
}
|
|
@@ -4071,7 +4086,7 @@ function promptHidden(question) {
|
|
|
4071
4086
|
input: process.stdin,
|
|
4072
4087
|
output: process.stdout
|
|
4073
4088
|
});
|
|
4074
|
-
return new Promise((
|
|
4089
|
+
return new Promise((resolve4) => {
|
|
4075
4090
|
process.stdout.write(question);
|
|
4076
4091
|
if (process.stdin.isTTY) {
|
|
4077
4092
|
process.stdin.setRawMode(true);
|
|
@@ -4086,7 +4101,7 @@ function promptHidden(question) {
|
|
|
4086
4101
|
}
|
|
4087
4102
|
process.stdout.write("\n");
|
|
4088
4103
|
rl.close();
|
|
4089
|
-
|
|
4104
|
+
resolve4(password);
|
|
4090
4105
|
} else if (c === "") {
|
|
4091
4106
|
process.exit(0);
|
|
4092
4107
|
} else if (c === "\x7F" || c === "\b") {
|
|
@@ -4335,8 +4350,8 @@ function createSetupCommand() {
|
|
|
4335
4350
|
|
|
4336
4351
|
// src/commands/mobile-setup.ts
|
|
4337
4352
|
import { Command as Command8 } from "commander";
|
|
4338
|
-
import { existsSync as
|
|
4339
|
-
import { join as
|
|
4353
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
4354
|
+
import { join as join8, resolve as resolve2 } from "path";
|
|
4340
4355
|
function createMobileSetupCommand() {
|
|
4341
4356
|
const command = new Command8("mobile-setup");
|
|
4342
4357
|
command.description("Generate mobile app .env file from CLI credentials").action(async () => {
|
|
@@ -4346,8 +4361,8 @@ function createMobileSetupCommand() {
|
|
|
4346
4361
|
config2.requireConfiguration();
|
|
4347
4362
|
const supabaseUrl = config2.getSupabaseUrl();
|
|
4348
4363
|
const supabaseAnonKey = config2.getSupabaseAnonKey();
|
|
4349
|
-
const mobileDir =
|
|
4350
|
-
if (!
|
|
4364
|
+
const mobileDir = resolve2(process.cwd(), "apps", "mobile");
|
|
4365
|
+
if (!existsSync7(mobileDir)) {
|
|
4351
4366
|
logger.error("Could not find apps/mobile directory.");
|
|
4352
4367
|
logger.error("");
|
|
4353
4368
|
logger.error("Make sure you run this command from the ClauTunnel project root:");
|
|
@@ -4355,8 +4370,8 @@ function createMobileSetupCommand() {
|
|
|
4355
4370
|
logger.error(" clautunnel mobile-setup");
|
|
4356
4371
|
process.exit(1);
|
|
4357
4372
|
}
|
|
4358
|
-
const envPath =
|
|
4359
|
-
if (
|
|
4373
|
+
const envPath = join8(mobileDir, ".env");
|
|
4374
|
+
if (existsSync7(envPath)) {
|
|
4360
4375
|
logger.warn("apps/mobile/.env already exists and will be overwritten.");
|
|
4361
4376
|
}
|
|
4362
4377
|
const envContent = [
|
|
@@ -4423,7 +4438,7 @@ function createResetCommand() {
|
|
|
4423
4438
|
try {
|
|
4424
4439
|
process.kill(pid, "SIGTERM");
|
|
4425
4440
|
logger.info(` - clautunnel daemon stopped (PID ${pid})`);
|
|
4426
|
-
await new Promise((
|
|
4441
|
+
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
4427
4442
|
} catch {
|
|
4428
4443
|
logger.info(" - could not stop daemon");
|
|
4429
4444
|
}
|
|
@@ -4621,9 +4636,9 @@ async function cleanSupabaseDb(logger) {
|
|
|
4621
4636
|
// src/index.ts
|
|
4622
4637
|
var __filename = fileURLToPath(import.meta.url);
|
|
4623
4638
|
var __dirname = dirname3(__filename);
|
|
4624
|
-
config({ path:
|
|
4639
|
+
config({ path: resolve3(__dirname, "../.env"), quiet: true });
|
|
4625
4640
|
var packageJson = JSON.parse(
|
|
4626
|
-
readFileSync6(
|
|
4641
|
+
readFileSync6(resolve3(__dirname, "../package.json"), "utf-8")
|
|
4627
4642
|
);
|
|
4628
4643
|
var version = packageJson.version || "0.0.0";
|
|
4629
4644
|
var program = new Command10();
|