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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/daemon/setup.ts +30 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.3.13",
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": {
@@ -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
- // 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 (e.g. ESC[1C)
282
- .replace(/\x1b\][^\x07]*\x07/g, "") // OSC: ESC ] ... BEL
283
- .replace(/\x1b[()#][A-Za-z0-9]/g, "") // 3-byte: ESC ( B, ESC ) 0, ESC # 8
284
- .replace(/\x1b./g, "") // Remaining 2-byte ESC sequences
285
- .replace(/[\x00-\x09\x0b-\x0c\x0e-\x1f]/g, ""); // Control chars (keep \n \r)
286
-
287
- // 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);
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