@agentteams/runner 0.0.86-dev.212 → 0.0.87
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/commands/start.js +16 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/windows-path.d.ts +16 -0
- package/dist/windows-path.js +105 -0
- package/dist/windows-path.js.map +1 -0
- package/dist/windows-path.test.d.ts +1 -0
- package/dist/windows-path.test.js +81 -0
- package/dist/windows-path.test.js.map +1 -0
- package/package.json +1 -1
package/dist/commands/start.js
CHANGED
|
@@ -4,6 +4,21 @@ import { DaemonApiClient } from '../api-client.js';
|
|
|
4
4
|
import { createTriggerHandler } from '../handlers/trigger-handler.js';
|
|
5
5
|
import { writePidFile, removePidFile } from '../pid.js';
|
|
6
6
|
import { logger } from '../logger.js';
|
|
7
|
+
import { refreshWindowsPathFromRegistry } from '../windows-path.js';
|
|
8
|
+
/**
|
|
9
|
+
* The Windows autostart launcher (Startup-folder VBS) injects a PATH snapshot
|
|
10
|
+
* frozen at registration time, so runner CLIs installed afterwards become
|
|
11
|
+
* unresolvable. Re-read the live registry PATH at startup to stay agnostic to
|
|
12
|
+
* how each CLI was installed (npm, scoop, choco, native installers, ...).
|
|
13
|
+
*/
|
|
14
|
+
const refreshExecutablePath = () => {
|
|
15
|
+
const addedEntries = refreshWindowsPathFromRegistry();
|
|
16
|
+
if (addedEntries.length > 0) {
|
|
17
|
+
logger.info('Merged live registry PATH entries missing from the autostart snapshot', {
|
|
18
|
+
addedEntries,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
7
22
|
/**
|
|
8
23
|
* Default CODEX_SANDBOX_LEVEL to "off" when not explicitly set.
|
|
9
24
|
* Auto-start services (launchd/systemd/Startup) inject CODEX_SANDBOX_LEVEL=off
|
|
@@ -17,6 +32,7 @@ const ensureCodexSandboxDefault = () => {
|
|
|
17
32
|
}
|
|
18
33
|
};
|
|
19
34
|
export const runStartCommand = async () => {
|
|
35
|
+
refreshExecutablePath();
|
|
20
36
|
ensureCodexSandboxDefault();
|
|
21
37
|
await writePidFile();
|
|
22
38
|
const cleanup = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,GAAS,EAAE;IACvC,MAAM,YAAY,GAAG,8BAA8B,EAAE,CAAC;IACtD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,uEAAuE,EAAE;YACnF,YAAY;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,GAAS,EAAE;IAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,KAAK,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,IAAmB,EAAE;IACvD,qBAAqB,EAAE,CAAC;IACxB,yBAAyB,EAAE,CAAC;IAC5B,MAAM,YAAY,EAAE,CAAC;IAErB,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;QACzB,MAAM,aAAa,EAAE,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,+EAA+E;IACjF,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAC5C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAEtE,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC,oBAAoB,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC;AACvH,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { platform as getPlatform } from 'node:os';
|
|
3
|
+
type RefreshDeps = {
|
|
4
|
+
platform?: typeof getPlatform;
|
|
5
|
+
execFileSync?: typeof execFileSync;
|
|
6
|
+
env?: NodeJS.ProcessEnv;
|
|
7
|
+
};
|
|
8
|
+
export declare const expandWindowsEnvPlaceholders: (value: string, env: NodeJS.ProcessEnv) => string;
|
|
9
|
+
export declare const mergePathEntries: (existingPath: string, additionalPaths: string[]) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Merge the live registry User + Machine PATH into process.env.PATH on Windows.
|
|
12
|
+
* No-op on other platforms. Returns the directories that were newly added so the
|
|
13
|
+
* caller can log what the stale snapshot was missing.
|
|
14
|
+
*/
|
|
15
|
+
export declare const refreshWindowsPathFromRegistry: (deps?: RefreshDeps) => string[];
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { platform as getPlatform } from 'node:os';
|
|
3
|
+
const USER_PATH_SOURCE = { root: 'HKCU\\Environment' };
|
|
4
|
+
const MACHINE_PATH_SOURCE = {
|
|
5
|
+
root: 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment',
|
|
6
|
+
};
|
|
7
|
+
// Matches a `reg query ... /v Path` value line, e.g.
|
|
8
|
+
// " Path REG_EXPAND_SZ C:\\foo;%LOCALAPPDATA%\\bar"
|
|
9
|
+
// The data segment (group 1) may itself contain spaces, so we capture everything
|
|
10
|
+
// after the value type to the end of the line.
|
|
11
|
+
const REGISTRY_PATH_VALUE_PATTERN = /^\s*Path\s+REG_(?:EXPAND_)?SZ\s+(.+)$/iu;
|
|
12
|
+
const parseRegistryPathValue = (output) => {
|
|
13
|
+
for (const line of output.split(/\r?\n/u)) {
|
|
14
|
+
const match = line.match(REGISTRY_PATH_VALUE_PATTERN);
|
|
15
|
+
if (match) {
|
|
16
|
+
return match[1].trim();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
const lookupEnvCaseInsensitive = (env, name) => {
|
|
22
|
+
const directHit = env[name];
|
|
23
|
+
if (directHit !== undefined) {
|
|
24
|
+
return directHit;
|
|
25
|
+
}
|
|
26
|
+
const lowerName = name.toLowerCase();
|
|
27
|
+
for (const [key, value] of Object.entries(env)) {
|
|
28
|
+
if (key.toLowerCase() === lowerName) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
};
|
|
34
|
+
// Registry PATH values use REG_EXPAND_SZ placeholders such as %SystemRoot% or
|
|
35
|
+
// %LOCALAPPDATA%. Expand them from the current environment; leave unknown
|
|
36
|
+
// placeholders untouched so a missing variable never collapses a directory.
|
|
37
|
+
export const expandWindowsEnvPlaceholders = (value, env) => value.replace(/%([^%]+)%/gu, (whole, name) => lookupEnvCaseInsensitive(env, name) ?? whole);
|
|
38
|
+
const toPathKey = (entry) => entry.replace(/[\\/]+$/u, '').toLowerCase();
|
|
39
|
+
export const mergePathEntries = (existingPath, additionalPaths) => {
|
|
40
|
+
const existingEntries = existingPath.split(';').filter((entry) => entry.length > 0);
|
|
41
|
+
const seen = new Set(existingEntries.map(toPathKey));
|
|
42
|
+
const merged = [...existingEntries];
|
|
43
|
+
for (const additional of additionalPaths) {
|
|
44
|
+
const entry = additional.trim();
|
|
45
|
+
if (entry.length === 0) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const key = toPathKey(entry);
|
|
49
|
+
if (seen.has(key)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
seen.add(key);
|
|
53
|
+
merged.push(entry);
|
|
54
|
+
}
|
|
55
|
+
return merged.join(';');
|
|
56
|
+
};
|
|
57
|
+
const readRegistryPath = (source, runner, env) => {
|
|
58
|
+
let output;
|
|
59
|
+
try {
|
|
60
|
+
output = String(runner('reg', ['query', source.root, '/v', 'Path'], {
|
|
61
|
+
encoding: 'utf8',
|
|
62
|
+
windowsHide: true,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const rawValue = parseRegistryPathValue(output);
|
|
69
|
+
if (!rawValue) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return expandWindowsEnvPlaceholders(rawValue, env)
|
|
73
|
+
.split(';')
|
|
74
|
+
.map((entry) => entry.trim())
|
|
75
|
+
.filter((entry) => entry.length > 0);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Merge the live registry User + Machine PATH into process.env.PATH on Windows.
|
|
79
|
+
* No-op on other platforms. Returns the directories that were newly added so the
|
|
80
|
+
* caller can log what the stale snapshot was missing.
|
|
81
|
+
*/
|
|
82
|
+
export const refreshWindowsPathFromRegistry = (deps = {}) => {
|
|
83
|
+
const os = (deps.platform ?? getPlatform)();
|
|
84
|
+
if (os !== 'win32') {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
const runner = deps.execFileSync ?? execFileSync;
|
|
88
|
+
const env = deps.env ?? process.env;
|
|
89
|
+
const currentPath = env.PATH ?? '';
|
|
90
|
+
// Machine PATH precedes User PATH to mirror how Windows composes the effective
|
|
91
|
+
// PATH; both are appended after the existing process PATH so nothing breaks.
|
|
92
|
+
const registryEntries = [
|
|
93
|
+
...readRegistryPath(MACHINE_PATH_SOURCE, runner, env),
|
|
94
|
+
...readRegistryPath(USER_PATH_SOURCE, runner, env),
|
|
95
|
+
];
|
|
96
|
+
const mergedPath = mergePathEntries(currentPath, registryEntries);
|
|
97
|
+
const beforeKeys = new Set(currentPath
|
|
98
|
+
.split(';')
|
|
99
|
+
.filter((entry) => entry.length > 0)
|
|
100
|
+
.map(toPathKey));
|
|
101
|
+
const addedEntries = mergedPath.split(';').filter((entry) => entry.length > 0 && !beforeKeys.has(toPathKey(entry)));
|
|
102
|
+
env.PATH = mergedPath;
|
|
103
|
+
return addedEntries;
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=windows-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows-path.js","sourceRoot":"","sources":["../src/windows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,IAAI,EAAE,CAAC;IAEnC,+EAA+E;IAC/E,6EAA6E;IAC7E,MAAM,eAAe,GAAG;QACtB,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,MAAM,EAAE,GAAG,CAAC;QACrD,GAAG,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,CAAC;KACnD,CAAC;IAEF,MAAM,UAAU,GAAG,gBAAgB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,WAAW;SACR,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;SACnC,GAAG,CAAC,SAAS,CAAC,CAClB,CAAC;IACF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEpH,GAAG,CAAC,IAAI,GAAG,UAAU,CAAC;IAEtB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { expandWindowsEnvPlaceholders, mergePathEntries, refreshWindowsPathFromRegistry } from './windows-path.js';
|
|
4
|
+
test('expandWindowsEnvPlaceholders expands known vars case-insensitively and leaves unknown intact', () => {
|
|
5
|
+
const env = { LOCALAPPDATA: 'C:\\Users\\rlaru\\AppData\\Local' };
|
|
6
|
+
const expanded = expandWindowsEnvPlaceholders('%localappdata%\\Programs\\OpenAI\\Codex\\bin;%UNSET%\\x', env);
|
|
7
|
+
assert.equal(expanded, 'C:\\Users\\rlaru\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin;%UNSET%\\x');
|
|
8
|
+
});
|
|
9
|
+
test('mergePathEntries appends only missing dirs, dedup is case/trailing-slash insensitive', () => {
|
|
10
|
+
const merged = mergePathEntries('C:\\nvm4w\\nodejs;C:\\Windows\\System32', [
|
|
11
|
+
'C:\\nvm4w\\nodejs\\', // duplicate (trailing slash)
|
|
12
|
+
'c:\\windows\\system32', // duplicate (case)
|
|
13
|
+
'C:\\Users\\rlaru\\.local\\bin', // new
|
|
14
|
+
]);
|
|
15
|
+
assert.equal(merged, 'C:\\nvm4w\\nodejs;C:\\Windows\\System32;C:\\Users\\rlaru\\.local\\bin');
|
|
16
|
+
});
|
|
17
|
+
test('refreshWindowsPathFromRegistry is a no-op on non-Windows platforms', () => {
|
|
18
|
+
const env = { PATH: '/usr/bin' };
|
|
19
|
+
const added = refreshWindowsPathFromRegistry({
|
|
20
|
+
platform: () => 'linux',
|
|
21
|
+
env,
|
|
22
|
+
execFileSync: (() => {
|
|
23
|
+
throw new Error('reg should not be called off Windows');
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
assert.deepEqual(added, []);
|
|
27
|
+
assert.equal(env.PATH, '/usr/bin');
|
|
28
|
+
});
|
|
29
|
+
test('refreshWindowsPathFromRegistry merges live registry PATH missing from the snapshot', () => {
|
|
30
|
+
const env = {
|
|
31
|
+
PATH: 'C:\\WINDOWS\\system32;C:\\nvm4w\\nodejs',
|
|
32
|
+
LOCALAPPDATA: 'C:\\Users\\rlaru\\AppData\\Local',
|
|
33
|
+
USERPROFILE: 'C:\\Users\\rlaru',
|
|
34
|
+
};
|
|
35
|
+
const added = refreshWindowsPathFromRegistry({
|
|
36
|
+
platform: () => 'win32',
|
|
37
|
+
env,
|
|
38
|
+
execFileSync: ((command, args) => {
|
|
39
|
+
assert.equal(command, 'reg');
|
|
40
|
+
const root = args[1];
|
|
41
|
+
if (root === 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment') {
|
|
42
|
+
return [
|
|
43
|
+
'',
|
|
44
|
+
'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment',
|
|
45
|
+
' Path REG_EXPAND_SZ C:\\WINDOWS\\system32;C:\\WINDOWS',
|
|
46
|
+
'',
|
|
47
|
+
].join('\r\n');
|
|
48
|
+
}
|
|
49
|
+
if (root === 'HKCU\\Environment') {
|
|
50
|
+
return [
|
|
51
|
+
'',
|
|
52
|
+
'HKEY_CURRENT_USER\\Environment',
|
|
53
|
+
' Path REG_EXPAND_SZ %USERPROFILE%\\.local\\bin;%LOCALAPPDATA%\\Programs\\OpenAI\\Codex\\bin',
|
|
54
|
+
'',
|
|
55
|
+
].join('\r\n');
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`unexpected registry root: ${root}`);
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
// Existing entries preserved; snapshot already had system32 + nodejs.
|
|
61
|
+
// Machine adds C:\WINDOWS; user adds the two native CLI install dirs (expanded).
|
|
62
|
+
assert.deepEqual(added, [
|
|
63
|
+
'C:\\WINDOWS',
|
|
64
|
+
'C:\\Users\\rlaru\\.local\\bin',
|
|
65
|
+
'C:\\Users\\rlaru\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin',
|
|
66
|
+
]);
|
|
67
|
+
assert.equal(env.PATH, 'C:\\WINDOWS\\system32;C:\\nvm4w\\nodejs;C:\\WINDOWS;C:\\Users\\rlaru\\.local\\bin;C:\\Users\\rlaru\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin');
|
|
68
|
+
});
|
|
69
|
+
test('refreshWindowsPathFromRegistry tolerates a missing registry value gracefully', () => {
|
|
70
|
+
const env = { PATH: 'C:\\WINDOWS\\system32' };
|
|
71
|
+
const added = refreshWindowsPathFromRegistry({
|
|
72
|
+
platform: () => 'win32',
|
|
73
|
+
env,
|
|
74
|
+
execFileSync: (() => {
|
|
75
|
+
throw new Error('ERROR: The system was unable to find the specified registry key or value.');
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
assert.deepEqual(added, []);
|
|
79
|
+
assert.equal(env.PATH, 'C:\\WINDOWS\\system32');
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=windows-path.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows-path.test.js","sourceRoot":"","sources":["../src/windows-path.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAEnH,IAAI,CAAC,8FAA8F,EAAE,GAAG,EAAE;IACxG,MAAM,GAAG,GAAG,EAAE,YAAY,EAAE,kCAAkC,EAAuB,CAAC;IACtF,MAAM,QAAQ,GAAG,4BAA4B,CAAC,yDAAyD,EAAE,GAAG,CAAC,CAAC;IAE9G,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,2EAA2E,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sFAAsF,EAAE,GAAG,EAAE;IAChG,MAAM,MAAM,GAAG,gBAAgB,CAAC,yCAAyC,EAAE;QACzE,qBAAqB,EAAE,6BAA6B;QACpD,uBAAuB,EAAE,mBAAmB;QAC5C,+BAA+B,EAAE,MAAM;KACxC,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,uEAAuE,CAAC,CAAC;AAChG,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oEAAoE,EAAE,GAAG,EAAE;IAC9E,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,UAAU,EAAuB,CAAC;IACtD,MAAM,KAAK,GAAG,8BAA8B,CAAC;QAC3C,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO;QACvB,GAAG;QACH,YAAY,EAAE,CAAC,GAAG,EA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