claude-bridge-cli 2.0.1 → 2.0.3

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/lib/bridge.js +44 -2
  2. package/package.json +1 -1
package/lib/bridge.js CHANGED
@@ -378,7 +378,26 @@ function getSessionMessages(sessionId) {
378
378
  }
379
379
  } catch {}
380
380
  }
381
- return { session_id: sessionId, messages, in_progress: running.has(sessionId) };
381
+ // Match the Python bridge's shape so the app's reconnect/resume loader can
382
+ // detect completion. Without `status` (and end-of-turn markers on the
383
+ // trailing assistant), the loader never finalizes — it shows "still working"
384
+ // forever even though Claude is done (the stuck-loader bug on this bridge).
385
+ const inProgress = running.has(sessionId);
386
+ const last_event_ts = messages.length ? (messages[messages.length - 1].timestamp || null) : null;
387
+ if (!inProgress && messages.length) {
388
+ const last = messages[messages.length - 1];
389
+ if (last.role === "assistant" && last.text) {
390
+ last.stop_reason = "end_turn";
391
+ last.final_text = last.text;
392
+ }
393
+ }
394
+ return {
395
+ session_id: sessionId,
396
+ messages,
397
+ in_progress: inProgress,
398
+ status: inProgress ? "in_progress" : "complete",
399
+ last_event_ts,
400
+ };
382
401
  }
383
402
  return { error: "session not found" };
384
403
  }
@@ -433,7 +452,7 @@ function renameSession(sessionId, title) {
433
452
 
434
453
  // ── Run claude -p ──
435
454
 
436
- function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_tools }) {
455
+ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_tools, model }) {
437
456
  return new Promise((resolve) => {
438
457
  let finalPrompt = prompt;
439
458
  if (images && images.length) {
@@ -497,6 +516,8 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
497
516
  }
498
517
  }
499
518
  if (plan_mode) args.push("--plan");
519
+ // Optional model override from the extension's model picker (alias or id).
520
+ if (model && String(model).trim()) args.push("--model", String(model).trim());
500
521
 
501
522
  const bin = isCmdShim ? process.env.COMSPEC || "cmd.exe" : config.claudeBin;
502
523
  const fullArgs = isCmdShim ? ["/c", config.claudeBin, ...args] : args;
@@ -689,6 +710,27 @@ function startBridge(config) {
689
710
  }
690
711
  }
691
712
 
713
+ // AutoMode cross-device state + single-runner lease (per session, like marks)
714
+ m = url.pathname.match(/^\/sessions\/([A-Za-z0-9._-]+)\/automode$/);
715
+ if (m) {
716
+ const amFile = path.join(dd, "automode-state.json");
717
+ const allAm = readJson(amFile, {});
718
+ if (req.method === "GET") {
719
+ send(200, { automode: allAm[m[1]] || {} });
720
+ return;
721
+ }
722
+ if (req.method === "PATCH" || req.method === "POST") {
723
+ const body = await readBody(req);
724
+ const allowed = ["to_claude", "to_gpt", "gpt_ready", "claude_ready", "active_client", "active_ts"];
725
+ const cur = allAm[m[1]] || {};
726
+ for (const k of allowed) if (k in body) cur[k] = body[k];
727
+ allAm[m[1]] = cur;
728
+ writeJson(amFile, allAm);
729
+ send(200, { automode: cur });
730
+ return;
731
+ }
732
+ }
733
+
692
734
  // Title rename
693
735
  m = url.pathname.match(/^\/sessions\/([A-Za-z0-9._-]+)\/title$/);
694
736
  if (m && (req.method === "PATCH" || req.method === "POST")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Use Claude Code from your browser. Runs a local server that connects your browser tools to the Claude CLI.",
5
5
  "main": "lib/bridge.js",
6
6
  "bin": {