@tedbrain/vlink 0.1.159 → 0.1.161

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
@@ -9,20 +9,25 @@ npx --registry=https://registry.npmmirror.com -y @tedbrain/vlink@latest install
9
9
 
10
10
  npm 包只注册 `vlink-install` 命令;`vlink` 命令由安装后的原生程序提供。
11
11
  `npx` 会自动选择包中唯一的命令入口,因此上面的安装命令保持不变。
12
- 全局安装 npm 包只会注册 `vlink-install`;Windows 下 npm 会生成
12
+ 全局安装 npm 包会注册 `vlink-install`;Windows 下 npm 会生成
13
13
  `vlink-install`、`vlink-install.cmd`、`vlink-install.ps1` 三个入口。
14
- 通过全局 npm 包安装原生程序时,执行:
14
+ 升级到原生程序只需一条命令:
15
15
 
16
16
  ```bash
17
17
  npm install -g @tedbrain/vlink@latest --registry=https://registry.npmmirror.com
18
- vlink-install install
19
18
  ```
20
19
 
21
- 该命令会识别平台和架构,始终安装与当前 npm 包版本一致的 vlink,配置用户
22
- PATH,并启动 `vlink setup tedbrain`。如果 PATH 中已有原生 vlink,会优先更新该位置;
23
- 旧文件或目录不可写时,自动回退到用户安装目录(Unix 为 `~/.local/bin`,Windows 为
24
- `%LOCALAPPDATA%\TedBrain\bin`),保留原来的共享安装。显式设置 `VLINK_INSTALL_DIR`
25
- 时始终使用该目录,写入失败会报错,不会再改装到其他位置。
20
+ `npm_config_global=true` 时,包内 `postinstall` 除下载二进制外,会像
21
+ `vlink-install install` 一样把它原子安装到用户安装目录、停掉旧 daemon 并
22
+ 配置用户 PATH;它不会启动交互式的 `vlink setup tedbrain`。如果 PATH 中已有
23
+ 原生 vlink,会优先更新该位置;旧文件或目录不可写时,自动回退到用户安装目录
24
+ (Unix 为 `~/.local/bin`,Windows 为 `%LOCALAPPDATA%\TedBrain\bin`),保留原来
25
+ 的共享安装。显式设置 `VLINK_INSTALL_DIR` 时始终使用该目录,写入失败会报错,
26
+ 不会再改装到其他位置。
27
+
28
+ 需要交互式 setup 或 `--no-setup` / `--web` / `--verbose` 选项时,仍可执行
29
+ `vlink-install install`。在 CI 或不允许 postinstall 触碰用户目录/daemon 的
30
+ 环境里,设置 `VLINK_NPM_GLOBAL_INSTALL=0` 让全局 `postinstall` 只下载二进制。
26
31
 
27
32
  安装目录会优先加入当前安装进程的 PATH,补全和 setup 均使用新二进制的绝对路径。
28
33
  默认目录还会写入 shell 配置或 Windows 用户 PATH;自定义 Unix 目录需要自行配置
@@ -198,9 +203,15 @@ V1 的版本查询、安装、自更新和七平台二进制统一由 npm 承载
198
203
  | Windows arm64 | `@tedbrain/vlink-windows-aarch64` |
199
204
 
200
205
  安装器使用 npm 已安装的平台包,缺失时从 registry 获取精确版本。Linux x64 依现有 glibc 检测选择兼容载荷。
201
- 默认 registry 为 `https://registry.npmjs.org`,可用 `VLINK_NPM_REGISTRY` 指定内部 npm registry;下载器沿用 HTTP(S)_PROXY / NO_PROXY 配置。
202
- `vlink update` 从 npm 查询最新正式版并下载对应载荷。`vlink ssh connect` 从 npm 下载与本机同版本的远端平台载荷并通过 SSH 上传。两者都支持 `VLINK_NPM_REGISTRY`,无需安装 Node/npm。
203
- 历史客户端若仍使用旧更新源,需通过 `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`。
204
215
 
