@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/config.js
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
5
|
import z from "@deepseek-ai/schemastery";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
19
|
export const DEFAULT_ENUMERATION_BUDGET_MS = 12_000;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
28
|
export const DEFAULT_WARM_UP_TITLE_BUDGET_MS = 10_000;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
export const Config = z.object({
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
path: z.string().pattern(/^\/[a-zA-Z0-9_-]+$/).default("/m"),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
41
|
authToken: z.string().default(""),
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
cookieName: z.string().default("dsh_mobile_token"),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
50
|
trustedHosts: z.array(z.string()).default([]),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
58
|
qrConfigBehindRelay: z.boolean().default(false),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
64
|
printConnectionInfo: z.boolean().default(true),
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
sessionTtlMs: z.number().default(30 * 24 * 3600 * 1000),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
79
|
enumerationBudgetMs: z.number().min(0).default(DEFAULT_ENUMERATION_BUDGET_MS),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
90
|
warmUpOnStart: z.boolean().default(true),
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
warmUpTitleBudgetMs: z.number().min(0).default(DEFAULT_WARM_UP_TITLE_BUDGET_MS),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
101
|
turnOutlineTimeoutMs: z.number().default(5000),
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
maxConnections: z.number().default(16),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
115
|
pushUrls: z
|
|
116
116
|
.array(z.object({ name: z.string().default("push"), url: z.string().required(), format: z.string().default("generic") }))
|
|
117
117
|
.default([]),
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
pushCooldownMs: z.number().default(60_000),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
125
|
doneGraceMs: z.number().default(15_000),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
133
|
pushContent: z.string().default("minimal"),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
138
|
rateLimit: z
|
|
139
139
|
.object({
|
|
140
140
|
maxFailures: z.number().default(10),
|
|
@@ -142,142 +142,156 @@ export const Config = z.object({
|
|
|
142
142
|
blockMs: z.number().default(60_000),
|
|
143
143
|
})
|
|
144
144
|
.default({}),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
154
|
lanBridge: z
|
|
155
155
|
.object({
|
|
156
156
|
enabled: z.union([z.boolean(), z.const("auto")]).default(false),
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
port: z.number().min(1).max(65535).default(3080),
|
|
159
159
|
host: z.string().min(1).default("0.0.0.0"),
|
|
160
160
|
})
|
|
161
161
|
.default({}),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
173
|
relay: z
|
|
174
174
|
.object({
|
|
175
175
|
enabled: z.boolean().default(true),
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
urls: z.array(z.string()).default(["wss://dsh.claud.ing"]),
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
name: z.string().default(""),
|
|
180
180
|
})
|
|
181
181
|
.default({}),
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
p2p: z
|
|
188
|
+
.object({
|
|
189
|
+
enabled: z.boolean().default(false),
|
|
190
|
+
stun: z.array(z.string()).default(["stun:stun.cloudflare.com:3478"]),
|
|
191
|
+
})
|
|
192
|
+
.default({}),
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
191
202
|
approvalMode: z
|
|
192
203
|
.union([z.const("both"), z.const("mobile"), z.const("desktop")])
|
|
193
204
|
.default("both"),
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
204
215
|
offlineHoldMs: z.number().min(0).max(3_600_000).default(300_000),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
209
220
|
offlineAlsoDesktop: z.boolean().default(true),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
217
228
|
pushApprovalGraceMs: z.number().min(0).max(60_000).default(5_000),
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
226
237
|
memory: z
|
|
227
238
|
.object({
|
|
228
239
|
enabled: z.boolean().default(false),
|
|
229
240
|
})
|
|
230
241
|
.default({ enabled: false }),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
239
253
|
persona: z.union([z.const("colleague"), z.const("character")]).default("colleague"),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
247
261
|
quietHours: z
|
|
248
262
|
.object({
|
|
249
263
|
start: z.string().default("23:30"),
|
|
250
264
|
end: z.string().default("08:30"),
|
|
251
265
|
})
|
|
252
266
|
.default({ start: "23:30", end: "08:30" }),
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
257
271
|
mode: z.union([z.const("work"), z.const("life")]).default("work"),
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
267
281
|
proactive: z
|
|
268
282
|
.object({
|
|
269
283
|
enabled: z.boolean().default(false),
|
|
270
|
-
|
|
284
|
+
|
|
271
285
|
dailyLimit: z.number().min(0).max(20).default(3),
|
|
272
|
-
|
|
286
|
+
|
|
273
287
|
minGapMs: z.number().min(0).default(90 * 60_000),
|
|
274
|
-
|
|
288
|
+
|
|
275
289
|
tickMs: z.number().min(1_000).default(60_000),
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
281
295
|
activeWindowMs: z.number().min(0).default(30 * 60_000),
|
|
282
296
|
})
|
|
283
297
|
.default({
|
|
@@ -287,16 +301,18 @@ export const Config = z.object({
|
|
|
287
301
|
tickMs: 60_000,
|
|
288
302
|
activeWindowMs: 30 * 60_000,
|
|
289
303
|
}),
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
297
313
|
breakReminder: z
|
|
298
314
|
.object({
|
|
299
|
-
enabled: z.boolean()
|
|
315
|
+
enabled: z.boolean(),
|
|
300
316
|
})
|
|
301
|
-
.default({
|
|
317
|
+
.default({}),
|
|
302
318
|
});
|
|
@@ -2,7 +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 } from "./protected-paths.js";
|
|
5
|
+
import { isProtectedFile, isProtectedPath, isStillAt } from "./protected-paths.js";
|
|
6
6
|
|
|
7
7
|
const UNTRACKED_PREVIEW_MAX = 512 * 1024;
|
|
8
8
|
const SIGNATURE_SAMPLE_BYTES = 4096;
|
|
@@ -11,18 +11,37 @@ function sameRegularFile(expected, opened) {
|
|
|
11
11
|
return expected.isFile() && opened.isFile() && expected.dev === opened.dev && expected.ino === opened.ino;
|
|
12
12
|
}
|
|
13
13
|
async function readPrefix(path, maximum, expected) {
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
if (isProtectedPath(path)) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
16
16
|
const handle = await open(path, readOnlyNoFollow);
|
|
17
17
|
try {
|
|
18
18
|
const opened = await handle.stat();
|
|
19
19
|
if (isProtectedFile(opened)) throw Object.assign(new Error("path-protected"), { code: "path-protected" });
|
|
20
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" });
|
|
21
22
|
const buffer = Buffer.alloc(maximum + 1);
|
|
22
23
|
const { bytesRead } = await handle.read(buffer, 0, maximum + 1, 0);
|
|
23
24
|
return { bytes: buffer.subarray(0, bytesRead), truncated: bytesRead > maximum };
|
|
24
25
|
} finally { await handle.close(); }
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
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;
|
|
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
|
+
}
|
|
26
45
|
async function sampledFileSignature(path, info) {
|
|
27
46
|
const handle = await open(path, readOnlyNoFollow);
|
|
28
47
|
try {
|
|
@@ -46,12 +65,12 @@ function gitError(code, status, message = code) {
|
|
|
46
65
|
return error;
|
|
47
66
|
}
|
|
48
67
|
|
|
49
|
-
|
|
68
|
+
|
|
50
69
|
export function createBundledGitReadProvider(ctx) {
|
|
51
70
|
const get = (name) => {
|
|
52
71
|
try { return ctx.get?.(name); } catch { return undefined; }
|
|
53
72
|
};
|
|
54
|
-
|
|
73
|
+
|
|
55
74
|
const subprocess = () => get("subprocess") ?? (() => { try { return ctx.subprocess; } catch { return undefined; } })();
|
|
56
75
|
const workspaces = () => (get("workspaceRegistry")?.list?.() ?? [])
|
|
57
76
|
.map((entry) => entry?.path).filter((path) => typeof path === "string" && path !== "");
|
|
@@ -88,8 +107,8 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
88
107
|
...args,
|
|
89
108
|
],
|
|
90
109
|
cwd: root,
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
|
|
111
|
+
|
|
93
112
|
env: {
|
|
94
113
|
GIT_TERMINAL_PROMPT: "0",
|
|
95
114
|
GCM_INTERACTIVE: "never",
|
|
@@ -102,7 +121,7 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
102
121
|
GIT_CONFIG: undefined,
|
|
103
122
|
GIT_CONFIG_PARAMETERS: undefined,
|
|
104
123
|
GIT_CONFIG_COUNT: "0",
|
|
105
|
-
|
|
124
|
+
|
|
106
125
|
...Object.fromEntries(Object.keys(process.env).filter((key) => /^GIT_TRACE(?:2)?(?:_|$)/.test(key)).map((key) => [key, undefined])),
|
|
107
126
|
GIT_TRACE: undefined,
|
|
108
127
|
GIT_TRACE2: undefined,
|
|
@@ -232,6 +251,7 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
232
251
|
return { diff: "", binary: false, additions: 0, deletions: 0, notice: "unavailable" };
|
|
233
252
|
}
|
|
234
253
|
}
|
|
254
|
+
await assertWorktreeFileNotProtected(resolve(root, path));
|
|
235
255
|
return { diff: await run(root, args, true), binary: false, additions: null, deletions: null };
|
|
236
256
|
},
|
|
237
257
|
async commitPreview(root, oid, path) {
|
package/lib/git-read-service.js
CHANGED
|
@@ -16,7 +16,7 @@ function failure(code, status, message = code) {
|
|
|
16
16
|
const providerCompatible = (provider) => provider?.contractVersion === "1.0.0"
|
|
17
17
|
&& ["repositoryRoot", "branches", "resolveTip", "graph", "commit"].every((method) => typeof provider[method] === "function");
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
export function createGitReadService(ctx, { bundledProvider, now = () => Date.now(), snapshotTtlMs = 5 * 60_000, pollIntervalMs = 30_000, onChanged } = {}) {
|
|
21
21
|
const get = (name) => { try { return ctx.get?.(name); } catch { return undefined; } };
|
|
22
22
|
const external = get("gitReadProvider");
|
|
@@ -131,8 +131,8 @@ export function createGitReadService(ctx, { bundledProvider, now = () => Date.no
|
|
|
131
131
|
async preview(sessionId, repositoryId, { kind, snapshotId, path, oid } = {}) {
|
|
132
132
|
const authorized = await binding(sessionId, repositoryId);
|
|
133
133
|
if (!safeFilePath(path) || !["staged", "unstaged", "untracked", "commit"].includes(kind)) throw failure("preview-invalid", 400);
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
|
|
135
|
+
|
|
136
136
|
if (isProtectedPath(resolve(authorized.root, path))) throw failure("path-protected", 403, "this file holds DSH's or the plugin's keys and data");
|
|
137
137
|
const reader = createBundledGitReadProvider(ctx);
|
|
138
138
|
let raw;
|
|
@@ -311,14 +311,14 @@ export function createGitReadService(ctx, { bundledProvider, now = () => Date.no
|
|
|
311
311
|
}); } catch { unsubscribeProvider = null; }
|
|
312
312
|
if (typeof unsubscribeProvider !== "function") unsubscribeProvider = null;
|
|
313
313
|
}
|
|
314
|
-
|
|
314
|
+
|
|
315
315
|
pollTimer = setInterval(() => { void service._pollOnce(); }, pollIntervalMs);
|
|
316
316
|
pollTimer.unref?.();
|
|
317
317
|
},
|
|
318
318
|
stop() {
|
|
319
319
|
if (pollTimer) clearInterval(pollTimer);
|
|
320
320
|
pollTimer = null;
|
|
321
|
-
try { unsubscribeProvider?.(); } catch {
|
|
321
|
+
try { unsubscribeProvider?.(); } catch { }
|
|
322
322
|
unsubscribeProvider = null;
|
|
323
323
|
},
|
|
324
324
|
};
|