better-dsh-pet 0.1.0 → 0.2.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/README.md +363 -68
- package/assets/thumb//344/270/211/347/220/203/346/212/233/346/216/245.webm +0 -0
- package/assets/thumb//344/270/213/344/272/224/345/255/220/346/243/213.webm +0 -0
- package/assets/thumb//344/270/234/345/274/240/350/245/277/346/234/233.webm +0 -0
- package/assets/thumb//344/270/255/347/247/213/350/265/217/346/234/210/345/220/203/346/234/210/351/245/274.webm +0 -0
- package/assets/thumb//344/274/230/351/233/205/345/245/263/344/273/206/350/210/236.webm +0 -0
- package/assets/thumb//345/201/267/345/220/203/351/233/266/351/243/237/350/242/253/346/212/223/344/275/217.webm +0 -0
- package/assets/thumb//345/206/231/344/273/243/347/240/201.webm +0 -0
- package/assets/thumb//345/206/231/347/246/217/345/255/227.webm +0 -0
- package/assets/thumb//345/207/255/347/251/272/347/224/237/350/212/261.webm +0 -0
- package/assets/thumb//345/212/250/347/211/251/347/216/257/347/273/225.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/344/270/223/345/277/203/347/216/251/351/255/224/346/226/271.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/345/260/217/346/206/251/346/262/211/347/234/240.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/345/267/246/350/275/254/345/245/224/350/267/221.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/346/225/262/345/207/273/346/241/214/351/235/242/344/272/222/345/212/250.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/346/274/202/346/265/256/350/270/217/346/255/245.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/350/267/263/350/267/203/346/212/223/347/242/216/345/244/264/351/241/266/347/211/251/345/223/201.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/350/271/262/344/270/213/347/216/251/347/216/251/345/205/267/346/261/275/350/275/246.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/351/207/215/345/212/233/344/270/213/350/271/262/345/216/213/347/274/251.webm +0 -0
- package/assets/thumb//345/217/230/351/270/275/345/255/220.webm +0 -0
- package/assets/thumb//345/217/257/347/210/261/345/256/205/350/210/236.webm +0 -0
- package/assets/thumb//345/220/203Token.webm +0 -0
- package/assets/thumb//345/220/203/345/206/260/346/267/207/346/267/213/350/236/215/345/214/226.webm +0 -0
- package/assets/thumb//345/220/203/345/215/210/351/244/220.webm +0 -0
- package/assets/thumb//345/220/203/345/244/247/351/227/270/350/237/271.webm +0 -0
- package/assets/thumb//345/220/203/345/271/264/347/263/225.webm +0 -0
- package/assets/thumb//345/220/203/346/227/251/351/244/220.webm +0 -0
- package/assets/thumb//345/220/203/346/231/232/351/244/220.webm +0 -0
- package/assets/thumb//345/220/203/346/261/244/345/234/206.webm +0 -0
- package/assets/thumb//345/220/203/347/231/275/351/245/255.webm +0 -0
- package/assets/thumb//345/220/203/347/262/275/345/255/220.webm +0 -0
- package/assets/thumb//345/220/203/347/263/226/350/221/253/350/212/246.webm +0 -0
- package/assets/thumb//345/220/203/350/205/212/345/205/253/347/262/245.webm +0 -0
- package/assets/thumb//345/220/203/350/245/277/347/223/234.webm +0 -0
- package/assets/thumb//345/220/203/351/207/215/351/230/263/347/263/225.webm +0 -0
- package/assets/thumb//345/220/203/351/225/277/345/257/277/351/235/242.webm +0 -0
- package/assets/thumb//345/220/203/351/235/222/345/233/242.webm +0 -0
- package/assets/thumb//345/220/203/351/245/272/345/255/220.webm +0 -0
- package/assets/thumb//345/220/271/346/260/224/347/220/203.webm +0 -0
- package/assets/thumb//345/220/271/347/254/233/345/255/220.webm +0 -0
- package/assets/thumb//345/223/210/346/254/240/350/277/236/345/244/251.webm +0 -0
- package/assets/thumb//345/240/206/351/233/252/344/272/272.webm +0 -0
- package/assets/thumb//345/244/247/345/217/243/345/220/203/351/233/266/351/243/237.webm +0 -0
- package/assets/thumb//345/245/263/344/273/206/345/261/210/350/206/235/347/244/274/344/273/252.webm +0 -0
- package/assets/thumb//345/260/217/345/271/205/345/272/246/345/216/237/345/234/260360/345/272/246/346/227/213/350/275/254/345/261/225/347/244/272.webm +0 -0
- package/assets/thumb//345/260/217/346/217/220/347/220/264/346/274/224/345/245/217.webm +0 -0
- package/assets/thumb//345/276/205/346/234/272/345/221/274/345/220/270/344/274/221/351/227/262.webm +0 -0
- package/assets/thumb//346/202/240/351/227/262/345/223/274/346/255/214.webm +0 -0
- package/assets/thumb//346/211/221/345/205/213/351/255/224/346/234/257.webm +0 -0
- package/assets/thumb//346/211/223/347/236/214/347/235/241/350/242/253/346/203/212/351/206/222.webm +0 -0
- package/assets/thumb//346/212/275/351/231/200/350/236/272.webm +0 -0
- package/assets/thumb//346/213/206/347/244/274/347/211/251.webm +0 -0
- package/assets/thumb//346/217/222/350/214/261/350/220/270/350/265/217/350/217/212.webm +0 -0
- package/assets/thumb//346/221/207/346/211/207/347/272/263/345/207/211.webm +0 -0
- package/assets/thumb//346/222/270/347/214/253.webm +0 -0
- package/assets/thumb//346/224/266/347/272/242/345/214/205.webm +0 -0
- package/assets/thumb//346/224/276/345/255/224/346/230/216/347/201/257.webm +0 -0
- package/assets/thumb//346/224/276/346/262/263/347/201/257.webm +0 -0
- package/assets/thumb//346/224/276/347/203/237/350/212/261.webm +0 -0
- package/assets/thumb//346/224/276/351/243/216/347/255/235.webm +0 -0
- package/assets/thumb//346/225/264/344/275/223/346/215/242/350/243/205/350/257/225/350/211/262.webm +0 -0
- package/assets/thumb//346/230/257/345/225/212/357/274/214/345/220/203/344/273/200/344/271/210.webm +0 -0
- package/assets/thumb//346/231/250/351/227/264/345/210/267/347/211/231.webm +0 -0
- package/assets/thumb//346/266/256/347/201/253/351/224/205.webm +0 -0
- package/assets/thumb//346/267/261/345/272/246/346/200/235/350/200/203/347/242/216/347/242/216/345/277/265.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/202/262/345/250/207/347/224/237/346/260/224.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/205/203/346/260/224/346/214/245/346/211/213.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/256/263/347/276/236/346/203/212/350/256/266.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/274/200/345/277/203/350/267/203/345/212/250.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/346/214/240/347/227/222/345/222/257/345/222/257/347/254/221.webm +0 -0
- package/assets/thumb//347/205/247/351/225/234/345/255/220.webm +0 -0
- package/assets/thumb//347/216/251/346/260/264/346/236/252.webm +0 -0
- package/assets/thumb//347/216/251/346/270/270/346/210/217/346/260/224/346/200/245/350/264/245/345/235/217.webm +0 -0
- package/assets/thumb//347/224/250/351/262/270/351/261/274/345/260/276/345/267/264/346/213/215/346/211/223/345/234/260/351/235/242.webm +0 -0
- package/assets/thumb//347/251/277/351/222/210/344/271/236/345/267/247.webm +0 -0
- package/assets/thumb//350/210/236/347/213/256/345/244/264.webm +0 -0
- package/assets/thumb//350/215/241/347/247/213/345/215/203.webm +0 -0
- package/assets/thumb//350/220/214/345/214/226/345/260/217/345/271/275/347/201/265.webm +0 -0
- package/assets/thumb//350/223/235/351/262/270/347/216/260/344/270/226.webm +0 -0
- package/assets/thumb//350/235/264/350/235/266/350/234/234/350/234/202/347/216/257/347/273/225/345/244/264/351/241/266/345/274/200/350/212/261.webm +0 -0
- package/assets/thumb//350/236/203/350/237/271/350/265/260/350/267/257.webm +0 -0
- package/assets/thumb//350/242/253/345/220/223/344/270/200/350/267/263.webm +0 -0
- package/assets/thumb//350/242/253/350/220/275/345/217/266/346/267/271/346/262/241.webm +0 -0
- package/assets/thumb//350/242/253/351/274/240/346/240/207/346/213/226/346/213/275/346/202/254/347/251/272/345/217/215/351/246/210.webm +0 -0
- package/assets/thumb//350/243/205/347/202/271/345/234/243/350/257/236/346/240/221.webm +0 -0
- package/assets/thumb//350/256/250/347/263/226/345/215/227/347/223/234/347/201/257.webm +0 -0
- package/assets/thumb//350/266/205/345/244/247/344/274/270/346/207/222/350/205/260.webm +0 -0
- package/assets/thumb//350/270/242/346/257/275/345/255/220.webm +0 -0
- package/assets/thumb//350/275/273/345/277/253/346/221/207/346/221/206/350/210/236.webm +0 -0
- package/assets/thumb//350/275/273/345/277/253/350/256/260/345/275/225.webm +0 -0
- package/assets/thumb//351/252/221/346/234/250/351/251/254.webm +0 -0
- package/assets/thumb//351/262/270/351/261/274/345/220/220/346/263/241/346/263/241/347/211/271/346/225/210.webm +0 -0
- package/cordis.patch.yml +6 -0
- package/lib/client.js +57 -5
- package/lib/index.js +33 -0
- package/lib/pet-helper-process.js +26 -2
- package/lib/types/client/index.d.ts +6 -0
- package/lib/types/index.d.ts +12 -0
- package/package.json +1 -1
- package/runtime/electron-helper/main.js +10 -0
- package/runtime/electron-helper/preload.js +3 -0
- package/runtime/electron-helper/renderer.js +473 -39
- package/assets/thumb//345/260/217/345/271/205/345/272/246/345/216/237/345/234/260 360 /345/272/246/346/227/213/350/275/254/345/261/225/347/244/272.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/202/262/345/250/207/347/224/237/346/260/224/357/274/210/344/276/247/350/272/253/345/261/225/347/244/272/357/274/211.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/256/263/347/276/236/346/203/212/350/256/266.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/274/200/345/277/203/350/267/203/345/212/250.webm +0 -0
- package/assets/thumb//350/242/253/345/220/223/344/270/200/350/267/263/357/274/210/347/202/270/346/257/233/357/274/211.webm +0 -0
- package/lib/index.js.bak-20260819-104008 +0 -483
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cordis.patch.yml
CHANGED
|
@@ -34,3 +34,9 @@
|
|
|
34
34
|
workMinutes: 25 # 番茄钟工作时长(分钟)
|
|
35
35
|
breakMinutes: 5 # 番茄钟休息时长(分钟)
|
|
36
36
|
roastEnabled: false # 根据本次对话自动吐槽(会消耗 Token)
|
|
37
|
+
walkEnabled: true # 待机时是否允许走动
|
|
38
|
+
enabledActions: [] # 自定义待机动作(留空=全部动作)
|
|
39
|
+
actionOrder: [] # 自定义待机动作播放顺序(留空=随机)
|
|
40
|
+
petSize: 460 # 宠物宽度(px)[patched: 462 非 10 倍数, schema step(10) 校验失败]
|
|
41
|
+
moveChance: 20 # 移动频繁度(百分比)
|
|
42
|
+
actionDelayMs: 0 # 动作切换间隔(毫秒)
|
package/lib/client.js
CHANGED
|
@@ -16,7 +16,7 @@ window.__ModuleLoader__.load({
|
|
|
16
16
|
const exports = module.exports
|
|
17
17
|
const React = require('react')
|
|
18
18
|
const { useEffect, useRef, useState } = React
|
|
19
|
-
const
|
|
19
|
+
const h = React.createElement
|
|
20
20
|
const CONFIG_ENDPOINT = '/plugins/better-dsh-pet/config'
|
|
21
21
|
|
|
22
22
|
const cardStyle = {
|
|
@@ -72,6 +72,7 @@ window.__ModuleLoader__.load({
|
|
|
72
72
|
function PetSettingsCard() {
|
|
73
73
|
const [status, setStatus] = useState('loading')
|
|
74
74
|
const [value, setValue] = useState({})
|
|
75
|
+
const [sizeDraft, setSizeDraft] = useState(null)
|
|
75
76
|
const [busy, setBusy] = useState(false)
|
|
76
77
|
const patchSeq = useRef(0)
|
|
77
78
|
const sliderTimers = useRef(new Map())
|
|
@@ -129,15 +130,15 @@ window.__ModuleLoader__.load({
|
|
|
129
130
|
|
|
130
131
|
return h('li', { style: cardStyle, 'data-testid': 'better-dsh-pet-settings' },
|
|
131
132
|
h('div', null,
|
|
132
|
-
h('strong', { style: { fontSize: 16 } }, '
|
|
133
|
-
h('p', { style: { margin: '5px 0 0', opacity: 0.72 } }, '
|
|
133
|
+
h('strong', { style: { fontSize: 16 } }, 'Better DSH Pet(大肥鱼增强版)'),
|
|
134
|
+
h('p', { style: { margin: '5px 0 0', opacity: 0.72 } }, '由 better-dsh-pet 提供:独立桌面气泡,DSH 状态联动、余额、番茄钟、吐槽、自定义动作。'),
|
|
134
135
|
),
|
|
135
136
|
status === 'unavailable'
|
|
136
|
-
? h('span', { role: 'status' }, '
|
|
137
|
+
? h('span', { role: 'status' }, 'Better DSH Pet 设置尚未连接到 DSH Host。')
|
|
137
138
|
: status === 'loading'
|
|
138
139
|
? h('span', null, '正在读取设置…')
|
|
139
140
|
: h(React.Fragment, null,
|
|
140
|
-
h(Field, { label: '
|
|
141
|
+
h(Field, { label: '启用 Better DSH Pet', hint: '关闭后立即退出桌面气泡;重新开启无需单独启动程序。' },
|
|
141
142
|
h('input', {
|
|
142
143
|
type: 'checkbox', checked: value.enabled !== false, disabled: !writable,
|
|
143
144
|
onChange: (event) => void write('enabled', event.target.checked),
|
|
@@ -150,6 +151,33 @@ window.__ModuleLoader__.load({
|
|
|
150
151
|
onChange: (event) => void writeSlider('scale', Number(event.target.value)),
|
|
151
152
|
}),
|
|
152
153
|
),
|
|
154
|
+
h(Field, { label: '宠物宽度(px)', hint: '基础尺寸,实时生效;会自动按 10 的倍数保存。' },
|
|
155
|
+
h('input', {
|
|
156
|
+
type: 'number', min: 100, max: 1000, step: 10,
|
|
157
|
+
value: sizeDraft ?? value.petSize ?? 460, disabled: !writable, style: selectStyle,
|
|
158
|
+
onChange: (event) => setSizeDraft(event.target.value),
|
|
159
|
+
onBlur: () => {
|
|
160
|
+
const raw = Number(sizeDraft ?? value.petSize ?? 460)
|
|
161
|
+
const rounded = Math.min(1000, Math.max(100, Math.round(raw / 10) * 10))
|
|
162
|
+
setSizeDraft(null)
|
|
163
|
+
void write('petSize', rounded)
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
),
|
|
167
|
+
h(Field, { label: '移动频繁度(%)', hint: '数值越高,待机时越容易走动。' },
|
|
168
|
+
h('input', {
|
|
169
|
+
type: 'range', min: 0, max: 100, step: 1,
|
|
170
|
+
value: value.moveChance ?? 20, disabled: status !== 'ready',
|
|
171
|
+
onChange: (event) => void writeSlider('moveChance', Number(event.target.value)),
|
|
172
|
+
}),
|
|
173
|
+
),
|
|
174
|
+
h(Field, { label: '动作切换间隔(ms)', hint: '每个动作播完后的停顿时间,0 表示立即切换。' },
|
|
175
|
+
h('input', {
|
|
176
|
+
type: 'range', min: 0, max: 5000, step: 100,
|
|
177
|
+
value: value.actionDelayMs ?? 0, disabled: status !== 'ready',
|
|
178
|
+
onChange: (event) => void writeSlider('actionDelayMs', Number(event.target.value)),
|
|
179
|
+
}),
|
|
180
|
+
),
|
|
153
181
|
h(Field, { label: '活跃程度', hint: '控制空闲时微动作的出现频率。' },
|
|
154
182
|
h('select', {
|
|
155
183
|
value: value.activityLevel ?? 'normal', disabled: !writable, style: selectStyle,
|
|
@@ -204,6 +232,30 @@ window.__ModuleLoader__.load({
|
|
|
204
232
|
onChange: (event) => void write('roastEnabled', event.target.checked),
|
|
205
233
|
}),
|
|
206
234
|
),
|
|
235
|
+
h(Field, { label: '允许行走', hint: '关闭后待机不会再走动。' },
|
|
236
|
+
h('input', {
|
|
237
|
+
type: 'checkbox', checked: value.walkEnabled !== false, disabled: !writable,
|
|
238
|
+
onChange: (event) => void write('walkEnabled', event.target.checked),
|
|
239
|
+
}),
|
|
240
|
+
),
|
|
241
|
+
h(Field, { label: '自定义待机动作', hint: '填写动作名,用逗号分隔;留空=全部动作。' },
|
|
242
|
+
h('textarea', {
|
|
243
|
+
rows: 3,
|
|
244
|
+
style: Object.assign({ width: '100%', padding: '6px 8px', borderRadius: 8 }, selectStyle),
|
|
245
|
+
value: Array.isArray(value.enabledActions) ? value.enabledActions.join(', ') : '',
|
|
246
|
+
disabled: !writable,
|
|
247
|
+
onChange: (event) => void write('enabledActions', event.target.value.split(/[,,]/).map((s) => s.trim()).filter(Boolean)),
|
|
248
|
+
}),
|
|
249
|
+
),
|
|
250
|
+
h(Field, { label: '自定义播放顺序', hint: '按顺序播放这些动作,用逗号分隔;留空=随机。' },
|
|
251
|
+
h('textarea', {
|
|
252
|
+
rows: 3,
|
|
253
|
+
style: Object.assign({ width: '100%', padding: '6px 8px', borderRadius: 8 }, selectStyle),
|
|
254
|
+
value: Array.isArray(value.actionOrder) ? value.actionOrder.join(', ') : '',
|
|
255
|
+
disabled: !writable,
|
|
256
|
+
onChange: (event) => void write('actionOrder', event.target.value.split(/[,,]/).map((s) => s.trim()).filter(Boolean)),
|
|
257
|
+
}),
|
|
258
|
+
),
|
|
207
259
|
h(Field, { label: '番茄钟工作时长(分钟)', hint: '右键菜单“开始番茄钟”使用此时长。' },
|
|
208
260
|
h('input', {
|
|
209
261
|
type: 'number', min: 1, max: 120, step: 1,
|
package/lib/index.js
CHANGED
|
@@ -52,6 +52,12 @@ export const Config = Schema.object({
|
|
|
52
52
|
workMinutes: Schema.number().min(1).max(120).step(1).default(25).description('番茄钟工作时长(分钟)'),
|
|
53
53
|
breakMinutes: Schema.number().min(1).max(60).step(1).default(5).description('番茄钟休息时长(分钟)'),
|
|
54
54
|
roastEnabled: Schema.boolean().default(false).description('根据本次对话自动吐槽(会消耗 Token)'),
|
|
55
|
+
walkEnabled: Schema.boolean().default(true).description('待机时是否允许走动'),
|
|
56
|
+
enabledActions: Schema.array(Schema.string()).default([]).description('自定义待机动作(留空=全部动作)'),
|
|
57
|
+
actionOrder: Schema.array(Schema.string()).default([]).description('自定义待机动作播放顺序(留空=随机)'),
|
|
58
|
+
petSize: Schema.number().min(100).max(1000).step(10).default(460).description('宠物宽度(px)'),
|
|
59
|
+
moveChance: Schema.number().min(0).max(100).step(1).default(20).description('移动频繁度(百分比)'),
|
|
60
|
+
actionDelayMs: Schema.number().min(0).max(5000).step(100).default(0).description('动作切换间隔(毫秒)'),
|
|
55
61
|
}).description('由 DeepSeek Harness 状态驱动的桌面大肥鱼')
|
|
56
62
|
|
|
57
63
|
const defaults = Object.freeze({
|
|
@@ -66,6 +72,12 @@ const defaults = Object.freeze({
|
|
|
66
72
|
workMinutes: 25,
|
|
67
73
|
breakMinutes: 5,
|
|
68
74
|
roastEnabled: false,
|
|
75
|
+
walkEnabled: true,
|
|
76
|
+
enabledActions: [],
|
|
77
|
+
actionOrder: [],
|
|
78
|
+
petSize: 460,
|
|
79
|
+
moveChance: 20,
|
|
80
|
+
actionDelayMs: 0,
|
|
69
81
|
})
|
|
70
82
|
|
|
71
83
|
function publicConfig(config = {}) {
|
|
@@ -81,6 +93,12 @@ function publicConfig(config = {}) {
|
|
|
81
93
|
workMinutes: config.workMinutes ?? defaults.workMinutes,
|
|
82
94
|
breakMinutes: config.breakMinutes ?? defaults.breakMinutes,
|
|
83
95
|
roastEnabled: config.roastEnabled ?? defaults.roastEnabled,
|
|
96
|
+
walkEnabled: config.walkEnabled ?? defaults.walkEnabled,
|
|
97
|
+
enabledActions: Array.isArray(config.enabledActions) ? config.enabledActions : defaults.enabledActions,
|
|
98
|
+
actionOrder: Array.isArray(config.actionOrder) ? config.actionOrder : defaults.actionOrder,
|
|
99
|
+
petSize: config.petSize ?? defaults.petSize,
|
|
100
|
+
moveChance: config.moveChance ?? defaults.moveChance,
|
|
101
|
+
actionDelayMs: config.actionDelayMs ?? defaults.actionDelayMs,
|
|
84
102
|
}
|
|
85
103
|
}
|
|
86
104
|
|
|
@@ -489,6 +507,10 @@ function mount(ctx, config = {}, eventCtx = ctx) {
|
|
|
489
507
|
} else if (event?.type === 'assistant/message') {
|
|
490
508
|
appendTranscript('assistant', event.data?.message?.content)
|
|
491
509
|
}
|
|
510
|
+
// 每轮对话结束后自动刷新一次余额。
|
|
511
|
+
if (event?.type === 'turn/end') {
|
|
512
|
+
void refreshBalance()
|
|
513
|
+
}
|
|
492
514
|
// 自动吐槽:每轮对话结束后,如果开启了吐槽,则延迟生成一条。
|
|
493
515
|
if (event?.type === 'turn/end' && settings.get().roastEnabled === true) {
|
|
494
516
|
if (roastTimer) clearTimeout(roastTimer)
|
|
@@ -549,6 +571,17 @@ function mount(ctx, config = {}, eventCtx = ctx) {
|
|
|
549
571
|
}),
|
|
550
572
|
'better-dsh-pet: local roast endpoint',
|
|
551
573
|
)
|
|
574
|
+
httpCtx.effect(
|
|
575
|
+
() => httpCtx.webServer.register({
|
|
576
|
+
kind: 'exact',
|
|
577
|
+
path: '/plugins/better-dsh-pet/refresh-balance',
|
|
578
|
+
handler: async (_req, res) => {
|
|
579
|
+
await refreshBalance()
|
|
580
|
+
jsonResponse(res, 200, { ok: true, balance })
|
|
581
|
+
},
|
|
582
|
+
}),
|
|
583
|
+
'better-dsh-pet: local refresh-balance endpoint',
|
|
584
|
+
)
|
|
552
585
|
httpCtx.effect(
|
|
553
586
|
() => httpCtx.webServer.register({ kind: 'prefix', path: ROUTE_PREFIX, handler: createAssetHandler(config) }),
|
|
554
587
|
'better-dsh-pet: /pet asset route',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process'
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process'
|
|
2
2
|
import { existsSync } from 'node:fs'
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
@@ -32,16 +32,40 @@ function resolveElectronPath(candidates = []) {
|
|
|
32
32
|
} catch {
|
|
33
33
|
/* electron 未安装时跳过 */
|
|
34
34
|
}
|
|
35
|
-
//
|
|
35
|
+
// 常见 Electron 安装位置(便于其他电脑直接跑通)。
|
|
36
36
|
const localCandidates = [
|
|
37
37
|
'D:/deepseek harness/tools/desktop-eval/dsh-desktop-electron/node_modules/electron/dist/electron.exe',
|
|
38
38
|
'D:/deepseek harness/tools/desktop-eval/dsh-desktop-electron/node_modules/electron/dist/electron',
|
|
39
39
|
join(process.env.USERPROFILE || '', '.dsh', 'electron', 'electron.exe'),
|
|
40
|
+
join(process.env.APPDATA || '', 'npm', 'node_modules', 'electron', 'dist', 'electron.exe'),
|
|
41
|
+
join(process.env.USERPROFILE || '', 'AppData', 'Roaming', 'npm', 'node_modules', 'electron', 'dist', 'electron.exe'),
|
|
42
|
+
join(process.env.LOCALAPPDATA || '', 'Programs', 'Electron', 'electron.exe'),
|
|
43
|
+
'C:/Program Files/Electron/electron.exe',
|
|
44
|
+
'C:/Program Files (x86)/Electron/electron.exe',
|
|
40
45
|
]
|
|
41
46
|
for (const candidate of localCandidates) push(candidate)
|
|
47
|
+
if (process.env.ELECTRON_PATH) push(process.env.ELECTRON_PATH)
|
|
48
|
+
if (!list.some((value) => existsSync(value))) {
|
|
49
|
+
const ensured = ensureElectron()
|
|
50
|
+
if (ensured) push(ensured)
|
|
51
|
+
}
|
|
42
52
|
return list.find((value) => existsSync(value))
|
|
43
53
|
}
|
|
44
54
|
|
|
55
|
+
function ensureElectron() {
|
|
56
|
+
const script = resolve(packageRoot, 'scripts', 'ensure-electron.mjs')
|
|
57
|
+
if (!existsSync(script)) return undefined
|
|
58
|
+
console.log('[better-dsh-pet] Electron not found, running ensure-electron.mjs ...')
|
|
59
|
+
const result = spawnSync(process.execPath, [script], {
|
|
60
|
+
stdio: 'inherit',
|
|
61
|
+
timeout: 10 * 60 * 1000,
|
|
62
|
+
})
|
|
63
|
+
if (result.status !== 0) return undefined
|
|
64
|
+
const home = process.env.DSH_HOME || join(process.env.USERPROFILE || '', '.dsh')
|
|
65
|
+
const exe = join(home, 'electron', 'electron.exe')
|
|
66
|
+
return existsSync(exe) ? exe : undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
45
69
|
function defaultLaunch(options = {}) {
|
|
46
70
|
const electronPath = resolveElectronPath([options.electronPath])
|
|
47
71
|
if (!electronPath) {
|
|
@@ -33,6 +33,12 @@ export interface Config {
|
|
|
33
33
|
workMinutes?: number;
|
|
34
34
|
breakMinutes?: number;
|
|
35
35
|
roastEnabled?: boolean;
|
|
36
|
+
walkEnabled?: boolean;
|
|
37
|
+
enabledActions?: string[];
|
|
38
|
+
actionOrder?: string[];
|
|
39
|
+
petSize?: number;
|
|
40
|
+
moveChance?: number;
|
|
41
|
+
actionDelayMs?: number;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -46,6 +46,18 @@ export interface Config {
|
|
|
46
46
|
breakMinutes?: number;
|
|
47
47
|
/** 是否根据本次对话自动吐槽(会消耗 Token)。默认 false。 */
|
|
48
48
|
roastEnabled?: boolean;
|
|
49
|
+
/** 待机时是否允许走动。默认 true。 */
|
|
50
|
+
walkEnabled?: boolean;
|
|
51
|
+
/** 自定义待机动作(留空=全部动作)。 */
|
|
52
|
+
enabledActions?: string[];
|
|
53
|
+
/** 自定义待机动作播放顺序(留空=随机)。 */
|
|
54
|
+
actionOrder?: string[];
|
|
55
|
+
/** 宠物宽度(px)。默认 460。 */
|
|
56
|
+
petSize?: number;
|
|
57
|
+
/** 移动频繁度(百分比)。默认 20。 */
|
|
58
|
+
moveChance?: number;
|
|
59
|
+
/** 动作切换间隔(毫秒)。默认 0。 */
|
|
60
|
+
actionDelayMs?: number;
|
|
49
61
|
/** 旧版 /pet 路由的 full 资源根目录。 */
|
|
50
62
|
fullRoot?: string;
|
|
51
63
|
/** Helper 进程选项。 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-dsh-pet",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A desktop-native pet bubble driven by DeepSeek Harness session events: transparent always-on-top Electron window, status-aware animations, balance, pomodoro, roast, and DSH settings card.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -178,6 +178,16 @@ app.whenReady().then(() => {
|
|
|
178
178
|
console.error('[better-dsh-pet-helper] request roast error:', error)
|
|
179
179
|
}
|
|
180
180
|
})
|
|
181
|
+
ipcMain.on('pet:refresh-balance', async () => {
|
|
182
|
+
const statusUrl = process.env.DSH_PET_STATUS_URL
|
|
183
|
+
if (!statusUrl) return
|
|
184
|
+
try {
|
|
185
|
+
const refreshUrl = statusUrl.replace(/\/plugins\/better-dsh-pet\/status$/, '/plugins/better-dsh-pet/refresh-balance')
|
|
186
|
+
await fetch(refreshUrl, { method: 'POST', cache: 'no-store' })
|
|
187
|
+
} catch (error) {
|
|
188
|
+
console.error('[better-dsh-pet-helper] refresh balance error:', error)
|
|
189
|
+
}
|
|
190
|
+
})
|
|
181
191
|
ipcMain.on('pet:move-by', () => {
|
|
182
192
|
// 已改为全屏画布内移动宠物 DOM,不再移动窗口。
|
|
183
193
|
})
|