n8n-nodes-claude-code-cli 1.0.3 → 1.0.5
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/nodes/ClaudeCode/transport/SshExecutor.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/transport/SshExecutor.js +65 -18
- package/dist/nodes/ClaudeCode/transport/SshExecutor.js.map +1 -1
- package/dist/nodes/ClaudeCode/utils/index.d.ts +1 -0
- package/dist/nodes/ClaudeCode/utils/index.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/utils/index.js +4 -1
- package/dist/nodes/ClaudeCode/utils/index.js.map +1 -1
- package/dist/nodes/ClaudeCode/utils/sshKeyUtils.d.ts +17 -0
- package/dist/nodes/ClaudeCode/utils/sshKeyUtils.d.ts.map +1 -0
- package/dist/nodes/ClaudeCode/utils/sshKeyUtils.js +61 -0
- package/dist/nodes/ClaudeCode/utils/sshKeyUtils.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SshExecutor.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/transport/SshExecutor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAEhB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"SshExecutor.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/transport/SshExecutor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAEhB,MAAM,wBAAwB,CAAC;AAWhC;;GAEG;AACH,qBAAa,WAAY,YAAW,mBAAmB;IACtD,OAAO,CAAC,WAAW,CAAiB;gBAExB,WAAW,EAAE,OAAO;IAIhC;;OAEG;IACH,OAAO,CAAC,cAAc;IAwCtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAK1B;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyHvE;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAqElC"}
|
|
@@ -26,13 +26,21 @@ class SshExecutor {
|
|
|
26
26
|
config.password = this.credentials.password;
|
|
27
27
|
}
|
|
28
28
|
else if (this.credentials.authMethod === "privateKey") {
|
|
29
|
+
let privateKey;
|
|
29
30
|
if (this.credentials.privateKey) {
|
|
30
|
-
|
|
31
|
+
const validation = (0, index_js_1.validatePrivateKey)(this.credentials.privateKey);
|
|
32
|
+
if (!validation.valid) {
|
|
33
|
+
throw new Error(`SSH private key error: ${validation.error}`);
|
|
34
|
+
}
|
|
35
|
+
privateKey = (0, index_js_1.normalizePrivateKey)(this.credentials.privateKey);
|
|
31
36
|
}
|
|
32
37
|
else if (this.credentials.privateKeyPath) {
|
|
33
38
|
// Expand ~ to home directory
|
|
34
39
|
const keyPath = this.credentials.privateKeyPath.replace(/^~/, (0, node_os_1.homedir)());
|
|
35
|
-
|
|
40
|
+
privateKey = (0, node_fs_1.readFileSync)(keyPath);
|
|
41
|
+
}
|
|
42
|
+
if (privateKey) {
|
|
43
|
+
config.privateKey = privateKey;
|
|
36
44
|
}
|
|
37
45
|
if (this.credentials.passphrase) {
|
|
38
46
|
config.passphrase = this.credentials.passphrase;
|
|
@@ -55,7 +63,15 @@ class SshExecutor {
|
|
|
55
63
|
return new Promise((resolve) => {
|
|
56
64
|
const startTime = Date.now();
|
|
57
65
|
const remoteCmd = this.buildRemoteCommand(options);
|
|
58
|
-
|
|
66
|
+
let sshConfig;
|
|
67
|
+
try {
|
|
68
|
+
sshConfig = this.buildSshConfig();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
const duration = Date.now() - startTime;
|
|
72
|
+
resolve((0, index_js_1.createErrorResult)(err.message, 1, duration));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
59
75
|
const timeoutMs = options.timeout ? options.timeout * 1000 : 300000;
|
|
60
76
|
let stdout = "";
|
|
61
77
|
let stderr = "";
|
|
@@ -71,7 +87,8 @@ class SshExecutor {
|
|
|
71
87
|
}
|
|
72
88
|
}, timeoutMs);
|
|
73
89
|
conn.on("ready", () => {
|
|
74
|
-
|
|
90
|
+
// Explicitly disable PTY allocation for non-interactive execution
|
|
91
|
+
conn.exec(remoteCmd, { pty: false }, (err, stream) => {
|
|
75
92
|
if (err) {
|
|
76
93
|
clearTimeout(connectionTimeout);
|
|
77
94
|
connectionClosed = true;
|
|
@@ -80,28 +97,42 @@ class SshExecutor {
|
|
|
80
97
|
resolve((0, index_js_1.createErrorResult)(`SSH exec error: ${err.message}`, 1, duration));
|
|
81
98
|
return;
|
|
82
99
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
let exitCode = null;
|
|
101
|
+
let streamClosed = false;
|
|
102
|
+
const handleCompletion = () => {
|
|
103
|
+
if (streamClosed && exitCode !== null && !connectionClosed) {
|
|
104
|
+
clearTimeout(connectionTimeout);
|
|
86
105
|
connectionClosed = true;
|
|
87
106
|
conn.end();
|
|
88
107
|
const duration = Date.now() - startTime;
|
|
89
|
-
const
|
|
108
|
+
const code = exitCode ?? 0;
|
|
90
109
|
if (options.outputFormat === "json") {
|
|
91
110
|
const parsed = (0, index_js_1.parseJsonOutput)(stdout);
|
|
92
|
-
resolve((0, index_js_1.normalizeOutput)(parsed,
|
|
111
|
+
resolve((0, index_js_1.normalizeOutput)(parsed, code, duration, stderr));
|
|
93
112
|
}
|
|
94
113
|
else {
|
|
95
114
|
resolve({
|
|
96
|
-
success:
|
|
115
|
+
success: code === 0,
|
|
97
116
|
sessionId: "",
|
|
98
117
|
output: stdout,
|
|
99
|
-
exitCode,
|
|
118
|
+
exitCode: code,
|
|
100
119
|
duration,
|
|
101
|
-
error:
|
|
120
|
+
error: code !== 0 ? stderr : undefined,
|
|
102
121
|
});
|
|
103
122
|
}
|
|
104
123
|
}
|
|
124
|
+
};
|
|
125
|
+
stream.on("exit", (code) => {
|
|
126
|
+
exitCode = code ?? 0;
|
|
127
|
+
handleCompletion();
|
|
128
|
+
});
|
|
129
|
+
stream.on("close", () => {
|
|
130
|
+
streamClosed = true;
|
|
131
|
+
// If exit wasn't received, use 0 as default
|
|
132
|
+
if (exitCode === null) {
|
|
133
|
+
exitCode = 0;
|
|
134
|
+
}
|
|
135
|
+
handleCompletion();
|
|
105
136
|
});
|
|
106
137
|
stream.on("data", (data) => {
|
|
107
138
|
stdout += data.toString();
|
|
@@ -109,8 +140,8 @@ class SshExecutor {
|
|
|
109
140
|
stream.stderr.on("data", (data) => {
|
|
110
141
|
stderr += data.toString();
|
|
111
142
|
});
|
|
112
|
-
// Close stdin to signal no input will be sent
|
|
113
|
-
// This
|
|
143
|
+
// Close stdin immediately to signal no input will be sent
|
|
144
|
+
// This is critical for non-interactive commands like Claude Code with -p flag
|
|
114
145
|
stream.end();
|
|
115
146
|
});
|
|
116
147
|
});
|
|
@@ -130,7 +161,14 @@ class SshExecutor {
|
|
|
130
161
|
*/
|
|
131
162
|
testConnection() {
|
|
132
163
|
return new Promise((resolve) => {
|
|
133
|
-
|
|
164
|
+
let sshConfig;
|
|
165
|
+
try {
|
|
166
|
+
sshConfig = this.buildSshConfig();
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
resolve(false);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
134
172
|
const conn = new ssh2_1.Client();
|
|
135
173
|
let resolved = false;
|
|
136
174
|
const timeout = setTimeout(() => {
|
|
@@ -142,7 +180,8 @@ class SshExecutor {
|
|
|
142
180
|
}, 10000);
|
|
143
181
|
conn.on("ready", () => {
|
|
144
182
|
const claudePath = this.credentials.claudePath || "claude";
|
|
145
|
-
|
|
183
|
+
// Explicitly disable PTY allocation
|
|
184
|
+
conn.exec(`${claudePath} --version`, { pty: false }, (err, stream) => {
|
|
146
185
|
if (err) {
|
|
147
186
|
clearTimeout(timeout);
|
|
148
187
|
if (!resolved) {
|
|
@@ -152,7 +191,7 @@ class SshExecutor {
|
|
|
152
191
|
}
|
|
153
192
|
return;
|
|
154
193
|
}
|
|
155
|
-
stream.on("
|
|
194
|
+
stream.on("exit", (code) => {
|
|
156
195
|
clearTimeout(timeout);
|
|
157
196
|
if (!resolved) {
|
|
158
197
|
resolved = true;
|
|
@@ -160,7 +199,15 @@ class SshExecutor {
|
|
|
160
199
|
resolve(code === 0);
|
|
161
200
|
}
|
|
162
201
|
});
|
|
163
|
-
|
|
202
|
+
stream.on("close", () => {
|
|
203
|
+
clearTimeout(timeout);
|
|
204
|
+
if (!resolved) {
|
|
205
|
+
resolved = true;
|
|
206
|
+
conn.end();
|
|
207
|
+
resolve(true); // Assume success if close without exit
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
// Close stdin immediately
|
|
164
211
|
stream.end();
|
|
165
212
|
});
|
|
166
213
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SshExecutor.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/transport/SshExecutor.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAClD,qCAAuC;AACvC,qCAAkC;AAOlC,
|
|
1
|
+
{"version":3,"file":"SshExecutor.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/transport/SshExecutor.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAClD,qCAAuC;AACvC,qCAAkC;AAOlC,gDAQ2B;AAE3B;;GAEG;AACH,MAAa,WAAW;IACf,WAAW,CAAiB;IAEpC,YAAY,WAAoB;QAC/B,IAAI,CAAC,WAAW,GAAG,WAA6B,CAAC;IAClD,CAAC;IAED;;OAEG;IACK,cAAc;QACrB,MAAM,MAAM,GAAkB;YAC7B,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YAC3B,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE;YACjC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ;SACnC,CAA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AAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AA9PD,kCA8PC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { buildCommand, escapeShellArg, buildShellCommand, } from "./commandBuilder.js";
|
|
2
2
|
export { parseJsonOutput, normalizeOutput, createErrorResult, } from "./outputParser.js";
|
|
3
3
|
export { buildExecutionOptions } from "./optionsBuilder.js";
|
|
4
|
+
export { normalizePrivateKey, validatePrivateKey } from "./sshKeyUtils.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,eAAe,EACf,eAAe,EACf,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,eAAe,EACf,eAAe,EACf,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildExecutionOptions = exports.createErrorResult = exports.normalizeOutput = exports.parseJsonOutput = exports.buildShellCommand = exports.escapeShellArg = exports.buildCommand = void 0;
|
|
3
|
+
exports.validatePrivateKey = exports.normalizePrivateKey = exports.buildExecutionOptions = exports.createErrorResult = exports.normalizeOutput = exports.parseJsonOutput = exports.buildShellCommand = exports.escapeShellArg = exports.buildCommand = void 0;
|
|
4
4
|
var commandBuilder_js_1 = require("./commandBuilder.js");
|
|
5
5
|
Object.defineProperty(exports, "buildCommand", { enumerable: true, get: function () { return commandBuilder_js_1.buildCommand; } });
|
|
6
6
|
Object.defineProperty(exports, "escapeShellArg", { enumerable: true, get: function () { return commandBuilder_js_1.escapeShellArg; } });
|
|
@@ -11,4 +11,7 @@ Object.defineProperty(exports, "normalizeOutput", { enumerable: true, get: funct
|
|
|
11
11
|
Object.defineProperty(exports, "createErrorResult", { enumerable: true, get: function () { return outputParser_js_1.createErrorResult; } });
|
|
12
12
|
var optionsBuilder_js_1 = require("./optionsBuilder.js");
|
|
13
13
|
Object.defineProperty(exports, "buildExecutionOptions", { enumerable: true, get: function () { return optionsBuilder_js_1.buildExecutionOptions; } });
|
|
14
|
+
var sshKeyUtils_js_1 = require("./sshKeyUtils.js");
|
|
15
|
+
Object.defineProperty(exports, "normalizePrivateKey", { enumerable: true, get: function () { return sshKeyUtils_js_1.normalizePrivateKey; } });
|
|
16
|
+
Object.defineProperty(exports, "validatePrivateKey", { enumerable: true, get: function () { return sshKeyUtils_js_1.validatePrivateKey; } });
|
|
14
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAI6B;AAH5B,iHAAA,YAAY,OAAA;AACZ,mHAAA,cAAc,OAAA;AACd,sHAAA,iBAAiB,OAAA;AAElB,qDAI2B;AAH1B,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,oHAAA,iBAAiB,OAAA;AAElB,yDAA4D;AAAnD,0HAAA,qBAAqB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAI6B;AAH5B,iHAAA,YAAY,OAAA;AACZ,mHAAA,cAAc,OAAA;AACd,sHAAA,iBAAiB,OAAA;AAElB,qDAI2B;AAH1B,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,oHAAA,iBAAiB,OAAA;AAElB,yDAA4D;AAAnD,0HAAA,qBAAqB,OAAA;AAC9B,mDAA2E;AAAlE,qHAAA,mBAAmB,OAAA;AAAE,oHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize SSH private key content
|
|
3
|
+
* Fixes common issues from copy/paste operations:
|
|
4
|
+
* - Windows line endings (\r\n)
|
|
5
|
+
* - Old Mac line endings (\r)
|
|
6
|
+
* - Leading/trailing whitespace
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizePrivateKey(key: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Validate SSH private key format
|
|
11
|
+
* Returns validation result with error message if invalid
|
|
12
|
+
*/
|
|
13
|
+
export declare function validatePrivateKey(key: string): {
|
|
14
|
+
valid: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=sshKeyUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sshKeyUtils.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/sshKeyUtils.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAwCA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePrivateKey = normalizePrivateKey;
|
|
4
|
+
exports.validatePrivateKey = validatePrivateKey;
|
|
5
|
+
/**
|
|
6
|
+
* Supported private key format headers
|
|
7
|
+
*/
|
|
8
|
+
const SUPPORTED_KEY_HEADERS = [
|
|
9
|
+
"-----BEGIN RSA PRIVATE KEY-----",
|
|
10
|
+
"-----BEGIN OPENSSH PRIVATE KEY-----",
|
|
11
|
+
"-----BEGIN PRIVATE KEY-----",
|
|
12
|
+
"-----BEGIN EC PRIVATE KEY-----",
|
|
13
|
+
"-----BEGIN DSA PRIVATE KEY-----",
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Normalize SSH private key content
|
|
17
|
+
* Fixes common issues from copy/paste operations:
|
|
18
|
+
* - Windows line endings (\r\n)
|
|
19
|
+
* - Old Mac line endings (\r)
|
|
20
|
+
* - Leading/trailing whitespace
|
|
21
|
+
*/
|
|
22
|
+
function normalizePrivateKey(key) {
|
|
23
|
+
return key.replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validate SSH private key format
|
|
27
|
+
* Returns validation result with error message if invalid
|
|
28
|
+
*/
|
|
29
|
+
function validatePrivateKey(key) {
|
|
30
|
+
if (!key || key.trim() === "") {
|
|
31
|
+
return { valid: false, error: "Private key is empty" };
|
|
32
|
+
}
|
|
33
|
+
const normalized = normalizePrivateKey(key);
|
|
34
|
+
const hasValidHeader = SUPPORTED_KEY_HEADERS.some((header) => normalized.startsWith(header));
|
|
35
|
+
if (!hasValidHeader) {
|
|
36
|
+
if (normalized.includes("PUBLIC KEY")) {
|
|
37
|
+
return {
|
|
38
|
+
valid: false,
|
|
39
|
+
error: "This appears to be a public key. Please provide a private key.",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (!normalized.startsWith("-----BEGIN")) {
|
|
43
|
+
return {
|
|
44
|
+
valid: false,
|
|
45
|
+
error: "Invalid key format. Key must start with -----BEGIN ... PRIVATE KEY-----",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
valid: false,
|
|
50
|
+
error: "Unsupported key format. Supported formats: RSA, OpenSSH, PKCS#8, EC, DSA",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (!normalized.includes("-----END")) {
|
|
54
|
+
return {
|
|
55
|
+
valid: false,
|
|
56
|
+
error: "Key is incomplete. Missing -----END ... PRIVATE KEY----- footer.",
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return { valid: true };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sshKeyUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sshKeyUtils.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/sshKeyUtils.ts"],"names":[],"mappings":";;AAkBA,kDAEC;AAMD,gDA2CC;AArED;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC7B,iCAAiC;IACjC,qCAAqC;IACrC,6BAA6B;IAC7B,gCAAgC;IAChC,iCAAiC;CACjC,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,GAAW;IAC9C,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAI7C,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAE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