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