@entrydesk/cli 1.5.0 → 1.7.0

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import E from"crypto";import f from"fs";import pe from"path";import u from"fs";import ce from"os";import S from"path";import{HTTPError as ae,TimeoutError as le}from"ky";import re,{TimeoutError as se}from"ky";import R from"fs";function X(r){let e=o.getEffectiveProfileName(r);return o.getProfileConfigFile(e)}function a(r){let e=X(r);try{if(!R.existsSync(e))return{};let t=R.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return{}}}function d(r,e){let t=o.getEffectiveProfileName(e);o.ensureProfileDir(t);let s=o.getProfileConfigFile(t);R.writeFileSync(s,JSON.stringify(r,null,2),{mode:384});try{R.chmodSync(s,384)}catch{}}var U={getApiUrl(r){return a(r).apiUrl??null},setApiUrl(r,e){let t=a(e);t.apiUrl=r,d(t,e)},clearApiUrl(r){let e=a(r);delete e.apiUrl,d(e,r)},getHubUrl(r){return a(r).hubUrl??null},setHubUrl(r,e){let t=a(e);t.hubUrl=r,d(t,e)},getAll(r){return a(r)},setAll(r,e){d(r,e)},set(r,e,t){let s=a(t);s[r]=e,d(s,t)},get(r,e){return a(e)[r]},unset(r,e){let t=a(e);delete t[r],d(t,e)},getDefaultModel(r){return a(r).model?.default??null},setDefaultModel(r,e){let t=a(e);t.model={...t.model,default:r},d(t,e)},getDefaultConnectorIds(r){return a(r).connectors?.defaults??null},setDefaultConnectorIds(r,e){let t=a(e);t.connectors={...t.connectors,defaults:r},d(t,e)},getCapabilities(r){return a(r).capabilities??null},setCapabilities(r,e){let t=a(e);t.capabilities={...t.capabilities,...r},d(t,e)},getLocalTools(r){return a(r).localTools??null},setLocalTools(r,e){let t=a(e);t.localTools={...t.localTools,...r},d(t,e)}};var Z="https://entrydesk-api.dcard.io",Q="https://entrydesk.dcard.io",ee=3100,te=300*1e3;function T(r){return{apiUrl:U.getApiUrl(r)||process.env.ENTRYDESK_API_URL||Z,hubUrl:U.getHubUrl(r)||process.env.ENTRYDESK_HUB_URL||Q,mcp:{httpPort:ee},auth:{loginTimeout:te,ignoreSslErrors:process.env.ENTRYDESK_IGNORE_SSL_ERRORS==="true"||!1}}}function O(r){return T(r).apiUrl}function Ae(r){return T(r).hubUrl}function be(){return T().mcp}function z(){return T().auth}var W="ENTRYDESK_ALLOW_INSECURE_LOGIN",K=class r{client;baseUrl;constructor(e,t){this.baseUrl=e||O(t),z().ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED="0",process.env.DEBUG&&console.log("[DEBUG] ApiClient: SSL certificate validation disabled")),this.client=re.create({prefixUrl:this.baseUrl,timeout:3e4,retry:{limit:3,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504]},hooks:{beforeError:[n=>(n.request?.headers&&(n.request.headers.delete("authorization"),n.request.headers.delete("Authorization")),n)]}})}getBaseUrl(){return this.baseUrl}shouldAllowInsecureLogin(){return process.env[W]?.toLowerCase()==="true"}assertSecureLogin(){let e;try{e=new URL(this.baseUrl)}catch(t){let s=t instanceof Error?t:void 0;throw new c("Invalid API URL; cannot perform login.",1,s)}if(e.protocol!=="https:"&&!this.shouldAllowInsecureLogin())throw new c(`Login requires HTTPS. Set apiUrl to https:// or set ${W}=true for local development.`)}async login(e,t){return this.assertSecureLogin(),await this.client.post("v1/auth/credentials/token",{json:{email:e,password:t}}).json()}async refreshToken(e){return await this.client.post("v1/auth/token/refresh",{json:{refreshToken:e}}).json()}async revokeToken(e){await this.client.post("v1/auth/token/revoke",{json:{refreshToken:e}})}async getWorkspaces(e){try{return process.env.DEBUG&&console.log(`[DEBUG] Calling getWorkspaces API: ${this.baseUrl}/v1/workspaces`),await this.client.get("v1/workspaces",{headers:{Authorization:`Bearer ${e}`}}).json()}catch(t){throw process.env.DEBUG&&(console.error("[DEBUG] getWorkspaces error:",t),t instanceof Error&&"cause"in t&&console.error("[DEBUG] Error cause:",t.cause)),t}}async getAgents(e,t){return await this.client.get(`v1/workspaces/${t}/availableAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:100}}).json()}async createAgent(e,t,s){return await this.client.post(`v1/workspaces/${t}/agents`,{headers:{Authorization:`Bearer ${e}`},json:s}).json()}async updateAgent(e,t,s,n){await this.client.put(`v1/workspaces/${t}/agents/${s}`,{headers:{Authorization:`Bearer ${e}`},json:n})}async deleteAgent(e,t,s){await this.client.delete(`v1/workspaces/${t}/agents/${s}`,{headers:{Authorization:`Bearer ${e}`}})}async getModels(e,t){return await this.client.get(`v1/workspaces/${t}/models`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getConnectors(e,t){return await this.client.get(`v1/workspaces/${t}/availableConnectors`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:100,connectionStatus:"connected"}}).json()}async getChats(e,t,s=20){return await this.client.get(`v1/workspaces/${t}/chats`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:s}}).json()}async getMessages(e,t,s,n=50){return await this.client.get(`v1/workspaces/${t}/chats/${s}/messages`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:n}}).json()}async getAgent(e,t,s){return await this.client.get(`v1/workspaces/${t}/agents/${s}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async listAvailableSkills(e,t,s){return await this.client.get(`v1/workspaces/${t}/availableSkills`,{headers:{Authorization:`Bearer ${e}`},searchParams:{createdBy:s?.createdBy,nextKey:s?.nextKey,limit:s?.limit??20}}).json()}async uploadSkill(e,t,s){return await this.client.post(`v1/workspaces/${t}/skills`,{headers:{Authorization:`Bearer ${e}`},body:s}).json()}async deleteSkill(e,t,s){await this.client.delete(`v1/workspaces/${t}/skills/${s}`,{headers:{Authorization:`Bearer ${e}`}})}async chat(e,t,s){try{let n=await this.client.post(`v1/workspaces/${t}/chats`,{headers:{Authorization:`Bearer ${e}`},json:s,timeout:6e4,throwHttpErrors:!1});if(!n.ok){let i=await n.text();throw new Error(`Chat API failed (${n.status}): ${i}`)}return n}catch(n){throw n instanceof se?new Error("Request timed out. Please check your connection and try again.",{cause:n}):n}}async getBudget(e,t){return await this.client.get(`v1/workspaces/${t}/budget`,{headers:{Authorization:`Bearer ${e}`}}).json()}async updateBudget(e,t,s){return await this.client.put(`v1/workspaces/${t}/budget`,{headers:{Authorization:`Bearer ${e}`},json:{budget:s}}).json()}async getMonthlyUsages(e,t,s){return await this.client.get(`v1/workspaces/${t}/monthlyUsages`,{headers:{Authorization:`Bearer ${e}`},searchParams:{nextKey:s?.nextKey,limit:s?.limit??20}}).json()}async createChatShare(e,t,s,n="public"){return await this.client.post(`v1/workspaces/${t}/chats/${s}/shares`,{headers:{Authorization:`Bearer ${e}`},json:{visibility:n}}).json()}async getSharedChat(e,t){let s={};return t&&(s.Authorization=`Bearer ${t}`),await this.client.get(`v1/shares/${e}`,{headers:s}).json()}async getSharedMessages(e,t=50,s){let n={};return s&&(n.Authorization=`Bearer ${s}`),await this.client.get(`v1/shares/${e}/messages`,{headers:n,searchParams:{limit:t}}).json()}async deleteChat(e,t,s){await this.client.delete(`v1/workspaces/${t}/chats/${s}`,{headers:{Authorization:`Bearer ${e}`}})}async getModelProviders(e,t){return await this.client.get(`v1/workspaces/${t}/modelProviders`,{headers:{Authorization:`Bearer ${e}`}}).json()}async uploadFile(e,t,s,n){let i=new FormData,g=new Blob([s.buffer],{type:s.mimeType});return i.append("file",g,s.filename),i.append("modelProviderId",n),await this.client.post(`v1/workspaces/${t}/files`,{headers:{Authorization:`Bearer ${e}`},body:i,timeout:12e4}).json()}async getSchedules(e,t,s){let n={limit:s?.limit??20};return s?.nextKey&&(n.nextKey=s.nextKey),s?.search&&(n.search=s.search),await this.client.get(`v1/workspaces/${t}/schedules`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getSchedule(e,t,s){return await this.client.get(`v1/workspaces/${t}/schedules/${s}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createSchedule(e,t,s){return await this.client.post(`v1/workspaces/${t}/schedules`,{headers:{Authorization:`Bearer ${e}`},json:s}).json()}async updateSchedule(e,t,s,n){await this.client.put(`v1/workspaces/${t}/schedules/${s}`,{headers:{Authorization:`Bearer ${e}`},json:n})}async deleteSchedule(e,t,s){await this.client.delete(`v1/workspaces/${t}/schedules/${s}`,{headers:{Authorization:`Bearer ${e}`}})}static async getAuthenticatedClient(e){let t=await h.getAll(e);return t?{client:new r(void 0,e),accessToken:t.accessToken,workspaceId:t.workspaceId??null}:null}};function ne(){return process.env.ENTRYDESK_SANDBOX==="true"}function I(){if(!ne())return null;let r=process.env.ENTRYDESK_SANDBOX_ACCESS_TOKEN?.trim(),e=process.env.ENTRYDESK_SANDBOX_WORKSPACE_ID?.trim();if(!r||!e){let t=[];throw r||t.push("ENTRYDESK_SANDBOX_ACCESS_TOKEN"),e||t.push("ENTRYDESK_SANDBOX_WORKSPACE_ID"),new Error(`Sandbox mode enabled but missing credentials: ${t.join(", ")}`)}return{accessToken:r,workspaceId:e}}var p=class extends Error{code;constructor(e,t){super(t),this.code=e}};function ie(r){try{let e=r.split(".");if(e.length<2)return null;let t=e[1].replace(/-/g,"+").replace(/_/g,"/"),s=(4-t.length%4)%4,n=t.padEnd(t.length+s,"="),i=Buffer.from(n,"base64").toString("utf8");return JSON.parse(i)}catch{return null}}function oe(r,e=300){let t=ie(r);if(!t?.exp)return!1;let s=Math.floor(Date.now()/1e3);return t.exp-s<=e}async function G(r){let e=r.accessToken;if(!oe(e))return e;if(!r.refreshToken)throw await h.clear(),new p("session-expired","Session expired. Please run `entrydesk login` again.");try{let t=new K,{token:s}=await t.refreshToken(r.refreshToken);return await h.saveAccessToken(s),s}catch{throw await h.clear(),new p("session-expired","Session expired. Please run `entrydesk login` again.")}}async function De(){let r=I();if(r)return r.accessToken;let e=await h.getAll();if(!e?.accessToken)throw new p("not-logged-in","Not logged in. Run `entrydesk login` first.");return G(e)}async function _e(){let r=I();if(r)return{accessToken:r.accessToken,workspaceId:r.workspaceId};let e=await h.getAll();if(!e?.accessToken)throw new p("not-logged-in","Not logged in. Run `entrydesk login` first.");if(!e.workspaceId)throw new p("no-workspace","No workspace selected. Run `entrydesk workspaces` first.");return{accessToken:await G(e),workspaceId:e.workspaceId}}var c=class extends Error{constructor(t,s=1,n){super(t);this.exitCode=s;this.cause=n;this.name="CLIError"}};function je(r){let e=!!process.env.DEBUG;r instanceof c&&(console.error(`Error: ${r.message}`),r.cause&&(console.error(`Cause: ${r.cause.message}`),e&&r.cause.stack&&console.error(r.cause.stack)),process.exit(r.exitCode)),r instanceof p&&(console.error(r.message),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof le&&(console.error("Request timed out. Please check your connection and try again."),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof ae&&(console.error(`Request failed (${r.response.status}): ${r.response.statusText}`),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof Error&&(console.error(`Unexpected error: ${r.message}`),e&&r.stack&&console.error(r.stack),process.exit(1)),console.error("An unknown error occurred"),process.exit(1)}var m="default",ge=/^[A-Za-z0-9_-]+$/,F=null;function D(){return S.join(ce.homedir(),".entrydesk")}function H(){return S.join(D(),"profiles")}function J(){return S.join(D(),"profiles.json")}function $(r){return S.join(H(),r)}function _(r){if(!u.existsSync(r))u.mkdirSync(r,{mode:448,recursive:!0});else try{u.chmodSync(r,448)}catch{}}function de(){_(D())}function B(){_(H())}function ue(){let r=J();try{if(!u.existsSync(r))return null;let e=u.readFileSync(r,"utf-8");return JSON.parse(e)}catch{return null}}function P(r){de();let e=J();u.writeFileSync(e,JSON.stringify(r,null,2),{mode:384});try{u.chmodSync(e,384)}catch{}}function fe(r){let e=r.profiles?.length?Array.from(new Set(r.profiles)):[],t=r.currentProfile&&e.includes(r.currentProfile)?r.currentProfile:e[0]||m;return e.length===0&&e.push(m),e.includes(t)||e.unshift(t),{currentProfile:t,profiles:e}}function y(){let r=ue();if(!r){let t={currentProfile:m,profiles:[m]};return P(t),B(),x(m),t}let e=fe(r);return(e.currentProfile!==r.currentProfile||e.profiles.length!==r.profiles.length)&&P(e),B(),e}function k(r){if(!r)throw new c("Profile name is required.");if(!ge.test(r))throw new c("Invalid profile name. Use letters, numbers, dash, or underscore.")}function b(r,e){if(!r.profiles.includes(e))throw new c(`Profile not found: ${e}`)}function Y(r,e){if(r.profiles.includes(e))throw new c(`Profile already exists: ${e}`)}function x(r){B(),_($(r))}var o={DEFAULT_PROFILE:m,setOverrideProfile(r){F=r},getOverrideProfile(){return F},getProfileDir(r){return $(r)},getProfileConfigFile(r){return S.join(o.getProfileDir(r),"config.json")},getProfileCredentialsFile(r){return S.join(o.getProfileDir(r),"credentials.json")},getProfileNames(){return[...y().profiles]},getProfileCount(){return o.getProfileNames().length},getCurrentProfileName(){return y().currentProfile},getEffectiveProfileName(r){let e=y(),t=r||F||e.currentProfile;return k(t),b(e,t),t},ensureProfileExists(r){let e=y();k(r),b(e,r)},createProfile(r){k(r);let e=y();Y(e,r);let t={currentProfile:e.currentProfile,profiles:[...e.profiles,r]};P(t),x(r)},deleteProfile(r){k(r);let e=y();if(b(e,r),e.profiles.length===1)throw new c("Cannot delete the last profile.");let t=e.profiles.filter(i=>i!==r),s=e.currentProfile;s===r&&(s=t.includes(m)?m:t[0]),P({currentProfile:s,profiles:t});try{u.rmSync(o.getProfileDir(r),{recursive:!0,force:!0})}catch{}return{currentProfile:s}},renameProfile(r,e){k(r),k(e);let t=y();b(t,r),Y(t,e);let s=$(r),n=$(e);if(u.existsSync(s))try{u.renameSync(s,n)}catch(v){throw new c("Failed to rename profile directory.",1,v)}else x(e);let i=t.profiles.map(v=>v===r?e:v),g=t.currentProfile===r?e:t.currentProfile;return P({currentProfile:g,profiles:i}),{currentProfile:g}},setCurrentProfile(r){k(r);let e=y();b(e,r);let t={currentProfile:r,profiles:e.profiles};P(t),x(r)},ensureProfileDir:x};var he="ENTRYDESK_FORCE_FILE_STORAGE",C="EntryDesk CLI",ye="__entrydesk_keychain_test__",me="profile:",we=".credentials.key",q={keychain:!1,permissions:!1,corruptFile:!1,windowsFile:!1};function w(r,e){q[r]||(q[r]=!0,console.error(e))}function V(r){if(!r||typeof r!="object")return!1;let e=r;return!(!("accessToken"in e||"refreshToken"in e||"email"in e||"workspaceId"in e)||"accessToken"in e&&typeof e.accessToken!="string"||"refreshToken"in e&&typeof e.refreshToken!="string"||"email"in e&&typeof e.email!="string"||"workspaceId"in e&&typeof e.workspaceId!="string")}function ve(r){if(!r||typeof r!="object")return!1;let e=r;return typeof e.getPassword=="function"&&typeof e.setPassword=="function"&&typeof e.deletePassword=="function"}function M(r){return o.getProfileCredentialsFile(r)}var L=class{getKeyFilePath(e){return pe.join(o.getProfileDir(e),we)}loadEncryptionKey(e){let t=this.getKeyFilePath(e);try{if(!f.existsSync(t))return null;let s=f.readFileSync(t);return s.length!==32?null:(this.ensureSecureFilePermissions(t),s)}catch{return null}}createEncryptionKey(e){o.ensureProfileDir(e);let t=this.getKeyFilePath(e),s=E.randomBytes(32);return f.writeFileSync(t,s,{mode:384}),this.ensureSecureFilePermissions(t),s}getOrCreateEncryptionKey(e){let t=this.loadEncryptionKey(e);return t||this.createEncryptionKey(e)}encrypt(e,t){let s=E.randomBytes(16),n=E.createCipheriv("aes-256-gcm",t,s),i=n.update(e,"utf8","hex");i+=n.final("hex");let g=n.getAuthTag();return`${s.toString("hex")}:${g.toString("hex")}:${i}`}decrypt(e,t){let s=e.split(":");if(s.length!==3)throw new Error("Invalid encrypted data format");let n=Buffer.from(s[0],"hex"),i=Buffer.from(s[1],"hex"),g=s[2],A=E.createDecipheriv("aes-256-gcm",t,n,{authTagLength:16});A.setAuthTag(i);let v=A.update(g,"hex","utf8");return v+=A.final("utf8"),v}tryDecrypt(e,t){try{return this.decrypt(e,t)}catch{return null}}tryParseCredentials(e){try{let t=JSON.parse(e);return V(t)?t:null}catch{return null}}ensureSecureFilePermissions(e){if(process.platform!=="win32"){try{f.chmodSync(e,384)}catch{w("permissions","Warning: Failed to set secure permissions on credentials file.");return}try{(f.statSync(e).mode&511)!==384&&w("permissions","Warning: Credentials file permissions are too permissive.")}catch{w("permissions","Warning: Failed to verify credentials file permissions.")}}}async getCredentials(e){let t=M(e);try{if(!f.existsSync(t))return null;let s=f.readFileSync(t,"utf-8").trim();if(!s)return null;let n=this.loadEncryptionKey(e),i=n?this.tryDecrypt(s,n):null;if(i){let g=this.tryParseCredentials(i);if(g)return g}return w("corruptFile","Warning: Credentials file is unreadable. Please run `entrydesk login` again."),null}catch{return null}}async setCredentials(e,t){o.ensureProfileDir(e);let s=M(e),n=this.getOrCreateEncryptionKey(e),i=this.encrypt(JSON.stringify(t),n);f.writeFileSync(s,i,{mode:384}),this.ensureSecureFilePermissions(s)}async deleteCredentials(e){let t=M(e);try{f.existsSync(t)&&f.unlinkSync(t)}catch{}}},N=class{keytarModule=null;keytarLoadAttempted=!1;keychainAvailable=null;async getKeytar(){if(this.keytarLoadAttempted)return this.keytarModule;this.keytarLoadAttempted=!0;try{let t=await import("keytar"),s=t&&typeof t=="object"&&"default"in t?t.default:t;this.keytarModule=ve(s)?s:null}catch{this.keytarModule=null}return this.keytarModule}getAccount(e){return`${me}${e}`}async checkKeychainAvailability(){if(this.keychainAvailable!==null)return this.keychainAvailable;try{let e=await this.getKeytar();if(!e)return this.keychainAvailable=!1,!1;let t=`${ye}${E.randomBytes(8).toString("hex")}`,s="test";await e.setPassword(C,t,s);let n=await e.getPassword(C,t),i=await e.deletePassword(C,t);return this.keychainAvailable=!!(i&&n===s),this.keychainAvailable}catch{return this.keychainAvailable=!1,!1}}async isAvailable(){return this.checkKeychainAvailability()}async getCredentials(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");let s=await t.getPassword(C,this.getAccount(e));if(!s)return null;let n=this.tryParseKeychainPayload(s);return n||w("corruptFile",`Warning: Keychain entry for profile "${e}" is unreadable.`),n}async setCredentials(e,t){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let s=await this.getKeytar();if(!s)throw new Error("Keytar module not available");let n=JSON.stringify(t);await s.setPassword(C,this.getAccount(e),n)}async deleteCredentials(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");await t.deletePassword(C,this.getAccount(e))}tryParseKeychainPayload(e){try{let t=JSON.parse(e);return V(t)?t:null}catch{return null}}},j=class{keychainStorage=null;fileStorage=new L;keychainAvailable=null;initPromise=null;shouldForceFileStorage(){return process.env[he]?.toLowerCase()==="true"}async initializeStorage(){if(this.shouldForceFileStorage()){this.keychainAvailable=!1,this.keychainStorage=null;return}try{let e=new N,t=await e.isAvailable();this.keychainAvailable=t,this.keychainStorage=t?e:null}catch{this.keychainAvailable=!1,this.keychainStorage=null}!this.keychainAvailable&&!this.shouldForceFileStorage()&&(w("keychain","Keychain unavailable. Falling back to file-based credentials."),process.platform==="win32"&&w("windowsFile","Warning: File-based credentials on Windows may be readable by other users."))}async ensureInitialized(){if(this.shouldForceFileStorage()){this.keychainAvailable=!1,this.keychainStorage=null;return}this.keychainAvailable===null&&(this.initPromise||(this.initPromise=this.initializeStorage()),await this.initPromise)}disableKeychain(){this.shouldForceFileStorage()||w("keychain","Keychain error encountered. Falling back to file-based credentials."),this.keychainAvailable=!1,this.keychainStorage=null}async getKeychainStorage(){return await this.ensureInitialized(),this.shouldForceFileStorage()?null:this.keychainAvailable?this.keychainStorage:null}async getCredentials(e){let t=await this.getKeychainStorage();if(!t)return this.fileStorage.getCredentials(e);try{let n=await t.getCredentials(e);if(n)return n}catch{return this.disableKeychain(),this.fileStorage.getCredentials(e)}let s=await this.fileStorage.getCredentials(e);if(s)try{await t.setCredentials(e,s),await this.fileStorage.deleteCredentials(e)}catch{}return s}async setCredentials(e,t){let s=await this.getKeychainStorage();if(!s){await this.fileStorage.setCredentials(e,t);return}try{await s.setCredentials(e,t),await this.fileStorage.deleteCredentials(e)}catch{this.disableKeychain(),await this.fileStorage.setCredentials(e,t)}}async deleteCredentials(e){let t=await this.getKeychainStorage();if(t)try{await t.deleteCredentials(e)}catch{this.disableKeychain()}await this.fileStorage.deleteCredentials(e)}},l=new j,h={async saveAccessToken(r,e){let t=o.getEffectiveProfileName(e),s=await l.getCredentials(t)||{};s.accessToken=r,await l.setCredentials(t,s)},async getAccessToken(r){let e=o.getEffectiveProfileName(r);return(await l.getCredentials(e))?.accessToken??null},async saveRefreshToken(r,e){let t=o.getEffectiveProfileName(e),s=await l.getCredentials(t)||{};s.refreshToken=r,await l.setCredentials(t,s)},async getRefreshToken(r){let e=o.getEffectiveProfileName(r);return(await l.getCredentials(e))?.refreshToken??null},async saveEmail(r,e){let t=o.getEffectiveProfileName(e),s=await l.getCredentials(t)||{};s.email=r,await l.setCredentials(t,s)},async getEmail(r){let e=o.getEffectiveProfileName(r);return(await l.getCredentials(e))?.email??null},async saveWorkspaceId(r,e){let t=o.getEffectiveProfileName(e),s=await l.getCredentials(t)||{};s.workspaceId=r,await l.setCredentials(t,s)},async getWorkspaceId(r){let e=o.getEffectiveProfileName(r);return(await l.getCredentials(e))?.workspaceId??null},async saveAll(r,e){let t=o.getEffectiveProfileName(e);await l.setCredentials(t,r)},async getAll(r){let e=o.getEffectiveProfileName(r);return l.getCredentials(e)},async clear(r){let e=o.getEffectiveProfileName(r);await l.deleteCredentials(e)},async isLoggedIn(r){let e=o.getEffectiveProfileName(r);return(await l.getCredentials(e))?.accessToken!=null}};export{h as a,p as b,De as c,_e as d,c as e,je as f,o as g,U as h,T as i,O as j,Ae as k,be as l,z as m,K as n};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{i as a,j as b,k as c,l as d,m as e}from"./chunk-J6ER4MMT.js";export{b as getApiUrl,e as getAuthConfig,a as getConfig,c as getHubUrl,d as getMcpConfig};
2
+ import{i as a,j as b,k as c,l as d,m as e}from"./chunk-G36L33PZ.js";export{b as getApiUrl,e as getAuthConfig,a as getConfig,c as getHubUrl,d as getMcpConfig};