bitfab-cli 0.2.87 → 0.2.88

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 +39 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9999,6 +9999,7 @@ var DaemonClient = class {
9999
9999
  buffer = "";
10000
10000
  responseQueue = [];
10001
10001
  eventHandler = null;
10002
+ disconnectHandler = null;
10002
10003
  socketPath;
10003
10004
  constructor(socketPath) {
10004
10005
  this.socketPath = socketPath ?? SOCKET_PATH;
@@ -10020,9 +10021,14 @@ var DaemonClient = class {
10020
10021
  return;
10021
10022
  }
10022
10023
  this.socket = null;
10024
+ this.disconnectHandler?.(err);
10023
10025
  });
10024
10026
  socket.on("close", () => {
10027
+ const wasConnected = this.socket !== null;
10025
10028
  this.socket = null;
10029
+ if (wasConnected) {
10030
+ this.disconnectHandler?.(new Error("daemon connection closed"));
10031
+ }
10026
10032
  });
10027
10033
  });
10028
10034
  }
@@ -10103,8 +10109,13 @@ var DaemonClient = class {
10103
10109
  onEvent(handler) {
10104
10110
  this.eventHandler = handler;
10105
10111
  }
10112
+ /** Fires once when the daemon connection drops unexpectedly (not on destroy). */
10113
+ onDisconnect(handler) {
10114
+ this.disconnectHandler = handler;
10115
+ }
10106
10116
  destroy() {
10107
10117
  this.eventHandler = null;
10118
+ this.disconnectHandler = null;
10108
10119
  this.responseQueue = [];
10109
10120
  if (this.socket) {
10110
10121
  this.socket.destroy();
@@ -10113,6 +10124,23 @@ var DaemonClient = class {
10113
10124
  }
10114
10125
  };
10115
10126
 
10127
+ // ../bitfab-plugin-lib/dist/studioUrl.js
10128
+ var DEFAULT_STUDIO_PATH = "/studio";
10129
+ function resolveStudioInitialPath(input) {
10130
+ if (input && isValidStudioRoute(input)) {
10131
+ return input;
10132
+ }
10133
+ return DEFAULT_STUDIO_PATH;
10134
+ }
10135
+ function buildStudioSessionUrl(args) {
10136
+ const { serviceUrl, path: path18, sessionId } = args;
10137
+ if (path18.includes("session=")) {
10138
+ return `${serviceUrl}${path18}`;
10139
+ }
10140
+ const separator = path18.includes("?") ? "&" : "?";
10141
+ return `${serviceUrl}${path18}${separator}session=${encodeURIComponent(sessionId)}`;
10142
+ }
10143
+
10116
10144
  // ../bitfab-plugin-lib/dist/studioChannel.js
10117
10145
  var DirectChannel = class {
10118
10146
  apiKey;
@@ -10127,11 +10155,12 @@ var DirectChannel = class {
10127
10155
  async openOrNavigate(path18, opts) {
10128
10156
  if (!this.apiKey) {
10129
10157
  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)}`;
10158
+ const initialPath = resolveStudioInitialPath(path18);
10159
+ const url2 = buildStudioSessionUrl({
10160
+ serviceUrl: this.serviceUrl,
10161
+ path: initialPath,
10162
+ sessionId: sessionId2
10163
+ });
10135
10164
  const windowPid = openChromelessWindow(url2);
10136
10165
  writeActiveStudioSession({
10137
10166
  sessionId: sessionId2,
@@ -10255,18 +10284,21 @@ var DaemonChannel = class _DaemonChannel {
10255
10284
  })
10256
10285
  ]);
10257
10286
  }
10258
- subscribe(_sessionId, onEvent, _onError) {
10287
+ subscribe(_sessionId, onEvent, onError) {
10259
10288
  const done = new Promise((resolve) => {
10260
10289
  this.doneResolve = resolve;
10261
10290
  });
10262
10291
  this.client.onEvent((push) => {
10263
10292
  const event = {
10264
- id: "",
10293
+ id: push.id,
10265
10294
  type: push.event,
10266
10295
  data: push.data
10267
10296
  };
10268
10297
  onEvent(event);
10269
10298
  });
10299
+ this.client.onDisconnect((err) => {
10300
+ onError(err);
10301
+ });
10270
10302
  return {
10271
10303
  abort: () => this.destroy(),
10272
10304
  done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitfab-cli",
3
- "version": "0.2.87",
3
+ "version": "0.2.88",
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",