@entrydesk/cli 1.22.0 → 1.23.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.
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as u}from"./chunk-2QLV6WQA.js";import{a as f,t as p}from"./chunk-YKH2UWFC.js";import"./chunk-KURQCTT3.js";function d(s,c,k=!1){let n={},e={};for(let o=k?0:1;o<s.length;o++){let t=s[o];if(t==="--json")n.json=!0;else if(t==="--help"||t==="-h")n.help=!0;else if(t==="--profile")n.profile=s[++o];else switch(c){case"login":break;case"task":if(t==="-m"||t==="--message")e.message=s[++o];else if(t==="-a"||t==="--agent")e.agentId=s[++o];else if(t==="--model")e.model=s[++o];else if(t==="--connectors"){let i=s[++o];e.connectors=i?.split(",").map(r=>r.trim())}else t==="-i"||t==="--interactive"?e.interactive=!0:t==="--full-output"?e.fullOutput=!0:t==="-c"||t==="--continue"?e.continue=parseInt(s[++o],10):t==="--plain"?e.plain=!0:t==="--output"?e.output=s[++o]:t==="--file-system"?e.fileSystem=!0:t==="--no-file-system"?e.noFileSystem=!0:t==="--dangerously-auto-approve-tools"&&(e.dangerouslyAutoApproveTools=!0);break;case"agents":if(t==="--name")e.name=s[++o];else if(t==="--description")e.description=s[++o];else if(t==="--system-prompt")e.systemPrompt=s[++o];else if(t==="--model-id")e.modelId=s[++o];else if(t==="--connector-ids"){let i=s[++o];e.connectorIds=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--capabilities"){let i=s[++o];e.capabilities=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--conversation-starters"){let i=s[++o];e.conversationStarters=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--tools"){let i=s[++o];e.tools=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--icon-id")e.iconId=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else if(t==="--all")e.all=!0;else if(t==="--mine"||t==="--me")e.mine=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--role"){let i=s[++o];i==="owner"||i==="editor"||i==="viewer"?e.role=i:(console.error("--role must be one of: owner, editor, viewer"),process.exit(1))}else t.startsWith("-")||(e.action?e.agentId=t:e.action=t);break;case"meeting":if(t==="--filter"){let i=s[++o];i==="mine"||i==="shared"||i==="all"?e.filter=i:(console.error("--filter must be one of: mine, shared, all"),process.exit(1))}else if(t==="--search")e.search=s[++o];else if(t==="--sort"){let i=s[++o];i==="updated"||i==="updated_at"?e.sortBy="updated_at":i==="start"||i==="start_time"?e.sortBy="start_time":(console.error("--sort must be one of: updated, start"),process.exit(1))}else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else if(t==="--all")e.all=!0;else if(t==="--title")e.title=s[++o];else if(t==="--description")e.description=s[++o];else if(t==="--location")e.location=s[++o];else if(t==="--start")e.startTime=s[++o];else if(t==="--end")e.endTime=s[++o];else if(t==="--conference-link")e.conferenceLink=s[++o];else if(t==="--notes")e.notes=s[++o];else if(t==="--status"){let i=s[++o];i==="scheduled"||i==="in_progress"||i==="completed"||i==="cancelled"?e.status=i:(console.error("--status must be one of: scheduled, in_progress, completed, cancelled"),process.exit(1))}else if(t==="--visibility"){let i=s[++o];i==="private"||i==="workspace"?e.visibility=i:(console.error("--visibility must be one of: private, workspace"),process.exit(1))}else if(t==="--raw")e.raw=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--add-team")e.addTeam=s[++o];else if(t==="--remove-team")e.removeTeam=s[++o];else if(t==="--role"){let i=s[++o];i==="viewer"||i==="editor"?e.role=i:(console.error("--role must be one of: viewer, editor"),process.exit(1))}else t.startsWith("-")||(e.action?e.action==="transcript"?e.recordingId=t:e.meetingId=t:e.action=t);break;case"workflow":if(t==="--search")e.search=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else if(t==="--all")e.all=!0;else if(t==="--name")e.name=s[++o];else if(t==="--description")e.description=s[++o];else if(t==="--file")e.file=s[++o];else if(t==="--activate")e.activate=!0;else if(t==="--deactivate")e.deactivate=!0;else if(t==="--show-source")e.showSource=!0;else if(t==="--args")e.args=s[++o];else if(t==="--args-file")e.argsFile=s[++o];else if(t==="--wait")e.wait=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--role"){let i=s[++o];i==="owner"||i==="editor"||i==="viewer"?e.role=i:(console.error("--role must be one of: owner, editor, viewer"),process.exit(1))}else t.startsWith("-")||(e.action?e.workflowId?e.action==="run-get"&&!e.runId?e.runId=t:(console.error(`Unexpected positional argument: ${t}`),process.exit(1)):e.workflowId=t:e.action=t);break;case"notifications":if(t==="--tab"){let i=s[++o];i==="all"||i==="action"||i==="info"?e.tab=i:(console.error("--tab must be one of: all, action, info"),process.exit(1))}else if(t==="--event-type")e.eventType=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:t.startsWith("-")||(e.action?e.notificationId=t:e.action=t);break;case"recordings":if(t==="--title")e.title=s[++o];else if(t==="--model")e.modelId=s[++o];else if(t==="--language")e.language=s[++o];else if(t==="--yes"||t==="-y")e.yes=!0;else if(t==="--search"){let i=s[++o];i&&i.length>200&&(console.error("--search must be at most 200 characters"),process.exit(1)),e.search=i}else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t.startsWith("-")||(e.action?e.action==="import"||e.action==="preview"?e.url||(e.url=t):e.recordingId||(e.recordingId=t):e.action=t);break;case"connectors":if(t==="--token")e.token=s[++o];else if(t==="--yes"||t==="-y")e.yes=!0;else if(t==="--username")e.username=s[++o];else if(t==="--password")e.password=s[++o];else if(t==="--oauth")e.oauth=!0;else if(t==="--all")e.all=!0;else if(t==="--search"){let i=s[++o];i&&i.length>200&&(console.error("--search must be at most 200 characters"),process.exit(1)),e.search=i}else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t.startsWith("-")||(e.action?e.connectorId||(e.connectorId=t):e.action=t);break;case"marketplace":if(t==="--type"){let i=s[++o];u.includes(i)?e.type=i:(console.error(`--type must be one of: ${u.join(", ")}`),process.exit(1))}else if(t==="--tag")e.tag=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--cursor"){let i=s[++o];i||(console.error("--cursor requires a value"),process.exit(1)),e.cursor=i}else t.startsWith("-")||(e.action?e.action==="search"?e.tag||(e.tag=t):e.slug||(e.slug=t):e.action=t);break;case"skills":if(t==="--force")e.force=!0;else if(t==="--me"||t==="--mine")e.createdBy="me";else if(t==="--enable")e.enable=!0;else if(t==="--disable")e.disable=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--role"){let i=s[++o];i==="owner"||i==="editor"||i==="viewer"?e.role=i:(console.error("--role must be one of: owner, editor, viewer"),process.exit(1))}else if(t==="-g"||t==="--global")e.global=!0;else if(t==="--local")e.local=!0;else if(t==="--remote")e.remote=!0;else if(t==="--all")e.all=!0;else if(t==="-a"||t==="--agent"){let i=s[o+1];(!i||i.startsWith("-"))&&(console.error("--agent requires a value"),process.exit(1));let r=e.agents??[];r.push(s[++o]),e.agents=r}else t.startsWith("-")||(e.action?e.configKey=t:e.action=t);break;case"schedules":if(t==="--name")e.name=s[++o];else if(t==="--prompt")e.prompt=s[++o];else if(t==="--agent-id")e.agentId=s[++o];else if(t==="--starts-at")e.startsAt=s[++o];else if(t==="--utc-offset")e.utcOffset=s[++o];else if(t==="--repeat-type"){let i=s[++o];i==="no-repeat"||i==="minutes"||i==="hours"||i==="days"||i==="weeks"||i==="months"?e.repeatType=i:(console.error("--repeat-type must be one of: no-repeat, minutes, hours, days, weeks, months"),process.exit(1))}else if(t==="--every")e.every=parseInt(s[++o],10);else if(t==="--time")e.time=s[++o];else if(t==="--days-of-week"){let i=s[++o];e.daysOfWeek=i?.split(",").map(r=>parseInt(r.trim(),10)).filter(r=>!isNaN(r))}else if(t==="--days-of-month"){let i=s[++o];e.daysOfMonth=i?.split(",").map(r=>parseInt(r.trim(),10)).filter(r=>!isNaN(r))}else if(t==="--last-day-of-month")e.lastDayOfMonth=!0;else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:t.startsWith("-")||(e.action?e.scheduleId=t:e.action=t);break;case"config":!e.action&&!t.startsWith("-")?e.action=t:!e.configKey&&!t.startsWith("-")?e.configKey=t:!e.value&&!t.startsWith("-")&&(e.value=t);break;case"profile":!e.action&&!t.startsWith("-")?e.action=t:!e.name&&!t.startsWith("-")?e.name=t:!e.value&&!t.startsWith("-")&&(e.value=t);break;case"tasks":if(t==="--share"||t==="-s")e.shareId=s[++o];else if(t==="--full-output")e.fullOutput=!0;else if(t==="--output")e.output=s[++o];else if(t==="--search"||t==="-q")e.search=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>50)&&(console.error("--limit must be an integer between 1 and 50"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else!e.taskId&&!t.startsWith("-")&&(e.taskId=t);break;case"budget":!e.action&&!t.startsWith("-")?e.action=t:!e.configKey&&!t.startsWith("-")&&(e.configKey=t);break;case"usage":if(t==="--limit")e.limit=parseInt(s[++o],10);else if(t==="--sort-by"){let i=s[++o];(i==="cost"||i==="operations")&&(e.sortBy=i)}else t==="--offset"?e.offset=parseInt(s[++o],10):t==="--period-start"?e.periodStart=s[++o]:t==="-o"||t==="--output"?e.output=s[++o]:!e.action&&!t.startsWith("-")&&(e.action=t);break;case"billing":if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:!e.action&&!t.startsWith("-")&&(e.action=t);break;case"mcp-server":t==="--http"?e.http=!0:(t==="-p"||t==="--port")&&(e.port=parseInt(s[++o],10));break;case"tool":t==="-i"||t==="--input"?e.input=s[++o]:t==="-f"||t==="--input-file"?e.inputFile=s[++o]:t==="-p"||t==="--prefix"?e.prefix=s[++o]:t.startsWith("-")||(e.action?e.name||(e.name=t):e.action=t);break;case"workspaces":t.startsWith("-")||(e.action?e.configKey||(e.configKey=t):e.action=t);break;default:break}}switch(c){case"login":return{command:"login",...n,...e};case"logout":return{command:"logout",...n,...e};case"status":return{command:"status",...n,...e};case"workspaces":return{command:"workspaces",...n,...e};case"agents":return{command:"agents",...n,...e};case"meeting":return{command:"meeting",...n,...e};case"workflow":return{command:"workflow",...n,...e};case"notifications":return{command:"notifications",...n,...e};case"models":return{command:"models",...n,...e};case"marketplace":return{command:"marketplace",...n,...e};case"recordings":return{command:"recordings",...n,...e};case"connectors":return{command:"connectors",...n,...e};case"skills":return{command:"skills",...n,...e};case"schedules":return{command:"schedules",...n,...e};case"config":return{command:"config",...n,...e};case"profile":return{command:"profile",...n,...e};case"task":return{command:"task",...n,...e};case"tasks":return{command:"tasks",...n,...e};case"budget":return{command:"budget",...n,...e};case"usage":return{command:"usage",...n,...e};case"billing":return{command:"billing",...n,...e};case"mcp-server":return{command:"mcp-server",...n,...e};case"tool":return{command:"tool",...n,...e};case"version":return{command:"version",...n,...e};default:return{command:"help",...n,...e}}}var l=process.argv.slice(2);if(l[0]==="--help"||l[0]==="-h"){let{printHelp:s}=await import("./help-RTXIBJ6C.js");s(),process.exit(0)}if(l[0]==="--version"||l[0]==="-v"){let{printVersion:s}=await import("./version-64Y3MKJV.js");s(),process.exit(0)}var m=!l[0]||l[0].startsWith("-"),b=m?"task":l[0],a=d(l,b,m);m&&a.command==="task"&&(a.interactive=!0);if(!m&&a.help&&a.command!=="help"){let{COMMANDS_WITH_OWN_HELP:s,printCommandHelp:c}=await import("./help-RTXIBJ6C.js");s.has(a.command)||(c(a.command),process.exit(0))}async function h(){try{if(a.command!=="profile"){let s=a.profile||f.getCurrentProfileName();f.ensureProfileExists(s),f.setOverrideProfile(s)}switch(a.command){case"login":{let{runLogin:s}=await import("./login-O77HDVW3.js");await s(a);break}case"logout":{let{runLogout:s}=await import("./logout-A7CYWGTM.js");await s(a);break}case"status":{let{runStatus:s}=await import("./status-XMD5WLMC.js");await s(a);break}case"workspaces":{let{runWorkspaces:s}=await import("./workspaces-65YARQ7K.js");await s(a);break}case"agents":{let{runAgents:s}=await import("./agents-JCLIHY4P.js");await s(a);break}case"meeting":{let{runMeeting:s}=await import("./meeting-QNPGY54E.js");await s(a);break}case"recordings":{let{runRecordings:s}=await import("./recordings-EIAQWZ6J.js");await s(a);break}case"workflow":{let{runWorkflow:s}=await import("./workflow-LUR7AL3C.js");await s(a);break}case"notifications":{let{runNotifications:s}=await import("./notifications-ZE4MQURK.js");await s(a);break}case"models":{let{runModels:s}=await import("./models-BQT6MNN3.js");await s(a);break}case"marketplace":{let{runMarketplace:s}=await import("./marketplace-CAXL5PH4.js");await s(a);break}case"connectors":{let{runConnectors:s}=await import("./connectors-NKSDT2HG.js");await s(a);break}case"skills":{let{runSkills:s}=await import("./skills-INLQDLRZ.js");await s(a);break}case"schedules":{let{runSchedules:s}=await import("./schedules-LWXLUKOS.js");await s(a);break}case"tasks":{let{runTasks:s}=await import("./tasks-7T7RUCWK.js");await s(a);break}case"budget":{let{runBudget:s}=await import("./budget-VDIBB2G7.js");await s(a);break}case"usage":{let{runUsage:s}=await import("./usage-4F4AGUYD.js");await s(a);break}case"billing":{let{runBilling:s}=await import("./billing-QKAGGKLE.js");await s(a);break}case"config":{if(a.action==="help"||l[1]==="--help"){let{renderConfigHelp:s}=await import("./config-help-MDC62DDX.js");s()}else{let{runConfig:s}=await import("./config-EHPADRGK.js");await s(a)}break}case"profile":{let{runProfile:s}=await import("./profile-PQUC4VYR.js");await s(a);break}case"task":{if(a.help){let{printTaskHelp:s}=await import("./task-EEOFXNBH.js");s()}else{let{runTask:s}=await import("./task-EEOFXNBH.js");await s(a)}break}case"mcp-server":{let{startMcpServer:s}=await import("./mcp-D7GHEFAP.js");await s({mode:a.http?"http":"stdio",port:a.port});break}case"tool":{let{runTool:s}=await import("./tool-J25QCBER.js");await s(a);break}case"version":{let{printVersion:s}=await import("./version-64Y3MKJV.js");s();break}default:{let{printHelp:s}=await import("./help-RTXIBJ6C.js");s();break}}}catch(s){p(s)}}h();
|
|
2
|
+
import{b as u}from"./chunk-2QLV6WQA.js";import{a as f,t as p}from"./chunk-YKH2UWFC.js";import"./chunk-KURQCTT3.js";function d(s,c,k=!1){let n={},e={};for(let o=k?0:1;o<s.length;o++){let t=s[o];if(t==="--json")n.json=!0;else if(t==="--help"||t==="-h")n.help=!0;else if(t==="--profile")n.profile=s[++o];else switch(c){case"login":break;case"task":if(t==="-m"||t==="--message")e.message=s[++o];else if(t==="-a"||t==="--agent")e.agentId=s[++o];else if(t==="--model")e.model=s[++o];else if(t==="--connectors"){let i=s[++o];e.connectors=i?.split(",").map(r=>r.trim())}else t==="-i"||t==="--interactive"?e.interactive=!0:t==="--full-output"?e.fullOutput=!0:t==="-c"||t==="--continue"?e.continue=parseInt(s[++o],10):t==="--plain"?e.plain=!0:t==="--output"?e.output=s[++o]:t==="--file-system"?e.fileSystem=!0:t==="--no-file-system"?e.noFileSystem=!0:t==="--dangerously-auto-approve-tools"&&(e.dangerouslyAutoApproveTools=!0);break;case"agents":if(t==="--name")e.name=s[++o];else if(t==="--description")e.description=s[++o];else if(t==="--system-prompt")e.systemPrompt=s[++o];else if(t==="--model-id")e.modelId=s[++o];else if(t==="--connector-ids"){let i=s[++o];e.connectorIds=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--capabilities"){let i=s[++o];e.capabilities=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--conversation-starters"){let i=s[++o];e.conversationStarters=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--tools"){let i=s[++o];e.tools=i?.split(",").map(r=>r.trim()).filter(Boolean)}else if(t==="--icon-id")e.iconId=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else if(t==="--all")e.all=!0;else if(t==="--mine"||t==="--me")e.mine=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--role"){let i=s[++o];i==="owner"||i==="editor"||i==="viewer"?e.role=i:(console.error("--role must be one of: owner, editor, viewer"),process.exit(1))}else t.startsWith("-")||(e.action?e.agentId=t:e.action=t);break;case"meeting":if(t==="--filter"){let i=s[++o];i==="mine"||i==="shared"||i==="all"?e.filter=i:(console.error("--filter must be one of: mine, shared, all"),process.exit(1))}else if(t==="--search")e.search=s[++o];else if(t==="--sort"){let i=s[++o];i==="updated"||i==="updated_at"?e.sortBy="updated_at":i==="start"||i==="start_time"?e.sortBy="start_time":(console.error("--sort must be one of: updated, start"),process.exit(1))}else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else if(t==="--all")e.all=!0;else if(t==="--title")e.title=s[++o];else if(t==="--description")e.description=s[++o];else if(t==="--location")e.location=s[++o];else if(t==="--start")e.startTime=s[++o];else if(t==="--end")e.endTime=s[++o];else if(t==="--conference-link")e.conferenceLink=s[++o];else if(t==="--notes")e.notes=s[++o];else if(t==="--status"){let i=s[++o];i==="scheduled"||i==="in_progress"||i==="completed"||i==="cancelled"?e.status=i:(console.error("--status must be one of: scheduled, in_progress, completed, cancelled"),process.exit(1))}else if(t==="--visibility"){let i=s[++o];i==="private"||i==="workspace"?e.visibility=i:(console.error("--visibility must be one of: private, workspace"),process.exit(1))}else if(t==="--raw")e.raw=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--add-team")e.addTeam=s[++o];else if(t==="--remove-team")e.removeTeam=s[++o];else if(t==="--role"){let i=s[++o];i==="viewer"||i==="editor"?e.role=i:(console.error("--role must be one of: viewer, editor"),process.exit(1))}else t.startsWith("-")||(e.action?e.action==="transcript"?e.recordingId=t:e.meetingId=t:e.action=t);break;case"workflow":if(t==="--search")e.search=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else if(t==="--all")e.all=!0;else if(t==="--name")e.name=s[++o];else if(t==="--description")e.description=s[++o];else if(t==="--file")e.file=s[++o];else if(t==="--activate")e.activate=!0;else if(t==="--deactivate")e.deactivate=!0;else if(t==="--show-source")e.showSource=!0;else if(t==="--args")e.args=s[++o];else if(t==="--args-file")e.argsFile=s[++o];else if(t==="--wait")e.wait=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--role"){let i=s[++o];i==="owner"||i==="editor"||i==="viewer"?e.role=i:(console.error("--role must be one of: owner, editor, viewer"),process.exit(1))}else t.startsWith("-")||(e.action?e.workflowId?e.action==="run-get"&&!e.runId?e.runId=t:(console.error(`Unexpected positional argument: ${t}`),process.exit(1)):e.workflowId=t:e.action=t);break;case"notifications":if(t==="--tab"){let i=s[++o];i==="all"||i==="action"||i==="info"?e.tab=i:(console.error("--tab must be one of: all, action, info"),process.exit(1))}else if(t==="--event-type")e.eventType=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:t.startsWith("-")||(e.action?e.notificationId=t:e.action=t);break;case"recordings":if(t==="--title")e.title=s[++o];else if(t==="--model")e.modelId=s[++o];else if(t==="--language")e.language=s[++o];else if(t==="--yes"||t==="-y")e.yes=!0;else if(t==="--search"){let i=s[++o];i&&i.length>200&&(console.error("--search must be at most 200 characters"),process.exit(1)),e.search=i}else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t.startsWith("-")||(e.action?e.action==="import"||e.action==="preview"?e.url||(e.url=t):e.recordingId||(e.recordingId=t):e.action=t);break;case"connectors":if(t==="--token")e.token=s[++o];else if(t==="--yes"||t==="-y")e.yes=!0;else if(t==="--username")e.username=s[++o];else if(t==="--password")e.password=s[++o];else if(t==="--oauth")e.oauth=!0;else if(t==="--all")e.all=!0;else if(t==="--search"){let i=s[++o];i&&i.length>200&&(console.error("--search must be at most 200 characters"),process.exit(1)),e.search=i}else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t.startsWith("-")||(e.action?e.connectorId||(e.connectorId=t):e.action=t);break;case"marketplace":if(t==="--type"){let i=s[++o];u.includes(i)?e.type=i:(console.error(`--type must be one of: ${u.join(", ")}`),process.exit(1))}else if(t==="--tag")e.tag=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--cursor"){let i=s[++o];i||(console.error("--cursor requires a value"),process.exit(1)),e.cursor=i}else t.startsWith("-")||(e.action?e.action==="search"?e.tag||(e.tag=t):e.slug||(e.slug=t):e.action=t);break;case"skills":if(t==="--force")e.force=!0;else if(t==="--me"||t==="--mine")e.createdBy="me";else if(t==="--enable")e.enable=!0;else if(t==="--disable")e.disable=!0;else if(t==="--add-user")e.addUser=s[++o];else if(t==="--remove-user")e.removeUser=s[++o];else if(t==="--role"){let i=s[++o];i==="owner"||i==="editor"||i==="viewer"?e.role=i:(console.error("--role must be one of: owner, editor, viewer"),process.exit(1))}else if(t==="-g"||t==="--global")e.global=!0;else if(t==="--local")e.local=!0;else if(t==="--remote")e.remote=!0;else if(t==="--all")e.all=!0;else if(t==="-a"||t==="--agent"){let i=s[o+1];(!i||i.startsWith("-"))&&(console.error("--agent requires a value"),process.exit(1));let r=e.agents??[];r.push(s[++o]),e.agents=r}else t.startsWith("-")||(e.action?e.configKey=t:e.action=t);break;case"schedules":if(t==="--name")e.name=s[++o];else if(t==="--prompt")e.prompt=s[++o];else if(t==="--agent-id")e.agentId=s[++o];else if(t==="--starts-at")e.startsAt=s[++o];else if(t==="--utc-offset")e.utcOffset=s[++o];else if(t==="--repeat-type"){let i=s[++o];i==="no-repeat"||i==="minutes"||i==="hours"||i==="days"||i==="weeks"||i==="months"?e.repeatType=i:(console.error("--repeat-type must be one of: no-repeat, minutes, hours, days, weeks, months"),process.exit(1))}else if(t==="--every")e.every=parseInt(s[++o],10);else if(t==="--time")e.time=s[++o];else if(t==="--days-of-week"){let i=s[++o];e.daysOfWeek=i?.split(",").map(r=>parseInt(r.trim(),10)).filter(r=>!isNaN(r))}else if(t==="--days-of-month"){let i=s[++o];e.daysOfMonth=i?.split(",").map(r=>parseInt(r.trim(),10)).filter(r=>!isNaN(r))}else if(t==="--last-day-of-month")e.lastDayOfMonth=!0;else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:t.startsWith("-")||(e.action?e.scheduleId=t:e.action=t);break;case"config":!e.action&&!t.startsWith("-")?e.action=t:!e.configKey&&!t.startsWith("-")?e.configKey=t:!e.value&&!t.startsWith("-")&&(e.value=t);break;case"profile":!e.action&&!t.startsWith("-")?e.action=t:!e.name&&!t.startsWith("-")?e.name=t:!e.value&&!t.startsWith("-")&&(e.value=t);break;case"tasks":if(t==="--share"||t==="-s")e.shareId=s[++o];else if(t==="--full-output")e.fullOutput=!0;else if(t==="--output")e.output=s[++o];else if(t==="--search"||t==="-q")e.search=s[++o];else if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>50)&&(console.error("--limit must be an integer between 1 and 50"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else!e.taskId&&!t.startsWith("-")&&(e.taskId=t);break;case"budget":!e.action&&!t.startsWith("-")?e.action=t:!e.configKey&&!t.startsWith("-")&&(e.configKey=t);break;case"usage":if(t==="--limit")e.limit=parseInt(s[++o],10);else if(t==="--sort-by"){let i=s[++o];(i==="cost"||i==="operations")&&(e.sortBy=i)}else t==="--offset"?e.offset=parseInt(s[++o],10):t==="--period-start"?e.periodStart=s[++o]:t==="-o"||t==="--output"?e.output=s[++o]:!e.action&&!t.startsWith("-")&&(e.action=t);break;case"billing":if(t==="--limit"){let i=parseInt(s[++o],10);(isNaN(i)||i<1||i>100)&&(console.error("--limit must be an integer between 1 and 100"),process.exit(1)),e.limit=i}else if(t==="--next-key"){let i=s[++o];i||(console.error("--next-key requires a value"),process.exit(1)),e.nextKey=i}else t==="--all"?e.all=!0:!e.action&&!t.startsWith("-")&&(e.action=t);break;case"mcp-server":t==="--http"?e.http=!0:(t==="-p"||t==="--port")&&(e.port=parseInt(s[++o],10));break;case"tool":t==="-i"||t==="--input"?e.input=s[++o]:t==="-f"||t==="--input-file"?e.inputFile=s[++o]:t==="-p"||t==="--prefix"?e.prefix=s[++o]:t.startsWith("-")||(e.action?e.name||(e.name=t):e.action=t);break;case"workspaces":t.startsWith("-")||(e.action?e.configKey||(e.configKey=t):e.action=t);break;default:break}}switch(c){case"login":return{command:"login",...n,...e};case"logout":return{command:"logout",...n,...e};case"status":return{command:"status",...n,...e};case"workspaces":return{command:"workspaces",...n,...e};case"agents":return{command:"agents",...n,...e};case"meeting":return{command:"meeting",...n,...e};case"workflow":return{command:"workflow",...n,...e};case"notifications":return{command:"notifications",...n,...e};case"models":return{command:"models",...n,...e};case"marketplace":return{command:"marketplace",...n,...e};case"recordings":return{command:"recordings",...n,...e};case"connectors":return{command:"connectors",...n,...e};case"skills":return{command:"skills",...n,...e};case"schedules":return{command:"schedules",...n,...e};case"config":return{command:"config",...n,...e};case"profile":return{command:"profile",...n,...e};case"task":return{command:"task",...n,...e};case"tasks":return{command:"tasks",...n,...e};case"budget":return{command:"budget",...n,...e};case"usage":return{command:"usage",...n,...e};case"billing":return{command:"billing",...n,...e};case"mcp-server":return{command:"mcp-server",...n,...e};case"tool":return{command:"tool",...n,...e};case"version":return{command:"version",...n,...e};default:return{command:"help",...n,...e}}}var l=process.argv.slice(2);if(l[0]==="--help"||l[0]==="-h"){let{printHelp:s}=await import("./help-RTXIBJ6C.js");s(),process.exit(0)}if(l[0]==="--version"||l[0]==="-v"){let{printVersion:s}=await import("./version-NNRXNHNM.js");s(),process.exit(0)}var m=!l[0]||l[0].startsWith("-"),b=m?"task":l[0],a=d(l,b,m);m&&a.command==="task"&&(a.interactive=!0);if(!m&&a.help&&a.command!=="help"){let{COMMANDS_WITH_OWN_HELP:s,printCommandHelp:c}=await import("./help-RTXIBJ6C.js");s.has(a.command)||(c(a.command),process.exit(0))}async function h(){try{if(a.command!=="profile"){let s=a.profile||f.getCurrentProfileName();f.ensureProfileExists(s),f.setOverrideProfile(s)}switch(a.command){case"login":{let{runLogin:s}=await import("./login-O77HDVW3.js");await s(a);break}case"logout":{let{runLogout:s}=await import("./logout-A7CYWGTM.js");await s(a);break}case"status":{let{runStatus:s}=await import("./status-XMD5WLMC.js");await s(a);break}case"workspaces":{let{runWorkspaces:s}=await import("./workspaces-65YARQ7K.js");await s(a);break}case"agents":{let{runAgents:s}=await import("./agents-JCLIHY4P.js");await s(a);break}case"meeting":{let{runMeeting:s}=await import("./meeting-QNPGY54E.js");await s(a);break}case"recordings":{let{runRecordings:s}=await import("./recordings-EIAQWZ6J.js");await s(a);break}case"workflow":{let{runWorkflow:s}=await import("./workflow-LUR7AL3C.js");await s(a);break}case"notifications":{let{runNotifications:s}=await import("./notifications-ZE4MQURK.js");await s(a);break}case"models":{let{runModels:s}=await import("./models-BQT6MNN3.js");await s(a);break}case"marketplace":{let{runMarketplace:s}=await import("./marketplace-CAXL5PH4.js");await s(a);break}case"connectors":{let{runConnectors:s}=await import("./connectors-NKSDT2HG.js");await s(a);break}case"skills":{let{runSkills:s}=await import("./skills-INLQDLRZ.js");await s(a);break}case"schedules":{let{runSchedules:s}=await import("./schedules-LWXLUKOS.js");await s(a);break}case"tasks":{let{runTasks:s}=await import("./tasks-7T7RUCWK.js");await s(a);break}case"budget":{let{runBudget:s}=await import("./budget-VDIBB2G7.js");await s(a);break}case"usage":{let{runUsage:s}=await import("./usage-4F4AGUYD.js");await s(a);break}case"billing":{let{runBilling:s}=await import("./billing-QKAGGKLE.js");await s(a);break}case"config":{if(a.action==="help"||l[1]==="--help"){let{renderConfigHelp:s}=await import("./config-help-MDC62DDX.js");s()}else{let{runConfig:s}=await import("./config-EHPADRGK.js");await s(a)}break}case"profile":{let{runProfile:s}=await import("./profile-PQUC4VYR.js");await s(a);break}case"task":{if(a.help){let{printTaskHelp:s}=await import("./task-6B73YL3H.js");s()}else{let{runTask:s}=await import("./task-6B73YL3H.js");await s(a)}break}case"mcp-server":{let{startMcpServer:s}=await import("./mcp-D7GHEFAP.js");await s({mode:a.http?"http":"stdio",port:a.port});break}case"tool":{let{runTool:s}=await import("./tool-J25QCBER.js");await s(a);break}case"version":{let{printVersion:s}=await import("./version-NNRXNHNM.js");s();break}default:{let{printHelp:s}=await import("./help-RTXIBJ6C.js");s();break}}}catch(s){p(s)}}h();
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as le,b as fe,c as jt,g as it,h as me,n as Je,q as dn,r as We,t as fn}from"./chunk-YKH2UWFC.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
|
+
|
|
4
|
+
You have access to filesystem tools that allow you to interact with the user's local filesystem.
|
|
5
|
+
|
|
6
|
+
### Available Operations
|
|
7
|
+
|
|
8
|
+
- **Read File**: Read the contents of a file. Image files (PNG, JPEG, GIF, WebP) are returned as viewable images you can analyze directly \u2014 no need to upload them.
|
|
9
|
+
- **Read Multiple Files**: Read multiple files at once (max 10). Images among them are returned as viewable images.
|
|
10
|
+
- **Write File**: Create or overwrite a file
|
|
11
|
+
- **Create Directory**: Create a new directory (including parent directories)
|
|
12
|
+
- **List Directory**: List files and subdirectories
|
|
13
|
+
- **Search Files**: Search for files matching a glob pattern
|
|
14
|
+
- **Get File Info**: Get metadata about a file or directory
|
|
15
|
+
- **Move File**: Move or rename a file or directory
|
|
16
|
+
- **Execute Command**: Run shell commands on the user's machine
|
|
17
|
+
|
|
18
|
+
### Important Notes
|
|
19
|
+
|
|
20
|
+
- Always use absolute paths when possible
|
|
21
|
+
- Be mindful of file permissions and access restrictions
|
|
22
|
+
- Large files will be truncated in responses
|
|
23
|
+
- Search results are limited to prevent overwhelming responses
|
|
24
|
+
- Execute Command has a default timeout of 30 seconds (max 5 minutes)
|
|
25
|
+
- The current working directory is: ${process.cwd()}
|
|
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 xt(e,t=1e5){return e.length<=t?e:e.slice(0,t)+`
|
|
28
|
+
|
|
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
|
+
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
|
+
The path does not exist.`;case"ENOTDIR":return`${n}
|
|
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 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
|
+
|
|
36
|
+
`)}function Be(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 Array.from(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
|
+
`){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(C.length),I.current=null):y(l=>It(l,C.length)),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
|
+
`,...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,O=Math.max(0,_-1),oe=Math.min(T,N[O]??0);y((E[O]??0)+oe),I.current=T;return}if(g&&te&&f.downArrow){let T=I.current??M,O=Math.min(k.length-1,_+1),oe=Math.min(T,N[O]??0);y((E[O]??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,O=[...C.slice(0,T),...C.slice(m)].join("");j(O,T)}return}if(l==="k"){if(M<pe){let T=(E[_]??0)+pe,O=[...C.slice(0,m),...C.slice(T)].join("");j(O,m)}return}if(l==="w"){if(M===0&&_>0){let O=[...C.slice(0,m-1),...C.slice(m)].join("");j(O,m-1);return}let T=Yt(b,M);if(T!==M){let O=(E[_]??0)+T,oe=[...C.slice(0,O),...C.slice(m)].join("");j(oe,O)}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
|
+
`).replace(/\r/g,`
|
|
40
|
+
`):l.replace(/\r?\n/g,"");if(!T||(T=T.replace(/^\x1b?\[200~/,"").replace(/\x1b?\[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(""),O=b[te]??" ",oe=b.slice(te+1).join(""),z=`${T}\x1B[7m${O}\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 On}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=On(Ie,{color:i,children:[Q,On(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,Oo=1,Bo=1,Uo=({content:e})=>{let t=e.join(`
|
|
42
|
+
`);return ce(Le,{paddingLeft:jn,flexDirection:"column",children:ce(Ge,{color:"yellow",children:t})})},Bn=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+Oo,flexDirection:"row",children:[ce(Le,{width:a,children:ce(Ge,{children:i})}),ce(Le,{flexGrow:Bo,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(Bn,{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(Bn,{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
|
+
set imageData to the clipboard as "PNGf"
|
|
44
|
+
set fileRef to open for access POSIX file "${e}" with write permission
|
|
45
|
+
set eof fileRef to 0
|
|
46
|
+
write imageData to fileRef
|
|
47
|
+
close access fileRef
|
|
48
|
+
`;return await St("osascript",["-e",t]),(await tt.stat(e)).size===0?void 0:{buffer:await tt.readFile(e),mime:"image/png"}}catch{return}finally{try{Ho.existsSync(e)&&await tt.unlink(e)}catch{}}}async function zo(){try{let e=`
|
|
49
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
50
|
+
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
51
|
+
if ($img) {
|
|
52
|
+
$ms = New-Object System.IO.MemoryStream
|
|
53
|
+
$img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
54
|
+
[System.Convert]::ToBase64String($ms.ToArray())
|
|
55
|
+
}
|
|
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
|
+
`);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=[];if(i.push(`${he}\u250C\u2500 Tool: ${o.toolName}${X}`),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(`
|
|
59
|
+
`))}else if(o.type.startsWith("tool-")&&o.type!=="tool-call"){let i=o.title||o.type.slice(5).replace(/__/g," "),a=[];if(a.push(`${he}\u250C\u2500 Tool: ${i}${X}`),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
|
+
`))}return n.join(`
|
|
61
|
+
|
|
62
|
+
`).trim()}var Et=class{pendingToolCalls=new Map;hasPending(){return this.pendingToolCalls.size>0}hasExecuting(){for(let t of this.pendingToolCalls.values())if(t.status==="executing")return!0;return!1}clear(t){this.pendingToolCalls.delete(t)}buildToolDisplay(){if(this.pendingToolCalls.size===0)return"";let t=[];for(let[,n]of this.pendingToolCalls){let o=n.toolName.replace(/__/g," "),i=`
|
|
63
|
+
|
|
64
|
+
${he}\u250C\u2500 Tool: ${o}${X}`;if(n.args){let a=n.args.length>100?n.args.slice(0,100)+"...":n.args;i+=`
|
|
65
|
+
${ve}\u2502 Input: ${a}${X}`}if(n.output){let a=n.output.length>150?n.output.slice(0,150)+"...":n.output;i+=`
|
|
66
|
+
${nt}\u2502 Output: ${a}${X}`}else if(n.status==="executing"){let a=n.startedAt??Date.now(),g=Math.floor((Date.now()-a)/1e3);i+=`
|
|
67
|
+
${he}\u2502${X} (executing... ${g}s)`}else n.status==="preparing"&&(i+=`
|
|
68
|
+
${he}\u2502${X} (preparing...)`);t.push(i)}return t.join("")}flushPending(t){if(this.pendingToolCalls.size===0)return t;for(let[n,o]of this.pendingToolCalls){let i=o.toolName.replace(/__/g," "),a=typeof o.args=="string"&&o.args.length>100?o.args.slice(0,100)+"...":o.args||"";t+=`
|
|
69
|
+
|
|
70
|
+
${he}\u250C\u2500 Tool: ${i}${X}`,a&&(t+=`
|
|
71
|
+
${ve}\u2502 Input: ${a}${X}`),t+=`
|
|
72
|
+
${he}\u2514\u2500 completed${X}
|
|
73
|
+
`,this.pendingToolCalls.delete(n)}return t}handleToolInputStart(t){return t.toolCallId&&t.toolName?(this.pendingToolCalls.set(t.toolCallId,{toolName:t.toolName,args:"",status:"preparing"}),this.buildToolDisplay()):null}handleToolInputDelta(t){if(t.toolCallId&&t.inputTextDelta){let n=this.pendingToolCalls.get(t.toolCallId);if(n)return n.args=(n.args||"")+t.inputTextDelta,n.status="executing",n.startedAt??=Date.now(),this.buildToolDisplay()}return null}handleToolOutputStart(t){if(t.toolCallId){let n=this.pendingToolCalls.get(t.toolCallId);if(n)return n.output="",n.status="output",this.buildToolDisplay()}return null}handleToolOutputDelta(t){if(t.toolCallId&&t.outputTextDelta){let n=this.pendingToolCalls.get(t.toolCallId);if(n)return n.output=(n.output||"")+t.outputTextDelta,this.buildToolDisplay()}return null}handleToolOutputEnd(t,n){if(!t.toolCallId)return null;let o=this.pendingToolCalls.get(t.toolCallId);if(!o)return null;let i=o.toolName.replace(/__/g," "),a=typeof o.args=="string"&&o.args.length>100?o.args.slice(0,100)+"...":o.args||"",g=(o.output||"").length>200?(o.output||"").slice(0,200)+"...":o.output||"";return n+=`
|
|
74
|
+
|
|
75
|
+
${he}\u250C\u2500 Tool: ${i}${X}`,a&&(n+=`
|
|
76
|
+
${ve}\u2502 Input: ${a}${X}`),n+=`
|
|
77
|
+
${nt}\u2502 Output: ${g}${X}`,n+=`
|
|
78
|
+
${he}\u2514\u2500 completed${X}
|
|
79
|
+
`,this.pendingToolCalls.delete(t.toolCallId),{fullResponse:n,toolDisplay:this.buildToolDisplay()}}handleToolError(t,n){if(!t.toolCallId)return null;let i=(this.pendingToolCalls.get(t.toolCallId)?.toolName||t.toolName||"Tool").replace(/__/g," "),a=t.errorText||"Unknown error",g=a.length>200?a.slice(0,200)+"...":a;return n+=`
|
|
80
|
+
|
|
81
|
+
${he}\u250C\u2500 Tool: ${i}${X}`,n+=`
|
|
82
|
+
${zn}\u2502 Error: ${g}${X}`,n+=`
|
|
83
|
+
${he}\u2514\u2500 failed${X}
|
|
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
|
+
DATA: ${JSON.stringify(t,null,2)}`),o+=`
|
|
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?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="",O="",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:B}=await ae.read();if(v)break;te+=pe.decode(B,{stream:!0});let S=te.split(`
|
|
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",O="";break;case"reasoning-delta":p.delta&&(O+=p.delta,h(`${ve}[Thinking...]${X}
|
|
89
|
+
${O}`)),p.providerMetadata?.anthropic?.signature&&(se=p.providerMetadata.anthropic.signature);break;case"reasoning-end":if(O){let P={type:"reasoning",id:oe,text:O,state:"done"};se&&(P.providerMetadata={anthropic:{signature:se}}),W.push(P),ne("Added reasoning to messageParts",{reasoningLength:O.length,hasSignature:!!se,messagePartsCount:W.length})}O="",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?Be(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&&Be(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?Be(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"),B=v===-1?W.length:v;W.splice(B,0,{type:"text",text:A}),ne("Added accumulated text to messageParts",{textLength:A.length,insertIndex:B})}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 B=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:B}};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="",O="",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",O="";break;case"reasoning-delta":R.delta&&(O+=R.delta,h(`${ve}[Thinking...]${X}
|
|
93
|
+
${O}`)),R.providerMetadata?.anthropic?.signature&&(se=R.providerMetadata.anthropic.signature);break;case"reasoning-end":if(O){let $e={type:"reasoning",id:oe,text:O,state:"done"};se&&($e.providerMetadata={anthropic:{signature:se}}),W.push($e),ne("Continuation: Added reasoning to messageParts",{reasoningLength:O.length,hasSignature:!!se,messagePartsCount:W.length})}O="",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&&Be(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 B=Ke(v,g);ne("=== Using formatted parts for local tools ===",{executedToolsCount:ie.length,textPartsCount:W.filter(S=>S.type==="text").length,contentLength:B.length}),m(S=>[...S,{role:"assistant",content:B,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 B=v.find(S=>S.role==="assistant");if(B){let S=B.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(B=>[...B,{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
|
+
/help, /h, /? Show this help message
|
|
95
|
+
/clear, /cls, /new Start a new task
|
|
96
|
+
/model [name], /m Show current model or switch to [name]
|
|
97
|
+
/agent [name], /a Show current agent or switch to [name]
|
|
98
|
+
/skills [name], /sk List skills or show details for [name]
|
|
99
|
+
/schedules [id], /sch List schedules or show details for [id]
|
|
100
|
+
/connectors, /conn Select active connectors
|
|
101
|
+
/capabilities, /cap Toggle client capabilities (FileSystem)
|
|
102
|
+
/tasks, /c Switch to another task
|
|
103
|
+
/workspace [id], /ws List or switch workspace
|
|
104
|
+
/budget [amount], /bg View or set workspace budget
|
|
105
|
+
/usage, /u View current month usage (top 10 by cost)
|
|
106
|
+
/status, /s Show current session status
|
|
107
|
+
/profile [args], /p Manage profiles (list/show/use/create/delete/rename/clone)
|
|
108
|
+
/open-in-browser Open current task in browser
|
|
109
|
+
/share Get share link for current task
|
|
110
|
+
/delete, /del Delete current task
|
|
111
|
+
/quit, /exit, /q Exit interactive mode
|
|
112
|
+
|
|
113
|
+
Note: For detailed usage with sorting/limits, use: entrydesk usage --help
|
|
114
|
+
|
|
115
|
+
Keyboard shortcuts:
|
|
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:O,hasUploadingFiles:oe=!1}){let{exit:se}=is(),[A,z]=Ce([]),[Y,V]=Ce(0),[W,ie]=Ce(!1),[F,v]=Ce(null),[B,S]=Ce([]),[G,p]=Ce(0),[P,x]=Ce(new Set),[ue,R]=Ce(new Set),[$e,gt]=Ce([]),[Ne,Ot]=Ce([]),[Se,st]=Ce([]),[Fe,ht]=Ce([]),[Ae,Me]=Ce(null),[Bt,rt]=Ce(""),Xe=as(!1),[Oe,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 Ot(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?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 "${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
|
+
${u.description}
|
|
121
|
+
Provider: ${u.provider}
|
|
122
|
+
Author: ${u.author.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
|
+
Agent: ${u.agent.name}
|
|
125
|
+
Status: ${u.isActive?"Active":"Paused"}
|
|
126
|
+
Repeat: ${sn(u.config)}
|
|
127
|
+
Next Run: ${c}
|
|
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
|
+
`);l(`Agent connectors:
|
|
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
|
+
`);l(`Active connectors:
|
|
132
|
+
${s}`)}return!0}case"capabilities":{if(y){let r=(L?.capabilities??[]).map(u=>O.get(u)??u);return l(r.length>0?`Agent capabilities:
|
|
133
|
+
${r.map(u=>` - ${u}`).join(`
|
|
134
|
+
`)}`:"No agent capabilities."),!0}let d=[];return C&&d.push("FileSystem"),l(d.length>0?`Active capabilities:
|
|
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(!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
|
+
ID: ${c.id}`);l(`Workspaces:
|
|
138
|
+
${u.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=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(`
|
|
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=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
|
+
`)),!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
|
+
`)),!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
|
+
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
|
+
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?(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,O,L,q,Z,Qe,Ze,ae,m,h,$,m,Pe,De]),yt=je(w=>{if(Xe.current=!1,Oe){(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,Oe,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||Oe)return;if(F==="model"&&B.length>0){let r=B[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"&&B.length>0){let r=B[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"&&B.length>0){let r=B[G];if(r){let u=Ne.find(c=>c.id===r.id);u&&l(`Skill: ${u.name}
|
|
149
|
+
${u.description}
|
|
150
|
+
Provider: ${u.provider}
|
|
151
|
+
Author: ${u.author.name}
|
|
152
|
+
ID: ${u.id}`)}v(null),S([]),t("");return}if(F==="schedules"&&B.length>0){let r=B[G];if(r){let u=Se.find(c=>c.id===r.id);if(u){let c=u.nextRunAt?new Date(u.nextRunAt).toLocaleString():"-";l(`Schedule: ${u.name}
|
|
153
|
+
Agent: ${u.agent.name}
|
|
154
|
+
Status: ${u.isActive?"Active":"Paused"}
|
|
155
|
+
Repeat: ${sn(u.config)}
|
|
156
|
+
Next Run: ${c}
|
|
157
|
+
ID: ${u.id}`)}}v(null),S([]),t("");return}if(F==="connectors"){let r=Array.from(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"&&B.length>0){let r=B[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,B,G,P,ue,K,Ne,Se,l,t,y,f,m,h,$,Q,k,oe,Pe,De,Oe,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(Oe){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&&B.length>0){if(d.upArrow){p(s=>s<=0?B.length-1:s-1);return}if(d.downArrow){p(s=>s>=B.length-1?0:s+1);return}if(d.escape){v(null),S([]),t("");return}if(d.return){if(F==="model"){let s=B[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=B[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=B[G];if(s){let r=Ne.find(u=>u.id===s.id);r&&l(`Skill: ${r.name}
|
|
158
|
+
${r.description}
|
|
159
|
+
Provider: ${r.provider}
|
|
160
|
+
Author: ${r.author.name}
|
|
161
|
+
ID: ${r.id}`)}}else if(F==="schedules"){let s=B[G];if(s){let r=Se.find(u=>u.id===s.id);if(r){let u=r.nextRunAt?new Date(r.nextRunAt).toLocaleString():"-";l(`Schedule: ${r.name}
|
|
162
|
+
Agent: ${r.agent.name}
|
|
163
|
+
Status: ${r.isActive?"Active":"Paused"}
|
|
164
|
+
Repeat: ${sn(r.config)}
|
|
165
|
+
Next Run: ${u}
|
|
166
|
+
ID: ${r.id}`)}}}else if(F==="connectors"){let s=Array.from(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=B[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=B[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(w===" "&&(F==="connectors"||F==="capabilities")){let s=B[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(B.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
|
+
`)||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
|
+
`)||Ae===null)return;if(Ae>=Fe.length-1){Me(null),t(Bt);return}let s=Ae+1;Me(s),t(Fe[s])}}),{suggestions:A,suggestionIndex:Y,showSuggestions:W,argMode:F,argItems:B,argIndex:G,selectedConnectorIds:P,selectedCapabilities:ue,deleteConfirmMode:Oe,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
|
+
`),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 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:O}=Xn(I);At(()=>{O&&!l&&f(O)},[O,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:B}=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&&B(c.length>0?c:void 0)}}},[t,e,a,W,B]);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:Ot,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]),Bt=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:Oe,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:B,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:Ot});rn((c,D)=>{(D.ctrl||D.meta)&&c==="v"&&Bt()},{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||Oe||(h.current=null,Se&>(),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.23.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:Oe}),$.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
|
+
Usage: entrydesk task [options]
|
|
172
|
+
|
|
173
|
+
Send a message to a model or agent, or start an interactive session.
|
|
174
|
+
|
|
175
|
+
Options:
|
|
176
|
+
-m, --message <text> Message to send (or pipe via stdin)
|
|
177
|
+
--model <modelId> Model to use
|
|
178
|
+
-a, --agent <agentId> Agent to use (instead of --model)
|
|
179
|
+
-c, --continue <n> Continue recent task #n
|
|
180
|
+
-i, --interactive Interactive mode (continuous chat)
|
|
181
|
+
--connectors id1,id2 Use specific connectors
|
|
182
|
+
--plain Plain text output
|
|
183
|
+
--output stream-json Stream events as JSON
|
|
184
|
+
--full-output Show full tool outputs
|
|
185
|
+
--no-file-system Disable local file operations
|
|
186
|
+
--json Output JSON
|
|
187
|
+
|
|
188
|
+
Examples:
|
|
189
|
+
entrydesk task -m "Hello" --model <model>
|
|
190
|
+
entrydesk task -m "Hello" -a <agentId>
|
|
191
|
+
entrydesk task -c 1 -m "Follow up" # Continue recent task
|
|
192
|
+
entrydesk task -i # Interactive mode
|
|
193
|
+
echo "Explain this" | entrydesk task --model <model> # Pipe stdin
|
|
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",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
|
+
`)}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) ...${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
|
+
`),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 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
|
+
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){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:"allow_always"}};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:B,value:S}=await z.read();if(B)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&&Be(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&&Be(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&&Be(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}]}),O=await m.task(t,n,T),oe=await te(O),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});O=await m.task(t,n,Y),oe=await te(O),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,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./chunk-KURQCTT3.js";function n(){console.log("entrydesk 1.
|
|
2
|
+
import"./chunk-KURQCTT3.js";function n(){console.log("entrydesk 1.23.0")}export{n as printVersion};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entrydesk/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "EntryDesk CLI - Interact with EntryDesk from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typescript": "^6.0.3",
|
|
38
38
|
"vitest": "^4.1.6",
|
|
39
39
|
"@entrydesk/ci": "^0.0.0",
|
|
40
|
-
"@entrydesk/
|
|
41
|
-
"@entrydesk/
|
|
40
|
+
"@entrydesk/shared": "^0.0.0",
|
|
41
|
+
"@entrydesk/utils": "^0.0.0"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
44
|
"keytar": "^7.9.0"
|
package/dist/task-EEOFXNBH.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as ae,b as fe,c as Bt,g as rt,h as me,n as Je,q as an,r as We,t as cn}from"./chunk-YKH2UWFC.js";import"./chunk-KURQCTT3.js";import{render as ms}from"ink";import{v4 as uo}from"uuid";import{exec as pn}from"child_process";import ho from"fs";import Oe from"fs/promises";import mn from"os";import Ut from"path";import{promisify as yo}from"util";import{glob as wo}from"glob";var xo=yo(pn),ko=`## Filesystem Tool Instructions
|
|
3
|
-
|
|
4
|
-
You have access to filesystem tools that allow you to interact with the user's local filesystem.
|
|
5
|
-
|
|
6
|
-
### Available Operations
|
|
7
|
-
|
|
8
|
-
- **Read File**: Read the contents of a file
|
|
9
|
-
- **Read Multiple Files**: Read multiple files at once (max 10)
|
|
10
|
-
- **Write File**: Create or overwrite a file
|
|
11
|
-
- **Create Directory**: Create a new directory (including parent directories)
|
|
12
|
-
- **List Directory**: List files and subdirectories
|
|
13
|
-
- **Search Files**: Search for files matching a glob pattern
|
|
14
|
-
- **Get File Info**: Get metadata about a file or directory
|
|
15
|
-
- **Move File**: Move or rename a file or directory
|
|
16
|
-
- **Execute Command**: Run shell commands on the user's machine
|
|
17
|
-
|
|
18
|
-
### Important Notes
|
|
19
|
-
|
|
20
|
-
- Always use absolute paths when possible
|
|
21
|
-
- Be mindful of file permissions and access restrictions
|
|
22
|
-
- Large files will be truncated in responses
|
|
23
|
-
- Search results are limited to prevent overwhelming responses
|
|
24
|
-
- Execute Command has a default timeout of 30 seconds (max 5 minutes)
|
|
25
|
-
- The current working directory is: ${process.cwd()}
|
|
26
|
-
- The user's home directory is: ${mn.homedir()}
|
|
27
|
-
`,To=[{name:"filesystem__read_file",description:"Read the contents of a file from the local filesystem.",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 gn(){return{name:"filesystem",systemPrompt:ko,tools:To}}function De(e){return e.startsWith("~/")?Ut.join(mn.homedir(),e.slice(2)):e}function yt(e,t=1e5){return e.length<=t?e:e.slice(0,t)+`
|
|
28
|
-
|
|
29
|
-
... (truncated, ${e.length-t} more characters)`}function hn(e){return e&&typeof e=="object"&&"code"in e?String(e.code):void 0}function un(e){let t=hn(e),n=e instanceof Error?e.message:String(e);switch(t){case"EACCES":case"EPERM":return`${n}
|
|
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
|
-
The path does not exist.`;case"ENOTDIR":return`${n}
|
|
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 dn=!1;function fn(e){if(process.platform!=="darwin"||dn||!process.stdout.isTTY)return;let t=hn(e);t!=="EPERM"&&t!=="EACCES"||(dn=!0,pn('open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"',()=>{}))}async function yn(e,t){try{switch(e){case"filesystem__read_file":{let n=De(t.path),s=await Oe.readFile(n,"utf-8");return{success:!0,result:yt(s)}}case"filesystem__read_multiple_files":{let n=t.paths.slice(0,10),s={};for(let l of n){let a=De(l);try{let m=await Oe.readFile(a,"utf-8");s[l]=yt(m,5e4)}catch(m){fn(m),s[l]={error:un(m)}}}return{success:!0,result:s}}case"filesystem__write_file":{let n=De(t.path),s=t.content;return await Oe.mkdir(Ut.dirname(n),{recursive:!0}),await Oe.writeFile(n,s,"utf-8"),{success:!0,result:{written:n}}}case"filesystem__create_directory":{let n=De(t.path);return await Oe.mkdir(n,{recursive:!0}),{success:!0,result:{created:n}}}case"filesystem__list_directory":{let n=De(t.path);return{success:!0,result:(await Oe.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,s=t.cwd?De(t.cwd):process.cwd(),l=await wo(n,{cwd:s,nodir:!0,maxDepth:10});return{success:!0,result:{files:l.slice(0,100),total:l.length,truncated:l.length>100}}}case"filesystem__get_file_info":{let n=De(t.path),s=await Oe.stat(n);return{success:!0,result:{path:n,type:s.isDirectory()?"directory":s.isFile()?"file":"other",size:s.size,created:s.birthtime.toISOString(),modified:s.mtime.toISOString(),accessed:s.atime.toISOString(),mode:s.mode.toString(8)}}}case"filesystem__move_file":{let n=De(t.source),s=De(t.destination);return await Oe.mkdir(Ut.dirname(s),{recursive:!0}),await Oe.rename(n,s),{success:!0,result:{moved:{from:n,to:s}}}}case"filesystem__execute_command":{let n=t.command,s=t.cwd?De(t.cwd):process.cwd(),l=Math.min(t.timeout||3e4,3e5);if(!ho.existsSync(s))return{success:!1,error:`Working directory does not exist: ${s}`};let{stdout:a,stderr:m}=await xo(n,{cwd:s,timeout:l,maxBuffer:10*1024*1024});return{success:!0,result:{stdout:yt(a,5e4),stderr:yt(m,5e4)}}}default:return{success:!1,error:`Unknown tool: ${e}`}}}catch(n){return fn(n),{success:!1,error:un(n)}}}function jt(e){return e.startsWith("filesystem__")}function wn(){return[gn()]}function wt(){return wn().flatMap(e=>e.tools)}function xt(){return wn().map(e=>e.systemPrompt).filter(Boolean).join(`
|
|
34
|
-
|
|
35
|
-
`)}function Be(e){return jt(e)}async function kt(e,t){return jt(e)?yn(e,t):{success:!1,error:`Unknown client tool: ${e}`}}import{Box as ye,Text as U,useInput as nn}from"ink";import on from"ink-spinner";import{useCallback as sn,useEffect as Et,useRef as rn,useState as is}from"react";import{Box as Tt,Text as it}from"ink";import{jsx as bt,jsxs as lt}from"react/jsx-runtime";function xn(e,t){return e.length<=t?e:t<=3?".".repeat(t):e.slice(0,t-3)+"..."}function kn({items:e,activeIndex:t,selectedIds:n,multiSelect:s=!1,visible:l,title:a,pageSize:m=10}){if(!l||e.length===0)return null;let h=process.stdout.columns??80,y=s?4:0,g=Math.max(20,h-2-2-y),j=Math.max(1,m),$=Math.floor(t/j)*j,P=Math.min(e.length,$+j),Q=e.slice($,P);return lt(Tt,{flexDirection:"column",marginBottom:1,children:[bt(it,{bold:!0,color:"cyan",children:a}),bt(Tt,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:Q.map((b,k)=>{let N=$+k===t,V=n?.has(b.id),Z=xn(b.name,g),q=b.description?xn(b.description,Math.max(0,g-y)):"",M=s?" ".repeat(y):"";return lt(Tt,{paddingX:1,flexDirection:"column",children:[lt(Tt,{children:[s&&bt(it,{color:V?"green":"gray",children:V?"[\u2713] ":"[ ] "}),bt(it,{backgroundColor:N?"cyan":void 0,color:N?"black":V?"green":"white",bold:!0,children:Z})]}),q&<(it,{dimColor:!0,children:[M,"\xB7 ",q]})]},b.id)})}),lt(it,{dimColor:!0,children:[s?"\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>j?` \xB7 Showing ${$+1}-${P} of ${e.length}`:""]})]})}import{Box as Mt,Text as at}from"ink";import{jsx as ct,jsxs as Wt}from"react/jsx-runtime";function Tn({suggestions:e,activeIndex:t,visible:n}){return!n||e.length===0?null:Wt(Mt,{flexDirection:"column",marginBottom:1,children:[ct(Mt,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:e.map((s,l)=>{let a=l===t,m=s.aliases.length>0?` (${s.aliases.join(", ")})`:"";return Wt(Mt,{paddingX:1,children:[Wt(at,{backgroundColor:a?"cyan":void 0,color:a?"black":"cyan",bold:a,children:["/",s.name]}),ct(at,{dimColor:!0,children:m}),ct(at,{children:" - "}),ct(at,{color:a?"white":"gray",children:s.description})]},s.name)})}),ct(at,{dimColor:!0,children:"\u2191\u2193 Navigate \xB7 Tab/Enter Select \xB7 Esc Cancel"})]})}import{Box as bo,Text as bn,useInput as Co,useStdout as $o}from"ink";import{useCallback as Cn,useEffect as $n,useMemo as Gt,useRef as In,useState as vn}from"react";import{jsx as Jt}from"react/jsx-runtime";function Ct(e,t){return e<0?0:e>t?t:e}function Ht(e){return Array.from(e)}function $t(e){return/\s/.test(e)}function qt(e,t){let n=t;for(;n>0&&$t(e[n-1]??"");)n-=1;for(;n>0&&!$t(e[n-1]??"");)n-=1;return n}function Sn(e,t){let n=t;for(;n<e.length&&$t(e[n]??"");)n+=1;for(;n<e.length&&!$t(e[n]??"");)n+=1;return n}function Io(e){let t=[],n=[],s=[],l=0;n.push(0),e.forEach((m,h)=>{if(m===`
|
|
36
|
-
`){t.push(s),s=[],l=h+1,n.push(l);return}s.push(m)}),t.push(s);let a=t.map(m=>m.length);return{lines:t,lineStarts:n,lineLengths:a}}function Pn(e,t,n){for(let l=0;l<t.length;l+=1){let a=t[l]??0,m=n[l]??0,h=a+m;if(e<=h)return{row:l,col:e-a}}let s=Math.max(0,t.length-1);return{row:s,col:n[s]??0}}var vo=2;function _n({value:e,onChange:t,onSubmit:n,onPaste:s,focus:l=!0,leadingOffset:a=0,multiline:m=!1}){let[h,y]=vn(()=>Ht(e).length),g=In(null),[j,$]=vn(0),P=In(null),{stdout:Q}=$o(),b=Gt(()=>Ht(e),[e]),{lines:k,lineStarts:E,lineLengths:N}=Gt(()=>Io(b),[b]),{row:V,col:Z}=Gt(()=>Pn(h,E,N),[h,E,N]),q=Math.max(1,(Q?.columns??80)-a);$n(()=>{g.current!==e?(y(b.length),P.current=null):y(i=>Ct(i,b.length)),g.current=e},[e,b.length]),$n(()=>{$(i=>{let f=i;Z<f?f=Z:Z>=f+q&&(f=Z-q+1);let _=N[V]??0,W=Z===_?_+1:_,C=Math.max(0,W-q);return f>C&&(f=C),f<0&&(f=0),f})},[q,Z,V,N]);let M=Cn((i,f)=>{g.current=i,t(i),y(f),P.current=null},[t]),ce=Cn(async(i,f)=>{if(!l)return;let{row:_,col:W}=Pn(h,E,N),C=k[_]??[],pe=N[_]??0,te=k.length>1;if(m&&(f.meta&&f.return||f.ctrl&&i==="j"||f.shift&&f.return)){let T=[...b.slice(0,h),`
|
|
37
|
-
`,...b.slice(h)].join("");M(T,h+1);return}if(f.return){n(e);return}if(f.leftArrow){f.ctrl||f.meta?(W===0&&_>0?y(E[_]-1):y(E[_]+qt(C,W)),P.current=null):(W===0&&_>0?y(E[_]-1):y(T=>Ct(T-1,b.length)),P.current=null);return}if(f.rightArrow){f.ctrl||f.meta?(W>=pe&&_<k.length-1?y(E[_+1]):y(E[_]+Sn(C,W)),P.current=null):(W>=pe&&_<k.length-1?y(E[_+1]):y(T=>Ct(T+1,b.length)),P.current=null);return}if(m&&te&&f.upArrow){let T=P.current??W,F=Math.max(0,_-1),oe=Math.min(T,N[F]??0);y((E[F]??0)+oe),P.current=T;return}if(m&&te&&f.downArrow){let T=P.current??W,F=Math.min(k.length-1,_+1),oe=Math.min(T,N[F]??0);y((E[F]??0)+oe),P.current=T;return}if(f.ctrl){if(i==="a"){y(E[_]??0),P.current=null;return}if(i==="e"){y((E[_]??0)+pe),P.current=null;return}if(i==="u"){if(W>0){let T=E[_]??0,F=[...b.slice(0,T),...b.slice(h)].join("");M(F,T)}return}if(i==="k"){if(W<pe){let T=(E[_]??0)+pe,F=[...b.slice(0,h),...b.slice(T)].join("");M(F,h)}return}if(i==="w"){if(W===0&&_>0){let F=[...b.slice(0,h-1),...b.slice(h)].join("");M(F,h-1);return}let T=qt(C,W);if(T!==W){let F=(E[_]??0)+T,oe=[...b.slice(0,F),...b.slice(h)].join("");M(oe,F)}return}if(i==="d"){if(h<b.length){let T=[...b.slice(0,h),...b.slice(h+1)].join("");M(T,h)}return}return}if(f.meta){i==="b"?(W===0&&_>0?y(E[_]-1):y(E[_]+qt(C,W)),P.current=null):i==="f"&&(W>=pe&&_<k.length-1?y(E[_+1]):y(E[_]+Sn(C,W)),P.current=null);return}if(f.backspace||f.delete){if(h<=0)return;let T=[...b.slice(0,h-1),...b.slice(h)].join("");M(T,h-1);return}if(!(f.tab||f.escape)&&i.length>0){let T=m?i.replace(/\r\n/g,`
|
|
38
|
-
`).replace(/\r/g,`
|
|
39
|
-
`):i.replace(/\r?\n/g,"");if(!T||(T=T.replace(/^\x1b?\[200~/,"").replace(/\x1b?\[201~$/,""),!T))return;if((T.length>=vo||T.includes(`
|
|
40
|
-
`))&&s){let A=!1,Y={text:T,preventDefault:()=>{A=!0}};if(await Promise.resolve(s(Y)),A)return}let oe=Ht(T),se=[...b.slice(0,h),...oe,...b.slice(h)].join("");M(se,h+oe.length)}},[b,h,l,N,E,k,m,s,n,M,e]);return Co(ce,{isActive:l}),Jt(bo,{flexDirection:"column",children:k.map((i,f)=>{let _=f===V,C=(_&&Z===i.length?[...i," "]:i).slice(j,j+q),pe=C.join("");if(!_)return Jt(bn,{children:pe||" "},f);let te=Ct(Z-j,Math.max(0,C.length-1)),T=C.slice(0,te).join(""),F=C[te]??" ",oe=C.slice(te+1).join(""),Y=`${T}\x1B[7m${F}\x1B[27m${oe}`;return Jt(bn,{children:Y},f)})})}import{Box as Re,Text as Ge}from"ink";import zt from"react";import{Text as Ie}from"ink";import So from"react";import{Fragment as Eo,jsx as _e,jsxs as An}from"react/jsx-runtime";var Yt=2,Kt=1,Vt=2,Po=1,En=3,Nn=4,_o=({text:e,defaultColor:t,linkColor:n,codeColor:s})=>{let l=t;if(!/[*_~`<[https?:]/.test(e))return _e(Ie,{color:l,children:e});let a=[],m=0,h=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g,y;for(;(y=h.exec(e))!==null;){y.index>m&&a.push(_e(Ie,{color:l,children:e.slice(m,y.index)},`t-${m}`));let g=y[0],j=null,$=`m-${y.index}`;try{if(g.startsWith("**")&&g.endsWith("**")&&g.length>Yt*2)j=_e(Ie,{bold:!0,color:l,children:g.slice(Yt,-Yt)},$);else if(g.length>Kt*2&&(g.startsWith("*")&&g.endsWith("*")||g.startsWith("_")&&g.endsWith("_"))&&!/\w/.test(e.substring(y.index-1,y.index))&&!/\w/.test(e.substring(h.lastIndex,h.lastIndex+1))&&!/\S[./\\]/.test(e.substring(y.index-2,y.index))&&!/[./\\]\S/.test(e.substring(h.lastIndex,h.lastIndex+2)))j=_e(Ie,{italic:!0,color:l,children:g.slice(Kt,-Kt)},$);else if(g.startsWith("~~")&&g.endsWith("~~")&&g.length>Vt*2)j=_e(Ie,{strikethrough:!0,color:l,children:g.slice(Vt,-Vt)},$);else if(g.startsWith("`")&&g.endsWith("`")&&g.length>Po){let P=g.match(/^(`+)(.+?)\1$/s);P&&P[2]&&(j=_e(Ie,{color:s,children:P[2]},$))}else if(g.startsWith("[")&&g.includes("](")&&g.endsWith(")")){let P=g.match(/\[(.*?)\]\((.*?)\)/);if(P){let Q=P[1],b=P[2];j=An(Ie,{color:l,children:[Q,An(Ie,{color:n,children:[" (",b,")"]})]},$)}}else g.startsWith("<u>")&&g.endsWith("</u>")&&g.length>En+Nn-1?j=_e(Ie,{underline:!0,color:l,children:g.slice(En,-Nn)},$):g.match(/^https?:\/\//)&&(j=_e(Ie,{color:n,children:g},$))}catch{j=null}a.push(j??_e(Ie,{color:l,children:g},$)),m=h.lastIndex}return m<e.length&&a.push(_e(Ie,{color:l,children:e.slice(m)},`t-${m}`)),_e(Eo,{children:a.filter(g=>g!==null)})},ut=So.memo(_o);import{Fragment as Oo,jsx as ue,jsxs as Fn}from"react/jsx-runtime";var No=1,Ln=1,Ao=1,Do=1,Ro=({content:e})=>{let t=e.join(`
|
|
41
|
-
`);return ue(Re,{paddingLeft:Ln,flexDirection:"column",children:ue(Ge,{color:"yellow",children:t})})},Dn=zt.memo(Ro),Lo=({itemText:e,type:t,marker:n,leadingWhitespace:s=""})=>{let l=t==="ol"?`${n}. `:`${n} `,a=l.length,m=s.length;return Fn(Re,{paddingLeft:m+Ao,flexDirection:"row",children:[ue(Re,{width:a,children:ue(Ge,{children:l})}),ue(Re,{flexGrow:Do,children:ue(Ge,{wrap:"wrap",children:ue(ut,{text:e,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})})]})},Rn=zt.memo(Lo),Fo=({text:e,renderMarkdown:t=!0})=>{if(!e)return null;if(!t)return ue(Re,{paddingLeft:Ln,flexDirection:"column",children:ue(Ge,{wrap:"wrap",children:e})});let n=e.split(/\r?\n/),s=/^ *(#{1,4}) +(.*)/,l=/^ *(`{3,}|~{3,}) *(\w*?) *$/,a=/^([ \t]*)([-*+]) +(.*)/,m=/^([ \t]*)(\d+)\. +(.*)/,h=/^ *([-*_] *){3,} *$/,y=/^ *> ?(.*)/,g=[],j=!1,$=!0,P=[],Q="";function b(k){k&&(g.push(k),$=!1)}return n.forEach((k,E)=>{let N=`line-${E}`;if(j){let f=k.match(l);f&&f[1].startsWith(Q[0])&&f[1].length>=Q.length?(b(ue(Dn,{content:P},N)),j=!1,P=[],Q=""):P.push(k);return}let V=k.match(l),Z=k.match(s),q=k.match(a),M=k.match(m),ce=k.match(h),i=k.match(y);if(V)j=!0,Q=V[1];else if(ce)b(ue(Re,{children:ue(Ge,{dimColor:!0,children:"---"})},N));else if(Z){let f=Z[1].length,_=Z[2],W=f<=2?"cyan":"blue";b(ue(Re,{children:ue(Ge,{color:W,...(f===4?"italic":"bold")==="italic"?{italic:!0}:{bold:!0},children:ue(ut,{text:_,defaultColor:W,linkColor:"cyan",codeColor:"yellow"})})},N))}else if(i){let f=i[1];b(ue(Re,{paddingLeft:1,children:Fn(Ge,{dimColor:!0,children:["> ",ue(ut,{text:f,defaultColor:"gray",linkColor:"cyan",codeColor:"yellow"})]})},N))}else if(q){let f=q[1],_=q[2],W=q[3];b(ue(Rn,{itemText:W,type:"ul",marker:_,leadingWhitespace:f},N))}else if(M){let f=M[1],_=M[2],W=M[3];b(ue(Rn,{itemText:W,type:"ol",marker:_,leadingWhitespace:f},N))}else k.trim().length===0?$||(g.push(ue(Re,{height:No},`spacer-${E}`)),$=!0):b(ue(Re,{children:ue(Ge,{wrap:"wrap",children:ue(ut,{text:k,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})},N))}),j&&b(ue(Dn,{content:P},"line-eof")),ue(Oo,{children:g})},Xt=zt.memo(Fo);import{execFile as Bo}from"child_process";import Uo from"fs";import et from"fs/promises";import On from"os";import vt from"path";import{promisify as jo}from"util";var It=jo(Bo);async function Mo(){let e=vt.join(On.tmpdir(),`entrydesk-clipboard-${Date.now()}.png`);try{let t=`
|
|
42
|
-
set imageData to the clipboard as "PNGf"
|
|
43
|
-
set fileRef to open for access POSIX file "${e}" with write permission
|
|
44
|
-
set eof fileRef to 0
|
|
45
|
-
write imageData to fileRef
|
|
46
|
-
close access fileRef
|
|
47
|
-
`;return await It("osascript",["-e",t]),(await et.stat(e)).size===0?void 0:{buffer:await et.readFile(e),mime:"image/png"}}catch{return}finally{try{Uo.existsSync(e)&&await et.unlink(e)}catch{}}}async function Wo(){try{let e=`
|
|
48
|
-
Add-Type -AssemblyName System.Windows.Forms
|
|
49
|
-
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
50
|
-
if ($img) {
|
|
51
|
-
$ms = New-Object System.IO.MemoryStream
|
|
52
|
-
$img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
53
|
-
[System.Convert]::ToBase64String($ms.ToArray())
|
|
54
|
-
}
|
|
55
|
-
`,{stdout:t}=await It("powershell.exe",["-command",e]),n=t.trim();if(!n)return;let s=Buffer.from(n,"base64");return s.length===0?void 0:{buffer:s,mime:"image/png"}}catch{return}}async function Go(){try{let{stdout:e}=await It("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 It("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 Bn(){let e=On.platform();if(e==="darwin")return Mo();if(e==="win32")return Wo();if(e==="linux")return Go()}var Ho=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 Un(e){let t=vt.extname(e).toLowerCase();return Ho.has(t)}function qo(e){let t=vt.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 St(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 jn(e){let t=St(e);if(/^https?:\/\//.test(t))return!1;try{return await et.access(t),!0}catch{return!1}}async function Mn(e){let t=St(e);try{if(!(await et.stat(t)).isFile())return;let s=await et.readFile(t),l=qo(t),a=vt.basename(t);return{buffer:s,mimeType:l,filename:a}}catch{return}}var ve="\x1B[2m",X="\x1B[0m",he="\x1B[36m",tt="\x1B[32m",Wn="\x1B[31m",Ye="\x1B[38;2;59;91;204m",Qt="\x1B[38;2;126;200;248m",Zt="\x1B[38;2;244;196;78m";import{useState as Ue}from"react";import{v4 as Gn}from"uuid";function Hn(e,t){let[n,s]=Ue({status:"loading"}),[l,a]=Ue([]),[m,h]=Ue(""),[y,g]=Ue(()=>e||Gn()),[j,$]=Ue(t),[P,Q]=Ue(!!e),[b,k]=Ue(null),[E,N]=Ue(""),[V,Z]=Ue(!1),q=ce=>{a(i=>[...i,{role:"system",content:ce}])};return{state:n,setState:s,messages:l,setMessages:a,input:m,setInput:h,taskId:y,setTaskId:g,currentTaskTitle:j,setCurrentTaskTitle:$,hasPersistedTask:P,setHasPersistedTask:Q,credentials:b,setCredentials:k,currentResponse:E,setCurrentResponse:N,fullOutput:V,setFullOutput:Z,addSystemMessage:q,startNewTask:ce=>{let i=Gn();g(i),$(void 0),Q(!1),a([]),ce&&q(ce)}}}import{useEffect as Jo,useState as qn}from"react";function Jn(e){let[t,n]=qn(null),[s,l]=qn(!0);return Jo(()=>{let a=!1;async function m(){try{let h=await We();if(a)return;n({accessToken:h.accessToken,workspaceId:h.workspaceId}),l(!1)}catch(h){if(a)return;if(h instanceof Je){if(h.code==="not-logged-in"){e({status:"not-logged-in"}),l(!1);return}if(h.code==="no-workspace"){e({status:"no-workspace"}),l(!1);return}}let y=h instanceof Error?h.message:"Failed to authenticate";e({status:"error",message:y}),l(!1)}}return m(),()=>{a=!0}},[e]),{credentials:t,loading:s}}import{useEffect as Yo,useState as dt}from"react";function Yn(e){let[t,n]=dt([]),[s,l]=dt([]),[a,m]=dt([]),[h,y]=dt([]),[g,j]=dt(!1);return Yo(()=>{if(!e)return;let $=!1;j(!0);async function P(){if(e)try{let Q=new me,[b,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(b.connectors),l(k.models),m(E.agents),y(N.providers??[])}catch{}finally{$||j(!1)}}return P(),()=>{$=!0}},[e]),{availableConnectors:t,availableModels:s,availableAgents:a,modelProviders:h,loading:g}}import nt from"fs";import Vn from"path";import{useCallback as Ko}from"react";import{v4 as Vo}from"uuid";function Kn(e,t){if(!e)return"(no result)";if(typeof e!="object"){let l=String(e);return t||l.length<=200?l:l.slice(0,200)+"..."}let n=e;if("structuredContent"in n&&n.structuredContent){let l=n.structuredContent;if(l.stdout&&typeof l.stdout=="string"){let a=l.stdout.trim();return t||a.length<=200?a:a.slice(0,200)+"..."}}if("content"in n&&Array.isArray(n.content)){let l=n.content.filter(a=>a.type==="text"&&a.text).map(a=>a.text).join(`
|
|
56
|
-
`);return l?t||l.length<=200?l:l.slice(0,200)+"...":"(result)"}let s=JSON.stringify(e,null,t?2:void 0);return t||s.length<=200?s:s.slice(0,200)+"..."}function Ke(e,t=!1){let n=[];for(let s of e)if(s.type==="text"&&s.text)n.push(s.text);else if(s.type==="reasoning"&&s.text)t?n.push(`${ve}[Thinking]
|
|
57
|
-
${s.text}${X}`):n.push(`${ve}[Thinking...]${X}`);else if(s.type==="tool-call"&&s.toolName){let l=[];if(l.push(`${he}\u250C\u2500 Tool: ${s.toolName}${X}`),s.args){let a=JSON.stringify(s.args,null,t?2:void 0),m=t||a.length<=100?a:a.slice(0,100)+"...";l.push(`${ve}\u2502 Args: ${m}${X}`)}s.result!==void 0?(l.push(`${tt}\u2502 Result: ${Kn(s.result,t)}${X}`),l.push(`${he}\u2514\u2500 completed${X}`)):l.push(`${he}\u2514\u2500${X}`),n.push(l.join(`
|
|
58
|
-
`))}else if(s.type.startsWith("tool-")&&s.type!=="tool-call"){let l=s.title||s.type.slice(5).replace(/__/g," "),a=[];if(a.push(`${he}\u250C\u2500 Tool: ${l}${X}`),s.input){let m=JSON.stringify(s.input,null,t?2:void 0),h=t||m.length<=100?m:m.slice(0,100)+"...";a.push(`${ve}\u2502 Input: ${h}${X}`)}s.output!==void 0&&s.state==="output-available"?(a.push(`${tt}\u2502 Output: ${Kn(s.output,t)}${X}`),a.push(`${he}\u2514\u2500 completed${X}`)):s.state==="error"?a.push(`${he}\u2514\u2500 failed${X}`):a.push(`${he}\u2514\u2500${X}`),n.push(a.join(`
|
|
59
|
-
`))}return n.join(`
|
|
60
|
-
|
|
61
|
-
`).trim()}var Pt=class{pendingToolCalls=new Map;hasPending(){return this.pendingToolCalls.size>0}hasExecuting(){for(let t of this.pendingToolCalls.values())if(t.status==="executing")return!0;return!1}clear(t){this.pendingToolCalls.delete(t)}buildToolDisplay(){if(this.pendingToolCalls.size===0)return"";let t=[];for(let[,n]of this.pendingToolCalls){let s=n.toolName.replace(/__/g," "),l=`
|
|
62
|
-
|
|
63
|
-
${he}\u250C\u2500 Tool: ${s}${X}`;if(n.args){let a=n.args.length>100?n.args.slice(0,100)+"...":n.args;l+=`
|
|
64
|
-
${ve}\u2502 Input: ${a}${X}`}if(n.output){let a=n.output.length>150?n.output.slice(0,150)+"...":n.output;l+=`
|
|
65
|
-
${tt}\u2502 Output: ${a}${X}`}else if(n.status==="executing"){let a=n.startedAt??Date.now(),m=Math.floor((Date.now()-a)/1e3);l+=`
|
|
66
|
-
${he}\u2502${X} (executing... ${m}s)`}else n.status==="preparing"&&(l+=`
|
|
67
|
-
${he}\u2502${X} (preparing...)`);t.push(l)}return t.join("")}flushPending(t){if(this.pendingToolCalls.size===0)return t;for(let[n,s]of this.pendingToolCalls){let l=s.toolName.replace(/__/g," "),a=typeof s.args=="string"&&s.args.length>100?s.args.slice(0,100)+"...":s.args||"";t+=`
|
|
68
|
-
|
|
69
|
-
${he}\u250C\u2500 Tool: ${l}${X}`,a&&(t+=`
|
|
70
|
-
${ve}\u2502 Input: ${a}${X}`),t+=`
|
|
71
|
-
${he}\u2514\u2500 completed${X}
|
|
72
|
-
`,this.pendingToolCalls.delete(n)}return t}handleToolInputStart(t){return t.toolCallId&&t.toolName?(this.pendingToolCalls.set(t.toolCallId,{toolName:t.toolName,args:"",status:"preparing"}),this.buildToolDisplay()):null}handleToolInputDelta(t){if(t.toolCallId&&t.inputTextDelta){let n=this.pendingToolCalls.get(t.toolCallId);if(n)return n.args=(n.args||"")+t.inputTextDelta,n.status="executing",n.startedAt??=Date.now(),this.buildToolDisplay()}return null}handleToolOutputStart(t){if(t.toolCallId){let n=this.pendingToolCalls.get(t.toolCallId);if(n)return n.output="",n.status="output",this.buildToolDisplay()}return null}handleToolOutputDelta(t){if(t.toolCallId&&t.outputTextDelta){let n=this.pendingToolCalls.get(t.toolCallId);if(n)return n.output=(n.output||"")+t.outputTextDelta,this.buildToolDisplay()}return null}handleToolOutputEnd(t,n){if(!t.toolCallId)return null;let s=this.pendingToolCalls.get(t.toolCallId);if(!s)return null;let l=s.toolName.replace(/__/g," "),a=typeof s.args=="string"&&s.args.length>100?s.args.slice(0,100)+"...":s.args||"",m=(s.output||"").length>200?(s.output||"").slice(0,200)+"...":s.output||"";return n+=`
|
|
73
|
-
|
|
74
|
-
${he}\u250C\u2500 Tool: ${l}${X}`,a&&(n+=`
|
|
75
|
-
${ve}\u2502 Input: ${a}${X}`),n+=`
|
|
76
|
-
${tt}\u2502 Output: ${m}${X}`,n+=`
|
|
77
|
-
${he}\u2514\u2500 completed${X}
|
|
78
|
-
`,this.pendingToolCalls.delete(t.toolCallId),{fullResponse:n,toolDisplay:this.buildToolDisplay()}}handleToolError(t,n){if(!t.toolCallId)return null;let l=(this.pendingToolCalls.get(t.toolCallId)?.toolName||t.toolName||"Tool").replace(/__/g," "),a=t.errorText||"Unknown error",m=a.length>200?a.slice(0,200)+"...":a;return n+=`
|
|
79
|
-
|
|
80
|
-
${he}\u250C\u2500 Tool: ${l}${X}`,n+=`
|
|
81
|
-
${Wn}\u2502 Error: ${m}${X}`,n+=`
|
|
82
|
-
${he}\u2514\u2500 failed${X}
|
|
83
|
-
`,this.pendingToolCalls.delete(t.toolCallId),{fullResponse:n,toolDisplay:this.buildToolDisplay()}}};var ft=Vn.join(process.env.HOME||"/tmp",".entrydesk","stream-debug.log");function ne(e,t){if(!process.env.DEBUG)return;let s=`[${new Date().toISOString()}] ${e}`;t!==void 0&&(s+=`
|
|
84
|
-
DATA: ${JSON.stringify(t,null,2)}`),s+=`
|
|
85
|
-
`;try{nt.appendFileSync(ft,s)}catch{}}function zo(){try{if(nt.existsSync(ft)&&nt.unlinkSync(ft),process.env.DEBUG){let e=Vn.dirname(ft);nt.existsSync(e)||nt.mkdirSync(e,{recursive:!0}),nt.writeFileSync(ft,`=== Debug session started at ${new Date().toISOString()} ===
|
|
86
|
-
`)}}catch{}}function _t(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch{return{}}return typeof e=="object"?e:{}}function zn({taskId:e,credentials:t,currentAgentId:n,currentModel:s,activeConnectorIds:l,localTools:a,fullOutput:m,setMessages:h,setState:y,setCurrentResponse:g,setCredentials:j,setHasPersistedTask:$,getFileIds:P,clearFiles:Q}){let b=a?wt():void 0,k=a?xt():void 0;return{sendMessage:Ko(async(N,V,Z)=>{zo(),ne("=== sendMessage called ===",{text:N,localTools:a,clientToolsCount:b?.length});let q=V||t?.accessToken,M=Z||t?.workspaceId;if(!q||!M)try{let f=await We();q=f.accessToken,M=f.workspaceId,j(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 an();f!==q&&(q=f,j({accessToken:f,workspaceId:M}))}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}h(f=>[...f,{role:"user",content:N}]),y({status:"sending"}),g("");let ce=null,i=null;try{let f=new me,_=P?.()??[],W={id:e,message:{id:Vo(),createdAt:new Date,role:"user",parts:[{type:"text",text:N}]}};_.length>0&&(W.fileIds=_),n?W.agentId=n:(s&&(W.model=s),W.connectorIds=l??[]),b&&(W.clientTools=b),k&&(W.clientToolSystemPrompt=k);let C=await f.task(q,M,W);if(!C.ok){let I=await C.text();throw new Error(`API error ${C.status}: ${I}`)}if(!C.body)throw new Error("No response body from server");ce=C.body.getReader();let pe=new TextDecoder,te="",T="",F="",oe="",se="",A="",Y="",K=new Pt,z=[],O=[],le=[],L=()=>{let I=K.hasExecuting();I&&!i?i=setInterval(()=>{if(!K.hasExecuting()){i&&(clearInterval(i),i=null);return}g(T+K.buildToolDisplay())},1e3):!I&&i&&(clearInterval(i),i=null)};for(;;){let{done:I,value:B}=await ce.read();if(I)break;te+=pe.decode(B,{stream:!0});let v=te.split(`
|
|
87
|
-
`);te=v.pop()||"";for(let G of v)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",F="";break;case"reasoning-delta":p.delta&&(F+=p.delta,g(`${ve}[Thinking...]${X}
|
|
88
|
-
${F}`)),p.providerMetadata?.anthropic?.signature&&(se=p.providerMetadata.anthropic.signature);break;case"reasoning-end":if(F){let S={type:"reasoning",id:oe,text:F,state:"done"};se&&(S.providerMetadata={anthropic:{signature:se}}),O.push(S),ne("Added reasoning to messageParts",{reasoningLength:F.length,hasSignature:!!se,messagePartsCount:O.length})}F="",se="",g("");break;case"text-delta":p.delta&&(K.hasPending()&&(T=K.flushPending(T)),T+=p.delta,A+=p.delta,g(T));break;case"tool-input-start":{let S=K.handleToolInputStart(p);S&&g(T+S),L();break}case"tool-input-delta":{let S=K.handleToolInputDelta(p);S&&g(T+S),L();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?Be(p.toolName):"no toolName",args:p.args,input:p.input}),p.toolCallId&&p.toolName){let S=_t(p.args??p.input);O.push({type:p.type,toolCallId:p.toolCallId,toolName:p.toolName,args:S}),ne("Added tool to messageParts",{messagePartsCount:O.length})}if(a&&p.toolCallId&&p.toolName&&Be(p.toolName)){let S=_t(p.args??p.input);z.push({toolCallId:p.toolCallId,toolName:p.toolName,args:S}),ne("Added to pendingClientTools",{pendingCount:z.length,pendingClientTools:z}),g(T+K.buildToolDisplay()+`
|
|
89
|
-
[Executing ${p.toolName} locally...]`)}else ne("NOT added to pendingClientTools - conditions not met",{localTools:a,hasToolCallId:!!p.toolCallId,hasToolName:!!p.toolName,isClientTool:p.toolName?Be(p.toolName):!1});break}case"tool-output-start":{let S=K.handleToolOutputStart(p);S&&g(T+S),L();break}case"tool-output-delta":{let S=K.handleToolOutputDelta(p);S&&g(T+S),L();break}case"tool-output-end":{let S=K.handleToolOutputEnd(p,T);S&&(T=S.fullResponse,g(T+S.toolDisplay)),L();break}case"tool-input-error":case"tool-output-error":{let S=K.handleToolError(p,T);S&&(T=S.fullResponse,g(T+S.toolDisplay)),L();break}case"start":p.messageId&&(Y=p.messageId,ne("Captured messageId from start event",{messageId:Y}));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 I=O.findIndex(v=>v.type!=="reasoning"),B=I===-1?O.length:I;O.splice(B,0,{type:"text",text:A}),ne("Added accumulated text to messageParts",{textLength:A.length,insertIndex:B})}for(ne("=== Initial stream ended ===",{pendingClientToolsCount:z.length,pendingClientTools:z,messagePartsCount:O.length,messageParts:O.map(I=>({type:I.type,toolCallId:I.toolCallId,toolName:I.toolName}))});z.length>0;){ne("=== Starting pending tools execution loop ===",{pendingCount:z.length});let I=[];for(let p of z){ne(`Executing tool: ${p.toolName}`,{toolCallId:p.toolCallId,args:p.args}),K.handleToolInputStart({toolCallId:p.toolCallId,toolName:p.toolName}),K.handleToolInputDelta({toolCallId:p.toolCallId,inputTextDelta:JSON.stringify(p.args)}),g(T+K.buildToolDisplay()),L();let S=await kt(p.toolName,p.args);ne(`Tool execution result: ${p.toolName}`,{success:S.success,resultPreview:S.success?JSON.stringify(S.result).slice(0,200):S.error});let w=S.success?JSON.stringify(S.result):S.error||"Unknown error";if(I.push({toolCallId:p.toolCallId,toolName:p.toolName,content:[{type:"text",text:w}],isError:!S.success}),S.success){K.handleToolOutputStart({toolCallId:p.toolCallId}),K.handleToolOutputDelta({toolCallId:p.toolCallId,outputTextDelta:JSON.stringify(S.result).slice(0,200)});let ie=K.handleToolOutputEnd({toolCallId:p.toolCallId},T);ie&&(T=ie.fullResponse)}else{let ie=K.handleToolError({toolCallId:p.toolCallId,errorText:S.error},T);ie&&(T=ie.fullResponse)}g(T+K.buildToolDisplay()),L()}z.length=0;for(let p of I){let S=O.find(w=>(w.type==="tool-input-available"||w.type==="tool-call")&&w.toolCallId===p.toolCallId);if(S){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 ie=w.join(`
|
|
90
|
-
`);le.push({type:`tool-${S.toolName}`,toolName:S.toolName,toolCallId:S.toolCallId,input:S.args,output:ie,isError:p.isError})}}if(ne("=== Sending clientToolResults for continuation ===",{toolResultsCount:I.length,toolResults:I.map(p=>({toolCallId:p.toolCallId,toolName:p.toolName,isError:p.isError}))}),ce)try{ce.releaseLock()}catch{}let B=I.map(p=>({type:`tool-${p.toolName}`,toolCallId:p.toolCallId,state:"output-available",output:{content:p.content,isError:p.isError}}));if(!Y)throw new Error("Cannot continue: missing assistant message id for tool results.");let v={id:e,message:{id:Y,role:"assistant",parts:B}};n?v.agentId=n:(s&&(v.model=s),v.connectorIds=l??[]),b&&(v.clientTools=b),k&&(v.clientToolSystemPrompt=k),ne("=== Sending continuation request ===",{taskId:e,hasAgentId:!!v.agentId,hasModel:!!v.model,clientToolResultsCount:I.length});let G=await f.task(q,M,v);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 ==="),ce=G.body.getReader(),O.length=0,A="",F="",oe="",se="";;){let{done:p,value:S}=await ce.read();if(p){ne("=== Continuation stream done ===");break}te+=pe.decode(S,{stream:!0});let w=te.split(`
|
|
91
|
-
`);te=w.pop()||"";for(let ie of w)if(ie.trim()!=="data: [DONE]"&&ie.startsWith("data: "))try{let R=JSON.parse(ie.slice(6));switch(ne(`Continuation SSE: ${R.type}`,R),R.type){case"start":R.messageId&&(Y=R.messageId);break;case"reasoning-start":oe=R.id||"0",F="";break;case"reasoning-delta":R.delta&&(F+=R.delta,g(`${ve}[Thinking...]${X}
|
|
92
|
-
${F}`)),R.providerMetadata?.anthropic?.signature&&(se=R.providerMetadata.anthropic.signature);break;case"reasoning-end":if(F){let $e={type:"reasoning",id:oe,text:F,state:"done"};se&&($e.providerMetadata={anthropic:{signature:se}}),O.push($e),ne("Continuation: Added reasoning to messageParts",{reasoningLength:F.length,hasSignature:!!se,messagePartsCount:O.length})}F="",se="",g(T);break;case"text-delta":R.delta&&(T+=R.delta,A+=R.delta,g(T));break;case"tool-call":case"tool-input-available":if(R.toolCallId&&R.toolName){let $e=_t(R.args??R.input);O.push({type:R.type,toolCallId:R.toolCallId,toolName:R.toolName,args:$e})}if(a&&R.toolCallId&&R.toolName&&Be(R.toolName)){let $e=_t(R.args??R.input);z.push({toolCallId:R.toolCallId,toolName:R.toolName,args:$e}),ne("Continuation: Added to pendingClientTools",{pendingCount:z.length})}break;case"finish":ne("Continuation finish event",R);break}}catch{}}if(A){let p=O.findIndex(w=>w.type!=="reasoning"),S=p===-1?O.length:p;O.splice(S,0,{type:"text",text:A})}ne("=== Continuation stream processing complete ===",{pendingClientToolsCount:z.length,messagePartsCount:O.length,fullResponseLength:T.length})}if(a&&b&&b.length>0){let I=[];for(let v of le)I.push({type:String(v.type),title:String(v.toolName).replace(/__/g," "),input:v.input,output:v.output,state:v.isError?"error":"output-available"});for(let v of O)v.type==="text"&&v.text&&I.push({type:"text",text:v.text});let B=Ke(I,m);ne("=== Using formatted parts for local tools ===",{executedToolsCount:le.length,textPartsCount:O.filter(v=>v.type==="text").length,contentLength:B.length}),h(v=>[...v,{role:"assistant",content:B,parts:I}])}else{ne("=== Fetching message from API ===",{fullResponseLength:T.length,fullResponsePreview:T.slice(0,200)});try{let{messages:I}=await f.getMessages(q,M,e,10);ne("=== API messages received ===",{count:I.length,roles:I.map(v=>v.role)});let B=I.find(v=>v.role==="assistant");if(B){let v=B.parts,G=Ke(v,m);ne("=== Setting message from API ===",{partsCount:v.length,partTypes:v.map(p=>p.type),contentLength:G.length,contentPreview:G.slice(0,200)}),h(p=>[...p,{role:"assistant",content:G,parts:v}])}else ne("=== No assistant message found, using fallback ==="),h(v=>[...v,{role:"assistant",content:T}])}catch(I){ne("=== API fetch failed, using fallback ===",{error:I instanceof Error?I.message:String(I)}),h(B=>[...B,{role:"assistant",content:T}])}}ne("=== Message handling complete ==="),g(""),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(i&&(clearInterval(i),i=null),ce)try{ce.releaseLock()}catch{}}},[t,e,n,s,l,a,b,k,m,h,y,g,j,$,P,Q])}}import{useState as Xo}from"react";var Xn=new Map([["sandbox","Sandbox"],["web_search","Web Search"],["image_generation","Image Generation"],["chart","Chart"],["file_system","FileSystem"]]);function Qn(e){let[t,n]=Xo(e);return{fileSystem:t,setFileSystem:n,capabilityLabelMap:Xn}}import{useEffect as Qo,useState as Zo}from"react";function Zn(e,t){let[n,s]=Zo(null);return Qo(()=>{let l=!1;async function a(){if(!e||!t){s(null);return}try{let h=await new me().getAgent(t.accessToken,t.workspaceId,e);l||s(h)}catch{l||s(null)}}return a(),()=>{l=!0}},[e,t]),{currentAgentDetails:n}}import{useState as en}from"react";function eo(e,t,n){let[s,l]=en(e),[a,m]=en(t),[h,y]=en(n);return{currentModel:s,setCurrentModel:l,currentAgentId:a,setCurrentAgentId:m,activeConnectorIds:h,setActiveConnectorIds:y}}import{useApp as ts,useInput as ns}from"ink";import{useCallback as je,useRef as os,useState as be}from"react";import{spawn as es}from"child_process";function to(e){return new Promise((t,n)=>{let s,l;process.platform==="darwin"?(s="open",l=[e]):process.platform==="win32"?(s="cmd",l=["/c","start","",e]):(s="xdg-open",l=[e]);let a=es(s,l,{stdio:"ignore",detached:!0});a.once("error",m=>{n(m)}),a.once("spawn",()=>{a.unref(),t()})})}var no=[{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 oo(e){if(!e.startsWith("/"))return[];let t=e.slice(1).toLowerCase();return t?no.filter(n=>n.name.startsWith(t)||n.aliases.some(s=>s.startsWith(t))):no}function so(e){let t=e.trim();if(!t.startsWith("/"))return null;let n=t.slice(1).split(/\s+/),s=n[0]?.toLowerCase(),l=n.slice(1).join(" ");switch(s){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:l||void 0};case"agent":case"a":return{type:"agent",value:l||void 0};case"skills":case"sk":return{type:"skills",value:l||void 0};case"schedules":case"sch":return{type:"schedules",value:l||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:l||void 0};case"budget":case"bg":return{type:"budget",value:l||void 0};case"usage":case"u":return{type:"usage"};case"status":case"s":return{type:"status"};case"profile":case"p":return{type:"profile",value:l||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 ro=`Available commands:
|
|
93
|
-
/help, /h, /? Show this help message
|
|
94
|
-
/clear, /cls, /new Start a new task
|
|
95
|
-
/model [name], /m Show current model or switch to [name]
|
|
96
|
-
/agent [name], /a Show current agent or switch to [name]
|
|
97
|
-
/skills [name], /sk List skills or show details for [name]
|
|
98
|
-
/schedules [id], /sch List schedules or show details for [id]
|
|
99
|
-
/connectors, /conn Select active connectors
|
|
100
|
-
/capabilities, /cap Toggle client capabilities (FileSystem)
|
|
101
|
-
/tasks, /c Switch to another task
|
|
102
|
-
/workspace [id], /ws List or switch workspace
|
|
103
|
-
/budget [amount], /bg View or set workspace budget
|
|
104
|
-
/usage, /u View current month usage (top 10 by cost)
|
|
105
|
-
/status, /s Show current session status
|
|
106
|
-
/profile [args], /p Manage profiles (list/show/use/create/delete/rename/clone)
|
|
107
|
-
/open-in-browser Open current task in browser
|
|
108
|
-
/share Get share link for current task
|
|
109
|
-
/delete, /del Delete current task
|
|
110
|
-
/quit, /exit, /q Exit interactive mode
|
|
111
|
-
|
|
112
|
-
Note: For detailed usage with sorting/limits, use: entrydesk usage --help
|
|
113
|
-
|
|
114
|
-
Keyboard shortcuts:
|
|
115
|
-
Ctrl+O Toggle full output mode
|
|
116
|
-
Ctrl+C Exit`;function tn(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 io({input:e,setInput:t,taskId:n,setTaskId:s,currentTaskTitle:l,setCurrentTaskTitle:a,currentModel:m,setCurrentModel:h,currentAgentId:y,setCurrentAgentId:g,currentAgentDetails:j,setCurrentAgentDetails:$,activeConnectorIds:P,setActiveConnectorIds:Q,fileSystem:b,setFileSystem:k,availableModels:E,availableAgents:N,availableConnectors:V,messages:Z,hasPersistedTask:q,setHasPersistedTask:M,setMessages:ce,addSystemMessage:i,startNewTask:f,sendMessage:_,setFullOutput:W,credentials:C,setCredentials:pe,setState:te,defaultCapabilities:T,capabilityLabelMap:F,hasUploadingFiles:oe=!1}){let{exit:se}=ts(),[A,Y]=be([]),[K,z]=be(0),[O,le]=be(!1),[L,I]=be(null),[B,v]=be([]),[G,p]=be(0),[S,w]=be(new Set),[ie,R]=be(new Set),[$e,mt]=be([]),[Ee,Lt]=be([]),[Se,ot]=be([]),[Le,gt]=be([]),[Ne,Me]=be(null),[Ft,st]=be(""),ze=os(!1),[Fe,xe]=be(!1),Xe=je(async()=>{if(!C)return[];let x=new me,d=[],o;do{let r=await x.listAvailableSkills(C.accessToken,C.workspaceId,{limit:100,nextKey:o});d.push(...r.skills),o=r.nextKey}while(o);return Lt(d),d},[C]),Qe=je(async()=>{if(!C)return[];let x=new me,d=[],o;do{let r=await x.getSchedules(C.accessToken,C.workspaceId,{limit:100,nextKey:o});d.push(...r.schedules),o=r.nextKey}while(o);return ot(d),d},[C]),ke=je(async x=>{if(x==="model"){if(E.length===0){i("No models available.");return}let d=E.map(r=>({id:r.id,name:r.name,description:r.description}));v(d);let o=m?d.findIndex(r=>r.id===m):-1;p(Math.max(o,0)),I("model")}else if(x==="agent"){if(N.length===0){i("No agents available.");return}let d=N.map(r=>({id:r.id,name:r.name,description:r.description}));v(d);let o=y?d.findIndex(r=>r.id===y):-1;p(Math.max(o,0)),I("agent")}else if(x==="skills"){let d=Ee;if(d.length===0)try{d=await Xe()}catch{i("Failed to load skills.");return}if(d.length===0){i("No skills available.");return}let o=d.map(r=>({id:r.id,name:r.name,description:r.description}));v(o),p(0),I("skills")}else if(x==="schedules"){let d=Se;if(d.length===0)try{d=await Qe()}catch{i("Failed to load schedules.");return}if(d.length===0){i("No schedules found.");return}let o=d.map(r=>({id:r.id,name:r.name,description:`${r.agent.name} - ${r.isActive?"Active":"Paused"}`}));v(o),p(0),I("schedules")}else if(x==="connectors"){if(V.length===0){i("No connectors available.");return}let d=V.map(o=>({id:o.id,name:o.name}));v(d),p(0),w(new Set(P??[])),I("connectors")}else if(x==="capabilities"){v([{id:"fileSystem",name:"FileSystem",description:"Local file operations"}]),p(0);let o=new Set;b&&o.add("fileSystem"),R(o),I("capabilities")}else if(x==="tasks"){if(!C){i("Not authenticated.");return}try{let d=new me,{tasks:o}=await d.getTasks(C.accessToken,C.workspaceId,20);if(o.length===0){i("No tasks available.");return}mt(o);let r=o.map(c=>({id:c.id,name:c.title||"Untitled",description:new Date(c.createdAt).toLocaleDateString()}));v(r);let u=r.findIndex(c=>c.id===n);p(Math.max(u,0)),I("tasks")}catch{i("Failed to load tasks.")}}else if(x==="profile"){let d=ae.getProfileNames(),o=ae.getCurrentProfileName(),r=d.map(c=>({id:c,name:c,description:c===o?"(current)":void 0}));v(r);let u=r.findIndex(c=>c.id===o);p(Math.max(u,0)),I("profile")}le(!1),Y([])},[E,N,Ee,Se,V,P,m,y,b,Xe,Qe,C,n,i]),Pe=je(x=>{let d=fe.getAll(x);h(d.model?.default),g(void 0),$(null);let o=d.connectors?.defaults;Q(o&&o.length>0?o:void 0);let r=d.localTools;k(r?.fileSystem??T.fileSystem)},[h,g,$,Q,k,T]),Ae=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 i(ro),!0;case"clear":return f("Started a new task."),!0;case"model":{if(x.value){let d=x.value.toLowerCase(),o=E.find(r=>r.id.toLowerCase()===d||r.name.toLowerCase().includes(d));if(o)y?f(`Switched to model: ${o.name} (new task)`):i(`Switched to model: ${o.name}`),h(o.id),g(void 0),$(null),fe.setDefaultModel(o.id);else{let r=E.map(u=>u.name).join(", ");i(`Model "${x.value}" not found.
|
|
117
|
-
Available: ${r||"none"}`)}}else{let d=E.find(o=>o.id===m)?.name||m;i(m?`Current model: ${d}`:"No model selected. Using agent mode.")}return!0}case"agent":{if(!x.value)return N.length===0?(i("No agents available."),!0):(ke("agent"),!0);let d=x.value.toLowerCase(),o=N.find(r=>r.id.toLowerCase()===d||r.name.toLowerCase().includes(d));if(o)o.id!==y?f(`Switched to agent: ${o.name} (new task)`):i(`Switched to agent: ${o.name}`),g(o.id),h(void 0);else{let r=N.map(u=>u.name).join(", ");i(`Agent "${x.value}" not found.
|
|
118
|
-
Available: ${r||"none"}`)}return!0}case"skills":{if(!x.value)return ke("skills"),!0;let d=x.value.toLowerCase();return(Ee.length>0?Promise.resolve(Ee):Xe().catch(()=>[])).then(r=>{let u=r.find(c=>c.id.toLowerCase()===d||c.name.toLowerCase().includes(d));i(u?`Skill: ${u.name}
|
|
119
|
-
${u.description}
|
|
120
|
-
Provider: ${u.provider}
|
|
121
|
-
Author: ${u.author.name}
|
|
122
|
-
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):Qe().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():"-";i(`Schedule: ${u.name}
|
|
123
|
-
Agent: ${u.agent.name}
|
|
124
|
-
Status: ${u.isActive?"Active":"Paused"}
|
|
125
|
-
Repeat: ${tn(u.config)}
|
|
126
|
-
Next Run: ${c}
|
|
127
|
-
ID: ${u.id}`)}else i(`Schedule "${x.value}" not found.`)}),!0}case"connectors":{if(y){let o=j?.connectors??[];if(o.length===0)i("No agent connectors.");else{let r=o.map(u=>` - ${u.name}`).join(`
|
|
128
|
-
`);i(`Agent connectors:
|
|
129
|
-
${r}`)}return!0}let d=V.filter(o=>P?.includes(o.id));if(d.length===0)i("No active connectors.");else{let o=d.map(r=>` - ${r.name}`).join(`
|
|
130
|
-
`);i(`Active connectors:
|
|
131
|
-
${o}`)}return!0}case"capabilities":{if(y){let r=(j?.capabilities??[]).map(u=>F.get(u)??u);return i(r.length>0?`Agent capabilities:
|
|
132
|
-
${r.map(u=>` - ${u}`).join(`
|
|
133
|
-
`)}`:"No agent capabilities."),!0}let d=[];return b&&d.push("FileSystem"),i(d.length>0?`Active capabilities:
|
|
134
|
-
${d.map(o=>` - ${o}`).join(`
|
|
135
|
-
`)}`:"No capabilities enabled."),!0}case"tasks":return i(l?`Current task: ${l}`:`Current task: ${n.slice(0,8)}...`),!0;case"workspace":{if(!C)return i("Not authenticated."),!0;let d=new me;if(!x.value){try{let{workspaces:r}=await d.getWorkspaces(C.accessToken);if(r.length===0)i("No workspaces found.");else{let u=r.map(c=>` ${c.id===C.workspaceId?"* ":" "}${c.name}
|
|
136
|
-
ID: ${c.id}`);i(`Workspaces:
|
|
137
|
-
${u.join(`
|
|
138
|
-
`)}`)}}catch(r){i(`Failed to load workspaces: ${r instanceof Error?r.message:"Unknown error"}`)}return!0}let o=x.value;try{let{workspaces:r}=await d.getWorkspaces(C.accessToken),u=r.find(c=>c.id===o);if(!u)return i(`Workspace not found: ${o}`),!0;await rt.saveWorkspaceId(o),i(`Switched to workspace: ${u.name}`),i("Please restart the task to apply changes.")}catch(r){i(`Failed to switch workspace: ${r instanceof Error?r.message:"Unknown error"}`)}return!0}case"budget":{if(!C)return i("Not authenticated."),!0;let d=new me;if(!x.value){try{let u=await d.getBudget(C.accessToken,C.workspaceId);u.budget===null?i("No budget set for this workspace."):i(`Current budget: $${u.budget}`)}catch(u){i(`Failed to get budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}let o=x.value.toLowerCase();if(o==="clear"||o==="null"){try{await d.updateBudget(C.accessToken,C.workspaceId,null),i("Budget cleared.")}catch(u){i(`Failed to clear budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}let r=parseFloat(o);if(isNaN(r)||r<0)return i("Invalid budget amount. Must be a positive number."),!0;try{await d.updateBudget(C.accessToken,C.workspaceId,o),i(`Budget set to: $${o}`)}catch(u){i(`Failed to set budget: ${u instanceof Error?u.message:"Unknown error"}`)}return!0}case"usage":{if(!C)return i("Not authenticated."),!0;let d=new me;try{let o=[],r,u=0,c=10;do{let ge=await d.getMonthlyUsages(C.accessToken,C.workspaceId,{nextKey:r,limit:20});if(o.push(...ge.monthlyUsages),r=ge.nextKey,u++,u>=c){i(`Warning: Showing first ${o.length} entries (pagination limit reached)`);break}}while(r);if(o.length===0)return i("No usage data found for this workspace."),!0;let D=0,ee=0;for(let ge of o)D+=parseFloat(ge.totalCost),ee+=ge.operationCount;let Te=[...o].toSorted((ge,qe)=>parseFloat(qe.totalCost)-parseFloat(ge.totalCost)),H=10,de=Te.slice(0,H),Ce=[`Total Cost: $${D.toFixed(2)}`,`Total Operations: ${ee.toLocaleString()}`,`Users: ${o.length}`,"",`Top ${de.length} Users by Cost:`,...de.map(ge=>` ${ge.user.name}: $${parseFloat(ge.totalCost).toFixed(2)} (${ge.operationCount.toLocaleString()} ops)`)];o.length>H&&(Ce.push("",`... and ${o.length-H} more users`),Ce.push("Use CLI command for full list: entrydesk usage --limit <n> --sort-by <cost|operations>")),i(Ce.join(`
|
|
139
|
-
`))}catch(o){i(`Failed to get usage: ${o instanceof Error?o.message:"Unknown error"}`)}return!0}case"status":{let d=ae.getCurrentProfileName(),o=m?E.find(D=>D.id===m)?.name||m:null,r=y?N.find(D=>D.id===y)?.name||y:null,u=P?V.filter(D=>P.includes(D.id)).map(D=>D.name):[],c=[];return b&&c.push("FileSystem"),rt.getEmail().then(D=>{let ee=[`Profile: ${d}${d!=="default"?" (non-default)":""}`,D?`Logged in as: ${D}`:"Not logged in",C?.workspaceId?`Workspace: ${C.workspaceId}`:null,q?`Task ID: ${n}`:null,o?`Model: ${o}`:null,r?`Agent: ${r}`:null,`Connectors: ${u.length>0?u.join(", "):"none"}`,`Capabilities: ${c.length>0?c.join(", "):"none"}`].filter(Boolean);i(ee.join(`
|
|
140
|
-
`))}).catch(()=>{let D=[`Profile: ${d}`,"Not logged in",q?`Task ID: ${n}`:null,o?`Model: ${o}`:null,r?`Agent: ${r}`:null,`Connectors: ${u.length>0?u.join(", "):"none"}`,`Capabilities: ${c.length>0?c.join(", "):"none"}`].filter(Boolean);i(D.join(`
|
|
141
|
-
`))}),!0}case"profile":{let d=x.value?x.value.split(/\s+/).filter(Boolean):[];if(d.length===0)return ke("profile"),!0;let o=d[0]?.toLowerCase()||"list",r=d[1],u=d[2],c=ae.getProfileNames(),D=ae.getCurrentProfileName(),ee=ae.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(o==="list"){let H=[`Profiles (${c.length}):`];for(let de of c){let Ce=de===D?" (current)":"";H.push(` ${de}${Ce}`)}return i(H.join(`
|
|
142
|
-
`)),!0}if(o==="current")return i(`Current profile: ${D}`),!0;if(o==="show"){let H=Te(r,!0),de=fe.getAll(H),Ce=await rt.getAll(H),ge=!!Ce?.accessToken,qe=de.connectors?.defaults&&de.connectors.defaults.length>0?de.connectors.defaults.join(", "):"unset",go=[`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: ${Ce?.email??"unknown"}`:"Not logged in",ge&&Ce?.workspaceId?`Workspace ID: ${Ce.workspaceId}`:null].filter(Boolean);return i(go.join(`
|
|
143
|
-
`)),!0}if(o==="create"){let H=r||ae.DEFAULT_PROFILE;return ae.createProfile(H),i(`Profile created: ${H}`),!0}if(o==="use"||o==="switch"){let H=Te(r,!0);return ae.setOverrideProfile(H),ae.setCurrentProfile(H),Pe(H),await Ae(),f(`Switched to profile: ${H} (new task)`),!0}if(o==="delete"||o==="remove"||o==="rm"){let H=Te(r,!0),de=H===D,Ce=ae.deleteProfile(H),ge=`Profile deleted: ${H}`;if(de)ae.setOverrideProfile(Ce.currentProfile),Pe(Ce.currentProfile),await Ae(),f(`${ge}
|
|
144
|
-
Switched to profile: ${Ce.currentProfile} (new task)`);else if(ee===H){let qe=ae.getCurrentProfileName();ae.setOverrideProfile(qe),Pe(qe),await Ae(),f(`${ge}
|
|
145
|
-
Switched to profile: ${qe} (new task)`)}else i(ge);return!0}if(o==="rename"||o==="move"||o==="mv"){let H=Te(r,!0);if(!u)throw new Error("New profile name is required.");let de=ae.renameProfile(H,u);return i(`Profile renamed: ${H} -> ${u}`),ee===H?(ae.setOverrideProfile(u),Pe(u)):de.currentProfile===u&&Pe(u),!0}if(o==="clone"||o==="copy"){let H=Te(r,!0);if(!u)throw new Error("Target profile name is required.");let de=fe.getAll(H);return ae.createProfile(u),fe.setAll(de,u),await rt.clear(u),i(`Profile cloned: ${H} -> ${u}`),!0}i(`Unknown profile command: ${o}`)}catch(H){let de=H instanceof Error?H.message:"Unknown error";i(`Profile error: ${de}`)}return!0}case"open-in-browser":{let d=Bt().hubUrl.replace(/\/$/,""),o=q||Z.some(ee=>ee.role!=="system"),r=C?`/${C.workspaceId}`:"",u=o?`${r}/task/${n}`:`${r}/task/new`,c=y?`?agentId=${encodeURIComponent(y)}`:"",D=`${d}${u}${c}`;try{await to(D),i(`Opened in browser: ${D}`)}catch(ee){i(`Failed to open browser: ${ee instanceof Error?ee.message:"Unknown error"}
|
|
146
|
-
URL: ${D}`)}return!0}case"share":{if(!C)return i("Not authenticated."),!0;if(!(q||Z.some(o=>o.role!=="system")))return i("No conversation to share. Start a task first."),!0;try{let r=await new me().createTaskShare(C.accessToken,C.workspaceId,n,"public"),c=`${Bt().hubUrl.replace(/\/$/,"")}/share/${r.id}`;i(`Share link: ${c}`)}catch(o){i(`Failed to create share link: ${o instanceof Error?o.message:"Unknown error"}`)}return!0}case"delete":return C?q?(xe(!0),i("Delete this task? (y/N)"),!0):(i("No task to delete."),!0):(i("Not authenticated."),!0);case"quit":return se(),!0;case"unknown":return i(`Unknown command: ${x.input}
|
|
147
|
-
Type /help for available commands.`),!0;default:return!1}},[i,E,N,V,Ee,Se,m,y,P,b,n,l,se,ke,f,F,j,q,Z,Xe,Qe,ce,h,g,$,h,Pe,Ae]),ht=je(x=>{if(ze.current=!1,Fe){(x===""||x.startsWith("/"))&&(t(x),x.startsWith("/")&&xe(!1));return}if(t(x),st(x),Ne!==null&&Me(null),L&&(I(null),v([])),x.startsWith("/")&&!x.includes(" ")){let d=oo(x);Y(d),z(0),le(d.length>0)}else le(!1),Y([])},[L,Ne,Fe,t]),Ze=je((x,d=!1)=>{if(x>=0&&x<A.length){let o=A[x];le(!1),Y([]),o.name==="model"?(t("/model "),ke("model")):o.name==="agent"?(t("/agent "),ke("agent")):o.name==="skills"?(t("/skills "),ke("skills")):o.name==="schedules"?(t("/schedules "),ke("schedules")):o.name==="connectors"?(t("/connectors "),ke("connectors")):o.name==="capabilities"?(t("/capabilities "),ke("capabilities")):o.name==="tasks"?(t("/tasks "),ke("tasks")):o.name==="profile"?(t("/profile "),ke("profile")):d?(t(""),He({type:o.name})):t(`/${o.name}`)}},[A,ke,t,He]),Ot=je(async x=>{ze.current=!1;let d=x.trim();if(!d||Fe)return;if(L==="model"&&B.length>0){let r=B[G];r&&(y?f(`Switched to model: ${r.name} (new task)`):i(`Switched to model: ${r.name}`),h(r.id),g(void 0),$(null)),I(null),v([]),t("");return}if(L==="agent"&&B.length>0){let r=B[G];r&&(r.id!==y?f(`Switched to agent: ${r.name} (new task)`):i(`Switched to agent: ${r.name}`),g(r.id),h(void 0)),I(null),v([]),t("");return}if(L==="skills"&&B.length>0){let r=B[G];if(r){let u=Ee.find(c=>c.id===r.id);u&&i(`Skill: ${u.name}
|
|
148
|
-
${u.description}
|
|
149
|
-
Provider: ${u.provider}
|
|
150
|
-
Author: ${u.author.name}
|
|
151
|
-
ID: ${u.id}`)}I(null),v([]),t("");return}if(L==="schedules"&&B.length>0){let r=B[G];if(r){let u=Se.find(c=>c.id===r.id);if(u){let c=u.nextRunAt?new Date(u.nextRunAt).toLocaleString():"-";i(`Schedule: ${u.name}
|
|
152
|
-
Agent: ${u.agent.name}
|
|
153
|
-
Status: ${u.isActive?"Active":"Paused"}
|
|
154
|
-
Repeat: ${tn(u.config)}
|
|
155
|
-
Next Run: ${c}
|
|
156
|
-
ID: ${u.id}`)}}I(null),v([]),t("");return}if(L==="connectors"){let r=Array.from(S);Q(r.length>0?r:void 0),fe.setDefaultConnectorIds(r);let u=V.filter(c=>S.has(c.id)).map(c=>c.name);i(u.length>0?`Active connectors: ${u.join(", ")}`:"All connectors disabled."),I(null),v([]),t("");return}if(L==="capabilities"){let r=ie.has("fileSystem");k(r),fe.setLocalTools({fileSystem:r});let u=[];r&&u.push("FileSystem"),i(u.length>0?`Active capabilities: ${u.join(", ")}`:"All capabilities disabled."),I(null),v([]),t("");return}if(L==="profile"&&B.length>0){let r=B[G];if(r){let u=ae.getCurrentProfileName();r.id!==u?(ae.setOverrideProfile(r.id),ae.setCurrentProfile(r.id),Pe(r.id),Ae(),f(`Switched to profile: ${r.name}`)):i(`Already using profile: ${r.name}`)}I(null),v([]),t("");return}if(O&&A.length>0){Ze(K,!0);return}Me(null),st(""),gt(r=>r.length>0&&r.at(-1)===d?r:[...r,d]);let o=so(d);if(o){await He(o),t(""),le(!1);return}if(oe){i("Please wait for file uploads to complete.");return}t(""),le(!1),_(d)},[_,He,O,A,K,Ze,L,B,G,S,ie,V,Ee,Se,i,t,y,f,h,g,$,Q,k,oe,Pe,Ae,Fe,C,q,n]);return ns((x,d)=>{if(d.ctrl&&x==="c"){if(e.length>0){ht(""),ze.current=!0,i("Press Ctrl+C again to exit.");return}if(ze.current){se();return}se();return}if(d.ctrl&&x==="o"){W(o=>!o);return}if(Fe){if(d.escape||d.return||x==="n"||x==="N"){xe(!1),t(""),i("Task deletion cancelled.");return}if(x==="y"||x==="Y"){xe(!1),t(""),C&&q&&new me().deleteTask(C.accessToken,C.workspaceId,n).then(()=>{f("Task deleted. Started a new task.")}).catch(r=>{i(`Failed to delete task: ${r.message||"Unknown error"}`)});return}return}if(L&&B.length>0){if(d.upArrow){p(o=>o<=0?B.length-1:o-1);return}if(d.downArrow){p(o=>o>=B.length-1?0:o+1);return}if(d.escape){I(null),v([]),t("");return}if(d.return){if(L==="model"){let o=B[G];o&&(y?f(`Switched to model: ${o.name} (new task)`):i(`Switched to model: ${o.name}`),h(o.id),g(void 0),$(null),fe.setDefaultModel(o.id))}else if(L==="agent"){let o=B[G];o&&(o.id!==y?f(`Switched to agent: ${o.name} (new task)`):i(`Switched to agent: ${o.name}`),g(o.id),h(void 0))}else if(L==="skills"){let o=B[G];if(o){let r=Ee.find(u=>u.id===o.id);r&&i(`Skill: ${r.name}
|
|
157
|
-
${r.description}
|
|
158
|
-
Provider: ${r.provider}
|
|
159
|
-
Author: ${r.author.name}
|
|
160
|
-
ID: ${r.id}`)}}else if(L==="schedules"){let o=B[G];if(o){let r=Se.find(u=>u.id===o.id);if(r){let u=r.nextRunAt?new Date(r.nextRunAt).toLocaleString():"-";i(`Schedule: ${r.name}
|
|
161
|
-
Agent: ${r.agent.name}
|
|
162
|
-
Status: ${r.isActive?"Active":"Paused"}
|
|
163
|
-
Repeat: ${tn(r.config)}
|
|
164
|
-
Next Run: ${u}
|
|
165
|
-
ID: ${r.id}`)}}}else if(L==="connectors"){let o=Array.from(S);Q(o.length>0?o:void 0),fe.setDefaultConnectorIds(o);let r=V.filter(u=>S.has(u.id)).map(u=>u.name);i(r.length>0?`Active connectors: ${r.join(", ")}`:"All connectors disabled.")}else if(L==="capabilities"){let o=ie.has("fileSystem");k(o),fe.setLocalTools({fileSystem:o});let r=[];o&&r.push("FileSystem"),i(r.length>0?`Active capabilities: ${r.join(", ")}`:"All capabilities disabled.")}else if(L==="tasks"){let o=B[G];if(o){let r=$e.find(u=>u.id===o.id);r&&C&&(s(r.id),a(r.title||void 0),M(!0),new me().getMessages(C.accessToken,C.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();ce(D),i(`Switched to: ${r.title||"Untitled"}`)}).catch(()=>{i("Failed to load task messages.")}))}}else if(L==="profile"){let o=B[G];if(o){let r=ae.getCurrentProfileName();o.id!==r?(ae.setOverrideProfile(o.id),ae.setCurrentProfile(o.id),Pe(o.id),Ae(),f(`Switched to profile: ${o.name}`)):i(`Already using profile: ${o.name}`)}}I(null),v([]),t("");return}if(x===" "&&(L==="connectors"||L==="capabilities")){let o=B[G];o&&(L==="connectors"?w:R)(u=>{let c=new Set(u);return c.has(o.id)?c.delete(o.id):c.add(o.id),c});return}if(x==="a"&&(L==="connectors"||L==="capabilities")){(L==="connectors"?w:R)(new Set(B.map(r=>r.id)));return}if(x==="n"&&(L==="connectors"||L==="capabilities")){(L==="connectors"?w:R)(new Set);return}return}if(O&&A.length>0){if(d.upArrow){z(o=>o<=0?A.length-1:o-1);return}if(d.downArrow){z(o=>o>=A.length-1?0:o+1);return}if(d.escape){le(!1),Y([]);return}if(d.tab){Ze(K);return}}if(d.upArrow){if(e.includes(`
|
|
166
|
-
`)||Le.length===0)return;if(Ne===null){st(e);let r=Le.length-1;Me(r),t(Le[r]);return}let o=Math.max(0,Ne-1);Me(o),t(Le[o]);return}if(d.downArrow){if(e.includes(`
|
|
167
|
-
`)||Ne===null)return;if(Ne>=Le.length-1){Me(null),t(Ft);return}let o=Ne+1;Me(o),t(Le[o])}}),{suggestions:A,suggestionIndex:K,showSuggestions:O,argMode:L,argItems:B,argIndex:G,selectedConnectorIds:S,selectedCapabilities:ie,deleteConfirmMode:Fe,handleInputChange:ht,handleSubmit:Ot}}import{useCallback as pt,useRef as ss,useState as rs}from"react";function lo({credentials:e,currentModel:t,modelProviders:n,onUploadSuccess:s,onUploadError:l}){let[a,m]=rs([]),h=ss(0),y=pt(k=>{if(!(!Array.isArray(n)||n.length===0)){for(let E of n)if(E.models.some(V=>V.id===k))return E.id;return n[0]?.id}},[n]),g=pt(async k=>{if(!e){l?.(k.filename,"Not logged in");return}if(!Array.isArray(n)||n.length===0){l?.(k.filename,"Model providers not loaded yet. Please wait and try again.");return}let E=t?y(t):n[0]?.id;if(!E){l?.(k.filename,"No model provider available");return}let N=`file-${++h.current}`;m(V=>[...V,{id:N,filename:k.filename,mimeType:k.mimeType,status:"uploading"}]);try{let Z=await new me().uploadFile(e.accessToken,e.workspaceId,k,E);m(q=>q.map(M=>M.id===N?{...M,status:"uploaded",fileId:Z.id}:M)),s?.(k.filename)}catch(V){let Z=V instanceof Error?V.message:"Upload failed";m(q=>q.map(M=>M.id===N?{...M,status:"error",error:Z}:M)),l?.(k.filename,Z)}},[e,t,y,n,s,l]),j=pt(k=>{m(E=>E.filter(N=>N.id!==k))},[]),$=pt(()=>{m([])},[]),P=pt(()=>a.filter(k=>k.status==="uploaded"&&k.fileId).map(k=>k.fileId),[a]),Q=a.some(k=>k.status==="uploading"),b=a.length>0;return{pendingFiles:a,addFile:g,removeFile:j,clearFiles:$,getUploadedFileIds:P,hasUploadingFiles:Q,hasFiles:b}}import{jsx as J,jsxs as re}from"react/jsx-runtime";var ls=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],as=[Zt,Zt,Qt,Qt,Ye,Ye,Ye,Ye],ao=ls.map((e,t)=>`${as[t]??Ye}${e}${X}`).join(`
|
|
168
|
-
`),cs=`${Ye}EntryDesk${X}`,us=500;function ds(e){let t="",n=0;for(;n<e.length;){if(e.charCodeAt(n)===27&&e[n+1]==="["){for(n+=2;n<e.length;){let s=e.charCodeAt(n);if(s>=64&&s<=126){n+=1;break}n+=1}continue}t+=e[n],n+=1}return t}function fs(e){let t=ds(e);return Math.max(...t.split(`
|
|
169
|
-
`).map(n=>n.length))}function ps(e){let t=fs(ao);return e>=t?ao:cs}function co({agentId:e,model:t,message:n,taskId:s,taskTitle:l,connectorIds:a,enableFileSystem:m=!0}){let h=process.stdout.columns??80,y=ps(h),g=rn(null),j=Hn(s,l),{state:$,setState:P,messages:Q,setMessages:b,input:k,setInput:E,taskId:N,setTaskId:V,currentTaskTitle:Z,setCurrentTaskTitle:q,hasPersistedTask:M,setHasPersistedTask:ce,credentials:i,setCredentials:f,currentResponse:_,setCurrentResponse:W,fullOutput:C,setFullOutput:pe,addSystemMessage:te,startNewTask:T}=j,{credentials:F}=Jn(P);Et(()=>{F&&!i&&f(F)},[F,i,f]);let{availableConnectors:oe,availableModels:se,availableAgents:A,modelProviders:Y,loading:K}=Yn(i),{currentModel:z,setCurrentModel:O,currentAgentId:le,setCurrentAgentId:L,activeConnectorIds:I,setActiveConnectorIds:B}=eo(t,e,a),v=rn(!1);Et(()=>{if(!v.current){if(v.current=!0,!t&&!e){let c=fe.getDefaultModel();c&&O(c)}if(!a&&!e){let c=fe.getDefaultConnectorIds();c&&B(c.length>0?c:void 0)}}},[t,e,a,O,B]);let{currentAgentDetails:G}=Zn(le,i),{fileSystem:p,setFileSystem:S,capabilityLabelMap:w}=Qn(m),{pendingFiles:ie,addFile:R,removeFile:$e,clearFiles:mt,getUploadedFileIds:Ee,hasUploadingFiles:Lt,hasFiles:Se}=lo({credentials:i,currentModel:z,modelProviders:Y,onUploadSuccess:c=>{te(`\u2713 Attached: ${c}`)},onUploadError:(c,D)=>{te(`\u2717 Failed to upload ${c}: ${D}`)}}),{sendMessage:ot}=zn({taskId:N,credentials:i,currentAgentId:le,currentModel:z,activeConnectorIds:I,localTools:p,fullOutput:C,setMessages:b,setState:P,setCurrentResponse:W,setCredentials:f,setHasPersistedTask:ce,getFileIds:Ee,clearFiles:mt}),Le=sn(c=>{T(c),W("")},[T]),[gt,Ne]=is(!1),Me=sn(async c=>{let D=c.text.trim(),ee=St(D);if(/^https?:\/\//.test(ee))return;if(await jn(D)&&Un(ee)){let H=await Mn(D);H&&(c.preventDefault(),await R(H))}},[R]),Ft=sn(async()=>{if(!(gt||$.status!=="ready")){if(K||Y.length===0){te("Please wait for resources to load before pasting images.");return}te("Reading clipboard..."),Ne(!0);try{let c=await Bn();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{Ne(!1)}}},[R,te,gt,$.status,K,Y.length]),{suggestions:st,suggestionIndex:ze,showSuggestions:Fe,argMode:xe,argItems:Xe,argIndex:Qe,selectedConnectorIds:ke,selectedCapabilities:Pe,deleteConfirmMode:Ae,handleInputChange:He,handleSubmit:ht}=io({input:k,setInput:E,taskId:N,setTaskId:V,currentTaskTitle:Z,setCurrentTaskTitle:q,currentModel:z,setCurrentModel:O,currentAgentId:le,setCurrentAgentId:L,currentAgentDetails:G,setCurrentAgentDetails:()=>{},activeConnectorIds:I,setActiveConnectorIds:B,fileSystem:p,setFileSystem:S,availableModels:se,availableAgents:A,availableConnectors:oe,messages:Q,hasPersistedTask:M,setHasPersistedTask:ce,setMessages:b,addSystemMessage:te,startNewTask:Le,sendMessage:ot,setFullOutput:pe,credentials:i,setCredentials:f,setState:P,defaultCapabilities:{fileSystem:m},capabilityLabelMap:w,hasUploadingFiles:Lt});nn((c,D)=>{(D.ctrl||D.meta)&&c==="v"&&Ft()},{isActive:$.status==="ready"&&!xe}),nn((c,D)=>{if(!D.escape)return;let ee=Date.now(),Te=g.current;g.current=ee,!(!Te||ee-Te>us)&&(xe||Fe||(g.current=null,Se&&mt(),k.length>0&&He("")))},{isActive:$.status==="ready"}),nn((c,D)=>{D.return&&(Le("Started a new task."),P({status:"ready"}))},{isActive:$.status==="error"}),Et(()=>{if(i&&!K&&$.status==="loading")if(!z&&!le){let c=fe.getDefaultModel(),D=c&&se.some(Te=>Te.id===c),ee=D?c:se[0]?.id;ee?(D||fe.setDefaultModel(ee),O(ee),P({status:"ready"})):A.length===0?P({status:"no-model"}):P({status:"ready"})}else P({status:"ready"})},[i,K,z,le,se,A,$.status,O,P]);let Ze=rn(!1);if(Et(()=>{Ze.current||n&&i&&$.status==="ready"&&(Ze.current=!0,ot(n))},[i,n,$.status,ot]),$.status==="loading")return re(ye,{flexDirection:"column",children:[J(U,{children:y}),re(ye,{children:[J(U,{color:"cyan",children:J(on,{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"}),s&&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 Ot=le?G?G.connectors&&G.connectors.length>0?G.connectors.map(c=>c.name).join(", "):"none":"loading...":I&&I.length>0?oe.filter(c=>I.includes(c.id)).map(c=>c.name).join(", ")||`${I.length} connector(s)`:"none",x=[];if(le)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=ae.getCurrentProfileName(),o=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.22.0"]}),o&&re(U,{color:"magenta",children:[" [",d,"]"]}),J(U,{dimColor:!0,children:" (type /help for commands)"})]})]}),Q.map((c,D)=>{let ee=c.parts&&C?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(Xt,{text:ee})]},D)}),_&&re(ye,{flexDirection:"column",marginBottom:1,children:[J(U,{bold:!0,color:"blue",children:"Assistant:"}),J(Xt,{text:_})]}),$.status==="ready"&&J(Tn,{suggestions:st,activeIndex:ze,visible:Fe}),$.status==="ready"&&xe&&J(kn,{items:Xe,activeIndex:Qe,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(on,{type:"dots"})}),J(U,{children:" Thinking..."})]}):$.status==="ready"&&!xe?re(ye,{flexDirection:"column",children:[Ae&&J(ye,{marginBottom:1,children:J(U,{color:"yellow",children:"\u26A0\uFE0F Delete this task? (y/N) "})}),Se&&!Ae&&re(ye,{marginBottom:1,flexDirection:"row",gap:1,children:[J(U,{dimColor:!0,children:"Attachments:"}),ie.map((c,D)=>re(U,{children:[c.status==="uploading"?re(U,{color:"yellow",children:[J(on,{type:"dots"})," ",c.filename]}):c.status==="error"?re(U,{color:"red",children:["\u2717 ",c.filename]}):re(U,{color:"green",children:["\u2713 ",c.filename]}),D<ie.length-1&&J(U,{children:", "})]},c.id))]}),re(ye,{children:[J(U,{color:"green",children:"> "}),J(_n,{value:k,onChange:He,onSubmit:ht,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:le?G?.model?.name||"loading...":se.find(c=>c.id===z)?.name||z||"none"})]}),re(U,{children:[J(U,{dimColor:!0,children:"Connectors: "}),J(U,{color:"cyan",children:Ot})]}),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 ",C?"(ON)":"(OFF)"," | Ctrl+C: Exit"]})]})]})}import{jsx as xs}from"react/jsx-runtime";function Ri(){console.log(`
|
|
170
|
-
Usage: entrydesk task [options]
|
|
171
|
-
|
|
172
|
-
Send a message to a model or agent, or start an interactive session.
|
|
173
|
-
|
|
174
|
-
Options:
|
|
175
|
-
-m, --message <text> Message to send (or pipe via stdin)
|
|
176
|
-
--model <modelId> Model to use
|
|
177
|
-
-a, --agent <agentId> Agent to use (instead of --model)
|
|
178
|
-
-c, --continue <n> Continue recent task #n
|
|
179
|
-
-i, --interactive Interactive mode (continuous chat)
|
|
180
|
-
--connectors id1,id2 Use specific connectors
|
|
181
|
-
--plain Plain text output
|
|
182
|
-
--output stream-json Stream events as JSON
|
|
183
|
-
--full-output Show full tool outputs
|
|
184
|
-
--no-file-system Disable local file operations
|
|
185
|
-
--json Output JSON
|
|
186
|
-
|
|
187
|
-
Examples:
|
|
188
|
-
entrydesk task -m "Hello" --model <model>
|
|
189
|
-
entrydesk task -m "Hello" -a <agentId>
|
|
190
|
-
entrydesk task -c 1 -m "Follow up" # Continue recent task
|
|
191
|
-
entrydesk task -i # Interactive mode
|
|
192
|
-
echo "Explain this" | entrydesk task --model <model> # Pipe stdin
|
|
193
|
-
entrydesk task -m "Hi" --model <m> --output stream-json
|
|
194
|
-
`)}async function gs(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").trim()}async function hs(e,t,n,s){if(s<1)return console.error("Task number must be 1 or greater"),null;let{tasks:l}=await e.getTasks(t,n,20);if(l.length===0)return console.error("No tasks found. Start a new task first."),null;if(s>l.length)return console.error(`Task number ${s} not found. You have ${l.length} recent tasks.`),console.error("Use `entrydesk tasks` to see available tasks."),null;let a=l[s-1],m;if(!a.agentId){let{messages:h}=await e.getMessages(t,n,a.id,10);m=h.find(g=>g.role==="assistant"&&g.modelId)?.modelId}return{task:a,modelId:m}}var Ve="\x1B[2m",we="\x1B[0m",ln="\x1B[36m",Rt="\x1B[33m",Nt="\x1B[32m",fo="stream-json";function ys(e,t,n,s){e&&t&&(console.error(`Error: Cannot use both ${n} and ${s}`),process.exit(1))}function At(e,t){let n=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${JSON.stringify(n)}
|
|
195
|
-
`)}function Dt(e,t){if(t)return e;let n=e.split(`
|
|
196
|
-
`);if(n.length<=20)return e;let s=n.slice(0,5),l=n.slice(-5),a=n.length-10;return[...s,`${Ve}... (${a} lines omitted, use --full-output to see all) ...${we}`,...l].join(`
|
|
197
|
-
`)}function ws(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function po(e,t){if(!e)return"(no result)";if(typeof e!="object")return Dt(String(e),t);let n=e;if("structuredContent"in n&&n.structuredContent){let s=n.structuredContent,l=[];if(s.stdout&&typeof s.stdout=="string"&&s.stdout.trim()&&l.push(s.stdout.trim()),s.stderr&&typeof s.stderr=="string"&&s.stderr.trim()&&l.push(`${Rt}[stderr]${we} ${s.stderr.trim()}`),s.urls&&Array.isArray(s.urls)){let a=s.urls;for(let m of a)m.path&&m.url&&l.push(`${m.path}: ${m.url}`)}return l.length===0&&l.push(JSON.stringify(s,null,2)),Dt(l.join(`
|
|
198
|
-
`),t)}if("content"in n&&Array.isArray(n.content)){let l=n.content.filter(a=>a.type==="text"&&a.text).map(a=>a.text).join(`
|
|
199
|
-
`);return Dt(l||JSON.stringify(e,null,2),t)}return Dt(JSON.stringify(e,null,2),t)}function mo(e){try{let n=(typeof e.data=="string"?JSON.parse(e.data):e.data)?.parts;return Array.isArray(n)?n.filter(s=>typeof s=="object"&&s!==null&&s.type==="text"&&typeof s.text=="string").map(s=>s.text).join(""):""}catch{return""}}async function Li(e){let t,n;try{let A=await We();t=A.accessToken,n=A.workspaceId}catch(A){cn(A)}let s=e.output===fo;e.output&&!s&&(console.error(`Invalid --output value. Supported: ${fo}`),process.exit(1));let l=!s&&(e.plain||!process.stdout.isTTY),a=fe.getDefaultModel(),m=e.message;!m&&!process.stdin.isTTY&&(m=await gs());let h=new me,y,g=!1;async function j(){if(g)return y;g=!0;try{({models:y}=await h.listSelectableModels(t,n))}catch{y=void 0}return y}async function $(){let A=await j();if(!A||a&&A.some(K=>K.id===a))return;let Y=A[0]?.id;Y&&(fe.setDefaultModel(Y),a=Y)}let P,Q,b,k;if(e.continue){let A=await hs(h,t,n,e.continue);if(A||process.exit(1),P=A.task.id,Q=A.task.title??void 0,b=A.task.agentId??void 0,k=A.modelId,k&&!b&&!e.model){let K=await j();K&&!K.some(z=>z.id===k)&&(k=void 0)}let Y=e.agentId||e.model||b||k||a;!Y&&!e.interactive&&(await $(),Y=e.agentId||e.model||b||k||a),!Y&&!e.interactive&&(l||console.log(`Continuing task: ${A.task.title||"Untitled"}`),console.error(`
|
|
200
|
-
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)),!l&&!e.interactive&&console.log(`Continuing task: ${A.task.title||"Untitled"}
|
|
201
|
-
`)}let E=e.agentId||b,N=e.model||k||void 0;!E&&!N&&(await $(),N=e.model||k||a||void 0),ys(e.fileSystem,e.noFileSystem,"--file-system","--no-file-system");let V=fe.getDefaultConnectorIds(),Z=e.connectors??V??void 0,q=fe.getLocalTools(),M=e.noFileSystem?!1:e.fileSystem?!0:q?.fileSystem??!0;if(e.interactive){ms(xs(co,{agentId:E,model:N,message:e.message,taskId:P,taskTitle:Q??void 0,connectorIds:Z,enableFileSystem:M}),{exitOnCtrlC:!1});return}let ce=!e.continue&&!N&&!E;(!m||ce)&&(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 i=e.fullOutput??!1,f=e.dangerouslyAutoApproveTools??!1,_=P||uo(),W=M?wt():void 0,C=M?xt():void 0,pe=A=>{let Y={id:_,...f&&{toolApprovalMode:"allow_always"}};return A&&(Y.message=A),E?Y.agentId=E:(N&&(Y.model=N),Y.connectorIds=Z??[]),W&&(Y.clientTools=W),C&&(Y.clientToolSystemPrompt=C),Y},te=async A=>{if(!A.body)throw new Error("No response body");let Y=A.body.getReader(),K=new TextDecoder,z="",O=new Map,le=[],L=!1,I="";for(;;){let{done:B,value:v}=await Y.read();if(B)break;z+=K.decode(v,{stream:!0});let G=z.split(`
|
|
202
|
-
`);z=G.pop()||"";for(let p of G){let S=p.trimEnd();if(S==="data: [DONE]"){s&&At("done");continue}if(S.startsWith("data: "))try{let w=JSON.parse(S.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")&&(L=!0),w.type==="start"&&typeof w.messageId=="string"&&(I=w.messageId),s){w.type==="text-delta"&&w.delta!==void 0?At("text-delta",w.delta):w.type==="reasoning-delta"&&w.delta!==void 0?At("reasoning-delta",w.delta):At(w.type||"event",w);continue}if(l){if(w.type==="text-delta"&&w.delta&&process.stdout.write(w.delta),w.type==="data-appendMessage"&&process.stdout.write(mo(w)),M&&(w.type==="tool-input-available"||w.type==="tool-call")&&w.toolCallId&&w.toolName&&Be(w.toolName)){let ie=w.args||w.input||{};le.push({toolCallId:w.toolCallId,toolName:w.toolName,args:ie})}continue}switch(w.type){case"reasoning-delta":w.delta&&process.stdout.write(`${Ve}${w.delta}${we}`);break;case"reasoning-end":process.stdout.write(`
|
|
203
|
-
|
|
204
|
-
`);break;case"text-delta":w.delta&&process.stdout.write(w.delta);break;case"data-appendMessage":process.stdout.write(mo(w));break;case"tool-call-streaming-start":case"tool-input-start":if(w.toolCallId&&w.toolName){O.set(w.toolCallId,{toolName:w.toolName});let R=M&&Be(w.toolName)?`${Nt}[LOCAL]${we} `:"";console.log(`
|
|
205
|
-
${ln}\u250C\u2500 ${R}Tool Call: ${w.toolName}${we}`)}break;case"tool-call":case"tool-input-available":if(w.toolCallId&&w.toolName){let ie=w.args||w.input||{},R=ws(ie);console.log(`${Rt}\u2502 Arguments:${we}`);for(let $e of R.split(`
|
|
206
|
-
`))console.log(`${Ve}\u2502 ${$e}${we}`);M&&Be(w.toolName)&&(O.set(w.toolCallId,{toolName:w.toolName,args:ie}),le.push({toolCallId:w.toolCallId,toolName:w.toolName,args:ie}))}break;case"tool-result":if(w.toolCallId){let ie=O.get(w.toolCallId),R=po(w.result,i);console.log(`${Nt}\u2502 Result:${we}`);for(let $e of R.split(`
|
|
207
|
-
`))console.log(`${Ve}\u2502 ${$e}${we}`);console.log(`${ln}\u2514\u2500 ${ie?.toolName||"Tool"} completed${we}
|
|
208
|
-
`),O.delete(w.toolCallId)}break;case"error":w.errorText&&console.error(`${Ve}Error: ${w.errorText}${we}`);break}}catch{}}}return{pendingClientTools:le,hadContent:L,messageId:I}},T=pe({id:uo(),createdAt:new Date,role:"user",parts:[{type:"text",text:m}]}),F=await h.task(t,n,T),oe=await te(F),se=oe.hadContent;for(;oe.pendingClientTools.length>0;){let A=oe.messageId,Y=[];for(let z of oe.pendingClientTools){!l&&!s&&console.log(`${Nt}\u2502 Executing locally...${we}`);let O=await kt(z.toolName,z.args);if(Y.push({type:`tool-${z.toolName}`,toolCallId:z.toolCallId,state:"output-available",output:{content:[{type:"text",text:O.success?JSON.stringify(O.result):O.error||"Unknown error"}],isError:!O.success}}),!l&&!s){let le=po(O.success?O.result:{error:O.error},i);console.log(`${Nt}\u2502 Result:${we}`);for(let L of le.split(`
|
|
209
|
-
`))console.log(`${Ve}\u2502 ${L}${we}`);console.log(`${ln}\u2514\u2500 ${z.toolName} completed${we}
|
|
210
|
-
`)}}A||(console.error(`${Rt}Cannot continue: missing assistant message id for tool results.${we}`),process.exit(1));let K=pe({id:A,role:"assistant",parts:Y});F=await h.task(t,n,K),oe=await te(F),se=se||oe.hadContent}se||(console.error(`${Rt}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)),s||console.log("")}export{Ri as printTaskHelp,Li as runTask};
|