arisa 2.3.38 → 2.3.40
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 +37 -42
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,45 +342,38 @@ 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
|
-
const tokenMatch = output.match(/(sk-ant-oat01-[A-Za-z0-9_-]+)/);
|
|
352
|
-
if (tokenMatch) {
|
|
353
|
-
const token = tokenMatch[1];
|
|
354
|
-
console.log(` [token] ${token.slice(0, 20)}...${token.slice(-6)} (${token.length} chars)`);
|
|
355
|
-
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
356
|
-
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
357
|
-
saveEnv(vars);
|
|
358
|
-
console.log(" ✓ token saved to .env");
|
|
359
|
-
} else {
|
|
360
|
-
console.log(" ⚠ could not extract token from output — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env");
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
console.log(` ✓ claude login successful`);
|
|
364
|
-
return true;
|
|
365
345
|
}
|
|
366
346
|
|
|
367
|
-
// For codex and others: inherit all stdio
|
|
368
|
-
const proc = Bun.spawn(buildBunWrappedAgentCliCommand(cli, args, { skipPreload: true }), {
|
|
369
|
-
stdin: "inherit",
|
|
370
|
-
stdout: "inherit",
|
|
371
|
-
stderr: "inherit",
|
|
372
|
-
});
|
|
373
347
|
const exitCode = await proc.exited;
|
|
374
348
|
|
|
375
|
-
if (exitCode
|
|
376
|
-
console.log(` ✓ ${cli} login successful`);
|
|
377
|
-
return true;
|
|
378
|
-
} else {
|
|
349
|
+
if (exitCode !== 0) {
|
|
379
350
|
console.log(` ✗ ${cli} login failed (exit ${exitCode})`);
|
|
380
351
|
return false;
|
|
381
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
|
+
// Grab everything from "sk-ant-" onwards, strip whitespace, extract full token
|
|
360
|
+
const idx = output.indexOf("sk-ant-");
|
|
361
|
+
if (idx >= 0) {
|
|
362
|
+
const token = output.substring(idx).split(/\n\n/)[0].replace(/\s+/g, "");
|
|
363
|
+
if (token.length > 80) {
|
|
364
|
+
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
365
|
+
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
366
|
+
saveEnv(vars);
|
|
367
|
+
console.log(` ✓ token saved to .env (${token.length} chars)`);
|
|
368
|
+
} else {
|
|
369
|
+
console.log(` ⚠ token looks short (${token.length} chars) — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env`);
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
console.log(" ⚠ could not find token in output — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env");
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return true;
|
|
382
377
|
} catch (e) {
|
|
383
378
|
console.error(` Login error: ${e}`);
|
|
384
379
|
return false;
|