better-dsh-pet 0.2.4 → 0.2.6

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 CHANGED
@@ -202,6 +202,14 @@
202
202
  dsh plugin --profile web add better-dsh-pet
203
203
  ```
204
204
 
205
+ > 如果刚发布新版本不到 24 小时,pnpm 11 的 `minimumReleaseAge` 安全策略可能不会自动选最新版,而是退回旧版。此时请指定精确版本安装:
206
+ >
207
+ > ```bash
208
+ > dsh plugin --profile web add better-dsh-pet@0.2.5
209
+ > ```
210
+ >
211
+ > pnpm 会自动把该版本加入 `minimumReleaseAgeExclude` 并完成安装;也可以等待 24 小时后直接用上面的普通命令。
212
+
205
213
  ### 启动
206
214
 
207
215
  ```bash
package/lib/index.js CHANGED
@@ -30,6 +30,7 @@ export const name = 'better-dsh-pet'
30
30
  export const inject = ['sessions']
31
31
  export const CONFIG_ENDPOINT = '/plugins/better-dsh-pet/config'
32
32
  export const STATUS_ENDPOINT = '/plugins/better-dsh-pet/status'
33
+ export const CLOSE_ENDPOINT = '/plugins/better-dsh-pet/close'
33
34
  export const ROUTE_PREFIX = '/pet'
34
35
 
35
36
  export const Config = Schema.object({
@@ -582,6 +583,19 @@ function mount(ctx, config = {}, eventCtx = ctx) {
582
583
  }),
583
584
  'better-dsh-pet: local refresh-balance endpoint',
584
585
  )
586
+ httpCtx.effect(
587
+ () => httpCtx.webServer.register({
588
+ kind: 'exact',
589
+ path: CLOSE_ENDPOINT,
590
+ handler: async (_req, res) => {
591
+ // 用户从右键菜单选择“本次关闭”时,先通知宿主停止守护,
592
+ // 避免 Helper 进程退出后被 HelperProcess 自动拉起。
593
+ stopRuntime('user-close')
594
+ jsonResponse(res, 200, { ok: true })
595
+ },
596
+ }),
597
+ 'better-dsh-pet: local close endpoint',
598
+ )
585
599
  httpCtx.effect(
586
600
  () => httpCtx.webServer.register({ kind: 'prefix', path: ROUTE_PREFIX, handler: createAssetHandler(config) }),
587
601
  'better-dsh-pet: /pet asset route',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-dsh-pet",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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",
@@ -69,8 +69,7 @@
69
69
  },
70
70
  "client": {
71
71
  "inject": [
72
- "@deepseek-ai/dsh-client-runtime",
73
- "@deepseek-ai/dsh-client-ui-settings-plugins"
72
+ "@deepseek-ai/dsh-client-runtime"
74
73
  ],
75
74
  "platform": "web"
76
75
  }
@@ -113,6 +113,17 @@ function createWindow() {
113
113
  })
114
114
  }
115
115
 
116
+ async function notifyHostClosed() {
117
+ const statusUrl = process.env.DSH_PET_STATUS_URL
118
+ if (!statusUrl) return
119
+ try {
120
+ const closeUrl = statusUrl.replace(/\/plugins\/better-dsh-pet\/status$/, '/plugins/better-dsh-pet/close')
121
+ await fetch(closeUrl, { method: 'POST', cache: 'no-store' })
122
+ } catch {
123
+ // 宿主不可达时无法通知,仍继续退出;宿主侧可能按崩溃重启处理。
124
+ }
125
+ }
126
+
116
127
  function startPolling() {
117
128
  const statusUrl = process.env.DSH_PET_STATUS_URL
118
129
  if (!statusUrl) {
@@ -140,7 +151,7 @@ function startPolling() {
140
151
  app.whenReady().then(() => {
141
152
  createWindow()
142
153
  ipcMain.on('pet:closed', (_event, reason) => {
143
- app.quit()
154
+ void notifyHostClosed().finally(() => app.quit())
144
155
  })
145
156
  ipcMain.on('pet:hide', () => {
146
157
  if (mainWindow) mainWindow.hide()
@@ -331,6 +331,7 @@ function playIdle() {
331
331
  }
332
332
 
333
333
  function playState(state, { pulse = false } = {}) {
334
+ clearIdleDelay()
334
335
  stopMove()
335
336
  currentMode = pulse ? 'pulse' : 'state'
336
337
  const pool = STATE_ANIMS[state] || STATE_ANIMS.IDLE
@@ -343,6 +344,7 @@ function playState(state, { pulse = false } = {}) {
343
344
  }
344
345
 
345
346
  function playClick() {
347
+ clearIdleDelay()
346
348
  stopMove()
347
349
  currentMode = 'click'
348
350
  const next = pick(CLICKS, anim)
@@ -354,6 +356,7 @@ function playClick() {
354
356
  }
355
357
 
356
358
  function playDrag() {
359
+ clearIdleDelay()
357
360
  stopMove()
358
361
  currentMode = 'drag'
359
362
  anim = DRAG
@@ -447,6 +450,13 @@ function clearIdleDelay() {
447
450
  function scheduleNextIdle() {
448
451
  clearIdleDelay()
449
452
  if (CONFIG.actionDelayMs > 0) {
453
+ // 等待“动作切换间隔”时不要定格在上一动作的最后一帧:
454
+ // 先播放循环待机呼吸,等间隔结束再进入下一个随机/自定义动作。
455
+ currentMode = 'idle'
456
+ anim = IDLE
457
+ animOnce = false
458
+ animLoop = true
459
+ switchTo(IDLE, { loop: true })
450
460
  idleDelayTimer = setTimeout(() => {
451
461
  idleDelayTimer = null
452
462
  playIdle()
@@ -602,6 +612,7 @@ function showManualBubble(message, detail, ttl = 2200) {
602
612
  }
603
613
 
604
614
  function feedPet() {
615
+ clearIdleDelay()
605
616
  const next = pick(EAT_ANIMS, anim)
606
617
  anim = next
607
618
  animOnce = true
@@ -766,6 +777,7 @@ document.addEventListener('mousemove', (e) => {
766
777
  })
767
778
 
768
779
  function startDrag(e) {
780
+ clearIdleDelay()
769
781
  stopMove()
770
782
  e.currentTarget.classList.add('dragging')
771
783
  try { e.currentTarget.setPointerCapture(e.pointerId) } catch { /* 忽略捕获失败 */ }