tamash-playwright 0.11.0-beta.1 → 0.11.0-beta.2
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/CHANGELOG.md +9 -0
- package/RELEASE-TESTING.md +12 -1
- package/package.json +2 -1
- package/dist/healer/providers/claude-cli.d.ts +0 -3
- package/dist/healer/providers/claude-cli.d.ts.map +0 -1
- package/dist/healer/providers/claude-cli.js +0 -122
- package/dist/healer/providers/claude-cli.js.map +0 -1
- package/dist/healer/providers/copilot-cli.d.ts +0 -3
- package/dist/healer/providers/copilot-cli.d.ts.map +0 -1
- package/dist/healer/providers/copilot-cli.js +0 -115
- package/dist/healer/providers/copilot-cli.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,15 @@ All notable changes to this project are documented here. Format loosely follows
|
|
|
7
7
|
|
|
8
8
|
### Fixed
|
|
9
9
|
|
|
10
|
+
- **The published package was silently carrying stale, orphaned compiled output.** `npm run build`
|
|
11
|
+
(plain `tsc`, no `--build`/incremental mode) never deletes `dist/` output for a source file that
|
|
12
|
+
was later removed — found in the `0.11.0-beta.1` publish itself: `dist/healer/providers/
|
|
13
|
+
claude-cli.js`/`copilot-cli.js` shipped in the tarball with no corresponding source file
|
|
14
|
+
anywhere in the repo (from an abandoned, never-committed, never-wired-up piece of past work) —
|
|
15
|
+
dead code nothing actually imports, but real, needless bloat in every install. Fixed by cleaning
|
|
16
|
+
`dist/` automatically before every build (`prebuild` script), verified by confirming a full
|
|
17
|
+
rebuild no longer produces those two files.
|
|
18
|
+
|
|
10
19
|
- **A popup/new tab opened via `context.waitForEvent('page')`, `page.on('popup', ...)`, or
|
|
11
20
|
`page.waitForEvent('popup')` was never healing-aware.** `bindContext`/`bindPageActions` already
|
|
12
21
|
made `context.newPage()`/`context.pages()`/`context.on('page', ...)` heal correctly, but these
|
package/RELEASE-TESTING.md
CHANGED
|
@@ -58,7 +58,7 @@ The table above is the current, living state. This section keeps a short history
|
|
|
58
58
|
release to release, and anything worth remembering that testing itself turned up — including real
|
|
59
59
|
mistakes, not just successes.
|
|
60
60
|
|
|
61
|
-
### [0.11.0-beta.1] — 2026-08-28
|
|
61
|
+
### [0.11.0-beta.1 → beta.2] — 2026-08-28
|
|
62
62
|
|
|
63
63
|
**Added this release**: the `tamash` provider, the automatic variable-name description enrichment,
|
|
64
64
|
and — found while closing the popup/new-tab coverage gap this document itself surfaced — two real,
|
|
@@ -93,6 +93,17 @@ tamash-playwright bug, a real environmental precondition, handled in the test th
|
|
|
93
93
|
suite would (dismiss it if present, don't fail if it never appeared). Stable across 6 repeat runs
|
|
94
94
|
after that fix.
|
|
95
95
|
|
|
96
|
+
**Found in the beta.1 publish itself, fixed as beta.2**: the actual published `beta.1` tarball
|
|
97
|
+
contained `dist/healer/providers/claude-cli.js`/`copilot-cli.js` — compiled output with no
|
|
98
|
+
corresponding source file anywhere in the repo, from an abandoned, never-committed, never-wired-up
|
|
99
|
+
piece of past work. Root cause: plain `tsc` (no `--build`/incremental mode) never deletes `dist/`
|
|
100
|
+
output for a source file removed since the last build, so this stale output silently survived
|
|
101
|
+
every rebuild since whenever it was first compiled. Fixed by cleaning `dist/` automatically before
|
|
102
|
+
every build; verified by confirming a full rebuild no longer produces either file, before
|
|
103
|
+
re-publishing as `beta.2`. Recorded here specifically because it was caught only by inspecting the
|
|
104
|
+
real, already-published tarball's own file listing after publishing — a reminder that "the build
|
|
105
|
+
succeeded and tests passed" doesn't guarantee the published artifact itself is clean.
|
|
106
|
+
|
|
96
107
|
**Regression check**: full existing e2e suite re-run against the published 0.10.0 baseline (not
|
|
97
108
|
just "did it pass," but "does the same thing fail on the untouched published package too"). The
|
|
98
109
|
only failures that reproduced identically on the untouched baseline were 3 known, pre-existing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamash-playwright",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.2",
|
|
4
4
|
"description": "Plug and Play Self-healing for Playwright and automatically recovers broken selectors using an AI model (Ollama, OpenAI, Anthropic, Gemini, or a Claude/GitHub Copilot subscription).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
".env.example"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
+
"prebuild": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
19
20
|
"build": "tsc -p tsconfig.json",
|
|
20
21
|
"pretest": "npm run build",
|
|
21
22
|
"test": "node --test \"unit-tests/*.test.js\"",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-cli.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/claude-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,YAAY,EAAsH,MAAM,SAAS,CAAC;AAqFpL,wBAAgB,uBAAuB,IAAI,YAAY,CAmDtD"}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createClaudeCliProvider = createClaudeCliProvider;
|
|
4
|
-
const prompt_1 = require("./prompt");
|
|
5
|
-
// Fallback only — normally overridden by SuggestSelectorInput.timeoutMs, same as the other providers.
|
|
6
|
-
const REQUEST_TIMEOUT_MS = 15000;
|
|
7
|
-
// @anthropic-ai/claude-agent-sdk is a peer dependency (optional — see package.json), not installed
|
|
8
|
-
// by default, so it's only ever loaded lazily inside a try/catch. It's also ESM-only ("type":
|
|
9
|
-
// "module", no "require" export condition) — but this project compiles to CommonJS (tsconfig
|
|
10
|
-
// "module": "commonjs"), and under that setting tsc silently downlevels a plain `await
|
|
11
|
-
// import(...)` into a deferred `require(...)`, which throws ERR_REQUIRE_ESM against an ESM-only
|
|
12
|
-
// package at runtime (confirmed by inspecting the compiled dist/ output). Loading it through
|
|
13
|
-
// `new Function(...)` hides the import() call from tsc's static rewrite — it stays a real,
|
|
14
|
-
// unmodified dynamic import at runtime, which is the only way to load an ESM-only package from a
|
|
15
|
-
// CommonJS module in Node.
|
|
16
|
-
const importClaudeAgentSdk = new Function('specifier', 'return import(specifier)');
|
|
17
|
-
function warnUnavailable(reason, error) {
|
|
18
|
-
const err = error;
|
|
19
|
-
const notInstalled = err?.code === 'ERR_MODULE_NOT_FOUND' || err?.code === 'MODULE_NOT_FOUND';
|
|
20
|
-
if (notInstalled) {
|
|
21
|
-
console.warn(`[self-healer] claude-cli: @anthropic-ai/claude-agent-sdk is not installed — run \`npm install @anthropic-ai/claude-agent-sdk\` to use it, or use HEALER_PROVIDER=anthropic + ANTHROPIC_API_KEY instead.`);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
console.warn(`[self-healer] claude-cli: ${reason} — not authenticated? Run \`claude login\`, or for CI set CLAUDE_CODE_OAUTH_TOKEN (see \`claude setup-token\`), or use HEALER_PROVIDER=anthropic + ANTHROPIC_API_KEY instead.`);
|
|
25
|
-
}
|
|
26
|
-
// A fresh query() call per invocation (own AbortController, no shared session) — the provider is a
|
|
27
|
-
// module-level singleton (see providers/index.ts) that can be called concurrently, so nothing here
|
|
28
|
-
// may hold state across calls.
|
|
29
|
-
async function runQuery(model, systemPrompt, prompt, timeoutMs) {
|
|
30
|
-
const { query } = await importClaudeAgentSdk('@anthropic-ai/claude-agent-sdk');
|
|
31
|
-
const controller = new AbortController();
|
|
32
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
33
|
-
try {
|
|
34
|
-
for await (const message of query({
|
|
35
|
-
prompt,
|
|
36
|
-
options: {
|
|
37
|
-
model,
|
|
38
|
-
maxTurns: 1,
|
|
39
|
-
tools: [],
|
|
40
|
-
permissionMode: 'bypassPermissions',
|
|
41
|
-
systemPrompt,
|
|
42
|
-
abortController: controller,
|
|
43
|
-
},
|
|
44
|
-
})) {
|
|
45
|
-
if (message.type === 'result') {
|
|
46
|
-
if (message.subtype !== 'success') {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
text: message.result,
|
|
51
|
-
inputTokens: message.usage?.input_tokens,
|
|
52
|
-
outputTokens: message.usage?.output_tokens,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
clearTimeout(timer);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function toUsage(result) {
|
|
63
|
-
const { inputTokens, outputTokens } = result;
|
|
64
|
-
if (inputTokens === undefined || outputTokens === undefined) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
return { inputTokens, outputTokens, totalTokens: inputTokens + outputTokens };
|
|
68
|
-
}
|
|
69
|
-
// Unlike the API-key providers (anthropic.ts, etc.), this one always returns a provider object —
|
|
70
|
-
// there's no env var to check synchronously, since auth is either an existing `claude login`
|
|
71
|
-
// session or CLAUDE_CODE_OAUTH_TOKEN, both of which can only be verified by actually trying a call.
|
|
72
|
-
// Failure is deferred to each method call below, matching the existing swallow-and-return-null
|
|
73
|
-
// contract every other provider already follows.
|
|
74
|
-
function createClaudeCliProvider() {
|
|
75
|
-
const model = process.env.CLAUDE_CLI_MODEL ?? 'haiku';
|
|
76
|
-
return {
|
|
77
|
-
name: `claude-cli:${model}`,
|
|
78
|
-
// Neither SDK's one-shot `prompt: string` path has a confirmed image-input shape suited to
|
|
79
|
-
// this package's "return pixel coordinates" vision task — safer not to attempt it than guess.
|
|
80
|
-
supportsVision: false,
|
|
81
|
-
async suggestSelector(input) {
|
|
82
|
-
try {
|
|
83
|
-
const result = await runQuery(model, prompt_1.SYSTEM_PROMPT, (0, prompt_1.buildUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
84
|
-
if (!result) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
const suggestion = (0, prompt_1.parseSuggestion)(result.text);
|
|
88
|
-
if (!suggestion) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return { suggestion, usage: toUsage(result) };
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
95
|
-
warnUnavailable(reason, error);
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
async suggestSelectorFromImage(_input) {
|
|
100
|
-
return null;
|
|
101
|
-
},
|
|
102
|
-
async suggestActionTactic(input) {
|
|
103
|
-
try {
|
|
104
|
-
const result = await runQuery(model, prompt_1.ACTION_RECOVERY_SYSTEM_PROMPT, (0, prompt_1.buildActionRecoveryUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
105
|
-
if (!result) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
const tactic = (0, prompt_1.parseActionTacticSuggestion)(result.text);
|
|
109
|
-
if (!tactic) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return { tactic, usage: toUsage(result) };
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
116
|
-
warnUnavailable(reason, error);
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=claude-cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-cli.js","sourceRoot":"","sources":["../../../src/healer/providers/claude-cli.ts"],"names":[],"mappings":";;;AACA,qCAAsK;AAEtK,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,mGAAmG;AACnG,8FAA8F;AAC9F,6FAA6F;AAC7F,uFAAuF;AACvF,gGAAgG;AAChG,6FAA6F;AAC7F,2FAA2F;AAC3F,iGAAiG;AACjG,2BAA2B;AAC3B,MAAM,oBAAoB,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{"version":3,"file":"copilot-cli.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/copilot-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,YAAY,EAAsH,MAAM,SAAS,CAAC;AAsEpL,wBAAgB,wBAAwB,IAAI,YAAY,CAuDvD"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCopilotCliProvider = createCopilotCliProvider;
|
|
4
|
-
const prompt_1 = require("./prompt");
|
|
5
|
-
// Fallback only — normally overridden by SuggestSelectorInput.timeoutMs, same as the other providers.
|
|
6
|
-
const REQUEST_TIMEOUT_MS = 15000;
|
|
7
|
-
// @github/copilot-sdk is a peer dependency (optional — see package.json), not installed by default,
|
|
8
|
-
// so it's only ever loaded lazily inside a try/catch. Unlike the Claude Agent SDK, this package
|
|
9
|
-
// ships both CJS and ESM builds, so a plain require() resolves correctly from this CJS package.
|
|
10
|
-
function warnUnavailable(reason, error) {
|
|
11
|
-
const err = error;
|
|
12
|
-
const notInstalled = err?.code === 'MODULE_NOT_FOUND';
|
|
13
|
-
if (notInstalled) {
|
|
14
|
-
console.warn(`[self-healer] copilot-cli: @github/copilot-sdk is not installed — run \`npm install @github/copilot-sdk\` to use it, or use HEALER_PROVIDER=openai/anthropic/gemini + an API key instead.`);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
console.warn(`[self-healer] copilot-cli: ${reason} — not authenticated? Install and sign in with the \`copilot\` CLI locally, or for CI set GITHUB_TOKEN (with a "copilot-requests: write" workflow permission on GitHub Actions, or a PAT with "Copilot Requests" scope elsewhere), or use HEALER_PROVIDER=openai/anthropic/gemini + an API key instead.`);
|
|
18
|
-
}
|
|
19
|
-
// A fresh CopilotClient (and its underlying `copilot` CLI subprocess) is started and stopped per
|
|
20
|
-
// call, matching the "no shared state across concurrent calls" requirement — the provider is a
|
|
21
|
-
// module-level singleton (see providers/index.ts) that can be invoked concurrently. A shared,
|
|
22
|
-
// lazily-started client reusing sessions per call would avoid the repeated subprocess-spawn cost
|
|
23
|
-
// and is architecturally supported by the SDK, but isn't implemented here to avoid taking on
|
|
24
|
-
// subprocess-lifecycle management (leftover child processes, retry-after-failure semantics)
|
|
25
|
-
// without a concrete need yet.
|
|
26
|
-
async function sendMessage(model, systemPrompt, prompt, timeoutMs) {
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
28
|
-
const { CopilotClient } = require('@github/copilot-sdk');
|
|
29
|
-
const client = new CopilotClient();
|
|
30
|
-
try {
|
|
31
|
-
await client.start();
|
|
32
|
-
// availableTools: [] keeps this a pure text completion — no tool/file access during a heal
|
|
33
|
-
// call. Deliberately not wiring up onPermissionRequest (e.g. approveAll): with no tools
|
|
34
|
-
// available, none should ever fire, and auto-approving tool calls would be a real security
|
|
35
|
-
// regression for something that can run unattended in CI.
|
|
36
|
-
const session = await client.createSession({ model, availableTools: [] });
|
|
37
|
-
const response = await session.sendAndWait({ prompt: `${systemPrompt}\n\n${prompt}` }, timeoutMs);
|
|
38
|
-
const content = response?.data.content;
|
|
39
|
-
if (!content) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return { content, outputTokens: response?.data.outputTokens };
|
|
43
|
-
}
|
|
44
|
-
finally {
|
|
45
|
-
try {
|
|
46
|
-
await client.stop();
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// Best-effort cleanup — nothing useful to do if the client can't be stopped cleanly.
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function toUsage(result) {
|
|
54
|
-
// The Copilot SDK's assistant.message event only exposes an output-token count, no input/prompt
|
|
55
|
-
// tokens — inputTokens/totalTokens stay undefined, which TokenUsage already allows.
|
|
56
|
-
return result.outputTokens === undefined ? undefined : { outputTokens: result.outputTokens };
|
|
57
|
-
}
|
|
58
|
-
// Unlike the API-key providers (openai.ts, etc.), this one always returns a provider object —
|
|
59
|
-
// there's no env var to check synchronously, since auth is either an existing `copilot` CLI login
|
|
60
|
-
// or an ambient GITHUB_TOKEN, both of which can only be verified by actually trying a call. Failure
|
|
61
|
-
// is deferred to each method call below, matching the existing swallow-and-return-null contract
|
|
62
|
-
// every other provider already follows.
|
|
63
|
-
function createCopilotCliProvider() {
|
|
64
|
-
// MAI-Code-1-Flash (Microsoft's own coding model, available on every Copilot tier including
|
|
65
|
-
// free) by default — cheap and fast, which fits this package's narrow selector-suggestion task
|
|
66
|
-
// well, and matches defaulting claude-cli to Haiku for the same reason. Override with
|
|
67
|
-
// COPILOT_CLI_MODEL for a different model (e.g. the newer MAI-Code-1.1-Flash).
|
|
68
|
-
const model = process.env.COPILOT_CLI_MODEL ?? 'MAI-Code-1-Flash';
|
|
69
|
-
return {
|
|
70
|
-
name: `copilot-cli:${model}`,
|
|
71
|
-
// Neither SDK's one-shot completion path has a confirmed image-input shape suited to this
|
|
72
|
-
// package's "return pixel coordinates" vision task — safer not to attempt it than guess.
|
|
73
|
-
supportsVision: false,
|
|
74
|
-
async suggestSelector(input) {
|
|
75
|
-
try {
|
|
76
|
-
const result = await sendMessage(model, prompt_1.SYSTEM_PROMPT, (0, prompt_1.buildUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
77
|
-
if (!result) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const suggestion = (0, prompt_1.parseSuggestion)(result.content);
|
|
81
|
-
if (!suggestion) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return { suggestion, usage: toUsage(result) };
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
88
|
-
warnUnavailable(reason, error);
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
async suggestSelectorFromImage(_input) {
|
|
93
|
-
return null;
|
|
94
|
-
},
|
|
95
|
-
async suggestActionTactic(input) {
|
|
96
|
-
try {
|
|
97
|
-
const result = await sendMessage(model, prompt_1.ACTION_RECOVERY_SYSTEM_PROMPT, (0, prompt_1.buildActionRecoveryUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
98
|
-
if (!result) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
const tactic = (0, prompt_1.parseActionTacticSuggestion)(result.content);
|
|
102
|
-
if (!tactic) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
return { tactic, usage: toUsage(result) };
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
109
|
-
warnUnavailable(reason, error);
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
//# sourceMappingURL=copilot-cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-cli.js","sourceRoot":"","sources":["../../../src/healer/providers/copilot-cli.ts"],"names":[],"mappings":";;;AACA,qCAAsK;AAEtK,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,oGAAoG;AACpG,gGAAgG;AAChG,gGAAgG;AAChG,SAAS,eAAe,CAAC,MAAc,EAAE,KAAc;IACrD,MAAM,GAAG,GAAG,KAA8B,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,EAAE,IAAI,KAAK,kBAAkB,CAAC;IACtD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,2LAA2L,CAC5L,CAAC;QACF,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CACV,8BAA8B,MAAM,ySAAyS,CAC9U,CAAC;AACJ,CAAC;AAID,iGAAiG;AACjG,+FAA+F;AAC/F,8FAA8F;AAC9F,iGAAiG;AACjG,6FAA6F;AAC7F,4FAA4F;AAC5F,+BAA+B;AAC/B,KAAK,UAAU,W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