@entrydesk/cli 1.7.11 → 1.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -195,7 +195,7 @@ ID: ${u.id}`)}}}else if(f==="connectors"){let c=Array.from(rt);S(c.length>0?c:vo
|
|
|
195
195
|
`)||lt.length===0)return;if(Ve===null){kt(e);let u=lt.length-1;Xe(u),t(lt[u]);return}let c=Math.max(0,Ve-1);Xe(c),t(lt[c]);return}if(y.downArrow){if(e.includes(`
|
|
196
196
|
`)||Ve===null)return;if(Ve>=lt.length-1){Xe(null),t(Qt);return}let c=Ve+1;Xe(c),t(lt[c])}}),{suggestions:q,suggestionIndex:Te,showSuggestions:ne,argMode:f,argItems:T,argIndex:U,selectedConnectorIds:rt,selectedCapabilities:Re,deleteConfirmMode:ct,handleInputChange:eo,handleSubmit:to}}import{useCallback as Jt,useRef as jr,useState as Br}from"react";function ss({credentials:e,currentModel:t,modelProviders:o,onUploadSuccess:s,onUploadError:n}){let[i,r]=Br([]),a=jr(0),l=Jt(h=>{if(!(!Array.isArray(o)||o.length===0)){for(let $ of o)if($.models.some(H=>H.id===h))return $.id;return o[0]?.id}},[o]),d=Jt(async h=>{if(!e){n?.(h.filename,"Not logged in");return}if(!Array.isArray(o)||o.length===0){n?.(h.filename,"Model providers not loaded yet. Please wait and try again.");return}let $=t?l(t):o[0]?.id;if(!$){n?.(h.filename,"No model provider available");return}let D=`file-${++a.current}`;r(H=>[...H,{id:D,filename:h.filename,mimeType:h.mimeType,status:"uploading"}]);try{let X=await new B().uploadFile(e.accessToken,e.workspaceId,h,$);r(ie=>ie.map(z=>z.id===D?{...z,status:"uploaded",fileId:X.id}:z)),s?.(h.filename)}catch(H){let X=H instanceof Error?H.message:"Upload failed";r(ie=>ie.map(z=>z.id===D?{...z,status:"error",error:X}:z)),n?.(h.filename,X)}},[e,t,l,o,s,n]),C=Jt(h=>{r($=>$.filter(D=>D.id!==h))},[]),k=Jt(()=>{r([])},[]),b=Jt(()=>i.filter(h=>h.status==="uploaded"&&h.fileId).map(h=>h.fileId),[i]),S=i.some(h=>h.status==="uploading"),g=i.length>0;return{pendingFiles:i,addFile:d,removeFile:C,clearFiles:k,getUploadedFileIds:b,hasUploadingFiles:S,hasFiles:g}}import{jsx as Y,jsxs as ue}from"react/jsx-runtime";var Wr=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],Mr=[Jo,Jo,Mo,Mo,mt,mt,mt,mt],is=Wr.map((e,t)=>`${Mr[t]??mt}${e}${se}`).join(`
|
|
197
197
|
`),Jr=`${mt}EntryDesk${se}`,Gr=500;function Hr(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 Vr(e){let t=Hr(e);return Math.max(...t.split(`
|
|
198
|
-
`).map(o=>o.length))}function Kr(e){let t=Vr(is);return e>=t?is:Jr}function as({agentId:e,model:t,message:o,chatId:s,chatTitle:n,connectorIds:i,enableSandbox:r=!0,enableWebSearch:a=!1,enableImageGeneration:l=!1,enableChart:d=!1,enableFileSystem:C=!0}){let k=process.stdout.columns??80,b=Kr(k),S=rs(null),g=Bn(s,n),{state:h,setState:$,messages:D,setMessages:H,input:X,setInput:ie,chatId:z,setChatId:$e,currentChatTitle:j,setCurrentChatTitle:P,hasPersistedChat:N,setHasPersistedChat:R,credentials:W,setCredentials:E,currentResponse:he,setCurrentResponse:_,fullOutput:p,setFullOutput:re,addSystemMessage:ke,startNewChat:K}=g,{credentials:A}=Wn($);ho(()=>{A&&!W&&E(A)},[A,W,E]);let{availableConnectors:ee,availableModels:Q,availableAgents:pe,modelProviders:le,loading:M}=Mn(W),{currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:Te,activeConnectorIds:F,setActiveConnectorIds:ne}=Xn(t,e,i),O=rs(!1);ho(()=>{if(!O.current){if(O.current=!0,!t&&!e){let x=oe.getDefaultModel();x&&q(x)}if(!i&&!e){let x=oe.getDefaultConnectorIds();x&&ne(x.length>0?x:void 0)}}},[t,e,i,q,ne]);let{currentAgentDetails:f}=Yn(de,W),{sandbox:w,setSandbox:T,webSearch:te,setWebSearch:U,imageGeneration:Se,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:To,capabilityLabelMap:Xt}=zn(r,a,l,d,C),{pendingFiles:We,addFile:wt,removeFile:Ye,clearFiles:Zt,getUploadedFileIds:lt,hasUploadingFiles:Io,hasFiles:Ve}=ss({credentials:W,currentModel:Z,modelProviders:le,onUploadSuccess:x=>{ke(`\u2713 Attached: ${x}`)},onUploadError:(x,L)=>{ke(`\u2717 Failed to upload ${x}: ${L}`)}}),{sendMessage:Xe}=Hn({chatId:z,credentials:W,currentAgentId:de,currentModel:Z,activeConnectorIds:F,sandbox:w,webSearch:te,imageGeneration:Se,chart:it,localTools:at,fullOutput:p,setMessages:H,setState:$,setCurrentResponse:_,setCredentials:E,setHasPersistedChat:R,getFileIds:lt,clearFiles:Zt}),Qt=qo(x=>{K(x),_("")},[K]),[kt,gt]=Fr(!1),ct=qo(async x=>{let L=x.text.trim(),ge=po(L);if(/^https?:\/\//.test(ge))return;if(await On(L)&&Dn(ge)){let ce=await Rn(L);ce&&(x.preventDefault(),await wt(ce))}},[wt]),xt=qo(async()=>{if(!(kt||h.status!=="ready")){if(M||le.length===0){ke("Please wait for resources to load before pasting images.");return}ke("Reading clipboard..."),gt(!0);try{let x=await Ln();if(x){let L=`clipboard-${Date.now()}.png`;ke(`Uploading: ${L} (${Math.round(x.buffer.length/1024)}KB)`),await wt({buffer:x.buffer,filename:L,mimeType:x.mime})}else ke("No image found in clipboard. Copy an image first.")}catch(x){let L=x instanceof Error?x.message:"Failed to read clipboard";ke(`Clipboard error: ${L}`)}finally{gt(!1)}}},[wt,ke,kt,h.status,M,le.length]),{suggestions:bt,suggestionIndex:Ct,showSuggestions:_e,argMode:ye,argItems:Ze,argIndex:St,selectedConnectorIds:eo,selectedCapabilities:Lt,deleteConfirmMode:to,handleInputChange:v,handleSubmit:y}=ns({input:X,setInput:ie,chatId:z,setChatId:$e,currentChatTitle:j,setCurrentChatTitle:P,currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:Te,currentAgentDetails:f,setCurrentAgentDetails:()=>{},activeConnectorIds:F,setActiveConnectorIds:ne,sandbox:w,setSandbox:T,webSearch:te,setWebSearch:U,imageGeneration:Se,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:To,availableModels:Q,availableAgents:pe,availableConnectors:ee,messages:D,hasPersistedChat:N,setHasPersistedChat:R,setMessages:H,addSystemMessage:ke,startNewChat:Qt,sendMessage:Xe,setFullOutput:re,credentials:W,setCredentials:E,setState:$,defaultCapabilities:{sandbox:r,webSearch:a,imageGeneration:l,chart:d,fileSystem:C},capabilityLabelMap:Xt,hasUploadingFiles:Io});if(Vo((x,L)=>{(L.ctrl||L.meta)&&x==="v"&&xt()},{isActive:h.status==="ready"&&!ye}),Vo((x,L)=>{if(!L.escape)return;let ge=Date.now(),J=S.current;S.current=ge,!(!J||ge-J>Gr)&&(ye||_e||(S.current=null,Ve&&Zt(),X.length>0&&v("")))},{isActive:h.status==="ready"}),Vo((x,L)=>{L.return&&(Qt("Started a new chat."),$({status:"ready"}))},{isActive:h.status==="error"}),ho(()=>{if(W&&!M&&h.status==="loading")if(!Z&&!de){let x=oe.getDefaultModel(),L=x&&Q.some(J=>J.id===x),ge=L?x:Q[0]?.id;ge?(L||oe.setDefaultModel(ge),q(ge),$({status:"ready"})):pe.length===0?$({status:"no-model"}):$({status:"ready"})}else $({status:"ready"})},[W,M,Z,de,Q,pe,h.status,q,$]),ho(()=>{o&&W&&h.status==="ready"&&Xe(o)},[W,o]),h.status==="loading")return ue(Pe,{flexDirection:"column",children:[Y(V,{children:b}),ue(Pe,{children:[Y(V,{color:"cyan",children:Y(Ko,{type:"dots"})}),Y(V,{children:" Initializing chat..."})]})]});if(h.status==="not-logged-in")return ue(Pe,{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(h.status==="no-workspace")return ue(Pe,{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(h.status==="no-model")return ue(Pe,{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(h.status==="error")return ue(Pe,{flexDirection:"column",children:[Y(V,{children:b}),ue(V,{color:"red",children:["Error: ",h.message]}),Y(V,{dimColor:!0,children:"Press Enter to start a new chat, or Ctrl+C to exit"})]});let c=de?f?f.connectors&&f.connectors.length>0?f.connectors.map(x=>x.name).join(", "):"none":"loading...":F&&F.length>0?ee.filter(x=>F.includes(x.id)).map(x=>x.name).join(", ")||`${F.length} connector(s)`:"none",u=[];if(de)if(f?.capabilities)for(let x of f.capabilities)u.push(Xt.get(x)??x);else u.push("loading...");else w&&u.push("Sandbox"),te&&u.push("Web"),Se&&u.push("Image"),it&&u.push("Chart");at&&u.push("FileSystem");let m=G.getCurrentProfileName(),I=m!=="default";return ue(Pe,{flexDirection:"column",children:[ue(Pe,{marginBottom:1,flexDirection:"column",children:[Y(V,{children:b}),ue(Pe,{children:[Y(V,{bold:!0,color:"cyan",children:j?`Continuing: ${j}`:"EntryDesk CLI"}),ue(V,{dimColor:!0,children:[" v","1.7.
|
|
198
|
+
`).map(o=>o.length))}function Kr(e){let t=Vr(is);return e>=t?is:Jr}function as({agentId:e,model:t,message:o,chatId:s,chatTitle:n,connectorIds:i,enableSandbox:r=!0,enableWebSearch:a=!1,enableImageGeneration:l=!1,enableChart:d=!1,enableFileSystem:C=!0}){let k=process.stdout.columns??80,b=Kr(k),S=rs(null),g=Bn(s,n),{state:h,setState:$,messages:D,setMessages:H,input:X,setInput:ie,chatId:z,setChatId:$e,currentChatTitle:j,setCurrentChatTitle:P,hasPersistedChat:N,setHasPersistedChat:R,credentials:W,setCredentials:E,currentResponse:he,setCurrentResponse:_,fullOutput:p,setFullOutput:re,addSystemMessage:ke,startNewChat:K}=g,{credentials:A}=Wn($);ho(()=>{A&&!W&&E(A)},[A,W,E]);let{availableConnectors:ee,availableModels:Q,availableAgents:pe,modelProviders:le,loading:M}=Mn(W),{currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:Te,activeConnectorIds:F,setActiveConnectorIds:ne}=Xn(t,e,i),O=rs(!1);ho(()=>{if(!O.current){if(O.current=!0,!t&&!e){let x=oe.getDefaultModel();x&&q(x)}if(!i&&!e){let x=oe.getDefaultConnectorIds();x&&ne(x.length>0?x:void 0)}}},[t,e,i,q,ne]);let{currentAgentDetails:f}=Yn(de,W),{sandbox:w,setSandbox:T,webSearch:te,setWebSearch:U,imageGeneration:Se,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:To,capabilityLabelMap:Xt}=zn(r,a,l,d,C),{pendingFiles:We,addFile:wt,removeFile:Ye,clearFiles:Zt,getUploadedFileIds:lt,hasUploadingFiles:Io,hasFiles:Ve}=ss({credentials:W,currentModel:Z,modelProviders:le,onUploadSuccess:x=>{ke(`\u2713 Attached: ${x}`)},onUploadError:(x,L)=>{ke(`\u2717 Failed to upload ${x}: ${L}`)}}),{sendMessage:Xe}=Hn({chatId:z,credentials:W,currentAgentId:de,currentModel:Z,activeConnectorIds:F,sandbox:w,webSearch:te,imageGeneration:Se,chart:it,localTools:at,fullOutput:p,setMessages:H,setState:$,setCurrentResponse:_,setCredentials:E,setHasPersistedChat:R,getFileIds:lt,clearFiles:Zt}),Qt=qo(x=>{K(x),_("")},[K]),[kt,gt]=Fr(!1),ct=qo(async x=>{let L=x.text.trim(),ge=po(L);if(/^https?:\/\//.test(ge))return;if(await On(L)&&Dn(ge)){let ce=await Rn(L);ce&&(x.preventDefault(),await wt(ce))}},[wt]),xt=qo(async()=>{if(!(kt||h.status!=="ready")){if(M||le.length===0){ke("Please wait for resources to load before pasting images.");return}ke("Reading clipboard..."),gt(!0);try{let x=await Ln();if(x){let L=`clipboard-${Date.now()}.png`;ke(`Uploading: ${L} (${Math.round(x.buffer.length/1024)}KB)`),await wt({buffer:x.buffer,filename:L,mimeType:x.mime})}else ke("No image found in clipboard. Copy an image first.")}catch(x){let L=x instanceof Error?x.message:"Failed to read clipboard";ke(`Clipboard error: ${L}`)}finally{gt(!1)}}},[wt,ke,kt,h.status,M,le.length]),{suggestions:bt,suggestionIndex:Ct,showSuggestions:_e,argMode:ye,argItems:Ze,argIndex:St,selectedConnectorIds:eo,selectedCapabilities:Lt,deleteConfirmMode:to,handleInputChange:v,handleSubmit:y}=ns({input:X,setInput:ie,chatId:z,setChatId:$e,currentChatTitle:j,setCurrentChatTitle:P,currentModel:Z,setCurrentModel:q,currentAgentId:de,setCurrentAgentId:Te,currentAgentDetails:f,setCurrentAgentDetails:()=>{},activeConnectorIds:F,setActiveConnectorIds:ne,sandbox:w,setSandbox:T,webSearch:te,setWebSearch:U,imageGeneration:Se,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:To,availableModels:Q,availableAgents:pe,availableConnectors:ee,messages:D,hasPersistedChat:N,setHasPersistedChat:R,setMessages:H,addSystemMessage:ke,startNewChat:Qt,sendMessage:Xe,setFullOutput:re,credentials:W,setCredentials:E,setState:$,defaultCapabilities:{sandbox:r,webSearch:a,imageGeneration:l,chart:d,fileSystem:C},capabilityLabelMap:Xt,hasUploadingFiles:Io});if(Vo((x,L)=>{(L.ctrl||L.meta)&&x==="v"&&xt()},{isActive:h.status==="ready"&&!ye}),Vo((x,L)=>{if(!L.escape)return;let ge=Date.now(),J=S.current;S.current=ge,!(!J||ge-J>Gr)&&(ye||_e||(S.current=null,Ve&&Zt(),X.length>0&&v("")))},{isActive:h.status==="ready"}),Vo((x,L)=>{L.return&&(Qt("Started a new chat."),$({status:"ready"}))},{isActive:h.status==="error"}),ho(()=>{if(W&&!M&&h.status==="loading")if(!Z&&!de){let x=oe.getDefaultModel(),L=x&&Q.some(J=>J.id===x),ge=L?x:Q[0]?.id;ge?(L||oe.setDefaultModel(ge),q(ge),$({status:"ready"})):pe.length===0?$({status:"no-model"}):$({status:"ready"})}else $({status:"ready"})},[W,M,Z,de,Q,pe,h.status,q,$]),ho(()=>{o&&W&&h.status==="ready"&&Xe(o)},[W,o]),h.status==="loading")return ue(Pe,{flexDirection:"column",children:[Y(V,{children:b}),ue(Pe,{children:[Y(V,{color:"cyan",children:Y(Ko,{type:"dots"})}),Y(V,{children:" Initializing chat..."})]})]});if(h.status==="not-logged-in")return ue(Pe,{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(h.status==="no-workspace")return ue(Pe,{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(h.status==="no-model")return ue(Pe,{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(h.status==="error")return ue(Pe,{flexDirection:"column",children:[Y(V,{children:b}),ue(V,{color:"red",children:["Error: ",h.message]}),Y(V,{dimColor:!0,children:"Press Enter to start a new chat, or Ctrl+C to exit"})]});let c=de?f?f.connectors&&f.connectors.length>0?f.connectors.map(x=>x.name).join(", "):"none":"loading...":F&&F.length>0?ee.filter(x=>F.includes(x.id)).map(x=>x.name).join(", ")||`${F.length} connector(s)`:"none",u=[];if(de)if(f?.capabilities)for(let x of f.capabilities)u.push(Xt.get(x)??x);else u.push("loading...");else w&&u.push("Sandbox"),te&&u.push("Web"),Se&&u.push("Image"),it&&u.push("Chart");at&&u.push("FileSystem");let m=G.getCurrentProfileName(),I=m!=="default";return ue(Pe,{flexDirection:"column",children:[ue(Pe,{marginBottom:1,flexDirection:"column",children:[Y(V,{children:b}),ue(Pe,{children:[Y(V,{bold:!0,color:"cyan",children:j?`Continuing: ${j}`:"EntryDesk CLI"}),ue(V,{dimColor:!0,children:[" v","1.7.12"]}),I&&ue(V,{color:"magenta",children:[" [",m,"]"]}),Y(V,{dimColor:!0,children:" (type /help for commands)"})]})]}),D.map((x,L)=>{let ge=x.parts&&p?ht(x.parts,!0):x.content,J=x.role==="user"?"green":x.role==="system"?"yellow":"blue",ce=x.role==="user"?"You":x.role==="system"?"System":"Assistant";return ue(Pe,{flexDirection:"column",marginBottom:1,children:[ue(V,{bold:!0,color:J,children:[ce,":"]}),Y(Wo,{text:ge})]},L)}),he&&ue(Pe,{flexDirection:"column",marginBottom:1,children:[Y(V,{bold:!0,color:"blue",children:"Assistant:"}),Y(Wo,{text:he})]}),h.status==="ready"&&Y(hn,{suggestions:bt,activeIndex:Ct,visible:_e}),h.status==="ready"&&ye&&Y(mn,{items:Ze,activeIndex:St,pageSize:ye==="agent"||ye==="skills"||ye==="model"?5:10,selectedIds:ye==="connectors"?eo:ye==="capabilities"?Lt:void 0,multiSelect:ye==="connectors"||ye==="capabilities",visible:!0,title:ye==="model"?"Select model:":ye==="agent"?"Select agent:":ye==="skills"?"Select skill:":ye==="connectors"?"Select connectors:":ye==="capabilities"?"Select capabilities:":"Select chat:"}),h.status==="sending"&&!he?ue(Pe,{children:[Y(V,{color:"cyan",children:Y(Ko,{type:"dots"})}),Y(V,{children:" Thinking..."})]}):h.status==="ready"&&!ye?ue(Pe,{flexDirection:"column",children:[to&&Y(Pe,{marginBottom:1,children:Y(V,{color:"yellow",children:"\u26A0\uFE0F Delete this chat? (y/N) "})}),Ve&&!to&&ue(Pe,{marginBottom:1,flexDirection:"row",gap:1,children:[Y(V,{dimColor:!0,children:"Attachments:"}),We.map((x,L)=>ue(V,{children:[x.status==="uploading"?ue(V,{color:"yellow",children:[Y(Ko,{type:"dots"})," ",x.filename]}):x.status==="error"?ue(V,{color:"red",children:["\u2717 ",x.filename]}):ue(V,{color:"green",children:["\u2713 ",x.filename]}),L<We.length-1&&Y(V,{children:", "})]},x.id))]}),ue(Pe,{children:[Y(V,{color:"green",children:"> "}),Y($n,{value:X,onChange:v,onSubmit:y,onPaste:ct,leadingOffset:2,multiline:!0})]})]}):null,ue(Pe,{marginTop:1,flexDirection:"column",children:[ue(Pe,{gap:2,children:[ue(V,{children:[Y(V,{dimColor:!0,children:"Model: "}),Y(V,{color:"magenta",children:de?f?.model?.name||"loading...":Q.find(x=>x.id===Z)?.name||Z||"none"})]}),ue(V,{children:[Y(V,{dimColor:!0,children:"Connectors: "}),Y(V,{color:"cyan",children:c})]}),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 Zr}from"react/jsx-runtime";async function zr(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").trim()}async function Yr(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 vt="\x1B[2m",Oe="\x1B[0m",zo="\x1B[36m",ds="\x1B[33m",wo="\x1B[32m",ls="stream-json";function cs(e,t,o,s){e&&t&&(console.error(`Error: Cannot use both ${o} and ${s}`),process.exit(1))}function ko(e,t){let o=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(o)}
|
|
199
199
|
`)}function xo(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,`${vt}... (${i} lines omitted, use --full-output to see all) ...${Oe}`,...n].join(`
|
|
201
201
|
`)}function Xr(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function us(e,t){if(!e)return"(no result)";if(typeof e!="object")return xo(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(`${ds}[stderr]${Oe} ${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)),xo(n.join(`
|
|
@@ -528,7 +528,7 @@ Examples:
|
|
|
528
528
|
`)}async function Js(e){if(e.help){Xi();return}let t,o;try{let g=await fe();t=g.accessToken,o=g.workspaceId}catch(g){let h=g instanceof Error?g.message:"Authentication failed";console.error(h),process.exit(1)}let s=new B,n=[],i,r=0,a=100;do{let g=await s.getMonthlyUsages(t,o,{nextKey:i,limit:100});if(n.push(...g.monthlyUsages),i=g.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:
|
|
529
529
|
`);let l=0,d=0;for(let g of n)l+=parseFloat(g.totalCost),d+=g.operationCount;console.log(`Total Cost: $${l.toFixed(2)}`),console.log(`Total Operations: ${d.toLocaleString()}`),console.log(`Users: ${n.length}
|
|
530
530
|
`);let C=e.sortBy||"cost",k=[...n].toSorted((g,h)=>C==="cost"?parseFloat(h.totalCost)-parseFloat(g.totalCost):h.operationCount-g.operationCount),b=e.limit&&e.limit>0?e.limit:k.length,S=k.slice(0,b);console.log(`Usage by User (sorted by ${C}, showing ${S.length} of ${n.length}):
|
|
531
|
-
`);for(let g of S){let h=parseFloat(g.totalCost);console.log(` ${g.user.name} (${g.user.email})`),console.log(` Cost: $${h.toFixed(2)}`),console.log(` Operations: ${g.operationCount.toLocaleString()}`),console.log("")}S.length<n.length&&console.log(`... and ${n.length-S.length} more users`)}function nn(){console.log("entrydesk 1.7.
|
|
531
|
+
`);for(let g of S){let h=parseFloat(g.totalCost);console.log(` ${g.user.name} (${g.user.email})`),console.log(` Cost: $${h.toFixed(2)}`),console.log(` Operations: ${g.operationCount.toLocaleString()}`),console.log("")}S.length<n.length&&console.log(`... and ${n.length-S.length} more users`)}function nn(){console.log("entrydesk 1.7.12")}function sn(){console.log(`
|
|
532
532
|
Usage: entrydesk workspaces [list|switch|use] [options]
|
|
533
533
|
|
|
534
534
|
Commands:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entrydesk/cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.12",
|
|
4
4
|
"description": "EntryDesk CLI - Interact with EntryDesk from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test:coverage": "vitest run --coverage",
|
|
55
55
|
"test:integration": "pnpm build && vitest run --root ./integration-tests",
|
|
56
56
|
"test:unit": "vitest run --config vitest.config.ts",
|
|
57
|
-
"test:watch": "vitest",
|
|
57
|
+
"test:watch": "vitest watch",
|
|
58
58
|
"typecheck": "tsc --noEmit"
|
|
59
59
|
}
|
|
60
60
|
}
|