@lifeaitools/clauth 1.5.69 → 1.5.71

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.
@@ -3793,6 +3793,29 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
3793
3793
  return;
3794
3794
  }
3795
3795
 
3796
+ // POST /terminal/recv — read last response from a terminal session
3797
+ if (method === "POST" && reqPath === "/terminal/recv") {
3798
+ let body = "";
3799
+ req.on("data", d => body += d);
3800
+ req.on("end", () => {
3801
+ try {
3802
+ const { session_id } = JSON.parse(body);
3803
+ if (!session_id) {
3804
+ res.writeHead(400, { "Content-Type": "application/json", ...CORS });
3805
+ return res.end(JSON.stringify({ error: "session_id required" }));
3806
+ }
3807
+ const result = recvTerminalResponse(session_id);
3808
+ const status = result.error ? 404 : 200;
3809
+ res.writeHead(status, { "Content-Type": "application/json", ...CORS });
3810
+ res.end(JSON.stringify(result));
3811
+ } catch {
3812
+ res.writeHead(400, { "Content-Type": "application/json", ...CORS });
3813
+ res.end(JSON.stringify({ error: "invalid JSON" }));
3814
+ }
3815
+ });
3816
+ return;
3817
+ }
3818
+
3796
3819
  // POST /channel — receive Coolify/GitHub webhook events
3797
3820
  if (method === "POST" && reqPath === "/channel") {
3798
3821
  let body = "";
@@ -5366,12 +5389,18 @@ function spawnClaudeTask(prompt, jobId, cwd) {
5366
5389
  }
5367
5390
 
5368
5391
  activeCliWorkers++;
5369
- const proc = spawnProc(binary, ['-p', prompt, '--dangerously-skip-permissions'], {
5370
- cwd: cwd || CHITCHAT_FALLBACK_CWD,
5371
- env: process.env,
5372
- stdio: ['ignore', 'pipe', 'pipe'],
5373
- shell: true,
5374
- });
5392
+ // Use cmd /c with shell: false so Node quotes each argument properly for
5393
+ // CreateProcess. This prevents prompts containing spaces from being parsed
5394
+ // as separate CLI flags by Windows. Works for both .cmd and plain binaries.
5395
+ const proc = spawnProc(
5396
+ 'cmd', ['/c', binary, '-p', prompt, '--dangerously-skip-permissions'],
5397
+ {
5398
+ cwd: cwd || CHITCHAT_FALLBACK_CWD,
5399
+ env: process.env,
5400
+ stdio: ['ignore', 'pipe', 'pipe'],
5401
+ shell: false,
5402
+ }
5403
+ );
5375
5404
 
5376
5405
  const startedAt = Date.now();
5377
5406
  proc.on('close', (code) => {
@@ -5561,34 +5590,15 @@ async function startChitchatSession(name) {
5561
5590
 
5562
5591
  const binary = findClaudeBinary();
5563
5592
 
5564
- // Spawn a Windows Terminal tab running `npx clauth chitchat --session <id>`
5565
- // Uses LOCALAPPDATA WindowsApps path (App Execution Alias not visible to fs.existsSync but spawnable)
5566
- try {
5567
- const wtPath = path.join(process.env.LOCALAPPDATA || '', 'Microsoft', 'WindowsApps', 'wt.exe');
5568
- const ps1Path = path.join(os.tmpdir(), `clauth-collab-${session_id.slice(0, 8)}.ps1`);
5569
- fs.writeFileSync(ps1Path,
5570
- `Set-Location '${CHITCHAT_CWD}'\r\n` +
5571
- `npx clauth chitchat --session ${session_id}\r\n`
5572
- );
5573
- const child = spawnProc(wtPath, [
5574
- 'new-tab', '--title', `collab-${session_id.slice(0, 8)}`,
5575
- '--', 'powershell.exe', '-NoExit', '-File', ps1Path
5576
- ], { detached: true, stdio: 'ignore', shell: false });
5577
- child.on('error', err => {
5578
- console.warn(`[ClaudeAItoCLI] wt spawn failed (${err.message}) — fallback to cmd /c start`);
5579
- try {
5580
- execSyncTop(
5581
- `cmd /c start "" wt.exe new-tab --title "collab-${session_id.slice(0, 8)}" -- powershell.exe -NoExit -File "${ps1Path}"`,
5582
- { stdio: 'ignore', shell: true }
5583
- );
5584
- } catch (e2) {
5585
- console.warn(`[ClaudeAItoCLI] fallback also failed: ${e2.message} — run manually: cd ${CHITCHAT_CWD} && npx clauth chitchat --session ${session_id}`);
5586
- }
5587
- });
5588
- child.unref();
5589
- console.log(`[ClaudeAItoCLI] spawned terminal tab for session ${session_id}`);
5590
- } catch (err) {
5591
- console.warn(`[ClaudeAItoCLI] could not spawn terminal: ${err.message}`);
5593
+ // Spawn the Claude Code agent directly via spawnClaudeTask.
5594
+ // Embeds the session ID as plain text in the prompt so there are no
5595
+ // shell-quoting issues with --session being parsed as a Claude flag.
5596
+ const prompt = `You are joining a chitchat collab session. Session ID: ${session_id}. Run /rdc:collab --session ${session_id}`;
5597
+ const spawnResult = spawnClaudeTask(prompt, `chitchat-${session_id.slice(0, 8)}`, CHITCHAT_FALLBACK_CWD);
5598
+ if (spawnResult.error) {
5599
+ console.warn(`[ClaudeAItoCLI] spawnClaudeTask failed: ${spawnResult.error} — ${spawnResult.message}`);
5600
+ } else {
5601
+ console.log(`[ClaudeAItoCLI] spawned agent pid=${spawnResult.pid} for session ${session_id}`);
5592
5602
  }
5593
5603
 
5594
5604
  // Queue greeting so claude.ai gets an immediate response on first chitchat_recv
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/clauth",
3
- "version": "1.5.69",
3
+ "version": "1.5.71",
4
4
  "description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
5
5
  "type": "module",
6
6
  "bin": {