@entrydesk/cli 1.7.1 → 1.7.3
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 +1 -1
package/dist/index.js
CHANGED
|
@@ -195,7 +195,7 @@ ID: ${u.id}`)}}}else if(f==="connectors"){let c=Array.from(rt);$(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(Xt);return}let c=Ve+1;Xe(c),t(lt[c])}}),{suggestions:z,suggestionIndex:Te,showSuggestions:se,argMode:f,argItems:I,argIndex:U,selectedConnectorIds:rt,selectedCapabilities:Re,deleteConfirmMode:ct,handleInputChange:Zt,handleSubmit:Qt}}import{useCallback as Wt,useRef as Ur,useState as jr}from"react";function ns({credentials:e,currentModel:t,modelProviders:o,onUploadSuccess:s,onUploadError:n}){let[i,r]=jr([]),a=Ur(0),l=Wt(h=>{if(!(!Array.isArray(o)||o.length===0)){for(let T of o)if(T.models.some(V=>V.id===h))return T.id;return o[0]?.id}},[o]),d=Wt(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=t?l(t):o[0]?.id;if(!T){n?.(h.filename,"No model provider available");return}let O=`file-${++a.current}`;r(V=>[...V,{id:O,filename:h.filename,mimeType:h.mimeType,status:"uploading"}]);try{let Z=await new F().uploadFile(e.accessToken,e.workspaceId,h,T);r(ae=>ae.map(Y=>Y.id===O?{...Y,status:"uploaded",fileId:Z.id}:Y)),s?.(h.filename)}catch(V){let Z=V instanceof Error?V.message:"Upload failed";r(ae=>ae.map(Y=>Y.id===O?{...Y,status:"error",error:Z}:Y)),n?.(h.filename,Z)}},[e,t,l,o,s,n]),b=Wt(h=>{r(T=>T.filter(O=>O.id!==h))},[]),x=Wt(()=>{r([])},[]),C=Wt(()=>i.filter(h=>h.status==="uploaded"&&h.fileId).map(h=>h.fileId),[i]),$=i.some(h=>h.status==="uploading"),m=i.length>0;return{pendingFiles:i,addFile:d,removeFile:b,clearFiles:x,getUploadedFileIds:C,hasUploadingFiles:$,hasFiles:m}}import{jsx as X,jsxs as de}from"react/jsx-runtime";var Br=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],Wr=[Wo,Wo,Bo,Bo,gt,gt,gt,gt],rs=Br.map((e,t)=>`${Wr[t]??gt}${e}${re}`).join(`
|
|
197
197
|
`),Mr=`${gt}EntryDesk${re}`,Jr=500;function Gr(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 Hr(e){let t=Gr(e);return Math.max(...t.split(`
|
|
198
|
-
`).map(o=>o.length))}function Vr(e){let t=Hr(rs);return e>=t?rs:Mr}function is({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:b=!0}){let x=process.stdout.columns??80,C=Vr(x),$=ss(null),m=jn(s,n),{state:h,setState:T,messages:O,setMessages:V,input:Z,setInput:ae,chatId:Y,setChatId:Se,currentChatTitle:j,setCurrentChatTitle:P,hasPersistedChat:E,setHasPersistedChat:R,credentials:W,setCredentials:_,currentResponse:he,setCurrentResponse:L,fullOutput:p,setFullOutput:ie,addSystemMessage:ke,startNewChat:q}=m,{credentials:A}=Bn(T);go(()=>{A&&!W&&_(A)},[A,W,_]);let{availableConnectors:te,availableModels:ee,availableAgents:me,modelProviders:ce,loading:M}=Wn(W),{currentModel:Q,setCurrentModel:z,currentAgentId:fe,setCurrentAgentId:Te,activeConnectorIds:B,setActiveConnectorIds:se}=Yn(t,e,i),D=ss(!1);go(()=>{if(!D.current){if(D.current=!0,!t&&!e){let k=ne.getDefaultModel();k&&z(k)}if(!i&&!e){let k=ne.getDefaultConnectorIds();k&&se(k.length>0?k:void 0)}}},[t,e,i,z,se]);let{currentAgentDetails:f}=zn(fe,W),{sandbox:w,setSandbox:I,webSearch:oe,setWebSearch:U,imageGeneration:Ce,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:$o,capabilityLabelMap:zt}=qn(r,a,l,d,b),{pendingFiles:We,addFile:wt,removeFile:Ye,clearFiles:Yt,getUploadedFileIds:lt,hasUploadingFiles:So,hasFiles:Ve}=ns({credentials:W,currentModel:Q,modelProviders:ce,onUploadSuccess:k=>{ke(`\u2713 Attached: ${k}`)},onUploadError:(k,N)=>{ke(`\u2717 Failed to upload ${k}: ${N}`)}}),{sendMessage:Xe}=Gn({chatId:Y,credentials:W,currentAgentId:fe,currentModel:Q,activeConnectorIds:B,sandbox:w,webSearch:oe,imageGeneration:Ce,chart:it,localTools:at,fullOutput:p,setMessages:V,setState:T,setCurrentResponse:L,setCredentials:_,setHasPersistedChat:R,getFileIds:lt,clearFiles:Yt}),Xt=Vo(k=>{q(k),L("")},[q]),[kt,mt]=Fr(!1),ct=Vo(async k=>{let N=k.text.trim(),J=uo(N);if(/^https?:\/\//.test(J))return;if(await Dn(N)&&Ln(J)){let ue=await On(N);ue&&(k.preventDefault(),await wt(ue))}},[wt]),xt=Vo(async()=>{if(!(kt||h.status!=="ready")){if(M||ce.length===0){ke("Please wait for resources to load before pasting images.");return}ke("Reading clipboard..."),mt(!0);try{let k=await _n();if(k){let N=`clipboard-${Date.now()}.png`;ke(`Uploading: ${N} (${Math.round(k.buffer.length/1024)}KB)`),await wt({buffer:k.buffer,filename:N,mimeType:k.mime})}else ke("No image found in clipboard. Copy an image first.")}catch(k){let N=k instanceof Error?k.message:"Failed to read clipboard";ke(`Clipboard error: ${N}`)}finally{mt(!1)}}},[wt,ke,kt,h.status,M,ce.length]),{suggestions:bt,suggestionIndex:Ct,showSuggestions:_e,argMode:ye,argItems:Ze,argIndex:$t,selectedConnectorIds:Zt,selectedCapabilities:_t,deleteConfirmMode:Qt,handleInputChange:v,handleSubmit:y}=os({input:Z,setInput:ae,chatId:Y,setChatId:Se,currentChatTitle:j,setCurrentChatTitle:P,currentModel:Q,setCurrentModel:z,currentAgentId:fe,setCurrentAgentId:Te,currentAgentDetails:f,setCurrentAgentDetails:()=>{},activeConnectorIds:B,setActiveConnectorIds:se,sandbox:w,setSandbox:I,webSearch:oe,setWebSearch:U,imageGeneration:Ce,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:$o,availableModels:ee,availableAgents:me,availableConnectors:te,messages:O,hasPersistedChat:E,setHasPersistedChat:R,setMessages:V,addSystemMessage:ke,startNewChat:Xt,sendMessage:Xe,setFullOutput:ie,credentials:W,setCredentials:_,setState:T,defaultCapabilities:{sandbox:r,webSearch:a,imageGeneration:l,chart:d,fileSystem:b},capabilityLabelMap:zt,hasUploadingFiles:So});if(Go((k,N)=>{(N.ctrl||N.meta)&&k==="v"&&xt()},{isActive:h.status==="ready"&&!ye}),Go((k,N)=>{if(!N.escape)return;let J=Date.now(),G=$.current;$.current=J,!(!G||J-G>Jr)&&(ye||_e||($.current=null,Ve&&Yt(),Z.length>0&&v("")))},{isActive:h.status==="ready"}),Go((k,N)=>{N.return&&(Xt("Started a new chat."),T({status:"ready"}))},{isActive:h.status==="error"}),go(()=>{if(W&&!M&&h.status==="loading")if(!Q&&!fe){let k=ne.getDefaultModel(),N=k&&ee.some(G=>G.id===k),J=N?k:ee[0]?.id;J?(N||ne.setDefaultModel(J),z(J),T({status:"ready"})):me.length===0?T({status:"no-model"}):T({status:"ready"})}else T({status:"ready"})},[W,M,Q,fe,ee,me,h.status,z,T]),go(()=>{o&&W&&h.status==="ready"&&Xe(o)},[W,o]),h.status==="loading")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),de(Pe,{children:[X(K,{color:"cyan",children:X(Ho,{type:"dots"})}),X(K,{children:" Initializing chat..."})]})]});if(h.status==="not-logged-in")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),X(K,{color:"yellow",children:"Not logged in"}),X(K,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if(h.status==="no-workspace")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),X(K,{color:"yellow",children:"No workspace selected"}),X(K,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if(h.status==="no-model")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),X(K,{color:"yellow",children:"No model or agent specified"}),s&&X(K,{dimColor:!0,children:"Could not determine the model used in this chat."}),X(K,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),X(K,{dimColor:!0,children:"Example: entrydesk chat -c 1 -i --model gemini-2.5-flash-lite"})]});if(h.status==="error")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),de(K,{color:"red",children:["Error: ",h.message]}),X(K,{dimColor:!0,children:"Press Enter to start a new chat, or Ctrl+C to exit"})]});let c=fe?f?f.connectors&&f.connectors.length>0?f.connectors.map(k=>k.name).join(", "):"none":"loading...":B&&B.length>0?te.filter(k=>B.includes(k.id)).map(k=>k.name).join(", ")||`${B.length} connector(s)`:"none",u=[];if(fe)if(f?.capabilities)for(let k of f.capabilities)u.push(zt.get(k)??k);else u.push("loading...");else w&&u.push("Sandbox"),oe&&u.push("Web"),Ce&&u.push("Image"),it&&u.push("Chart");at&&u.push("FileSystem");let g=H.getCurrentProfileName(),S=g!=="default";return de(Pe,{flexDirection:"column",children:[de(Pe,{marginBottom:1,flexDirection:"column",children:[X(K,{children:C}),de(Pe,{children:[X(K,{bold:!0,color:"cyan",children:j?`Continuing: ${j}`:"EntryDesk CLI"}),de(K,{dimColor:!0,children:[" v","1.7.
|
|
198
|
+
`).map(o=>o.length))}function Vr(e){let t=Hr(rs);return e>=t?rs:Mr}function is({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:b=!0}){let x=process.stdout.columns??80,C=Vr(x),$=ss(null),m=jn(s,n),{state:h,setState:T,messages:O,setMessages:V,input:Z,setInput:ae,chatId:Y,setChatId:Se,currentChatTitle:j,setCurrentChatTitle:P,hasPersistedChat:E,setHasPersistedChat:R,credentials:W,setCredentials:_,currentResponse:he,setCurrentResponse:L,fullOutput:p,setFullOutput:ie,addSystemMessage:ke,startNewChat:q}=m,{credentials:A}=Bn(T);go(()=>{A&&!W&&_(A)},[A,W,_]);let{availableConnectors:te,availableModels:ee,availableAgents:me,modelProviders:ce,loading:M}=Wn(W),{currentModel:Q,setCurrentModel:z,currentAgentId:fe,setCurrentAgentId:Te,activeConnectorIds:B,setActiveConnectorIds:se}=Yn(t,e,i),D=ss(!1);go(()=>{if(!D.current){if(D.current=!0,!t&&!e){let k=ne.getDefaultModel();k&&z(k)}if(!i&&!e){let k=ne.getDefaultConnectorIds();k&&se(k.length>0?k:void 0)}}},[t,e,i,z,se]);let{currentAgentDetails:f}=zn(fe,W),{sandbox:w,setSandbox:I,webSearch:oe,setWebSearch:U,imageGeneration:Ce,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:$o,capabilityLabelMap:zt}=qn(r,a,l,d,b),{pendingFiles:We,addFile:wt,removeFile:Ye,clearFiles:Yt,getUploadedFileIds:lt,hasUploadingFiles:So,hasFiles:Ve}=ns({credentials:W,currentModel:Q,modelProviders:ce,onUploadSuccess:k=>{ke(`\u2713 Attached: ${k}`)},onUploadError:(k,N)=>{ke(`\u2717 Failed to upload ${k}: ${N}`)}}),{sendMessage:Xe}=Gn({chatId:Y,credentials:W,currentAgentId:fe,currentModel:Q,activeConnectorIds:B,sandbox:w,webSearch:oe,imageGeneration:Ce,chart:it,localTools:at,fullOutput:p,setMessages:V,setState:T,setCurrentResponse:L,setCredentials:_,setHasPersistedChat:R,getFileIds:lt,clearFiles:Yt}),Xt=Vo(k=>{q(k),L("")},[q]),[kt,mt]=Fr(!1),ct=Vo(async k=>{let N=k.text.trim(),J=uo(N);if(/^https?:\/\//.test(J))return;if(await Dn(N)&&Ln(J)){let ue=await On(N);ue&&(k.preventDefault(),await wt(ue))}},[wt]),xt=Vo(async()=>{if(!(kt||h.status!=="ready")){if(M||ce.length===0){ke("Please wait for resources to load before pasting images.");return}ke("Reading clipboard..."),mt(!0);try{let k=await _n();if(k){let N=`clipboard-${Date.now()}.png`;ke(`Uploading: ${N} (${Math.round(k.buffer.length/1024)}KB)`),await wt({buffer:k.buffer,filename:N,mimeType:k.mime})}else ke("No image found in clipboard. Copy an image first.")}catch(k){let N=k instanceof Error?k.message:"Failed to read clipboard";ke(`Clipboard error: ${N}`)}finally{mt(!1)}}},[wt,ke,kt,h.status,M,ce.length]),{suggestions:bt,suggestionIndex:Ct,showSuggestions:_e,argMode:ye,argItems:Ze,argIndex:$t,selectedConnectorIds:Zt,selectedCapabilities:_t,deleteConfirmMode:Qt,handleInputChange:v,handleSubmit:y}=os({input:Z,setInput:ae,chatId:Y,setChatId:Se,currentChatTitle:j,setCurrentChatTitle:P,currentModel:Q,setCurrentModel:z,currentAgentId:fe,setCurrentAgentId:Te,currentAgentDetails:f,setCurrentAgentDetails:()=>{},activeConnectorIds:B,setActiveConnectorIds:se,sandbox:w,setSandbox:I,webSearch:oe,setWebSearch:U,imageGeneration:Ce,setImageGeneration:rt,chart:it,setChart:Re,fileSystem:at,setFileSystem:$o,availableModels:ee,availableAgents:me,availableConnectors:te,messages:O,hasPersistedChat:E,setHasPersistedChat:R,setMessages:V,addSystemMessage:ke,startNewChat:Xt,sendMessage:Xe,setFullOutput:ie,credentials:W,setCredentials:_,setState:T,defaultCapabilities:{sandbox:r,webSearch:a,imageGeneration:l,chart:d,fileSystem:b},capabilityLabelMap:zt,hasUploadingFiles:So});if(Go((k,N)=>{(N.ctrl||N.meta)&&k==="v"&&xt()},{isActive:h.status==="ready"&&!ye}),Go((k,N)=>{if(!N.escape)return;let J=Date.now(),G=$.current;$.current=J,!(!G||J-G>Jr)&&(ye||_e||($.current=null,Ve&&Yt(),Z.length>0&&v("")))},{isActive:h.status==="ready"}),Go((k,N)=>{N.return&&(Xt("Started a new chat."),T({status:"ready"}))},{isActive:h.status==="error"}),go(()=>{if(W&&!M&&h.status==="loading")if(!Q&&!fe){let k=ne.getDefaultModel(),N=k&&ee.some(G=>G.id===k),J=N?k:ee[0]?.id;J?(N||ne.setDefaultModel(J),z(J),T({status:"ready"})):me.length===0?T({status:"no-model"}):T({status:"ready"})}else T({status:"ready"})},[W,M,Q,fe,ee,me,h.status,z,T]),go(()=>{o&&W&&h.status==="ready"&&Xe(o)},[W,o]),h.status==="loading")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),de(Pe,{children:[X(K,{color:"cyan",children:X(Ho,{type:"dots"})}),X(K,{children:" Initializing chat..."})]})]});if(h.status==="not-logged-in")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),X(K,{color:"yellow",children:"Not logged in"}),X(K,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if(h.status==="no-workspace")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),X(K,{color:"yellow",children:"No workspace selected"}),X(K,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if(h.status==="no-model")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),X(K,{color:"yellow",children:"No model or agent specified"}),s&&X(K,{dimColor:!0,children:"Could not determine the model used in this chat."}),X(K,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),X(K,{dimColor:!0,children:"Example: entrydesk chat -c 1 -i --model gemini-2.5-flash-lite"})]});if(h.status==="error")return de(Pe,{flexDirection:"column",children:[X(K,{children:C}),de(K,{color:"red",children:["Error: ",h.message]}),X(K,{dimColor:!0,children:"Press Enter to start a new chat, or Ctrl+C to exit"})]});let c=fe?f?f.connectors&&f.connectors.length>0?f.connectors.map(k=>k.name).join(", "):"none":"loading...":B&&B.length>0?te.filter(k=>B.includes(k.id)).map(k=>k.name).join(", ")||`${B.length} connector(s)`:"none",u=[];if(fe)if(f?.capabilities)for(let k of f.capabilities)u.push(zt.get(k)??k);else u.push("loading...");else w&&u.push("Sandbox"),oe&&u.push("Web"),Ce&&u.push("Image"),it&&u.push("Chart");at&&u.push("FileSystem");let g=H.getCurrentProfileName(),S=g!=="default";return de(Pe,{flexDirection:"column",children:[de(Pe,{marginBottom:1,flexDirection:"column",children:[X(K,{children:C}),de(Pe,{children:[X(K,{bold:!0,color:"cyan",children:j?`Continuing: ${j}`:"EntryDesk CLI"}),de(K,{dimColor:!0,children:[" v","1.7.3"]}),S&&de(K,{color:"magenta",children:[" [",g,"]"]}),X(K,{dimColor:!0,children:" (type /help for commands)"})]})]}),O.map((k,N)=>{let J=k.parts&&p?ht(k.parts,!0):k.content,G=k.role==="user"?"green":k.role==="system"?"yellow":"blue",ue=k.role==="user"?"You":k.role==="system"?"System":"Assistant";return de(Pe,{flexDirection:"column",marginBottom:1,children:[de(K,{bold:!0,color:G,children:[ue,":"]}),X(Fo,{text:J})]},N)}),he&&de(Pe,{flexDirection:"column",marginBottom:1,children:[X(K,{bold:!0,color:"blue",children:"Assistant:"}),X(Fo,{text:he})]}),h.status==="ready"&&X(gn,{suggestions:bt,activeIndex:Ct,visible:_e}),h.status==="ready"&&ye&&X(mn,{items:Ze,activeIndex:$t,pageSize:ye==="agent"||ye==="skills"||ye==="model"?5:10,selectedIds:ye==="connectors"?Zt:ye==="capabilities"?_t: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?de(Pe,{children:[X(K,{color:"cyan",children:X(Ho,{type:"dots"})}),X(K,{children:" Thinking..."})]}):h.status==="ready"&&!ye?de(Pe,{flexDirection:"column",children:[Qt&&X(Pe,{marginBottom:1,children:X(K,{color:"yellow",children:"\u26A0\uFE0F Delete this chat? (y/N) "})}),Ve&&!Qt&&de(Pe,{marginBottom:1,flexDirection:"row",gap:1,children:[X(K,{dimColor:!0,children:"Attachments:"}),We.map((k,N)=>de(K,{children:[k.status==="uploading"?de(K,{color:"yellow",children:[X(Ho,{type:"dots"})," ",k.filename]}):k.status==="error"?de(K,{color:"red",children:["\u2717 ",k.filename]}):de(K,{color:"green",children:["\u2713 ",k.filename]}),N<We.length-1&&X(K,{children:", "})]},k.id))]}),de(Pe,{children:[X(K,{color:"green",children:"> "}),X($n,{value:Z,onChange:v,onSubmit:y,onPaste:ct,leadingOffset:2,multiline:!0})]})]}):null,de(Pe,{marginTop:1,flexDirection:"column",children:[de(Pe,{gap:2,children:[de(K,{children:[X(K,{dimColor:!0,children:"Model: "}),X(K,{color:"magenta",children:fe?f?.model?.name||"loading...":ee.find(k=>k.id===Q)?.name||Q||"none"})]}),de(K,{children:[X(K,{dimColor:!0,children:"Connectors: "}),X(K,{color:"cyan",children:c})]}),de(K,{children:[X(K,{dimColor:!0,children:"Capabilities: "}),X(K,{color:"green",children:u.length>0?u.join(", "):"none"})]})]}),de(K,{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 Xr}from"react/jsx-runtime";async function qr(){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 It="\x1B[2m",Oe="\x1B[0m",Ko="\x1B[36m",us="\x1B[33m",yo="\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 wo(e,t){let o=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(o)}
|
|
199
199
|
`)}function ko(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,`${It}... (${i} lines omitted, use --full-output to see all) ...${Oe}`,...n].join(`
|
|
201
201
|
`)}function Yr(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 ko(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]${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)),ko(n.join(`
|
|
@@ -526,7 +526,7 @@ Examples:
|
|
|
526
526
|
`)}async function Ms(e){if(e.help){Yi();return}let t,o;try{let m=await pe();t=m.accessToken,o=m.workspaceId}catch(m){let h=m instanceof Error?m.message:"Authentication failed";console.error(h),process.exit(1)}let s=new F,n=[],i,r=0,a=100;do{let m=await s.getMonthlyUsages(t,o,{nextKey:i,limit:100});if(n.push(...m.monthlyUsages),i=m.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:
|
|
527
527
|
`);let l=0,d=0;for(let m of n)l+=parseFloat(m.totalCost),d+=m.operationCount;console.log(`Total Cost: $${l.toFixed(2)}`),console.log(`Total Operations: ${d.toLocaleString()}`),console.log(`Users: ${n.length}
|
|
528
528
|
`);let b=e.sortBy||"cost",x=[...n].toSorted((m,h)=>b==="cost"?parseFloat(h.totalCost)-parseFloat(m.totalCost):h.operationCount-m.operationCount),C=e.limit&&e.limit>0?e.limit:x.length,$=x.slice(0,C);console.log(`Usage by User (sorted by ${b}, showing ${$.length} of ${n.length}):
|
|
529
|
-
`);for(let m of $){let h=parseFloat(m.totalCost);console.log(` ${m.user.name} (${m.user.email})`),console.log(` Cost: $${h.toFixed(2)}`),console.log(` Operations: ${m.operationCount.toLocaleString()}`),console.log("")}$.length<n.length&&console.log(`... and ${n.length-$.length} more users`)}function on(){console.log("entrydesk 1.7.
|
|
529
|
+
`);for(let m of $){let h=parseFloat(m.totalCost);console.log(` ${m.user.name} (${m.user.email})`),console.log(` Cost: $${h.toFixed(2)}`),console.log(` Operations: ${m.operationCount.toLocaleString()}`),console.log("")}$.length<n.length&&console.log(`... and ${n.length-$.length} more users`)}function on(){console.log("entrydesk 1.7.3")}function nn(){console.log(`
|
|
530
530
|
Usage: entrydesk workspaces [list|switch|use] [options]
|
|
531
531
|
|
|
532
532
|
Commands:
|