arisa 2.3.13 → 2.3.14
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 +30 -10
package/package.json
CHANGED
package/src/daemon/setup.ts
CHANGED
|
@@ -276,15 +276,36 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
276
276
|
|
|
277
277
|
const exitCode = await proc.exited;
|
|
278
278
|
if (exitCode === 0) {
|
|
279
|
-
//
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
// Strip ANSI with a state machine (regex can't handle all Ink sequences)
|
|
280
|
+
function stripAnsi(s: string): string {
|
|
281
|
+
let out = "";
|
|
282
|
+
for (let i = 0; i < s.length; i++) {
|
|
283
|
+
if (s.charCodeAt(i) === 0x1b) {
|
|
284
|
+
i++;
|
|
285
|
+
if (i >= s.length) break;
|
|
286
|
+
if (s[i] === "[") {
|
|
287
|
+
// CSI: ESC [ <params 0x20-0x3F>* <final 0x40-0x7E>
|
|
288
|
+
i++;
|
|
289
|
+
while (i < s.length && s.charCodeAt(i) < 0x40) i++;
|
|
290
|
+
// i now on final byte, loop will i++
|
|
291
|
+
} else if (s[i] === "]") {
|
|
292
|
+
// OSC: ESC ] ... BEL(0x07) or ST(ESC \)
|
|
293
|
+
i++;
|
|
294
|
+
while (i < s.length && s.charCodeAt(i) !== 0x07 && s[i] !== "\x1b") i++;
|
|
295
|
+
} else if (s[i] === "(" || s[i] === ")" || s[i] === "#") {
|
|
296
|
+
i++; // skip designator byte
|
|
297
|
+
}
|
|
298
|
+
// else: 2-byte Fe sequence, already skipped
|
|
299
|
+
} else if (s.charCodeAt(i) < 0x20 && s[i] !== "\n" && s[i] !== "\r") {
|
|
300
|
+
// skip control chars
|
|
301
|
+
} else {
|
|
302
|
+
out += s[i];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const clean = stripAnsi(output);
|
|
288
309
|
const startIdx = clean.indexOf("sk-ant-");
|
|
289
310
|
let token = "";
|
|
290
311
|
|
|
@@ -294,7 +315,6 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
294
315
|
if (endIdx < 0) endIdx = startIdx + 200;
|
|
295
316
|
|
|
296
317
|
const tokenArea = clean.substring(startIdx, endIdx);
|
|
297
|
-
// Step 3: Strip whitespace and any remaining non-token chars
|
|
298
318
|
token = tokenArea.replace(/[^A-Za-z0-9_-]/g, "");
|
|
299
319
|
}
|
|
300
320
|
|