@dsh-mobile/mobile-remote 3.3.1 → 3.4.0

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 (58) hide show
  1. package/README.md +9 -5
  2. package/docs/PRIVACY-POLICY.en.md +10 -3
  3. package/docs/PRIVACY-POLICY.md +10 -3
  4. package/docs/USER-GUIDE.zh-CN.md +1 -0
  5. package/lib/account-usage-query.js +60 -60
  6. package/lib/account-usage.js +10 -10
  7. package/lib/api-helpers.js +109 -109
  8. package/lib/assistant-prefs.js +82 -59
  9. package/lib/auto-config.js +65 -65
  10. package/lib/backup.js +117 -117
  11. package/lib/break-reminder.js +45 -45
  12. package/lib/client.js +93 -93
  13. package/lib/config.js +232 -218
  14. package/lib/git-read-bundled-provider.js +12 -12
  15. package/lib/git-read-service.js +5 -5
  16. package/lib/host-compat.js +84 -84
  17. package/lib/http-util.js +17 -17
  18. package/lib/index.js +1534 -1534
  19. package/lib/memory/context.js +44 -44
  20. package/lib/memory/decay.js +93 -93
  21. package/lib/memory/extract.js +77 -77
  22. package/lib/memory/routes.js +33 -33
  23. package/lib/memory/store.js +196 -196
  24. package/lib/notify-copy.js +93 -93
  25. package/lib/permission-guide.js +86 -86
  26. package/lib/persona-cards.js +73 -65
  27. package/lib/phone-action-args.js +175 -0
  28. package/lib/phone-actions.js +227 -0
  29. package/lib/phone-announce.js +58 -0
  30. package/lib/proactive-material.js +42 -42
  31. package/lib/proactive.js +121 -121
  32. package/lib/protected-paths.js +79 -79
  33. package/lib/protocol.js +61 -26
  34. package/lib/push.js +29 -29
  35. package/lib/rate-limit.js +16 -16
  36. package/lib/relay/connector.js +246 -102
  37. package/lib/relay/crypto.js +15 -15
  38. package/lib/relay/devices.js +36 -36
  39. package/lib/relay/fingerprint.js +34 -34
  40. package/lib/relay/identity.js +26 -26
  41. package/lib/relay/mux.js +60 -46
  42. package/lib/relay/noise.js +40 -40
  43. package/lib/relay/on-demand.js +33 -33
  44. package/lib/relay/p2p.js +239 -0
  45. package/lib/relay/pairing.js +24 -24
  46. package/lib/relay/phone.js +62 -40
  47. package/lib/relay/serve.js +21 -21
  48. package/lib/relay/signal.js +69 -0
  49. package/lib/relay/ws-server.js +32 -32
  50. package/lib/reminders.js +15 -15
  51. package/lib/rpc-adapter.js +43 -43
  52. package/lib/session-list.js +31 -31
  53. package/lib/session-rotation.js +95 -95
  54. package/lib/session-title-cache.js +35 -35
  55. package/lib/session-title-refresh.js +51 -51
  56. package/lib/timeline.js +140 -140
  57. package/lib/turn-outline.js +104 -104
  58. package/package.json +6 -13
package/README.md CHANGED
@@ -27,13 +27,13 @@
27
27
  - 🏢 **模型提供商互通**:PC 端「设置 → 模型」与手机同一配置通道——37 个内置提供商(anthropic / openai / google / groq 等)手机可见可配(baseURL + API Key 即激活),模型选择器按提供商分组,设置页「模型提供商」可搜索/编辑/探测模型
28
28
  - 👀 **过程可见性**:活动条(思考中 / 正在调用工具实时状态行)+ 可折叠思考面板(默认只显示状态)
29
29
  - 🛠️ **会话工具**:运行中的后台任务实时卡片(可取消)+ 三页签弹层——任务 / 子代理(查看+中断)/ 目标(查看、创建、暂停、继续、标记完成,与 PC 端 goal 服务同源)