205
216
  ### 薄包模式(直链数据包)
206
217
 
package/binaries.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
- "version": "0.1.159",
2
+ "version": "0.1.161",
3
3
  "binaries": {
4
4
  "linux-x86_64": {
5
- "url": "https://cloud.tsinghua.edu.cn/f/16e5a8f3c8b74048b537/?dl=1",
6
- "sha256": "c3e32724ce1af7dedf93f9290043ebcd9d3a18903c7e402bd6f7e607c3cd6208",
7
- "size": 24807805
5
+ "url": "https://cloud.tsinghua.edu.cn/f/4b824ceb5a6141709ccd/?dl=1",
6
+ "sha256": "cd85e516e29f1f754d4721468140caff0222aff5903cb80a480e60d9d0ff90d7",
7
+ "size": 24877437
8
8
  },
9
9
  "linux-x86_64-glibc2.17": {
10
- "url": "https://cloud.tsinghua.edu.cn/f/ac7c1329616746eba8fd/?dl=1",
11
- "sha256": "dc654f8ca507bcc9b96a59bfb7d88973b98d980d1c920a911483933152c65d3d",
12
- "size": 25530233
10
+ "url": "https://cloud.tsinghua.edu.cn/f/1620d41fbbd0405fb684/?dl=1",
11
+ "sha256": "ac36a5ae4510917b80442804f608ea66f2f72dea8be301f4add8aafeca14619a",
12
+ "size": 25603249
13
13
  },
14
14
  "linux-aarch64": {
15
- "url": "https://cloud.tsinghua.edu.cn/f/3c23abe92a4f47b29655/?dl=1",
16
- "sha256": "51eca4ee6eeb6523ed3faa2368c0ecb4deb75120967429048716ffef510d2d71",
17
- "size": 21113765
15
+ "url": "https://cloud.tsinghua.edu.cn/f/0754e59860cd4a1a86ef/?dl=1",
16
+ "sha256": "6d65f88f0f7e1b8167e6568674680a5bfa6f3e5568e3f994088d97570a3d776c",
17
+ "size": 21179301
18
18
  },
19
19
  "macos-x86_64": {
20
- "url": "https://cloud.tsinghua.edu.cn/f/c16b789421bb43158c31/?dl=1",
21
- "sha256": "5ace58e9ece6fcfa516b707f42148dadf374aeab2c91895163039fd55f98df31",
22
- "size": 22185681
20
+ "url": "https://cloud.tsinghua.edu.cn/f/30983e728c7041858932/?dl=1",
21
+ "sha256": "d2fff46ccfeb3b150b4888bcad364c5c1160f8397d45c38d34ec020866be1408",
22
+ "size": 22247233
23
23
  },
24
24
  "macos-aarch64": {
25
- "url": "https://cloud.tsinghua.edu.cn/f/19684ff1be334669b9d2/?dl=1",
26
- "sha256": "6edc731e483665bdbfc5ba37895602545438ce091377e8889c90cbcdeae1d532",
27
- "size": 17972805
25
+ "url": "https://cloud.tsinghua.edu.cn/f/151b437c7bcd4df7846d/?dl=1",
26
+ "sha256": "362a30090ccd57ffa18eaf9cd32f42ad3b63e89785aab2f9add802ddb0d9004a",
27
+ "size": 18022389
28
28
  },
29
29
  "windows-x86_64.exe": {
30
- "url": "https://cloud.tsinghua.edu.cn/f/d96c4e4c15274312ab31/?dl=1",
31
- "sha256": "757af31917c2759262cc3b8ff9ce9024c0ecf1dc33092fed7eb888499d76166d",
32
- "size": 9745701
30
+ "url": "https://cloud.tsinghua.edu.cn/f/2c23d16117a84a8abe60/?dl=1",
31
+ "sha256": "035b5b6b006ebc30c6e1460e0ff4e271f499dc51fd84b27919acc8934c58859c",
32
+ "size": 9781029
33
33
  },
34
34
  "windows-aarch64.exe": {
35
- "url": "https://cloud.tsinghua.edu.cn/f/29c9276c37e149349044/?dl=1",
36
- "sha256": "7b2504ef6e7e699e03f085f57977398e0637682be13633bf5a72564d7ef8cc69",
37
- "size": 11226409
35
+ "url": "https://cloud.tsinghua.edu.cn/f/6a586869ac0f4329b75b/?dl=1",
36
+ "sha256": "99e52099ae5e1b77939670d75ae3bf0ebac5e76783d96352b5e9a8b1cc14d598",
37
+ "size": 11281193
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
  }
@@ -611,6 +621,48 @@ async function ensureBinary(options = {}) {
611
621
  throw new VlinkInstallError(`all download sources failed: ${lastError.message}`);
612
622
  }
613
623
 
624
+ // `npm i -g @tedbrain/vlink` must be the only step a user needs. npm runs this
625
+ // file as the global postinstall, but the package's own `vlink-install` bin is
626
+ // not on PATH, so download-only would leave no `vlink` command behind. When
627
+ // npm reports a global install, hand over to the installer: it atomically
628
+ // places the binary in the user install directory, stops the previous daemon
629
+ // and updates PATH, exactly like `vlink-install install` does.
630
+ function globalInstallRequested(env = process.env) {
631
+ return ['1', 'true', 'yes', 'on'].includes(
632
+ String(env.npm_config_global || '').toLowerCase()
633
+ );
634
+ }
635
+
636
+ function globalInstallDisabled(env = process.env) {
637
+ return ['0', 'false', 'no', 'off'].includes(
638
+ String(env.VLINK_NPM_GLOBAL_INSTALL || '').toLowerCase()
639
+ );
640
+ }
641
+
642
+ async function runPostinstall(options = {}) {
643
+ const env = options.env || process.env;
644
+ const output = options.output || process.stderr;
645
+ const globalInstall =
646
+ options.globalInstall === undefined
647
+ ? globalInstallRequested(env) && !globalInstallDisabled(env)
648
+ : options.globalInstall === true;
649
+ if (globalInstall) {
650
+ // Installer setup is interactive; npm postinstall has no terminal. The
651
+ // explicit `vlink-install install` / `vlink setup tedbrain` path still
652
+ // offers the wizard and its --no-setup/--web flags.
653
+ const runInstaller =
654
+ options.runInstaller || require('./installer').runInstaller;
655
+ const result = await runInstaller({ env, output, skipSetup: true });
656
+ output.write(`[vlink] installed ${result.vlinkPath}\n`);
657
+ return { global: true, ...result };
658
+ }
659
+ const ensure = options.ensureBinary || ensureBinary;
660
+ const binaryPath = await ensure();
661
+ cleanupLegacyNpmShims();
662
+ output.write(`[vlink] installed ${binaryPath}\n`);
663
+ return { global: false, binaryPath };
664
+ }
665
+
614
666
  module.exports = {
615
667
  VlinkInstallError,
616
668
  VERSION,
@@ -631,17 +683,15 @@ module.exports = {
631
683
  downloadFile,
632
684
  resolveBinaryPath,
633
685
  ensureBinary,
634
- verifyBinary
686
+ verifyBinary,
687
+ globalInstallRequested,
688
+ globalInstallDisabled,
689
+ runPostinstall
635
690
  };
636
691
 
637
692
  if (require.main === module) {
638
- ensureBinary()
639
- .then((binaryPath) => {
640
- cleanupLegacyNpmShims();
641
- console.error(`[vlink] installed ${binaryPath}`);
642
- })
643
- .catch((err) => {
644
- console.error(`[vlink] install failed: ${err.message}`);
645
- process.exitCode = 1;
646
- });
693
+ runPostinstall().catch((err) => {
694
+ console.error(`[vlink] install failed: ${err.message}`);
695
+ process.exitCode = 1;
696
+ });
647
697
  }
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.159",
3
+ "version": "0.1.161",
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": {