@takboo/dsh-coopanion 0.4.7 → 0.4.9

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.
Files changed (419) hide show
  1. package/README.md +20 -10
  2. package/desktop/display-controller.cjs +21 -0
  3. package/desktop/main.cjs +58 -42
  4. package/desktop/preload.cjs +2 -0
  5. package/desktop/test-display-probe.cjs +13 -0
  6. package/desktop/tray-state.cjs +12 -6
  7. package/dist/bridge.js +57 -20
  8. package/dist/bridge.js.map +3 -3
  9. package/dist/client.js +479 -18
  10. package/dist/index.js +777 -88
  11. package/dist/index.js.map +4 -4
  12. package/dist/model.js +71 -4
  13. package/dist/model.js.map +3 -3
  14. package/docs/daily-rhythm-contract.md +29 -0
  15. package/docs/desktop-recovery-contract.md +17 -0
  16. package/docs/evidence/m1/README.md +68 -0
  17. package/docs/evidence/m1/goal-host-0.2.0-rc.2.json +918 -0
  18. package/docs/evidence/m1/goal-host-0.2.1-alpha.1.json +918 -0
  19. package/docs/evidence/m1/install-0.2.0-rc.2.json +24 -0
  20. package/docs/evidence/m1/install-0.2.1-alpha.1.json +24 -0
  21. package/docs/evidence/m1/package-verification.json +7 -0
  22. package/docs/evidence/m1/runtime-lock-0.2.0-rc.2.json.gz +0 -0
  23. package/docs/evidence/m1/runtime-lock-0.2.1-alpha.1.json.gz +0 -0
  24. package/docs/evidence/m1/validation.json +94 -0
  25. package/docs/evidence/m2/README.md +77 -0
  26. package/docs/evidence/m2/controller-0.2.0-rc.2.json +1632 -0
  27. package/docs/evidence/m2/controller-0.2.1-alpha.1.json +1925 -0
  28. package/docs/evidence/m2/controller-probe.mjs +52 -0
  29. package/docs/evidence/m2/goal-host-0.2.0-rc.2.json +918 -0
  30. package/docs/evidence/m2/goal-host-0.2.1-alpha.1.json +918 -0
  31. package/docs/evidence/m2/install-0.2.0-rc.2.json +27 -0
  32. package/docs/evidence/m2/install-0.2.1-alpha.1.json +27 -0
  33. package/docs/evidence/m2/notification-host-0.2.0-rc.2.json +182 -0
  34. package/docs/evidence/m2/notification-host-0.2.1-alpha.1.json +182 -0
  35. package/docs/evidence/m2/notification-integration-0.2.0-rc.2.json +108 -0
  36. package/docs/evidence/m2/notification-integration-0.2.1-alpha.1.json +108 -0
  37. package/docs/evidence/m2/notification-source-0.2.0-rc.2.json +17 -0
  38. package/docs/evidence/m2/notification-source-0.2.1-alpha.1.json +17 -0
  39. package/docs/evidence/m2/package-source-content.json +18 -0
  40. package/docs/evidence/m2/package-verification.json +7 -0
  41. package/docs/evidence/m2/release-notes.md +12 -0
  42. package/docs/evidence/m2/runtime-lock-0.2.0-rc.2.json.gz +0 -0
  43. package/docs/evidence/m2/runtime-lock-0.2.1-alpha.1.json.gz +0 -0
  44. package/docs/evidence/m2/session-host-0.2.0-rc.2.json +3181 -0
  45. package/docs/evidence/m2/session-host-0.2.1-alpha.1.json +3767 -0
  46. package/docs/evidence/m2/session-native-0.2.0-rc.2.json +1161 -0
  47. package/docs/evidence/m2/session-native-0.2.1-alpha.1.json +1523 -0
  48. package/docs/evidence/m2/validation.json +187 -0
  49. package/docs/evidence/m3/README.md +64 -0
  50. package/docs/evidence/m3/build.log.gz +0 -0
  51. package/docs/evidence/m3/character-pack.log.gz +0 -0
  52. package/docs/evidence/m3/ci.log.gz +0 -0
  53. package/docs/evidence/m3/desktop-recovery-0.2.0-rc.2.json +392 -0
  54. package/docs/evidence/m3/desktop-recovery-0.2.1-alpha.1.json +394 -0
  55. package/docs/evidence/m3/desktop-recovery.json +615 -0
  56. package/docs/evidence/m3/desktop.log.gz +0 -0
  57. package/docs/evidence/m3/electron-setup.log.gz +0 -0
  58. package/docs/evidence/m3/goal-host-0.2.0-rc.2.json +918 -0
  59. package/docs/evidence/m3/goal-host-0.2.1-alpha.1.json +918 -0
  60. package/docs/evidence/m3/inbox-ui.log.gz +0 -0
  61. package/docs/evidence/m3/install-0.2.0-rc.2.json +28 -0
  62. package/docs/evidence/m3/install-0.2.1-alpha.1.json +28 -0
  63. package/docs/evidence/m3/install-alpha.log.gz +0 -0
  64. package/docs/evidence/m3/install-rc.log.gz +0 -0
  65. package/docs/evidence/m3/metadata.log.gz +0 -0
  66. package/docs/evidence/m3/notification-host-0.2.0-rc.2.json +182 -0
  67. package/docs/evidence/m3/notification-host-0.2.1-alpha.1.json +182 -0
  68. package/docs/evidence/m3/notification-integration-0.2.0-rc.2.json +108 -0
  69. package/docs/evidence/m3/notification-integration-0.2.1-alpha.1.json +108 -0
  70. package/docs/evidence/m3/notification-source-0.2.0-rc.2.json +17 -0
  71. package/docs/evidence/m3/notification-source-0.2.1-alpha.1.json +17 -0
  72. package/docs/evidence/m3/notification-ui.log.gz +0 -0
  73. package/docs/evidence/m3/package-source-content.json +3070 -0
  74. package/docs/evidence/m3/package-verification.json +7 -0
  75. package/docs/evidence/m3/package.log.gz +0 -0
  76. package/docs/evidence/m3/release-notes.md +12 -0
  77. package/docs/evidence/m3/runtime-lock-0.2.0-rc.2.json.gz +0 -0
  78. package/docs/evidence/m3/runtime-lock-0.2.1-alpha.1.json.gz +0 -0
  79. package/docs/evidence/m3/session-host-0.2.0-rc.2.json +3181 -0
  80. package/docs/evidence/m3/session-host-0.2.1-alpha.1.json +3767 -0
  81. package/docs/evidence/m3/session-native-0.2.0-rc.2.json +1131 -0
  82. package/docs/evidence/m3/session-native-0.2.1-alpha.1.json +1424 -0
  83. package/docs/evidence/m3/test.log.gz +0 -0
  84. package/docs/evidence/m3/typecheck.log.gz +0 -0
  85. package/docs/evidence/m3/ui.log.gz +0 -0
  86. package/docs/evidence/m3/validation.json +306 -0
  87. package/docs/evidence/m4/README.md +61 -0
  88. package/docs/evidence/m4/build.log.gz +0 -0
  89. package/docs/evidence/m4/character-pack.log.gz +0 -0
  90. package/docs/evidence/m4/ci.log.gz +0 -0
  91. package/docs/evidence/m4/desktop-recovery-0.2.0-rc.2.json +392 -0
  92. package/docs/evidence/m4/desktop-recovery-0.2.1-alpha.1.json +392 -0
  93. package/docs/evidence/m4/desktop-recovery.json +615 -0
  94. package/docs/evidence/m4/desktop.log.gz +0 -0
  95. package/docs/evidence/m4/electron-setup.log.gz +0 -0
  96. package/docs/evidence/m4/goal-host-0.2.0-rc.2.json +918 -0
  97. package/docs/evidence/m4/goal-host-0.2.1-alpha.1.json +918 -0
  98. package/docs/evidence/m4/inbox-ui.log.gz +0 -0
  99. package/docs/evidence/m4/install-0.2.0-rc.2.json +28 -0
  100. package/docs/evidence/m4/install-0.2.1-alpha.1.json +28 -0
  101. package/docs/evidence/m4/install-alpha.log.gz +0 -0
  102. package/docs/evidence/m4/install-rc.log.gz +0 -0
  103. package/docs/evidence/m4/metadata.log.gz +0 -0
  104. package/docs/evidence/m4/notification-host-0.2.0-rc.2.json +182 -0
  105. package/docs/evidence/m4/notification-host-0.2.1-alpha.1.json +182 -0
  106. package/docs/evidence/m4/notification-integration-0.2.0-rc.2.json +108 -0
  107. package/docs/evidence/m4/notification-integration-0.2.1-alpha.1.json +108 -0
  108. package/docs/evidence/m4/notification-source-0.2.0-rc.2.json +17 -0
  109. package/docs/evidence/m4/notification-source-0.2.1-alpha.1.json +17 -0
  110. package/docs/evidence/m4/notification-ui.log.gz +0 -0
  111. package/docs/evidence/m4/package-check.log.gz +0 -0
  112. package/docs/evidence/m4/package-negative-check.json +8 -0
  113. package/docs/evidence/m4/package-source-content.json +2638 -0
  114. package/docs/evidence/m4/package-verification.json +7 -0
  115. package/docs/evidence/m4/package.log.gz +0 -0
  116. package/docs/evidence/m4/release-notes.md +12 -0
  117. package/docs/evidence/m4/runtime-lock-0.2.0-rc.2.json.gz +0 -0
  118. package/docs/evidence/m4/runtime-lock-0.2.1-alpha.1.json.gz +0 -0
  119. package/docs/evidence/m4/session-host-0.2.0-rc.2.json +3181 -0
  120. package/docs/evidence/m4/session-host-0.2.1-alpha.1.json +3767 -0
  121. package/docs/evidence/m4/session-native-0.2.0-rc.2.json +1161 -0
  122. package/docs/evidence/m4/session-native-0.2.1-alpha.1.json +1454 -0
  123. package/docs/evidence/m4/test.log.gz +0 -0
  124. package/docs/evidence/m4/text-scale-chat-en-US.png +0 -0
  125. package/docs/evidence/m4/text-scale-chat-zh-CN.png +0 -0
  126. package/docs/evidence/m4/text-scale-en-US-240-1.25.png +0 -0
  127. package/docs/evidence/m4/text-scale-en-US-240-1.5.png +0 -0
  128. package/docs/evidence/m4/text-scale-en-US-240-1.png +0 -0
  129. package/docs/evidence/m4/text-scale-en-US-90-1.25.png +0 -0
  130. package/docs/evidence/m4/text-scale-en-US-90-1.5.png +0 -0
  131. package/docs/evidence/m4/text-scale-en-US-90-1.png +0 -0
  132. package/docs/evidence/m4/text-scale-en-US.json +50 -0
  133. package/docs/evidence/m4/text-scale-inbox-en-US.png +0 -0
  134. package/docs/evidence/m4/text-scale-inbox-zh-CN.png +0 -0
  135. package/docs/evidence/m4/text-scale-installed-0.2.0-rc.2.json +95 -0
  136. package/docs/evidence/m4/text-scale-installed-0.2.0-rc.2.png +0 -0
  137. package/docs/evidence/m4/text-scale-installed-0.2.1-alpha.1.json +95 -0
  138. package/docs/evidence/m4/text-scale-installed-0.2.1-alpha.1.png +0 -0
  139. package/docs/evidence/m4/text-scale-native.json +166 -0
  140. package/docs/evidence/m4/text-scale-native.png +0 -0
  141. package/docs/evidence/m4/text-scale-zh-CN-240-1.25.png +0 -0
  142. package/docs/evidence/m4/text-scale-zh-CN-240-1.5.png +0 -0
  143. package/docs/evidence/m4/text-scale-zh-CN-240-1.png +0 -0
  144. package/docs/evidence/m4/text-scale-zh-CN-90-1.25.png +0 -0
  145. package/docs/evidence/m4/text-scale-zh-CN-90-1.5.png +0 -0
  146. package/docs/evidence/m4/text-scale-zh-CN-90-1.png +0 -0
  147. package/docs/evidence/m4/text-scale-zh-CN.json +50 -0
  148. package/docs/evidence/m4/toolchain.log.gz +0 -0
  149. package/docs/evidence/m4/typecheck.log.gz +0 -0
  150. package/docs/evidence/m4/ui.log.gz +0 -0
  151. package/docs/evidence/m4/validation.json +407 -0
  152. package/docs/evidence/m5/README.md +87 -0
  153. package/docs/evidence/m5/active-drag-fixed.json +27 -0
  154. package/docs/evidence/m5/active-drag-fixed.log.gz +0 -0
  155. package/docs/evidence/m5/active-drag-reproduction.json +27 -0
  156. package/docs/evidence/m5/baseline-reproduction.json +88 -0
  157. package/docs/evidence/m5/build.log.gz +0 -0
  158. package/docs/evidence/m5/character-pack.log.gz +0 -0
  159. package/docs/evidence/m5/ci.log.gz +0 -0
  160. package/docs/evidence/m5/desktop-recovery-0.2.0-rc.2.json +394 -0
  161. package/docs/evidence/m5/desktop-recovery-0.2.1-alpha.1.json +392 -0
  162. package/docs/evidence/m5/desktop-recovery.json +615 -0
  163. package/docs/evidence/m5/desktop.log.gz +0 -0
  164. package/docs/evidence/m5/electron-setup.log.gz +0 -0
  165. package/docs/evidence/m5/evidence-identity.json +138 -0
  166. package/docs/evidence/m5/goal-host-0.2.0-rc.2.json +918 -0
  167. package/docs/evidence/m5/goal-host-0.2.1-alpha.1.json +918 -0
  168. package/docs/evidence/m5/inbox-ui.log.gz +0 -0
  169. package/docs/evidence/m5/install-0.2.0-rc.2.json +28 -0
  170. package/docs/evidence/m5/install-0.2.0-rc.2.log.gz +0 -0
  171. package/docs/evidence/m5/install-0.2.1-alpha.1.json +28 -0
  172. package/docs/evidence/m5/install-0.2.1-alpha.1.log.gz +0 -0
  173. package/docs/evidence/m5/metadata.log.gz +0 -0
  174. package/docs/evidence/m5/multi-display-installed-0.2.0-rc.2.json +557 -0
  175. package/docs/evidence/m5/multi-display-installed-0.2.1-alpha.1.json +557 -0
  176. package/docs/evidence/m5/multi-display-native.json +518 -0
  177. package/docs/evidence/m5/multi-display-native.png +0 -0
  178. package/docs/evidence/m5/multi-display-reader.png +0 -0
  179. package/docs/evidence/m5/multi-display-ui.json +133 -0
  180. package/docs/evidence/m5/native-input-failure.json +9 -0
  181. package/docs/evidence/m5/native-input-failure.redacted.log.gz +0 -0
  182. package/docs/evidence/m5/native-input-startup-loop.json +2197 -0
  183. package/docs/evidence/m5/native-input-startup-loop.log.gz +0 -0
  184. package/docs/evidence/m5/native-input-startup-loop.mjs.txt +23 -0
  185. package/docs/evidence/m5/native-pet.png +0 -0
  186. package/docs/evidence/m5/notification-host-0.2.0-rc.2.json +182 -0
  187. package/docs/evidence/m5/notification-host-0.2.1-alpha.1.json +182 -0
  188. package/docs/evidence/m5/notification-integration-0.2.0-rc.2.json +108 -0
  189. package/docs/evidence/m5/notification-integration-0.2.1-alpha.1.json +108 -0
  190. package/docs/evidence/m5/notification-source-0.2.0-rc.2.json +17 -0
  191. package/docs/evidence/m5/notification-source-0.2.1-alpha.1.json +17 -0
  192. package/docs/evidence/m5/notification-ui.log.gz +0 -0
  193. package/docs/evidence/m5/pack.log.gz +0 -0
  194. package/docs/evidence/m5/package-negative-check.json +8 -0
  195. package/docs/evidence/m5/package-source-content.json +2946 -0
  196. package/docs/evidence/m5/package-verification.json +7 -0
  197. package/docs/evidence/m5/package.log.gz +0 -0
  198. package/docs/evidence/m5/previous-milestones.json +36 -0
  199. package/docs/evidence/m5/release-notes.md +12 -0
  200. package/docs/evidence/m5/reproduce-active-drag.mjs +32 -0
  201. package/docs/evidence/m5/reproduce-baseline.mjs +23 -0
  202. package/docs/evidence/m5/runtime-lock-0.2.0-rc.2.json.gz +0 -0
  203. package/docs/evidence/m5/runtime-lock-0.2.1-alpha.1.json.gz +0 -0
  204. package/docs/evidence/m5/session-host-0.2.0-rc.2.json +3181 -0
  205. package/docs/evidence/m5/session-host-0.2.1-alpha.1.json +3767 -0
  206. package/docs/evidence/m5/session-native-0.2.0-rc.2.json +1131 -0
  207. package/docs/evidence/m5/session-native-0.2.1-alpha.1.json +1523 -0
  208. package/docs/evidence/m5/test.log.gz +0 -0
  209. package/docs/evidence/m5/text-scale-chat-en-US.png +0 -0
  210. package/docs/evidence/m5/text-scale-chat-zh-CN.png +0 -0
  211. package/docs/evidence/m5/text-scale-en-US-240-1.25.png +0 -0
  212. package/docs/evidence/m5/text-scale-en-US-240-1.5.png +0 -0
  213. package/docs/evidence/m5/text-scale-en-US-240-1.png +0 -0
  214. package/docs/evidence/m5/text-scale-en-US-90-1.25.png +0 -0
  215. package/docs/evidence/m5/text-scale-en-US-90-1.5.png +0 -0
  216. package/docs/evidence/m5/text-scale-en-US-90-1.png +0 -0
  217. package/docs/evidence/m5/text-scale-en-US.json +50 -0
  218. package/docs/evidence/m5/text-scale-inbox-en-US.png +0 -0
  219. package/docs/evidence/m5/text-scale-inbox-zh-CN.png +0 -0
  220. package/docs/evidence/m5/text-scale-installed-0.2.0-rc.2.json +629 -0
  221. package/docs/evidence/m5/text-scale-installed-0.2.0-rc.2.png +0 -0
  222. package/docs/evidence/m5/text-scale-installed-0.2.1-alpha.1.json +629 -0
  223. package/docs/evidence/m5/text-scale-installed-0.2.1-alpha.1.png +0 -0
  224. package/docs/evidence/m5/text-scale-native.json +1234 -0
  225. package/docs/evidence/m5/text-scale-native.png +0 -0
  226. package/docs/evidence/m5/text-scale-zh-CN-240-1.25.png +0 -0
  227. package/docs/evidence/m5/text-scale-zh-CN-240-1.5.png +0 -0
  228. package/docs/evidence/m5/text-scale-zh-CN-240-1.png +0 -0
  229. package/docs/evidence/m5/text-scale-zh-CN-90-1.25.png +0 -0
  230. package/docs/evidence/m5/text-scale-zh-CN-90-1.5.png +0 -0
  231. package/docs/evidence/m5/text-scale-zh-CN-90-1.png +0 -0
  232. package/docs/evidence/m5/text-scale-zh-CN.json +50 -0
  233. package/docs/evidence/m5/toolchain.log.gz +0 -0
  234. package/docs/evidence/m5/typecheck.log.gz +0 -0
  235. package/docs/evidence/m5/ui.log.gz +0 -0
  236. package/docs/evidence/m5/validation.json +542 -0
  237. package/docs/evidence/m6/README.md +110 -0
  238. package/docs/evidence/m6/baseline-identity.json +10 -0
  239. package/docs/evidence/m6/build.log.gz +0 -0
  240. package/docs/evidence/m6/character-pack.log.gz +0 -0
  241. package/docs/evidence/m6/daily-rhythm-installed-0.2.0-rc.2.json +14 -0
  242. package/docs/evidence/m6/daily-rhythm-installed-0.2.1-alpha.1.json +14 -0
  243. package/docs/evidence/m6/daily-rhythm-native.json +147 -0
  244. package/docs/evidence/m6/daily-rhythm-native.png +0 -0
  245. package/docs/evidence/m6/daily-rhythm-ui.json +119 -0
  246. package/docs/evidence/m6/daily-rhythm-ui.png +0 -0
  247. package/docs/evidence/m6/desktop-recovery-0.2.0-rc.2.json +403 -0
  248. package/docs/evidence/m6/desktop-recovery-0.2.1-alpha.1.json +403 -0
  249. package/docs/evidence/m6/desktop-recovery.json +615 -0
  250. package/docs/evidence/m6/desktop.log.gz +0 -0
  251. package/docs/evidence/m6/electron.log.gz +0 -0
  252. package/docs/evidence/m6/evidence-identity.json +151 -0
  253. package/docs/evidence/m6/goal-host-0.2.0-rc.2.json +918 -0
  254. package/docs/evidence/m6/goal-host-0.2.1-alpha.1.json +918 -0
  255. package/docs/evidence/m6/idle-baseline-controlled.json.gz +0 -0
  256. package/docs/evidence/m6/idle-baseline-controlled.log.gz +0 -0
  257. package/docs/evidence/m6/idle-baseline.json +7850 -0
  258. package/docs/evidence/m6/idle-day.json.gz +0 -0
  259. package/docs/evidence/m6/idle-day.log.gz +0 -0
  260. package/docs/evidence/m6/idle-night.json.gz +0 -0
  261. package/docs/evidence/m6/idle-night.log.gz +0 -0
  262. package/docs/evidence/m6/idle-off.json.gz +0 -0
  263. package/docs/evidence/m6/idle-off.log.gz +0 -0
  264. package/docs/evidence/m6/inbox-ui.log.gz +0 -0
  265. package/docs/evidence/m6/install-0.2.0-rc.2.json +28 -0
  266. package/docs/evidence/m6/install-0.2.0-rc.2.log.gz +0 -0
  267. package/docs/evidence/m6/install-0.2.1-alpha.1.json +28 -0
  268. package/docs/evidence/m6/install-0.2.1-alpha.1.log.gz +0 -0
  269. package/docs/evidence/m6/measure-isolated.mjs +42 -0
  270. package/docs/evidence/m6/metadata.log.gz +0 -0
  271. package/docs/evidence/m6/multi-display-installed-0.2.0-rc.2.json +557 -0
  272. package/docs/evidence/m6/multi-display-installed-0.2.1-alpha.1.json +557 -0
  273. package/docs/evidence/m6/multi-display-native.json +518 -0
  274. package/docs/evidence/m6/multi-display-native.png +0 -0
  275. package/docs/evidence/m6/multi-display-reader.png +0 -0
  276. package/docs/evidence/m6/multi-display-ui.json +133 -0
  277. package/docs/evidence/m6/native-pet.png +0 -0
  278. package/docs/evidence/m6/notification-host-0.2.0-rc.2.json +182 -0
  279. package/docs/evidence/m6/notification-host-0.2.1-alpha.1.json +182 -0
  280. package/docs/evidence/m6/notification-integration-0.2.0-rc.2.json +108 -0
  281. package/docs/evidence/m6/notification-integration-0.2.1-alpha.1.json +108 -0
  282. package/docs/evidence/m6/notification-source-0.2.0-rc.2.json +17 -0
  283. package/docs/evidence/m6/notification-source-0.2.1-alpha.1.json +17 -0
  284. package/docs/evidence/m6/notification-ui.log.gz +0 -0
  285. package/docs/evidence/m6/npm-ci.log.gz +0 -0
  286. package/docs/evidence/m6/pack.log.gz +0 -0
  287. package/docs/evidence/m6/package-negative-check.json +7 -0
  288. package/docs/evidence/m6/package-source-content.json +3310 -0
  289. package/docs/evidence/m6/package-verification.json +7 -0
  290. package/docs/evidence/m6/package.log.gz +0 -0
  291. package/docs/evidence/m6/previous-milestones.json +45 -0
  292. package/docs/evidence/m6/release-notes.md +12 -0
  293. package/docs/evidence/m6/resource-budget.json +12 -0
  294. package/docs/evidence/m6/resource-comparison.json +228 -0
  295. package/docs/evidence/m6/runtime-lock-0.2.0-rc.2.json.gz +0 -0
  296. package/docs/evidence/m6/runtime-lock-0.2.1-alpha.1.json.gz +0 -0
  297. package/docs/evidence/m6/session-host-0.2.0-rc.2.json +3181 -0
  298. package/docs/evidence/m6/session-host-0.2.1-alpha.1.json +3767 -0
  299. package/docs/evidence/m6/session-native-0.2.0-rc.2.json +1230 -0
  300. package/docs/evidence/m6/session-native-0.2.1-alpha.1.json +1424 -0
  301. package/docs/evidence/m6/settings-0.2.0-rc.2.png +0 -0
  302. package/docs/evidence/m6/settings-0.2.1-alpha.1.png +0 -0
  303. package/docs/evidence/m6/settings-dark-0.2.0-rc.2.png +0 -0
  304. package/docs/evidence/m6/settings-dark-0.2.1-alpha.1.png +0 -0
  305. package/docs/evidence/m6/settings-en-0.2.0-rc.2.png +0 -0
  306. package/docs/evidence/m6/settings-en-0.2.1-alpha.1.png +0 -0
  307. package/docs/evidence/m6/settings-system-en-US-0.2.0-rc.2.png +0 -0
  308. package/docs/evidence/m6/settings-system-en-US-0.2.1-alpha.1.png +0 -0
  309. package/docs/evidence/m6/settings-system-zh-CN-0.2.0-rc.2.png +0 -0
  310. package/docs/evidence/m6/settings-system-zh-CN-0.2.1-alpha.1.png +0 -0
  311. package/docs/evidence/m6/test.log.gz +0 -0
  312. package/docs/evidence/m6/text-scale-chat-en-US.png +0 -0
  313. package/docs/evidence/m6/text-scale-chat-zh-CN.png +0 -0
  314. package/docs/evidence/m6/text-scale-en-US-240-1.25.png +0 -0
  315. package/docs/evidence/m6/text-scale-en-US-240-1.5.png +0 -0
  316. package/docs/evidence/m6/text-scale-en-US-240-1.png +0 -0
  317. package/docs/evidence/m6/text-scale-en-US-90-1.25.png +0 -0
  318. package/docs/evidence/m6/text-scale-en-US-90-1.5.png +0 -0
  319. package/docs/evidence/m6/text-scale-en-US-90-1.png +0 -0
  320. package/docs/evidence/m6/text-scale-en-US.json +50 -0
  321. package/docs/evidence/m6/text-scale-inbox-en-US.png +0 -0
  322. package/docs/evidence/m6/text-scale-inbox-zh-CN.png +0 -0
  323. package/docs/evidence/m6/text-scale-installed-0.2.0-rc.2.json +629 -0
  324. package/docs/evidence/m6/text-scale-installed-0.2.0-rc.2.png +0 -0
  325. package/docs/evidence/m6/text-scale-installed-0.2.1-alpha.1.json +629 -0
  326. package/docs/evidence/m6/text-scale-installed-0.2.1-alpha.1.png +0 -0
  327. package/docs/evidence/m6/text-scale-native.json +1234 -0
  328. package/docs/evidence/m6/text-scale-native.png +0 -0
  329. package/docs/evidence/m6/text-scale-zh-CN-240-1.25.png +0 -0
  330. package/docs/evidence/m6/text-scale-zh-CN-240-1.5.png +0 -0
  331. package/docs/evidence/m6/text-scale-zh-CN-240-1.png +0 -0
  332. package/docs/evidence/m6/text-scale-zh-CN-90-1.25.png +0 -0
  333. package/docs/evidence/m6/text-scale-zh-CN-90-1.5.png +0 -0
  334. package/docs/evidence/m6/text-scale-zh-CN-90-1.png +0 -0
  335. package/docs/evidence/m6/text-scale-zh-CN.json +50 -0
  336. package/docs/evidence/m6/toolchain.log.gz +0 -0
  337. package/docs/evidence/m6/typecheck.log.gz +0 -0
  338. package/docs/evidence/m6/ui.log.gz +0 -0
  339. package/docs/evidence/m6/validation.json +852 -0
  340. package/docs/multi-display-contract.md +29 -0
  341. package/docs/notification-contract.md +25 -1
  342. package/docs/release-notes.md +30 -0
  343. package/docs/releasing.md +2 -0
  344. package/docs/roadmap.md +184 -0
  345. package/docs/session-chat-contract.md +44 -0
  346. package/docs/text-readability-contract.md +28 -0
  347. package/npm-shrinkwrap.json +32 -11
  348. package/package.json +20 -10
  349. package/scripts/check-package.mjs +5 -2
  350. package/scripts/measure-idle.mjs +76 -0
  351. package/src/bridge.ts +42 -20
  352. package/src/chat.ts +72 -0
  353. package/src/client/Settings.tsx +13 -4
  354. package/src/client/index.ts +21 -3
  355. package/src/client/locale-sync.ts +34 -0
  356. package/src/client/locales.ts +8 -2
  357. package/src/client/notification-copy.ts +5 -4
  358. package/src/client/settings.css +2 -0
  359. package/src/completion.ts +66 -0
  360. package/src/controls.ts +90 -28
  361. package/src/desktop-lifecycle.ts +10 -0
  362. package/src/index.ts +70 -27
  363. package/src/model.ts +21 -6
  364. package/src/notification-broker.ts +14 -7
  365. package/src/notification-contract.ts +4 -2
  366. package/tests/bridge.test.ts +123 -2
  367. package/tests/chat.test.ts +61 -0
  368. package/tests/completion.test.ts +110 -0
  369. package/tests/controls.test.ts +132 -2
  370. package/tests/daily-rhythm-native.mjs +51 -0
  371. package/tests/daily-rhythm-ui.mjs +166 -0
  372. package/tests/daily-rhythm.test.js +83 -0
  373. package/tests/desktop.mjs +96 -7
  374. package/tests/display-geometry.test.js +55 -0
  375. package/tests/fixtures/desktop-recovery.ts +3 -0
  376. package/tests/fixtures/goal-host.mjs +104 -0
  377. package/tests/fixtures/host.mjs +40 -1
  378. package/tests/fixtures/session-host.mjs +119 -0
  379. package/tests/goal-host-contract.mjs +53 -0
  380. package/tests/helpers/daily-rhythm.mjs +34 -0
  381. package/tests/helpers/desktop-recovery.mjs +25 -0
  382. package/tests/helpers/installed-notifications.mjs +1 -1
  383. package/tests/helpers/multi-display-native.mjs +19 -0
  384. package/tests/helpers/native-pointer.mjs +37 -9
  385. package/tests/helpers/text-scale-native.mjs +34 -0
  386. package/tests/inbox-ui.mjs +2 -1
  387. package/tests/install.mjs +144 -3
  388. package/tests/locale-client.mjs +25 -0
  389. package/tests/locale-sync.test.ts +36 -0
  390. package/tests/locale-ui.mjs +79 -0
  391. package/tests/model.test.ts +15 -4
  392. package/tests/multi-display-native.mjs +91 -0
  393. package/tests/multi-display-ui.mjs +95 -0
  394. package/tests/notification-broker.test.ts +1 -1
  395. package/tests/notification-client.test.ts +8 -1
  396. package/tests/notification-integration.test.ts +50 -2
  397. package/tests/notification-ui.mjs +18 -0
  398. package/tests/plugin.test.ts +84 -13
  399. package/tests/presentation.test.js +27 -1
  400. package/tests/session-host-contract.mjs +53 -0
  401. package/tests/session-recovery.test.ts +20 -0
  402. package/tests/session-replies-ui.mjs +73 -1
  403. package/tests/text-scale-ui.mjs +113 -0
  404. package/tests/text-scale.test.ts +7 -0
  405. package/tests/ui.mjs +3 -1
  406. package/web/chat-contract.d.ts +4 -0
  407. package/web/chat-contract.js +14 -0
  408. package/web/daily-rhythm.d.ts +6 -0
  409. package/web/daily-rhythm.js +38 -0
  410. package/web/display-geometry.js +30 -0
  411. package/web/index.html +42 -42
  412. package/web/locale.d.ts +8 -0
  413. package/web/locale.js +106 -0
  414. package/web/notification-ui.js +6 -5
  415. package/web/pet.js +238 -83
  416. package/web/session-ui.js +32 -2
  417. package/web/style.css +79 -59
  418. package/web/text-scale.d.ts +4 -0
  419. package/web/text-scale.js +6 -0
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # DeepSeek 大肥鱼 · dsh-coopanion
2
2
 
