bitfab-cli 0.2.168 → 0.2.170
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 +42 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9334,6 +9334,28 @@ function getConfig() {
|
|
|
9334
9334
|
sessionLogConsent: getSessionLogConsentValue()
|
|
9335
9335
|
};
|
|
9336
9336
|
}
|
|
9337
|
+
function isProductionServiceUrl(serviceUrl) {
|
|
9338
|
+
try {
|
|
9339
|
+
const url2 = new URL(serviceUrl);
|
|
9340
|
+
return url2.protocol === "https:" && url2.hostname === "bitfab.ai" && (url2.pathname === "" || url2.pathname === "/");
|
|
9341
|
+
} catch {
|
|
9342
|
+
return false;
|
|
9343
|
+
}
|
|
9344
|
+
}
|
|
9345
|
+
function formatNonProductionEndpointSuffix(serviceUrl) {
|
|
9346
|
+
if (isProductionServiceUrl(serviceUrl)) {
|
|
9347
|
+
return "";
|
|
9348
|
+
}
|
|
9349
|
+
try {
|
|
9350
|
+
const url2 = new URL(serviceUrl);
|
|
9351
|
+
if (!url2.host) {
|
|
9352
|
+
return ` @ ${serviceUrl}`;
|
|
9353
|
+
}
|
|
9354
|
+
return ` @ ${url2.host}`;
|
|
9355
|
+
} catch {
|
|
9356
|
+
return ` @ ${serviceUrl}`;
|
|
9357
|
+
}
|
|
9358
|
+
}
|
|
9337
9359
|
function saveCredentials(apiKey) {
|
|
9338
9360
|
const projectFile = findProjectFiles()?.credentialsFile;
|
|
9339
9361
|
if (projectFile) {
|
|
@@ -11409,8 +11431,9 @@ async function runLogin(platform2, pluginVersion, options) {
|
|
|
11409
11431
|
const who = await verifyToken(config4.serviceUrl, config4.apiKey);
|
|
11410
11432
|
if (who) {
|
|
11411
11433
|
const identity = who.user.email ?? "your account";
|
|
11434
|
+
const endpoint = formatNonProductionEndpointSuffix(config4.serviceUrl);
|
|
11412
11435
|
console.log(`
|
|
11413
|
-
Already logged in as ${identity}. Run the login command with --force to re-authenticate.`);
|
|
11436
|
+
Already logged in as ${identity}${endpoint}. Run the login command with --force to re-authenticate.`);
|
|
11414
11437
|
if (exitOnComplete) {
|
|
11415
11438
|
process.exit(0);
|
|
11416
11439
|
}
|
|
@@ -11442,7 +11465,8 @@ Already logged in as ${identity}. Run the login command with --force to re-authe
|
|
|
11442
11465
|
ticketAvailable: false
|
|
11443
11466
|
});
|
|
11444
11467
|
const who = await verifyToken(config4.serviceUrl, apiKey);
|
|
11445
|
-
const
|
|
11468
|
+
const endpoint = formatNonProductionEndpointSuffix(config4.serviceUrl);
|
|
11469
|
+
const greeting = who?.user.email ? `Logged in as ${who.user.email}${endpoint}.` : "Authentication successful.";
|
|
11446
11470
|
console.log(`
|
|
11447
11471
|
${greeting}`);
|
|
11448
11472
|
console.log("Bitfab MCP tools are now active. (via studio)");
|
|
@@ -30782,14 +30806,25 @@ import * as p from "@clack/prompts";
|
|
|
30782
30806
|
function pluginOutputIsUpToDate(output) {
|
|
30783
30807
|
return output.includes("already") || output.includes("up to date");
|
|
30784
30808
|
}
|
|
30809
|
+
function extractPluginVersion(output) {
|
|
30810
|
+
const match = /(?:^|[^\d])v?(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)(?:$|[^\d])/.exec(
|
|
30811
|
+
output
|
|
30812
|
+
);
|
|
30813
|
+
return match?.[1] ?? null;
|
|
30814
|
+
}
|
|
30815
|
+
function formatPluginRefreshResult(output) {
|
|
30816
|
+
const version2 = extractPluginVersion(output);
|
|
30817
|
+
if (pluginOutputIsUpToDate(output)) {
|
|
30818
|
+
return version2 ? `Plugin already up to date (v${version2})` : "Plugin already up to date";
|
|
30819
|
+
}
|
|
30820
|
+
return version2 ? `Plugin updated to v${version2}` : "Plugin updated to latest";
|
|
30821
|
+
}
|
|
30785
30822
|
function ensureLatestPlugin(pull) {
|
|
30786
30823
|
const s = p.spinner();
|
|
30787
30824
|
s.start("Checking for the latest bitfab plugin");
|
|
30788
30825
|
try {
|
|
30789
30826
|
const out = pull();
|
|
30790
|
-
s.stop(
|
|
30791
|
-
pluginOutputIsUpToDate(out) ? "Plugin already up to date" : "Plugin updated to latest"
|
|
30792
|
-
);
|
|
30827
|
+
s.stop(formatPluginRefreshResult(out));
|
|
30793
30828
|
} catch (err) {
|
|
30794
30829
|
s.stop("Could not check for plugin updates");
|
|
30795
30830
|
p.log.warn(
|
|
@@ -30829,9 +30864,7 @@ function cliUpdate(cfg, args, skipPermissions) {
|
|
|
30829
30864
|
s.stop("Plugin update failed");
|
|
30830
30865
|
throw err;
|
|
30831
30866
|
}
|
|
30832
|
-
s.stop(
|
|
30833
|
-
pluginOutputIsUpToDate(out) ? "Plugin already up to date" : "Plugin updated"
|
|
30834
|
-
);
|
|
30867
|
+
s.stop(formatPluginRefreshResult(out));
|
|
30835
30868
|
}
|
|
30836
30869
|
if (mode === "sdk" || mode === "all") {
|
|
30837
30870
|
p2.log.info(`Launching ${cfg.updateCommand} sdk...
|
|
@@ -31371,7 +31404,7 @@ async function pickEditor(detected) {
|
|
|
31371
31404
|
return detected[0];
|
|
31372
31405
|
}
|
|
31373
31406
|
const choice = await p6.select({
|
|
31374
|
-
message: "Which
|
|
31407
|
+
message: "Which agent should we use?",
|
|
31375
31408
|
options: detected.map((e) => ({
|
|
31376
31409
|
value: e,
|
|
31377
31410
|
label: ADAPTERS[e].label
|