better-dsh-pet 0.2.4 → 0.2.5

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/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.5",
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()