@dsh-mobile/mobile-remote 3.2.7 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FAQ.md +19 -12
- package/LICENSE +0 -0
- package/README.md +40 -40
- package/cordis.patch.yml +8 -4
- package/docs/PRIVACY-POLICY.en.md +89 -47
- package/docs/PRIVACY-POLICY.md +89 -47
- package/docs/SUPPORT.md +5 -5
- package/docs/TERMS-OF-SERVICE.en.md +5 -3
- package/docs/TERMS-OF-SERVICE.md +5 -3
- package/docs/USER-GUIDE.zh-CN.md +562 -0
- package/lib/account-usage.js +0 -0
- package/lib/api-helpers.js +6 -2
- package/lib/assistant-prefs.js +167 -0
- package/lib/auto-config.js +55 -3
- package/lib/backup.js +441 -0
- package/lib/break-reminder.js +133 -0
- package/lib/client.js +321 -77
- package/lib/config.js +96 -5
- package/lib/git-read-bundled-provider.js +32 -3
- package/lib/git-read-service.js +4 -0
- package/lib/host-compat.js +25 -0
- package/lib/http-util.js +6 -2
- package/lib/index.js +1121 -83
- package/lib/memory/context.js +81 -0
- package/lib/memory/decay.js +144 -0
- package/lib/memory/extract.js +146 -0
- package/lib/memory/routes.js +198 -0
- package/lib/memory/store.js +714 -0
- package/lib/notify-copy.js +245 -0
- package/lib/permission-guide.js +184 -0
- package/lib/persona-cards.js +366 -0
- package/lib/proactive-material.js +162 -0
- package/lib/proactive.js +372 -0
- package/lib/protected-paths.js +290 -0
- package/lib/protocol.js +39 -0
- package/lib/rate-limit.js +1 -1
- package/lib/relay/connector.js +208 -14
- package/lib/relay/devices.js +54 -8
- package/lib/relay/fingerprint.js +55 -0
- package/lib/relay/identity.js +69 -0
- package/lib/relay/on-demand.js +89 -0
- package/lib/relay/pairing.js +45 -6
- package/lib/relay/phone.js +89 -12
- package/lib/relay/ws-server.js +245 -0
- package/lib/reminders.js +140 -0
- package/lib/rpc-adapter.js +21 -2
- package/lib/session-rotation.js +198 -0
- package/lib/session-title-cache.js +0 -0
- package/lib/session-title-refresh.js +0 -0
- package/lib/timeline.js +1 -1
- package/package.json +30 -14
- package/CHANGELOG.md +0 -1383
- package/CONTRIBUTING.md +0 -61
- package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +0 -432
- package/docs/01-PRD.md +0 -148
- package/docs/02-architecture.md +0 -249
- package/docs/03-api.md +0 -882
- package/docs/04-security.md +0 -110
- package/docs/05-test-cases.md +0 -376
- package/docs/06-install-run.md +0 -335
- package/docs/07-user-manual.md +0 -92
- package/docs/08-/346/211/251/345/261/225/345/274/200/345/217/221/346/214/207/345/215/227.md +0 -86
- package/docs/09-compatibility.md +0 -201
- package/docs/11-remote-relay-guide.md +0 -86
- package/docs/APP-ENCRYPTION-DESCRIPTION.md +0 -50
- package/docs/APP-ENCRYPTION-DESCRIPTION.pdf +0 -0
- package/docs/APP-REVIEW-NOTES.md +0 -105
- package/docs/BRAND-ASSETS.md +0 -142
- package/docs/COMPANION-PLAN.md +0 -199
- package/docs/STORE-LAUNCH.md +0 -341
- package/docs/STORE-LISTING.md +0 -190
|
@@ -2,6 +2,7 @@ import { constants as fsConstants } from "node:fs";
|
|
|
2
2
|
import { realpath, open, lstat } from "node:fs/promises";
|
|
3
3
|
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
+
import { isProtectedFile, isProtectedPath, isStillAt } from "./protected-paths.js";
|
|
5
6
|
|
|
6
7
|
const UNTRACKED_PREVIEW_MAX = 512 * 1024;
|
|
7
8
|
const SIGNATURE_SAMPLE_BYTES = 4096;
|
|
@@ -10,14 +11,37 @@ function sameRegularFile(expected, opened) {
|
|
|
10
11
|
return expected.isFile() && opened.isFile() && expected.dev === opened.dev && expected.ino === opened.ino;
|
|
11
12
|
}
|
|
12
13
|
async function readPrefix(path, maximum, expected) {
|
|
14
|
+
// T-62 fix: never read the DSH home's keys or the plugin's state, by any name or link.
|
|
15
|
+
if (isProtectedPath(path)) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
13
16
|
const handle = await open(path, readOnlyNoFollow);
|
|
14
17
|
try {
|
|
15
|
-
|
|
18
|
+
const opened = await handle.stat();
|
|
19
|
+
if (isProtectedFile(opened)) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
20
|
+
if (!sameRegularFile(expected, opened)) throw new Error("file changed while opening preview");
|
|
21
|
+
if (!isStillAt(path, opened)) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
16
22
|
const buffer = Buffer.alloc(maximum + 1);
|
|
17
23
|
const { bytesRead } = await handle.read(buffer, 0, maximum + 1, 0);
|
|
18
24
|
return { bytes: buffer.subarray(0, bytesRead), truncated: bytesRead > maximum };
|
|
19
25
|
} finally { await handle.close(); }
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A-06: `git diff` (unstaged and staged previews) reads the worktree file itself, so before it runs,
|
|
29
|
+
* the worktree file must not be (a hard link to) a protected file. A symlink is fine: git shows its
|
|
30
|
+
* target text, not the content. A file that is missing or special is left to git.
|
|
31
|
+
*/
|
|
32
|
+
async function assertWorktreeFileNotProtected(path) {
|
|
33
|
+
if (isProtectedPath(path)) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
34
|
+
let handle;
|
|
35
|
+
try {
|
|
36
|
+
handle = await open(path, readOnlyNoFollow | (fsConstants.O_NONBLOCK ?? 0));
|
|
37
|
+
} catch {
|
|
38
|
+
return; // missing (a deletion), a symlink (ELOOP), unreadable: git shows no protected content
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const opened = await handle.stat();
|
|
42
|
+
if (opened.isFile() && (isProtectedFile(opened) || !isStillAt(path, opened))) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
43
|
+
} finally { await handle.close(); }
|
|
44
|
+
}
|
|
21
45
|
async function sampledFileSignature(path, info) {
|
|
22
46
|
const handle = await open(path, readOnlyNoFollow);
|
|
23
47
|
try {
|
|
@@ -46,7 +70,8 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
46
70
|
const get = (name) => {
|
|
47
71
|
try { return ctx.get?.(name); } catch { return undefined; }
|
|
48
72
|
};
|
|
49
|
-
|
|
73
|
+
// 真实 cordis 的 ctx 读没声明的属性会抛错,所以兜底读取也要 try。
|
|
74
|
+
const subprocess = () => get("subprocess") ?? (() => { try { return ctx.subprocess; } catch { return undefined; } })();
|
|
50
75
|
const workspaces = () => (get("workspaceRegistry")?.list?.() ?? [])
|
|
51
76
|
.map((entry) => entry?.path).filter((path) => typeof path === "string" && path !== "");
|
|
52
77
|
const inside = (child, parent) => {
|
|
@@ -221,8 +246,12 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
221
246
|
const { bytes, truncated } = await readPrefix(target, UNTRACKED_PREVIEW_MAX, info);
|
|
222
247
|
const binary = bytes.includes(0);
|
|
223
248
|
return { diff: binary ? "" : bytes.toString("utf8"), binary, truncated, additions: null, deletions: null, ...(binary ? { notice: "binary preview omitted" } : {}) };
|
|
224
|
-
} catch
|
|
249
|
+
} catch (error) {
|
|
250
|
+
if (error?.code === "path-protected") throw error;
|
|
251
|
+
return { diff: "", binary: false, additions: 0, deletions: 0, notice: "unavailable" };
|
|
252
|
+
}
|
|
225
253
|
}
|
|
254
|
+
await assertWorktreeFileNotProtected(resolve(root, path));
|
|
226
255
|
return { diff: await run(root, args, true), binary: false, additions: null, deletions: null };
|
|
227
256
|
},
|
|
228
257
|
async commitPreview(root, oid, path) {
|
package/lib/git-read-service.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
2
2
|
import { basename, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { realpath } from "node:fs/promises";
|
|
4
4
|
import { createBundledGitReadProvider } from "./git-read-bundled-provider.js";
|
|
5
|
+
import { isProtectedPath } from "./protected-paths.js";
|
|
5
6
|
|
|
6
7
|
const MAX_GRAPH_TIPS = 5;
|
|
7
8
|
|
|
@@ -130,6 +131,9 @@ export function createGitReadService(ctx, { bundledProvider, now = () => Date.no
|
|
|
130
131
|
async preview(sessionId, repositoryId, { kind, snapshotId, path, oid } = {}) {
|
|
131
132
|
const authorized = await binding(sessionId, repositoryId);
|
|
132
133
|
if (!safeFilePath(path) || !["staged", "unstaged", "untracked", "commit"].includes(kind)) throw failure("preview-invalid", 400);
|
|
134
|
+
// T-62 fix: a repository can contain the DSH home (a dotfiles repo). Its keys and the
|
|
135
|
+
// plugin's state are never previewed, whatever the kind (worktree, staged, untracked, commit).
|
|
136
|
+
if (isProtectedPath(resolve(authorized.root, path))) throw failure("path-protected", 403, "this file holds DSH's or the plugin's keys and data");
|
|
133
137
|
const reader = createBundledGitReadProvider(ctx);
|
|
134
138
|
let raw;
|
|
135
139
|
if (kind === "commit") {
|
package/lib/host-compat.js
CHANGED
|
@@ -115,6 +115,31 @@ export const jobsCallerFor = (jobs, agent, sessionId) => {
|
|
|
115
115
|
return typeof id === "string" && id !== "" ? id.replace(/^session:/, "") : undefined;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Live top-level agents (not subagents), in registration order.
|
|
120
|
+
*
|
|
121
|
+
* A host that still has `AgentRegistry.roots()` (DSH ≤ 0.2.2-rc.1) knows its own runtime
|
|
122
|
+
* tree, so its answer is used as is: filtering `list()` there would count a subagent whose
|
|
123
|
+
* session header lacks `origin` as a root. DSH 0.2.2-rc.2 removed `roots()` (upgrade guide
|
|
124
|
+
* `v0.2.1-rc.3/subagent-runtime-ownership`); there only `get()` and `list()` remain, and the
|
|
125
|
+
* migration is to filter `list()` by `session.header.origin !== "subagent"`. User forks keep
|
|
126
|
+
* `parentSession`, so they count as top-level, as they did under `roots()`. Anything else yields [].
|
|
127
|
+
*/
|
|
128
|
+
export const liveRootAgents = (agents) => {
|
|
129
|
+
if (typeof agents?.roots === "function") {
|
|
130
|
+
const roots = agents.roots();
|
|
131
|
+
return Array.isArray(roots) ? [...roots] : [];
|
|
132
|
+
}
|
|
133
|
+
if (typeof agents?.list === "function") {
|
|
134
|
+
const all = agents.list();
|
|
135
|
+
return Array.isArray(all) ? all.filter((agent) => agent?.session?.header?.origin !== "subagent") : [];
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/** The first live top-level agent, or undefined. */
|
|
141
|
+
export const firstRootAgent = (agents) => liveRootAgents(agents)[0];
|
|
142
|
+
|
|
118
143
|
/**
|
|
119
144
|
* 单项宿主能力的状态(ADR 0017 要求的三态报告)。仅报"服务在不在"不够:
|
|
120
145
|
* 本次四处不兼容**全部**是"服务在、调用不报错、语义已变",两分法看不见它们。
|
package/lib/http-util.js
CHANGED
|
@@ -34,18 +34,22 @@ export const readBody = (req, limit = 64 * 1024) =>
|
|
|
34
34
|
new Promise((resolve, reject) => {
|
|
35
35
|
let size = 0;
|
|
36
36
|
const chunks = [];
|
|
37
|
-
|
|
37
|
+
const onData = (chunk) => {
|
|
38
38
|
size += chunk.length;
|
|
39
39
|
if (size > limit) {
|
|
40
40
|
reject(Object.assign(new Error("body too large"), { status: 413 }));
|
|
41
41
|
// v3.0.0 修复:超限先停读并让 handler 回 413——此前先 req.destroy()
|
|
42
42
|
// 会把连接直接掐断,客户端看到的是"连接意外关闭/连接重置"而非 413
|
|
43
43
|
// (592KB 图片上传即此症状:上游看到连接被切断 → 桥回 502 bridge-unavailable)
|
|
44
|
+
// T-55: stop listening too, so the server can discard the rest after an early 413
|
|
45
|
+
// without this handler pausing the request again on every chunk.
|
|
46
|
+
req.off("data", onData);
|
|
44
47
|
req.pause();
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
chunks.push(chunk);
|
|
48
|
-
}
|
|
51
|
+
};
|
|
52
|
+
req.on("data", onData);
|
|
49
53
|
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
50
54
|
req.on("error", reject);
|
|
51
55
|
// review:客户端断开且不触发 error 时也要 settle,避免 handler 悬挂
|