dsh-extra-paths 0.2.1 → 0.3.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 (52) hide show
  1. package/README.md +189 -28
  2. package/README.zh.md +163 -21
  3. package/lib/argv.js +96 -24
  4. package/lib/argv.js.map +1 -1
  5. package/lib/client.js +1169 -467
  6. package/lib/config.js +140 -44
  7. package/lib/config.js.map +1 -1
  8. package/lib/context.js +48 -12
  9. package/lib/context.js.map +1 -1
  10. package/lib/denial.js +132 -0
  11. package/lib/denial.js.map +1 -0
  12. package/lib/index.js +40 -5
  13. package/lib/index.js.map +1 -1
  14. package/lib/name-rule.js +217 -0
  15. package/lib/name-rule.js.map +1 -0
  16. package/lib/paths.js +155 -27
  17. package/lib/paths.js.map +1 -1
  18. package/lib/pattern.js +128 -62
  19. package/lib/pattern.js.map +1 -1
  20. package/lib/platform.js +325 -0
  21. package/lib/platform.js.map +1 -0
  22. package/lib/preview.js +47 -20
  23. package/lib/preview.js.map +1 -1
  24. package/lib/resolve.js +345 -64
  25. package/lib/resolve.js.map +1 -1
  26. package/lib/schema.js +19 -6
  27. package/lib/schema.js.map +1 -1
  28. package/lib/shell-dialect.js +92 -0
  29. package/lib/shell-dialect.js.map +1 -0
  30. package/lib/tool-guard.js +214 -0
  31. package/lib/tool-guard.js.map +1 -0
  32. package/lib/types/argv.d.ts +50 -12
  33. package/lib/types/config.d.ts +29 -13
  34. package/lib/types/context.d.ts +6 -1
  35. package/lib/types/denial.d.ts +88 -0
  36. package/lib/types/index.d.ts +8 -4
  37. package/lib/types/name-rule.d.ts +112 -0
  38. package/lib/types/paths.d.ts +55 -10
  39. package/lib/types/pattern.d.ts +43 -5
  40. package/lib/types/platform.d.ts +148 -0
  41. package/lib/types/preview.d.ts +39 -3
  42. package/lib/types/resolve.d.ts +129 -23
  43. package/lib/types/schema.d.ts +24 -8
  44. package/lib/types/shell-dialect.d.ts +60 -0
  45. package/lib/types/tool-guard.d.ts +103 -0
  46. package/lib/types/wrap-fs.d.ts +86 -4
  47. package/lib/types/wrap-sandbox.d.ts +26 -6
  48. package/lib/wrap-fs.js +323 -47
  49. package/lib/wrap-fs.js.map +1 -1
  50. package/lib/wrap-sandbox.js +149 -12
  51. package/lib/wrap-sandbox.js.map +1 -1
  52. package/package.json +1 -1
