bitfab-cli 0.2.128 → 0.2.130
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.
- package/dist/index.js +291 -151
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5152,8 +5152,8 @@ var require_utils = __commonJS({
|
|
|
5152
5152
|
}
|
|
5153
5153
|
return ind;
|
|
5154
5154
|
}
|
|
5155
|
-
function removeDotSegments(
|
|
5156
|
-
let input =
|
|
5155
|
+
function removeDotSegments(path20) {
|
|
5156
|
+
let input = path20;
|
|
5157
5157
|
const output = [];
|
|
5158
5158
|
let nextSlash = -1;
|
|
5159
5159
|
let len = 0;
|
|
@@ -5352,8 +5352,8 @@ var require_schemes = __commonJS({
|
|
|
5352
5352
|
wsComponent.secure = void 0;
|
|
5353
5353
|
}
|
|
5354
5354
|
if (wsComponent.resourceName) {
|
|
5355
|
-
const [
|
|
5356
|
-
wsComponent.path =
|
|
5355
|
+
const [path20, query] = wsComponent.resourceName.split("?");
|
|
5356
|
+
wsComponent.path = path20 && path20 !== "/" ? path20 : void 0;
|
|
5357
5357
|
wsComponent.query = query;
|
|
5358
5358
|
wsComponent.resourceName = void 0;
|
|
5359
5359
|
}
|
|
@@ -8715,12 +8715,12 @@ var require_dist = __commonJS({
|
|
|
8715
8715
|
throw new Error(`Unknown format "${name}"`);
|
|
8716
8716
|
return f;
|
|
8717
8717
|
};
|
|
8718
|
-
function addFormats(ajv, list,
|
|
8718
|
+
function addFormats(ajv, list, fs23, exportName) {
|
|
8719
8719
|
var _a2;
|
|
8720
8720
|
var _b;
|
|
8721
8721
|
(_a2 = (_b = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
8722
8722
|
for (const f of list)
|
|
8723
|
-
ajv.addFormat(f,
|
|
8723
|
+
ajv.addFormat(f, fs23[f]);
|
|
8724
8724
|
}
|
|
8725
8725
|
module.exports = exports = formatsPlugin;
|
|
8726
8726
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -8924,18 +8924,18 @@ async function closeStudio(client, message) {
|
|
|
8924
8924
|
data: message ? { message } : {}
|
|
8925
8925
|
});
|
|
8926
8926
|
}
|
|
8927
|
-
async function navigateStudio(client,
|
|
8928
|
-
if (!isValidStudioRoute(
|
|
8929
|
-
throw new Error(`Studio route not allowed: ${
|
|
8927
|
+
async function navigateStudio(client, path20) {
|
|
8928
|
+
if (!isValidStudioRoute(path20)) {
|
|
8929
|
+
throw new Error(`Studio route not allowed: ${path20}`);
|
|
8930
8930
|
}
|
|
8931
8931
|
return pushAgentSessionEvent(client, {
|
|
8932
8932
|
type: "agent:navigate",
|
|
8933
|
-
data: { path:
|
|
8933
|
+
data: { path: path20 }
|
|
8934
8934
|
});
|
|
8935
8935
|
}
|
|
8936
8936
|
var STUDIO_NAVIGATE_ACK_TIMEOUT_MS = 12e3;
|
|
8937
8937
|
var PING_PONG_TIMEOUT_MS = 5e3;
|
|
8938
|
-
function awaitNavigateAck(client,
|
|
8938
|
+
function awaitNavigateAck(client, path20, ackTimeoutMs, startCursor) {
|
|
8939
8939
|
const abortController = new AbortController();
|
|
8940
8940
|
let timer = null;
|
|
8941
8941
|
const result = new Promise((resolve2) => {
|
|
@@ -8943,7 +8943,7 @@ function awaitNavigateAck(client, path19, ackTimeoutMs, startCursor) {
|
|
|
8943
8943
|
resolve2({ acked: false, reason: "timeout" });
|
|
8944
8944
|
abortController.abort();
|
|
8945
8945
|
}, ackTimeoutMs);
|
|
8946
|
-
const pathOnly =
|
|
8946
|
+
const pathOnly = path20.split("?")[0];
|
|
8947
8947
|
pollAgentSessionEvents({
|
|
8948
8948
|
serviceUrl: client.serviceUrl,
|
|
8949
8949
|
apiKey: client.apiKey,
|
|
@@ -9029,18 +9029,18 @@ function awaitPong(client, pingTs) {
|
|
|
9029
9029
|
});
|
|
9030
9030
|
});
|
|
9031
9031
|
}
|
|
9032
|
-
async function navigateStudioAndAwaitAck(client,
|
|
9032
|
+
async function navigateStudioAndAwaitAck(client, path20, opts = {}) {
|
|
9033
9033
|
const ackTimeoutMs = opts.ackTimeoutMs ?? STUDIO_NAVIGATE_ACK_TIMEOUT_MS;
|
|
9034
|
-
if (!isValidStudioRoute(
|
|
9034
|
+
if (!isValidStudioRoute(path20)) {
|
|
9035
9035
|
return { acked: false, reason: "invalid-route" };
|
|
9036
9036
|
}
|
|
9037
9037
|
const startCursor = await fetchStreamTip(client);
|
|
9038
9038
|
try {
|
|
9039
|
-
await navigateStudio(client,
|
|
9039
|
+
await navigateStudio(client, path20);
|
|
9040
9040
|
} catch {
|
|
9041
9041
|
return { acked: false, reason: "push-failed" };
|
|
9042
9042
|
}
|
|
9043
|
-
const result = await awaitNavigateAck(client,
|
|
9043
|
+
const result = await awaitNavigateAck(client, path20, ackTimeoutMs, startCursor);
|
|
9044
9044
|
if (result.acked || result.reason !== "timeout") {
|
|
9045
9045
|
return result;
|
|
9046
9046
|
}
|
|
@@ -9397,7 +9397,8 @@ function readLegacySession() {
|
|
|
9397
9397
|
browserConnected: false,
|
|
9398
9398
|
lastEventAt: null,
|
|
9399
9399
|
lastEventCursor: null,
|
|
9400
|
-
agentSessionKey: null
|
|
9400
|
+
agentSessionKey: null,
|
|
9401
|
+
worktreeRoot: null
|
|
9401
9402
|
};
|
|
9402
9403
|
} catch {
|
|
9403
9404
|
return null;
|
|
@@ -9419,7 +9420,8 @@ function writeActiveStudioSession(init) {
|
|
|
9419
9420
|
browserConnected: false,
|
|
9420
9421
|
lastEventAt: null,
|
|
9421
9422
|
lastEventCursor: null,
|
|
9422
|
-
agentSessionKey: null
|
|
9423
|
+
agentSessionKey: null,
|
|
9424
|
+
worktreeRoot: null
|
|
9423
9425
|
};
|
|
9424
9426
|
writeStateFile(sessionFilePath(), state);
|
|
9425
9427
|
}
|
|
@@ -9935,7 +9937,7 @@ function extractCommandName(argv) {
|
|
|
9935
9937
|
}
|
|
9936
9938
|
|
|
9937
9939
|
// ../bitfab-plugin-lib/dist/studioChannel.js
|
|
9938
|
-
import
|
|
9940
|
+
import crypto8 from "crypto";
|
|
9939
9941
|
|
|
9940
9942
|
// ../bitfab-plugin-lib/dist/commands/createStudioSession.js
|
|
9941
9943
|
function ensureStudioPath(p5) {
|
|
@@ -9974,19 +9976,39 @@ async function createStudioSession({ serviceUrl, apiKey, sessionId, initialPath
|
|
|
9974
9976
|
import net2 from "net";
|
|
9975
9977
|
|
|
9976
9978
|
// ../bitfab-plugin-lib/dist/daemon/ensure.js
|
|
9977
|
-
import { execFileSync as
|
|
9978
|
-
import
|
|
9979
|
-
import
|
|
9979
|
+
import { execFileSync as execFileSync5, fork } from "child_process";
|
|
9980
|
+
import crypto6 from "crypto";
|
|
9981
|
+
import fs10 from "fs";
|
|
9980
9982
|
import net from "net";
|
|
9981
|
-
import
|
|
9982
|
-
import { fileURLToPath as
|
|
9983
|
+
import path9 from "path";
|
|
9984
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
9983
9985
|
|
|
9984
9986
|
// ../bitfab-plugin-lib/dist/daemon/protocol.js
|
|
9987
|
+
import crypto5 from "crypto";
|
|
9985
9988
|
import os9 from "os";
|
|
9986
9989
|
import path7 from "path";
|
|
9987
9990
|
var BITFAB_CONFIG_DIR = path7.join(os9.homedir(), ".config", "bitfab");
|
|
9988
9991
|
var SOCKET_PATH = path7.join(BITFAB_CONFIG_DIR, "studio-daemon.sock");
|
|
9989
9992
|
var PID_FILE_PATH = path7.join(BITFAB_CONFIG_DIR, "studio-daemon.pid");
|
|
9993
|
+
var DAEMON_DIR = path7.join(BITFAB_CONFIG_DIR, "daemon");
|
|
9994
|
+
var SINGLETON_DAEMON_PATHS = {
|
|
9995
|
+
socketPath: SOCKET_PATH,
|
|
9996
|
+
pidPath: PID_FILE_PATH,
|
|
9997
|
+
metaPath: null,
|
|
9998
|
+
worktreeRoot: null
|
|
9999
|
+
};
|
|
10000
|
+
function hashWorktreeRoot(worktreeRoot) {
|
|
10001
|
+
return crypto5.createHash("sha256").update(worktreeRoot).digest("hex").slice(0, 12);
|
|
10002
|
+
}
|
|
10003
|
+
function devDaemonPaths(worktreeRoot) {
|
|
10004
|
+
const base = path7.join(DAEMON_DIR, `dev-${hashWorktreeRoot(worktreeRoot)}`);
|
|
10005
|
+
return {
|
|
10006
|
+
socketPath: `${base}.sock`,
|
|
10007
|
+
pidPath: `${base}.pid`,
|
|
10008
|
+
metaPath: `${base}.meta.json`,
|
|
10009
|
+
worktreeRoot
|
|
10010
|
+
};
|
|
10011
|
+
}
|
|
9990
10012
|
var BROWSER_HEALTH_INTERVAL_MS = 10 * 1e3;
|
|
9991
10013
|
var ENSURE_POLL_INTERVAL_MS = 200;
|
|
9992
10014
|
var ENSURE_TIMEOUT_MS = 5e3;
|
|
@@ -10002,9 +10024,108 @@ function isPush(msg) {
|
|
|
10002
10024
|
return typeof msg === "object" && msg !== null && "event" in msg;
|
|
10003
10025
|
}
|
|
10004
10026
|
|
|
10027
|
+
// ../bitfab-plugin-lib/dist/daemon/scope.js
|
|
10028
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
10029
|
+
import fs9 from "fs";
|
|
10030
|
+
import path8 from "path";
|
|
10031
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
10032
|
+
function resolveWorktreeRoot(fromDir) {
|
|
10033
|
+
try {
|
|
10034
|
+
const out = execFileSync4("git", ["rev-parse", "--show-toplevel"], {
|
|
10035
|
+
cwd: fromDir,
|
|
10036
|
+
encoding: "utf-8",
|
|
10037
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
10038
|
+
}).trim();
|
|
10039
|
+
return out || null;
|
|
10040
|
+
} catch {
|
|
10041
|
+
return null;
|
|
10042
|
+
}
|
|
10043
|
+
}
|
|
10044
|
+
function moduleDir() {
|
|
10045
|
+
return path8.dirname(fileURLToPath2(import.meta.url));
|
|
10046
|
+
}
|
|
10047
|
+
var PROD_INSTALL_MARKERS = [
|
|
10048
|
+
`${path8.sep}.claude${path8.sep}plugins${path8.sep}`,
|
|
10049
|
+
`${path8.sep}.codex${path8.sep}plugins${path8.sep}`,
|
|
10050
|
+
`${path8.sep}.cursor${path8.sep}plugins${path8.sep}`,
|
|
10051
|
+
`${path8.sep}.npm${path8.sep}`
|
|
10052
|
+
];
|
|
10053
|
+
function isProdInstallPath(dir) {
|
|
10054
|
+
return PROD_INSTALL_MARKERS.some((marker) => dir.includes(marker));
|
|
10055
|
+
}
|
|
10056
|
+
function resolveDevWorktreeRoot() {
|
|
10057
|
+
const dir = moduleDir();
|
|
10058
|
+
if (isProdInstallPath(dir)) {
|
|
10059
|
+
return null;
|
|
10060
|
+
}
|
|
10061
|
+
return resolveWorktreeRoot(dir);
|
|
10062
|
+
}
|
|
10063
|
+
function resolveDaemonPaths() {
|
|
10064
|
+
const worktreeRoot = resolveDevWorktreeRoot();
|
|
10065
|
+
return worktreeRoot ? devDaemonPaths(worktreeRoot) : SINGLETON_DAEMON_PATHS;
|
|
10066
|
+
}
|
|
10067
|
+
function processIsAlive(pid) {
|
|
10068
|
+
try {
|
|
10069
|
+
process.kill(pid, 0);
|
|
10070
|
+
return true;
|
|
10071
|
+
} catch (err) {
|
|
10072
|
+
return err.code !== "ESRCH";
|
|
10073
|
+
}
|
|
10074
|
+
}
|
|
10075
|
+
function unlinkQuietly(...paths) {
|
|
10076
|
+
for (const p5 of paths) {
|
|
10077
|
+
try {
|
|
10078
|
+
fs9.unlinkSync(p5);
|
|
10079
|
+
} catch {
|
|
10080
|
+
}
|
|
10081
|
+
}
|
|
10082
|
+
}
|
|
10083
|
+
function readMeta(metaPath) {
|
|
10084
|
+
try {
|
|
10085
|
+
const parsed = JSON.parse(fs9.readFileSync(metaPath, "utf-8"));
|
|
10086
|
+
if (typeof parsed.pid === "number" && typeof parsed.worktreeRoot === "string" && typeof parsed.socketPath === "string" && typeof parsed.pidPath === "string") {
|
|
10087
|
+
return parsed;
|
|
10088
|
+
}
|
|
10089
|
+
} catch {
|
|
10090
|
+
}
|
|
10091
|
+
return null;
|
|
10092
|
+
}
|
|
10093
|
+
function sweepZombieDaemons(dir = DAEMON_DIR) {
|
|
10094
|
+
let entries;
|
|
10095
|
+
try {
|
|
10096
|
+
entries = fs9.readdirSync(dir);
|
|
10097
|
+
} catch {
|
|
10098
|
+
return;
|
|
10099
|
+
}
|
|
10100
|
+
for (const name of entries) {
|
|
10101
|
+
if (!name.startsWith("dev-") || !name.endsWith(".meta.json")) {
|
|
10102
|
+
continue;
|
|
10103
|
+
}
|
|
10104
|
+
const metaPath = path8.join(dir, name);
|
|
10105
|
+
const meta3 = readMeta(metaPath);
|
|
10106
|
+
if (!meta3) {
|
|
10107
|
+
unlinkQuietly(metaPath);
|
|
10108
|
+
continue;
|
|
10109
|
+
}
|
|
10110
|
+
const pidAlive = processIsAlive(meta3.pid);
|
|
10111
|
+
const worktreeExists = fs9.existsSync(meta3.worktreeRoot);
|
|
10112
|
+
if (pidAlive && worktreeExists) {
|
|
10113
|
+
continue;
|
|
10114
|
+
}
|
|
10115
|
+
if (!pidAlive) {
|
|
10116
|
+
unlinkQuietly(meta3.socketPath, meta3.pidPath, `${meta3.socketPath}.lock`, metaPath);
|
|
10117
|
+
continue;
|
|
10118
|
+
}
|
|
10119
|
+
try {
|
|
10120
|
+
process.kill(meta3.pid, "SIGHUP");
|
|
10121
|
+
} catch {
|
|
10122
|
+
}
|
|
10123
|
+
}
|
|
10124
|
+
}
|
|
10125
|
+
|
|
10005
10126
|
// ../bitfab-plugin-lib/dist/daemon/ensure.js
|
|
10006
10127
|
var LOCK_STALE_MS = 1e4;
|
|
10007
|
-
function
|
|
10128
|
+
function processIsAlive2(pid) {
|
|
10008
10129
|
try {
|
|
10009
10130
|
process.kill(pid, 0);
|
|
10010
10131
|
return true;
|
|
@@ -10014,7 +10135,7 @@ function processIsAlive(pid) {
|
|
|
10014
10135
|
}
|
|
10015
10136
|
function readPid(pidPath) {
|
|
10016
10137
|
try {
|
|
10017
|
-
const raw =
|
|
10138
|
+
const raw = fs10.readFileSync(pidPath, "utf-8").trim();
|
|
10018
10139
|
const pid = Number.parseInt(raw, 10);
|
|
10019
10140
|
return Number.isNaN(pid) ? null : pid;
|
|
10020
10141
|
} catch {
|
|
@@ -10078,10 +10199,10 @@ async function waitForLockHolderDaemon(socketPath, timeoutMs, localBuild = local
|
|
|
10078
10199
|
}
|
|
10079
10200
|
function localBuildFingerprint() {
|
|
10080
10201
|
try {
|
|
10081
|
-
const thisDir =
|
|
10082
|
-
const serverPath =
|
|
10083
|
-
const content =
|
|
10084
|
-
return
|
|
10202
|
+
const thisDir = path9.dirname(fileURLToPath3(import.meta.url));
|
|
10203
|
+
const serverPath = path9.join(thisDir, "server.js");
|
|
10204
|
+
const content = fs10.readFileSync(serverPath);
|
|
10205
|
+
return crypto6.createHash("sha256").update(content).digest("hex").slice(0, 16);
|
|
10085
10206
|
} catch {
|
|
10086
10207
|
return "unknown";
|
|
10087
10208
|
}
|
|
@@ -10089,7 +10210,7 @@ function localBuildFingerprint() {
|
|
|
10089
10210
|
function findDaemonPids(socketPath) {
|
|
10090
10211
|
let out;
|
|
10091
10212
|
try {
|
|
10092
|
-
out =
|
|
10213
|
+
out = execFileSync5("ps", ["-axww", "-o", "pid=,command="], {
|
|
10093
10214
|
encoding: "utf-8"
|
|
10094
10215
|
});
|
|
10095
10216
|
} catch {
|
|
@@ -10123,9 +10244,9 @@ function commandTargetsSocket(command, socketPath) {
|
|
|
10123
10244
|
}
|
|
10124
10245
|
return false;
|
|
10125
10246
|
}
|
|
10126
|
-
async function reapAllDaemons(
|
|
10127
|
-
const pids = new Set(findDaemonPids(socketPath));
|
|
10128
|
-
const pidfilePid = readPid(pidPath);
|
|
10247
|
+
async function reapAllDaemons(paths) {
|
|
10248
|
+
const pids = new Set(findDaemonPids(paths.socketPath));
|
|
10249
|
+
const pidfilePid = readPid(paths.pidPath);
|
|
10129
10250
|
if (pidfilePid !== null) {
|
|
10130
10251
|
pids.add(pidfilePid);
|
|
10131
10252
|
}
|
|
@@ -10137,43 +10258,54 @@ async function reapAllDaemons(socketPath, pidPath) {
|
|
|
10137
10258
|
}
|
|
10138
10259
|
const deadline = Date.now() + 5e3;
|
|
10139
10260
|
while (Date.now() < deadline) {
|
|
10140
|
-
if (![...pids].some(
|
|
10261
|
+
if (![...pids].some(processIsAlive2)) {
|
|
10141
10262
|
break;
|
|
10142
10263
|
}
|
|
10143
10264
|
await new Promise((r) => setTimeout(r, 50));
|
|
10144
10265
|
}
|
|
10145
10266
|
for (const pid of pids) {
|
|
10146
|
-
if (
|
|
10267
|
+
if (processIsAlive2(pid)) {
|
|
10147
10268
|
try {
|
|
10148
10269
|
process.kill(pid, "SIGKILL");
|
|
10149
10270
|
} catch {
|
|
10150
10271
|
}
|
|
10151
10272
|
}
|
|
10152
10273
|
}
|
|
10153
|
-
cleanupStaleFiles(
|
|
10274
|
+
cleanupStaleFiles(paths);
|
|
10154
10275
|
}
|
|
10155
|
-
function spawnDaemon(
|
|
10156
|
-
const thisDir =
|
|
10157
|
-
const mainPath =
|
|
10158
|
-
if (!
|
|
10276
|
+
function spawnDaemon(paths) {
|
|
10277
|
+
const thisDir = path9.dirname(fileURLToPath3(import.meta.url));
|
|
10278
|
+
const mainPath = path9.join(thisDir, "main.js");
|
|
10279
|
+
if (!fs10.existsSync(mainPath)) {
|
|
10159
10280
|
throw new DaemonUnavailableError(`daemon entry point not found: ${mainPath}`);
|
|
10160
10281
|
}
|
|
10161
|
-
const child = fork(mainPath, [
|
|
10282
|
+
const child = fork(mainPath, [
|
|
10283
|
+
paths.socketPath,
|
|
10284
|
+
paths.pidPath,
|
|
10285
|
+
paths.metaPath ?? "",
|
|
10286
|
+
paths.worktreeRoot ?? ""
|
|
10287
|
+
], {
|
|
10162
10288
|
detached: true,
|
|
10163
10289
|
stdio: "ignore",
|
|
10164
10290
|
execArgv: []
|
|
10165
10291
|
});
|
|
10166
10292
|
child.unref();
|
|
10167
10293
|
}
|
|
10168
|
-
function cleanupStaleFiles(
|
|
10294
|
+
function cleanupStaleFiles(paths) {
|
|
10169
10295
|
try {
|
|
10170
|
-
|
|
10296
|
+
fs10.unlinkSync(paths.socketPath);
|
|
10171
10297
|
} catch {
|
|
10172
10298
|
}
|
|
10173
10299
|
try {
|
|
10174
|
-
|
|
10300
|
+
fs10.unlinkSync(paths.pidPath);
|
|
10175
10301
|
} catch {
|
|
10176
10302
|
}
|
|
10303
|
+
if (paths.metaPath) {
|
|
10304
|
+
try {
|
|
10305
|
+
fs10.unlinkSync(paths.metaPath);
|
|
10306
|
+
} catch {
|
|
10307
|
+
}
|
|
10308
|
+
}
|
|
10177
10309
|
}
|
|
10178
10310
|
function lockPath(socketPath) {
|
|
10179
10311
|
return `${socketPath}.lock`;
|
|
@@ -10181,8 +10313,8 @@ function lockPath(socketPath) {
|
|
|
10181
10313
|
function acquireLock(socketPath) {
|
|
10182
10314
|
const lock = lockPath(socketPath);
|
|
10183
10315
|
try {
|
|
10184
|
-
|
|
10185
|
-
|
|
10316
|
+
fs10.mkdirSync(path9.dirname(lock), { recursive: true });
|
|
10317
|
+
fs10.writeFileSync(lock, `${process.pid}
|
|
10186
10318
|
`, { flag: "wx" });
|
|
10187
10319
|
return true;
|
|
10188
10320
|
} catch (err) {
|
|
@@ -10190,10 +10322,10 @@ function acquireLock(socketPath) {
|
|
|
10190
10322
|
return true;
|
|
10191
10323
|
}
|
|
10192
10324
|
try {
|
|
10193
|
-
const stat =
|
|
10325
|
+
const stat = fs10.statSync(lock);
|
|
10194
10326
|
if (Date.now() - stat.mtimeMs > LOCK_STALE_MS) {
|
|
10195
|
-
|
|
10196
|
-
|
|
10327
|
+
fs10.unlinkSync(lock);
|
|
10328
|
+
fs10.writeFileSync(lock, `${process.pid}
|
|
10197
10329
|
`, { flag: "wx" });
|
|
10198
10330
|
return true;
|
|
10199
10331
|
}
|
|
@@ -10204,13 +10336,15 @@ function acquireLock(socketPath) {
|
|
|
10204
10336
|
}
|
|
10205
10337
|
function releaseLock(socketPath) {
|
|
10206
10338
|
try {
|
|
10207
|
-
|
|
10339
|
+
fs10.unlinkSync(lockPath(socketPath));
|
|
10208
10340
|
} catch {
|
|
10209
10341
|
}
|
|
10210
10342
|
}
|
|
10211
|
-
async function ensureDaemon(
|
|
10343
|
+
async function ensureDaemon(paths = SINGLETON_DAEMON_PATHS) {
|
|
10344
|
+
const { socketPath, pidPath } = paths;
|
|
10345
|
+
sweepZombieDaemons();
|
|
10212
10346
|
const pid = readPid(pidPath);
|
|
10213
|
-
if (pid !== null &&
|
|
10347
|
+
if (pid !== null && processIsAlive2(pid)) {
|
|
10214
10348
|
const ping = await pingSocket(socketPath);
|
|
10215
10349
|
if (ping.alive) {
|
|
10216
10350
|
const localBuild = localBuildFingerprint();
|
|
@@ -10226,8 +10360,8 @@ async function ensureDaemon(socketPath = SOCKET_PATH, pidPath = PID_FILE_PATH) {
|
|
|
10226
10360
|
return;
|
|
10227
10361
|
}
|
|
10228
10362
|
try {
|
|
10229
|
-
await reapAllDaemons(
|
|
10230
|
-
spawnDaemon(
|
|
10363
|
+
await reapAllDaemons(paths);
|
|
10364
|
+
spawnDaemon(paths);
|
|
10231
10365
|
await waitForSocket(socketPath, ENSURE_TIMEOUT_MS);
|
|
10232
10366
|
} finally {
|
|
10233
10367
|
releaseLock(socketPath);
|
|
@@ -10241,12 +10375,14 @@ var DaemonClient = class {
|
|
|
10241
10375
|
responseQueue = [];
|
|
10242
10376
|
eventHandler = null;
|
|
10243
10377
|
disconnectHandler = null;
|
|
10378
|
+
paths;
|
|
10244
10379
|
socketPath;
|
|
10245
|
-
constructor(
|
|
10246
|
-
this.
|
|
10380
|
+
constructor(paths = SINGLETON_DAEMON_PATHS) {
|
|
10381
|
+
this.paths = paths;
|
|
10382
|
+
this.socketPath = paths.socketPath;
|
|
10247
10383
|
}
|
|
10248
10384
|
async connect() {
|
|
10249
|
-
await ensureDaemon(this.
|
|
10385
|
+
await ensureDaemon(this.paths);
|
|
10250
10386
|
return new Promise((resolve2, reject) => {
|
|
10251
10387
|
const socket = net2.createConnection(this.socketPath, () => {
|
|
10252
10388
|
this.socket = socket;
|
|
@@ -10379,16 +10515,16 @@ var DaemonClient = class {
|
|
|
10379
10515
|
};
|
|
10380
10516
|
|
|
10381
10517
|
// ../bitfab-plugin-lib/dist/studioEventLog.js
|
|
10382
|
-
import
|
|
10383
|
-
import
|
|
10518
|
+
import crypto7 from "crypto";
|
|
10519
|
+
import fs11 from "fs";
|
|
10384
10520
|
import os10 from "os";
|
|
10385
|
-
import
|
|
10386
|
-
var SESSIONS_DIR2 =
|
|
10521
|
+
import path10 from "path";
|
|
10522
|
+
var SESSIONS_DIR2 = path10.join(os10.homedir(), ".config", "bitfab", "sessions");
|
|
10387
10523
|
function shortHash2(input) {
|
|
10388
|
-
return
|
|
10524
|
+
return crypto7.createHash("sha256").update(input).digest("hex").slice(0, 16);
|
|
10389
10525
|
}
|
|
10390
10526
|
function eventLogPathForKey(key) {
|
|
10391
|
-
return
|
|
10527
|
+
return path10.join(SESSIONS_DIR2, `${shortHash2(key)}.events.jsonl`);
|
|
10392
10528
|
}
|
|
10393
10529
|
function studioEventToLogLine(event, sessionId) {
|
|
10394
10530
|
const data = event.data ?? {};
|
|
@@ -10403,21 +10539,21 @@ function studioEventToLogLine(event, sessionId) {
|
|
|
10403
10539
|
function appendStudioEvent(key, line) {
|
|
10404
10540
|
try {
|
|
10405
10541
|
const target = eventLogPathForKey(key);
|
|
10406
|
-
|
|
10407
|
-
|
|
10542
|
+
fs11.mkdirSync(path10.dirname(target), { recursive: true });
|
|
10543
|
+
fs11.appendFileSync(target, `${JSON.stringify(line)}
|
|
10408
10544
|
`);
|
|
10409
10545
|
} catch {
|
|
10410
10546
|
}
|
|
10411
10547
|
}
|
|
10412
10548
|
function truncateStudioEventLog(key) {
|
|
10413
10549
|
try {
|
|
10414
|
-
|
|
10550
|
+
fs11.rmSync(eventLogPathForKey(key), { force: true });
|
|
10415
10551
|
} catch {
|
|
10416
10552
|
}
|
|
10417
10553
|
}
|
|
10418
10554
|
function readStudioEventLogTail(key, fromLine = 1) {
|
|
10419
10555
|
try {
|
|
10420
|
-
const raw =
|
|
10556
|
+
const raw = fs11.readFileSync(eventLogPathForKey(key), "utf-8");
|
|
10421
10557
|
const all = raw.split("\n").filter((l) => l.length > 0);
|
|
10422
10558
|
const start = Math.max(0, fromLine - 1);
|
|
10423
10559
|
const slice = all.slice(start);
|
|
@@ -10473,17 +10609,17 @@ function resolveStudioInitialPath(input) {
|
|
|
10473
10609
|
return DEFAULT_STUDIO_PATH;
|
|
10474
10610
|
}
|
|
10475
10611
|
function buildStudioSessionUrl(args) {
|
|
10476
|
-
const { serviceUrl, path:
|
|
10477
|
-
if (
|
|
10478
|
-
return `${serviceUrl}${
|
|
10612
|
+
const { serviceUrl, path: path20, sessionId } = args;
|
|
10613
|
+
if (path20.includes("session=")) {
|
|
10614
|
+
return `${serviceUrl}${path20}`;
|
|
10479
10615
|
}
|
|
10480
|
-
const separator =
|
|
10481
|
-
return `${serviceUrl}${
|
|
10616
|
+
const separator = path20.includes("?") ? "&" : "?";
|
|
10617
|
+
return `${serviceUrl}${path20}${separator}session=${encodeURIComponent(sessionId)}`;
|
|
10482
10618
|
}
|
|
10483
10619
|
|
|
10484
10620
|
// ../bitfab-plugin-lib/dist/studioChannel.js
|
|
10485
|
-
function stripSessionId(
|
|
10486
|
-
return sessionId ?
|
|
10621
|
+
function stripSessionId(path20, sessionId) {
|
|
10622
|
+
return sessionId ? path20.split(sessionId).join("__SID__") : path20;
|
|
10487
10623
|
}
|
|
10488
10624
|
var DirectChannel = class {
|
|
10489
10625
|
apiKey;
|
|
@@ -10498,10 +10634,10 @@ var DirectChannel = class {
|
|
|
10498
10634
|
isPersistent() {
|
|
10499
10635
|
return false;
|
|
10500
10636
|
}
|
|
10501
|
-
async openOrNavigate(
|
|
10637
|
+
async openOrNavigate(path20, opts) {
|
|
10502
10638
|
if (!this.apiKey) {
|
|
10503
|
-
const sessionId2 = opts?.sessionId ??
|
|
10504
|
-
const initialPath = resolveStudioInitialPath(
|
|
10639
|
+
const sessionId2 = opts?.sessionId ?? crypto8.randomUUID();
|
|
10640
|
+
const initialPath = resolveStudioInitialPath(path20);
|
|
10505
10641
|
const live = readActiveStudioSession();
|
|
10506
10642
|
if (live && live.source === "direct" && !live.authenticated && live.windowState !== "closed" && live.serviceUrl === this.serviceUrl && live.currentPath != null && stripSessionId(live.currentPath, live.sessionId) === stripSessionId(initialPath, sessionId2)) {
|
|
10507
10643
|
return { sessionId: live.sessionId, opened: false };
|
|
@@ -10532,20 +10668,20 @@ var DirectChannel = class {
|
|
|
10532
10668
|
serviceUrl: existing.serviceUrl,
|
|
10533
10669
|
apiKey: this.apiKey,
|
|
10534
10670
|
sessionId: existing.sessionId
|
|
10535
|
-
},
|
|
10671
|
+
}, path20);
|
|
10536
10672
|
if (!ack.acked) {
|
|
10537
10673
|
throw new StudioNavigationError(ack.reason ?? "unknown", ack.blockedReason, existing.sessionId);
|
|
10538
10674
|
}
|
|
10539
|
-
updateActiveStudioSession({ currentPath:
|
|
10675
|
+
updateActiveStudioSession({ currentPath: path20 });
|
|
10540
10676
|
return { sessionId: existing.sessionId, opened: false };
|
|
10541
10677
|
}
|
|
10542
10678
|
truncateStudioEventLog(resolveAgentSessionKey());
|
|
10543
|
-
const sessionId = opts?.sessionId ??
|
|
10679
|
+
const sessionId = opts?.sessionId ?? crypto8.randomUUID();
|
|
10544
10680
|
const session = await createStudioSession({
|
|
10545
10681
|
serviceUrl: this.serviceUrl,
|
|
10546
10682
|
apiKey: this.apiKey,
|
|
10547
10683
|
sessionId,
|
|
10548
|
-
initialPath:
|
|
10684
|
+
initialPath: path20,
|
|
10549
10685
|
clientHeaders: opts?.clientHeaders
|
|
10550
10686
|
});
|
|
10551
10687
|
return { sessionId: session.sessionId, opened: true };
|
|
@@ -10601,7 +10737,7 @@ var DaemonChannel = class _DaemonChannel {
|
|
|
10601
10737
|
this.serviceUrl = serviceUrl;
|
|
10602
10738
|
}
|
|
10603
10739
|
static async connect(apiKey, serviceUrl) {
|
|
10604
|
-
const client = new DaemonClient();
|
|
10740
|
+
const client = new DaemonClient(resolveDaemonPaths());
|
|
10605
10741
|
await client.connect();
|
|
10606
10742
|
const key = resolveAgentSessionKey();
|
|
10607
10743
|
return new _DaemonChannel(client, key, apiKey, serviceUrl);
|
|
@@ -10612,18 +10748,18 @@ var DaemonChannel = class _DaemonChannel {
|
|
|
10612
10748
|
isPersistent() {
|
|
10613
10749
|
return true;
|
|
10614
10750
|
}
|
|
10615
|
-
async openOrNavigate(
|
|
10751
|
+
async openOrNavigate(path20, opts) {
|
|
10616
10752
|
const openRes = await this.client.open({
|
|
10617
10753
|
key: this.key,
|
|
10618
10754
|
serviceUrl: this.serviceUrl,
|
|
10619
10755
|
apiKey: this.apiKey,
|
|
10620
10756
|
sessionId: opts?.sessionId,
|
|
10621
|
-
initialPath:
|
|
10757
|
+
initialPath: path20,
|
|
10622
10758
|
clientHeaders: opts?.clientHeaders,
|
|
10623
10759
|
focusTarget: opts?.focusTarget
|
|
10624
10760
|
});
|
|
10625
10761
|
if (openRes.reconnected) {
|
|
10626
|
-
const navRes = await this.client.navigate(this.key,
|
|
10762
|
+
const navRes = await this.client.navigate(this.key, path20);
|
|
10627
10763
|
if (!navRes.acked) {
|
|
10628
10764
|
this.client.destroy();
|
|
10629
10765
|
throw new StudioNavigationError(navRes.reason ?? "unknown", void 0, openRes.sessionId);
|
|
@@ -10632,7 +10768,7 @@ var DaemonChannel = class _DaemonChannel {
|
|
|
10632
10768
|
sessionId: openRes.sessionId,
|
|
10633
10769
|
serviceUrl: this.serviceUrl,
|
|
10634
10770
|
source: "daemon",
|
|
10635
|
-
currentPath:
|
|
10771
|
+
currentPath: path20
|
|
10636
10772
|
});
|
|
10637
10773
|
return { sessionId: openRes.sessionId, opened: false };
|
|
10638
10774
|
}
|
|
@@ -10640,7 +10776,7 @@ var DaemonChannel = class _DaemonChannel {
|
|
|
10640
10776
|
sessionId: openRes.sessionId,
|
|
10641
10777
|
serviceUrl: this.serviceUrl,
|
|
10642
10778
|
source: "daemon",
|
|
10643
|
-
currentPath:
|
|
10779
|
+
currentPath: path20
|
|
10644
10780
|
});
|
|
10645
10781
|
return { sessionId: openRes.sessionId, opened: true };
|
|
10646
10782
|
}
|
|
@@ -10693,9 +10829,9 @@ function isDaemonEnabled() {
|
|
|
10693
10829
|
function withDirectFallback(primary, apiKey, serviceUrl) {
|
|
10694
10830
|
let active = primary;
|
|
10695
10831
|
return {
|
|
10696
|
-
async openOrNavigate(
|
|
10832
|
+
async openOrNavigate(path20, opts) {
|
|
10697
10833
|
try {
|
|
10698
|
-
return await active.openOrNavigate(
|
|
10834
|
+
return await active.openOrNavigate(path20, opts);
|
|
10699
10835
|
} catch (err) {
|
|
10700
10836
|
if (err instanceof StudioNavigationError || active !== primary) {
|
|
10701
10837
|
throw err;
|
|
@@ -10703,7 +10839,7 @@ function withDirectFallback(primary, apiKey, serviceUrl) {
|
|
|
10703
10839
|
console.error(`daemon failed, falling back to direct: ${err instanceof Error ? err.message : String(err)}`);
|
|
10704
10840
|
active.destroy();
|
|
10705
10841
|
active = new DirectChannel(apiKey, serviceUrl);
|
|
10706
|
-
return active.openOrNavigate(
|
|
10842
|
+
return active.openOrNavigate(path20, opts);
|
|
10707
10843
|
}
|
|
10708
10844
|
},
|
|
10709
10845
|
async close(sessionId, message) {
|
|
@@ -10754,12 +10890,12 @@ var semver3 = __toESM(require_semver2(), 1);
|
|
|
10754
10890
|
|
|
10755
10891
|
// ../bitfab-plugin-lib/dist/installedSdk.js
|
|
10756
10892
|
var semver2 = __toESM(require_semver2(), 1);
|
|
10757
|
-
import
|
|
10758
|
-
import
|
|
10893
|
+
import fs13 from "fs";
|
|
10894
|
+
import path12 from "path";
|
|
10759
10895
|
|
|
10760
10896
|
// ../bitfab-plugin-lib/dist/workspaces.js
|
|
10761
|
-
import
|
|
10762
|
-
import
|
|
10897
|
+
import fs12 from "fs";
|
|
10898
|
+
import path11 from "path";
|
|
10763
10899
|
|
|
10764
10900
|
// ../bitfab-plugin-lib/dist/analytics.js
|
|
10765
10901
|
async function reportHandoff(apiKey, pluginVersion, platform2, body) {
|
|
@@ -10783,16 +10919,16 @@ async function reportHandoff(apiKey, pluginVersion, platform2, body) {
|
|
|
10783
10919
|
}
|
|
10784
10920
|
|
|
10785
10921
|
// ../bitfab-plugin-lib/dist/commands/openStudioTo.js
|
|
10786
|
-
import
|
|
10922
|
+
import crypto9 from "crypto";
|
|
10787
10923
|
|
|
10788
10924
|
// ../bitfab-plugin-lib/dist/frontmostApp.js
|
|
10789
|
-
import { execFileSync as
|
|
10925
|
+
import { execFileSync as execFileSync6, spawn as spawn2 } from "child_process";
|
|
10790
10926
|
import os11 from "os";
|
|
10791
10927
|
function findAncestorApp() {
|
|
10792
10928
|
try {
|
|
10793
10929
|
let pid = process.ppid;
|
|
10794
10930
|
while (pid > 1) {
|
|
10795
|
-
const output =
|
|
10931
|
+
const output = execFileSync6("ps", ["-o", "ppid=,comm=", "-p", String(pid)], { stdio: "pipe", encoding: "utf-8" }).trim();
|
|
10796
10932
|
const match = output.match(/^\s*(\d+)\s+(.+)$/);
|
|
10797
10933
|
if (!match) {
|
|
10798
10934
|
break;
|
|
@@ -10851,19 +10987,19 @@ function getFrontmostApp() {
|
|
|
10851
10987
|
const platform2 = os11.platform();
|
|
10852
10988
|
try {
|
|
10853
10989
|
if (platform2 === "darwin") {
|
|
10854
|
-
return
|
|
10990
|
+
return execFileSync6("osascript", [
|
|
10855
10991
|
"-e",
|
|
10856
10992
|
'tell application "System Events" to get name of first process whose frontmost is true'
|
|
10857
10993
|
], { stdio: "pipe", encoding: "utf-8" }).trim();
|
|
10858
10994
|
}
|
|
10859
10995
|
if (platform2 === "linux") {
|
|
10860
|
-
return
|
|
10996
|
+
return execFileSync6("xdotool", ["getactivewindow"], {
|
|
10861
10997
|
stdio: "pipe",
|
|
10862
10998
|
encoding: "utf-8"
|
|
10863
10999
|
}).trim();
|
|
10864
11000
|
}
|
|
10865
11001
|
if (platform2 === "win32") {
|
|
10866
|
-
return
|
|
11002
|
+
return execFileSync6("powershell.exe", [
|
|
10867
11003
|
"-NoProfile",
|
|
10868
11004
|
"-Command",
|
|
10869
11005
|
`Add-Type -MemberDefinition '[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();' -Name WinFocus -Namespace Bitfab; [Bitfab.WinFocus]::GetForegroundWindow().ToInt64()`
|
|
@@ -11025,7 +11161,7 @@ function createEventSubscription(channel, sessionId, onEvent, restoreFocus) {
|
|
|
11025
11161
|
done: sub.done
|
|
11026
11162
|
};
|
|
11027
11163
|
}
|
|
11028
|
-
async function openStudioTo(
|
|
11164
|
+
async function openStudioTo(path20, opts = {}) {
|
|
11029
11165
|
const config2 = getConfig();
|
|
11030
11166
|
const serviceUrl = config2.serviceUrl;
|
|
11031
11167
|
const apiKey = !opts.forceLogin && hasCredentials() ? config2.apiKey : null;
|
|
@@ -11102,13 +11238,13 @@ async function openStudioTo(path19, opts = {}) {
|
|
|
11102
11238
|
};
|
|
11103
11239
|
};
|
|
11104
11240
|
if (!apiKey) {
|
|
11105
|
-
const destination = opts.freshWindowPath ??
|
|
11241
|
+
const destination = opts.freshWindowPath ?? path20;
|
|
11106
11242
|
const destSeparator = destination.includes("?") ? "&" : "?";
|
|
11107
11243
|
const buildSignInPath = (sid) => {
|
|
11108
11244
|
const redirectPath = `${destination}${destSeparator}session=${encodeURIComponent(sid)}&pluginLogin=true`;
|
|
11109
11245
|
return `/studio/sign-in?redirect_url=${encodeURIComponent(redirectPath)}&session=${encodeURIComponent(sid)}`;
|
|
11110
11246
|
};
|
|
11111
|
-
const requestedSessionId =
|
|
11247
|
+
const requestedSessionId = crypto9.randomUUID();
|
|
11112
11248
|
const openResult = await channel.openOrNavigate(buildSignInPath(requestedSessionId), {
|
|
11113
11249
|
clientHeaders: opts.clientHeaders,
|
|
11114
11250
|
sessionId: requestedSessionId,
|
|
@@ -11144,7 +11280,7 @@ async function openStudioTo(path19, opts = {}) {
|
|
|
11144
11280
|
channel.setApiKey(loginApiKey);
|
|
11145
11281
|
return finish(sessionId2, openResult.opened, loginApiKey);
|
|
11146
11282
|
}
|
|
11147
|
-
const { sessionId, opened } = await channel.openOrNavigate(
|
|
11283
|
+
const { sessionId, opened } = await channel.openOrNavigate(path20, {
|
|
11148
11284
|
clientHeaders: opts.clientHeaders,
|
|
11149
11285
|
focusTarget: focusTarget ?? void 0
|
|
11150
11286
|
});
|
|
@@ -12011,10 +12147,10 @@ function mergeDefs(...defs) {
|
|
|
12011
12147
|
function cloneDef(schema) {
|
|
12012
12148
|
return mergeDefs(schema._zod.def);
|
|
12013
12149
|
}
|
|
12014
|
-
function getElementAtPath(obj,
|
|
12015
|
-
if (!
|
|
12150
|
+
function getElementAtPath(obj, path20) {
|
|
12151
|
+
if (!path20)
|
|
12016
12152
|
return obj;
|
|
12017
|
-
return
|
|
12153
|
+
return path20.reduce((acc, key) => acc?.[key], obj);
|
|
12018
12154
|
}
|
|
12019
12155
|
function promiseAllObject(promisesObj) {
|
|
12020
12156
|
const keys = Object.keys(promisesObj);
|
|
@@ -12397,11 +12533,11 @@ function aborted(x, startIndex = 0) {
|
|
|
12397
12533
|
}
|
|
12398
12534
|
return false;
|
|
12399
12535
|
}
|
|
12400
|
-
function prefixIssues(
|
|
12536
|
+
function prefixIssues(path20, issues) {
|
|
12401
12537
|
return issues.map((iss) => {
|
|
12402
12538
|
var _a2;
|
|
12403
12539
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
12404
|
-
iss.path.unshift(
|
|
12540
|
+
iss.path.unshift(path20);
|
|
12405
12541
|
return iss;
|
|
12406
12542
|
});
|
|
12407
12543
|
}
|
|
@@ -12584,7 +12720,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
12584
12720
|
}
|
|
12585
12721
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
12586
12722
|
const result = { errors: [] };
|
|
12587
|
-
const processError = (error49,
|
|
12723
|
+
const processError = (error49, path20 = []) => {
|
|
12588
12724
|
var _a2, _b;
|
|
12589
12725
|
for (const issue2 of error49.issues) {
|
|
12590
12726
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -12594,7 +12730,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
12594
12730
|
} else if (issue2.code === "invalid_element") {
|
|
12595
12731
|
processError({ issues: issue2.issues }, issue2.path);
|
|
12596
12732
|
} else {
|
|
12597
|
-
const fullpath = [...
|
|
12733
|
+
const fullpath = [...path20, ...issue2.path];
|
|
12598
12734
|
if (fullpath.length === 0) {
|
|
12599
12735
|
result.errors.push(mapper(issue2));
|
|
12600
12736
|
continue;
|
|
@@ -12626,8 +12762,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
12626
12762
|
}
|
|
12627
12763
|
function toDotPath(_path) {
|
|
12628
12764
|
const segs = [];
|
|
12629
|
-
const
|
|
12630
|
-
for (const seg of
|
|
12765
|
+
const path20 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
12766
|
+
for (const seg of path20) {
|
|
12631
12767
|
if (typeof seg === "number")
|
|
12632
12768
|
segs.push(`[${seg}]`);
|
|
12633
12769
|
else if (typeof seg === "symbol")
|
|
@@ -24604,13 +24740,13 @@ function resolveRef(ref, ctx) {
|
|
|
24604
24740
|
if (!ref.startsWith("#")) {
|
|
24605
24741
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
24606
24742
|
}
|
|
24607
|
-
const
|
|
24608
|
-
if (
|
|
24743
|
+
const path20 = ref.slice(1).split("/").filter(Boolean);
|
|
24744
|
+
if (path20.length === 0) {
|
|
24609
24745
|
return ctx.rootSchema;
|
|
24610
24746
|
}
|
|
24611
24747
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
24612
|
-
if (
|
|
24613
|
-
const key =
|
|
24748
|
+
if (path20[0] === defsKey) {
|
|
24749
|
+
const key = path20[1];
|
|
24614
24750
|
if (!key || !ctx.defs[key]) {
|
|
24615
24751
|
throw new Error(`Reference not found: ${ref}`);
|
|
24616
24752
|
}
|
|
@@ -25046,6 +25182,10 @@ import { writeFileSync } from "fs";
|
|
|
25046
25182
|
import { tmpdir } from "os";
|
|
25047
25183
|
import { join } from "path";
|
|
25048
25184
|
|
|
25185
|
+
// ../bitfab-plugin-lib/dist/commands/reapDaemon.js
|
|
25186
|
+
import fs14 from "fs";
|
|
25187
|
+
import net3 from "net";
|
|
25188
|
+
|
|
25049
25189
|
// ../bitfab-plugin-lib/dist/commands/replayProgress.js
|
|
25050
25190
|
import { spawn as spawn4 } from "child_process";
|
|
25051
25191
|
import { createWriteStream, existsSync, mkdirSync, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -25054,18 +25194,18 @@ import { createInterface } from "readline";
|
|
|
25054
25194
|
var HEARTBEAT_MS = Number(process.env.BITFAB_REPLAY_HEARTBEAT_MS) || 12e3;
|
|
25055
25195
|
|
|
25056
25196
|
// ../bitfab-plugin-lib/dist/activePreviewSession.js
|
|
25057
|
-
import
|
|
25197
|
+
import fs15 from "fs";
|
|
25058
25198
|
import os12 from "os";
|
|
25059
|
-
import
|
|
25060
|
-
var FILE_PATH =
|
|
25199
|
+
import path13 from "path";
|
|
25200
|
+
var FILE_PATH = path13.join(os12.homedir(), ".config", "bitfab", "active-preview-session.json");
|
|
25061
25201
|
|
|
25062
25202
|
// ../bitfab-plugin-lib/dist/commands/status.js
|
|
25063
|
-
import
|
|
25203
|
+
import path15 from "path";
|
|
25064
25204
|
|
|
25065
25205
|
// ../bitfab-plugin-lib/dist/updates.js
|
|
25066
|
-
import
|
|
25206
|
+
import fs16 from "fs";
|
|
25067
25207
|
import os13 from "os";
|
|
25068
|
-
import
|
|
25208
|
+
import path14 from "path";
|
|
25069
25209
|
|
|
25070
25210
|
// ../bitfab-plugin-lib/dist/commands/update.js
|
|
25071
25211
|
import { execSync as execSync2 } from "child_process";
|
|
@@ -25074,15 +25214,15 @@ import { execSync as execSync2 } from "child_process";
|
|
|
25074
25214
|
var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
25075
25215
|
|
|
25076
25216
|
// ../bitfab-plugin-lib/dist/hooks/captureHook.js
|
|
25077
|
-
import
|
|
25217
|
+
import fs17 from "fs";
|
|
25078
25218
|
|
|
25079
25219
|
// ../bitfab-plugin-lib/dist/hooks/userPromptSubmit.js
|
|
25080
|
-
import
|
|
25220
|
+
import fs18 from "fs";
|
|
25081
25221
|
|
|
25082
25222
|
// ../bitfab-plugin-lib/dist/installScope.js
|
|
25083
|
-
import
|
|
25223
|
+
import fs19 from "fs";
|
|
25084
25224
|
import os14 from "os";
|
|
25085
|
-
import
|
|
25225
|
+
import path16 from "path";
|
|
25086
25226
|
|
|
25087
25227
|
// ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.js
|
|
25088
25228
|
var util;
|
|
@@ -25443,8 +25583,8 @@ function getErrorMap2() {
|
|
|
25443
25583
|
|
|
25444
25584
|
// ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.js
|
|
25445
25585
|
var makeIssue = (params) => {
|
|
25446
|
-
const { data, path:
|
|
25447
|
-
const fullPath = [...
|
|
25586
|
+
const { data, path: path20, errorMaps, issueData } = params;
|
|
25587
|
+
const fullPath = [...path20, ...issueData.path || []];
|
|
25448
25588
|
const fullIssue = {
|
|
25449
25589
|
...issueData,
|
|
25450
25590
|
path: fullPath
|
|
@@ -25559,11 +25699,11 @@ var errorUtil;
|
|
|
25559
25699
|
|
|
25560
25700
|
// ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.js
|
|
25561
25701
|
var ParseInputLazyPath = class {
|
|
25562
|
-
constructor(parent, value,
|
|
25702
|
+
constructor(parent, value, path20, key) {
|
|
25563
25703
|
this._cachedPath = [];
|
|
25564
25704
|
this.parent = parent;
|
|
25565
25705
|
this.data = value;
|
|
25566
|
-
this._path =
|
|
25706
|
+
this._path = path20;
|
|
25567
25707
|
this._key = key;
|
|
25568
25708
|
}
|
|
25569
25709
|
get path() {
|
|
@@ -30459,9 +30599,9 @@ import process3 from "process";
|
|
|
30459
30599
|
|
|
30460
30600
|
// src/claude.ts
|
|
30461
30601
|
import { spawnSync } from "child_process";
|
|
30462
|
-
import
|
|
30602
|
+
import fs20 from "fs";
|
|
30463
30603
|
import os15 from "os";
|
|
30464
|
-
import
|
|
30604
|
+
import path17 from "path";
|
|
30465
30605
|
import * as p from "@clack/prompts";
|
|
30466
30606
|
var REPO = "Project-White-Rabbit/bitfab-claude-plugin";
|
|
30467
30607
|
var MARKETPLACE = "bitfab";
|
|
@@ -30481,7 +30621,7 @@ function runClaudeInstall() {
|
|
|
30481
30621
|
}
|
|
30482
30622
|
s.start("Enabling auto-updates");
|
|
30483
30623
|
const changed = enableAutoUpdate(
|
|
30484
|
-
|
|
30624
|
+
path17.join(os15.homedir(), ".claude", "settings.json")
|
|
30485
30625
|
);
|
|
30486
30626
|
if (changed) {
|
|
30487
30627
|
s.stop("Auto-updates enabled");
|
|
@@ -30572,8 +30712,8 @@ function runClaude(args) {
|
|
|
30572
30712
|
}
|
|
30573
30713
|
function enableAutoUpdate(settingsPath) {
|
|
30574
30714
|
let settings = {};
|
|
30575
|
-
if (
|
|
30576
|
-
const raw =
|
|
30715
|
+
if (fs20.existsSync(settingsPath)) {
|
|
30716
|
+
const raw = fs20.readFileSync(settingsPath, "utf-8");
|
|
30577
30717
|
settings = raw.trim() === "" ? {} : JSON.parse(raw);
|
|
30578
30718
|
}
|
|
30579
30719
|
const marketplaces = settings.extraKnownMarketplaces ?? {};
|
|
@@ -30587,17 +30727,17 @@ function enableAutoUpdate(settingsPath) {
|
|
|
30587
30727
|
autoUpdate: true
|
|
30588
30728
|
};
|
|
30589
30729
|
settings.extraKnownMarketplaces = marketplaces;
|
|
30590
|
-
|
|
30591
|
-
|
|
30730
|
+
fs20.mkdirSync(path17.dirname(settingsPath), { recursive: true });
|
|
30731
|
+
fs20.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}
|
|
30592
30732
|
`);
|
|
30593
30733
|
return true;
|
|
30594
30734
|
}
|
|
30595
30735
|
|
|
30596
30736
|
// src/codex.ts
|
|
30597
30737
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
30598
|
-
import
|
|
30738
|
+
import fs21 from "fs";
|
|
30599
30739
|
import os16 from "os";
|
|
30600
|
-
import
|
|
30740
|
+
import path18 from "path";
|
|
30601
30741
|
import * as p2 from "@clack/prompts";
|
|
30602
30742
|
var REPO2 = "Project-White-Rabbit/bitfab-codex-plugin";
|
|
30603
30743
|
var PLUGIN_KEY2 = "bitfab@bitfab";
|
|
@@ -30625,7 +30765,7 @@ function runCodexInstall() {
|
|
|
30625
30765
|
}
|
|
30626
30766
|
s.start("Enabling bitfab plugin in config");
|
|
30627
30767
|
const changed = enableCodexPlugin(
|
|
30628
|
-
|
|
30768
|
+
path18.join(os16.homedir(), ".codex", "config.toml")
|
|
30629
30769
|
);
|
|
30630
30770
|
if (changed) {
|
|
30631
30771
|
s.stop("Plugin enabled");
|
|
@@ -30688,8 +30828,8 @@ function runCodexUpdate(args, skipPermissions) {
|
|
|
30688
30828
|
}
|
|
30689
30829
|
function enableCodexPlugin(configPath) {
|
|
30690
30830
|
let content = "";
|
|
30691
|
-
if (
|
|
30692
|
-
content =
|
|
30831
|
+
if (fs21.existsSync(configPath)) {
|
|
30832
|
+
content = fs21.readFileSync(configPath, "utf-8");
|
|
30693
30833
|
}
|
|
30694
30834
|
const header = `[plugins."${PLUGIN_KEY2}"]`;
|
|
30695
30835
|
const desiredSection = `${header}
|
|
@@ -30712,8 +30852,8 @@ enabled = true
|
|
|
30712
30852
|
|
|
30713
30853
|
${desiredSection}`;
|
|
30714
30854
|
}
|
|
30715
|
-
|
|
30716
|
-
|
|
30855
|
+
fs21.mkdirSync(path18.dirname(configPath), { recursive: true });
|
|
30856
|
+
fs21.writeFileSync(configPath, next);
|
|
30717
30857
|
return true;
|
|
30718
30858
|
}
|
|
30719
30859
|
function escapeRegex2(s) {
|
|
@@ -30824,12 +30964,12 @@ var platform = {
|
|
|
30824
30964
|
};
|
|
30825
30965
|
|
|
30826
30966
|
// src/version.ts
|
|
30827
|
-
import
|
|
30828
|
-
import
|
|
30829
|
-
import { fileURLToPath as
|
|
30967
|
+
import fs22 from "fs";
|
|
30968
|
+
import path19 from "path";
|
|
30969
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
30830
30970
|
var CLI_VERSION = JSON.parse(
|
|
30831
|
-
|
|
30832
|
-
|
|
30971
|
+
fs22.readFileSync(
|
|
30972
|
+
path19.join(path19.dirname(fileURLToPath4(import.meta.url)), "../package.json"),
|
|
30833
30973
|
"utf-8"
|
|
30834
30974
|
)
|
|
30835
30975
|
).version;
|