@eum-agent/sandbox-presets 1.0.2 → 1.2.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 (2) hide show
  1. package/dist/index.js +12 -80
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,15 +1,11 @@
1
+ import { delimiter, dirname, isAbsolute, normalize, parse, resolve } from "node:path";
1
2
  import { existsSync } from "node:fs";
2
3
  import { fileURLToPath } from "node:url";
3
4
  import { z } from "zod";
4
5
  import { createHash, randomUUID } from "node:crypto";
5
- import { delimiter, isAbsolute, normalize, parse, resolve } from "node:path";
6
6
  //#region src/sandbox-presets/schema.ts
7
- /** Strict public preset data and persisted application shapes. */
8
- /** Fixed repository; users never submit arbitrary download URLs. */
9
7
  const PRESET_REPOSITORY = "https://github.com/yanxuan-lc/yaoguang-presets";
10
- /** A full Git object identity. */
11
8
  const ShaSchema = z.string().regex(/^[a-f0-9]{40}$/);
12
- /** Portable owner-local category identity. */
13
9
  const IdSchema = z.string().max(80).regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);
14
10
  const text = (max) => z.string().refine((s) => [...s].length >= 1 && [...s].length <= max && /\S/u.test(s), "invalid text length");
15
11
  const url = z.string().max(2048).refine((value) => {
@@ -24,7 +20,6 @@ const date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
24
20
  const d = /* @__PURE__ */ new Date(`${value}T00:00:00Z`);
25
21
  return Number.isFinite(d.getTime()) && d.toISOString().slice(0, 10) === value;
26
22
  }, "invalid calendar date");
