@entrydesk/cli 1.24.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +8 -0
  2. package/dist/{agents-DFOYNMYK.js → agents-BPEYRMJS.js} +1 -1
  3. package/dist/{billing-SAYH5EB7.js → billing-ZIIVREJT.js} +1 -1
  4. package/dist/budget-GOLUDBCL.js +12 -0
  5. package/dist/{chunk-UWTX2MZZ.js → chunk-DR3LDSMV.js} +1 -1
  6. package/dist/{chunk-AJ4WRMUZ.js → chunk-EFMVEUKG.js} +34 -34
  7. package/dist/{config-TFD5BJJO.js → config-4IUXVJTP.js} +1 -1
  8. package/dist/{config-DD5WRAEN.js → config-IAKKALFC.js} +1 -1
  9. package/dist/{config-help-DS2LTR5S.js → config-help-VOALBZOV.js} +1 -1
  10. package/dist/{connectors-FHYWNO5W.js → connectors-CSQK22LM.js} +1 -1
  11. package/dist/{help-RTXIBJ6C.js → help-4WGGQ6JC.js} +2 -2
  12. package/dist/index.js +1 -1
  13. package/dist/{login-CJAEUMVX.js → login-EB3L2V2J.js} +1 -1
  14. package/dist/{logout-FQMPTUEL.js → logout-ADWPA2FG.js} +1 -1
  15. package/dist/{marketplace-LIW2SN7A.js → marketplace-SQVRI7DY.js} +1 -1
  16. package/dist/{mcp-FW5USUH2.js → mcp-VDO3M3ZZ.js} +1 -1
  17. package/dist/{meeting-5BTYIWGD.js → meeting-TW3VZXAR.js} +2 -2
  18. package/dist/{models-Y2Q2FX4V.js → models-B3KI6HNA.js} +1 -1
  19. package/dist/{notifications-4U7KBVDF.js → notifications-W4JZNPP5.js} +2 -2
  20. package/dist/{profile-HEUIWMVW.js → profile-AHVLOC6L.js} +1 -1
  21. package/dist/{recordings-LKICUUCK.js → recordings-LYXVL3QK.js} +1 -1
  22. package/dist/schedules-EBOKWL2V.js +57 -0
  23. package/dist/{skills-B5E2GJFV.js → skills-KZ3IZP5O.js} +2 -2
  24. package/dist/{status-VF7DKVXN.js → status-L6BVD6XO.js} +1 -1
  25. package/dist/{task-NMVJ4NDH.js → task-RMAWXZYH.js} +40 -40
  26. package/dist/{tasks-PDRHMFWK.js → tasks-IN2ZYMSB.js} +12 -12
  27. package/dist/{token-TTVFX36M.js → token-FCXXKQBB.js} +1 -1
  28. package/dist/token-util-OEHRI4SO.js +2 -0
  29. package/dist/{tool-SF3NK5EN.js → tool-MJKJCMYH.js} +1 -1
  30. package/dist/update-5CGQNKNF.js +4 -0
  31. package/dist/{usage-PVIH4OC6.js → usage-46QSLRS2.js} +6 -6
  32. package/dist/{version-4TEIO7G3.js → version-CE6LTBHK.js} +1 -1
  33. package/dist/{workflow-FXSMA7T3.js → workflow-BR4CFCAK.js} +2 -2
  34. package/dist/{workspaces-3KKM3FBA.js → workspaces-IAN5MGM7.js} +1 -1
  35. package/package.json +5 -5
  36. package/dist/budget-VMRIKUAD.js +0 -12
  37. package/dist/schedules-QZUI6HKS.js +0 -57
  38. package/dist/token-util-YJCUCZTI.js +0 -2
  39. /package/dist/{chunk-35QGVUAZ.js → chunk-HDVXCFOU.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as le,b as fe,c as jt,g as it,h as me,m as Je,p as dn,q as We,s as fn}from"./chunk-UWTX2MZZ.js";import"./chunk-KURQCTT3.js";import{render as xs}from"ink";import{v4 as ho}from"uuid";import{exec as xn}from"child_process";import To from"fs";import _e from"fs/promises";import kn from"os";import ze from"path";import{promisify as Co}from"util";import{glob as bo}from"glob";var $o=Co(xn),Io=`## Filesystem Tool Instructions
2
+ import{a as le,b as fe,c as jt,g as it,h as me,m as Je,p as dn,q as We,s as fn}from"./chunk-DR3LDSMV.js";import"./chunk-KURQCTT3.js";import{render as ws}from"ink";import{v4 as ho}from"uuid";import{exec as wn}from"child_process";import To from"fs";import _e from"fs/promises";import kn from"os";import ze from"path";import{promisify as Co}from"util";import{glob as bo}from"glob";var $o=Co(wn),Io=`## Filesystem Tool Instructions
3
3
 
4
4
  You have access to filesystem tools that allow you to interact with the user's local filesystem.
5
5
 
@@ -24,21 +24,21 @@ You have access to filesystem tools that allow you to interact with the user's l
24
24
  - Execute Command has a default timeout of 30 seconds (max 5 minutes)
25
25
  - The current working directory is: ${process.cwd()}
26
26
  - The user's home directory is: ${kn.homedir()}
27
- `,vo=[{name:"filesystem__read_file",description:"Read the contents of a file from the local filesystem. Image files (PNG, JPEG, GIF, WebP) are returned as viewable images you can analyze directly.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path to the file to read."}},required:["path"]}},{name:"filesystem__read_multiple_files",description:"Read multiple files at once (max 10 files).",inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Array of absolute file paths to read."}},required:["paths"]}},{name:"filesystem__write_file",description:"Create or overwrite a file with the given content.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path to the file to write."},content:{type:"string",description:"The content to write to the file."}},required:["path","content"]}},{name:"filesystem__create_directory",description:"Create a new directory (including parent directories if needed).",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path of the directory to create."}},required:["path"]}},{name:"filesystem__list_directory",description:"List files and subdirectories in a directory.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path of the directory to list."}},required:["path"]}},{name:"filesystem__search_files",description:"Search for files matching a glob pattern.",inputSchema:{type:"object",properties:{pattern:{type:"string",description:'Glob pattern to match files (e.g., "**/*.ts").'},cwd:{type:"string",description:"Base directory to search in (optional)."}},required:["pattern"]}},{name:"filesystem__get_file_info",description:"Get metadata about a file or directory.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path to get info for."}},required:["path"]}},{name:"filesystem__move_file",description:"Move or rename a file or directory.",inputSchema:{type:"object",properties:{source:{type:"string",description:"The source path."},destination:{type:"string",description:"The destination path."}},required:["source","destination"]}},{name:"filesystem__execute_command",description:"Execute a shell command on the local machine.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command to execute."},cwd:{type:"string",description:"Working directory for the command (optional)."},timeout:{type:"number",description:"Timeout in milliseconds (default: 30000, max: 300000)."}},required:["command"]}}];function Tn(){return{name:"filesystem",systemPrompt:Io,tools:vo}}function Re(e){return e.startsWith("~/")?ze.join(kn.homedir(),e.slice(2)):e}var pn=4*1024*1024;function mn(e){if(e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255)return"image/jpeg";if(e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56)return"image/gif";if(e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return"image/webp"}function Wt(e){return e&&typeof e=="object"&&"code"in e?String(e.code):void 0}function gn(e){return e.normalize("NFC").replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g," ")}async function Mt(e){try{return await _e.access(e),e}catch(t){if(Wt(t)!=="ENOENT")throw t;let n=ze.dirname(e),o=ze.basename(e),i;try{i=await _e.readdir(n)}catch{throw t}let a=gn(o),g=i.filter(m=>gn(m)===a);if(g.length===1)return ze.join(n,g[0]);if(g.length>1){let m=new Error(`Multiple files match "${o}" after whitespace normalization: ${g.join(", ")}. Use filesystem__list_directory and pass an exact name.`);throw m.code="EAMBIG",m}throw t}}function wt(e,t=1e5){return e.length<=t?e:e.slice(0,t)+`
27
+ `,vo=[{name:"filesystem__read_file",description:"Read the contents of a file from the local filesystem. Image files (PNG, JPEG, GIF, WebP) are returned as viewable images you can analyze directly.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path to the file to read."}},required:["path"]}},{name:"filesystem__read_multiple_files",description:"Read multiple files at once (max 10 files).",inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Array of absolute file paths to read."}},required:["paths"]}},{name:"filesystem__write_file",description:"Create or overwrite a file with the given content.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path to the file to write."},content:{type:"string",description:"The content to write to the file."}},required:["path","content"]}},{name:"filesystem__create_directory",description:"Create a new directory (including parent directories if needed).",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path of the directory to create."}},required:["path"]}},{name:"filesystem__list_directory",description:"List files and subdirectories in a directory.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path of the directory to list."}},required:["path"]}},{name:"filesystem__search_files",description:"Search for files matching a glob pattern.",inputSchema:{type:"object",properties:{pattern:{type:"string",description:'Glob pattern to match files (e.g., "**/*.ts").'},cwd:{type:"string",description:"Base directory to search in (optional)."}},required:["pattern"]}},{name:"filesystem__get_file_info",description:"Get metadata about a file or directory.",inputSchema:{type:"object",properties:{path:{type:"string",description:"The absolute path to get info for."}},required:["path"]}},{name:"filesystem__move_file",description:"Move or rename a file or directory.",inputSchema:{type:"object",properties:{source:{type:"string",description:"The source path."},destination:{type:"string",description:"The destination path."}},required:["source","destination"]}},{name:"filesystem__execute_command",description:"Execute a shell command on the local machine.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command to execute."},cwd:{type:"string",description:"Working directory for the command (optional)."},timeout:{type:"number",description:"Timeout in milliseconds (default: 30000, max: 300000)."}},required:["command"]}}];function Tn(){return{name:"filesystem",systemPrompt:Io,tools:vo}}function Re(e){return e.startsWith("~/")?ze.join(kn.homedir(),e.slice(2)):e}var pn=4*1024*1024;function mn(e){if(e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255)return"image/jpeg";if(e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56)return"image/gif";if(e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return"image/webp"}function Wt(e){return e&&typeof e=="object"&&"code"in e?String(e.code):void 0}function gn(e){return e.normalize("NFC").replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g," ")}async function Mt(e){try{return await _e.access(e),e}catch(t){if(Wt(t)!=="ENOENT")throw t;let n=ze.dirname(e),o=ze.basename(e),i;try{i=await _e.readdir(n)}catch{throw t}let a=gn(o),g=i.filter(m=>gn(m)===a);if(g.length===1)return ze.join(n,g[0]);if(g.length>1){let m=new Error(`Multiple files match "${o}" after whitespace normalization: ${g.join(", ")}. Use filesystem__list_directory and pass an exact name.`);throw m.code="EAMBIG",m}throw t}}function xt(e,t=1e5){return e.length<=t?e:e.slice(0,t)+`
28
28
 
29
29
  ... (truncated, ${e.length-t} more characters)`}function hn(e){let t=Wt(e),n=e instanceof Error?e.message:String(e);switch(t){case"EACCES":case"EPERM":return`${n}
30
30
  Permission denied by the operating system. On macOS this is usually a privacy restriction \u2014 access can be granted under System Settings \u2192 Privacy & Security \u2192 Files and Folders (or Full Disk Access).`;case"ENOENT":return`${n}
31
31
  The path does not exist.`;case"ENOTDIR":return`${n}
32
32
  A component of the path is not a directory.`;case"EISDIR":return`${n}
33
- The path is a directory, not a file.`;default:return n}}var yn=!1;function wn(e){if(process.platform!=="darwin"||yn||!process.stdout.isTTY)return;let t=Wt(e);t!=="EPERM"&&t!=="EACCES"||(yn=!0,xn('open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"',()=>{}))}async function Cn(e,t){try{switch(e){case"filesystem__read_file":{let n=await Mt(Re(t.path)),o=await _e.readFile(n),i=mn(o);if(i){let a=o.toString("base64");return a.length>pn?{success:!0,result:`Image is too large to read inline (${o.length} bytes). Ask the user to resize/compress it, or have them upload it to the task.`}:{success:!0,content:[{type:"image",data:a,mimeType:i}],result:`[image ${ze.basename(n)} (${i}, ${o.length} bytes)]`}}return{success:!0,result:wt(o.toString("utf-8"))}}case"filesystem__read_multiple_files":{let n=t.paths.slice(0,10),o={},i=[],a=!1,g=0;for(let m of n)try{let y=await Mt(Re(m)),h=await _e.readFile(y),L=mn(h);if(L){a=!0;let $=h.toString("base64");if(g+$.length>pn){let I=`Image too large to read inline (${h.length} bytes); the combined inline-image size for this read exceeds the limit.`;o[m]=I,i.push({type:"text",text:`${m}: ${I}`})}else g+=$.length,o[m]=`[image (${L}, ${h.length} bytes)]`,i.push({type:"text",text:`File: ${m} (${L})`}),i.push({type:"image",data:$,mimeType:L})}else{let $=wt(h.toString("utf-8"),5e4);o[m]=$,i.push({type:"text",text:`File: ${m}
34
- ${$}`})}}catch(y){wn(y);let h=hn(y);o[m]={error:h},i.push({type:"text",text:`${m}: ${h}`})}return a?{success:!0,result:o,content:i}:{success:!0,result:o}}case"filesystem__write_file":{let n=Re(t.path),o=t.content;return await _e.mkdir(ze.dirname(n),{recursive:!0}),await _e.writeFile(n,o,"utf-8"),{success:!0,result:{written:n}}}case"filesystem__create_directory":{let n=Re(t.path);return await _e.mkdir(n,{recursive:!0}),{success:!0,result:{created:n}}}case"filesystem__list_directory":{let n=Re(t.path);return{success:!0,result:(await _e.readdir(n,{withFileTypes:!0})).map(a=>({name:a.name,type:a.isDirectory()?"directory":a.isFile()?"file":a.isSymbolicLink()?"symlink":"other"}))}}case"filesystem__search_files":{let n=t.pattern,o=t.cwd?Re(t.cwd):process.cwd(),i=await bo(n,{cwd:o,nodir:!0,maxDepth:10});return{success:!0,result:{files:i.slice(0,100),total:i.length,truncated:i.length>100}}}case"filesystem__get_file_info":{let n=await Mt(Re(t.path)),o=await _e.stat(n);return{success:!0,result:{path:n,type:o.isDirectory()?"directory":o.isFile()?"file":"other",size:o.size,created:o.birthtime.toISOString(),modified:o.mtime.toISOString(),accessed:o.atime.toISOString(),mode:o.mode.toString(8)}}}case"filesystem__move_file":{let n=Re(t.source),o=Re(t.destination);return await _e.mkdir(ze.dirname(o),{recursive:!0}),await _e.rename(n,o),{success:!0,result:{moved:{from:n,to:o}}}}case"filesystem__execute_command":{let n=t.command,o=t.cwd?Re(t.cwd):process.cwd(),i=Math.min(t.timeout||3e4,3e5);if(!To.existsSync(o))return{success:!1,error:`Working directory does not exist: ${o}`};let{stdout:a,stderr:g}=await $o(n,{cwd:o,timeout:i,maxBuffer:10*1024*1024});return{success:!0,result:{stdout:wt(a,5e4),stderr:wt(g,5e4)}}}default:return{success:!1,error:`Unknown tool: ${e}`}}}catch(n){return wn(n),{success:!1,error:hn(n)}}}function Gt(e){return e.startsWith("filesystem__")}function bn(){return[Tn()]}function xt(){return bn().flatMap(e=>e.tools)}function kt(){return bn().map(e=>e.systemPrompt).filter(Boolean).join(`
33
+ The path is a directory, not a file.`;default:return n}}var yn=!1;function xn(e){if(process.platform!=="darwin"||yn||!process.stdout.isTTY)return;let t=Wt(e);t!=="EPERM"&&t!=="EACCES"||(yn=!0,wn('open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"',()=>{}))}async function Cn(e,t){try{switch(e){case"filesystem__read_file":{let n=await Mt(Re(t.path)),o=await _e.readFile(n),i=mn(o);if(i){let a=o.toString("base64");return a.length>pn?{success:!0,result:`Image is too large to read inline (${o.length} bytes). Ask the user to resize/compress it, or have them upload it to the task.`}:{success:!0,content:[{type:"image",data:a,mimeType:i}],result:`[image ${ze.basename(n)} (${i}, ${o.length} bytes)]`}}return{success:!0,result:xt(o.toString("utf-8"))}}case"filesystem__read_multiple_files":{let n=t.paths.slice(0,10),o={},i=[],a=!1,g=0;for(let m of n)try{let y=await Mt(Re(m)),h=await _e.readFile(y),L=mn(h);if(L){a=!0;let $=h.toString("base64");if(g+$.length>pn){let I=`Image too large to read inline (${h.length} bytes); the combined inline-image size for this read exceeds the limit.`;o[m]=I,i.push({type:"text",text:`${m}: ${I}`})}else g+=$.length,o[m]=`[image (${L}, ${h.length} bytes)]`,i.push({type:"text",text:`File: ${m} (${L})`}),i.push({type:"image",data:$,mimeType:L})}else{let $=xt(h.toString("utf-8"),5e4);o[m]=$,i.push({type:"text",text:`File: ${m}
34
+ ${$}`})}}catch(y){xn(y);let h=hn(y);o[m]={error:h},i.push({type:"text",text:`${m}: ${h}`})}return a?{success:!0,result:o,content:i}:{success:!0,result:o}}case"filesystem__write_file":{let n=Re(t.path),o=t.content;return await _e.mkdir(ze.dirname(n),{recursive:!0}),await _e.writeFile(n,o,"utf-8"),{success:!0,result:{written:n}}}case"filesystem__create_directory":{let n=Re(t.path);return await _e.mkdir(n,{recursive:!0}),{success:!0,result:{created:n}}}case"filesystem__list_directory":{let n=Re(t.path);return{success:!0,result:(await _e.readdir(n,{withFileTypes:!0})).map(a=>({name:a.name,type:a.isDirectory()?"directory":a.isFile()?"file":a.isSymbolicLink()?"symlink":"other"}))}}case"filesystem__search_files":{let n=t.pattern,o=t.cwd?Re(t.cwd):process.cwd(),i=await bo(n,{cwd:o,nodir:!0,maxDepth:10});return{success:!0,result:{files:i.slice(0,100),total:i.length,truncated:i.length>100}}}case"filesystem__get_file_info":{let n=await Mt(Re(t.path)),o=await _e.stat(n);return{success:!0,result:{path:n,type:o.isDirectory()?"directory":o.isFile()?"file":"other",size:o.size,created:o.birthtime.toISOString(),modified:o.mtime.toISOString(),accessed:o.atime.toISOString(),mode:o.mode.toString(8)}}}case"filesystem__move_file":{let n=Re(t.source),o=Re(t.destination);return await _e.mkdir(ze.dirname(o),{recursive:!0}),await _e.rename(n,o),{success:!0,result:{moved:{from:n,to:o}}}}case"filesystem__execute_command":{let n=t.command,o=t.cwd?Re(t.cwd):process.cwd(),i=Math.min(t.timeout||3e4,3e5);if(!To.existsSync(o))return{success:!1,error:`Working directory does not exist: ${o}`};let{stdout:a,stderr:g}=await $o(n,{cwd:o,timeout:i,maxBuffer:10*1024*1024});return{success:!0,result:{stdout:xt(a,5e4),stderr:xt(g,5e4)}}}default:return{success:!1,error:`Unknown tool: ${e}`}}}catch(n){return xn(n),{success:!1,error:hn(n)}}}function Gt(e){return e.startsWith("filesystem__")}function bn(){return[Tn()]}function wt(){return bn().flatMap(e=>e.tools)}function kt(){return bn().map(e=>e.systemPrompt).filter(Boolean).join(`
35
35
 
36
36
  `)}function Oe(e){return Gt(e)}async function Tt(e,t){return Gt(e)?Cn(e,t):{success:!1,error:`Unknown client tool: ${e}`}}function Ct(e){return e.success&&e.content?e.content:[{type:"text",text:e.success?JSON.stringify(e.result):e.error||"Unknown error"}]}import{Box as ye,Text as U,useInput as rn}from"ink";import ln from"ink-spinner";import{useCallback as an,useEffect as At,useRef as cn,useState as ds}from"react";import{Box as bt,Text as lt}from"ink";import{jsx as $t,jsxs as at}from"react/jsx-runtime";function $n(e,t){return e.length<=t?e:t<=3?".".repeat(t):e.slice(0,t-3)+"..."}function In({items:e,activeIndex:t,selectedIds:n,multiSelect:o=!1,visible:i,title:a,pageSize:g=10}){if(!i||e.length===0)return null;let m=process.stdout.columns??80,y=o?4:0,h=Math.max(20,m-2-2-y),L=Math.max(1,g),$=Math.floor(t/L)*L,I=Math.min(e.length,$+L),Q=e.slice($,I);return at(bt,{flexDirection:"column",marginBottom:1,children:[$t(lt,{bold:!0,color:"cyan",children:a}),$t(bt,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:Q.map((C,k)=>{let N=$+k===t,K=n?.has(C.id),Z=$n(C.name,h),q=C.description?$n(C.description,Math.max(0,h-y)):"",j=o?" ".repeat(y):"";return at(bt,{paddingX:1,flexDirection:"column",children:[at(bt,{children:[o&&$t(lt,{color:K?"green":"gray",children:K?"[\u2713] ":"[ ] "}),$t(lt,{backgroundColor:N?"cyan":void 0,color:N?"black":K?"green":"white",bold:!0,children:Z})]}),q&&at(lt,{dimColor:!0,children:[j,"\xB7 ",q]})]},C.id)})}),at(lt,{dimColor:!0,children:[o?"\u2191\u2193 Navigate \xB7 Space Toggle \xB7 a All \xB7 n None \xB7 Enter Confirm \xB7 Esc Cancel":"\u2191\u2193 Navigate \xB7 Enter Select \xB7 Esc Cancel",e.length>L?` \xB7 Showing ${$+1}-${I} of ${e.length}`:""]})]})}import{Box as Ht,Text as ct}from"ink";import{jsx as ut,jsxs as qt}from"react/jsx-runtime";function vn({suggestions:e,activeIndex:t,visible:n}){return!n||e.length===0?null:qt(Ht,{flexDirection:"column",marginBottom:1,children:[ut(Ht,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:e.map((o,i)=>{let a=i===t,g=o.aliases.length>0?` (${o.aliases.join(", ")})`:"";return qt(Ht,{paddingX:1,children:[qt(ct,{backgroundColor:a?"cyan":void 0,color:a?"black":"cyan",bold:a,children:["/",o.name]}),ut(ct,{dimColor:!0,children:g}),ut(ct,{children:" - "}),ut(ct,{color:a?"white":"gray",children:o.description})]},o.name)})}),ut(ct,{dimColor:!0,children:"\u2191\u2193 Navigate \xB7 Tab/Enter Select \xB7 Esc Cancel"})]})}import{Box as So,Text as Sn,useInput as Po,useStdout as _o}from"ink";import{useCallback as Pn,useEffect as _n,useMemo as Jt,useRef as En,useState as Nn}from"react";import{jsx as Kt}from"react/jsx-runtime";function It(e,t){return e<0?0:e>t?t:e}function zt(e){return[...e]}function vt(e){return/\s/.test(e)}function Yt(e,t){let n=t;for(;n>0&&vt(e[n-1]??"");)n-=1;for(;n>0&&!vt(e[n-1]??"");)n-=1;return n}function An(e,t){let n=t;for(;n<e.length&&vt(e[n]??"");)n+=1;for(;n<e.length&&!vt(e[n]??"");)n+=1;return n}function Eo(e){let t=[],n=[],o=[],i=0;n.push(0),e.forEach((g,m)=>{if(g===`
