@dsh-mobile/mobile-remote 3.2.5 → 3.2.7

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 (44) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/CONTRIBUTING.md +3 -1
  3. package/FAQ.md +1 -1
  4. package/README.md +7 -7
  5. package/cordis.patch.yml +10 -2
  6. package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +413 -102
  7. package/docs/01-PRD.md +1 -1
  8. package/docs/02-architecture.md +1 -1
  9. package/docs/04-security.md +2 -1
  10. package/docs/06-install-run.md +0 -14
  11. package/docs/09-compatibility.md +1 -1
  12. package/docs/11-remote-relay-guide.md +18 -14
  13. package/docs/APP-REVIEW-NOTES.md +105 -0
  14. package/docs/COMPANION-PLAN.md +199 -0
  15. package/docs/PRIVACY-POLICY.en.md +76 -68
  16. package/docs/PRIVACY-POLICY.md +76 -68
  17. package/docs/STORE-LAUNCH.md +88 -25
  18. package/docs/STORE-LISTING.md +80 -40
  19. package/docs/TERMS-OF-SERVICE.en.md +58 -26
  20. package/docs/TERMS-OF-SERVICE.md +58 -26
  21. package/lib/account-usage-query.js +117 -4
  22. package/lib/client.js +4 -5
  23. package/lib/config.js +6 -4
  24. package/lib/index.js +109 -19
  25. package/lib/relay/mux.js +9 -1
  26. package/lib/timeline.js +26 -10
  27. package/package.json +8 -1
  28. package/docs/10-remote-access-and-launch-plan.md +0 -216
  29. package/docs/ARCHITECTURE-CURRENT.md +0 -229
  30. package/docs/AUDIT-2026-11-node.md +0 -181
  31. package/docs/AUDIT-2026-11.md +0 -167
  32. package/docs/BUILD-ENVIRONMENT.md +0 -180
  33. package/docs/FEATURE-PARITY.md +0 -195
  34. package/docs/REA-UNDERSTANDING.md +0 -246
  35. package/docs/screenshots/01-home.png +0 -0
  36. package/docs/screenshots/02-notifications.png +0 -0
  37. package/docs/screenshots/03-sessions.png +0 -0
  38. package/docs/screenshots/04-chat.png +0 -0
  39. package/docs/screenshots/05-settings.png +0 -0
  40. package/docs/screenshots/06-new-session.png +0 -0
  41. package/docs/screenshots/07-connect.png +0 -0
  42. package/docs/screenshots/pgy-appstore.jpg +0 -0
  43. package/docs/screenshots/pgy-mobile-app.jpg +0 -0
  44. package/docs/screenshots/pgy-pc-client.jpg +0 -0
