@entrydesk/cli 1.26.1 → 1.27.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.
- package/dist/{agents-XQH67YBG.js → agents-ZOLKUK3V.js} +1 -1
- package/dist/{billing-PZG7BF2R.js → billing-EXNUZ27V.js} +1 -1
- package/dist/{budget-LHLL6XAX.js → budget-GP7TPIHT.js} +1 -1
- package/dist/{chunk-3LVMVSXH.js → chunk-B5EWO4CJ.js} +7 -7
- package/dist/chunk-EH2LVJZD.js +4 -0
- package/dist/{config-I6QH74VH.js → config-OKYEHGIF.js} +1 -1
- package/dist/{config-help-54ZPTSGK.js → config-help-IKI7XAH3.js} +1 -1
- package/dist/{connectors-R6BMPLPB.js → connectors-RWQYKGOG.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/login-DQELHKE3.js +2 -0
- package/dist/{logout-N3DWUIVM.js → logout-V2NLWFNM.js} +1 -1
- package/dist/{marketplace-X7HJBCLX.js → marketplace-XQPPKUMQ.js} +1 -1
- package/dist/{mcp-L2E3UYM3.js → mcp-HPPSJT7W.js} +1 -1
- package/dist/{meeting-ZPU6GRAQ.js → meeting-7SGZAPPL.js} +1 -1
- package/dist/models-6W5QSXEO.js +3 -0
- package/dist/{notifications-A2E4NNUF.js → notifications-OLXBWR6Q.js} +1 -1
- package/dist/{profile-7EC34EQQ.js → profile-QQXHY3ZS.js} +1 -1
- package/dist/{recordings-WTXTIM47.js → recordings-OI24HIML.js} +1 -1
- package/dist/{schedules-6HOZPI2B.js → schedules-VT37LVQS.js} +1 -1
- package/dist/{skills-IMSSEM4W.js → skills-JYDSRE6Y.js} +1 -1
- package/dist/status-HY3ZS7SA.js +2 -0
- package/dist/{task-REAQDDHD.js → task-A4RVTJS5.js} +2 -2
- package/dist/{tasks-F7APMWQ2.js → tasks-VSKYJMRE.js} +1 -1
- package/dist/{tool-HK6VUF2X.js → tool-MJBJPNVQ.js} +1 -1
- package/dist/{update-DKQXM2AG.js → update-YHLJYPBF.js} +1 -1
- package/dist/{usage-PHN54NZW.js → usage-QMI573O7.js} +1 -1
- package/dist/{version-SNWB2HVT.js → version-4CHSBNSW.js} +1 -1
- package/dist/{workflow-ASYU6KRW.js → workflow-QILMEKPR.js} +1 -1
- package/dist/{workspaces-6L42VXYO.js → workspaces-BTA5XP43.js} +1 -1
- package/package.json +5 -5
- package/dist/chunk-U3S6IYK7.js +0 -4
- package/dist/config-2UKI6TWQ.js +0 -2
- package/dist/login-5PYRMAXU.js +0 -2
- package/dist/models-ZQQ6IAMC.js +0 -3
- package/dist/status-APAONGPM.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entrydesk/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "EntryDesk CLI - Interact with EntryDesk from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"ink-spinner": "^5.0.0",
|
|
20
20
|
"jose": "^6.2.3",
|
|
21
21
|
"ky": "^2.0.2",
|
|
22
|
-
"react": "^19.2.
|
|
22
|
+
"react": "^19.2.8",
|
|
23
23
|
"uuid": "^14.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@testing-library/react": "^16.3.2",
|
|
28
28
|
"@types/archiver": "^7.0.0",
|
|
29
29
|
"@types/node": "^24.12.4",
|
|
30
|
-
"@types/react": "^19.2.
|
|
30
|
+
"@types/react": "^19.2.17",
|
|
31
31
|
"@vitest/coverage-v8": "^4.1.6",
|
|
32
32
|
"happy-dom": "^20.8.9",
|
|
33
33
|
"oxlint": "^1.74.0",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"typescript": "^7.0.2",
|
|
37
37
|
"vitest": "^4.1.6",
|
|
38
38
|
"@entrydesk/shared": "^0.0.0",
|
|
39
|
-
"@gntc/
|
|
40
|
-
"@gntc/
|
|
39
|
+
"@gntc/utils": "^0.0.0",
|
|
40
|
+
"@gntc/ci": "^0.0.0"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
43
|
"keytar": "^7.9.0"
|
package/dist/chunk-U3S6IYK7.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import I from"fs";import m from"fs";import Oe from"os";import b from"path";import{HTTPError as ze,TimeoutError as Fe}from"ky";import{HTTPError as Ue}from"ky";import Ae,{TimeoutError as Se,isHTTPError as ne}from"ky";import T from"crypto";import p from"fs";import ye from"path";var me="ENTRYDESK_FORCE_FILE_STORAGE",S="EntryDesk CLI",we="__entrydesk_keychain_test__",ke="profile:",ve=".credentials.key",re={keychain:!1,permissions:!1,corruptFile:!1,windowsFile:!1};function v(s,e){re[s]||(re[s]=!0,console.error(e))}function Re(){return process.env.ENTRYDESK_DEBUG?.toLowerCase()==="true"}function se(s){if(!s||typeof s!="object")return!1;let e=s;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 Pe(s){if(!s||typeof s!="object")return!1;let e=s;return typeof e.getPassword=="function"&&typeof e.setPassword=="function"&&typeof e.deletePassword=="function"}function z(s){return a.getProfileCredentialsFile(s)}var F=class{getKeyFilePath(e){return ye.join(a.getProfileDir(e),ve)}loadEncryptionKey(e){let t=this.getKeyFilePath(e);try{if(!p.existsSync(t))return null;let r=p.readFileSync(t);return r.length!==32?null:(this.ensureSecureFilePermissions(t),r)}catch{return null}}createEncryptionKey(e){a.ensureProfileDir(e);let t=this.getKeyFilePath(e),r=T.randomBytes(32);return p.writeFileSync(t,r,{mode:384}),this.ensureSecureFilePermissions(t),r}getOrCreateEncryptionKey(e){let t=this.loadEncryptionKey(e);return t||this.createEncryptionKey(e)}encrypt(e,t){let r=T.randomBytes(16),n=T.createCipheriv("aes-256-gcm",t,r),i=n.update(e,"utf8","hex");i+=n.final("hex");let o=n.getAuthTag();return`${r.toString("hex")}:${o.toString("hex")}:${i}`}decrypt(e,t){let r=e.split(":");if(r.length!==3)throw new Error("Invalid encrypted data format");let n=Buffer.from(r[0],"hex"),i=Buffer.from(r[1],"hex"),o=r[2],d=T.createDecipheriv("aes-256-gcm",t,n,{authTagLength:16});d.setAuthTag(i);let u=d.update(o,"hex","utf8");return u+=d.final("utf8"),u}tryDecrypt(e,t){try{return this.decrypt(e,t)}catch{return null}}tryParseCredentials(e){try{let t=JSON.parse(e);return se(t)?t:null}catch{return null}}ensureSecureFilePermissions(e){if(process.platform!=="win32"){try{p.chmodSync(e,384)}catch{v("permissions","Warning: Failed to set secure permissions on credentials file.");return}try{(p.statSync(e).mode&511)!==384&&v("permissions","Warning: Credentials file permissions are too permissive.")}catch{v("permissions","Warning: Failed to verify credentials file permissions.")}}}async getCredentials(e){let t=z(e);try{if(!p.existsSync(t))return null;let r=p.readFileSync(t,"utf-8").trim();if(!r)return null;let n=this.loadEncryptionKey(e),i=n?this.tryDecrypt(r,n):null;if(i){let o=this.tryParseCredentials(i);if(o)return o}return v("corruptFile","Warning: Credentials file is unreadable. Please run `entrydesk login` again."),null}catch{return null}}async setCredentials(e,t){a.ensureProfileDir(e);let r=z(e),n=this.getOrCreateEncryptionKey(e),i=this.encrypt(JSON.stringify(t),n);p.writeFileSync(r,i,{mode:384}),this.ensureSecureFilePermissions(r)}async deleteCredentials(e){let t=z(e);try{p.existsSync(t)&&p.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"),r=t&&typeof t=="object"&&"default"in t?t.default:t;this.keytarModule=Pe(r)?r:null}catch{this.keytarModule=null}return this.keytarModule}getAccount(e){return`${ke}${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=`${we}${T.randomBytes(8).toString("hex")}`,r="test";await e.setPassword(S,t,r);let n=await e.getPassword(S,t),i=await e.deletePassword(S,t);return this.keychainAvailable=!!(i&&n===r),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 r=await t.getPassword(S,this.getAccount(e));if(!r)return null;let n=this.tryParseKeychainPayload(r);return n||v("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 r=await this.getKeytar();if(!r)throw new Error("Keytar module not available");let n=JSON.stringify(t);await r.setPassword(S,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(S,this.getAccount(e))}tryParseKeychainPayload(e){try{let t=JSON.parse(e);return se(t)?t:null}catch{return null}}},O=class{keychainStorage=null;fileStorage=new F;keychainAvailable=null;initPromise=null;shouldForceFileStorage(){return process.env[me]?.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()&&(Re()&&v("keychain","Keychain unavailable. Falling back to file-based credentials."),process.platform==="win32"&&v("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.initializeStorage(),await this.initPromise)}disableKeychain(){this.shouldForceFileStorage()||v("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 r=await this.fileStorage.getCredentials(e);if(r)try{await t.setCredentials(e,r),await this.fileStorage.deleteCredentials(e)}catch{}return r}async setCredentials(e,t){let r=await this.getKeychainStorage();if(!r){await this.fileStorage.setCredentials(e,t);return}try{await r.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 O,h={async saveAccessToken(s,e){let t=a.getEffectiveProfileName(e),r=await l.getCredentials(t)??{};r.accessToken=s,await l.setCredentials(t,r)},async getAccessToken(s){let e=a.getEffectiveProfileName(s);return(await l.getCredentials(e))?.accessToken??null},async saveRefreshToken(s,e){let t=a.getEffectiveProfileName(e),r=await l.getCredentials(t)??{};r.refreshToken=s,await l.setCredentials(t,r)},async getRefreshToken(s){let e=a.getEffectiveProfileName(s);return(await l.getCredentials(e))?.refreshToken??null},async saveEmail(s,e){let t=a.getEffectiveProfileName(e),r=await l.getCredentials(t)??{};r.email=s,await l.setCredentials(t,r)},async getEmail(s){let e=a.getEffectiveProfileName(s);return(await l.getCredentials(e))?.email??null},async saveWorkspaceId(s,e){let t=a.getEffectiveProfileName(e),r=await l.getCredentials(t)??{};r.workspaceId=s,await l.setCredentials(t,r)},async getWorkspaceId(s){let e=a.getEffectiveProfileName(s);return(await l.getCredentials(e))?.workspaceId??null},async saveAll(s,e){let t=a.getEffectiveProfileName(e);await l.setCredentials(t,s)},async getAll(s){let e=a.getEffectiveProfileName(s);return l.getCredentials(e)},async clear(s){let e=a.getEffectiveProfileName(s);await l.deleteCredentials(e)},async isLoggedIn(s){let e=a.getEffectiveProfileName(s);return(await l.getCredentials(e))?.accessToken!=null}};var M=class s{client;baseUrl;runtimeConfigCache;constructor(e,t){this.baseUrl=e||$(t),K().ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED="0",process.env.DEBUG&&console.log("[DEBUG] ApiClient: SSL certificate validation disabled")),this.client=Ae.create({baseUrl:this.baseUrl.replace(/\/?$/,"/"),timeout:3e4,retry:{limit:3,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504]},hooks:{beforeError:[({error:n})=>(ne(n)&&(n.request.headers.delete("authorization"),n.request.headers.delete("Authorization")),n)]}})}getBaseUrl(){return this.baseUrl}async refreshOAuthToken(e){return this.client.post("v1/oauth/token",{json:{grant_type:"refresh_token",refresh_token:e.refreshToken,client_id:e.clientId}}).json()}async revokeOAuthToken(e){await this.client.post("v1/oauth/revoke",{json:{token:e.token,token_type_hint:"refresh_token",client_id:e.clientId}})}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,r){let n={limit:r?.limit??100};return r?.nextKey&&(n.nextKey=r.nextKey),r?.search&&(n.search=r.search),await this.client.get(`v1/workspaces/${t}/availableAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async createAgent(e,t,r){return await this.client.post(`v1/workspaces/${t}/agents`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async updateAgent(e,t,r,n){await this.client.put(`v1/workspaces/${t}/agents/${r}`,{headers:{Authorization:`Bearer ${e}`},json:n})}async deleteAgent(e,t,r){await this.client.delete(`v1/workspaces/${t}/agents/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async getMyAgents(e,t,r){let n={limit:r?.limit??100};return r?.nextKey&&(n.nextKey=r.nextKey),r?.search&&(n.search=r.search),await this.client.get(`v1/workspaces/${t}/myAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async publishAgent(e,t,r){await this.client.post(`v1/workspaces/${t}/agents/${r}/publish`,{headers:{Authorization:`Bearer ${e}`}})}async getAgentGrants(e,t,r){return await this.client.get(`v1/workspaces/${t}/agents/${r}/grants`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertAgentGrant(e,t,r,n,i){return await this.client.put(`v1/workspaces/${t}/agents/${r}/grants/${n}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeAgentGrant(e,t,r,n){await this.client.delete(`v1/workspaces/${t}/agents/${r}/grants/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async getMeetings(e,t,r){let n={limit:r?.limit??20};return r?.nextKey&&(n.nextKey=r.nextKey),r?.search&&(n.search=r.search),r?.filter&&(n.filter=r.filter),r?.sortBy&&(n.sortBy=r.sortBy),await this.client.get(`v1/workspaces/${t}/meetings`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getMeeting(e,t,r){return await this.client.get(`v1/workspaces/${t}/meetings/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createMeeting(e,t,r){return await this.client.post(`v1/workspaces/${t}/meetings`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async updateMeeting(e,t,r,n){return await this.client.patch(`v1/workspaces/${t}/meetings/${r}`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async deleteMeeting(e,t,r){await this.client.delete(`v1/workspaces/${t}/meetings/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async getMeetingPreviousBrief(e,t,r){return await this.client.get(`v1/workspaces/${t}/meetings/${r}/previous`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getRecording(e,t,r){return await this.client.get(`v1/workspaces/${t}/recordings/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getMeetingShares(e,t,r){return await this.client.get(`v1/workspaces/${t}/meetings/${r}/shares`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertMeetingUserGrant(e,t,r,n,i){return await this.client.put(`v1/workspaces/${t}/meetings/${r}/shares/users/${n}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeMeetingUserGrant(e,t,r,n){await this.client.delete(`v1/workspaces/${t}/meetings/${r}/shares/users/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async upsertMeetingTeamGrant(e,t,r,n,i){return await this.client.put(`v1/workspaces/${t}/meetings/${r}/shares/teams/${n}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeMeetingTeamGrant(e,t,r,n){await this.client.delete(`v1/workspaces/${t}/meetings/${r}/shares/teams/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async getWorkflows(e,t,r){let n={limit:r?.limit??20};return r?.nextKey&&(n.nextKey=r.nextKey),r?.search&&(n.search=r.search),await this.client.get(`v1/workspaces/${t}/workflows`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getWorkflow(e,t,r){return await this.client.get(`v1/workspaces/${t}/workflows/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createWorkflow(e,t,r){return await this.client.post(`v1/workspaces/${t}/workflows`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async updateWorkflow(e,t,r,n){await this.client.put(`v1/workspaces/${t}/workflows/${r}`,{headers:{Authorization:`Bearer ${e}`},json:n})}async triggerWorkflowRun(e,t,r,n){return await this.client.post(`v1/workspaces/${t}/workflows/${r}/runs`,{headers:{Authorization:`Bearer ${e}`},json:n===void 0?{}:{args:n}}).json()}async getWorkflowRuns(e,t,r,n){let i={limit:n?.limit??20};return n?.nextKey&&(i.nextKey=n.nextKey),await this.client.get(`v1/workspaces/${t}/workflows/${r}/runs`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json()}async getWorkflowRun(e,t,r,n){return await this.client.get(`v1/workspaces/${t}/workflows/${r}/runs/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getWorkflowGrants(e,t,r){return await this.client.get(`v1/workspaces/${t}/workflows/${r}/grants`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertWorkflowGrant(e,t,r,n,i){return await this.client.put(`v1/workspaces/${t}/workflows/${r}/grants/${n}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeWorkflowGrant(e,t,r,n){await this.client.delete(`v1/workspaces/${t}/workflows/${r}/grants/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async getNotifications(e,t,r){let n={limit:r?.limit??20};return r?.tab&&(n.tab=r.tab),r?.eventType&&(n.eventType=r.eventType),r?.cursor&&(n.cursor=r.cursor),await this.client.get(`v1/workspaces/${t}/notifications`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getNotificationUnreadCount(e,t){return await this.client.get(`v1/workspaces/${t}/notifications/unreadCount`,{headers:{Authorization:`Bearer ${e}`}}).json()}async markNotificationRead(e,t,r){await this.client.post(`v1/workspaces/${t}/notifications/${r}/read`,{headers:{Authorization:`Bearer ${e}`}})}async markAllNotificationsRead(e,t){await this.client.post(`v1/workspaces/${t}/notifications/readAll`,{headers:{Authorization:`Bearer ${e}`}})}async getRuntimeConfig(){if(this.runtimeConfigCache)return this.runtimeConfigCache;let e=await this.client.get("v1/runtimeConfig").json();return this.runtimeConfigCache=e,e}async getModels(e,t){return await this.client.get(`v1/workspaces/${t}/models`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getModelTiers(e,t){return await this.client.get(`v1/workspaces/${t}/modelTiers`,{headers:{Authorization:`Bearer ${e}`}}).json()}async listSelectableModels(e,t){let{deploymentMode:r}=await this.getRuntimeConfig(),{models:n}=r==="saas"?await this.getModelTiers(e,t):await this.getModels(e,t);return{models:n.filter(i=>i.enabled!==!1)}}async getConnectors(e,t,r){let n={limit:r?.limit??100,connectionStatus:r?.connectionStatus??"connected"};return r?.search&&(n.search=r.search),r?.nextKey&&(n.nextKey=r.nextKey),await this.client.get(`v1/workspaces/${t}/availableConnectors`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getConnectorTools(e,t,r){return this.client.get(`v1/workspaces/${t}/connectors/${r}/tools`,{headers:{Authorization:`Bearer ${e}`}}).json()}async connectConnectorToken(e,t,r,n){await this.client.put(`v1/workspaces/${t}/connectors/${r}/token`,{headers:{Authorization:`Bearer ${e}`},json:n})}async getConnectorAuthUrl(e,t,r){return this.client.post(`v1/workspaces/${t}/connectors/${r}/authUrl`,{headers:{Authorization:`Bearer ${e}`},json:{}}).json()}async disconnectConnector(e,t,r){await this.client.delete(`v1/workspaces/${t}/connectors/${r}/token`,{headers:{Authorization:`Bearer ${e}`}})}async getTasks(e,t,r=20){return await this.client.get(`v1/workspaces/${t}/tasks`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:r}}).json()}async searchTasks(e,t,r,n){let i={q:r,limit:n?.limit??20};return n?.nextKey&&(i.nextKey=n.nextKey),await this.client.get(`v1/workspaces/${t}/tasks/search`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json()}async getMessages(e,t,r,n=50){return await this.client.get(`v1/workspaces/${t}/tasks/${r}/messages`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:n}}).json()}async getAgent(e,t,r){return await this.client.get(`v1/workspaces/${t}/agents/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async listAvailableSkills(e,t,r){return await this.client.get(`v1/workspaces/${t}/availableSkills`,{headers:{Authorization:`Bearer ${e}`},searchParams:{createdBy:r?.createdBy,nextKey:r?.nextKey,limit:r?.limit??20}}).json()}async uploadSkill(e,t,r){return await this.client.post(`v1/workspaces/${t}/skills`,{headers:{Authorization:`Bearer ${e}`},body:r}).json()}async deleteSkill(e,t,r){await this.client.delete(`v1/workspaces/${t}/skills/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async updateSkillPreference(e,t,r,n){return await this.client.patch(`v1/workspaces/${t}/skills/${r}/preference`,{headers:{Authorization:`Bearer ${e}`},json:{isEnabled:n}}).json()}async getSkillVersions(e,t,r){return await this.client.get(`v1/workspaces/${t}/skills/${r}/versions`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getSkillGrants(e,t,r){return await this.client.get(`v1/workspaces/${t}/skills/${r}/grants`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertSkillGrant(e,t,r,n,i){return await this.client.put(`v1/workspaces/${t}/skills/${r}/grants/${n}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeSkillGrant(e,t,r,n){await this.client.delete(`v1/workspaces/${t}/skills/${r}/grants/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async downloadSkillCurrent(e,t,r){return await this.client.get(`v1/workspaces/${t}/skills/${r}/download`,{headers:{Authorization:`Bearer ${e}`}}).json()}async task(e,t,r){try{let n=await this.client.post(`v1/workspaces/${t}/tasks`,{headers:{Authorization:`Bearer ${e}`},json:r,timeout:6e4,throwHttpErrors:!1});if(!n.ok){let o=await n.text();throw new Error(`Task API failed (${n.status}): ${o}`)}let i=await n.json();return i.noop||!i.streamId?new Response(`data: [DONE]
|
|
3
|
-
|
|
4
|
-
`,{headers:{"Content-Type":"text/event-stream"}}):await this.taskStream(e,t,i.taskId)}catch(n){throw n instanceof Se?new TypeError("Request timed out. Please check your connection and try again.",{cause:n}):n}}async taskStream(e,t,r){let n=await this.client.get(`v1/workspaces/${t}/tasks/${r}/stream`,{headers:{Authorization:`Bearer ${e}`,Accept:"text/event-stream"},timeout:!1,throwHttpErrors:!1});if(!n.ok){let i=await n.text();throw new Error(`Task stream failed (${n.status}): ${i}`)}return n}async getBudget(e,t){return await this.client.get(`v1/workspaces/${t}/budget`,{headers:{Authorization:`Bearer ${e}`}}).json()}async updateBudget(e,t,r){await this.client.put(`v1/workspaces/${t}/budget`,{headers:{Authorization:`Bearer ${e}`},json:{budget:r}})}async getMonthlyUsages(e,t,r){return await this.client.get(`v1/workspaces/${t}/monthlyUsages`,{headers:{Authorization:`Bearer ${e}`},searchParams:{nextKey:r?.nextKey,limit:r?.limit??20}}).json()}async getBillingOverview(e,t){return await this.client.get(`v1/workspaces/${t}/billing/overview`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getBillingInvoices(e,t,r){let n={limit:r?.limit??20};return r?.nextKey&&(n.nextKey=r.nextKey),await this.client.get(`v1/workspaces/${t}/billing/invoices`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getUsageOverview(e,t){return await this.client.get(`v1/workspaces/${t}/usage/overview`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getUsageMe(e,t){return await this.client.get(`v1/workspaces/${t}/usage/me`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getUsageConsumptions(e,t,r){let n={limit:r?.limit??20,offset:r?.offset??0};return r?.periodStart&&(n.periodStart=r.periodStart),await this.client.get(`v1/workspaces/${t}/usage/consumptions`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async exportUsageCsv(e,t,r){let n={};return r&&(n.periodStart=r),await this.client.get(`v1/workspaces/${t}/usage/export`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).text()}async createTaskShare(e,t,r,n="public"){try{return await this.client.post(`v1/workspaces/${t}/tasks/${r}/shares`,{headers:{Authorization:`Bearer ${e}`},json:{visibility:n}}).json()}catch(i){if(ne(i)&&i.response.status===403){let o=await i.response.json().catch(()=>null);if(o?.code==="sharing_disabled")throw new Error("Sharing is turned off for this workspace by an admin.",{cause:i});if(o?.code==="share_visibility_not_allowed")throw new Error("Public sharing is turned off for this workspace by an admin.",{cause:i})}throw i}}async getSharedTask(e,t){let r={};return t&&(r.Authorization=`Bearer ${t}`),await this.client.get(`v1/shares/${e}`,{headers:r}).json()}async getSharedMessages(e,t=50,r){let n={};return r&&(n.Authorization=`Bearer ${r}`),await this.client.get(`v1/shares/${e}/messages`,{headers:n,searchParams:{limit:t}}).json()}async deleteTask(e,t,r){await this.client.delete(`v1/workspaces/${t}/tasks/${r}`,{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,r,n){let i=new FormData,o=new Blob([r.buffer],{type:r.mimeType});return i.append("file",o,r.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,r){let n={limit:r?.limit??20};return r?.nextKey&&(n.nextKey=r.nextKey),r?.search&&(n.search=r.search),await this.client.get(`v1/workspaces/${t}/schedules`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getSchedule(e,t,r){return await this.client.get(`v1/workspaces/${t}/schedules/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createSchedule(e,t,r){return await this.client.post(`v1/workspaces/${t}/schedules`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async updateSchedule(e,t,r,n){await this.client.put(`v1/workspaces/${t}/schedules/${r}`,{headers:{Authorization:`Bearer ${e}`},json:n})}async deleteSchedule(e,t,r){await this.client.delete(`v1/workspaces/${t}/schedules/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async activateSchedule(e,t,r){await this.client.post(`v1/workspaces/${t}/schedules/${r}/activate`,{headers:{Authorization:`Bearer ${e}`}})}async deactivateSchedule(e,t,r){await this.client.post(`v1/workspaces/${t}/schedules/${r}/deactivate`,{headers:{Authorization:`Bearer ${e}`}})}async runScheduleNow(e,t,r){return await this.client.post(`v1/workspaces/${t}/schedules/${r}/run`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getScheduleRuns(e,t,r,n){let i={limit:n?.limit??20};return n?.nextKey&&(i.nextKey=n.nextKey),await this.client.get(`v1/workspaces/${t}/schedules/${r}/runs`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json()}async listRecordings(e,t,r){let n={limit:r?.limit??20};return r?.nextKey&&(n.nextKey=r.nextKey),r?.search&&(n.search=r.search),this.client.get(`v1/workspaces/${t}/recordings`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async importRecordingMedia(e,t,r){return this.client.post(`v1/workspaces/${t}/recordings/import/media`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async previewRecordingMedia(e,t,r){let n={url:r};return this.client.get(`v1/workspaces/${t}/recordings/preview/media`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).json()}async getRecordingAudioUrl(e,t,r){return this.client.get(`v1/workspaces/${t}/recordings/${r}/audioUrl`,{headers:{Authorization:`Bearer ${e}`}}).json()}async retryRecording(e,t,r){return this.client.post(`v1/workspaces/${t}/recordings/${r}/retry`,{headers:{Authorization:`Bearer ${e}`}}).json()}async deleteRecording(e,t,r){await this.client.delete(`v1/workspaces/${t}/recordings/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async searchMarketplace(e){let t={};return e?.type&&(t.type=e.type),e?.tag&&(t.tag=e.tag),e?.limit&&(t.limit=e.limit),e?.cursor&&(t.cursor=e.cursor),this.client.get("v1/marketplace/resources",{searchParams:t}).json()}async getMarketplaceAgent(e){return this.client.get(`v1/marketplace/agents/${encodeURIComponent(e)}`).json()}async getMarketplaceSkill(e){return this.client.get(`v1/marketplace/skills/${encodeURIComponent(e)}`).json()}async listMarketplaceRoles(){return this.client.get("v1/marketplace/roles").json()}async installMarketplaceResource(e,t,r,n){return this.client.post(`v1/workspaces/${t}/marketplace/${r}s/${encodeURIComponent(n)}/install`,{headers:{Authorization:`Bearer ${e}`},json:{}}).json()}static async getAuthenticatedClient(e){let t=await h.getAll(e);return t?{client:new s(void 0,e),accessToken:t.accessToken,workspaceId:t.workspaceId??null}:null}};function L(){return process.env.ENTRYDESK_SANDBOX==="true"}function _(){if(!L())return null;let s=process.env.ENTRYDESK_SANDBOX_ACCESS_TOKEN?.trim(),e=process.env.ENTRYDESK_SANDBOX_WORKSPACE_ID?.trim();if(!s||!e){let t=[];throw s||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:s,workspaceId:e}}function ie(){return!!process.env.ENTRYDESK_TOKEN?.trim()}function G(){let s=process.env.ENTRYDESK_TOKEN?.trim();if(!s)return null;let e=process.env.ENTRYDESK_WORKSPACE_ID?.trim();if(!e)throw new Error("ENTRYDESK_TOKEN is set but ENTRYDESK_WORKSPACE_ID is missing. Both are required for PAT authentication.");return{accessToken:s,workspaceId:e}}var W="sandbox environment (ENTRYDESK_SANDBOX)",$e="personal access token (ENTRYDESK_TOKEN)";function ct(){let s=_();if(s)return{authSource:"sandbox-env",label:W,workspaceId:s.workspaceId};let e=G();return e?{authSource:"pat-env",label:$e,workspaceId:e.workspaceId}:null}import{execFile as Ce}from"child_process";import{setTimeout as be}from"timers/promises";import{decodeJwt as Te}from"jose";import Ee,{HTTPError as ae,isHTTPError as xe}from"ky";function H(s){if(s===null||typeof s!="object")return{error:""};let e=s;return{code:typeof e.code=="string"?e.code:void 0,error:typeof e.error=="string"?e.error:""}}var E="entrydesk-cli",Be="offline_access workspaces:read tasks:read tasks:write tasks:delete agents:read agents:write connectors:read connectors:write tools:read tools:execute skills:read skills:write meetings:read meetings:write workflows:read workflows:write notifications:read notifications:write publishes:read publishes:write calendar:read calendar:write schedules:read schedules:write user:read user:write";function Me(s,e){let t=new Set(e.split(/[\s,]+/).filter(Boolean)),r=s.split(" ").filter(Boolean);return{rejected:r.filter(n=>t.has(n)),remaining:r.filter(n=>!t.has(n))}}async function Ke(s,e,t){try{return await s.post("v1/oauth/device/code",{json:{client_id:E,scope:e}}).json()}catch(r){if(!(r instanceof ae))throw r;let{code:n,error:i}=H(r.data);if(n==="invalid_scope"){let{rejected:o,remaining:d}=Me(e,i);if(o.length>0&&d.length>0)return t?.onWarning?.(`This server doesn't support these scopes: ${o.join(", ")}. Continuing without them \u2014 commands that need them may be unavailable.`),s.post("v1/oauth/device/code",{json:{client_id:E,scope:d.join(" ")}}).json()}throw new Error(i?`Failed to request device code: ${i}`:"Failed to request device code",{cause:r})}}function _e(s){return new Promise((e,t)=>{let r=process.platform,n,i;switch(r){case"darwin":n="open",i=[s];break;case"win32":n="cmd",i=["/c","start","",s];break;default:n="xdg-open",i=[s];break}Ce(n,i,o=>{o?t(new Error(`Failed to open browser. Please manually visit: ${s}`,{cause:o})):e()})})}async function mt(s){let e=$(),t=oe(),r=K(),n=process.env.NODE_TLS_REJECT_UNAUTHORIZED;r.ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED="0",console.error("WARNING: SSL certificate validation is disabled globally for this process during the login flow. All connections in this process will skip TLS verification. Only use ENTRYDESK_IGNORE_SSL_ERRORS for local development."));try{let i=Ee.create({baseUrl:e.replace(/\/?$/,"/"),timeout:3e4,hooks:{beforeError:[({error:c})=>(xe(c)&&(c.request.headers.delete("authorization"),c.request.headers.delete("Authorization")),c)]}}),o;try{o=await Ke(i,Be,s)}catch(c){let k=c instanceof Error?c:new Error("Failed to request device code");throw s?.onError?.(k),k}let{device_code:d,user_code:u,expires_in:ue,interval:pe}=o,Q=new URL("/oauth/device",t);Q.searchParams.set("user_code",u);let ee=Q.toString();s?.onDeviceCodeReceived?.(u,ee),s?.onBrowserOpening?.();try{await _e(ee)}catch(c){process.env.DEBUG&&console.error("[DEBUG] Failed to open browser:",c)}s?.onWaitingForAuthorization?.();let te=Math.max(pe,5)*1e3,he=Date.now()+ue*1e3;for(;Date.now()<he;){await be(te);try{let c=await i.post("v1/oauth/token",{json:{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:d,client_id:E}}).json();s?.onAuthorized?.();let k={};try{k=Te(c.access_token)}catch{}return{accessToken:c.access_token,refreshToken:c.refresh_token??void 0,email:k.email||"",scopes:c.scope.split(" ").filter(j=>j.length>0)}}catch(c){if(c instanceof ae){let{code:j,error:fe}=H(c.data),D=j||fe;if(!D)continue;switch(D){case"authorization_pending":continue;case"slow_down":te+=5e3;continue;case"access_denied":throw new Error("Authorization denied by user",{cause:c});case"expired_token":throw new Error("Device code expired. Please try again.",{cause:c});default:throw new Error(`Authorization failed: ${D||"Unknown error"}`,{cause:c})}}let k=c instanceof Error?c:new Error("Unknown error during authorization");throw s?.onError?.(k),k}}throw new Error("Device code expired. Please try again.")}finally{n===void 0?delete process.env.NODE_TLS_REJECT_UNAUTHORIZED:process.env.NODE_TLS_REJECT_UNAUTHORIZED=n}}function Ie(s){if(s instanceof Ue){let e=s.response.status;return e===400||e===401}return!1}var f=class extends Error{code;constructor(e,t){super(t),this.name="AuthError",this.code=e}};function je(s){try{let e=s.split(".");if(e.length<2)return null;let t=e[1].replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,"="),i=Buffer.from(n,"base64").toString("utf8");return JSON.parse(i)}catch{return null}}function De(s,e=300){let r=je(s)?.exp;if(typeof r!="number")return!1;let n=Math.floor(Date.now()/1e3);return r-n<=e}async function ce(s){let e=s.accessToken;if(!De(e))return e;if(!s.refreshToken)throw await h.clear(),new f("session-expired","Session expired. Please run `entrydesk login` again.");let t=s.refreshToken;try{let n=await new M().refreshOAuthToken({refreshToken:t,clientId:E}),i=await h.getAll();return i?.accessToken&&i.refreshToken&&i.refreshToken!==t?i.accessToken:(await h.saveAll({...i??s,accessToken:n.access_token,refreshToken:n.refresh_token??i?.refreshToken??t}),n.access_token)}catch(r){if(!Ie(r))throw new f("refresh-failed","Could not refresh your session (auth server unreachable). Please try again.");let n=await h.getAll();if(n?.accessToken&&n.refreshToken&&n.refreshToken!==t)return n.accessToken;throw await h.clear(),new f("session-expired","Session expired. Please run `entrydesk login` again.")}}async function St(){let s=_();if(s)return s.accessToken;let e=await h.getAll();if(!e?.accessToken)throw new f("not-logged-in","Not logged in. Run `entrydesk login` first.");return ce(e)}async function $t(){let s=_();if(s)return{accessToken:s.accessToken,workspaceId:s.workspaceId};let e=G();if(e)return e;let t=await h.getAll();if(!t?.accessToken)throw new f("not-logged-in","Not logged in. Run `entrydesk login` first.");if(!t.workspaceId)throw new f("no-workspace","No workspace selected. Run `entrydesk workspaces` first.");return{accessToken:await ce(t),workspaceId:t.workspaceId}}function Ne(){let s="";try{s=` by ${$()}`}catch{}let e;return L()?e=`Requests are authenticated via ${W} \u2014 ask the sandbox owner to issue fresh credentials.`:ie()?e="ENTRYDESK_TOKEN is set and takes priority over `entrydesk login` credentials for workspace commands \u2014 unset it or replace it with a valid token; if this command does not use it, run `entrydesk login`.":e="Your session may have expired \u2014 run `entrydesk login`. If this is not the environment you expect, check `entrydesk config get apiUrl`.",`Not authorized (401)${s}. ${e}`}var y=class extends Error{constructor(t,r=1,n){super(t);this.exitCode=r;this.cause=n;this.name="CLIError"}exitCode;cause};function Bt(s){let e=!!process.env.DEBUG;if(s instanceof y&&(console.error(`Error: ${s.message}`),s.cause&&(console.error(`Cause: ${s.cause.message}`),e&&s.cause.stack&&console.error(s.cause.stack)),process.exit(s.exitCode)),s instanceof f&&(console.error(s.message),e&&s.stack&&console.error(s.stack),process.exit(1)),s instanceof Fe&&(console.error("Request timed out. Please check your connection and try again."),e&&s.stack&&console.error(s.stack),process.exit(1)),s instanceof ze){let t=s.response.status;console.error(t===401?Ne():t===403?"Forbidden (403). Your account or token lacks permission for this action. If your token predates a recently added feature, run `entrydesk login` to refresh its scopes; otherwise you may lack permission in this workspace.":`Request failed (${t}): ${s.response.statusText}`),e&&s.stack&&console.error(s.stack),process.exit(1)}s instanceof Error&&(console.error(`Unexpected error: ${s.message}`),e&&s.stack&&console.error(s.stack),process.exit(1)),console.error("An unknown error occurred"),process.exit(1)}var P="default",Le=/^[A-Za-z0-9_-]+$/,Y=null;function q(){return b.join(Oe.homedir(),".entrydesk")}function ge(){return b.join(q(),"profiles")}function de(){return b.join(q(),"profiles.json")}function U(s){return b.join(ge(),s)}function J(s){if(m.existsSync(s))try{m.chmodSync(s,448)}catch{}else m.mkdirSync(s,{mode:448,recursive:!0})}function Ge(){J(q())}function V(){J(ge())}function We(){let s=de();try{if(!m.existsSync(s))return null;let e=m.readFileSync(s,"utf-8");return JSON.parse(e)}catch{return null}}function C(s){Ge();let e=de();m.writeFileSync(e,JSON.stringify(s,null,2),{mode:384});try{m.chmodSync(e,384)}catch{}}function He(s){let e=s.profiles?.length?[...new Set(s.profiles)]:[],t=s.currentProfile&&e.includes(s.currentProfile)?s.currentProfile:e[0]||P;return e.length===0&&e.push(P),e.includes(t)||e.unshift(t),{currentProfile:t,profiles:e}}function B(s){V(),J(U(s))}function R(){let s=We();if(!s){let t={currentProfile:P,profiles:[P]};return C(t),V(),B(P),t}let e=He(s);return(e.currentProfile!==s.currentProfile||e.profiles.length!==s.profiles.length)&&C(e),V(),e}function A(s){if(!s)throw new y("Profile name is required.");if(!Le.test(s))throw new y("Invalid profile name. Use letters, numbers, dash, or underscore.")}function x(s,e){if(!s.profiles.includes(e))throw new y(`Profile not found: ${e}`)}function le(s,e){if(s.profiles.includes(e))throw new y(`Profile already exists: ${e}`)}var a={DEFAULT_PROFILE:P,setOverrideProfile(s){Y=s},getOverrideProfile(){return Y},getProfileDir(s){return U(s)},getProfileConfigFile(s){return b.join(a.getProfileDir(s),"config.json")},getProfileCredentialsFile(s){return b.join(a.getProfileDir(s),"credentials.json")},getProfileNames(){return[...R().profiles]},getProfileCount(){return a.getProfileNames().length},getCurrentProfileName(){return R().currentProfile},getEffectiveProfileName(s){let e=R(),t=s||Y||e.currentProfile;return A(t),x(e,t),t},ensureProfileExists(s){let e=R();A(s),x(e,s)},createProfile(s){A(s);let e=R();le(e,s);let t={currentProfile:e.currentProfile,profiles:[...e.profiles,s]};C(t),B(s)},deleteProfile(s){A(s);let e=R();if(x(e,s),e.profiles.length===1)throw new y("Cannot delete the last profile.");let t=e.profiles.filter(i=>i!==s),r=e.currentProfile;r===s&&(r=t.includes(P)?P:t[0]),C({currentProfile:r,profiles:t});try{m.rmSync(a.getProfileDir(s),{recursive:!0,force:!0})}catch{}return{currentProfile:r}},renameProfile(s,e){A(s),A(e);let t=R();x(t,s),le(t,e);let r=U(s),n=U(e);if(m.existsSync(r))try{m.renameSync(r,n)}catch(u){throw new y("Failed to rename profile directory.",1,u)}else B(e);let i=t.profiles.map(u=>u===s?e:u),o=t.currentProfile===s?e:t.currentProfile;return C({currentProfile:o,profiles:i}),{currentProfile:o}},setCurrentProfile(s){A(s);let e=R();x(e,s);let t={currentProfile:s,profiles:e.profiles};C(t),B(s)},ensureProfileDir:B};function Ye(s){let e=a.getEffectiveProfileName(s);return a.getProfileConfigFile(e)}function g(s){let e=Ye(s);try{if(!I.existsSync(e))return{};let t=I.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return{}}}function w(s,e){let t=a.getEffectiveProfileName(e);a.ensureProfileDir(t);let r=a.getProfileConfigFile(t);I.writeFileSync(r,JSON.stringify(s,null,2),{mode:384});try{I.chmodSync(r,384)}catch{}}var X={getApiUrl(s){return g(s).apiUrl??null},setApiUrl(s,e){let t=g(e);t.apiUrl=s,w(t,e)},clearApiUrl(s){let e=g(s);delete e.apiUrl,w(e,s)},getHubUrl(s){return g(s).hubUrl??null},setHubUrl(s,e){let t=g(e);t.hubUrl=s,w(t,e)},getAll(s){return g(s)},setAll(s,e){w(s,e)},set(s,e,t){let r=g(t);r[s]=e,w(r,t)},get(s,e){return g(e)[s]},unset(s,e){let t=g(e);delete t[s],w(t,e)},getDefaultModel(s){return g(s).model?.default??null},setDefaultModel(s,e){let t=g(e);t.model={...t.model,default:s},w(t,e)},getDefaultConnectorIds(s){return g(s).connectors?.defaults??null},setDefaultConnectorIds(s,e){let t=g(e);t.connectors={...t.connectors,defaults:s},w(t,e)},getLocalTools(s){return g(s).localTools??null},setLocalTools(s,e){let t=g(e);t.localTools={...t.localTools,...s},w(t,e)}};var Ve="https://api.entrydesk.com",qe="https://app.entrydesk.com",Je=3100,Xe=300*1e3;function Z(s){return{apiUrl:X.getApiUrl(s)||process.env.ENTRYDESK_API_URL||Ve,hubUrl:X.getHubUrl(s)||process.env.ENTRYDESK_HUB_URL||qe,mcp:{httpPort:Je},auth:{loginTimeout:Xe,ignoreSslErrors:process.env.ENTRYDESK_IGNORE_SSL_ERRORS==="true"||!1}}}function $(s){return Z(s).apiUrl}function oe(s){return Z(s).hubUrl}function K(){return Z().auth}export{a,X as b,Z as c,$ as d,oe as e,K as f,h as g,M as h,_ as i,ie as j,G as k,W as l,ct as m,E as n,mt as o,f as p,De as q,ce as r,St as s,$t as t,y as u,Bt as v};
|
package/dist/config-2UKI6TWQ.js
DELETED
package/dist/login-5PYRMAXU.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{g as r,h as l,i as a,j as c,l as g,o as d}from"./chunk-U3S6IYK7.js";import"./chunk-KBW7PPBV.js";async function h(o){let t=a();if(t){o.json?console.log(JSON.stringify({alreadyAuthenticated:!0,authSource:"sandbox-env",workspaceId:t.workspaceId})):(console.log(`Already authenticated via ${g}.`),console.log("No login required \u2014 environment credentials are active."));return}if(c()&&console.error("Warning: ENTRYDESK_TOKEN is set \u2014 workspace commands will keep using it instead of the credentials saved by this login. Unset ENTRYDESK_TOKEN if you want this login to take effect."),process.env.DEBUG){let{getApiUrl:i,getHubUrl:s}=await import("./config-2UKI6TWQ.js");console.log(`[DEBUG] Hub URL: ${s()}`),console.log(`[DEBUG] API URL: ${i()}`)}let e=await d({onDeviceCodeReceived:(i,s)=>{o.json||(console.log(""),console.log("To authenticate, please:"),console.log(""),console.log(` 1. Visit: ${s}`),console.log(` 2. Enter code: ${i}`),console.log(""))},onBrowserOpening:()=>{o.json||console.log("Opening browser...")},onWaitingForAuthorization:()=>{o.json||console.log("Waiting for authorization...")},onAuthorized:()=>{o.json||console.log("Authorization successful!")},onWarning:i=>{console.error(`Warning: ${i}`)}}),f=new l,{workspaces:p}=await f.getWorkspaces(e.accessToken),n=p[0];await r.saveAll({accessToken:e.accessToken,refreshToken:e.refreshToken,email:e.email,workspaceId:n?.id}),o.json?console.log(JSON.stringify({email:e.email,workspaceId:n?.id,workspaceName:n?.name})):(console.log(`Logged in as ${e.email}`),n&&console.log(`Workspace: ${n.name}`))}export{h as runLogin};
|
package/dist/models-ZQQ6IAMC.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{h as n,t,v as l}from"./chunk-U3S6IYK7.js";import"./chunk-KBW7PPBV.js";async function p(c){try{let e,r;try{let o=await t();e=o.accessToken,r=o.workspaceId}catch(o){let a=o instanceof Error?o.message:"Authentication failed";console.error(a),process.exit(1)}let i=new n,{models:s}=await i.listSelectableModels(e,r);if(c.json){console.log(JSON.stringify(s));return}if(s.length===0){console.log("No models available in this workspace.");return}console.log(`Available Models (${s.length}):
|
|
3
|
-
`);for(let o of s)console.log(` ${o.name}`),o.description&&console.log(` ${o.description.slice(0,80)}`),console.log(` ID: ${o.id}`),console.log("")}catch(e){l(e)}}export{p as runModels};
|
package/dist/status-APAONGPM.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as c,b as i,g as a,h as g,m as f,p,s as d,v as u}from"./chunk-U3S6IYK7.js";import"./chunk-KBW7PPBV.js";async function W(t){try{let o=c.getEffectiveProfileName(),n={model:i.getDefaultModel(),connectors:i.getDefaultConnectorIds()},r=f();if(r){t.json?console.log(JSON.stringify({loggedIn:!0,authSource:r.authSource,profile:o,workspaceId:r.workspaceId,defaults:n})):(console.log(`Profile: ${o}`),console.log(`Authenticated via ${r.label} (no login required)`),console.log(`Workspace ID: ${r.workspaceId}`));return}let e=await a.getAll();if(!e){t.json?console.log(JSON.stringify({loggedIn:!1,profile:o,defaults:n})):(console.log(`Profile: ${o}`),console.log("Not logged in"),console.log("Run `entrydesk login` to authenticate"));return}let l;if(e.workspaceId)try{let s=new g,m=await d(),{workspaces:k}=await s.getWorkspaces(m);l=k.find(I=>I.id===e.workspaceId)?.name}catch(s){if(s instanceof p){t.json?console.log(JSON.stringify({loggedIn:!1,profile:o,defaults:n})):(console.log(`Profile: ${o}`),console.log("Not logged in"),console.log("Run `entrydesk login` to authenticate"));return}}t.json?console.log(JSON.stringify({loggedIn:!0,authSource:"file",profile:o,email:e.email,workspaceId:e.workspaceId,workspaceName:l,defaults:n})):(console.log(`Profile: ${o}`),console.log(`Logged in as ${e.email}`),l&&console.log(`Workspace: ${l}`),e.workspaceId&&console.log(`Workspace ID: ${e.workspaceId}`))}catch(o){u(o)}}export{W as runStatus};
|