arisa 2.3.12 → 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/index.ts +6 -0
- package/src/daemon/setup.ts +30 -9
package/package.json
CHANGED
package/src/daemon/index.ts
CHANGED
|
@@ -42,6 +42,12 @@ const { saveMessageRecord } = await import("../shared/db");
|
|
|
42
42
|
|
|
43
43
|
const log = createLogger("daemon");
|
|
44
44
|
|
|
45
|
+
// Log version
|
|
46
|
+
try {
|
|
47
|
+
const _pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
48
|
+
log.info(`Arisa v${_pkg.version}`);
|
|
49
|
+
} catch {}
|
|
50
|
+
|
|
45
51
|
// --- Claim process: kill previous daemon, write our PID ---
|
|
46
52
|
claimProcess("daemon");
|
|
47
53
|
|
package/src/daemon/setup.ts
CHANGED
|
@@ -276,14 +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
|
-
|
|
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);
|
|
287
309
|
const startIdx = clean.indexOf("sk-ant-");
|
|
288
310
|
let token = "";
|
|
289
311
|
|
|
@@ -293,7 +315,6 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
293
315
|
if (endIdx < 0) endIdx = startIdx + 200;
|
|
294
316
|
|
|
295
317
|
const tokenArea = clean.substring(startIdx, endIdx);
|
|
296
|
-
// Step 3: Strip whitespace and any remaining non-token chars
|
|
297
318
|
token = tokenArea.replace(/[^A-Za-z0-9_-]/g, "");
|
|
298
319
|
}
|
|
299
320
|
|