@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.
- 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 +232 -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 +6 -13
package/lib/api-helpers.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
5
|
import { extname } from "node:path";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
12
|
const REDACT_PATH_PATTERN = /(?:\/[\p{L}\p{N}\p{M}_.~@+-]+){2,}|[A-Za-z]:\\[^\s"']*/gu;
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
const REDACT_QUOTED_PATH = /(['"`])(?:\/|[A-Za-z]:\\)[^'"`\n]*\1/g;
|
|
15
15
|
|
|
16
16
|
export function redactPathText(value) {
|
|
@@ -19,26 +19,26 @@ export function redactPathText(value) {
|
|
|
19
19
|
.replace(REDACT_PATH_PATTERN, "<redacted>");
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
28
|
export const FILE_RANGE_CAPABILITIES = {
|
|
29
29
|
version: 1,
|
|
30
30
|
supported: true,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
export function requestHeaderText(req, name) {
|
|
35
35
|
const raw = req?.headers?.[name];
|
|
36
36
|
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
37
37
|
return typeof value === "string" ? value : "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
|
|
41
|
+
|
|
42
42
|
export function clampText(text, max) {
|
|
43
43
|
text = text === undefined || text === null ? "" : String(text);
|
|
44
44
|
if (text.length <= max) return text;
|
|
@@ -47,7 +47,7 @@ export function clampText(text, max) {
|
|
|
47
47
|
return keep > 0 ? `${text.slice(0, keep)}${suffix}` : text.slice(0, max);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
const FILE_MIME = {
|
|
52
52
|
".txt": "text/plain; charset=utf-8", ".md": "text/markdown; charset=utf-8", ".json": "application/json",
|
|
53
53
|
".pdf": "application/pdf", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
|
@@ -61,11 +61,11 @@ const FILE_MIME = {
|
|
|
61
61
|
|
|
62
62
|
export const fileMimeOf = (name) => FILE_MIME[extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
69
|
export const mapBounded = async (items, width, worker) => {
|
|
70
70
|
const list = [...items];
|
|
71
71
|
if (list.length === 0) return [];
|
|
@@ -79,34 +79,34 @@ export const mapBounded = async (items, width, worker) => {
|
|
|
79
79
|
results[index] = await worker(list[index], index);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
86
|
const settled = await Promise.allSettled(Array.from({ length: Math.min(width, list.length) }, run));
|
|
87
87
|
const failed = settled.find((entry) => entry.status === "rejected");
|
|
88
88
|
if (failed) throw failed.reason;
|
|
89
89
|
return results;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
110
|
export const orderQrAddresses = (ips) => {
|
|
111
111
|
const rankOf = (ip) => {
|
|
112
112
|
const o = String(ip).split(".").map(Number);
|
|
@@ -120,18 +120,18 @@ export const orderQrAddresses = (ips) => {
|
|
|
120
120
|
const rank = rankOf(ip);
|
|
121
121
|
return rank === 0 || rank === 1;
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
const adjusted = (ip) => (rankOf(ip) === 2 && !hasLanPrivate ? 0 : rankOf(ip));
|
|
125
125
|
return [...ips].sort((a, b) => adjusted(a) - adjusted(b));
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
export function receiptExpired(at, now, ttl = 15 * 60 * 1000) {
|
|
130
130
|
return now - at > ttl;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
|
|
134
|
+
|
|
135
135
|
export function pruneReceiptMap(receipts, now = Date.now(), ttl = 15 * 60 * 1000, max = 2000) {
|
|
136
136
|
let changed = false;
|
|
137
137
|
for (const [k, v] of receipts) {
|
|
@@ -141,27 +141,27 @@ export function pruneReceiptMap(receipts, now = Date.now(), ttl = 15 * 60 * 1000
|
|
|
141
141
|
return changed;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
149
|
export function normalizeServerPath(p, platform = process.platform) {
|
|
150
150
|
if (typeof p !== "string") return p;
|
|
151
151
|
return platform === "win32" ? p.replaceAll("/", "\\") : p.replaceAll("\\", "/");
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
165
|
export function validateQuestionAnswers(questions, answers) {
|
|
166
166
|
if (!Array.isArray(questions) || questions.length === 0) {
|
|
167
167
|
return { ok: false, code: "question-answer-invalid", detail: "问询条目缺少 questions" };
|
|
@@ -171,7 +171,7 @@ export function validateQuestionAnswers(questions, answers) {
|
|
|
171
171
|
}
|
|
172
172
|
const byId = new Map();
|
|
173
173
|
for (const answer of answers) {
|
|
174
|
-
|
|
174
|
+
|
|
175
175
|
if (!answer || typeof answer !== "object" || typeof answer.id !== "string" || byId.has(answer.id)) {
|
|
176
176
|
return { ok: false, code: "question-answer-invalid", detail: "答案 id 无效或重复" };
|
|
177
177
|
}
|
|
@@ -183,8 +183,8 @@ export function validateQuestionAnswers(questions, answers) {
|
|
|
183
183
|
}
|
|
184
184
|
const answer = byId.get(question.id);
|
|
185
185
|
if (!answer) return { ok: false, code: "question-answer-invalid", detail: `缺少问题 ${question.id} 的答案` };
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
|
|
187
|
+
|
|
188
188
|
if (!Object.hasOwn(answer, "selected") || !Array.isArray(answer.selected)) {
|
|
189
189
|
return { ok: false, code: "question-answer-invalid", detail: `问题 ${question.id} 的 selected 无效` };
|
|
190
190
|
}
|
|
@@ -221,14 +221,14 @@ export function validateQuestionAnswers(questions, answers) {
|
|
|
221
221
|
return { ok: true };
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
232
|
export const classifyFetchFailure = (err) => {
|
|
233
233
|
const name = typeof err?.name === "string" ? err.name : "";
|
|
234
234
|
const code = typeof err?.code === "string" ? err.code : (typeof err?.cause?.code === "string" ? err.cause.code : "");
|
|
@@ -238,9 +238,9 @@ export const classifyFetchFailure = (err) => {
|
|
|
238
238
|
if (code === "ECONNREFUSED") return "connection-refused";
|
|
239
239
|
if (code === "ECONNRESET") return "connection-reset";
|
|
240
240
|
if (code === "UND_ERR_SOCKET") return "socket-error";
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
244
|
if (code === "OPENAI_CODEX_REAUTH_REQUIRED") return "reauth-required";
|
|
245
245
|
const status = Number.isInteger(err?.status)
|
|
246
246
|
? err.status
|
|
@@ -248,13 +248,13 @@ export const classifyFetchFailure = (err) => {
|
|
|
248
248
|
if (status !== undefined && status >= 400 && status <= 599) {
|
|
249
249
|
return status === 429 ? "rate-limited" : "http-error";
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
|
|
252
|
+
|
|
253
253
|
if (name === "TypeError") return "invalid-request";
|
|
254
254
|
return "unreachable";
|
|
255
255
|
};
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
const FAILURE_SUMMARY = {
|
|
259
259
|
timeout: "请求超时",
|
|
260
260
|
"connect-timeout": "连接超时",
|
|
@@ -263,34 +263,34 @@ const FAILURE_SUMMARY = {
|
|
|
263
263
|
"connection-reset": "连接被重置",
|
|
264
264
|
"socket-error": "连接异常中断",
|
|
265
265
|
"invalid-request": "请求构造被拒(可能是凭据或地址形态问题)",
|
|
266
|
-
|
|
266
|
+
|
|
267
267
|
"reauth-required": "需重新登录",
|
|
268
268
|
"rate-limited": "请求被限流",
|
|
269
269
|
"http-error": "服务端返回错误",
|
|
270
270
|
unreachable: "网络不可达",
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
|
|
274
274
|
export const safeFailureReason = (err) => {
|
|
275
275
|
const code = classifyFetchFailure(err);
|
|
276
276
|
return `${code}(${FAILURE_SUMMARY[code] ?? FAILURE_SUMMARY.unreachable})`;
|
|
277
277
|
};
|
|
278
278
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
294
|
export const requestAbort = (res) => {
|
|
295
295
|
const ac = new AbortController();
|
|
296
296
|
res.once("close", () => {
|
|
@@ -299,14 +299,14 @@ export const requestAbort = (res) => {
|
|
|
299
299
|
return ac.signal;
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
-
/** 插件主体。 */
|
|
303
302
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
310
|
export const parseByteRange = (value, size) => {
|
|
311
311
|
const text = String(value ?? "").trim();
|
|
312
312
|
if (text === "") return null;
|
|
@@ -325,7 +325,7 @@ export const parseByteRange = (value, size) => {
|
|
|
325
325
|
if (!Number.isSafeInteger(end) || end < start) return { invalid: true };
|
|
326
326
|
return { start, end: Math.min(end, size - 1) };
|
|
327
327
|
};
|
|
328
|
-
|
|
328
|
+
|
|
329
329
|
export const ifNoneMatch = (req, etag) => {
|
|
330
330
|
if (!etag) return false;
|
|
331
331
|
const raw = requestHeaderText(req, "if-none-match");
|
package/lib/assistant-prefs.js
CHANGED
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
14
|
import { readFileSync, writeFileSync, renameSync, mkdirSync } from "node:fs";
|
|
15
15
|
import { join } from "node:path";
|
|
16
16
|
import { parseHm } from "./notify-copy.js";
|
|
17
17
|
|
|
18
18
|
const MODES = ["work", "life"];
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
const PERSONA_CARD_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
21
21
|
const PERSONAS = ["colleague", "character"];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const NO_PERSONA_ID = "none";
|
|
24
|
+
|
|
25
|
+
const UNPICKED_LEGACY_CARDS = ["workaholic", "life-assistant"];
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
29
33
|
function validWindow(start, end) {
|
|
30
34
|
return parseHm(start) !== null && parseHm(end) !== null;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
38
42
|
export function createAssistantPrefs({ dir, defaults }) {
|
|
39
43
|
const file = join(dir, "assistant.json");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
47
59
|
let explicit = null;
|
|
48
60
|
|
|
49
61
|
function readExplicit() {
|
|
@@ -54,24 +66,31 @@ export function createAssistantPrefs({ dir, defaults }) {
|
|
|
54
66
|
} catch {
|
|
55
67
|
raw = null;
|
|
56
68
|
}
|
|
57
|
-
const legacy = raw && raw.v
|
|
69
|
+
const legacy = raw && !(raw.v >= 2);
|
|
70
|
+
const preNoCardDefault = raw && !(raw.v >= 3);
|
|
58
71
|
const e = {};
|
|
59
72
|
if (raw && typeof raw === "object") {
|
|
60
73
|
if (MODES.includes(raw.mode)) e.mode = raw.mode;
|
|
61
74
|
if (PERSONAS.includes(raw.persona)) e.persona = raw.persona;
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
|
|
76
|
+
|
|
64
77
|
const quiet = raw.quietHours;
|
|
65
78
|
if (quiet && validWindow(quiet.start, quiet.end)) e.quietHours = { start: quiet.start, end: quiet.end };
|
|
66
79
|
if (typeof raw.breakReminder === "boolean" && !(legacy && raw.breakReminder === true)) e.breakReminder = raw.breakReminder;
|
|
67
|
-
|
|
68
|
-
if (
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
PERSONA_CARD_ID.test(raw.personaCard ?? "") &&
|
|
83
|
+
raw.personaCard !== NO_PERSONA_ID &&
|
|
84
|
+
!(preNoCardDefault && UNPICKED_LEGACY_CARDS.includes(raw.personaCard))
|
|
85
|
+
) {
|
|
86
|
+
e.personaCard = raw.personaCard;
|
|
87
|
+
}
|
|
69
88
|
}
|
|
70
89
|
explicit = e;
|
|
71
90
|
return explicit;
|
|
72
91
|
}
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
|
|
75
94
|
function effective() {
|
|
76
95
|
const e = readExplicit();
|
|
77
96
|
const fallback = defaults();
|
|
@@ -79,7 +98,7 @@ export function createAssistantPrefs({ dir, defaults }) {
|
|
|
79
98
|
mode: e.mode ?? fallback.mode,
|
|
80
99
|
persona: e.persona ?? fallback.persona,
|
|
81
100
|
quietHours: { ...(e.quietHours ?? fallback.quietHours ?? { start: "23:30", end: "08:30" }) },
|
|
82
|
-
|
|
101
|
+
|
|
83
102
|
breakReminder: e.breakReminder ?? true,
|
|
84
103
|
...(e.personaCard ? { personaCard: e.personaCard } : {}),
|
|
85
104
|
};
|
|
@@ -87,29 +106,29 @@ export function createAssistantPrefs({ dir, defaults }) {
|
|
|
87
106
|
|
|
88
107
|
function save(next) {
|
|
89
108
|
mkdirSync(dir, { recursive: true });
|
|
90
|
-
|
|
109
|
+
|
|
91
110
|
const tmp = `${file}.tmp`;
|
|
92
|
-
writeFileSync(tmp, JSON.stringify({ v:
|
|
111
|
+
writeFileSync(tmp, JSON.stringify({ v: 3, ...next }, null, 2), "utf8");
|
|
93
112
|
renameSync(tmp, file);
|
|
94
113
|
explicit = next;
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
return {
|
|
98
117
|
file,
|
|
99
|
-
|
|
118
|
+
|
|
100
119
|
get: () => effective(),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
105
124
|
breakReminderSetByApp: () => typeof readExplicit().breakReminder === "boolean",
|
|
106
125
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
113
132
|
set(patch) {
|
|
114
133
|
const before = JSON.stringify(effective());
|
|
115
134
|
const next = { ...readExplicit() };
|
|
@@ -129,16 +148,20 @@ export function createAssistantPrefs({ dir, defaults }) {
|
|
|
129
148
|
const start = patch.quietHours?.start;
|
|
130
149
|
const end = patch.quietHours?.end;
|
|
131
150
|
if (!validWindow(start, end)) {
|
|
132
|
-
|
|
151
|
+
|
|
133
152
|
throw new Error("quietHours 必须是 {start: \"HH:MM\", end: \"HH:MM\"}");
|
|
134
153
|
}
|
|
135
154
|
next.quietHours = { start, end };
|
|
136
155
|
}
|
|
137
156
|
if (patch?.personaCard !== undefined) {
|
|
138
|
-
if (
|
|
139
|
-
|
|
157
|
+
if (patch.personaCard === null || patch.personaCard === NO_PERSONA_ID) {
|
|
158
|
+
|
|
159
|
+
delete next.personaCard;
|
|
160
|
+
} else if (typeof patch.personaCard !== "string" || !PERSONA_CARD_ID.test(patch.personaCard)) {
|
|
161
|
+
throw new Error('personaCard 必须是人格卡的 id 或 "none" / personaCard must be a persona card id or "none"');
|
|
162
|
+
} else {
|
|
163
|
+
next.personaCard = patch.personaCard;
|
|
140
164
|
}
|
|
141
|
-
next.personaCard = patch.personaCard;
|
|
142
165
|
}
|
|
143
166
|
if (patch?.breakReminder !== undefined) {
|
|
144
167
|
if (typeof patch.breakReminder !== "boolean") throw new Error("breakReminder 必须是 true / false");
|
|
@@ -152,10 +175,10 @@ export function createAssistantPrefs({ dir, defaults }) {
|
|
|
152
175
|
};
|
|
153
176
|
}
|
|
154
177
|
|
|
155
|
-
// personaBrief was removed with T-31 (D8): the active persona card's own text is the only
|
|
156
|
-
// persona text the model sees (lib/persona-cards.js, personaPromptText).
|
|
157
178
|
|
|
158
|
-
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
159
182
|
export function modeBrief(mode) {
|
|
160
183
|
if (mode === "life") {
|
|
161
184
|
return [
|