package/lib/timeline.js CHANGED
@@ -165,13 +165,25 @@ function reasoningText(blocks) {
165
165
 
166
166
  /** image attachment 引用 → 移动端图片元数据(仅引用不含字节;渲染时 App 按 attachmentId 走 /attachment 端点拉取)。 */
167
167
  function imageMetaOf(ref) {
168
- if (!ref || typeof ref !== "object" || !ref.attachmentId) return null;
168
+ if (!ref || typeof ref !== "object") return null;
169
+ // 内核不同路径产出的附件引用字段并不统一:桌面端历史里可能是 `{ id }`,
170
+ // 移动端上传是 `{ attachmentId }`,媒体类型也有 mediaType/mimeType 两种写法。
171
+ const attachment = ref.attachment && typeof ref.attachment === "object" ? ref.attachment : ref;
172
+ const id = attachment.attachmentId ?? attachment.id;
173
+ if (id === undefined || id === null || String(id) === "") return null;
174
+ const mediaType = typeof attachment.mediaType === "string"
175
+ ? attachment.mediaType
176
+ : typeof attachment.mimeType === "string"
177
+ ? attachment.mimeType
178
+ : typeof attachment.media_type === "string"
179
+ ? attachment.media_type
180
+ : "image/jpeg";
169
181
  return {
170
- attachmentId: String(ref.attachmentId),
171
- mediaType: typeof ref.mediaType === "string" ? ref.mediaType : "image/jpeg",
172
- ...(Number.isFinite(ref.width) ? { width: ref.width } : {}),
173
- ...(Number.isFinite(ref.height) ? { height: ref.height } : {}),
174
- ...(typeof ref.name === "string" && ref.name !== "" ? { name: ref.name } : {}),
182
+ attachmentId: String(id),
183
+ mediaType,
184
+ ...(Number.isFinite(attachment.width) ? { width: attachment.width } : {}),
185
+ ...(Number.isFinite(attachment.height) ? { height: attachment.height } : {}),
186
+ ...(typeof attachment.name === "string" && attachment.name !== "" ? { name: attachment.name } : {}),
175
187
  };
176
188
  }
177
189
 
@@ -179,9 +191,12 @@ function imageMetaOf(ref) {
179
191
  function imagesOf(blocks) {
180
192
  const out = [];
181
193
  for (const block of blocks ?? []) {
182
- const ref = block?.type === "image" ? block.attachment : undefined;
183
- const meta = imageMetaOf(ref);
184
- if (meta) out.push(meta);
194
+ if (!block || typeof block !== "object") continue;
195
+ // image block 既可能把引用放在 `attachment` 里,也可能直接平铺在 block 上。
196
+ if (block.type === "image") {
197
+ const meta = imageMetaOf(block.attachment ?? block);
198
+ if (meta) out.push(meta);
199
+ }
185
200
  }
186
201
  return out;
187
202
  }
@@ -197,7 +212,8 @@ function imagesOfNested(blocks) {
197
212
  for (const block of list ?? []) {
198
213
  if (!block || typeof block !== "object") continue;
199
214
  if (block.type === "image") {
200
- const meta = imageMetaOf(block.attachment);
215
+ // 与 imagesOf 一致:引用可能在 attachment 里,也可能直接平铺在 block 上。
216
+ const meta = imageMetaOf(block.attachment ?? block);
201
217
  if (meta) out.push(meta);
202
218
  } else if (block.type === "tool-result" && Array.isArray(block.content)) {
203
219
  walk(block.content);
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@dsh-mobile/mobile-remote",
3
- "version": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "description": "DSH Mobile:把 DeepSeek Harness 变成随身控制台——手机远程发消息派活、看进度、收通知、审批决策、管理会话;配套 Flutter App(Android 已发布;iOS 工程已编译通过,尚未真机验证)",
5
5
  "type": "module",
6
+ "scripts": {
7
+ "test": "node --test test/*.js test/*.mjs",
8
+ "check": "node --check lib/index.js && node --check lib/client.js",
9
+ "verify:deploy": "node tools/verify-deployment.mjs"
10
+ },
6
11
  "main": "lib/index.js",
7
12
  "exports": {
8
13
  ".": "./lib/index.js",
@@ -13,6 +18,8 @@
13
18
  "lib",
14
19
  "cordis.patch.yml",
15
20
  "docs",
21
+ "!docs/screenshots",
22
+ "!docs/business-plan",
16
23
  "README.md",
17
24
  "FAQ.md",
18
25
  "CHANGELOG.md",
@@ -1,216 +0,0 @@
1
- # 10 — Off-LAN access design and store-launch readiness
2
-
3
- > Status (updated 2026-11-01): **designed, implemented and tested in code; not deployed anywhere.** The relay server, the
4
- > plugin connector with pairing and the desktop panel, the phone-side client and the in-app pairing flow all exist
5
- > (section 1.8 lists exactly what is verified and what is not). Section 2 is the store-readiness audit as of the first
6
- > audit date; its code-side items have since been addressed (see section 2.5).
7
- >
8
- > **Launch scope (decided 2026-11-01): the first store release is LAN-only.** The relay code, protocol, tests and docs stay in the
9
- > tree, but every user-facing entry point is hidden: the app's `Features.remoteAccess` (`lib/features.dart`) defaults to `false`
10
- > and the desktop panel's `relayUi.advertiseWhenOff` (`lib/client.js`) defaults to `false`. Phones that were already paired through
11
- > a relay keep working and can still unpair. Because the relay's own cipher code still ships inside the binary, the iOS export
12
- > declaration stays `true` (section 3c of `STORE-LAUNCH.md`). Turning remote access on for a later release is two one-line changes
13
- > plus the deployment steps in section 1.9 and `11-remote-relay-guide.md`.
14
- >
15
- > Evidence for the original audit was gathered at App `3.2.4+31` / plugin `3.2.4` and from the Android release build of that day.
16
- > Items marked **(verify)** rest on a source that is not Apple's or Google's own text; check them in the live console.
17
-
18
- ## 0. Decisions needed from you before any code
19
-
20
- | # | Decision | Why it blocks |
21
- |---|---|---|
22
- | D1 | **Which Apple program are the accounts in?** Apple's Enterprise Program is for internal employee apps only; Apple tells anyone shipping to the public to enroll in the standard Apple Developer Program ([Apple](https://developer.apple.com/programs/enterprise/)). App Store Connect / TestFlight / App Store release need the standard program (Organization). | If the account is Enterprise, nothing in section 3 can be submitted. |
23
- | D2 | **Who runs the relay** (your company, or customers self-host) and **in which region** (mainland China needs ICP filing; Hong Kong / Singapore does not but adds latency). | Sets hosting, legal and privacy-label answers. |
24
- | D3 | **DeepSeek branding.** The app icon and home screen use a whale mark that reads as DeepSeek's logo, the README calls it the "official logo", and the store subtitle names DeepSeek. Do you have written permission? *(Update 2026-11-01: the whale mark is gone from the app; what remains is the nominative use of the name "DeepSeek Harness" — see `docs/STORE-LAUNCH.md` §3c.)* | Apple 5.2 (intellectual property) and Google Play's impersonation policy are common rejection reasons. |
25
- | D4 | **Push strategy**: APNs + FCM through the relay, or keep user-configured webhooks only. | iOS cannot deliver notifications while suspended without APNs. |
26
-
27
- **Where these stand (2026-11-01).** D1: resolved by the owner (accounts are in order). D2: the code supports both; Cloudflare
28
- is a suitable host (section 1.9) and a self-hosted Node relay is the fallback, procurement is the owner's. D3: **unresolved** and not
29
- a code question. D4: open; push over the relay is not built (section 1.8).
30
-
31
- ## 1. Part A — Making the app work off the home network
32
-
33
- ### 1.1 Requirements
34
-
35
- 1. Works from any network with **no VPN app** on the phone and **no extra software** on the PC beyond the plugin that is already installed.
36
- 2. A compromised relay must **not** be able to control a PC (the agent can run commands, so this is the key risk).
37
- 3. Prefer a **direct LAN** connection when it exists (speed, privacy, no relay cost).
38
- 4. **Reuse the existing HTTP + SSE API** (`/m/api/*`); do not rewrite the screens.
39
- 5. **Per-device revocation** (today one shared token authorises every phone).
40
- 6. Notifications while the app is suspended.
41
- 7. Store-compliant: encrypted in transit, claims in the listing are true.
42
-
43
- ### 1.2 Options considered
44
-
45
- | Option | Phone software | PC software | Secure if the middle is hostile? | Verdict |
46
- |---|---|---|---|---|
47
- | Virtual LAN (Pgyer, ZeroTier, EasyTier, WireGuard) | VPN app | VPN app | yes | works today; fails requirement 1 |
48
- | Public tunnel (frp, Cloudflare Tunnel) + bearer token | none | tunnel tool | no — tunnel sees plaintext; one shared token guards remote code execution | acceptable stop-gap only |
49
- | Cloud relay that terminates TLS | none | none | **no** — relay sees and can alter everything | rejected |
50
- | **End-to-end-encrypted rendezvous relay (chosen)** | none | none | **yes** — relay forwards ciphertext only | recommended |
51
- | WebRTC peer-to-peer | none | none | yes | still needs a signalling server and a TURN relay for symmetric NATs; keep as a later optimisation |
52
- | Embed a WireGuard/Tailscale stack in the app | none | daemon needed on PC | yes | heavy, Go/native on both sides, Tailscale control plane is not reachable from mainland China per the existing docs |
53
-
54
- ### 1.3 Chosen design: outbound-only E2EE relay with request tunnelling
55
-
56
- ```
57
- Phone app Relay (ciphertext only) PC plugin
58
- ───────── ─────────────────────── ─────────
59
- RelayClient ──WSS (outbound)──▶ rooms[roomId] ◀──WSS (outbound)── relay connector
60
- │ forwards frames │
61
- └────────── Noise_IK end-to-end encrypted channel ───────────────────────┘
62
- (HTTP requests / SSE streams tunnelled inside) │
63
- loopback ──▶ existing /m/api handlers
64
- ```
65
-
66
- * **Both sides dial out.** The PC opens no inbound port, so it works behind any NAT or home router.
67
- * **Relay** is a small WebSocket router: it knows `roomId` and byte counts, never keys or plaintext. It stores nothing on disk.
68
- * **Channel security**: `Noise_IK_25519_ChaChaPoly_BLAKE2s`. The phone already knows the PC's static public key from the pairing QR; the first message carries the phone's static key encrypted. Mutual authentication, forward secrecy, one round trip per reconnect. Primitives come from audited libraries (Dart: `cryptography`; Node: `@noble/*` or libsodium); the handshake is verified against the official Noise test vectors in CI so no custom crypto is trusted on faith.
69
- * **Tunnelling**: inside the encrypted channel a small stream multiplexer carries `OPEN(streamId, method, path, headers)`, `DATA`, `END`, `RST`, `WINDOW`. SSE is just a long-lived response whose `DATA` frames arrive over time. Credit-based flow control (e.g. 256 KiB per stream, 4 MiB per connection), 16 KiB frames, so a 20 MB image upload cannot stall `hello`/heartbeat frames.
70
- * **Pairing**: the desktop settings page ("连接移动端设备") already renders a QR. It would encode `dsh://pair?v=1&relay=<wss urls>&pc=<roomId>&pk=<PC public key>&otp=<one-time secret>&lan=<lan urls>`. The OTP is single-use and expires in minutes; the phone's key is stored in the PC's device list, shown in the desktop UI with a **Revoke** button. After pairing, no reusable bearer token crosses the network.
71
- * **Path selection**: candidates are tried in order LAN → any virtual-network address → relay, with short timeouts, and re-probed on a network change. The app already stores several addresses and rotates between them (`Api.baseUrls`, `rotateBaseUrl()`, `AppStore.switchBase`); the relay becomes one more candidate, and the (still unreleased) fix that makes the live stream follow the saved address is what makes switching safe.
72
- * **Optional later hardening**: run the *same* Noise channel directly over the LAN as well. That removes cleartext HTTP and the shared token entirely (answers "encrypted in transit: yes" for both stores).
73
-
74
- ### 1.4 Where it plugs into the existing code (checked, not assumed)
75
-
76
- | Area | Fact found | Change |
77
- |---|---|---|
78
- | App networking | Every request goes through one injectable `http.Client`: `Api({http.Client? client})` (`api.dart:84`); file downloads take an injectable `downloadClient` (`api.dart:498-500`, `:586`). No raw `WebSocket`, `HttpClient` or `Image.network` elsewhere in `lib/`. | Add `TransportClient extends http.BaseClient` that dispatches `http(s)://` to the normal client and `dsh-relay://<roomId>` to the tunnel. Screens stay untouched. |
79
- | Live stream | `AppStore.connect()` / `_connectedBase` (added by the unreleased live-stream fix) rebuild the SSE when the address changes. | No change; relay base URLs just flow through it. |
80
- | Plugin auth | The LAN bridge already forwards to the webserver with a per-process nonce header (`CLIENT_IP_HEADER`, `lib/index.js` ~7236) that outsiders cannot forge. | The relay connector replays decrypted requests to loopback with a second nonce header meaning "device already authenticated by Noise"; the bridge strips that header from any external request. |
81
- | Desktop UI | `lib/client.js` injects the settings section that shows the QR. | Add the new QR payload and a paired-devices list. |
82
-
83
- ### 1.5 Security and threat model
84
-
85
- | Threat | Outcome with this design |
86
- |---|---|
87
- | Relay operator or attacker controls the relay | Sees only metadata (room id, IPs, sizes, timing). Cannot read, alter or inject traffic, and cannot impersonate the phone (needs its private key) or the PC. Can deny service. |
88
- | Network attacker between phone and relay | TLS (WSS) outside, Noise inside. |
89
- | Stolen phone | Revoke the device on the PC. Device key lives in Keychain / Keystore (optionally biometric-gated). |
90
- | QR photographed | OTP is single-use and short-lived; useless afterwards. |
91
- | Malicious device on the LAN | Unchanged from today: loopback-only webserver, LAN bridge needs a token ≥ 16 chars; to be superseded by LAN Noise (phase 3). |
92
- | Replay / downgrade | Noise nonces, per-stream counters, version in the handshake prologue, no plaintext fallback. |
93
- | Relay abuse | Per-IP join rate limits, per-room caps, byte quotas, bound on unauthenticated bytes before handshake completes. |
94
- | Malware already on the PC | Out of scope (it could already run the agent). |
95
-
96
- ### 1.6 Operations and compliance
97
-
98
- * Relay: stateless Node (or Go) service, in-memory room table, sticky routing by `roomId` for horizontal scaling; or Cloudflare Durable Objects. Docker image so enterprises can self-host. Expect thousands of idle WebSockets per small node, **to be load-tested**; this is an estimate, not a measurement.
99
- * Encryption export rules: using Noise/ChaCha20 from third-party libraries is *custom encryption* for App Store Connect export-compliance purposes, so the "uses non-exempt encryption" answer and annual self-classification paperwork likely apply. Decide this early with legal advice. The app now declares `ITSAppUsesNonExemptEncryption = true` because the relay client ships its own Noise / X25519 / ChaCha20-Poly1305 (see `docs/STORE-LAUNCH.md` section 3c); the paperwork itself is the publisher's to file.
100
- * Privacy labels change: the relay processes IP addresses and room identifiers, even though it cannot read content.
101
- * Mainland-China hosting needs ICP filing; cross-border handling of data is a separate legal question.
102
-
103
- ### 1.7 Phases (rough planning estimates for one senior engineer, not commitments)
104
-
105
- | Phase | Scope | Estimate |
106
- |---|---|---|
107
- | 0 | Docs: say "same Wi-Fi needs nothing; away from home is optional, here are the choices"; in-app hint; correct the "from anywhere" subtitle until phase 1 ships | 1–2 days |
108
- | 1 | Noise implementation + test vectors; relay MVP; plugin connector; `TransportClient`; pairing QR + paired-devices UI; path selection; tests with real sockets | 4–6 weeks |
109
- | 2 | Push: APNs (+ notification-service extension that fetches and shows real text locally), FCM; keep user webhooks; device management polish | 3–4 weeks |
110
- | 3 | Noise over LAN (drop cleartext HTTP and shared token); optional WebRTC direct upgrade; relay observability | 2–3 weeks |
111
-
112
- ### 1.8 Implementation status
113
-
114
- | Piece | State | Evidence | Not verified |
115
- |---|---|---|---|
116
- | Relay hub (platform-neutral routing, host auth by Ed25519, pre-verification budget, limits) | Done | `relay-hub` 18 tests, mutation-checked | No load test |
117
- | Node/`ws` adapter and Cloudflare Worker + Durable Object adapter | Done | `relay-node-server` 8 (real sockets), `relay-cloudflare` 6 (fake runtime) | **Never run on real Cloudflare** |
118
- | Noise_IK / mux / pairing link (Node reference) | Done | `relay-noise` 15, `relay-mux` 17, deterministic vectors | **Official Noise test vectors** (none available offline) |
119
- | Plugin connector, device store, one-time pairing codes, revocation, `/m/api/relay/*` | Done, disabled by default | `relay-state` 14, `relay-e2e` 18 through the real plugin and HTTP server | Real network conditions |
120
- | Desktop settings panel (status, pairing QR, devices, revoke) | Done | `client-relay-panel` 16 (tiny renderer, 8 mutations on the panel plus 3 on the launch gate) | **Not looked at inside a real DSH Desktop** |
121
- | Phone crypto in pure Dart (X25519, ChaCha20-Poly1305, HKDF) | Done, **hand-written** | 90+ vectors from OpenSSL, RFC vectors, BigInt differential, 18 mutations | **Not audited; Dart gives no constant-time guarantee.** Replace with an audited package before launch (one file: `lib/relay/crypto.dart`) |
122
- | Phone Noise / mux / relay client / `TransportClient` exit | Done | Dart unit 76, **Dart-to-Node end-to-end against a real relay and the real plugin** 19 | Real devices |
123
- | App pairing flow (scan or paste link), Keychain/Keystore storage, settings (status, unpair), fresh-install purge | Done | `relay_store` 8, `relay_messages` 6, `api_relay` 15, `relay_pairing_ui` 19 (includes the launch gate: switch off hides the entry points, switch on restores them), mutation-checked | iOS/Android hardware, camera scan of the real QR |
124
- | Path selection | **Partial.** A relay-paired phone uses the relay everywhere, including at home. If the phone also has a LAN token, LAN and relay are both rotation candidates. | `api_relay` rotation tests | **No automatic "prefer LAN when reachable".** A direct Noise-over-LAN path (phase 3) is the clean fix |
125
- | Push notifications over the relay (APNs/FCM) | **Not built** | n/a | iOS cannot deliver while suspended without it |
126
- | Login / accounts | **Not built, and not needed** (section 2.4) | n/a | n/a |
127
-
128
- Two defects found only because the second implementation existed: a cancelled-before-response request hung forever in the Node
129
- mux, and the paste dialog disposed its controller while the route was still animating. Both fixed with tests.
130
-
131
- ### 1.9 Is Cloudflare a suitable relay host?
132
-
133
- **Yes, with four caveats.** The relay only forwards opaque frames, keeps no database and holds no secrets, which is the shape
134
- Workers + Durable Objects handles well: global TLS termination, no server to patch, built-in DDoS absorption, and one Durable
135
- Object per room gives the "all sockets of a room land in one place" property the hub needs.
136
-
137
- 1. **Untested on the real platform.** The adapter is contract-tested against a fake runtime. The first deploy must be followed
138
- by `node relay/smoke.mjs wss://<host>`; the most likely first failure is the WebCrypto name for Ed25519 on Workers.
139
- 2. **Cost shape.** The adapter uses the standard `accept()`, so a Durable Object stays resident and is billed for duration while
140
- any socket is open. Hibernation would cut that but means moving hub state into socket attachments. Check current pricing and
141
- plan limits in Cloudflare's own documentation **(verify)**; they were not looked up in this session.
142
- 3. **Mainland China.** Cloudflare is not reliably reachable or fast from the mainland. If most users are there, also run the
143
- Node relay on a Hong Kong or ICP-filed host; the pairing link already carries up to four relay URLs and the client fails over.
144
- 4. **Privacy label.** Cloudflare's own request logs may retain IPs. If they do, the App Privacy answer is no longer
145
- "Data Not Collected" (see `docs/STORE-LAUNCH.md` section 3c).
146
-
147
- Neither choice is lock-in: the hub is shared, and the Node adapter is a drop-in for a small VPS.
148
-
149
- ## 2. Part B — Store-launch readiness (development side only)
150
-
151
- ### 2.1 Verdict
152
-
153
- The client itself is in good technical shape: the Android release APK and AAB build, 612 automated tests pass, `flutter analyze` and `dart format` are clean, and Android meets the 16 KB page-size rule. **It is not ready to submit.** The gaps are: account type (D1), no review path for Apple/Google reviewers, no release signing, a branding risk, and two claims in the listing that are not true yet ("from anywhere", "receive notifications" on iOS). Most of the remaining list is quick.
154
-
155
- ### 2.2 Evidence table
156
-
157
- Legend: OK = verified; GAP = needs work; YOU = only you can do it.
158
-
159
- | Area | Finding | Status |
160
- |---|---|---|
161
- | Apple account | Enterprise Program cannot publish to the App Store (see D1). | **YOU — blocker** |
162
- | Review access | No demo mode exists in the app (searched `lib/`). A reviewer cannot run a DSH host, so Apple 2.1 (app completeness) and Play "app access" will fail without a built-in demo mode or hosted demo host + review notes. | **GAP — blocker** (≈ 3–5 days) |
163
- | Release signing | No `key.properties`; builds are debug-signed (`CN=Android Debug`). `release.yml` / `android-build.yml` do not exist in the repo (the launch notes say so). | **YOU / GAP** |
164
- | Branding / IP | ~~Whale mark resembles DeepSeek's logo; README says "官方 logo"~~ — **resolved 2026-11-01**: the DeepSeek logo and the icons derived from it were removed; the default icon, logo and home character are now the project's own pictures and the other icons and the pet are code-drawn (`docs/BRAND-ASSETS.md`). Still open for the publisher: the listing names DeepSeek (nominative use + non-affiliation statement), and git history still contains the old files. | **Mostly closed — publisher to confirm name usage (D3)** |
165
- | Listing accuracy | Subtitle "DeepSeek Harness from anywhere" but the app only works on a shared/virtual network today. Description says "receive notifications"; iOS has no background mode or push entitlement, so notifications arrive only while the app is open or through user webhooks. | **GAP** (Apple 2.3) |
166
- | Android target / format | `targetSdk 36`, `minSdk 24`, AAB builds (96 MB universal; Play serves per-ABI splits), R8 mapping produced, `allowBackup=false`. | OK |
167
- | 16 KB pages | All 64-bit native libraries have LOAD alignment ≥ 0x4000 (checked with `llvm-readelf` on arm64-v8a and x86_64). One 32-bit ML Kit library is 4 KB-aligned; 16 KB devices run 64-bit only, so it does not matter. | OK |
168
- | Android permissions | `INTERNET`, `CAMERA`, `POST_NOTIFICATIONS`, `SYSTEM_ALERT_WINDOW`, `FOREGROUND_SERVICE(+_SPECIAL_USE)`, plus harmless `ACCESS_NETWORK_STATE`, `VIBRATE`. Matches the launch notes except those two. | OK |
169
- | Foreground services | Two services, both `specialUse`. Play requires every foreground-service type to be declared in Play Console with a video demonstrating the feature, and all types are reviewed ([Google](https://support.google.com/googleplay/android-developer/answer/16965181)). Whether `specialUse` needs the video is **(verify)**. Both features are opt-in (keep-alive defaults off; overlay needs the user to grant "display over other apps"). | **GAP** — prepare declarations, or ship the Play build without them |
170
- | Cleartext traffic | Android `usesCleartextTraffic=true`; iOS `NSAllowsLocalNetworking`. Fine for LAN, but off-LAN must be TLS/E2EE, and the Data-safety "encrypted in transit" answer depends on it. | **GAP** (solved by phase 1/3) |
171
- | iOS privacy manifest | App target has none. The app's Swift code uses no Apple required-reason API (`fileSizeKey` is not on the list); seven plugins and `Flutter.framework` ship their own manifests. | Low risk; add a minimal one anyway |
172
- | iOS Info.plist | Camera, photo, local-network strings present but **Chinese only**; `NSUserNotificationUsageDescription` has no effect on iOS as far as I know, since notification permission needs no Info.plist string (harmless); `ITSAppUsesNonExemptEncryption` missing. | **GAP** (small) |
173
- | iOS devices | `TARGETED_DEVICE_FAMILY = "1,2"`: iPad is supported, so iPad screenshots and layouts are required; restrict to iPhone if you do not want to test iPad. | **GAP** (decision) |
174
- | iOS real-device behaviour | CHANGELOG states real-device behaviour is unverified; unsigned builds cannot use the Keychain (error −34018); only simulator runs have been done. | **GAP** — TestFlight smoke test |
175
- | Background on iOS | No `UIBackgroundModes`, no `aps-environment` entitlement, no APNs code. | **GAP** (phase 2) |
176
- | Google Play new-account testing | Google requires a closed test with at least 12 testers opted in for 14 days before production access; reports say organization accounts are exempt, but that exemption is in third-party sources only **(verify)** ([Google](https://support.google.com/googleplay/android-developer/answer/14151465)). | YOU |
177
- | Store URLs and policies | Privacy-policy and support URLs, support e-mail, App Privacy / Data-safety forms, content rating. Draft text exists (`PRIVACY-POLICY.md`, `SUPPORT.md`, `STORE-LAUNCH.md`). | YOU |
178
- | Robustness found during testing | One mistyped field makes the whole session list fail to parse (`'String' is not a subtype of 'num?'`), so version skew between the store app and the separately installed plugin could blank the list. The first-run "old shortcut" dialog also appears on brand-new Android installs. | **GAP** (small) |
179
-
180
- ### 2.3 Suggested order of work
181
-
182
- 1. **You:** settle D1 and D3; create the Apple Developer Program (Organization) enrolment if needed; Android upload keystore with Play App Signing; public privacy / support URLs.
183
- 2. **Quick code fixes (≈ 3–4 days):** English `InfoPlist` strings, `ITSAppUsesNonExemptEncryption`, minimal `PrivacyInfo.xcprivacy`, tolerant session parsing, hide the upgrade-only dialog on fresh installs, decide iPad scope, correct the listing claims.
184
- 3. **Review path (≈ 3–5 days):** an in-app demo mode with canned sessions and a scripted conversation, plus a short review-notes template.
185
- 4. **Branding** resolved (permission or replacement assets).
186
- 5. **Relay phase 1**, then push (phase 2), then TestFlight / Play internal-track smoke tests on real devices.
187
-
188
- A realistic path to a *submittable* build without the relay is roughly 2–3 weeks once the account and branding questions are answered; with relay phase 1 it is roughly 6–8 weeks. These are planning estimates.
189
-
190
- ### 2.4 Does either store require a user login?
191
-
192
- **No.** Neither Apple nor Google requires an app to have accounts. The relevant rules only apply if you add them:
193
-
194
- * Apple App Review 5.1.1(v): an app that lets users create an account must also let them delete it inside the app.
195
- Guideline 4.8 (Sign in with Apple as an equal option) applies only if you offer a third-party social login.
196
- * Google Play's account-deletion and "App access" requirements likewise apply to apps with accounts or gated content.
197
- * What reviewers do need is a way to see the app working (Apple 2.1, Play "App access"). The built-in demo mode covers that
198
- without credentials.
199
-
200
- DSH Mobile has no developer-side account: the "login" is the pairing between one phone and one computer (a per-computer key in the
201
- Keychain/Keystore, revocable from the computer). Adding accounts would create a server, stored personal data, deletion flows
202
- and a larger privacy label, with no feature that needs it. Revisit only if you add something that does (paid plans, a
203
- publisher-run relay that needs per-customer quotas).
204
-
205
- ### 2.5 What happened to the original blockers (code side)
206
-
207
- Done: demo mode, iOS en/zh-Hans permission strings and privacy manifest, iPhone-only, export-compliance declaration (now `true`),
208
- Play foreground-service and overlay text, Data-safety draft, upload-key script with a verified signing chain, privacy policy
209
- sections for demo mode and the relay. **Still open and not code:** DeepSeek branding permission (D3), the export-compliance filings,
210
- store-console forms, real-device and TestFlight testing, iPad support (not attempted), push (D4).
211
-
212
- ## 3. Sources
213
-
214
- * Apple, Developer Enterprise Program: <https://developer.apple.com/programs/enterprise/>
215
- * Google Play, testing requirement for new personal accounts: <https://support.google.com/googleplay/android-developer/answer/14151465>
216
- * Google Play, foreground-service declaration: <https://support.google.com/googleplay/android-developer/answer/16965181>
@@ -1,229 +0,0 @@
1
- # DSH Mobile 当前架构
2
-
3
- 这份文档把当前代码实际形成的边界固定下来,作为补 iOS、脚本和 CI 时的改动基线。它刻意保留现有 Android 业务架构和 `/m/api` 协议;平台差异只在需要原生能力的接缝处理,避免为了双端适配重写已经稳定的状态、路由和事件模型。
4
-
5
- > 记录时间:2026-11-01(Asia/Shanghai)
6
- > 基线:插件 `3.2.4`,Flutter App `3.2.4+31`
7
-
8
- ## 1. 总体数据流
9
-
10
- ```text
11
- Flutter App(iOS / Android)
12
- │ HTTP JSON + SSE
13
- ▼
14
- dsh-mobile-remote 插件(/m/api、SSE、认证、通知、LAN bridge)
15
- │ ctx.get / ctx.inject / session event
16
- ▼
17
- DSH 宿主服务(agents / sessions / llm / permission / workspaces / goals)
18
- │
19
- ▼
20
- DSH agent loop 与会话持久化(电脑端唯一真源)
21
- ```
22
-
23
- 手机端不复制会话数据库。App 启动时先恢复连接配置和 UI 缓存,再从 `/api/bootstrap` 获取服务端状态;持续状态由 `/api/events` SSE 和按需 REST 补拉共同维护。
24
-
25
- ## 2. Flutter 入口和页面结构
26
-
27
- ### 2.1 入口
28
-
29
- - `lib/main.dart`:`WidgetsFlutterBinding.ensureInitialized()`、日志初始化、API 配置加载、App 偏好加载、主题和全局 `AppStore` 创建、通知/保活/宠物初始化,以及连接页和主导航。
30
- - 全局 `AppStore store = AppStore()`:使用 `ChangeNotifier`,由页面通过构造参数或全局入口读取。
31
- - `rootNavigatorKey`:允许通知、桌面宠物面板动作和冷启动动作跨页面跳转。
32
-
33
- ### 2.2 页面
34
-
35
- | 区域 | 实现 | 责任 |
36
- |---|---|---|
37
- | 连接 | `main.dart`、`scan_screen.dart` | 扫码、手动地址/token、探测、保存、进入主界面 |
38
- | 首页 | `screens/home_screen.dart` | 欢迎语、最近会话、新建会话、输入配置、皮肤背景/角色 |
39
- | 会话 | `screens/sessions_screen.dart`、`session_list.dart` | 会话列表、刷新、工作区归属、归档和打开 |
40
- | 对话 | `screens/chat_screen.dart` | 历史、流式消息、Markdown、工具状态、队列、任务、审批/问询、文件/Git/命令 |
41
- | 通知 | `screens/notifications_screen.dart` | 未读、已读、删除、跳转会话 |
42
- | 设置 | `screens/settings_screen.dart` | 连接、主题、语言、外观、模型/权限/provider、用量、诊断、后台能力 |
43
- | 用量 | `screens/usage_screen.dart` | 余额、账户来源和配额 |
44
- | Provider | `screens/providers_screen.dart` | 真实 provider 列表、编辑、探测、保存和删除密钥 |
45
- | 文件 | `screens/session_files_screen.dart`、`session_files_controller.dart` | 工作区文件、下载、预览、Markdown/源码、解码 |
46
- | 工具弹层 | `screens/session_tools_sheet.dart`、`git_browser_sheet.dart`、`sheets.dart` | jobs、子代理、目标、Git、目录和新建会话选择 |
47
-
48
- 现有页面和业务不应因为 iOS 工程补齐而删除。需要平台差异时,页面依赖平台能力抽象,不直接调用 Android MethodChannel。
49
-
50
- ## 3. 状态管理
51
-
52
- `lib/store.dart` 的 `AppStore extends ChangeNotifier` 负责:
53
-
54
- - 当前 `sessionId`、会话列表、catalog、session config、actions、workspace;
55
- - 当前 agent/session 状态映射,规范为 `idle | running`;
56
- - 连接状态、SSE subscription、看门狗、重试退避和地址轮换;
57
- - pending questions、approvals、队列镜像、任务和上下文窗口;
58
- - 通知列表、未读数和 `AttentionLedger`;
59
- - 主题、语言、皮肤、图标、推理显示和聊天行为偏好;
60
- - 会话列表缓存、草稿、思维链折叠覆盖和 Git tab 状态。
61
-
62
- 状态来源按优先级分为:
63
-
64
- 1. 服务端 bootstrap 的快照;
65
- 2. SSE 的增量事件和 pending frame;
66
- 3. 事件缺失或恢复期间的 REST 补拉;
67
- 4. 仅用于首屏体验的本地偏好/列表缓存。
68
-
69
- AppStore 不应把本地缓存当作服务端事实;重连和回前台必须重新从服务端收敛状态。
70
-
71
- ## 4. API 层
72
-
73
- `lib/api.dart` 是唯一的 Flutter HTTP/SSE 客户端,负责:
74
-
75
- - 连接配置、path 标准化、候选 URL 合并和轮换;
76
- - `X-Mobile-Token` 认证头;
77
- - JSON 请求、错误码和 HTTP status 映射到 `ApiException`;
78
- - SSE 文本分帧、JSON 解码、心跳和连接建立超时;
79
- - 会话、历史、消息、审批、通知、文件、工作区、Git、模型、provider、用量和诊断端点;
80
- - 文件下载的流式响应、Range/ETag 能力和图片附件 LRU。
81
-
82
- 协议面保持 `/m/api` 和服务端既有字段,不引入新状态管理框架或第二套 API 客户端。iOS 适配首先复用该层,只有平台保存、通知和文件交互需要新增能力实现。
83
-
84
- ## 5. 事件流
85
-
86
- ### 5.1 App 侧 SSE 分发
87
-
88
- `store.dart` 的事件入口把顶层帧分发为:
89
-
90
- - `hello`:能力、连接、地址、会话、通知、目录和 catch-up;
91
- - `git/changed`:Git 数据变化;
92
- - `notifications/changed`:通知列表变化;
93
- - `mobile/notify`:插件通知;
94
- - `mobile/frame`:问询/审批 requested/resolved;
95
- - `mobile/queue`:队列镜像;
96
- - `session/context`:上下文窗口;
97
- - `session/jobs`:任务和进度;
98
- - `session/event`:可见会话事件;
99
- - `agent/status`:agent/session 运行状态。
100
-
101
- `session/event` 不使用过窄白名单;`assistant/chunk`、`assistant/live-chunk`、`tool/call`、`tool/result` 等由聊天页根据事件类型解释。`turn/end` 触发通知判据。
102
-
103
- ### 5.2 服务端事件桥
104
-
105
- `lib/index.js` 在宿主 session/event 上订阅并生成移动端摘要,通过 SSE 广播;问询、审批和队列等瞬态帧通过移动桥回放。服务端负责认证、连接上限、心跳和广播失败隔离。桌面版 webserver 强制回环时,LAN bridge 在插件内监听外部地址并只转发移动路由。
106
-
107
- ## 6. 连接和重连
108
-
109
- 当前流程:
110
-
111
- 1. 手动输入或扫码得到 base URL、path、token。
112
- 2. 请求 bootstrap,收集服务端返回的地址候选。
113
- 3. 建立 SSE 并处理 `hello`。
114
- 4. 事件增量更新 AppStore;聊天页按 seq/消息身份去重。
115
- 5. SSE 超时、心跳看门狗或网络错误触发重建。
116
- 6. 连续失败后按候选地址轮换,指数退避。
117
- 7. 回到前台或恢复连接后重新 bootstrap,并按当前会话补拉 history/pending 状态。
118
-
119
- 这个模型必须保留;iOS 不能用“Flutter 进程一直后台运行”代替后台通知。iOS 回前台时要把服务端状态作为权威重新同步。
120
-
121
- ## 7. 通知和审批
122
-
123
- ### 7.1 App 内
124
-
125
- - `mobile/notify`、`notifications/changed` 和 `turn/end` 更新通知中心。
126
- - `attention.dart` 用 `kind|sessionId|approvalId/rpcId` 形成稳定身份,负责去重、展示决策和精确撤销。
127
- - 进入对应会话后,App 内卡片和横幅承担即时提醒。
128
-
129
- ### 7.2 系统通知
130
-
131
- - `local_notifications.dart` 使用 `flutter_local_notifications`;当前初始化逻辑只对 Android 生效。
132
- - iOS 需要在同一抽象后补 `UNUserNotificationCenter` 权限、分类动作、badge、点击 payload 和冷启动会话跳转。
133
- - 服务端既有 `pushUrls` 作为 App 被挂起或离线时的推送桥;不能把 Android 前台服务行为直接承诺为 iOS 行为。
134
-
135
- ## 8. 本地存储
136
-
137
- ### 8.1 SharedPreferences
138
-
139
- 普通偏好和连接配置目前由 `SharedPreferences` 保存:
140
-
141
- - 地址/path/token/候选地址/插件版本;
142
- - 当前会话、会话列表缓存、工作区;
143
- - 主题、语言、皮肤、图标、Git tab、动作顺序;
144
- - 推理显示、余额预警、宠物设置、后台保活开关。
145
-
146
- 其中 token 是敏感凭据,当前实现仍在普通偏好存储;上架前必须用 Android Keystore + iOS Keychain 的 Flutter 封装迁移,且保留普通偏好只存非敏感配置。
147
-
148
- ### 8.2 内存状态和文件
149
-
150
- - 草稿、队列镜像、pending 问询/审批是进程内状态。
151
- - 会话列表和偏好可恢复,不能替代服务端事实。
152
- - 图片附件有进程内 LRU。
153
- - 日志由 `AppLog` 统一入口记录,需在发布前确认 token、二维码和会话敏感内容不会写入日志或截图。
154
-
155
- ## 9. 原生平台桥接
156
-
157
- ### 9.1 当前 Android 通道
158
-
159
- | 通道 | 原生功能 | 当前实现 |
160
- |---|---|---|
161
- | `dsh/floating` | 悬浮宠物、overlay 权限、余额/配置同步、面板动作 | `MainActivity.kt` + `FloatingBubbleService.kt` |
162
- | `dsh/files` | 文件选择、保存、打开、分享、文本解码 | `MainActivity.kt` |
163
- | `dsh/app_icon` | activity-alias 图标切换/同步 | `MainActivity.kt` + Manifest |
164
- | `dsh/keepalive` | 前台服务保活、状态、心跳、电池设置 | `MainActivity.kt` + `KeepAliveService.kt` |
165
-
166
- `main.dart` 和 `settings_screen.dart` 当前存在启动/初始化时直接触发这些通道的路径;iOS 补齐前必须集中成平台能力接口,非支持能力返回明确状态,不允许页面收到 `MissingPluginException`。
167
-
168
- ### 9.2 iOS 需要补齐
169
-
170
- - Flutter Runner 工程、AppDelegate/Scene 配置、Info.plist 和 AppIcon。
171
- - Bundle Identifier、最低 iOS 版本、网络和相机/照片/通知用途说明。
172
- - Keychain 安全存储实现。
173
- - `UNUserNotificationCenter` 通知权限、分类、点击和 badge。
174
- - `UIDocumentPickerViewController` 或等价文件选择;文件保存到 Files/分享面板;文件打开和文本解码。
175
- - scene phase 生命周期:回前台 bootstrap、SSE 重建和 pending 事件补拉。
176
- - 设备网络权限和 ATS:只加实际需要的最小配置,不默认放开公网不安全 HTTP。
177
- - 固定 App Icon;若以后支持 alternate icons,独立实现并更新矩阵。
178
-
179
- Android 专属的悬浮宠物、前台服务和 activity-alias 不直接移植到 iOS。它们对应的产品结果分别是 App 内状态入口、APNs/回前台补拉、固定图标。
180
-
181
- ## 10. Android 构建和发布结构
182
-
183
- - `dsh-mobile-app/android/settings.gradle.kts`:Flutter Gradle loader、AGP、Kotlin。
184
- - `android/app/build.gradle.kts`:namespace `com.dsh.remote`、Java/Kotlin 17、desugaring、release keystore 读取、无 key 时 release 构建失败(`DSH_ALLOW_DEBUG_SIGNING=1` 显式放行 debug 签名)。
185
- - `android/app/src/main/AndroidManifest.xml`:相机、网络、通知、悬浮窗、前台服务、8 个图标 alias 和两个 service。
186
- - `assets/`:Logo、图标、皮肤、桌面宠物和动画资源。
187
- - `pubspec.yaml`:Flutter 依赖和资产声明。
188
-
189
- 当前 `key.properties`、release keystore、Flutter local.properties 都不存在。正式商店构建必须由用户保管 keystore 或由 CI Secrets 注入,不能写入仓库。
190
-
191
- ## 11. iOS 构建和发布结构(目标)
192
-
193
- 补齐后目标结构:
194
-
195
- ```text
196
- dsh-mobile-app/ios/
197
- Runner/
198
- AppDelegate.swift
199
- Info.plist
200
- Assets.xcassets/AppIcon.appiconset/
201
- LaunchScreen.storyboard
202
- Runner.xcodeproj/
203
- Runner.xcworkspace/
204
- Podfile
205
- ```
206
-
207
- 构建分工:
208
-
209
- - Windows:Dart 开发、Node/Flutter 测试(安装工具链后)、Android debug/release 无签名构建。
210
- - macOS GitHub runner:Flutter pub get、分析、测试、`flutter build ios --no-codesign`;有证书时再执行签名/IPA。
211
- - 用户账号边界:Apple Developer/App Store Connect、Google Play 服务账号、签名证书、provisioning profile、keystore 都不由仓库生成或提交。
212
-
213
- ## 12. 当前不改变的架构决策
214
-
215
- 1. 保留 Node.js 插件作为 DSH 电脑端真实协议实现。
216
- 2. 保留 Flutter `ChangeNotifier` 状态模型和现有页面结构。
217
- 3. 保留 HTTP JSON + SSE,不把协议改成 WebSocket。
218
- 4. 保留服务端会话唯一真源,不在 App 侧做第二份会话数据库。
219
- 5. 保留 Android 全部现有入口;平台差异写进矩阵并做等价替代。
220
- 6. 不用假 API、写死响应、静态截图或 Demo 数据绕过真实链路。
221
-
222
- ## 13. 本轮实现状态更新(2026-11-01)
223
-
224
- - iOS Runner 已由 Flutter 3.47.9 官方生成并纳入工程;Bundle ID 与 Android applicationId 统一为 `com.mrdayone.dshmobile`。
225
- - iOS 原生桥接位于 `ios/Runner/AppDelegate.swift`:文件选择/导出/预览/分享/文本解码走 UIKit;Android overlay、前台服务和动态图标在 iOS 明确返回不支持,Flutter 页面提供状态说明和 App 内替代路径。
226
- - `flutter_secure_storage 11.2.0` 已成为 token 的安全存储边界;连接地址和 UI 偏好仍由 SharedPreferences 保存。
227
- - `flutter_local_notifications` 已为 iOS 配置 Darwin 初始化、权限请求和通知展示;iOS 后台依赖系统通知与回前台补拉,不依赖常驻 Flutter 进程。
228
- - iOS `Info.plist` 已声明相机、照片、本地网络和通知用途;ATS 仅开启 `NSAllowsLocalNetworking`。
229
- - 当前可在 Windows 验证 Dart 分析、测试和配置契约;Swift/Xcode 编译和设备行为必须在 macOS runner 完成。