@tedbrain/vlink 0.1.160 → 0.1.162

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/README.md CHANGED
@@ -203,9 +203,15 @@ V1 的版本查询、安装、自更新和七平台二进制统一由 npm 承载
203
203
  | Windows arm64 | `@tedbrain/vlink-windows-aarch64` |
204
204
 
205
205
  安装器使用 npm 已安装的平台包,缺失时从 registry 获取精确版本。Linux x64 依现有 glibc 检测选择兼容载荷。
206
- 默认 registry 为 `https://registry.npmjs.org`,可用 `VLINK_NPM_REGISTRY` 指定内部 npm registry;下载器沿用 HTTP(S)_PROXY / NO_PROXY 配置。
207
- `vlink update` 从 npm 查询最新正式版并下载对应载荷。`vlink ssh connect` 从 npm 下载与本机同版本的远端平台载荷并通过 SSH 上传。两者都支持 `VLINK_NPM_REGISTRY`,无需安装 Node/npm。
208
- 历史客户端若仍使用旧更新源,需通过 `npx -y @tedbrain/vlink@latest install` 完成一次迁移。
206
+ 安装器、`vlink update` 和 SSH 远端载荷下载默认先访问 `https://registry.npmjs.org`,
207
+ 遇到连接失败、超时、限流或服务端故障时自动改用 `https://registry.npmmirror.com`。
208
+ 下载继续使用已选版本,并校验归档完整性和二进制 SHA256。
209
+ 安装器使用 npm 解析并传入的 `registry` 配置,包括 `.npmrc` 中的 `registry=` 和 npm 的 `--registry`。
210
+ 直接运行 `vlink update` 或 `vlink ssh connect` 时,可以设置 `npm_config_registry` 或
211
+ `NPM_CONFIG_REGISTRY`。两项都设置时小写优先。下载器沿用 HTTP(S)_PROXY / NO_PROXY 配置。
212
+ `vlink update` 查询最新正式版,`vlink ssh connect` 下载与本机同版本的远端平台载荷并通过 SSH 上传。两者无需安装 Node/npm。
213
+ `npx` 首次获取安装包时由 npm 选择 registry。如果 npmjs 无法访问,运行
214
+ `npx --registry=https://registry.npmmirror.com -y @tedbrain/vlink@latest install --no-setup`。
209
215
 
210
216
  ### 薄包模式(直链数据包)
211
217
 
