@ds-hu/dsh-tailcat-remote 0.1.0 → 0.1.1

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/NOTICE CHANGED
@@ -19,9 +19,9 @@ QR Code Generator
19
19
 
20
20
  tailcat
21
21
  tailcat is a separate program by Tailscale Inc & contributors, licensed
22
- under the BSD 3-Clause License. It is not bundled with this package and is
23
- not a dependency of the npm package; users install it themselves. This
24
- plugin only starts the user's `tailcat` executable and parses its output.
22
+ under the BSD 3-Clause License. It is not bundled with this package. The
23
+ plugin can install a verified, user-local copy on request, or use a
24
+ pre-existing installation; it starts that executable and parses its output.
25
25
  Copyright (c) 2020 Tailscale Inc & contributors.
26
26
  Source: https://github.com/tailscale/tailcat
27
27
 
package/README.en.md CHANGED
@@ -42,15 +42,7 @@ Remote Access folds that into one plugin. The Host supervises a `tailcat` proces
42
42
 
43
43
  ## Install
44
44
 
45
- Install [tailcat](https://github.com/tailscale/tailcat#install) first. It must be on the Host's `PATH`; you can also set an absolute `binaryPath` in the plugin config later.
46
-
47
- ```sh
48
- # macOS, Linux, Windows, FreeBSD, and more
49
- # for example, a static binary:
50
- tailcat version
51
- ```
52
-
53
- Then add the plugin to the web profile:
45
+ Add the plugin to the web profile:
54
46
 
55
47
  ```sh
56
48
  dsh plugin --profile web add @ds-hu/dsh-tailcat-remote
@@ -70,10 +62,27 @@ List the package in the profile's `dsh.profile.bundles`, then restart `dsh web`:
70
62
 
71
63
  Installing the bundle from **Plugin Manager** has the same effect.
72
64
 
65
+ ### tailcat installation is managed
66
+
67
+ Restart `dsh web` and open **Remote Access**. If the Host has no tailcat, the page shows an install card:
68
+
69
+ - **Linux / Windows:** click **Install tailcat**. The plugin selects the official tailcat v0.8.0 asset for `process.arch`, downloads it, verifies its SHA-256 against the official `checksums.txt`, and extracts it to `$DSH_HOME/tailcat-remote/bin/`. The system `PATH` is not modified.
70
+ - **macOS:** if Homebrew is available, the same button updates Homebrew and installs/upgrades tailcat (0.8.0 or newer), then copies the executable into the managed directory. Intel Macs have no bottle, so Homebrew builds from source and can take several minutes. Without Homebrew, the page shows a clear message and a manual-install link.
71
+ - **Your own tailcat:** on startup the plugin checks `PATH` and common package locations (`/opt/homebrew/bin`, `/usr/local/bin`, `/usr/bin`, and so on). It uses an existing install directly and never downloads over it. The diagnostics section shows the executable's source and version.
72
+ - **Other platforms or architectures:** install tailcat manually (0.8.0 or newer) from [the upstream instructions](https://github.com/tailscale/tailcat#install), then point `binaryPath` at it. `binaryPath` takes precedence over the managed copy.
73
+
74
+ <p align="center">
75
+ <img src="docs/screenshots/03-install.png" alt="Install card shown when tailcat is missing: detection, method, checksum note, and the one-click button" width="820">
76
+ </p>
77
+
78
+ The managed install only runs after you click the button: there is no background download and no per-platform binary payload in the npm package.
79
+
80
+ > Automatic installation covers the **Host-side** tailcat server only. The client device still needs its own tailcat to run `tailcat forward`; this plugin does not include a client program.
81
+
73
82
  ## Use
74
83
 
75
84
  1. Restart Harness and open **Remote Access** in the sidebar.
76
- 2. Wait for **Online** and the address. The first start creates a saved key and probes a DERP region, which can take a minute.
85
+ 2. If the page reports a missing tailcat, click **Install tailcat** first; otherwise wait for **Online** and the address. The first start creates a saved key and probes a DERP region, which can take a minute.
77
86
  3. On the client device, install tailcat and run the command shown on the page, or scan the QR code for the address:
78
87
 
79
88
  ```sh
package/README.md CHANGED
@@ -42,15 +42,7 @@ DeepSeek Harness 默认只在本机监听。想从笔记本、手机或另一台
42
42
 
43
43
  ## 安装
44
44
 
45
- 先安装 [tailcat](https://github.com/tailscale/tailcat#install)。它需要出现在 Host 的 `PATH` 里;也可以稍后在插件配置里写绝对路径 `binaryPath`。
46
-
47
- ```sh
48
- # macOS、Linux、Windows、FreeBSD 等都有安装方式
49
- # 例如静态二进制:
50
- tailcat version
51
- ```
52
-
53
- 再把插件装进 web profile:
45
+ 把插件装进 web profile:
54
46
 
55
47
  ```sh
56
48
  dsh plugin --profile web add @ds-hu/dsh-tailcat-remote
@@ -70,10 +62,27 @@ dsh plugin --profile web add @ds-hu/dsh-tailcat-remote
70
62
 
71
63
  也可以在 **插件管理** 里安装这个 bundle,效果相同。
72
64
 
65
+ ### tailcat 会自动安装
66
+
67
+ 重启 `dsh web` 后打开 **远程访问**。如果 Host 还没有 tailcat,页面会显示安装卡片:
68
+
69
+ - **Linux / Windows**:点 **一键安装 tailcat**。插件会按 `process.arch` 选择 tailcat 官方 v0.8.0 release 资产,下载后用官方 `checksums.txt` 校验 SHA-256,再解压到 `$DSH_HOME/tailcat-remote/bin/`。不修改系统 `PATH`。
70
+ - **macOS**:如果 Host 有 Homebrew,点同一个按钮会先更新 Homebrew,再安装/升级 tailcat(需要 0.8.0 或更新),然后把可执行文件复制到受管目录。Intel Mac 没有现成 bottle,Homebrew 会从源码构建,可能比 Apple Silicon 慢几分钟。没有 Homebrew 时,页面会给出明确提示和手动安装链接。
71
+ - **已经自己安装过 tailcat**:插件启动时会检查 `PATH`,以及 `/opt/homebrew/bin`、`/usr/local/bin`、`/usr/bin` 等常见位置。检测到就直接使用,不会下载,也不会覆盖你的安装。诊断区会显示可执行文件来源和版本。
72
+ - **其他平台或架构**:自动安装不可用时,按 [tailcat 安装说明](https://github.com/tailscale/tailcat#install) 手动安装(需要 0.8.0 或更新),再用 `binaryPath` 指向它。`binaryPath` 的优先级高于受管安装。
73
+
74
+ <p align="center">
75
+ <img src="docs/screenshots/03-install.png" alt="缺少 tailcat 时的安装卡片:检测结果、安装方式、校验说明和一键安装按钮" width="820">
76
+ </p>
77
+
78
+ 受管安装只在点击按钮时发生:插件不会在后台静默下载,也不把各平台二进制塞进 npm 包。
79
+
80
+ > 自动安装只针对 **Host 端**的 tailcat 服务进程。要访问 Harness 的客户端设备仍然需要自己安装 tailcat,用来运行 `tailcat forward`;本插件不包含客户端程序。
81
+
73
82
  ## 使用
74
83
 
75
84
  1. 重启 Harness,侧边栏打开 **远程访问**。
76
- 2. 确认状态是 **运行中**,地址和二维码已经出现。首次启动要生成保存密钥并探测 DERP 区域,可能需要一分钟。
85
+ 2. 如果页面提示缺少 tailcat,先点 **一键安装 tailcat**;否则确认状态是 **运行中**,地址和二维码已经出现。首次启动要生成保存密钥并探测 DERP 区域,可能需要一分钟。
77
86
  3. 在要访问的客户端设备上安装 tailcat,运行页面给出的命令,或者扫描二维码取得地址:
78
87
 
79
88
  ```sh
@@ -89,7 +98,7 @@ dsh plugin --profile web add @ds-hu/dsh-tailcat-remote
89
98
 
90
99
  - 给地址配白名单:客户端运行 `tailcat genkey --client --key=client-default`,把打印的公钥加进页面。
91
100
  - 更换地址后,旧地址立即失效。已经拿到 DSH cookie 的浏览器不会自动退出,需要按 DSH 的会话管理单独处理。
92
- - 不要直接暴露 3080。插件只让 tailcat 通过一条 0600 的 Unix socket 访问 door,不监听公网。
101
+ - 不要直接暴露 3080。在 Linux/macOS 上,插件只让 tailcat 通过一条 0600 的 Unix socket 访问 door;Windows 没有 tailcat Unix-socket 支持,默认使用仅绑定 `127.0.0.1` 的 TCP 端口,仍不对局域网或公网开放。
93
102
  - 如果 Web listener 是 HTTPS,door 会拒绝启动;当前版本不支持在 TLS 后面重放 cookie。
94
103
 
95
104
  完整威胁模型、限制和检查清单见 [安全说明](docs/SECURITY.md)。
package/client.js CHANGED
@@ -50,7 +50,7 @@ window.__ModuleLoader__.load({
50
50
  stepInstall: '在客户端设备安装 tailcat。',
51
51
  stepRun: '运行下面的命令,或扫描二维码把地址带到那台设备。',
52
52
  stepOpen: '在客户端浏览器打开 http://127.0.0.1:{localPort}/。',
53
- installHint: '可通过 Homebrew、发行版包或 GitHub Release 安装 tailcat;Linux 下载后赋予可执行权限并放进 PATH。',
53
+ installHint: '插件可以自动安装 tailcat;如果自动安装不可用,也可以从 GitHub Release 手动安装并设置 binaryPath。',
54
54
  securityTitle: '安全',
55
55
  allowOffTitle: '地址就是唯一的钥匙',
56
56
  allowOffBody: '任何拿到 tailcat 地址的人都能访问本 Harness。在下方添加至少一个客户端公钥后,访问才会限制在已配对设备。',
@@ -90,8 +90,38 @@ window.__ModuleLoader__.load({
90
90
  unavailableBody: '插件无法读取控制接口。请刷新页面或查看 Host 日志。',
91
91
  sessionExpired: '浏览器会话已过期,请重新打开 dsh web 输出的地址。',
92
92
  setupTitle: '安装 tailcat',
93
- setupBody: '插件找不到 tailcat 可执行文件。安装后重试。',
93
+ setupBody: '插件找不到 tailcat 可执行文件。可以一键安装,也可以使用系统已有的 tailcat。',
94
94
  setupRetry: '重新检测',
95
+ installMethodDownload: '安装方式:下载官方 {asset},校验 SHA-256 后解压。',
96
+ installMethodBrew: '安装方式:Homebrew({command})。',
97
+ installButton: '一键安装 tailcat',
98
+ installReinstall: '重新安装受管版本',
99
+ installBusy: '正在安装 tailcat…',
100
+ installPhaseChecksums: '正在获取官方 SHA-256 校验值…',
101
+ installPhaseDownload: '正在下载 tailcat…',
102
+ installPhaseVerify: '正在校验下载文件…',
103
+ installPhaseExtract: '正在解压…',
104
+ installPhaseInstall: '正在安装…',
105
+ installPhaseHomebrew: '正在通过 Homebrew 安装 tailcat,这可能需要几分钟…',
106
+ installProgress: '{percent}%({received} / {total})',
107
+ installProgressUnknown: '已下载 {received}',
108
+ installFailed: '安装失败',
109
+ installDetected: '已检测到系统 tailcat',
110
+ installDetectedBody: '版本 {version}。插件会直接使用它,不需要重复安装;路径见下方诊断。',
111
+ installChecking: '正在检查系统是否已安装 tailcat…',
112
+ installSystemOutdated: '检测到的 tailcat {version} 缺少本插件需要的能力(需要 0.8.0 或更新)。可以一键安装受管版本,或先升级系统 tailcat。',
113
+ installSystemOutdatedBrew: '检测到的 tailcat {version} 缺少本插件需要的能力(需要 0.8.0 或更新)。点击按钮会通过 Homebrew 升级系统 tailcat,并复制一份到受管目录;也可以先手动升级。',
114
+ installUnsupported: '当前平台 {platform}/{arch} 暂无自动安装。',
115
+ installConfigOverride: 'binaryPath 当前为 {path}。一键安装只会写入受管目录,不会覆盖该配置;请改回 tailcat 或手动安装到该路径。',
116
+ installManual: '手动安装说明',
117
+ installManagedNote: '受管版本位于 {path},不会修改系统 PATH。',
118
+ diagBinarySource: '可执行文件来源',
119
+ diagInstallSource: 'tailcat 安装',
120
+ sourceManaged: '受管安装',
121
+ sourcePath: '系统 PATH',
122
+ sourceConfig: '配置指定',
123
+ sourceUnavailable: '未检测到',
124
+ noticeInstalled: 'tailcat 已安装。',
95
125
  firstRun: '首次启动:tailcat 正在生成保存密钥并向 DERP 中继探测路由,可能需要一分钟。',
96
126
  modeStable: '保存密钥(稳定)',
97
127
  modeEphemeral: '临时密钥(重启后变化)',
@@ -154,7 +184,7 @@ window.__ModuleLoader__.load({
154
184
  stepInstall: 'Install tailcat on the client device.',
155
185
  stepRun: 'Run the command, or scan the QR code to move the address to that device.',
156
186
  stepOpen: 'Open http://127.0.0.1:{localPort}/ in the client browser.',
157
- installHint: 'Install tailcat with Homebrew, a release binary, or another supported package. On Linux, download it from the GitHub release, make it executable, and put it on PATH.',
187
+ installHint: 'The plugin can install tailcat automatically. If that is unavailable, install it from the GitHub release and set binaryPath.',
158
188
  securityTitle: 'Security',
159
189
  allowOffTitle: 'The address is the only key',
160
190
  allowOffBody: 'Anyone who obtains the tailcat address can reach this Harness. Add at least one client public key below to restrict access to paired devices.',
@@ -194,8 +224,38 @@ window.__ModuleLoader__.load({
194
224
  unavailableBody: 'The plugin could not read its control API. Reload the page or check the Host log.',
195
225
  sessionExpired: 'The browser session expired; reopen the URL printed by dsh web.',
196
226
  setupTitle: 'Install tailcat',
197
- setupBody: 'The plugin could not find the tailcat executable. Install it, then retry.',
227
+ setupBody: 'The plugin could not find the tailcat executable. Install it here or use an existing system copy.',
198
228
  setupRetry: 'Check again',
229
+ installMethodDownload: 'Method: download the official {asset} and verify its SHA-256 before extraction.',
230
+ installMethodBrew: 'Method: Homebrew ({command}).',
231
+ installButton: 'Install tailcat',
232
+ installReinstall: 'Reinstall managed copy',
233
+ installBusy: 'Installing tailcat…',
234
+ installPhaseChecksums: 'Fetching the official SHA-256 manifest…',
235
+ installPhaseDownload: 'Downloading tailcat…',
236
+ installPhaseVerify: 'Verifying the download…',
237
+ installPhaseExtract: 'Extracting…',
238
+ installPhaseInstall: 'Installing…',
239
+ installPhaseHomebrew: 'Installing tailcat through Homebrew; this can take a few minutes…',
240
+ installProgress: '{percent}% ({received} / {total})',
241
+ installProgressUnknown: '{received} downloaded',
242
+ installFailed: 'Installation failed',
243
+ installDetected: 'Existing tailcat detected',
244
+ installDetectedBody: 'Version {version}. The plugin uses it directly; no duplicate install is needed. The path is in diagnostics below.',
245
+ installChecking: 'Checking whether tailcat is already installed…',
246
+ installSystemOutdated: 'The detected tailcat {version} lacks the features this plugin needs (0.8.0 or newer is required). Install the managed copy or upgrade the system tailcat first.',
247
+ installSystemOutdatedBrew: 'The detected tailcat {version} lacks the features this plugin needs (0.8.0 or newer is required). The button upgrades it through Homebrew and copies the result into the managed directory; you can also upgrade manually first.',
248
+ installUnsupported: 'Automatic installation is unavailable on {platform}/{arch}.',
249
+ installConfigOverride: 'binaryPath is set to {path}. A managed install only writes the plugin directory and will not override that setting; set it back to tailcat or install manually at that path.',
250
+ installManual: 'Manual install instructions',
251
+ installManagedNote: 'The managed copy lives at {path}; the system PATH is not modified.',
252
+ diagBinarySource: 'Executable source',
253
+ diagInstallSource: 'tailcat install',
254
+ sourceManaged: 'Managed',
255
+ sourcePath: 'System PATH',
256
+ sourceConfig: 'Configured path',
257
+ sourceUnavailable: 'Not detected',
258
+ noticeInstalled: 'tailcat is installed.',
199
259
  firstRun: 'First run: tailcat is creating a saved key and asking a DERP relay for a route. This can take a minute.',
200
260
  modeStable: 'Saved (stable)',
201
261
  modeEphemeral: 'Ephemeral (changes on restart)',
@@ -291,6 +351,8 @@ window.__ModuleLoader__.load({
291
351
  .tcr-notice-ok { border-color: color-mix(in srgb, var(--dsw-alias-state-success-primary) 35%, var(--dsw-alias-border-l3)); background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 9%, var(--dsw-alias-bg-layer-1)); }
292
352
  .tcr-notice-error { border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 35%, var(--dsw-alias-border-l3)); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 9%, var(--dsw-alias-bg-layer-1)); color: var(--dsw-alias-label-primary); }
293
353
  .tcr-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--dsw-alias-label-tertiary); font-size: 11.5px; line-height: 1.6; padding-top: 6px; }
354
+ .tcr-progress { height: 6px; overflow: hidden; border-radius: 999px; background: var(--dsw-alias-bg-layer-3); margin-top: 8px; }
355
+ .tcr-progress-bar { height: 100%; border-radius: inherit; background: var(--dsw-alias-brand-primary); transition: width .25s ease; }
294
356
  .tcr-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--dsw-alias-border-l2); border-top-color: var(--dsw-alias-brand-primary); animation: tcr-spin .8s linear infinite; }
295
357
  @keyframes tcr-spin { to { transform: rotate(360deg); } }
296
358
  .tcr-empty { color: var(--dsw-alias-label-tertiary); font-size: 13px; }
@@ -572,7 +634,9 @@ window.__ModuleLoader__.load({
572
634
  ? 'busyRotate'
573
635
  : busy === 'devices'
574
636
  ? 'busySave'
575
- : null;
637
+ : busy === 'install'
638
+ ? 'installBusy'
639
+ : null;
576
640
 
577
641
  const reportCopy = (text, ok) => setLocalNotice({ kind: ok ? 'ok' : 'error', text });
578
642
 
@@ -602,6 +666,56 @@ window.__ModuleLoader__.load({
602
666
  }
603
667
 
604
668
  const binaryMissing = tailcat.binary?.resolved === null && phase === 'error';
669
+ const installer = snapshot.installer;
670
+ const system = installer?.system;
671
+ const systemFound = system?.status === 'found';
672
+ const systemCompatible = system?.compatible !== false;
673
+ const configOverride = snapshot.config.binaryPath !== 'tailcat';
674
+ const installerBusy = busy === 'install' || Boolean(installer?.busy);
675
+ const anyBusy = Boolean(busy) || Boolean(installer?.busy);
676
+ const progress = installer?.progress;
677
+ const percent = progress && Number.isFinite(progress.percent) ? progress.percent : null;
678
+ const phaseText = progress
679
+ ? progress.phase === 'checksums'
680
+ ? t('installPhaseChecksums')
681
+ : progress.phase === 'verifying'
682
+ ? t('installPhaseVerify')
683
+ : progress.phase === 'extracting'
684
+ ? t('installPhaseExtract')
685
+ : progress.phase === 'installing'
686
+ ? t('installPhaseInstall')
687
+ : progress.phase === 'homebrew'
688
+ ? t('installPhaseHomebrew')
689
+ : t('installPhaseDownload')
690
+ : null;
691
+ const installProgress = progress
692
+ ? h(
693
+ 'div',
694
+ { className: 'tcr-install-progress' },
695
+ h(
696
+ 'p',
697
+ { className: 'tcr-hint', style: { marginTop: 0 } },
698
+ percent === null
699
+ ? h('span', { className: 'tcr-spinner', style: { display: 'inline-block', verticalAlign: 'middle', marginRight: 8 } })
700
+ : null,
701
+ phaseText,
702
+ progress.phase === 'downloading' && progress.total > 0
703
+ ? ` ${t('installProgress', { percent, received: formatBytes(progress.received), total: formatBytes(progress.total) })}`
704
+ : progress.phase === 'downloading' && progress.received > 0
705
+ ? ` ${t('installProgressUnknown', { received: formatBytes(progress.received) })}`
706
+ : null,
707
+ ),
708
+ percent !== null ? h('div', { className: 'tcr-progress' }, h('div', { className: 'tcr-progress-bar', style: { width: `${percent}%` } })) : null,
709
+ )
710
+ : null;
711
+ const sourceLabel =
712
+ tailcat.binary?.source === 'managed'
713
+ ? t('sourceManaged')
714
+ : tailcat.binary?.source === 'config'
715
+ ? t('sourceConfig')
716
+ : tailcat.binary?.source === 'path'
717
+ ? t('sourcePath')
718
+ : t('sourceUnavailable');
605
719
  const install = snapshot.plugin?.name ?? '@ds-hu/dsh-tailcat-remote';
606
720
  const command = pairing?.command ?? '';
607
721
  const localUrl = pairing ? `http://127.0.0.1:${pairing.localPort}/` : '';
@@ -651,7 +765,7 @@ window.__ModuleLoader__.load({
651
765
  Button,
652
766
  {
653
767
  variant: 'primary',
654
- disabled: Boolean(busy),
768
+ disabled: anyBusy,
655
769
  onClick: () => void act('start', {}, 'noticeStarted'),
656
770
  },
657
771
  t('start'),
@@ -659,17 +773,17 @@ window.__ModuleLoader__.load({
659
773
  : h(
660
774
  Button,
661
775
  {
662
- disabled: Boolean(busy),
776
+ disabled: anyBusy,
663
777
  onClick: () => void act('stop', {}, 'noticeStopped'),
664
778
  },
665
779
  t('stop'),
666
780
  ),
667
781
  h(
668
782
  Button,
669
- { disabled: Boolean(busy), onClick: () => void act('restart', {}, 'noticeRestarted') },
783
+ { disabled: anyBusy, onClick: () => void act('restart', {}, 'noticeRestarted') },
670
784
  t('restart'),
671
785
  ),
672
- h(Button, { variant: 'ghost', disabled: Boolean(busy), onClick: () => void reload() }, t('refresh')),
786
+ h(Button, { variant: 'ghost', disabled: anyBusy, onClick: () => void reload() }, t('refresh')),
673
787
  ),
674
788
  ),
675
789
 
@@ -690,12 +804,85 @@ window.__ModuleLoader__.load({
690
804
  ? h(Alert, { tone: 'danger', title: t('diagLastError') }, h('p', { className: 'tcr-mono' }, tailcat.lastError))
691
805
  : null,
692
806
 
807
+ !binaryMissing && systemFound && systemCompatible && !installer?.installed
808
+ ? h(
809
+ Alert,
810
+ { tone: 'info', title: t('installDetected') },
811
+ h('p', null, t('installDetectedBody', { version: system.version ?? t('unknown'), path: system.path })),
812
+ )
813
+ : null,
814
+
693
815
  binaryMissing
694
816
  ? h(
695
817
  Card,
696
- { title: t('setupTitle'), subtitle: t('setupBody') },
697
- h('p', { className: 'tcr-hint' }, t('installHint')),
698
- h('div', { className: 'tcr-actions' }, h(Button, { variant: 'primary', disabled: Boolean(busy), onClick: () => void act('restart', {}, 'noticeRestarted') }, t('setupRetry'))),
818
+ {
819
+ title: systemFound && systemCompatible ? t('installDetected') : t('setupTitle'),
820
+ subtitle: systemFound
821
+ ? systemCompatible
822
+ ? t('installDetectedBody', { version: system.version ?? t('unknown'), path: system.path })
823
+ : t(installer?.method === 'brew' ? 'installSystemOutdatedBrew' : 'installSystemOutdated', { version: system.version ?? t('unknown') })
824
+ : system?.status === 'checking' || !system
825
+ ? t('installChecking')
826
+ : t('setupBody'),
827
+ },
828
+ !systemFound
829
+ ? h('p', { className: 'tcr-hint' }, t('installHint'))
830
+ : null,
831
+ configOverride
832
+ ? h(Alert, { tone: 'warn', title: t('setupTitle') }, t('installConfigOverride', { path: snapshot.config.binaryPath }))
833
+ : null,
834
+ (!systemFound || !systemCompatible) && installer?.supported && !configOverride
835
+ ? h(
836
+ 'p',
837
+ { className: 'tcr-hint' },
838
+ installer.method === 'brew'
839
+ ? t('installMethodBrew', { command: installer.command })
840
+ : t('installMethodDownload', { asset: installer.asset ?? 'tailcat' }),
841
+ )
842
+ : null,
843
+ !installer?.supported
844
+ ? h(Alert, { tone: 'warn' }, t('installUnsupported', { platform: installer?.platform ?? 'unknown', arch: installer?.arch ?? 'unknown' }))
845
+ : null,
846
+ installer?.error
847
+ ? h(Alert, { tone: 'danger', title: t('installFailed') }, h('p', { className: 'tcr-mono' }, installer.error))
848
+ : null,
849
+ installerBusy ? installProgress : null,
850
+ h(
851
+ 'div',
852
+ { className: 'tcr-actions' },
853
+ (!systemFound || !systemCompatible) && installer?.supported && !configOverride
854
+ ? h(
855
+ Button,
856
+ {
857
+ variant: 'primary',
858
+ disabled: installerBusy,
859
+ onClick: () => void act('install', {}, 'noticeInstalled'),
860
+ },
861
+ installerBusy ? t('installBusy') : installer?.installed ? t('installReinstall') : t('installButton'),
862
+ )
863
+ : null,
864
+ h(
865
+ Button,
866
+ { variant: 'ghost', disabled: installerBusy, onClick: () => void act('restart', {}, 'noticeRestarted') },
867
+ t('setupRetry'),
868
+ ),
869
+ installer?.manualUrl
870
+ ? h(
871
+ 'a',
872
+ {
873
+ className: 'tcr-btn tcr-btn-ghost',
874
+ href: installer.manualUrl,
875
+ target: '_blank',
876
+ rel: 'noopener noreferrer',
877
+ style: { textDecoration: 'none' },
878
+ },
879
+ t('installManual'),
880
+ )
881
+ : null,
882
+ ),
883
+ installer?.installed && installer.binaryPath
884
+ ? h('p', { className: 'tcr-hint' }, t('installManagedNote', { path: installer.binaryPath }))
885
+ : null,
699
886
  )
700
887
  : null,
701
888
 
@@ -827,6 +1014,8 @@ window.__ModuleLoader__.load({
827
1014
  h(Row, { label: t('diagKeyName') }, h('span', { className: 'tcr-mono' }, tailcat.keyName)),
828
1015
  h(Row, { label: t('diagVersion') }, tailcat.binary?.version ?? t('unknown')),
829
1016
  h(Row, { label: t('diagBinary') }, h('span', { className: 'tcr-mono' }, tailcat.binary?.resolved ?? snapshot.config.binaryPath)),
1017
+ h(Row, { label: t('diagBinarySource') }, sourceLabel),
1018
+ h(Row, { label: t('diagInstallSource') }, installer?.installed ? `${t('sourceManaged')} · ${installer.installedVersion ?? t('unknown')}` : systemFound ? `${t('sourcePath')} · ${system.version ?? t('unknown')}` : t('sourceUnavailable')),
830
1019
  h(Row, { label: t('diagRegion') }, tailcat.region ? `${tailcat.region.name} (${tailcat.region.id})` : t('unknown')),
831
1020
  h(Row, { label: t('diagRestarts') }, String(tailcat.restarts ?? 0)),
832
1021
  h(Row, { label: t('diagDoor') }, snapshot.door.mode === 'socket' ? `${t('modeSocket')} · ${snapshot.door.socketPath}` : `${t('modeTcp')} · 127.0.0.1:${snapshot.door.port}`),
@@ -952,6 +1141,17 @@ window.__ModuleLoader__.load({
952
1141
  return `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1_000)}s`;
953
1142
  }
954
1143
 
1144
+ /**
1145
+ * @param {number | null | undefined} bytes - byte count.
1146
+ * @returns {string} compact size for installer progress.
1147
+ */
1148
+ function formatBytes(bytes) {
1149
+ if (typeof bytes !== 'number' || !Number.isFinite(bytes) || bytes <= 0) return '0 B';
1150
+ if (bytes < 1_024) return `${bytes} B`;
1151
+ if (bytes < 1_048_576) return `${(bytes / 1_024).toFixed(1)} KB`;
1152
+ return `${(bytes / 1_048_576).toFixed(1)} MB`;
1153
+ }
1154
+
955
1155
  /**
956
1156
  * @param {string | null | undefined} iso - timestamp.
957
1157
  * @returns {string} local clock time.
package/cordis.patch.yml CHANGED
@@ -12,8 +12,9 @@
12
12
  # Host root realm instead of an `isolate` group.
13
13
  #
14
14
  # Every field below is optional. Defaults are chosen for the common case
15
- # (Unix-socket door, saved stable key, allow-list off). Uncomment a field only
16
- # when the machine needs a different placement.
15
+ # (Unix-socket door on Linux/macOS, loopback TCP on Windows; saved stable key;
16
+ # allow-list off). Uncomment a field only when the machine needs a different
17
+ # placement.
17
18
  #
18
19
  # - insert:
19
20
  # - id: dsh-tailcat-remote
@@ -21,7 +22,7 @@
21
22
  # config:
22
23
  # binaryPath: tailcat # PATH name or absolute path
23
24
  # port: 13080 # virtual port inside tailcat
24
- # listen: socket # socket | tcp
25
+ # listen: socket # socket | tcp; Windows defaults to tcp
25
26
  # socketPath: '' # empty = $DSH_HOME/tailcat-remote.sock
26
27
  # keyName: dsh-tailcat # saved tailcat key name (or path)
27
28
  # addressMode: stable # stable | ephemeral
package/docs/CONTRACT.md CHANGED
@@ -15,7 +15,7 @@
15
15
  ```json
16
16
  {
17
17
  "ok": true,
18
- "plugin": { "name": "@ds-hu/dsh-tailcat-remote", "version": "0.1.0" },
18
+ "plugin": { "name": "@ds-hu/dsh-tailcat-remote", "version": "0.1.1" },
19
19
  "now": "2026-11-24T16:22:50.998Z",
20
20
  "web": { "protocol": "http:", "port": 3080 },
21
21
  "config": {
@@ -52,7 +52,7 @@
52
52
  "listen": "socket",
53
53
  "endpoint": { "mode": "socket", "socketPath": "/home/you/.dsh/tailcat-remote.sock" },
54
54
  "region": { "id": 304, "name": "Tokyo" },
55
- "binary": { "requested": "tailcat", "resolved": "/usr/local/bin/tailcat", "version": "v0.8.0", "error": null },
55
+ "binary": { "requested": "tailcat", "resolved": "/usr/local/bin/tailcat", "source": "path", "version": "v0.8.0", "error": null },
56
56
  "restarts": 0,
57
57
  "lastError": null,
58
58
  "lastExit": null,
@@ -75,6 +75,32 @@
75
75
  "onlineAt": "2026-11-24T16:22:02.000Z",
76
76
  "nextRestartAt": null
77
77
  },
78
+ "installer": {
79
+ "supported": true,
80
+ "method": "archive",
81
+ "platform": "linux",
82
+ "arch": "x64",
83
+ "version": "0.8.0",
84
+ "installed": false,
85
+ "installedVersion": null,
86
+ "installedAt": null,
87
+ "source": null,
88
+ "binaryPath": "/home/you/.dsh/tailcat-remote/bin/tailcat",
89
+ "asset": "tailcat_0.8.0_linux_amd64.tar.gz",
90
+ "command": null,
91
+ "manualUrl": "https://github.com/tailscale/tailcat#install",
92
+ "busy": false,
93
+ "phase": "idle",
94
+ "progress": null,
95
+ "error": null,
96
+ "system": {
97
+ "status": "found",
98
+ "path": "/usr/local/bin/tailcat",
99
+ "version": "v0.8.0",
100
+ "compatible": true,
101
+ "checkedAt": "2026-11-24T16:22:01.000Z"
102
+ }
103
+ },
78
104
  "devices": {
79
105
  "allow": [],
80
106
  "enforced": false,
@@ -98,6 +124,17 @@
98
124
 
99
125
  `tailcat.phase` 的取值:`stopped`、`starting`、`online`、`stopping`、`restarting`、`error`。
100
126
 
127
+ `tailcat.binary.source` 的取值:`managed`(受管安装)、`path`(PATH 或常见安装位置)、`config`(显式 `binaryPath`)。
128
+
129
+ `installer` 是安装器的只读状态:
130
+
131
+ - `system.status`:`checking`、`found`、`missing`。`found` 表示用户已经装了 tailcat,插件会直接使用;
132
+ - `system.compatible`:`true`/`false`/`null`。`false` 表示检测到的版本低于 0.8.0(缺少 Unix-socket serve / `--log` 等本插件依赖的能力),面板会改为提供受管安装;
133
+ - `supported` / `method`:当前平台是否能自动安装,`archive` 或 `brew`;
134
+ - `phase`:`idle`、`starting`、`checksums`、`downloading`、`verifying`、`extracting`、`installing`、`homebrew`、`done`、`error`;
135
+ - `progress`:下载时的 `{ phase, received, total, percent }`,其余阶段为 `null`;
136
+ - `installed` 表示受管目录里已有可执行文件,不代表系统检测结果。
137
+
101
138
  ## POST
102
139
 
103
140
  请求体必须包含 `action`。动作串行执行;`start` 会先确保 door 可用。
@@ -109,11 +146,13 @@
109
146
  | `restart` | — | 停掉再用当前配置启动;地址通常不变 | 新进程、`restarts` 递增 |
110
147
  | `rotate` | — | 覆盖保存密钥、重启、等新地址上线 | `tailcat.address` 改变,旧地址失效 |
111
148
  | `devices` | `allow: string[]` | 规范化并持久化白名单;运行中的 tailcat 会重启以应用 | `devices.enforced` / `count` 更新 |
149
+ | `install` | `force?: boolean` | 安装受管 tailcat。默认会跳过已有受管副本;`force` 强制重新安装。隧道若在运行会短暂停止,成功后按原状态恢复 | `installer.*` 与 `tailcat.binary.source` 更新 |
112
150
 
113
151
  示例:
114
152
 
115
153
  ```json
116
154
  { "action": "devices", "allow": ["nodekey:…64 hex…"] }
155
+ { "action": "install", "force": true }
117
156
  ```
118
157
 
119
158
  `allow: []` 表示仅凭地址访问;非空数组会变成 `tailcat serve --allow=…`。
@@ -131,11 +170,16 @@
131
170
  | 409 | `door-tls-unsupported` | Web listener 是 HTTPS |
132
171
  | 413 | `body-too-large` | 请求体超过 64 KiB |
133
172
  | 500 | `internal` | 未预期错误 |
173
+ | 400 | `tailcat-platform-unsupported` | 当前 OS/架构没有自动安装目标 |
174
+ | 409 | `tailcat-binary-overridden` | `binaryPath` 是显式路径,受管安装不会生效 |
175
+ | 502 | `tailcat-download-failed` / `tailcat-checksum-*` / `tailcat-archive-invalid` | 下载、校验或解压失败 |
134
176
  | 503 | `tailcat-not-found` / `tailcat-spawn-failed` | tailcat 找不到或无法启动 |
177
+ | 503 | `tailcat-brew-missing` / `tailcat-extract-unavailable` | macOS 没有 Homebrew,或系统没有解压能力 |
178
+ | 503 | `tailcat-version-too-old` | 检测到/安装到的 tailcat 低于 0.8.0,缺少本插件依赖的能力 |
135
179
  | 503 | `door-listen-failed` / `door-socket-missing` | door 未监听或 socket 丢失 |
136
180
  | 503 | `disposed` | 插件正在卸载 |
137
181
 
138
- `tailcat-not-found` 的 message 会包含 `binaryPath` 与底层解析错误;面板用 `tailcat.binary.resolved === null && tailcat.phase === "error"` 识别安装提示。
182
+ `tailcat-not-found` 的 message 会包含 `binaryPath` 与底层解析错误;面板用 `tailcat.binary.resolved === null && tailcat.phase === "error"` 识别安装提示。面板只在 `installer.supported` 为真、没有显式 `binaryPath` 覆盖、且(没有检测到系统 tailcat 或检测到的版本低于 0.8.0)时显示安装按钮;检测到可用的系统 tailcat 时不会再诱导用户下载。
139
183
 
140
184
  ## 兼容性
141
185
 
package/docs/SECURITY.md CHANGED
@@ -12,7 +12,7 @@ tailcat DERP / 直连(加密)
12
12
  │
13
13
  ▼
14
14
  tailcat serve(本机进程)
15
- │ 13080 → Unix socket 0600
15
+ │ 13080 → Unix socket 0600(Windows 默认回环 TCP)
16
16
  ▼
17
17
  Door ──► DSH Connection(cookie、Host、Origin、owner)
18
18
  │
@@ -21,7 +21,7 @@ DSH Web / API / WebSocket
21
21
  ```
22
22
 
23
23
  - **Door 不是公网监听。** 默认只创建 `$DSH_HOME/tailcat-remote.sock`(0600),本机其他用户不能连接;同用户的本地进程可以连接,这是本机进程信任模型的自然结果。
24
- - **tailcat 是唯一的入口。** 插件不打开 TCP 端口。只有 `tailcat serve` 能把虚拟端口 13080 映射到 door。
24
+ - **tailcat 是唯一的隧道入口。** Linux/macOS 上插件不打开 TCP 端口;Windows 上 tailcat 不支持 Unix socket 目标,door 绑定 `127.0.0.1` 的 TCP 端口,仍不对局域网开放。只有 `tailcat serve` 能把虚拟端口 13080 映射到 door。
25
25
  - **鉴权仍由 DSH 负责。** Door 不做自己的账号体系,也不把 remote 标成 owner;它让 DSH 对远程请求执行同一套 `requestRejection` / cookie 判断。
26
26
  - **地址是一份凭据。** tailcat 地址本身足以建立隧道;没有设备白名单时,拿到地址就能到达 DSH 登录入口,再由 DSH 的 cookie 机制决定会话。地址应当按密码对待。
27
27
 
@@ -57,22 +57,35 @@ tailcat genkey --client --key=client-default
57
57
 
58
58
  只做第 1 步不足以让已拿到 cookie 的攻击者下线。
59
59
 
60
+ ## 受管安装的信任边界
61
+
62
+ “一键安装”不是静默更新,也不是把第三方二进制塞进 npm 包。它的信任链如下:
63
+
64
+ - **只在用户点击时联网。** 插件没有 postinstall 脚本,不会在后台下载;安装动作必须在面板点击,或在已认证的 owner API 上显式调用 `install`。
65
+ - **Linux / Windows:** 从 `https://github.com/tailscale/tailcat/releases/tag/v0.8.0` 下载与当前 `process.platform`/`process.arch` 对应的官方资产,并从同一个 release 读取 `checksums.txt`。下载完成后先校验 SHA-256,校验不通过就删除临时文件并保留旧版本。HTTPS 保护传输,校验值保护下载完整性;如果上游 release 本身被攻破,校验值也会一起被改,插件无法提供超过上游的保证。
66
+ - **macOS:** 先执行 `brew update`,再通过 Homebrew 安装/升级 `tailcat` formula;信任 Homebrew 的 formula、bottle 或源码构建链。没有 Homebrew 时不会尝试其他来源,而是提示手动安装。
67
+ - **用户已有的 tailcat:** 检测和正常启动只读取、探测 `PATH`、Homebrew 前缀等常见位置,不移动、不覆盖、不升级。检测到 0.8.0 或更新的系统版本时,面板不再显示下载按钮;更旧的版本会被标为不兼容。只有用户点击安装后,macOS 才会通过 Homebrew 升级过旧的系统 formula(因为 macOS 没有官方静态二进制),Linux/Windows 则新建受管副本、不动系统安装。
68
+ - **写入位置:** 受管可执行文件固定在 `$DSH_HOME/tailcat-remote/bin/tailcat`(Windows 为 `tailcat.exe`),模式 0755;临时下载目录权限 0700;元数据 `tailcat.json` 权限 0600;替换采用同目录备份 + 原子 rename。系统 `PATH` 不会被修改,也不会向系统目录写入任何文件。
69
+ - **执行权限:** 受管 tailcat 与 Host 使用同一个 OS 用户运行,因此拥有该用户的权限。不要把 `binaryPath` 指向可被其他用户写入的路径。
70
+
71
+ 受管安装的 tailcat 遵循上游 BSD-3-Clause 许可,归属见 [NOTICE](../NOTICE)。
72
+
60
73
  ## 已知限制
61
74
 
62
75
  - **Door 只支持明文 HTTP 的 Web listener。** 如果 DSH 配置了 TLS,插件拒绝启动 door(`door-tls-unsupported`)。原因是没有可重放的 `Set-Cookie` 语义:远程客户端看到的是 `http://127.0.0.1:18080`,把 `Secure` cookie 直接搬过去会失效。要在 TLS 场景使用,应让 tailcat 映射到一个明确终止 TLS 的反向代理,并单独评估 cookie 属性;当前版本不提供这个模式。
63
- - **`listen: tcp` 会扩大本机可达面。** 绑定 `127.0.0.1` 后,本机任何进程都能访问 door;Unix socket 0600 是默认值。除非 Unix socket 不可用,不要改成 tcp。
64
- - **tailcat 自身的信任假设。** 插件信任 tailcat 二进制、它的 DERP map、本机代理配置和本机用户环境。请从可信来源安装 tailcat,并保持更新。
76
+ - **`listen: tcp` 会扩大本机可达面。** 绑定 `127.0.0.1` 后,本机任何进程都能访问 door;Unix socket 0600 是 Linux/macOS 的默认值。Windows 因 tailcat 不支持 Unix socket 目标而默认 tcp;不要把该端口转发到局域网。
77
+ - **tailcat 自身的信任假设。** 插件信任 tailcat 二进制、它的 DERP map、本机代理配置和本机用户环境。请从可信来源安装 tailcat,并保持更新;Unix-socket door 和 `--log` 需要 tailcat 0.8.0 或更新。
65
78
  - **访问日志是诊断数据。** `--log` 会记录 peer 公钥前缀/后缀、端口、路径和时长;插件对地址和完整 nodekey 做脱敏,但日志仍可能透露连接时间与设备数量。关闭 `logAccess` 可减少记录。
66
79
  - **二维码等同地址。** 二维码只编码 tailcat 地址;截图、投屏或转发二维码与转发地址等价。
67
80
  - **本插件没有经过独立安全审计。** 它复用 DSH 的认证路径,但没有形式化验证。
68
81
 
69
82
  ## 推荐配置
70
83
 
71
- 1. 保持默认的 Unix socket door,不要直接暴露 3080。
84
+ 1. Linux/macOS 保持默认的 Unix socket door;Windows 使用默认的 `127.0.0.1` TCP door。不要直接暴露 3080,也不要把 door 端口转发到局域网。
72
85
  2. 在分享地址前添加至少一个设备公钥;面板的红色警告消失后再继续。
73
86
  3. 用 `stable` 地址模式;需要轮换时用面板按钮,不要手改密钥文件。
74
87
  4. 不要把地址、二维码或带 `nodekey:` 的日志贴到公开 issue;需要贴日志时先脱敏。
75
- 5. 只从官方发行版或可信包管理器安装 tailcat。
88
+ 5. 优先使用面板的受管安装,或只从官方发行版/可信包管理器安装 tailcat;安装后在诊断区核对来源、版本和路径。
76
89
  6. 在不再需要远程访问时,在面板停止隧道,或停用插件。
77
90
 
78
91
  ## 报告问题