@dsh-mobile/mobile-remote 3.3.1 → 3.4.1-beta.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/README.md +9 -5
- package/docs/PRIVACY-POLICY.en.md +10 -3
- package/docs/PRIVACY-POLICY.md +10 -3
- package/docs/USER-GUIDE.zh-CN.md +1 -0
- package/lib/account-usage-query.js +60 -60
- package/lib/account-usage.js +10 -10
- package/lib/api-helpers.js +109 -109
- package/lib/assistant-prefs.js +82 -59
- package/lib/auto-config.js +65 -65
- package/lib/backup.js +117 -117
- package/lib/break-reminder.js +45 -45
- package/lib/client.js +93 -93
- package/lib/config.js +234 -218
- package/lib/git-read-bundled-provider.js +12 -12
- 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 +1534 -1534
- package/lib/memory/context.js +44 -44
- 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 +196 -196
- package/lib/notify-copy.js +93 -93
- package/lib/permission-guide.js +86 -86
- package/lib/persona-cards.js +73 -65
- 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 +121 -121
- package/lib/protected-paths.js +79 -79
- package/lib/protocol.js +61 -26
- package/lib/push.js +29 -29
- package/lib/rate-limit.js +16 -16
- package/lib/relay/connector.js +246 -102
- package/lib/relay/crypto.js +15 -15
- package/lib/relay/devices.js +36 -36
- 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 +33 -33
- package/lib/relay/p2p.js +239 -0
- package/lib/relay/pairing.js +24 -24
- package/lib/relay/phone.js +62 -40
- package/lib/relay/serve.js +21 -21
- package/lib/relay/signal.js +69 -0
- package/lib/relay/ws-server.js +32 -32
- 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 +3 -13
package/lib/auto-config.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
15
|
import { randomBytes } from "node:crypto";
|
|
16
16
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
18
|
import { join } from "node:path";
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
export const AUTO = "@auto";
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
const SAVED_TOKEN_RE = /^[A-Za-z0-9_-]{24,128}$/;
|
|
25
25
|
|
|
26
26
|
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
export function mobileRemoteStateDir(env = process.env, home = homedir()) {
|
|
30
30
|
const base = typeof env.DSH_HOME === "string" && env.DSH_HOME.trim() !== "" ? env.DSH_HOME : join(home, ".dsh");
|
|
31
31
|
return join(base, "mobile-remote");
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
41
|
export function resolveAuthToken(configured, { dir = mobileRemoteStateDir(), generate = () => randomBytes(24).toString("base64url") } = {}) {
|
|
42
42
|
if (configured !== AUTO) return { token: configured ?? "", auto: false };
|
|
43
43
|
const file = join(dir, "auth-token");
|
|
@@ -47,7 +47,7 @@ export function resolveAuthToken(configured, { dir = mobileRemoteStateDir(), gen
|
|
|
47
47
|
if (SAVED_TOKEN_RE.test(saved)) return { token: saved, auto: true, generated: false, file };
|
|
48
48
|
}
|
|
49
49
|
} catch {
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
}
|
|
52
52
|
const token = generate();
|
|
53
53
|
try {
|
|
@@ -61,39 +61,39 @@ export function resolveAuthToken(configured, { dir = mobileRemoteStateDir(), gen
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
72
|
export function isLoopbackOnly({ webHost, lanBridgeEnabled = false, trustedHosts = [], relayEnabled = false } = {}) {
|
|
73
73
|
if (typeof webHost !== "string" || !LOOPBACK_HOSTS.has(webHost.trim().toLowerCase())) return false;
|
|
74
74
|
if (lanBridgeEnabled || relayEnabled) return false;
|
|
75
75
|
return !(Array.isArray(trustedHosts) && trustedHosts.length > 0);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
87
|
export function effectiveAuthSetting(configured, reach = {}) {
|
|
88
88
|
if (typeof configured === "string" && configured !== "") return configured;
|
|
89
89
|
return isLoopbackOnly(reach) ? "" : AUTO;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
97
|
export function rotateAuthToken({ dir = mobileRemoteStateDir(), generate = () => randomBytes(24).toString("base64url") } = {}) {
|
|
98
98
|
const file = join(dir, "auth-token");
|
|
99
99
|
const token = generate();
|
|
@@ -104,35 +104,35 @@ export function rotateAuthToken({ dir = mobileRemoteStateDir(), generate = () =>
|
|
|
104
104
|
return { token, file };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
112
|
export function resolveLanBridgeEnabled(setting, { webHost, webPort, bridgePort } = {}) {
|
|
113
113
|
if (setting !== "auto") return Boolean(setting);
|
|
114
114
|
if (typeof webHost === "string" && webHost !== "") return LOOPBACK_HOSTS.has(webHost.toLowerCase());
|
|
115
115
|
return !(webPort !== undefined && bridgePort === webPort);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
123
|
export function resolveLanBridgePort(setting, port, webPort) {
|
|
124
124
|
if (setting === "auto" && webPort !== undefined && port === webPort) return port < 65535 ? port + 1 : port - 1;
|
|
125
125
|
return port;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
136
|
export function formatConnectionBanner({ addresses, token, tokenIsAuto, tokenNew = true, tokenFile, persistError, authEnabled = true }) {
|
|
137
137
|
const [first, ...rest] = addresses;
|
|
138
138
|
const lines = ["mobile-remote ▶ 手机 App 连接信息 / Phone app connection"];
|
package/lib/backup.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
23
|
import { createCipheriv, createDecipheriv, randomBytes, scrypt } from "node:crypto";
|
|
24
24
|
import { SCOPES } from "./memory/store.js";
|
|
25
25
|
import { parseHm } from "./notify-copy.js";
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
export const BACKUP_FORMAT = "dsh-mobile-backup";
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
export const BACKUP_VERSION = 1;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
const MAX_TEXT = 4000;
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
export const MAX_RESTORE_ITEMS = 5000;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
44
|
export const MAX_RESTORE_BODY_BYTES = 32 * 1024 * 1024;
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
50
|
export const BACKUP_EXCLUDES = [
|
|
51
51
|
"auth-token(连接口令)",
|
|
52
52
|
"relay/(中继身份私钥与设备名单)",
|
|
@@ -55,22 +55,22 @@ export const BACKUP_EXCLUDES = [
|
|
|
55
55
|
"session-titles / session-activity / session-message-time(与本机会话 id 绑定)",
|
|
56
56
|
];
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
66
|
export function buildBackup({ store, prefs, now = () => Date.now() }) {
|
|
67
67
|
const memories = store ? store.exportAll() : [];
|
|
68
68
|
return {
|
|
69
69
|
format: BACKUP_FORMAT,
|
|
70
70
|
version: BACKUP_VERSION,
|
|
71
71
|
createdAt: new Date(now()).toISOString(),
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
|
|
73
|
+
|
|
74
74
|
excludes: BACKUP_EXCLUDES,
|
|
75
75
|
assistant: prefs?.get?.() ?? null,
|
|
76
76
|
memories: memories.map((m) => ({
|
|
@@ -79,38 +79,38 @@ export function buildBackup({ store, prefs, now = () => Date.now() }) {
|
|
|
79
79
|
source: m.source === "manual" ? "manual" : "conversation",
|
|
80
80
|
origin: m.origin ?? null,
|
|
81
81
|
pinned: Boolean(m.pinned),
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
|
|
83
|
+
|
|
84
84
|
stability: typeof m.stability === "number" ? m.stability : undefined,
|
|
85
85
|
difficulty: typeof m.difficulty === "number" ? m.difficulty : undefined,
|
|
86
86
|
lastRecalledAt:
|
|
87
87
|
typeof m.lastRecalledAt === "number" ? m.lastRecalledAt : undefined,
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
|
|
89
|
+
|
|
90
90
|
})),
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
105
|
export const MIN_BACKUP_PASSPHRASE = 15;
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
const COMMON_PASSPHRASES = new Set([
|
|
109
109
|
"passwordpassword", "password1234567", "123456789012345", "1234567890123456", "qwertyuiopasdfg",
|
|
110
110
|
"qwertyuiopasdfgh", "1q2w3e4r5t6y7u8i", "iloveyouiloveyou", "abcdefghijklmno", "abcdefghijklmnop",
|
|
111
111
|
]);
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
export function passphraseProblem(passphrase) {
|
|
115
115
|
if (typeof passphrase !== "string") return `口令至少 ${MIN_BACKUP_PASSPHRASE} 个字符 / the passphrase needs at least ${MIN_BACKUP_PASSPHRASE} characters`;
|
|
116
116
|
const chars = [...passphrase.normalize("NFC")];
|
|
@@ -122,16 +122,16 @@ export function passphraseProblem(passphrase) {
|
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
130
|
const KDF = { name: "scrypt", N: 1 << 17, r: 8, p: 1, keyLen: 32 };
|
|
131
131
|
const ACCEPTED_KDF = [KDF, { name: "scrypt", N: 1 << 15, r: 8, p: 1, keyLen: 32 }];
|
|
132
132
|
export const BACKUP_KDF = Object.freeze({ ...KDF });
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
let kdfQueue = Promise.resolve();
|
|
136
136
|
const deriveKey = (passphrase, salt, kdf = KDF) => {
|
|
137
137
|
const run = () =>
|
|
@@ -145,17 +145,17 @@ const deriveKey = (passphrase, salt, kdf = KDF) => {
|
|
|
145
145
|
return next;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
export function isEncryptedBackup(payload) {
|
|
150
150
|
return Boolean(payload && typeof payload === "object" && payload.encrypted && typeof payload.encrypted === "object");
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
159
|
export async function encryptBackup(backup, passphrase) {
|
|
160
160
|
const problem = passphraseProblem(passphrase);
|
|
161
161
|
if (problem) throw Object.assign(new Error(problem), { code: "weak-passphrase" });
|
|
@@ -163,7 +163,7 @@ export async function encryptBackup(backup, passphrase) {
|
|
|
163
163
|
const iv = randomBytes(12);
|
|
164
164
|
const key = await deriveKey(passphrase, salt);
|
|
165
165
|
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
cipher.setAAD(Buffer.from(`${BACKUP_FORMAT}/${BACKUP_VERSION}`));
|
|
168
168
|
const data = Buffer.concat([cipher.update(JSON.stringify(backup), "utf8"), cipher.final()]);
|
|
169
169
|
return {
|
|
@@ -179,10 +179,10 @@ export async function encryptBackup(backup, passphrase) {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
186
|
export async function decryptBackup(envelope, passphrase) {
|
|
187
187
|
const e = envelope?.encrypted;
|
|
188
188
|
if (!e || e.cipher !== "aes-256-gcm" || e.kdf?.name !== "scrypt") {
|
|
@@ -191,8 +191,8 @@ export async function decryptBackup(envelope, passphrase) {
|
|
|
191
191
|
if (typeof passphrase !== "string" || passphrase === "") {
|
|
192
192
|
throw Object.assign(new Error("这份备份设了口令 / this backup needs its passphrase"), { code: "passphrase-required" });
|
|
193
193
|
}
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
|
|
195
|
+
|
|
196
196
|
const N = Number(e.kdf.N);
|
|
197
197
|
const r = Number(e.kdf.r);
|
|
198
198
|
const p = Number(e.kdf.p);
|
|
@@ -205,7 +205,7 @@ export async function decryptBackup(envelope, passphrase) {
|
|
|
205
205
|
}
|
|
206
206
|
try {
|
|
207
207
|
const key = await deriveKey(passphrase, Buffer.from(String(e.kdf.salt), "base64"), { N, r, p, keyLen: 32 });
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
const decipher = createDecipheriv("aes-256-gcm", key, Buffer.from(String(e.iv), "base64"), { authTagLength: 16 });
|
|
210
210
|
decipher.setAAD(Buffer.from(`${envelope.format}/${envelope.version}`));
|
|
211
211
|
decipher.setAuthTag(tag);
|
|
@@ -216,11 +216,11 @@ export async function decryptBackup(envelope, passphrase) {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
224
|
function validateMemory(raw, index) {
|
|
225
225
|
if (!raw || typeof raw !== "object") {
|
|
226
226
|
return { ok: false, reason: "不是对象", index };
|
|
@@ -238,7 +238,7 @@ function validateMemory(raw, index) {
|
|
|
238
238
|
return { ok: false, reason: `text 超过 ${MAX_TEXT} 字符`, index };
|
|
239
239
|
}
|
|
240
240
|
if (raw.deleted === true) {
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
return { ok: false, reason: "备份里这条已删除", index };
|
|
243
243
|
}
|
|
244
244
|
return {
|
|
@@ -254,15 +254,15 @@ function validateMemory(raw, index) {
|
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
266
|
export function planRestore(payload, { store, prefs }) {
|
|
267
267
|
const empty = {
|
|
268
268
|
ok: false,
|
|
@@ -285,8 +285,8 @@ export function planRestore(payload, { store, prefs }) {
|
|
|
285
285
|
return { ...empty, error: "备份版本号缺失或非法" };
|
|
286
286
|
}
|
|
287
287
|
if (payload.version > BACKUP_VERSION) {
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
|
|
289
|
+
|
|
290
290
|
return {
|
|
291
291
|
...empty,
|
|
292
292
|
error: `备份来自更新的版本(v${payload.version}),请先升级插件`,
|
|
@@ -304,8 +304,8 @@ export function planRestore(payload, { store, prefs }) {
|
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
|
|
308
|
+
|
|
309
309
|
const existing = new Set();
|
|
310
310
|
if (store) {
|
|
311
311
|
for (const mode of ["work", "life"]) {
|
|
@@ -341,8 +341,8 @@ export function planRestore(payload, { store, prefs }) {
|
|
|
341
341
|
items.push(v.item);
|
|
342
342
|
});
|
|
343
343
|
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
|
|
345
|
+
|
|
346
346
|
let assistant = null;
|
|
347
347
|
const a = payload.assistant;
|
|
348
348
|
if (a && typeof a === "object") {
|
|
@@ -352,9 +352,9 @@ export function planRestore(payload, { store, prefs }) {
|
|
|
352
352
|
next.persona = a.persona;
|
|
353
353
|
}
|
|
354
354
|
const q = a.quietHours;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
358
|
if (
|
|
359
359
|
q &&
|
|
360
360
|
typeof q === "object" &&
|
|
@@ -384,13 +384,13 @@ export function planRestore(payload, { store, prefs }) {
|
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
394
|
export function applyRestore(payload, { store, prefs }) {
|
|
395
395
|
const plan = planRestore(payload, { store, prefs });
|
|
396
396
|
if (!plan.ok) {
|
|
@@ -416,7 +416,7 @@ export function applyRestore(payload, { store, prefs }) {
|
|
|
416
416
|
});
|
|
417
417
|
added += 1;
|
|
418
418
|
} catch (err) {
|
|
419
|
-
|
|
419
|
+
|
|
420
420
|
plan.skipped.push({ index: -1, reason: err?.message ?? "写入失败" });
|
|
421
421
|
}
|
|
422
422
|
}
|
|
@@ -427,13 +427,13 @@ export function applyRestore(payload, { store, prefs }) {
|
|
|
427
427
|
prefs.set(plan.assistant);
|
|
428
428
|
assistant = true;
|
|
429
429
|
} catch {
|
|
430
|
-
|
|
430
|
+
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
return {
|
|
434
434
|
ok: true,
|
|
435
435
|
added,
|
|
436
|
-
|
|
436
|
+
|
|
437
437
|
skipped: plan.skipped.length,
|
|
438
438
|
invalid: plan.counts.invalid,
|
|
439
439
|
assistant,
|