vibelet 1.2.153 → 1.2.154

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.
@@ -1,2 +1,2 @@
1
- var c=require("node:fs"),n=require("node:path"),p="@vibelet/cli";function i(r){try{let e=JSON.parse((0,c.readFileSync)(r,"utf8"));if(e.name===p&&typeof e.version=="string"&&e.version.length>0)return e.version}catch{}return null}function l(){return"1.2.153"}var a=l();process.stdout.write(`${a}
1
+ var c=require("node:fs"),n=require("node:path"),p="@vibelet/cli";function i(r){try{let e=JSON.parse((0,c.readFileSync)(r,"utf8"));if(e.name===p&&typeof e.version=="string"&&e.version.length>0)return e.version}catch{}return null}function l(){return"1.2.154"}var a=l();process.stdout.write(`${a}
2
2
  `);
package/dist/vibelet.mjs CHANGED
@@ -11245,7 +11245,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib");
11245
11245
 
11246
11246
  /***/ }),
11247
11247
 
11248
- /***/ 2517:
11248
+ /***/ 2755:
11249
11249
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
11250
11250
 
11251
11251
 
@@ -11267,17 +11267,208 @@ var external_node_fs_ = __nccwpck_require__(3024);
11267
11267
  var external_node_module_ = __nccwpck_require__(8995);
11268
11268
  // EXTERNAL MODULE: external "node:path"
11269
11269
  var external_node_path_ = __nccwpck_require__(6760);
11270
+ ;// CONCATENATED MODULE: external "node:fs/promises"
11271
+ const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs/promises");
11272
+ ;// CONCATENATED MODULE: external "node:util"
11273
+ const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:util");
11274
+ ;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/managed-binary.mjs
11275
+
11276
+
11277
+
11278
+
11279
+
11280
+
11281
+ const execFileAsync = (0,external_node_util_namespaceObject.promisify)(external_node_child_process_.execFile);
11282
+ const DEFAULT_UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
11283
+ const DEFAULT_UPDATE_TIMEOUT_MS = 30_000;
11284
+
11285
+ function parseCloudflaredVersion(output) {
11286
+ return String(output || '').match(/cloudflared version\s+([0-9]+(?:\.[0-9]+){1,2})/i)?.[1] ?? null;
11287
+ }
11288
+
11289
+ async function readUpdateState(updateStatePath) {
11290
+ try {
11291
+ const state = JSON.parse(await (0,promises_namespaceObject.readFile)(updateStatePath, 'utf8'));
11292
+ return state && typeof state === 'object' ? state : null;
11293
+ } catch {
11294
+ return null;
11295
+ }
11296
+ }
11297
+
11298
+ async function writeUpdateState(updateStatePath, state) {
11299
+ await (0,promises_namespaceObject.mkdir)((0,external_node_path_.dirname)(updateStatePath), { recursive: true });
11300
+ const temporaryPath = `${updateStatePath}.tmp-${process.pid}-${Date.now()}`;
11301
+ await (0,promises_namespaceObject.writeFile)(temporaryPath, `${JSON.stringify(state, null, 2)}\n`, 'utf8');
11302
+ await (0,promises_namespaceObject.rename)(temporaryPath, updateStatePath);
11303
+ }
11304
+
11305
+ async function runVersion(binaryPath, timeoutMs, runCommand) {
11306
+ if (!binaryPath || !(0,external_node_fs_.existsSync)(binaryPath)) return null;
11307
+ try {
11308
+ const { stdout, stderr } = await runCommand(binaryPath, ['--version'], {
11309
+ encoding: 'utf8',
11310
+ timeout: timeoutMs,
11311
+ maxBuffer: 1024 * 1024,
11312
+ });
11313
+ return parseCloudflaredVersion(`${stdout || ''}\n${stderr || ''}`);
11314
+ } catch {
11315
+ return null;
11316
+ }
11317
+ }
11318
+
11319
+ async function probeCloudflaredLaunchSpecVersion(
11320
+ launchSpec,
11321
+ { timeoutMs = 5_000, runCommand = execFileAsync } = {},
11322
+ ) {
11323
+ try {
11324
+ const { stdout, stderr } = await runCommand(launchSpec.command, [...launchSpec.args, '--version'], {
11325
+ encoding: 'utf8',
11326
+ timeout: timeoutMs,
11327
+ maxBuffer: 1024 * 1024,
11328
+ ...(launchSpec.shell ? { shell: true } : {}),
11329
+ });
11330
+ return parseCloudflaredVersion(`${stdout || ''}\n${stderr || ''}`);
11331
+ } catch {
11332
+ return null;
11333
+ }
11334
+ }
11335
+
11336
+ async function installLatestToTemporaryPath({ launchSpec, binaryPath, timeoutMs, platform, runCommand }) {
11337
+ const temporaryDir = (0,external_node_path_.join)((0,external_node_path_.dirname)(binaryPath), `.cloudflared-update-${process.pid}-${Date.now()}`);
11338
+ const temporaryBinaryPath = (0,external_node_path_.join)(temporaryDir, (0,external_node_path_.basename)(binaryPath));
11339
+ await (0,promises_namespaceObject.mkdir)(temporaryDir, { recursive: true });
11340
+ try {
11341
+ await runCommand(launchSpec.command, [...launchSpec.args, 'bin', 'install', 'latest'], {
11342
+ encoding: 'utf8',
11343
+ timeout: timeoutMs,
11344
+ maxBuffer: 4 * 1024 * 1024,
11345
+ env: { ...process.env, CLOUDFLARED_BIN: temporaryBinaryPath },
11346
+ ...(launchSpec.shell ? { shell: true } : {}),
11347
+ });
11348
+ const version = await runVersion(temporaryBinaryPath, timeoutMs, runCommand);
11349
+ if (!version) throw new Error('downloaded cloudflared did not report a valid version');
11350
+
11351
+ if (platform === 'win32' && (0,external_node_fs_.existsSync)(binaryPath)) {
11352
+ const backupPath = `${binaryPath}.previous-${process.pid}`;
11353
+ await (0,promises_namespaceObject.rename)(binaryPath, backupPath);
11354
+ try {
11355
+ await (0,promises_namespaceObject.rename)(temporaryBinaryPath, binaryPath);
11356
+ await (0,promises_namespaceObject.rm)(backupPath, { force: true });
11357
+ } catch (error) {
11358
+ await (0,promises_namespaceObject.rename)(backupPath, binaryPath).catch(() => undefined);
11359
+ throw error;
11360
+ }
11361
+ } else {
11362
+ await (0,promises_namespaceObject.rename)(temporaryBinaryPath, binaryPath);
11363
+ }
11364
+ return version;
11365
+ } finally {
11366
+ await (0,promises_namespaceObject.rm)(temporaryDir, { recursive: true, force: true });
11367
+ }
11368
+ }
11369
+
11370
+ async function resolveManagedCloudflared({
11371
+ launchSpec,
11372
+ updateStatePath,
11373
+ now = Date.now(),
11374
+ updateIntervalMs = DEFAULT_UPDATE_INTERVAL_MS,
11375
+ timeoutMs = DEFAULT_UPDATE_TIMEOUT_MS,
11376
+ platform = process.platform,
11377
+ runCommand = execFileAsync,
11378
+ }) {
11379
+ const state = await readUpdateState(updateStatePath);
11380
+ const lastAttemptAt = Date.parse(state?.lastAttemptAt || '');
11381
+ const recentlyAttempted = Number.isFinite(lastAttemptAt) && now - lastAttemptAt < updateIntervalMs;
11382
+ if (recentlyAttempted) {
11383
+ return {
11384
+ launchSpec,
11385
+ version: state?.installedVersion ?? null,
11386
+ update: 'skipped',
11387
+ };
11388
+ }
11389
+
11390
+ const attemptedAt = new Date(now).toISOString();
11391
+ const binaryPath = launchSpec.managedBinaryPath;
11392
+ if (launchSpec.source !== 'dependency' || !binaryPath) {
11393
+ const version = state?.installedVersion ?? null;
11394
+ let stateWarning = '';
11395
+ try {
11396
+ await writeUpdateState(updateStatePath, {
11397
+ ...state,
11398
+ lastAttemptAt: attemptedAt,
11399
+ installedVersion: version,
11400
+ });
11401
+ } catch (error) {
11402
+ stateWarning = ` Update state could not be saved: ${error instanceof Error ? error.message : String(error)}`;
11403
+ }
11404
+ return {
11405
+ launchSpec,
11406
+ version,
11407
+ update: 'skipped',
11408
+ warning: `Skipping cloudflared self-update for unmanaged ${launchSpec.source} executable: ${launchSpec.description}.${stateWarning}`,
11409
+ };
11410
+ }
11411
+
11412
+ const previousVersion = await runVersion(binaryPath, timeoutMs, runCommand);
11413
+ try {
11414
+ const installedVersion = await installLatestToTemporaryPath({
11415
+ launchSpec,
11416
+ binaryPath,
11417
+ timeoutMs,
11418
+ platform,
11419
+ runCommand,
11420
+ });
11421
+ await writeUpdateState(updateStatePath, {
11422
+ lastAttemptAt: attemptedAt,
11423
+ lastSuccessAt: attemptedAt,
11424
+ installedVersion,
11425
+ });
11426
+ return {
11427
+ launchSpec,
11428
+ version: installedVersion,
11429
+ update: previousVersion ? 'updated' : 'fresh',
11430
+ };
11431
+ } catch (error) {
11432
+ const fallbackVersion = previousVersion || (await runVersion(binaryPath, timeoutMs, runCommand));
11433
+ await writeUpdateState(updateStatePath, {
11434
+ ...state,
11435
+ lastAttemptAt: attemptedAt,
11436
+ installedVersion: fallbackVersion,
11437
+ }).catch(() => undefined);
11438
+ return {
11439
+ launchSpec,
11440
+ version: fallbackVersion,
11441
+ update: 'failed',
11442
+ warning: `cloudflared update failed; continuing with ${fallbackVersion || 'the existing launcher'}: ${error instanceof Error ? error.message : String(error)}`,
11443
+ };
11444
+ }
11445
+ }
11446
+
11270
11447
  ;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/index.mjs
11271
11448
 
11272
11449
 
11273
11450
 
11274
11451
 
11275
11452
 
11453
+
11454
+
11455
+
11276
11456
  const QUICK_TUNNEL_URL_PATTERN = /https:\/\/[a-z0-9-]+\.trycloudflare\.com(?=$|[\s"',)\]])/g;
11277
11457
  const npmFallbackArgs = ['--yes', '--package=cloudflared', 'cloudflared'];
11278
11458
  const npmFallbackDescription = `npx ${npmFallbackArgs.join(' ')}`;
11279
11459
  const defaultUrlTimeoutMs = 90_000;
11280
11460
 
11461
+ function supportsFastAutoProtocolFallback(version) {
11462
+ if (!version) return false;
11463
+ const parts = version.split('.').map(Number);
11464
+ const threshold = [2026, 5, 2];
11465
+ for (let index = 0; index < threshold.length; index += 1) {
11466
+ const value = parts[index] || 0;
11467
+ if (value !== threshold[index]) return value > threshold[index];
11468
+ }
11469
+ return true;
11470
+ }
11471
+
11281
11472
  function extractQuickTunnelUrl(logContent) {
11282
11473
  if (typeof logContent !== 'string' || logContent.length === 0) {
11283
11474
  return null;
@@ -11403,6 +11594,21 @@ function resolveInstalledCloudflaredCliPath({
11403
11594
  return (0,external_node_fs_.existsSync)(cliPath) ? cliPath : null;
11404
11595
  }
11405
11596
 
11597
+ function createDependencyLaunchSpec(dependencyCliPath, platform = process.platform) {
11598
+ return {
11599
+ command: process.execPath,
11600
+ args: [dependencyCliPath],
11601
+ source: 'dependency',
11602
+ description: dependencyCliPath,
11603
+ managedBinaryPath: (0,external_node_path_.join)(
11604
+ (0,external_node_path_.dirname)((0,external_node_path_.dirname)(dependencyCliPath)),
11605
+ 'bin',
11606
+ platform === 'win32' ? 'cloudflared.exe' : 'cloudflared',
11607
+ ),
11608
+ urlTimeoutMs: defaultUrlTimeoutMs,
11609
+ };
11610
+ }
11611
+
11406
11612
  function resolveCloudflaredLaunchSpec({
11407
11613
  pathValue = process.env.PATH ?? '',
11408
11614
  pathExtValue = process.env.PATHEXT ?? '',
@@ -11427,13 +11633,7 @@ function resolveCloudflaredLaunchSpec({
11427
11633
 
11428
11634
  const dependencyCliPath = resolveInstalledCloudflaredCliPath({ resolvePackageJsonPath });
11429
11635
  if (dependencyCliPath) {
11430
- return {
11431
- command: process.execPath,
11432
- args: [dependencyCliPath],
11433
- source: 'dependency',
11434
- description: dependencyCliPath,
11435
- urlTimeoutMs: defaultUrlTimeoutMs,
11436
- };
11636
+ return createDependencyLaunchSpec(dependencyCliPath, platform);
11437
11637
  }
11438
11638
 
11439
11639
  return {
@@ -11446,6 +11646,11 @@ function resolveCloudflaredLaunchSpec({
11446
11646
  };
11447
11647
  }
11448
11648
 
11649
+ function resolvePreferredCloudflaredLaunchSpec() {
11650
+ const dependencyCliPath = resolveInstalledCloudflaredCliPath();
11651
+ return dependencyCliPath ? createDependencyLaunchSpec(dependencyCliPath) : resolveCloudflaredLaunchSpec();
11652
+ }
11653
+
11449
11654
  function summarizeCloudflaredLog(logContent, { maxLines = 8, maxChars = 1200 } = {}) {
11450
11655
  const lines = logContent
11451
11656
  .split(/\r?\n/u)
@@ -11546,13 +11751,50 @@ function readCloudflaredLog(logPath) {
11546
11751
  }
11547
11752
  }
11548
11753
 
11549
- function startTunnel({ port, logDir, tunnelStatePath, resolveLaunchSpec = resolveCloudflaredLaunchSpec }) {
11754
+ async function startTunnel({
11755
+ port,
11756
+ logDir,
11757
+ tunnelStatePath,
11758
+ protocol = 'auto',
11759
+ updateStatePath,
11760
+ resolveLaunchSpec = resolvePreferredCloudflaredLaunchSpec,
11761
+ resolveFallbackLaunchSpec = resolveCloudflaredLaunchSpec,
11762
+ }) {
11763
+ if (!['auto', 'quic', 'http2'].includes(protocol)) {
11764
+ throw new Error(`Unsupported cloudflared protocol: ${protocol}`);
11765
+ }
11766
+ const unresolvedLaunchSpec = resolveLaunchSpec();
11767
+ const managed = updateStatePath
11768
+ ? await resolveManagedCloudflared({ launchSpec: unresolvedLaunchSpec, updateStatePath })
11769
+ : null;
11770
+ let launchSpec = managed?.launchSpec ?? unresolvedLaunchSpec;
11771
+ if (
11772
+ managed &&
11773
+ managed.version === null &&
11774
+ launchSpec.managedBinaryPath &&
11775
+ !(0,external_node_fs_.existsSync)(launchSpec.managedBinaryPath)
11776
+ ) {
11777
+ const fallbackLaunchSpec = resolveFallbackLaunchSpec();
11778
+ if (fallbackLaunchSpec.source !== 'dependency') launchSpec = fallbackLaunchSpec;
11779
+ }
11780
+ if (managed?.warning) process.stderr.write(`[cloudflared] ${managed.warning}\n`);
11781
+ const launchVersion =
11782
+ managed?.version ??
11783
+ (updateStatePath && launchSpec.source !== 'dependency'
11784
+ ? await probeCloudflaredLaunchSpecVersion(launchSpec)
11785
+ : null);
11786
+ const effectiveProtocol =
11787
+ protocol === 'auto' && updateStatePath && !supportsFastAutoProtocolFallback(launchVersion) ? 'http2' : protocol;
11788
+ if (effectiveProtocol !== protocol) {
11789
+ process.stderr.write(
11790
+ `[cloudflared] cloudflared ${launchVersion || 'unknown'} lacks fast auto connectivity pre-checks; using http2 until the managed binary updates to 2026.5.2 or newer.\n`,
11791
+ );
11792
+ }
11793
+
11550
11794
  return new Promise((resolveStart, rejectStart) => {
11551
11795
  const logPath = (0,external_node_path_.join)(logDir, 'tunnel.stderr.log');
11552
11796
  (0,external_node_fs_.mkdirSync)(logDir, { recursive: true });
11553
11797
 
11554
- const launchSpec = resolveLaunchSpec();
11555
-
11556
11798
  // Truncate first so URL polling cannot match a stale quick-tunnel URL.
11557
11799
  (0,external_node_fs_.writeFileSync)(logPath, '', 'utf8');
11558
11800
  const stdoutLogFd = (0,external_node_fs_.openSync)(logPath, 'a');
@@ -11561,7 +11803,7 @@ function startTunnel({ port, logDir, tunnelStatePath, resolveLaunchSpec = resolv
11561
11803
  try {
11562
11804
  child = (0,external_node_child_process_.spawn)(
11563
11805
  launchSpec.command,
11564
- [...launchSpec.args, 'tunnel', '--protocol', 'http2', '--url', `http://localhost:${port}`],
11806
+ [...launchSpec.args, 'tunnel', '--protocol', effectiveProtocol, '--url', `http://localhost:${port}`],
11565
11807
  {
11566
11808
  detached: true,
11567
11809
  stdio: ['ignore', stdoutLogFd, stderrLogFd],
@@ -13817,7 +14059,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
13817
14059
  /* harmony import */ var node_url__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(3136);
13818
14060
  /* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(7514);
13819
14061
  /* harmony import */ var _vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_14__ = __nccwpck_require__(6927);
13820
- /* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(2517);
14062
+ /* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(2755);
13821
14063
  /* harmony import */ var _vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_11__ = __nccwpck_require__(1010);
13822
14064
  /* harmony import */ var _linux_systemd_mjs__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(4217);
13823
14065
  /* harmony import */ var _vibelet_stop_logic_mjs__WEBPACK_IMPORTED_MODULE_12__ = __nccwpck_require__(6274);
@@ -13861,6 +14103,7 @@ const stderrLogPath = (0,node_path__WEBPACK_IMPORTED_MODULE_4__.join)(logDir, 'd
13861
14103
  const pidFilePath = (0,node_path__WEBPACK_IMPORTED_MODULE_4__.join)(vibeletDir, 'daemon.pid');
13862
14104
  const relayConfigPath = (0,node_path__WEBPACK_IMPORTED_MODULE_4__.join)(vibeletDir, 'relay.json');
13863
14105
  const tunnelStatePath = (0,node_path__WEBPACK_IMPORTED_MODULE_4__.join)(vibeletDir, 'tunnel.json');
14106
+ const cloudflaredUpdateStatePath = (0,node_path__WEBPACK_IMPORTED_MODULE_4__.join)(vibeletDir, 'cloudflared-update.json');
13864
14107
  const updateCheckPath = (0,node_path__WEBPACK_IMPORTED_MODULE_4__.join)(vibeletDir, 'update-check.json');
13865
14108
  const OFFICIAL_SITE_URL = 'https://vibelet.icu';
13866
14109
  const UPDATE_CHECK_INTERVAL_MS = 4 * 60 * 60 * 1000; // 4 hours
@@ -14799,7 +15042,7 @@ function printHelp() {
14799
15042
  process.stdout.write(` # Need a fresh Cloudflare Tunnel URL?\n`);
14800
15043
  process.stdout.write(` npx ${packageJson.name} --access=remote --force\n\n`);
14801
15044
  process.stdout.write(` # Or bring your own tunnel and pass the URL manually:\n`);
14802
- process.stdout.write(` npx cloudflared tunnel --protocol http2 --url http://localhost:${port}\n`);
15045
+ process.stdout.write(` npx cloudflared tunnel --protocol auto --url http://localhost:${port}\n`);
14803
15046
  process.stdout.write(` ngrok http ${port}\n`);
14804
15047
  process.stdout.write(` npx ${packageJson.name} --access=https://<your-tunnel-url>\n\n`);
14805
15048
  process.stdout.write(` # Tailscale (P2P VPN, no tunnel needed)\n`);
@@ -14979,6 +15222,10 @@ async function main() {
14979
15222
  // --remote/--tunnel remain accepted for compatibility, but startup commands
14980
15223
  // now default to managed remote access unless another connection target wins.
14981
15224
  const shouldManageTunnel = startCommand && !localFlag && relayArg === null && !hostArg && !fallbackHostsArg;
15225
+ const cloudflaredProtocol = process.env.VIBELET_CLOUDFLARED_PROTOCOL?.trim() || 'http2';
15226
+ if (!['auto', 'quic', 'http2'].includes(cloudflaredProtocol)) {
15227
+ fail(`Unsupported VIBELET_CLOUDFLARED_PROTOCOL: ${cloudflaredProtocol}. Use auto, quic, or http2.`);
15228
+ }
14982
15229
 
14983
15230
  if (localFlag) {
14984
15231
  process.env.VIBELET_LOCAL_ONLY = '1';
@@ -14995,7 +15242,13 @@ async function main() {
14995
15242
  if (forceFlag) (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_7__/* .stopTunnel */ .HM)(getTunnelManagerOptions());
14996
15243
  process.stdout.write('Starting Cloudflare Tunnel...\n');
14997
15244
  try {
14998
- const tunnel = await (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_7__/* .startTunnel */ .DH)({ port, logDir, tunnelStatePath });
15245
+ const tunnel = await (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_7__/* .startTunnel */ .DH)({
15246
+ port,
15247
+ logDir,
15248
+ tunnelStatePath,
15249
+ protocol: cloudflaredProtocol,
15250
+ updateStatePath: cloudflaredUpdateStatePath,
15251
+ });
14999
15252
  process.stdout.write(`Tunnel ready: ${tunnel.url}\n`);
15000
15253
  saveRelayConfig(tunnel.url);
15001
15254
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibelet",
3
- "version": "1.2.153",
3
+ "version": "1.2.154",
4
4
  "description": "Cross-platform CLI for installing and running the Vibelet daemon",
5
5
  "homepage": "https://vibelet.icu",
6
6
  "files": [
@@ -26,6 +26,7 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
+ "cloudflared": "0.7.1",
29
30
  "node-pty": "^1.1.0",
30
31
  "ws": "^8.18.0"
31
32
  }