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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/daemon/setup.ts +23 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.3.8",
3
+ "version": "2.3.10",
4
4
  "description": "Arisa - dynamic agent runtime with daemon/core architecture that evolves through user interaction",
5
5
  "preferGlobal": true,
6
6
  "bin": {
@@ -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 ALL ANSI escape sequences and control chars, then extract token line-by-line
279
+ // Step 1: Strip ANSI escape sequences FIRST (their params contain digits/letters)
280
280
  const clean = output
281
- .replace(/\x1b\[[\x20-\x3f]*[\x40-\x7e]/g, "") // CSI sequences
282
- .replace(/\x1b[^\x1b]{0,5}/g, "") // other ESC sequences
283
- .replace(/\r/g, ""); // carriage returns
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
- for (const line of clean.split("\n")) {
287
- const t = line.trim();
288
- if (t.startsWith("sk-ant-")) {
289
- token = t;
290
- } else if (token && t && /^[A-Za-z0-9_-]+$/.test(t)) {
291
- token += t; // continuation line (wrapped token)
292
- } else if (token) {
293
- break; // end of token (empty line or text)
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(` [debug] token captured: ${token.slice(0, 20)}...${token.slice(-10)} (${token.length} chars)`);
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("could not extract token from output");
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;