@eum-agent/sandbox 0.0.0-stage → 1.0.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.
Files changed (4) hide show
  1. package/dist/index.js +1136 -0
  2. package/package.json +52 -3
  3. package/ui/ui.js +1273 -0
  4. package/README.md +0 -3
package/ui/ui.js ADDED
@@ -0,0 +1,1273 @@
1
+ import { ActionButton, Alert, Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, Failure, FilePicker, FormFailure, Panel, Popover, Radio, ReadFailure, RuleEditor, SecurityRuleList, Segmented, SettingsLink, Tabs, TabsContent, TabsList, TabsTrigger, Warning, failureText, useBrowserService, useGateway, useGatewayAction, useTranslation } from "@eum-agent/host/framework";
2
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region ui-src/api.ts
5
+ var owner;
6
+ /** Binds calls to this exact browser activation. */
7
+ function configureApi(context) {
8
+ owner = context;
9
+ }
10
+ /** Invokes one method through the contributing owner and preserves its typed result. */
11
+ function sandboxCall(method, input) {
12
+ if (!owner) return Promise.reject(/* @__PURE__ */ new Error("Sandbox browser owner is unavailable"));
13
+ return owner.invoke(method, input ?? {});
14
+ }
15
+ /** Serializes reads and discards answers invalidated while in flight. */
16
+ function useSandboxRead(method) {
17
+ const client = useGateway();
18
+ const [state, setState] = useState({
19
+ data: null,
20
+ error: null,
21
+ pending: true
22
+ });
23
+ const refresh = useRef(() => Promise.resolve());
24
+ const reload = useCallback(() => refresh.current(), []);
25
+ useEffect(() => {
26
+ let live = true, running = false, invalidated = false;
27
+ let previousConnection = client.connection.status;
28
+ const waiters = /* @__PURE__ */ new Set();
29
+ const settle = () => {
30
+ for (const waiter of waiters) waiter();
31
+ waiters.clear();
32
+ };
33
+ const read = () => {
34
+ if (!live || client.connection.status !== "online") return Promise.resolve();
35
+ const completion = new Promise((resolve) => waiters.add(resolve));
36
+ if (running) {
37
+ invalidated = true;
38
+ return completion;
39
+ }
40
+ running = true;
41
+ setState((previous) => ({
42
+ ...previous,
43
+ pending: true
44
+ }));
45
+ (async () => {
46
+ try {
47
+ do {
48
+ invalidated = false;
49
+ try {
50
+ const data = await sandboxCall(method);
51
+ if (live && !invalidated) setState({
52
+ data,
53
+ error: null,
54
+ pending: false
55
+ });
56
+ } catch (error) {
57
+ if (live && !invalidated) setState((previous) => ({
58
+ ...previous,
59
+ error: failureText(error, () => ""),
60
+ pending: false
61
+ }));
62
+ }
63
+ } while (live && invalidated && client.connection.status === "online");
64
+ } finally {
65
+ running = false;
66
+ settle();
67
+ }
68
+ })();
69
+ return completion;
70
+ };
71
+ refresh.current = read;
72
+ read();
73
+ const off = client.subscribe((frame) => {
74
+ if (frame.kind === "plugin._eum_agent_sandbox.sandboxChanged" || frame.kind === "config.accessChanged") read();
75
+ });
76
+ const offConnection = client.watchConnection((connection) => {
77
+ if (connection.status === "online") {
78
+ if (previousConnection !== "online") read();
79
+ } else {
80
+ invalidated = true;
81
+ settle();
82
+ setState({
83
+ data: null,
84
+ error: null,
85
+ pending: false
86
+ });
87
+ }
88
+ previousConnection = connection.status;
89
+ });
90
+ return () => {
91
+ live = false;
92
+ settle();
93
+ off();
94
+ offConnection();
95
+ refresh.current = () => Promise.resolve();
96
+ };
97
+ }, [client, method]);
98
+ return {
99
+ ...state,
100
+ reload
101
+ };
102
+ }
103
+ //#endregion
104
+ //#region ui-src/i18n.ts
105
+ /** Platform browser strings share the host's language and React translation runtime. */
106
+ var translations;
107
+ /** Binds this activation's registered namespace without reconstructing the owner's namespace. */
108
+ function configureTranslations(ctx) {
109
+ translations = ctx.i18n;
110
+ }
111
+ /** Observes the shared language while resolving platform-owned copy. */
112
+ function useTranslation$1() {
113
+ const shared = useTranslation();
114
+ if (!translations) throw new Error("platform browser translations are not registered");
115
+ return {
116
+ ...shared,
117
+ t: translations.t
118
+ };
119
+ }
120
+ //#endregion
121
+ //#region ui-src/store/security-view.ts
122
+ var STORAGE_KEY = "yaoguang.security.viewMode";
123
+ /** Reads a valid local choice; missing, invalid or inaccessible storage defaults to simple. */
124
+ function readSecurityView() {
125
+ try {
126
+ return localStorage.getItem(STORAGE_KEY) === "professional" ? "professional" : "simple";
127
+ } catch {
128
+ return "simple";
129
+ }
130
+ }
131
+ /** Persists only the display choice; false means the current page must retain it in memory. */
132
+ function saveSecurityView(mode) {
133
+ try {
134
+ localStorage.setItem(STORAGE_KEY, mode);
135
+ return true;
136
+ } catch {
137
+ return false;
138
+ }
139
+ }
140
+ //#endregion
141
+ //#region ui-src/components/settings/sandbox-enabled.tsx
142
+ /** Installation-wide shell confinement, with saved values retained during writes. */
143
+ /** Writes only user-selected modes; failed or unread settings cannot be toggled. */
144
+ function SandboxEnabledPanel({ read }) {
145
+ const { t } = useTranslation$1();
146
+ const write = useGatewayAction();
147
+ async function save(value) {
148
+ if (!read.data || read.error || write.pending) return;
149
+ await write.run(() => sandboxCall("setEnabled", { enabled: value === "local" }));
150
+ read.reload();
151
+ }
152
+ return /* @__PURE__ */ jsxs("div", {
153
+ className: "flex min-w-0 flex-col gap-3",
154
+ children: [
155
+ /* @__PURE__ */ jsx(Panel, {
156
+ title: t("authorization.sandboxIsolation"),
157
+ hint: t("authorization.sandboxScope"),
158
+ inline: true,
159
+ children: /* @__PURE__ */ jsx("div", {
160
+ className: "flex min-w-0 justify-end",
161
+ "aria-busy": write.pending || void 0,
162
+ children: read.data ? /* @__PURE__ */ jsx(Segmented, {
163
+ label: t("authorization.sandboxIsolation"),
164
+ value: read.data.enabled ? "local" : "off",
165
+ options: [{
166
+ value: "off",
167
+ label: t("authorization.sandboxOff")
168
+ }, {
169
+ value: "local",
170
+ label: t("authorization.sandboxLocal")
171
+ }],
172
+ disabled: write.pending || read.error !== null,
173
+ onSelect: (value) => {
174
+ save(value);
175
+ }
176
+ }) : !read.error && /* @__PURE__ */ jsx("p", {
177
+ className: "text-sm text-muted-foreground",
178
+ children: t("authorization.sandboxLoading")
179
+ })
180
+ })
181
+ }),
182
+ read.data?.enabled === false && /* @__PURE__ */ jsx("p", {
183
+ className: "text-xs text-muted-foreground",
184
+ children: t("authorization.sandboxInactiveRules")
185
+ }),
186
+ /* @__PURE__ */ jsx(Failure, { reason: write.error })
187
+ ]
188
+ });
189
+ }
190
+ //#endregion
191
+ //#region ui-src/components/settings/sandbox-network.tsx
192
+ /** Independent sandbox network policies managed by the installation's configuration service. */
193
+ var POLICIES = [
194
+ "ask",
195
+ "deny",
196
+ "allow"
197
+ ];
198
+ /** Keeps saved values visible while writes are pending or fail; policy Allow creates no approval record. */
199
+ function NetworkPoliciesPanel() {
200
+ const { t } = useTranslation$1();
201
+ const read = useSandboxRead("getNetworkPolicies");
202
+ const write = useGatewayAction();
203
+ async function save(capability, policy) {
204
+ if (!read.data || write.pending) return;
205
+ if ((await write.run(() => sandboxCall("setNetworkPolicies", {
206
+ ...read.data.policies,
207
+ [capability]: policy
208
+ }))).ok) read.reload();
209
+ }
210
+ return /* @__PURE__ */ jsxs(Panel, {
211
+ title: t("authorization.networkPolicies"),
212
+ hint: t("authorization.networkPoliciesHint"),
213
+ children: [
214
+ /* @__PURE__ */ jsx(Warning, { children: /* @__PURE__ */ jsxs("div", {
215
+ className: "flex flex-col gap-1",
216
+ children: [/* @__PURE__ */ jsx("p", { children: t("authorization.externalWarning") }), /* @__PURE__ */ jsx("p", { children: t("authorization.listenWarning") })]
217
+ }) }),
218
+ /* @__PURE__ */ jsx(ReadFailure, {
219
+ reason: read.error,
220
+ pending: read.pending && read.data === null,
221
+ onRetry: read.reload
222
+ }),
223
+ [
224
+ "external",
225
+ "connect",
226
+ "listen"
227
+ ].map((capability) => /* @__PURE__ */ jsx(Panel, {
228
+ title: t(`authorization.${capability}`),
229
+ hint: t(`authorization.${capability}Hint`),
230
+ level: "field",
231
+ inline: true,
232
+ children: read.data && /* @__PURE__ */ jsx("div", {
233
+ className: "flex min-w-0 justify-end",
234
+ children: /* @__PURE__ */ jsx(Segmented, {
235
+ label: t(`authorization.${capability}`),
236
+ value: read.data.policies[capability],
237
+ options: POLICIES.map((value) => ({
238
+ value,
239
+ label: t(`permissions.${value}`)
240
+ })),
241
+ disabled: write.pending,
242
+ onSelect: (value) => {
243
+ save(capability, value);
244
+ }
245
+ })
246
+ })
247
+ }, capability)),
248
+ /* @__PURE__ */ jsx("p", {
249
+ className: "text-xs text-muted-foreground",
250
+ children: t("authorization.protectedPorts", { ports: read.data?.protectedLocalPorts.join(", ") || "—" })
251
+ }),
252
+ /* @__PURE__ */ jsx(Failure, { reason: write.error })
253
+ ]
254
+ });
255
+ }
256
+ //#endregion
257
+ //#region ui-src/components/settings/security-presets.tsx
258
+ /** Platform-owned presets over the installation's actual security configuration. */
259
+ /** The three presentation presets; runtime decisions use their actual policy values. */
260
+ var SECURITY_PRESETS = [
261
+ "default",
262
+ "automatic",
263
+ "dangerous"
264
+ ];
265
+ /** Builds a complete policy bundle without changing grants or readable paths. */
266
+ function configurationFor(preset) {
267
+ const policy = preset === "default" ? "ask" : "allow";
268
+ return {
269
+ approvalPolicy: policy,
270
+ sandboxEnabled: preset !== "dangerous",
271
+ networkPolicies: {
272
+ external: policy,
273
+ connect: policy,
274
+ listen: policy
275
+ }
276
+ };
277
+ }
278
+ /** Matches all five actual values exactly; custom combinations have no selected preset. */
279
+ function presetOf(state) {
280
+ return SECURITY_PRESETS.find((preset) => {
281
+ const expected = configurationFor(preset);
282
+ return state.approvalPolicy === expected.approvalPolicy && state.sandboxEnabled === expected.sandboxEnabled && state.networkPolicies.external === expected.networkPolicies.external && state.networkPolicies.connect === expected.networkPolicies.connect && state.networkPolicies.listen === expected.networkPolicies.listen;
283
+ }) ?? null;
284
+ }
285
+ /** Shows only presets and their explanations; detailed policy controls are mounted elsewhere. */
286
+ function SecurityPresets({ state, saving, reading, readError, error, onRetry, onSelect }) {
287
+ const { t } = useTranslation$1();
288
+ const group = useId();
289
+ const selected = state?.status === "ready" ? presetOf(state) : null;
290
+ return /* @__PURE__ */ jsxs("div", {
291
+ className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pr-2",
292
+ children: [
293
+ /* @__PURE__ */ jsx("div", {
294
+ role: "radiogroup",
295
+ "aria-busy": saving || void 0,
296
+ "aria-label": t("security.presets"),
297
+ className: "flex shrink-0 flex-col gap-3",
298
+ children: SECURITY_PRESETS.map((preset) => /* @__PURE__ */ jsxs("label", {
299
+ className: ["relative flex min-w-0 cursor-pointer flex-col gap-3 rounded-surface border p-4 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring", preset === "dangerous" ? "border-destructive/30 bg-destructive/5 has-[:checked]:border-destructive" : "surface border-border has-[:checked]:border-primary"].join(" "),
300
+ children: [/* @__PURE__ */ jsxs("span", {
301
+ className: "flex min-w-0 items-center gap-3",
302
+ children: [/* @__PURE__ */ jsx(Radio, {
303
+ name: group,
304
+ value: preset,
305
+ "aria-label": t(`security.${preset}`),
306
+ "aria-describedby": `${group}-${preset}-hint`,
307
+ checked: selected === preset,
308
+ disabled: saving || reading || readError !== null || state?.status !== "ready",
309
+ onChange: () => {
310
+ onSelect(configurationFor(preset));
311
+ },
312
+ className: preset === "dangerous" ? "shrink-0 [--primary:var(--destructive)]" : "shrink-0"
313
+ }), /* @__PURE__ */ jsx("span", {
314
+ className: preset === "dangerous" ? "text-sm font-medium text-destructive" : "text-sm font-medium",
315
+ children: t(`security.${preset}`)
316
+ })]
317
+ }), /* @__PURE__ */ jsxs("ul", {
318
+ id: `${group}-${preset}-hint`,
319
+ className: "ml-4 flex list-disc flex-col gap-2 text-xs leading-relaxed text-muted-foreground",
320
+ children: [/* @__PURE__ */ jsx("li", { children: t(`security.${preset}Behavior`) }), /* @__PURE__ */ jsx("li", { children: t(`security.${preset}Protection`) })]
321
+ })]
322
+ }, preset))
323
+ }),
324
+ state?.status === "ready" && selected === null && /* @__PURE__ */ jsx("p", {
325
+ className: "text-xs leading-relaxed text-muted-foreground",
326
+ children: t("security.custom")
327
+ }),
328
+ state?.status === "recovery-required" && /* @__PURE__ */ jsx("p", {
329
+ className: "text-xs leading-relaxed text-muted-foreground",
330
+ children: t("security.recoveryFailure")
331
+ }),
332
+ reading && state === null && /* @__PURE__ */ jsx("p", {
333
+ role: "status",
334
+ className: "text-xs text-muted-foreground",
335
+ children: t("security.loading")
336
+ }),
337
+ /* @__PURE__ */ jsx(FormFailure, { reason: error }),
338
+ readError && state?.status !== "recovery-required" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
339
+ variant: "outline",
340
+ onClick: () => {
341
+ onRetry();
342
+ },
343
+ children: t("security.retry")
344
+ }) })
345
+ ]
346
+ });
347
+ }
348
+ //#endregion
349
+ //#region ui-src/components/settings/sandbox-status.tsx
350
+ /** Live effective isolation facts, separate from the saved preference. */
351
+ /** Rechecks backend capability while mounted and after configuration or window focus changes. */
352
+ function useSandboxStatus() {
353
+ const client = useGateway();
354
+ const read = useSandboxRead("getEnabled");
355
+ useEffect(() => {
356
+ const off = client.subscribe((frame) => {
357
+ if (frame.kind === "plugin._eum_agent_sandbox.sandboxChanged" || frame.kind === "plugin._eum_agent_authorization_policy.approvalChanged") read.reload();
358
+ });
359
+ window.addEventListener("focus", read.reload);
360
+ const timer = window.setInterval(read.reload, 1e4);
361
+ return () => {
362
+ off();
363
+ window.removeEventListener("focus", read.reload);
364
+ window.clearInterval(timer);
365
+ };
366
+ }, [client, read.reload]);
367
+ return read;
368
+ }
369
+ /** Shows a safety notice only when isolation is inactive or its status cannot be read. */
370
+ function SandboxStatusPanel({ read, security }) {
371
+ const { t } = useTranslation$1();
372
+ const status = read.error ? null : read.data;
373
+ if (!read.error && status?.mode !== "direct") return null;
374
+ return /* @__PURE__ */ jsxs("div", {
375
+ className: "flex shrink-0 flex-col gap-2",
376
+ "aria-live": "polite",
377
+ children: [/* @__PURE__ */ jsx(ReadFailure, {
378
+ reason: read.error,
379
+ pending: read.pending && read.data === null,
380
+ onRetry: read.reload
381
+ }), status?.mode === "direct" && /* @__PURE__ */ jsxs(Alert, {
382
+ tone: "destructive",
383
+ variant: "soft",
384
+ role: "alert",
385
+ title: t("security.isolationInactive"),
386
+ className: "text-xs",
387
+ children: [/* @__PURE__ */ jsx("p", { children: status.enabled && !status.availability.ok ? t("security.unavailableReason", { reason: status.availability.reason }) : t(security?.status === "ready" && presetOf(security) === "dangerous" ? "security.dangerousReason" : "security.explicitlyDisabled") }), /* @__PURE__ */ jsx("p", { children: t("security.directIsolationWarning") })]
388
+ })]
389
+ });
390
+ }
391
+ //#endregion
392
+ //#region ui-src/components/settings/security-state.ts
393
+ /** Holds committed values while a replacement is being persisted. */
394
+ function useSecurityState() {
395
+ const client = useGateway();
396
+ const [state, setState] = useState(null);
397
+ const [saving, setSaving] = useState(false);
398
+ const [writeError, setWriteError] = useState(null);
399
+ const [readError, setReadError] = useState(null);
400
+ const [reading, setReading] = useState(true);
401
+ const mounted = useRef(false);
402
+ const generation = useRef(0);
403
+ const pending = useRef(false);
404
+ const invalidated = useRef(false);
405
+ const reload = useCallback(async () => {
406
+ const request = ++generation.current;
407
+ setReading(true);
408
+ setReadError(null);
409
+ try {
410
+ const value = await sandboxCall("securityGet");
411
+ if (request === generation.current) setState(value);
412
+ } catch (failure) {
413
+ if (request === generation.current) setReadError(failureText(failure, () => ""));
414
+ } finally {
415
+ if (request === generation.current) setReading(false);
416
+ }
417
+ }, [client]);
418
+ useEffect(() => {
419
+ mounted.current = true;
420
+ let previous = client.connection.status;
421
+ if (previous === "online") reload();
422
+ else {
423
+ setReading(false);
424
+ setReadError(null);
425
+ }
426
+ const offConnection = client.watchConnection((connection) => {
427
+ if (connection.status !== "online") {
428
+ generation.current++;
429
+ setState(null);
430
+ setReading(false);
431
+ setReadError(null);
432
+ setWriteError(null);
433
+ } else if (previous !== "online") reload();
434
+ previous = connection.status;
435
+ });
436
+ const off = client.subscribe((frame) => {
437
+ if (frame.kind !== "plugin._eum_agent_sandbox.sandboxChanged" && frame.kind !== "plugin._eum_agent_authorization_policy.approvalChanged") return;
438
+ if (pending.current) invalidated.current = true;
439
+ else reload();
440
+ });
441
+ return () => {
442
+ mounted.current = false;
443
+ generation.current++;
444
+ off();
445
+ offConnection();
446
+ };
447
+ }, [client, reload]);
448
+ async function save(configuration) {
449
+ if (pending.current || reading || readError || state?.status !== "ready") return;
450
+ pending.current = true;
451
+ const request = ++generation.current;
452
+ setSaving(true);
453
+ setWriteError(null);
454
+ try {
455
+ const value = await sandboxCall("securitySet", configuration);
456
+ if (request === generation.current) setState(value);
457
+ } catch (failure) {
458
+ if (request === generation.current) setWriteError(failureText(failure, () => ""));
459
+ invalidated.current = true;
460
+ } finally {
461
+ pending.current = false;
462
+ if (mounted.current) {
463
+ setSaving(false);
464
+ if (invalidated.current) {
465
+ invalidated.current = false;
466
+ reload();
467
+ }
468
+ }
469
+ }
470
+ }
471
+ return {
472
+ state,
473
+ saving,
474
+ reading,
475
+ readError,
476
+ error: state?.status === "recovery-required" ? state.error : writeError ?? readError,
477
+ reload,
478
+ save
479
+ };
480
+ }
481
+ //#endregion
482
+ //#region ui-src/components/settings/system-rules.tsx
483
+ /** Renders the preset owner's management surface when its optional capability exists. */
484
+ function SystemRules() {
485
+ const service = useBrowserService("sandbox-preset-management");
486
+ return service ? /* @__PURE__ */ jsx(service.component, {}) : null;
487
+ }
488
+ //#endregion
489
+ //#region ui-src/components/settings/permissions.tsx
490
+ /** Approval policy, sandbox rules, and grants managed through the gateway. */
491
+ /** Adds selected readable paths in order, retaining failed and unattempted items for retry. */
492
+ function AddReadablePathDialog({ open, onOpenChange }) {
493
+ const { t } = useTranslation$1();
494
+ const add = useGatewayAction();
495
+ const [paths, setPaths] = useState([]);
496
+ useEffect(() => {
497
+ if (!open) setPaths([]);
498
+ }, [open]);
499
+ async function submit() {
500
+ if (add.pending || paths.length === 0) return;
501
+ if ((await add.run(async () => {
502
+ for (const path of paths) {
503
+ await sandboxCall("addReadablePath", { path });
504
+ setPaths((remaining) => remaining.filter((entry) => entry !== path));
505
+ }
506
+ })).ok) onOpenChange(false);
507
+ }
508
+ return /* @__PURE__ */ jsx(Dialog, {
509
+ open,
510
+ onOpenChange: (next) => {
511
+ if (!add.pending) onOpenChange(next);
512
+ },
513
+ children: /* @__PURE__ */ jsxs(DialogContent, {
514
+ closeLabel: t("settings.close"),
515
+ overlayProps: {
516
+ forceRender: true,
517
+ className: "file-picker-backdrop"
518
+ },
519
+ className: "file-picker-dialog max-w-3xl grid-rows-[auto_minmax(0,1fr)] gap-5 p-6 sm:max-w-3xl",
520
+ children: [/* @__PURE__ */ jsxs(DialogHeader, {
521
+ className: "pr-8",
522
+ children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("permissions.readableAdd") }), /* @__PURE__ */ jsx(DialogDescription, { children: t("permissions.readableWarning") })]
523
+ }), /* @__PURE__ */ jsxs("form", {
524
+ onSubmit: (event) => {
525
+ event.preventDefault();
526
+ submit();
527
+ },
528
+ className: "flex min-h-0 flex-1 flex-col gap-3",
529
+ children: [/* @__PURE__ */ jsx("fieldset", {
530
+ disabled: add.pending,
531
+ inert: add.pending,
532
+ className: "flex min-h-0 min-w-0 flex-1 flex-col",
533
+ children: /* @__PURE__ */ jsx(FilePicker, {
534
+ mode: "any",
535
+ multiple: true,
536
+ value: paths,
537
+ onChange: setPaths
538
+ })
539
+ }), /* @__PURE__ */ jsxs("div", {
540
+ className: "mt-auto flex items-center justify-end gap-2",
541
+ children: [/* @__PURE__ */ jsx(ActionButton, {
542
+ type: "submit",
543
+ label: t("common.add"),
544
+ pending: add.pending,
545
+ disabled: paths.length === 0
546
+ }), /* @__PURE__ */ jsx(FormFailure, { reason: add.error })]
547
+ })]
548
+ })]
549
+ })
550
+ });
551
+ }
552
+ /** Summarizes system and custom rules; details live in a dedicated editor. */
553
+ function ReadablePathsList() {
554
+ const { t } = useTranslation$1();
555
+ const presetManagement = useBrowserService("sandbox-preset-management");
556
+ const list = useSandboxRead("listReadablePaths");
557
+ const [editing, setEditing] = useState(null);
558
+ const [adding, setAdding] = useState(false);
559
+ const custom = list.data?.readable ?? [];
560
+ return /* @__PURE__ */ jsxs("div", {
561
+ className: "flex min-w-0 flex-col gap-6",
562
+ children: [
563
+ /* @__PURE__ */ jsx(ReadFailure, {
564
+ reason: list.error,
565
+ pending: list.pending && list.data === null,
566
+ onRetry: list.reload
567
+ }),
568
+ /* @__PURE__ */ jsx(SettingsLink, {
569
+ label: t("permissions.systemRules"),
570
+ help: t("permissions.systemRulesHint"),
571
+ summary: t("permissions.systemRulesManage"),
572
+ disabled: !presetManagement,
573
+ onClick: () => setEditing("system")
574
+ }),
575
+ /* @__PURE__ */ jsx(SettingsLink, {
576
+ label: t("permissions.customRules"),
577
+ help: t("permissions.customRulesHint"),
578
+ summary: list.data === null ? "—" : t("permissions.ruleCount", { count: custom.length }),
579
+ disabled: list.data === null,
580
+ onClick: () => setEditing("custom")
581
+ }),
582
+ /* @__PURE__ */ jsxs(RuleEditor, {
583
+ fill: true,
584
+ open: editing !== null,
585
+ onOpenChange: (open) => {
586
+ if (!open) setEditing(null);
587
+ },
588
+ title: t(editing === "system" ? "permissions.systemRules" : "permissions.customRules"),
589
+ children: [/* @__PURE__ */ jsx(ReadFailure, {
590
+ reason: list.error,
591
+ pending: list.pending && list.data === null,
592
+ onRetry: list.reload
593
+ }), editing === "system" ? presetManagement ? /* @__PURE__ */ jsx(SystemRules, {}) : null : /* @__PURE__ */ jsx(SecurityRuleList, {
594
+ fill: true,
595
+ items: custom,
596
+ loading: list.pending,
597
+ keyOf: (path) => path,
598
+ labelOf: (path) => path,
599
+ searchOf: (path) => path,
600
+ reload: list.reload,
601
+ empty: t("permissions.noCustomRules"),
602
+ removalHint: t("securityRules.removalHint"),
603
+ onRemove: (_client, path) => sandboxCall("removeReadablePath", { path }),
604
+ tools: /* @__PURE__ */ jsx(ActionButton, {
605
+ label: t("permissions.readableAdd"),
606
+ onClick: () => setAdding(true)
607
+ }),
608
+ columns: [{
609
+ id: "path",
610
+ label: t("securityRules.path"),
611
+ render: (path) => /* @__PURE__ */ jsx("div", {
612
+ className: "w-64 max-w-80 @3xl:w-80",
613
+ children: /* @__PURE__ */ jsx(Popover, {
614
+ label: t("securityRules.path"),
615
+ width: 480,
616
+ trigger: /* @__PURE__ */ jsx(Button, {
617
+ variant: "plain",
618
+ className: "w-full truncate rounded-control text-left font-mono text-xs hover:text-primary focus-visible:outline-2 focus-visible:outline-ring",
619
+ children: path
620
+ }),
621
+ children: /* @__PURE__ */ jsx("p", {
622
+ className: "whitespace-pre-wrap break-all p-1 font-mono text-xs leading-relaxed",
623
+ children: path
624
+ })
625
+ })
626
+ })
627
+ }, {
628
+ id: "permission",
629
+ label: t("securityRules.permission"),
630
+ className: "w-32 text-xs whitespace-nowrap",
631
+ render: () => t("securityRules.read")
632
+ }]
633
+ })]
634
+ }),
635
+ /* @__PURE__ */ jsx(AddReadablePathDialog, {
636
+ open: adding,
637
+ onOpenChange: (open) => {
638
+ setAdding(open);
639
+ if (!open) list.reload();
640
+ }
641
+ })
642
+ ]
643
+ });
644
+ }
645
+ /** Retains the complete authorization and sandbox editors in professional mode. */
646
+ function ProfessionalPermissions({ sandboxStatus }) {
647
+ const { t } = useTranslation$1();
648
+ const authorization = useBrowserService("authorization-settings");
649
+ const AuthorPanel = authorization?.component;
650
+ const LocalPortsPanel = authorization?.ports;
651
+ return /* @__PURE__ */ jsxs(Tabs, {
652
+ defaultValue: authorization ? "agent" : "sandbox",
653
+ className: "-mx-3 min-h-0 flex-1 overflow-hidden",
654
+ children: [
655
+ /* @__PURE__ */ jsxs(TabsList, {
656
+ "aria-label": t("settings.permissions"),
657
+ className: "mx-3 shrink-0 flex-wrap",
658
+ children: [authorization && /* @__PURE__ */ jsx(TabsTrigger, {
659
+ value: "agent",
660
+ children: t("authorization.management")
661
+ }), /* @__PURE__ */ jsx(TabsTrigger, {
662
+ value: "sandbox",
663
+ children: t("authorization.sandboxManagement")
664
+ })]
665
+ }),
666
+ /* @__PURE__ */ jsx(TabsContent, {
667
+ value: "agent",
668
+ className: "flex min-h-0 flex-col gap-6 overflow-x-hidden overflow-y-auto py-2 pl-3 pr-5 [scrollbar-gutter:stable] [&>*]:shrink-0",
669
+ children: AuthorPanel && /* @__PURE__ */ jsx(AuthorPanel, {})
670
+ }),
671
+ /* @__PURE__ */ jsxs(TabsContent, {
672
+ value: "sandbox",
673
+ className: "flex min-h-0 flex-col gap-6 overflow-x-hidden overflow-y-auto py-2 pl-3 pr-5 [scrollbar-gutter:stable] [&>*]:shrink-0",
674
+ children: [
675
+ /* @__PURE__ */ jsx(SandboxEnabledPanel, { read: sandboxStatus }),
676
+ /* @__PURE__ */ jsx(NetworkPoliciesPanel, {}),
677
+ /* @__PURE__ */ jsx(ReadablePathsList, {}),
678
+ LocalPortsPanel && /* @__PURE__ */ jsx(LocalPortsPanel, {})
679
+ ]
680
+ })
681
+ ]
682
+ });
683
+ }
684
+ /** Switches the whole security page while retaining one installation-wide configuration. */
685
+ function PermissionsPanel() {
686
+ const { t } = useTranslation$1();
687
+ const [mode, setMode] = useState(readSecurityView);
688
+ const authorization = useBrowserService("authorization-settings");
689
+ const [preferenceError, setPreferenceError] = useState(false);
690
+ const security = useSecurityState();
691
+ const sandboxStatus = useSandboxStatus();
692
+ return /* @__PURE__ */ jsxs("div", {
693
+ className: "flex min-h-0 flex-1 flex-col",
694
+ children: [/* @__PURE__ */ jsxs("header", {
695
+ className: "flex h-16 shrink-0 items-center justify-between gap-3 px-6 sm:pr-14",
696
+ children: [/* @__PURE__ */ jsx("h2", {
697
+ className: "shrink-0 text-lg font-semibold",
698
+ children: t("settings.permissions")
699
+ }), authorization && /* @__PURE__ */ jsx(Button, {
700
+ variant: "text",
701
+ className: "min-w-0 text-right",
702
+ onClick: () => {
703
+ const next = mode === "simple" ? "professional" : "simple";
704
+ setMode(next);
705
+ setPreferenceError(!saveSecurityView(next));
706
+ },
707
+ disabled: security.saving,
708
+ children: t(mode === "simple" ? "security.switchProfessional" : "security.switchSimple")
709
+ })]
710
+ }), /* @__PURE__ */ jsxs("div", {
711
+ className: "@container flex min-h-0 flex-1 flex-col gap-4 px-6 pb-6 pt-1",
712
+ children: [
713
+ /* @__PURE__ */ jsx(FormFailure, { reason: preferenceError ? t("security.preferenceFailure") : null }),
714
+ mode === "simple" && authorization ? /* @__PURE__ */ jsx("div", {
715
+ className: "flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto",
716
+ children: /* @__PURE__ */ jsx(SecurityPresets, {
717
+ state: security.state,
718
+ saving: security.saving,
719
+ reading: security.reading,
720
+ readError: security.readError,
721
+ error: security.error,
722
+ onRetry: security.reload,
723
+ onSelect: security.save
724
+ })
725
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormFailure, { reason: security.error }), security.state?.status === "recovery-required" ? /* @__PURE__ */ jsx("p", {
726
+ className: "text-xs leading-relaxed text-muted-foreground",
727
+ children: t("security.recoveryFailure")
728
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [security.readError && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
729
+ variant: "outline",
730
+ onClick: () => {
731
+ security.reload();
732
+ },
733
+ children: t("security.retry")
734
+ }) }), /* @__PURE__ */ jsx("fieldset", {
735
+ disabled: security.reading || security.readError !== null || security.state?.status !== "ready",
736
+ className: "m-0 flex min-h-0 min-w-0 flex-1 flex-col border-0 p-0",
737
+ children: /* @__PURE__ */ jsx(ProfessionalPermissions, { sandboxStatus })
738
+ })] })] }),
739
+ /* @__PURE__ */ jsx(SandboxStatusPanel, {
740
+ read: sandboxStatus,
741
+ security: security.state
742
+ })
743
+ ]
744
+ })]
745
+ });
746
+ }
747
+ var en_US_default = {
748
+ network: {
749
+ "title": "Network",
750
+ "proxySettings": "Proxy settings",
751
+ "mode": "Proxy mode",
752
+ "system": "System proxy",
753
+ "manual": "Manual",
754
+ "direct": "Direct",
755
+ "environment": "Environment variables",
756
+ "url": "Proxy URL",
757
+ "noProxy": "Bypass proxy (comma-separated)",
758
+ "effective": "In effect",
759
+ "bypass": "Bypass",
760
+ "source": "Source",
761
+ "directValue": "Direct",
762
+ "bypassDetails": "Proxy bypass addresses",
763
+ "notLoaded": "No configuration available",
764
+ "unavailable": "Proxy configuration unavailable",
765
+ "addressRequired": "Enter a proxy URL.",
766
+ "support": "HTTP/HTTPS proxies without authentication are supported.",
767
+ "applying": "Updating…",
768
+ "refresh": "Refresh"
769
+ },
770
+ permissions: {
771
+ "approvalField": "Default authorization policy",
772
+ "systemRules": "System sandbox rules",
773
+ "systemRulesHint": "Select rows to enable or disable rules in bulk; click a rule count to inspect paths.",
774
+ "customRules": "Custom sandbox rules",
775
+ "customRulesHint": "Add files or directories that commands may read, including directory contents.",
776
+ "systemRule": "System",
777
+ "customRule": "Custom",
778
+ "ruleCount": "{{count}} rules",
779
+ "ruleCount_one": "{{count}} rule",
780
+ "enabledCount": "{{count}} enabled",
781
+ "enabled": "Enabled",
782
+ "disabled": "Disabled",
783
+ "noCustomRules": "No custom rules.",
784
+ "approval": "Authorization mode",
785
+ "approvalHint": "Choose how to handle file access, website access and commands without an existing permission.",
786
+ "ask": "Ask",
787
+ "deny": "Deny by default",
788
+ "allow": "Allow by default",
789
+ "allowWarning": "File access, website access and commands will be approved automatically. Set sandbox network permissions separately. Protected resources remain blocked.",
790
+ "readable": "Sandbox access",
791
+ "readableHint": "Choose additional files and directories that commands may read.",
792
+ "sandbox": "Sandbox",
793
+ "localPorts": "Allowed local ports",
794
+ "localPortsHint": "Allow all agents to connect to specified local TCP ports. Listening requires separate permission.",
795
+ "localPortsTrust": "Authorize only trusted local services; they may access the network or perform operations on your behalf.",
796
+ "localPortsEmpty": "No local ports allowed",
797
+ "localPortInvalid": "Enter an integer port from 1 to 65535",
798
+ "localPortProtected": "Gateway port; not active",
799
+ "localPortDuplicate": "This port is already listed",
800
+ "localPortAdd": "Add local port",
801
+ "localPortNumber": "TCP port",
802
+ "localPortsRemoval": "New commands will no longer connect to this port. Stop running commands to remove their existing permissions.",
803
+ "localPortsProcesses": "View running processes",
804
+ "localPortStop": "Stop",
805
+ "localPortsNoProcesses": "No running processes",
806
+ "readableAdd": "Add readable path",
807
+ "readableRemove": "Remove",
808
+ "readablePlaceholder": "Absolute path",
809
+ "readableWarning": "Commands may read the selected files or directories, including directory contents.",
810
+ "systemRulesManage": "Manage installed templates and read rules"
811
+ },
812
+ common: {
813
+ "increase": "Increase",
814
+ "decrease": "Decrease",
815
+ "back": "Back",
816
+ "edit": "Edit",
817
+ "save": "Save",
818
+ "create": "Create",
819
+ "add": "Add",
820
+ "remove": "Remove",
821
+ "cancel": "Cancel",
822
+ "confirm": "Confirm",
823
+ "dismiss": "Got it",
824
+ "retry": "Retry",
825
+ "working": "Working…"
826
+ },
827
+ settings: {
828
+ "close": "Close",
829
+ "personalization": "Personalization",
830
+ "runLayoutCombined": "Continuous outputs",
831
+ "runLayoutSegmented": "Separate replies",
832
+ "colorMode": "Color scheme",
833
+ "systemMode": "System",
834
+ "lightMode": "Light",
835
+ "darkMode": "Dark",
836
+ "brand": "Theme colour",
837
+ "contentWidth": "Content width",
838
+ "contentWidthDefault": "Default",
839
+ "contentWidthWide": "Wide",
840
+ "contentWidthFull": "Full",
841
+ "runLayout": "Reply layout",
842
+ "interfaceLanguage": "Interface language",
843
+ "permissions": "Security"
844
+ },
845
+ authorization: {
846
+ "sandboxIsolation": "Sandbox isolation",
847
+ "sandboxLocal": "Local sandbox",
848
+ "sandboxOff": "Off",
849
+ "sandboxLoading": "Reading sandbox isolation…",
850
+ "sandboxSaving": "Saving…",
851
+ "sandboxScope": "Prefer local sandbox isolation when available; otherwise commands use host permissions. Applies to all agents and workspaces, and only to newly started commands.",
852
+ "sandboxInactiveRules": "The rules below take effect when the local sandbox is restored. Access approvals for other tools are unaffected.",
853
+ "management": "Authorization management",
854
+ "sandboxManagement": "Sandbox management",
855
+ "website": "Public website access permissions",
856
+ "port": "Local port permissions",
857
+ "command": "Command permissions",
858
+ "records": "Authorization records",
859
+ "websiteHint": "Allow access to specified websites and ports for all agents.",
860
+ "portHint": "Allow all agents to connect to local services or listen on specified ports.",
861
+ "commandAccessHint": "Allow all agents to run specified commands in a specified directory.",
862
+ "globalHint": "Permissions apply to all agents. One-time approvals are not listed here.",
863
+ "recordsHint": "View and revoke existing permissions. One-time approvals are not listed here.",
864
+ "addwebsite": "Add public website access permission",
865
+ "addport": "Add local port permission",
866
+ "addcommand": "Add command permission",
867
+ "argv": "Exact executable arguments (JSON array)",
868
+ "cwd": "Working directory (absolute path)",
869
+ "commandHint": "Enter the full execution arguments and working directory. Changes require a new permission. Authorize file and network access separately.",
870
+ "commandInvalid": "Enter a nonempty string array and an absolute working directory.",
871
+ "hostInvalid": "Enter a host or *.domain and a specific TCP port.",
872
+ "host": "Host or domain pattern",
873
+ "operation": "Permission type",
874
+ "both": "Both",
875
+ "listenWarning": "Bind local-only services to 127.0.0.1 or ::1.",
876
+ "removalHint": "Revocation affects later operations. Stop running commands to remove their existing permissions.",
877
+ "scope": "Scope",
878
+ "global": "Global",
879
+ "source": "Source",
880
+ "manual": "Manual",
881
+ "approval": "Approved",
882
+ "state": "State",
883
+ "effective": "Active",
884
+ "inactive": "Blocked by policy or fixed restrictions",
885
+ "networkPolicies": "Network access settings",
886
+ "networkPoliciesHint": "Set public access, local connections and listening separately. Deny by default overrides existing permissions.",
887
+ "external": "Public network access",
888
+ "connect": "Local port connections",
889
+ "listen": "Local port listening",
890
+ "externalHint": "Control whether commands can access the internet.",
891
+ "connectHint": "Control whether commands can connect to local services.",
892
+ "listenHint": "Control whether commands can start services that other programs can connect to.",
893
+ "externalWarning": "Use Ask for public network access; Allow permits all external addresses.",
894
+ "protectedPorts": "Commands cannot access the YaoGuang service ports ({{ports}}).",
895
+ "kind": {
896
+ "file": "File",
897
+ "host": "Host",
898
+ "command": "Command",
899
+ "sandbox-network": "Sandbox external network",
900
+ "business-approval": "Business approval"
901
+ }
902
+ },
903
+ securityRules: {
904
+ "processes": "Running processes",
905
+ "triggerDuration": "While the task exists",
906
+ "search": "Search rules",
907
+ "bulkRemove": "Remove selected",
908
+ "bulkRevoke": "Revoke selected",
909
+ "clearSelection": "Clear selection",
910
+ "selectPage": "Select all rules on this page",
911
+ "selectRow": "Select {{label}}",
912
+ "noMatches": "No matching rules",
913
+ "pagination": "Rule pagination",
914
+ "previous": "Previous page",
915
+ "next": "Next page",
916
+ "pageSize": "Rows per page",
917
+ "perPage": "{{count}} per page",
918
+ "perPage_one": "{{count}} per page",
919
+ "confirmTitle": "{{verb}} {{count}} selected permissions?",
920
+ "confirmTitle_one": "{{verb}} {{count}} selected permission?",
921
+ "confirmRemove": "Confirm removal",
922
+ "confirmRevoke": "Confirm revocation",
923
+ "scope": "Scope",
924
+ "path": "Readable path",
925
+ "port": "Connection port",
926
+ "permission": "Permission",
927
+ "read": "Read allowed",
928
+ "connect": "Connection allowed",
929
+ "hostDuplicate": "This host rule is already listed",
930
+ "hostPreview": "Will allow {{host}}",
931
+ "removalHint": "Removes read permission for this path. Stop running commands to remove their existing permissions.",
932
+ "hostRemovalHint": "Removes access permission for this website.",
933
+ "kind": "Permission type",
934
+ "duration": "Duration",
935
+ "target": "Target",
936
+ "time": "Granted at",
937
+ "everyWorkspace": "Every workspace",
938
+ "category": "Rule category",
939
+ "bulkEnable": "Enable selected",
940
+ "bulkDisable": "Disable selected",
941
+ "enable": "Enable",
942
+ "disable": "Disable",
943
+ "systemSearch": "Search category or path",
944
+ "statusFilter": "Enabled status",
945
+ "filterAll": "All",
946
+ "filterEnabled": "Enabled",
947
+ "filterDisabled": "Disabled",
948
+ "matching": "{{count}} matching rules",
949
+ "matching_one": "{{count}} matching rule",
950
+ "expandAll": "Expand all",
951
+ "collapseAll": "Collapse all",
952
+ "expandGroup": "Expand {{name}}",
953
+ "collapseGroup": "Collapse {{name}}",
954
+ "selectWholeGroup": "Change all {{count}} rules in this group, including filtered rules",
955
+ "selectWholeGroup_one": "Change the {{count}} rule in this group, including filtered rules",
956
+ "system": "System environment",
957
+ "systemHint": "System commands, libraries, and runtime resources",
958
+ "devTools": "Development tools · DevTools",
959
+ "devToolsHint": "Package managers, toolchains, and dependency caches",
960
+ "applications": "Installed applications and tools",
961
+ "applicationsHint": "Homebrew and Xcode",
962
+ "other": "Other system rules",
963
+ "otherHint": "System paths outside the scenarios above",
964
+ "groupEnable": "Enable {{name}}",
965
+ "groupCount": "{{enabled}} / {{count}} enabled",
966
+ "groupCount_one": "{{enabled}} / {{count}} enabled",
967
+ "portSuggestions": "Example ports",
968
+ "load": "Reading configuration…"
969
+ },
970
+ security: {
971
+ "switchProfessional": "Switch to professional mode",
972
+ "switchSimple": "Switch to simple mode",
973
+ "presets": "Security presets",
974
+ "default": "Default mode",
975
+ "automatic": "Automatic mode",
976
+ "dangerous": "Dangerous mode",
977
+ "defaultBehavior": "Ask you before actions that need extra permissions.",
978
+ "defaultProtection": "Prefer sandbox isolation when available; otherwise approve commands with host permissions.",
979
+ "automaticBehavior": "Allow actions automatically, with fewer questions and interruptions.",
980
+ "automaticProtection": "Prefer sandbox isolation when available; otherwise commands run with host permissions.",
981
+ "dangerousBehavior": "Allow actions automatically; commands run with your permissions on this computer.",
982
+ "dangerousProtection": "YaoGuang's isolation limits no longer apply. Commands can access files and networks, including YaoGuang's own data and services.",
983
+ "saving": "Saving…",
984
+ "preferenceFailure": "This browser could not save the display preference. Your choice is kept until this page closes.",
985
+ "retry": "Retry",
986
+ "custom": "Current configuration is custom. Switch to Professional to inspect it, or choose a preset to replace the policies.",
987
+ "offline": "Disconnected. Reconnect before changing security settings.",
988
+ "loading": "Reading security configuration…",
989
+ "recoveryFailure": "Business and configuration writes are stopped because security configuration recovery failed. Complete recovery and reload before continuing.",
990
+ "isolationInactive": "Sandbox isolation is not active",
991
+ "unavailableReason": "This system cannot provide sandbox isolation: {{reason}}. Your sandbox setting remains enabled.",
992
+ "dangerousReason": "You selected Dangerous mode, which turns off sandbox isolation.",
993
+ "explicitlyDisabled": "You manually turned off sandbox isolation.",
994
+ "directIsolationWarning": "Commands run with your permissions on this computer and can access files and networks, including YaoGuang's own data and services."
995
+ }
996
+ };
997
+ var zh_CN_default = {
998
+ network: {
999
+ "title": "网络",
1000
+ "proxySettings": "代理设置",
1001
+ "mode": "代理模式",
1002
+ "system": "系统代理",
1003
+ "manual": "手动设置",
1004
+ "direct": "直连",
1005
+ "environment": "环境变量",
1006
+ "url": "代理地址",
1007
+ "noProxy": "绕过代理(逗号分隔)",
1008
+ "effective": "当前生效",
1009
+ "bypass": "绕过",
1010
+ "source": "配置来源",
1011
+ "directValue": "直连",
1012
+ "bypassDetails": "绕过代理的地址",
1013
+ "notLoaded": "暂无配置",
1014
+ "unavailable": "代理配置不可用",
1015
+ "addressRequired": "请输入代理地址。",
1016
+ "support": "支持 HTTP/HTTPS 代理,不支持身份认证。",
1017
+ "applying": "正在更新…",
1018
+ "refresh": "刷新"
1019
+ },
1020
+ permissions: {
1021
+ "approvalField": "默认授权策略",
1022
+ "systemRules": "系统沙箱规则",
1023
+ "systemRulesHint": "选择规则后批量启用或禁用;点击规则数量查看路径。",
1024
+ "customRules": "自定义沙箱规则",
1025
+ "customRulesHint": "添加允许命令读取的文件或目录;目录内的内容也可读取。",
1026
+ "systemRule": "系统",
1027
+ "customRule": "自定义",
1028
+ "ruleCount": "共 {{count}} 条",
1029
+ "enabledCount": "已启用 {{count}} 条",
1030
+ "enabled": "启用",
1031
+ "disabled": "禁用",
1032
+ "noCustomRules": "暂无自定义规则。",
1033
+ "approval": "授权模式",
1034
+ "approvalHint": "设置如何处理尚未授权的文件访问、网站访问和命令执行。",
1035
+ "ask": "询问",
1036
+ "deny": "默认拒绝",
1037
+ "allow": "默认允许",
1038
+ "allowWarning": "未授权的文件访问、网站访问和命令执行将自动获准。沙箱网络权限需单独设置,受保护内容仍不可访问。",
1039
+ "readable": "沙箱授权",
1040
+ "readableHint": "设置命令可读取的额外文件和目录。",
1041
+ "sandbox": "沙箱",
1042
+ "localPorts": "允许连接的本机端口",
1043
+ "localPortsHint": "允许所有智能体连接指定的本机 TCP 端口,不包含端口监听。",
1044
+ "localPortsTrust": "请仅授权可信的本机服务;服务可代为联网或执行操作。",
1045
+ "localPortsEmpty": "尚未允许任何本机端口",
1046
+ "localPortInvalid": "请输入 1 至 65535 的整数端口",
1047
+ "localPortProtected": "瑶光网关端口,当前不生效",
1048
+ "localPortDuplicate": "该端口已在列表中",
1049
+ "localPortAdd": "添加本机端口",
1050
+ "localPortNumber": "TCP 端口",
1051
+ "localPortsRemoval": "移除后,新命令不能再连接此端口。要收回运行中命令的权限,请停止该命令。",
1052
+ "localPortsProcesses": "查看运行中的进程",
1053
+ "localPortStop": "停止",
1054
+ "localPortsNoProcesses": "没有运行中的进程",
1055
+ "readableAdd": "添加可读路径",
1056
+ "readableRemove": "移除",
1057
+ "readablePlaceholder": "绝对路径",
1058
+ "readableWarning": "所选文件或目录将允许命令读取,包含目录内的内容。",
1059
+ "systemRulesManage": "管理已安装模板与读取规则"
1060
+ },
1061
+ common: {
1062
+ "increase": "增加",
1063
+ "decrease": "减少",
1064
+ "back": "返回",
1065
+ "edit": "编辑",
1066
+ "save": "保存",
1067
+ "create": "创建",
1068
+ "add": "添加",
1069
+ "remove": "移除",
1070
+ "cancel": "取消",
1071
+ "confirm": "确定",
1072
+ "dismiss": "知道了",
1073
+ "retry": "重试",
1074
+ "working": "处理中……"
1075
+ },
1076
+ settings: {
1077
+ "close": "关闭",
1078
+ "personalization": "个性化设置",
1079
+ "runLayoutCombined": "连续显示输出",
1080
+ "runLayoutSegmented": "按回复分段",
1081
+ "colorMode": "显示模式",
1082
+ "systemMode": "跟随系统",
1083
+ "lightMode": "浅色",
1084
+ "darkMode": "深色",
1085
+ "brand": "主题色",
1086
+ "contentWidth": "内容宽度",
1087
+ "contentWidthDefault": "默认",
1088
+ "contentWidthWide": "宽屏",
1089
+ "contentWidthFull": "全宽",
1090
+ "runLayout": "回复排版",
1091
+ "interfaceLanguage": "界面语言",
1092
+ "permissions": "安全"
1093
+ },
1094
+ authorization: {
1095
+ "sandboxIsolation": "沙箱隔离方案",
1096
+ "sandboxLocal": "本地沙箱",
1097
+ "sandboxOff": "关闭",
1098
+ "sandboxLoading": "正在读取沙箱隔离方案…",
1099
+ "sandboxSaving": "正在保存…",
1100
+ "sandboxScope": "可用时优先使用本地沙箱隔离;不可用时命令使用宿主权限。适用于所有智能体和工作空间,仅影响新启动的命令。",
1101
+ "sandboxInactiveRules": "下方规则将在恢复本地沙箱后生效;其他工具的访问授权不受影响。",
1102
+ "management": "授权管理",
1103
+ "sandboxManagement": "沙箱管理",
1104
+ "website": "公网网站访问授权",
1105
+ "port": "本机端口授权",
1106
+ "command": "指令授权",
1107
+ "records": "访问授权记录",
1108
+ "websiteHint": "允许访问指定的网站和端口,对所有智能体生效。",
1109
+ "portHint": "允许连接本机服务或监听指定端口,对所有智能体生效。",
1110
+ "commandAccessHint": "允许在指定目录执行指定命令,对所有智能体生效。",
1111
+ "globalHint": "授权对所有智能体生效;单次授权不在此列出。",
1112
+ "recordsHint": "查看和撤销已有授权;单次授权不在此列出。",
1113
+ "addwebsite": "新增公网网站访问授权",
1114
+ "addport": "新增本机端口授权",
1115
+ "addcommand": "新增指令授权",
1116
+ "argv": "完整执行参数(JSON 数组)",
1117
+ "cwd": "工作目录(绝对路径)",
1118
+ "commandHint": "填写完整执行参数和工作目录;更改后需重新授权。文件和网络访问需单独授权。",
1119
+ "commandInvalid": "请输入非空字符串数组和绝对工作目录。",
1120
+ "hostInvalid": "请输入主机或 *.域名,并指定 TCP 端口。",
1121
+ "host": "主机或域名模式",
1122
+ "operation": "授权类型",
1123
+ "both": "全部",
1124
+ "listenWarning": "仅供本机使用的服务,请绑定 127.0.0.1 或 ::1。",
1125
+ "removalHint": "撤销仅影响后续操作。要收回运行中命令的权限,请停止该命令。",
1126
+ "scope": "影响范围",
1127
+ "global": "全局",
1128
+ "source": "来源",
1129
+ "manual": "手工配置",
1130
+ "approval": "人工批准",
1131
+ "state": "状态",
1132
+ "effective": "生效",
1133
+ "inactive": "策略或固定规则阻止",
1134
+ "networkPolicies": "网络访问设置",
1135
+ "networkPoliciesHint": "分别设置公网访问、本机连接和端口监听权限;「默认拒绝」优先于已有授权。",
1136
+ "external": "公网网络访问",
1137
+ "connect": "本机端口连接",
1138
+ "listen": "本机端口监听",
1139
+ "externalHint": "控制命令访问互联网。",
1140
+ "connectHint": "控制命令连接本机服务。",
1141
+ "listenHint": "控制命令启动服务,供其他程序连接。",
1142
+ "externalWarning": "公网访问建议选择「询问」;「默认允许」会放行所有外部地址。",
1143
+ "protectedPorts": "命令不能访问瑶光服务端口({{ports}})。",
1144
+ "kind": {
1145
+ "file": "文件",
1146
+ "host": "主机",
1147
+ "command": "指令",
1148
+ "sandbox-network": "沙箱外网",
1149
+ "business-approval": "业务审批"
1150
+ }
1151
+ },
1152
+ securityRules: {
1153
+ "processes": "运行中进程",
1154
+ "triggerDuration": "任务存续期间",
1155
+ "search": "搜索规则",
1156
+ "bulkRemove": "批量移除",
1157
+ "bulkRevoke": "批量撤销",
1158
+ "clearSelection": "取消选择",
1159
+ "selectPage": "选择本页全部规则",
1160
+ "selectRow": "选择 {{label}}",
1161
+ "noMatches": "没有匹配的规则",
1162
+ "pagination": "规则分页",
1163
+ "previous": "上一页",
1164
+ "next": "下一页",
1165
+ "pageSize": "每页条数",
1166
+ "perPage": "每页 {{count}} 条",
1167
+ "confirmTitle": "{{verb}}选中的 {{count}} 条许可?",
1168
+ "confirmRemove": "确认移除",
1169
+ "confirmRevoke": "确认撤销",
1170
+ "scope": "匹配范围",
1171
+ "path": "可读路径",
1172
+ "port": "连接端口",
1173
+ "permission": "权限",
1174
+ "read": "允许读取",
1175
+ "connect": "允许连接",
1176
+ "hostDuplicate": "该主机规则已在列表中",
1177
+ "hostPreview": "将允许 {{host}}",
1178
+ "removalHint": "移除后,此路径的读取授权将失效。要收回运行中命令的权限,请停止该命令。",
1179
+ "hostRemovalHint": "移除后,此网站的访问授权将失效。",
1180
+ "kind": "权限类型",
1181
+ "duration": "有效期",
1182
+ "target": "授权对象",
1183
+ "time": "授权时间",
1184
+ "everyWorkspace": "全部工作空间",
1185
+ "category": "规则分类",
1186
+ "bulkEnable": "批量启用",
1187
+ "bulkDisable": "批量禁用",
1188
+ "enable": "启用",
1189
+ "disable": "禁用",
1190
+ "systemSearch": "搜索分类或路径",
1191
+ "statusFilter": "启用状态",
1192
+ "filterAll": "全部",
1193
+ "filterEnabled": "已启用",
1194
+ "filterDisabled": "未启用",
1195
+ "matching": "匹配 {{count}} 条",
1196
+ "expandAll": "全部展开",
1197
+ "collapseAll": "全部收起",
1198
+ "expandGroup": "展开 {{name}}",
1199
+ "collapseGroup": "收起 {{name}}",
1200
+ "selectWholeGroup": "操作整组 {{count}} 条规则,包括筛选隐藏的规则",
1201
+ "system": "系统运行环境",
1202
+ "systemHint": "系统命令、共享库与基础运行资源",
1203
+ "devTools": "开发工具 · DevTools",
1204
+ "devToolsHint": "包管理器、工具链与依赖缓存",
1205
+ "applications": "已安装的应用与工具",
1206
+ "applicationsHint": "Homebrew 与 Xcode",
1207
+ "other": "其他系统规则",
1208
+ "otherHint": "未归入上述场景的系统路径",
1209
+ "groupEnable": "启用 {{name}}",
1210
+ "groupCount": "{{enabled}} / {{count}} 已启用",
1211
+ "portSuggestions": "常用端口示例",
1212
+ "load": "正在读取配置…"
1213
+ },
1214
+ security: {
1215
+ "switchProfessional": "切换至专业模式",
1216
+ "switchSimple": "切换至简洁模式",
1217
+ "presets": "安全预设",
1218
+ "default": "默认模式",
1219
+ "automatic": "自动模式",
1220
+ "dangerous": "危险模式",
1221
+ "defaultBehavior": "遇到需要额外权限的操作,会先询问你。",
1222
+ "defaultProtection": "可用时优先使用沙箱隔离;不可用时审批使用宿主权限的命令。",
1223
+ "automaticBehavior": "自动允许需要授权的操作,减少询问和打断。",
1224
+ "automaticProtection": "可用时优先使用沙箱隔离;不可用时命令使用宿主权限运行。",
1225
+ "dangerousBehavior": "自动允许操作,命令直接使用你在电脑上的权限运行。",
1226
+ "dangerousProtection": "不再受瑶光的隔离限制,可访问文件和网络,包括瑶光自身的数据和服务。",
1227
+ "saving": "正在保存…",
1228
+ "preferenceFailure": "当前浏览器无法保存页面模式;本页会保留你的选择,关闭后恢复默认。",
1229
+ "retry": "重试",
1230
+ "custom": "当前为自定义配置,可切换专业模式查看,或选择预设覆盖策略。",
1231
+ "offline": "连接已断开,请重新连接后再修改安全设置。",
1232
+ "loading": "正在读取安全配置…",
1233
+ "recoveryFailure": "安全配置恢复失败,业务与配置写入已停止。请完成恢复并重新读取后再继续。",
1234
+ "isolationInactive": "沙箱隔离未生效",
1235
+ "unavailableReason": "当前系统无法提供沙箱隔离:{{reason}}。沙箱设置仍保持开启。",
1236
+ "dangerousReason": "你已选择危险模式,主动关闭了沙箱隔离。",
1237
+ "explicitlyDisabled": "你已手动关闭沙箱隔离。",
1238
+ "directIsolationWarning": "命令会使用你在电脑上的权限运行,可访问文件与网络,包括瑶光自身的数据和服务。"
1239
+ }
1240
+ };
1241
+ //#endregion
1242
+ //#region ui-src/index.tsx
1243
+ function flatten(value, prefix = "") {
1244
+ return Object.fromEntries(Object.entries(value).flatMap(([key, entry]) => typeof entry === "string" ? [[prefix + key, entry]] : Object.entries(flatten(entry, `${prefix}${key}.`))));
1245
+ }
1246
+ /** Public browser framework version. */
1247
+ var runtimeVersion = 5;
1248
+ /** Current sandbox settings page composition. */
1249
+ var provides = ["sandbox-settings"];
1250
+ /** Registers the grouped page and withdraws it together with this owner. */
1251
+ function register(ctx) {
1252
+ configureApi(ctx);
1253
+ configureTranslations(ctx);
1254
+ ctx.i18n.register({
1255
+ "en-US": flatten(en_US_default),
1256
+ "zh-CN": flatten(zh_CN_default)
1257
+ }, "zh-CN");
1258
+ ctx.services.provide("sandbox-settings", {
1259
+ component: PermissionsPanel,
1260
+ subscribe: (listener) => ctx.on("sandboxChanged", listener)
1261
+ });
1262
+ ctx.slots.register("shell.settings.category", {
1263
+ id: "permissions",
1264
+ label: () => ctx.i18n.t("settings.permissions"),
1265
+ icon: "shield-check",
1266
+ region: "preset",
1267
+ order: 50,
1268
+ layout: "fill",
1269
+ component: PermissionsPanel
1270
+ });
1271
+ }
1272
+ //#endregion
1273
+ export { provides, register, runtimeVersion };