arisa 2.3.43 → 2.3.45
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 +27 -58
package/package.json
CHANGED
package/src/daemon/setup.ts
CHANGED
|
@@ -44,13 +44,16 @@ function saveEnv(vars: Record<string, string>) {
|
|
|
44
44
|
writeFileSync(ENV_PATH, content);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
//
|
|
47
|
+
// Robust readline that survives after child processes inherit stdin
|
|
48
48
|
async function readLine(question: string): Promise<string> {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const rl = await import("node:readline");
|
|
50
|
+
const iface = rl.createInterface({ input: process.stdin, output: process.stdout });
|
|
51
|
+
return new Promise<string>((resolve) => {
|
|
52
|
+
iface.question(question, (answer) => {
|
|
53
|
+
iface.close();
|
|
54
|
+
resolve(answer.trim());
|
|
55
|
+
});
|
|
56
|
+
});
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export async function runSetup(): Promise<boolean> {
|
|
@@ -320,30 +323,12 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
320
323
|
console.log(`Starting ${cli} login...`);
|
|
321
324
|
|
|
322
325
|
try {
|
|
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
326
|
const proc = Bun.spawn(buildBunWrappedAgentCliCommand(cli, args, { skipPreload: true }), {
|
|
328
327
|
stdin: "inherit",
|
|
329
|
-
stdout:
|
|
328
|
+
stdout: "inherit",
|
|
330
329
|
stderr: "inherit",
|
|
331
|
-
env: isClaudeSetupToken ? { ...process.env, NO_COLOR: "1" } : undefined,
|
|
332
330
|
});
|
|
333
331
|
|
|
334
|
-
let output = "";
|
|
335
|
-
if (isClaudeSetupToken) {
|
|
336
|
-
const reader = (proc.stdout as ReadableStream<Uint8Array>).getReader();
|
|
337
|
-
const decoder = new TextDecoder();
|
|
338
|
-
while (true) {
|
|
339
|
-
const { done, value } = await reader.read();
|
|
340
|
-
if (done) break;
|
|
341
|
-
const chunk = decoder.decode(value, { stream: true });
|
|
342
|
-
process.stdout.write(chunk);
|
|
343
|
-
output += chunk;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
332
|
const exitCode = await proc.exited;
|
|
348
333
|
|
|
349
334
|
if (exitCode !== 0) {
|
|
@@ -353,40 +338,24 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
353
338
|
|
|
354
339
|
console.log(` ✓ ${cli} login successful`);
|
|
355
340
|
|
|
356
|
-
// `claude setup-token` prints a
|
|
357
|
-
//
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
.
|
|
363
|
-
.
|
|
364
|
-
|
|
365
|
-
.
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
for (const line of lines) {
|
|
373
|
-
const trimmed = line.trim();
|
|
374
|
-
if (trimmed && /^[A-Za-z0-9_-]+$/.test(trimmed)) {
|
|
375
|
-
token += trimmed;
|
|
376
|
-
} else {
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (token.startsWith("sk-ant-") && token.length > 80) {
|
|
381
|
-
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
382
|
-
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
383
|
-
saveEnv(vars);
|
|
384
|
-
console.log(` ✓ token saved to .env (${token.length} chars)`);
|
|
385
|
-
} else {
|
|
386
|
-
console.log(` ⚠ token looks invalid (${token.length} chars) — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env`);
|
|
387
|
-
}
|
|
341
|
+
// `claude setup-token` prints a token but does NOT store it.
|
|
342
|
+
// Ask the user to paste it.
|
|
343
|
+
if (cli === "claude") {
|
|
344
|
+
console.log("\n Paste the token shown above (starts with sk-ant-):");
|
|
345
|
+
const token = (await readLine(" > ")).trim();
|
|
346
|
+
if (token.startsWith("sk-ant-") && token.length > 80) {
|
|
347
|
+
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
348
|
+
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
349
|
+
saveEnv(vars);
|
|
350
|
+
console.log(` ✓ token saved to .env (${token.length} chars)`);
|
|
351
|
+
} else if (token) {
|
|
352
|
+
// Save it anyway, user knows best
|
|
353
|
+
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
354
|
+
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
355
|
+
saveEnv(vars);
|
|
356
|
+
console.log(` ⚠ token saved (${token.length} chars) — verify it works`);
|
|
388
357
|
} else {
|
|
389
|
-
console.log(" ⚠
|
|
358
|
+
console.log(" ⚠ no token — set CLAUDE_CODE_OAUTH_TOKEN in ~/.arisa/.env");
|
|
390
359
|
}
|
|
391
360
|
}
|
|
392
361
|
|