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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/daemon/setup.ts +27 -58
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.3.43",
3
+ "version": "2.3.45",
4
4
  "description": "Arisa - dynamic agent runtime with daemon/core architecture that evolves through user interaction",
5
5
  "keywords": [
6
6
  "tinyclaw",
@@ -44,13 +44,16 @@ function saveEnv(vars: Record<string, string>) {
44
44
  writeFileSync(ENV_PATH, content);
45
45
  }
46
46
 
47
- // Fallback readline for non-TTY environments
47
+ // Robust readline that survives after child processes inherit stdin
48
48
  async function readLine(question: string): Promise<string> {
49
- process.stdout.write(question);
50
- for await (const line of console) {
51
- return line.trim();
52
- }
53
- return "";
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: isClaudeSetupToken ? "pipe" : "inherit",
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 long-lived (1 year) token but does NOT
357
- // store it. Extract from captured output and save to .env.
358
- if (isClaudeSetupToken) {
359
- // Ink CLI embeds ANSI escape sequences (cursor, colors, OSC) even with
360
- // NO_COLOR. Strip everything non-printable before searching for the token.
361
- const clean = output
362
- .replace(/\x1b\[[0-9;]*[A-Za-z]/g, "") // CSI sequences
363
- .replace(/\x1b\][^\x07]*\x07/g, "") // OSC sequences
364
- .replace(/\x1b[()][A-Z0-9]/g, "") // Charset sequences
365
- .replace(/\r/g, ""); // Carriage returns
366
-
367
- // Token lines are purely [A-Za-z0-9_-] with no spaces.
368
- const idx = clean.indexOf("sk-ant-");
369
- if (idx >= 0) {
370
- const lines = clean.substring(idx).split("\n");
371
- let token = "";
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(" ⚠ could not find token in output — set CLAUDE_CODE_OAUTH_TOKEN manually in ~/.arisa/.env");
358
+ console.log(" ⚠ no token — set CLAUDE_CODE_OAUTH_TOKEN in ~/.arisa/.env");
390
359
  }
391
360
  }
392
361