arisa 2.3.8 → 2.3.10
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/package.json +1 -1
- package/src/daemon/setup.ts +23 -16
package/package.json
CHANGED
package/src/daemon/setup.ts
CHANGED
|
@@ -276,31 +276,38 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
276
276
|
|
|
277
277
|
const exitCode = await proc.exited;
|
|
278
278
|
if (exitCode === 0) {
|
|
279
|
-
// Strip
|
|
279
|
+
// Step 1: Strip ANSI escape sequences FIRST (their params contain digits/letters)
|
|
280
280
|
const clean = output
|
|
281
|
-
.replace(/\x1b\[[
|
|
282
|
-
.replace(/\x1b[^\
|
|
283
|
-
.replace(/\
|
|
281
|
+
.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "") // CSI: ESC [ params final
|
|
282
|
+
.replace(/\x1b\][^\x07]*\x07/g, "") // OSC: ESC ] ... BEL
|
|
283
|
+
.replace(/\x1b[^[\]]/g, "") // Other ESC sequences (ESC + one char)
|
|
284
|
+
.replace(/[\x00-\x09\x0b-\x0c\x0e-\x1f]/g, ""); // Control chars (keep \n \r)
|
|
284
285
|
|
|
286
|
+
// Step 2: Find boundaries in clean text
|
|
287
|
+
const startIdx = clean.indexOf("sk-ant-");
|
|
285
288
|
let token = "";
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
|
|
290
|
+
if (startIdx >= 0) {
|
|
291
|
+
let endIdx = clean.indexOf("Store", startIdx);
|
|
292
|
+
if (endIdx < 0) endIdx = clean.indexOf("Use this", startIdx);
|
|
293
|
+
if (endIdx < 0) endIdx = startIdx + 200;
|
|
294
|
+
|
|
295
|
+
const tokenArea = clean.substring(startIdx, endIdx);
|
|
296
|
+
// Step 3: Strip whitespace and any remaining non-token chars
|
|
297
|
+
token = tokenArea.replace(/[^A-Za-z0-9_-]/g, "");
|
|
295
298
|
}
|
|
296
299
|
|
|
297
|
-
if (token) {
|
|
298
|
-
console.log(` [
|
|
300
|
+
if (token && token.startsWith("sk-ant-") && token.length > 50 && token.length < 150) {
|
|
301
|
+
console.log(` [token] ${token.slice(0, 20)}...${token.slice(-6)} (${token.length} chars)`);
|
|
299
302
|
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
300
303
|
saveEnv(vars);
|
|
301
304
|
console.log(" ✓ claude token saved to .env");
|
|
302
305
|
} else {
|
|
303
|
-
console.log(
|
|
306
|
+
console.log(` ⚠ token extraction failed (indexOf=${startIdx}, len=${token.length})`);
|
|
307
|
+
// Show what the cleaned text looks like around the token
|
|
308
|
+
if (startIdx >= 0) {
|
|
309
|
+
console.log(` [clean] ${clean.substring(startIdx, startIdx + 150).replace(/\n/g, "\\n")}`);
|
|
310
|
+
}
|
|
304
311
|
}
|
|
305
312
|
console.log(` ✓ claude login successful`);
|
|
306
313
|
return true;
|