better-dsh-pet 0.3.3 → 0.3.4
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 +5 -4
- package/package.json +1 -1
- package/scripts/download-sensevoice.mjs +46 -24
- package/scripts/ensure-electron.mjs +48 -26
package/README.md
CHANGED
|
@@ -277,7 +277,7 @@ dsh plugin --profile web add better-dsh-pet
|
|
|
277
277
|
> 如果刚发布新版本不到 24 小时,pnpm 11 的 `minimumReleaseAge` 安全策略可能不会自动选最新版,而是退回旧版。此时请指定精确版本安装:
|
|
278
278
|
>
|
|
279
279
|
> ```bash
|
|
280
|
-
> dsh plugin --profile web add better-dsh-pet@0.3.
|
|
280
|
+
> dsh plugin --profile web add better-dsh-pet@0.3.4
|
|
281
281
|
> ```
|
|
282
282
|
>
|
|
283
283
|
> pnpm 会自动把该版本加入 `minimumReleaseAgeExclude` 并完成安装;也可以等待 24 小时后直接用上面的普通命令。
|
|
@@ -391,8 +391,9 @@ Remove-Item "C:\Users\Administrator\.dsh\voice" -Recurse -Force
|
|
|
391
391
|
- **Electron 解压报“文件正由另一进程使用”**:
|
|
392
392
|
- 先关闭 DSH / 桌宠,再重新下载;
|
|
393
393
|
- 或手动运行 `ensure-electron.mjs`。
|
|
394
|
-
- **语音模型一直 0% /
|
|
395
|
-
-
|
|
394
|
+
- **语音模型一直 0% / 进度条半天不动**:
|
|
395
|
+
- 脚本会在 30 秒无数据后自动切换到下一个镜像;
|
|
396
|
+
- 如果所有镜像都失败才会报错;
|
|
396
397
|
- 也可以手动指定镜像:
|
|
397
398
|
```powershell
|
|
398
399
|
$env:DSH_VOICE_MODEL_URL = "https://ghfast.top/https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2024-07-17.tar.bz2"
|
|
@@ -401,7 +402,7 @@ Remove-Item "C:\Users\Administrator\.dsh\voice" -Recurse -Force
|
|
|
401
402
|
- **升级时提示 EPERM**:
|
|
402
403
|
- 先完全退出 DSH / 桌宠,再执行:
|
|
403
404
|
```bash
|
|
404
|
-
dsh plugin --profile web add better-dsh-pet@0.3.
|
|
405
|
+
dsh plugin --profile web add better-dsh-pet@0.3.4
|
|
405
406
|
```
|
|
406
407
|
|
|
407
408
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-dsh-pet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "A desktop-native pet bubble driven by DeepSeek Harness session events: transparent always-on-top Electron window, status-aware animations, voice chat/wake, real DSH task execution, emotion, festival, balance, pomodoro, roast, and DSH settings card.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -66,31 +66,53 @@ function hasModel() {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
async function download(url, dest, label = 'download') {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
const controller = new AbortController()
|
|
70
|
+
let connected = false
|
|
71
|
+
let lastChunkAt = Date.now()
|
|
72
|
+
const connectTimer = setTimeout(() => {
|
|
73
|
+
if (!connected) controller.abort(new Error('连接超时(30秒未响应)'))
|
|
74
|
+
}, 30000)
|
|
75
|
+
let stallTimer
|
|
76
|
+
try {
|
|
77
|
+
log(`[${label}] 等待响应...`)
|
|
78
|
+
const response = await fetch(url, { redirect: 'follow', signal: controller.signal })
|
|
79
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} ${response.statusText}`)
|
|
80
|
+
connected = true
|
|
81
|
+
clearTimeout(connectTimer)
|
|
82
|
+
const total = Number(response.headers.get('content-length')) || 0
|
|
83
|
+
let received = 0
|
|
84
|
+
let lastLoggedAt = 0
|
|
85
|
+
let lastPercent = -1
|
|
86
|
+
lastChunkAt = Date.now()
|
|
87
|
+
stallTimer = setInterval(() => {
|
|
88
|
+
if (Date.now() - lastChunkAt > 30000) {
|
|
89
|
+
controller.abort(new Error('下载停滞(30秒无数据)'))
|
|
88
90
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
}, 5000)
|
|
92
|
+
const progress = new Transform({
|
|
93
|
+
transform(chunk, _encoding, callback) {
|
|
94
|
+
received += chunk.length
|
|
95
|
+
lastChunkAt = Date.now()
|
|
96
|
+
const percent = total ? Math.floor((received / total) * 100) : 0
|
|
97
|
+
const shouldLog = total
|
|
98
|
+
? (percent !== lastPercent && (percent % 10 === 0 || percent === 100))
|
|
99
|
+
: (received - lastLoggedAt >= 10 * 1024 * 1024)
|
|
100
|
+
if (shouldLog) {
|
|
101
|
+
lastPercent = percent
|
|
102
|
+
lastLoggedAt = received
|
|
103
|
+
const mb = (received / 1024 / 1024).toFixed(1)
|
|
104
|
+
const totalMb = total ? ` / ${(total / 1024 / 1024).toFixed(1)}MB` : ''
|
|
105
|
+
log(`[${label}] ${total ? `${percent}%` : mb} (${mb}MB${totalMb})`)
|
|
106
|
+
}
|
|
107
|
+
callback(null, chunk)
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
await pipeline(response.body, progress, createWriteStream(dest))
|
|
111
|
+
log(`[${label}] 下载完成:${(received / 1024 / 1024).toFixed(1)}MB`)
|
|
112
|
+
} finally {
|
|
113
|
+
clearTimeout(connectTimer)
|
|
114
|
+
if (stallTimer) clearInterval(stallTimer)
|
|
115
|
+
}
|
|
94
116
|
}
|
|
95
117
|
|
|
96
118
|
function extract(archive, target) {
|
|
@@ -67,33 +67,55 @@ function log(msg) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async function download(url, dest, label = 'download') {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
const controller = new AbortController()
|
|
71
|
+
let connected = false
|
|
72
|
+
let lastChunkAt = Date.now()
|
|
73
|
+
const connectTimer = setTimeout(() => {
|
|
74
|
+
if (!connected) controller.abort(new Error('连接超时(30秒未响应)'))
|
|
75
|
+
}, 30000)
|
|
76
|
+
let stallTimer
|
|
77
|
+
try {
|
|
78
|
+
log(`[${label}] 等待响应...`)
|
|
79
|
+
const response = await fetch(url, { redirect: 'follow', signal: controller.signal })
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
throw new Error(`download failed: ${response.status} ${response.statusText} (${url})`)
|
|
82
|
+
}
|
|
83
|
+
connected = true
|
|
84
|
+
clearTimeout(connectTimer)
|
|
85
|
+
const total = Number(response.headers.get('content-length')) || 0
|
|
86
|
+
let received = 0
|
|
87
|
+
let lastLoggedAt = 0
|
|
88
|
+
let lastPercent = -1
|
|
89
|
+
lastChunkAt = Date.now()
|
|
90
|
+
stallTimer = setInterval(() => {
|
|
91
|
+
if (Date.now() - lastChunkAt > 30000) {
|
|
92
|
+
controller.abort(new Error('下载停滞(30秒无数据)'))
|
|
91
93
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
}, 5000)
|
|
95
|
+
const progress = new Transform({
|
|
96
|
+
transform(chunk, _encoding, callback) {
|
|
97
|
+
received += chunk.length
|
|
98
|
+
lastChunkAt = Date.now()
|
|
99
|
+
const percent = total ? Math.floor((received / total) * 100) : 0
|
|
100
|
+
const shouldLog = total
|
|
101
|
+
? (percent !== lastPercent && (percent % 10 === 0 || percent === 100))
|
|
102
|
+
: (received - lastLoggedAt >= 10 * 1024 * 1024)
|
|
103
|
+
if (shouldLog) {
|
|
104
|
+
lastPercent = percent
|
|
105
|
+
lastLoggedAt = received
|
|
106
|
+
const mb = (received / 1024 / 1024).toFixed(1)
|
|
107
|
+
const totalMb = total ? ` / ${(total / 1024 / 1024).toFixed(1)}MB` : ''
|
|
108
|
+
log(`[${label}] ${total ? `${percent}%` : mb} (${mb}MB${totalMb})`)
|
|
109
|
+
}
|
|
110
|
+
callback(null, chunk)
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
await pipeline(response.body, progress, createWriteStream(dest))
|
|
114
|
+
log(`[${label}] 下载完成:${(received / 1024 / 1024).toFixed(1)}MB`)
|
|
115
|
+
} finally {
|
|
116
|
+
clearTimeout(connectTimer)
|
|
117
|
+
if (stallTimer) clearInterval(stallTimer)
|
|
118
|
+
}
|
|
97
119
|
}
|
|
98
120
|
|
|
99
121
|
function extractZip(zipPath, targetDir) {
|