37
37
  `){t.push(o),o=[],i=m+1,n.push(i);return}o.push(g)}),t.push(o);let a=t.map(g=>g.length);return{lines:t,lineStarts:n,lineLengths:a}}function Dn(e,t,n){for(let i=0;i<t.length;i+=1){let a=t[i]??0,g=n[i]??0,m=a+g;if(e<=m)return{row:i,col:e-a}}let o=Math.max(0,t.length-1);return{row:o,col:n[o]??0}}var No=2;function Rn({value:e,onChange:t,onSubmit:n,onPaste:o,focus:i=!0,leadingOffset:a=0,multiline:g=!1}){let[m,y]=Nn(()=>zt(e).length),h=En(null),[L,$]=Nn(0),I=En(null),{stdout:Q}=_o(),C=Jt(()=>zt(e),[e]),{lines:k,lineStarts:E,lineLengths:N}=Jt(()=>Eo(C),[C]),{row:K,col:Z}=Jt(()=>Dn(m,E,N),[m,E,N]),q=Math.max(1,(Q?.columns??80)-a);_n(()=>{h.current===e?y(l=>It(l,C.length)):(y(C.length),I.current=null),h.current=e},[e,C.length]),_n(()=>{$(l=>{let f=l;Z<f?f=Z:Z>=f+q&&(f=Z-q+1);let _=N[K]??0,M=Z===_?_+1:_,b=Math.max(0,M-q);return f>b&&(f=b),f<0&&(f=0),f})},[q,Z,K,N]);let j=Pn((l,f)=>{h.current=l,t(l),y(f),I.current=null},[t]),ae=Pn(async(l,f)=>{if(!i)return;let{row:_,col:M}=Dn(m,E,N),b=k[_]??[],pe=N[_]??0,te=k.length>1;if(g&&(f.meta&&f.return||f.ctrl&&l==="j"||f.shift&&f.return)){let T=[...C.slice(0,m),`
38
38
  `,...C.slice(m)].join("");j(T,m+1);return}if(f.return){n(e);return}if(f.leftArrow){f.ctrl||f.meta?(M===0&&_>0?y(E[_]-1):y(E[_]+Yt(b,M)),I.current=null):(M===0&&_>0?y(E[_]-1):y(T=>It(T-1,C.length)),I.current=null);return}if(f.rightArrow){f.ctrl||f.meta?(M>=pe&&_<k.length-1?y(E[_+1]):y(E[_]+An(b,M)),I.current=null):(M>=pe&&_<k.length-1?y(E[_+1]):y(T=>It(T+1,C.length)),I.current=null);return}if(g&&te&&f.upArrow){let T=I.current??M,B=Math.max(0,_-1),oe=Math.min(T,N[B]??0);y((E[B]??0)+oe),I.current=T;return}if(g&&te&&f.downArrow){let T=I.current??M,B=Math.min(k.length-1,_+1),oe=Math.min(T,N[B]??0);y((E[B]??0)+oe),I.current=T;return}if(f.ctrl){if(l==="a"){y(E[_]??0),I.current=null;return}if(l==="e"){y((E[_]??0)+pe),I.current=null;return}if(l==="u"){if(M>0){let T=E[_]??0,B=[...C.slice(0,T),...C.slice(m)].join("");j(B,T)}return}if(l==="k"){if(M<pe){let T=(E[_]??0)+pe,B=[...C.slice(0,m),...C.slice(T)].join("");j(B,m)}return}if(l==="w"){if(M===0&&_>0){let B=[...C.slice(0,m-1),...C.slice(m)].join("");j(B,m-1);return}let T=Yt(b,M);if(T!==M){let B=(E[_]??0)+T,oe=[...C.slice(0,B),...C.slice(m)].join("");j(oe,B)}return}if(l==="d"){if(m<C.length){let T=[...C.slice(0,m),...C.slice(m+1)].join("");j(T,m)}return}return}if(f.meta){l==="b"?(M===0&&_>0?y(E[_]-1):y(E[_]+Yt(b,M)),I.current=null):l==="f"&&(M>=pe&&_<k.length-1?y(E[_+1]):y(E[_]+An(b,M)),I.current=null);return}if(f.backspace||f.delete){if(m<=0)return;let T=[...C.slice(0,m-1),...C.slice(m)].join("");j(T,m-1);return}if(!(f.tab||f.escape)&&l.length>0){let T=g?l.replace(/\r\n/g,`
39
39
  `).replace(/\r/g,`
40
40
  `):l.replace(/\r?\n/g,"");if(!T||(T=T.replace(/^\u001B?\[200~/,"").replace(/\u001B?\[201~$/,""),!T))return;if((T.length>=No||T.includes(`