3
- 给 [DeepSeek Harness Desktop](https://github.com/deepseek-ai/deepseek-harness) 加一只桌面伙伴。她会陪你工作,在任务完成、出错或需要确认时提醒你;双击角色,可以向已打开的 Harness 会话发送消息。
3
+ 给 [DeepSeek Harness Desktop](https://github.com/deepseek-ai/deepseek-harness) 加一只桌面伙伴。她会陪你工作,在回复生成、目标完成、出错或需要确认时提醒你;双击角色,可以继续选中的 Harness 普通会话,包括尚未打开的历史会话。
4
4
 
5
- **v0.4.7 使用 Coopanion 的原生动画与角色运行时,组合程序采用 AGPL-3.0-or-later。** 大肥鱼的网格变形、弹簧动作、动态五官、物理拖拽和八套配色直接复用上游固定版本。角色贴图保留独立权利声明,见 [第三方声明](THIRD_PARTY_NOTICES.md) 和 [上游版本记录](web/upstream/UPSTREAM.md)。
5
+ **v0.4.9 使用 Coopanion 的原生动画与角色运行时,组合程序采用 AGPL-3.0-or-later。** 大肥鱼的网格变形、弹簧动作、动态五官、物理拖拽和八套配色直接复用上游固定版本。角色贴图保留独立权利声明,见 [第三方声明](THIRD_PARTY_NOTICES.md) 和 [上游版本记录](web/upstream/UPSTREAM.md)。
6
6
 
7
- 本次更新将同一会话的未读回合合并为最新回复,并为完整阅读提供 Markdown 标题、粗体、表格、列表和代码块渲染。查看 [最新修改记录](https://github.com/takboo/dsh-coopanion/releases/latest) 或 [完整版本记录](docs/release-notes.md)。
7
+ 本次更新改进目标完成判断、历史会话续接、异常恢复、文字大小与多屏定位,并新增默认关闭的日常陪伴节奏。查看 [最新修改记录](https://github.com/takboo/dsh-coopanion/releases/latest) 或 [完整版本记录](docs/release-notes.md)。
8
+
9
+ M1–M6 的实现与本地验收记录已归档:[完成语义](docs/evidence/m1/README.md)、[会话续接](docs/evidence/m2/README.md)、[异常恢复](docs/evidence/m3/README.md)、[文字可读性](docs/evidence/m4/README.md)、[多屏适配](docs/evidence/m5/README.md)及[日常陪伴节奏](docs/evidence/m6/README.md)。这些历史记录绑定当时的源码与 v0.4.8 测试包;v0.4.9 分发产物由 CI 单独验证。物理多屏 / 混合 DPI、长期体验与资源表现、真实模型及系统通知中心验收仍待完成。
8
10
 
9
11
  ## 功能
10
12
 
@@ -12,21 +14,22 @@
12
14
  - 上游动作和表情:走路、跑步、跳跃、挥手、鞠躬、跳舞、坐下、睡眠等;拖拽、抛掷与落地由同一物理系统处理。
13
15
  - 最终回复使用描边气泡,短预览在最多约 3 秒内显示;可立即显示、展开完整阅读和返回源会话。嘴部同步与合成音效可关闭,不是 TTS。
14
16
  - `figure.json` API 2 ZIP 角色包导入、动画预览、配色 / 多轴换装、切换、删除;角色和搭配在重启后保留。
17
+ - 支持拖拽松手切换到原生鼠标所在显示器,也可从托盘 **移到显示器** 选择;拔掉当前屏后回到有效工作区,其他屏变化保持当前位置,阅读和草稿在当前窗口保留。物理多屏 / 混合 DPI 仍待实机验收,受控与本机结果见 M5 记录。
15
18
  - 透明、无边框、置顶桌宠;空白区域点击穿透。点击互动、双击聊天、右键菜单、闲时活动、休息和显示 / 隐藏。
16
19
  - 角色周围不显示常驻操作按钮或名称标签;有未读回复、待处理审批 / 提问或异常时出现小信封。聊天面板中点击当前会话可切换对话。
17
20
  - Harness 原生 **Settings → 桌宠** 页面:运行状态、启动 / 重启 / 关闭、显示 / 隐藏、角色管理及实时保存的偏好设置。
18
- - 实时思考 / 生成 / 工具工作动画;完成、审批、AI 提问、出错和各类停止通过角色表情与互动提示呈现。流式片段驱动嘴部,最终回复独立进入阅读气泡;完成表情约 2.5 秒后回到待机。
21
+ - 实时思考 / 生成 / 工具工作动画;完成、审批、AI 提问、出错和各类停止通过角色表情与互动提示呈现。流式片段驱动嘴部,最终回复独立进入阅读气泡;只有已提交目标完成才庆祝,约 2.5 秒后回到待机。普通回合和目标中间轮保留全文及未读,提示“本轮回复已生成”;目标继续、暂停和阻塞分别呈现。
19
22
  - 角色显示时由角色提醒;运行中隐藏角色时,可由 Harness 发送系统通知并点击返回源会话。系统通知默认关闭,设置页提供权限申请、测试通知和送达回执。
20
23
  - 审批与 AI 提问的待处理列表、默认 10 分钟后的一次自动补提醒及“稍后提醒”;同一会话同时到期的请求合并提示。
21
24
  - 会话以真实提问、项目路径、时间和有效短编号区分,支持搜索及键盘切换;旧会话从公开历史恢复提问。
22
25
  - 菜单与聊天使用角色风格的描边卡片,颜色跟随换装;摸头、叫醒、拖拽等互动使用上游身体事件。
23
26
  - macOS 状态栏采用随系统明暗变化的角色模板图标与状态小图形,不显示状态文字;悬停和菜单保留会话、任务、未读及设置详情,与桌面共用状态判断和持久偏好。
24
- - 聊天输入通过 `Agent.followup()` 进入 Harness 的持久会话,使用其现有模型、工具和权限。互动和换装不会自动发起模型请求。
27
+ - 聊天输入通过正式 `sessionController.prompt`(`mode: queue`) 进入 Harness 的持久会话,使用其现有模型、工具和权限。互动和换装不会自动发起模型请求。
25
28
  - 菜单提供 **源码 · AGPL**,包含对应源代码、上游运行时、构建脚本和依赖锁文件。
26
29
 
27
30
  桌宠不作出审批,也不单独收集 API Key。聊天始终发给明确选中的关注会话,新建会话和后台任务不会自动切换目标。关注会话进行中时优先展示它的动作;空闲时用动作反映后台工作或确认 / 异常。状态栏图形优先提示任一会话的确认 / 异常,菜单显示详情。
28
31
 
29
- 信封直接打开回复与待办收件箱:同一会话的多个未读回合合并展示最新回复,未读数量按会话计算。只有一份回复时展开全文;多份回复显示摘要和各自的 **继续对话 ↗**,审批、提问及异常提供 **去处理 ↗**。全文支持 Markdown 标题、粗体、列表、表格和代码块。阅读不会切换正在聊天的会话;收件箱阅读器可连续读不同会话的结果,并返回收件箱查看新内容。正在阅读的回复不会被新结果替换。保留最近 200 份完整结果,优先淘汰已读;只有本次 Harness 运行中实时完成的回复计入未读,打开历史会话或重启 Harness 不会把旧回复重新标为未读。重启后原始对话仍由 Harness 保存;任务动画根据当前 Agent 的运行状态恢复。
32
+ 信封直接打开回复与待办收件箱:同一会话的多个未读回合合并展示最新回复,未读数量按会话计算。只有一份回复时展开全文;多份回复显示摘要和各自的 **继续对话 ↗**(在桌宠输入框继续来源会话),审批、提问及异常提供 **去处理 ↗**。全文支持 Markdown 标题、粗体、列表、表格和代码块。阅读不会切换正在聊天的会话;收件箱阅读器可连续读不同会话的结果,并返回收件箱查看新内容。正在阅读的回复不会被新结果替换。保留最近 200 份完整结果,优先淘汰已读;只有本次 Harness 运行中实时完成的回复计入未读,打开历史会话或重启 Harness 不会把旧回复重新标为未读。重启后原始对话仍由 Harness 保存;任务动画根据当前 Agent 的运行状态恢复。
30
33
 
31
34
  回复气泡展示或自动收起、查看收件箱摘要及收起收件箱均不会标记已读;主动展开阅读、关闭单份回复气泡或通过该回复回到源会话时,确认展示时合并的未读回合。阅读期间新到的回合继续保留未读,旧回合的完整结果仍可通过历史导航查看。审批与 AI 提问由 Harness 的实际答复、决定或取消结果结算;查看、收起互动提示或打开源会话均不会代替处理请求。
32
35
 
@@ -44,7 +47,7 @@ v0.4.0 移除了旧 Canvas 关键帧引擎、`dsh-character` v1 协议、`.dshpe
44
47
 
45
48
  支持 **DSH 0.2.0-rc.2 和 0.2.1-alpha.1**;其他版本未声明兼容。
46
49
 
47
- 1. 下载对应 [Release](https://github.com/takboo/dsh-coopanion/releases) 的 `dsh-coopanion-0.4.7.tgz`,或按下面步骤构建 `takboo-dsh-coopanion-0.4.7.tgz`。npm 包名为 `@takboo/dsh-coopanion`;本地 `npm pack` 的文件名包含 scope。
50
+ 1. 下载对应 [Release](https://github.com/takboo/dsh-coopanion/releases) 的 `dsh-coopanion-0.4.9.tgz`,或按下面步骤构建 `takboo-dsh-coopanion-0.4.9.tgz`。npm 包名为 `@takboo/dsh-coopanion`;本地 `npm pack` 的文件名包含 scope。
48
51
  2. 在 Harness 侧边栏 **插件** 页安装压缩包的绝对路径,启用 `dsh-coopanion`。
49
52
  3. 完全退出再重新打开 Harness。首次启动时会下载并校验 Electron 44 运行时。
50
53
  4. 打开一段 Harness 会话,双击角色聊天,或从 **Settings → 桌宠** 管理角色。
@@ -52,13 +55,15 @@ v0.4.0 移除了旧 Canvas 关键帧引擎、`dsh-character` v1 协议、`.dshpe
52
55
  也可使用 Desktop 自带的 CLI。先启动 Desktop 一次初始化 profile,完全退出应用,再执行:
53
56
 
54
57
  ```bash
55
- dsh plugin --profile desktop add /absolute/path/dsh-coopanion-0.4.7.tgz
58
+ dsh plugin --profile desktop add /absolute/path/dsh-coopanion-0.4.9.tgz
56
59
  ```
57
60
 
58
61
  npm 安装的 dsh 不能管理 Desktop 所拥有的 profile。Desktop 完全退出后执行包管理命令,再重新打开应用。
59
62
 
60
63
  ## 开发与验证
61
64
 
65
+ 后续改进的范围、实施顺序与验收条件见[桌面伙伴改进路线图](docs/roadmap.md)。
66
+
62
67
  通知阶段及交付状态见 [通知执行计划](docs/notification-plan.md),本轮集成验收范围见 [N3 验收记录](docs/notification-n3.md)。
63
68
 
64
69
  开发工具链固定 Node.js 24.21.0 和 npm 11.19.1。Electron 支持 Windows、macOS、Linux;Linux 的窗口测试需要 X11 / XWayland 或 Xvfb,以及 Python 3 和 libX11,用于同步原生鼠标位置。原生网格需要 Chromium 的 WebGL 支持。
@@ -101,7 +106,11 @@ npm run character:pack -- examples/star paper-star.zip
101
106
 
102
107
  ## 配置与会话
103
108
 
104
- **Settings → 桌宠** 沿用 Harness 的主题、中英文与系统语言设置。可控制随 Harness 启动、闲时活动、任务通知、系统通知、待处理请求补提醒、等待时间、角色尺寸(90–240)和气泡时长(2–60 秒);数值按 Enter 或离开输入框保存。
109
+ **Settings → 桌宠** 沿用 Harness 的主题、中英文与系统语言设置。可控制随 Harness 启动、闲时活动、任务通知、系统通知、待处理请求补提醒、等待时间、角色尺寸(90–240)、文字大小(100% / 125% / 150%)和气泡时长(2–60 秒);数值按 Enter 或离开输入框保存。文字大小选择后立即保存并同步到当前桌宠,独立于角色尺寸,保留当前阅读、草稿与在途发送;旧配置默认 100%。
110
+
111
+ **日常陪伴节奏** 默认关闭,旧配置沿用原有闲时动作。开启闲时走动及此偏好后,按系统本地时间在 07:00–22:00 每 45–90 秒尝试现有轻动作,夜间每 2–4 分钟仅轻点头或坐下;缺少动作时保持待机。任务、待办、阅读、输入、拖拽、用户休息及减少动态效果始终优先,占用解除后重新等待,动作结束恢复当前神态。偏好立即同步并持久保存,不增加模型请求或通知,详见[日常节奏契约](docs/daily-rhythm-contract.md)及[本地验证边界](docs/evidence/m6/README.md)。
112
+
113
+ 桌宠意外退出后按 1、3、10 秒间隔最多自动恢复三次,连续稳定运行 60 秒后清零。设置页显示恢复次数和诊断,可随时关闭或在失败后手动重启;主动关闭不触发恢复。隐藏的角色恢复后仍隐藏,关注会话、完整结果、未读和有效待办保留,旧结果不再次主动提醒。窗口内草稿与阅读位置会随进程退出丢失,恢复不会重发聊天或任务。缺少图形环境、无效运行时路径或未确认清理的进程直接反馈错误,详见[恢复契约](docs/desktop-recovery-contract.md)。
105
114
 
106
115
  ```yaml
107
116
  - id: dsh-coopanion
@@ -109,6 +118,7 @@ npm run character:pack -- examples/star paper-star.zip
109
118
  autoStart: true
110
119
  size: 180
111
120
  roam: true
121
+ dailyRhythm: false
112
122
  notifications: true
113
123
  systemNotifications: false
114
124
  reminders: true
@@ -119,7 +129,7 @@ npm run character:pack -- examples/star paper-star.zip
119
129
 
120
130
  最终回复气泡与事件互动提示分别显示。回复气泡时长从逐字显示完成后计时,鼠标停留或键盘聚焦时暂停收起;互动提示收起后,未处理的审批和提问仍保留在小信封列表。超过 180 字的回复展示按句子截取的开头(不做模型摘要),可展开完整阅读;原文保留且不截断,完整阅读器不会自动关闭。减少动态效果时禁用闲时活动与逐字显示,保留直接拖动及落地。
121
131
 
122
- 桌宠仅展示已加载的顶层会话,忽略子代理;首次可用会话成为当前对话,之后保持用户选中的关注会话。未加载的历史会话需先在 Harness 中打开。桌面版通过公开的 `dsh://open` 协议唤回 Harness。多个本机客户端同时连接时,返回请求由首先领取的客户端处理。
132
+ 桌宠展示普通顶层会话,忽略子代理;首次可用会话成为当前对话,之后保持用户选中的关注会话。启动时从正式列表恢复最近最多 100 个普通会话,冷会话无需先在 Harness 中打开即可续接。发送中保留草稿,收到“已进入收件队列”回执后才清空;失败可重试,同一次提交复用请求 ID。切换关注会话不会改变在途消息的目标;会话缺失、其他进程占用、权限限制或模型不可用会明确反馈。接受不代表任务完成。详见[会话续接契约](docs/session-chat-contract.md)。桌面版通过公开的 `dsh://open` 协议唤回 Harness。多个本机客户端同时连接时,返回请求由首先领取的客户端处理。
123
133
 
124
134
  ## 提醒与系统通知
125
135
 
@@ -0,0 +1,21 @@
1
+ const { displayTarget } = require('../web/display-geometry.js');
2
+
3
+ // The injected screen/window are also used by the deterministic CI layout tests.
4
+ module.exports.createDisplayController = ({ screen, win, send, changed = () => {} }) => {
5
+ let currentId = screen.getPrimaryDisplay().id, previous, state, lastKey, revision = 0;
6
+ const publish = () => { if (state) send({ type: 'display-changed', ...state }); };
7
+ function refresh({ point, displayId } = {}) {
8
+ const target = displayTarget(screen.getAllDisplays(), { currentId, previous, point, displayId });
9
+ if (!target) return;
10
+ currentId = target.id; previous = { ...target.workArea };
11
+ const b = win.getBounds();
12
+ if (['x', 'y', 'width', 'height'].some(k => b[k] !== target.workArea[k])) win.setBounds(target.workArea);
13
+ const next = { displayId: target.id, workArea: { ...target.workArea }, contentBounds: win.getContentBounds(), scaleFactor: target.scaleFactor };
14
+ const key = JSON.stringify(next);
15
+ if (key !== lastKey) {
16
+ lastKey = key; state = { ...next, revision: ++revision }; publish(); changed();
17
+ }
18
+ }
19
+ return { refresh, publish, get state() { return state; }, moveToCursor() { const before = revision; refresh({ point: screen.getCursorScreenPoint() }); if (before === revision) publish(); },
20
+ cursor() { const p = screen.getCursorScreenPoint(), b = state?.contentBounds; return b ? { type: 'cursor', x: p.x - b.x, y: p.y - b.y, revision: state.revision } : undefined; } };
21
+ };
package/desktop/main.cjs CHANGED
@@ -4,8 +4,10 @@ const { randomBytes } = require('node:crypto');
4
4
  const { once } = require('node:events');
5
5
  const { CharacterStore } = require('../dist/character-store.cjs');
6
6
  const { createPetServer } = require('../dist/figure-server.cjs');
7
- const { trayState } = require('./tray-state.cjs');
8
- app.setName('DeepSeek 大肥鱼');
7
+ const { trayState, trayLocale } = require('./tray-state.cjs');
8
+ const { createDisplayController } = require('./display-controller.cjs');
9
+ const { petCopy, petLanguage } = require('../web/locale.js');
10
+ app.setName(petCopy('en').defaultName);
9
11
  if (process.env.DSH_PET_TEST_DATA_DIR) {
10
12
  app.setPath('userData', process.env.DSH_PET_TEST_DATA_DIR);
11
13
  app.setPath('crashDumps', join(process.env.DSH_PET_TEST_DATA_DIR, 'crashes'));
@@ -21,12 +23,15 @@ if (process.env.DSH_PET_TEST_DEBUG_PORT) {
21
23
  app.commandLine.appendSwitch('remote-debugging-address', '127.0.0.1');
22
24
  app.commandLine.appendSwitch('remote-debugging-port', process.env.DSH_PET_TEST_DEBUG_PORT);
23
25
  }
24
- let win, tray, options, lastFrame, poll, assetServer, characters;
26
+ const displayTest = process.env.DSH_PET_TEST_NO_SANDBOX === '1' && !!process.env.DSH_PET_TEST_DEBUG_PORT;
27
+ let win, tray, options, lastFrame, poll, assetServer, characters, displays;
25
28
  let presentation = {}, lastTrayKey, lastIconKey, iconBase, iconAppearance;
26
29
  let interactive = null;
27
30
  const generation = Number(process.env.DSH_PET_GENERATION ?? 1);
28
- let visibilityRevision = 0, suspended = false, screenLocked = false, systemAsleep = false;
29
- function visibility() { if (win && !win.isDestroyed()) { process.send?.({ type: 'visibility', generation, visibilityRevision: ++visibilityRevision, visible: win.isVisible(), suspended }); syncTray(); } }
31
+ let visibilityRevision = 0, screenLocked = process.env.DSH_PET_SCREEN_LOCKED === '1', systemAsleep = process.env.DSH_PET_SYSTEM_ASLEEP === '1';
32
+ let suspended = screenLocked || systemAsleep;
33
+ let desiredVisible = process.env.DSH_PET_VISIBLE !== '0', userClosed = false;
34
+ function visibility() { if (win && !win.isDestroyed()) { process.send?.({ type: 'visibility', generation, visibilityRevision: ++visibilityRevision, visible: win.isVisible(), desiredVisible, suspended, screenLocked, systemAsleep }); syncTray(); } }
30
35
  function forward(message) { if (win && !win.isDestroyed()) win.webContents.send('pet:update', message); }
31
36
  function hit(active) {
32
37
  if (!win || win.isDestroyed()) return;
@@ -36,12 +41,17 @@ function hit(active) {
36
41
  }
37
42
  forward({ type: 'hit-state', active, focused: win.isFocused(), visible: win.isVisible() });
38
43
  }
39
- function show() { win?.showInactive(); syncTray(); }
44
+ function show() { desiredVisible = true; win?.showInactive(); visibility(); }
45
+ function hide() { desiredVisible = false; win?.hide(); visibility(); }
40
46
  function act(action) { process.send?.({ type: 'action', action }); }
41
47
  function syncTray() {
42
48
  if (!tray || tray.isDestroyed()) return;
43
- const state = trayState(lastFrame?.snapshot, presentation, options, win?.isVisible());
44
- const key = JSON.stringify(state);
49
+ const locale = trayLocale(options, presentation, app.getPreferredSystemLanguages());
50
+ const state = trayState(lastFrame?.snapshot, presentation, { ...options, locale }, win?.isVisible());
51
+ const copy = petCopy(locale);
52
+ if (app.getName() !== copy.defaultName) app.setName(copy.defaultName);
53
+ const displayList = screen.getAllDisplays();
54
+ const key = JSON.stringify([state, displays?.state?.displayId, displayList.map(d => [d.id, d.label])]);
45
55
  if (key === lastTrayKey) return;
46
56
  lastTrayKey = key;
47
57
  tray.setToolTip(state.tooltip);
@@ -49,19 +59,20 @@ function syncTray() {
49
59
  tray.setContextMenu(Menu.buildFromTemplate([
50
60
  { label: `${state.name} · ${state.stateLabel}`, enabled: false },
51
61
  { label: state.sessionLabel, enabled: false },
52
- { label: '回到当前会话', enabled: !!state.sessionId, click: () => act({ type: 'open-session', sessionId: state.sessionId }) },
53
- { label: '切换陪伴会话', enabled: !!state.sessions.length, submenu: state.sessions.slice(0, 20).map(session => ({ type: 'radio', label: `${session.label} · ${session.id.replace(/^session[-_:]/, '').slice(-8)}${session.unread ? ` · ${session.unread} 份未读` : ''}${['waiting', 'error'].includes(session.mood) ? ' · 需要你' : ''}`, checked: session.selected, click: () => act({ type: 'select', sessionId: session.id }) })) },
54
- { label: `待查看 · ${state.activity.unread} 份回复 · ${state.activity.waiting + state.activity.errors} 段需要你`, click: () => { show(); forward({ type: 'ui-control', command: 'sessions' }); } },
62
+ { label: copy.trayOpen, enabled: !!state.sessionId, click: () => act({ type: 'open-session', sessionId: state.sessionId }) },
63
+ { label: copy.traySwitch, enabled: !!state.sessions.length, submenu: state.sessions.slice(0, 20).map(session => ({ type: 'radio', label: `${session.label} · ${session.id.replace(/^session[-_:]/, '').slice(-8)}${session.unread ? copy.trayUnread(session.unread) : ''}${['waiting', 'error'].includes(session.mood) ? copy.trayNeeds : ''}`, checked: session.selected, click: () => act({ type: 'select', sessionId: session.id }) })) },
64
+ { label: copy.trayPending(state.activity.unread, state.activity.waiting + state.activity.errors), click: () => { show(); forward({ type: 'ui-control', command: 'sessions' }); } },
55
65
  { type: 'separator' },
56
- { label: '说句话', click: () => { show(); forward({ type: 'ui-control', command: 'chat' }); } },
57
- { label: '角色与配色', click: () => { show(); forward({ type: 'characters' }); } },
58
- { label: '自在走动', type: 'checkbox', checked: state.roam, click: item => act({ type: 'preference', field: 'roam', value: item.checked }) },
59
- { label: '休息一下(新任务会唤醒)', type: 'checkbox', checked: state.sleeping, enabled: !state.active, click: () => forward({ type: 'ui-control', command: 'sleep' }) },
60
- { label: '任务提醒', type: 'checkbox', checked: state.notifications, click: item => act({ type: 'preference', field: 'notifications', value: item.checked }) },
61
- { label: '动作与说话音效', type: 'checkbox', checked: state.sound, click: () => forward({ type: 'ui-control', command: 'sound' }) },
66
+ { label: copy.trayChat, click: () => { show(); forward({ type: 'ui-control', command: 'chat' }); } },
67
+ { label: copy.trayCharacters, click: () => { show(); forward({ type: 'characters' }); } },
68
+ { label: copy.trayDisplay, submenu: displayList.map(d => ({ type: 'radio', label: `${d.label || copy.display} · ${d.id}`, checked: d.id === displays?.state?.displayId, click: () => displays.refresh({ displayId: d.id }) })) },
69
+ { label: copy.trayRoam, type: 'checkbox', checked: state.roam, click: item => act({ type: 'preference', field: 'roam', value: item.checked }) },
70
+ { label: copy.traySleep, type: 'checkbox', checked: state.sleeping, enabled: !state.active, click: () => forward({ type: 'ui-control', command: 'sleep' }) },
71
+ { label: copy.trayNotices, type: 'checkbox', checked: state.notifications, click: item => act({ type: 'preference', field: 'notifications', value: item.checked }) },
72
+ { label: copy.traySound, type: 'checkbox', checked: state.sound, click: () => forward({ type: 'ui-control', command: 'sound' }) },
62
73
  { type: 'separator' },
63
- { label: state.visible ? '暂时藏起来' : '显示伙伴', click: () => state.visible ? win.hide() : show() },
64
- { label: '关闭桌宠', click: () => app.quit() },
74
+ { label: state.visible ? copy.hide : copy.trayShow, click: () => state.visible ? hide() : show() },
75
+ { label: copy.trayQuit, click: () => { userClosed = true; app.quit(); } },
65
76
  ]));
66
77
  process.send?.({ type: 'tray-state', state });
67
78
  const iconKey = `${state.characterId}:${state.scheme}:${state.iconReady}:${state.icon}`;
@@ -94,24 +105,20 @@ async function syncIcon(state, key) {
94
105
  }
95
106
  } catch { /* Keep the packaged icon when a pack thumbnail cannot be rendered. */ }
96
107
  }
97
- function bounds() {
98
- const display = screen.getDisplayNearestPoint(screen.getCursorScreenPoint());
99
- return display.workArea;
100
- }
101
-
102
108
  process.on('message', message => {
103
109
  if (!message || typeof message !== 'object') return;
104
110
  if (message.type === 'quit') { app.quit(); return; }
105
111
  if (message.type === 'init') { options = message.options; lastFrame = message; forward(message); syncTray(); }
106
112
  if (message.type === 'configure') { options = message.options; if (lastFrame) lastFrame.options = options; forward(message); syncTray(); }
107
113
  if (message.type === 'control') {
108
- if (message.command === 'hide') win?.hide();
114
+ if (message.command === 'hide') hide();
109
115
  if (message.command === 'show' || message.command === 'characters') show();
110
116
  if (message.command === 'characters') forward({ type: 'characters' });
111
117
  // Fixed public Desktop protocol; no renderer-supplied URL or private shell IPC.
112
118
  if (message.command === 'focus-harness' && process.env.DSH_PET_TEST_NO_SANDBOX !== '1') void shell.openExternal('dsh://open').catch(() => {});
113
119
  }
114
- if (message.type === 'snapshot') { lastFrame = { type: 'init', options, snapshot: { ...message.snapshot, results: message.snapshot.results ?? lastFrame?.snapshot?.results ?? [] } }; forward(message); syncTray(); }
120
+ if (message.type === 'snapshot') { lastFrame = { type: 'init', baseline: true, options, snapshot: { ...message.snapshot, results: message.snapshot.results ?? lastFrame?.snapshot?.results ?? [] } }; forward(message); syncTray(); }
121
+ if (message.type === 'chat-result') forward(message);
115
122
  if (message.type === 'notification-state' || message.type === 'notification-snooze-result') forward(message);
116
123
  if (message.type === 'notice') {
117
124
  if (message.generation !== undefined && (message.generation !== generation || message.visibilityRevision !== visibilityRevision || !win?.isVisible() || suspended)) return;
@@ -122,6 +129,7 @@ process.on('disconnect', () => app.quit());
122
129
  process.on('SIGTERM', () => app.quit());
123
130
 
124
131
  app.whenReady().then(async () => {
132
+ const { chatRequest } = await import('../web/chat-contract.js');
125
133
  const webRoot = join(__dirname, '../web');
126
134
  characters = new CharacterStore(join(app.getPath('userData'), 'figures-v2'), join(webRoot, 'upstream/whale'));
127
135
  const prefix = `/${randomBytes(24).toString('hex')}/`;
@@ -149,9 +157,10 @@ app.whenReady().then(async () => {
149
157
  if (!(value instanceof ArrayBuffer)) throw new Error('请选择 API 2 ZIP 角色包');
150
158
  return characters.import(new Uint8Array(value));
151
159
  });
152
- win = new BrowserWindow({ ...screen.getPrimaryDisplay().workArea, transparent: true, frame: false, resizable: false, skipTaskbar: true, hasShadow: false, show: false, alwaysOnTop: true, backgroundColor: '#00000000', webPreferences: { preload: join(__dirname, 'preload.cjs'), sandbox: true, contextIsolation: true, nodeIntegration: false } });
160
+ win = new BrowserWindow({ ...screen.getPrimaryDisplay().workArea, transparent: true, frame: false, resizable: false, skipTaskbar: true, hasShadow: false, show: false, alwaysOnTop: true, backgroundColor: '#00000000', webPreferences: { additionalArguments: displayTest ? ['--dsh-pet-display-test'] : [], preload: join(__dirname, 'preload.cjs'), sandbox: true, contextIsolation: true, nodeIntegration: false } });
153
161
  win.setAlwaysOnTop(true, 'floating');
154
162
  win.on('show', visibility); win.on('hide', visibility);
163
+ win.webContents.on('render-process-gone', () => app.exit(1));
155
164
  const suspendState = () => { suspended = screenLocked || systemAsleep; visibility(); };
156
165
  powerMonitor.on('suspend', () => { systemAsleep = true; suspendState(); });
157
166
  powerMonitor.on('resume', () => { systemAsleep = false; suspendState(); });
@@ -162,41 +171,48 @@ app.whenReady().then(async () => {
162
171
  win.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
163
172
  win.webContents.on('will-navigate', event => event.preventDefault());
164
173
  win.webContents.session.setPermissionRequestHandler((_contents, _permission, callback) => callback(false));
165
- win.webContents.on('did-finish-load', () => { if (lastFrame) forward(lastFrame); });
174
+ displays = createDisplayController({ screen, win, send: forward, changed: syncTray });
175
+ displays.refresh();
176
+ if (displayTest) require('./test-display-probe.cjs').installDisplayProbe({ ipcMain, screen, win, displays });
177
+ for (const event of ['resize', 'move']) win.on(event, () => setImmediate(() => { if (!win.isDestroyed()) displays.refresh(); }));
178
+ win.webContents.on('did-finish-load', () => { if (lastFrame) forward(lastFrame); displays.publish(); });
166
179
  ipcMain.on('pet:hit', (event, active) => { if (event.sender === win.webContents && event.senderFrame === win.webContents.mainFrame && typeof active === 'boolean') hit(active); });
167
180
  ipcMain.on('pet:action', (event, action) => {
168
181
  if (event.sender !== win.webContents || event.senderFrame !== win.webContents.mainFrame || !action || typeof action !== 'object') return;
169
- if (action.type === 'hide') { win.hide(); return; }
170
- if (action.type === 'move-display') { win.setBounds(bounds()); forward({ type: 'display-changed' }); return; }
182
+ if (action.type === 'hide') { hide(); return; }
183
+ if (action.type === 'move-display') { displays.moveToCursor(); return; }
171
184
  if (action.type === 'presentation') {
172
185
  if (typeof action.characterId !== 'string' || !/^[a-z0-9-]{1,32}$/.test(action.characterId) || typeof action.scheme !== 'string' || action.scheme.length > 200 || typeof action.name !== 'string' || action.name.length > 200 || typeof action.sleeping !== 'boolean' || typeof action.sound !== 'boolean') return;
173
- presentation = { characterId: action.characterId, scheme: action.scheme, name: action.name, sleeping: action.sleeping, sound: action.sound, ready: action.ready === true }; syncTray(); return;
186
+ presentation = { characterId: action.characterId, scheme: action.scheme, name: action.name, locale: typeof action.locale === 'string' ? petLanguage(action.locale) : undefined, sleeping: action.sleeping, sound: action.sound, ready: action.ready === true }; syncTray(); return;
174
187
  }
175
188
  if (action.type === 'notification-snooze') { if (typeof action.interactionId === 'string' && action.interactionId.length <= 2048 && Number.isSafeInteger(action.generation)) act(action); return; }
176
- if (action.type !== 'chat' && action.type !== 'select' && action.type !== 'open-session' && action.type !== 'preference' && action.type !== 'read') return;
189
+ if (action.type === 'chat') { const request = chatRequest(action); if (request) act(request); return; }
190
+ if (action.type !== 'select' && action.type !== 'open-session' && action.type !== 'preference' && action.type !== 'read') return;
177
191
  process.send?.({ type: 'action', action });
178
192
  });
179
193
  hit(false);
180
194
  await win.loadURL(`http://127.0.0.1:${assetServer.address().port}${prefix}`);
181
- show();
195
+ if (desiredVisible) show(); else visibility();
182
196
  // Restore input when a click-through window misses movement, without repeatedly
183
197
  // overriding the renderer's newer pointer event with a stationary OS cursor.
184
198
  let lastCursor;
185
199
  const pollCursor = () => {
186
200
  if (!win || win.isDestroyed() || !win.isVisible()) return;
187
- const p = screen.getCursorScreenPoint(), b = win.getBounds();
188
- const next = { x: p.x - b.x, y: p.y - b.y };
189
- if (next.x === lastCursor?.x && next.y === lastCursor?.y) return;
190
- lastCursor = next; forward({ type: 'cursor', ...next });
201
+ const next = displays.cursor();
202
+ if (!next || (next.x === lastCursor?.x && next.y === lastCursor?.y && next.revision === lastCursor?.revision)) return;
203
+ lastCursor = next; forward(next);
191
204
  };
192
205
  pollCursor(); poll = setInterval(pollCursor, 100);
193
206
  const icon = nativeImage.createFromPath(join(__dirname, 'icon.png')).resize({ height: 24 });
194
207
  tray = new Tray(icon); syncTray();
195
208
  tray.on('click', show);
196
- screen.on('display-removed', () => { win.setBounds(screen.getPrimaryDisplay().workArea); forward({ type: 'display-changed' }); });
197
- screen.on('display-metrics-changed', () => { const b = win.getBounds(); win.setBounds(screen.getDisplayMatching(b).workArea); forward({ type: 'display-changed' }); });
209
+ for (const event of ['display-added', 'display-removed', 'display-metrics-changed']) screen.on(event, () => { displays.refresh(); lastTrayKey = undefined; syncTray(); });
198
210
  process.send?.({ type: 'ready' });
199
- }).catch(error => { console.error(error); app.exit(1); });
211
+ }).catch(error => {
212
+ console.error(error);
213
+ const failure = { type: 'startup-error', error: String(error?.message ?? error).slice(0, 600), recoverable: ['EADDRINUSE', 'EAGAIN', 'ENOMEM'].includes(error?.code) };
214
+ if (process.connected) process.send(failure, () => app.exit(1)); else app.exit(1);
215
+ });
200
216
 
201
- app.on('before-quit', () => { clearInterval(poll); assetServer?.close(); tray?.destroy(); });
202
- app.on('window-all-closed', () => app.quit());
217
+ app.on('before-quit', () => { if (userClosed) process.send?.({ type: 'closed' }); clearInterval(poll); assetServer?.close(); tray?.destroy(); });
218
+ app.on('window-all-closed', () => { userClosed = true; app.quit(); });
@@ -5,11 +5,13 @@ async function characterCall(channel, value) {
5
5
  return result.value;
6
6
  }
7
7
  contextBridge.exposeInMainWorld('dshPetBridge', {
8
+ ...(process.argv.includes('--dsh-pet-display-test') ? { testScreenPoint: value => ipcRenderer.invoke('pet:test-screen-point', value) } : {}),
8
9
  subscribe(callback) {
9
10
  const listener = (_event, message) => callback(message);
10
11
  ipcRenderer.on('pet:update', listener);
11
12
  return () => ipcRenderer.removeListener('pet:update', listener);
12
13
  },
14
+ // Chat carries its immutable target and client request identity unchanged.
13
15
  action(value) { ipcRenderer.send('pet:action', value); },
14
16
  hit(active) { ipcRenderer.send('pet:hit', active); },
15
17
  characters: {
@@ -0,0 +1,13 @@
1
+ // Read-only native measurements for isolated test profiles. Never loaded by a normal install.
2
+ module.exports.installDisplayProbe = ({ ipcMain, screen, win, displays }) => {
3
+ ipcMain.handle('pet:test-screen-point', (event, value) => {
4
+ if (event.sender !== win.webContents || event.senderFrame !== win.webContents.mainFrame || !value || !['x', 'y', 'width', 'height'].every(k => Number.isFinite(value[k])) || value.width <= 0 || value.height <= 0) return null;
5
+ const b = win.getContentBounds();
6
+ const dip = { x: Math.round(b.x + value.x * b.width / value.width), y: Math.round(b.y + value.y * b.height / value.height) };
7
+ // CoreGraphics cursor points are logical global coordinates. X11/Win32 need
8
+ // the platform converter: global DIP * devicePixelRatio breaks mixed DPI.
9
+ const point = process.platform === 'darwin' ? dip : screen.dipToScreenPoint(dip);
10
+ return { point, dip, geometry: displays.state, contentBounds: b, cursor: screen.getCursorScreenPoint(),
11
+ displays: screen.getAllDisplays().map(d => ({id:d.id,label:d.label,bounds:d.bounds,workArea:d.workArea,scaleFactor:d.scaleFactor,rotation:d.rotation})), electron: process.versions.electron };
12
+ });
13
+ };
@@ -1,17 +1,23 @@
1
- const labels = { idle: '陪伴中', thinking: '正在思考', talking: '正在回复', working: '正在工作', waiting: '等待确认', happy: '任务完成', error: '需要关注', sleeping: '休息中' };
2
1
  const { sessionActivity } = require('../web/session-ui.js');
2
+ const { petCopy, automaticPetLanguage, sessionStateLabel } = require('../web/locale.js');
3
+
4
+ function trayLocale(options = {}, presentation = {}, languages = []) {
5
+ return options.locale ?? presentation.locale ?? automaticPetLanguage(languages);
6
+ }
3
7
 
4
8
  /** Desktop and status bar project the same host snapshot and acknowledged preferences. */
5
9
  function trayState(snapshot = {}, presentation = {}, options = {}, visible = false) {
10
+ const copy = petCopy(options.locale ?? presentation.locale);
6
11
  const selected = snapshot.sessions?.find(session => session.id === snapshot.sessionId);
7
12
  const activity = sessionActivity(snapshot), active = activity.active;
8
13
  const mood = !active && !activity.waiting && !activity.errors && presentation.sleeping ? 'sleeping' : activity.mood;
9
- const name = presentation.name || 'DeepSeek 大肥鱼';
10
- return { name, characterId: presentation.characterId || 'whale', scheme: presentation.scheme || '', iconReady: !!presentation.ready, icon: mood === 'sleeping' ? 'sleeping' : activity.icon, mood, stateLabel: labels[mood] ?? labels.idle, activity, active, sleeping: mood === 'sleeping', visible, roam: options.roam ?? true, notifications: options.notifications ?? true, sound: presentation.sound ?? true,
11
- sessionId: snapshot.sessionId ?? null, sessionLabel: selected?.label ?? '还没有会话',
14
+ const stateLabel = sessionStateLabel(selected, options.locale ?? presentation.locale, mood);
15
+ const name = presentation.name || copy.defaultName;
16
+ return { name, characterId: presentation.characterId || 'whale', scheme: presentation.scheme || '', iconReady: !!presentation.ready, icon: mood === 'sleeping' ? 'sleeping' : activity.icon, mood, stateLabel, activity, active, sleeping: mood === 'sleeping', visible, roam: options.roam ?? true, notifications: options.notifications ?? true, sound: presentation.sound ?? true,
17
+ sessionId: snapshot.sessionId ?? null, sessionLabel: selected?.label ?? copy.noConversation,
12
18
  sessions: [...(snapshot.sessions ?? [])].sort((a, b) => Number(b.id === snapshot.sessionId) - Number(a.id === snapshot.sessionId) || (b.updatedAt ?? 0) - (a.updatedAt ?? 0)).map(session => ({ id: session.id, label: session.label, project: session.project, selected: session.id === snapshot.sessionId, mood: session.mood, unread: Number(!!session.unread) })),
13
- tooltip: `${name} · ${labels[mood] ?? labels.idle}\n关注:${selected?.label ?? '还没有会话'}\n${activity.busy} 段进行中 · ${activity.waiting + activity.errors} 段需要你 · ${activity.unread} 份未读回复`,
19
+ tooltip: copy.trayTooltip(name, stateLabel, selected?.label ?? copy.noConversation, activity.busy, activity.waiting + activity.errors, activity.unread),
14
20
  title: '',
15
21
  };
16
22
  }
17
- module.exports = { trayState };
23
+ module.exports = { trayState, trayLocale };
package/dist/bridge.js CHANGED
@@ -3,39 +3,59 @@ import { spawn } from "node:child_process";
3
3
  import { createRequire } from "node:module";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { EventEmitter } from "node:events";
6
+
7
+ // src/desktop-lifecycle.ts
8
+ var NativeStartError = class extends Error {
9
+ constructor(message, recoverable) {
10
+ super(message);
11
+ this.recoverable = recoverable;
12
+ this.name = "NativeStartError";
13
+ }
14
+ };
15
+
16
+ // src/bridge.ts
6
17
  var ElectronBridge = class extends EventEmitter {
7
18
  child;
8
19
  latest;
20
+ latestOptions;
9
21
  resultKey;
10
22
  closing = false;
11
23
  generation = 0;
12
24
  visibilityRevision = 0;
13
25
  nativeVisible = false;
14
26
  suspended = false;
27
+ screenLocked = false;
28
+ systemAsleep = false;
15
29
  lastNotificationState;
16
30
  async start(options, lifetime) {
17
- if (this.child) throw new Error("Desktop pet is already running");
31
+ if (this.child) throw new NativeStartError("Desktop pet is already running", false);
18
32
  if (lifetime?.signal.aborted) throw new Error("\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88");
33
+ this.latestOptions = { ...options };
19
34
  this.closing = false;
20
35
  this.generation = lifetime?.generation ?? this.generation + 1;
21
36
  this.visibilityRevision = 0;
22
37
  this.nativeVisible = false;
23
- this.suspended = false;
24
- if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) throw new Error("\u684C\u5BA0\u9700\u8981\u684C\u9762\u663E\u793A\u73AF\u5883\u3002");
25
- const executable = options.electronPath ?? createRequire(import.meta.url)("electron");
26
- const env = { ...process.env, DSH_PET_GENERATION: String(this.generation) };
38
+ if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) throw new NativeStartError("\u684C\u5BA0\u9700\u8981\u684C\u9762\u663E\u793A\u73AF\u5883\u3002", false);
39
+ let executable;
40
+ try {
41
+ executable = options.electronPath ?? createRequire(import.meta.url)("electron");
42
+ } catch (error) {
43
+ throw new NativeStartError(String(error).slice(0, 600), false);
44
+ }
45
+ const env = { ...process.env, DSH_PET_GENERATION: String(this.generation), DSH_PET_VISIBLE: lifetime?.visible === false ? "0" : "1", DSH_PET_SCREEN_LOCKED: this.screenLocked ? "1" : "0", DSH_PET_SYSTEM_ASLEEP: this.systemAsleep ? "1" : "0" };
27
46
  delete env.ELECTRON_RUN_AS_NODE;
28
47
  const args = [fileURLToPath(new URL("../desktop/main.cjs", import.meta.url))];
29
48
  if (env.DSH_PET_TEST_NO_SANDBOX === "1") args.unshift("--no-sandbox");
30
49
  const child = spawn(executable, args, { env, stdio: ["ignore", "pipe", "pipe", "ipc"] });
31
50
  const generation = this.generation;
32
51
  this.child = child;
33
- let diagnostic = "";
52
+ let diagnostic = "", userClosed = false;
34
53
  child.stderr?.on("data", (data) => {
35
54
  diagnostic = (diagnostic + data.toString()).slice(-4e3);
36
55
  });
37
56
  child.on("message", (message) => {
38
- if (this.child !== child || !isRecord(message)) return;
57
+ if (this.child !== child || this.closing || lifetime?.signal.aborted || !isRecord(message)) return;
58
+ if (message.type === "closed") userClosed = true;
39
59
  if (message.type === "action") this.emit("action", message.action);
40
60
  if (message.type === "tray-state") this.emit("tray-state", message.state);
41
61
  if (message.type === "tray-icon") this.emit("tray-icon", message);
@@ -43,17 +63,23 @@ var ElectronBridge = class extends EventEmitter {
43
63
  this.visibilityRevision = message.visibilityRevision;
44
64
  this.nativeVisible = message.visible;
45
65
  this.suspended = message.suspended === true;
46
- this.emit("lifecycle", { running: true, visible: this.nativeVisible, generation, visibilityRevision: this.visibilityRevision, suspended: this.suspended });
66
+ if (typeof message.screenLocked === "boolean") this.screenLocked = message.screenLocked;
67
+ if (typeof message.systemAsleep === "boolean") this.systemAsleep = message.systemAsleep;
68
+ this.emit("lifecycle", { running: true, visible: this.nativeVisible, generation, visibilityRevision: this.visibilityRevision, suspended: this.suspended, ...typeof message.desiredVisible === "boolean" ? { desiredVisible: message.desiredVisible } : {} });
47
69
  }
48
70
  });
49
71
  child.once("exit", (code, signal) => {
50
72
  if (this.child !== child) return;
51
73
  this.child = void 0;
52
74
  this.nativeVisible = false;
53
- const error = !this.closing && (code !== 0 || signal) ? `\u684C\u5BA0\u8FDB\u7A0B\u5DF2\u9000\u51FA (${signal ?? code})` : void 0;
54
- this.emit("lifecycle", { running: false, visible: false, generation, visibilityRevision: ++this.visibilityRevision, suspended: false, ...error ? { error } : {} });
75
+ const unexpected = !this.closing && !userClosed && !lifetime?.signal.aborted;
76
+ const error = unexpected ? `\u684C\u5BA0\u8FDB\u7A0B\u5DF2\u9000\u51FA (${signal ?? code}): ${diagnostic}`.slice(0, 600) : void 0;
77
+ this.emit("lifecycle", { running: false, visible: false, generation, visibilityRevision: ++this.visibilityRevision, suspended: false, unexpected, ...error ? { error } : {} });
55
78
  if (error) this.emit("failure", new Error(error));
56
79
  });
80
+ child.on("error", (error) => {
81
+ if (this.child === child && !this.closing && !lifetime?.signal.aborted) this.emit("failure", error);
82
+ });
57
83
  await new Promise((resolve, reject) => {
58
84
  let done = false;
59
85
  const finish = (error) => {
@@ -70,25 +96,27 @@ var ElectronBridge = class extends EventEmitter {
70
96
  } else resolve();
71
97
  };
72
98
  const ready = (message) => {
99
+ if (isRecord(message) && message.type === "startup-error" && this.child === child && typeof message.error === "string") {
100
+ finish(new NativeStartError(message.error.slice(0, 600), message.recoverable === true));
101
+ return;
102
+ }
73
103
  if (isRecord(message) && message.type === "ready" && this.child === child && !lifetime?.signal.aborted) {
74
- this.send({ type: "init", options, snapshot: this.latest && desktopSnapshot(this.latest, true) });
104
+ this.resultKey = void 0;
105
+ this.send({ type: "init", options: { ...this.latestOptions, locale: this.latestOptions?.locale ?? null }, baseline: true, snapshot: this.latest && desktopSnapshot(this.latest, true) });
75
106
  if (this.lastNotificationState) this.notificationState(this.lastNotificationState);
76
107
  finish();
77
108
  }
78
109
  };
79
- const failed = (error) => finish(error);
80
- const exited = (code, signal) => finish(new Error(`\u684C\u5BA0\u542F\u52A8\u5931\u8D25 (${signal ?? code}): ${diagnostic}`));
110
+ const failed = (error) => finish(new NativeStartError(error.message.slice(0, 600), error.code === "EAGAIN" || error.code === "ENOMEM"));
111
+ const exited = (code, signal) => finish(new NativeStartError(`\u684C\u5BA0\u542F\u52A8\u5931\u8D25 (${signal ?? code}): ${diagnostic}`.slice(0, 600), true));
81
112
  const aborted = () => finish(new Error("\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88"));
82
- const timer = setTimeout(() => finish(new Error(`\u684C\u5BA0\u672A\u80FD\u5728 20 \u79D2\u5185\u542F\u52A8: ${diagnostic}`)), 2e4);
113
+ const timer = setTimeout(() => finish(new NativeStartError(`\u684C\u5BA0\u672A\u80FD\u5728 20 \u79D2\u5185\u542F\u52A8: ${diagnostic}`.slice(0, 600), true)), 2e4);
83
114
  child.on("message", ready);
84
115
  child.once("error", failed);
85
116
  child.once("exit", exited);
86
117
  lifetime?.signal.addEventListener("abort", aborted, { once: true });
87
118
  if (lifetime?.signal.aborted) aborted();
88
119
  });
89
- child.on("error", (error) => {
90
- if (this.child === child && !this.closing) this.emit("failure", error);
91
- });
92
120
  }
93
121
  update(snapshot) {
94
122
  this.latest = snapshot;
@@ -111,14 +139,21 @@ var ElectronBridge = class extends EventEmitter {
111
139
  this.send({ type: "notice", notice, generation: runtime.generation, visibilityRevision: runtime.visibilityRevision });
112
140
  return true;
113
141
  }
142
+ chatResult(receipt) {
143
+ this.send(receipt);
144
+ }
114
145
  onAction(listener) {
115
146
  this.on("action", listener);
116
147
  }
117
148
  removeAction(listener) {
118
149
  this.off("action", listener);
119
150
  }
151
+ // JSON IPC omits undefined. An explicit null lets a cleared Harness
152
+ // preference restore the renderer's automatic language instead of retaining
153
+ // its previous locale during a merged configuration update.
120
154
  configure(options) {
121
- this.send({ type: "configure", options });
155
+ this.latestOptions = { ...options };
156
+ this.send({ type: "configure", options: { ...options, locale: options.locale ?? null } });
122
157
  }
123
158
  control(command) {
124
159
  this.send({ type: "control", command });
@@ -133,8 +168,9 @@ var ElectronBridge = class extends EventEmitter {
133
168
  this.off("lifecycle", listener);
134
169
  }
135
170
  send(message) {
136
- if (this.child?.connected) this.child.send(message, (error) => {
137
- if (error && !this.closing) this.emit("failure", error);
171
+ const child = this.child;
172
+ if (child?.connected && !this.closing) child.send(message, (error) => {
173
+ if (error && this.child === child && !this.closing) this.emit("failure", error);
138
174
  });
139
175
  }
140
176
  async dispose() {
@@ -181,6 +217,7 @@ function desktopSnapshot(snapshot, includeResults) {
181
217
  }
182
218
  export {
183
219
  ElectronBridge,
220
+ NativeStartError,
184
221
  isRecord
185
222
  };
186
223
  //# sourceMappingURL=bridge.js.map