@@ -0,0 +1,217 @@
1
+ /**
2
+ * NAME RULES: a configured path that is a single component (`.git`, `.env`,
3
+ * `node_modules`) means "that component at any depth", not one literal path.
4
+ *
5
+ * Why: protecting the same handful of names in every repository should not need
6
+ * a full path (or a walk-everything pattern) per checkout. A bare name is the
7
+ * cheapest possible spelling of "this structure anywhere in my projects".
8
+ *
9
+ * Two different jobs, deliberately separate:
10
+ * - {@link findNameComponent} is the LEXICAL, filesystem-free test the fs
11
+ * wrapper runs per call: it walks the target's components under the scope
12
+ * roots and returns the matched component path (or undefined). It costs
13
+ * nothing and applies to files created a moment ago.
14
+ * - {@link expandNameMatches} is the bounded filesystem WALK. It exists ONLY for
15
+ * the settings preview's "N matches right now" display: the shell surface
16
+ * deliberately does not enumerate bare names (that was costly, stale and
17
+ * partial in the real host), so no enforcement path walks. The preview caches
18
+ * the walk and reports when a cap makes the count partial; fs stays exact
19
+ * either way.
20
+ *
21
+ * Scope (chosen by the user): the session workspace plus every configured
22
+ * writable root. A name is compared case-insensitively on a Windows host.
23
+ * @module dsh-extra-paths/name-rule
24
+ */
25
+ import { lstatSync, readdirSync } from 'node:fs';
26
+ import { isUnder, pathApiOf } from './paths.js';
27
+ /** Caps that keep one name-rule walk bounded (same spirit as the pattern limits). */
28
+ export const NAME_RULE_LIMITS = {
29
+ /** Directory entries examined in one expansion pass. */
30
+ maxDirs: 8192,
31
+ /** Directory levels walked below each scope root. */
32
+ maxDepth: 12,
33
+ /** Paths one name rule may match (each match becomes a sandbox rule). */
34
+ maxMatches: 256,
35
+ /** How long one expansion is reused (milliseconds). */
36
+ cacheMs: 30000,
37
+ };
38
+ /** Names the walk never DESCENDS into: their own name is still matched at its level. */
39
+ const PRUNED_DESCENT = new Set(['node_modules', '.git']);
40
+ /**
41
+ * Build the scope roots of every name rule: the session workspace plus every
42
+ * configured writable root, deduplicated and with nested roots dropped (a root
43
+ * inside another cannot add a match the outer walk would miss).
44
+ * @param workspaceRoot - the session workspace (canonical).
45
+ * @param writableRoots - canonical roots of the configured write entries.
46
+ * @returns scope roots in walk order.
47
+ */
48
+ export function scopeRootsOf(workspaceRoot, writableRoots, facts) {
49
+ const api = pathApiOf(facts);
50
+ const candidates = [workspaceRoot, ...writableRoots].map(root => api.resolve(root));
51
+ const out = [];
52
+ for (const candidate of candidates) {
53
+ if (out.some(existing => isUnder(candidate, existing, facts)))
54
+ continue;
55
+ out.push(candidate);
56
+ }
57
+ return out;
58
+ }
59
+ /** The component comparator, case-insensitive on Windows like the host. */
60
+ function sameComponent(left, right, facts) {
61
+ return facts.platform === 'win32' ? left.toLowerCase() === right.toLowerCase() : left === right;
62
+ }
63
+ /**
64
+ * The LEXICAL match: find the first component named `name` on the path from one
65
+ * of the scope roots down to the target. No filesystem access, so a name rule
66
+ * applies to a directory the moment it appears.
67
+ * @param targetKey - a canonical target path.
68
+ * @param name - the component name to match.
69
+ * @param scopeRoots - {@link scopeRootsOf} output.
70
+ * @param facts - host facts.
71
+ * @returns the matched component path (the rule's effective root), or undefined.
72
+ */
73
+ export function findNameComponent(targetKey, name, scopeRoots, facts) {
74
+ const api = pathApiOf(facts);
75
+ for (const root of scopeRoots) {
76
+ if (!isUnder(targetKey, root, facts))
77
+ continue;
78
+ // A scope root whose OWN basename matches (e.g. a writable root named `.git`).
79
+ if (sameComponent(api.basename(root), name, facts))
80
+ return root;
81
+ const relative = api.relative(root, targetKey);
82
+ if (relative === '')
83
+ continue;
84
+ const segments = relative.split(api.sep);
85
+ let current = root;
86
+ for (const segment of segments) {
87
+ current = api.join(current, segment);
88
+ if (sameComponent(segment, name, facts))
89
+ return current;
90
+ }
91
+ }
92
+ return undefined;
93
+ }
94
+ /**
95
+ * The bounded filesystem walk for one name rule: enumerate concrete matches so
96
+ * the shell sandbox can deny them.
97
+ *
98
+ * Matching stops at a match (the rule covers its whole subtree, so descending is
99
+ * wasted work), and the walk never descends into `node_modules`/`.git` (their
100
+ * own names are still matched at their level). Symlinked matches are SKIPPED and
101
+ * counted: a sandbox cannot reliably mask a link destination, so the caller must
102
+ * report the incompleteness instead of pretending the path is covered.
103
+ * @param name - the component name to match.
104
+ * @param scopeRoots - {@link scopeRootsOf} output.
105
+ * @param facts - host facts.
106
+ * @param limits - caps (tests pass a small budget to pin the degraded path).
107
+ * @returns the concrete matches plus the completeness verdict.
108
+ */
109
+ export function expandNameMatches(name, scopeRoots, facts, limits = NAME_RULE_LIMITS) {
110
+ const api = pathApiOf(facts);
111
+ const matched = new Set();
112
+ const budget = { scanned: 0 };
113
+ let truncated = false;
114
+ let skippedSymlinks = 0;
115
+ const incompleteRoots = new Set();
116
+ const walk = (directory, depth, root) => {
117
+ if (budget.cap !== undefined)
118
+ return;
119
+ if (budget.scanned >= limits.maxDirs) {
120
+ budget.cap = 'directories';
121
+ incompleteRoots.add(root);
122
+ return;
123
+ }
124
+ budget.scanned += 1;
125
+ let entries;
126
+ try {
127
+ entries = readdirSync(directory).sort();
128
+ }
129
+ catch {
130
+ // Unreadable directory: this ROOT is incomplete, but the other roots (and
131
+ // what was already found here) keep their value instead of being thrown
132
+ // away with it.
133
+ incompleteRoots.add(root);
134
+ return;
135
+ }
136
+ for (const entry of entries) {
137
+ const full = api.join(directory, entry);
138
+ if (sameComponent(entry, name, facts)) {
139
+ if (matched.size >= limits.maxMatches) {
140
+ budget.cap = 'matches';
141
+ incompleteRoots.add(root);
142
+ return;
143
+ }
144
+ try {
145
+ if (lstatSync(full).isSymbolicLink()) {
146
+ skippedSymlinks += 1;
147
+ incompleteRoots.add(root);
148
+ continue;
149
+ }
150
+ matched.add(api.resolve(full));
151
+ }
152
+ catch {
153
+ // Vanished between readdir and lstat: the next pass will see it, but
154
+ // this pass cannot claim completeness.
155
+ incompleteRoots.add(root);
156
+ }
157
+ continue;
158
+ }
159
+ if (depth >= limits.maxDepth) {
160
+ truncated = true;
161
+ incompleteRoots.add(root);
162
+ continue;
163
+ }
164
+ if (PRUNED_DESCENT.has(entry))
165
+ continue;
166
+ let directoryEntry = false;
167
+ try {
168
+ directoryEntry = lstatSync(full).isDirectory();
169
+ }
170
+ catch {
171
+ incompleteRoots.add(root);
172
+ continue;
173
+ }
174
+ if (directoryEntry)
175
+ walk(full, depth + 1, root);
176
+ if (budget.cap !== undefined)
177
+ return;
178
+ }
179
+ };
180
+ const roots = [...scopeRoots];
181
+ for (let index = 0; index < roots.length; index += 1) {
182
+ const root = roots[index] ?? '';
183
+ if (sameComponent(api.basename(root), name, facts)) {
184
+ // The root itself is the match; its subtree is covered, nothing to walk.
185
+ matched.add(root);
186
+ continue;
187
+ }
188
+ let directory = false;
189
+ try {
190
+ directory = lstatSync(root).isDirectory();
191
+ }
192
+ catch {
193
+ incompleteRoots.add(root);
194
+ }
195
+ if (directory)
196
+ walk(root, 0, root);
197
+ if (budget.cap !== undefined) {
198
+ // A global budget stopped the walk: every root not visited yet is
199
+ // incomplete too, or the caller would mistake "never looked" for "clean".
200
+ for (const remaining of roots.slice(index + 1))
201
+ incompleteRoots.add(remaining);
202
+ break;
203
+ }
204
+ }
205
+ const matches = [...matched].sort();
206
+ return {
207
+ matches,
208
+ capped: budget.cap !== undefined,
209
+ ...(budget.cap === undefined ? {} : { cap: budget.cap }),
210
+ truncated,
211
+ incompleteRoots: [...incompleteRoots].sort(),
212
+ skippedSymlinks,
213
+ scanned: budget.scanned,
214
+ complete: budget.cap === undefined && incompleteRoots.size === 0,
215
+ };
216
+ }
217
+ //# sourceMappingURL=name-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-rule.js","sourceRoot":"","sources":["../src/name-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,SAAS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epest EXISTING ancestor plus the remaining suffix — so a not-yet-created
5
5
  * directory still compares equal to the path the enforcement layer computes.
