bitfab-cli 0.2.85 → 0.2.87

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/dist/index.js +35 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8742,6 +8742,12 @@ var NotAuthenticatedError = class extends Error {
8742
8742
  this.name = "NotAuthenticatedError";
8743
8743
  }
8744
8744
  };
8745
+ var DaemonUnavailableError = class extends Error {
8746
+ constructor(message) {
8747
+ super(message);
8748
+ this.name = "DaemonUnavailableError";
8749
+ }
8750
+ };
8745
8751
  var StudioNavigationError = class extends Error {
8746
8752
  reason;
8747
8753
  blockedReason;
@@ -9844,8 +9850,8 @@ async function pingSocket(socketPath) {
9844
9850
  socket.write('{"cmd":"ping"}\n');
9845
9851
  });
9846
9852
  let buffer = "";
9847
- socket.on("data", (chunk) => {
9848
- buffer += chunk.toString();
9853
+ socket.on("data", (chunk2) => {
9854
+ buffer += chunk2.toString();
9849
9855
  if (buffer.includes("\n")) {
9850
9856
  clearTimeout(timeout);
9851
9857
  socket.destroy();
@@ -9908,7 +9914,7 @@ function spawnDaemon(socketPath, pidPath) {
9908
9914
  const thisDir = path8.dirname(fileURLToPath2(import.meta.url));
9909
9915
  const mainPath = path8.join(thisDir, "main.js");
9910
9916
  if (!fs9.existsSync(mainPath)) {
9911
- throw new Error(`daemon entry point not found: ${mainPath}`);
9917
+ throw new DaemonUnavailableError(`daemon entry point not found: ${mainPath}`);
9912
9918
  }
9913
9919
  const child = fork(mainPath, [socketPath, pidPath], {
9914
9920
  detached: true,
@@ -10004,8 +10010,8 @@ var DaemonClient = class {
10004
10010
  this.socket = socket;
10005
10011
  resolve();
10006
10012
  });
10007
- socket.on("data", (chunk) => {
10008
- this.buffer += chunk.toString();
10013
+ socket.on("data", (chunk2) => {
10014
+ this.buffer += chunk2.toString();
10009
10015
  this.drain();
10010
10016
  });
10011
10017
  socket.on("error", (err) => {
@@ -10119,6 +10125,22 @@ var DirectChannel = class {
10119
10125
  this.apiKey = apiKey;
10120
10126
  }
10121
10127
  async openOrNavigate(path18, opts) {
10128
+ if (!this.apiKey) {
10129
+ const sessionId2 = opts?.sessionId ?? crypto6.randomUUID();
10130
+ const initialPath = path18.startsWith("/studio") ? path18 : "/studio";
10131
+ if (!isValidStudioRoute(initialPath)) {
10132
+ throw new Error(`Studio route not allowed: ${initialPath}`);
10133
+ }
10134
+ const url2 = initialPath.includes("session=") ? `${this.serviceUrl}${initialPath}` : `${this.serviceUrl}${initialPath}${initialPath.includes("?") ? "&" : "?"}session=${encodeURIComponent(sessionId2)}`;
10135
+ const windowPid = openChromelessWindow(url2);
10136
+ writeActiveStudioSession({
10137
+ sessionId: sessionId2,
10138
+ serviceUrl: this.serviceUrl,
10139
+ windowPid,
10140
+ currentPath: initialPath
10141
+ });
10142
+ return { sessionId: sessionId2, opened: true };
10143
+ }
10122
10144
  const existing = readActiveStudioSession();
10123
10145
  if (existing && existing.windowState !== "closed") {
10124
10146
  const ack = await navigateStudioAndAwaitAck({
@@ -10302,7 +10324,9 @@ async function resolveChannel(apiKey, serviceUrl) {
10302
10324
  if (err instanceof StudioNavigationError) {
10303
10325
  throw err;
10304
10326
  }
10305
- console.error(`daemon unavailable, falling back to direct: ${err instanceof Error ? err.message : String(err)}`);
10327
+ if (!(err instanceof DaemonUnavailableError)) {
10328
+ console.error(`daemon unavailable, falling back to direct: ${err instanceof Error ? err.message : String(err)}`);
10329
+ }
10306
10330
  }
10307
10331
  }
10308
10332
  return new DirectChannel(apiKey, serviceUrl);
@@ -24526,6 +24550,11 @@ var inputFileSchema = external_exports.object({
24526
24550
  // ../bitfab-plugin-lib/dist/commands/pushActivity.js
24527
24551
  import { spawn as spawn3 } from "child_process";
24528
24552
 
24553
+ // ../bitfab-plugin-lib/dist/commands/readTracesBatched.js
24554
+ import { writeFileSync } from "fs";
24555
+ import { tmpdir } from "os";
24556
+ import { join } from "path";
24557
+
24529
24558
  // ../bitfab-plugin-lib/dist/activePreviewSession.js
24530
24559
  import fs12 from "fs";
24531
24560
  import os11 from "os";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitfab-cli",
3
- "version": "0.2.85",
3
+ "version": "0.2.87",
4
4
  "description": "Install and configure the Bitfab plugin in Claude Code, Codex, or Cursor.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",