@entrydesk/cli 1.11.19 → 1.12.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/README.md +17 -17
- package/dist/{agents-6SL2CJJJ.js → agents-F6WZ75FO.js} +1 -1
- package/dist/{budget-XMLYDL5J.js → budget-T5N2N4MP.js} +1 -1
- package/dist/{chunk-6AL7OBSG.js → chunk-QCYRC3HX.js} +1 -1
- package/dist/{config-ASV5NL7Z.js → config-3R3GDZWB.js} +1 -1
- package/dist/{config-FLAGIMCN.js → config-MEIIXIQS.js} +1 -1
- package/dist/{config-help-W3HXZ7F6.js → config-help-LGEAPZUD.js} +1 -1
- package/dist/{connectors-CWI5IVDN.js → connectors-FUAOLPGH.js} +1 -1
- package/dist/{help-Z5YLPTUZ.js → help-NESOCXU4.js} +31 -31
- package/dist/index.js +1 -1
- package/dist/{login-JXFYDARD.js → login-XMQUQC6W.js} +1 -1
- package/dist/{logout-Q55UDAOR.js → logout-RLZWCE3X.js} +1 -1
- package/dist/{mcp-3EUOE6DQ.js → mcp-47MJFVKB.js} +1 -1
- package/dist/{models-3XO5UL2T.js → models-UVC4PPAL.js} +1 -1
- package/dist/{profile-37GMFZPS.js → profile-SNZTVXLY.js} +1 -1
- package/dist/{schedules-TKPFSTIL.js → schedules-ZUXF7C6D.js} +1 -1
- package/dist/{skills-CQFFZAZY.js → skills-YESN74QW.js} +1 -1
- package/dist/{status-NIH542GP.js → status-DCA3JEPN.js} +1 -1
- package/dist/{chat-UGJ345HC.js → task-LFS7JM7C.js} +83 -83
- package/dist/tasks-CWQXUKK6.js +19 -0
- package/dist/{tool-I5NZCJP7.js → tool-RAYVZNS2.js} +1 -1
- package/dist/{usage-FKKIXVFK.js → usage-NDVCWDNA.js} +1 -1
- package/dist/version-P7RLOGGP.js +2 -0
- package/dist/{workspaces-QJAHQQ2L.js → workspaces-DZMNMF5V.js} +1 -1
- package/package.json +1 -1
- package/dist/chats-O7AN67QW.js +0 -19
- package/dist/version-6NQBVGVC.js +0 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# EntryDesk CLI
|
|
2
2
|
|
|
3
|
-
Command-line client for EntryDesk. Includes interactive
|
|
3
|
+
Command-line client for EntryDesk. Includes interactive task, tool output
|
|
4
4
|
rendering, and scripting-friendly JSON output.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
@@ -24,10 +24,10 @@ Build and run from the repo:
|
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
pnpm --filter @entrydesk/cli build
|
|
27
|
-
pnpm --filter @entrydesk/cli start --
|
|
27
|
+
pnpm --filter @entrydesk/cli start -- task -i
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
Interactive
|
|
30
|
+
Interactive task is also the default when no command is provided:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
entrydesk
|
|
@@ -55,24 +55,24 @@ To force file storage (for example, in CI), set
|
|
|
55
55
|
Login requires HTTPS by default. For local development against an HTTP API,
|
|
56
56
|
set `ENTRYDESK_ALLOW_INSECURE_LOGIN=true`.
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Task
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
entrydesk
|
|
62
|
-
entrydesk
|
|
63
|
-
entrydesk
|
|
64
|
-
entrydesk
|
|
65
|
-
entrydesk
|
|
66
|
-
entrydesk
|
|
67
|
-
entrydesk
|
|
61
|
+
entrydesk task -m "Hello" --model <model>
|
|
62
|
+
entrydesk task -a <agent>
|
|
63
|
+
entrydesk task -c 1 -m "Follow up"
|
|
64
|
+
entrydesk task -i
|
|
65
|
+
entrydesk task -i --web-search # Enable web search
|
|
66
|
+
entrydesk task -i --no-sandbox # Disable sandbox
|
|
67
|
+
entrydesk task -i --connectors id1,id2 # Use specific connectors
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
Piping input and output:
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
echo "Hello" | entrydesk
|
|
74
|
-
entrydesk
|
|
75
|
-
entrydesk
|
|
73
|
+
echo "Hello" | entrydesk task --model <model>
|
|
74
|
+
entrydesk task -m "Hi" --model <model> --plain
|
|
75
|
+
entrydesk task -m "Hi" --model <model> --output stream-json
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
## Browse Resources
|
|
@@ -84,8 +84,8 @@ entrydesk models
|
|
|
84
84
|
entrydesk agents
|
|
85
85
|
entrydesk connectors
|
|
86
86
|
entrydesk skills
|
|
87
|
-
entrydesk
|
|
88
|
-
entrydesk
|
|
87
|
+
entrydesk tasks
|
|
88
|
+
entrydesk tasks 1
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
## MCP Server
|
|
@@ -156,7 +156,7 @@ entrydesk profile delete staging
|
|
|
156
156
|
|
|
157
157
|
# Run a single command against a specific profile without switching
|
|
158
158
|
entrydesk status --profile staging
|
|
159
|
-
entrydesk
|
|
159
|
+
entrydesk task -i --profile staging
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
## Development
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import F from"fs";import h from"fs";import _e from"os";import E from"path";import{HTTPError as Te,TimeoutError as xe}from"ky";import ye,{TimeoutError as me}from"ky";import T from"crypto";import u from"fs";import le from"path";var ge="ENTRYDESK_FORCE_FILE_STORAGE",A="EntryDesk CLI",de="__entrydesk_keychain_test__",ue="profile:",fe=".credentials.key",Z={keychain:!1,permissions:!1,corruptFile:!1,windowsFile:!1};function v(r,e){Z[r]||(Z[r]=!0,console.error(e))}function he(){return process.env.ENTRYDESK_DEBUG?.toLowerCase()==="true"}function Q(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 pe(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 B(r){return o.getProfileCredentialsFile(r)}var O=class{getKeyFilePath(e){return le.join(o.getProfileDir(e),fe)}loadEncryptionKey(e){let t=this.getKeyFilePath(e);try{if(!u.existsSync(t))return null;let s=u.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=T.randomBytes(32);return u.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=T.randomBytes(16),n=T.createCipheriv("aes-256-gcm",t,s),i=n.update(e,"utf8","hex");i+=n.final("hex");let c=n.getAuthTag();return`${s.toString("hex")}:${c.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"),c=s[2],S=T.createDecipheriv("aes-256-gcm",t,n,{authTagLength:16});S.setAuthTag(i);let d=S.update(c,"hex","utf8");return d+=S.final("utf8"),d}tryDecrypt(e,t){try{return this.decrypt(e,t)}catch{return null}}tryParseCredentials(e){try{let t=JSON.parse(e);return Q(t)?t:null}catch{return null}}ensureSecureFilePermissions(e){if(process.platform!=="win32"){try{u.chmodSync(e,384)}catch{v("permissions","Warning: Failed to set secure permissions on credentials file.");return}try{(u.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=B(e);try{if(!u.existsSync(t))return null;let s=u.readFileSync(t,"utf-8").trim();if(!s)return null;let n=this.loadEncryptionKey(e),i=n?this.tryDecrypt(s,n):null;if(i){let c=this.tryParseCredentials(i);if(c)return c}return v("corruptFile","Warning: Credentials file is unreadable. Please run `entrydesk login` again."),null}catch{return null}}async setCredentials(e,t){o.ensureProfileDir(e);let s=B(e),n=this.getOrCreateEncryptionKey(e),i=this.encrypt(JSON.stringify(t),n);u.writeFileSync(s,i,{mode:384}),this.ensureSecureFilePermissions(s)}async deleteCredentials(e){let t=B(e);try{u.existsSync(t)&&u.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=pe(s)?s:null}catch{this.keytarModule=null}return this.keytarModule}getAccount(e){return`${ue}${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=`${de}${T.randomBytes(8).toString("hex")}`,s="test";await e.setPassword(A,t,s);let n=await e.getPassword(A,t),i=await e.deletePassword(A,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(A,this.getAccount(e));if(!s)return null;let n=this.tryParseKeychainPayload(s);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 s=await this.getKeytar();if(!s)throw new Error("Keytar module not available");let n=JSON.stringify(t);await s.setPassword(A,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(A,this.getAccount(e))}tryParseKeychainPayload(e){try{let t=JSON.parse(e);return Q(t)?t:null}catch{return null}}},M=class{keychainStorage=null;fileStorage=new O;keychainAvailable=null;initPromise=null;shouldForceFileStorage(){return process.env[ge]?.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()&&(he()&&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 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)}},g=new M,y={async saveAccessToken(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.accessToken=r,await g.setCredentials(t,s)},async getAccessToken(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.accessToken??null},async saveRefreshToken(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.refreshToken=r,await g.setCredentials(t,s)},async getRefreshToken(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.refreshToken??null},async saveEmail(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.email=r,await g.setCredentials(t,s)},async getEmail(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.email??null},async saveWorkspaceId(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.workspaceId=r,await g.setCredentials(t,s)},async getWorkspaceId(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.workspaceId??null},async saveAll(r,e){let t=o.getEffectiveProfileName(e);await g.setCredentials(t,r)},async getAll(r){let e=o.getEffectiveProfileName(r);return g.getCredentials(e)},async clear(r){let e=o.getEffectiveProfileName(r);await g.deleteCredentials(e)},async isLoggedIn(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.accessToken!=null}};var K=class r{client;baseUrl;constructor(e,t){this.baseUrl=e||D(t),U().ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED="0",process.env.DEBUG&&console.log("[DEBUG] ApiClient: SSL certificate validation disabled")),this.client=ye.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}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,s){let n={limit:s?.limit??100};return s?.nextKey&&(n.nextKey=s.nextKey),s?.search&&(n.search=s.search),await this.client.get(`v1/workspaces/${t}/availableAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).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 downloadSkillCurrent(e,t,s){return await this.client.get(`v1/workspaces/${t}/skills/${s}/download`,{headers:{Authorization:`Bearer ${e}`}}).json()}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 me?new TypeError("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,c=new Blob([s.buffer],{type:s.mimeType});return i.append("file",c,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 y.getAll(e);return t?{client:new r(void 0,e),accessToken:t.accessToken,workspaceId:t.workspaceId??null}:null}};function we(){return process.env.ENTRYDESK_SANDBOX==="true"}function j(){if(!we())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}}function ee(){let r=process.env.ENTRYDESK_TOKEN?.trim();if(!r)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:r,workspaceId:e}}import{execFile as ve}from"child_process";import{setTimeout as ke}from"timers/promises";import{decodeJwt as Pe}from"jose";import Se,{HTTPError as Ce}from"ky";var I="entrydesk-cli",Ae="offline_access workspaces:read chats:read chats:write chats:delete agents:read agents:write connectors:read connectors:write tools:read tools:execute skills:read skills:write meetings:read meetings:write publishes:read publishes:write calendar:read calendar:write schedules:read schedules:write user:read user:write";function be(r){return new Promise((e,t)=>{let s=process.platform,n,i;switch(s){case"darwin":n="open",i=[r];break;case"win32":n="cmd",i=["/c","start","",r];break;default:n="xdg-open",i=[r];break}ve(n,i,c=>{c?t(new Error(`Failed to open browser. Please manually visit: ${r}`,{cause:c})):e()})})}async function rt(r){let e=D(),t=te(),s=U(),n=process.env.NODE_TLS_REJECT_UNAUTHORIZED;s.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=Se.create({prefixUrl:e,timeout:3e4,hooks:{beforeError:[a=>(a.request?.headers&&(a.request.headers.delete("authorization"),a.request.headers.delete("Authorization")),a)]}}),c;try{c=await i.post("v1/oauth/device/code",{json:{client_id:I,scope:Ae}}).json()}catch(a){let w=a instanceof Error?a:new Error("Failed to request device code");throw r?.onError?.(w),w}let{device_code:S,user_code:d,expires_in:oe,interval:ae}=c,J=new URL("/oauth/device",t);J.searchParams.set("user_code",d);let q=J.toString();r?.onDeviceCodeReceived?.(d,q),r?.onBrowserOpening?.();try{await be(q)}catch(a){process.env.DEBUG&&console.error("[DEBUG] Failed to open browser:",a)}r?.onWaitingForAuthorization?.();let V=Math.max(ae,5)*1e3,ce=Date.now()+oe*1e3;for(;Date.now()<ce;){await ke(V);try{let a=await i.post("v1/oauth/token",{json:{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:S,client_id:I}}).json();r?.onAuthorized?.();let w={};try{w=Pe(a.access_token)}catch{}return{accessToken:a.access_token,refreshToken:a.refresh_token??void 0,email:w.email||"",scopes:a.scope.split(" ").filter(R=>R.length>0)}}catch(a){if(a instanceof Ce){let R;try{let X=await a.response.json();R=X.code||X.error}catch{continue}switch(R){case"authorization_pending":continue;case"slow_down":V+=5e3;continue;case"access_denied":throw new Error("Authorization denied by user",{cause:a});case"expired_token":throw new Error("Device code expired. Please try again.",{cause:a});default:throw new Error(`Authorization failed: ${R||"Unknown error"}`,{cause:a})}}let w=a instanceof Error?a:new Error("Unknown error during authorization");throw r?.onError?.(w),w}}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}}var m=class extends Error{code;constructor(e,t){super(t),this.code=e}};function Ee(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 Re(r,e=300){let s=Ee(r)?.exp;if(typeof s!="number")return!1;let n=Math.floor(Date.now()/1e3);return s-n<=e}async function re(r){let e=r.accessToken;if(!Re(e))return e;if(!r.refreshToken)throw await y.clear(),new m("session-expired","Session expired. Please run `entrydesk login` again.");try{let s=await new K().refreshOAuthToken({refreshToken:r.refreshToken,clientId:I});return await y.saveAccessToken(s.access_token),s.refresh_token&&await y.saveRefreshToken(s.refresh_token),s.access_token}catch{throw await y.clear(),new m("session-expired","Session expired. Please run `entrydesk login` again.")}}async function ct(){let r=j();if(r)return r.accessToken;let e=await y.getAll();if(!e?.accessToken)throw new m("not-logged-in","Not logged in. Run `entrydesk login` first.");return re(e)}async function lt(){let r=j();if(r)return{accessToken:r.accessToken,workspaceId:r.workspaceId};let e=ee();if(e)return e;let t=await y.getAll();if(!t?.accessToken)throw new m("not-logged-in","Not logged in. Run `entrydesk login` first.");if(!t.workspaceId)throw new m("no-workspace","No workspace selected. Run `entrydesk workspaces` first.");return{accessToken:await re(t),workspaceId:t.workspaceId}}var f=class extends Error{constructor(t,s=1,n){super(t);this.exitCode=s;this.cause=n;this.name="CLIError"}exitCode;cause};function ft(r){let e=!!process.env.DEBUG;r instanceof f&&(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 m&&(console.error(r.message),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof xe&&(console.error("Request timed out. Please check your connection and try again."),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof Te&&(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 P="default",Ke=/^[A-Za-z0-9_-]+$/,z=null;function W(){return E.join(_e.homedir(),".entrydesk")}function ne(){return E.join(W(),"profiles")}function ie(){return E.join(W(),"profiles.json")}function $(r){return E.join(ne(),r)}function H(r){if(!h.existsSync(r))h.mkdirSync(r,{mode:448,recursive:!0});else try{h.chmodSync(r,448)}catch{}}function De(){H(W())}function L(){H(ne())}function Ue(){let r=ie();try{if(!h.existsSync(r))return null;let e=h.readFileSync(r,"utf-8");return JSON.parse(e)}catch{return null}}function b(r){De();let e=ie();h.writeFileSync(e,JSON.stringify(r,null,2),{mode:384});try{h.chmodSync(e,384)}catch{}}function Ie(r){let e=r.profiles?.length?Array.from(new Set(r.profiles)):[],t=r.currentProfile&&e.includes(r.currentProfile)?r.currentProfile:e[0]||P;return e.length===0&&e.push(P),e.includes(t)||e.unshift(t),{currentProfile:t,profiles:e}}function k(){let r=Ue();if(!r){let t={currentProfile:P,profiles:[P]};return b(t),L(),_(P),t}let e=Ie(r);return(e.currentProfile!==r.currentProfile||e.profiles.length!==r.profiles.length)&&b(e),L(),e}function C(r){if(!r)throw new f("Profile name is required.");if(!Ke.test(r))throw new f("Invalid profile name. Use letters, numbers, dash, or underscore.")}function x(r,e){if(!r.profiles.includes(e))throw new f(`Profile not found: ${e}`)}function se(r,e){if(r.profiles.includes(e))throw new f(`Profile already exists: ${e}`)}function _(r){L(),H($(r))}var o={DEFAULT_PROFILE:P,setOverrideProfile(r){z=r},getOverrideProfile(){return z},getProfileDir(r){return $(r)},getProfileConfigFile(r){return E.join(o.getProfileDir(r),"config.json")},getProfileCredentialsFile(r){return E.join(o.getProfileDir(r),"credentials.json")},getProfileNames(){return[...k().profiles]},getProfileCount(){return o.getProfileNames().length},getCurrentProfileName(){return k().currentProfile},getEffectiveProfileName(r){let e=k(),t=r||z||e.currentProfile;return C(t),x(e,t),t},ensureProfileExists(r){let e=k();C(r),x(e,r)},createProfile(r){C(r);let e=k();se(e,r);let t={currentProfile:e.currentProfile,profiles:[...e.profiles,r]};b(t),_(r)},deleteProfile(r){C(r);let e=k();if(x(e,r),e.profiles.length===1)throw new f("Cannot delete the last profile.");let t=e.profiles.filter(i=>i!==r),s=e.currentProfile;s===r&&(s=t.includes(P)?P:t[0]),b({currentProfile:s,profiles:t});try{h.rmSync(o.getProfileDir(r),{recursive:!0,force:!0})}catch{}return{currentProfile:s}},renameProfile(r,e){C(r),C(e);let t=k();x(t,r),se(t,e);let s=$(r),n=$(e);if(h.existsSync(s))try{h.renameSync(s,n)}catch(d){throw new f("Failed to rename profile directory.",1,d)}else _(e);let i=t.profiles.map(d=>d===r?e:d),c=t.currentProfile===r?e:t.currentProfile;return b({currentProfile:c,profiles:i}),{currentProfile:c}},setCurrentProfile(r){C(r);let e=k();x(e,r);let t={currentProfile:r,profiles:e.profiles};b(t),_(r)},ensureProfileDir:_};function $e(r){let e=o.getEffectiveProfileName(r);return o.getProfileConfigFile(e)}function l(r){let e=$e(r);try{if(!F.existsSync(e))return{};let t=F.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return{}}}function p(r,e){let t=o.getEffectiveProfileName(e);o.ensureProfileDir(t);let s=o.getProfileConfigFile(t);F.writeFileSync(s,JSON.stringify(r,null,2),{mode:384});try{F.chmodSync(s,384)}catch{}}var G={getApiUrl(r){return l(r).apiUrl??null},setApiUrl(r,e){let t=l(e);t.apiUrl=r,p(t,e)},clearApiUrl(r){let e=l(r);delete e.apiUrl,p(e,r)},getHubUrl(r){return l(r).hubUrl??null},setHubUrl(r,e){let t=l(e);t.hubUrl=r,p(t,e)},getAll(r){return l(r)},setAll(r,e){p(r,e)},set(r,e,t){let s=l(t);s[r]=e,p(s,t)},get(r,e){return l(e)[r]},unset(r,e){let t=l(e);delete t[r],p(t,e)},getDefaultModel(r){return l(r).model?.default??null},setDefaultModel(r,e){let t=l(e);t.model={...t.model,default:r},p(t,e)},getDefaultConnectorIds(r){return l(r).connectors?.defaults??null},setDefaultConnectorIds(r,e){let t=l(e);t.connectors={...t.connectors,defaults:r},p(t,e)},getCapabilities(r){return l(r).capabilities??null},setCapabilities(r,e){let t=l(e);t.capabilities={...t.capabilities,...r},p(t,e)},getLocalTools(r){return l(r).localTools??null},setLocalTools(r,e){let t=l(e);t.localTools={...t.localTools,...r},p(t,e)}};var Fe="https://api.entrydesk.com",Be="https://app.entrydesk.com",Oe=3100,Ne=300*1e3;function Y(r){return{apiUrl:G.getApiUrl(r)||process.env.ENTRYDESK_API_URL||Fe,hubUrl:G.getHubUrl(r)||process.env.ENTRYDESK_HUB_URL||Be,mcp:{httpPort:Oe},auth:{loginTimeout:Ne,ignoreSslErrors:process.env.ENTRYDESK_IGNORE_SSL_ERRORS==="true"||!1}}}function D(r){return Y(r).apiUrl}function te(r){return Y(r).hubUrl}function U(){return Y().auth}export{o as a,G as b,Y as c,D as d,te as e,U as f,y as g,K as h,I as i,rt as j,m as k,Re as l,re as m,ct as n,lt as o,f as p,ft as q};
|
|
2
|
+
import F from"fs";import p from"fs";import _e from"os";import E from"path";import{HTTPError as Re,TimeoutError as xe}from"ky";import ye,{TimeoutError as me}from"ky";import R from"crypto";import u from"fs";import le from"path";var ge="ENTRYDESK_FORCE_FILE_STORAGE",C="EntryDesk CLI",de="__entrydesk_keychain_test__",ue="profile:",fe=".credentials.key",Z={keychain:!1,permissions:!1,corruptFile:!1,windowsFile:!1};function w(r,e){Z[r]||(Z[r]=!0,console.error(e))}function pe(){return process.env.ENTRYDESK_DEBUG?.toLowerCase()==="true"}function Q(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 he(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 B(r){return o.getProfileCredentialsFile(r)}var O=class{getKeyFilePath(e){return le.join(o.getProfileDir(e),fe)}loadEncryptionKey(e){let t=this.getKeyFilePath(e);try{if(!u.existsSync(t))return null;let s=u.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=R.randomBytes(32);return u.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=R.randomBytes(16),n=R.createCipheriv("aes-256-gcm",t,s),i=n.update(e,"utf8","hex");i+=n.final("hex");let c=n.getAuthTag();return`${s.toString("hex")}:${c.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"),c=s[2],S=R.createDecipheriv("aes-256-gcm",t,n,{authTagLength:16});S.setAuthTag(i);let d=S.update(c,"hex","utf8");return d+=S.final("utf8"),d}tryDecrypt(e,t){try{return this.decrypt(e,t)}catch{return null}}tryParseCredentials(e){try{let t=JSON.parse(e);return Q(t)?t:null}catch{return null}}ensureSecureFilePermissions(e){if(process.platform!=="win32"){try{u.chmodSync(e,384)}catch{w("permissions","Warning: Failed to set secure permissions on credentials file.");return}try{(u.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=B(e);try{if(!u.existsSync(t))return null;let s=u.readFileSync(t,"utf-8").trim();if(!s)return null;let n=this.loadEncryptionKey(e),i=n?this.tryDecrypt(s,n):null;if(i){let c=this.tryParseCredentials(i);if(c)return c}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=B(e),n=this.getOrCreateEncryptionKey(e),i=this.encrypt(JSON.stringify(t),n);u.writeFileSync(s,i,{mode:384}),this.ensureSecureFilePermissions(s)}async deleteCredentials(e){let t=B(e);try{u.existsSync(t)&&u.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=he(s)?s:null}catch{this.keytarModule=null}return this.keytarModule}getAccount(e){return`${ue}${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=`${de}${R.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 Q(t)?t:null}catch{return null}}},M=class{keychainStorage=null;fileStorage=new O;keychainAvailable=null;initPromise=null;shouldForceFileStorage(){return process.env[ge]?.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()&&(pe()&&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.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)}},g=new M,y={async saveAccessToken(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.accessToken=r,await g.setCredentials(t,s)},async getAccessToken(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.accessToken??null},async saveRefreshToken(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.refreshToken=r,await g.setCredentials(t,s)},async getRefreshToken(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.refreshToken??null},async saveEmail(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.email=r,await g.setCredentials(t,s)},async getEmail(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.email??null},async saveWorkspaceId(r,e){let t=o.getEffectiveProfileName(e),s=await g.getCredentials(t)??{};s.workspaceId=r,await g.setCredentials(t,s)},async getWorkspaceId(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.workspaceId??null},async saveAll(r,e){let t=o.getEffectiveProfileName(e);await g.setCredentials(t,r)},async getAll(r){let e=o.getEffectiveProfileName(r);return g.getCredentials(e)},async clear(r){let e=o.getEffectiveProfileName(r);await g.deleteCredentials(e)},async isLoggedIn(r){let e=o.getEffectiveProfileName(r);return(await g.getCredentials(e))?.accessToken!=null}};var K=class r{client;baseUrl;constructor(e,t){this.baseUrl=e||D(t),U().ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED="0",process.env.DEBUG&&console.log("[DEBUG] ApiClient: SSL certificate validation disabled")),this.client=ye.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}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,s){let n={limit:s?.limit??100};return s?.nextKey&&(n.nextKey=s.nextKey),s?.search&&(n.search=s.search),await this.client.get(`v1/workspaces/${t}/availableAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:n}).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 getTasks(e,t,s=20){return await this.client.get(`v1/workspaces/${t}/tasks`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:s}}).json()}async getMessages(e,t,s,n=50){return await this.client.get(`v1/workspaces/${t}/tasks/${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 downloadSkillCurrent(e,t,s){return await this.client.get(`v1/workspaces/${t}/skills/${s}/download`,{headers:{Authorization:`Bearer ${e}`}}).json()}async task(e,t,s){try{let n=await this.client.post(`v1/workspaces/${t}/tasks`,{headers:{Authorization:`Bearer ${e}`},json:s,timeout:6e4,throwHttpErrors:!1});if(!n.ok){let i=await n.text();throw new Error(`Task API failed (${n.status}): ${i}`)}return n}catch(n){throw n instanceof me?new TypeError("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 createTaskShare(e,t,s,n="public"){return await this.client.post(`v1/workspaces/${t}/tasks/${s}/shares`,{headers:{Authorization:`Bearer ${e}`},json:{visibility:n}}).json()}async getSharedTask(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 deleteTask(e,t,s){await this.client.delete(`v1/workspaces/${t}/tasks/${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,c=new Blob([s.buffer],{type:s.mimeType});return i.append("file",c,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 y.getAll(e);return t?{client:new r(void 0,e),accessToken:t.accessToken,workspaceId:t.workspaceId??null}:null}};function ke(){return process.env.ENTRYDESK_SANDBOX==="true"}function j(){if(!ke())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}}function ee(){let r=process.env.ENTRYDESK_TOKEN?.trim();if(!r)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:r,workspaceId:e}}import{execFile as we}from"child_process";import{setTimeout as ve}from"timers/promises";import{decodeJwt as Pe}from"jose";import Se,{HTTPError as Ae}from"ky";var I="entrydesk-cli",Ce="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 publishes:read publishes:write calendar:read calendar:write schedules:read schedules:write user:read user:write";function be(r){return new Promise((e,t)=>{let s=process.platform,n,i;switch(s){case"darwin":n="open",i=[r];break;case"win32":n="cmd",i=["/c","start","",r];break;default:n="xdg-open",i=[r];break}we(n,i,c=>{c?t(new Error(`Failed to open browser. Please manually visit: ${r}`,{cause:c})):e()})})}async function rt(r){let e=D(),t=te(),s=U(),n=process.env.NODE_TLS_REJECT_UNAUTHORIZED;s.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=Se.create({prefixUrl:e,timeout:3e4,hooks:{beforeError:[a=>(a.request?.headers&&(a.request.headers.delete("authorization"),a.request.headers.delete("Authorization")),a)]}}),c;try{c=await i.post("v1/oauth/device/code",{json:{client_id:I,scope:Ce}}).json()}catch(a){let k=a instanceof Error?a:new Error("Failed to request device code");throw r?.onError?.(k),k}let{device_code:S,user_code:d,expires_in:oe,interval:ae}=c,J=new URL("/oauth/device",t);J.searchParams.set("user_code",d);let q=J.toString();r?.onDeviceCodeReceived?.(d,q),r?.onBrowserOpening?.();try{await be(q)}catch(a){process.env.DEBUG&&console.error("[DEBUG] Failed to open browser:",a)}r?.onWaitingForAuthorization?.();let V=Math.max(ae,5)*1e3,ce=Date.now()+oe*1e3;for(;Date.now()<ce;){await ve(V);try{let a=await i.post("v1/oauth/token",{json:{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:S,client_id:I}}).json();r?.onAuthorized?.();let k={};try{k=Pe(a.access_token)}catch{}return{accessToken:a.access_token,refreshToken:a.refresh_token??void 0,email:k.email||"",scopes:a.scope.split(" ").filter(T=>T.length>0)}}catch(a){if(a instanceof Ae){let T;try{let X=await a.response.json();T=X.code||X.error}catch{continue}switch(T){case"authorization_pending":continue;case"slow_down":V+=5e3;continue;case"access_denied":throw new Error("Authorization denied by user",{cause:a});case"expired_token":throw new Error("Device code expired. Please try again.",{cause:a});default:throw new Error(`Authorization failed: ${T||"Unknown error"}`,{cause:a})}}let k=a instanceof Error?a:new Error("Unknown error during authorization");throw r?.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}}var m=class extends Error{code;constructor(e,t){super(t),this.code=e}};function Ee(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 Te(r,e=300){let s=Ee(r)?.exp;if(typeof s!="number")return!1;let n=Math.floor(Date.now()/1e3);return s-n<=e}async function re(r){let e=r.accessToken;if(!Te(e))return e;if(!r.refreshToken)throw await y.clear(),new m("session-expired","Session expired. Please run `entrydesk login` again.");try{let s=await new K().refreshOAuthToken({refreshToken:r.refreshToken,clientId:I});return await y.saveAccessToken(s.access_token),s.refresh_token&&await y.saveRefreshToken(s.refresh_token),s.access_token}catch{throw await y.clear(),new m("session-expired","Session expired. Please run `entrydesk login` again.")}}async function ct(){let r=j();if(r)return r.accessToken;let e=await y.getAll();if(!e?.accessToken)throw new m("not-logged-in","Not logged in. Run `entrydesk login` first.");return re(e)}async function lt(){let r=j();if(r)return{accessToken:r.accessToken,workspaceId:r.workspaceId};let e=ee();if(e)return e;let t=await y.getAll();if(!t?.accessToken)throw new m("not-logged-in","Not logged in. Run `entrydesk login` first.");if(!t.workspaceId)throw new m("no-workspace","No workspace selected. Run `entrydesk workspaces` first.");return{accessToken:await re(t),workspaceId:t.workspaceId}}var f=class extends Error{constructor(t,s=1,n){super(t);this.exitCode=s;this.cause=n;this.name="CLIError"}exitCode;cause};function ft(r){let e=!!process.env.DEBUG;r instanceof f&&(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 m&&(console.error(r.message),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof xe&&(console.error("Request timed out. Please check your connection and try again."),e&&r.stack&&console.error(r.stack),process.exit(1)),r instanceof Re&&(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 P="default",Ke=/^[A-Za-z0-9_-]+$/,z=null;function W(){return E.join(_e.homedir(),".entrydesk")}function ne(){return E.join(W(),"profiles")}function ie(){return E.join(W(),"profiles.json")}function $(r){return E.join(ne(),r)}function H(r){if(!p.existsSync(r))p.mkdirSync(r,{mode:448,recursive:!0});else try{p.chmodSync(r,448)}catch{}}function De(){H(W())}function L(){H(ne())}function Ue(){let r=ie();try{if(!p.existsSync(r))return null;let e=p.readFileSync(r,"utf-8");return JSON.parse(e)}catch{return null}}function b(r){De();let e=ie();p.writeFileSync(e,JSON.stringify(r,null,2),{mode:384});try{p.chmodSync(e,384)}catch{}}function Ie(r){let e=r.profiles?.length?Array.from(new Set(r.profiles)):[],t=r.currentProfile&&e.includes(r.currentProfile)?r.currentProfile:e[0]||P;return e.length===0&&e.push(P),e.includes(t)||e.unshift(t),{currentProfile:t,profiles:e}}function v(){let r=Ue();if(!r){let t={currentProfile:P,profiles:[P]};return b(t),L(),_(P),t}let e=Ie(r);return(e.currentProfile!==r.currentProfile||e.profiles.length!==r.profiles.length)&&b(e),L(),e}function A(r){if(!r)throw new f("Profile name is required.");if(!Ke.test(r))throw new f("Invalid profile name. Use letters, numbers, dash, or underscore.")}function x(r,e){if(!r.profiles.includes(e))throw new f(`Profile not found: ${e}`)}function se(r,e){if(r.profiles.includes(e))throw new f(`Profile already exists: ${e}`)}function _(r){L(),H($(r))}var o={DEFAULT_PROFILE:P,setOverrideProfile(r){z=r},getOverrideProfile(){return z},getProfileDir(r){return $(r)},getProfileConfigFile(r){return E.join(o.getProfileDir(r),"config.json")},getProfileCredentialsFile(r){return E.join(o.getProfileDir(r),"credentials.json")},getProfileNames(){return[...v().profiles]},getProfileCount(){return o.getProfileNames().length},getCurrentProfileName(){return v().currentProfile},getEffectiveProfileName(r){let e=v(),t=r||z||e.currentProfile;return A(t),x(e,t),t},ensureProfileExists(r){let e=v();A(r),x(e,r)},createProfile(r){A(r);let e=v();se(e,r);let t={currentProfile:e.currentProfile,profiles:[...e.profiles,r]};b(t),_(r)},deleteProfile(r){A(r);let e=v();if(x(e,r),e.profiles.length===1)throw new f("Cannot delete the last profile.");let t=e.profiles.filter(i=>i!==r),s=e.currentProfile;s===r&&(s=t.includes(P)?P:t[0]),b({currentProfile:s,profiles:t});try{p.rmSync(o.getProfileDir(r),{recursive:!0,force:!0})}catch{}return{currentProfile:s}},renameProfile(r,e){A(r),A(e);let t=v();x(t,r),se(t,e);let s=$(r),n=$(e);if(p.existsSync(s))try{p.renameSync(s,n)}catch(d){throw new f("Failed to rename profile directory.",1,d)}else _(e);let i=t.profiles.map(d=>d===r?e:d),c=t.currentProfile===r?e:t.currentProfile;return b({currentProfile:c,profiles:i}),{currentProfile:c}},setCurrentProfile(r){A(r);let e=v();x(e,r);let t={currentProfile:r,profiles:e.profiles};b(t),_(r)},ensureProfileDir:_};function $e(r){let e=o.getEffectiveProfileName(r);return o.getProfileConfigFile(e)}function l(r){let e=$e(r);try{if(!F.existsSync(e))return{};let t=F.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return{}}}function h(r,e){let t=o.getEffectiveProfileName(e);o.ensureProfileDir(t);let s=o.getProfileConfigFile(t);F.writeFileSync(s,JSON.stringify(r,null,2),{mode:384});try{F.chmodSync(s,384)}catch{}}var G={getApiUrl(r){return l(r).apiUrl??null},setApiUrl(r,e){let t=l(e);t.apiUrl=r,h(t,e)},clearApiUrl(r){let e=l(r);delete e.apiUrl,h(e,r)},getHubUrl(r){return l(r).hubUrl??null},setHubUrl(r,e){let t=l(e);t.hubUrl=r,h(t,e)},getAll(r){return l(r)},setAll(r,e){h(r,e)},set(r,e,t){let s=l(t);s[r]=e,h(s,t)},get(r,e){return l(e)[r]},unset(r,e){let t=l(e);delete t[r],h(t,e)},getDefaultModel(r){return l(r).model?.default??null},setDefaultModel(r,e){let t=l(e);t.model={...t.model,default:r},h(t,e)},getDefaultConnectorIds(r){return l(r).connectors?.defaults??null},setDefaultConnectorIds(r,e){let t=l(e);t.connectors={...t.connectors,defaults:r},h(t,e)},getCapabilities(r){return l(r).capabilities??null},setCapabilities(r,e){let t=l(e);t.capabilities={...t.capabilities,...r},h(t,e)},getLocalTools(r){return l(r).localTools??null},setLocalTools(r,e){let t=l(e);t.localTools={...t.localTools,...r},h(t,e)}};var Fe="https://api.entrydesk.com",Be="https://app.entrydesk.com",Oe=3100,Ne=300*1e3;function Y(r){return{apiUrl:G.getApiUrl(r)||process.env.ENTRYDESK_API_URL||Fe,hubUrl:G.getHubUrl(r)||process.env.ENTRYDESK_HUB_URL||Be,mcp:{httpPort:Oe},auth:{loginTimeout:Ne,ignoreSslErrors:process.env.ENTRYDESK_IGNORE_SSL_ERRORS==="true"||!1}}}function D(r){return Y(r).apiUrl}function te(r){return Y(r).hubUrl}function U(){return Y().auth}export{o as a,G as b,Y as c,D as d,te as e,U as f,y as g,K as h,I as i,rt as j,m as k,Te as l,re as m,ct as n,lt as o,f as p,ft as q};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{c as a,d as b,e as c,f as d}from"./chunk-
|
|
2
|
+
import{c as a,d as b,e as c,f as d}from"./chunk-QCYRC3HX.js";export{b as getApiUrl,d as getAuthConfig,a as getConfig,c as getHubUrl};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as f,b as s}from"./chunk-
|
|
2
|
+
import{a as f,b as s}from"./chunk-QCYRC3HX.js";var i=["apiUrl","hubUrl"];function l(e){return i.includes(e)}async function d(e){let n=e.action||"list",o=e.configKey,t=e.value,a=f.getEffectiveProfileName();if(n==="list"){let r=s.getAll(),c=Object.entries(r);if(e.json){console.log(JSON.stringify(r));return}if(console.log(`Profile: ${a}`),c.length===0){console.log("No configuration set."),console.log(`Available keys: ${i.join(", ")}`);return}console.log(`Configuration:
|
|
3
3
|
`);for(let[g,u]of c)console.log(` ${g}=${u}`);console.log(`
|
|
4
4
|
Available keys: ${i.join(", ")}`);return}if(n==="get"){o||(console.error("Error: key is required for get action"),process.exit(1)),l(o)||(console.error(`Error: Invalid key '${o}'. Valid keys: ${i.join(", ")}`),process.exit(1));let r=s.get(o);e.json?console.log(JSON.stringify({[o]:r??null})):console.log(r||"Not set");return}if(n==="set"){o||(console.error("Error: key is required for set action"),process.exit(1)),l(o)||(console.error(`Error: Invalid key '${o}'. Valid keys: ${i.join(", ")}`),process.exit(1)),t||(console.error("Error: value is required for set action"),process.exit(1)),s.set(o,t),console.log(`Set ${o}=${t}`);return}if(n==="unset"){o||(console.error("Error: key is required for unset action"),process.exit(1)),l(o)||(console.error(`Error: Invalid key '${o}'. Valid keys: ${i.join(", ")}`),process.exit(1)),s.unset(o),console.log(`Unset ${o}`);return}console.error(`Unknown action: ${n}`),process.exit(1)}export{d as runConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{c as i}from"./chunk-
|
|
2
|
+
import{c as i}from"./chunk-QCYRC3HX.js";import{Box as r,Text as e,render as l}from"ink";import{jsx as t,jsxs as n}from"react/jsx-runtime";function g(){l(t(a,{}))}function a(){let o=i();return n(r,{flexDirection:"column",children:[t(e,{bold:!0,children:"entrydesk config"}),t(e,{children:" "}),t(e,{children:"Manage CLI configuration"}),t(e,{children:" "}),t(e,{bold:!0,children:"Usage:"}),t(e,{children:" entrydesk config List all configuration"}),n(e,{children:[" entrydesk config get ","<key>"," Get a configuration value"]}),n(e,{children:[" ","entrydesk config set ","<key>"," ","<value>"," Set a configuration value"]}),n(e,{children:[" ","entrydesk config unset ","<key>"," Remove a configuration value"]}),t(e,{children:" "}),t(e,{bold:!0,children:"Available keys:"}),n(e,{children:[" apiUrl API server URL (default: ",o.apiUrl,")"]}),n(e,{children:[" hubUrl Hub server URL (default: ",o.hubUrl,")"]}),t(e,{children:" "}),t(e,{bold:!0,children:"Examples:"}),t(e,{children:" entrydesk config set apiUrl http://localhost:3200"}),t(e,{children:" entrydesk config get apiUrl"}),t(e,{children:" entrydesk config unset apiUrl"})]})}export{g as renderConfigHelp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{h as c,o as s,q as i}from"./chunk-
|
|
2
|
+
import{h as c,o as s,q as i}from"./chunk-QCYRC3HX.js";async function p(l){try{let n,t;try{let o=await s();n=o.accessToken,t=o.workspaceId}catch(o){let r=o instanceof Error?o.message:"Authentication failed";console.error(r),process.exit(1)}let a=new c,{connectors:e}=await a.getConnectors(n,t);if(l.json){console.log(JSON.stringify(e));return}if(e.length===0){console.log("No connectors found in this workspace.");return}console.log(`Connected Connectors (${e.length}):
|
|
3
3
|
`);for(let o of e){let r=o.connected?"connected":"disconnected";console.log(` ${o.name} (${r})`),console.log(` Provider: ${o.provider}`),console.log(` ID: ${o.id}`),console.log("")}}catch(n){i(n)}}export{p as runConnectors};
|
|
@@ -16,8 +16,8 @@ Commands:
|
|
|
16
16
|
connectors List connected connectors
|
|
17
17
|
tool List, get, or call MCP tools
|
|
18
18
|
profile Manage profiles
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
tasks List recent tasks or view messages
|
|
20
|
+
task Send a message or start interactive task
|
|
21
21
|
budget View or manage workspace budget
|
|
22
22
|
usage View current month usage statistics
|
|
23
23
|
mcp-server Start MCP server (stdio or HTTP)
|
|
@@ -27,24 +27,24 @@ Commands:
|
|
|
27
27
|
|
|
28
28
|
Global Options:
|
|
29
29
|
--json Output in JSON format (for scripting)
|
|
30
|
-
-i Interactive mode (for
|
|
30
|
+
-i Interactive mode (for task)
|
|
31
31
|
--profile Use a specific profile for this command
|
|
32
32
|
|
|
33
33
|
Login:
|
|
34
34
|
entrydesk login # Open browser login (OAuth Device Flow)
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
entrydesk
|
|
38
|
-
entrydesk
|
|
39
|
-
entrydesk
|
|
40
|
-
entrydesk
|
|
41
|
-
echo "Hello" | entrydesk
|
|
42
|
-
entrydesk
|
|
43
|
-
entrydesk
|
|
44
|
-
entrydesk
|
|
45
|
-
entrydesk
|
|
46
|
-
entrydesk
|
|
47
|
-
entrydesk
|
|
36
|
+
Task:
|
|
37
|
+
entrydesk task -m "Hello" --model <model> # Send with model
|
|
38
|
+
entrydesk task -m "Hello" -a <agent> # Send with agent
|
|
39
|
+
entrydesk task -c 1 -m "Follow up" # Continue recent task
|
|
40
|
+
entrydesk task -i # Interactive mode
|
|
41
|
+
echo "Hello" | entrydesk task --model <m> # Pipe input from stdin
|
|
42
|
+
entrydesk task -m "Hi" --model <m> --plain # Plain text output
|
|
43
|
+
entrydesk task -m "Hi" --model <m> --output stream-json # Stream JSON
|
|
44
|
+
entrydesk task -i --web-search # Enable web search
|
|
45
|
+
entrydesk task -i --no-sandbox # Disable sandbox
|
|
46
|
+
entrydesk task -i --no-file-system # Disable local file operations
|
|
47
|
+
entrydesk task -i --connectors id1,id2 # Use specific connectors
|
|
48
48
|
|
|
49
49
|
MCP Server:
|
|
50
50
|
entrydesk mcp-server # Start stdio server
|
|
@@ -74,13 +74,13 @@ Usage:
|
|
|
74
74
|
entrydesk usage --limit 10 --sort-by cost # Top 10 by cost
|
|
75
75
|
entrydesk usage --json # Get usage as JSON
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
entrydesk
|
|
79
|
-
entrydesk
|
|
80
|
-
entrydesk
|
|
81
|
-
entrydesk
|
|
82
|
-
entrydesk
|
|
83
|
-
entrydesk
|
|
77
|
+
Tasks:
|
|
78
|
+
entrydesk tasks # List recent tasks
|
|
79
|
+
entrydesk tasks 1 # View task #1 messages
|
|
80
|
+
entrydesk tasks <uuid> # View task by ID
|
|
81
|
+
entrydesk tasks --share <shareId> # View shared task by share ID
|
|
82
|
+
entrydesk tasks -s <shareId> # Short form for --share
|
|
83
|
+
entrydesk tasks --share <id> --json # Get shared task as JSON
|
|
84
84
|
|
|
85
85
|
Examples:
|
|
86
86
|
$ entrydesk login
|
|
@@ -101,17 +101,17 @@ Examples:
|
|
|
101
101
|
$ entrydesk skills
|
|
102
102
|
$ entrydesk skills upload ./my-skill.zip
|
|
103
103
|
$ entrydesk skills upload ./my-skill-folder
|
|
104
|
-
$ entrydesk
|
|
105
|
-
$ entrydesk
|
|
106
|
-
$ entrydesk
|
|
107
|
-
$ entrydesk
|
|
108
|
-
$ entrydesk
|
|
109
|
-
$ entrydesk
|
|
104
|
+
$ entrydesk task -m "Hello" --model gemini-2.5-flash-lite
|
|
105
|
+
$ entrydesk tasks # List recent tasks
|
|
106
|
+
$ entrydesk tasks 1 # View task #1 messages
|
|
107
|
+
$ entrydesk task -c 1 -m "Tell me more" # Continue task #1
|
|
108
|
+
$ entrydesk tasks 0 --output stream-json # Stream recent task as JSON
|
|
109
|
+
$ entrydesk tasks --share <shareId> # View shared task
|
|
110
110
|
|
|
111
111
|
Piping:
|
|
112
|
-
$ echo "Explain this code" | entrydesk
|
|
113
|
-
$ cat file.txt | entrydesk
|
|
114
|
-
$ entrydesk
|
|
112
|
+
$ echo "Explain this code" | entrydesk task --model gemini-2.5-flash-lite
|
|
113
|
+
$ cat file.txt | entrydesk task -c 1 # Pipe file content
|
|
114
|
+
$ entrydesk task -m "Hi" --model <m> > out.txt # Save to file
|
|
115
115
|
|
|
116
116
|
Usage Examples:
|
|
117
117
|
$ entrydesk usage # Show all users, sorted by cost
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as l,q as p}from"./chunk-
|
|
2
|
+
import{a as l,q as p}from"./chunk-QCYRC3HX.js";function u(s,f,d=!1){let r={},e={};for(let a=d?0:1;a<s.length;a++){let t=s[a];if(t==="--json")r.json=!0;else if(t==="--help"||t==="-h")r.help=!0;else if(t==="--profile")r.profile=s[++a];else switch(f){case"login":break;case"task":if(t==="-m"||t==="--message")e.message=s[++a];else if(t==="-a"||t==="--agent")e.agentId=s[++a];else if(t==="--model")e.model=s[++a];else if(t==="--connectors"){let i=s[++a];e.connectors=i?.split(",").map(n=>n.trim())}else t==="-i"||t==="--interactive"?e.interactive=!0:t==="--full-output"?e.fullOutput=!0:t==="-c"||t==="--continue"?e.continue=parseInt(s[++a],10):t==="--plain"?e.plain=!0:t==="--output"?e.output=s[++a]:t==="--sandbox"?e.sandbox=!0:t==="--no-sandbox"?e.noSandbox=!0:t==="--web-search"?e.webSearch=!0:t==="--image-gen"?e.imageGen=!0:t==="--chart"?e.chart=!0:t==="--file-system"?e.fileSystem=!0:t==="--no-file-system"?e.noFileSystem=!0:t==="--dangerously-auto-approve-tools"&&(e.dangerouslyAutoApproveTools=!0);break;case"agents":if(t==="--name")e.name=s[++a];else if(t==="--description")e.description=s[++a];else if(t==="--system-prompt")e.systemPrompt=s[++a];else if(t==="--model-id")e.modelId=s[++a];else if(t==="--connector-ids"){let i=s[++a];e.connectorIds=i?.split(",").map(n=>n.trim()).filter(Boolean)}else if(t==="--capabilities"){let i=s[++a];e.capabilities=i?.split(",").map(n=>n.trim()).filter(Boolean)}else if(t==="--conversation-starters"){let i=s[++a];e.conversationStarters=i?.split(",").map(n=>n.trim()).filter(Boolean)}else if(t==="--tools"){let i=s[++a];e.tools=i?.split(",").map(n=>n.trim()).filter(Boolean)}else if(t==="--icon-id")e.iconId=s[++a];else if(t==="--limit"){let i=parseInt(s[++a],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++a];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:t.startsWith("-")||(e.action?e.agentId=t:e.action=t);break;case"skills":t==="--force"?e.force=!0:t==="--me"||t==="--mine"?e.createdBy="me":t.startsWith("-")||(e.action?e.configKey=t:e.action=t);break;case"schedules":if(t==="--name")e.name=s[++a];else if(t==="--prompt")e.prompt=s[++a];else if(t==="--agent-id")e.agentId=s[++a];else if(t==="--starts-at")e.startsAt=s[++a];else if(t==="--utc-offset")e.utcOffset=s[++a];else if(t==="--repeat-type")e.repeatType=s[++a];else if(t==="--every")e.every=parseInt(s[++a],10);else if(t==="--time")e.time=s[++a];else if(t==="--days-of-week"){let i=s[++a];e.daysOfWeek=i?.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n))}else if(t==="--days-of-month"){let i=s[++a];e.daysOfMonth=i?.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n))}else t==="--last-day-of-month"?e.lastDayOfMonth=!0:t.startsWith("-")||(e.action?e.scheduleId=t:e.action=t);break;case"config":!e.action&&!t.startsWith("-")?e.action=t:!e.configKey&&!t.startsWith("-")?e.configKey=t:!e.value&&!t.startsWith("-")&&(e.value=t);break;case"profile":!e.action&&!t.startsWith("-")?e.action=t:!e.name&&!t.startsWith("-")?e.name=t:!e.value&&!t.startsWith("-")&&(e.value=t);break;case"tasks":t==="--share"||t==="-s"?e.shareId=s[++a]:t==="--full-output"?e.fullOutput=!0:t==="--output"?e.output=s[++a]:!e.taskId&&!t.startsWith("-")&&(e.taskId=t);break;case"budget":!e.action&&!t.startsWith("-")?e.action=t:!e.configKey&&!t.startsWith("-")&&(e.configKey=t);break;case"usage":if(t==="--limit")e.limit=parseInt(s[++a],10);else if(t==="--sort-by"){let i=s[++a];(i==="cost"||i==="operations")&&(e.sortBy=i)}break;case"mcp-server":t==="--http"?e.http=!0:(t==="-p"||t==="--port")&&(e.port=parseInt(s[++a],10));break;case"tool":t==="-i"||t==="--input"?e.input=s[++a]:t==="-f"||t==="--input-file"?e.inputFile=s[++a]:t==="-p"||t==="--prefix"?e.prefix=s[++a]:t.startsWith("-")||(e.action?e.name||(e.name=t):e.action=t);break;case"workspaces":!e.action&&!t.startsWith("-")&&(e.action=t);break;default:break}}switch(f){case"login":return{command:"login",...r,...e};case"logout":return{command:"logout",...r,...e};case"status":return{command:"status",...r,...e};case"workspaces":return{command:"workspaces",...r,...e};case"agents":return{command:"agents",...r,...e};case"models":return{command:"models",...r,...e};case"connectors":return{command:"connectors",...r,...e};case"skills":return{command:"skills",...r,...e};case"schedules":return{command:"schedules",...r,...e};case"config":return{command:"config",...r,...e};case"profile":return{command:"profile",...r,...e};case"task":return{command:"task",...r,...e};case"tasks":return{command:"tasks",...r,...e};case"budget":return{command:"budget",...r,...e};case"usage":return{command:"usage",...r,...e};case"mcp-server":return{command:"mcp-server",...r,...e};case"tool":return{command:"tool",...r,...e};case"version":return{command:"version",...r,...e};default:return{command:"help",...r,...e}}}var c=process.argv.slice(2);if(c[0]==="--help"||c[0]==="-h"){let{printHelp:s}=await import("./help-NESOCXU4.js");s(),process.exit(0)}if(c[0]==="--version"||c[0]==="-v"){let{printVersion:s}=await import("./version-P7RLOGGP.js");s(),process.exit(0)}var m=!c[0]||c[0].startsWith("-"),k=m?"task":c[0],o=u(c,k,m);m&&o.command==="task"&&(o.interactive=!0);async function h(){try{if(o.command!=="profile"){let s=o.profile||l.getCurrentProfileName();l.ensureProfileExists(s),l.setOverrideProfile(s)}switch(o.command){case"login":{let{runLogin:s}=await import("./login-XMQUQC6W.js");await s(o);break}case"logout":{let{runLogout:s}=await import("./logout-RLZWCE3X.js");await s(o);break}case"status":{let{runStatus:s}=await import("./status-DCA3JEPN.js");await s(o);break}case"workspaces":{let{runWorkspaces:s}=await import("./workspaces-DZMNMF5V.js");await s(o);break}case"agents":{let{runAgents:s}=await import("./agents-F6WZ75FO.js");await s(o);break}case"models":{let{runModels:s}=await import("./models-UVC4PPAL.js");await s(o);break}case"connectors":{let{runConnectors:s}=await import("./connectors-FUAOLPGH.js");await s(o);break}case"skills":{let{runSkills:s}=await import("./skills-YESN74QW.js");await s(o);break}case"schedules":{let{runSchedules:s}=await import("./schedules-ZUXF7C6D.js");await s(o);break}case"tasks":{let{runTasks:s}=await import("./tasks-CWQXUKK6.js");await s(o);break}case"budget":{let{runBudget:s}=await import("./budget-T5N2N4MP.js");await s(o);break}case"usage":{let{runUsage:s}=await import("./usage-NDVCWDNA.js");await s(o);break}case"config":{if(o.action==="help"||c[1]==="--help"){let{renderConfigHelp:s}=await import("./config-help-LGEAPZUD.js");s()}else{let{runConfig:s}=await import("./config-MEIIXIQS.js");await s(o)}break}case"profile":{let{runProfile:s}=await import("./profile-SNZTVXLY.js");await s(o);break}case"task":{if(c[1]==="--help"||c[1]==="-h"){let{printHelp:s}=await import("./help-NESOCXU4.js");s()}else{let{runTask:s}=await import("./task-LFS7JM7C.js");await s(o)}break}case"mcp-server":{let{startMcpServer:s}=await import("./mcp-47MJFVKB.js");await s({mode:o.http?"http":"stdio",port:o.port});break}case"tool":{let{runTool:s}=await import("./tool-RAYVZNS2.js");await s(o);break}case"version":{let{printVersion:s}=await import("./version-P7RLOGGP.js");s();break}default:{let{printHelp:s}=await import("./help-NESOCXU4.js");s();break}}}catch(s){p(s)}}h();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{g as l,h as c,j as t}from"./chunk-
|
|
2
|
+
import{g as l,h as c,j as t}from"./chunk-QCYRC3HX.js";async function m(e){if(process.env.DEBUG){let{getApiUrl:i,getHubUrl:s}=await import("./config-3R3GDZWB.js");console.log(`[DEBUG] Hub URL: ${s()}`),console.log(`[DEBUG] API URL: ${i()}`)}let o=await t({onDeviceCodeReceived:(i,s)=>{e.json||(console.log(""),console.log("To authenticate, please:"),console.log(""),console.log(` 1. Visit: ${s}`),console.log(` 2. Enter code: ${i}`),console.log(""))},onBrowserOpening:()=>{e.json||console.log("Opening browser...")},onWaitingForAuthorization:()=>{e.json||console.log("Waiting for authorization...")},onAuthorized:()=>{e.json||console.log("Authorization successful!")}}),r=new c,{workspaces:a}=await r.getWorkspaces(o.accessToken),n=a[0];await l.saveAll({accessToken:o.accessToken,refreshToken:o.refreshToken,email:o.email,workspaceId:n?.id}),e.json?console.log(JSON.stringify({email:o.email,workspaceId:n?.id,workspaceName:n?.name})):(console.log(`Logged in as ${o.email}`),n&&console.log(`Workspace: ${n.name}`))}export{m as runLogin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{g as r,h as e,i as t,q as n}from"./chunk-
|
|
2
|
+
import{g as r,h as e,i as t,q as n}from"./chunk-QCYRC3HX.js";async function f(i){try{let o=await r.getAll();if(!o){console.log("Not logged in");return}try{o.refreshToken&&await new e().revokeOAuthToken({token:o.refreshToken,clientId:t})}catch{}await r.clear(),console.log("Logged out successfully")}catch(o){n(o)}}export{f as runLogout};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{c as m,g as u,l as y,m as w,o as f}from"./chunk-
|
|
2
|
+
import{c as m,g as u,l as y,m as w,o as f}from"./chunk-QCYRC3HX.js";import h from"http";import{stderr as T}from"process";import{Client as k}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as C}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{Server as v}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as P}from"@modelcontextprotocol/sdk/server/stdio.js";import{StreamableHTTPServerTransport as A}from"@modelcontextprotocol/sdk/server/streamableHttp.js";import{CallToolRequestSchema as O,ListToolsRequestSchema as E}from"@modelcontextprotocol/sdk/types.js";function a(c){T.write(`${c}
|
|
3
3
|
`)}async function g(c,e,o){let r=new k({name:"entrydesk-cli-proxy",version:"1.0.0"}),i=new URL(`${c}/v1/workspaces/${o}/mcp`),t=new C(i,{requestInit:{headers:{Authorization:`Bearer ${e}`}}});return await r.connect(t),r}function S(c){let e=new v({name:"entrydesk-cli",version:"1.0.0"},{capabilities:{tools:{}}});return e.setRequestHandler(E,async()=>({tools:(await(await c()).listTools()).tools})),e.setRequestHandler(O,async o=>{let{name:r,arguments:i}=o.params,n=await(await c()).callTool({name:r,arguments:i}),l=Array.isArray(n.content)?[...n.content]:[];return n.structuredContent&&l.push({type:"text",text:JSON.stringify(n.structuredContent,null,2)}),{content:l,structuredContent:n.structuredContent,isError:n.isError}}),e}async function H(c,e,o){let r=h.createServer(async(i,t)=>{if(i.method==="OPTIONS"){t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST, DELETE, OPTIONS"),t.setHeader("Access-Control-Allow-Headers","Content-Type, Accept"),t.writeHead(204),t.end();return}if(i.url!=="/mcp"){t.writeHead(404,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Not found"}));return}let n=S(c),l=new A({sessionIdGenerator:void 0});if(t.setHeader("Access-Control-Allow-Origin","*"),t.on("close",()=>{l.close(),n.close()}),await n.connect(l),i.method==="POST"){let p="";i.on("data",s=>{p+=s.toString()}),i.on("end",async()=>{try{let s=JSON.parse(p);await l.handleRequest(i,t,s)}catch{t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid JSON"}))}})}else await l.handleRequest(i,t)});r.listen(o,()=>{a(`EntryDesk MCP server running at http://localhost:${o}/mcp`),a("Press Ctrl+C to stop")}),process.on("SIGINT",async()=>{a(`
|
|
4
4
|
Shutting down...`),r.close(),await e(),process.exit(0)}),process.on("SIGTERM",async()=>{r.close(),await e(),process.exit(0)})}async function x(c,e){let o=S(c),r=new P;r.onclose=async()=>{await e()},await o.connect(r)}async function L(c={mode:"stdio"}){process.on("unhandledRejection",e=>{console.error("[entrydesk-mcp] Unhandled rejection:",e)}),process.on("uncaughtException",e=>{console.error("[entrydesk-mcp] Uncaught exception:",e)});try{a("[entrydesk-mcp] Starting MCP server...");let e,o;try{let s=await f();e=s.accessToken,o=s.workspaceId}catch(s){let d=s instanceof Error?s.message:"Authentication failed";console.error(d),process.exit(1)}let{apiUrl:r,mcp:i}=m();a(`[entrydesk-mcp] Connecting to ${r}...`),a(`[entrydesk-mcp] Workspace: ${o}`);let t=await g(r,e,o);a("[entrydesk-mcp] Connected to EntryDesk API");let n=null,l=async()=>y(e)?n||(n=(async()=>{a("[entrydesk-mcp] Token expiring soon, refreshing...");let s=await u.getAll();if(!s?.accessToken)throw new Error("Not logged in. Please run `entrydesk login` again.");let d=await w(s);if(d!==e){e=d;try{await t.close()}catch{}t=await g(r,e,o),a("[entrydesk-mcp] Token refreshed, reconnected")}return t})().finally(()=>{n=null}),n):t,p=async()=>{try{await t.close()}catch{}};if(c.mode==="http"){let s=c.port??i.httpPort;await H(l,p,s)}else a("[entrydesk-mcp] Starting stdio server..."),await x(l,p),a("[entrydesk-mcp] Stdio server started")}catch(e){console.error("[entrydesk-mcp] Fatal error:",e),process.exit(1)}}export{L as startMcpServer};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{h as n,o as t,q as l}from"./chunk-
|
|
2
|
+
import{h as n,o as t,q as l}from"./chunk-QCYRC3HX.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.getModels(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
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};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as t,b as u,g as m,p as f,q as d}from"./chunk-
|
|
2
|
+
import{a as t,b as u,g as m,p as f,q as d}from"./chunk-QCYRC3HX.js";function h(){console.log(`
|
|
3
3
|
Usage: entrydesk profile [list|show|current|create|use|delete|rename|clone] [args]
|
|
4
4
|
|
|
5
5
|
Commands:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{h as S,o as z,q as I}from"./chunk-
|
|
2
|
+
import{h as S,o as z,q as I}from"./chunk-QCYRC3HX.js";import U from"crypto";import g from"fs";import i from"fs/promises";import b from"os";import o from"path";import{Readable as A}from"stream";import{pipeline as E}from"stream/promises";import j from"adm-zip";import N from"archiver";function D(){console.log(`
|
|
3
3
|
Usage: entrydesk skills [list|upload|delete|download] [options]
|
|
4
4
|
|
|
5
5
|
Commands:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as i,b as r,g as c,h as a,k as g,n as f,q as p}from"./chunk-
|
|
2
|
+
import{a as i,b as r,g as c,h as a,k as g,n as f,q as p}from"./chunk-QCYRC3HX.js";async function A(s){try{let o=i.getEffectiveProfileName(),e=await c.getAll(),n={model:r.getDefaultModel(),connectors:r.getDefaultConnectorIds(),capabilities:r.getCapabilities()};if(!e){s.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 t;if(e.workspaceId)try{let l=new a,d=await f(),{workspaces:m}=await l.getWorkspaces(d);t=m.find(k=>k.id===e.workspaceId)?.name}catch(l){if(l instanceof g){s.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}}s.json?console.log(JSON.stringify({loggedIn:!0,profile:o,email:e.email,workspaceId:e.workspaceId,workspaceName:t,defaults:n})):(console.log(`Profile: ${o}`),console.log(`Logged in as ${e.email}`),t&&console.log(`Workspace: ${t}`),e.workspaceId&&console.log(`Workspace ID: ${e.workspaceId}`))}catch(o){p(o)}}export{A as runStatus};
|