@entrydesk/cli 1.8.0 → 1.8.1

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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -195,7 +195,7 @@ ID: ${u.id}`)}}}else if(f==="connectors"){let l=Array.from(tt);v(l.length>0?l:vo
195
195
  `)||st.length===0)return;if(We===null){mt(e);let u=st.length-1;Ve(u),t(st[u]);return}let l=Math.max(0,We-1);Ve(l),t(st[l]);return}if(m.downArrow){if(e.includes(`
196
196
  `)||We===null)return;if(We>=st.length-1){Ve(null),t(zt);return}let l=We+1;Ve(l),t(st[l])}}),{suggestions:q,suggestionIndex:$e,showSuggestions:ne,argMode:f,argItems:S,argIndex:U,selectedConnectorIds:tt,selectedCapabilities:De,deleteConfirmMode:rt,handleInputChange:qt,handleSubmit:Yt}}import{useCallback as Ft,useRef as Lr,useState as Rr}from"react";function ts({credentials:e,currentModel:t,modelProviders:n,onUploadSuccess:s,onUploadError:o}){let[i,r]=Rr([]),a=Lr(0),c=Ft(y=>{if(!(!Array.isArray(n)||n.length===0)){for(let k of n)if(k.models.some(F=>F.id===y))return k.id;return n[0]?.id}},[n]),d=Ft(async y=>{if(!e){o?.(y.filename,"Not logged in");return}if(!Array.isArray(n)||n.length===0){o?.(y.filename,"Model providers not loaded yet. Please wait and try again.");return}let k=t?c(t):n[0]?.id;if(!k){o?.(y.filename,"No model provider available");return}let _=`file-${++a.current}`;r(F=>[...F,{id:_,filename:y.filename,mimeType:y.mimeType,status:"uploading"}]);try{let K=await new H().uploadFile(e.accessToken,e.workspaceId,y,k);r(ie=>ie.map(Y=>Y.id===_?{...Y,status:"uploaded",fileId:K.id}:Y)),s?.(y.filename)}catch(F){let K=F instanceof Error?F.message:"Upload failed";r(ie=>ie.map(Y=>Y.id===_?{...Y,status:"error",error:K}:Y)),o?.(y.filename,K)}},[e,t,c,n,s,o]),$=Ft(y=>{r(k=>k.filter(_=>_.id!==y))},[]),C=Ft(()=>{r([])},[]),x=Ft(()=>i.filter(y=>y.status==="uploaded"&&y.fileId).map(y=>y.fileId),[i]),v=i.some(y=>y.status==="uploading"),h=i.length>0;return{pendingFiles:i,addFile:d,removeFile:$,clearFiles:C,getUploadedFileIds:x,hasUploadingFiles:v,hasFiles:h}}import{jsx as X,jsxs as ue}from"react/jsx-runtime";var jr=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],Fr=[jo,jo,Uo,Uo,dt,dt,dt,dt],ns=jr.map((e,t)=>`${Fr[t]??dt}${e}${se}`).join(`
197
197
  `),Br=`${dt}EntryDesk${se}`,Wr=500;function Mr(e){let t="",n=0;for(;n<e.length;){if(e.charCodeAt(n)===27&&e[n+1]==="["){for(n+=2;n<e.length;){let s=e.charCodeAt(n);if(s>=64&&s<=126){n+=1;break}n+=1}continue}t+=e[n],n+=1}return t}function Jr(e){let t=Mr(e);return Math.max(...t.split(`
198
- `).map(n=>n.length))}function Gr(e){let t=Jr(ns);return e>=t?ns:Br}function ss({agentId:e,model:t,message:n,chatId:s,chatTitle:o,connectorIds:i,enableSandbox:r=!0,enableWebSearch:a=!1,enableImageGeneration:c=!1,enableChart:d=!1,enableFileSystem:$=!0}){let C=process.stdout.columns??80,x=Gr(C),v=os(null),h=Rn(s,o),{state:y,setState:k,messages:_,setMessages:F,input:K,setInput:ie,chatId:Y,setChatId:Ce,currentChatTitle:j,setCurrentChatTitle:A,hasPersistedChat:N,setHasPersistedChat:R,credentials:W,setCredentials:E,currentResponse:me,setCurrentResponse:D,fullOutput:p,setFullOutput:re,addSystemMessage:we,startNewChat:z}=h,{credentials:P}=jn(k);uo(()=>{P&&!W&&E(P)},[P,W,E]);let{availableConnectors:ee,availableModels:Q,availableAgents:pe,modelProviders:le,loading:M}=Fn(W),{currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:$e,activeConnectorIds:B,setActiveConnectorIds:ne}=zn(t,e,i),L=os(!1);uo(()=>{if(!L.current){if(L.current=!0,!t&&!e){let b=oe.getDefaultModel();b&&q(b)}if(!i&&!e){let b=oe.getDefaultConnectorIds();b&&ne(b.length>0?b:void 0)}}},[t,e,i,q,ne]);let{currentAgentDetails:f}=Kn(de,W),{sandbox:w,setSandbox:S,webSearch:te,setWebSearch:U,imageGeneration:xe,setImageGeneration:tt,chart:ot,setChart:De,fileSystem:nt,setFileSystem:bo,capabilityLabelMap:Vt}=Vn(r,a,c,d,$),{pendingFiles:je,addFile:gt,removeFile:He,clearFiles:Kt,getUploadedFileIds:st,hasUploadingFiles:xo,hasFiles:We}=ts({credentials:W,currentModel:Z,modelProviders:le,onUploadSuccess:b=>{we(`\u2713 Attached: ${b}`)},onUploadError:(b,O)=>{we(`\u2717 Failed to upload ${b}: ${O}`)}}),{sendMessage:Ve}=Mn({chatId:Y,credentials:W,currentAgentId:de,currentModel:Z,activeConnectorIds:B,sandbox:w,webSearch:te,imageGeneration:xe,chart:ot,localTools:nt,fullOutput:p,setMessages:F,setState:k,setCurrentResponse:D,setCredentials:E,setHasPersistedChat:R,getFileIds:st,clearFiles:Kt}),zt=Jo(b=>{z(b),D("")},[z]),[mt,ut]=Ur(!1),rt=Jo(async b=>{let O=b.text.trim(),ge=ao(O);if(/^https?:\/\//.test(ge))return;if(await _n(O)&&En(ge)){let ce=await Dn(O);ce&&(b.preventDefault(),await gt(ce))}},[gt]),ht=Jo(async()=>{if(!(mt||y.status!=="ready")){if(M||le.length===0){we("Please wait for resources to load before pasting images.");return}we("Reading clipboard..."),ut(!0);try{let b=await Nn();if(b){let O=`clipboard-${Date.now()}.png`;we(`Uploading: ${O} (${Math.round(b.buffer.length/1024)}KB)`),await gt({buffer:b.buffer,filename:O,mimeType:b.mime})}else we("No image found in clipboard. Copy an image first.")}catch(b){let O=b instanceof Error?b.message:"Failed to read clipboard";we(`Clipboard error: ${O}`)}finally{ut(!1)}}},[gt,we,mt,y.status,M,le.length]),{suggestions:yt,suggestionIndex:wt,showSuggestions:Ne,argMode:he,argItems:Ke,argIndex:kt,selectedConnectorIds:qt,selectedCapabilities:Pt,deleteConfirmMode:Yt,handleInputChange:I,handleSubmit:m}=es({input:K,setInput:ie,chatId:Y,setChatId:Ce,currentChatTitle:j,setCurrentChatTitle:A,currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:$e,currentAgentDetails:f,setCurrentAgentDetails:()=>{},activeConnectorIds:B,setActiveConnectorIds:ne,sandbox:w,setSandbox:S,webSearch:te,setWebSearch:U,imageGeneration:xe,setImageGeneration:tt,chart:ot,setChart:De,fileSystem:nt,setFileSystem:bo,availableModels:Q,availableAgents:pe,availableConnectors:ee,messages:_,hasPersistedChat:N,setHasPersistedChat:R,setMessages:F,addSystemMessage:we,startNewChat:zt,sendMessage:Ve,setFullOutput:re,credentials:W,setCredentials:E,setState:k,defaultCapabilities:{sandbox:r,webSearch:a,imageGeneration:c,chart:d,fileSystem:$},capabilityLabelMap:Vt,hasUploadingFiles:xo});if(Wo((b,O)=>{(O.ctrl||O.meta)&&b==="v"&&ht()},{isActive:y.status==="ready"&&!he}),Wo((b,O)=>{if(!O.escape)return;let ge=Date.now(),J=v.current;v.current=ge,!(!J||ge-J>Wr)&&(he||Ne||(v.current=null,We&&Kt(),K.length>0&&I("")))},{isActive:y.status==="ready"}),Wo((b,O)=>{O.return&&(zt("Started a new chat."),k({status:"ready"}))},{isActive:y.status==="error"}),uo(()=>{if(W&&!M&&y.status==="loading")if(!Z&&!de){let b=oe.getDefaultModel(),O=b&&Q.some(J=>J.id===b),ge=O?b:Q[0]?.id;ge?(O||oe.setDefaultModel(ge),q(ge),k({status:"ready"})):pe.length===0?k({status:"no-model"}):k({status:"ready"})}else k({status:"ready"})},[W,M,Z,de,Q,pe,y.status,q,k]),uo(()=>{n&&W&&y.status==="ready"&&Ve(n)},[W,n]),y.status==="loading")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),ue(Ie,{children:[X(V,{color:"cyan",children:X(Mo,{type:"dots"})}),X(V,{children:" Initializing chat..."})]})]});if(y.status==="not-logged-in")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),X(V,{color:"yellow",children:"Not logged in"}),X(V,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if(y.status==="no-workspace")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),X(V,{color:"yellow",children:"No workspace selected"}),X(V,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if(y.status==="no-model")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),X(V,{color:"yellow",children:"No model or agent specified"}),s&&X(V,{dimColor:!0,children:"Could not determine the model used in this chat."}),X(V,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),X(V,{dimColor:!0,children:"Example: entrydesk chat -c 1 -i --model gemini-2.5-flash-lite"})]});if(y.status==="error")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),ue(V,{color:"red",children:["Error: ",y.message]}),X(V,{dimColor:!0,children:"Press Enter to start a new chat, or Ctrl+C to exit"})]});let l=de?f?f.connectors&&f.connectors.length>0?f.connectors.map(b=>b.name).join(", "):"none":"loading...":B&&B.length>0?ee.filter(b=>B.includes(b.id)).map(b=>b.name).join(", ")||`${B.length} connector(s)`:"none",u=[];if(de)if(f?.capabilities)for(let b of f.capabilities)u.push(Vt.get(b)??b);else u.push("loading...");else w&&u.push("Sandbox"),te&&u.push("Web"),xe&&u.push("Image"),ot&&u.push("Chart");nt&&u.push("FileSystem");let g=G.getCurrentProfileName(),T=g!=="default";return ue(Ie,{flexDirection:"column",children:[ue(Ie,{marginBottom:1,flexDirection:"column",children:[X(V,{children:x}),ue(Ie,{children:[X(V,{bold:!0,color:"cyan",children:j?`Continuing: ${j}`:"EntryDesk CLI"}),ue(V,{dimColor:!0,children:[" v","1.8.0"]}),T&&ue(V,{color:"magenta",children:[" [",g,"]"]}),X(V,{dimColor:!0,children:" (type /help for commands)"})]})]}),_.map((b,O)=>{let ge=b.parts&&p?ft(b.parts,!0):b.content,J=b.role==="user"?"green":b.role==="system"?"yellow":"blue",ce=b.role==="user"?"You":b.role==="system"?"System":"Assistant";return ue(Ie,{flexDirection:"column",marginBottom:1,children:[ue(V,{bold:!0,color:J,children:[ce,":"]}),X(Ro,{text:ge})]},O)}),me&&ue(Ie,{flexDirection:"column",marginBottom:1,children:[X(V,{bold:!0,color:"blue",children:"Assistant:"}),X(Ro,{text:me})]}),y.status==="ready"&&X(pn,{suggestions:yt,activeIndex:wt,visible:Ne}),y.status==="ready"&&he&&X(fn,{items:Ke,activeIndex:kt,pageSize:he==="agent"||he==="skills"||he==="model"?5:10,selectedIds:he==="connectors"?qt:he==="capabilities"?Pt:void 0,multiSelect:he==="connectors"||he==="capabilities",visible:!0,title:he==="model"?"Select model:":he==="agent"?"Select agent:":he==="skills"?"Select skill:":he==="connectors"?"Select connectors:":he==="capabilities"?"Select capabilities:":"Select chat:"}),y.status==="sending"&&!me?ue(Ie,{children:[X(V,{color:"cyan",children:X(Mo,{type:"dots"})}),X(V,{children:" Thinking..."})]}):y.status==="ready"&&!he?ue(Ie,{flexDirection:"column",children:[Yt&&X(Ie,{marginBottom:1,children:X(V,{color:"yellow",children:"\u26A0\uFE0F Delete this chat? (y/N) "})}),We&&!Yt&&ue(Ie,{marginBottom:1,flexDirection:"row",gap:1,children:[X(V,{dimColor:!0,children:"Attachments:"}),je.map((b,O)=>ue(V,{children:[b.status==="uploading"?ue(V,{color:"yellow",children:[X(Mo,{type:"dots"})," ",b.filename]}):b.status==="error"?ue(V,{color:"red",children:["\u2717 ",b.filename]}):ue(V,{color:"green",children:["\u2713 ",b.filename]}),O<je.length-1&&X(V,{children:", "})]},b.id))]}),ue(Ie,{children:[X(V,{color:"green",children:"> "}),X(xn,{value:K,onChange:I,onSubmit:m,onPaste:rt,leadingOffset:2,multiline:!0})]})]}):null,ue(Ie,{marginTop:1,flexDirection:"column",children:[ue(Ie,{gap:2,children:[ue(V,{children:[X(V,{dimColor:!0,children:"Model: "}),X(V,{color:"magenta",children:de?f?.model?.name||"loading...":Q.find(b=>b.id===Z)?.name||Z||"none"})]}),ue(V,{children:[X(V,{dimColor:!0,children:"Connectors: "}),X(V,{color:"cyan",children:l})]}),ue(V,{children:[X(V,{dimColor:!0,children:"Capabilities: "}),X(V,{color:"green",children:u.length>0?u.join(", "):"none"})]})]}),ue(V,{dimColor:!0,children:["Esc Esc: Clear input & attachments | Ctrl+V: Paste image | Ctrl+O: Toggle full output ",p?"(ON)":"(OFF)"," | Ctrl+C: Exit"]})]})]})}import{jsx as qr}from"react/jsx-runtime";async function Vr(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").trim()}async function Kr(e,t,n,s){if(s<1)return console.error("Chat number must be 1 or greater"),null;let{chats:o}=await e.getChats(t,n,20);if(o.length===0)return console.error("No chats found. Start a new chat first."),null;if(s>o.length)return console.error(`Chat number ${s} not found. You have ${o.length} recent chats.`),console.error("Use `entrydesk chats` to see available chats."),null;let i=o[s-1],r;if(!i.agentId){let{messages:a}=await e.getMessages(t,n,i.id,10);r=a.find(d=>d.role==="assistant"&&d.modelId)?.modelId}return{chat:i,modelId:r}}var $t="\x1B[2m",_e="\x1B[0m",Go="\x1B[36m",ls="\x1B[33m",po="\x1B[32m",rs="stream-json";function is(e,t,n,s){e&&t&&(console.error(`Error: Cannot use both ${n} and ${s}`),process.exit(1))}function go(e,t){let n=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(n)}
198
+ `).map(n=>n.length))}function Gr(e){let t=Jr(ns);return e>=t?ns:Br}function ss({agentId:e,model:t,message:n,chatId:s,chatTitle:o,connectorIds:i,enableSandbox:r=!0,enableWebSearch:a=!1,enableImageGeneration:c=!1,enableChart:d=!1,enableFileSystem:$=!0}){let C=process.stdout.columns??80,x=Gr(C),v=os(null),h=Rn(s,o),{state:y,setState:k,messages:_,setMessages:F,input:K,setInput:ie,chatId:Y,setChatId:Ce,currentChatTitle:j,setCurrentChatTitle:A,hasPersistedChat:N,setHasPersistedChat:R,credentials:W,setCredentials:E,currentResponse:me,setCurrentResponse:D,fullOutput:p,setFullOutput:re,addSystemMessage:we,startNewChat:z}=h,{credentials:P}=jn(k);uo(()=>{P&&!W&&E(P)},[P,W,E]);let{availableConnectors:ee,availableModels:Q,availableAgents:pe,modelProviders:le,loading:M}=Fn(W),{currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:$e,activeConnectorIds:B,setActiveConnectorIds:ne}=zn(t,e,i),L=os(!1);uo(()=>{if(!L.current){if(L.current=!0,!t&&!e){let b=oe.getDefaultModel();b&&q(b)}if(!i&&!e){let b=oe.getDefaultConnectorIds();b&&ne(b.length>0?b:void 0)}}},[t,e,i,q,ne]);let{currentAgentDetails:f}=Kn(de,W),{sandbox:w,setSandbox:S,webSearch:te,setWebSearch:U,imageGeneration:xe,setImageGeneration:tt,chart:ot,setChart:De,fileSystem:nt,setFileSystem:bo,capabilityLabelMap:Vt}=Vn(r,a,c,d,$),{pendingFiles:je,addFile:gt,removeFile:He,clearFiles:Kt,getUploadedFileIds:st,hasUploadingFiles:xo,hasFiles:We}=ts({credentials:W,currentModel:Z,modelProviders:le,onUploadSuccess:b=>{we(`\u2713 Attached: ${b}`)},onUploadError:(b,O)=>{we(`\u2717 Failed to upload ${b}: ${O}`)}}),{sendMessage:Ve}=Mn({chatId:Y,credentials:W,currentAgentId:de,currentModel:Z,activeConnectorIds:B,sandbox:w,webSearch:te,imageGeneration:xe,chart:ot,localTools:nt,fullOutput:p,setMessages:F,setState:k,setCurrentResponse:D,setCredentials:E,setHasPersistedChat:R,getFileIds:st,clearFiles:Kt}),zt=Jo(b=>{z(b),D("")},[z]),[mt,ut]=Ur(!1),rt=Jo(async b=>{let O=b.text.trim(),ge=ao(O);if(/^https?:\/\//.test(ge))return;if(await _n(O)&&En(ge)){let ce=await Dn(O);ce&&(b.preventDefault(),await gt(ce))}},[gt]),ht=Jo(async()=>{if(!(mt||y.status!=="ready")){if(M||le.length===0){we("Please wait for resources to load before pasting images.");return}we("Reading clipboard..."),ut(!0);try{let b=await Nn();if(b){let O=`clipboard-${Date.now()}.png`;we(`Uploading: ${O} (${Math.round(b.buffer.length/1024)}KB)`),await gt({buffer:b.buffer,filename:O,mimeType:b.mime})}else we("No image found in clipboard. Copy an image first.")}catch(b){let O=b instanceof Error?b.message:"Failed to read clipboard";we(`Clipboard error: ${O}`)}finally{ut(!1)}}},[gt,we,mt,y.status,M,le.length]),{suggestions:yt,suggestionIndex:wt,showSuggestions:Ne,argMode:he,argItems:Ke,argIndex:kt,selectedConnectorIds:qt,selectedCapabilities:Pt,deleteConfirmMode:Yt,handleInputChange:I,handleSubmit:m}=es({input:K,setInput:ie,chatId:Y,setChatId:Ce,currentChatTitle:j,setCurrentChatTitle:A,currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:$e,currentAgentDetails:f,setCurrentAgentDetails:()=>{},activeConnectorIds:B,setActiveConnectorIds:ne,sandbox:w,setSandbox:S,webSearch:te,setWebSearch:U,imageGeneration:xe,setImageGeneration:tt,chart:ot,setChart:De,fileSystem:nt,setFileSystem:bo,availableModels:Q,availableAgents:pe,availableConnectors:ee,messages:_,hasPersistedChat:N,setHasPersistedChat:R,setMessages:F,addSystemMessage:we,startNewChat:zt,sendMessage:Ve,setFullOutput:re,credentials:W,setCredentials:E,setState:k,defaultCapabilities:{sandbox:r,webSearch:a,imageGeneration:c,chart:d,fileSystem:$},capabilityLabelMap:Vt,hasUploadingFiles:xo});if(Wo((b,O)=>{(O.ctrl||O.meta)&&b==="v"&&ht()},{isActive:y.status==="ready"&&!he}),Wo((b,O)=>{if(!O.escape)return;let ge=Date.now(),J=v.current;v.current=ge,!(!J||ge-J>Wr)&&(he||Ne||(v.current=null,We&&Kt(),K.length>0&&I("")))},{isActive:y.status==="ready"}),Wo((b,O)=>{O.return&&(zt("Started a new chat."),k({status:"ready"}))},{isActive:y.status==="error"}),uo(()=>{if(W&&!M&&y.status==="loading")if(!Z&&!de){let b=oe.getDefaultModel(),O=b&&Q.some(J=>J.id===b),ge=O?b:Q[0]?.id;ge?(O||oe.setDefaultModel(ge),q(ge),k({status:"ready"})):pe.length===0?k({status:"no-model"}):k({status:"ready"})}else k({status:"ready"})},[W,M,Z,de,Q,pe,y.status,q,k]),uo(()=>{n&&W&&y.status==="ready"&&Ve(n)},[W,n]),y.status==="loading")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),ue(Ie,{children:[X(V,{color:"cyan",children:X(Mo,{type:"dots"})}),X(V,{children:" Initializing chat..."})]})]});if(y.status==="not-logged-in")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),X(V,{color:"yellow",children:"Not logged in"}),X(V,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if(y.status==="no-workspace")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),X(V,{color:"yellow",children:"No workspace selected"}),X(V,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if(y.status==="no-model")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),X(V,{color:"yellow",children:"No model or agent specified"}),s&&X(V,{dimColor:!0,children:"Could not determine the model used in this chat."}),X(V,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),X(V,{dimColor:!0,children:"Example: entrydesk chat -c 1 -i --model gemini-2.5-flash-lite"})]});if(y.status==="error")return ue(Ie,{flexDirection:"column",children:[X(V,{children:x}),ue(V,{color:"red",children:["Error: ",y.message]}),X(V,{dimColor:!0,children:"Press Enter to start a new chat, or Ctrl+C to exit"})]});let l=de?f?f.connectors&&f.connectors.length>0?f.connectors.map(b=>b.name).join(", "):"none":"loading...":B&&B.length>0?ee.filter(b=>B.includes(b.id)).map(b=>b.name).join(", ")||`${B.length} connector(s)`:"none",u=[];if(de)if(f?.capabilities)for(let b of f.capabilities)u.push(Vt.get(b)??b);else u.push("loading...");else w&&u.push("Sandbox"),te&&u.push("Web"),xe&&u.push("Image"),ot&&u.push("Chart");nt&&u.push("FileSystem");let g=G.getCurrentProfileName(),T=g!=="default";return ue(Ie,{flexDirection:"column",children:[ue(Ie,{marginBottom:1,flexDirection:"column",children:[X(V,{children:x}),ue(Ie,{children:[X(V,{bold:!0,color:"cyan",children:j?`Continuing: ${j}`:"EntryDesk CLI"}),ue(V,{dimColor:!0,children:[" v","1.8.1"]}),T&&ue(V,{color:"magenta",children:[" [",g,"]"]}),X(V,{dimColor:!0,children:" (type /help for commands)"})]})]}),_.map((b,O)=>{let ge=b.parts&&p?ft(b.parts,!0):b.content,J=b.role==="user"?"green":b.role==="system"?"yellow":"blue",ce=b.role==="user"?"You":b.role==="system"?"System":"Assistant";return ue(Ie,{flexDirection:"column",marginBottom:1,children:[ue(V,{bold:!0,color:J,children:[ce,":"]}),X(Ro,{text:ge})]},O)}),me&&ue(Ie,{flexDirection:"column",marginBottom:1,children:[X(V,{bold:!0,color:"blue",children:"Assistant:"}),X(Ro,{text:me})]}),y.status==="ready"&&X(pn,{suggestions:yt,activeIndex:wt,visible:Ne}),y.status==="ready"&&he&&X(fn,{items:Ke,activeIndex:kt,pageSize:he==="agent"||he==="skills"||he==="model"?5:10,selectedIds:he==="connectors"?qt:he==="capabilities"?Pt:void 0,multiSelect:he==="connectors"||he==="capabilities",visible:!0,title:he==="model"?"Select model:":he==="agent"?"Select agent:":he==="skills"?"Select skill:":he==="connectors"?"Select connectors:":he==="capabilities"?"Select capabilities:":"Select chat:"}),y.status==="sending"&&!me?ue(Ie,{children:[X(V,{color:"cyan",children:X(Mo,{type:"dots"})}),X(V,{children:" Thinking..."})]}):y.status==="ready"&&!he?ue(Ie,{flexDirection:"column",children:[Yt&&X(Ie,{marginBottom:1,children:X(V,{color:"yellow",children:"\u26A0\uFE0F Delete this chat? (y/N) "})}),We&&!Yt&&ue(Ie,{marginBottom:1,flexDirection:"row",gap:1,children:[X(V,{dimColor:!0,children:"Attachments:"}),je.map((b,O)=>ue(V,{children:[b.status==="uploading"?ue(V,{color:"yellow",children:[X(Mo,{type:"dots"})," ",b.filename]}):b.status==="error"?ue(V,{color:"red",children:["\u2717 ",b.filename]}):ue(V,{color:"green",children:["\u2713 ",b.filename]}),O<je.length-1&&X(V,{children:", "})]},b.id))]}),ue(Ie,{children:[X(V,{color:"green",children:"> "}),X(xn,{value:K,onChange:I,onSubmit:m,onPaste:rt,leadingOffset:2,multiline:!0})]})]}):null,ue(Ie,{marginTop:1,flexDirection:"column",children:[ue(Ie,{gap:2,children:[ue(V,{children:[X(V,{dimColor:!0,children:"Model: "}),X(V,{color:"magenta",children:de?f?.model?.name||"loading...":Q.find(b=>b.id===Z)?.name||Z||"none"})]}),ue(V,{children:[X(V,{dimColor:!0,children:"Connectors: "}),X(V,{color:"cyan",children:l})]}),ue(V,{children:[X(V,{dimColor:!0,children:"Capabilities: "}),X(V,{color:"green",children:u.length>0?u.join(", "):"none"})]})]}),ue(V,{dimColor:!0,children:["Esc Esc: Clear input & attachments | Ctrl+V: Paste image | Ctrl+O: Toggle full output ",p?"(ON)":"(OFF)"," | Ctrl+C: Exit"]})]})]})}import{jsx as qr}from"react/jsx-runtime";async function Vr(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").trim()}async function Kr(e,t,n,s){if(s<1)return console.error("Chat number must be 1 or greater"),null;let{chats:o}=await e.getChats(t,n,20);if(o.length===0)return console.error("No chats found. Start a new chat first."),null;if(s>o.length)return console.error(`Chat number ${s} not found. You have ${o.length} recent chats.`),console.error("Use `entrydesk chats` to see available chats."),null;let i=o[s-1],r;if(!i.agentId){let{messages:a}=await e.getMessages(t,n,i.id,10);r=a.find(d=>d.role==="assistant"&&d.modelId)?.modelId}return{chat:i,modelId:r}}var $t="\x1B[2m",_e="\x1B[0m",Go="\x1B[36m",ls="\x1B[33m",po="\x1B[32m",rs="stream-json";function is(e,t,n,s){e&&t&&(console.error(`Error: Cannot use both ${n} and ${s}`),process.exit(1))}function go(e,t){let n=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(n)}
199
199
  `)}function mo(e,t){if(t)return e;let n=e.split(`
200
200
  `);if(n.length<=20)return e;let s=n.slice(0,5),o=n.slice(-5),i=n.length-10;return[...s,`${$t}... (${i} lines omitted, use --full-output to see all) ...${_e}`,...o].join(`
201
201
  `)}function zr(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function as(e,t){if(!e)return"(no result)";if(typeof e!="object")return mo(String(e),t);let n=e;if("structuredContent"in n&&n.structuredContent){let s=n.structuredContent,o=[];if(s.stdout&&typeof s.stdout=="string"&&s.stdout.trim()&&o.push(s.stdout.trim()),s.stderr&&typeof s.stderr=="string"&&s.stderr.trim()&&o.push(`${ls}[stderr]${_e} ${s.stderr.trim()}`),s.urls&&Array.isArray(s.urls)){let i=s.urls;for(let r of i)r.path&&r.url&&o.push(`${r.path}: ${r.url}`)}return o.length===0&&o.push(JSON.stringify(s,null,2)),mo(o.join(`
@@ -523,7 +523,7 @@ Examples:
523
523
  `)}async function Bs(e){if(e.help){Hi();return}let t,n;try{let h=await fe();t=h.accessToken,n=h.workspaceId}catch(h){let y=h instanceof Error?h.message:"Authentication failed";console.error(y),process.exit(1)}let s=new H,o=[],i,r=0,a=100;do{let h=await s.getMonthlyUsages(t,n,{nextKey:i,limit:100});if(o.push(...h.monthlyUsages),i=h.nextKey,r++,r>=a){console.error(`Warning: Showing first ${o.length} entries (pagination limit reached)`);break}}while(i);if(e.json){console.log(JSON.stringify(o));return}if(o.length===0){console.log("No usage data found for this workspace.");return}console.log(`Current Month Usage:
524
524
  `);let c=0,d=0;for(let h of o)c+=parseFloat(h.totalCost),d+=h.operationCount;console.log(`Total Cost: $${c.toFixed(2)}`),console.log(`Total Operations: ${d.toLocaleString()}`),console.log(`Users: ${o.length}
525
525
  `);let $=e.sortBy||"cost",C=[...o].toSorted((h,y)=>$==="cost"?parseFloat(y.totalCost)-parseFloat(h.totalCost):y.operationCount-h.operationCount),x=e.limit&&e.limit>0?e.limit:C.length,v=C.slice(0,x);console.log(`Usage by User (sorted by ${$}, showing ${v.length} of ${o.length}):
526
- `);for(let h of v){let y=parseFloat(h.totalCost);console.log(` ${h.user.name} (${h.user.email})`),console.log(` Cost: $${y.toFixed(2)}`),console.log(` Operations: ${h.operationCount.toLocaleString()}`),console.log("")}v.length<o.length&&console.log(`... and ${o.length-v.length} more users`)}function Xo(){console.log("entrydesk 1.8.0")}function Zo(){console.log(`
526
+ `);for(let h of v){let y=parseFloat(h.totalCost);console.log(` ${h.user.name} (${h.user.email})`),console.log(` Cost: $${y.toFixed(2)}`),console.log(` Operations: ${h.operationCount.toLocaleString()}`),console.log("")}v.length<o.length&&console.log(`... and ${o.length-v.length} more users`)}function Xo(){console.log("entrydesk 1.8.1")}function Zo(){console.log(`
527
527
  Usage: entrydesk workspaces [list|switch|use] [options]
528
528
 
529
529
  Commands:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entrydesk/cli",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "EntryDesk CLI - Interact with EntryDesk from your terminal",
5
5
  "type": "module",
6
6
  "bin": {