arisa 2.3.39 → 2.3.41
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 +47 -47
package/package.json
CHANGED
package/src/daemon/setup.ts
CHANGED
|
@@ -320,17 +320,19 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
320
320
|
console.log(`Starting ${cli} login...`);
|
|
321
321
|
|
|
322
322
|
try {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
323
|
+
const isClaudeSetupToken = cli === "claude";
|
|
324
|
+
|
|
325
|
+
// For claude setup-token: pipe stdout to capture token while echoing to terminal.
|
|
326
|
+
// For others (codex): inherit stdout for full native rendering.
|
|
327
|
+
const proc = Bun.spawn(buildBunWrappedAgentCliCommand(cli, args, { skipPreload: true }), {
|
|
328
|
+
stdin: "inherit",
|
|
329
|
+
stdout: isClaudeSetupToken ? "pipe" : "inherit",
|
|
330
|
+
stderr: "inherit",
|
|
331
|
+
env: isClaudeSetupToken ? { ...process.env, FORCE_COLOR: "1" } : undefined,
|
|
332
|
+
});
|
|
332
333
|
|
|
333
|
-
|
|
334
|
+
let output = "";
|
|
335
|
+
if (isClaudeSetupToken) {
|
|
334
336
|
const reader = (proc.stdout as ReadableStream<Uint8Array>).getReader();
|
|
335
337
|
const decoder = new TextDecoder();
|
|
336
338
|
while (true) {
|
|
@@ -340,50 +342,48 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
340
342
|
process.stdout.write(chunk);
|
|
341
343
|
output += chunk;
|
|
342
344
|
}
|
|
343
|
-
|
|
344
|
-
const exitCode = await proc.exited;
|
|
345
|
-
if (exitCode !== 0) {
|
|
346
|
-
console.log(` ✗ claude login failed (exit ${exitCode})`);
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Extract token from output (format: sk-ant-oat01-...)
|
|
351
|
-
// The CLI wraps long tokens across multiple lines — collect until blank line, strip whitespace.
|
|
352
|
-
const tokenStartIdx = output.indexOf("sk-ant-oat01-");
|
|
353
|
-
const tokenArea = tokenStartIdx >= 0
|
|
354
|
-
? output.substring(tokenStartIdx, output.indexOf("\n\n", tokenStartIdx) >>> 0 || tokenStartIdx + 200)
|
|
355
|
-
: "";
|
|
356
|
-
const tokenMatch = tokenArea ? tokenArea.replace(/\s+/g, "").match(/(sk-ant-oat01-[A-Za-z0-9_-]+)/) : null;
|
|
357
|
-
if (tokenMatch) {
|
|
358
|
-
const token = tokenMatch[1];
|
|
359
|
-
console.log(` [token] ${token.slice(0, 20)}...${token.slice(-6)} (${token.length} chars)`);
|
|
360
|
-
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
361
|
-
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
362
|
-
saveEnv(vars);
|
|
363
|
-
console.log(" ✓ token saved to .env");
|
|
364
|
-
} else {
|
|
365
|
-
console.log(" ⚠ could not extract token from output — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env");
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
console.log(` ✓ claude login successful`);
|
|
369
|
-
return true;
|
|
370
345
|
}
|
|
371
346
|
|
|
372
|
-
// For codex and others: inherit all stdio
|
|
373
|
-
const proc = Bun.spawn(buildBunWrappedAgentCliCommand(cli, args, { skipPreload: true }), {
|
|
374
|
-
stdin: "inherit",
|
|
375
|
-
stdout: "inherit",
|
|
376
|
-
stderr: "inherit",
|
|
377
|
-
});
|
|
378
347
|
const exitCode = await proc.exited;
|
|
379
348
|
|
|
380
|
-
if (exitCode
|
|
381
|
-
console.log(` ✓ ${cli} login successful`);
|
|
382
|
-
return true;
|
|
383
|
-
} else {
|
|
349
|
+
if (exitCode !== 0) {
|
|
384
350
|
console.log(` ✗ ${cli} login failed (exit ${exitCode})`);
|
|
385
351
|
return false;
|
|
386
352
|
}
|
|
353
|
+
|
|
354
|
+
console.log(` ✓ ${cli} login successful`);
|
|
355
|
+
|
|
356
|
+
// `claude setup-token` prints a long-lived (1 year) token but does NOT
|
|
357
|
+
// store it. Extract from captured output and save to .env.
|
|
358
|
+
if (isClaudeSetupToken) {
|
|
359
|
+
// Token lines are purely [A-Za-z0-9_-] with no spaces.
|
|
360
|
+
// Stop collecting when we hit a line with spaces (e.g. "Store this token...")
|
|
361
|
+
const idx = output.indexOf("sk-ant-");
|
|
362
|
+
if (idx >= 0) {
|
|
363
|
+
const lines = output.substring(idx).split("\n");
|
|
364
|
+
let token = "";
|
|
365
|
+
for (const line of lines) {
|
|
366
|
+
const trimmed = line.trim();
|
|
367
|
+
if (trimmed && /^[A-Za-z0-9_-]+$/.test(trimmed)) {
|
|
368
|
+
token += trimmed;
|
|
369
|
+
} else {
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (token.startsWith("sk-ant-") && token.length > 80) {
|
|
374
|
+
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
375
|
+
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
376
|
+
saveEnv(vars);
|
|
377
|
+
console.log(` ✓ token saved to .env (${token.length} chars)`);
|
|
378
|
+
} else {
|
|
379
|
+
console.log(` ⚠ token looks invalid (${token.length} chars) — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env`);
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
console.log(" ⚠ could not find token in output — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env");
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return true;
|
|
387
387
|
} catch (e) {
|
|
388
388
|
console.error(` Login error: ${e}`);
|
|
389
389
|
return false;
|