@eum-agent/sandbox-presets 0.0.0-stage → 1.0.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/dist/index.js +1209 -0
- package/package.json +57 -3
- package/ui/ui.js +952 -0
- package/README.md +0 -3
package/ui/ui.js
ADDED
|
@@ -0,0 +1,952 @@
|
|
|
1
|
+
import { Badge, Button, DataTable, EmptyState, OperationProgress, Popover, ReadFailure, Warning, captureOperationFocus, failureText, useGateway, useToast, useTranslation } from "@eum-agent/host/framework";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region ui-src/acquisition.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates an owner-held acquisition lifetime; construction issues no RPCs.
|
|
7
|
+
* Panel entry shares pending work and retains cached permissions. The owner's abort signal
|
|
8
|
+
* withdraws connection observation and cancels only this owner's request. Installation identity
|
|
9
|
+
* changes clear cached data and cooldowns; old-connection replies never update the current snapshot.
|
|
10
|
+
*/
|
|
11
|
+
function createPresetAcquisition(api, owner) {
|
|
12
|
+
let snapshot = {
|
|
13
|
+
reading: false,
|
|
14
|
+
ready: false,
|
|
15
|
+
state: null,
|
|
16
|
+
result: null,
|
|
17
|
+
syncing: false
|
|
18
|
+
};
|
|
19
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
20
|
+
let successfulAt;
|
|
21
|
+
let retryAt = 0;
|
|
22
|
+
let pending;
|
|
23
|
+
let operationId;
|
|
24
|
+
let epoch = 0;
|
|
25
|
+
let online = owner.gateway.connection.status === "online";
|
|
26
|
+
let gatewayId;
|
|
27
|
+
let identityEpoch;
|
|
28
|
+
let identifying;
|
|
29
|
+
let reading;
|
|
30
|
+
const closed = () => owner.signal.aborted;
|
|
31
|
+
function cancel() {
|
|
32
|
+
if (!operationId) return;
|
|
33
|
+
const id = operationId;
|
|
34
|
+
(async () => api.cancel(id))().catch(() => {});
|
|
35
|
+
}
|
|
36
|
+
function publish(value) {
|
|
37
|
+
snapshot = value;
|
|
38
|
+
for (const listener of listeners) listener();
|
|
39
|
+
}
|
|
40
|
+
function remember(state) {
|
|
41
|
+
if (closed()) return;
|
|
42
|
+
if (snapshot.state === state) return;
|
|
43
|
+
if (snapshot.state && state.appliedRevision < snapshot.state.appliedRevision) return;
|
|
44
|
+
if (snapshot.state?.syncState && !state.syncState && !pending) {
|
|
45
|
+
if (state.lastSyncedAt && state.lastSyncedAt !== snapshot.state.lastSyncedAt) {
|
|
46
|
+
successfulAt = performance.now();
|
|
47
|
+
retryAt = 0;
|
|
48
|
+
} else retryAt = performance.now() + 3e4;
|
|
49
|
+
}
|
|
50
|
+
publish({
|
|
51
|
+
...snapshot,
|
|
52
|
+
state
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function identify() {
|
|
56
|
+
if (closed() || !online) return false;
|
|
57
|
+
if (identityEpoch === epoch) return true;
|
|
58
|
+
if (identifying?.epoch === epoch) return identifying.promise;
|
|
59
|
+
const requestEpoch = epoch;
|
|
60
|
+
const promise = (async () => {
|
|
61
|
+
try {
|
|
62
|
+
const identity = await owner.gateway.call("connection.info", {});
|
|
63
|
+
if (closed() || !online || requestEpoch !== epoch) return false;
|
|
64
|
+
if (gatewayId && gatewayId !== identity.gatewayId) {
|
|
65
|
+
successfulAt = void 0;
|
|
66
|
+
retryAt = 0;
|
|
67
|
+
publish({
|
|
68
|
+
...snapshot,
|
|
69
|
+
ready: false,
|
|
70
|
+
state: null,
|
|
71
|
+
result: null,
|
|
72
|
+
syncing: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
gatewayId = identity.gatewayId;
|
|
76
|
+
identityEpoch = requestEpoch;
|
|
77
|
+
return true;
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
const request = {
|
|
83
|
+
epoch: requestEpoch,
|
|
84
|
+
promise
|
|
85
|
+
};
|
|
86
|
+
identifying = request;
|
|
87
|
+
const result = await promise;
|
|
88
|
+
if (identifying === request) identifying = void 0;
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
async function read(invalidate = false) {
|
|
92
|
+
if (closed() || !online) return void 0;
|
|
93
|
+
if (reading?.epoch === epoch) {
|
|
94
|
+
if (invalidate) reading.invalidate();
|
|
95
|
+
return reading.promise;
|
|
96
|
+
}
|
|
97
|
+
const requestEpoch = epoch;
|
|
98
|
+
let invalidated = false;
|
|
99
|
+
publish({
|
|
100
|
+
...snapshot,
|
|
101
|
+
reading: true
|
|
102
|
+
});
|
|
103
|
+
const promise = (async () => {
|
|
104
|
+
if (!await identify()) return closed() || !online || requestEpoch !== epoch ? void 0 : {
|
|
105
|
+
ok: false,
|
|
106
|
+
code: "UNAVAILABLE",
|
|
107
|
+
message: "Unable to read Gateway identity"
|
|
108
|
+
};
|
|
109
|
+
while (!closed() && online && requestEpoch === epoch) {
|
|
110
|
+
invalidated = false;
|
|
111
|
+
let result;
|
|
112
|
+
try {
|
|
113
|
+
result = await api.list();
|
|
114
|
+
} catch (failure) {
|
|
115
|
+
if (invalidated && !closed() && online && requestEpoch === epoch) continue;
|
|
116
|
+
throw failure;
|
|
117
|
+
}
|
|
118
|
+
if (closed() || !online || requestEpoch !== epoch) return void 0;
|
|
119
|
+
if (invalidated) continue;
|
|
120
|
+
if (result.ok) {
|
|
121
|
+
remember(result.data);
|
|
122
|
+
publish({
|
|
123
|
+
...snapshot,
|
|
124
|
+
ready: true
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
})();
|
|
130
|
+
const request = {
|
|
131
|
+
epoch: requestEpoch,
|
|
132
|
+
promise,
|
|
133
|
+
invalidate: () => {
|
|
134
|
+
invalidated = true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
reading = request;
|
|
138
|
+
try {
|
|
139
|
+
return await promise;
|
|
140
|
+
} finally {
|
|
141
|
+
if (reading === request) {
|
|
142
|
+
reading = void 0;
|
|
143
|
+
publish({
|
|
144
|
+
...snapshot,
|
|
145
|
+
reading: false
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async function acquire(force) {
|
|
151
|
+
if (closed() || !online) return void 0;
|
|
152
|
+
if (!await identify()) return void 0;
|
|
153
|
+
if (snapshot.state && !snapshot.state.supportedPlatform) return void 0;
|
|
154
|
+
if (pending) {
|
|
155
|
+
const running = pending;
|
|
156
|
+
const result = await running.promise;
|
|
157
|
+
if (closed() || !online) return void 0;
|
|
158
|
+
if (running.epoch !== epoch) return void 0;
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
if (snapshot.state?.syncState) return void 0;
|
|
162
|
+
if (!force && successfulAt !== void 0 && performance.now() - successfulAt < 6e4) return void 0;
|
|
163
|
+
if (!force && performance.now() < retryAt) return void 0;
|
|
164
|
+
publish({
|
|
165
|
+
...snapshot,
|
|
166
|
+
syncing: true
|
|
167
|
+
});
|
|
168
|
+
operationId = owner.uuid?.() ?? crypto.randomUUID();
|
|
169
|
+
const id = operationId;
|
|
170
|
+
const running = {
|
|
171
|
+
epoch,
|
|
172
|
+
promise: (async () => api.sync(id))().catch((failure) => ({
|
|
173
|
+
ok: false,
|
|
174
|
+
code: "UNAVAILABLE",
|
|
175
|
+
message: failure instanceof Error ? failure.message : "Catalog acquisition failed"
|
|
176
|
+
}))
|
|
177
|
+
};
|
|
178
|
+
pending = running;
|
|
179
|
+
const result = await running.promise;
|
|
180
|
+
if (pending === running) {
|
|
181
|
+
pending = void 0;
|
|
182
|
+
operationId = void 0;
|
|
183
|
+
}
|
|
184
|
+
if (closed() || !online || running.epoch !== epoch) return void 0;
|
|
185
|
+
if (result.ok) {
|
|
186
|
+
successfulAt = performance.now();
|
|
187
|
+
retryAt = 0;
|
|
188
|
+
remember(result.data);
|
|
189
|
+
} else {
|
|
190
|
+
const seconds = result.retryAfterSeconds;
|
|
191
|
+
const delay = seconds !== void 0 && Number.isFinite(seconds) ? Math.max(3e4, Math.min(864e5, seconds * 1e3)) : 3e4;
|
|
192
|
+
retryAt = performance.now() + delay;
|
|
193
|
+
}
|
|
194
|
+
publish({
|
|
195
|
+
...snapshot,
|
|
196
|
+
ready: snapshot.ready || result.ok,
|
|
197
|
+
result,
|
|
198
|
+
syncing: false
|
|
199
|
+
});
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
const stopConnection = owner.gateway.watchConnection((value) => {
|
|
203
|
+
const next = value.status === "online";
|
|
204
|
+
if (online && !next) {
|
|
205
|
+
epoch++;
|
|
206
|
+
cancel();
|
|
207
|
+
pending = void 0;
|
|
208
|
+
operationId = void 0;
|
|
209
|
+
publish({
|
|
210
|
+
...snapshot,
|
|
211
|
+
reading: false,
|
|
212
|
+
ready: false,
|
|
213
|
+
syncing: false
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
online = next;
|
|
217
|
+
});
|
|
218
|
+
function dispose() {
|
|
219
|
+
epoch++;
|
|
220
|
+
stopConnection();
|
|
221
|
+
cancel();
|
|
222
|
+
publish({
|
|
223
|
+
...snapshot,
|
|
224
|
+
reading: false,
|
|
225
|
+
ready: false,
|
|
226
|
+
syncing: false
|
|
227
|
+
});
|
|
228
|
+
listeners.clear();
|
|
229
|
+
}
|
|
230
|
+
if (closed()) dispose();
|
|
231
|
+
else owner.signal.addEventListener("abort", dispose, { once: true });
|
|
232
|
+
return {
|
|
233
|
+
read,
|
|
234
|
+
getSnapshot: () => snapshot,
|
|
235
|
+
subscribe(listener) {
|
|
236
|
+
if (closed()) return () => {};
|
|
237
|
+
listeners.add(listener);
|
|
238
|
+
return () => listeners.delete(listener);
|
|
239
|
+
},
|
|
240
|
+
remember,
|
|
241
|
+
enter: () => acquire(false),
|
|
242
|
+
refresh: () => acquire(true)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region ui-src/i18n.ts
|
|
247
|
+
var translations;
|
|
248
|
+
/** Binds this activation's registered namespace without reconstructing the owner's namespace. */
|
|
249
|
+
function configureTranslations(ctx) {
|
|
250
|
+
translations = ctx.i18n;
|
|
251
|
+
}
|
|
252
|
+
/** Observes the shared language while resolving platform-owned copy. */
|
|
253
|
+
function useTranslation$1() {
|
|
254
|
+
const shared = useTranslation();
|
|
255
|
+
if (!translations) throw new Error("platform browser translations are not registered");
|
|
256
|
+
return {
|
|
257
|
+
...shared,
|
|
258
|
+
t: translations.t
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region ui-src/components/settings/sandbox-presets.tsx
|
|
263
|
+
/** System sandbox presets use one table of exact, applied category selections. */
|
|
264
|
+
/** Selects operation rows independently and applies explicit bulk actions after backend validation. */
|
|
265
|
+
function SandboxPresetsContent({ api, acquisition }) {
|
|
266
|
+
const { t } = useTranslation$1();
|
|
267
|
+
const gateway = useGateway();
|
|
268
|
+
const toast = useToast();
|
|
269
|
+
const [state, setState] = useState(() => acquisition.getSnapshot().state);
|
|
270
|
+
const [reading, setReading] = useState(acquisition.getSnapshot().reading || !state && gateway.connection.status === "online");
|
|
271
|
+
const [syncing, setSyncing] = useState(acquisition.getSnapshot().syncing);
|
|
272
|
+
const [ready, setReady] = useState(acquisition.getSnapshot().ready);
|
|
273
|
+
const [readError, setReadError] = useState("");
|
|
274
|
+
const [actionError, setActionError] = useState("");
|
|
275
|
+
const [syncError, setSyncError] = useState("");
|
|
276
|
+
const [busy, setBusy] = useState(false);
|
|
277
|
+
const [progressOpen, setProgressOpen] = useState(false);
|
|
278
|
+
const [online, setOnline] = useState(gateway.connection.status === "online");
|
|
279
|
+
const [chosenKeys, setChosenKeys] = useState(/* @__PURE__ */ new Set());
|
|
280
|
+
const returnFocus = useRef(void 0);
|
|
281
|
+
const retryIntent = useRef(null);
|
|
282
|
+
const pendingReceipt = useRef(null);
|
|
283
|
+
const active = useRef(false);
|
|
284
|
+
const onlineRef = useRef(online);
|
|
285
|
+
const lifetime = useRef(0);
|
|
286
|
+
const generation = useRef(0);
|
|
287
|
+
const operation = useRef(null);
|
|
288
|
+
const stateRef = useRef(state);
|
|
289
|
+
const syncResult = useRef(null);
|
|
290
|
+
stateRef.current = state;
|
|
291
|
+
function unwrap(result) {
|
|
292
|
+
if (!result.ok) throw new Error(`${result.code}: ${result.message}${result.retryAfterSeconds === void 0 ? "" : ` (${t("sandboxPresets.retryAfter", { seconds: result.retryAfterSeconds })})`}`);
|
|
293
|
+
return result.data;
|
|
294
|
+
}
|
|
295
|
+
function accept(value) {
|
|
296
|
+
if (stateRef.current && value.appliedRevision < stateRef.current.appliedRevision) {
|
|
297
|
+
if (value.error) setReadError(`${value.error.code}: ${value.error.message}`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
stateRef.current = value;
|
|
301
|
+
setState(value);
|
|
302
|
+
acquisition.remember(value);
|
|
303
|
+
setChosenKeys((previous) => {
|
|
304
|
+
const present = new Set(value.profiles.map((profile) => profile.id));
|
|
305
|
+
const next = new Set([...previous].filter((key) => present.has(key)));
|
|
306
|
+
return next.size === previous.size ? previous : next;
|
|
307
|
+
});
|
|
308
|
+
setReadError(value.error ? `${value.error.code}: ${value.error.message}` : "");
|
|
309
|
+
if (pendingReceipt.current && value.lastReceipt?.previewId === pendingReceipt.current) {
|
|
310
|
+
pendingReceipt.current = null;
|
|
311
|
+
retryIntent.current = null;
|
|
312
|
+
setActionError("");
|
|
313
|
+
setChosenKeys(/* @__PURE__ */ new Set());
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async function reload(invalidate = false) {
|
|
317
|
+
if (!active.current || !onlineRef.current) return;
|
|
318
|
+
if (operation.current) {
|
|
319
|
+
operation.current.reload = true;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const request = ++generation.current, owner = lifetime.current;
|
|
323
|
+
try {
|
|
324
|
+
const result = await acquisition.read(invalidate);
|
|
325
|
+
if (!result) return;
|
|
326
|
+
const value = unwrap(result);
|
|
327
|
+
if (active.current && onlineRef.current && owner === lifetime.current && request === generation.current) accept(value);
|
|
328
|
+
} catch (failure) {
|
|
329
|
+
if (active.current && onlineRef.current && owner === lifetime.current && request === generation.current) setReadError(failureText(failure, () => "") ?? "");
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
active.current = true;
|
|
334
|
+
onlineRef.current = gateway.connection.status === "online";
|
|
335
|
+
setOnline(onlineRef.current);
|
|
336
|
+
const viewLifetime = lifetime.current;
|
|
337
|
+
const observe = () => {
|
|
338
|
+
if (!active.current) return;
|
|
339
|
+
const snapshot = acquisition.getSnapshot();
|
|
340
|
+
setSyncing(snapshot.syncing);
|
|
341
|
+
setReading(snapshot.reading);
|
|
342
|
+
setReady(snapshot.ready);
|
|
343
|
+
if (snapshot.state && snapshot.state !== stateRef.current) {
|
|
344
|
+
generation.current++;
|
|
345
|
+
accept(snapshot.state);
|
|
346
|
+
}
|
|
347
|
+
if (!snapshot.state && stateRef.current) {
|
|
348
|
+
lifetime.current++;
|
|
349
|
+
generation.current++;
|
|
350
|
+
operation.current = null;
|
|
351
|
+
retryIntent.current = null;
|
|
352
|
+
pendingReceipt.current = null;
|
|
353
|
+
setBusy(false);
|
|
354
|
+
stateRef.current = null;
|
|
355
|
+
setState(null);
|
|
356
|
+
setReadError("");
|
|
357
|
+
setActionError("");
|
|
358
|
+
setSyncError("");
|
|
359
|
+
setChosenKeys(/* @__PURE__ */ new Set());
|
|
360
|
+
reload();
|
|
361
|
+
}
|
|
362
|
+
if (snapshot.result !== syncResult.current) {
|
|
363
|
+
syncResult.current = snapshot.result;
|
|
364
|
+
setSyncError(snapshot.result && !snapshot.result.ok ? `${snapshot.result.code}: ${snapshot.result.message}${snapshot.result.retryAfterSeconds === void 0 ? "" : ` (${t("sandboxPresets.retryAfter", { seconds: snapshot.result.retryAfterSeconds })})`}` : "");
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
observe();
|
|
368
|
+
const stopAcquisition = acquisition.subscribe(observe);
|
|
369
|
+
if (onlineRef.current) reload().then(() => {
|
|
370
|
+
if (!active.current || !onlineRef.current || viewLifetime !== lifetime.current) return;
|
|
371
|
+
if (stateRef.current) acquisition.remember(stateRef.current);
|
|
372
|
+
acquisition.enter();
|
|
373
|
+
});
|
|
374
|
+
const off = api.onChanged(() => void reload(true));
|
|
375
|
+
function invalidate() {
|
|
376
|
+
pendingReceipt.current = null;
|
|
377
|
+
lifetime.current++;
|
|
378
|
+
generation.current++;
|
|
379
|
+
operation.current = null;
|
|
380
|
+
}
|
|
381
|
+
const connection = gateway.watchConnection((value) => {
|
|
382
|
+
const next = value.status === "online", previous = onlineRef.current;
|
|
383
|
+
onlineRef.current = next;
|
|
384
|
+
setOnline(next);
|
|
385
|
+
if (!next) {
|
|
386
|
+
invalidate();
|
|
387
|
+
setBusy(false);
|
|
388
|
+
setReadError("");
|
|
389
|
+
setActionError("");
|
|
390
|
+
setSyncError("");
|
|
391
|
+
} else if (!previous) reload().then(() => {
|
|
392
|
+
if (active.current && onlineRef.current) acquisition.enter();
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
return () => {
|
|
396
|
+
active.current = false;
|
|
397
|
+
invalidate();
|
|
398
|
+
off();
|
|
399
|
+
connection();
|
|
400
|
+
stopAcquisition();
|
|
401
|
+
};
|
|
402
|
+
}, [
|
|
403
|
+
api,
|
|
404
|
+
gateway,
|
|
405
|
+
acquisition
|
|
406
|
+
]);
|
|
407
|
+
useEffect(() => {
|
|
408
|
+
if (!busy || operation.current?.sync) {
|
|
409
|
+
setProgressOpen(false);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const timer = window.setTimeout(() => setProgressOpen(true), 500);
|
|
413
|
+
return () => window.clearTimeout(timer);
|
|
414
|
+
}, [busy]);
|
|
415
|
+
function changeSelections(current, intent) {
|
|
416
|
+
if (intent.kind === "update") {
|
|
417
|
+
const profile = current.profiles.find((p) => p.id === intent.id);
|
|
418
|
+
if (!profile?.availableCommit || !current.selections.some((s) => s.presetId === intent.id) || profile.latest && !profile.latest.platforms[current.platform]) throw new Error(t("sandboxPresets.unavailableVersion"));
|
|
419
|
+
const commit = profile.availableCommit;
|
|
420
|
+
return current.selections.map((s) => s.presetId === intent.id ? {
|
|
421
|
+
...s,
|
|
422
|
+
commit
|
|
423
|
+
} : s);
|
|
424
|
+
}
|
|
425
|
+
const selections = current.selections.filter((s) => !intent.remove.includes(s.presetId));
|
|
426
|
+
for (const id of intent.add) {
|
|
427
|
+
if (selections.some((s) => s.presetId === id)) continue;
|
|
428
|
+
const profile = current.profiles.find((p) => p.id === id), commit = profile?.availableCommit ?? profile?.bundledCommit;
|
|
429
|
+
if (!profile?.supported || !commit) throw new Error(t("sandboxPresets.unavailableVersion"));
|
|
430
|
+
selections.push({
|
|
431
|
+
presetId: id,
|
|
432
|
+
commit
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
return selections;
|
|
436
|
+
}
|
|
437
|
+
async function run(intent, refresh = false) {
|
|
438
|
+
if (!stateRef.current || operation.current || !onlineRef.current || !active.current || intent !== "sync" && !refresh && !!readError || intent !== "sync" && acquisition.getSnapshot().syncing || intent !== "sync" && !acquisition.getSnapshot().ready) return;
|
|
439
|
+
const token = {
|
|
440
|
+
lifetime: lifetime.current,
|
|
441
|
+
reload: false,
|
|
442
|
+
sync: intent === "sync"
|
|
443
|
+
};
|
|
444
|
+
const live = () => active.current && onlineRef.current && token.lifetime === lifetime.current && operation.current === token;
|
|
445
|
+
returnFocus.current = captureOperationFocus();
|
|
446
|
+
operation.current = token;
|
|
447
|
+
generation.current++;
|
|
448
|
+
pendingReceipt.current = null;
|
|
449
|
+
retryIntent.current = intent;
|
|
450
|
+
setBusy(true);
|
|
451
|
+
setActionError("");
|
|
452
|
+
setSyncError("");
|
|
453
|
+
try {
|
|
454
|
+
if (refresh) {
|
|
455
|
+
const refreshed = await acquisition.read();
|
|
456
|
+
if (!refreshed) return;
|
|
457
|
+
const current = unwrap(refreshed);
|
|
458
|
+
if (!live()) return;
|
|
459
|
+
accept(current);
|
|
460
|
+
if (current.error) throw new Error(`${current.error.code}: ${current.error.message}`);
|
|
461
|
+
}
|
|
462
|
+
if (intent === "sync") {
|
|
463
|
+
const result = await acquisition.refresh();
|
|
464
|
+
if (!result) return;
|
|
465
|
+
const value = unwrap(result);
|
|
466
|
+
if (!live()) return;
|
|
467
|
+
accept(value);
|
|
468
|
+
toast.add({
|
|
469
|
+
title: t("sandboxPresets.synced"),
|
|
470
|
+
tone: "success"
|
|
471
|
+
});
|
|
472
|
+
} else {
|
|
473
|
+
const current = stateRef.current;
|
|
474
|
+
if (!current?.supportedPlatform) throw new Error(t("sandboxPresets.unsupported"));
|
|
475
|
+
const preview = unwrap(await api.preview(changeSelections(current, intent)));
|
|
476
|
+
if (!live()) return;
|
|
477
|
+
if (!preview.canApply) {
|
|
478
|
+
const blocked = preview.rows.find((row) => ![
|
|
479
|
+
"ready",
|
|
480
|
+
"missing",
|
|
481
|
+
"unresolved"
|
|
482
|
+
].includes(row.status));
|
|
483
|
+
throw new Error(`${t("sandboxPresets.blocked", { count: preview.blockedCount })}${blocked ? ` ${blocked.path ?? blocked.locator} · ${t(`sandboxPresets.status.${blocked.status}`)}` : ""}`);
|
|
484
|
+
}
|
|
485
|
+
pendingReceipt.current = preview.previewId;
|
|
486
|
+
const result = unwrap(await api.apply(preview.previewId));
|
|
487
|
+
if (!live()) return;
|
|
488
|
+
accept(result.state);
|
|
489
|
+
pendingReceipt.current = null;
|
|
490
|
+
setChosenKeys(/* @__PURE__ */ new Set());
|
|
491
|
+
}
|
|
492
|
+
retryIntent.current = null;
|
|
493
|
+
} catch (failure) {
|
|
494
|
+
if (live()) setActionError(failureText(failure, () => "") ?? "");
|
|
495
|
+
} finally {
|
|
496
|
+
if (operation.current === token) {
|
|
497
|
+
operation.current = null;
|
|
498
|
+
generation.current++;
|
|
499
|
+
if (active.current) setBusy(false);
|
|
500
|
+
if (token.reload && active.current && onlineRef.current) reload();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const enabledIds = new Set(state?.selections.map((s) => s.presetId));
|
|
505
|
+
const canEnable = state?.profiles.some((profile) => chosenKeys.has(profile.id) && !enabledIds.has(profile.id) && profile.supported && !!(profile.availableCommit ?? profile.bundledCommit)) ?? false;
|
|
506
|
+
const canDisable = state?.profiles.some((profile) => chosenKeys.has(profile.id) && enabledIds.has(profile.id) && profile.supported) ?? false;
|
|
507
|
+
const catalogSyncing = syncing || !!state?.syncState;
|
|
508
|
+
const locked = !state || !ready || busy || syncing || !online || !!readError || !state.supportedPlatform || !!state.syncState;
|
|
509
|
+
function enableChosen() {
|
|
510
|
+
const add = state?.profiles.filter((profile) => chosenKeys.has(profile.id) && !enabledIds.has(profile.id) && profile.supported && !!(profile.availableCommit ?? profile.bundledCommit)).map((profile) => profile.id) ?? [];
|
|
511
|
+
if (add.length) run({
|
|
512
|
+
kind: "selection",
|
|
513
|
+
add,
|
|
514
|
+
remove: []
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function disableChosen() {
|
|
518
|
+
const remove = state?.profiles.filter((profile) => chosenKeys.has(profile.id) && enabledIds.has(profile.id) && profile.supported).map((profile) => profile.id) ?? [];
|
|
519
|
+
if (remove.length) run({
|
|
520
|
+
kind: "selection",
|
|
521
|
+
add: [],
|
|
522
|
+
remove
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
526
|
+
className: "flex min-h-0 flex-1 flex-col gap-3",
|
|
527
|
+
children: [
|
|
528
|
+
/* @__PURE__ */ jsx(OperationProgress, {
|
|
529
|
+
open: busy && progressOpen,
|
|
530
|
+
onOpenChange: setProgressOpen,
|
|
531
|
+
finalFocus: returnFocus.current,
|
|
532
|
+
title: t(operation.current?.sync ? "sandboxPresets.sync" : "sandboxPresets.applyRules"),
|
|
533
|
+
pending: busy,
|
|
534
|
+
completed: 0,
|
|
535
|
+
total: 1,
|
|
536
|
+
delay: 0
|
|
537
|
+
}),
|
|
538
|
+
/* @__PURE__ */ jsx(ReadFailure, {
|
|
539
|
+
reason: actionError || readError || syncError || null,
|
|
540
|
+
onRetry: () => {
|
|
541
|
+
if (retryIntent.current) run(retryIntent.current, true);
|
|
542
|
+
else if (syncError && !readError && stateRef.current) run("sync");
|
|
543
|
+
else {
|
|
544
|
+
setActionError("");
|
|
545
|
+
reload().then(() => {
|
|
546
|
+
if (active.current && onlineRef.current) acquisition.enter();
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}),
|
|
551
|
+
state && !state.supportedPlatform && /* @__PURE__ */ jsx(Warning, { children: t("sandboxPresets.unsupported") }),
|
|
552
|
+
state && !state.sandboxEnabled && /* @__PURE__ */ jsx(Warning, { children: t("sandboxPresets.disabled") }),
|
|
553
|
+
/* @__PURE__ */ jsx(Warning, { children: t("sandboxPresets.readRisk") }),
|
|
554
|
+
/* @__PURE__ */ jsx(DataTable, {
|
|
555
|
+
size: "sm",
|
|
556
|
+
loading: online && (reading || syncing || !readError && !syncError && (!state || !!state.syncState)),
|
|
557
|
+
fill: true,
|
|
558
|
+
ariaLabel: t("permissions.systemRules"),
|
|
559
|
+
items: state?.profiles ?? [],
|
|
560
|
+
keyOf: (profile) => profile.id,
|
|
561
|
+
labelOf: (profile) => profile.name,
|
|
562
|
+
searchOf: (profile) => profile.name,
|
|
563
|
+
selection: {
|
|
564
|
+
keys: chosenKeys,
|
|
565
|
+
onChange: setChosenKeys,
|
|
566
|
+
disabled: locked,
|
|
567
|
+
disabledOf: (profile) => !profile.supported || !enabledIds.has(profile.id) && !(profile.availableCommit ?? profile.bundledCommit)
|
|
568
|
+
},
|
|
569
|
+
selectionActions: /* @__PURE__ */ jsxs("div", {
|
|
570
|
+
className: "flex min-h-8 min-w-0 flex-wrap items-center gap-1",
|
|
571
|
+
style: { visibility: chosenKeys.size ? "visible" : "hidden" },
|
|
572
|
+
"aria-hidden": !chosenKeys.size || void 0,
|
|
573
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
574
|
+
variant: "ghost",
|
|
575
|
+
size: "sm",
|
|
576
|
+
loading: busy && !operation.current?.sync && retryIntent.current !== "sync" && retryIntent.current?.kind === "selection" && retryIntent.current.add.length > 0,
|
|
577
|
+
disabled: locked || !canEnable,
|
|
578
|
+
onClick: enableChosen,
|
|
579
|
+
children: t("sandboxPresets.enableSelected")
|
|
580
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
581
|
+
variant: "ghost",
|
|
582
|
+
size: "sm",
|
|
583
|
+
loading: busy && !operation.current?.sync && retryIntent.current !== "sync" && retryIntent.current?.kind === "selection" && retryIntent.current.remove.length > 0,
|
|
584
|
+
disabled: locked || !canDisable,
|
|
585
|
+
onClick: disableChosen,
|
|
586
|
+
children: t("sandboxPresets.disableSelected")
|
|
587
|
+
})]
|
|
588
|
+
}),
|
|
589
|
+
toolbar: /* @__PURE__ */ jsx(Button, {
|
|
590
|
+
icon: catalogSyncing ? void 0 : "refresh",
|
|
591
|
+
loading: catalogSyncing,
|
|
592
|
+
onClick: () => void run("sync"),
|
|
593
|
+
disabled: !state || busy || syncing || !online || !!state.syncState,
|
|
594
|
+
children: t("sandboxPresets.sync")
|
|
595
|
+
}),
|
|
596
|
+
empty: /* @__PURE__ */ jsx(EmptyState, { title: t("sandboxPresets.empty") }),
|
|
597
|
+
columns: [
|
|
598
|
+
{
|
|
599
|
+
id: "name",
|
|
600
|
+
label: t("sandboxPresets.template"),
|
|
601
|
+
render: (profile) => {
|
|
602
|
+
const source = profile.sourceUrl;
|
|
603
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
604
|
+
className: "min-w-0 space-y-1",
|
|
605
|
+
children: [/* @__PURE__ */ jsx("p", { children: profile.name }), source && /* @__PURE__ */ jsx("a", {
|
|
606
|
+
className: "block break-all text-xs text-muted-foreground hover:text-primary hover:underline",
|
|
607
|
+
href: source,
|
|
608
|
+
title: source,
|
|
609
|
+
target: "_blank",
|
|
610
|
+
rel: "noreferrer",
|
|
611
|
+
children: "GitHub"
|
|
612
|
+
})]
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
id: "rules",
|
|
618
|
+
width: "7rem",
|
|
619
|
+
label: t("sandboxPresets.rules"),
|
|
620
|
+
render: (profile) => /* @__PURE__ */ jsx(Popover, {
|
|
621
|
+
label: `${profile.name} · ${t("sandboxPresets.rules")}`,
|
|
622
|
+
width: 480,
|
|
623
|
+
trigger: /* @__PURE__ */ jsx(Button, {
|
|
624
|
+
variant: "text",
|
|
625
|
+
size: "sm",
|
|
626
|
+
children: t("sandboxPresets.ruleCount", { count: profile.entries.length })
|
|
627
|
+
}),
|
|
628
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
629
|
+
className: "p-1",
|
|
630
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
631
|
+
className: "divide-y divide-border",
|
|
632
|
+
children: profile.entries.map((entry) => /* @__PURE__ */ jsxs("li", {
|
|
633
|
+
className: "space-y-1 py-3 text-xs first:pt-0 last:pb-0",
|
|
634
|
+
children: [
|
|
635
|
+
/* @__PURE__ */ jsx("p", {
|
|
636
|
+
className: "break-all font-mono",
|
|
637
|
+
children: entry.path
|
|
638
|
+
}),
|
|
639
|
+
/* @__PURE__ */ jsx("p", { children: entry.description }),
|
|
640
|
+
/* @__PURE__ */ jsx("ul", {
|
|
641
|
+
className: "space-y-1",
|
|
642
|
+
children: entry.sources.map((source) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
|
|
643
|
+
className: "break-all text-primary underline",
|
|
644
|
+
href: source,
|
|
645
|
+
target: "_blank",
|
|
646
|
+
rel: "noreferrer",
|
|
647
|
+
children: source
|
|
648
|
+
}) }, source))
|
|
649
|
+
})
|
|
650
|
+
]
|
|
651
|
+
}, entry.id))
|
|
652
|
+
})
|
|
653
|
+
})
|
|
654
|
+
})
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
id: "status",
|
|
658
|
+
label: t("sandboxPresets.state"),
|
|
659
|
+
render: (profile) => /* @__PURE__ */ jsx(Badge, {
|
|
660
|
+
size: "sm",
|
|
661
|
+
dot: true,
|
|
662
|
+
tone: enabledIds.has(profile.id) ? "success" : "neutral",
|
|
663
|
+
children: t(enabledIds.has(profile.id) ? "sandboxPresets.ruleEnabled" : "sandboxPresets.ruleDisabled")
|
|
664
|
+
})
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
id: "version",
|
|
668
|
+
width: "8rem",
|
|
669
|
+
label: t("sandboxPresets.versionStatus"),
|
|
670
|
+
render: (profile) => /* @__PURE__ */ jsxs("div", {
|
|
671
|
+
className: "flex flex-nowrap items-center gap-2 whitespace-nowrap",
|
|
672
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
673
|
+
className: "font-mono text-xs text-muted-foreground",
|
|
674
|
+
title: profile.appliedCommit ?? profile.availableCommit ?? profile.bundledCommit ?? void 0,
|
|
675
|
+
children: (profile.appliedCommit ?? profile.availableCommit ?? profile.bundledCommit)?.slice(0, 12) ?? "—"
|
|
676
|
+
}), profile.appliedCommit && profile.availableCommit && profile.appliedCommit !== profile.availableCommit && /* @__PURE__ */ jsx(Button, {
|
|
677
|
+
variant: "ghost",
|
|
678
|
+
size: "sm",
|
|
679
|
+
disabled: busy || !ready || syncing || !online || !!readError || !state?.supportedPlatform || !!state.syncState || !profile.supported || !!profile.latest && !profile.latest.platforms[state.platform],
|
|
680
|
+
onClick: () => {
|
|
681
|
+
if (stateRef.current && profile.availableCommit) run({
|
|
682
|
+
kind: "update",
|
|
683
|
+
id: profile.id
|
|
684
|
+
});
|
|
685
|
+
},
|
|
686
|
+
children: t("sandboxPresets.update")
|
|
687
|
+
})]
|
|
688
|
+
})
|
|
689
|
+
}
|
|
690
|
+
]
|
|
691
|
+
})
|
|
692
|
+
]
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
var en_US_default = {
|
|
696
|
+
sandboxPresets: {
|
|
697
|
+
"title": "System sandbox templates",
|
|
698
|
+
"readRisk": "Enabling rules lets sandboxed commands read confirmed files and entire directories, which may contain keys or other sensitive data. Enable only trusted rules you need; these rules grant read access only.",
|
|
699
|
+
"hint": "Choose templates and confirm their read targets before installing. Bundled templates are available offline; synchronize the catalog for updates.",
|
|
700
|
+
"selectedCount": "{{count}} categories applied",
|
|
701
|
+
"retryAfter": "Retry in {{seconds}} seconds",
|
|
702
|
+
"gatewayPlatform": "Gateway platform",
|
|
703
|
+
"available": "Synced commit",
|
|
704
|
+
"revision": "Applied revision",
|
|
705
|
+
"notSynced": "Not synced yet",
|
|
706
|
+
"unsupported": "This gateway platform has no supported sandbox backend. Category descriptions remain available.",
|
|
707
|
+
"disabled": "The sandbox is disabled. Saving presets does not enable it; direct commands retain host permissions.",
|
|
708
|
+
"inactiveApplied": "{{count}} confirmed targets are inactive. Preview and apply again.",
|
|
709
|
+
"scope": "Directory permission covers all its contents. Presets add reads only, without write, network, or file-tool grants. Unmarked entries may also contain sensitive data. Revocation affects new commands; running commands keep their existing permissions.",
|
|
710
|
+
"preview": "Preview application",
|
|
711
|
+
"changes": "Added {{added}} · Removed {{removed}} · Retained {{retained}} · Source changes {{sources}}",
|
|
712
|
+
"blocked": "{{count}} entries are blocked. Resolve them and preview again.",
|
|
713
|
+
"path": "Actual path and status",
|
|
714
|
+
"scopeLabel": "Read scope",
|
|
715
|
+
"sources": "Sources",
|
|
716
|
+
"credentials": "May contain credentials",
|
|
717
|
+
"details": "Details and sources",
|
|
718
|
+
"file": "Entire file contents",
|
|
719
|
+
"directory": "Directory and all contents",
|
|
720
|
+
"clear": "No categories selected. Applying removes preset contributions and retains other sources.",
|
|
721
|
+
"changesDetail": "All target and provenance changes",
|
|
722
|
+
"added": "Added targets",
|
|
723
|
+
"removed": "Removed targets",
|
|
724
|
+
"retained": "Retained targets",
|
|
725
|
+
"back": "Edit selection",
|
|
726
|
+
"working": "Working…",
|
|
727
|
+
"apply": "Confirm and apply",
|
|
728
|
+
"syncing": "Syncing…",
|
|
729
|
+
"sync": "Update catalog",
|
|
730
|
+
"cancelSync": "Cancel sync",
|
|
731
|
+
"search": "Search technology categories",
|
|
732
|
+
"empty": "No categories available. Sync the catalog first.",
|
|
733
|
+
"noMatches": "No matching categories.",
|
|
734
|
+
"removedCategory": "Removed from repository. Keep the old version or unselect it.",
|
|
735
|
+
"unsupportedCategory": "Unavailable on this gateway platform",
|
|
736
|
+
"unavailableVersion": "This draft version is unavailable. Use the latest version, or deselect and choose again.",
|
|
737
|
+
"keepOld": "Keeping the old version",
|
|
738
|
+
"useLatest": "Use latest version",
|
|
739
|
+
"synced": "Sync complete; applied permissions are unchanged.",
|
|
740
|
+
"close": "Close",
|
|
741
|
+
"previous": "Previous",
|
|
742
|
+
"next": "Next",
|
|
743
|
+
"status": {
|
|
744
|
+
"ready": "Ready to apply",
|
|
745
|
+
"missing": "Missing; inactive",
|
|
746
|
+
"unresolved": "Variable unset or not a single path; inactive",
|
|
747
|
+
"invalid": "Invalid scope; application blocked",
|
|
748
|
+
"sealed": "Sealed target; application blocked",
|
|
749
|
+
"type-mismatch": "Object type mismatch; application blocked",
|
|
750
|
+
"changed-target": "Target changed; apply again",
|
|
751
|
+
"unsupported": "Unsupported platform"
|
|
752
|
+
},
|
|
753
|
+
"verification": {
|
|
754
|
+
"documentation": "Documentation verified",
|
|
755
|
+
"sandbox-tested": "Maintainer reports sandbox testing"
|
|
756
|
+
},
|
|
757
|
+
"origin": {
|
|
758
|
+
"base": "Manual configuration",
|
|
759
|
+
"owner": "Other extension",
|
|
760
|
+
"preset": "Template"
|
|
761
|
+
},
|
|
762
|
+
"installed": "Installed templates",
|
|
763
|
+
"install": "Install templates",
|
|
764
|
+
"summary": "Effective rules",
|
|
765
|
+
"manage": "Manage installed templates and read rules",
|
|
766
|
+
"noneInstalled": "No templates installed.",
|
|
767
|
+
"template": "Rule name",
|
|
768
|
+
"installedVersion": "Installed version",
|
|
769
|
+
"versionStatus": "Version",
|
|
770
|
+
"updateAvailable": "Update available",
|
|
771
|
+
"currentVersion": "Current version",
|
|
772
|
+
"appliedSummary": "Applied configuration read paths, deduplicated by actual path and target type with every source retained. Excludes workspace directories, temporary directories, approved grants, and platform baseline rules. Installation drafts and previews do not change this list.",
|
|
773
|
+
"noEffectiveRules": "No effective read rules.",
|
|
774
|
+
"uninstallSelected": "Uninstall selected templates",
|
|
775
|
+
"uninstallTitle": "Uninstall templates",
|
|
776
|
+
"update": "Update",
|
|
777
|
+
"updateTitle": "Update template",
|
|
778
|
+
"previewRetry": "Preview failed. Return and retry.",
|
|
779
|
+
"bundledSource": "Bundled template · Available offline",
|
|
780
|
+
"syncedSource": "Synchronized template",
|
|
781
|
+
"rules": "Rule count",
|
|
782
|
+
"ruleCount": "{{count}} rules",
|
|
783
|
+
"ruleCount_one": "{{count}} rule",
|
|
784
|
+
"latestVersion": "Latest version",
|
|
785
|
+
"removedVersion": "Removed from catalog",
|
|
786
|
+
"localVersion": "Bundled version",
|
|
787
|
+
"declaredHint": "Declared targets for this gateway platform. The count is not an effective permission count; unconfirmed paths do not gain access automatically.",
|
|
788
|
+
"notGranted": "Read access not granted",
|
|
789
|
+
"confirmedRead": "Read access confirmed",
|
|
790
|
+
"applyRules": "Apply rules",
|
|
791
|
+
"offline": "Gateway disconnected. Reconnect to change rules or update the catalog.",
|
|
792
|
+
"enableSelected": "Enable selected",
|
|
793
|
+
"state": "Status",
|
|
794
|
+
"ruleEnabled": "Enabled",
|
|
795
|
+
"ruleDisabled": "Disabled",
|
|
796
|
+
"disableSelected": "Disable selected"
|
|
797
|
+
},
|
|
798
|
+
permissions: { "systemRules": "System sandbox rules" }
|
|
799
|
+
};
|
|
800
|
+
var zh_CN_default = {
|
|
801
|
+
sandboxPresets: {
|
|
802
|
+
"title": "系统沙箱模板",
|
|
803
|
+
"readRisk": "启用后,沙箱命令可读取已确认文件和目录的全部内容,其中可能包含密钥等敏感信息。请仅启用可信且需要的规则;这些规则仅授予读取权限。",
|
|
804
|
+
"hint": "选择模板并确认读取目标后安装。包内模板可离线安装;同步模板库可获取新版。",
|
|
805
|
+
"selectedCount": "已应用 {{count}} 个分类",
|
|
806
|
+
"retryAfter": "{{seconds}} 秒后重试",
|
|
807
|
+
"gatewayPlatform": "网关平台",
|
|
808
|
+
"available": "已同步提交",
|
|
809
|
+
"revision": "应用修订",
|
|
810
|
+
"notSynced": "尚未同步",
|
|
811
|
+
"unsupported": "当前网关平台没有受支持的沙箱后端,可查看分类说明。",
|
|
812
|
+
"disabled": "沙箱当前已关闭。保存模板不会开启沙箱;直接执行的命令仍使用宿主权限。",
|
|
813
|
+
"inactiveApplied": "{{count}} 个已确认目标已失效,请重新预览后应用。",
|
|
814
|
+
"scope": "目录授权允许命令读取其全部内容。模板只增加读取,不增加写入、网络或文件工具许可;未标记含认证的条目也不保证没有敏感内容。撤销影响新命令,已运行命令保留原有权限。",
|
|
815
|
+
"preview": "查看应用预览",
|
|
816
|
+
"changes": "新增 {{added}} · 移除 {{removed}} · 保留 {{retained}} · 来源变化 {{sources}}",
|
|
817
|
+
"blocked": "{{count}} 个条目被阻止,解决问题后请重新预览。",
|
|
818
|
+
"path": "实际路径与状态",
|
|
819
|
+
"scopeLabel": "读取范围",
|
|
820
|
+
"sources": "来源",
|
|
821
|
+
"credentials": "可能包含认证信息",
|
|
822
|
+
"details": "查看说明与来源",
|
|
823
|
+
"file": "此文件的全部内容",
|
|
824
|
+
"directory": "此目录及其全部内容",
|
|
825
|
+
"clear": "未选择分类。应用后将撤销模板贡献,保留其他来源。",
|
|
826
|
+
"changesDetail": "查看全部目标与来源差异",
|
|
827
|
+
"added": "新增目标",
|
|
828
|
+
"removed": "移除目标",
|
|
829
|
+
"retained": "保留目标",
|
|
830
|
+
"back": "返回修改",
|
|
831
|
+
"working": "处理中…",
|
|
832
|
+
"apply": "确认并应用",
|
|
833
|
+
"syncing": "同步中…",
|
|
834
|
+
"sync": "更新目录",
|
|
835
|
+
"cancelSync": "取消同步",
|
|
836
|
+
"search": "搜索技术分类",
|
|
837
|
+
"empty": "尚无可用分类,请先同步模板库。",
|
|
838
|
+
"noMatches": "没有匹配的分类。",
|
|
839
|
+
"removedCategory": "已从仓库移除,保留旧版或取消选择。",
|
|
840
|
+
"unsupportedCategory": "不适用于当前网关平台",
|
|
841
|
+
"unavailableVersion": "草稿版本已不可用,请使用新版或取消选择后重选。",
|
|
842
|
+
"keepOld": "当前保留旧版",
|
|
843
|
+
"useLatest": "使用新版",
|
|
844
|
+
"synced": "同步完成;已应用权限保持不变。",
|
|
845
|
+
"close": "关闭",
|
|
846
|
+
"previous": "上一页",
|
|
847
|
+
"next": "下一页",
|
|
848
|
+
"status": {
|
|
849
|
+
"ready": "可应用",
|
|
850
|
+
"missing": "路径不存在,不生效",
|
|
851
|
+
"unresolved": "变量未设置或不是单一路径,不生效",
|
|
852
|
+
"invalid": "路径范围无效,阻止应用",
|
|
853
|
+
"sealed": "目标属于密封目录,阻止应用",
|
|
854
|
+
"type-mismatch": "文件或目录类型不符,阻止应用",
|
|
855
|
+
"changed-target": "目标已变化,需要重新应用",
|
|
856
|
+
"unsupported": "平台不支持"
|
|
857
|
+
},
|
|
858
|
+
"verification": {
|
|
859
|
+
"documentation": "资料验证",
|
|
860
|
+
"sandbox-tested": "维护者声明已沙箱实测"
|
|
861
|
+
},
|
|
862
|
+
"origin": {
|
|
863
|
+
"base": "手工配置",
|
|
864
|
+
"owner": "其他扩展",
|
|
865
|
+
"preset": "模板"
|
|
866
|
+
},
|
|
867
|
+
"installed": "已安装模板",
|
|
868
|
+
"install": "安装模板",
|
|
869
|
+
"summary": "汇总规则",
|
|
870
|
+
"manage": "管理已安装模板与读取规则",
|
|
871
|
+
"noneInstalled": "尚未安装模板。",
|
|
872
|
+
"template": "规则名称",
|
|
873
|
+
"installedVersion": "已安装版本",
|
|
874
|
+
"versionStatus": "版本",
|
|
875
|
+
"updateAvailable": "有新版可用",
|
|
876
|
+
"currentVersion": "当前版本",
|
|
877
|
+
"appliedSummary": "已应用的配置可读路径,按实际路径与目标类型去重并保留全部来源。不包含工作目录、临时目录、已审批授权和平台基础规则。安装草稿与预览不会改变此列表。",
|
|
878
|
+
"noEffectiveRules": "暂无生效的读取规则。",
|
|
879
|
+
"uninstallSelected": "卸载所选模板",
|
|
880
|
+
"uninstallTitle": "卸载模板",
|
|
881
|
+
"update": "更新",
|
|
882
|
+
"updateTitle": "更新模板",
|
|
883
|
+
"previewRetry": "预览失败,请返回后重试。",
|
|
884
|
+
"bundledSource": "包内模板 · 可离线安装",
|
|
885
|
+
"syncedSource": "已同步模板",
|
|
886
|
+
"rules": "规则数量",
|
|
887
|
+
"ruleCount": "{{count}} 条规则",
|
|
888
|
+
"latestVersion": "最新版本",
|
|
889
|
+
"removedVersion": "目录已移除",
|
|
890
|
+
"localVersion": "内置版本",
|
|
891
|
+
"declaredHint": "以下是当前网关平台的声明目标;规则数量不代表实际生效的读取权限。未确认的路径不会自动获得授权。",
|
|
892
|
+
"notGranted": "尚未授予读取",
|
|
893
|
+
"confirmedRead": "已确认读取",
|
|
894
|
+
"applyRules": "应用规则",
|
|
895
|
+
"offline": "网关已断开,重新连接后可修改规则或更新目录。",
|
|
896
|
+
"enableSelected": "启用所选",
|
|
897
|
+
"state": "状态",
|
|
898
|
+
"ruleEnabled": "已启用",
|
|
899
|
+
"ruleDisabled": "未启用",
|
|
900
|
+
"disableSelected": "禁用所选"
|
|
901
|
+
},
|
|
902
|
+
permissions: { "systemRules": "系统沙箱规则" }
|
|
903
|
+
};
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region ui-src/index.tsx
|
|
906
|
+
function flatten(value, prefix = "") {
|
|
907
|
+
return Object.fromEntries(Object.entries(value).flatMap(([key, entry]) => typeof entry === "string" ? [[prefix + key, entry]] : Object.entries(flatten(entry, `${prefix}${key}.`))));
|
|
908
|
+
}
|
|
909
|
+
/** Browser runtime version. */
|
|
910
|
+
var runtimeVersion = 5;
|
|
911
|
+
/** Owner-provided preset management surface. */
|
|
912
|
+
var provides = ["sandbox-preset-management"];
|
|
913
|
+
/** Publishes a settings surface with RPC callbacks bound to the preset owner. */
|
|
914
|
+
function register(ctx) {
|
|
915
|
+
configureTranslations(ctx);
|
|
916
|
+
ctx.i18n.register({
|
|
917
|
+
"en-US": flatten(en_US_default),
|
|
918
|
+
"zh-CN": flatten(zh_CN_default)
|
|
919
|
+
}, "zh-CN");
|
|
920
|
+
const api = {
|
|
921
|
+
list: () => ctx.invoke("sandboxPresetList", {}),
|
|
922
|
+
sync: (operationId) => ctx.invoke("sandboxPresetSync", { operationId }),
|
|
923
|
+
cancel: (operationId) => ctx.invoke("sandboxPresetSyncCancel", { operationId }),
|
|
924
|
+
preview: (selections) => ctx.invoke("sandboxPresetPreview", { selections }),
|
|
925
|
+
apply: (previewId) => ctx.invoke("sandboxPresetApply", { previewId }),
|
|
926
|
+
onChanged(listener) {
|
|
927
|
+
const owner = ctx.on("sandboxPresetChanged", listener);
|
|
928
|
+
let stopSandbox;
|
|
929
|
+
const bindSandbox = () => {
|
|
930
|
+
stopSandbox?.();
|
|
931
|
+
stopSandbox = ctx.services.get("sandbox-settings")?.subscribe(listener);
|
|
932
|
+
};
|
|
933
|
+
const stopAvailability = ctx.services.subscribe("sandbox-settings", () => {
|
|
934
|
+
bindSandbox();
|
|
935
|
+
listener();
|
|
936
|
+
});
|
|
937
|
+
bindSandbox();
|
|
938
|
+
return () => {
|
|
939
|
+
owner();
|
|
940
|
+
stopAvailability();
|
|
941
|
+
stopSandbox?.();
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
const acquisition = createPresetAcquisition(api, ctx);
|
|
946
|
+
ctx.services.provide("sandbox-preset-management", { component: () => /* @__PURE__ */ jsx(SandboxPresetsContent, {
|
|
947
|
+
api,
|
|
948
|
+
acquisition
|
|
949
|
+
}) });
|
|
950
|
+
}
|
|
951
|
+
//#endregion
|
|
952
|
+
export { provides, register, runtimeVersion };
|