41
- `))&&o){let A=!1,z={text:T,preventDefault:()=>{A=!0}};if(await Promise.resolve(o(z)),A)return}let oe=zt(T),se=[...C.slice(0,m),...oe,...C.slice(m)].join("");j(se,m+oe.length)}},[C,m,i,N,E,k,g,o,n,j,e]);return Po(ae,{isActive:i}),Kt(So,{flexDirection:"column",children:k.map((l,f)=>{let _=f===K,b=(_&&Z===l.length?[...l," "]:l).slice(L,L+q),pe=b.join("");if(!_)return Kt(Sn,{children:pe||" "},f);let te=It(Z-L,Math.max(0,b.length-1)),T=b.slice(0,te).join(""),B=b[te]??" ",oe=b.slice(te+1).join(""),z=`${T}\x1B[7m${B}\x1B[27m${oe}`;return Kt(Sn,{children:z},f)})})}import{Box as Le,Text as Ge}from"ink";import Zt from"react";import{Text as Ie}from"ink";import Ao from"react";import{Fragment as Lo,jsx as Ee,jsxs as Bn}from"react/jsx-runtime";var Vt=2,Xt=1,Qt=2,Do=1,Ln=3,Fn=4,Ro=({text:e,defaultColor:t,linkColor:n,codeColor:o})=>{let i=t;if(!/[*_~`<[https?:]/.test(e))return Ee(Ie,{color:i,children:e});let a=[],g=0,m=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g,y;for(;(y=m.exec(e))!==null;){y.index>g&&a.push(Ee(Ie,{color:i,children:e.slice(g,y.index)},`t-${g}`));let h=y[0],L=null,$=`m-${y.index}`;try{if(h.startsWith("**")&&h.endsWith("**")&&h.length>Vt*2)L=Ee(Ie,{bold:!0,color:i,children:h.slice(Vt,-Vt)},$);else if(h.length>Xt*2&&(h.startsWith("*")&&h.endsWith("*")||h.startsWith("_")&&h.endsWith("_"))&&!/\w/.test(e.substring(y.index-1,y.index))&&!/\w/.test(e.substring(m.lastIndex,m.lastIndex+1))&&!/\S[./\\]/.test(e.substring(y.index-2,y.index))&&!/[./\\]\S/.test(e.substring(m.lastIndex,m.lastIndex+2)))L=Ee(Ie,{italic:!0,color:i,children:h.slice(Xt,-Xt)},$);else if(h.startsWith("~~")&&h.endsWith("~~")&&h.length>Qt*2)L=Ee(Ie,{strikethrough:!0,color:i,children:h.slice(Qt,-Qt)},$);else if(h.startsWith("`")&&h.endsWith("`")&&h.length>Do){let I=h.match(/^(`+)(.+?)\1$/s);I&&I[2]&&(L=Ee(Ie,{color:o,children:I[2]},$))}else if(h.startsWith("[")&&h.includes("](")&&h.endsWith(")")){let I=h.match(/\[(.*?)\]\((.*?)\)/);if(I){let Q=I[1],C=I[2];L=Bn(Ie,{color:i,children:[Q,Bn(Ie,{color:n,children:[" (",C,")"]})]},$)}}else h.startsWith("<u>")&&h.endsWith("</u>")&&h.length>Ln+Fn-1?L=Ee(Ie,{underline:!0,color:i,children:h.slice(Ln,-Fn)},$):h.match(/^https?:\/\//)&&(L=Ee(Ie,{color:n,children:h},$))}catch{L=null}a.push(L??Ee(Ie,{color:i,children:h},$)),g=m.lastIndex}return g<e.length&&a.push(Ee(Ie,{color:i,children:e.slice(g)},`t-${g}`)),Ee(Lo,{children:a.filter(h=>h!==null)})},dt=Ao.memo(Ro);import{Fragment as Wo,jsx as ce,jsxs as Mn}from"react/jsx-runtime";var Fo=1,jn=1,Bo=1,Oo=1,Uo=({content:e})=>{let t=e.join(`
41
+ `))&&o){let A=!1,z={text:T,preventDefault:()=>{A=!0}};if(await Promise.resolve(o(z)),A)return}let oe=zt(T),se=[...C.slice(0,m),...oe,...C.slice(m)].join("");j(se,m+oe.length)}},[C,m,i,N,E,k,g,o,n,j,e]);return Po(ae,{isActive:i}),Kt(So,{flexDirection:"column",children:k.map((l,f)=>{let _=f===K,b=(_&&Z===l.length?[...l," "]:l).slice(L,L+q),pe=b.join("");if(!_)return Kt(Sn,{children:pe||" "},f);let te=It(Z-L,Math.max(0,b.length-1)),T=b.slice(0,te).join(""),B=b[te]??" ",oe=b.slice(te+1).join(""),z=`${T}\x1B[7m${B}\x1B[27m${oe}`;return Kt(Sn,{children:z},f)})})}import{Box as Le,Text as Ge}from"ink";import Zt from"react";import{Text as Ie}from"ink";import Ao from"react";import{Fragment as Lo,jsx as Ee,jsxs as Bn}from"react/jsx-runtime";var Vt=2,Xt=1,Qt=2,Do=1,Ln=3,Fn=4,Ro=({text:e,defaultColor:t,linkColor:n,codeColor:o})=>{let i=t;if(!/[*_~`<[https?:]/.test(e))return Ee(Ie,{color:i,children:e});let a=[],g=0,m=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g,y;for(;(y=m.exec(e))!==null;){y.index>g&&a.push(Ee(Ie,{color:i,children:e.slice(g,y.index)},`t-${g}`));let h=y[0],L=null,$=`m-${y.index}`;try{if(h.startsWith("**")&&h.endsWith("**")&&h.length>Vt*2)L=Ee(Ie,{bold:!0,color:i,children:h.slice(Vt,-Vt)},$);else if(h.length>Xt*2&&(h.startsWith("*")&&h.endsWith("*")||h.startsWith("_")&&h.endsWith("_"))&&!/\w/.test(e.slice(Math.max(0,y.index-1),y.index))&&!/\w/.test(e.slice(m.lastIndex,m.lastIndex+1))&&!/\S[./\\]/.test(e.slice(Math.max(0,y.index-2),y.index))&&!/[./\\]\S/.test(e.slice(m.lastIndex,m.lastIndex+2)))L=Ee(Ie,{italic:!0,color:i,children:h.slice(Xt,-Xt)},$);else if(h.startsWith("~~")&&h.endsWith("~~")&&h.length>Qt*2)L=Ee(Ie,{strikethrough:!0,color:i,children:h.slice(Qt,-Qt)},$);else if(h.startsWith("`")&&h.endsWith("`")&&h.length>Do){let I=h.match(/^(`+)(.+?)\1$/s);I&&I[2]&&(L=Ee(Ie,{color:o,children:I[2]},$))}else if(h.startsWith("[")&&h.includes("](")&&h.endsWith(")")){let I=h.match(/\[(.*?)\]\((.*?)\)/);if(I){let Q=I[1],C=I[2];L=Bn(Ie,{color:i,children:[Q,Bn(Ie,{color:n,children:[" (",C,")"]})]},$)}}else h.startsWith("<u>")&&h.endsWith("</u>")&&h.length>Ln+Fn-1?L=Ee(Ie,{underline:!0,color:i,children:h.slice(Ln,-Fn)},$):/^https?:\/\//.test(h)&&(L=Ee(Ie,{color:n,children:h},$))}catch{L=null}a.push(L??Ee(Ie,{color:i,children:h},$)),g=m.lastIndex}return g<e.length&&a.push(Ee(Ie,{color:i,children:e.slice(g)},`t-${g}`)),Ee(Lo,{children:a.filter(h=>h!==null)})},dt=Ao.memo(Ro);import{Fragment as Wo,jsx as ce,jsxs as Mn}from"react/jsx-runtime";var Fo=1,jn=1,Bo=1,Oo=1,Uo=({content:e})=>{let t=e.join(`
42
42
  `);return ce(Le,{paddingLeft:jn,flexDirection:"column",children:ce(Ge,{color:"yellow",children:t})})},On=Zt.memo(Uo),jo=({itemText:e,type:t,marker:n,leadingWhitespace:o=""})=>{let i=t==="ol"?`${n}. `:`${n} `,a=i.length,g=o.length;return Mn(Le,{paddingLeft:g+Bo,flexDirection:"row",children:[ce(Le,{width:a,children:ce(Ge,{children:i})}),ce(Le,{flexGrow:Oo,children:ce(Ge,{wrap:"wrap",children:ce(dt,{text:e,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})})]})},Un=Zt.memo(jo),Mo=({text:e,renderMarkdown:t=!0})=>{if(!e)return null;if(!t)return ce(Le,{paddingLeft:jn,flexDirection:"column",children:ce(Ge,{wrap:"wrap",children:e})});let n=e.split(/\r?\n/),o=/^ *(#{1,4}) +(.*)/,i=/^ *(`{3,}|~{3,}) *(\w*?) *$/,a=/^([ \t]*)([-*+]) +(.*)/,g=/^([ \t]*)(\d+)\. +(.*)/,m=/^ *([-*_] *){3,} *$/,y=/^ *> ?(.*)/,h=[],L=!1,$=!0,I=[],Q="";function C(k){k&&(h.push(k),$=!1)}return n.forEach((k,E)=>{let N=`line-${E}`;if(L){let f=k.match(i);f&&f[1].startsWith(Q[0])&&f[1].length>=Q.length?(C(ce(On,{content:I},N)),L=!1,I=[],Q=""):I.push(k);return}let K=k.match(i),Z=k.match(o),q=k.match(a),j=k.match(g),ae=k.match(m),l=k.match(y);if(K)L=!0,Q=K[1];else if(ae)C(ce(Le,{children:ce(Ge,{dimColor:!0,children:"---"})},N));else if(Z){let f=Z[1].length,_=Z[2],M=f<=2?"cyan":"blue";C(ce(Le,{children:ce(Ge,{color:M,...(f===4?"italic":"bold")==="italic"?{italic:!0}:{bold:!0},children:ce(dt,{text:_,defaultColor:M,linkColor:"cyan",codeColor:"yellow"})})},N))}else if(l){let f=l[1];C(ce(Le,{paddingLeft:1,children:Mn(Ge,{dimColor:!0,children:["> ",ce(dt,{text:f,defaultColor:"gray",linkColor:"cyan",codeColor:"yellow"})]})},N))}else if(q){let f=q[1],_=q[2],M=q[3];C(ce(Un,{itemText:M,type:"ul",marker:_,leadingWhitespace:f},N))}else if(j){let f=j[1],_=j[2],M=j[3];C(ce(Un,{itemText:M,type:"ol",marker:_,leadingWhitespace:f},N))}else k.trim().length===0?$||(h.push(ce(Le,{height:Fo},`spacer-${E}`)),$=!0):C(ce(Le,{children:ce(Ge,{wrap:"wrap",children:ce(dt,{text:k,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})},N))}),L&&C(ce(On,{content:I},"line-eof")),ce(Wo,{children:h})},en=Zt.memo(Mo);import{execFile as Go}from"child_process";import Ho from"fs";import tt from"fs/promises";import Wn from"os";import Pt from"path";import{promisify as qo}from"util";var St=qo(Go);async function Jo(){let e=Pt.join(Wn.tmpdir(),`entrydesk-clipboard-${Date.now()}.png`);try{let t=`
43
43
  set imageData to the clipboard as "PNGf"
44
44
  set fileRef to open for access POSIX file "${e}" with write permission
@@ -55,7 +55,7 @@ ${$}`})}}catch(y){wn(y);let h=hn(y);o[m]={error:h},i.push({type:"text",text:`${m
55
55
  }
56
56
  `,{stdout:t}=await St("powershell.exe",["-command",e]),n=t.trim();if(!n)return;let o=Buffer.from(n,"base64");return o.length===0?void 0:{buffer:o,mime:"image/png"}}catch{return}}async function Yo(){try{let{stdout:e}=await St("wl-paste",["-t","image/png"],{encoding:"buffer",maxBuffer:52428800});if(e&&e.length>0)return{buffer:e,mime:"image/png"}}catch{}try{let{stdout:e}=await St("xclip",["-selection","clipboard","-t","image/png","-o"],{encoding:"buffer",maxBuffer:52428800});if(e&&e.length>0)return{buffer:e,mime:"image/png"}}catch{}}async function Gn(){let e=Wn.platform();if(e==="darwin")return Jo();if(e==="win32")return zo();if(e==="linux")return Yo()}var Ko=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".heic",".heif",".pdf",".txt",".md",".rtf",".csv",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".key",".pages",".numbers",".odt",".ods",".odp",".json",".xml",".yaml",".yml"]);function Hn(e){let t=Pt.extname(e).toLowerCase();return Ko.has(t)}function Vo(e){let t=Pt.extname(e).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".txt":"text/plain",".md":"text/markdown",".pdf":"application/pdf",".csv":"text/csv",".rtf":"application/rtf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".key":"application/vnd.apple.keynote",".pages":"application/vnd.apple.pages",".numbers":"application/vnd.apple.numbers",".odt":"application/vnd.oasis.opendocument.text",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odp":"application/vnd.oasis.opendocument.presentation",".json":"application/json",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml"}[t]||"application/octet-stream"}function _t(e){let t=e.trim();return t.startsWith("file://")&&(t=decodeURIComponent(t.slice(7))),(t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"'))&&(t=t.slice(1,-1)),t=t.replace(/\\(.)/g,"$1"),t}async function qn(e){let t=_t(e);if(/^https?:\/\//.test(t))return!1;try{return await tt.access(t),!0}catch{return!1}}async function Jn(e){let t=_t(e);try{if(!(await tt.stat(t)).isFile())return;let o=await tt.readFile(t),i=Vo(t),a=Pt.basename(t);return{buffer:o,mimeType:i,filename:a}}catch{return}}var ve="\x1B[2m",X="\x1B[0m",he="\x1B[36m",nt="\x1B[32m",zn="\x1B[31m",Ye="\x1B[38;2;59;91;204m",tn="\x1B[38;2;126;200;248m",nn="\x1B[38;2;244;196;78m";import{useState as Ue}from"react";import{v4 as Yn}from"uuid";function Kn(e,t){let[n,o]=Ue({status:"loading"}),[i,a]=Ue([]),[g,m]=Ue(""),[y,h]=Ue(()=>e||Yn()),[L,$]=Ue(t),[I,Q]=Ue(!!e),[C,k]=Ue(null),[E,N]=Ue(""),[K,Z]=Ue(!1),q=ae=>{a(l=>[...l,{role:"system",content:ae}])};return{state:n,setState:o,messages:i,setMessages:a,input:g,setInput:m,taskId:y,setTaskId:h,currentTaskTitle:L,setCurrentTaskTitle:$,hasPersistedTask:I,setHasPersistedTask:Q,credentials:C,setCredentials:k,currentResponse:E,setCurrentResponse:N,fullOutput:K,setFullOutput:Z,addSystemMessage:q,startNewTask:ae=>{let l=Yn();h(l),$(void 0),Q(!1),a([]),ae&&q(ae)}}}import{useEffect as Xo,useState as Vn}from"react";function Xn(e){let[t,n]=Vn(null),[o,i]=Vn(!0);return Xo(()=>{let a=!1;async function g(){try{let m=await We();if(a)return;n({accessToken:m.accessToken,workspaceId:m.workspaceId}),i(!1)}catch(m){if(a)return;if(m instanceof Je){if(m.code==="not-logged-in"){e({status:"not-logged-in"}),i(!1);return}if(m.code==="no-workspace"){e({status:"no-workspace"}),i(!1);return}}let y=m instanceof Error?m.message:"Failed to authenticate";e({status:"error",message:y}),i(!1)}}return g(),()=>{a=!0}},[e]),{credentials:t,loading:o}}import{useEffect as Qo,useState as ft}from"react";function Qn(e){let[t,n]=ft([]),[o,i]=ft([]),[a,g]=ft([]),[m,y]=ft([]),[h,L]=ft(!1);return Qo(()=>{if(!e)return;let $=!1;L(!0);async function I(){if(e)try{let Q=new me,[C,k,E,N]=await Promise.all([Q.getConnectors(e.accessToken,e.workspaceId),Q.listSelectableModels(e.accessToken,e.workspaceId),Q.getAgents(e.accessToken,e.workspaceId),Q.getModelProviders(e.accessToken,e.workspaceId)]);if($)return;n(C.connectors),i(k.models),g(E.agents),y(N.providers??[])}catch{}finally{$||L(!1)}}return I(),()=>{$=!0}},[e]),{availableConnectors:t,availableModels:o,availableAgents:a,modelProviders:m,loading:h}}import ot from"fs";import eo from"path";import{useCallback as Zo}from"react";import{v4 as es}from"uuid";function Zn(e,t){if(!e)return"(no result)";if(typeof e!="object"){let i=String(e);return t||i.length<=200?i:i.slice(0,200)+"..."}let n=e;if("structuredContent"in n&&n.structuredContent){let i=n.structuredContent;if(i.stdout&&typeof i.stdout=="string"){let a=i.stdout.trim();return t||a.length<=200?a:a.slice(0,200)+"..."}}if("content"in n&&Array.isArray(n.content)){let i=n.content.filter(a=>a.type==="text"&&a.text).map(a=>a.text).join(`
57
57
  `);return i?t||i.length<=200?i:i.slice(0,200)+"...":"(result)"}let o=JSON.stringify(e,null,t?2:void 0);return t||o.length<=200?o:o.slice(0,200)+"..."}function Ke(e,t=!1){let n=[];for(let o of e)if(o.type==="text"&&o.text)n.push(o.text);else if(o.type==="reasoning"&&o.text)t?n.push(`${ve}[Thinking]
58
- ${o.text}${X}`):n.push(`${ve}[Thinking...]${X}`);else if(o.type==="tool-call"&&o.toolName){let i=[`${he}\u250C\u2500 Tool: ${o.toolName}${X}`];if(o.args){let a=JSON.stringify(o.args,null,t?2:void 0),g=t||a.length<=100?a:a.slice(0,100)+"...";i.push(`${ve}\u2502 Args: ${g}${X}`)}o.result!==void 0?(i.push(`${nt}\u2502 Result: ${Zn(o.result,t)}${X}`),i.push(`${he}\u2514\u2500 completed${X}`)):i.push(`${he}\u2514\u2500${X}`),n.push(i.join(`
58
+ ${o.text}${X}`):n.push(`${ve}[Thinking...]${X}`);else if(o.type==="tool-call"&&o.toolName){let i=[`${he}\u250C\u2500 Tool: ${o.toolName}${X}`];if(o.args){let a=JSON.stringify(o.args,null,t?2:void 0),g=t||a.length<=100?a:a.slice(0,100)+"...";i.push(`${ve}\u2502 Args: ${g}${X}`)}o.result===void 0?i.push(`${he}\u2514\u2500${X}`):(i.push(`${nt}\u2502 Result: ${Zn(o.result,t)}${X}`),i.push(`${he}\u2514\u2500 completed${X}`)),n.push(i.join(`
59
59
  `))}else if(o.type.startsWith("tool-")&&o.type!=="tool-call"){let i=o.title||o.type.slice(5).replace(/__/g," "),a=[`${he}\u250C\u2500 Tool: ${i}${X}`];if(o.input){let g=JSON.stringify(o.input,null,t?2:void 0),m=t||g.length<=100?g:g.slice(0,100)+"...";a.push(`${ve}\u2502 Input: ${m}${X}`)}o.output!==void 0&&o.state==="output-available"?(a.push(`${nt}\u2502 Output: ${Zn(o.output,t)}${X}`),a.push(`${he}\u2514\u2500 completed${X}`)):o.state==="error"?a.push(`${he}\u2514\u2500 failed${X}`):a.push(`${he}\u2514\u2500${X}`),n.push(a.join(`
60
60
  `))}return n.join(`
61
61
 
@@ -84,13 +84,13 @@ ${he}\u2514\u2500 failed${X}
84
84
  `,this.pendingToolCalls.delete(t.toolCallId),{fullResponse:n,toolDisplay:this.buildToolDisplay()}}};var pt=eo.join(process.env.HOME||"/tmp",".entrydesk","stream-debug.log");function ne(e,t){if(!process.env.DEBUG)return;let o=`[${new Date().toISOString()}] ${e}`;t!==void 0&&(o+=`
85
85
  DATA: ${JSON.stringify(t,null,2)}`),o+=`
86
86
  `;try{ot.appendFileSync(pt,o)}catch{}}function ts(){try{if(ot.existsSync(pt)&&ot.unlinkSync(pt),process.env.DEBUG){let e=eo.dirname(pt);ot.existsSync(e)||ot.mkdirSync(e,{recursive:!0}),ot.writeFileSync(pt,`=== Debug session started at ${new Date().toISOString()} ===
87
- `)}}catch{}}function Nt(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch{return{}}return typeof e=="object"?e:{}}function to({taskId:e,credentials:t,currentAgentId:n,currentModel:o,activeConnectorIds:i,localTools:a,fullOutput:g,setMessages:m,setState:y,setCurrentResponse:h,setCredentials:L,setHasPersistedTask:$,getFileIds:I,clearFiles:Q}){let C=a?xt():void 0,k=a?kt():void 0;return{sendMessage:Zo(async(N,K,Z)=>{ts(),ne("=== sendMessage called ===",{text:N,localTools:a,clientToolsCount:C?.length});let q=K||t?.accessToken,j=Z||t?.workspaceId;if(!q||!j)try{let f=await We();q=f.accessToken,j=f.workspaceId,L(f)}catch(f){if(f instanceof Je){if(f.code==="not-logged-in"){y({status:"not-logged-in"});return}if(f.code==="no-workspace"){y({status:"no-workspace"});return}}let _=f instanceof Error?f.message:"Authentication failed";y({status:"error",message:_});return}else try{let f=await dn();f!==q&&(q=f,L({accessToken:f,workspaceId:j}))}catch(f){if(f instanceof Je&&f.code==="not-logged-in"){y({status:"not-logged-in"});return}let _=f instanceof Error?f.message:"Authentication failed";y({status:"error",message:_});return}m(f=>[...f,{role:"user",content:N}]),y({status:"sending"}),h("");let ae=null,l=null;try{let f=new me,_=I?.()??[],M={id:e,message:{id:es(),createdAt:new Date,role:"user",parts:[{type:"text",text:N}]}};_.length>0&&(M.fileIds=_),n?M.agentId=n:(o&&(M.model=o),M.connectorIds=i??[]),C&&(M.clientTools=C),k&&(M.clientToolSystemPrompt=k);let b=await f.task(q,j,M);if(!b.ok){let v=await b.text();throw new Error(`API error ${b.status}: ${v}`)}if(!b.body)throw new Error("No response body from server");ae=b.body.getReader();let pe=new TextDecoder,te="",T="",B="",oe="",se="",A="",z="",Y=new Et,V=[],W=[],ie=[],F=()=>{let v=Y.hasExecuting();v&&!l?l=setInterval(()=>{if(!Y.hasExecuting()){l&&(clearInterval(l),l=null);return}h(T+Y.buildToolDisplay())},1e3):!v&&l&&(clearInterval(l),l=null)};for(;;){let{done:v,value:O}=await ae.read();if(v)break;te+=pe.decode(O,{stream:!0});let S=te.split(`
87
+ `)}}catch{}}function Nt(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch{return{}}return typeof e=="object"?e:{}}function to({taskId:e,credentials:t,currentAgentId:n,currentModel:o,activeConnectorIds:i,localTools:a,fullOutput:g,setMessages:m,setState:y,setCurrentResponse:h,setCredentials:L,setHasPersistedTask:$,getFileIds:I,clearFiles:Q}){let C=a?wt():void 0,k=a?kt():void 0;return{sendMessage:Zo(async(N,K,Z)=>{ts(),ne("=== sendMessage called ===",{text:N,localTools:a,clientToolsCount:C?.length});let q=K||t?.accessToken,j=Z||t?.workspaceId;if(!q||!j)try{let f=await We();q=f.accessToken,j=f.workspaceId,L(f)}catch(f){if(f instanceof Je){if(f.code==="not-logged-in"){y({status:"not-logged-in"});return}if(f.code==="no-workspace"){y({status:"no-workspace"});return}}let _=f instanceof Error?f.message:"Authentication failed";y({status:"error",message:_});return}else try{let f=await dn();f!==q&&(q=f,L({accessToken:f,workspaceId:j}))}catch(f){if(f instanceof Je&&f.code==="not-logged-in"){y({status:"not-logged-in"});return}let _=f instanceof Error?f.message:"Authentication failed";y({status:"error",message:_});return}m(f=>[...f,{role:"user",content:N}]),y({status:"sending"}),h("");let ae=null,l=null;try{let f=new me,_=I?.()??[],M={id:e,message:{id:es(),createdAt:new Date,role:"user",parts:[{type:"text",text:N}]}};_.length>0&&(M.fileIds=_),n?M.agentId=n:(o&&(M.model=o),M.connectorIds=i??[]),C&&(M.clientTools=C),k&&(M.clientToolSystemPrompt=k);let b=await f.task(q,j,M);if(!b.ok){let v=await b.text();throw new Error(`API error ${b.status}: ${v}`)}if(!b.body)throw new Error("No response body from server");ae=b.body.getReader();let pe=new TextDecoder,te="",T="",B="",oe="",se="",A="",z="",Y=new Et,V=[],W=[],ie=[],F=()=>{let v=Y.hasExecuting();v&&!l?l=setInterval(()=>{if(!Y.hasExecuting()){l&&(clearInterval(l),l=null);return}h(T+Y.buildToolDisplay())},1e3):!v&&l&&(clearInterval(l),l=null)};for(;;){let{done:v,value:O}=await ae.read();if(v)break;te+=pe.decode(O,{stream:!0});let S=te.split(`
88
88
  `);te=S.pop()||"";for(let G of S)if(G.trim()!=="data: [DONE]"&&G.startsWith("data: "))try{let p=JSON.parse(G.slice(6));switch(ne(`SSE event received: ${p.type}`,p),p.type){case"reasoning-start":oe=p.id||"0",B="";break;case"reasoning-delta":p.delta&&(B+=p.delta,h(`${ve}[Thinking...]${X}
89
- ${B}`)),p.providerMetadata?.anthropic?.signature&&(se=p.providerMetadata.anthropic.signature);break;case"reasoning-end":if(B){let P={type:"reasoning",id:oe,text:B,state:"done"};se&&(P.providerMetadata={anthropic:{signature:se}}),W.push(P),ne("Added reasoning to messageParts",{reasoningLength:B.length,hasSignature:!!se,messagePartsCount:W.length})}B="",se="",h("");break;case"text-delta":p.delta&&(Y.hasPending()&&(T=Y.flushPending(T)),T+=p.delta,A+=p.delta,h(T));break;case"tool-input-start":{let P=Y.handleToolInputStart(p);P&&h(T+P),F();break}case"tool-input-delta":{let P=Y.handleToolInputDelta(p);P&&h(T+P),F();break}case"tool-call":case"tool-input-available":{if(ne(`=== Tool event: ${p.type} ===`,{toolCallId:p.toolCallId,toolName:p.toolName,localTools:a,isClientToolResult:p.toolName?Oe(p.toolName):"no toolName",args:p.args,input:p.input}),p.toolCallId&&p.toolName){let P=Nt(p.args??p.input);W.push({type:p.type,toolCallId:p.toolCallId,toolName:p.toolName,args:P}),ne("Added tool to messageParts",{messagePartsCount:W.length})}if(a&&p.toolCallId&&p.toolName&&Oe(p.toolName)){let P=Nt(p.args??p.input);V.push({toolCallId:p.toolCallId,toolName:p.toolName,args:P}),ne("Added to pendingClientTools",{pendingCount:V.length,pendingClientTools:V}),h(T+Y.buildToolDisplay()+`
90
- [Executing ${p.toolName} locally...]`)}else ne("NOT added to pendingClientTools - conditions not met",{localTools:a,hasToolCallId:!!p.toolCallId,hasToolName:!!p.toolName,isClientTool:p.toolName?Oe(p.toolName):!1});break}case"tool-output-start":{let P=Y.handleToolOutputStart(p);P&&h(T+P),F();break}case"tool-output-delta":{let P=Y.handleToolOutputDelta(p);P&&h(T+P),F();break}case"tool-output-end":{let P=Y.handleToolOutputEnd(p,T);P&&(T=P.fullResponse,h(T+P.toolDisplay)),F();break}case"tool-input-error":case"tool-output-error":{let P=Y.handleToolError(p,T);P&&(T=P.fullResponse,h(T+P.toolDisplay)),F();break}case"start":p.messageId&&(z=p.messageId,ne("Captured messageId from start event",{messageId:z}));break;case"start-step":case"text-start":case"text-end":case"finish-step":case"message-metadata":case"finish":break;case"error":p.errorText&&console.error("Stream error:",p.errorText);break}}catch{}}if(A){let v=W.findIndex(S=>S.type!=="reasoning"),O=v===-1?W.length:v;W.splice(O,0,{type:"text",text:A}),ne("Added accumulated text to messageParts",{textLength:A.length,insertIndex:O})}for(ne("=== Initial stream ended ===",{pendingClientToolsCount:V.length,pendingClientTools:V,messagePartsCount:W.length,messageParts:W.map(v=>({type:v.type,toolCallId:v.toolCallId,toolName:v.toolName}))});V.length>0;){ne("=== Starting pending tools execution loop ===",{pendingCount:V.length});let v=[];for(let p of V){ne(`Executing tool: ${p.toolName}`,{toolCallId:p.toolCallId,args:p.args}),Y.handleToolInputStart({toolCallId:p.toolCallId,toolName:p.toolName}),Y.handleToolInputDelta({toolCallId:p.toolCallId,inputTextDelta:JSON.stringify(p.args)}),h(T+Y.buildToolDisplay()),F();let P=await Tt(p.toolName,p.args);if(ne(`Tool execution result: ${p.toolName}`,{success:P.success,resultPreview:P.success?JSON.stringify(P.result).slice(0,200):P.error}),v.push({toolCallId:p.toolCallId,toolName:p.toolName,content:Ct(P),isError:!P.success}),P.success){Y.handleToolOutputStart({toolCallId:p.toolCallId}),Y.handleToolOutputDelta({toolCallId:p.toolCallId,outputTextDelta:JSON.stringify(P.result).slice(0,200)});let w=Y.handleToolOutputEnd({toolCallId:p.toolCallId},T);w&&(T=w.fullResponse)}else{let w=Y.handleToolError({toolCallId:p.toolCallId,errorText:P.error},T);w&&(T=w.fullResponse)}h(T+Y.buildToolDisplay()),F()}V.length=0;for(let p of v){let P=W.find(w=>(w.type==="tool-input-available"||w.type==="tool-call")&&w.toolCallId===p.toolCallId);if(P){let w=[];for(let R of p.content)R.type==="text"?w.push(R.text):R.type==="image"?w.push("[Image]"):R.type==="audio"?w.push("[Audio]"):(R.type==="resource"||R.type==="resource_link")&&w.push("[Resource]");let ue=w.join(`
91
- `);ie.push({type:`tool-${P.toolName}`,toolName:P.toolName,toolCallId:P.toolCallId,input:P.args,output:ue,isError:p.isError})}}if(ne("=== Sending clientToolResults for continuation ===",{toolResultsCount:v.length,toolResults:v.map(p=>({toolCallId:p.toolCallId,toolName:p.toolName,isError:p.isError}))}),ae)try{ae.releaseLock()}catch{}let O=v.map(p=>({type:`tool-${p.toolName}`,toolCallId:p.toolCallId,state:"output-available",output:{content:p.content,isError:p.isError}}));if(!z)throw new Error("Cannot continue: missing assistant message id for tool results.");let S={id:e,message:{id:z,role:"assistant",parts:O}};n?S.agentId=n:(o&&(S.model=o),S.connectorIds=i??[]),C&&(S.clientTools=C),k&&(S.clientToolSystemPrompt=k),ne("=== Sending continuation request ===",{taskId:e,hasAgentId:!!S.agentId,hasModel:!!S.model,clientToolResultsCount:v.length});let G=await f.task(q,j,S);if(ne("=== Continuation response received ===",{ok:G.ok,status:G.status}),!G.ok){let p=await G.text();throw new Error(`Continuation failed: ${G.status}: ${p}`)}if(!G.body)break;for(ne("=== Processing continuation stream ==="),ae=G.body.getReader(),W.length=0,A="",B="",oe="",se="";;){let{done:p,value:P}=await ae.read();if(p){ne("=== Continuation stream done ===");break}te+=pe.decode(P,{stream:!0});let w=te.split(`
92
- `);te=w.pop()||"";for(let ue of w)if(ue.trim()!=="data: [DONE]"&&ue.startsWith("data: "))try{let R=JSON.parse(ue.slice(6));switch(ne(`Continuation SSE: ${R.type}`,R),R.type){case"start":R.messageId&&(z=R.messageId);break;case"reasoning-start":oe=R.id||"0",B="";break;case"reasoning-delta":R.delta&&(B+=R.delta,h(`${ve}[Thinking...]${X}
93
- ${B}`)),R.providerMetadata?.anthropic?.signature&&(se=R.providerMetadata.anthropic.signature);break;case"reasoning-end":if(B){let $e={type:"reasoning",id:oe,text:B,state:"done"};se&&($e.providerMetadata={anthropic:{signature:se}}),W.push($e),ne("Continuation: Added reasoning to messageParts",{reasoningLength:B.length,hasSignature:!!se,messagePartsCount:W.length})}B="",se="",h(T);break;case"text-delta":R.delta&&(T+=R.delta,A+=R.delta,h(T));break;case"tool-call":case"tool-input-available":if(R.toolCallId&&R.toolName){let $e=Nt(R.args??R.input);W.push({type:R.type,toolCallId:R.toolCallId,toolName:R.toolName,args:$e})}if(a&&R.toolCallId&&R.toolName&&Oe(R.toolName)){let $e=Nt(R.args??R.input);V.push({toolCallId:R.toolCallId,toolName:R.toolName,args:$e}),ne("Continuation: Added to pendingClientTools",{pendingCount:V.length})}break;case"finish":ne("Continuation finish event",R);break}}catch{}}if(A){let p=W.findIndex(w=>w.type!=="reasoning"),P=p===-1?W.length:p;W.splice(P,0,{type:"text",text:A})}ne("=== Continuation stream processing complete ===",{pendingClientToolsCount:V.length,messagePartsCount:W.length,fullResponseLength:T.length})}if(a&&C&&C.length>0){let v=[];for(let S of ie)v.push({type:String(S.type),title:String(S.toolName).replace(/__/g," "),input:S.input,output:S.output,state:S.isError?"error":"output-available"});for(let S of W)S.type==="text"&&S.text&&v.push({type:"text",text:S.text});let O=Ke(v,g);ne("=== Using formatted parts for local tools ===",{executedToolsCount:ie.length,textPartsCount:W.filter(S=>S.type==="text").length,contentLength:O.length}),m(S=>[...S,{role:"assistant",content:O,parts:v}])}else{ne("=== Fetching message from API ===",{fullResponseLength:T.length,fullResponsePreview:T.slice(0,200)});try{let{messages:v}=await f.getMessages(q,j,e,10);ne("=== API messages received ===",{count:v.length,roles:v.map(S=>S.role)});let O=v.find(S=>S.role==="assistant");if(O){let S=O.parts,G=Ke(S,g);ne("=== Setting message from API ===",{partsCount:S.length,partTypes:S.map(p=>p.type),contentLength:G.length,contentPreview:G.slice(0,200)}),m(p=>[...p,{role:"assistant",content:G,parts:S}])}else ne("=== No assistant message found, using fallback ==="),m(S=>[...S,{role:"assistant",content:T}])}catch(v){ne("=== API fetch failed, using fallback ===",{error:v instanceof Error?v.message:String(v)}),m(O=>[...O,{role:"assistant",content:T}])}}ne("=== Message handling complete ==="),h(""),y({status:"ready"}),$(!0),_.length>0&&Q?.()}catch(f){ne("=== ERROR ===",{message:f instanceof Error?f.message:String(f),stack:f instanceof Error?f.stack:void 0});let _=f instanceof Error?f.message:"Failed to send message";y({status:"error",message:_})}finally{if(l&&(clearInterval(l),l=null),ae)try{ae.releaseLock()}catch{}}},[t,e,n,o,i,a,C,k,g,m,y,h,L,$,I,Q])}}import{useState as ns}from"react";var no=new Map([["sandbox","Sandbox"],["web_search","Web Search"],["image_generation","Image Generation"],["chart","Chart"],["file_system","FileSystem"]]);function oo(e){let[t,n]=ns(e);return{fileSystem:t,setFileSystem:n,capabilityLabelMap:no}}import{useEffect as os,useState as ss}from"react";function so(e,t){let[n,o]=ss(null);return os(()=>{let i=!1;async function a(){if(!e||!t){o(null);return}try{let m=await new me().getAgent(t.accessToken,t.workspaceId,e);i||o(m)}catch{i||o(null)}}return a(),()=>{i=!0}},[e,t]),{currentAgentDetails:n}}import{useState as on}from"react";function ro(e,t,n){let[o,i]=on(e),[a,g]=on(t),[m,y]=on(n);return{currentModel:o,setCurrentModel:i,currentAgentId:a,setCurrentAgentId:g,activeConnectorIds:m,setActiveConnectorIds:y}}import{useApp as is,useInput as ls}from"ink";import{useCallback as je,useRef as as,useState as Ce}from"react";import{spawn as rs}from"child_process";function io(e){return new Promise((t,n)=>{let o,i;process.platform==="darwin"?(o="open",i=[e]):process.platform==="win32"?(o="cmd",i=["/c","start","",e]):(o="xdg-open",i=[e]);let a=rs(o,i,{stdio:"ignore",detached:!0});a.once("error",g=>{n(g)}),a.once("spawn",()=>{a.unref(),t()})})}var lo=[{name:"help",aliases:["h","?"],description:"Show available commands"},{name:"clear",aliases:["cls","new"],description:"Start a new task"},{name:"model",aliases:["m"],description:"Show/switch model",hasArgs:!0},{name:"agent",aliases:["a"],description:"Show/switch agent",hasArgs:!0},{name:"skills",aliases:["sk"],description:"List skills",hasArgs:!0},{name:"schedules",aliases:["sch"],description:"List schedules",hasArgs:!0},{name:"connectors",aliases:["conn"],description:"Select connectors"},{name:"capabilities",aliases:["cap"],description:"Toggle client capabilities"},{name:"tasks",aliases:["c"],description:"Switch to another task"},{name:"workspace",aliases:["ws"],description:"List/switch workspace",hasArgs:!0},{name:"budget",aliases:["bg"],description:"View/set workspace budget",hasArgs:!0},{name:"usage",aliases:["u"],description:"View current month usage"},{name:"status",aliases:["s"],description:"Show session status"},{name:"profile",aliases:["p"],description:"Manage profiles",hasArgs:!0},{name:"open-in-browser",aliases:[],description:"Open current task in browser"},{name:"share",aliases:[],description:"Get share link for current task"},{name:"delete",aliases:["del"],description:"Delete current task"},{name:"quit",aliases:["exit","q"],description:"Exit task"}];function ao(e){if(!e.startsWith("/"))return[];let t=e.slice(1).toLowerCase();return t?lo.filter(n=>n.name.startsWith(t)||n.aliases.some(o=>o.startsWith(t))):lo}function co(e){let t=e.trim();if(!t.startsWith("/"))return null;let n=t.slice(1).split(/\s+/),o=n[0]?.toLowerCase(),i=n.slice(1).join(" ");switch(o){case"help":case"h":case"?":return{type:"help"};case"clear":case"cls":case"new":return{type:"clear"};case"model":case"m":return{type:"model",value:i||void 0};case"agent":case"a":return{type:"agent",value:i||void 0};case"skills":case"sk":return{type:"skills",value:i||void 0};case"schedules":case"sch":return{type:"schedules",value:i||void 0};case"connectors":case"conn":return{type:"connectors"};case"capabilities":case"cap":return{type:"capabilities"};case"tasks":case"c":return{type:"tasks"};case"workspace":case"ws":return{type:"workspace",value:i||void 0};case"budget":case"bg":return{type:"budget",value:i||void 0};case"usage":case"u":return{type:"usage"};case"status":case"s":return{type:"status"};case"profile":case"p":return{type:"profile",value:i||void 0};case"open-in-browser":return{type:"open-in-browser"};case"share":return{type:"share"};case"delete":case"del":return{type:"delete"};case"quit":case"exit":case"q":return{type:"quit"};default:return{type:"unknown",input:t}}}var uo=`Available commands:
89
+ ${B}`)),p.providerMetadata?.anthropic?.signature&&(se=p.providerMetadata.anthropic.signature);break;case"reasoning-end":if(B){let P={type:"reasoning",id:oe,text:B,state:"done"};se&&(P.providerMetadata={anthropic:{signature:se}}),W.push(P),ne("Added reasoning to messageParts",{reasoningLength:B.length,hasSignature:!!se,messagePartsCount:W.length})}B="",se="",h("");break;case"text-delta":p.delta&&(Y.hasPending()&&(T=Y.flushPending(T)),T+=p.delta,A+=p.delta,h(T));break;case"tool-input-start":{let P=Y.handleToolInputStart(p);P&&h(T+P),F();break}case"tool-input-delta":{let P=Y.handleToolInputDelta(p);P&&h(T+P),F();break}case"tool-call":case"tool-input-available":if(ne(`=== Tool event: ${p.type} ===`,{toolCallId:p.toolCallId,toolName:p.toolName,localTools:a,isClientToolResult:p.toolName?Oe(p.toolName):"no toolName",args:p.args,input:p.input}),p.toolCallId&&p.toolName){let P=Nt(p.args??p.input);W.push({type:p.type,toolCallId:p.toolCallId,toolName:p.toolName,args:P}),ne("Added tool to messageParts",{messagePartsCount:W.length})}if(a&&p.toolCallId&&p.toolName&&Oe(p.toolName)){let P=Nt(p.args??p.input);V.push({toolCallId:p.toolCallId,toolName:p.toolName,args:P}),ne("Added to pendingClientTools",{pendingCount:V.length,pendingClientTools:V}),h(T+Y.buildToolDisplay()+`
90
+ [Executing ${p.toolName} locally...]`)}else ne("NOT added to pendingClientTools - conditions not met",{localTools:a,hasToolCallId:!!p.toolCallId,hasToolName:!!p.toolName,isClientTool:p.toolName?Oe(p.toolName):!1});break;case"tool-output-start":{let P=Y.handleToolOutputStart(p);P&&h(T+P),F();break}case"tool-output-delta":{let P=Y.handleToolOutputDelta(p);P&&h(T+P),F();break}case"tool-output-end":{let P=Y.handleToolOutputEnd(p,T);P&&(T=P.fullResponse,h(T+P.toolDisplay)),F();break}case"tool-input-error":case"tool-output-error":{let P=Y.handleToolError(p,T);P&&(T=P.fullResponse,h(T+P.toolDisplay)),F();break}case"start":p.messageId&&(z=p.messageId,ne("Captured messageId from start event",{messageId:z}));break;case"start-step":case"text-start":case"text-end":case"finish-step":case"message-metadata":case"finish":break;case"error":p.errorText&&console.error("Stream error:",p.errorText);break}}catch{}}if(A){let v=W.findIndex(S=>S.type!=="reasoning"),O=v===-1?W.length:v;W.splice(O,0,{type:"text",text:A}),ne("Added accumulated text to messageParts",{textLength:A.length,insertIndex:O})}for(ne("=== Initial stream ended ===",{pendingClientToolsCount:V.length,pendingClientTools:V,messagePartsCount:W.length,messageParts:W.map(v=>({type:v.type,toolCallId:v.toolCallId,toolName:v.toolName}))});V.length>0;){ne("=== Starting pending tools execution loop ===",{pendingCount:V.length});let v=[];for(let p of V){ne(`Executing tool: ${p.toolName}`,{toolCallId:p.toolCallId,args:p.args}),Y.handleToolInputStart({toolCallId:p.toolCallId,toolName:p.toolName}),Y.handleToolInputDelta({toolCallId:p.toolCallId,inputTextDelta:JSON.stringify(p.args)}),h(T+Y.buildToolDisplay()),F();let P=await Tt(p.toolName,p.args);if(ne(`Tool execution result: ${p.toolName}`,{success:P.success,resultPreview:P.success?JSON.stringify(P.result).slice(0,200):P.error}),v.push({toolCallId:p.toolCallId,toolName:p.toolName,content:Ct(P),isError:!P.success}),P.success){Y.handleToolOutputStart({toolCallId:p.toolCallId}),Y.handleToolOutputDelta({toolCallId:p.toolCallId,outputTextDelta:JSON.stringify(P.result).slice(0,200)});let x=Y.handleToolOutputEnd({toolCallId:p.toolCallId},T);x&&(T=x.fullResponse)}else{let x=Y.handleToolError({toolCallId:p.toolCallId,errorText:P.error},T);x&&(T=x.fullResponse)}h(T+Y.buildToolDisplay()),F()}V.length=0;for(let p of v){let P=W.find(x=>(x.type==="tool-input-available"||x.type==="tool-call")&&x.toolCallId===p.toolCallId);if(P){let x=[];for(let R of p.content)R.type==="text"?x.push(R.text):R.type==="image"?x.push("[Image]"):R.type==="audio"?x.push("[Audio]"):(R.type==="resource"||R.type==="resource_link")&&x.push("[Resource]");let ue=x.join(`
91
+ `);ie.push({type:`tool-${P.toolName}`,toolName:P.toolName,toolCallId:P.toolCallId,input:P.args,output:ue,isError:p.isError})}}if(ne("=== Sending clientToolResults for continuation ===",{toolResultsCount:v.length,toolResults:v.map(p=>({toolCallId:p.toolCallId,toolName:p.toolName,isError:p.isError}))}),ae)try{ae.releaseLock()}catch{}let O=v.map(p=>({type:`tool-${p.toolName}`,toolCallId:p.toolCallId,state:"output-available",output:{content:p.content,isError:p.isError}}));if(!z)throw new Error("Cannot continue: missing assistant message id for tool results.");let S={id:e,message:{id:z,role:"assistant",parts:O}};n?S.agentId=n:(o&&(S.model=o),S.connectorIds=i??[]),C&&(S.clientTools=C),k&&(S.clientToolSystemPrompt=k),ne("=== Sending continuation request ===",{taskId:e,hasAgentId:!!S.agentId,hasModel:!!S.model,clientToolResultsCount:v.length});let G=await f.task(q,j,S);if(ne("=== Continuation response received ===",{ok:G.ok,status:G.status}),!G.ok){let p=await G.text();throw new Error(`Continuation failed: ${G.status}: ${p}`)}if(!G.body)break;for(ne("=== Processing continuation stream ==="),ae=G.body.getReader(),W.length=0,A="",B="",oe="",se="";;){let{done:p,value:P}=await ae.read();if(p){ne("=== Continuation stream done ===");break}te+=pe.decode(P,{stream:!0});let x=te.split(`
92
+ `);te=x.pop()||"";for(let ue of x)if(ue.trim()!=="data: [DONE]"&&ue.startsWith("data: "))try{let R=JSON.parse(ue.slice(6));switch(ne(`Continuation SSE: ${R.type}`,R),R.type){case"start":R.messageId&&(z=R.messageId);break;case"reasoning-start":oe=R.id||"0",B="";break;case"reasoning-delta":R.delta&&(B+=R.delta,h(`${ve}[Thinking...]${X}
93
+ ${B}`)),R.providerMetadata?.anthropic?.signature&&(se=R.providerMetadata.anthropic.signature);break;case"reasoning-end":if(B){let $e={type:"reasoning",id:oe,text:B,state:"done"};se&&($e.providerMetadata={anthropic:{signature:se}}),W.push($e),ne("Continuation: Added reasoning to messageParts",{reasoningLength:B.length,hasSignature:!!se,messagePartsCount:W.length})}B="",se="",h(T);break;case"text-delta":R.delta&&(T+=R.delta,A+=R.delta,h(T));break;case"tool-call":case"tool-input-available":if(R.toolCallId&&R.toolName){let $e=Nt(R.args??R.input);W.push({type:R.type,toolCallId:R.toolCallId,toolName:R.toolName,args:$e})}if(a&&R.toolCallId&&R.toolName&&Oe(R.toolName)){let $e=Nt(R.args??R.input);V.push({toolCallId:R.toolCallId,toolName:R.toolName,args:$e}),ne("Continuation: Added to pendingClientTools",{pendingCount:V.length})}break;case"finish":ne("Continuation finish event",R);break}}catch{}}if(A){let p=W.findIndex(x=>x.type!=="reasoning"),P=p===-1?W.length:p;W.splice(P,0,{type:"text",text:A})}ne("=== Continuation stream processing complete ===",{pendingClientToolsCount:V.length,messagePartsCount:W.length,fullResponseLength:T.length})}if(a&&C&&C.length>0){let v=[];for(let S of ie)v.push({type:String(S.type),title:String(S.toolName).replace(/__/g," "),input:S.input,output:S.output,state:S.isError?"error":"output-available"});for(let S of W)S.type==="text"&&S.text&&v.push({type:"text",text:S.text});let O=Ke(v,g);ne("=== Using formatted parts for local tools ===",{executedToolsCount:ie.length,textPartsCount:W.filter(S=>S.type==="text").length,contentLength:O.length}),m(S=>[...S,{role:"assistant",content:O,parts:v}])}else{ne("=== Fetching message from API ===",{fullResponseLength:T.length,fullResponsePreview:T.slice(0,200)});try{let{messages:v}=await f.getMessages(q,j,e,10);ne("=== API messages received ===",{count:v.length,roles:v.map(S=>S.role)});let O=v.find(S=>S.role==="assistant");if(O){let S=O.parts,G=Ke(S,g);ne("=== Setting message from API ===",{partsCount:S.length,partTypes:S.map(p=>p.type),contentLength:G.length,contentPreview:G.slice(0,200)}),m(p=>[...p,{role:"assistant",content:G,parts:S}])}else ne("=== No assistant message found, using fallback ==="),m(S=>[...S,{role:"assistant",content:T}])}catch(v){ne("=== API fetch failed, using fallback ===",{error:v instanceof Error?v.message:String(v)}),m(O=>[...O,{role:"assistant",content:T}])}}ne("=== Message handling complete ==="),h(""),y({status:"ready"}),$(!0),_.length>0&&Q?.()}catch(f){ne("=== ERROR ===",{message:f instanceof Error?f.message:String(f),stack:f instanceof Error?f.stack:void 0});let _=f instanceof Error?f.message:"Failed to send message";y({status:"error",message:_})}finally{if(l&&(clearInterval(l),l=null),ae)try{ae.releaseLock()}catch{}}},[t,e,n,o,i,a,C,k,g,m,y,h,L,$,I,Q])}}import{useState as ns}from"react";var no=new Map([["sandbox","Sandbox"],["web_search","Web Search"],["image_generation","Image Generation"],["chart","Chart"],["file_system","FileSystem"]]);function oo(e){let[t,n]=ns(e);return{fileSystem:t,setFileSystem:n,capabilityLabelMap:no}}import{useEffect as os,useState as ss}from"react";function so(e,t){let[n,o]=ss(null);return os(()=>{let i=!1;async function a(){if(!e||!t){o(null);return}try{let m=await new me().getAgent(t.accessToken,t.workspaceId,e);i||o(m)}catch{i||o(null)}}return a(),()=>{i=!0}},[e,t]),{currentAgentDetails:n}}import{useState as on}from"react";function ro(e,t,n){let[o,i]=on(e),[a,g]=on(t),[m,y]=on(n);return{currentModel:o,setCurrentModel:i,currentAgentId:a,setCurrentAgentId:g,activeConnectorIds:m,setActiveConnectorIds:y}}import{useApp as is,useInput as ls}from"ink";import{useCallback as je,useRef as as,useState as Ce}from"react";import{spawn as rs}from"child_process";function io(e){return new Promise((t,n)=>{let o,i;process.platform==="darwin"?(o="open",i=[e]):process.platform==="win32"?(o="cmd",i=["/c","start","",e]):(o="xdg-open",i=[e]);let a=rs(o,i,{stdio:"ignore",detached:!0});a.once("error",g=>{n(g)}),a.once("spawn",()=>{a.unref(),t()})})}var lo=[{name:"help",aliases:["h","?"],description:"Show available commands"},{name:"clear",aliases:["cls","new"],description:"Start a new task"},{name:"model",aliases:["m"],description:"Show/switch model",hasArgs:!0},{name:"agent",aliases:["a"],description:"Show/switch agent",hasArgs:!0},{name:"skills",aliases:["sk"],description:"List skills",hasArgs:!0},{name:"schedules",aliases:["sch"],description:"List schedules",hasArgs:!0},{name:"connectors",aliases:["conn"],description:"Select connectors"},{name:"capabilities",aliases:["cap"],description:"Toggle client capabilities"},{name:"tasks",aliases:["c"],description:"Switch to another task"},{name:"workspace",aliases:["ws"],description:"List/switch workspace",hasArgs:!0},{name:"budget",aliases:["bg"],description:"View/set workspace budget",hasArgs:!0},{name:"usage",aliases:["u"],description:"View current month usage"},{name:"status",aliases:["s"],description:"Show session status"},{name:"profile",aliases:["p"],description:"Manage profiles",hasArgs:!0},{name:"open-in-browser",aliases:[],description:"Open current task in browser"},{name:"share",aliases:[],description:"Get share link for current task"},{name:"delete",aliases:["del"],description:"Delete current task"},{name:"quit",aliases:["exit","q"],description:"Exit task"}];function ao(e){if(!e.startsWith("/"))return[];let t=e.slice(1).toLowerCase();return t?lo.filter(n=>n.name.startsWith(t)||n.aliases.some(o=>o.startsWith(t))):lo}function co(e){let t=e.trim();if(!t.startsWith("/"))return null;let n=t.slice(1).split(/\s+/),o=n[0]?.toLowerCase(),i=n.slice(1).join(" ");switch(o){case"help":case"h":case"?":return{type:"help"};case"clear":case"cls":case"new":return{type:"clear"};case"model":case"m":return{type:"model",value:i||void 0};case"agent":case"a":return{type:"agent",value:i||void 0};case"skills":case"sk":return{type:"skills",value:i||void 0};case"schedules":case"sch":return{type:"schedules",value:i||void 0};case"connectors":case"conn":return{type:"connectors"};case"capabilities":case"cap":return{type:"capabilities"};case"tasks":case"c":return{type:"tasks"};case"workspace":case"ws":return{type:"workspace",value:i||void 0};case"budget":case"bg":return{type:"budget",value:i||void 0};case"usage":case"u":return{type:"usage"};case"status":case"s":return{type:"status"};case"profile":case"p":return{type:"profile",value:i||void 0};case"open-in-browser":return{type:"open-in-browser"};case"share":return{type:"share"};case"delete":case"del":return{type:"delete"};case"quit":case"exit":case"q":return{type:"quit"};default:return{type:"unknown",input:t}}}var uo=`Available commands:
94
94
  /help, /h, /? Show this help message
95
95
  /clear, /cls, /new Start a new task
96
96
  /model [name], /m Show current model or switch to [name]
@@ -114,18 +114,18 @@ Note: For detailed usage with sorting/limits, use: entrydesk usage --help
114
114
 
115
115
  Keyboard shortcuts:
116
116
  Ctrl+O Toggle full output mode
117
- Ctrl+C Exit`;function sn(e){if(e.type==="no-repeat")return"No repeat";let{interval:t}=e;switch(t.unit){case"minutes":return`Every ${t.every} min`;case"hours":return`Every ${t.every} hr`;case"days":return`Every ${t.every} day at ${String(t.time.hour).padStart(2,"0")}:${String(t.time.minute).padStart(2,"0")}`;case"weeks":return`Every ${t.every} week`;case"months":return`Every ${t.every} month`;default:return"Unknown"}}function fo({input:e,setInput:t,taskId:n,setTaskId:o,currentTaskTitle:i,setCurrentTaskTitle:a,currentModel:g,setCurrentModel:m,currentAgentId:y,setCurrentAgentId:h,currentAgentDetails:L,setCurrentAgentDetails:$,activeConnectorIds:I,setActiveConnectorIds:Q,fileSystem:C,setFileSystem:k,availableModels:E,availableAgents:N,availableConnectors:K,messages:Z,hasPersistedTask:q,setHasPersistedTask:j,setMessages:ae,addSystemMessage:l,startNewTask:f,sendMessage:_,setFullOutput:M,credentials:b,setCredentials:pe,setState:te,defaultCapabilities:T,capabilityLabelMap:B,hasUploadingFiles:oe=!1}){let{exit:se}=is(),[A,z]=Ce([]),[Y,V]=Ce(0),[W,ie]=Ce(!1),[F,v]=Ce(null),[O,S]=Ce([]),[G,p]=Ce(0),[P,w]=Ce(new Set),[ue,R]=Ce(new Set),[$e,gt]=Ce([]),[Ne,Bt]=Ce([]),[Se,st]=Ce([]),[Fe,ht]=Ce([]),[Ae,Me]=Ce(null),[Ot,rt]=Ce(""),Xe=as(!1),[Be,xe]=Ce(!1),Qe=je(async()=>{if(!b)return[];let x=new me,d=[],s;do{let r=await x.listAvailableSkills(b.accessToken,b.workspaceId,{limit:100,nextKey:s});d.push(...r.skills),s=r.nextKey}while(s);return Bt(d),d},[b]),Ze=je(async()=>{if(!b)return[];let x=new me,d=[],s;do{let r=await x.getSchedules(b.accessToken,b.workspaceId,{limit:100,nextKey:s});d.push(...r.schedules),s=r.nextKey}while(s);return st(d),d},[b]),ke=je(async x=>{if(x==="model"){if(E.length===0){l("No models available.");return}let d=E.map(r=>({id:r.id,name:r.name,description:r.description}));S(d);let s=g?d.findIndex(r=>r.id===g):-1;p(Math.max(s,0)),v("model")}else if(x==="agent"){if(N.length===0){l("No agents available.");return}let d=N.map(r=>({id:r.id,name:r.name,description:r.description}));S(d);let s=y?d.findIndex(r=>r.id===y):-1;p(Math.max(s,0)),v("agent")}else if(x==="skills"){let d=Ne;if(d.length===0)try{d=await Qe()}catch{l("Failed to load skills.");return}if(d.length===0){l("No skills available.");return}let s=d.map(r=>({id:r.id,name:r.name,description:r.description}));S(s),p(0),v("skills")}else if(x==="schedules"){let d=Se;if(d.length===0)try{d=await Ze()}catch{l("Failed to load schedules.");return}if(d.length===0){l("No schedules found.");return}let s=d.map(r=>({id:r.id,name:r.name,description:`${r.agent.name} - ${r.isActive?"Active":"Paused"}`}));S(s),p(0),v("schedules")}else if(x==="connectors"){if(K.length===0){l("No connectors available.");return}let d=K.map(s=>({id:s.id,name:s.name}));S(d),p(0),w(new Set(I??[])),v("connectors")}else if(x==="capabilities"){S([{id:"fileSystem",name:"FileSystem",description:"Local file operations"}]),p(0);let s=new Set;C&&s.add("fileSystem"),R(s),v("capabilities")}else if(x==="tasks"){if(!b){l("Not authenticated.");return}try{let d=new me,{tasks:s}=await d.getTasks(b.accessToken,b.workspaceId,20);if(s.length===0){l("No tasks available.");return}gt(s);let r=s.map(c=>({id:c.id,name:c.title||"Untitled",description:new Date(c.createdAt).toLocaleDateString()}));S(r);let u=r.findIndex(c=>c.id===n);p(Math.max(u,0)),v("tasks")}catch{l("Failed to load tasks.")}}else if(x==="profile"){let d=le.getProfileNames(),s=le.getCurrentProfileName(),r=d.map(c=>({id:c,name:c,description:c===s?"(current)":void 0}));S(r);let u=r.findIndex(c=>c.id===s);p(Math.max(u,0)),v("profile")}ie(!1),z([])},[E,N,Ne,Se,K,I,g,y,C,Qe,Ze,b,n,l]),Pe=je(x=>{let d=fe.getAll(x);m(d.model?.default),h(void 0),$(null);let s=d.connectors?.defaults;Q(s&&s.length>0?s:void 0);let r=d.localTools;k(r?.fileSystem??T.fileSystem)},[m,h,$,Q,k,T]),De=je(async()=>{try{let x=await We();pe({accessToken:x.accessToken,workspaceId:x.workspaceId}),te({status:"ready"})}catch(x){if(pe(null),x instanceof Je){if(x.code==="not-logged-in"){te({status:"not-logged-in"});return}if(x.code==="no-workspace"){te({status:"no-workspace"});return}}let d=x instanceof Error?x.message:"Failed to authenticate";te({status:"error",message:d})}},[pe,te]),He=je(async x=>{switch(x.type){case"help":return l(uo),!0;case"clear":return f("Started a new task."),!0;case"model":{if(x.value){let d=x.value.toLowerCase(),s=E.find(r=>r.id.toLowerCase()===d||r.name.toLowerCase().includes(d));if(s)y?f(`Switched to model: ${s.name} (new task)`):l(`Switched to model: ${s.name}`),m(s.id),h(void 0),$(null),fe.setDefaultModel(s.id);else{let r=E.map(u=>u.name).join(", ");l(`Model "${x.value}" not found.
118
- Available: ${r||"none"}`)}}else{let d=E.find(s=>s.id===g)?.name||g;l(g?`Current model: ${d}`:"No model selected. Using agent mode.")}return!0}case"agent":{if(!x.value)return N.length===0?(l("No agents available."),!0):(ke("agent"),!0);let d=x.value.toLowerCase(),s=N.find(r=>r.id.toLowerCase()===d||r.name.toLowerCase().includes(d));if(s)s.id!==y?f(`Switched to agent: ${s.name} (new task)`):l(`Switched to agent: ${s.name}`),h(s.id),m(void 0);else{let r=N.map(u=>u.name).join(", ");l(`Agent "${x.value}" not found.
119
- Available: ${r||"none"}`)}return!0}case"skills":{if(!x.value)return ke("skills"),!0;let d=x.value.toLowerCase();return(Ne.length>0?Promise.resolve(Ne):Qe().catch(()=>[])).then(r=>{let u=r.find(c=>c.id.toLowerCase()===d||c.name.toLowerCase().includes(d));l(u?`Skill: ${u.name}
117
+ Ctrl+C Exit`;function sn(e){if(e.type==="no-repeat")return"No repeat";let{interval:t}=e;switch(t.unit){case"minutes":return`Every ${t.every} min`;case"hours":return`Every ${t.every} hr`;case"days":return`Every ${t.every} day at ${String(t.time.hour).padStart(2,"0")}:${String(t.time.minute).padStart(2,"0")}`;case"weeks":return`Every ${t.every} week`;case"months":return`Every ${t.every} month`;default:return"Unknown"}}function fo({input:e,setInput:t,taskId:n,setTaskId:o,currentTaskTitle:i,setCurrentTaskTitle:a,currentModel:g,setCurrentModel:m,currentAgentId:y,setCurrentAgentId:h,currentAgentDetails:L,setCurrentAgentDetails:$,activeConnectorIds:I,setActiveConnectorIds:Q,fileSystem:C,setFileSystem:k,availableModels:E,availableAgents:N,availableConnectors:K,messages:Z,hasPersistedTask:q,setHasPersistedTask:j,setMessages:ae,addSystemMessage:l,startNewTask:f,sendMessage:_,setFullOutput:M,credentials:b,setCredentials:pe,setState:te,defaultCapabilities:T,capabilityLabelMap:B,hasUploadingFiles:oe=!1}){let{exit:se}=is(),[A,z]=Ce([]),[Y,V]=Ce(0),[W,ie]=Ce(!1),[F,v]=Ce(null),[O,S]=Ce([]),[G,p]=Ce(0),[P,x]=Ce(new Set),[ue,R]=Ce(new Set),[$e,gt]=Ce([]),[Ne,Bt]=Ce([]),[Se,st]=Ce([]),[Fe,ht]=Ce([]),[Ae,Me]=Ce(null),[Ot,rt]=Ce(""),Xe=as(!1),[Be,we]=Ce(!1),Qe=je(async()=>{if(!b)return[];let w=new me,d=[],s;do{let r=await w.listAvailableSkills(b.accessToken,b.workspaceId,{limit:100,nextKey:s});d.push(...r.skills),s=r.nextKey}while(s);return Bt(d),d},[b]),Ze=je(async()=>{if(!b)return[];let w=new me,d=[],s;do{let r=await w.getSchedules(b.accessToken,b.workspaceId,{limit:100,nextKey:s});d.push(...r.schedules),s=r.nextKey}while(s);return st(d),d},[b]),ke=je(async w=>{if(w==="model"){if(E.length===0){l("No models available.");return}let d=E.map(r=>({id:r.id,name:r.name,description:r.description}));S(d);let s=g?d.findIndex(r=>r.id===g):-1;p(Math.max(s,0)),v("model")}else if(w==="agent"){if(N.length===0){l("No agents available.");return}let d=N.map(r=>({id:r.id,name:r.name,description:r.description}));S(d);let s=y?d.findIndex(r=>r.id===y):-1;p(Math.max(s,0)),v("agent")}else if(w==="skills"){let d=Ne;if(d.length===0)try{d=await Qe()}catch{l("Failed to load skills.");return}if(d.length===0){l("No skills available.");return}let s=d.map(r=>({id:r.id,name:r.name,description:r.description}));S(s),p(0),v("skills")}else if(w==="schedules"){let d=Se;if(d.length===0)try{d=await Ze()}catch{l("Failed to load schedules.");return}if(d.length===0){l("No schedules found.");return}let s=d.map(r=>({id:r.id,name:r.name,description:`${r.agent.name} - ${r.isActive?"Active":"Paused"}`}));S(s),p(0),v("schedules")}else if(w==="connectors"){if(K.length===0){l("No connectors available.");return}let d=K.map(s=>({id:s.id,name:s.name}));S(d),p(0),x(new Set(I)),v("connectors")}else if(w==="capabilities"){S([{id:"fileSystem",name:"FileSystem",description:"Local file operations"}]),p(0);let s=new Set;C&&s.add("fileSystem"),R(s),v("capabilities")}else if(w==="tasks"){if(!b){l("Not authenticated.");return}try{let d=new me,{tasks:s}=await d.getTasks(b.accessToken,b.workspaceId,20);if(s.length===0){l("No tasks available.");return}gt(s);let r=s.map(c=>({id:c.id,name:c.title||"Untitled",description:new Date(c.createdAt).toLocaleDateString()}));S(r);let u=r.findIndex(c=>c.id===n);p(Math.max(u,0)),v("tasks")}catch{l("Failed to load tasks.")}}else if(w==="profile"){let d=le.getProfileNames(),s=le.getCurrentProfileName(),r=d.map(c=>({id:c,name:c,description:c===s?"(current)":void 0}));S(r);let u=r.findIndex(c=>c.id===s);p(Math.max(u,0)),v("profile")}ie(!1),z([])},[E,N,Ne,Se,K,I,g,y,C,Qe,Ze,b,n,l]),Pe=je(w=>{let d=fe.getAll(w);m(d.model?.default),h(void 0),$(null);let s=d.connectors?.defaults;Q(s&&s.length>0?s:void 0);let r=d.localTools;k(r?.fileSystem??T.fileSystem)},[m,h,$,Q,k,T]),De=je(async()=>{try{let w=await We();pe({accessToken:w.accessToken,workspaceId:w.workspaceId}),te({status:"ready"})}catch(w){if(pe(null),w instanceof Je){if(w.code==="not-logged-in"){te({status:"not-logged-in"});return}if(w.code==="no-workspace"){te({status:"no-workspace"});return}}let d=w instanceof Error?w.message:"Failed to authenticate";te({status:"error",message:d})}},[pe,te]),He=je(async w=>{switch(w.type){case"help":return l(uo),!0;case"clear":return f("Started a new task."),!0;case"model":if(w.value){let d=w.value.toLowerCase(),s=E.find(r=>r.id.toLowerCase()===d||r.name.toLowerCase().includes(d));if(s)y?f(`Switched to model: ${s.name} (new task)`):l(`Switched to model: ${s.name}`),m(s.id),h(void 0),$(null),fe.setDefaultModel(s.id);else{let r=E.map(u=>u.name).join(", ");l(`Model "${w.value}" not found.
118
+ Available: ${r||"none"}`)}}else{let d=E.find(s=>s.id===g)?.name||g;l(g?`Current model: ${d}`:"No model selected. Using agent mode.")}return!0;case"agent":{if(!w.value)return N.length===0?(l("No agents available."),!0):(ke("agent"),!0);let d=w.value.toLowerCase(),s=N.find(r=>r.id.toLowerCase()===d||r.name.toLowerCase().includes(d));if(s)s.id===y?l(`Switched to agent: ${s.name}`):f(`Switched to agent: ${s.name} (new task)`),h(s.id),m(void 0);else{let r=N.map(u=>u.name).join(", ");l(`Agent "${w.value}" not found.
119
+ Available: ${r||"none"}`)}return!0}case"skills":{if(!w.value)return ke("skills"),!0;let d=w.value.toLowerCase();return(Ne.length>0?Promise.resolve(Ne):Qe().catch(()=>[])).then(r=>{let u=r.find(c=>c.id.toLowerCase()===d||c.name.toLowerCase().includes(d));l(u?`Skill: ${u.name}
120
120
  ${u.description}
121
121
  Provider: ${u.provider}
122
122
  Author: ${u.author.name}
123
- ID: ${u.id}`:`Skill "${x.value}" not found.`)}),!0}case"schedules":{if(!x.value)return ke("schedules"),!0;let d=x.value.toLowerCase();return(Se.length>0?Promise.resolve(Se):Ze().catch(()=>[])).then(r=>{let u=r.find(c=>c.id.toLowerCase()===d||c.name.toLowerCase().includes(d));if(u){let c=u.nextRunAt?new Date(u.nextRunAt).toLocaleString():"-";l(`Schedule: ${u.name}
123
+ ID: ${u.id}`:`Skill "${w.value}" not found.`)}),!0}case"schedules":{if(!w.value)return ke("schedules"),!0;let d=w.value.toLowerCase();return(Se.length>0?Promise.resolve(Se):Ze().catch(()=>[])).then(r=>{let u=r.find(c=>c.id.toLowerCase()===d||c.name.toLowerCase().includes(d));if(u){let c=u.nextRunAt?new Date(u.nextRunAt).toLocaleString():"-";l(`Schedule: ${u.name}
124
124
  Agent: ${u.agent.name}
125
125
  Status: ${u.isActive?"Active":"Paused"}
126
126
  Repeat: ${sn(u.config)}
127
127
  Next Run: ${c}
128
- ID: ${u.id}`)}else l(`Schedule "${x.value}" not found.`)}),!0}case"connectors":{if(y){let s=L?.connectors??[];if(s.length===0)l("No agent connectors.");else{let r=s.map(u=>` - ${u.name}`).join(`
128
+ ID: ${u.id}`)}else l(`Schedule "${w.value}" not found.`)}),!0}case"connectors":{if(y){let s=L?.connectors??[];if(s.length===0)l("No agent connectors.");else{let r=s.map(u=>` - ${u.name}`).join(`
129
129
  `);l(`Agent connectors:
130
130
  ${r}`)}return!0}let d=K.filter(s=>I?.includes(s.id));if(d.length===0)l("No active connectors.");else{let s=d.map(r=>` - ${r.name}`).join(`
131
131
  `);l(`Active connectors:
@@ -133,19 +133,19 @@ ${s}`)}return!0}case"capabilities":{if(y){let r=(L?.capabilities??[]).map(u=>B.g
133
133
  ${r.map(u=>` - ${u}`).join(`
134
134
  `)}`:"No agent capabilities."),!0}let d=[];return C&&d.push("FileSystem"),l(d.length>0?`Active capabilities:
135
135
  ${d.map(s=>` - ${s}`).join(`
136
- `)}`:"No capabilities enabled."),!0}case"tasks":return l(i?`Current task: ${i}`:`Current task: ${n.slice(0,8)}...`),!0;case"workspace":{if(!b)return l("Not authenticated."),!0;let d=new me;if(!x.value){try{let{workspaces:r}=await d.getWorkspaces(b.accessToken);if(r.length===0)l("No workspaces found.");else{let u=r.map(c=>` ${c.id===b.workspaceId?"* ":" "}${c.name}
136
+ `)}`:"No capabilities enabled."),!0}case"tasks":return l(i?`Current task: ${i}`:`Current task: ${n.slice(0,8)}...`),!0;case"workspace":{if(!b)return l("Not authenticated."),!0;let d=new me;if(!w.value){try{let{workspaces:r}=await d.getWorkspaces(b.accessToken);if(r.length===0)l("No workspaces found.");else{let u=r.map(c=>` ${c.id===b.workspaceId?"* ":" "}${c.name}
137
137
  ID: ${c.id}`);l(`Workspaces:
138
138
  ${u.join(`
139
- `)}`)}}catch(r){l(`Failed to load workspaces: ${r instanceof Error?r.message:"Unknown error"}`)}return!0}let s=x.value;try{let{workspaces:r}=await d.getWorkspaces(b.accessToken),u=r.find(c=>c.id===s);if(!u)return l(`Workspace not found: ${s}`),!0;await it.saveWorkspaceId(s),l(`Switched to workspace: ${u.name}`),l("Please restart the task to apply changes.")}catch(r){l(`Failed to switch workspace: ${r instanceof Error?r.message:"Unknown error"}`)}return!0}case"budget":{if(!b)return l("Not authenticated."),!0;let d=new me;if(!x.value){try{let u=await d.getBudget(b.accessToken,b.workspaceId);u.budget===null?l("No budget set for this workspace."):l(`Current budget: $${u.budget}`)}catch(u){l(`Failed to get budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}let s=x.value.toLowerCase();if(s==="clear"||s==="null"){try{await d.updateBudget(b.accessToken,b.workspaceId,null),l("Budget cleared.")}catch(u){l(`Failed to clear budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}let r=parseFloat(s);if(isNaN(r)||r<0)return l("Invalid budget amount. Must be a positive number."),!0;try{await d.updateBudget(b.accessToken,b.workspaceId,s),l(`Budget set to: $${s}`)}catch(u){l(`Failed to set budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}case"usage":{if(!b)return l("Not authenticated."),!0;let d=new me;try{let s=[],r,u=0,c=10;do{let ge=await d.getMonthlyUsages(b.accessToken,b.workspaceId,{nextKey:r,limit:20});if(s.push(...ge.monthlyUsages),r=ge.nextKey,u++,u>=c){l(`Warning: Showing first ${s.length} entries (pagination limit reached)`);break}}while(r);if(s.length===0)return l("No usage data found for this workspace."),!0;let D=0,ee=0;for(let ge of s)D+=parseFloat(ge.totalCost),ee+=ge.operationCount;let Te=[...s].toSorted((ge,qe)=>parseFloat(qe.totalCost)-parseFloat(ge.totalCost)),H=10,de=Te.slice(0,H),be=[`Total Cost: $${D.toFixed(2)}`,`Total Operations: ${ee.toLocaleString()}`,`Users: ${s.length}`,"",`Top ${de.length} Users by Cost:`,...de.map(ge=>` ${ge.user.name}: $${parseFloat(ge.totalCost).toFixed(2)} (${ge.operationCount.toLocaleString()} ops)`)];s.length>H&&(be.push("",`... and ${s.length-H} more users`),be.push("Use CLI command for full list: entrydesk usage --limit <n> --sort-by <cost|operations>")),l(be.join(`
140
- `))}catch(s){l(`Failed to get usage: ${s instanceof Error?s.message:"Unknown error"}`)}return!0}case"status":{let d=le.getCurrentProfileName(),s=g?E.find(D=>D.id===g)?.name||g:null,r=y?N.find(D=>D.id===y)?.name||y:null,u=I?K.filter(D=>I.includes(D.id)).map(D=>D.name):[],c=[];return C&&c.push("FileSystem"),it.getEmail().then(D=>{let ee=[`Profile: ${d}${d!=="default"?" (non-default)":""}`,D?`Logged in as: ${D}`:"Not logged in",b?.workspaceId?`Workspace: ${b.workspaceId}`:null,q?`Task ID: ${n}`:null,s?`Model: ${s}`:null,r?`Agent: ${r}`:null,`Connectors: ${u.length>0?u.join(", "):"none"}`,`Capabilities: ${c.length>0?c.join(", "):"none"}`].filter(Boolean);l(ee.join(`
139
+ `)}`)}}catch(r){l(`Failed to load workspaces: ${r instanceof Error?r.message:"Unknown error"}`)}return!0}let s=w.value;try{let{workspaces:r}=await d.getWorkspaces(b.accessToken),u=r.find(c=>c.id===s);if(!u)return l(`Workspace not found: ${s}`),!0;await it.saveWorkspaceId(s),l(`Switched to workspace: ${u.name}`),l("Please restart the task to apply changes.")}catch(r){l(`Failed to switch workspace: ${r instanceof Error?r.message:"Unknown error"}`)}return!0}case"budget":{if(!b)return l("Not authenticated."),!0;let d=new me;if(!w.value){try{let u=await d.getBudget(b.accessToken,b.workspaceId);u.budget===null?l("No budget set for this workspace."):l(`Current budget: $${u.budget}`)}catch(u){l(`Failed to get budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}let s=w.value.toLowerCase();if(s==="clear"||s==="null"){try{await d.updateBudget(b.accessToken,b.workspaceId,null),l("Budget cleared.")}catch(u){l(`Failed to clear budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}let r=Number.parseFloat(s);if(Number.isNaN(r)||r<0)return l("Invalid budget amount. Must be a positive number."),!0;try{await d.updateBudget(b.accessToken,b.workspaceId,s),l(`Budget set to: $${s}`)}catch(u){l(`Failed to set budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}case"usage":{if(!b)return l("Not authenticated."),!0;let d=new me;try{let s=[],r,u=0,c=10;do{let ge=await d.getMonthlyUsages(b.accessToken,b.workspaceId,{nextKey:r,limit:20});if(s.push(...ge.monthlyUsages),r=ge.nextKey,u++,u>=c){l(`Warning: Showing first ${s.length} entries (pagination limit reached)`);break}}while(r);if(s.length===0)return l("No usage data found for this workspace."),!0;let D=0,ee=0;for(let ge of s)D+=Number.parseFloat(ge.totalCost),ee+=ge.operationCount;let Te=[...s].toSorted((ge,qe)=>Number.parseFloat(qe.totalCost)-Number.parseFloat(ge.totalCost)),H=10,de=Te.slice(0,H),be=[`Total Cost: $${D.toFixed(2)}`,`Total Operations: ${ee.toLocaleString()}`,`Users: ${s.length}`,"",`Top ${de.length} Users by Cost:`,...de.map(ge=>` ${ge.user.name}: $${Number.parseFloat(ge.totalCost).toFixed(2)} (${ge.operationCount.toLocaleString()} ops)`)];s.length>H&&(be.push("",`... and ${s.length-H} more users`),be.push("Use CLI command for full list: entrydesk usage --limit <n> --sort-by <cost|operations>")),l(be.join(`
140
+ `))}catch(s){l(`Failed to get usage: ${s instanceof Error?s.message:"Unknown error"}`)}return!0}case"status":{let d=le.getCurrentProfileName(),s=g?E.find(D=>D.id===g)?.name||g:null,r=y?N.find(D=>D.id===y)?.name||y:null,u=I?K.filter(D=>I.includes(D.id)).map(D=>D.name):[],c=[];return C&&c.push("FileSystem"),it.getEmail().then(D=>{let ee=[`Profile: ${d}${d==="default"?"":" (non-default)"}`,D?`Logged in as: ${D}`:"Not logged in",b?.workspaceId?`Workspace: ${b.workspaceId}`:null,q?`Task ID: ${n}`:null,s?`Model: ${s}`:null,r?`Agent: ${r}`:null,`Connectors: ${u.length>0?u.join(", "):"none"}`,`Capabilities: ${c.length>0?c.join(", "):"none"}`].filter(Boolean);l(ee.join(`
141
141
  `))}).catch(()=>{let D=[`Profile: ${d}`,"Not logged in",q?`Task ID: ${n}`:null,s?`Model: ${s}`:null,r?`Agent: ${r}`:null,`Connectors: ${u.length>0?u.join(", "):"none"}`,`Capabilities: ${c.length>0?c.join(", "):"none"}`].filter(Boolean);l(D.join(`
142
- `))}),!0}case"profile":{let d=x.value?x.value.split(/\s+/).filter(Boolean):[];if(d.length===0)return ke("profile"),!0;let s=d[0]?.toLowerCase()||"list",r=d[1],u=d[2],c=le.getProfileNames(),D=le.getCurrentProfileName(),ee=le.getOverrideProfile(),Te=(H,de=!1)=>{if(H)return H;if(de&&c.length===1)return c[0];throw new Error("Profile name is required when multiple profiles exist.")};try{if(s==="list"){let H=[`Profiles (${c.length}):`];for(let de of c){let be=de===D?" (current)":"";H.push(` ${de}${be}`)}return l(H.join(`
142
+ `))}),!0}case"profile":{let d=w.value?w.value.split(/\s+/).filter(Boolean):[];if(d.length===0)return ke("profile"),!0;let s=d[0]?.toLowerCase()||"list",r=d[1],u=d[2],c=le.getProfileNames(),D=le.getCurrentProfileName(),ee=le.getOverrideProfile(),Te=(H,de=!1)=>{if(H)return H;if(de&&c.length===1)return c[0];throw new Error("Profile name is required when multiple profiles exist.")};try{if(s==="list"){let H=[`Profiles (${c.length}):`];for(let de of c){let be=de===D?" (current)":"";H.push(` ${de}${be}`)}return l(H.join(`
143
143
  `)),!0}if(s==="current")return l(`Current profile: ${D}`),!0;if(s==="show"){let H=Te(r,!0),de=fe.getAll(H),be=await it.getAll(H),ge=!!be?.accessToken,qe=de.connectors?.defaults&&de.connectors.defaults.length>0?de.connectors.defaults.join(", "):"unset",ko=[`Profile: ${H}${H===D?" (current)":""}`,`API URL: ${de.apiUrl??"default"}`,`Hub URL: ${de.hubUrl??"default"}`,`Model: ${de.model?.default??"unset"}`,`Connectors: ${qe}`,ge?`Logged in as: ${be?.email??"unknown"}`:"Not logged in",ge&&be?.workspaceId?`Workspace ID: ${be.workspaceId}`:null].filter(Boolean);return l(ko.join(`
144
144
  `)),!0}if(s==="create"){let H=r||le.DEFAULT_PROFILE;return le.createProfile(H),l(`Profile created: ${H}`),!0}if(s==="use"||s==="switch"){let H=Te(r,!0);return le.setOverrideProfile(H),le.setCurrentProfile(H),Pe(H),await De(),f(`Switched to profile: ${H} (new task)`),!0}if(s==="delete"||s==="remove"||s==="rm"){let H=Te(r,!0),de=H===D,be=le.deleteProfile(H),ge=`Profile deleted: ${H}`;if(de)le.setOverrideProfile(be.currentProfile),Pe(be.currentProfile),await De(),f(`${ge}
145
145
  Switched to profile: ${be.currentProfile} (new task)`);else if(ee===H){let qe=le.getCurrentProfileName();le.setOverrideProfile(qe),Pe(qe),await De(),f(`${ge}
146
146
  Switched to profile: ${qe} (new task)`)}else l(ge);return!0}if(s==="rename"||s==="move"||s==="mv"){let H=Te(r,!0);if(!u)throw new Error("New profile name is required.");let de=le.renameProfile(H,u);return l(`Profile renamed: ${H} -> ${u}`),ee===H?(le.setOverrideProfile(u),Pe(u)):de.currentProfile===u&&Pe(u),!0}if(s==="clone"||s==="copy"){let H=Te(r,!0);if(!u)throw new Error("Target profile name is required.");let de=fe.getAll(H);return le.createProfile(u),fe.setAll(de,u),await it.clear(u),l(`Profile cloned: ${H} -> ${u}`),!0}l(`Unknown profile command: ${s}`)}catch(H){let de=H instanceof Error?H.message:"Unknown error";l(`Profile error: ${de}`)}return!0}case"open-in-browser":{let d=jt().hubUrl.replace(/\/$/,""),s=q||Z.some(ee=>ee.role!=="system"),r=b?`/${b.workspaceId}`:"",u=s?`${r}/task/${n}`:`${r}/task/new`,c=y?`?agentId=${encodeURIComponent(y)}`:"",D=`${d}${u}${c}`;try{await io(D),l(`Opened in browser: ${D}`)}catch(ee){l(`Failed to open browser: ${ee instanceof Error?ee.message:"Unknown error"}
147
- URL: ${D}`)}return!0}case"share":{if(!b)return l("Not authenticated."),!0;if(!(q||Z.some(s=>s.role!=="system")))return l("No conversation to share. Start a task first."),!0;try{let r=await new me().createTaskShare(b.accessToken,b.workspaceId,n,"public"),c=`${jt().hubUrl.replace(/\/$/,"")}/share/${r.id}`;l(`Share link: ${c}`)}catch(s){l(`Failed to create share link: ${s instanceof Error?s.message:"Unknown error"}`)}return!0}case"delete":return b?q?(xe(!0),l("Delete this task? (y/N)"),!0):(l("No task to delete."),!0):(l("Not authenticated."),!0);case"quit":return se(),!0;case"unknown":return l(`Unknown command: ${x.input}
148
- Type /help for available commands.`),!0;default:return!1}},[l,E,N,K,Ne,Se,g,y,I,C,n,i,se,ke,f,B,L,q,Z,Qe,Ze,ae,m,h,$,m,Pe,De]),yt=je(x=>{if(Xe.current=!1,Be){(x===""||x.startsWith("/"))&&(t(x),x.startsWith("/")&&xe(!1));return}if(t(x),rt(x),Ae!==null&&Me(null),F&&(v(null),S([])),x.startsWith("/")&&!x.includes(" ")){let d=ao(x);z(d),V(0),ie(d.length>0)}else ie(!1),z([])},[F,Ae,Be,t]),et=je((x,d=!1)=>{if(x>=0&&x<A.length){let s=A[x];ie(!1),z([]),s.name==="model"?(t("/model "),ke("model")):s.name==="agent"?(t("/agent "),ke("agent")):s.name==="skills"?(t("/skills "),ke("skills")):s.name==="schedules"?(t("/schedules "),ke("schedules")):s.name==="connectors"?(t("/connectors "),ke("connectors")):s.name==="capabilities"?(t("/capabilities "),ke("capabilities")):s.name==="tasks"?(t("/tasks "),ke("tasks")):s.name==="profile"?(t("/profile "),ke("profile")):d?(t(""),He({type:s.name})):t(`/${s.name}`)}},[A,ke,t,He]),Ut=je(async x=>{Xe.current=!1;let d=x.trim();if(!d||Be)return;if(F==="model"&&O.length>0){let r=O[G];r&&(y?f(`Switched to model: ${r.name} (new task)`):l(`Switched to model: ${r.name}`),m(r.id),h(void 0),$(null)),v(null),S([]),t("");return}if(F==="agent"&&O.length>0){let r=O[G];r&&(r.id!==y?f(`Switched to agent: ${r.name} (new task)`):l(`Switched to agent: ${r.name}`),h(r.id),m(void 0)),v(null),S([]),t("");return}if(F==="skills"&&O.length>0){let r=O[G];if(r){let u=Ne.find(c=>c.id===r.id);u&&l(`Skill: ${u.name}
147
+ URL: ${D}`)}return!0}case"share":{if(!b)return l("Not authenticated."),!0;if(!(q||Z.some(s=>s.role!=="system")))return l("No conversation to share. Start a task first."),!0;try{let r=await new me().createTaskShare(b.accessToken,b.workspaceId,n,"public"),c=`${jt().hubUrl.replace(/\/$/,"")}/share/${r.id}`;l(`Share link: ${c}`)}catch(s){l(`Failed to create share link: ${s instanceof Error?s.message:"Unknown error"}`)}return!0}case"delete":return b?q?(we(!0),l("Delete this task? (y/N)"),!0):(l("No task to delete."),!0):(l("Not authenticated."),!0);case"quit":return se(),!0;case"unknown":return l(`Unknown command: ${w.input}
148
+ Type /help for available commands.`),!0;default:return!1}},[l,E,N,K,Ne,Se,g,y,I,C,n,i,se,ke,f,B,L,q,Z,Qe,Ze,ae,m,h,$,m,Pe,De]),yt=je(w=>{if(Xe.current=!1,Be){(w===""||w.startsWith("/"))&&(t(w),w.startsWith("/")&&we(!1));return}if(t(w),rt(w),Ae!==null&&Me(null),F&&(v(null),S([])),w.startsWith("/")&&!w.includes(" ")){let d=ao(w);z(d),V(0),ie(d.length>0)}else ie(!1),z([])},[F,Ae,Be,t]),et=je((w,d=!1)=>{if(w>=0&&w<A.length){let s=A[w];ie(!1),z([]),s.name==="model"?(t("/model "),ke("model")):s.name==="agent"?(t("/agent "),ke("agent")):s.name==="skills"?(t("/skills "),ke("skills")):s.name==="schedules"?(t("/schedules "),ke("schedules")):s.name==="connectors"?(t("/connectors "),ke("connectors")):s.name==="capabilities"?(t("/capabilities "),ke("capabilities")):s.name==="tasks"?(t("/tasks "),ke("tasks")):s.name==="profile"?(t("/profile "),ke("profile")):d?(t(""),He({type:s.name})):t(`/${s.name}`)}},[A,ke,t,He]),Ut=je(async w=>{Xe.current=!1;let d=w.trim();if(!d||Be)return;if(F==="model"&&O.length>0){let r=O[G];r&&(y?f(`Switched to model: ${r.name} (new task)`):l(`Switched to model: ${r.name}`),m(r.id),h(void 0),$(null)),v(null),S([]),t("");return}if(F==="agent"&&O.length>0){let r=O[G];r&&(r.id===y?l(`Switched to agent: ${r.name}`):f(`Switched to agent: ${r.name} (new task)`),h(r.id),m(void 0)),v(null),S([]),t("");return}if(F==="skills"&&O.length>0){let r=O[G];if(r){let u=Ne.find(c=>c.id===r.id);u&&l(`Skill: ${u.name}
149
149
  ${u.description}
150
150
  Provider: ${u.provider}
151
151
  Author: ${u.author.name}
@@ -154,7 +154,7 @@ Agent: ${u.agent.name}
154
154
  Status: ${u.isActive?"Active":"Paused"}
155
155
  Repeat: ${sn(u.config)}
156
156
  Next Run: ${c}
157
- ID: ${u.id}`)}}v(null),S([]),t("");return}if(F==="connectors"){let r=[...P];Q(r.length>0?r:void 0),fe.setDefaultConnectorIds(r);let u=K.filter(c=>P.has(c.id)).map(c=>c.name);l(u.length>0?`Active connectors: ${u.join(", ")}`:"All connectors disabled."),v(null),S([]),t("");return}if(F==="capabilities"){let r=ue.has("fileSystem");k(r),fe.setLocalTools({fileSystem:r});let u=[];r&&u.push("FileSystem"),l(u.length>0?`Active capabilities: ${u.join(", ")}`:"All capabilities disabled."),v(null),S([]),t("");return}if(F==="profile"&&O.length>0){let r=O[G];if(r){let u=le.getCurrentProfileName();r.id!==u?(le.setOverrideProfile(r.id),le.setCurrentProfile(r.id),Pe(r.id),De(),f(`Switched to profile: ${r.name}`)):l(`Already using profile: ${r.name}`)}v(null),S([]),t("");return}if(W&&A.length>0){et(Y,!0);return}Me(null),rt(""),ht(r=>r.length>0&&r.at(-1)===d?r:[...r,d]);let s=co(d);if(s){await He(s),t(""),ie(!1);return}if(oe){l("Please wait for file uploads to complete.");return}t(""),ie(!1),_(d)},[_,He,W,A,Y,et,F,O,G,P,ue,K,Ne,Se,l,t,y,f,m,h,$,Q,k,oe,Pe,De,Be,b,q,n]);return ls((x,d)=>{if(d.ctrl&&x==="c"){if(e.length>0){yt(""),Xe.current=!0,l("Press Ctrl+C again to exit.");return}if(Xe.current){se();return}se();return}if(d.ctrl&&x==="o"){M(s=>!s);return}if(Be){if(d.escape||d.return||x==="n"||x==="N"){xe(!1),t(""),l("Task deletion cancelled.");return}if(x==="y"||x==="Y"){xe(!1),t(""),b&&q&&new me().deleteTask(b.accessToken,b.workspaceId,n).then(()=>{f("Task deleted. Started a new task.")}).catch(r=>{l(`Failed to delete task: ${r.message||"Unknown error"}`)});return}return}if(F&&O.length>0){if(d.upArrow){p(s=>s<=0?O.length-1:s-1);return}if(d.downArrow){p(s=>s>=O.length-1?0:s+1);return}if(d.escape){v(null),S([]),t("");return}if(d.return){if(F==="model"){let s=O[G];s&&(y?f(`Switched to model: ${s.name} (new task)`):l(`Switched to model: ${s.name}`),m(s.id),h(void 0),$(null),fe.setDefaultModel(s.id))}else if(F==="agent"){let s=O[G];s&&(s.id!==y?f(`Switched to agent: ${s.name} (new task)`):l(`Switched to agent: ${s.name}`),h(s.id),m(void 0))}else if(F==="skills"){let s=O[G];if(s){let r=Ne.find(u=>u.id===s.id);r&&l(`Skill: ${r.name}
157
+ ID: ${u.id}`)}}v(null),S([]),t("");return}if(F==="connectors"){let r=[...P];Q(r.length>0?r:void 0),fe.setDefaultConnectorIds(r);let u=K.filter(c=>P.has(c.id)).map(c=>c.name);l(u.length>0?`Active connectors: ${u.join(", ")}`:"All connectors disabled."),v(null),S([]),t("");return}if(F==="capabilities"){let r=ue.has("fileSystem");k(r),fe.setLocalTools({fileSystem:r});let u=[];r&&u.push("FileSystem"),l(u.length>0?`Active capabilities: ${u.join(", ")}`:"All capabilities disabled."),v(null),S([]),t("");return}if(F==="profile"&&O.length>0){let r=O[G];if(r){let u=le.getCurrentProfileName();r.id===u?l(`Already using profile: ${r.name}`):(le.setOverrideProfile(r.id),le.setCurrentProfile(r.id),Pe(r.id),De(),f(`Switched to profile: ${r.name}`))}v(null),S([]),t("");return}if(W&&A.length>0){et(Y,!0);return}Me(null),rt(""),ht(r=>r.length>0&&r.at(-1)===d?r:[...r,d]);let s=co(d);if(s){await He(s),t(""),ie(!1);return}if(oe){l("Please wait for file uploads to complete.");return}t(""),ie(!1),_(d)},[_,He,W,A,Y,et,F,O,G,P,ue,K,Ne,Se,l,t,y,f,m,h,$,Q,k,oe,Pe,De,Be,b,q,n]);return ls((w,d)=>{if(d.ctrl&&w==="c"){if(e.length>0){yt(""),Xe.current=!0,l("Press Ctrl+C again to exit.");return}if(Xe.current){se();return}se();return}if(d.ctrl&&w==="o"){M(s=>!s);return}if(Be){if(d.escape||d.return||w==="n"||w==="N"){we(!1),t(""),l("Task deletion cancelled.");return}if(w==="y"||w==="Y"){we(!1),t(""),b&&q&&new me().deleteTask(b.accessToken,b.workspaceId,n).then(()=>{f("Task deleted. Started a new task.")}).catch(r=>{l(`Failed to delete task: ${r.message||"Unknown error"}`)});return}return}if(F&&O.length>0){if(d.upArrow){p(s=>s<=0?O.length-1:s-1);return}if(d.downArrow){p(s=>s>=O.length-1?0:s+1);return}if(d.escape){v(null),S([]),t("");return}if(d.return){if(F==="model"){let s=O[G];s&&(y?f(`Switched to model: ${s.name} (new task)`):l(`Switched to model: ${s.name}`),m(s.id),h(void 0),$(null),fe.setDefaultModel(s.id))}else if(F==="agent"){let s=O[G];s&&(s.id===y?l(`Switched to agent: ${s.name}`):f(`Switched to agent: ${s.name} (new task)`),h(s.id),m(void 0))}else if(F==="skills"){let s=O[G];if(s){let r=Ne.find(u=>u.id===s.id);r&&l(`Skill: ${r.name}
158
158
  ${r.description}
159
159
  Provider: ${r.provider}
160
160
  Author: ${r.author.name}
@@ -163,11 +163,11 @@ Agent: ${r.agent.name}
163
163
  Status: ${r.isActive?"Active":"Paused"}
164
164
  Repeat: ${sn(r.config)}
165
165
  Next Run: ${u}
166
- ID: ${r.id}`)}}}else if(F==="connectors"){let s=[...P];Q(s.length>0?s:void 0),fe.setDefaultConnectorIds(s);let r=K.filter(u=>P.has(u.id)).map(u=>u.name);l(r.length>0?`Active connectors: ${r.join(", ")}`:"All connectors disabled.")}else if(F==="capabilities"){let s=ue.has("fileSystem");k(s),fe.setLocalTools({fileSystem:s});let r=[];s&&r.push("FileSystem"),l(r.length>0?`Active capabilities: ${r.join(", ")}`:"All capabilities disabled.")}else if(F==="tasks"){let s=O[G];if(s){let r=$e.find(u=>u.id===s.id);r&&b&&(o(r.id),a(r.title||void 0),j(!0),new me().getMessages(b.accessToken,b.workspaceId,r.id,20).then(({messages:c})=>{let D=c.filter(ee=>ee.role==="user"||ee.role==="assistant").map(ee=>({role:ee.role,content:Ke(ee.parts,!1),parts:ee.parts})).filter(ee=>ee.content).toReversed();ae(D),l(`Switched to: ${r.title||"Untitled"}`)}).catch(()=>{l("Failed to load task messages.")}))}}else if(F==="profile"){let s=O[G];if(s){let r=le.getCurrentProfileName();s.id!==r?(le.setOverrideProfile(s.id),le.setCurrentProfile(s.id),Pe(s.id),De(),f(`Switched to profile: ${s.name}`)):l(`Already using profile: ${s.name}`)}}v(null),S([]),t("");return}if(x===" "&&(F==="connectors"||F==="capabilities")){let s=O[G];s&&(F==="connectors"?w:R)(u=>{let c=new Set(u);return c.has(s.id)?c.delete(s.id):c.add(s.id),c});return}if(x==="a"&&(F==="connectors"||F==="capabilities")){(F==="connectors"?w:R)(new Set(O.map(r=>r.id)));return}if(x==="n"&&(F==="connectors"||F==="capabilities")){(F==="connectors"?w:R)(new Set);return}return}if(W&&A.length>0){if(d.upArrow){V(s=>s<=0?A.length-1:s-1);return}if(d.downArrow){V(s=>s>=A.length-1?0:s+1);return}if(d.escape){ie(!1),z([]);return}if(d.tab){et(Y);return}}if(d.upArrow){if(e.includes(`
166
+ ID: ${r.id}`)}}}else if(F==="connectors"){let s=[...P];Q(s.length>0?s:void 0),fe.setDefaultConnectorIds(s);let r=K.filter(u=>P.has(u.id)).map(u=>u.name);l(r.length>0?`Active connectors: ${r.join(", ")}`:"All connectors disabled.")}else if(F==="capabilities"){let s=ue.has("fileSystem");k(s),fe.setLocalTools({fileSystem:s});let r=[];s&&r.push("FileSystem"),l(r.length>0?`Active capabilities: ${r.join(", ")}`:"All capabilities disabled.")}else if(F==="tasks"){let s=O[G];if(s){let r=$e.find(u=>u.id===s.id);r&&b&&(o(r.id),a(r.title||void 0),j(!0),new me().getMessages(b.accessToken,b.workspaceId,r.id,20).then(({messages:c})=>{let D=c.filter(ee=>ee.role==="user"||ee.role==="assistant").map(ee=>({role:ee.role,content:Ke(ee.parts,!1),parts:ee.parts})).filter(ee=>ee.content).toReversed();ae(D),l(`Switched to: ${r.title||"Untitled"}`)}).catch(()=>{l("Failed to load task messages.")}))}}else if(F==="profile"){let s=O[G];if(s){let r=le.getCurrentProfileName();s.id===r?l(`Already using profile: ${s.name}`):(le.setOverrideProfile(s.id),le.setCurrentProfile(s.id),Pe(s.id),De(),f(`Switched to profile: ${s.name}`))}}v(null),S([]),t("");return}if(w===" "&&(F==="connectors"||F==="capabilities")){let s=O[G];s&&(F==="connectors"?x:R)(u=>{let c=new Set(u);return c.has(s.id)?c.delete(s.id):c.add(s.id),c});return}if(w==="a"&&(F==="connectors"||F==="capabilities")){(F==="connectors"?x:R)(new Set(O.map(r=>r.id)));return}if(w==="n"&&(F==="connectors"||F==="capabilities")){(F==="connectors"?x:R)(new Set);return}return}if(W&&A.length>0){if(d.upArrow){V(s=>s<=0?A.length-1:s-1);return}if(d.downArrow){V(s=>s>=A.length-1?0:s+1);return}if(d.escape){ie(!1),z([]);return}if(d.tab){et(Y);return}}if(d.upArrow){if(e.includes(`
167
167
  `)||Fe.length===0)return;if(Ae===null){rt(e);let r=Fe.length-1;Me(r),t(Fe[r]);return}let s=Math.max(0,Ae-1);Me(s),t(Fe[s]);return}if(d.downArrow){if(e.includes(`
168
168
  `)||Ae===null)return;if(Ae>=Fe.length-1){Me(null),t(Ot);return}let s=Ae+1;Me(s),t(Fe[s])}}),{suggestions:A,suggestionIndex:Y,showSuggestions:W,argMode:F,argItems:O,argIndex:G,selectedConnectorIds:P,selectedCapabilities:ue,deleteConfirmMode:Be,handleInputChange:yt,handleSubmit:Ut}}import{useCallback as mt,useRef as cs,useState as us}from"react";function po({credentials:e,currentModel:t,modelProviders:n,onUploadSuccess:o,onUploadError:i}){let[a,g]=us([]),m=cs(0),y=mt(k=>{if(!(!Array.isArray(n)||n.length===0)){for(let E of n)if(E.models.some(K=>K.id===k))return E.id;return n[0]?.id}},[n]),h=mt(async k=>{if(!e){i?.(k.filename,"Not logged in");return}if(!Array.isArray(n)||n.length===0){i?.(k.filename,"Model providers not loaded yet. Please wait and try again.");return}let E=t?y(t):n[0]?.id;if(!E){i?.(k.filename,"No model provider available");return}let N=`file-${++m.current}`;g(K=>[...K,{id:N,filename:k.filename,mimeType:k.mimeType,status:"uploading"}]);try{let Z=await new me().uploadFile(e.accessToken,e.workspaceId,k,E);g(q=>q.map(j=>j.id===N?{...j,status:"uploaded",fileId:Z.id}:j)),o?.(k.filename)}catch(K){let Z=K instanceof Error?K.message:"Upload failed";g(q=>q.map(j=>j.id===N?{...j,status:"error",error:Z}:j)),i?.(k.filename,Z)}},[e,t,y,n,o,i]),L=mt(k=>{g(E=>E.filter(N=>N.id!==k))},[]),$=mt(()=>{g([])},[]),I=mt(()=>a.filter(k=>k.status==="uploaded"&&k.fileId).map(k=>k.fileId),[a]),Q=a.some(k=>k.status==="uploading"),C=a.length>0;return{pendingFiles:a,addFile:h,removeFile:L,clearFiles:$,getUploadedFileIds:I,hasUploadingFiles:Q,hasFiles:C}}import{jsx as J,jsxs as re}from"react/jsx-runtime";var fs=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],ps=[nn,nn,tn,tn,Ye,Ye,Ye,Ye],mo=fs.map((e,t)=>`${ps[t]??Ye}${e}${X}`).join(`
169
169
  `),ms=`${Ye}EntryDesk${X}`,gs=500;function hs(e){let t="",n=0;for(;n<e.length;){if(e.charCodeAt(n)===27&&e[n+1]==="["){for(n+=2;n<e.length;){let o=e.charCodeAt(n);if(o>=64&&o<=126){n+=1;break}n+=1}continue}t+=e[n],n+=1}return t}function ys(e){let t=hs(e);return Math.max(...t.split(`
170
- `).map(n=>n.length))}function ws(e){let t=ys(mo);return e>=t?mo:ms}function go({agentId:e,model:t,message:n,taskId:o,taskTitle:i,connectorIds:a,enableFileSystem:g=!0}){let m=process.stdout.columns??80,y=ws(m),h=cn(null),L=Kn(o,i),{state:$,setState:I,messages:Q,setMessages:C,input:k,setInput:E,taskId:N,setTaskId:K,currentTaskTitle:Z,setCurrentTaskTitle:q,hasPersistedTask:j,setHasPersistedTask:ae,credentials:l,setCredentials:f,currentResponse:_,setCurrentResponse:M,fullOutput:b,setFullOutput:pe,addSystemMessage:te,startNewTask:T}=L,{credentials:B}=Xn(I);At(()=>{B&&!l&&f(B)},[B,l,f]);let{availableConnectors:oe,availableModels:se,availableAgents:A,modelProviders:z,loading:Y}=Qn(l),{currentModel:V,setCurrentModel:W,currentAgentId:ie,setCurrentAgentId:F,activeConnectorIds:v,setActiveConnectorIds:O}=ro(t,e,a),S=cn(!1);At(()=>{if(!S.current){if(S.current=!0,!t&&!e){let c=fe.getDefaultModel();c&&W(c)}if(!a&&!e){let c=fe.getDefaultConnectorIds();c&&O(c.length>0?c:void 0)}}},[t,e,a,W,O]);let{currentAgentDetails:G}=so(ie,l),{fileSystem:p,setFileSystem:P,capabilityLabelMap:w}=oo(g),{pendingFiles:ue,addFile:R,removeFile:$e,clearFiles:gt,getUploadedFileIds:Ne,hasUploadingFiles:Bt,hasFiles:Se}=po({credentials:l,currentModel:V,modelProviders:z,onUploadSuccess:c=>{te(`\u2713 Attached: ${c}`)},onUploadError:(c,D)=>{te(`\u2717 Failed to upload ${c}: ${D}`)}}),{sendMessage:st}=to({taskId:N,credentials:l,currentAgentId:ie,currentModel:V,activeConnectorIds:v,localTools:p,fullOutput:b,setMessages:C,setState:I,setCurrentResponse:M,setCredentials:f,setHasPersistedTask:ae,getFileIds:Ne,clearFiles:gt}),Fe=an(c=>{T(c),M("")},[T]),[ht,Ae]=ds(!1),Me=an(async c=>{let D=c.text.trim(),ee=_t(D);if(/^https?:\/\//.test(ee))return;if(await qn(D)&&Hn(ee)){let H=await Jn(D);H&&(c.preventDefault(),await R(H))}},[R]),Ot=an(async()=>{if(!(ht||$.status!=="ready")){if(Y||z.length===0){te("Please wait for resources to load before pasting images.");return}te("Reading clipboard..."),Ae(!0);try{let c=await Gn();if(c){let D=`clipboard-${Date.now()}.png`;te(`Uploading: ${D} (${Math.round(c.buffer.length/1024)}KB)`),await R({buffer:c.buffer,filename:D,mimeType:c.mime})}else te("No image found in clipboard. Copy an image first.")}catch(c){let D=c instanceof Error?c.message:"Failed to read clipboard";te(`Clipboard error: ${D}`)}finally{Ae(!1)}}},[R,te,ht,$.status,Y,z.length]),{suggestions:rt,suggestionIndex:Xe,showSuggestions:Be,argMode:xe,argItems:Qe,argIndex:Ze,selectedConnectorIds:ke,selectedCapabilities:Pe,deleteConfirmMode:De,handleInputChange:He,handleSubmit:yt}=fo({input:k,setInput:E,taskId:N,setTaskId:K,currentTaskTitle:Z,setCurrentTaskTitle:q,currentModel:V,setCurrentModel:W,currentAgentId:ie,setCurrentAgentId:F,currentAgentDetails:G,setCurrentAgentDetails:()=>{},activeConnectorIds:v,setActiveConnectorIds:O,fileSystem:p,setFileSystem:P,availableModels:se,availableAgents:A,availableConnectors:oe,messages:Q,hasPersistedTask:j,setHasPersistedTask:ae,setMessages:C,addSystemMessage:te,startNewTask:Fe,sendMessage:st,setFullOutput:pe,credentials:l,setCredentials:f,setState:I,defaultCapabilities:{fileSystem:g},capabilityLabelMap:w,hasUploadingFiles:Bt});rn((c,D)=>{(D.ctrl||D.meta)&&c==="v"&&Ot()},{isActive:$.status==="ready"&&!xe}),rn((c,D)=>{if(!D.escape)return;let ee=Date.now(),Te=h.current;h.current=ee,!(!Te||ee-Te>gs)&&(xe||Be||(h.current=null,Se&&gt(),k.length>0&&He("")))},{isActive:$.status==="ready"}),rn((c,D)=>{D.return&&(Fe("Started a new task."),I({status:"ready"}))},{isActive:$.status==="error"}),At(()=>{if(l&&!Y&&$.status==="loading")if(!V&&!ie){let c=fe.getDefaultModel(),D=c&&se.some(Te=>Te.id===c),ee=D?c:se[0]?.id;ee?(D||fe.setDefaultModel(ee),W(ee),I({status:"ready"})):A.length===0?I({status:"no-model"}):I({status:"ready"})}else I({status:"ready"})},[l,Y,V,ie,se,A,$.status,W,I]);let et=cn(!1);if(At(()=>{et.current||n&&l&&$.status==="ready"&&(et.current=!0,st(n))},[l,n,$.status,st]),$.status==="loading")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),re(ye,{children:[J(U,{color:"cyan",children:J(ln,{type:"dots"})}),J(U,{children:" Initializing task..."})]})]});if($.status==="not-logged-in")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),J(U,{color:"yellow",children:"Not logged in"}),J(U,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if($.status==="no-workspace")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),J(U,{color:"yellow",children:"No workspace selected"}),J(U,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if($.status==="no-model")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),J(U,{color:"yellow",children:"No model or agent specified"}),o&&J(U,{dimColor:!0,children:"Could not determine the model used in this task."}),J(U,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),J(U,{dimColor:!0,children:"Example: entrydesk task -c 1 -i --model gemini-2.5-flash-lite"})]});if($.status==="error")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),re(U,{color:"red",children:["Error: ",$.message]}),J(U,{dimColor:!0,children:"Press Enter to start a new task, or Ctrl+C to exit"})]});let Ut=ie?G?G.connectors&&G.connectors.length>0?G.connectors.map(c=>c.name).join(", "):"none":"loading...":v&&v.length>0?oe.filter(c=>v.includes(c.id)).map(c=>c.name).join(", ")||`${v.length} connector(s)`:"none",x=[];if(ie)if(G?.capabilities)for(let c of G.capabilities)x.push(w.get(c)??c);else x.push("loading...");p&&x.push("FileSystem");let d=le.getCurrentProfileName(),s=d!=="default",r=(()=>{switch(xe){case"model":return"Select model:";case"agent":return"Select agent:";case"skills":return"Select skill:";case"connectors":return"Select connectors:";case"capabilities":return"Select capabilities:";default:return"Select task:"}})(),u=(()=>{if(xe==="connectors")return ke;if(xe==="capabilities")return Pe})();return re(ye,{flexDirection:"column",children:[re(ye,{marginBottom:1,flexDirection:"column",children:[J(U,{children:y}),re(ye,{children:[J(U,{bold:!0,color:"cyan",children:Z?`Continuing: ${Z}`:"EntryDesk CLI"}),re(U,{dimColor:!0,children:[" v","1.24.0"]}),s&&re(U,{color:"magenta",children:[" [",d,"]"]}),J(U,{dimColor:!0,children:" (type /help for commands)"})]})]}),Q.map((c,D)=>{let ee=c.parts&&b?Ke(c.parts,!0):c.content,Te=c.role==="user"?"green":c.role==="system"?"yellow":"blue",H=c.role==="user"?"You":c.role==="system"?"System":"Assistant";return re(ye,{flexDirection:"column",marginBottom:1,children:[re(U,{bold:!0,color:Te,children:[H,":"]}),J(en,{text:ee})]},D)}),_&&re(ye,{flexDirection:"column",marginBottom:1,children:[J(U,{bold:!0,color:"blue",children:"Assistant:"}),J(en,{text:_})]}),$.status==="ready"&&J(vn,{suggestions:rt,activeIndex:Xe,visible:Be}),$.status==="ready"&&xe&&J(In,{items:Qe,activeIndex:Ze,pageSize:xe==="agent"||xe==="skills"||xe==="model"?5:10,selectedIds:u,multiSelect:xe==="connectors"||xe==="capabilities",visible:!0,title:r}),$.status==="sending"&&!_?re(ye,{children:[J(U,{color:"cyan",children:J(ln,{type:"dots"})}),J(U,{children:" Thinking..."})]}):$.status==="ready"&&!xe?re(ye,{flexDirection:"column",children:[De&&J(ye,{marginBottom:1,children:J(U,{color:"yellow",children:"\u26A0\uFE0F Delete this task? (y/N) "})}),Se&&!De&&re(ye,{marginBottom:1,flexDirection:"row",gap:1,children:[J(U,{dimColor:!0,children:"Attachments:"}),ue.map((c,D)=>re(U,{children:[c.status==="uploading"?re(U,{color:"yellow",children:[J(ln,{type:"dots"})," ",c.filename]}):c.status==="error"?re(U,{color:"red",children:["\u2717 ",c.filename]}):re(U,{color:"green",children:["\u2713 ",c.filename]}),D<ue.length-1&&J(U,{children:", "})]},c.id))]}),re(ye,{children:[J(U,{color:"green",children:"> "}),J(Rn,{value:k,onChange:He,onSubmit:yt,onPaste:Me,leadingOffset:2,multiline:!0})]})]}):null,re(ye,{marginTop:1,flexDirection:"column",children:[re(ye,{gap:2,children:[re(U,{children:[J(U,{dimColor:!0,children:"Model: "}),J(U,{color:"magenta",children:ie?G?.model?.name||"loading...":se.find(c=>c.id===V)?.name||V||"none"})]}),re(U,{children:[J(U,{dimColor:!0,children:"Connectors: "}),J(U,{color:"cyan",children:Ut})]}),re(U,{children:[J(U,{dimColor:!0,children:"Capabilities: "}),J(U,{color:"green",children:x.length>0?x.join(", "):"none"})]})]}),re(U,{dimColor:!0,children:["Esc Esc: Clear input & attachments | Ctrl+V: Paste image | Ctrl+O: Toggle full output ",b?"(ON)":"(OFF)"," | Ctrl+C: Exit"]})]})]})}import{jsx as $s}from"react/jsx-runtime";function Ui(){console.log(`
170
+ `).map(n=>n.length))}function xs(e){let t=ys(mo);return e>=t?mo:ms}function go({agentId:e,model:t,message:n,taskId:o,taskTitle:i,connectorIds:a,enableFileSystem:g=!0}){let m=process.stdout.columns??80,y=xs(m),h=cn(null),L=Kn(o,i),{state:$,setState:I,messages:Q,setMessages:C,input:k,setInput:E,taskId:N,setTaskId:K,currentTaskTitle:Z,setCurrentTaskTitle:q,hasPersistedTask:j,setHasPersistedTask:ae,credentials:l,setCredentials:f,currentResponse:_,setCurrentResponse:M,fullOutput:b,setFullOutput:pe,addSystemMessage:te,startNewTask:T}=L,{credentials:B}=Xn(I);At(()=>{B&&!l&&f(B)},[B,l,f]);let{availableConnectors:oe,availableModels:se,availableAgents:A,modelProviders:z,loading:Y}=Qn(l),{currentModel:V,setCurrentModel:W,currentAgentId:ie,setCurrentAgentId:F,activeConnectorIds:v,setActiveConnectorIds:O}=ro(t,e,a),S=cn(!1);At(()=>{if(!S.current){if(S.current=!0,!t&&!e){let c=fe.getDefaultModel();c&&W(c)}if(!a&&!e){let c=fe.getDefaultConnectorIds();c&&O(c.length>0?c:void 0)}}},[t,e,a,W,O]);let{currentAgentDetails:G}=so(ie,l),{fileSystem:p,setFileSystem:P,capabilityLabelMap:x}=oo(g),{pendingFiles:ue,addFile:R,removeFile:$e,clearFiles:gt,getUploadedFileIds:Ne,hasUploadingFiles:Bt,hasFiles:Se}=po({credentials:l,currentModel:V,modelProviders:z,onUploadSuccess:c=>{te(`\u2713 Attached: ${c}`)},onUploadError:(c,D)=>{te(`\u2717 Failed to upload ${c}: ${D}`)}}),{sendMessage:st}=to({taskId:N,credentials:l,currentAgentId:ie,currentModel:V,activeConnectorIds:v,localTools:p,fullOutput:b,setMessages:C,setState:I,setCurrentResponse:M,setCredentials:f,setHasPersistedTask:ae,getFileIds:Ne,clearFiles:gt}),Fe=an(c=>{T(c),M("")},[T]),[ht,Ae]=ds(!1),Me=an(async c=>{let D=c.text.trim(),ee=_t(D);if(/^https?:\/\//.test(ee))return;if(await qn(D)&&Hn(ee)){let H=await Jn(D);H&&(c.preventDefault(),await R(H))}},[R]),Ot=an(async()=>{if(!(ht||$.status!=="ready")){if(Y||z.length===0){te("Please wait for resources to load before pasting images.");return}te("Reading clipboard..."),Ae(!0);try{let c=await Gn();if(c){let D=`clipboard-${Date.now()}.png`;te(`Uploading: ${D} (${Math.round(c.buffer.length/1024)}KB)`),await R({buffer:c.buffer,filename:D,mimeType:c.mime})}else te("No image found in clipboard. Copy an image first.")}catch(c){let D=c instanceof Error?c.message:"Failed to read clipboard";te(`Clipboard error: ${D}`)}finally{Ae(!1)}}},[R,te,ht,$.status,Y,z.length]),{suggestions:rt,suggestionIndex:Xe,showSuggestions:Be,argMode:we,argItems:Qe,argIndex:Ze,selectedConnectorIds:ke,selectedCapabilities:Pe,deleteConfirmMode:De,handleInputChange:He,handleSubmit:yt}=fo({input:k,setInput:E,taskId:N,setTaskId:K,currentTaskTitle:Z,setCurrentTaskTitle:q,currentModel:V,setCurrentModel:W,currentAgentId:ie,setCurrentAgentId:F,currentAgentDetails:G,setCurrentAgentDetails:()=>{},activeConnectorIds:v,setActiveConnectorIds:O,fileSystem:p,setFileSystem:P,availableModels:se,availableAgents:A,availableConnectors:oe,messages:Q,hasPersistedTask:j,setHasPersistedTask:ae,setMessages:C,addSystemMessage:te,startNewTask:Fe,sendMessage:st,setFullOutput:pe,credentials:l,setCredentials:f,setState:I,defaultCapabilities:{fileSystem:g},capabilityLabelMap:x,hasUploadingFiles:Bt});rn((c,D)=>{(D.ctrl||D.meta)&&c==="v"&&Ot()},{isActive:$.status==="ready"&&!we}),rn((c,D)=>{if(!D.escape)return;let ee=Date.now(),Te=h.current;h.current=ee,!(!Te||ee-Te>gs)&&(we||Be||(h.current=null,Se&&gt(),k.length>0&&He("")))},{isActive:$.status==="ready"}),rn((c,D)=>{D.return&&(Fe("Started a new task."),I({status:"ready"}))},{isActive:$.status==="error"}),At(()=>{if(l&&!Y&&$.status==="loading")if(!V&&!ie){let c=fe.getDefaultModel(),D=c&&se.some(Te=>Te.id===c),ee=D?c:se[0]?.id;ee?(D||fe.setDefaultModel(ee),W(ee),I({status:"ready"})):A.length===0?I({status:"no-model"}):I({status:"ready"})}else I({status:"ready"})},[l,Y,V,ie,se,A,$.status,W,I]);let et=cn(!1);if(At(()=>{et.current||n&&l&&$.status==="ready"&&(et.current=!0,st(n))},[l,n,$.status,st]),$.status==="loading")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),re(ye,{children:[J(U,{color:"cyan",children:J(ln,{type:"dots"})}),J(U,{children:" Initializing task..."})]})]});if($.status==="not-logged-in")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),J(U,{color:"yellow",children:"Not logged in"}),J(U,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if($.status==="no-workspace")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),J(U,{color:"yellow",children:"No workspace selected"}),J(U,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if($.status==="no-model")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),J(U,{color:"yellow",children:"No model or agent specified"}),o&&J(U,{dimColor:!0,children:"Could not determine the model used in this task."}),J(U,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),J(U,{dimColor:!0,children:"Example: entrydesk task -c 1 -i --model gemini-2.5-flash-lite"})]});if($.status==="error")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),re(U,{color:"red",children:["Error: ",$.message]}),J(U,{dimColor:!0,children:"Press Enter to start a new task, or Ctrl+C to exit"})]});let Ut=ie?G?G.connectors&&G.connectors.length>0?G.connectors.map(c=>c.name).join(", "):"none":"loading...":v&&v.length>0?oe.filter(c=>v.includes(c.id)).map(c=>c.name).join(", ")||`${v.length} connector(s)`:"none",w=[];if(ie)if(G?.capabilities)for(let c of G.capabilities)w.push(x.get(c)??c);else w.push("loading...");p&&w.push("FileSystem");let d=le.getCurrentProfileName(),s=d!=="default",r=(()=>{switch(we){case"model":return"Select model:";case"agent":return"Select agent:";case"skills":return"Select skill:";case"connectors":return"Select connectors:";case"capabilities":return"Select capabilities:";default:return"Select task:"}})(),u=(()=>{if(we==="connectors")return ke;if(we==="capabilities")return Pe})();return re(ye,{flexDirection:"column",children:[re(ye,{marginBottom:1,flexDirection:"column",children:[J(U,{children:y}),re(ye,{children:[J(U,{bold:!0,color:"cyan",children:Z?`Continuing: ${Z}`:"EntryDesk CLI"}),re(U,{dimColor:!0,children:[" v","1.26.0"]}),s&&re(U,{color:"magenta",children:[" [",d,"]"]}),J(U,{dimColor:!0,children:" (type /help for commands)"})]})]}),Q.map((c,D)=>{let ee=c.parts&&b?Ke(c.parts,!0):c.content,Te=c.role==="user"?"green":c.role==="system"?"yellow":"blue",H=c.role==="user"?"You":c.role==="system"?"System":"Assistant";return re(ye,{flexDirection:"column",marginBottom:1,children:[re(U,{bold:!0,color:Te,children:[H,":"]}),J(en,{text:ee})]},D)}),_&&re(ye,{flexDirection:"column",marginBottom:1,children:[J(U,{bold:!0,color:"blue",children:"Assistant:"}),J(en,{text:_})]}),$.status==="ready"&&J(vn,{suggestions:rt,activeIndex:Xe,visible:Be}),$.status==="ready"&&we&&J(In,{items:Qe,activeIndex:Ze,pageSize:we==="agent"||we==="skills"||we==="model"?5:10,selectedIds:u,multiSelect:we==="connectors"||we==="capabilities",visible:!0,title:r}),$.status==="sending"&&!_?re(ye,{children:[J(U,{color:"cyan",children:J(ln,{type:"dots"})}),J(U,{children:" Thinking..."})]}):$.status==="ready"&&!we?re(ye,{flexDirection:"column",children:[De&&J(ye,{marginBottom:1,children:J(U,{color:"yellow",children:"\u26A0\uFE0F Delete this task? (y/N) "})}),Se&&!De&&re(ye,{marginBottom:1,flexDirection:"row",gap:1,children:[J(U,{dimColor:!0,children:"Attachments:"}),ue.map((c,D)=>re(U,{children:[c.status==="uploading"?re(U,{color:"yellow",children:[J(ln,{type:"dots"})," ",c.filename]}):c.status==="error"?re(U,{color:"red",children:["\u2717 ",c.filename]}):re(U,{color:"green",children:["\u2713 ",c.filename]}),D<ue.length-1&&J(U,{children:", "})]},c.id))]}),re(ye,{children:[J(U,{color:"green",children:"> "}),J(Rn,{value:k,onChange:He,onSubmit:yt,onPaste:Me,leadingOffset:2,multiline:!0})]})]}):null,re(ye,{marginTop:1,flexDirection:"column",children:[re(ye,{gap:2,children:[re(U,{children:[J(U,{dimColor:!0,children:"Model: "}),J(U,{color:"magenta",children:ie?G?.model?.name||"loading...":se.find(c=>c.id===V)?.name||V||"none"})]}),re(U,{children:[J(U,{dimColor:!0,children:"Connectors: "}),J(U,{color:"cyan",children:Ut})]}),re(U,{children:[J(U,{dimColor:!0,children:"Capabilities: "}),J(U,{color:"green",children:w.length>0?w.join(", "):"none"})]})]}),re(U,{dimColor:!0,children:["Esc Esc: Clear input & attachments | Ctrl+V: Paste image | Ctrl+O: Toggle full output ",b?"(ON)":"(OFF)"," | Ctrl+C: Exit"]})]})]})}import{jsx as $s}from"react/jsx-runtime";function Ui(){console.log(`
171
171
  Usage: entrydesk task [options]
172
172
 
173
173
  Send a message to a model or agent, or start an interactive session.
@@ -192,20 +192,20 @@ Examples:
192
192
  entrydesk task -i # Interactive mode
193
193
  echo "Explain this" | entrydesk task --model <model> # Pipe stdin
194
194
  entrydesk task -m "Hi" --model <m> --output stream-json
195
- `)}async function ks(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").trim()}async function Ts(e,t,n,o){if(o<1)return console.error("Task number must be 1 or greater"),null;let{tasks:i}=await e.getTasks(t,n,20);if(i.length===0)return console.error("No tasks found. Start a new task first."),null;if(o>i.length)return console.error(`Task number ${o} not found. You have ${i.length} recent tasks.`),console.error("Use `entrydesk tasks` to see available tasks."),null;let a=i[o-1],g;if(!a.agentId){let{messages:m}=await e.getMessages(t,n,a.id,10);g=m.find(h=>h.role==="assistant"&&h.modelId)?.modelId}return{task:a,modelId:g}}var Ve="\x1B[2m",we="\x1B[0m",un="\x1B[36m",Ft="\x1B[33m",Dt="\x1B[32m",yo="stream-json";function Cs(e,t,n,o){e&&t&&(console.error(`Error: Cannot use both ${n} and ${o}`),process.exit(1))}function Rt(e,t){let n=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(n)}
195
+ `)}async function ks(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").trim()}async function Ts(e,t,n,o){if(o<1)return console.error("Task number must be 1 or greater"),null;let{tasks:i}=await e.getTasks(t,n,20);if(i.length===0)return console.error("No tasks found. Start a new task first."),null;if(o>i.length)return console.error(`Task number ${o} not found. You have ${i.length} recent tasks.`),console.error("Use `entrydesk tasks` to see available tasks."),null;let a=i[o-1],g;if(!a.agentId){let{messages:m}=await e.getMessages(t,n,a.id,10);g=m.find(h=>h.role==="assistant"&&h.modelId)?.modelId}return{task:a,modelId:g}}var Ve="\x1B[2m",xe="\x1B[0m",un="\x1B[36m",Ft="\x1B[33m",Dt="\x1B[32m",yo="stream-json";function Cs(e,t,n,o){e&&t&&(console.error(`Error: Cannot use both ${n} and ${o}`),process.exit(1))}function Rt(e,t){let n=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(n)}
196
196
  `)}function Lt(e,t){if(t)return e;let n=e.split(`
197
- `);if(n.length<=20)return e;let o=n.slice(0,5),i=n.slice(-5),a=n.length-10;return[...o,`${Ve}... (${a} lines omitted, use --full-output to see all) ...${we}`,...i].join(`
198
- `)}function bs(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function wo(e,t){if(!e)return"(no result)";if(typeof e!="object")return Lt(String(e),t);let n=e;if("structuredContent"in n&&n.structuredContent){let o=n.structuredContent,i=[];if(o.stdout&&typeof o.stdout=="string"&&o.stdout.trim()&&i.push(o.stdout.trim()),o.stderr&&typeof o.stderr=="string"&&o.stderr.trim()&&i.push(`${Ft}[stderr]${we} ${o.stderr.trim()}`),o.urls&&Array.isArray(o.urls)){let a=o.urls;for(let g of a)g.path&&g.url&&i.push(`${g.path}: ${g.url}`)}return i.length===0&&i.push(JSON.stringify(o,null,2)),Lt(i.join(`
197
+ `);if(n.length<=20)return e;let o=n.slice(0,5),i=n.slice(-5),a=n.length-10;return[...o,`${Ve}... (${a} lines omitted, use --full-output to see all) ...${xe}`,...i].join(`
198
+ `)}function bs(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function xo(e,t){if(!e)return"(no result)";if(typeof e!="object")return Lt(String(e),t);let n=e;if("structuredContent"in n&&n.structuredContent){let o=n.structuredContent,i=[];if(o.stdout&&typeof o.stdout=="string"&&o.stdout.trim()&&i.push(o.stdout.trim()),o.stderr&&typeof o.stderr=="string"&&o.stderr.trim()&&i.push(`${Ft}[stderr]${xe} ${o.stderr.trim()}`),o.urls&&Array.isArray(o.urls)){let a=o.urls;for(let g of a)g.path&&g.url&&i.push(`${g.path}: ${g.url}`)}return i.length===0&&i.push(JSON.stringify(o,null,2)),Lt(i.join(`
199
199
  `),t)}if("content"in n&&Array.isArray(n.content)){let i=n.content.filter(a=>a.type==="text"&&a.text).map(a=>a.text).join(`
200
- `);return Lt(i||JSON.stringify(e,null,2),t)}return Lt(JSON.stringify(e,null,2),t)}function xo(e){try{let n=(typeof e.data=="string"?JSON.parse(e.data):e.data)?.parts;return Array.isArray(n)?n.filter(o=>typeof o=="object"&&o!==null&&o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(""):""}catch{return""}}async function ji(e){let t,n;try{let A=await We();t=A.accessToken,n=A.workspaceId}catch(A){fn(A)}let o=e.output===yo;e.output&&!o&&(console.error(`Invalid --output value. Supported: ${yo}`),process.exit(1));let i=!o&&(e.plain||!process.stdout.isTTY),a=fe.getDefaultModel(),g=e.message;!g&&!process.stdin.isTTY&&(g=await ks());let m=new me,y,h=!1;async function L(){if(h)return y;h=!0;try{({models:y}=await m.listSelectableModels(t,n))}catch{y=void 0}return y}async function $(){let A=await L();if(!A||a&&A.some(Y=>Y.id===a))return;let z=A[0]?.id;z&&(fe.setDefaultModel(z),a=z)}let I,Q,C,k;if(e.continue){let A=await Ts(m,t,n,e.continue);if(A||process.exit(1),I=A.task.id,Q=A.task.title??void 0,C=A.task.agentId??void 0,k=A.modelId,k&&!C&&!e.model){let Y=await L();Y&&!Y.some(V=>V.id===k)&&(k=void 0)}let z=e.agentId||e.model||C||k||a;!z&&!e.interactive&&(await $(),z=e.agentId||e.model||C||k||a),!z&&!e.interactive&&(i||console.log(`Continuing task: ${A.task.title||"Untitled"}`),console.error(`
200
+ `);return Lt(i||JSON.stringify(e,null,2),t)}return Lt(JSON.stringify(e,null,2),t)}function wo(e){try{let n=(typeof e.data=="string"?JSON.parse(e.data):e.data)?.parts;return Array.isArray(n)?n.filter(o=>typeof o=="object"&&o!==null&&o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(""):""}catch{return""}}async function ji(e){let t,n;try{let A=await We();t=A.accessToken,n=A.workspaceId}catch(A){fn(A)}let o=e.output===yo;e.output&&!o&&(console.error(`Invalid --output value. Supported: ${yo}`),process.exit(1));let i=!o&&(e.plain||!process.stdout.isTTY),a=fe.getDefaultModel(),g=e.message;!g&&!process.stdin.isTTY&&(g=await ks());let m=new me,y,h=!1;async function L(){if(h)return y;h=!0;try{({models:y}=await m.listSelectableModels(t,n))}catch{y=void 0}return y}async function $(){let A=await L();if(!A||a&&A.some(Y=>Y.id===a))return;let z=A[0]?.id;z&&(fe.setDefaultModel(z),a=z)}let I,Q,C,k;if(e.continue){let A=await Ts(m,t,n,e.continue);if(A||process.exit(1),I=A.task.id,Q=A.task.title??void 0,C=A.task.agentId??void 0,k=A.modelId,k&&!C&&!e.model){let Y=await L();Y&&!Y.some(V=>V.id===k)&&(k=void 0)}let z=e.agentId||e.model||C||k||a;!z&&!e.interactive&&(await $(),z=e.agentId||e.model||C||k||a),!z&&!e.interactive&&(i||console.log(`Continuing task: ${A.task.title||"Untitled"}`),console.error(`
201
201
  Could not determine model for this task. Please specify --model or -a.`),console.error('Example: entrydesk task -c 1 -m "message" --model gemini-2.5-flash-lite'),process.exit(1)),!i&&!e.interactive&&console.log(`Continuing task: ${A.task.title||"Untitled"}
202
- `)}let E=e.agentId||C,N=e.model||k||void 0;!E&&!N&&(await $(),N=e.model||k||a||void 0),Cs(e.fileSystem,e.noFileSystem,"--file-system","--no-file-system");let K=fe.getDefaultConnectorIds(),Z=e.connectors??K??void 0,q=fe.getLocalTools(),j=e.noFileSystem?!1:e.fileSystem?!0:q?.fileSystem??!0;if(e.interactive){xs($s(go,{agentId:E,model:N,message:e.message,taskId:I,taskTitle:Q??void 0,connectorIds:Z,enableFileSystem:j}),{exitOnCtrlC:!1});return}let ae=!e.continue&&!N&&!E;(!g||ae)&&(console.error("Usage: entrydesk task -m <message> --model <model>"),console.error(" entrydesk task -m <message> -a <agent>"),console.error(" entrydesk task -c <number> -m <message>"),console.error(' echo "message" | entrydesk task --model <model>'),console.error(" entrydesk task -i (interactive mode)"),console.error(""),console.error("Options:"),console.error(" -m, --message Message to send (or pipe via stdin)"),console.error(" --model Model ID to use (required if no agent and no default)"),console.error(" -a, --agent Agent ID to use (required if no model)"),console.error(" -c, --continue Continue recent task by number (1 = most recent)"),console.error(" -i Interactive mode"),console.error(" --plain Plain text output (no colors/formatting)"),console.error(" --output stream-json Stream JSON events (for scripting)"),console.error(" --full-output Show full tool results without truncation"),console.error(" --dangerously-auto-approve-tools"),console.error(" Auto-approve all server-side tool calls (required for"),console.error(" non-interactive use with connectors/MCP tools)"),console.error(""),console.error("List available models: entrydesk models"),console.error("List available agents: entrydesk agents"),console.error("List recent tasks: entrydesk tasks"),process.exit(1));let l=e.fullOutput??!1,f=e.dangerouslyAutoApproveTools??!1,_=I||ho(),M=j?xt():void 0,b=j?kt():void 0,pe=A=>{let z={id:_,...f&&{toolApprovalMode:"always_allow"}};return A&&(z.message=A),E?z.agentId=E:(N&&(z.model=N),z.connectorIds=Z??[]),M&&(z.clientTools=M),b&&(z.clientToolSystemPrompt=b),z},te=async A=>{if(!A.body)throw new Error("No response body");let z=A.body.getReader(),Y=new TextDecoder,V="",W=new Map,ie=[],F=!1,v="";for(;;){let{done:O,value:S}=await z.read();if(O)break;V+=Y.decode(S,{stream:!0});let G=V.split(`
203
- `);V=G.pop()||"";for(let p of G){let P=p.trimEnd();if(P==="data: [DONE]"){o&&Rt("done");continue}if(P.startsWith("data: "))try{let w=JSON.parse(P.slice(6));if((w.type==="text-delta"||w.type==="reasoning-delta"||w.type==="tool-call"||w.type==="tool-input-available"||w.type==="tool-result"||w.type==="data-appendMessage")&&(F=!0),w.type==="start"&&typeof w.messageId=="string"&&(v=w.messageId),o){w.type==="text-delta"&&w.delta!==void 0?Rt("text-delta",w.delta):w.type==="reasoning-delta"&&w.delta!==void 0?Rt("reasoning-delta",w.delta):Rt(w.type||"event",w);continue}if(i){if(w.type==="text-delta"&&w.delta&&process.stdout.write(w.delta),w.type==="data-appendMessage"&&process.stdout.write(xo(w)),j&&(w.type==="tool-input-available"||w.type==="tool-call")&&w.toolCallId&&w.toolName&&Oe(w.toolName)){let ue=w.args||w.input||{};ie.push({toolCallId:w.toolCallId,toolName:w.toolName,args:ue})}continue}switch(w.type){case"reasoning-delta":w.delta&&process.stdout.write(`${Ve}${w.delta}${we}`);break;case"reasoning-end":process.stdout.write(`
204
-
205
- `);break;case"text-delta":w.delta&&process.stdout.write(w.delta);break;case"data-appendMessage":process.stdout.write(xo(w));break;case"tool-call-streaming-start":case"tool-input-start":if(w.toolCallId&&w.toolName){W.set(w.toolCallId,{toolName:w.toolName});let R=j&&Oe(w.toolName)?`${Dt}[LOCAL]${we} `:"";console.log(`
206
- ${un}\u250C\u2500 ${R}Tool Call: ${w.toolName}${we}`)}break;case"tool-call":case"tool-input-available":if(w.toolCallId&&w.toolName){let ue=w.args||w.input||{},R=bs(ue);console.log(`${Ft}\u2502 Arguments:${we}`);for(let $e of R.split(`
207
- `))console.log(`${Ve}\u2502 ${$e}${we}`);j&&Oe(w.toolName)&&(W.set(w.toolCallId,{toolName:w.toolName,args:ue}),ie.push({toolCallId:w.toolCallId,toolName:w.toolName,args:ue}))}break;case"tool-result":if(w.toolCallId){let ue=W.get(w.toolCallId),R=wo(w.result,l);console.log(`${Dt}\u2502 Result:${we}`);for(let $e of R.split(`
208
- `))console.log(`${Ve}\u2502 ${$e}${we}`);console.log(`${un}\u2514\u2500 ${ue?.toolName||"Tool"} completed${we}
209
- `),W.delete(w.toolCallId)}break;case"error":w.errorText&&console.error(`${Ve}Error: ${w.errorText}${we}`);break}}catch{}}}return{pendingClientTools:ie,hadContent:F,messageId:v}},T=pe({id:ho(),createdAt:new Date,role:"user",parts:[{type:"text",text:g}]}),B=await m.task(t,n,T),oe=await te(B),se=oe.hadContent;for(;oe.pendingClientTools.length>0;){let A=oe.messageId,z=[];for(let V of oe.pendingClientTools){!i&&!o&&console.log(`${Dt}\u2502 Executing locally...${we}`);let W=await Tt(V.toolName,V.args);if(z.push({type:`tool-${V.toolName}`,toolCallId:V.toolCallId,state:"output-available",output:{content:Ct(W),isError:!W.success}}),!i&&!o){let ie=wo(W.success?W.result:{error:W.error},l);console.log(`${Dt}\u2502 Result:${we}`);for(let F of ie.split(`
210
- `))console.log(`${Ve}\u2502 ${F}${we}`);console.log(`${un}\u2514\u2500 ${V.toolName} completed${we}
211
- `)}}A||(console.error(`${Ft}Cannot continue: missing assistant message id for tool results.${we}`),process.exit(1));let Y=pe({id:A,role:"assistant",parts:z});B=await m.task(t,n,Y),oe=await te(B),se=se||oe.hadContent}se||(console.error(`${Ft}No response received from the server (empty stream).${we}`),console.error(`${Ve}The task may have failed server-side. Re-run with DEBUG=1 for details.${we}`),process.exit(1)),o||console.log("")}export{Ui as printTaskHelp,ji as runTask};
202
+ `)}let E=e.agentId||C,N=e.model||k||void 0;!E&&!N&&(await $(),N=e.model||k||a||void 0),Cs(e.fileSystem,e.noFileSystem,"--file-system","--no-file-system");let K=fe.getDefaultConnectorIds(),Z=e.connectors??K??void 0,q=fe.getLocalTools(),j=e.noFileSystem?!1:e.fileSystem?!0:q?.fileSystem??!0;if(e.interactive){ws($s(go,{agentId:E,model:N,message:e.message,taskId:I,taskTitle:Q??void 0,connectorIds:Z,enableFileSystem:j}),{exitOnCtrlC:!1});return}let ae=!e.continue&&!N&&!E;(!g||ae)&&(console.error("Usage: entrydesk task -m <message> --model <model>"),console.error(" entrydesk task -m <message> -a <agent>"),console.error(" entrydesk task -c <number> -m <message>"),console.error(' echo "message" | entrydesk task --model <model>'),console.error(" entrydesk task -i (interactive mode)"),console.error(""),console.error("Options:"),console.error(" -m, --message Message to send (or pipe via stdin)"),console.error(" --model Model ID to use (required if no agent and no default)"),console.error(" -a, --agent Agent ID to use (required if no model)"),console.error(" -c, --continue Continue recent task by number (1 = most recent)"),console.error(" -i Interactive mode"),console.error(" --plain Plain text output (no colors/formatting)"),console.error(" --output stream-json Stream JSON events (for scripting)"),console.error(" --full-output Show full tool results without truncation"),console.error(" --dangerously-auto-approve-tools"),console.error(" Auto-approve all server-side tool calls (required for"),console.error(" non-interactive use with connectors/MCP tools)"),console.error(""),console.error("List available models: entrydesk models"),console.error("List available agents: entrydesk agents"),console.error("List recent tasks: entrydesk tasks"),process.exit(1));let l=e.fullOutput??!1,f=e.dangerouslyAutoApproveTools??!1,_=I||ho(),M=j?wt():void 0,b=j?kt():void 0,pe=A=>{let z={id:_,...f&&{toolApprovalMode:"always_allow"}};return A&&(z.message=A),E?z.agentId=E:(N&&(z.model=N),z.connectorIds=Z??[]),M&&(z.clientTools=M),b&&(z.clientToolSystemPrompt=b),z},te=async A=>{if(!A.body)throw new Error("No response body");let z=A.body.getReader(),Y=new TextDecoder,V="",W=new Map,ie=[],F=!1,v="";for(;;){let{done:O,value:S}=await z.read();if(O)break;V+=Y.decode(S,{stream:!0});let G=V.split(`
203
+ `);V=G.pop()||"";for(let p of G){let P=p.trimEnd();if(P==="data: [DONE]"){o&&Rt("done");continue}if(P.startsWith("data: "))try{let x=JSON.parse(P.slice(6));if((x.type==="text-delta"||x.type==="reasoning-delta"||x.type==="tool-call"||x.type==="tool-input-available"||x.type==="tool-result"||x.type==="data-appendMessage")&&(F=!0),x.type==="start"&&typeof x.messageId=="string"&&(v=x.messageId),o){x.type==="text-delta"&&x.delta!==void 0?Rt("text-delta",x.delta):x.type==="reasoning-delta"&&x.delta!==void 0?Rt("reasoning-delta",x.delta):Rt(x.type||"event",x);continue}if(i){if(x.type==="text-delta"&&x.delta&&process.stdout.write(x.delta),x.type==="data-appendMessage"&&process.stdout.write(wo(x)),j&&(x.type==="tool-input-available"||x.type==="tool-call")&&x.toolCallId&&x.toolName&&Oe(x.toolName)){let ue=x.args||x.input||{};ie.push({toolCallId:x.toolCallId,toolName:x.toolName,args:ue})}continue}switch(x.type){case"reasoning-delta":x.delta&&process.stdout.write(`${Ve}${x.delta}${xe}`);break;case"reasoning-end":process.stdout.write(`
204
+
205
+ `);break;case"text-delta":x.delta&&process.stdout.write(x.delta);break;case"data-appendMessage":process.stdout.write(wo(x));break;case"tool-call-streaming-start":case"tool-input-start":if(x.toolCallId&&x.toolName){W.set(x.toolCallId,{toolName:x.toolName});let R=j&&Oe(x.toolName)?`${Dt}[LOCAL]${xe} `:"";console.log(`
206
+ ${un}\u250C\u2500 ${R}Tool Call: ${x.toolName}${xe}`)}break;case"tool-call":case"tool-input-available":if(x.toolCallId&&x.toolName){let ue=x.args||x.input||{},R=bs(ue);console.log(`${Ft}\u2502 Arguments:${xe}`);for(let $e of R.split(`
207
+ `))console.log(`${Ve}\u2502 ${$e}${xe}`);j&&Oe(x.toolName)&&(W.set(x.toolCallId,{toolName:x.toolName,args:ue}),ie.push({toolCallId:x.toolCallId,toolName:x.toolName,args:ue}))}break;case"tool-result":if(x.toolCallId){let ue=W.get(x.toolCallId),R=xo(x.result,l);console.log(`${Dt}\u2502 Result:${xe}`);for(let $e of R.split(`
208
+ `))console.log(`${Ve}\u2502 ${$e}${xe}`);console.log(`${un}\u2514\u2500 ${ue?.toolName||"Tool"} completed${xe}
209
+ `),W.delete(x.toolCallId)}break;case"error":x.errorText&&console.error(`${Ve}Error: ${x.errorText}${xe}`);break}}catch{}}}return{pendingClientTools:ie,hadContent:F,messageId:v}},T=pe({id:ho(),createdAt:new Date,role:"user",parts:[{type:"text",text:g}]}),B=await m.task(t,n,T),oe=await te(B),se=oe.hadContent;for(;oe.pendingClientTools.length>0;){let A=oe.messageId,z=[];for(let V of oe.pendingClientTools){!i&&!o&&console.log(`${Dt}\u2502 Executing locally...${xe}`);let W=await Tt(V.toolName,V.args);if(z.push({type:`tool-${V.toolName}`,toolCallId:V.toolCallId,state:"output-available",output:{content:Ct(W),isError:!W.success}}),!i&&!o){let ie=xo(W.success?W.result:{error:W.error},l);console.log(`${Dt}\u2502 Result:${xe}`);for(let F of ie.split(`
210
+ `))console.log(`${Ve}\u2502 ${F}${xe}`);console.log(`${un}\u2514\u2500 ${V.toolName} completed${xe}
211
+ `)}}A||(console.error(`${Ft}Cannot continue: missing assistant message id for tool results.${xe}`),process.exit(1));let Y=pe({id:A,role:"assistant",parts:z});B=await m.task(t,n,Y),oe=await te(B),se=se||oe.hadContent}se||(console.error(`${Ft}No response received from the server (empty stream).${xe}`),console.error(`${Ve}The task may have failed server-side. Re-run with DEBUG=1 for details.${xe}`),process.exit(1)),o||console.log("")}export{Ui as printTaskHelp,ji as runTask};
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import{h as I,p as A,q as O,s as v}from"./chunk-UWTX2MZZ.js";import"./chunk-KURQCTT3.js";var h="\x1B[2m",c="\x1B[0m",p="\x1B[36m",N="\x1B[33m",R="\x1B[32m",j="stream-json";function f(t,n){let r=n===void 0?{event:t}:{event:t,data:n};process.stdout.write(`${JSON.stringify(r)}
3
- `)}function S(t){let n=new Date(t),e=new Date().getTime()-n.getTime(),o=Math.floor(e/(1e3*60*60*24));return o===0?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}):o===1?"Yesterday":o<7?`${o} days ago`:n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}var M="\x1B[1m";function J(t){return t.replace(/<mark>/g,M).replace(/<\/mark>/g,c).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function w(t,n){if(n)return t;let r=t.split(`
2
+ import{h as I,p as A,q as O,s as v}from"./chunk-DR3LDSMV.js";import"./chunk-KURQCTT3.js";var h="\x1B[2m",c="\x1B[0m",p="\x1B[36m",N="\x1B[33m",R="\x1B[32m",b="stream-json";function f(t,n){let r=n===void 0?{event:t}:{event:t,data:n};process.stdout.write(`${JSON.stringify(r)}
3
+ `)}function S(t){let n=new Date(t),e=new Date().getTime()-n.getTime(),o=Math.floor(e/(1e3*60*60*24));return o===0?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}):o===1?"Yesterday":o<7?`${o} days ago`:n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}var M="\x1B[1m";function j(t){return t.replace(/<mark>/g,M).replace(/<\/mark>/g,c).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function w(t,n){if(n)return t;let r=t.split(`
4
4
  `);if(r.length<=15)return t;let e=r.slice(0,6),o=r.slice(-4),i=r.length-10;return[...e,`... (${i} lines omitted, use --full-output to see all) ...`,...o].join(`
5
- `)}function x(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(x);let n={};for(let[r,e]of Object.entries(t))typeof e=="string"&&e.length>200?n[r]=e.slice(0,150)+"... (truncated)":typeof e=="object"&&e!==null?n[r]=x(e):n[r]=e;return n}function E(t){if(!t||typeof t!="object")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function L(t,n){if(!t)return"(no result)";if(typeof t!="object")return w(String(t),n);let r=n?t:x(t);if("structuredContent"in r&&r.structuredContent){let e=r.structuredContent,o=[];if(e.stdout&&typeof e.stdout=="string"&&e.stdout.trim()&&o.push(e.stdout.trim()),e.stderr&&typeof e.stderr=="string"&&e.stderr.trim()&&o.push(`${N}[stderr]${c} ${e.stderr.trim()}`),e.urls&&Array.isArray(e.urls)){let i=e.urls;for(let s of i)s.path&&s.url&&o.push(`${s.path}: ${s.url}`)}return o.length===0&&o.push(JSON.stringify(e,null,2)),w(o.join(`
5
+ `)}function x(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(x);let n={};for(let[r,e]of Object.entries(t))typeof e=="string"&&e.length>200?n[r]=e.slice(0,150)+"... (truncated)":typeof e=="object"&&e!==null?n[r]=x(e):n[r]=e;return n}function J(t){if(!t||typeof t!="object")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function E(t,n){if(!t)return"(no result)";if(typeof t!="object")return w(String(t),n);let r=n?t:x(t);if("structuredContent"in r&&r.structuredContent){let e=r.structuredContent,o=[];if(e.stdout&&typeof e.stdout=="string"&&e.stdout.trim()&&o.push(e.stdout.trim()),e.stderr&&typeof e.stderr=="string"&&e.stderr.trim()&&o.push(`${N}[stderr]${c} ${e.stderr.trim()}`),e.urls&&Array.isArray(e.urls)){let i=e.urls;for(let s of i)s.path&&s.url&&o.push(`${s.path}: ${s.url}`)}return o.length===0&&o.push(JSON.stringify(e,null,2)),w(o.join(`
6
6
  `),n)}if("content"in r&&Array.isArray(r.content)){let o=r.content.filter(i=>i.type==="text"&&i.text).map(i=>i.text).join(`
7
- `);return w(o||JSON.stringify(t,null,2),n)}return w(JSON.stringify(t,null,2),n)}function D(t){if(typeof t.title=="string")return t.title;if(typeof t.toolName=="string")return t.toolName;let n=t.type;return n.startsWith("tool-")?n.slice(5).replace(/__/g," ").replace(/_/g," "):n}function b(t,n){let r=[];for(let e of t)if(e.type==="reasoning"&&e.text)r.push(`${h}${e.text}${c}`);else if(e.type==="text"&&e.text)r.push(e.text);else if(e.type==="tool-call"&&e.toolName){let o=[`${p}\u250C\u2500 Tool Call: ${e.toolName}${c}`];if(e.args){o.push(`${N}\u2502 Arguments:${c}`);let i=E(e.args);for(let s of i.split(`
8
- `))o.push(`${h}\u2502 ${s}${c}`)}if(e.result!==void 0){o.push(`${R}\u2502 Result:${c}`);let i=L(e.result,n);for(let s of i.split(`
7
+ `);return w(o||JSON.stringify(t,null,2),n)}return w(JSON.stringify(t,null,2),n)}function D(t){if(typeof t.title=="string")return t.title;if(typeof t.toolName=="string")return t.toolName;let n=t.type;return n.startsWith("tool-")?n.slice(5).replace(/__/g," ").replace(/_/g," "):n}function L(t,n){let r=[];for(let e of t)if(e.type==="reasoning"&&e.text)r.push(`${h}${e.text}${c}`);else if(e.type==="text"&&e.text)r.push(e.text);else if(e.type==="tool-call"&&e.toolName){let o=[`${p}\u250C\u2500 Tool Call: ${e.toolName}${c}`];if(e.args){o.push(`${N}\u2502 Arguments:${c}`);let i=J(e.args);for(let s of i.split(`
8
+ `))o.push(`${h}\u2502 ${s}${c}`)}if(e.result!==void 0){o.push(`${R}\u2502 Result:${c}`);let i=E(e.result,n);for(let s of i.split(`
9
9
  `))o.push(`${h}\u2502 ${s}${c}`);o.push(`${p}\u2514\u2500 ${e.toolName} completed${c}`)}else e.state==="call"?o.push(`${p}\u2514\u2500 (awaiting result)${c}`):o.push(`${p}\u2514\u2500${c}`);r.push(o.join(`
10
- `))}else if(e.type.startsWith("tool-")&&e.type!=="tool-call"){let o=D(e),i=[`${p}\u250C\u2500 Tool: ${o}${c}`];if(e.input){i.push(`${N}\u2502 Input:${c}`);let s=E(e.input);for(let l of s.split(`
11
- `))i.push(`${h}\u2502 ${l}${c}`)}if(e.output!==void 0&&e.state==="output-available"){i.push(`${R}\u2502 Output:${c}`);let s=L(e.output,n);for(let l of s.split(`
10
+ `))}else if(e.type.startsWith("tool-")&&e.type!=="tool-call"){let o=D(e),i=[`${p}\u250C\u2500 Tool: ${o}${c}`];if(e.input){i.push(`${N}\u2502 Input:${c}`);let s=J(e.input);for(let l of s.split(`
11
+ `))i.push(`${h}\u2502 ${l}${c}`)}if(e.output!==void 0&&e.state==="output-available"){i.push(`${R}\u2502 Output:${c}`);let s=E(e.output,n);for(let l of s.split(`
12
12
  `))i.push(`${h}\u2502 ${l}${c}`);i.push(`${p}\u2514\u2500 completed${c}`)}else e.state==="call"||e.state==="partial-call"?i.push(`${p}\u2514\u2500 (in progress)${c}`):i.push(`${p}\u2514\u2500${c}`);r.push(i.join(`
13
13
  `))}return r.join(`
14
14
 
@@ -32,10 +32,10 @@ Examples:
32
32
  entrydesk tasks <taskId> # View a task's messages
33
33
  entrydesk tasks <taskId> --full-output # ...with full tool outputs
34
34
  entrydesk tasks -s <shareId> # View a shared task
35
- `)}async function V(t){if(t.help){U();return}let n=t.output===j;t.output&&!n&&(console.error(`Invalid --output value. Supported: ${j}`),process.exit(1));let r=new I;if(t.shareId){let s;try{s=await A()}catch{}try{let l=await r.getSharedTask(t.shareId,s),{messages:a}=await r.getSharedMessages(t.shareId,50,s);if(t.json){console.log(JSON.stringify({task:l,messages:a}));return}if(n){if(f("task",l),a.length===0)f("info","No messages in this shared task.");else for(let u of a.toReversed())f("message",u);f("done");return}if(console.log(`Shared Task: ${l.title||"Untitled"}`),console.log(`Visibility: ${l.visibility}`),l.agent&&console.log(`Agent: ${l.agent.name}`),console.log(`${a.length} messages
36
- `),a.length===0){console.log("No messages in this shared task.");return}let d=a.toReversed(),$=t.fullOutput??!1;for(let u of d){let y=b(u.parts,$);if(!y)continue;let T=u.role==="user"?"You":"Assistant";console.log(`[${T}] ${S(u.createdAt)}`),console.log(y),console.log("")}return}catch(l){if(l instanceof Error){let a=l.message.toLowerCase();a.includes("401")||a.includes("unauthorized")?console.error("Access denied. This shared task requires authentication or is not accessible to you."):a.includes("404")||a.includes("not found")?console.error("Shared task not found. The share ID may be invalid or the task was deleted."):console.error(`Failed to fetch shared task: ${l.message}`)}else console.error("Failed to fetch shared task");process.exit(1)}}let e,o;try{let s=await O();e=s.accessToken,o=s.workspaceId}catch(s){v(s)}if(t.taskId){let s=t.taskId,l=!1,a=null,d=parseInt(t.taskId,10);if(!isNaN(d)&&d>=0&&/^\d+$/.test(t.taskId)){let g=d===0?1:d,{tasks:k}=await r.getTasks(e,o,20);g>k.length&&(console.error(`Task number ${g} not found. You have ${k.length} recent tasks.`),process.exit(1));let m=k[g-1];s=m.id,l=!0,a=m,n||console.log(`Task: ${m.title||"Untitled"}
35
+ `)}async function V(t){if(t.help){U();return}let n=t.output===b;t.output&&!n&&(console.error(`Invalid --output value. Supported: ${b}`),process.exit(1));let r=new I;if(t.shareId){let s;try{s=await A()}catch{}try{let l=await r.getSharedTask(t.shareId,s),{messages:a}=await r.getSharedMessages(t.shareId,50,s);if(t.json){console.log(JSON.stringify({task:l,messages:a}));return}if(n){if(f("task",l),a.length===0)f("info","No messages in this shared task.");else for(let u of a.toReversed())f("message",u);f("done");return}if(console.log(`Shared Task: ${l.title||"Untitled"}`),console.log(`Visibility: ${l.visibility}`),l.agent&&console.log(`Agent: ${l.agent.name}`),console.log(`${a.length} messages
36
+ `),a.length===0){console.log("No messages in this shared task.");return}let d=a.toReversed(),$=t.fullOutput??!1;for(let u of d){let y=L(u.parts,$);if(!y)continue;let T=u.role==="user"?"You":"Assistant";console.log(`[${T}] ${S(u.createdAt)}`),console.log(y),console.log("")}return}catch(l){if(l instanceof Error){let a=l.message.toLowerCase();a.includes("401")||a.includes("unauthorized")?console.error("Access denied. This shared task requires authentication or is not accessible to you."):a.includes("404")||a.includes("not found")?console.error("Shared task not found. The share ID may be invalid or the task was deleted."):console.error(`Failed to fetch shared task: ${l.message}`)}else console.error("Failed to fetch shared task");process.exit(1)}}let e,o;try{let s=await O();e=s.accessToken,o=s.workspaceId}catch(s){v(s)}if(t.taskId){let s=t.taskId,l=!1,a=null,d=Number.parseInt(t.taskId,10);if(!Number.isNaN(d)&&d>=0&&/^\d+$/.test(t.taskId)){let g=d===0?1:d,{tasks:k}=await r.getTasks(e,o,20);g>k.length&&(console.error(`Task number ${g} not found. You have ${k.length} recent tasks.`),process.exit(1));let m=k[g-1];s=m.id,l=!0,a=m,n||console.log(`Task: ${m.title||"Untitled"}
37
37
  `)}let{messages:u}=await r.getMessages(e,o,s,50);if(t.json){console.log(JSON.stringify(u));return}if(n){if(a&&f("task",a),u.length===0)f("info","No messages in this task.");else for(let g of u.toReversed())f("message",g);f("done");return}if(u.length===0){console.log("No messages in this task.");return}let y=u.toReversed(),T=t.fullOutput??!1;l||console.log(`Task: ${t.taskId.slice(0,8)}...`),console.log(`${u.length} messages
38
- `);for(let g of y){let k=b(g.parts,T);if(!k)continue;let m=g.role==="user"?"You":"Assistant";console.log(`[${m}] ${S(g.createdAt)}`),console.log(k),console.log("")}return}if(t.search){let{results:s,nextKey:l}=await r.searchTasks(e,o,t.search,{limit:t.limit,nextKey:t.nextKey});if(n){for(let a of s)f("task",a);f("done");return}if(t.json){console.log(JSON.stringify({results:s,nextKey:l}));return}if(s.length===0){console.log(`No tasks match "${t.search}".`);return}console.log(`Search results for "${t.search}" (${s.length}):
39
- `),s.forEach((a,d)=>{let $=(d+1).toString().padStart(2," "),u=a.titleHighlight?J(a.titleHighlight):a.title||"Untitled";console.log(` ${$}. ${h}${S(a.createdAt)}${c} ${u}`),a.contentSnippet&&console.log(` ${J(a.contentSnippet)}`),console.log(` ${h}ID: ${a.id}${c}`)}),l&&console.log(`
38
+ `);for(let g of y){let k=L(g.parts,T);if(!k)continue;let m=g.role==="user"?"You":"Assistant";console.log(`[${m}] ${S(g.createdAt)}`),console.log(k),console.log("")}return}if(t.search){let{results:s,nextKey:l}=await r.searchTasks(e,o,t.search,{limit:t.limit,nextKey:t.nextKey});if(n){for(let a of s)f("task",a);f("done");return}if(t.json){console.log(JSON.stringify({results:s,nextKey:l}));return}if(s.length===0){console.log(`No tasks match "${t.search}".`);return}console.log(`Search results for "${t.search}" (${s.length}):
39
+ `),s.forEach((a,d)=>{let $=(d+1).toString().padStart(2," "),u=a.titleHighlight?j(a.titleHighlight):a.title||"Untitled";console.log(` ${$}. ${h}${S(a.createdAt)}${c} ${u}`),a.contentSnippet&&console.log(` ${j(a.contentSnippet)}`),console.log(` ${h}ID: ${a.id}${c}`)}),l&&console.log(`
40
40
  Next page: --next-key ${l}`);return}let{tasks:i}=await r.getTasks(e,o,20);if(n){for(let s of i)f("task",s);f("done");return}if(t.json){console.log(JSON.stringify(i));return}if(i.length===0){console.log("No tasks found.");return}console.log(`Recent Tasks (${i.length}):
41
- `),i.forEach((s,l)=>{let a=(l+1).toString().padStart(2," ");console.log(` ${a}. ${S(s.createdAt).padEnd(12)} ${s.title||"Untitled"}`)}),console.log(""),console.log("Use `entrydesk tasks 1` to view the most recent task"),console.log('Use `entrydesk task -c 1 -m "message"` to continue it')}export{U as printTasksHelp,J as renderHighlight,V as runTasks};
41
+ `),i.forEach((s,l)=>{let a=(l+1).toString().padStart(2," ");console.log(` ${a}. ${S(s.createdAt).padEnd(12)} ${s.title||"Untitled"}`)}),console.log(""),console.log("Use `entrydesk tasks 1` to view the most recent task"),console.log('Use `entrydesk task -c 1 -m "message"` to continue it')}export{U as printTasksHelp,j as renderHighlight,V as runTasks};