@botpress/adk-cli
Version:
Command-line interface for the Botpress Agent Development Kit (ADK)
98 lines (96 loc) • 2.79 kB
JavaScript
// @bun
import {
ensureJsonOnlyFormat
} from "./chunk-7sfagm12.js";
import {
telemetry_default
} from "./chunk-kwmsaz7n.js";
import {
createCliLogger
} from "./chunk-gzwt1qdr.js";
import"./chunk-nxy2ya5r.js";
import"./chunk-wzj4dc7n.js";
import {
auth
} from "./chunk-p0hjqn4r.js";
import"./chunk-np5wcwfv.js";
import"./chunk-dq2xpa24.js";
import"./chunk-6w0knnta.js";
import"./chunk-40x04ckt.js";
import"./chunk-t76d8fxx.js";
import"./chunk-nh2akp42.js";
import"./chunk-0fdvzjbh.js";
import"./chunk-2a5b6azq.js";
import"./chunk-vay209b5.js";
import"./chunk-3xrpxgq4.js";
import"./chunk-rfm3jr1m.js";
import"./chunk-w346ejn9.js";
import"./chunk-knvm2anf.js";
import"./chunk-65h5trb5.js";
import"./chunk-s2akeqpw.js";
import"./chunk-6771vrjp.js";
import"./chunk-g8mm42v1.js";
import"./chunk-50hzjdck.js";
import"./chunk-nn2jb0x0.js";
import"./chunk-v8xvth6j.js";
import"./chunk-kkk13rcb.js";
import"./chunk-ytpp1kam.js";
import"./chunk-na956zz3.js";
import"./chunk-f4bw8q7c.js";
import"./chunk-0v8vgrns.js";
import"./chunk-54qt5g7m.js";
import"./chunk-dhs2bg35.js";
// src/commands/adk-logout.ts
async function adkLogout(options = {}) {
ensureJsonOnlyFormat(options.format);
const logger = createCliLogger({ format: options.format });
let currentProfile;
let targetProfile = options.profile;
if (targetProfile) {
currentProfile = await auth.getCurrentProfile();
} else {
const profiles = await auth.listProfiles();
if (profiles.length === 0) {
logger.info("Already logged out").result({
success: true,
loggedOut: false,
alreadyLoggedOut: true,
message: "Already logged out"
});
return;
}
currentProfile = await auth.getCurrentProfile();
targetProfile = currentProfile;
}
const isCurrentProfile = targetProfile === currentProfile;
if (options.profile) {
await auth.logout(options.profile);
} else {
await auth.logout();
}
let newCurrentProfile;
if (isCurrentProfile) {
telemetry_default.reset();
const remainingProfiles = await auth.listProfiles();
if (remainingProfiles.length > 0) {
newCurrentProfile = await auth.getCurrentProfile();
logger.info(`Logged out of profile: ${targetProfile}`, "green");
logger.info(`Current profile is now: ${newCurrentProfile}`);
} else {
logger.info(`Logged out of profile: ${targetProfile}`, "green");
logger.warn("No profiles remain. Run 'adk login' to authenticate again.");
}
} else {
logger.info(`Logged out of profile: ${targetProfile}`, "green");
}
logger.debug("").result({
success: true,
loggedOut: true,
alreadyLoggedOut: false,
profile: targetProfile,
...newCurrentProfile ? { currentProfile: newCurrentProfile } : {}
});
}
export {
adkLogout
};