30
- - 🧍 **桌面宠物**:Android 悬浮宠物就是首页的那个女孩(动画由角色包渲染);首页角色是分层的活动角色(`lib/character/character_view.dart`:按任务/通知状态切换动作,会眨眼,点头部/身体/尾巴有反应)。宠物常驻桌面——任务/通知/余额驱动 16 组动作(思考、处理、等待、完成、出错、待机微动作);点头部/身体/尾巴互动,双击摸头,拖动悬空+落地,长按打开迷你面板(运行中会话 / 通知 / 用量与额度 / 余额 / 打开 App);拖到边缘或角落会探头(只露出头和手扒着屏幕边,悬浮窗只有露出的那一块,不挡旁边的触摸),点一下跳出来,完成/等待/出错时也会跳出来提示;随机眨眼;默认约 50dp 高,四档大小与减少动效;**App 在前台时自动收起**(不与首页角色同屏、不挡按钮);错过的通知也会补提示(气泡/角标/横幅)
31
- - 🎨 **外观:皮肤与图标**:四套皮肤(默认 / 深潜夜航 / 海盐汽水 / 鲸落星海,各含明暗两套)——三套角色皮肤下首页换成角色 Hero + 动态背景(气泡/声呐环/星尘月盘的 30fps 上限动画),角色可点头部/身体/尾巴互动、长按开面板;App 图标 8 款(默认 / 深海荧光 / 贝壳徽章 / 月夜潮线 / 奶油贴纸 / 邮票 / 霓虹灯牌 / 单色剪影,「默认」是项目方提供的标志,其余 7 款由代码绘制),用 `activity-alias` 切换;全部图标与插图由 `dsh-mobile-app/tools/brand/build.sh` 一键生成,素材清单与重新生成方式见 [Part C](docs/CONSOLIDATED-DOCUMENTATION.en.md#part-c)
30
+ - 🧍 **桌面宠物**:Android 悬浮宠物是同一个角色的正常身材版(三视图,首页仍是 Q 版);首页角色是分层的活动角色(`lib/character/character_view.dart`:按任务/通知状态切换动作,会眨眼,点头部/身体/尾巴有反应)。宠物常驻桌面——任务/通知/余额驱动 16 组动作(思考、处理、等待、完成、出错、待机微动作);点头部/身体/尾巴互动,双击摸头,拖动悬空+落地,长按打开迷你面板(运行中会话 / 通知 / 用量与额度 / 余额 / 打开 App);拖到边缘或角落会探头(只露出头和手扒着屏幕边,悬浮窗只有露出的那一块,不挡旁边的触摸),点一下跳出来,完成/等待/出错时也会跳出来提示;随机眨眼;默认 96dp 高(四档 72 / 96 / 120 / 144dp),可减少动效;**App 在前台时自动收起**(不与首页角色同屏、不挡按钮);错过的通知也会补提示(气泡/角标/横幅)
31
+ - 🎨 **外观:皮肤与图标**:四套皮肤(默认 / 午夜 / 薄荷 / 靛蓝,各含明暗两套)——三套角色皮肤下首页换成角色 Hero + 动态背景(气泡/光环/星尘月盘的 30fps 上限动画),角色可点头部/身体/尾巴互动、长按开面板;App 图标 8 款(默认 / 夜光 / 圆形徽章 / 月夜 / 奶油贴纸 / 邮票 / 霓虹灯牌 / 单色剪影,「默认」是项目方提供的标志,其余 7 款由代码绘制),用 `activity-alias` 切换;全部图标与插图由 `dsh-mobile-app/tools/brand/build.sh` 一键生成,素材清单与重新生成方式见 [Part C](docs/CONSOLIDATED-DOCUMENTATION.en.md#part-c)
32
32
  - 💾 **体验打磨**:Agent 状态 bootstrap 同步(按钮/活动条即时反映 PC 状态)、下拉刷新收集地址(蒲公英/Tailscale 自动进候选)、聊天草稿保留(退出重进自动恢复)、首页改版(活动角色 / 新欢迎语 / 状态胶囊 / 最近会话卡片滑动)、语言切换(中/英)
33
33
  - 📶 **扫码连接**:桌面 dsh 设置页出现「连接移动端设备」二维码 → 手机 App 扫码即连(免输 IP/口令)
34
34
  - 🩺 **环境诊断**:一键查看当前环境各项能力(含问询/审批桥状态),升级/排障一目了然
35
35
  - 🧭 **连接可解释**:连接失败按九类归因(网络不可达 / 超时 / TLS / 不是 DSH / 口令 / 订阅 / 版本 / 5xx / 未知),口令错与订阅过期这类**不再无限重试**;设置页「连接路径」显示走直连还是加密中继、耗时、RTT、上次退回原因;Wi-Fi ⇄ 蜂窝切换立即重连;「连接诊断包」一键导出(已脱敏)。订阅票据抖动时提示「暂时读不到订阅状态」,不弹付费墙
36
- - 🧠 **长期记忆与助手模式**:电脑端 SQLite 记忆库(`scope` = work / life / shared,默认关闭,只存本机并入库前脱敏),App 内可查看 / 搜索 / 编辑 / 删除 / 手动添加;工作模式两份记忆都用,**生活模式按查询条件硬过滤工作记忆**;**人格卡**(JSON,`schema: "dsh-mobile.persona/1"`):三张原创卡(工作狂 / 生活助理 / 游戏玩家)免费,导入自己写的卡是订阅功能(只检查结构、不审内容、未知字段保留);模型看到的人格就是当前卡片的原文,只换说法不改事实;安静时段(默认 23:30–08:30)内不弹通知;回复按行拆成 1–3 条短气泡并做文本清洗
36
+ - 🧠 **长期记忆与助手模式**:电脑端 SQLite 记忆库(`scope` = work / life / shared,默认关闭,只存本机并入库前脱敏),App 内可查看 / 搜索 / 编辑 / 删除 / 手动添加;工作模式两份记忆都用,**生活模式按查询条件硬过滤工作记忆**;**人格卡**(JSON,`schema: "dsh-mobile.persona/1"`):**默认不用人格卡**(「无(默认)」:提示里不加任何人格文字,不额外花 token),用户亲手选了卡才生效;三张原创卡(工作狂 / 生活助理 / 游戏玩家)免费,导入自己写的卡是订阅功能(只检查结构、不审内容、未知字段保留);模型看到的人格就是所选卡片的原文,只换说法不改事实;安静时段(默认 23:30–08:30)内不弹通知;回复按行拆成 1–3 条短气泡并做文本清洗
37
37
  - 🧩 **插件动作区**:第三方插件注册的动作自动出现在移动端(可选)
38
38
  - 🖼️ **原生 App**:`dsh-mobile-app/` 子目录,Flutter 原生实现,与网页端共享同一 API 与设计
39
39
 
@@ -91,7 +91,7 @@ DSH 的 **设置 → 连接移动端设备** 里也会自动出现二维码、
91
91
 
92
92
  - **口令**:首次启动自动生成并保存,之后不变(手机只需配对一次)。你自己在配置里写了 `authToken` 就以你的为准,且**不会**打进日志。
93
93
  - **LAN 桥**:自动判断——只有 DSH 的 web 服务只听回环时才开(`dsh web` 0.2.1 就是回环);端口和 DSH 自己撞车会自动让到下一个,所以地址常是 `:3081`。
94
- - **想装本地打好的包**(比如还没发布的改动):`npm pack`,再 `npx @deepseek-ai/dsh plugin --profile web add file:<路径>/dsh-mobile-mobile-remote-<版本>.tgz`(这条路径在 DSH 0.2.1-rc.5 上验证过)。
94
+ - **想装本地打好的包**(比如还没发布的改动):`npm run pack`(打出 `dist/dsh-mobile-mobile-remote-<版本>.tgz`,与发布的包一致),再 `npx @deepseek-ai/dsh plugin --profile web add file:<路径>/dsh-mobile-mobile-remote-<版本>.tgz`(这条路径在 DSH 0.2.1-rc.5 上验证过)。
95
95
  - **之前手写过 `mobile-remote` 配置行?** 先删掉那一行,否则会重复加载。
96
96
  - **DSH Desktop**:同一个包,`--profile desktop`——**我没有在 Desktop 上测过**。
97
97
  - 想完全手动控制(固定口令、关桥、改端口),见下面的手动配置。
@@ -155,6 +155,10 @@ npx @deepseek-ai/dsh web
155
155
  # breakReminder: { enabled: false } # 连续工作 2 小时的休息提醒。默认:App 里有这个开关(发过 breakReminder)才提醒;true = 不看 App 也提醒,false = 这台电脑永不提醒
156
156
  ```
157
157
 
158
+ ### P2P 直连(实验性,默认关闭)
159
+
160
+ 手机与电脑之间可以尝试建立 WebRTC 直连(数据通道),不经中继转发流量。**实验性功能,默认关闭,也不随插件安装**(它依赖的 `werift` 体积较大,所以只是可选的 peer 依赖)。要试用:在终端运行 `dsh plugin add werift@0.27.0`(这条命令把参数原样交给 DSH 配置目录里的 pnpm,已在全新的 `DSH_HOME` 里验证:先装插件再装 werift、或先装 werift 再装插件,插件都能找到它;DSH 会提示它「不是插件、按普通依赖安装」,属正常),然后在上面的 `config` 里加 `p2p: { enabled: true }`(可选 `stun: ["stun:stun.cloudflare.com:3478"]`)并重启。没装 werift 时插件照常工作,只是不提供 P2P,`/bootstrap` 的 `features` 里也不会有 `p2p`。握手用的 offer / answer / 候选地址只经端到端加密的信令连接传输,不写日志;数据通道里会再跑一遍全新的 Noise 加密会话,只认已配对的手机。不涉及 TURN 中转:直连不成功时手机仍走原来的路径。
161
+
158
162
  ## 桌面设置页入口(客户端模块)
159
163
 
160
164
  插件启用后,dsh 设置页会出现**「连接移动端设备」**一页:显示连接二维码(含地址+口令)、电脑地址列表与口令(可复制)。手机 App 扫此二维码自动连接。该页数据仅电脑本机可读取(`/m/api/qr-config` 仅允许 loopback 访问)。
@@ -249,7 +253,7 @@ pushUrls:
249
253
 
250
254
  ## 版本与兼容
251
255
 
252
- - **版本号统一**:App 版本和插件版本用同一条版本线(插件 3.3.1,App 3.3.0+41)。插件发布在 npm(`@dsh-mobile/mobile-remote`),手机 App 在 App Store 和官网 https://dsh.claud.ing/。
256
+ - **版本号统一**:App 版本和插件版本用同一条版本线(插件 3.4.0,App 3.4.0+42)。插件发布在 npm(`@dsh-mobile/mobile-remote`),手机 App 在 App Store 和官网 https://dsh.claud.ing/。
253
257
  - **版本差矩阵**(一句话:谁旧谁吃亏,但都不崩):
254
258
 
255
259
  | 组合 | 结果 |
@@ -1,6 +1,6 @@
1
1
  # DSH Mobile - DeepSeek Harness Privacy Policy
2
2
 
3
- > Effective date: 2026-11-02 · Last updated: 2026-11-20
3
+ > Effective date: 2026-11-02 · Last updated: 2026-11-23
4
4
  > Publisher: Digital Bang Intelligence LLC., 30 N Gould St Ste R, Sheridan, WY 82801, USA · support@claud.ing
5
5
 
6
6
  ## 1. Overview
@@ -31,7 +31,7 @@ This policy covers the DSH Mobile app for iOS and Android, the desktop plugin, o
31
31
  | Does the app show ads? | No. The current version contains no ads and no advertising SDK. |
32
32
  | Does the app include analytics, crash-reporting or tracking SDKs? | We added no analytics, crash-reporting, advertising or cross-app tracking SDK. **On Android**, the QR-code scanner is Google's ML Kit library, which sends Google diagnostic and usage data about the scanner (Section 10). The iOS app uses Apple's built-in scanner instead. |
33
33
  | Do you measure how the service is used? | Our relay keeps connection counters with no content and no IP addresses, for about 90 days (Section 6). The app itself sends us no usage statistics. |
34
- | Does the app collect your location, contacts, calendar or messages? | The app does not request access to your location, contacts, calendar or messages. Our relay counters record the country a relay connection comes from, as reported by Cloudflare (Section 6). |
34
+ | Does the app collect your location, contacts, calendar or messages? | The app does not request access to your location, contacts, calendar or messages. Our relay counters record the country a relay connection comes from, as reported by Cloudflare (Section 6). The app can hand a calendar event to your Calendar app when you confirm it, but it does not read your calendar (Section 10). |
35
35
  | What leaves your phone? | On a local network: traffic only to your own computer. After cloud sign-in: the sign-in assertion, store receipts and relay ticket requests go to dsh.claud.ing. On the Public network: encrypted traffic through our relay. On Android: diagnostics that the built-in ML Kit scanner library sends to Google while the app runs. |
36
36
  | What do we receive? | After sign-in: the account identifier, email address and name that Google or Apple give us (never your password), your subscription records, and relay connection metadata. We never receive your sessions, files, images or your computer's access token. |
37
37
  | What does the desktop plugin send? | To our relay: an outbound connection that carries only encrypted traffic. To DeepSeek, OpenAI or OpenCode: usage queries with your own credentials each time the app starts with a computer set up, when you open the usage page and when you open the Android desktop pet's panel; and, while the pet is on, DeepSeek balance queries every 30 minutes, about once a minute while its panel is open. To push channels you set up: your alerts. Its memory and backups stay on your computer (Section 7). |
@@ -85,6 +85,8 @@ The desktop plugin runs inside DeepSeek Harness on your computer. We publish it,
85
85
  - **Backups.** When you request a backup, the plugin produces a file with your current memories (deleted ones are not in it) and your assistant settings (mode, persona and quiet hours). It contains no access token or keys. Without a passphrase it is a plain JSON file. With a passphrase (at least 15 characters) the whole file is encrypted with AES-256-GCM under a key derived from the passphrase with scrypt; the plugin does not keep the passphrase, and without it the file cannot be read or restored. A backup made earlier still holds the memories that existed when it was made. If you fetch a backup to your phone, it travels over your connection (plain HTTP on a local network, encrypted through the relay); where you keep it is up to you. Restoring a backup only adds entries, so restoring an older backup brings back memories you deleted after making it.
86
86
  - **Balance and usage queries.** The plugin answers two kinds of request from your phone, using your own credentials. A usage request asks DeepSeek (through the DeepSeek account you signed in to in DeepSeek Harness, or `api.deepseek.com` with your API key), OpenAI (Codex usage, through DeepSeek Harness's Codex settings) and OpenCode (`opencode.ai`). The app sends one each time it starts with a computer set up (or first connects to one) and when you open or refresh the usage page; the Android desktop pet sends one when you open its panel, at most every 2 minutes. A balance request asks DeepSeek only. While the Android desktop pet is on, it sends one every 30 minutes, and every 5 seconds while its panel is open; because the plugin caches the answer for 60 seconds, DeepSeek is then asked about once a minute. Those credentials never go to the phone or to us. When the app's usage request goes through your DeepSeek account, the plugin passes the app's interface language (English or Chinese) and your phone's time-zone offset to DeepSeek Harness's DeepSeek account service, which sends them to DeepSeek with the request. Results are cached on your computer for up to 60 seconds.
87
87
  - **Push channels.** If you add push channels (ServerChan, ntfy, Bark, a WeCom group robot or any webhook), the plugin sends alerts to them directly. By default (`pushContent: minimal`) an alert contains the event type and a short session code, and a generic webhook also receives the full session ID and the time; with `standard` alerts also contain the session title and event details. Those services handle alerts under their own policies.
88
+ - **Phone actions.** If you use the app, the AI agent running on your computer can ask your phone to set a timer or an alarm, add a calendar event or open a link. The plugin offers the agent these tools only while a phone whose app supports them is connected to your computer. A request travels from your computer to your phone over the connection you already use (your local network, or the Public network relay, where it is end-to-end encrypted like every other message, Section 6). **Nothing happens until you confirm it on the phone**, on a screen that names your computer (or after you chose "Allow this turn" for the same kind of action within the same agent turn). The request holds what the agent wrote, such as an event title, a time, notes or a link. **We do not store, log or receive these details: they go to no server of ours, and they are not part of any telemetry or relay counter.** The plugin's own logs keep at most the kind of action, a request ID and the outcome, never the details. Like any other tool call, though, the agent's request and its result are part of the conversation, which DeepSeek Harness keeps and sends to your model provider (Section 9). Nothing is sent to us for this beyond the encrypted relay traffic described in Section 6, which exists with or without phone actions.
89
+ - **Direct (peer-to-peer) connection (experimental, off by default).** Only if you turn it on, the phone and your computer can try to connect directly instead of through the relay. To set it up they trade connection set-up messages (session descriptions and network candidates, which contain IP addresses) through your computer's room on our relay. **These messages are end-to-end encrypted with the keys from your pairing, so our servers cannot read them.** Our relay sees only that a set-up connection happened, and its size and timing, and counts it without content and without IP addresses, like the other relay counters (Section 6). The data itself then goes directly between your two devices and is encrypted again; it does not pass through our servers. To find its public address, each side asks a STUN server, by default `stun:stun.cloudflare.com:3478`, which is run by Cloudflare and sees the IP address of the device that asks; you can change that server in the plugin's configuration (`p2p.stun`).
88
90
  - **Proactive messages and quiet hours.** Both are decided on your computer. Proactive messages are off by default; their schedule is kept in `proactive.json` in the state folder, and the messages reach you the same way as alerts.
89
91
 
90
92
  ## 8. In-app purchases and subscriptions
@@ -110,7 +112,7 @@ DeepSeek Harness, model providers, push channels and file services are chosen an
110
112
  | Google Sign-In | Google one-tap sign-in | [Google Privacy Policy](https://policies.google.com/privacy) |
111
113
  | Apple Sign In | Apple one-tap sign-in | [Apple Privacy Policy](https://www.apple.com/legal/privacy/) |
112
114
  | Google ML Kit (Android only) | QR-code scanning in the app; sends Google diagnostic and usage data (Section 10) | [ML Kit data disclosure](https://developers.google.com/ml-kit/android-data-disclosure) |
113
- | Cloudflare | Website hosting, the cloud account service and its storage (D1, R2), the Public network relay and its counters (Workers Analytics Engine) | [Cloudflare Privacy Policy](https://www.cloudflare.com/privacypolicy/) |
115
+ | Cloudflare | Website hosting, the cloud account service and its storage (D1, R2), the Public network relay and its counters (Workers Analytics Engine); the default STUN server for direct connections, only if you turn them on (Section 7) | [Cloudflare Privacy Policy](https://www.cloudflare.com/privacypolicy/) |
114
116
  | DeepSeek, OpenAI, OpenCode | Balance and usage queries from the desktop plugin, with your own credentials | Their own policies |
115
117
  | ServerChan, ntfy, Bark, WeCom, webhooks | Push alerts you set up in the desktop plugin | Their own policies |
116
118
  | WeChat, QQ, Discord | Support channels listed on our website | Their own policies |
@@ -130,6 +132,11 @@ What each permission is for:
130
132
  - Local network: reach the DeepSeek Harness service on your local network.
131
133
  - Notifications: show alerts for finished tasks, questions, approvals and errors.
132
134
  - Android overlay and foreground service: used only after you turn on the Android desktop pet or background alerts; iOS does not request these permissions.
135
+ - Alarm setting (Android, `SET_ALARM`, granted when you install the app): lets the app ask your Clock app to set a timer or an alarm after you confirmed it. It does not let the app read or change your alarms.
136
+
137
+ **Phone actions.** When the agent on your computer asks your phone to set a timer or an alarm, add a calendar event or open a link, the app first shows a confirmation that names the computer, with "Allow once", "Allow this turn" (the same kind of action from that computer for the rest of that agent turn) and "Cancel"; with no answer in 30 seconds it cancels. Only after you allow it does the app pass the request to your phone's Clock, Calendar or browser app, which then handle it under their own policies (a calendar event may, for example, be synced by the calendar account you use). The app does not read your calendar or alarms, does not put the title, time, notes or link in its diagnostic log, and tells your computer only whether the action was done, cancelled or failed. Phone actions currently work on Android only; on iOS the app answers that they are not available.
138
+
139
+ **Direct connection (experimental, off by default).** If it is turned on, the app and your computer trade connection set-up messages through our relay, end-to-end encrypted, and then connect directly, as described in Section 7. The app asks a STUN server (by default Cloudflare's `stun.cloudflare.com`) for its public IP address for that.
133
140
 
134
141
  **On Android, the built-in QR scanner library sends data to Google.** The Android app scans QR codes with Google's ML Kit barcode-scanning library, which is built into the app. It can send data while the app runs, not only when you scan a code. According to Google, it collects and sends to Google, over HTTPS and for diagnostics and usage analytics: device information (manufacturer, model, OS version and build, available machine-learning accelerators), app information (package name and app version), a per-installation identifier that is not meant to identify you or your device, and scanner events, settings, performance and error codes. Google's list does not include the camera images or the contents of the codes you scan, and Google says it does not transfer this data to third parties. The data goes to Google's Firebase logging service (firebaselogging.googleapis.com), not to us. The iOS app scans with Apple's built-in Vision framework and sends no such data.
135
142
 
@@ -1,6 +1,6 @@
1
1
  # DSH Mobile - DeepSeek Harness 隐私政策
2
2
 
3
- > 生效日期:2026-11-02 · 最近更新:2026-11-20
3
+ > 生效日期:2026-11-02 · 最近更新:2026-11-23
4
4
  > 发布者:Digital Bang Intelligence LLC.,30 N Gould St Ste R, Sheridan, WY 82801, USA · support@claud.ing
5
5
 
6
6
  ## 1. 概述
@@ -31,7 +31,7 @@ DSH Mobile 让你连接到自己在电脑上运行的 DeepSeek Harness 服务,
31
31
  | 应用里有广告吗? | 没有。当前版本不含广告,也不含广告 SDK。 |
32
32
  | 应用里有分析、崩溃上报或跟踪 SDK 吗? | 我们没有加入任何分析、崩溃上报、广告或跨应用跟踪 SDK。**在 Android 上**,扫码功能使用 Google 的 ML Kit 扫码库,它会把扫码功能的诊断和使用数据发给 Google(第 10 节)。iOS 版使用 Apple 系统自带的扫码能力。 |
33
33
  | 你们会统计服务的使用情况吗? | 我们的中继会记录连接计数,不含任何内容,也不含 IP 地址,保留约 90 天(第 6 节)。应用本身不向我们发送任何使用统计。 |
34
- | 应用会收集你的位置、通讯录、日历或短信吗? | 应用不申请位置、通讯录、日历或短信权限。中继计数会记录 Cloudflare 报告的连接来源国家或地区(第 6 节)。 |
34
+ | 应用会收集你的位置、通讯录、日历或短信吗? | 应用不申请位置、通讯录、日历或短信权限。中继计数会记录 Cloudflare 报告的连接来源国家或地区(第 6 节)。你确认后,应用可以把日历事件交给你的日历应用,但不会读取你的日历(第 10 节)。 |
35
35
  | 哪些数据会离开你的手机? | 局域网直连时:只发往你自己的电脑。登录云端账号后:登录凭证、商店收据和中继票据请求会发到 dsh.claud.ing。使用公开网络时:经过我们中继的加密流量。在 Android 上:内置的 ML Kit 扫码库在应用运行时发给 Google 的诊断数据。 |
36
36
  | 我们会收到什么? | 登录后:Google 或 Apple 提供的账号标识、邮箱和姓名(不包含密码)、你的订阅记录,以及中继连接元数据。我们永远不会收到你的会话、文件、图片或访问电脑的口令。 |
37
37
  | 电脑端插件会发出什么? | 发往我们的中继:一条只承载加密流量的出站连接。发往 DeepSeek、OpenAI 或 OpenCode:每次在已配置电脑的情况下启动应用、打开用量页或打开 Android 桌面宠物面板时,用你自己的凭据查询用量;桌面宠物开启时,还会每 30 分钟查询一次 DeepSeek 余额,面板打开期间约每分钟一次。发往你配置的推送通道:你的提醒。它的记忆和备份都留在你的电脑上(第 7 节)。 |
@@ -85,6 +85,8 @@ DSH Mobile 让你连接到自己在电脑上运行的 DeepSeek Harness 服务,
85
85
  - **备份。** 当你请求备份时,插件会生成一个文件,内含你现有的记忆(已删除的不在其中)和助手设置(模式、人格和安静时段)。它不含访问口令或密钥。不设口令时它是明文 JSON 文件;设了口令(至少 15 个字符)时,整个文件用 AES-256-GCM 加密,密钥由口令经 scrypt 派生;插件不保存口令,没有口令就无法读取或恢复该文件。之前做的备份仍包含做备份时存在的记忆。如果你把备份取到手机上,它会经由你的连接传输(局域网下是明文 HTTP,经中继时加密);保存在哪里由你决定。恢复备份只会新增条目,所以恢复一份较早的备份,会把你在那之后删除的记忆加回来。
86
86
  - **余额与用量查询。** 插件会用你自己的凭据,回应手机发来的两类请求。用量请求会向 DeepSeek(通过你在 DeepSeek Harness 里登录的 DeepSeek 账号,或用你的 API Key 访问 `api.deepseek.com`)、OpenAI(Codex 用量,通过 DeepSeek Harness 的 Codex 设置)和 OpenCode(`opencode.ai`)查询。每次在已配置电脑的情况下启动应用(或第一次连上电脑)时、以及你打开或刷新用量页时,应用会发一次;你打开 Android 桌面宠物的面板时,宠物也会发一次,最多每 2 分钟一次。余额请求只查询 DeepSeek。开启 Android 桌面宠物后,它每 30 分钟发一次,面板打开期间每 5 秒发一次;由于插件会把结果缓存 60 秒,这时 DeepSeek 约每分钟被查询一次。这些凭据永远不会发到手机或我们这里。应用的用量请求通过你的 DeepSeek 账号查询时,插件会把应用的界面语言(中文或英文)和手机的时区偏移交给 DeepSeek Harness 的 DeepSeek 账号服务,由它随请求一起发给 DeepSeek。查询结果在你的电脑上最多缓存 60 秒。
87
87
  - **推送通道。** 如果你添加了推送通道(Server酱、ntfy、Bark、企业微信群机器人或任意 Webhook),插件会把提醒直接发给它们。默认(`pushContent: minimal`)提醒包含事件类型和会话短码,通用 Webhook 还会收到完整的会话 ID 和时间;设为 `standard` 时提醒还会包含会话标题和事件详情。这些服务按其各自政策处理提醒。
88
+ - **手机动作。** 如果你使用本应用,运行在你电脑上的 AI 智能体可以请求你的手机设置计时器或闹钟、添加日历事件或打开链接。只有在支持这些动作的应用版本连接到你的电脑时,插件才会把这些工具提供给智能体。请求从你的电脑经你已经在用的连接送到手机(局域网,或公开网络中继;经中继时与其他所有消息一样端到端加密,见第 6 节)。**你在手机上确认之前,什么都不会发生**:确认界面会写明是哪台电脑(或者你在同一次智能体轮次内,已对同一类动作选择了“本轮允许”)。请求里包含智能体写下的内容,例如事件标题、时间、备注或链接。**我们不会存储、记录或接收这些内容:它们不会发往我们的任何服务器,也不属于任何遥测或中继计数。** 插件自己的日志最多只记录动作的种类、请求 ID 和结果,不记录这些内容。不过,与任何其他工具调用一样,智能体的请求及其结果属于对话的一部分,而对话由 DeepSeek Harness 保存并发送给你的模型提供方(第 9 节)。除第 6 节所述、无论是否使用手机动作都已存在的加密中继流量外,这项功能不会向我们发送任何数据。
89
+ - **直连(点对点)连接(实验性,默认关闭)。** 只有在你主动开启后,手机和你的电脑才会尝试直接连接,而不经过中继。为了建立连接,它们会通过我们中继上你电脑的房间交换连接建立消息(会话描述和网络候选地址,其中包含 IP 地址)。**这些消息用你们配对时的密钥端到端加密,我们的服务器无法读取。** 我们的中继只能看到发生过一次建立连接、它的大小和时间,并像其他中继计数一样记录,不含内容,也不含 IP 地址(第 6 节)。随后数据直接在你的两台设备之间传输并再次加密,不经过我们的服务器。为了得知自己的公网地址,双方会向 STUN 服务器发起查询,默认是 `stun:stun.cloudflare.com:3478`,由 Cloudflare 运营,它会看到发起查询的设备的 IP 地址;你可以在插件配置里更换这个服务器(`p2p.stun`)。
88
90
  - **主动消息与安静时段。** 两者都在你的电脑上决定。主动消息默认关闭;其排程保存在状态目录的 `proactive.json` 中,消息和提醒走同样的通道到达你。
89
91
 
90
92
  ## 8. 内购与订阅
@@ -110,7 +112,7 @@ DeepSeek Harness、模型提供商、推送通道和文件服务由你选择并
110
112
  | Google Sign-In | Google 一键登录 | [Google 隐私权政策](https://policies.google.com/privacy) |
111
113
  | Apple Sign In | Apple 一键登录 | [Apple 隐私政策](https://www.apple.com/legal/privacy/) |
112
114
  | Google ML Kit(仅 Android) | 应用内扫码;会把诊断和使用数据发给 Google(第 10 节) | [ML Kit 数据披露](https://developers.google.com/ml-kit/android-data-disclosure) |
113
- | Cloudflare | 托管网站、云端账号服务及其存储(D1、R2)、公开网络中继及其计数(Workers Analytics Engine) | [Cloudflare 隐私政策](https://www.cloudflare.com/privacypolicy/) |
115
+ | Cloudflare | 托管网站、云端账号服务及其存储(D1、R2)、公开网络中继及其计数(Workers Analytics Engine);直连默认使用的 STUN 服务器(仅在你开启直连时,第 7 节) | [Cloudflare 隐私政策](https://www.cloudflare.com/privacypolicy/) |
114
116
  | DeepSeek、OpenAI、OpenCode | 电脑端插件用你自己的凭据查询余额和用量 | 其各自政策 |
115
117
  | Server酱、ntfy、Bark、企业微信、Webhook | 你在电脑端插件里配置的推送提醒 | 其各自政策 |
116
118
  | 微信、QQ、Discord | 我们网站上列出的客服渠道 | 其各自政策 |
@@ -130,6 +132,11 @@ DeepSeek Harness、模型提供商、推送通道和文件服务由你选择并
130
132
  - 本地网络:访问你局域网中的 DeepSeek Harness 服务。
131
133
  - 通知:显示任务完成、问询、审批和错误提醒。
132
134
  - Android 悬浮窗和前台服务:仅在你主动开启 Android 桌面宠物或后台提醒后使用;iOS 不申请这些权限。
135
+ - 闹钟设置(Android,`SET_ALARM`,安装应用时授予):让应用在你确认之后,请时钟应用设置计时器或闹钟。它不允许应用读取或修改你的闹钟。
136
+
137
+ **手机动作。** 当你电脑上的智能体请求手机设置计时器或闹钟、添加日历事件或打开链接时,应用会先弹出一个写明电脑名称的确认界面,选项为“允许一次”“本轮允许”(在该智能体的本轮余下时间里,允许这台电脑的同一类动作)和“取消”;30 秒内没有回答则自动取消。只有在你允许之后,应用才会把请求交给手机上的时钟、日历或浏览器应用,由它们按各自的政策处理(例如日历事件可能会被你所用的日历账号同步)。应用不会读取你的日历或闹钟,不会把标题、时间、备注或链接写进它的诊断日志,只会告诉你的电脑这个动作已完成、已取消还是失败。目前手机动作只在 Android 上可用;在 iOS 上应用会回答不支持。
138
+
139
+ **直连(实验性,默认关闭)。** 如果开启,应用和你的电脑会通过我们的中继交换端到端加密的连接建立消息,然后直接连接,详见第 7 节。为此,应用会向 STUN 服务器(默认是 Cloudflare 的 `stun.cloudflare.com`)查询自己的公网 IP 地址。
133
140
 
134
141
  **Android 版内置的扫码库会向 Google 发送数据。** Android 版使用内置在应用里的 Google ML Kit 条码扫描库扫码。它在应用运行时就可能发送数据,不限于扫码的时候。据 Google 说明,它会通过 HTTPS 收集并发给 Google 以下数据,用于诊断和使用分析:设备信息(制造商、型号、系统版本和构建号、可用的机器学习加速硬件)、应用信息(包名和应用版本)、一个不用于识别你或你设备的按安装生成的标识符,以及扫码功能的事件、设置、性能和错误码。Google 列出的数据不包括相机画面或你扫描的二维码内容,Google 也说明不会把这些数据转给第三方。这些数据发往 Google 的 Firebase 日志服务(firebaselogging.googleapis.com),不是发给我们。iOS 版使用 Apple 系统自带的 Vision 框架扫码,不发送此类数据。
135
142
 
@@ -427,6 +427,7 @@ mkcert 192.168.1.100 172.16.x.x # 给电脑的局域网/组网 IP 签证书
427
427
  **审批/回答**:agent 思考途中需要你拍板时,对话页弹出卡片——按选项选择(可多选),或输入你自己的答案后「提交」;工具需要更高权限时弹出「权限请求」,选「允许一次 / 拒绝」。与电脑端同一个待办,任一端回答后两端同时消失;也可点卡片右上角 ✕ 取消(agent 按取消继续)。agent 只是等待你普通回复时(状态点橙色),直接输入消息即可。
428
428
  **新建会话**:首页「+ 新建会话」→ 选模式(标准/PTC/极简/创造)→ 可选工作目录(跨盘浏览、可新建文件夹)→ 创建。
429
429
  **修改默认配置**:设置 → 默认 Agent 预设 / 默认权限预设 → 选择(作用于之后新建的会话,与 PC 端同一写入通道)。
430
+ **人格卡**:设置 → 助手 → 人格卡。默认是「无(默认)」:不向模型添加任何人格文字,不额外花 token;选了工作狂 / 生活助理 / 游戏玩家或自己导入的卡,模型才会看到那张卡的原文。随时可以选回「无(默认)」。
430
431
  **深色模式**:设置 → 深色模式:跟随系统 / 深色 / 浅色。
431
432
  **换主题**:设置 → 外观 → 主题,多套任选,每套都含明暗两套配色,跟随「深色模式」切换。
432
433
  **换图标**:设置 → 外观 → App 图标,8 款任选。切换后若桌面没变,回桌面刷新一次即可。升级后**桌面上的旧快捷方式可能失效一次**,删掉从抽屉重拖一个即可。
@@ -1,7 +1,7 @@
1
- /**
2
- * 账户用量与额度的上游查询(DeepSeek 余额 / Codex / OpenCode Go)。归一化纯函数在 account-usage.js。
3
- * 从 lib/index.js 原样拆出(行为不变)。
4
- */
1
+
2
+
3
+
4
+
5
5
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
6
6
  import { createRequire } from "node:module";
7
7
  import { homedir } from "node:os";
@@ -11,7 +11,7 @@ import { normalizeCodexUsage, normalizeDeepSeekBalance, normalizeOpenCodeUsage }
11
11
  import { safeFailureReason } from "./api-helpers.js";
12
12
  import { readSettingsSection, readSettingsSectionStrict } from "./host-compat.js";
13
13
 
14
- /** 插件自身版本:作为 DSH 账号请求的客户端版本头(读不到时退回 unknown)。 */
14
+
15
15
  const pluginVersion = (() => {
16
16
  try {
17
17
  return createRequire(import.meta.url)("../package.json").version ?? "unknown";
@@ -20,7 +20,7 @@ const pluginVersion = (() => {
20
20
  }
21
21
  })();
22
22
 
23
- /** DSH 账号服务默认的客户端身份;手机端可覆盖语言与时区。 */
23
+
24
24
  function accountClientMetadata(client = {}) {
25
25
  return {
26
26
  version: typeof client.version === "string" && client.version !== "" ? client.version : pluginVersion,
@@ -31,7 +31,7 @@ function accountClientMetadata(client = {}) {
31
31
  };
32
32
  }
33
33
 
34
- /** DSH 内置的 DeepSeek 账号服务;旧版宿主没有该能力时返回 undefined。 */
34
+
35
35
  function deepSeekAccountService(ctx) {
36
36
  try {
37
37
  const service = ctx?.get?.("deepseekAccount");
@@ -41,10 +41,10 @@ function deepSeekAccountService(ctx) {
41
41
  }
42
42
  }
43
43
 
44
- /** 充值入口:账号服务给了部署地址就用它,否则用官方平台地址。 */
44
+
45
45
  const DEFAULT_DEEPSEEK_TOP_UP = "https://platform.deepseek.com/top_up";
46
46
 
47
- /** 与 PC 端设置页一致的凭据引用派生规则(v2.6):路由 id 大写 → `<ID>_API_KEY`。 */
47
+
48
48
  export function deriveKeyRef(provider) {
49
49
  return `${String(provider).toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
50
50
  }
@@ -55,7 +55,7 @@ async function resolveCredentialValue(ctx, ref) {
55
55
  const credentials = ctx.get("credentials");
56
56
  if (credentials?.resolve) value = (await credentials.resolve(credentialRef(ref)))?.value;
57
57
  } catch {
58
- // 环境变量兜底;不把凭据服务异常暴露给手机端。
58
+
59
59
  }
60
60
  if ((!value || typeof value !== "string") && typeof process.env[ref] === "string") value = process.env[ref];
61
61
  return typeof value === "string" && value.trim() !== "" ? value : undefined;
@@ -76,7 +76,7 @@ async function resolveOpenCodeCredential(ctx, profileRef) {
76
76
  : undefined;
77
77
  if (record?.kind === "api-key" && typeof record.key === "string" && record.key.trim() !== "") return record.key;
78
78
  } catch {
79
- // 旧版 credentials 服务没有 readRecord 时继续走引用/环境变量回退。
79
+
80
80
  }
81
81
  for (const ref of ["OPENCODE_GO_API_KEY", "OPENCODE_API_KEY"]) {
82
82
  const fallback = await resolveCredentialValue(ctx, ref);
@@ -101,19 +101,19 @@ async function loadCodexConnect() {
101
101
  const entry = profileRequire.resolve("dsh-codex-connect");
102
102
  return await import(pathToFileURL(entry).href);
103
103
  } catch {
104
- // 继续尝试其他 DSH profile;缺失时最终按“未安装”处理。
104
+
105
105
  }
106
106
  }
107
107
  throw bareError;
108
108
  }
109
109
 
110
- /**
111
- * 读取 DSH 登录的 DeepSeek 账号余额。
112
- *
113
- * 很多人是在 DSH 里用 DeepSeek 账号登录(`deepseekAccount` 服务持有登录凭证),
114
- * 而不是在「设置 → 模型」里填 API Key;只查 DEEPSEEK_API_KEY 会让他们整块余额消失。
115
- * 返回值区分三态:`ready` / `signed-out` / `failed`,`unavailable` 表示宿主没有账号能力。
116
- */
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
117
  export async function queryDeepSeekAccountBalance(ctx, client = {}) {
118
118
  const service = deepSeekAccountService(ctx);
119
119
  if (!service) return { status: "unavailable" };
@@ -122,10 +122,10 @@ export async function queryDeepSeekAccountBalance(ctx, client = {}) {
122
122
  try {
123
123
  const state = await service.getState?.();
124
124
  links = state?.links;
125
- // getState 不可用时仍尝试 getBalance:它自己会在未登录时返回 null。
125
+
126
126
  if (state && state.status !== "credential-stored") return { status: "signed-out", links };
127
127
  } catch {
128
- // 账号状态读失败不等于未登录:继续走余额查询,由它给出真实结果。
128
+
129
129
  }
130
130
  let balance;
131
131
  try {
@@ -140,7 +140,7 @@ export async function queryDeepSeekAccountBalance(ctx, client = {}) {
140
140
  const result = await service.getProfile?.(metadata);
141
141
  if (result?.status === "ready") profile = result.value;
142
142
  } catch {
143
- // 账号标签是可选的展示信息,读失败不影响余额。
143
+
144
144
  }
145
145
  return {
146
146
  status: "ready",
@@ -151,7 +151,7 @@ export async function queryDeepSeekAccountBalance(ctx, client = {}) {
151
151
  };
152
152
  }
153
153
 
154
- /** CNY 优先;没有 CNY 时用第一个钱包(与 API Key 余额的取值规则一致)。 */
154
+
155
155
  function preferredWallet(wallets) {
156
156
  return wallets.find((wallet) => wallet?.currency === "CNY") ?? wallets[0];
157
157
  }
@@ -183,7 +183,7 @@ async function queryDeepSeekUsage(ctx, client = {}) {
183
183
  }
184
184
  const key = await resolveCredentialValue(ctx, "DEEPSEEK_API_KEY");
185
185
  if (!key) {
186
- // 账号已登录但余额查询失败:把失败原因报上去,而不是退回"未配置"。
186
+
187
187
  if (account.status === "failed") {
188
188
  return { configured: true, failed: true, failedId: "deepseek", failedReason: account.failedReason };
189
189
  }
@@ -215,16 +215,16 @@ async function queryDeepSeekUsage(ctx, client = {}) {
215
215
  }
216
216
  }
217
217
 
218
- /**
219
- * 读取 Codex 代理配置(导出以便单测:issue #21 的回归点正在这里)。
220
- *
221
- * 返回值三态,**必须区分**:
222
- * - `{ enabled: false }` —— 设置读得到,但用户没开代理(走直连是正确的);
223
- * - `{ enabled: true, url }` —— 代理已启用且地址有效;
224
- * - `{ enabled: true, url: undefined, unreadable: true }` —— **读不到宿主设置**。
225
- * 这是插件与宿主的接口问题,不是用户的选择;原实现把它误判为"代理未启用",
226
- * 于是静默改走直连、最终以"Codex 余额消失"的形式暴露,根因完全不可见。
227
- */
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
228
  export function codexProxyUrl(ctx, mod) {
229
229
  const namespace = mod.OPENAI_CODEX_SETTINGS_NAMESPACE ?? "llm-openai-codex";
230
230
  let settingsSvc;
@@ -233,16 +233,16 @@ export function codexProxyUrl(ctx, mod) {
233
233
  } catch {
234
234
  settingsSvc = undefined;
235
235
  }
236
- // issue #21:原实现用 `settings.get()` 读该命名空间,而宿主 0.2.0 **移除了该方法**
237
- // (同一处破坏在 issue #19 已修过另两个调用点,这一处因是可选链写法 `?.get?.(` 被漏掉)。
238
- // 更要紧的是**语义**:读不到配置 ≠ 代理未启用。原实现把前者当作后者 → 返回 enabled:false
239
- // → 插件静默改走直连 chatgpt.com → 连接超时 → 表现为"手机看不到 Codex 余额",
240
- // 而配置本身(enableProxy:true + proxyUrl)一直好好的,用户完全看不出根因。
241
- //
242
- // 评审 WARNING 3 的补充:仅判断"读取方法存在"不够——`get()` 抛错、`describe()` 抛错、
243
- // 或 describe 返回形状不合法时,宽松读取会把它们一律折叠成 undefined,再由 `?? {}`
244
- // 伪装成"命名空间不存在"。故此处用**严格读取**,只有"读取成功且命名空间确实不存在"
245
- // 才允许判定为"用户没开代理"。
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
246
  const read = readSettingsSectionStrict(settingsSvc, namespace);
247
247
  if (!read.ok) return { enabled: true, url: undefined, unreadable: true, reason: read.reason };
248
248
  const settings = read.value ?? {};
@@ -251,7 +251,7 @@ export function codexProxyUrl(ctx, mod) {
251
251
  ? mod.resolveOpenAICodexSettings(settings)
252
252
  : settings;
253
253
  const enabled = resolved?.enableProxy === true || settings?.enableProxy === true;
254
- // 命名空间确实不存在 ⇒ 用户没开代理,走直连是正确行为(区别于上面的"读不了")
254
+
255
255
  if (!enabled) return { enabled: false, url: undefined };
256
256
  const url = typeof mod.resolveOpenAICodexProxyUrl === "function"
257
257
  ? mod.resolveOpenAICodexProxyUrl(resolved)
@@ -277,16 +277,16 @@ async function queryCodexUsage(ctx) {
277
277
  let proxyManager;
278
278
  try {
279
279
  store = new mod.OpenAICodexCredentialStore();
280
- // 新版返回同一账户快照;旧版没有该方法时仍可读取额度,但账户标签降级为可选。
280
+
281
281
  captured = typeof store.captureActiveAccount === "function" ? await store.captureActiveAccount() : store;
282
282
  if (!captured) return { configured: false };
283
283
  const status = await mod.openAICodexAuthStatus(captured);
284
284
  if (status?.authenticated !== true) return { configured: false };
285
285
  const proxy = codexProxyUrl(ctx, mod);
286
286
  if (proxy.enabled && (!proxy.url || typeof mod.OpenAICodexProxyManager !== "function")) {
287
- // v3.1.6(issue #21):**必须区分**「读不到宿主配置」与「用户没开代理」。
288
- // 前者是插件与宿主的接口问题,后者是用户的选择;原实现把两者都归为 failed,
289
- // 于是 Codex 余额整块消失而原因无法归因(见 failedReason 的两种措辞)。
287
+
288
+
289
+
290
290
  return {
291
291
  configured: true, failed: true, failedId: "codex",
292
292
  failedReason: proxy.unreadable
@@ -302,7 +302,7 @@ async function queryCodexUsage(ctx) {
302
302
  const accounts = typeof captured.accounts === "function" ? await captured.accounts() : [];
303
303
  active = Array.isArray(accounts) ? accounts.find((account) => account?.active === true) : undefined;
304
304
  } catch {
305
- // 账户标签是可选展示信息;额度投影成功时不因标签读取失败而隐藏来源。
305
+
306
306
  }
307
307
  return {
308
308
  configured: true,
@@ -320,14 +320,14 @@ async function queryCodexUsage(ctx) {
320
320
  },
321
321
  };
322
322
  } catch (err) {
323
- // v3.1.6(issue #21):失败原因要能对上号(此前只记 failed,用户无从判断是网络、
324
- // 凭据还是插件读不到宿主配置)。detail 走脱敏。
323
+
324
+
325
325
  return { configured: true, failed: true, failedId: "codex", failedReason: safeFailureReason(err) };
326
326
  } finally {
327
327
  try {
328
328
  await proxyManager?.dispose?.();
329
329
  } catch {
330
- // 代理池释放失败不应掩盖已拿到的额度快照。
330
+
331
331
  }
332
332
  }
333
333
  }
@@ -335,9 +335,9 @@ async function queryCodexUsage(ctx) {
335
335
  async function queryOpenCodeUsage(ctx) {
336
336
  let profile;
337
337
  try {
338
- // issue #21:与 codexProxyUrl 同一种写法(可选链),同样受"0.2.0 移除 settings.get()"影响。
339
- // 此处目前**碰巧仍有数据**(额度走的是凭据解析路径,profile 只用于取 apiKeyEnv),
340
- // 但同一形式的读取必须一并改为跨代版本——否则换个宿主版本就会静默失效。
338
+
339
+
340
+
341
341
  const settingsSvc = ctx?.get?.("settings");
342
342
  const section = readSettingsSection(settingsSvc, "llm-pi-ai");
343
343
  profile = section?.providers?.["opencode-go"];
@@ -346,7 +346,7 @@ async function queryOpenCodeUsage(ctx) {
346
346
  }
347
347
  const key = await resolveOpenCodeCredential(ctx, profile?.apiKeyEnv);
348
348
  if (!key) return { configured: false };
349
- // 不接受设置页可配置的 baseURL,避免把套餐密钥发送到非官方/内网地址。
349
+
350
350
  const url = "https://opencode.ai/zen/go/v1/usage";
351
351
  try {
352
352
  const response = await fetch(url, {
@@ -378,9 +378,9 @@ export async function queryAccountUsage(ctx, client = {}) {
378
378
  sources,
379
379
  availableCount: sources.length,
380
380
  failedCount: failures.length,
381
- // v3.1.6(issue #21):此前只给 failedCount。用户看到的是「Codex 整块消失」,
382
- // 却无法判断是凭据没配、网络不通、还是插件读不到宿主配置——定位只能靠猜。
383
- // 现在把**哪个来源失败、为什么失败**一并给出(无失败时省略该字段,保持响应稳定)。
381
+
382
+
383
+
384
384
  ...(failures.length > 0 ? {
385
385
  failures: failures.map((result) => ({
386
386
  id: result.failedId ?? "unknown",
@@ -1,6 +1,6 @@
1
- // 用量与额度领域归一化:保持无运行时依赖,便于服务端单测与其它宿主复用。
2
1
 
3
- /** 额度窗口标签:优先使用 provider 约定名称,未知窗口保持稳定可读。 */
2
+
3
+
4
4
  export function usageWindowLabel(seconds) {
5
5
  const value = Number(seconds);
6
6
  if (!Number.isFinite(value) || value <= 0) return null;
@@ -37,7 +37,7 @@ function isoFromDate(value) {
37
37
  return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
38
38
  }
39
39
 
40
- /** DeepSeek /user/balance 的顶层投影;优先选择 CNY 余额项。 */
40
+
41
41
  export function normalizeDeepSeekBalance(data) {
42
42
  const infos = data && typeof data === 'object' && !Array.isArray(data) ? data.balance_infos : undefined;
43
43
  const validInfos = Array.isArray(infos) ? infos.filter((item) => item && typeof item === 'object' && !Array.isArray(item)) : [];
@@ -51,10 +51,10 @@ export function normalizeDeepSeekBalance(data) {
51
51
  };
52
52
  }
53
53
 
54
- /**
55
- * dsh-codex-connect 的无密钥投影 → 手机额度领域模型。
56
- * 保留主 bucket 与 additional_rate_limits 的全部有效窗口,仅返回百分比/金额/窗口,不接触 OAuth token。
57
- */
54
+
55
+
56
+
57
+
58
58
  export function normalizeCodexUsage(usage) {
59
59
  if (!usage || typeof usage !== 'object' || Array.isArray(usage)) throw new Error('invalid codex usage');
60
60
  if (usage.rateLimits !== undefined && !Array.isArray(usage.rateLimits)) throw new Error('invalid codex rate limits');
@@ -107,7 +107,7 @@ export function normalizeCodexUsage(usage) {
107
107
  } else if (finiteNumber(credits.balance) !== undefined) {
108
108
  codexCredits = { unlimited: false, balance: String(credits.balance) };
109
109
  } else {
110
- // balance 是可选字段,但 unlimited=false 仍是一个有效、可展示的 Credits 状态。
110
+
111
111
  codexCredits = { unlimited: false };
112
112
  }
113
113
  }
@@ -119,7 +119,7 @@ export function normalizeCodexUsage(usage) {
119
119
  };
120
120
  }
121
121
 
122
- /** OpenCode Go usage payload → 剩余百分比窗口;无效窗口单独跳过,限流窗口保留。 */
122
+
123
123
  export function normalizeOpenCodeUsage(payload) {
124
124
  const usage = payload && typeof payload === 'object' && !Array.isArray(payload) ? (payload.usage ?? payload) : undefined;
125
125
  if (!usage || typeof usage !== 'object' || Array.isArray(usage)) throw new Error('invalid opencode usage');
@@ -131,7 +131,7 @@ export function normalizeOpenCodeUsage(payload) {
131
131
  if (status !== undefined && status !== null && status !== 'ok' && status !== 'rate-limited') continue;
132
132
  const usedPercent = clampPercent(detail.percent);
133
133
  if (usedPercent === undefined) continue;
134
- // percent=0 时 OpenCode 返回的是 now+window 占位值,不是可展示的 resetAt。
134
+
135
135
  const resetAt = usedPercent === 0 ? undefined : isoFromDate(detail.resetsAt);
136
136
  windows.push({
137
137
  window: label,