# dsh-lan-access

[![npm version](https://img.shields.io/npm/v/@woyeshishen/dsh-lan-access)](https://www.npmjs.com/package/@woyeshishen/dsh-lan-access)
[![license](https://img.shields.io/npm/l/@woyeshishen/dsh-lan-access)](LICENSE)

[English](README.md) | 中文

让 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)（DSH）的 Web GUI 绑定 `0.0.0.0`，使局域网内其他机器可以访问——同时注入 `crypto.randomUUID` polyfill，让纯 HTTP 局域网源下 GUI 完全可用——**不修改任何原始代码**。

## 特性

| | |
| --- | --- |
| 🌐 **局域网访问** | 通过 id 定向 config patch 把 Web GUI 重新绑定到 `0.0.0.0`。不传 `--host` flag，内置的 `0.0.0.0` 拦截逻辑不会触发 |
| 🛡️ **`crypto.randomUUID` polyfill** | 向 index.html 注入一段脚本，使非安全上下文（纯 HTTP 局域网源，该 Web API 不存在）下的 `/api` RPC 正常工作 |
| 🔓 **局域网访问特权方法** | 设置 / 凭据 / agent preset 也能从局域网使用（`allowRemotePrivileged`，默认开启） |
| 📦 **一次安装，长期有效** | 静态 bundle 自动挂载进 profile，随 DSH 启动加载，重启不丢 |

## 安装

### 一键安装（推荐）

**Windows（PowerShell）**

```powershell
irm https://raw.githubusercontent.com/woyeshishen/dsh-lan-access/main/scripts/install.ps1 | iex
```

**macOS / Linux**

```sh
bash <(curl -fsSL https://raw.githubusercontent.com/woyeshishen/dsh-lan-access/main/scripts/install.sh)
```

### dsh plugin 命令安装

**从 npm**

```sh
dsh plugin --profile web add @woyeshishen/dsh-lan-access
```

**从 GitHub**

```sh
dsh plugin --profile web add github:woyeshishen/dsh-lan-access
```

安装完成后，插件会自动挂载到 profile，重启 DSH（或热重载）即生效。

## 说明

- 绑定 host 由本插件 patch 固定为 `0.0.0.0`；如需调整请改 `cordis.patch.yml`。
- `--port` 仍然生效（patch 保留了 `!!js` 端口表达式）。
- 默认局域网受信任 Host 可访问特权 `/api` 方法（设置/凭据/agent preset，
  `allowRemotePrivileged: true`）；如需恢复"仅回环"，在 `lan-access` 行加
  `config: { allowRemotePrivileged: false }`。
- 卸载：`dsh plugin --profile web remove @woyeshishen/dsh-lan-access`
- 本插件刻意把远程代码执行面暴露到网络——请仅在可信内网使用。

## 开发

```sh
npm install
npm run build     # tsc -> lib/
npm run check     # 仅类型检查
npm run check:legacy   # cordis.patch.yml 结构健全性检查
```

## 许可证

[Apache-2.0](./LICENSE)
