@wendongfly/myhi 1.3.127 → 1.3.128
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 +6 -0
- package/installer/README.md +20 -6
- package/installer/gateway.json.example +6 -0
- package/installer/install-myhi.ps1 +25 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,12 @@ npm install -g @wendongfly/myhi
|
|
|
32
32
|
|
|
33
33
|
需要 Node.js >= 18。
|
|
34
34
|
|
|
35
|
+
> **新版 npm 注意**:若看到 `npm warn allow-scripts`(新版 npm 默认拦包的安装脚本),说明 `node-pty` 的原生模块脚本被跳过、终端可能受影响。加参数放行即可:
|
|
36
|
+
> ```bash
|
|
37
|
+
> npm install -g @wendongfly/myhi --allow-scripts=@wendongfly/myhi,node-pty
|
|
38
|
+
> ```
|
|
39
|
+
> 或本机一次性放行:`npm config set allow-scripts=@wendongfly/myhi,node-pty --location=user`。用下面的 Windows 安装器则已自动处理,无需手动加。
|
|
40
|
+
|
|
35
41
|
### Windows 傻瓜安装(给普通员工,免命令行)
|
|
36
42
|
|
|
37
43
|
不想让员工碰终端?用 `installer/` 里的一键安装:右键 **`Install-myhi.bat` → 以管理员身份运行**,它会自动装 Node(缺则 winget 装)、装/更新 myhi、**注册计划任务实现开机登录自启(脱离会话、无黑窗、普通权限)**、放行防火墙、建桌面「myhi 控制台」快捷方式。装完开机登录即自动后台运行,员工只管点桌面图标用。详见 [`installer/README.md`](installer/README.md)。
|
package/installer/README.md
CHANGED
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
|
|
16
16
|
卸载:右键 **`Uninstall-myhi.bat` → 以管理员身份运行**(撤销自启/防火墙/快捷方式;保留 myhi 本体与数据)。
|
|
17
17
|
|
|
18
|
+
## 批量部署很多新电脑(一次配好、台台开箱即用)
|
|
19
|
+
|
|
20
|
+
安装器已经把**依赖一起装了**:Node(缺则 winget 装)+ **Claude CLI**(AI 引擎)+ myhi。要让新机**连 AI 都免配、开箱即用**,管理员只需在部署包里预置一份网关配置:
|
|
21
|
+
|
|
22
|
+
1. 把 `installer/gateway.json.example` 复制成 **`gateway.json`**,填入你的 AI 网关 `baseUrl` 和 `apiKey`,放在 installer 文件夹里。
|
|
23
|
+
2. 把整个文件夹(含 `gateway.json`)打包发到各新机。
|
|
24
|
+
3. 每台机右键 `Install-myhi.bat`(或 `Install-myhi-headless.bat`)以管理员运行 → 自动装好 node/claude/myhi + **把 gateway.json 部署到 `~/.myhi/`** → AI 直接能用。
|
|
25
|
+
|
|
26
|
+
> 🔒 `gateway.json` 含密钥,已被 `.gitignore` 忽略、**绝不进 git**;只在你的部署包/各机本地之间流转。不预置也行——那样各机装完需在 `~/.myhi/gateway.json` 手动填 `{"baseUrl":"...","apiKey":"..."}`(或在网页里配)后 AI 才可用。
|
|
27
|
+
|
|
28
|
+
> 还没做的(可后续加):预置登录密码、预置密钥库 `secrets.json`。需要的话告诉我。
|
|
29
|
+
|
|
18
30
|
## 升级怎么做
|
|
19
31
|
|
|
20
32
|
myhi 有两条升级路径,都不需要员工敲命令:
|
|
@@ -29,12 +41,14 @@ myhi 有两条升级路径,都不需要员工敲命令:
|
|
|
29
41
|
`install-myhi.ps1`:
|
|
30
42
|
|
|
31
43
|
1. **Node**:没有就 `winget install OpenJS.NodeJS.LTS` 自动装;已有则用现成的。
|
|
32
|
-
2. **myhi**:`npm i -g @wendongfly/myhi@latest
|
|
33
|
-
3.
|
|
34
|
-
4.
|
|
35
|
-
5.
|
|
36
|
-
6.
|
|
37
|
-
7.
|
|
44
|
+
2. **myhi**:`npm i -g @wendongfly/myhi@latest --allow-scripts=@wendongfly/myhi,node-pty`(放行 node-pty 原生模块)。
|
|
45
|
+
3. **Claude CLI**(myhi 的 AI 引擎):`npm i -g @anthropic-ai/claude-code@latest`(加 `-SkipClaude` 可跳过)。
|
|
46
|
+
4. **隐藏启动器**:生成 `~/.myhi/myhi-launch.vbs`,用 `WScript.Shell.Run(cmd, 0, False)` **窗口隐藏**启动 `node bin/daemon.js`(无黑窗)。
|
|
47
|
+
5. **AI 网关配置**:若安装包目录随附 `gateway.json`(管理员预置),复制到 `~/.myhi/gateway.json`,AI 开箱即用。
|
|
48
|
+
6. **开机自启 = 计划任务**(Windows 上的「systemd 等价物」):`myhi-autostart`,**当前用户身份 + `RunLevel Limited`(非提权) + 脱离创建者会话**;触发方式按模式:默认「登录触发」,`-Headless` 则「开机触发 + S4U(无论是否登录)」。同时解决开机自启、登出/重启后存活、终端为普通权限(安全)。
|
|
49
|
+
7. **防火墙**:放行 TCP 12300/12301(Private/Domain),局域网手机平板可访问。
|
|
50
|
+
8. **快捷方式**:桌面 + 开始菜单 `myhi 控制台.url → https://localhost:12300`。
|
|
51
|
+
9. **立即启动**一次。
|
|
38
52
|
|
|
39
53
|
**升级**照旧走网页里的「更新」横幅(daemon 内建 `npm i -g @latest` + 重启,见 `bin/daemon.js`),员工点一下即可,无需碰命令行。
|
|
40
54
|
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
# 需以管理员运行(Install-myhi.bat 会自动提权)。
|
|
7
7
|
#Requires -Version 5
|
|
8
8
|
# -Headless:开机即运行(无论是否登录,用 S4U 免密码);不加则默认「登录时运行」(员工电脑场景)。
|
|
9
|
-
|
|
9
|
+
# -SkipClaude:不安装 Claude CLI(默认会装,myhi 的 AI 引擎)。
|
|
10
|
+
param([switch]$Headless, [switch]$SkipClaude)
|
|
10
11
|
|
|
11
12
|
$ErrorActionPreference = 'Stop'
|
|
12
13
|
$Port = 12300
|
|
@@ -68,6 +69,19 @@ try {
|
|
|
68
69
|
$npmRoot = (npm.cmd root -g | Select-Object -Last 1).ToString().Trim()
|
|
69
70
|
$ErrorActionPreference = $eaPrev
|
|
70
71
|
if ($npmExit -ne 0) { throw "npm 安装失败 (exit $npmExit)。若是 EBUSY,多为 myhi 仍在运行占用 pty.node,请关掉后重试。" }
|
|
72
|
+
|
|
73
|
+
# ---------- 2b) Claude Code CLI(myhi 的 AI 引擎,@anthropic-ai/claude-code)----------
|
|
74
|
+
if (-not $SkipClaude) {
|
|
75
|
+
Info "安装/更新 Claude CLI(npm i -g @anthropic-ai/claude-code@latest,稍候)..."
|
|
76
|
+
$eaC = $ErrorActionPreference; $ErrorActionPreference = 'Continue'
|
|
77
|
+
npm.cmd i -g '@anthropic-ai/claude-code@latest' --allow-scripts=@anthropic-ai/claude-code
|
|
78
|
+
if ($LASTEXITCODE -ne 0) { npm.cmd i -g '@anthropic-ai/claude-code@latest' }
|
|
79
|
+
$claudeExit = $LASTEXITCODE
|
|
80
|
+
$ErrorActionPreference = $eaC
|
|
81
|
+
# 不因 claude 装失败而中断整体部署(可事后手动补)
|
|
82
|
+
if ($claudeExit -eq 0) { Ok "Claude CLI 已安装" }
|
|
83
|
+
else { Warn "Claude CLI 安装失败(exit $claudeExit),可稍后手动:npm i -g @anthropic-ai/claude-code" }
|
|
84
|
+
}
|
|
71
85
|
$pkgDir = Join-Path $npmRoot '@wendongfly\myhi'
|
|
72
86
|
$daemon = Join-Path $pkgDir 'bin\daemon.js'
|
|
73
87
|
if (-not (Test-Path $daemon)) { throw "未找到 myhi 安装目录:$daemon" }
|
|
@@ -85,6 +99,16 @@ try {
|
|
|
85
99
|
[IO.File]::WriteAllText($vbs, $vbsBody, [Text.Encoding]::Default)
|
|
86
100
|
Ok "启动器:$vbs"
|
|
87
101
|
|
|
102
|
+
# 部署 AI 网关配置:若安装包目录随附 gateway.json(管理员预置,含 baseUrl/apiKey),复制到 ~/.myhi。
|
|
103
|
+
# 这样批量部署时 AI 开箱即用;此文件含密钥,只留本机、绝不进 git(见 installer/README 的批量部署)。
|
|
104
|
+
$gwSrc = Join-Path $PSScriptRoot 'gateway.json'
|
|
105
|
+
if (Test-Path $gwSrc) {
|
|
106
|
+
Copy-Item $gwSrc (Join-Path $cfgDir 'gateway.json') -Force
|
|
107
|
+
Ok "已部署 AI 网关配置(gateway.json → ~/.myhi,AI 开箱即用)"
|
|
108
|
+
} else {
|
|
109
|
+
Warn "未随附 gateway.json:AI 需部署后在 ~/.myhi/gateway.json 填 {\"baseUrl\":...,\"apiKey\":...} 才能用(见 README)"
|
|
110
|
+
}
|
|
111
|
+
|
|
88
112
|
# ---------- 4) 计划任务:登录触发 / 当前用户 / 非提权 / 脱离会话 ----------
|
|
89
113
|
# 用当前用户身份 + RunLevel Limited:myhi 里开的终端就是普通员工权限,不是管理员,避免提权面。
|
|
90
114
|
# 用规范账户名(机器名\用户 或 域\用户),Windows 能正确映射到 SID;
|
package/package.json
CHANGED