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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.3.12",
3
+ "version": "2.3.14",
4
4
  "description": "Arisa - dynamic agent runtime with daemon/core architecture that evolves through user interaction",
5
5
  "preferGlobal": true,
6
6
  "bin": {
@@ -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
 
@@ -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
- // Step 1: Strip ANSI escape sequences FIRST (their params contain digits/letters)
280
- const clean = output
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)
285
-
286
- // Step 2: Find boundaries in clean text
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