package/binaries.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
- "version": "0.1.160",
2
+ "version": "0.1.162",
3
3
  "binaries": {
4
4
  "linux-x86_64": {
5
- "url": "https://cloud.tsinghua.edu.cn/f/e0fa60e0b68f4d2f88e3/?dl=1",
6
- "sha256": "e1f5cb23e28da74a9f9a7962d2e880fd7f57d3171b5cb7c9edef9e5cbbe91eb8",
7
- "size": 24803709
5
+ "url": "https://cloud.tsinghua.edu.cn/f/28806d4398b04f86b2cd/?dl=1",
6
+ "sha256": "7c6169a9fb2446438987e8e434c99af4cb760209b2327551f0b35f88893720f0",
7
+ "size": 24807677
8
8
  },
9
9
  "linux-x86_64-glibc2.17": {
10
- "url": "https://cloud.tsinghua.edu.cn/f/729d55a84fb54d239f2f/?dl=1",
11
- "sha256": "02d68d969eadd3757e771974c974b533ae571230e10addfcd0409b9a26c3a539",
12
- "size": 25526985
10
+ "url": "https://cloud.tsinghua.edu.cn/f/0ad134b039424d01b114/?dl=1",
11
+ "sha256": "ce5510d2932bc03f7da80624aab84a8222068cf0dfe4c0feb026b8728d736c25",
12
+ "size": 25529721
13
13
  },
14
14
  "linux-aarch64": {
15
- "url": "https://cloud.tsinghua.edu.cn/f/f913297b974f475b8535/?dl=1",
16
- "sha256": "edfb9470a416046b352cc95f062daf40915d0263f18b46767d6eefd85d950ef3",
17
- "size": 21113765
15
+ "url": "https://cloud.tsinghua.edu.cn/f/1971610875924db4b176/?dl=1",
16
+ "sha256": "1b5a7ad7996f52f032290dcc7a68b6ba3b4775f0f25c56692b2aabd29f77c2e9",
17
+ "size": 21113645
18
18
  },
19
19
  "macos-x86_64": {
20
- "url": "https://cloud.tsinghua.edu.cn/f/1bf74767cf074d24a149/?dl=1",
21
- "sha256": "2789f0e2f9fdc3884aef92fff9824490e52f75029c7acd04ae0f3cd7be0a7549",
22
- "size": 22181593
20
+ "url": "https://cloud.tsinghua.edu.cn/f/9a1be749932f45769d4a/?dl=1",
21
+ "sha256": "d775b4e5ec4b83a3231421868ac1cc9c7bf163fec5c6a665995b1e784d9f8924",
22
+ "size": 22185609
23
23
  },
24
24
  "macos-aarch64": {
25
- "url": "https://cloud.tsinghua.edu.cn/f/824b1cf060ff4d548054/?dl=1",
26
- "sha256": "127e180ba53d4033a7543d97e1e5df81b6c7c2dac6ad123d8f6b777e28fbdd48",
27
- "size": 17956309
25
+ "url": "https://cloud.tsinghua.edu.cn/f/594358ec14ac4fc09ce3/?dl=1",
26
+ "sha256": "64116b5fc377629bc05ff1d2ff7a4dccb2f817b2c474cd7745c475a5b13b79e8",
27
+ "size": 17972709
28
28
  },
29
29
  "windows-x86_64.exe": {
30
- "url": "https://cloud.tsinghua.edu.cn/f/2ee4076c15ee4af4a1c3/?dl=1",
31
- "sha256": "529795cb23428b70de94f2256b6c2a620c2d662e8f6e1edcaad043346d699ea9",
32
- "size": 9742629
30
+ "url": "https://cloud.tsinghua.edu.cn/f/aa5b9c3d1e7d4f43bbdb/?dl=1",
31
+ "sha256": "ffb28876ed49b0ee1d0d2c0514b8da892ccd2a47d08068dd221d79e9922b08c7",
32
+ "size": 9775397
33
33
  },
34
34
  "windows-aarch64.exe": {
35
- "url": "https://cloud.tsinghua.edu.cn/f/78af63aa46ad4fd69395/?dl=1",
36
- "sha256": "2915213f17f874cde721f288c8875c2e78b2bd05310c974088ef07e50d72d049",
37
- "size": 11224361
35
+ "url": "https://cloud.tsinghua.edu.cn/f/8ffd00a6b6f44aab90c0/?dl=1",
36
+ "sha256": "b4a37128ab2ab3b5362a092e1da6042c41662432b309e6494a63464d8e840bed",
37
+ "size": 11270441
38
38
  }
39
39
  }
40
40
  }
package/install.js CHANGED
@@ -8,6 +8,7 @@ const https = require('https');
8
8
  const os = require('os');
9
9
  const path = require('path');
10
10
  const { spawnSync } = require('child_process');
11
+ const { pipeline } = require('stream/promises');
11
12
  const { HttpProxyAgent } = require('http-proxy-agent');
12
13
  const { HttpsProxyAgent } = require('https-proxy-agent');
13
14
 
@@ -251,7 +252,7 @@ function fallbackDownloadUrl(spec, suffix = spec.suffix) {
251
252
  return `${DOWNLOAD_BASE}/${CHANNEL}/vlink/${VERSION}/vlink-${suffix}`;
252
253
  }
253
254
 
254
- function httpGetText(url, options = {}) {
255
+ function httpResponse(url, timeout, options) {
255
256
  return new Promise((resolve, reject) => {
256
257
  const request = (target, redirects) => {
257
258
  const transport = target.startsWith('https:') ? https : http;
@@ -274,25 +275,33 @@ function httpGetText(url, options = {}) {
274
275
  }
275
276
  if (res.statusCode !== 200) {
276
277
  res.resume();
277
- return reject(
278
- new VlinkInstallError(`HTTP ${res.statusCode} from ${displayUrl(target)}`)
279
- );
278
+ const error = new VlinkInstallError(`HTTP ${res.statusCode} from ${displayUrl(target)}`);
279
+ error.statusCode = res.statusCode;
280
+ return reject(error);
280
281
  }
281
-
282
- const chunks = [];
283
- res.on('data', (chunk) => chunks.push(chunk));
284
- res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
282
+ resolve(res);
285
283
  }
286
284
  );
287
285
 
288
286
  req.on('error', reject);
289
- req.setTimeout(30000, () => req.destroy(new VlinkInstallError('request timed out')));
287
+ req.setTimeout(timeout, () => {
288
+ const error = new VlinkInstallError('request timed out');
289
+ error.code = 'ETIMEDOUT';
290
+ req.destroy(error);
291
+ });
290
292
  };
291
293
 
292
294
  request(url, 0);
293
295
  });