6
+ *
7
+ * The FILE-SYSTEM side lives here; the pure spelling/dialect vocabulary lives
8
+ * in `platform.ts` and is re-used by both halves. Host facts (platform, WSL,
9
+ * home) are always injected, so the Windows and WSL rules are unit-testable on
10
+ * a POSIX machine and the client can share the pure part.
6
11
  * @module dsh-extra-paths/paths
7
12
  */
8
- import { existsSync, realpathSync } from 'node:fs';
9
- import { homedir } from 'node:os';
10
- import { basename, dirname, isAbsolute, join, relative, resolve as resolvePath, sep } from 'node:path';
13
+ import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
14
+ import { homedir, release } from 'node:os';
15
+ import { dirname as posixDirname, posix, win32 } from 'node:path';
16
+ import { DEFAULT_WSL_MOUNT_ROOT, expandPath, hostDialect, isHostVolumeRoot, } from './platform.js';
17
+ export { expandPath } from './platform.js';
18
+ /** `process.platform` cannot change at runtime; the WSL probe is cached too. */
19
+ let cachedFacts;
11
20
  /**
12
- * Resolve one configured path spelling to an absolute path.
13
- * @param raw - the configured spelling: absolute, `~`-anchored, or relative.
21
+ * Whether this Linux host is a WSL guest: WSL exports `WSL_DISTRO_NAME` /
22
+ * `WSL_INTEROP` into the environment, and older releases only expose the
23
+ * Microsoft kernel string.
24
+ * @returns true inside WSL.
25
+ */
26
+ export function isWslHost() {
27
+ if (process.platform !== 'linux')
28
+ return false;
29
+ if (process.env.WSL_DISTRO_NAME !== undefined || process.env.WSL_INTEROP !== undefined)
30
+ return true;
31
+ return release().toLowerCase().includes('microsoft');
32
+ }
33
+ /**
34
+ * Discover where Windows drives are mounted inside WSL. `/mnt` is the default,
35
+ * but `/etc/wsl.conf` can remap the automount root, so the REAL mount table is
36
+ * consulted when it is readable; failure falls back to the documented default.
37
+ * @returns the mount root without a trailing slash.
38
+ */
39
+ export function detectWslMountRoot() {
40
+ try {
41
+ const mounts = readFileSync('/proc/mounts', 'utf8');
42
+ for (const line of mounts.split('\n')) {
43
+ const [source, mountPoint, fsType] = line.split(' ');
44
+ if (mountPoint === undefined || source === undefined)
45
+ continue;
46
+ // drvfs/9p rows look like `C: /mnt/c drvfs rw,relatime 0 0`.
47
+ if (!/^[A-Za-z]:$/.test(source) || !/drvfs|9p/i.test(fsType ?? ''))
48
+ continue;
49
+ const root = posixDirname(mountPoint);
50
+ if (root !== '/' && root !== '.')
51
+ return root.replace(/\/+$/, '');
52
+ }
53
+ }
54
+ catch {
55
+ // No /proc/mounts (non-Linux or restricted): fall back to the default.
56
+ }
57
+ return DEFAULT_WSL_MOUNT_ROOT;
58
+ }
59
+ /**
60
+ * The host facts the path layer needs, discovered from the running process.
61
+ * @returns a frozen snapshot (cached: platform, WSL flag and home cannot move).
62
+ */
63
+ export function discoverPlatformFacts() {
64
+ if (cachedFacts !== undefined)
65
+ return cachedFacts;
66
+ const wsl = isWslHost();
67
+ cachedFacts = Object.freeze({
68
+ platform: process.platform,
69
+ wsl,
70
+ wslMountRoot: wsl ? detectWslMountRoot() : DEFAULT_WSL_MOUNT_ROOT,
71
+ home: homedir(),
72
+ });
73
+ return cachedFacts;
74
+ }
75
+ /** Test-only: forget the discovered facts so a different host can be simulated. */
76
+ export function resetPlatformFactsCache() {
77
+ cachedFacts = undefined;
78
+ }
79
+ /** The `node:path` implementation matching one host. */
80
+ export function pathApiOf(facts) {
81
+ return hostDialect(facts) === 'windows' ? win32 : posix;
82
+ }
83
+ /** The dialect of host-native paths. */
84
+ export function hostPathDialect(facts = discoverPlatformFacts()) {
85
+ return hostDialect(facts);
86
+ }
87
+ /**
88
+ * Resolve one configured spelling to a canonical host-native path.
89
+ * @param raw - the configured spelling: absolute, `~`-anchored, relative, or a
90
+ * path from the other platform (translated when the host can map it).
14
91
  * @param workspaceRoot - the session workspace a relative spelling is resolved against.
15
- * @param home - home directory seam (tests).
16
- * @returns the absolute path, not yet canonicalised.
92
+ * @param facts - host facts (defaults to the discovered ones).
93
+ * @returns the expansion outcome, including the `foreign` reason.
17
94
  */
18
- export function expandPath(raw, workspaceRoot, home = homedir()) {
19
- if (raw === '~')
20
- return home;
21
- if (raw.startsWith(`~${sep}`) || raw.startsWith('~/'))
22
- return join(home, raw.slice(2));
23
- if (isAbsolute(raw))
24
- return raw;
25
- return resolvePath(workspaceRoot, raw);
95
+ export function expandConfiguredPath(raw, workspaceRoot, facts = discoverPlatformFacts()) {
96
+ return expandPath(raw, workspaceRoot, facts);
26
97
  }
27
98
  /**
28
99
  * Canonical spelling of a configured root. Symlinked ancestors are resolved
29
100
  * (so `/tmp` and `/private/tmp` cannot silently fail to match), while a suffix
30
101
  * that does not exist yet is appended verbatim.
31
- * @param path - an absolute path.
102
+ * @param path - an absolute path in the host's dialect.
103
+ * @param facts - host facts (defaults to the discovered ones).
32
104
  * @returns the canonical spelling.
33
105
  */
34
- export function canonicalizeRoot(path) {
35
- const resolved = resolvePath(path);
106
+ export function canonicalizeRoot(path, facts = discoverPlatformFacts()) {
107
+ const api = pathApiOf(facts);
108
+ const resolved = api.resolve(path);
36
109
  const suffix = [];
37
110
  let probe = resolved;
38
111
  while (!existsSync(probe)) {
39
- const parent = dirname(probe);
112
+ const parent = api.dirname(probe);
40
113
  if (parent === probe)
41
114
  return resolved;
42
- suffix.unshift(basename(probe));
115
+ suffix.unshift(api.basename(probe));
43
116
  probe = parent;
44
117
  }
45
118
  let real;
@@ -49,22 +122,77 @@ export function canonicalizeRoot(path) {
49
122
  catch {
50
123
  real = probe;
51
124
  }
52
- return suffix.length === 0 ? real : join(real, ...suffix);
125
+ return suffix.length === 0 ? real : api.join(real, ...suffix);
126
+ }
127
+ /**
128
+ * Whether a canonical path names a volume root on THIS host (translated Windows
129
+ * drive roots included: `/mnt/c` inside WSL).
130
+ * @param path - a canonical host-native path.
131
+ * @param facts - host facts (defaults to the discovered ones).
132
+ * @returns true for a filesystem/volume root.
133
+ */
134
+ export function isHostVolumeRootPath(path, facts = discoverPlatformFacts()) {
135
+ return isHostVolumeRoot(path, facts);
136
+ }
137
+ /** Whether identity fallback is worth its `stat` cost on this host. */
138
+ function mightAliasSpellings(facts) {
139
+ // Plain Linux (ext4 etc.) compares case-sensitively and has no 8.3 aliases;
140
+ // macOS is case-insensitive by default and WSL's drvfs/windows shares are
141
+ // alias-prone, so both keep the follower-based fallback.
142
+ return facts.platform === 'win32' || facts.platform === 'darwin' || facts.wsl;
143
+ }
144
+ /**
145
+ * Whether two spellings name the same node (dev + inode), walking the target's
146
+ * existing ancestors. Mirrors the base fence's alias fallback so a denied or
147
+ * granted root cannot be dodged with a casing/8.3 alias.
148
+ */
149
+ function sharesIdentity(targetKey, root, api) {
150
+ let rootInfo;
151
+ try {
152
+ rootInfo = statSync(root, { bigint: true });
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ let current = targetKey;
158
+ for (;;) {
159
+ try {
160
+ const info = statSync(current, { bigint: true });
161
+ if (info.dev === rootInfo.dev && info.ino === rootInfo.ino)
162
+ return true;
163
+ }
164
+ catch {
165
+ // A missing ancestor is not an error: the next pass simply will not see it.
166
+ }
167
+ const parent = api.dirname(current);
168
+ if (parent === current)
169
+ return false;
170
+ current = parent;
171
+ }
53
172
  }
54
173
  /**
55
174
  * Whether a canonical target is a root or lies beneath it. Both sides must
56
- * already be canonical; containment is then purely lexical, which is why the
57
- * caller canonicalises before comparing.
175
+ * already be canonical; containment is then purely lexical, with a filesystem
176
+ * identity fallback for alias-prone hosts (see {@link sharesIdentity}).
58
177
  * @param targetKey - canonical write target.
59
178
  * @param root - canonical configured root.
179
+ * @param facts - host facts (defaults to the discovered ones).
60
180
  * @returns true for the root itself and every descendant.
61
181
  */
62
- export function isUnder(targetKey, root) {
182
+ export function isUnder(targetKey, root, facts = discoverPlatformFacts()) {
183
+ const api = pathApiOf(facts);
184
+ if (api === win32 && targetKey.toLowerCase() === root.toLowerCase())
185
+ return true;
63
186
  if (targetKey === root)
64
187
  return true;
65
- const rel = relative(root, targetKey);
188
+ const rel = api.relative(root, targetKey);
66
189
  // `..foo` is a legitimate CHILD whose name starts with dots; only the `..`
67
- // segment itself and a `../` prefix escape the root.
68
- return rel !== '' && rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
190
+ // segment itself and a `../` prefix escape the root. `win32.relative` already
191
+ // compares case-insensitively, which matches how Windows resolves paths.
192
+ if (rel !== '' && rel !== '..' && !rel.startsWith(`..${api.sep}`) && !api.isAbsolute(rel))
193
+ return true;
194
+ if (!mightAliasSpellings(facts))
195
+ return false;
196
+ return sharesIdentity(targetKey, root, api);
69
197
  }
70
198
  //# sourceMappingURL=paths.js.map
package/lib/paths.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAEtG;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,aAAqB,EAAE,OAAe,OAAO,EAAE;IACrF,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAC5B,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACtF,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAA;IAC/B,OAAO,WAAW,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,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