27
- /** Environment names allowed by preset locator syntax; bootstrap injects these as explicit policy. */
28
23
  const SANDBOX_LOCATOR_ENVIRONMENT_NAMES = [
29
24
  "XDG_CONFIG_HOME",
30
25
  "XDG_CACHE_HOME",
@@ -74,9 +69,7 @@ const SANDBOX_LOCATOR_ENVIRONMENT_NAMES = [
74
69
  "LOCALAPPDATA",
75
70
  "USERPROFILE"
76
71
  ];
77
- /** Literal locator syntax shared with the maintained schema; no interpolation code. */
78
72
  const LocatorSchema = z.string().max(4096).regex(new RegExp(String.raw`^(?!.*(?:^|\/)(?:\.|\.\.)(?:\/|$))(?!.*\/\/)(?:~\/(?!$)|\/(?!\/|$)|[A-Za-z]:\/(?!\/|$)|\$\{(?:${SANDBOX_LOCATOR_ENVIRONMENT_NAMES.join("|")})\}(?:\/|$))[^\u0000-\u001f\u007f\\*?[\]{}$\x60:]*$`, "u"));
79
- /** One declared configuration root and its public provenance. */
80
73
  const EntrySchema = z.object({
81
74
  id: IdSchema,
82
75
  path: LocatorSchema,
@@ -86,7 +79,6 @@ const EntrySchema = z.object({
86
79
  sources: z.array(url).min(1).max(8)
87
80
  }).strict();
88
81
  const platform = z.object({ readable: z.array(EntrySchema).min(1).max(4096) }).strict();
89
- /** Complete category content; unknown fields cannot acquire semantics. */
90
82
  const ProfileSchema = z.object({
91
83
  id: IdSchema,
92
84
  name: text(120),
@@ -123,7 +115,6 @@ const ProfileSchema = z.object({
123
115
  }
124
116
  }
125
117
  });
126
- /** Exact source bytes and revision: remote Git commit or package-local Git blob identity. */
127
118
  const StoredProfileSchema = z.object({
128
119
  id: IdSchema,
129
120
  commit: ShaSchema,
@@ -131,18 +122,15 @@ const StoredProfileSchema = z.object({
131
122
  content: z.string().max(131072),
132
123
  profile: ProfileSchema
133
124
  }).strict();
134
- /** Complete verified snapshot used for new selections. */
135
125
  const SnapshotSchema = z.object({
136
126
  commit: ShaSchema,
137
127
  syncedAt: z.string(),
138
128
  profiles: z.array(StoredProfileSchema).min(1).max(128)
139
129
  }).strict();
140
- /** User choice identifies an exact category revision, never a filesystem root. */
141
130
  const SelectionSchema = z.object({
142
131
  presetId: IdSchema,
143
132
  commit: ShaSchema
144
133
  }).strict();
145
- /** Roots explicitly confirmed at apply time; missing locators are not persisted as permissions. */
146
134
  const ContributionSchema = z.object({
147
135
  presetId: IdSchema,
148
136
  entryId: IdSchema,
@@ -154,13 +142,11 @@ const ContributionSchema = z.object({
154
142
  containsCredentials: z.boolean(),
155
143
  sources: z.array(url).min(1).max(8)
156
144
  }).strict();
157
- /** Durable receipt for the most recently committed application only. */
158
145
  const ReceiptSchema = z.object({
159
146
  previewId: z.uuid(),
160
147
  revision: z.number().int().nonnegative(),
161
148
  selections: z.array(SelectionSchema).max(128)
162
149
  }).strict();
163
- /** One atomic installation-level state row. */
164
150
  const StoredStateSchema = z.object({
165
151
  revision: z.number().int().nonnegative(),
166
152
  available: SnapshotSchema.nullable(),
@@ -170,9 +156,7 @@ const StoredStateSchema = z.object({
170
156
  }).strict();
171
157
  //#endregion
172
158
  //#region src/sandbox-presets/bundled.ts
173
- /** Offline runtime profile copied verbatim from the maintained preset repository. */
174
- const content$1 = "{\n \"id\": \"system-runtime\",\n \"name\": \"基础运行环境\",\n \"description\": \"macOS 基础命令、系统库和系统运行数据的只读访问;新安装随平台扩展默认安装。\",\n \"verification\": {\n \"level\": \"documentation\",\n \"toolVersions\": [\n \"macOS system runtime\"\n ],\n \"checkedAt\": \"2026-10-04\"\n },\n \"notes\": [\n \"不另行增加 /opt/homebrew、Xcode 或用户研发工具目录;/usr 的递归读取包含 /usr/local,因此也覆盖 Intel Homebrew 安装在该处的内容。\",\n \"/Library 和系统配置目录可能包含主机及应用配置;安装前核对整个递归读取范围。\",\n \"只授予读取,缺失目录不会在以后出现时自动获权。\"\n ],\n \"platforms\": {\n \"darwin\": {\n \"readable\": [\n {\n \"id\": \"system-1\",\n \"path\": \"/usr\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/usr;不授予写入。\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-2\",\n \"path\": \"/bin\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/bin;不授予写入。\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-3\",\n \"path\": \"/sbin\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/sbin;不授予写入。\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-4\",\n \"path\": \"/System\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/System;不授予写入。\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-5\",\n \"path\": \"/Library\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/Library;不授予写入。\",\n \"containsCredentials\": true,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-6\",\n \"path\": \"/private/etc\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/private/etc;不授予写入。\",\n \"containsCredentials\": true,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-7\",\n \"path\": \"/private/var/db\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/private/var/db;不授予写入。\",\n \"containsCredentials\": true,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-8\",\n \"path\": \"/private/var/select\",\n \"targetType\": \"directory\",\n \"description\": \"macOS 系统运行目录的递归读取:/private/var/select;不授予写入。\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n }\n ]\n }\n }\n}\n";
175
- /** Exact profile bytes from https://github.com/yanxuan-lc/yaoguang-presets/blob/8f5eab8e92914178791d7f562d141d0d84857592/sandbox/system-runtime/paths.json. */
159
+ const content$1 = "{\n \"id\": \"system-runtime\",\n \"name\": \"\u57fa\u7840\u8fd0\u884c\u73af\u5883\",\n \"description\": \"macOS \u57fa\u7840\u547d\u4ee4\u3001\u7cfb\u7edf\u5e93\u548c\u7cfb\u7edf\u8fd0\u884c\u6570\u636e\u7684\u53ea\u8bfb\u8bbf\u95ee\uff1b\u65b0\u5b89\u88c5\u968f\u5e73\u53f0\u6269\u5c55\u9ed8\u8ba4\u5b89\u88c5\u3002\",\n \"verification\": {\n \"level\": \"documentation\",\n \"toolVersions\": [\n \"macOS system runtime\"\n ],\n \"checkedAt\": \"2026-10-04\"\n },\n \"notes\": [\n \"\u4e0d\u53e6\u884c\u589e\u52a0 /opt/homebrew\u3001Xcode \u6216\u7528\u6237\u7814\u53d1\u5de5\u5177\u76ee\u5f55\uff1b/usr \u7684\u9012\u5f52\u8bfb\u53d6\u5305\u542b /usr/local\uff0c\u56e0\u6b64\u4e5f\u8986\u76d6 Intel Homebrew \u5b89\u88c5\u5728\u8be5\u5904\u7684\u5185\u5bb9\u3002\",\n \"/Library \u548c\u7cfb\u7edf\u914d\u7f6e\u76ee\u5f55\u53ef\u80fd\u5305\u542b\u4e3b\u673a\u53ca\u5e94\u7528\u914d\u7f6e\uff1b\u5b89\u88c5\u524d\u6838\u5bf9\u6574\u4e2a\u9012\u5f52\u8bfb\u53d6\u8303\u56f4\u3002\",\n \"\u53ea\u6388\u4e88\u8bfb\u53d6\uff0c\u7f3a\u5931\u76ee\u5f55\u4e0d\u4f1a\u5728\u4ee5\u540e\u51fa\u73b0\u65f6\u81ea\u52a8\u83b7\u6743\u3002\"\n ],\n \"platforms\": {\n \"darwin\": {\n \"readable\": [\n {\n \"id\": \"system-1\",\n \"path\": \"/usr\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/usr\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-2\",\n \"path\": \"/bin\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/bin\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-3\",\n \"path\": \"/sbin\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/sbin\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-4\",\n \"path\": \"/System\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/System\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-5\",\n \"path\": \"/Library\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/Library\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": true,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-6\",\n \"path\": \"/private/etc\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/private/etc\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": true,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-7\",\n \"path\": \"/private/var/db\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/private/var/db\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": true,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n },\n {\n \"id\": \"system-8\",\n \"path\": \"/private/var/select\",\n \"targetType\": \"directory\",\n \"description\": \"macOS \u7cfb\u7edf\u8fd0\u884c\u76ee\u5f55\u7684\u9012\u5f52\u8bfb\u53d6\uff1a/private/var/select\uff1b\u4e0d\u6388\u4e88\u5199\u5165\u3002\",\n \"containsCredentials\": false,\n \"sources\": [\n \"https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html\"\n ]\n }\n ]\n }\n }\n}\n";
176
160
  const BUNDLED_PRESETS = [StoredProfileSchema.parse({
177
161
  id: "system-runtime",
178
162
  commit: "8f5eab8e92914178791d7f562d141d0d84857592",
@@ -182,13 +166,9 @@ const BUNDLED_PRESETS = [StoredProfileSchema.parse({
182
166
  })];
183
167
  //#endregion
184
168
  //#region src/sandbox-presets/errors.ts
185
- /** Safe error categories; neither environment values nor remote error bodies cross this boundary. */
186
169
  var PresetError = class extends Error {
187
- /** Stable management failure code. */
188
170
  code;
189
- /** Optional server-directed retry delay in seconds. */
190
171
  retryAfterSeconds;
191
- /** Creates an actionable failure with already sanitized text. */
192
172
  constructor(code, message, retryAfterSeconds) {
193
173
  super(message);
194
174
  this.name = "PresetError";
@@ -196,11 +176,9 @@ var PresetError = class extends Error {
196
176
  this.retryAfterSeconds = retryAfterSeconds;
197
177
  }
198
178
  };
199
- /** Throws a bounded catalog error without echoing untrusted input. */
200
179
  function invalid(message) {
201
180
  throw new PresetError("CATALOG_INVALID", message);
202
181
  }
203
- /** Parses JSON without silently accepting duplicate object keys. */
204
182
  function parseJson(content) {
205
183
  let value;
206
184
  try {
@@ -225,7 +203,6 @@ function parseJson(content) {
225
203
  }
226
204
  return value;
227
205
  }
228
- /** Decodes lossless UTF-8, retaining BOMs for the JSON grammar to reject. */
229
206
  function decodeUtf8(bytes) {
230
207
  try {
231
208
  return new TextDecoder("utf-8", {
@@ -238,8 +215,6 @@ function decodeUtf8(bytes) {
238
215
  }
239
216
  //#endregion
240
217
  //#region src/sandbox-presets/catalog.ts
241
- /** Generated bundle verification for one pinned commit of the fixed public repository. */
242
- /** Computes Git's SHA-1 blob identity over exact UTF-8 bytes. */
243
218
  function blobSha(bytes) {
244
219
  return createHash("sha1").update(`blob ${bytes.length}\0`).update(bytes).digest("hex");
245
220
  }
@@ -249,7 +224,6 @@ const BundleSchema = z.object({ presets: z.array(z.object({
249
224
  blobSha: ShaSchema,
250
225
  content: z.string()
251
226
  }).strict()).min(1).max(128) }).strict();
252
- /** Validates retained source bytes against their decoded profile and digest. */
253
227
  function verifyProfile(stored) {
254
228
  const bytes = Buffer.from(stored.content);
255
229
  if (bytes.length > 131072) throw new PresetError("LIMIT_EXCEEDED", "Profile exceeds 128 KiB");
@@ -257,12 +231,6 @@ function verifyProfile(stored) {
257
231
  const result = ProfileSchema.safeParse(parseJson(stored.content));
258
232
  if (!result.success || result.data.id !== stored.id || JSON.stringify(result.data) !== JSON.stringify(stored.profile)) invalid("Profile content and identity disagree");
259
233
  }
260
- /**
261
- * Decodes the generated bundle read from one pinned commit into a complete snapshot.
262
- * Every category must have a unique id, live at `sandbox/<id>/paths.json`, and carry content
263
- * whose Git blob identity matches its declared digest. Throws `PresetError` with
264
- * `CATALOG_INVALID` for malformed or inconsistent data and `LIMIT_EXCEEDED` for oversized input.
265
- */
266
234
  function decodeCatalog(commit, bytes, syncedAt = (/* @__PURE__ */ new Date()).toISOString()) {
267
235
  if (bytes.length > 8388608) throw new PresetError("LIMIT_EXCEEDED", "Catalog exceeds 8 MiB");
268
236
  const bundle = BundleSchema.safeParse(parseJson(decodeUtf8(bytes)));
@@ -295,20 +263,19 @@ function decodeCatalog(commit, bytes, syncedAt = (/* @__PURE__ */ new Date()).to
295
263
  }
296
264
  //#endregion
297
265
  //#region src/sandbox-presets/linux-bundled.ts
298
- /** Package-maintained Linux baseline; independent of the downloaded Darwin snapshot. */
299
266
  const profile = ProfileSchema.parse({
300
267
  id: "linux-system-runtime",
301
- name: "Linux 基础运行环境",
302
- description: "Linux 系统命令、动态库、名称解析与公共证书的只读访问;新安装默认启用,可移除。",
268
+ name: "Linux \u57fa\u7840\u8fd0\u884c\u73af\u5883",
269
+ description: "Linux \u7cfb\u7edf\u547d\u4ee4\u3001\u52a8\u6001\u5e93\u3001\u540d\u79f0\u89e3\u6790\u4e0e\u516c\u5171\u8bc1\u4e66\u7684\u53ea\u8bfb\u8bbf\u95ee\uff1b\u65b0\u5b89\u88c5\u9ed8\u8ba4\u542f\u7528\uff0c\u53ef\u79fb\u9664\u3002",
303
270
  verification: {
304
271
  level: "documentation",
305
272
  toolVersions: ["Linux filesystem hierarchy"],
306
273
  checkedAt: "2026-10-06"
307
274
  },
308
275
  notes: [
309
- "由平台扩展维护,修订号为随包内容的 Git blob 身份,不代表远程预设仓库的提交。",
310
- "/usr 包含 /usr/local;只授予读取,不增加用户工具目录、私钥目录或写入权限。",
311
- "符号链接解析到真实目标;缺失目标不会在之后出现时自动获权。"
276
+ "\u7531\u5e73\u53f0\u6269\u5c55\u7ef4\u62a4\uff0c\u4fee\u8ba2\u53f7\u4e3a\u968f\u5305\u5185\u5bb9\u7684 Git blob \u8eab\u4efd\uff0c\u4e0d\u4ee3\u8868\u8fdc\u7a0b\u9884\u8bbe\u4ed3\u5e93\u7684\u63d0\u4ea4\u3002",
277
+ "/usr \u5305\u542b /usr/local\uff1b\u53ea\u6388\u4e88\u8bfb\u53d6\uff0c\u4e0d\u589e\u52a0\u7528\u6237\u5de5\u5177\u76ee\u5f55\u3001\u79c1\u94a5\u76ee\u5f55\u6216\u5199\u5165\u6743\u9650\u3002",
278
+ "\u7b26\u53f7\u94fe\u63a5\u89e3\u6790\u5230\u771f\u5b9e\u76ee\u6807\uff1b\u7f3a\u5931\u76ee\u6807\u4e0d\u4f1a\u5728\u4e4b\u540e\u51fa\u73b0\u65f6\u81ea\u52a8\u83b7\u6743\u3002"
312
279
  ],
313
280
  platforms: { linux: { readable: [
314
281
  "/usr",
@@ -328,14 +295,13 @@ const profile = ProfileSchema.parse({
328
295
  id: `runtime-${index + 1}`,
329
296
  path,
330
297
  targetType: index < 6 ? "directory" : "file",
331
- description: `Linux 基础运行环境只读目标:${path}`,
298
+ description: `Linux \u57fa\u7840\u8fd0\u884c\u73af\u5883\u53ea\u8bfb\u76ee\u6807\uff1a${path}`,
332
299
  containsCredentials: false,
333
300
  sources: ["https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html"]
334
301
  })) } }
335
302
  });
336
303
  const content = `${JSON.stringify(profile, null, 2)}\n`;
337
304
  const identity = blobSha(Buffer.from(content));
338
- /** Local immutable content revision, never treated as a remote catalog commit. */
339
305
  const BUNDLED_LINUX_PRESETS = [{
340
306
  id: profile.id,
341
307
  commit: identity,
@@ -345,8 +311,6 @@ const BUNDLED_LINUX_PRESETS = [{
345
311
  }];
346
312
  //#endregion
347
313
  //#region src/sandbox-presets/paths.ts
348
- /** Locator resolution reads host facts and metadata only, never configuration bodies. */
349
- /** Resolves one platform's entries and fingerprints locator facts without returning raw environment. */
350
314
  function resolveProfile(profile, commit, host, reads) {
351
315
  const platform = profile.platforms[host.platform];
352
316
  const rows = [], contributions = [], facts = [];
@@ -413,7 +377,6 @@ function resolveProfile(profile, commit, host, reads) {
413
377
  //#region src/sandbox-presets/sync.ts
414
378
  const refsUrl = "https://github.com/yanxuan-lc/yaoguang-presets.git/info/refs?service=git-upload-pack";
415
379
  const rawBase = "https://raw.githubusercontent.com/yanxuan-lc/yaoguang-presets";
416
- /** Reads one bounded public response; failures map to stable preset error codes. */
417
380
  async function readResponse(network, url, signal) {
418
381
  signal.throwIfAborted();
419
382
  let response;
@@ -459,11 +422,6 @@ async function readResponse(network, url, signal) {
459
422
  reader.releaseLock();
460
423
  }
461
424
  }
462
- /**
463
- * Extracts the `refs/heads/main` commit from a Git smart HTTP upload-pack ref advertisement.
464
- * Requires the `# service=git-upload-pack` announcement and well-formed pkt-lines; throws
465
- * `PresetError` with `CATALOG_INVALID` otherwise.
466
- */
467
425
  function mainCommit(text) {
468
426
  const lines = [];
469
427
  for (let at = 0; at < text.length;) {
@@ -485,10 +443,6 @@ function mainCommit(text) {
485
443
  }
486
444
  return invalid("Branch main is not advertised");
487
445
  }
488
- /**
489
- * Resolves `main` with one ref-advertisement request, then reads `sandbox/index.json` pinned to
490
- * that commit. An unchanged commit reuses `previous` with a fresh sync time and no second request.
491
- */
492
446
  async function synchronize(network, signal, previous) {
493
447
  const commit = mainCommit(decodeUtf8(await readResponse(network, refsUrl, signal)));
494
448
  if (previous?.commit === commit) return {
@@ -501,13 +455,6 @@ async function synchronize(network, signal, previous) {
501
455
  }
502
456
  //#endregion
503
457
  //#region src/sandbox-presets/service.ts
504
- /**
505
- * Creates one activation with committed owner permissions and offline package candidates.
506
- * Installs the supplied package profiles only into a pristine supported-platform state; a recorded
507
- * application or explicit removal prevents later automatic installation. An absent optional
508
- * projection defers installation until a state or readable-source read can inspect roots. Initialization
509
- * failures contribute no preset permissions. Source reads never download catalogs.
510
- */
511
458
  function createPresetService(deps) {
512
459
  const { host, store, reads, owner } = deps;
513
460
  const supportedPlatform = host.platform === "darwin" || host.platform === "linux";
@@ -730,7 +677,6 @@ function createPresetService(deps) {
730
677
  };
731
678
  }
732
679
  const service = {
733
- /** Reads committed enabled names without touching path projection or initialization. */
734
680
  summary() {
735
681
  try {
736
682
  guard();
@@ -878,7 +824,6 @@ function createPresetService(deps) {
878
824
  }
879
825
  //#endregion
880
826
  //#region src/sandbox-presets/store.ts
881
- /** Checks relational identities in addition to the strict JSON shape. */
882
827
  function validateState(input) {
883
828
  const parsed = StoredStateSchema.safeParse(input);
884
829
  if (!parsed.success) throw new PresetError("CATALOG_INVALID", "Stored preset state is invalid; contribution is disabled");
@@ -909,7 +854,6 @@ function validateState(input) {
909
854
  if (state.receipt && (state.receipt.revision !== state.revision || JSON.stringify(selections) !== JSON.stringify(state.receipt.selections))) throw new PresetError("CATALOG_INVALID", "Receipt does not match applied state");
910
855
  return state;
911
856
  }
912
- /** Creates the state authority on the supplied cooperative database lease. */
913
857
  function createPresetStore(storage) {
914
858
  const { db } = storage;
915
859
  const name = storage.tableName("sandbox_catalog_state");
@@ -972,11 +916,9 @@ function createPresetStore(storage) {
972
916
  }
973
917
  return {
974
918
  read,
975
- /** Reads confirmed permissions independently of the replaceable download cache. */
976
919
  readApplied() {
977
920
  return applied(row());
978
921
  },
979
- /** Reports damaged downloaded data without invalidating confirmed permissions. */
980
922
  cacheError() {
981
923
  try {
982
924
  available(row());
@@ -990,7 +932,6 @@ function createPresetStore(storage) {
990
932
  }
991
933
  },
992
934
  transact,
993
- /** Replaces available data only after full validation; applied fields are preserved. */
994
935
  saveSnapshot(snapshot) {
995
936
  return transact((before) => ({
996
937
  ...before,
@@ -1001,8 +942,6 @@ function createPresetStore(storage) {
1001
942
  }
1002
943
  //#endregion
1003
944
  //#region src/sandbox-presets/views.ts
1004
- /** Browser management values validated by the extension at the socket boundary. */
1005
- /** Per-entry locator and current metadata outcome. */
1006
945
  const RowSchema = z.object({
1007
946
  presetId: z.string(),
1008
947
  entryId: z.string(),
@@ -1024,7 +963,6 @@ const RowSchema = z.object({
1024
963
  containsCredentials: z.boolean(),
1025
964
  sources: z.array(z.string())
1026
965
  }).strict();
1027
- /** All provenance retained for one target. */
1028
966
  const TargetSourceSchema = z.object({
1029
967
  owner: z.string(),
1030
968
  id: z.string(),
@@ -1038,13 +976,11 @@ const TargetSourceSchema = z.object({
1038
976
  entryId: z.string().optional(),
1039
977
  commit: ShaSchema.optional()
1040
978
  }).strict();
1041
- /** A unique actual read root; parents never replace child roots. */
1042
979
  const TargetSchema = z.object({
1043
980
  path: z.string(),
1044
981
  targetType: z.enum(["file", "directory"]),
1045
982
  sources: z.array(TargetSourceSchema)
1046
983
  }).strict();
1047
- /** One selectable category, including removed-but-applied old versions. */
1048
984
  const CategorySchema = z.object({
1049
985
  id: z.string(),
1050
986
  name: z.string(),
@@ -1060,7 +996,6 @@ const CategorySchema = z.object({
1060
996
  latest: ProfileSchema.nullable(),
1061
997
  entries: z.array(EntrySchema)
1062
998
  }).strict();
1063
- /** Current local state; list never makes HTTP requests. */
1064
999
  const StateSchema = z.object({
1065
1000
  source: z.string(),
1066
1001
  bundled: z.object({
@@ -1088,7 +1023,6 @@ const StateSchema = z.object({
1088
1023
  message: z.string()
1089
1024
  }).nullable()
1090
1025
  }).strict();
1091
- /** An exact permission draft with actual roots, inactive rows, and full source differences. */
1092
1026
  const PreviewSchema = z.object({
1093
1027
  previewId: z.uuid(),
1094
1028
  inputRevision: z.string(),
@@ -1106,20 +1040,17 @@ const PreviewSchema = z.object({
1106
1040
  inactiveCount: z.number(),
1107
1041
  canApply: z.boolean()
1108
1042
  }).strict();
1109
- /** Committed application with most-recent receipt replay status. */
1110
1043
  const ApplySchema = z.object({
1111
1044
  state: StateSchema,
1112
1045
  receipt: ReceiptSchema,
1113
1046
  alreadyApplied: z.boolean()
1114
1047
  }).strict();
1115
- /** A business failure that leaves prior permission state untouched. */
1116
1048
  const FailureSchema = z.object({
1117
1049
  ok: z.literal(false),
1118
1050
  code: z.string(),
1119
1051
  message: z.string(),
1120
1052
  retryAfterSeconds: z.number().optional()
1121
1053
  }).strict();
1122
- /** Constructs a real result schema for owner-managed RPC responses. */
1123
1054
  function resultSchema(data) {
1124
1055
  return z.union([z.object({
1125
1056
  ok: z.literal(true),
@@ -1128,7 +1059,6 @@ function resultSchema(data) {
1128
1059
  }
1129
1060
  //#endregion
1130
1061
  //#region src/sandbox-presets/register.ts
1131
- /** Registers installation-level catalog management and a pure invalidation frame. */
1132
1062
  function registerSandboxPresets(ctx) {
1133
1063
  const frame = ctx.client.registerFrame({
1134
1064
  name: "sandboxPresetChanged",
@@ -1211,7 +1141,6 @@ function registerSandboxPresets(ctx) {
1211
1141
  }
1212
1142
  //#endregion
1213
1143
  //#region src/index.ts
1214
- /** Owns sandbox-presets capabilities independently from bootstrap resources. */
1215
1144
  const plugin = {
1216
1145
  name: "@eum-agent/sandbox-presets",
1217
1146
  requires: ["sandbox-path-locator", "network"],
@@ -1220,7 +1149,10 @@ const plugin = {
1220
1149
  apply(ctx) {
1221
1150
  registerSandboxPresets(ctx);
1222
1151
  const module = fileURLToPath(new URL("../ui/ui.js", import.meta.url));
1223
- if (existsSync(module)) ctx.client.registerUi({ module });
1152
+ if (existsSync(module)) ctx.client.registerPackageFiles({
1153
+ root: dirname(module),
1154
+ entry: "ui.js"
1155
+ });
1224
1156
  }
1225
1157
  };
1226
1158
  //#endregion
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "en-US": "Sandbox Presets",
5
5
  "zh-CN": "沙箱预设"
6
6
  },
7
- "version": "1.0.2",
7
+ "version": "1.2.0",
8
8
  "type": "module",
9
9
  "description": "Sandbox Presets",
10
10
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  "zod": "^4.4.3"
22
22
  },
23
23
  "devDependencies": {
24
- "@eum-agent/plugin": "1.0.1",
24
+ "@eum-agent/plugin": "1.2.0",
25
25
  "@types/react": "^19.2.18",
26
26
  "@types/react-dom": "^19.2.5",
27
27
  "react": "^19.2.0",
@@ -37,8 +37,8 @@
37
37
  "lucide-react": "^1.40.0",
38
38
  "@types/semver": "7.8.0",
39
39
  "i18next": "^26.4.1",
40
- "@eum-agent/infra-local": "1.0.1",
41
- "@eum-agent/storage-sqlite": "1.0.1"
40
+ "@eum-agent/infra-local": "1.2.0",
41
+ "@eum-agent/storage-sqlite": "1.2.0"
42
42
  },
43
43
  "yaoguang": {
44
44
  "kind": "extension",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {},
50
50
  "foundationDependencies": {
51
- "@eum-agent/infra-local": "1.0.1",
52
- "@eum-agent/storage-sqlite": "1.0.1"
51
+ "@eum-agent/infra-local": "1.2.0",
52
+ "@eum-agent/storage-sqlite": "1.2.0"
53
53
  }
54
54
  },
55
55
  "scripts": {