@eum-agent/authorization-policy 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 +126 -0
- package/package.json +51 -3
- package/ui/ui.js +1132 -0
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/schema.ts
|
|
6
|
+
/** Default policy owned by the authorization extension. */
|
|
7
|
+
/** Missing owner settings use Ask; unknown values are refused. */
|
|
8
|
+
const ApprovalPolicy = z.enum([
|
|
9
|
+
"ask",
|
|
10
|
+
"deny",
|
|
11
|
+
"allow"
|
|
12
|
+
]);
|
|
13
|
+
/** Complete persisted authorization settings. */
|
|
14
|
+
const AuthorizationSettings = z.object({ policy: ApprovalPolicy }).strict();
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/index.ts
|
|
17
|
+
/** Owns the default authorization policy and its settings methods. */
|
|
18
|
+
const plugin = {
|
|
19
|
+
name: "@eum-agent/authorization-policy",
|
|
20
|
+
requires: ["approval-mechanism", "configuration-transactions"],
|
|
21
|
+
provides: ["authorization-strategy", "authorization-settings-participant"],
|
|
22
|
+
apply(ctx) {
|
|
23
|
+
const storage = ctx.storage.open();
|
|
24
|
+
const database = storage.db;
|
|
25
|
+
const table = storage.tableName("settings");
|
|
26
|
+
database.exec(`CREATE TABLE IF NOT EXISTS ${table} (id INTEGER PRIMARY KEY CHECK (id = 1), value TEXT NOT NULL)`);
|
|
27
|
+
const mechanism = ctx.services.get("approval-mechanism");
|
|
28
|
+
const transactions = ctx.services.get("configuration-transactions");
|
|
29
|
+
const changed = ctx.client.registerFrame({
|
|
30
|
+
name: "approvalChanged",
|
|
31
|
+
delivery: "broadcast",
|
|
32
|
+
payload: z.object({ policy: ApprovalPolicy }).strict()
|
|
33
|
+
});
|
|
34
|
+
let revision = 0;
|
|
35
|
+
const epoch = randomUUID();
|
|
36
|
+
const read = () => {
|
|
37
|
+
ctx.signal.throwIfAborted();
|
|
38
|
+
const row = database.prepare(`SELECT value FROM ${table} WHERE id = 1`).get();
|
|
39
|
+
return row ? AuthorizationSettings.parse(JSON.parse(row.value)) : { policy: "ask" };
|
|
40
|
+
};
|
|
41
|
+
const strategy = {
|
|
42
|
+
policy: () => read().policy,
|
|
43
|
+
askQuestionId: (id) => {
|
|
44
|
+
ctx.signal.throwIfAborted();
|
|
45
|
+
return `strategy:${epoch}:${id ?? "decision"}`;
|
|
46
|
+
},
|
|
47
|
+
decide(authority, request, approval) {
|
|
48
|
+
const policy = read().policy;
|
|
49
|
+
if (policy === "deny") return {
|
|
50
|
+
kind: "result",
|
|
51
|
+
result: { kind: "unavailable" },
|
|
52
|
+
source: "policy-deny"
|
|
53
|
+
};
|
|
54
|
+
if (policy === "ask" || authority.answer?.answers.some((answer) => answer.questionId === approval.questionId(request.id))) return approval.decide(authority, request);
|
|
55
|
+
return {
|
|
56
|
+
kind: "result",
|
|
57
|
+
result: { kind: "allowed-once" },
|
|
58
|
+
source: "policy-allow"
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
ask(authority, request) {
|
|
62
|
+
ctx.signal.throwIfAborted();
|
|
63
|
+
const id = strategy.askQuestionId(request.id);
|
|
64
|
+
if (authority.answer && !authority.answer.answers.some((answer) => answer.questionId === id)) return {
|
|
65
|
+
kind: "result",
|
|
66
|
+
result: { kind: "unavailable" },
|
|
67
|
+
source: "policy-deny"
|
|
68
|
+
};
|
|
69
|
+
return mechanism.decide(authority, {
|
|
70
|
+
...request,
|
|
71
|
+
id
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
ctx.services.provide("authorization-strategy", strategy);
|
|
76
|
+
const participant = {
|
|
77
|
+
connectionIdentity: storage.connectionIdentity,
|
|
78
|
+
prepare(value) {
|
|
79
|
+
const input = AuthorizationSettings.parse(value);
|
|
80
|
+
const unchanged = input.policy === read().policy;
|
|
81
|
+
const at = revision;
|
|
82
|
+
const assertCurrent = () => {
|
|
83
|
+
ctx.signal.throwIfAborted();
|
|
84
|
+
if (revision !== at) throw new Error("Authorization settings changed before commit");
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
assertCurrent,
|
|
88
|
+
write() {
|
|
89
|
+
assertCurrent();
|
|
90
|
+
if (unchanged) return;
|
|
91
|
+
database.prepare(`INSERT INTO ${table} (id, value) VALUES (1, ?) ON CONFLICT (id) DO UPDATE SET value = excluded.value`).run(JSON.stringify(input));
|
|
92
|
+
},
|
|
93
|
+
publish() {
|
|
94
|
+
if (!unchanged) {
|
|
95
|
+
revision++;
|
|
96
|
+
changed.emit(input);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
ctx.services.provide("authorization-settings-participant", participant);
|
|
103
|
+
ctx.client.registerMethod({
|
|
104
|
+
name: "approvalGet",
|
|
105
|
+
params: z.object({}).strict(),
|
|
106
|
+
result: AuthorizationSettings,
|
|
107
|
+
handle: read
|
|
108
|
+
});
|
|
109
|
+
ctx.client.registerMethod({
|
|
110
|
+
name: "approvalSet",
|
|
111
|
+
params: AuthorizationSettings,
|
|
112
|
+
result: AuthorizationSettings,
|
|
113
|
+
handle(input) {
|
|
114
|
+
transactions.commit([{
|
|
115
|
+
service: "authorization-settings-participant",
|
|
116
|
+
value: input
|
|
117
|
+
}]);
|
|
118
|
+
return read();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const module = fileURLToPath(new URL("../ui/ui.js", import.meta.url));
|
|
122
|
+
if (existsSync(module)) ctx.client.registerUi({ module });
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
export { plugin as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eum-agent/authorization-policy",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"displayName": {
|
|
4
|
+
"en-US": "Authorization Policy",
|
|
5
|
+
"zh-CN": "授权策略"
|
|
6
|
+
},
|
|
7
|
+
"version": "1.0.1",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"description": "Default authorization policy and resource permission settings",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"ui"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"zod": "^4.4.3",
|
|
22
|
+
"i18next": "^26.4.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@eum-agent/plugin": "1.0.1",
|
|
26
|
+
"@types/react": "^19.2.18",
|
|
27
|
+
"@types/react-dom": "^19.2.5",
|
|
28
|
+
"react": "^19.2.0",
|
|
29
|
+
"react-dom": "^19.2.0",
|
|
30
|
+
"vite": "^8.2.2",
|
|
31
|
+
"@eum-agent/protocol": "1.0.0",
|
|
32
|
+
"@testing-library/react": "^16.3.3",
|
|
33
|
+
"@testing-library/user-event": "^14.6.6",
|
|
34
|
+
"zustand": "^5.0.15",
|
|
35
|
+
"react-i18next": "^17.0.13",
|
|
36
|
+
"lucide-react": "^1.40.0"
|
|
37
|
+
},
|
|
38
|
+
"yaoguang": {
|
|
39
|
+
"kind": "extension",
|
|
40
|
+
"description": {
|
|
41
|
+
"en-US": "Default authorization policy and resource permission settings",
|
|
42
|
+
"zh-CN": "工具调用与资源访问的默认授权策略"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {},
|
|
45
|
+
"foundationDependencies": {
|
|
46
|
+
"@eum-agent/storage-sqlite": "1.0.1"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsdown && vite build",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.ui.json"
|
|
53
|
+
}
|
|
6
54
|
}
|
package/ui/ui.js
ADDED
|
@@ -0,0 +1,1132 @@
|
|
|
1
|
+
import { ActionButton, Badge, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FacetedFilter, Failure, Field, FormFailure, Input, Panel, Popover, ReadFailure, RuleEditor, SecurityRuleList, Segmented, SettingsLink, Warning, failureText, useBrowserService, useGateway, useGatewayAction, useGatewayRead, useTranslation, uuid } from "@eum-agent/host/framework";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region ui-src/api.ts
|
|
5
|
+
/** Owner-bound sandbox reads refresh on settings changes and connection recovery. */
|
|
6
|
+
var owner;
|
|
7
|
+
/** Binds calls to this exact browser activation. */
|
|
8
|
+
function configureApi(context) {
|
|
9
|
+
owner = context;
|
|
10
|
+
}
|
|
11
|
+
/** Invokes one method through the contributing owner and preserves its typed result. */
|
|
12
|
+
function authorizationCall(method, input) {
|
|
13
|
+
if (!owner) return Promise.reject(/* @__PURE__ */ new Error("Authorization browser owner is unavailable"));
|
|
14
|
+
return owner.invoke(method, input ?? {});
|
|
15
|
+
}
|
|
16
|
+
/** Serializes reads and discards answers invalidated while in flight. */
|
|
17
|
+
function useAuthorizationRead(method) {
|
|
18
|
+
const client = useGateway();
|
|
19
|
+
const [state, setState] = useState({
|
|
20
|
+
data: null,
|
|
21
|
+
error: null,
|
|
22
|
+
pending: true
|
|
23
|
+
});
|
|
24
|
+
const refresh = useRef(() => Promise.resolve());
|
|
25
|
+
const reload = useCallback(() => refresh.current(), []);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
let live = true, running = false, invalidated = false;
|
|
28
|
+
let previousConnection = client.connection.status;
|
|
29
|
+
const waiters = /* @__PURE__ */ new Set();
|
|
30
|
+
const settle = () => {
|
|
31
|
+
for (const waiter of waiters) waiter();
|
|
32
|
+
waiters.clear();
|
|
33
|
+
};
|
|
34
|
+
const read = () => {
|
|
35
|
+
if (!live || client.connection.status !== "online") return Promise.resolve();
|
|
36
|
+
const completion = new Promise((resolve) => waiters.add(resolve));
|
|
37
|
+
if (running) {
|
|
38
|
+
invalidated = true;
|
|
39
|
+
return completion;
|
|
40
|
+
}
|
|
41
|
+
running = true;
|
|
42
|
+
setState((previous) => ({
|
|
43
|
+
...previous,
|
|
44
|
+
pending: true
|
|
45
|
+
}));
|
|
46
|
+
(async () => {
|
|
47
|
+
try {
|
|
48
|
+
do {
|
|
49
|
+
invalidated = false;
|
|
50
|
+
try {
|
|
51
|
+
const data = await authorizationCall(method);
|
|
52
|
+
if (live && !invalidated) setState({
|
|
53
|
+
data,
|
|
54
|
+
error: null,
|
|
55
|
+
pending: false
|
|
56
|
+
});
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (live && !invalidated) setState((previous) => ({
|
|
59
|
+
...previous,
|
|
60
|
+
error: failureText(error, () => ""),
|
|
61
|
+
pending: false
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
} while (live && invalidated && client.connection.status === "online");
|
|
65
|
+
} finally {
|
|
66
|
+
running = false;
|
|
67
|
+
settle();
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
70
|
+
return completion;
|
|
71
|
+
};
|
|
72
|
+
refresh.current = read;
|
|
73
|
+
read();
|
|
74
|
+
const off = client.subscribe((frame) => {
|
|
75
|
+
if (frame.kind === "plugin._eum_agent_authorization_policy.approvalChanged") read();
|
|
76
|
+
});
|
|
77
|
+
const offConnection = client.watchConnection((connection) => {
|
|
78
|
+
if (connection.status === "online") {
|
|
79
|
+
if (previousConnection !== "online") read();
|
|
80
|
+
} else {
|
|
81
|
+
invalidated = true;
|
|
82
|
+
settle();
|
|
83
|
+
setState({
|
|
84
|
+
data: null,
|
|
85
|
+
error: null,
|
|
86
|
+
pending: false
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
previousConnection = connection.status;
|
|
90
|
+
});
|
|
91
|
+
return () => {
|
|
92
|
+
live = false;
|
|
93
|
+
settle();
|
|
94
|
+
off();
|
|
95
|
+
offConnection();
|
|
96
|
+
refresh.current = () => Promise.resolve();
|
|
97
|
+
};
|
|
98
|
+
}, [client, method]);
|
|
99
|
+
return {
|
|
100
|
+
...state,
|
|
101
|
+
reload
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region ui-src/i18n.ts
|
|
106
|
+
/** Platform browser strings share the host's language and React translation runtime. */
|
|
107
|
+
var translations;
|
|
108
|
+
/** Binds this activation's registered namespace without reconstructing the owner's namespace. */
|
|
109
|
+
function configureTranslations(ctx) {
|
|
110
|
+
translations = ctx.i18n;
|
|
111
|
+
}
|
|
112
|
+
/** Observes the shared language while resolving platform-owned copy. */
|
|
113
|
+
function useTranslation$1() {
|
|
114
|
+
const shared = useTranslation();
|
|
115
|
+
if (!translations) throw new Error("platform browser translations are not registered");
|
|
116
|
+
return {
|
|
117
|
+
...shared,
|
|
118
|
+
t: translations.t
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ui-src/components/settings/approval.tsx
|
|
123
|
+
/** Default approval policy editor owned by its active authorization strategy. */
|
|
124
|
+
var POLICIES = [
|
|
125
|
+
"ask",
|
|
126
|
+
"deny",
|
|
127
|
+
"allow"
|
|
128
|
+
];
|
|
129
|
+
function ApprovalPanel() {
|
|
130
|
+
const { t } = useTranslation$1();
|
|
131
|
+
const policy = useAuthorizationRead("approvalGet");
|
|
132
|
+
const write = useGatewayAction();
|
|
133
|
+
return /* @__PURE__ */ jsxs(Panel, {
|
|
134
|
+
title: t("permissions.approval"),
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsx(ReadFailure, {
|
|
137
|
+
reason: policy.error,
|
|
138
|
+
pending: policy.pending && policy.data === null,
|
|
139
|
+
onRetry: policy.reload
|
|
140
|
+
}),
|
|
141
|
+
policy.data !== null && /* @__PURE__ */ jsx(Panel, {
|
|
142
|
+
title: t("permissions.approvalField"),
|
|
143
|
+
level: "field",
|
|
144
|
+
inline: true,
|
|
145
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
146
|
+
className: "flex min-w-0 justify-end",
|
|
147
|
+
children: /* @__PURE__ */ jsx(Segmented, {
|
|
148
|
+
slot: "approval-policy",
|
|
149
|
+
disabled: write.pending,
|
|
150
|
+
label: t("permissions.approvalField"),
|
|
151
|
+
value: policy.data.policy,
|
|
152
|
+
options: POLICIES.map((one) => ({
|
|
153
|
+
value: one,
|
|
154
|
+
label: t(`permissions.${one}`)
|
|
155
|
+
})),
|
|
156
|
+
onSelect: (picked) => {
|
|
157
|
+
write.run(() => authorizationCall("approvalSet", { policy: picked }));
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
policy.data?.policy === "allow" && /* @__PURE__ */ jsx(Warning, { children: t("permissions.allowWarning") }),
|
|
163
|
+
/* @__PURE__ */ jsx(Failure, { reason: write.error })
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ui-src/components/settings/resource-grants.tsx
|
|
169
|
+
/** Shared resource management backed by the core authorization catalog. */
|
|
170
|
+
/** Human-readable exact target, also used by search and deletion confirmation. */
|
|
171
|
+
function resourceTarget(record) {
|
|
172
|
+
switch (record.kind) {
|
|
173
|
+
case "file": return `${record.target.operation.toUpperCase()} ${record.target.path}`;
|
|
174
|
+
case "host": return `${record.target.host}:${record.target.port} ${record.target.operation.toUpperCase()}`;
|
|
175
|
+
case "command": return `${JSON.stringify(record.target.argv)} · ${record.target.cwd}`;
|
|
176
|
+
case "sandbox-network": return "External network";
|
|
177
|
+
case "business-approval": return `${record.target.label} · ${record.target.owner}`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function local(record) {
|
|
181
|
+
return record.kind === "host" && [
|
|
182
|
+
"localhost",
|
|
183
|
+
"127.0.0.1",
|
|
184
|
+
"::1"
|
|
185
|
+
].includes(record.target.host);
|
|
186
|
+
}
|
|
187
|
+
/** Existing processes keep their initial profile; file holders can be explicitly stopped. */
|
|
188
|
+
function FileHolders({ record }) {
|
|
189
|
+
const { t } = useTranslation$1();
|
|
190
|
+
const processes = useBrowserService("processes")?.getState().processes ?? [];
|
|
191
|
+
const client = useGateway();
|
|
192
|
+
const stopping = useGatewayAction();
|
|
193
|
+
if (record.kind !== "file") return null;
|
|
194
|
+
const holders = processes.filter((process) => process.state !== "ended" && process.held.some((held) => held.path === record.target.path && held.access === record.target.operation));
|
|
195
|
+
if (!holders.length) return null;
|
|
196
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
197
|
+
"data-slot": "grant-holders",
|
|
198
|
+
className: "flex flex-wrap items-center gap-2 text-xs text-warning",
|
|
199
|
+
children: [
|
|
200
|
+
t("access.stillHeld", { count: holders.length }),
|
|
201
|
+
/* @__PURE__ */ jsx(Button, {
|
|
202
|
+
variant: "ghost",
|
|
203
|
+
size: "sm",
|
|
204
|
+
loading: stopping.pending,
|
|
205
|
+
disabled: stopping.pending,
|
|
206
|
+
onClick: () => {
|
|
207
|
+
stopping.run(() => client.call("process.stop", { processIds: holders.map((process) => process.processId) }).then((answer) => {
|
|
208
|
+
const refused = answer.results.find((member) => !member.ok);
|
|
209
|
+
if (refused && !refused.ok) throw new Error(refused.error.message);
|
|
210
|
+
}));
|
|
211
|
+
},
|
|
212
|
+
children: t("access.stopHolders")
|
|
213
|
+
}),
|
|
214
|
+
/* @__PURE__ */ jsx(Failure, { reason: stopping.error })
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/** One add dialog keeps invalid input intact and closes only after the authoritative write succeeds. */
|
|
219
|
+
function AddResource({ open, onOpenChange, kind, reload }) {
|
|
220
|
+
const { t } = useTranslation$1();
|
|
221
|
+
const action = useGatewayAction();
|
|
222
|
+
const [host, setHost] = useState("");
|
|
223
|
+
const [port, setPort] = useState("");
|
|
224
|
+
const [operation, setOperation] = useState("connect");
|
|
225
|
+
const [argv, setArgv] = useState("");
|
|
226
|
+
const [cwd, setCwd] = useState("");
|
|
227
|
+
const [invalid, setInvalid] = useState(null);
|
|
228
|
+
const intent = useRef(null);
|
|
229
|
+
async function submit() {
|
|
230
|
+
if (action.pending) return;
|
|
231
|
+
let authorization;
|
|
232
|
+
try {
|
|
233
|
+
if (kind === "command") {
|
|
234
|
+
const args = JSON.parse(argv);
|
|
235
|
+
if (!Array.isArray(args) || !args.length || args.some((arg) => typeof arg !== "string" || arg.includes("\0")) || !cwd.length || cwd.includes("\0")) throw new Error(t("authorization.commandInvalid"));
|
|
236
|
+
authorization = {
|
|
237
|
+
kind: "command",
|
|
238
|
+
argv: args,
|
|
239
|
+
cwd
|
|
240
|
+
};
|
|
241
|
+
} else {
|
|
242
|
+
const tcp = port.trim() === "any" ? "any" : Number(port);
|
|
243
|
+
if (tcp !== "any" && (!/^\d+$/.test(port.trim()) || !Number.isInteger(tcp) || tcp < 1 || tcp > 65535)) throw new Error(t("permissions.localPortInvalid"));
|
|
244
|
+
if (kind === "website" && (!host.trim() || tcp === "any")) throw new Error(t("authorization.hostInvalid"));
|
|
245
|
+
authorization = {
|
|
246
|
+
kind: "host",
|
|
247
|
+
host: kind === "port" ? "localhost" : host.trim(),
|
|
248
|
+
port: tcp,
|
|
249
|
+
operations: kind === "website" ? ["connect"] : operation === "both" ? ["connect", "listen"] : [operation]
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
} catch (error) {
|
|
253
|
+
setInvalid(error instanceof Error ? error.message : String(error));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
setInvalid(null);
|
|
257
|
+
const key = JSON.stringify(authorization);
|
|
258
|
+
const operationId = intent.current?.key === key ? intent.current.id : uuid();
|
|
259
|
+
intent.current = {
|
|
260
|
+
key,
|
|
261
|
+
id: operationId
|
|
262
|
+
};
|
|
263
|
+
if ((await action.run(async (client) => {
|
|
264
|
+
const answer = await client.call("config.access.add", {
|
|
265
|
+
operationId,
|
|
266
|
+
authorizations: [authorization]
|
|
267
|
+
});
|
|
268
|
+
if (answer.operationState === "admitted") throw new Error(t("common.working"));
|
|
269
|
+
return answer;
|
|
270
|
+
})).ok) {
|
|
271
|
+
intent.current = null;
|
|
272
|
+
reload();
|
|
273
|
+
onOpenChange(false);
|
|
274
|
+
setHost("");
|
|
275
|
+
setPort("");
|
|
276
|
+
setArgv("");
|
|
277
|
+
setCwd("");
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
281
|
+
open,
|
|
282
|
+
onOpenChange: (next) => {
|
|
283
|
+
if (!action.pending) onOpenChange(next);
|
|
284
|
+
},
|
|
285
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
286
|
+
closeLabel: t("settings.close"),
|
|
287
|
+
className: "max-w-lg overflow-y-auto p-6",
|
|
288
|
+
overlayProps: { forceRender: true },
|
|
289
|
+
children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t(`authorization.add${kind}`) }), /* @__PURE__ */ jsx(DialogDescription, { children: t(kind === "command" ? "authorization.commandAccessHint" : kind === "website" ? "authorization.websiteHint" : "authorization.portHint") })] }), /* @__PURE__ */ jsxs("form", {
|
|
290
|
+
className: "flex flex-col gap-4",
|
|
291
|
+
onSubmit: (event) => {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
submit();
|
|
294
|
+
},
|
|
295
|
+
children: [
|
|
296
|
+
/* @__PURE__ */ jsx("fieldset", {
|
|
297
|
+
disabled: action.pending,
|
|
298
|
+
className: "flex min-w-0 flex-col gap-4",
|
|
299
|
+
children: kind === "command" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
300
|
+
/* @__PURE__ */ jsx(Field, {
|
|
301
|
+
label: t("authorization.argv"),
|
|
302
|
+
children: (binding) => /* @__PURE__ */ jsx(Input, {
|
|
303
|
+
...binding,
|
|
304
|
+
value: argv,
|
|
305
|
+
onChange: (event) => setArgv(event.target.value),
|
|
306
|
+
placeholder: "[\"/bin/bash\",\"--noprofile\",\"--norc\",\"-c\",\"pnpm test\"]"
|
|
307
|
+
})
|
|
308
|
+
}),
|
|
309
|
+
/* @__PURE__ */ jsx(Field, {
|
|
310
|
+
label: t("authorization.cwd"),
|
|
311
|
+
children: (binding) => /* @__PURE__ */ jsx(Input, {
|
|
312
|
+
...binding,
|
|
313
|
+
value: cwd,
|
|
314
|
+
onChange: (event) => setCwd(event.target.value),
|
|
315
|
+
placeholder: "/Users/me/project"
|
|
316
|
+
})
|
|
317
|
+
}),
|
|
318
|
+
/* @__PURE__ */ jsx("p", {
|
|
319
|
+
className: "text-xs text-muted-foreground",
|
|
320
|
+
children: t("authorization.commandHint")
|
|
321
|
+
})
|
|
322
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
323
|
+
kind === "website" && /* @__PURE__ */ jsx(Field, {
|
|
324
|
+
label: t("authorization.host"),
|
|
325
|
+
children: (binding) => /* @__PURE__ */ jsx(Input, {
|
|
326
|
+
...binding,
|
|
327
|
+
value: host,
|
|
328
|
+
onChange: (event) => setHost(event.target.value),
|
|
329
|
+
placeholder: "*.baidu.com"
|
|
330
|
+
})
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ jsx(Field, {
|
|
333
|
+
label: t("securityRules.port"),
|
|
334
|
+
children: (binding) => /* @__PURE__ */ jsx(Input, {
|
|
335
|
+
...binding,
|
|
336
|
+
value: port,
|
|
337
|
+
onChange: (event) => setPort(event.target.value),
|
|
338
|
+
placeholder: kind === "port" ? "10010 / any" : "443"
|
|
339
|
+
})
|
|
340
|
+
}),
|
|
341
|
+
kind === "port" && /* @__PURE__ */ jsx(Segmented, {
|
|
342
|
+
label: t("authorization.operation"),
|
|
343
|
+
value: operation,
|
|
344
|
+
options: [
|
|
345
|
+
{
|
|
346
|
+
value: "connect",
|
|
347
|
+
label: t("authorization.connect")
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
value: "listen",
|
|
351
|
+
label: t("authorization.listen")
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
value: "both",
|
|
355
|
+
label: t("authorization.both")
|
|
356
|
+
}
|
|
357
|
+
],
|
|
358
|
+
onSelect: setOperation
|
|
359
|
+
}),
|
|
360
|
+
kind === "port" && /* @__PURE__ */ jsx(Warning, { children: t("authorization.listenWarning") })
|
|
361
|
+
] })
|
|
362
|
+
}),
|
|
363
|
+
/* @__PURE__ */ jsx(FormFailure, { reason: invalid ?? action.error }),
|
|
364
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
365
|
+
type: "button",
|
|
366
|
+
variant: "ghost",
|
|
367
|
+
disabled: action.pending,
|
|
368
|
+
onClick: () => onOpenChange(false),
|
|
369
|
+
children: t("common.cancel")
|
|
370
|
+
}), /* @__PURE__ */ jsx(ActionButton, {
|
|
371
|
+
type: "submit",
|
|
372
|
+
label: t("common.add"),
|
|
373
|
+
pending: action.pending
|
|
374
|
+
})] })
|
|
375
|
+
]
|
|
376
|
+
})]
|
|
377
|
+
})
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
/** Lists website, local TCP, exact command, or all authorization records from the same core snapshot. */
|
|
381
|
+
function ResourceGrantsPanel({ kind }) {
|
|
382
|
+
const { t } = useTranslation$1();
|
|
383
|
+
const list = useGatewayRead("config.access.list");
|
|
384
|
+
const [editing, setEditing] = useState(false);
|
|
385
|
+
const [adding, setAdding] = useState(false);
|
|
386
|
+
const [kinds, setKinds] = useState([]);
|
|
387
|
+
const [operations, setOperations] = useState([]);
|
|
388
|
+
const [sources, setSources] = useState([]);
|
|
389
|
+
const scope = (list.data?.grants ?? []).filter((record) => kind === "records" || (kind === "command" ? record.kind === "command" : kind === "port" ? local(record) : record.kind === "host" && !local(record)));
|
|
390
|
+
const rows = scope.filter((record) => (!kinds.length || kinds.includes(record.kind)) && (!sources.length || sources.includes(record.source)) && (!operations.length || record.kind === "host" && operations.includes(record.target.operation)));
|
|
391
|
+
const heading = t(`authorization.${kind}`);
|
|
392
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
393
|
+
className: "flex min-w-0 flex-col gap-3",
|
|
394
|
+
children: [
|
|
395
|
+
/* @__PURE__ */ jsx(ReadFailure, {
|
|
396
|
+
reason: list.error,
|
|
397
|
+
pending: list.pending && list.data === null,
|
|
398
|
+
onRetry: list.reload
|
|
399
|
+
}),
|
|
400
|
+
/* @__PURE__ */ jsx(SettingsLink, {
|
|
401
|
+
label: heading,
|
|
402
|
+
help: t(kind === "command" ? "authorization.commandAccessHint" : kind === "website" ? "authorization.websiteHint" : kind === "port" ? "authorization.portHint" : "authorization.recordsHint"),
|
|
403
|
+
summary: list.data === null ? "—" : t("permissions.ruleCount", { count: scope.length }),
|
|
404
|
+
disabled: list.data === null,
|
|
405
|
+
onClick: () => setEditing(true)
|
|
406
|
+
}),
|
|
407
|
+
/* @__PURE__ */ jsxs(RuleEditor, {
|
|
408
|
+
fill: true,
|
|
409
|
+
open: editing,
|
|
410
|
+
onOpenChange: setEditing,
|
|
411
|
+
title: heading,
|
|
412
|
+
children: [/* @__PURE__ */ jsx(ReadFailure, {
|
|
413
|
+
reason: list.error,
|
|
414
|
+
pending: list.pending && list.data === null,
|
|
415
|
+
onRetry: list.reload
|
|
416
|
+
}), /* @__PURE__ */ jsx(SecurityRuleList, {
|
|
417
|
+
fill: true,
|
|
418
|
+
filters: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
419
|
+
kind === "records" && /* @__PURE__ */ jsx(FacetedFilter, {
|
|
420
|
+
size: "sm",
|
|
421
|
+
label: t("securityRules.kind"),
|
|
422
|
+
options: [...new Set(scope.map((record) => record.kind))].map((value) => ({
|
|
423
|
+
value,
|
|
424
|
+
label: t(`authorization.kind.${value}`),
|
|
425
|
+
count: scope.filter((record) => record.kind === value).length
|
|
426
|
+
})),
|
|
427
|
+
value: kinds,
|
|
428
|
+
onChange: setKinds
|
|
429
|
+
}),
|
|
430
|
+
kind === "port" && /* @__PURE__ */ jsx(FacetedFilter, {
|
|
431
|
+
size: "sm",
|
|
432
|
+
label: t("authorization.operation"),
|
|
433
|
+
options: ["connect", "listen"].map((value) => ({
|
|
434
|
+
value,
|
|
435
|
+
label: t(`authorization.${value}`),
|
|
436
|
+
count: scope.filter((record) => record.kind === "host" && record.target.operation === value).length
|
|
437
|
+
})),
|
|
438
|
+
value: operations,
|
|
439
|
+
onChange: setOperations
|
|
440
|
+
}),
|
|
441
|
+
kind === "records" && /* @__PURE__ */ jsx(FacetedFilter, {
|
|
442
|
+
size: "sm",
|
|
443
|
+
label: t("authorization.source"),
|
|
444
|
+
options: ["manual", "approval"].map((value) => ({
|
|
445
|
+
value,
|
|
446
|
+
label: t(`authorization.${value}`),
|
|
447
|
+
count: scope.filter((record) => record.source === value).length
|
|
448
|
+
})),
|
|
449
|
+
value: sources,
|
|
450
|
+
onChange: setSources
|
|
451
|
+
})
|
|
452
|
+
] }),
|
|
453
|
+
items: rows,
|
|
454
|
+
allItems: scope,
|
|
455
|
+
loading: list.pending,
|
|
456
|
+
keyOf: (record) => record.id,
|
|
457
|
+
labelOf: resourceTarget,
|
|
458
|
+
searchOf: (record) => `${resourceTarget(record)} ${record.kind} ${record.source}`,
|
|
459
|
+
reload: list.reload,
|
|
460
|
+
empty: t("access.empty"),
|
|
461
|
+
removalHint: t("authorization.removalHint"),
|
|
462
|
+
revoke: true,
|
|
463
|
+
onRemove: (client, records) => client.call("config.access.revoke", {
|
|
464
|
+
operationId: uuid(),
|
|
465
|
+
ids: records.map((record) => record.id)
|
|
466
|
+
}),
|
|
467
|
+
tools: kind === "records" ? void 0 : /* @__PURE__ */ jsx(ActionButton, {
|
|
468
|
+
label: t("common.add"),
|
|
469
|
+
onClick: () => setAdding(true)
|
|
470
|
+
}),
|
|
471
|
+
columns: [
|
|
472
|
+
{
|
|
473
|
+
id: "target",
|
|
474
|
+
label: t("securityRules.target"),
|
|
475
|
+
render: (record) => /* @__PURE__ */ jsxs("div", {
|
|
476
|
+
className: "flex w-48 max-w-64 flex-col gap-1 @3xl:w-64",
|
|
477
|
+
children: [/* @__PURE__ */ jsx(Popover, {
|
|
478
|
+
label: t("securityRules.target"),
|
|
479
|
+
width: 480,
|
|
480
|
+
trigger: /* @__PURE__ */ jsx(Button, {
|
|
481
|
+
variant: "plain",
|
|
482
|
+
className: "w-full truncate rounded-control text-left font-mono text-xs hover:text-primary focus-visible:outline-2 focus-visible:outline-ring",
|
|
483
|
+
children: resourceTarget(record)
|
|
484
|
+
}),
|
|
485
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
486
|
+
className: "whitespace-pre-wrap break-all p-1 font-mono text-xs leading-relaxed",
|
|
487
|
+
children: resourceTarget(record)
|
|
488
|
+
})
|
|
489
|
+
}), /* @__PURE__ */ jsx(FileHolders, { record })]
|
|
490
|
+
})
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
id: "kind",
|
|
494
|
+
className: "whitespace-nowrap",
|
|
495
|
+
label: t("securityRules.kind"),
|
|
496
|
+
render: (record) => /* @__PURE__ */ jsx(Badge, {
|
|
497
|
+
size: "sm",
|
|
498
|
+
children: t(`authorization.kind.${record.kind}`)
|
|
499
|
+
})
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
id: "scope",
|
|
503
|
+
className: "max-w-48",
|
|
504
|
+
label: t("authorization.scope"),
|
|
505
|
+
render: (record) => /* @__PURE__ */ jsx("span", {
|
|
506
|
+
className: "text-xs text-muted-foreground",
|
|
507
|
+
children: record.kind === "business-approval" ? `${record.target.agentId} · ${record.target.workspaceId} · ${record.target.sessionTitle ?? record.target.sessionId ?? t("access.permanent")}` : t("authorization.global")
|
|
508
|
+
})
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: "source",
|
|
512
|
+
className: "whitespace-nowrap",
|
|
513
|
+
label: t("authorization.source"),
|
|
514
|
+
render: (record) => /* @__PURE__ */ jsx("span", {
|
|
515
|
+
className: "whitespace-nowrap text-xs",
|
|
516
|
+
children: t(`authorization.${record.source}`)
|
|
517
|
+
})
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
id: "state",
|
|
521
|
+
className: "whitespace-nowrap",
|
|
522
|
+
label: t("authorization.state"),
|
|
523
|
+
render: (record) => /* @__PURE__ */ jsx(Badge, {
|
|
524
|
+
size: "sm",
|
|
525
|
+
dot: true,
|
|
526
|
+
tone: record.effective ? "success" : "neutral",
|
|
527
|
+
children: t(record.effective ? "authorization.effective" : "authorization.inactive")
|
|
528
|
+
})
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
id: "time",
|
|
532
|
+
className: "whitespace-nowrap",
|
|
533
|
+
label: t("securityRules.time"),
|
|
534
|
+
render: (record) => /* @__PURE__ */ jsx("span", {
|
|
535
|
+
className: "whitespace-nowrap text-xs",
|
|
536
|
+
children: new Date(record.createdAt).toLocaleString()
|
|
537
|
+
})
|
|
538
|
+
}
|
|
539
|
+
]
|
|
540
|
+
})]
|
|
541
|
+
}),
|
|
542
|
+
kind !== "records" && /* @__PURE__ */ jsx(AddResource, {
|
|
543
|
+
open: adding,
|
|
544
|
+
onOpenChange: setAdding,
|
|
545
|
+
kind,
|
|
546
|
+
reload: list.reload
|
|
547
|
+
})
|
|
548
|
+
]
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region ui-src/components/settings/local-ports.tsx
|
|
553
|
+
/** Local TCP permissions share the same core catalog in both security tabs. */
|
|
554
|
+
/** Manages CONNECT and LISTEN targets independently, with explicit binding-address limitations. */
|
|
555
|
+
function LocalPortsPanel() {
|
|
556
|
+
return /* @__PURE__ */ jsx(ResourceGrantsPanel, { kind: "port" });
|
|
557
|
+
}
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region ui-src/components/settings/web-hosts.tsx
|
|
560
|
+
/** Website permissions use the core host catalog shared with sandbox resources. */
|
|
561
|
+
/** Manages external CONNECT targets by host and effective TCP port. */
|
|
562
|
+
function WebHostsPanel() {
|
|
563
|
+
return /* @__PURE__ */ jsx(ResourceGrantsPanel, { kind: "website" });
|
|
564
|
+
}
|
|
565
|
+
var en_US_default = {
|
|
566
|
+
access: { "empty": "No authorization records" },
|
|
567
|
+
network: {
|
|
568
|
+
"title": "Network",
|
|
569
|
+
"proxySettings": "Proxy settings",
|
|
570
|
+
"mode": "Proxy mode",
|
|
571
|
+
"system": "System proxy",
|
|
572
|
+
"manual": "Manual",
|
|
573
|
+
"direct": "Direct",
|
|
574
|
+
"environment": "Environment variables",
|
|
575
|
+
"url": "Proxy URL",
|
|
576
|
+
"noProxy": "Bypass proxy (comma-separated)",
|
|
577
|
+
"effective": "In effect",
|
|
578
|
+
"bypass": "Bypass",
|
|
579
|
+
"source": "Source",
|
|
580
|
+
"directValue": "Direct",
|
|
581
|
+
"bypassDetails": "Proxy bypass addresses",
|
|
582
|
+
"notLoaded": "No configuration available",
|
|
583
|
+
"unavailable": "Proxy configuration unavailable",
|
|
584
|
+
"addressRequired": "Enter a proxy URL.",
|
|
585
|
+
"support": "HTTP/HTTPS proxies without authentication are supported.",
|
|
586
|
+
"applying": "Updating…",
|
|
587
|
+
"refresh": "Refresh"
|
|
588
|
+
},
|
|
589
|
+
permissions: {
|
|
590
|
+
"approvalField": "Default authorization policy",
|
|
591
|
+
"systemRules": "System sandbox rules",
|
|
592
|
+
"systemRulesHint": "Select rows to enable or disable rules in bulk; click a rule count to inspect paths.",
|
|
593
|
+
"customRules": "Custom sandbox rules",
|
|
594
|
+
"customRulesHint": "Add files or directories that commands may read, including directory contents.",
|
|
595
|
+
"systemRule": "System",
|
|
596
|
+
"customRule": "Custom",
|
|
597
|
+
"ruleCount": "{{count}} rules",
|
|
598
|
+
"ruleCount_one": "{{count}} rule",
|
|
599
|
+
"enabledCount": "{{count}} enabled",
|
|
600
|
+
"enabled": "Enabled",
|
|
601
|
+
"disabled": "Disabled",
|
|
602
|
+
"noCustomRules": "No custom rules.",
|
|
603
|
+
"approval": "Authorization mode",
|
|
604
|
+
"approvalHint": "Choose how to handle file access, website access and commands without an existing permission.",
|
|
605
|
+
"ask": "Ask",
|
|
606
|
+
"deny": "Deny by default",
|
|
607
|
+
"allow": "Allow by default",
|
|
608
|
+
"allowWarning": "File access, website access and commands will be approved automatically. Set sandbox network permissions separately. Protected resources remain blocked.",
|
|
609
|
+
"readable": "Sandbox access",
|
|
610
|
+
"readableHint": "Choose additional files and directories that commands may read.",
|
|
611
|
+
"sandbox": "Sandbox",
|
|
612
|
+
"localPorts": "Allowed local ports",
|
|
613
|
+
"localPortsHint": "Allow all agents to connect to specified local TCP ports. Listening requires separate permission.",
|
|
614
|
+
"localPortsTrust": "Authorize only trusted local services; they may access the network or perform operations on your behalf.",
|
|
615
|
+
"localPortsEmpty": "No local ports allowed",
|
|
616
|
+
"localPortInvalid": "Enter an integer port from 1 to 65535",
|
|
617
|
+
"localPortProtected": "Gateway port; not active",
|
|
618
|
+
"localPortDuplicate": "This port is already listed",
|
|
619
|
+
"localPortAdd": "Add local port",
|
|
620
|
+
"localPortNumber": "TCP port",
|
|
621
|
+
"localPortsRemoval": "New commands will no longer connect to this port. Stop running commands to remove their existing permissions.",
|
|
622
|
+
"localPortsProcesses": "View running processes",
|
|
623
|
+
"localPortStop": "Stop",
|
|
624
|
+
"localPortsNoProcesses": "No running processes",
|
|
625
|
+
"readableAdd": "Add readable path",
|
|
626
|
+
"readableRemove": "Remove",
|
|
627
|
+
"readablePlaceholder": "Absolute path",
|
|
628
|
+
"readableWarning": "Commands may read the selected files or directories, including directory contents.",
|
|
629
|
+
"systemRulesManage": "Manage installed templates and read rules"
|
|
630
|
+
},
|
|
631
|
+
common: {
|
|
632
|
+
"increase": "Increase",
|
|
633
|
+
"decrease": "Decrease",
|
|
634
|
+
"back": "Back",
|
|
635
|
+
"edit": "Edit",
|
|
636
|
+
"save": "Save",
|
|
637
|
+
"create": "Create",
|
|
638
|
+
"add": "Add",
|
|
639
|
+
"remove": "Remove",
|
|
640
|
+
"cancel": "Cancel",
|
|
641
|
+
"confirm": "Confirm",
|
|
642
|
+
"dismiss": "Got it",
|
|
643
|
+
"retry": "Retry",
|
|
644
|
+
"working": "Working…"
|
|
645
|
+
},
|
|
646
|
+
settings: {
|
|
647
|
+
"close": "Close",
|
|
648
|
+
"personalization": "Personalization",
|
|
649
|
+
"runLayoutCombined": "Continuous outputs",
|
|
650
|
+
"runLayoutSegmented": "Separate replies",
|
|
651
|
+
"colorMode": "Color scheme",
|
|
652
|
+
"systemMode": "System",
|
|
653
|
+
"lightMode": "Light",
|
|
654
|
+
"darkMode": "Dark",
|
|
655
|
+
"brand": "Theme colour",
|
|
656
|
+
"contentWidth": "Content width",
|
|
657
|
+
"contentWidthDefault": "Default",
|
|
658
|
+
"contentWidthWide": "Wide",
|
|
659
|
+
"contentWidthFull": "Full",
|
|
660
|
+
"runLayout": "Reply layout",
|
|
661
|
+
"interfaceLanguage": "Interface language",
|
|
662
|
+
"permissions": "Security"
|
|
663
|
+
},
|
|
664
|
+
authorization: {
|
|
665
|
+
"sandboxIsolation": "Sandbox isolation",
|
|
666
|
+
"sandboxLocal": "Local sandbox",
|
|
667
|
+
"sandboxOff": "Off",
|
|
668
|
+
"sandboxLoading": "Reading sandbox isolation…",
|
|
669
|
+
"sandboxSaving": "Saving…",
|
|
670
|
+
"sandboxScope": "Prefer local sandbox isolation when available; otherwise commands use host permissions. Applies to all agents and workspaces, and only to newly started commands.",
|
|
671
|
+
"sandboxInactiveRules": "The rules below take effect when the local sandbox is restored. Access approvals for other tools are unaffected.",
|
|
672
|
+
"management": "Authorization management",
|
|
673
|
+
"sandboxManagement": "Sandbox management",
|
|
674
|
+
"website": "Public website access permissions",
|
|
675
|
+
"port": "Local port permissions",
|
|
676
|
+
"command": "Command permissions",
|
|
677
|
+
"records": "Authorization records",
|
|
678
|
+
"websiteHint": "Allow access to specified websites and ports for all agents.",
|
|
679
|
+
"portHint": "Allow all agents to connect to local services or listen on specified ports.",
|
|
680
|
+
"commandAccessHint": "Allow all agents to run specified commands in a specified directory.",
|
|
681
|
+
"globalHint": "Permissions apply to all agents. One-time approvals are not listed here.",
|
|
682
|
+
"recordsHint": "View and revoke existing permissions. One-time approvals are not listed here.",
|
|
683
|
+
"addwebsite": "Add public website access permission",
|
|
684
|
+
"addport": "Add local port permission",
|
|
685
|
+
"addcommand": "Add command permission",
|
|
686
|
+
"argv": "Exact executable arguments (JSON array)",
|
|
687
|
+
"cwd": "Working directory (absolute path)",
|
|
688
|
+
"commandHint": "Enter the full execution arguments and working directory. Changes require a new permission. Authorize file and network access separately.",
|
|
689
|
+
"commandInvalid": "Enter a nonempty string array and an absolute working directory.",
|
|
690
|
+
"hostInvalid": "Enter a host or *.domain and a specific TCP port.",
|
|
691
|
+
"host": "Host or domain pattern",
|
|
692
|
+
"operation": "Permission type",
|
|
693
|
+
"both": "Both",
|
|
694
|
+
"listenWarning": "Bind local-only services to 127.0.0.1 or ::1.",
|
|
695
|
+
"removalHint": "Revocation affects later operations. Stop running commands to remove their existing permissions.",
|
|
696
|
+
"scope": "Scope",
|
|
697
|
+
"global": "Global",
|
|
698
|
+
"source": "Source",
|
|
699
|
+
"manual": "Manual",
|
|
700
|
+
"approval": "Approved",
|
|
701
|
+
"state": "State",
|
|
702
|
+
"effective": "Active",
|
|
703
|
+
"inactive": "Blocked by policy or fixed restrictions",
|
|
704
|
+
"networkPolicies": "Network access settings",
|
|
705
|
+
"networkPoliciesHint": "Set public access, local connections and listening separately. Deny by default overrides existing permissions.",
|
|
706
|
+
"external": "Public network access",
|
|
707
|
+
"connect": "Local port connections",
|
|
708
|
+
"listen": "Local port listening",
|
|
709
|
+
"externalHint": "Control whether commands can access the internet.",
|
|
710
|
+
"connectHint": "Control whether commands can connect to local services.",
|
|
711
|
+
"listenHint": "Control whether commands can start services that other programs can connect to.",
|
|
712
|
+
"externalWarning": "Use Ask for public network access; Allow permits all external addresses.",
|
|
713
|
+
"protectedPorts": "Commands cannot access the YaoGuang service ports ({{ports}}).",
|
|
714
|
+
"kind": {
|
|
715
|
+
"file": "File",
|
|
716
|
+
"host": "Host",
|
|
717
|
+
"command": "Command",
|
|
718
|
+
"sandbox-network": "Sandbox external network",
|
|
719
|
+
"business-approval": "Business approval"
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
securityRules: {
|
|
723
|
+
"processes": "Running processes",
|
|
724
|
+
"triggerDuration": "While the task exists",
|
|
725
|
+
"search": "Search rules",
|
|
726
|
+
"bulkRemove": "Remove selected",
|
|
727
|
+
"bulkRevoke": "Revoke selected",
|
|
728
|
+
"clearSelection": "Clear selection",
|
|
729
|
+
"selectPage": "Select all rules on this page",
|
|
730
|
+
"selectRow": "Select {{label}}",
|
|
731
|
+
"noMatches": "No matching rules",
|
|
732
|
+
"pagination": "Rule pagination",
|
|
733
|
+
"previous": "Previous page",
|
|
734
|
+
"next": "Next page",
|
|
735
|
+
"pageSize": "Rows per page",
|
|
736
|
+
"perPage": "{{count}} per page",
|
|
737
|
+
"perPage_one": "{{count}} per page",
|
|
738
|
+
"confirmTitle": "{{verb}} {{count}} selected permissions?",
|
|
739
|
+
"confirmTitle_one": "{{verb}} {{count}} selected permission?",
|
|
740
|
+
"confirmRemove": "Confirm removal",
|
|
741
|
+
"confirmRevoke": "Confirm revocation",
|
|
742
|
+
"scope": "Scope",
|
|
743
|
+
"path": "Readable path",
|
|
744
|
+
"port": "Connection port",
|
|
745
|
+
"permission": "Permission",
|
|
746
|
+
"read": "Read allowed",
|
|
747
|
+
"connect": "Connection allowed",
|
|
748
|
+
"hostDuplicate": "This host rule is already listed",
|
|
749
|
+
"hostPreview": "Will allow {{host}}",
|
|
750
|
+
"removalHint": "Removes read permission for this path. Stop running commands to remove their existing permissions.",
|
|
751
|
+
"hostRemovalHint": "Removes access permission for this website.",
|
|
752
|
+
"kind": "Permission type",
|
|
753
|
+
"duration": "Duration",
|
|
754
|
+
"target": "Target",
|
|
755
|
+
"time": "Granted at",
|
|
756
|
+
"everyWorkspace": "Every workspace",
|
|
757
|
+
"category": "Rule category",
|
|
758
|
+
"bulkEnable": "Enable selected",
|
|
759
|
+
"bulkDisable": "Disable selected",
|
|
760
|
+
"enable": "Enable",
|
|
761
|
+
"disable": "Disable",
|
|
762
|
+
"systemSearch": "Search category or path",
|
|
763
|
+
"statusFilter": "Enabled status",
|
|
764
|
+
"filterAll": "All",
|
|
765
|
+
"filterEnabled": "Enabled",
|
|
766
|
+
"filterDisabled": "Disabled",
|
|
767
|
+
"matching": "{{count}} matching rules",
|
|
768
|
+
"matching_one": "{{count}} matching rule",
|
|
769
|
+
"expandAll": "Expand all",
|
|
770
|
+
"collapseAll": "Collapse all",
|
|
771
|
+
"expandGroup": "Expand {{name}}",
|
|
772
|
+
"collapseGroup": "Collapse {{name}}",
|
|
773
|
+
"selectWholeGroup": "Change all {{count}} rules in this group, including filtered rules",
|
|
774
|
+
"selectWholeGroup_one": "Change the {{count}} rule in this group, including filtered rules",
|
|
775
|
+
"system": "System environment",
|
|
776
|
+
"systemHint": "System commands, libraries, and runtime resources",
|
|
777
|
+
"devTools": "Development tools · DevTools",
|
|
778
|
+
"devToolsHint": "Package managers, toolchains, and dependency caches",
|
|
779
|
+
"applications": "Installed applications and tools",
|
|
780
|
+
"applicationsHint": "Homebrew and Xcode",
|
|
781
|
+
"other": "Other system rules",
|
|
782
|
+
"otherHint": "System paths outside the scenarios above",
|
|
783
|
+
"groupEnable": "Enable {{name}}",
|
|
784
|
+
"groupCount": "{{enabled}} / {{count}} enabled",
|
|
785
|
+
"groupCount_one": "{{enabled}} / {{count}} enabled",
|
|
786
|
+
"portSuggestions": "Example ports",
|
|
787
|
+
"load": "Reading configuration…"
|
|
788
|
+
},
|
|
789
|
+
security: {
|
|
790
|
+
"switchProfessional": "Switch to professional mode",
|
|
791
|
+
"switchSimple": "Switch to simple mode",
|
|
792
|
+
"presets": "Security presets",
|
|
793
|
+
"default": "Default mode",
|
|
794
|
+
"automatic": "Automatic mode",
|
|
795
|
+
"dangerous": "Dangerous mode",
|
|
796
|
+
"defaultBehavior": "Ask you before actions that need extra permissions.",
|
|
797
|
+
"defaultProtection": "Prefer sandbox isolation when available; otherwise approve commands with host permissions.",
|
|
798
|
+
"automaticBehavior": "Allow actions automatically, with fewer questions and interruptions.",
|
|
799
|
+
"automaticProtection": "Prefer sandbox isolation when available; otherwise commands run with host permissions.",
|
|
800
|
+
"dangerousBehavior": "Allow actions automatically; commands run with your permissions on this computer.",
|
|
801
|
+
"dangerousProtection": "YaoGuang's isolation limits no longer apply. Commands can access files and networks, including YaoGuang's own data and services.",
|
|
802
|
+
"saving": "Saving…",
|
|
803
|
+
"preferenceFailure": "This browser could not save the display preference. Your choice is kept until this page closes.",
|
|
804
|
+
"retry": "Retry",
|
|
805
|
+
"custom": "Current configuration is custom. Switch to Professional to inspect it, or choose a preset to replace the policies.",
|
|
806
|
+
"offline": "Disconnected. Reconnect before changing security settings.",
|
|
807
|
+
"loading": "Reading security configuration…",
|
|
808
|
+
"recoveryFailure": "Business and configuration writes are stopped because security configuration recovery failed. Complete recovery and reload before continuing.",
|
|
809
|
+
"isolationInactive": "Sandbox isolation is not active",
|
|
810
|
+
"unavailableReason": "This system cannot provide sandbox isolation: {{reason}}. Your sandbox setting remains enabled.",
|
|
811
|
+
"dangerousReason": "You selected Dangerous mode, which turns off sandbox isolation.",
|
|
812
|
+
"explicitlyDisabled": "You manually turned off sandbox isolation.",
|
|
813
|
+
"directIsolationWarning": "Commands run with your permissions on this computer and can access files and networks, including YaoGuang's own data and services."
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
var zh_CN_default = {
|
|
817
|
+
access: { "empty": "暂无授权记录" },
|
|
818
|
+
network: {
|
|
819
|
+
"title": "网络",
|
|
820
|
+
"proxySettings": "代理设置",
|
|
821
|
+
"mode": "代理模式",
|
|
822
|
+
"system": "系统代理",
|
|
823
|
+
"manual": "手动设置",
|
|
824
|
+
"direct": "直连",
|
|
825
|
+
"environment": "环境变量",
|
|
826
|
+
"url": "代理地址",
|
|
827
|
+
"noProxy": "绕过代理(逗号分隔)",
|
|
828
|
+
"effective": "当前生效",
|
|
829
|
+
"bypass": "绕过",
|
|
830
|
+
"source": "配置来源",
|
|
831
|
+
"directValue": "直连",
|
|
832
|
+
"bypassDetails": "绕过代理的地址",
|
|
833
|
+
"notLoaded": "暂无配置",
|
|
834
|
+
"unavailable": "代理配置不可用",
|
|
835
|
+
"addressRequired": "请输入代理地址。",
|
|
836
|
+
"support": "支持 HTTP/HTTPS 代理,不支持身份认证。",
|
|
837
|
+
"applying": "正在更新…",
|
|
838
|
+
"refresh": "刷新"
|
|
839
|
+
},
|
|
840
|
+
permissions: {
|
|
841
|
+
"approvalField": "默认授权策略",
|
|
842
|
+
"systemRules": "系统沙箱规则",
|
|
843
|
+
"systemRulesHint": "选择规则后批量启用或禁用;点击规则数量查看路径。",
|
|
844
|
+
"customRules": "自定义沙箱规则",
|
|
845
|
+
"customRulesHint": "添加允许命令读取的文件或目录;目录内的内容也可读取。",
|
|
846
|
+
"systemRule": "系统",
|
|
847
|
+
"customRule": "自定义",
|
|
848
|
+
"ruleCount": "共 {{count}} 条",
|
|
849
|
+
"enabledCount": "已启用 {{count}} 条",
|
|
850
|
+
"enabled": "启用",
|
|
851
|
+
"disabled": "禁用",
|
|
852
|
+
"noCustomRules": "暂无自定义规则。",
|
|
853
|
+
"approval": "授权模式",
|
|
854
|
+
"approvalHint": "设置如何处理尚未授权的文件访问、网站访问和命令执行。",
|
|
855
|
+
"ask": "询问",
|
|
856
|
+
"deny": "默认拒绝",
|
|
857
|
+
"allow": "默认允许",
|
|
858
|
+
"allowWarning": "未授权的文件访问、网站访问和命令执行将自动获准。沙箱网络权限需单独设置,受保护内容仍不可访问。",
|
|
859
|
+
"readable": "沙箱授权",
|
|
860
|
+
"readableHint": "设置命令可读取的额外文件和目录。",
|
|
861
|
+
"sandbox": "沙箱",
|
|
862
|
+
"localPorts": "允许连接的本机端口",
|
|
863
|
+
"localPortsHint": "允许所有智能体连接指定的本机 TCP 端口,不包含端口监听。",
|
|
864
|
+
"localPortsTrust": "请仅授权可信的本机服务;服务可代为联网或执行操作。",
|
|
865
|
+
"localPortsEmpty": "尚未允许任何本机端口",
|
|
866
|
+
"localPortInvalid": "请输入 1 至 65535 的整数端口",
|
|
867
|
+
"localPortProtected": "瑶光网关端口,当前不生效",
|
|
868
|
+
"localPortDuplicate": "该端口已在列表中",
|
|
869
|
+
"localPortAdd": "添加本机端口",
|
|
870
|
+
"localPortNumber": "TCP 端口",
|
|
871
|
+
"localPortsRemoval": "移除后,新命令不能再连接此端口。要收回运行中命令的权限,请停止该命令。",
|
|
872
|
+
"localPortsProcesses": "查看运行中的进程",
|
|
873
|
+
"localPortStop": "停止",
|
|
874
|
+
"localPortsNoProcesses": "没有运行中的进程",
|
|
875
|
+
"readableAdd": "添加可读路径",
|
|
876
|
+
"readableRemove": "移除",
|
|
877
|
+
"readablePlaceholder": "绝对路径",
|
|
878
|
+
"readableWarning": "所选文件或目录将允许命令读取,包含目录内的内容。",
|
|
879
|
+
"systemRulesManage": "管理已安装模板与读取规则"
|
|
880
|
+
},
|
|
881
|
+
common: {
|
|
882
|
+
"increase": "增加",
|
|
883
|
+
"decrease": "减少",
|
|
884
|
+
"back": "返回",
|
|
885
|
+
"edit": "编辑",
|
|
886
|
+
"save": "保存",
|
|
887
|
+
"create": "创建",
|
|
888
|
+
"add": "添加",
|
|
889
|
+
"remove": "移除",
|
|
890
|
+
"cancel": "取消",
|
|
891
|
+
"confirm": "确定",
|
|
892
|
+
"dismiss": "知道了",
|
|
893
|
+
"retry": "重试",
|
|
894
|
+
"working": "处理中……"
|
|
895
|
+
},
|
|
896
|
+
settings: {
|
|
897
|
+
"close": "关闭",
|
|
898
|
+
"personalization": "个性化设置",
|
|
899
|
+
"runLayoutCombined": "连续显示输出",
|
|
900
|
+
"runLayoutSegmented": "按回复分段",
|
|
901
|
+
"colorMode": "显示模式",
|
|
902
|
+
"systemMode": "跟随系统",
|
|
903
|
+
"lightMode": "浅色",
|
|
904
|
+
"darkMode": "深色",
|
|
905
|
+
"brand": "主题色",
|
|
906
|
+
"contentWidth": "内容宽度",
|
|
907
|
+
"contentWidthDefault": "默认",
|
|
908
|
+
"contentWidthWide": "宽屏",
|
|
909
|
+
"contentWidthFull": "全宽",
|
|
910
|
+
"runLayout": "回复排版",
|
|
911
|
+
"interfaceLanguage": "界面语言",
|
|
912
|
+
"permissions": "安全"
|
|
913
|
+
},
|
|
914
|
+
authorization: {
|
|
915
|
+
"sandboxIsolation": "沙箱隔离方案",
|
|
916
|
+
"sandboxLocal": "本地沙箱",
|
|
917
|
+
"sandboxOff": "关闭",
|
|
918
|
+
"sandboxLoading": "正在读取沙箱隔离方案…",
|
|
919
|
+
"sandboxSaving": "正在保存…",
|
|
920
|
+
"sandboxScope": "可用时优先使用本地沙箱隔离;不可用时命令使用宿主权限。适用于所有智能体和工作空间,仅影响新启动的命令。",
|
|
921
|
+
"sandboxInactiveRules": "下方规则将在恢复本地沙箱后生效;其他工具的访问授权不受影响。",
|
|
922
|
+
"management": "授权管理",
|
|
923
|
+
"sandboxManagement": "沙箱管理",
|
|
924
|
+
"website": "公网网站访问授权",
|
|
925
|
+
"port": "本机端口授权",
|
|
926
|
+
"command": "指令授权",
|
|
927
|
+
"records": "访问授权记录",
|
|
928
|
+
"websiteHint": "允许访问指定的网站和端口,对所有智能体生效。",
|
|
929
|
+
"portHint": "允许连接本机服务或监听指定端口,对所有智能体生效。",
|
|
930
|
+
"commandAccessHint": "允许在指定目录执行指定命令,对所有智能体生效。",
|
|
931
|
+
"globalHint": "授权对所有智能体生效;单次授权不在此列出。",
|
|
932
|
+
"recordsHint": "查看和撤销已有授权;单次授权不在此列出。",
|
|
933
|
+
"addwebsite": "新增公网网站访问授权",
|
|
934
|
+
"addport": "新增本机端口授权",
|
|
935
|
+
"addcommand": "新增指令授权",
|
|
936
|
+
"argv": "完整执行参数(JSON 数组)",
|
|
937
|
+
"cwd": "工作目录(绝对路径)",
|
|
938
|
+
"commandHint": "填写完整执行参数和工作目录;更改后需重新授权。文件和网络访问需单独授权。",
|
|
939
|
+
"commandInvalid": "请输入非空字符串数组和绝对工作目录。",
|
|
940
|
+
"hostInvalid": "请输入主机或 *.域名,并指定 TCP 端口。",
|
|
941
|
+
"host": "主机或域名模式",
|
|
942
|
+
"operation": "授权类型",
|
|
943
|
+
"both": "全部",
|
|
944
|
+
"listenWarning": "仅供本机使用的服务,请绑定 127.0.0.1 或 ::1。",
|
|
945
|
+
"removalHint": "撤销仅影响后续操作。要收回运行中命令的权限,请停止该命令。",
|
|
946
|
+
"scope": "影响范围",
|
|
947
|
+
"global": "全局",
|
|
948
|
+
"source": "来源",
|
|
949
|
+
"manual": "手工配置",
|
|
950
|
+
"approval": "人工批准",
|
|
951
|
+
"state": "状态",
|
|
952
|
+
"effective": "生效",
|
|
953
|
+
"inactive": "策略或固定规则阻止",
|
|
954
|
+
"networkPolicies": "网络访问设置",
|
|
955
|
+
"networkPoliciesHint": "分别设置公网访问、本机连接和端口监听权限;「默认拒绝」优先于已有授权。",
|
|
956
|
+
"external": "公网网络访问",
|
|
957
|
+
"connect": "本机端口连接",
|
|
958
|
+
"listen": "本机端口监听",
|
|
959
|
+
"externalHint": "控制命令访问互联网。",
|
|
960
|
+
"connectHint": "控制命令连接本机服务。",
|
|
961
|
+
"listenHint": "控制命令启动服务,供其他程序连接。",
|
|
962
|
+
"externalWarning": "公网访问建议选择「询问」;「默认允许」会放行所有外部地址。",
|
|
963
|
+
"protectedPorts": "命令不能访问瑶光服务端口({{ports}})。",
|
|
964
|
+
"kind": {
|
|
965
|
+
"file": "文件",
|
|
966
|
+
"host": "主机",
|
|
967
|
+
"command": "指令",
|
|
968
|
+
"sandbox-network": "沙箱外网",
|
|
969
|
+
"business-approval": "业务审批"
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
securityRules: {
|
|
973
|
+
"processes": "运行中进程",
|
|
974
|
+
"triggerDuration": "任务存续期间",
|
|
975
|
+
"search": "搜索规则",
|
|
976
|
+
"bulkRemove": "批量移除",
|
|
977
|
+
"bulkRevoke": "批量撤销",
|
|
978
|
+
"clearSelection": "取消选择",
|
|
979
|
+
"selectPage": "选择本页全部规则",
|
|
980
|
+
"selectRow": "选择 {{label}}",
|
|
981
|
+
"noMatches": "没有匹配的规则",
|
|
982
|
+
"pagination": "规则分页",
|
|
983
|
+
"previous": "上一页",
|
|
984
|
+
"next": "下一页",
|
|
985
|
+
"pageSize": "每页条数",
|
|
986
|
+
"perPage": "每页 {{count}} 条",
|
|
987
|
+
"confirmTitle": "{{verb}}选中的 {{count}} 条许可?",
|
|
988
|
+
"confirmRemove": "确认移除",
|
|
989
|
+
"confirmRevoke": "确认撤销",
|
|
990
|
+
"scope": "匹配范围",
|
|
991
|
+
"path": "可读路径",
|
|
992
|
+
"port": "连接端口",
|
|
993
|
+
"permission": "权限",
|
|
994
|
+
"read": "允许读取",
|
|
995
|
+
"connect": "允许连接",
|
|
996
|
+
"hostDuplicate": "该主机规则已在列表中",
|
|
997
|
+
"hostPreview": "将允许 {{host}}",
|
|
998
|
+
"removalHint": "移除后,此路径的读取授权将失效。要收回运行中命令的权限,请停止该命令。",
|
|
999
|
+
"hostRemovalHint": "移除后,此网站的访问授权将失效。",
|
|
1000
|
+
"kind": "权限类型",
|
|
1001
|
+
"duration": "有效期",
|
|
1002
|
+
"target": "授权对象",
|
|
1003
|
+
"time": "授权时间",
|
|
1004
|
+
"everyWorkspace": "全部工作空间",
|
|
1005
|
+
"category": "规则分类",
|
|
1006
|
+
"bulkEnable": "批量启用",
|
|
1007
|
+
"bulkDisable": "批量禁用",
|
|
1008
|
+
"enable": "启用",
|
|
1009
|
+
"disable": "禁用",
|
|
1010
|
+
"systemSearch": "搜索分类或路径",
|
|
1011
|
+
"statusFilter": "启用状态",
|
|
1012
|
+
"filterAll": "全部",
|
|
1013
|
+
"filterEnabled": "已启用",
|
|
1014
|
+
"filterDisabled": "未启用",
|
|
1015
|
+
"matching": "匹配 {{count}} 条",
|
|
1016
|
+
"expandAll": "全部展开",
|
|
1017
|
+
"collapseAll": "全部收起",
|
|
1018
|
+
"expandGroup": "展开 {{name}}",
|
|
1019
|
+
"collapseGroup": "收起 {{name}}",
|
|
1020
|
+
"selectWholeGroup": "操作整组 {{count}} 条规则,包括筛选隐藏的规则",
|
|
1021
|
+
"system": "系统运行环境",
|
|
1022
|
+
"systemHint": "系统命令、共享库与基础运行资源",
|
|
1023
|
+
"devTools": "开发工具 · DevTools",
|
|
1024
|
+
"devToolsHint": "包管理器、工具链与依赖缓存",
|
|
1025
|
+
"applications": "已安装的应用与工具",
|
|
1026
|
+
"applicationsHint": "Homebrew 与 Xcode",
|
|
1027
|
+
"other": "其他系统规则",
|
|
1028
|
+
"otherHint": "未归入上述场景的系统路径",
|
|
1029
|
+
"groupEnable": "启用 {{name}}",
|
|
1030
|
+
"groupCount": "{{enabled}} / {{count}} 已启用",
|
|
1031
|
+
"portSuggestions": "常用端口示例",
|
|
1032
|
+
"load": "正在读取配置…"
|
|
1033
|
+
},
|
|
1034
|
+
security: {
|
|
1035
|
+
"switchProfessional": "切换至专业模式",
|
|
1036
|
+
"switchSimple": "切换至简洁模式",
|
|
1037
|
+
"presets": "安全预设",
|
|
1038
|
+
"default": "默认模式",
|
|
1039
|
+
"automatic": "自动模式",
|
|
1040
|
+
"dangerous": "危险模式",
|
|
1041
|
+
"defaultBehavior": "遇到需要额外权限的操作,会先询问你。",
|
|
1042
|
+
"defaultProtection": "可用时优先使用沙箱隔离;不可用时审批使用宿主权限的命令。",
|
|
1043
|
+
"automaticBehavior": "自动允许需要授权的操作,减少询问和打断。",
|
|
1044
|
+
"automaticProtection": "可用时优先使用沙箱隔离;不可用时命令使用宿主权限运行。",
|
|
1045
|
+
"dangerousBehavior": "自动允许操作,命令直接使用你在电脑上的权限运行。",
|
|
1046
|
+
"dangerousProtection": "不再受瑶光的隔离限制,可访问文件和网络,包括瑶光自身的数据和服务。",
|
|
1047
|
+
"saving": "正在保存…",
|
|
1048
|
+
"preferenceFailure": "当前浏览器无法保存页面模式;本页会保留你的选择,关闭后恢复默认。",
|
|
1049
|
+
"retry": "重试",
|
|
1050
|
+
"custom": "当前为自定义配置,可切换专业模式查看,或选择预设覆盖策略。",
|
|
1051
|
+
"offline": "连接已断开,请重新连接后再修改安全设置。",
|
|
1052
|
+
"loading": "正在读取安全配置…",
|
|
1053
|
+
"recoveryFailure": "安全配置恢复失败,业务与配置写入已停止。请完成恢复并重新读取后再继续。",
|
|
1054
|
+
"isolationInactive": "沙箱隔离未生效",
|
|
1055
|
+
"unavailableReason": "当前系统无法提供沙箱隔离:{{reason}}。沙箱设置仍保持开启。",
|
|
1056
|
+
"dangerousReason": "你已选择危险模式,主动关闭了沙箱隔离。",
|
|
1057
|
+
"explicitlyDisabled": "你已手动关闭沙箱隔离。",
|
|
1058
|
+
"directIsolationWarning": "命令会使用你在电脑上的权限运行,可访问文件与网络,包括瑶光自身的数据和服务。"
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region ui-src/index.tsx
|
|
1063
|
+
function flatten(value, prefix = "") {
|
|
1064
|
+
return Object.fromEntries(Object.entries(value).flatMap(([key, entry]) => typeof entry === "string" ? [[prefix + key, entry]] : Object.entries(flatten(entry, `${prefix}${key}.`))));
|
|
1065
|
+
}
|
|
1066
|
+
/** Renders only this owner's authorization controls. */
|
|
1067
|
+
function AuthorizationPanel() {
|
|
1068
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1069
|
+
/* @__PURE__ */ jsx(ApprovalPanel, {}),
|
|
1070
|
+
/* @__PURE__ */ jsx(WebHostsPanel, {}),
|
|
1071
|
+
/* @__PURE__ */ jsx(LocalPortsPanel, {}),
|
|
1072
|
+
/* @__PURE__ */ jsx(ResourceGrantsPanel, { kind: "command" }),
|
|
1073
|
+
/* @__PURE__ */ jsx(ResourceGrantsPanel, { kind: "records" })
|
|
1074
|
+
] });
|
|
1075
|
+
}
|
|
1076
|
+
function SecurityPage() {
|
|
1077
|
+
const { t } = useTranslation$1();
|
|
1078
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1079
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
1080
|
+
children: [/* @__PURE__ */ jsx("header", {
|
|
1081
|
+
className: "flex h-16 shrink-0 items-center gap-3 px-6 sm:pr-14",
|
|
1082
|
+
children: /* @__PURE__ */ jsx("h2", {
|
|
1083
|
+
className: "text-lg font-semibold",
|
|
1084
|
+
children: t("settings.permissions")
|
|
1085
|
+
})
|
|
1086
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1087
|
+
className: "@container flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto px-6 pb-6 pt-1",
|
|
1088
|
+
children: /* @__PURE__ */ jsx(AuthorizationPanel, {})
|
|
1089
|
+
})]
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
/** Public browser framework version. */
|
|
1093
|
+
var runtimeVersion = 5;
|
|
1094
|
+
/** Optional authorization tab contribution. */
|
|
1095
|
+
var provides = ["authorization-settings"];
|
|
1096
|
+
/** Uses the sandbox page when present and otherwise owns the same Security navigation entry. */
|
|
1097
|
+
function register(ctx) {
|
|
1098
|
+
configureApi(ctx);
|
|
1099
|
+
configureTranslations(ctx);
|
|
1100
|
+
ctx.i18n.register({
|
|
1101
|
+
"en-US": flatten(en_US_default),
|
|
1102
|
+
"zh-CN": flatten(zh_CN_default)
|
|
1103
|
+
}, "zh-CN");
|
|
1104
|
+
ctx.services.provide("authorization-settings", {
|
|
1105
|
+
component: AuthorizationPanel,
|
|
1106
|
+
ports: LocalPortsPanel
|
|
1107
|
+
});
|
|
1108
|
+
let drop;
|
|
1109
|
+
const refresh = () => {
|
|
1110
|
+
if (ctx.signal.aborted) return;
|
|
1111
|
+
if (ctx.services.get("sandbox-settings")) {
|
|
1112
|
+
drop?.();
|
|
1113
|
+
drop = void 0;
|
|
1114
|
+
} else if (!drop) drop = ctx.slots.register("shell.settings.category", {
|
|
1115
|
+
id: "permissions",
|
|
1116
|
+
label: () => ctx.i18n.t("settings.permissions"),
|
|
1117
|
+
icon: "shield-check",
|
|
1118
|
+
region: "preset",
|
|
1119
|
+
order: 50,
|
|
1120
|
+
layout: "fill",
|
|
1121
|
+
component: SecurityPage
|
|
1122
|
+
});
|
|
1123
|
+
};
|
|
1124
|
+
const off = ctx.services.subscribe("sandbox-settings", refresh);
|
|
1125
|
+
refresh();
|
|
1126
|
+
ctx.signal.addEventListener("abort", () => {
|
|
1127
|
+
off();
|
|
1128
|
+
drop?.();
|
|
1129
|
+
}, { once: true });
|
|
1130
|
+
}
|
|
1131
|
+
//#endregion
|
|
1132
|
+
export { AuthorizationPanel, provides, register, runtimeVersion };
|
package/README.md
DELETED