@dsh-mobile/mobile-remote 3.3.0 → 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.
- package/FAQ.md +2 -2
- package/LICENSE +0 -0
- package/README.md +13 -8
- package/docs/PRIVACY-POLICY.en.md +26 -18
- package/docs/PRIVACY-POLICY.md +26 -18
- package/docs/SUPPORT.md +1 -1
- package/docs/TERMS-OF-SERVICE.en.md +5 -3
- package/docs/TERMS-OF-SERVICE.md +5 -3
- package/docs/USER-GUIDE.zh-CN.md +7 -6
- package/lib/account-usage-query.js +60 -60
- package/lib/account-usage.js +10 -10
- package/lib/api-helpers.js +114 -110
- package/lib/assistant-prefs.js +119 -76
- package/lib/auto-config.js +65 -65
- package/lib/backup.js +159 -123
- package/lib/break-reminder.js +45 -45
- package/lib/client.js +336 -138
- package/lib/config.js +234 -218
- package/lib/git-read-bundled-provider.js +27 -7
- package/lib/git-read-service.js +5 -5
- package/lib/host-compat.js +84 -84
- package/lib/http-util.js +17 -17
- package/lib/index.js +1670 -1511
- package/lib/memory/context.js +45 -40
- package/lib/memory/decay.js +93 -93
- package/lib/memory/extract.js +77 -77
- package/lib/memory/routes.js +33 -33
- package/lib/memory/store.js +239 -192
- package/lib/notify-copy.js +93 -93
- package/lib/permission-guide.js +86 -86
- package/lib/persona-cards.js +73 -61
- package/lib/phone-action-args.js +175 -0
- package/lib/phone-actions.js +227 -0
- package/lib/phone-announce.js +58 -0
- package/lib/proactive-material.js +42 -42
- package/lib/proactive.js +122 -119
- package/lib/protected-paths.js +205 -45
- package/lib/protocol.js +62 -23
- package/lib/push.js +29 -29
- package/lib/rate-limit.js +16 -16
- package/lib/relay/connector.js +334 -81
- package/lib/relay/crypto.js +15 -15
- package/lib/relay/devices.js +64 -32
- package/lib/relay/fingerprint.js +34 -34
- package/lib/relay/identity.js +26 -26
- package/lib/relay/mux.js +60 -46
- package/lib/relay/noise.js +40 -40
- package/lib/relay/on-demand.js +36 -31
- package/lib/relay/p2p.js +239 -0
- package/lib/relay/pairing.js +54 -15
- package/lib/relay/phone.js +63 -39
- package/lib/relay/serve.js +21 -21
- package/lib/relay/signal.js +69 -0
- package/lib/relay/ws-server.js +245 -0
- package/lib/reminders.js +15 -15
- package/lib/rpc-adapter.js +43 -43
- package/lib/session-list.js +31 -31
- package/lib/session-rotation.js +95 -95
- package/lib/session-title-cache.js +35 -35
- package/lib/session-title-refresh.js +51 -51
- package/lib/timeline.js +140 -140
- package/lib/turn-outline.js +104 -104
- package/package.json +11 -18
package/lib/host-compat.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
13
|
export const jobsNeedsSessionId = (jobs) => typeof jobs?.events?.subscribe === "function";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
21
|
export const wireStreamTakesControl = (gateway) =>
|
|
22
22
|
typeof gateway?.openWireStream === "function" && gateway.openWireStream.length >= 5;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
39
|
export const hostPeerSource = (gateway, connection) => {
|
|
40
40
|
if (typeof connection?.createPeer === "function") return "createPeer";
|
|
41
41
|
if (typeof gateway?.operatorPeer === "function") return "operatorPeer";
|
|
42
42
|
return "none";
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
49
|
export const createInProcessPeer = (connection) => {
|
|
50
50
|
if (typeof connection?.createPeer !== "function") return undefined;
|
|
51
51
|
return connection.createPeer({ principal: { kind: "owner" }, interactions: "answer" });
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
58
|
export const readSettingsSection = (settings, ns) => {
|
|
59
59
|
const result = readSettingsSectionStrict(settings, ns);
|
|
60
60
|
return result.ok ? result.value : undefined;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
76
|
export const readSettingsSectionStrict = (settings, ns) => {
|
|
77
77
|
if (!settings) return { ok: false, reason: "settings-service-missing" };
|
|
78
78
|
if (typeof ns !== "string" || ns === "") return { ok: false, reason: "namespace-invalid" };
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
if (typeof settings.get === "function") {
|
|
81
81
|
try {
|
|
82
82
|
return { ok: true, value: settings.get(ns) };
|
|
@@ -84,7 +84,7 @@ export const readSettingsSectionStrict = (settings, ns) => {
|
|
|
84
84
|
return { ok: false, reason: "settings-get-threw" };
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
if (typeof settings.describe === "function") {
|
|
89
89
|
let rows;
|
|
90
90
|
try {
|
|
@@ -92,22 +92,22 @@ export const readSettingsSectionStrict = (settings, ns) => {
|
|
|
92
92
|
} catch {
|
|
93
93
|
return { ok: false, reason: "settings-describe-threw" };
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
if (!Array.isArray(rows)) return { ok: false, reason: "settings-describe-shape-invalid" };
|
|
97
97
|
const row = rows.find((candidate) => candidate?.ns === ns);
|
|
98
|
-
if (row === undefined) return { ok: true, value: undefined };
|
|
98
|
+
if (row === undefined) return { ok: true, value: undefined };
|
|
99
99
|
if (!Object.prototype.hasOwnProperty.call(row, "value")) return { ok: false, reason: "settings-descriptor-without-value" };
|
|
100
100
|
return { ok: true, value: row.value };
|
|
101
101
|
}
|
|
102
102
|
return { ok: false, reason: "settings-has-no-read-method" };
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
111
|
export const jobsCallerFor = (jobs, agent, sessionId) => {
|
|
112
112
|
if (!jobsNeedsSessionId(jobs)) return agent;
|
|
113
113
|
if (typeof sessionId === "string" && sessionId !== "") return sessionId;
|
|
@@ -115,16 +115,16 @@ export const jobsCallerFor = (jobs, agent, sessionId) => {
|
|
|
115
115
|
return typeof id === "string" && id !== "" ? id.replace(/^session:/, "") : undefined;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
128
|
export const liveRootAgents = (agents) => {
|
|
129
129
|
if (typeof agents?.roots === "function") {
|
|
130
130
|
const roots = agents.roots();
|
|
@@ -137,22 +137,22 @@ export const liveRootAgents = (agents) => {
|
|
|
137
137
|
return [];
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
export const firstRootAgent = (agents) => liveRootAgents(agents)[0];
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
151
|
export const capabilityState = (service, predicate) => {
|
|
152
152
|
if (!service) return "missing";
|
|
153
153
|
try {
|
|
154
154
|
return predicate(service) ? "ok" : "drift";
|
|
155
155
|
} catch {
|
|
156
|
-
return "drift";
|
|
156
|
+
return "drift";
|
|
157
157
|
}
|
|
158
158
|
};
|
package/lib/http-util.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON 响应 / 请求体读取 / 方法检查 / 响应防崩守卫。从 lib/index.js 原样拆出(行为不变;`error` 在模块内更名为 `sendError`)。
|
|
3
|
-
*/
|
|
4
1
|
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
6
|
export const guardRes = (res) => {
|
|
7
7
|
if (!res.__dshErrGuarded) {
|
|
8
8
|
res.__dshErrGuarded = true;
|
|
@@ -11,17 +11,17 @@ export const guardRes = (res) => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const sendJson = (res, status, body, headers = {}) => {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
|
|
16
16
|
guardRes(res);
|
|
17
17
|
const text = JSON.stringify(body);
|
|
18
18
|
res.writeHead(status, {
|
|
19
19
|
"content-type": "application/json; charset=utf-8",
|
|
20
20
|
"cache-control": "no-store",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
25
|
"connection": "close",
|
|
26
26
|
"content-length": Buffer.byteLength(text),
|
|
27
27
|
...headers,
|
|
@@ -38,11 +38,11 @@ export const readBody = (req, limit = 64 * 1024) =>
|
|
|
38
38
|
size += chunk.length;
|
|
39
39
|
if (size > limit) {
|
|
40
40
|
reject(Object.assign(new Error("body too large"), { status: 413 }));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
46
|
req.off("data", onData);
|
|
47
47
|
req.pause();
|
|
48
48
|
return;
|
|
@@ -52,11 +52,11 @@ export const readBody = (req, limit = 64 * 1024) =>
|
|
|
52
52
|
req.on("data", onData);
|
|
53
53
|
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
54
54
|
req.on("error", reject);
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
req.on("close", () => reject(Object.assign(new Error("request closed"), { status: 400 })));
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
export const requireGet = (method, res) => {
|
|
61
61
|
if (method !== "GET" && method !== "HEAD") {
|
|
62
62
|
sendError(res, 405, "method-not-allowed");
|