294
296
  }
295
297
 
298
+ async function httpGetText(url, options = {}) {
299
+ const response = await httpResponse(url, 30000, options);
300
+ const chunks = [];
301
+ for await (const chunk of response) chunks.push(chunk);
302
+ return Buffer.concat(chunks).toString('utf8');
303
+ }
304
+
296
305
  function parseJson(text, url) {
297
306
  try {
298
307
  return JSON.parse(text);
@@ -347,7 +356,8 @@ function buildDownloadSources(spec, suffix = spec.suffix, options = {}) {
347
356
  resolve: () => Promise.resolve(`npm:${require('./npm-payload').packageName(suffix)}@${VERSION}`),
348
357
  fetchTo: (destination) => require('./npm-payload').installPayload(
349
358
  suffix, VERSION, expectedChecksum(spec, suffix), destination,
350
- { text: url => httpGetText(url, options), download: (url, dest) => downloadFile(url, dest, options) }
359
+ { text: url => httpGetText(url, options), download: (url, dest) => downloadFile(url, dest, options) },
360
+ options.env || process.env
351
361
  )
352
362
  }];
353
363
  }
@@ -472,56 +482,9 @@ function sha256File(filePath) {
472
482
  });
473
483
  }
474
484
 
475
- function downloadFile(url, destPath, options = {}) {
476
- return new Promise((resolve, reject) => {
477
- const fileStream = fs.createWriteStream(destPath, { mode: 0o755 });
478
-
479
- const finish = () => {
480
- fileStream.close((closeErr) => {
481
- if (closeErr) reject(closeErr);
482
- else resolve();
483
- });
484
- };
485
-
486
- const request = (target, redirects) => {
487
- const transport = target.startsWith('https:') ? https : http;
488
- const req = transport.get(
489
- target,
490
- {
491
- agent: requestAgent(target, options),
492
- headers: { 'user-agent': `${PKG.name}/${PKG.version}` }
493
- },
494
- (res) => {
495
- if (
496
- res.statusCode >= 300 &&
497
- res.statusCode < 400 &&
498
- res.headers.location &&
499
- redirects < 5
500
- ) {
501
- res.resume();
502
- const next = new URL(res.headers.location, target).toString();
503
- return request(next, redirects + 1);
504
- }
505
- if (res.statusCode !== 200) {
506
- res.resume();
507
- return reject(
508
- new VlinkInstallError(
509
- `download failed: HTTP ${res.statusCode} from ${displayUrl(target)}`
510
- )
511
- );
512
- }
513
- res.pipe(fileStream);
514
- }
515
- );
516
-
517
- req.on('error', reject);
518
- req.setTimeout(downloadTimeoutMs(), () => req.destroy(new VlinkInstallError('download timed out')));
519
- };
520
-
521
- fileStream.on('finish', finish);
522
- fileStream.on('error', reject);
523
- request(url, 0);
524
- });
485
+ async function downloadFile(url, destPath, options = {}) {
486
+ const response = await httpResponse(url, downloadTimeoutMs(), options);
487
+ await pipeline(response, fs.createWriteStream(destPath, { mode: 0o755 }));
525
488
  }
526
489
 
527
490
  function verifyBinary(binaryPath) {
package/npm-payload.js CHANGED
@@ -11,6 +11,12 @@ const SUFFIXES = [
11
11
  'macos-x86_64', 'macos-aarch64', 'windows-x86_64.exe', 'windows-aarch64.exe'
12
12
  ];
13
13
  const MAX_PAYLOAD = 128 * 1024 * 1024;
14
+ const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
15
+ const MIRROR_REGISTRY = 'https://registry.npmmirror.com';
16
+ const NETWORK_ERRORS = new Set([
17
+ 'EAI_AGAIN', 'ENOTFOUND', 'ETIMEDOUT', 'EHOSTUNREACH', 'ENETUNREACH',
18
+ 'ECONNABORTED', 'ECONNREFUSED', 'ECONNRESET', 'EPIPE', 'ERR_STREAM_PREMATURE_CLOSE'
19
+ ]);
14
20
 
15
21
  function packageName(suffix) {
16
22
  if (!SUFFIXES.includes(suffix)) throw new Error(`unsupported platform: ${suffix}`);
@@ -65,7 +71,16 @@ function verify(data, expected, algorithm) {
65
71
  if (!expected || actual !== expected) throw new Error(`${algorithm} integrity mismatch`);
66
72
  }
67
73
 
68
- async function installPayload(suffix, version, checksum, destination, transport) {
74
+ function registryUnavailable(error) {
75
+ const { statusCode, code } = error;
76
+ if (statusCode !== undefined) {
77
+ return [403, 408, 429].includes(statusCode) || (statusCode >= 500 && statusCode < 600);
78
+ }
79
+ return NETWORK_ERRORS.has(code) ||
80
+ /^(ERR_TLS_|ERR_SSL_|CERT_|UNABLE_TO_|DEPTH_ZERO_|SELF_SIGNED_)/.test(code);
81
+ }
82
+
83
+ async function installPayload(suffix, version, checksum, destination, transport, env = process.env) {
69
84
  const name = packageName(suffix);
70
85
  const contentVersion = packageVersion(suffix, version);
71
86
  const binaryName = suffix.endsWith('.exe') ? 'vlink.exe' : 'vlink';
@@ -79,15 +94,41 @@ async function installPayload(suffix, version, checksum, destination, transport)
79
94
  fs.writeFileSync(destination, data, { mode: 0o755 });
80
95
  return;
81
96
  }
82
- const registry = (process.env.VLINK_NPM_REGISTRY || 'https://registry.npmjs.org').replace(/\/+$/, '');
83
- const metadata = JSON.parse(await transport.text(`${registry}/${encodeURIComponent(name)}/${contentVersion}`));
97
+ let registry = (env.npm_config_registry || env.NPM_CONFIG_REGISTRY || DEFAULT_REGISTRY)
98
+ .replace(/\/+$/, '');
99
+ async function fromRegistry(request) {
100
+ try {
101
+ return await request(registry);
102
+ } catch (error) {
103
+ if (registry !== DEFAULT_REGISTRY || !registryUnavailable(error)) throw error;
104
+ registry = MIRROR_REGISTRY;
105
+ console.error(`[vlink] npmjs request failed, retrying via ${registry}`);
106
+ try {
107
+ return await request(registry);
108
+ } catch (mirrorError) {
109
+ throw new Error(`npmjs request failed (${error.message}), mirror request failed (${mirrorError.message})`);
110
+ }
111
+ }
112
+ }
113
+ const text = await fromRegistry(origin => transport.text(
114
+ `${origin}/${encodeURIComponent(name)}/${contentVersion}`
115
+ ));
116
+ const metadata = JSON.parse(text);
84
117
  if (metadata.name !== name || metadata.version !== contentVersion || !metadata.dist ||
118
+ typeof metadata.dist.tarball !== 'string' ||
85
119
  !/^sha512-[A-Za-z0-9+/]+={0,2}$/.test(metadata.dist.integrity || '')) {
86
120
  throw new Error('invalid npm platform metadata');
87
121
  }
88
122
  const tarball = `${destination}.tgz`;
89
123
  try {
90
- await transport.download(metadata.dist.tarball, tarball);
124
+ const url = metadata.dist.tarball;
125
+ const upstreamPrefix = `${DEFAULT_REGISTRY}/`;
126
+ if ([DEFAULT_REGISTRY, MIRROR_REGISTRY].includes(registry) && url.startsWith(upstreamPrefix)) {
127
+ const tarballPath = url.slice(upstreamPrefix.length);
128
+ await fromRegistry(origin => transport.download(`${origin}/${tarballPath}`, tarball));
129
+ } else {
130
+ await transport.download(url, tarball);
131
+ }
91
132
  if (fs.statSync(tarball).size > MAX_PAYLOAD) throw new Error('platform package too large');
92
133
  const data = fs.readFileSync(tarball);
93
134
  verify(data, metadata.dist.integrity.slice(7), 'sha512');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tedbrain/vlink",
3
- "version": "0.1.160",
3
+ "version": "0.1.162",
4
4
  "description": "vlink Virtuoso bridge CLI installer. Installs the matching platform binary at npm install time, like Claude Code / Codex.",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {