@entrydesk/cli 1.30.0 → 1.32.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +19 -0
  2. package/dist/agents-6VHSTGVU.js +43 -0
  3. package/dist/{billing-MGDBCV6I.js → billing-WA7WGH7U.js} +1 -1
  4. package/dist/{budget-YYGSDB4J.js → budget-PC4EAZLV.js} +1 -1
  5. package/dist/chunk-5QJUAR4K.js +120 -0
  6. package/dist/chunk-77D346VR.js +2 -0
  7. package/dist/chunk-JMYSCKCF.js +2 -0
  8. package/dist/config-ED6PZQ7J.js +4 -0
  9. package/dist/{config-help-RTQDCM2A.js → config-help-CTZHKILN.js} +1 -1
  10. package/dist/{connectors-EEPEIQ76.js → connectors-O4K2ZFDM.js} +8 -8
  11. package/dist/help-KDHCFJNF.js +4 -0
  12. package/dist/index.js +1 -1
  13. package/dist/login-LX3ISJEI.js +2 -0
  14. package/dist/logout-YNCDJ5ST.js +2 -0
  15. package/dist/{marketplace-5QZCY7QH.js → marketplace-FHSTOAWV.js} +8 -8
  16. package/dist/mcp-2G4B3BVK.js +4 -0
  17. package/dist/{meeting-5RUQYMWF.js → meeting-UBBSEEHT.js} +5 -5
  18. package/dist/models-PGGTDNI4.js +3 -0
  19. package/dist/{notifications-ZCJVVQIC.js → notifications-DHPLCJFY.js} +3 -3
  20. package/dist/{profile-RIAXCLXG.js → profile-K4V2Y63H.js} +1 -1
  21. package/dist/{recordings-FMD3YL7B.js → recordings-OXG66QN2.js} +3 -3
  22. package/dist/{schedules-JFVHBBM3.js → schedules-R4U37II4.js} +9 -9
  23. package/dist/{skills-L4AGJVTQ.js → skills-JVSRQSKA.js} +3 -3
  24. package/dist/status-S37SXIYD.js +2 -0
  25. package/dist/task-H2COR6Z4.js +180 -0
  26. package/dist/{tasks-7SK2EZZS.js → tasks-7NS4UOBP.js} +9 -9
  27. package/dist/tool-VLJFDXQ4.js +35 -0
  28. package/dist/update-5GLLNVRU.js +4 -0
  29. package/dist/{usage-6PXKAMOY.js → usage-PAL5KJ5C.js} +5 -5
  30. package/dist/version-ROABNJFL.js +2 -0
  31. package/dist/workflow-XERZYR3S.js +62 -0
  32. package/dist/{workspaces-EQSJKVVV.js → workspaces-PLJMIDJR.js} +3 -3
  33. package/package.json +6 -7
  34. package/dist/agents-JG6OXKYV.js +0 -43
  35. package/dist/chunk-LHRI5YM6.js +0 -2
  36. package/dist/chunk-NC63CPWW.js +0 -118
  37. package/dist/chunk-RJGB52EF.js +0 -4
  38. package/dist/chunk-ZIAOI7B2.js +0 -2
  39. package/dist/config-PBKYHI2B.js +0 -4
  40. package/dist/help-FBKSAMA7.js +0 -4
  41. package/dist/login-HL5KEHEN.js +0 -2
  42. package/dist/logout-QI7X4M4E.js +0 -2
  43. package/dist/mcp-5764U6QO.js +0 -4
  44. package/dist/models-PFIG6ACY.js +0 -3
  45. package/dist/status-DBKKDZAF.js +0 -2
  46. package/dist/task-PBX6HRS3.js +0 -194
  47. package/dist/token-5JSZTSX7.js +0 -2
  48. package/dist/token-util-U6DGFQDY.js +0 -2
  49. package/dist/tool-YOUXWQ76.js +0 -35
  50. package/dist/update-3SS5DWV3.js +0 -4
  51. package/dist/version-RYL2AKE2.js +0 -2
  52. package/dist/workflow-6MU3A6LB.js +0 -62
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{g as I,s as A,t as O,v}from"./chunk-RJGB52EF.js";import"./chunk-ZIAOI7B2.js";var h="\x1B[2m",c="\x1B[0m",p="\x1B[36m",N="\x1B[33m",R="\x1B[32m",b="stream-json";function f(t,n){let o=n===void 0?{event:t}:{event:t,data:n};process.stdout.write(`${JSON.stringify(o)}
2
+ import{C as I,O as A,P as O,T as v}from"./chunk-5QJUAR4K.js";import"./chunk-JMYSCKCF.js";var h="\x1B[2m",c="\x1B[0m",p="\x1B[36m",N="\x1B[33m",R="\x1B[32m",b="stream-json";function f(t,n){let o=n===void 0?{event:t}:{event:t,data:n};process.stdout.write(`${JSON.stringify(o)}
3
3
  `)}function w(t){let n=new Date(t),e=new Date().getTime()-n.getTime(),r=Math.floor(e/(1e3*60*60*24));return r===0?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}):r===1?"Yesterday":r<7?`${r} days ago`:n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}var M="\x1B[1m";function j(t){return t.replace(/<mark>/g,M).replace(/<\/mark>/g,c).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function $(t,n){if(n)return t;let o=t.split(`
4
- `);if(o.length<=15)return t;let e=o.slice(0,6),r=o.slice(-4),i=o.length-10;return[...e,`... (${i} lines omitted, use --full-output to see all) ...`,...r].join(`
5
- `)}function x(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(x);let n={};for(let[o,e]of Object.entries(t))typeof e=="string"&&e.length>200?n[o]=e.slice(0,150)+"... (truncated)":typeof e=="object"&&e!==null?n[o]=x(e):n[o]=e;return n}function J(t){if(!t||typeof t!="object")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function E(t,n){if(!t)return"(no result)";if(typeof t!="object")return $(String(t),n);let o=n?t:x(t);if("structuredContent"in o&&o.structuredContent){let e=o.structuredContent,r=[];if(e.stdout&&typeof e.stdout=="string"&&e.stdout.trim()&&r.push(e.stdout.trim()),e.stderr&&typeof e.stderr=="string"&&e.stderr.trim()&&r.push(`${N}[stderr]${c} ${e.stderr.trim()}`),e.urls&&Array.isArray(e.urls)){let i=e.urls;for(let s of i)s.path&&s.url&&r.push(`${s.path}: ${s.url}`)}return r.length===0&&r.push(JSON.stringify(e,null,2)),$(r.join(`
4
+ `);if(o.length<=15)return t;let e=o.slice(0,6),r=o.slice(-4),i=o.length-10;return[...e,`\u2026 (${i} lines omitted, use --full-output to see all) \u2026`,...r].join(`
5
+ `)}function x(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(x);let n={};for(let[o,e]of Object.entries(t))typeof e=="string"&&e.length>200?n[o]=e.slice(0,150)+"\u2026 (truncated)":typeof e=="object"&&e!==null?n[o]=x(e):n[o]=e;return n}function J(t){if(!t||typeof t!="object")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function E(t,n){if(!t)return"(no result)";if(typeof t!="object")return $(String(t),n);let o=n?t:x(t);if("structuredContent"in o&&o.structuredContent){let e=o.structuredContent,r=[];if(e.stdout&&typeof e.stdout=="string"&&e.stdout.trim()&&r.push(e.stdout.trim()),e.stderr&&typeof e.stderr=="string"&&e.stderr.trim()&&r.push(`${N}[stderr]${c} ${e.stderr.trim()}`),e.urls&&Array.isArray(e.urls)){let i=e.urls;for(let s of i)s.path&&s.url&&r.push(`${s.path}: ${s.url}`)}return r.length===0&&r.push(JSON.stringify(e,null,2)),$(r.join(`
6
6
  `),n)}if("content"in o&&Array.isArray(o.content)){let r=o.content.filter(i=>i.type==="text"&&i.text).map(i=>i.text).join(`
7
- `);return $(r||JSON.stringify(t,null,2),n)}return o.type==="text"&&typeof o.content=="string"?$(o.content,n):$(JSON.stringify(t,null,2),n)}function D(t){if(typeof t.title=="string")return t.title;if(typeof t.toolName=="string")return t.toolName;let n=t.type;return n.startsWith("tool-")?n.slice(5).replace(/__/g," ").replace(/_/g," "):n}function L(t,n){let o=[];for(let e of t)if(e.type==="reasoning"&&e.text)o.push(`${h}${e.text}${c}`);else if(e.type==="text"&&e.text)o.push(e.text);else if(e.type==="tool-call"&&e.toolName){let r=[`${p}\u250C\u2500 Tool Call: ${e.toolName}${c}`];if(e.args){r.push(`${N}\u2502 Arguments:${c}`);let i=J(e.args);for(let s of i.split(`
8
- `))r.push(`${h}\u2502 ${s}${c}`)}if(e.result!==void 0){r.push(`${R}\u2502 Result:${c}`);let i=E(e.result,n);for(let s of i.split(`
7
+ `);return $(r||JSON.stringify(t,null,2),n)}return o.type==="text"&&typeof o.content=="string"?$(o.content,n):$(JSON.stringify(t,null,2),n)}function D(t){if(typeof t.title=="string")return t.title;if(typeof t.toolName=="string")return t.toolName;let n=t.type;return n.startsWith("tool-")?n.slice(5).replace(/__/g," ").replace(/_/g," "):n}function L(t,n){let o=[];for(let e of t)if(e.type==="reasoning"&&e.text)o.push(`${h}${e.text}${c}`);else if(e.type==="text"&&e.text)o.push(e.text);else if(e.type==="tool-call"&&e.toolName){let r=[`${p}\u250C\u2500 Tool: ${e.toolName}${c}`];if(e.args){r.push(`${N}\u2502 Input:${c}`);let i=J(e.args);for(let s of i.split(`
8
+ `))r.push(`${h}\u2502 ${s}${c}`)}if(e.result!==void 0){r.push(`${R}\u2502 Output:${c}`);let i=E(e.result,n);for(let s of i.split(`
9
9
  `))r.push(`${h}\u2502 ${s}${c}`);r.push(`${p}\u2514\u2500 ${e.toolName} completed${c}`)}else e.state==="call"?r.push(`${p}\u2514\u2500 (awaiting result)${c}`):r.push(`${p}\u2514\u2500${c}`);o.push(r.join(`
10
10
  `))}else if(e.type.startsWith("tool-")&&e.type!=="tool-call"){let r=D(e),i=[`${p}\u250C\u2500 Tool: ${r}${c}`];if(e.input){i.push(`${N}\u2502 Input:${c}`);let s=J(e.input);for(let l of s.split(`
11
11
  `))i.push(`${h}\u2502 ${l}${c}`)}if(e.output!==void 0&&e.state==="output-available"){i.push(`${R}\u2502 Output:${c}`);let s=E(e.output,n);for(let l of s.split(`
@@ -30,12 +30,12 @@ Examples:
30
30
  entrydesk tasks # List recent tasks
31
31
  entrydesk tasks -q "deploy" --limit 20 # Search tasks
32
32
  entrydesk tasks <taskId> # View a task's messages
33
- entrydesk tasks <taskId> --full-output # ...with full tool outputs
33
+ entrydesk tasks <taskId> --full-output # \u2026with full tool outputs
34
34
  entrydesk tasks -s <shareId> # View a shared task
35
- `)}async function V(t){if(t.help){U();return}let n=t.output===b;t.output&&!n&&(console.error(`Invalid --output value. Supported: ${b}`),process.exit(1));let o=new I;if(t.shareId){let s;try{s=await A()}catch{}try{let l=await o.getSharedTask(t.shareId,s),{messages:a}=await o.getSharedMessages(t.shareId,50,s);if(t.json){console.log(JSON.stringify({task:l,messages:a}));return}if(n){if(f("task",l),a.length===0)f("info","No messages in this shared task.");else for(let u of a.toReversed())f("message",u);f("done");return}if(console.log(`Shared Task: ${l.title||"Untitled"}`),console.log(`Visibility: ${l.visibility}`),l.agent&&console.log(`Agent: ${l.agent.name}`),console.log(`${a.length} messages
35
+ `)}async function V(t){if(t.help){U();return}let n=t.output===b;t.output&&!n&&(console.error(`Invalid --output value. Supported: ${b}`),process.exit(1));let o=new I;if(t.shareId){let s;try{s=await A()}catch{}try{let l=await o.getSharedTask(t.shareId,s),{messages:a}=await o.getSharedMessages(t.shareId,50,s);if(t.json){console.log(JSON.stringify({task:l,messages:a}));return}if(n){if(f("task",l),a.length===0)f("info","No messages in this shared task.");else for(let u of a.toReversed())f("message",u);f("done");return}if(console.log(`Shared task: ${l.title||"Untitled"}`),console.log(`Visibility: ${l.visibility}`),l.agent&&console.log(`Agent: ${l.agent.name}`),console.log(`${a.length} messages
36
36
  `),a.length===0){console.log("No messages in this shared task.");return}let d=a.toReversed(),y=t.fullOutput??!1;for(let u of d){let S=L(u.parts,y);if(!S)continue;let T=u.role==="user"?"You":"Assistant";console.log(`[${T}] ${w(u.createdAt)}`),console.log(S),console.log("")}return}catch(l){if(l instanceof Error){let a=l.message.toLowerCase();a.includes("401")||a.includes("unauthorized")?console.error("Access denied. This shared task requires authentication or is not accessible to you."):a.includes("404")||a.includes("not found")?console.error("Shared task not found. The share ID may be invalid or the task was deleted."):console.error(`Failed to fetch shared task: ${l.message}`)}else console.error("Failed to fetch shared task");process.exit(1)}}let e,r;try{let s=await O();e=s.accessToken,r=s.workspaceId}catch(s){v(s)}if(t.taskId){let s=t.taskId,l=!1,a=null,d=Number.parseInt(t.taskId,10);if(!Number.isNaN(d)&&d>=0&&/^\d+$/.test(t.taskId)){let g=d===0?1:d,{tasks:k}=await o.getTasks(e,r,20);g>k.length&&(console.error(`Task number ${g} not found. You have ${k.length} recent tasks.`),process.exit(1));let m=k[g-1];s=m.id,l=!0,a=m,n||console.log(`Task: ${m.title||"Untitled"}
37
- `)}let{messages:u}=await o.getMessages(e,r,s,50);if(t.json){console.log(JSON.stringify(u));return}if(n){if(a&&f("task",a),u.length===0)f("info","No messages in this task.");else for(let g of u.toReversed())f("message",g);f("done");return}if(u.length===0){console.log("No messages in this task.");return}let S=u.toReversed(),T=t.fullOutput??!1;l||console.log(`Task: ${t.taskId.slice(0,8)}...`),console.log(`${u.length} messages
37
+ `)}let{messages:u}=await o.getMessages(e,r,s,50);if(t.json){console.log(JSON.stringify(u));return}if(n){if(a&&f("task",a),u.length===0)f("info","No messages in this task.");else for(let g of u.toReversed())f("message",g);f("done");return}if(u.length===0){console.log("No messages in this task.");return}let S=u.toReversed(),T=t.fullOutput??!1;l||console.log(`Task: ${t.taskId.slice(0,8)}\u2026`),console.log(`${u.length} messages
38
38
  `);for(let g of S){let k=L(g.parts,T);if(!k)continue;let m=g.role==="user"?"You":"Assistant";console.log(`[${m}] ${w(g.createdAt)}`),console.log(k),console.log("")}return}if(t.search){let{results:s,nextKey:l}=await o.searchTasks(e,r,t.search,{limit:t.limit,nextKey:t.nextKey});if(n){for(let a of s)f("task",a);f("done");return}if(t.json){console.log(JSON.stringify({results:s,nextKey:l}));return}if(s.length===0){console.log(`No tasks match "${t.search}".`);return}console.log(`Search results for "${t.search}" (${s.length}):
39
39
  `),s.forEach((a,d)=>{let y=(d+1).toString().padStart(2," "),u=a.titleHighlight?j(a.titleHighlight):a.title||"Untitled";console.log(` ${y}. ${h}${w(a.createdAt)}${c} ${u}`),a.contentSnippet&&console.log(` ${j(a.contentSnippet)}`),console.log(` ${h}ID: ${a.id}${c}`)}),l&&console.log(`
40
- Next page: --next-key ${l}`);return}let{tasks:i}=await o.getTasks(e,r,20);if(n){for(let s of i)f("task",s);f("done");return}if(t.json){console.log(JSON.stringify(i));return}if(i.length===0){console.log("No tasks found.");return}console.log(`Recent Tasks (${i.length}):
40
+ Next page: --next-key ${l}`);return}let{tasks:i}=await o.getTasks(e,r,20);if(n){for(let s of i)f("task",s);f("done");return}if(t.json){console.log(JSON.stringify(i));return}if(i.length===0){console.log('No tasks yet. Start one with `entrydesk task -m "..."`.');return}console.log(`Recent tasks (${i.length}):
41
41
  `),i.forEach((s,l)=>{let a=(l+1).toString().padStart(2," ");console.log(` ${a}. ${w(s.createdAt).padEnd(12)} ${s.title||"Untitled"}`)}),console.log(""),console.log("Use `entrydesk tasks 1` to view the most recent task"),console.log('Use `entrydesk task -c 1 -m "message"` to continue it')}export{U as printTasksHelp,j as renderHighlight,V as runTasks};
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ import{a as y,b as T}from"./chunk-77D346VR.js";import{Q as O,R as w}from"./chunk-5QJUAR4K.js";import"./chunk-JMYSCKCF.js";import M from"fs";import _ from"fs/promises";import A from"os";import d from"path";var h=!process.env.NO_COLOR&&!!process.stdout.isTTY,p={green:h?"\x1B[32m":"",yellow:h?"\x1B[33m":"",reset:h?"\x1B[0m":""},C=10*1024,N=8*1024,E=2*1024,D=100,P=100;function b(){return d.join(A.homedir(),".entrydesk","tool-results")}function F(t){let e=t.trim().replace(/[/\\:*?"<>|\s]/g,"_").replace(/_+/g,"_").replace(/^[._]+|[._]+$/g,"").slice(0,D);return!e||e==="."||e===".."?"unnamed_tool":e}function J(t){try{return JSON.stringify(t,(e,o)=>typeof o=="bigint"?`${o}n`:typeof o=="function"?"[Function]":typeof o=="symbol"?o.toString():o,2)}catch{return String(t)}}function B(t){let e=new Date,o=[e.getFullYear(),String(e.getMonth()+1).padStart(2,"0"),String(e.getDate()).padStart(2,"0")].join("-")+"_"+[String(e.getHours()).padStart(2,"0"),String(e.getMinutes()).padStart(2,"0"),String(e.getSeconds()).padStart(2,"0")].join("-"),n=F(t);return`${o}_${n}.json`}async function I(t,e){try{return await _.writeFile(t,e,{encoding:"utf8",flag:"wx"}),!0}catch(o){if(o instanceof Error&&"code"in o&&o.code==="EEXIST")return!1;throw o}}async function $(t,e){try{let o=b();await _.mkdir(o,{recursive:!0});let n=B(t),i=d.extname(n),s=n.slice(0,-i.length),r=J(e),a=d.join(o,n);if(await I(a,r))return a;for(let f=1;f<=P;f++){let S=d.join(o,`${s}-${f}${i}`);if(await I(S,r))return S}let l=Math.random().toString(36).slice(2,10),c=d.join(o,`${s}-${l}${i}`);return await _.writeFile(c,r,{encoding:"utf8",flag:"wx"}),c}catch(o){let n=o instanceof Error?o.message:"unknown error";return console.error(`${p.yellow}Warning: Could not save result to file: ${n}${p.reset}`),null}}function L(t,e){let o=Buffer.byteLength(t,"utf8");if(o<=C)return t;let n=t.slice(0,N),i=t.slice(-E),r=((o-N-E)/1024).toFixed(1),a=(o/1024).toFixed(1),l=` \u2026 (skipped ${r}KB of ${a}KB) \u2026`;return e&&(l+=`
3
+ Tip: jq -r '.structuredContent.field' <file> | grep/head/tail`),`${n}
4
+
5
+ ${l}
6
+
7
+ ${i}`}function x(t){console.log(`${p.green}Tool execution result saved to: ${t}${p.reset}`),console.log()}function k(){console.log(`${p.green}Tool execution result:${p.reset}`)}function R(t){return t.split("__")[0]??t}function u(t,e,o){console.error(o?JSON.stringify({error:{code:t,message:e}}):`Error [${t}]: ${e}`),process.exit(1)}function g(t,e,o="CONNECTION_FAILED"){O(t)&&u(o,w(),e);let n=t instanceof Error?t.message:"Unknown error";n.includes("Not logged in")||n.includes("not-logged-in")?u("AUTH_MISSING",n,e):u(o,n,e)}async function U(){return process.stdin.isTTY?null:new Promise(t=>{let e=[],o=!1,n=!1,i,s,r,a,l=()=>{clearTimeout(i),process.stdin.removeListener("data",s),process.stdin.removeListener("end",r),process.stdin.removeListener("error",a)},c=f=>{n||(n=!0,l(),t(f))};s=f=>{o=!0,clearTimeout(i),e.push(f)},r=()=>{e.length===0?c(null):c(Buffer.concat(e).toString("utf-8").trim())},a=()=>{c(null)},i=setTimeout(()=>{o||c(null)},100),process.stdin.on("data",s),process.stdin.on("end",r),process.stdin.on("error",a),process.stdin.resume()})}var m=class extends Error{constructor(e){super(e),this.name="InputError"}};async function q(t,e){if(t)return t;if(e)try{return M.readFileSync(e,"utf-8").trim()}catch(n){let i=n instanceof Error?n.message:"Failed to read input file";throw new m(`Failed to read input file: ${i}`)}let o=await U();if(o)return o;throw new m("Input JSON is required. Use --input, --input-file, or pipe it via stdin.")}function H(t){let e=[`Tool: ${t.name}`];return t.description&&e.push(` Description: ${t.description}`),e.join(`
8
+ `)}function Y(t){let e=[`Tool: ${t.name}`];return t.description&&(e.push("Description:"),e.push(` ${t.description}`)),e.push("Input Schema:"),e.push(JSON.stringify(t.inputSchema,null,2)),e.join(`
9
+ `)}async function V(t,e){let o=await T().catch(n=>{g(n,t)});try{let i=(await o.listTools({},y())).tools;if(e){let s=e.toLowerCase();i=i.filter(r=>R(r.name).toLowerCase().startsWith(s))}if(t)console.log(JSON.stringify(i,null,2));else{let s=e?` (prefix: ${e})`:"";console.log(`Available tools (${i.length})${s}:
10
+ `);for(let r of i)console.log(H(r)),console.log()}}catch(n){g(n,t)}finally{await o.close().catch(()=>{})}}async function X(t,e){let o=await T().catch(n=>{g(n,e)});try{let i=(await o.listTools({},y())).tools.find(s=>s.name===t);i||u("TOOL_NOT_FOUND",`Tool not found: ${t}`,e),console.log(e?JSON.stringify(i,null,2):Y(i))}catch(n){g(n,e)}finally{await o.close().catch(()=>{})}}async function G(t,e,o){let n;try{n=JSON.parse(e)}catch(r){let a=r instanceof Error?`Invalid JSON input: ${r.message}`:"Invalid JSON input";u("INVALID_INPUT",a,o)}let i=await T().catch(r=>{g(r,o,"TOOL_CALL_FAILED")}),s=!1;try{let r=await i.callTool({name:t,arguments:n},y());if(o)console.log(JSON.stringify(r,null,2));else{let a=await $(t,r);a&&x(a),k();for(let l of r.content)l.type==="text"?console.log(l.text):l.type==="image"?console.log(`[Image: ${l.mimeType}]`):l.type==="resource"?console.log(`[Resource: ${l.resource.uri}]`):console.log(JSON.stringify(l,null,2));if(r.structuredContent){let l=JSON.stringify(r.structuredContent,null,2),c=L(l,a);console.log(c)}}r.isError&&(s=!0)}catch(r){g(r,o,"TOOL_CALL_FAILED")}finally{await i.close().catch(()=>{})}s&&process.exit(1)}function v(){console.log(`Usage: entrydesk tool <action> [options]
11
+
12
+ Actions:
13
+ list List all available tools
14
+ get <name> Get details of a specific tool
15
+ call <name> Call a tool with JSON input
16
+
17
+ Options:
18
+ --json Output in JSON format
19
+ -p, --prefix <name> Filter tools by prefix (for 'list' action)
20
+ -i, --input <json> JSON input for tool call
21
+ -f, --input-file <path> Read JSON input from file
22
+
23
+ Input Priority (for 'call' action):
24
+ 1. --input flag (direct JSON string)
25
+ 2. --input-file flag (read from file)
26
+ 3. stdin (piped input)
27
+
28
+ Examples:
29
+ entrydesk tool list
30
+ entrydesk tool list --prefix agent
31
+ entrydesk tool get agent__search_agents
32
+ entrydesk tool call agent__search_agents --input '{"limit": 5}'
33
+ entrydesk tool call agent__search_agents --input-file input.json
34
+ echo '{"limit": 5}' | entrydesk tool call agent__search_agents
35
+ `)}async function ot(t){let e=t.json??!1;if(t.help){v();return}switch(t.action){case"list":await V(e,t.prefix);break;case"get":t.name||u("INVALID_INPUT","Tool name is required. Usage: entrydesk tool get <name>",e),await X(t.name,e);break;case"call":{t.name||u("INVALID_INPUT","Tool name is required. Usage: entrydesk tool call <name> --input <json>",e);let o;try{o=await q(t.input,t.inputFile)}catch(n){throw n instanceof m&&u("INVALID_INPUT",n.message,e),n}await G(t.name,o,e);break}default:v();break}}export{m as InputError,q as getInputJson,v as printToolUsage,U as readStdin,ot as runTool};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{S as l}from"./chunk-5QJUAR4K.js";import"./chunk-JMYSCKCF.js";import{spawn as f}from"child_process";var a="@entrydesk/cli";function g(){return"1.32.0-beta"}function d(n){let e=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u.exec(n.trim());return e?{nums:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]??null}:null}function h(n,e){if(n===e)return 0;if(n===null)return 1;if(e===null)return-1;let t=n.split("."),i=e.split("."),r=Math.min(t.length,i.length);for(let s=0;s<r;s++){let u=t[s],o=i[s];if(u!==o){let c=/^\d+$/u.test(u),p=/^\d+$/u.test(o);return c&&p?Number(u)<Number(o)?-1:1:c?-1:p?1:u<o?-1:1}}return t.length===i.length?0:t.length<i.length?-1:1}function y(n,e){let t=d(n),i=d(e);if(!t||!i)return t?1:i?-1:0;for(let r=0;r<3;r++)if(t.nums[r]!==i.nums[r])return t.nums[r]<i.nums[r]?-1:1;return h(t.prerelease,i.prerelease)}function $(){return process.platform==="win32"?"npm.cmd":"npm"}function m(n,{inheritOutput:e}){return new Promise((t,i)=>{let r=f($(),n,{stdio:e?["ignore","inherit","inherit"]:["ignore","pipe","pipe"]}),s="",u="";r.stdout?.on("data",o=>{s+=String(o)}),r.stderr?.on("data",o=>{u+=String(o)}),r.once("error",i),r.once("close",o=>{t({exitCode:o??1,stdout:s,stderr:u})})})}async function w(){let n;try{n=await m(["view",a,"version"],{inheritOutput:!1})}catch(t){throw new l("Failed to run npm \u2014 is npm installed and on your PATH?",1,t instanceof Error?t:void 0)}let e=n.stdout.trim();if(n.exitCode!==0||!e)throw new l(`Failed to look up the latest ${a} version from the npm registry.${n.stderr?`
3
+ ${n.stderr.trim()}`:""}`);if(!d(e))throw new l(`Unexpected version from the npm registry: ${JSON.stringify(e)}`);return e}async function _(n){let e=g(),t=await w(),i=y(e,t),r=i>=0;if(n.check||r){n.json?console.log(JSON.stringify({current:e,latest:t,upToDate:r,updated:!1})):i>0?console.log(`entrydesk ${e} is newer than the latest published version (${t}). Nothing to do.`):console.log(r?`entrydesk ${e} is already the latest version.`:`Update available: ${e} \u2192 ${t}. Run \`entrydesk update\` to install.`);return}n.json||console.log(`Updating entrydesk ${e} \u2192 ${t}\u2026`);let s=await m(["install","-g",`${a}@${t}`],{inheritOutput:!n.json});if(s.exitCode!==0){let u=s.stderr?`
4
+ ${s.stderr.trim()}`:"";throw new l(`npm install failed (exit code ${s.exitCode}). You can update manually with \`npm install -g ${a}@latest\`.`+u,s.exitCode)}n.json?console.log(JSON.stringify({current:e,latest:t,upToDate:r,updated:!0})):console.log(`entrydesk updated to ${t}.`)}export{_ as runUpdate};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{g as d,t as y,v as U}from"./chunk-RJGB52EF.js";import"./chunk-ZIAOI7B2.js";import{writeFileSync as S}from"fs";function $(){console.log(`
2
+ import{C as d,P as y,T as U}from"./chunk-5QJUAR4K.js";import"./chunk-JMYSCKCF.js";import{writeFileSync as S}from"fs";function $(){console.log(`
3
3
  Usage: entrydesk usage [balance|me|consumptions|export] [options]
4
4
 
5
5
  Commands:
@@ -23,7 +23,7 @@ Examples:
23
23
  entrydesk usage consumptions --limit 20
24
24
  entrydesk usage export -o usage.csv
25
25
  `)}function s(o){return`$${o.toFixed(2)}`}function b(o){console.log(`Extra-usage balance: ${s(o.balanceUsd)}`);let n=o.currentSpentUsedPercent==null?"":` (${o.currentSpentUsedPercent}% of limit)`;console.log(`Spent this period: ${s(o.currentSpentUsd)}${n}`),o.monthlyExtraUsageLimitUsd!=null&&console.log(`Workspace limit: ${s(o.monthlyExtraUsageLimitUsd)} / month`),o.memberMonthlyExtraUsageLimitUsd!=null&&console.log(`Per-member limit: ${s(o.memberMonthlyExtraUsageLimitUsd)} / month`),o.nextExpiry&&console.log(`Next expiry: ${s(o.nextExpiry.amountUsd)} at ${new Date(o.nextExpiry.expiresAt).toLocaleString()}`),console.log(`Period: ${new Date(o.period.startAt).toLocaleDateString()} \u2013 ${new Date(o.period.endAt).toLocaleDateString()}`)}function C(o){console.log(`Seat type: ${o.seatType}`),o.hourly&&console.log(`Hourly used: ${o.hourly.usedPercent}%`),console.log(`Weekly used: ${o.weekly.usedPercent}%`),console.log(`Extra spent: ${s(o.extraUsage.spentUsd)}`),console.log(`Available: ${o.availability.allowed?"yes":`no (${o.availability.reason??"unknown"})`}`),o.trial&&console.log(`Trial: ${o.trial.remainingDays} days remaining`)}function k(o){console.log(`Consumptions (${o.items.length} of ${o.total}):
26
- `);for(let n of o.items)console.log(` ${n.user.name} (${n.user.email})`),console.log(` Seat: ${n.seatType} \xB7 Extra usage: ${s(n.extraUsage)}`),console.log(` User ID: ${n.user.id}`),console.log("")}async function N(o){if(o.help){$();return}let n,i;try{let e=await y();n=e.accessToken,i=e.workspaceId}catch(e){let a=e instanceof Error?e.message:"Authentication failed";console.error(a),process.exit(1)}let r=new d;try{if(o.action==="balance"){let t=await r.getUsageOverview(n,i);if(o.json){console.log(JSON.stringify(t));return}b(t);return}if(o.action==="me"){let t=await r.getUsageMe(n,i);if(o.json){console.log(JSON.stringify(t));return}C(t);return}if(o.action==="consumptions"){let t=await r.getUsageConsumptions(n,i,{limit:o.limit,offset:o.offset,periodStart:o.periodStart});if(o.json){console.log(JSON.stringify(t));return}if(t.items.length===0){console.log("No consumptions for this period.");return}k(t);return}if(o.action==="export"){let t=await r.exportUsageCsv(n,i,o.periodStart);o.output?(S(o.output,t),console.log(`Wrote usage CSV to ${o.output}`)):process.stdout.write(t);return}o.action&&(console.error(`Unknown usage command: ${o.action}`),$(),process.exit(1));let e=[],a,u=0,h=100;do{let t=await r.getMonthlyUsages(n,i,{nextKey:a,limit:100});if(e.push(...t.monthlyUsages),a=t.nextKey,u++,u>=h){console.error(`Warning: Showing first ${e.length} entries (pagination limit reached)`);break}}while(a);if(o.json){console.log(JSON.stringify(e));return}if(e.length===0){console.log("No usage data found for this workspace.");return}console.log(`Current Month Usage:
27
- `);let g=0,p=0;for(let t of e)g+=Number.parseFloat(t.totalCost),p+=t.operationCount;console.log(`Total Cost: $${g.toFixed(2)}`),console.log(`Total Operations: ${p.toLocaleString()}`),console.log(`Users: ${e.length}
28
- `);let m=o.sortBy||"cost",f=[...e].toSorted((t,c)=>m==="cost"?Number.parseFloat(c.totalCost)-Number.parseFloat(t.totalCost):c.operationCount-t.operationCount),x=o.limit&&o.limit>0?o.limit:f.length,l=f.slice(0,x);console.log(`Usage by User (sorted by ${m}, showing ${l.length} of ${e.length}):
29
- `);for(let t of l){let c=Number.parseFloat(t.totalCost);console.log(` ${t.user.name} (${t.user.email})`),console.log(` Cost: $${c.toFixed(2)}`),console.log(` Operations: ${t.operationCount.toLocaleString()}`),console.log("")}l.length<e.length&&console.log(`... and ${e.length-l.length} more users`)}catch(e){U(e)}}export{N as runUsage};
26
+ `);for(let n of o.items)console.log(` ${n.user.name} (${n.user.email})`),console.log(` Seat: ${n.seatType} \xB7 Extra usage: ${s(n.extraUsage)}`),console.log(` User ID: ${n.user.id}`),console.log("")}async function N(o){if(o.help){$();return}let n,i;try{let e=await y();n=e.accessToken,i=e.workspaceId}catch(e){let a=e instanceof Error?e.message:"Authentication failed";console.error(a),process.exit(1)}let r=new d;try{if(o.action==="balance"){let t=await r.getUsageOverview(n,i);if(o.json){console.log(JSON.stringify(t));return}b(t);return}if(o.action==="me"){let t=await r.getUsageMe(n,i);if(o.json){console.log(JSON.stringify(t));return}C(t);return}if(o.action==="consumptions"){let t=await r.getUsageConsumptions(n,i,{limit:o.limit,offset:o.offset,periodStart:o.periodStart});if(o.json){console.log(JSON.stringify(t));return}if(t.items.length===0){console.log("No consumptions for this period.");return}k(t);return}if(o.action==="export"){let t=await r.exportUsageCsv(n,i,o.periodStart);o.output?(S(o.output,t),console.log(`Wrote usage CSV to ${o.output}`)):process.stdout.write(t);return}o.action&&(console.error(`Unknown usage command: ${o.action}`),$(),process.exit(1));let e=[],a,u=0,h=100;do{let t=await r.getMonthlyUsages(n,i,{nextKey:a,limit:100});if(e.push(...t.monthlyUsages),a=t.nextKey,u++,u>=h){console.error(`Warning: Showing first ${e.length} entries (pagination limit reached)`);break}}while(a);if(o.json){console.log(JSON.stringify(e));return}if(e.length===0){console.log("No usage data found for this workspace.");return}console.log(`Current month usage:
27
+ `);let g=0,p=0;for(let t of e)g+=Number.parseFloat(t.totalCost),p+=t.operationCount;console.log(`Total cost: $${g.toFixed(2)}`),console.log(`Total operations: ${p.toLocaleString()}`),console.log(`Users: ${e.length}
28
+ `);let m=o.sortBy||"cost",f=[...e].toSorted((t,c)=>m==="cost"?Number.parseFloat(c.totalCost)-Number.parseFloat(t.totalCost):c.operationCount-t.operationCount),x=o.limit&&o.limit>0?o.limit:f.length,l=f.slice(0,x);console.log(`Usage by user (sorted by ${m}, showing ${l.length} of ${e.length}):
29
+ `);for(let t of l){let c=Number.parseFloat(t.totalCost);console.log(` ${t.user.name} (${t.user.email})`),console.log(` Cost: $${c.toFixed(2)}`),console.log(` Operations: ${t.operationCount.toLocaleString()}`),console.log("")}l.length<e.length&&console.log(`\u2026 and ${e.length-l.length} more users`)}catch(e){U(e)}}export{N as runUsage};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import"./chunk-JMYSCKCF.js";function n(){console.log("entrydesk 1.32.0-beta")}export{n as printVersion};
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ import{C as p,P as k,T as g,r as u}from"./chunk-5QJUAR4K.js";import"./chunk-JMYSCKCF.js";import{readFileSync as $}from"fs";var m=262144,R=new Set(["completed","failed","cancelled"]);function c(){console.log(`
3
+ Usage: entrydesk workflow [list|get|create|update|run|runs|run-get|share] [options]
4
+
5
+ Commands:
6
+ list List workflows (default)
7
+ get <workflowId> Show workflow details (--show-source for the script)
8
+ create Create a workflow from a local script file
9
+ update <workflowId> Update name/description/script or enable/disable
10
+ run <workflowId> Trigger a run; prints the runId (--wait to follow)
11
+ runs <workflowId> List runs of a workflow
12
+ run-get <workflowId> <runId> Show a run's status, nodes, and logs
13
+ share <workflowId> Show or manage sharing (user grants)
14
+
15
+ List Options:
16
+ --search <text> Search by name
17
+ --limit <number> Max workflows per page (default: 20)
18
+ --next-key <cursor> Fetch next page using cursor
19
+ --all Fetch all workflows (auto-paginate)
20
+
21
+ Create/Update Options:
22
+ --name <text> (required for create)
23
+ --description <text>
24
+ --file <path.js> Script source file (required for create)
25
+ --activate Enable the workflow (update only)
26
+ --deactivate Disable the workflow (update only)
27
+
28
+ Get Options:
29
+ --show-source Print the full script source
30
+
31
+ Run Options:
32
+ --args '<json>' Inline JSON passed to the workflow's args global
33
+ --args-file <path> Read the JSON args from a file
34
+ --wait Poll the run until it finishes, then print the result
35
+
36
+ Share Options:
37
+ --add-user <userId> Grant a user access (use with --role)
38
+ --remove-user <userId> Revoke a user's access
39
+ --role owner|editor|viewer Role for --add-user (default: viewer)
40
+
41
+ Flags:
42
+ --json Output JSON
43
+
44
+ Examples:
45
+ entrydesk workflow list --search report
46
+ entrydesk workflow create --name "Nightly report" --file ./report.js
47
+ entrydesk workflow run <workflowId> --args '{"date":"2026-06-20"}' --wait
48
+ entrydesk workflow runs <workflowId>
49
+ entrydesk workflow run-get <workflowId> <runId>
50
+ entrydesk workflow share <workflowId> --add-user <userId> --role editor
51
+ `)}function w(e){if(!e)return"";let o=new Date(e);return Number.isNaN(o.getTime())?e:o.toLocaleString()}function h(e){let o;try{o=$(e,"utf8")}catch{console.error(`Cannot read script file: ${e}`),process.exit(1)}return o.trim().length===0&&(console.error(`Script file is empty: ${e}`),process.exit(1)),Buffer.byteLength(o,"utf8")>m&&(console.error(`Script file exceeds ${m} bytes.`),process.exit(1)),o}function A(e){e.args!==void 0&&e.argsFile!==void 0&&(console.error("Use only one of --args or --args-file."),process.exit(1));let o;if(e.argsFile===void 0)o=e.args;else try{o=$(e.argsFile,"utf8")}catch{console.error(`Cannot read args file: ${e.argsFile}`),process.exit(1)}if(o!==void 0)try{return JSON.parse(o)}catch{console.error("--args/--args-file must be valid JSON."),process.exit(1)}}function y(e){console.log(`Workflows (${e.length}):
52
+ `);for(let o of e){let r=o.isActive?"active":"inactive";if(console.log(` ${o.name} (${r})`),o.description){let t=o.description.length>80?`${o.description.slice(0,80)}\u2026`:o.description;console.log(` ${t}`)}console.log(` ${o.myRole??"no-role"} \xB7 ID: ${o.id}`),console.log("")}}function v(e,o){console.log(`${e.name}
53
+ `),console.log(` ID: ${e.id}`),console.log(` Active: ${e.isActive}`),console.log(` My role: ${e.myRole??"no-role"}`),e.description&&console.log(` Description: ${e.description}`),console.log(` Updated: ${w(e.updatedAt)}`);let r=e.scriptSource.split(`
54
+ `).length;o?(console.log(`
55
+ Script (${r} lines):
56
+ `),console.log(e.scriptSource)):console.log(` Script: ${r} lines (use --show-source to print)`)}function I(e){console.log(`Runs (${e.length}):
57
+ `);for(let o of e){let r=w(o.startedAt??o.createdAt);console.log(` ${o.status}${r?` \xB7 ${r}`:""}`),console.log(` ID: ${o.id}`)}}function S(e){console.log(`Run ${e.id}`),console.log(` Workflow: ${e.workflowId}`),console.log(` Status: ${e.status}`),e.startedAt&&console.log(` Started: ${w(e.startedAt)}`),e.completedAt&&console.log(` Completed: ${w(e.completedAt)}`),e.error!=null&&console.log(` Error: ${JSON.stringify(e.error)}`);let o=Object.entries(e.context?.nodes??{});if(o.length>0){console.log(`
58
+ Nodes (${o.length}):`);for(let[t,s]of o){let n=[s.kind??"node",s.status];s.durationMs!=null&&n.push(`${s.durationMs}ms`),console.log(` - ${s.label??t} [${n.join(" \xB7 ")}]`)}}let r=e.context?.logs??[];if(r.length>0){console.log(`
59
+ Logs:`);for(let t of r)console.log(` ${t}`)}e.context?.spent!=null&&console.log(`
60
+ Tokens spent: ${e.context.spent}`)}function W(e){let o=u(e);if(console.log(`User grants (${o.length}):`),o.length===0){console.log(" (none)");return}for(let r of o)console.log(` - ${r.user.name} <${r.user.email}> \xB7 ${r.role}`),console.log(` ID: ${r.userId}`)}async function N(e,o,r,t,s){for(let i=0;i<600;i++){let l=await e.getWorkflowRun(o,r,t,s);if(R.has(l.status))return i>0&&process.stderr.write(`
61
+ `),l;let f=i*2;process.stderr.write(`\rWaiting\u2026 ${l.status} (${f}s)`),await new Promise(a=>setTimeout(a,2e3))}throw process.stderr.write(`
62
+ `),new Error(`Run ${s} did not finish within the wait window.`)}async function x(e){let r=[],t;for(let s=0;;s++){s>=100&&(console.error("Reached maximum page limit (100). Use --limit and --next-key for manual pagination."),process.exit(1));let n=await e(t);if(r.push(...n.items),t=n.nextKey,!t)break}return r}async function O(e,o,r,t){if(t.all&&t.nextKey&&(console.error("Cannot use --all and --next-key together."),process.exit(1)),t.all){let i=await x(async l=>{let f=await e.getWorkflows(o,r,{limit:t.limit??20,nextKey:l,search:t.search});return{items:f.workflows,nextKey:f.nextKey}});if(t.json){console.log(JSON.stringify({workflows:i}));return}if(i.length===0){console.log("No workflows in this workspace yet. Create one with `entrydesk workflow create --name <name> --file <path.js>`.");return}y(i);return}let{workflows:s,nextKey:n}=await e.getWorkflows(o,r,{limit:t.limit,nextKey:t.nextKey,search:t.search});if(t.json){console.log(JSON.stringify({workflows:s,nextKey:n}));return}if(s.length===0){console.log("No workflows in this workspace yet. Create one with `entrydesk workflow create --name <name> --file <path.js>`.");return}y(s),n&&console.log(`Next page: --next-key ${n}`)}async function U(e,o,r,t){if(!t.workflowId)throw new Error("Missing workflow ID. Usage: entrydesk workflow share <workflowId>");let s=t.workflowId,n=t.role??"viewer";if(t.addUser){let l=await e.upsertWorkflowGrant(o,r,s,t.addUser,n);if(t.json){console.log(JSON.stringify(l));return}console.log(`Granted ${n} to user ${t.addUser}`);return}if(t.removeUser){if(await e.removeWorkflowGrant(o,r,s,t.removeUser),t.json){console.log(JSON.stringify({userId:t.removeUser,removed:!0}));return}console.log(`Revoked access for user ${t.removeUser}`);return}let i=await e.getWorkflowGrants(o,r,s);if(t.json){console.log(JSON.stringify(i));return}W(i)}async function M(e){try{if(e.help){c();return}let{accessToken:o,workspaceId:r}=await k(),t=e.action||"list",s=new p;if(t==="list"){await O(s,o,r,e);return}if(t==="get"){if(!e.workflowId)throw new Error("Missing workflow ID. Usage: entrydesk workflow get <workflowId>");let n=await s.getWorkflow(o,r,e.workflowId);if(e.json){console.log(JSON.stringify(n));return}v(n,!!e.showSource);return}if(t==="create"){(!e.name||!e.file)&&(console.error("create requires --name and --file <path.js>."),c(),process.exit(1));let n=h(e.file),i=await s.createWorkflow(o,r,{name:e.name,description:e.description,scriptSource:n});if(e.json){console.log(JSON.stringify(i));return}console.log(`Created workflow: ${i.name}`),console.log(` ID: ${i.id}`);return}if(t==="update"){if(!e.workflowId)throw new Error("Missing workflow ID. Usage: entrydesk workflow update <workflowId>");e.activate&&e.deactivate&&(console.error("Cannot use --activate and --deactivate together."),process.exit(1));let n={};if(e.name!==void 0&&(n.name=e.name),e.description!==void 0&&(n.description=e.description),e.file!==void 0&&(n.scriptSource=h(e.file)),e.activate&&(n.isActive=!0),e.deactivate&&(n.isActive=!1),Object.keys(n).length===0&&(console.error("No fields provided to update."),c(),process.exit(1)),await s.updateWorkflow(o,r,e.workflowId,n),e.json){console.log(JSON.stringify({id:e.workflowId,updated:!0}));return}console.log(`Updated workflow: ${e.workflowId}`);return}if(t==="run"){if(!e.workflowId)throw new Error("Missing workflow ID. Usage: entrydesk workflow run <workflowId>");let n=A(e),{runId:i}=await s.triggerWorkflowRun(o,r,e.workflowId,n);if(!e.wait){if(e.json){console.log(JSON.stringify({runId:i}));return}console.log(`Started run: ${i}`),console.log(` Check: entrydesk workflow run-get ${e.workflowId} ${i}`);return}let l=await N(s,o,r,e.workflowId,i);e.json?console.log(JSON.stringify(l)):S(l),l.status!=="completed"&&process.exit(1);return}if(t==="runs"){if(!e.workflowId)throw new Error("Missing workflow ID. Usage: entrydesk workflow runs <workflowId>");if(e.all&&e.nextKey&&(console.error("Cannot use --all and --next-key together."),process.exit(1)),e.all){let l=e.workflowId,f=await x(async a=>{let d=await s.getWorkflowRuns(o,r,l,{limit:e.limit??20,nextKey:a});return{items:d.runs,nextKey:d.nextKey}});if(e.json){console.log(JSON.stringify({runs:f}));return}if(f.length===0){console.log("No runs for this workflow.");return}I(f);return}let{runs:n,nextKey:i}=await s.getWorkflowRuns(o,r,e.workflowId,{limit:e.limit,nextKey:e.nextKey});if(e.json){console.log(JSON.stringify({runs:n,nextKey:i}));return}if(n.length===0){console.log("No runs for this workflow.");return}I(n),i&&console.log(`Next page: --next-key ${i}`);return}if(t==="run-get"){if(!e.workflowId||!e.runId)throw new Error("Missing workflow ID or run ID. Usage: entrydesk workflow run-get <workflowId> <runId>");let n=await s.getWorkflowRun(o,r,e.workflowId,e.runId);if(e.json){console.log(JSON.stringify(n));return}S(n);return}if(t==="share"){await U(s,o,r,e);return}console.error(`Unknown workflow command: ${t}`),c(),process.exit(1)}catch(o){g(o)}}export{M as runWorkflow};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{f as a,g as w,s as k}from"./chunk-RJGB52EF.js";import"./chunk-ZIAOI7B2.js";function l(){console.log(`
2
+ import{B as i,C as k,O as w}from"./chunk-5QJUAR4K.js";import"./chunk-JMYSCKCF.js";function l(){console.log(`
3
3
  Usage: entrydesk workspaces [list|switch|use] [options]
4
4
 
5
5
  Commands:
@@ -9,6 +9,6 @@ Commands:
9
9
 
10
10
  Flags:
11
11
  --json Output JSON
12
- `)}async function h(e){if(e.help){l();return}let t,f=(await a.getAll())?.workspaceId;try{t=await k()}catch(o){let s=o instanceof Error?o.message:"Authentication failed";console.error(s),process.exit(1)}let r=e.action||"list",p=new w;if(r==="switch"||r==="use"){let o=e.configKey;o||(console.error("Missing workspaceId for switch."),l(),process.exit(1));let{workspaces:s}=await p.getWorkspaces(t),i=s.find(n=>n.id===o);if(!i){console.error(`Workspace not found: ${o}`),console.error(`
13
- Available workspaces:`);for(let n of s)console.error(` ${n.name}: ${n.id}`);process.exit(1)}if(await a.saveWorkspaceId(o),e.json){console.log(JSON.stringify({workspaceId:o,workspaceName:i.name}));return}console.log(`Switched to workspace: ${i.name}`),console.log(` ID: ${o}`);return}r!=="list"&&(console.error(`Unknown workspaces command: ${r}`),l(),process.exit(1));let{workspaces:c}=await p.getWorkspaces(t);if(e.json){console.log(JSON.stringify(c));return}if(c.length===0){console.log("No workspaces found.");return}console.log(`Workspaces (${c.length}):
12
+ `)}async function h(e){if(e.help){l();return}let t,f=(await i.getAll())?.workspaceId;try{t=await w()}catch(o){let s=o instanceof Error?o.message:"Authentication failed";console.error(s),process.exit(1)}let r=e.action||"list",p=new k;if(r==="switch"||r==="use"){let o=e.configKey;o||(console.error("Missing workspace ID. Usage: entrydesk workspaces switch <workspaceId>"),l(),process.exit(1));let{workspaces:s}=await p.getWorkspaces(t),a=s.find(n=>n.id===o);if(!a){console.error(`Workspace not found: ${o}`),console.error(`
13
+ Available workspaces:`);for(let n of s)console.error(` ${n.name}: ${n.id}`);process.exit(1)}if(await i.saveWorkspaceId(o),e.json){console.log(JSON.stringify({workspaceId:o,workspaceName:a.name}));return}console.log(`Switched to workspace: ${a.name}`),console.log(` ID: ${o}`);return}r!=="list"&&(console.error(`Unknown workspaces command: ${r}`),l(),process.exit(1));let{workspaces:c}=await p.getWorkspaces(t);if(e.json){console.log(JSON.stringify(c));return}if(c.length===0){console.log("No workspaces found.");return}console.log(`Workspaces (${c.length}):
14
14
  `);for(let o of c){let s=o.id===f?" (current)":"";console.log(` ${o.name}${s}`),console.log(` ID: ${o.id}`),console.log("")}}export{h as runWorkspaces};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entrydesk/cli",
3
- "version": "1.30.0",
3
+ "version": "1.32.0-beta",
4
4
  "description": "EntryDesk CLI - Interact with EntryDesk from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,10 +11,12 @@
11
11
  "README.md"
12
12
  ],
13
13
  "dependencies": {
14
+ "@ai-sdk/react": "^4.0.55",
14
15
  "@modelcontextprotocol/client": "^2.0.0",
15
16
  "@modelcontextprotocol/node": "^2.0.0",
16
17
  "@modelcontextprotocol/server": "^2.0.0",
17
18
  "adm-zip": "^0.6.0",
19
+ "ai": "^7.0.52",
18
20
  "archiver": "^7.0.1",
19
21
  "ink": "^7.1.1",
20
22
  "ink-spinner": "^5.0.0",
@@ -24,7 +26,6 @@
24
26
  "uuid": "^14.0.0"
25
27
  },
26
28
  "devDependencies": {
27
- "@lydell/node-pty": "^1.1.0",
28
29
  "@testing-library/react": "^16.3.2",
29
30
  "@types/archiver": "^7.0.0",
30
31
  "@types/node": "^24.12.4",
@@ -32,15 +33,14 @@
32
33
  "@vitest/coverage-v8": "^4.1.6",
33
34
  "happy-dom": "^20.8.9",
34
35
  "oxlint": "^1.75.0",
35
- "strip-ansi": "^7.1.2",
36
36
  "tsup": "^8.5.0",
37
37
  "typescript": "^7.0.2",
38
38
  "vitest": "^4.1.6",
39
- "@entrydesk/client-tools": "^0.0.0",
40
39
  "@entrydesk/shared": "^0.0.0",
41
40
  "@gntc/utils": "^0.0.0",
42
- "@gntc/ci": "^0.0.0",
43
- "@gntc/vitest": "^0.0.0"
41
+ "@gntc/vitest": "^0.0.0",
42
+ "@entrydesk/client-tools": "^0.0.0",
43
+ "@gntc/ci": "^0.0.0"
44
44
  },
45
45
  "optionalDependencies": {
46
46
  "keytar": "^7.9.0"
@@ -55,7 +55,6 @@
55
55
  "start": "node dist/index.js",
56
56
  "test": "vitest run",
57
57
  "test:coverage": "vitest run --coverage",
58
- "test:integration": "pnpm build && vitest run --root ./integration-tests",
59
58
  "test:unit": "vitest run --config vitest.config.ts",
60
59
  "test:watch": "vitest watch",
61
60
  "typecheck": "tsc --noEmit"
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
- import{g as u}from"./chunk-NC63CPWW.js";import{g as f,t as h,v as y}from"./chunk-RJGB52EF.js";import"./chunk-ZIAOI7B2.js";function m(){console.log(`
3
- Usage: entrydesk agents [list|show|create|update|delete|publish|share] [options]
4
-
5
- Commands:
6
- list List available agents (default; --mine for your own)
7
- show <agentId> Show one agent's full details
8
- create Create a new agent
9
- update <agentId> Update an agent you own
10
- delete <agentId> Delete an agent you own
11
- publish <agentId> Publish an agent to the workspace
12
- share <agentId> Show or manage sharing (user grants)
13
-
14
- Create/Update Options:
15
- --name <name>
16
- --description <text>
17
- --system-prompt <text>
18
- --model-id <modelId>
19
- --connector-ids id1,id2
20
- --capabilities sandbox,web_search,image_generation,chart
21
- --conversation-starters s1,s2,s3
22
- --tools prefix__tool1,prefix__tool2
23
- --icon-id <iconId>
24
-
25
- List Options:
26
- --mine List agents you own/edit (with publish state)
27
- --limit <number> Max agents per page; also page size for --all (default: 100)
28
- --next-key <cursor> Fetch next page using cursor
29
- --all Fetch all agents (auto-paginate)
30
-
31
- Share Options:
32
- --add-user <userId> Grant a user access (use with --role)
33
- --remove-user <userId> Revoke a user's access
34
- --role owner|editor|viewer Role for --add-user (default: viewer)
35
-
36
- Flags:
37
- --json Output JSON
38
- `)}function I(e){if(!e)return[];let o=new Map([["sandbox","sandbox"],["web","web_search"],["web-search","web_search"],["web_search","web_search"],["image","image_generation"],["image-gen","image_generation"],["image_generation","image_generation"],["chart","chart"]]);return e.map(t=>o.get(t)??t)}function w(e){console.log(`Available Agents (${e.length}):
39
- `);for(let o of e){if(console.log(` ${o.name} (${o.visibility})`),o.description){let t=o.description.length>80?`${o.description.slice(0,80)}...`:o.description;console.log(` ${t}`)}console.log(` ID: ${o.id}`),console.log("")}}function A(e){console.log(`My Agents (${e.length}):
40
- `);for(let o of e){let t=[];o.latestVersionNumber!=null&&t.push(`v${o.latestVersionNumber}`),o.hasUnpublishedChanges&&t.push("unpublished changes");let s=t.length>0?` (${t.join(" \xB7 ")})`:"";if(console.log(` ${o.name}${s}`),o.description){let a=o.description.length>80?`${o.description.slice(0,80)}...`:o.description;console.log(` ${a}`)}console.log(` ${o.myRole??"no-role"} \xB7 ID: ${o.id}`),console.log("")}}function b(e){console.log(`${e.name}
41
- `),console.log(` ID: ${e.id}`),e.visibility&&console.log(` Visibility: ${e.visibility}`),e.model&&console.log(` Model: ${e.model.name}`),e.author&&console.log(` Author: ${e.author.name}${e.author.isMe?" (you)":""}`),e.description&&console.log(` Description: ${e.description}`),e.capabilities&&e.capabilities.length>0&&console.log(` Capabilities: ${e.capabilities.join(", ")}`),e.connectors&&e.connectors.length>0&&console.log(` Connectors: ${e.connectors.map(o=>o.name).join(", ")}`),e.tools&&e.tools.length>0&&console.log(` Tools: ${e.tools.length}`),e.conversationStarters&&e.conversationStarters.length>0&&console.log(` Starters: ${e.conversationStarters.length}`),e.systemPrompt&&console.log(`
42
- System Prompt:
43
- ${e.systemPrompt}`)}function $(e){let o=u(e);if(console.log(`User grants (${o.length}):`),o.length===0){console.log(" (none)");return}for(let t of o)console.log(` - ${t.user.name} <${t.user.email}> \xB7 ${t.role}`),console.log(` ID: ${t.userId}`)}function x(e){return(!e.name||!e.description||!e.systemPrompt||!e.modelId)&&(console.error("Missing required fields for agent create/update."),m(),process.exit(1)),{name:e.name,description:e.description,systemPrompt:e.systemPrompt,modelId:e.modelId,connectorIds:e.connectorIds??[],capabilities:I(e.capabilities),conversationStarters:e.conversationStarters??[],tools:e.tools,iconId:e.iconId}}async function P(e){try{if(e.help){m();return}let o=await h(),{accessToken:t,workspaceId:s}=o,a=e.action||"list",r=new f;if(a==="show"){if(!e.agentId)throw new Error("Missing agentId for show command");let i=await r.getAgent(t,s,e.agentId);if(e.json){console.log(JSON.stringify(i));return}b(i);return}if(a==="publish"){if(!e.agentId)throw new Error("Missing agentId for publish command");if(await r.publishAgent(t,s,e.agentId),e.json){console.log(JSON.stringify({id:e.agentId,published:!0}));return}console.log(`Published agent to the workspace: ${e.agentId}`);return}if(a==="share"){if(!e.agentId)throw new Error("Missing agentId for share command");let i=e.agentId,n=e.role??"viewer";if(e.addUser){let c=await r.upsertAgentGrant(t,s,i,e.addUser,n);if(e.json){console.log(JSON.stringify(c));return}console.log(`Granted ${n} to user ${e.addUser}`);return}if(e.removeUser){if(await r.removeAgentGrant(t,s,i,e.removeUser),e.json){console.log(JSON.stringify({userId:e.removeUser,removed:!0}));return}console.log(`Revoked access for user ${e.removeUser}`);return}let l=await r.getAgentGrants(t,s,i);if(e.json){console.log(JSON.stringify(l));return}$(l);return}if(a==="create"){let i=x(e),n=await r.createAgent(t,s,i);if(e.json){console.log(JSON.stringify(n));return}console.log(`Created agent: ${n.name}`),console.log(` ID: ${n.id}`);return}if(a==="update"){let i=e.agentId;if(!i)throw new Error("Missing agentId for update command");let n=await r.getAgent(t,s,i),l={name:e.name??n.name,description:e.description??n.description,systemPrompt:e.systemPrompt??n.systemPrompt??"",modelId:e.modelId??n.model?.id??"",connectorIds:e.connectorIds??n.connectors?.map(c=>c.id)??[],capabilities:e.capabilities?I(e.capabilities):n.capabilities??[],conversationStarters:e.conversationStarters??n.conversationStarters??[],tools:e.tools??n.tools??[],iconId:e.iconId??n.iconId};await r.updateAgent(t,s,i,l),console.log(`Updated agent: ${i}`);return}if(a==="delete"){let i=e.agentId;if(!i)throw new Error("Missing agentId for delete command");await r.deleteAgent(t,s,i),console.log(`Deleted agent: ${i}`);return}if(a!=="list"&&(console.error(`Unknown agents command: ${a}`),m(),process.exit(1)),e.all&&e.nextKey&&(console.error("Cannot use --all and --next-key together."),process.exit(1)),e.mine){let i=[],n=e.all?void 0:e.nextKey,l=100;for(let c=0;;c++){c>=l&&(console.error(`Reached maximum page limit (${l}). Use --limit and --next-key for manual pagination.`),process.exit(1));let d=await r.getMyAgents(t,s,{limit:e.limit,nextKey:n});if(i.push(...d.agents),n=d.nextKey,!e.all||!n)break}if(e.json){console.log(JSON.stringify({agents:i,nextKey:n}));return}if(i.length===0){console.log("You have no agents in this workspace.");return}A(i),!e.all&&n&&console.log(`Next page: --next-key ${n}`);return}if(e.all){let n=[],l;for(let c=0;;c++){c>=100&&(console.error("Reached maximum page limit (100). Use --limit and --next-key for manual pagination."),process.exit(1));let d=await r.getAgents(t,s,{limit:e.limit??100,nextKey:l});if(n.push(...d.agents),l=d.nextKey,!l)break}if(e.json){console.log(JSON.stringify({agents:n}));return}if(n.length===0){console.log("No agents found in this workspace.");return}w(n);return}let{agents:g,nextKey:p}=await r.getAgents(t,s,{limit:e.limit,nextKey:e.nextKey});if(e.json){console.log(JSON.stringify({agents:g,nextKey:p}));return}if(g.length===0){console.log("No agents found in this workspace.");return}w(g),p&&console.log(`Next page: --next-key ${p}`)}catch(o){y(o)}}export{P as runAgents};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as s,b as c}from"./chunk-ZIAOI7B2.js";var O=c((ur,V)=>{"use strict";var g=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ne=Object.getOwnPropertyNames,se=Object.prototype.hasOwnProperty,ie=(e,r)=>{for(var t in r)g(e,t,{get:r[t],enumerable:!0})},ae=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ne(r))!se.call(e,o)&&o!==t&&g(e,o,{get:()=>r[o],enumerable:!(n=oe(r,o))||n.enumerable});return e},ce=e=>ae(g({},"__esModule",{value:!0}),e),S={};ie(S,{VercelOidcTokenError:()=>w});V.exports=ce(S);var w=class extends Error{constructor(r,t){super(r),this.name="VercelOidcTokenError",this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}}});var M=c((pr,I)=>{"use strict";var ue=Object.create,h=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyNames,fe=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty,de=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},C=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of le(r))!_e.call(e,o)&&o!==t&&h(e,o,{get:()=>r[o],enumerable:!(n=pe(r,o))||n.enumerable});return e},b=(e,r,t)=>(t=e!=null?ue(fe(e)):{},C(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),he=e=>C(h({},"__esModule",{value:!0}),e),R={};de(R,{findRootDir:()=>ye,getUserDataDir:()=>we});I.exports=he(R);var f=b(s("path")),ve=b(s("fs")),P=b(s("os")),ke=O();function ye(){try{let e=process.cwd();for(;e!==f.default.dirname(e);){let r=f.default.join(e,".vercel");if(ve.default.existsSync(r))return e;e=f.default.dirname(e)}}catch{throw new ke.VercelOidcTokenError("Token refresh only supported in node server environments")}return null}function we(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(P.default.platform()){case"darwin":return f.default.join(P.default.homedir(),"Library/Application Support");case"linux":return f.default.join(P.default.homedir(),".local/share");case"win32":return process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:null;default:return null}}});var L=c((lr,J)=>{"use strict";var ge=Object.create,v=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Pe=Object.getOwnPropertyNames,be=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty,Te=(e,r)=>{for(var t in r)v(e,t,{get:r[t],enumerable:!0})},N=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Pe(r))!je.call(e,o)&&o!==t&&v(e,o,{get:()=>r[o],enumerable:!(n=Oe(r,o))||n.enumerable});return e},q=(e,r,t)=>(t=e!=null?ge(be(e)):{},N(r||!e||!e.__esModule?v(t,"default",{value:e,enumerable:!0}):t,e)),Ee=e=>N(v({},"__esModule",{value:!0}),e),$={};Te($,{isValidAccessToken:()=>Ae,readAuthConfig:()=>De,writeAuthConfig:()=>xe});J.exports=Ee($);var _=q(s("fs")),F=q(s("path")),me=B();function U(){let e=(0,me.getVercelDataDir)();if(!e)throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return F.join(e,"auth.json")}function De(){try{let e=U();if(!_.existsSync(e))return null;let r=_.readFileSync(e,"utf8");return r?JSON.parse(r):null}catch{return null}}function xe(e){let r=U(),t=F.dirname(r);_.existsSync(t)||_.mkdirSync(t,{mode:504,recursive:!0}),_.writeFileSync(r,JSON.stringify(e,null,2),{mode:384})}function Ae(e,r=0){if(!e.token)return!1;if(typeof e.expiresAt!="number")return!0;let t=Math.floor(Date.now()/1e3),n=r/1e3;return e.expiresAt>=t+n}});var X=c((fr,G)=>{"use strict";var E=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,Ce=Object.prototype.hasOwnProperty,Re=(e,r)=>{for(var t in r)E(e,t,{get:r[t],enumerable:!0})},Ie=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ve(r))!Ce.call(e,o)&&o!==t&&E(e,o,{get:()=>r[o],enumerable:!(n=Se(r,o))||n.enumerable});return e},Me=e=>Ie(E({},"__esModule",{value:!0}),e),H={};Re(H,{processTokenResponse:()=>Ue,refreshTokenRequest:()=>Fe});G.exports=Me(H);var j=s("os"),Ne="https://vercel.com",qe="cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp",z=`@vercel/oidc node-${process.version} ${(0,j.platform)()} (${(0,j.arch)()}) ${(0,j.hostname)()}`,T=null;async function $e(){if(T)return T;let e=`${Ne}/.well-known/openid-configuration`,r=await fetch(e,{headers:{"user-agent":z}});if(!r.ok)throw new Error("Failed to discover OAuth endpoints");let t=await r.json();if(!t||typeof t.token_endpoint!="string")throw new Error("Invalid OAuth discovery response");let n=t.token_endpoint;return T=n,n}async function Fe(e){let r=await $e();return await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","user-agent":z},body:new URLSearchParams({client_id:qe,grant_type:"refresh_token",...e})})}async function Ue(e){let r=await e.json();if(!e.ok){let t=typeof r=="object"&&r&&"error"in r?String(r.error):"Token refresh failed";return[new Error(t)]}return typeof r!="object"||r===null?[new Error("Invalid token response")]:typeof r.access_token!="string"?[new Error("Missing access_token in response")]:r.token_type!=="Bearer"?[new Error("Invalid token_type in response")]:typeof r.expires_in!="number"?[new Error("Missing expires_in in response")]:[null,r]}});var Z=c((_r,Q)=>{"use strict";var x=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Le=Object.getOwnPropertyNames,Be=Object.prototype.hasOwnProperty,He=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},ze=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Le(r))!Be.call(e,o)&&o!==t&&x(e,o,{get:()=>r[o],enumerable:!(n=Je(r,o))||n.enumerable});return e},Ge=e=>ze(x({},"__esModule",{value:!0}),e),Y={};He(Y,{AccessTokenMissingError:()=>m,RefreshAccessTokenFailedError:()=>D});Q.exports=Ge(Y);var m=class extends Error{constructor(){super("No authentication found. Please log in with the Vercel CLI (vercel login)."),this.name="AccessTokenMissingError"}},D=class extends Error{constructor(r){super("Failed to refresh authentication token.",{cause:r}),this.name="RefreshAccessTokenFailedError"}}});var B=c((dr,te)=>{var Xe=Object.create,k=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Qe=Object.getOwnPropertyNames,Ze=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty,We=(e,r)=>{for(var t in r)k(e,t,{get:r[t],enumerable:!0})},W=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Qe(r))!Ke.call(e,o)&&o!==t&&k(e,o,{get:()=>r[o],enumerable:!(n=Ye(r,o))||n.enumerable});return e},ee=(e,r,t)=>(t=e!=null?Xe(Ze(e)):{},W(r||!e||!e.__esModule?k(t,"default",{value:e,enumerable:!0}):t,e)),er=e=>W(k({},"__esModule",{value:!0}),e),re={};We(re,{assertVercelOidcTokenResponse:()=>A,findProjectInfo:()=>nr,getTokenPayload:()=>ar,getVercelDataDir:()=>rr,getVercelOidcToken:()=>or,getVercelToken:()=>tr,isExpired:()=>cr,loadToken:()=>ir,saveToken:()=>sr});te.exports=er(re);var d=ee(s("path")),i=ee(s("fs")),l=O(),y=M(),u=L(),K=X(),p=Z();function rr(){let e="com.vercel.cli",r=(0,y.getUserDataDir)();return r?d.join(r,e):null}async function tr(e){let r=(0,u.readAuthConfig)();if(!r?.token)throw new p.AccessTokenMissingError;if((0,u.isValidAccessToken)(r,e?.expirationBufferMs))return r.token;if(!r.refreshToken)throw(0,u.writeAuthConfig)({}),new p.RefreshAccessTokenFailedError("No refresh token available");try{let t=await(0,K.refreshTokenRequest)({refresh_token:r.refreshToken}),[n,o]=await(0,K.processTokenResponse)(t);if(n||!o)throw(0,u.writeAuthConfig)({}),new p.RefreshAccessTokenFailedError(n);let a={token:o.access_token,expiresAt:Math.floor(Date.now()/1e3)+o.expires_in};return o.refresh_token&&(a.refreshToken=o.refresh_token),(0,u.writeAuthConfig)(a),a.token}catch(t){throw(0,u.writeAuthConfig)({}),t instanceof p.AccessTokenMissingError||t instanceof p.RefreshAccessTokenFailedError?t:new p.RefreshAccessTokenFailedError(t)}}async function or(e,r,t){let n=`https://api.vercel.com/v1/projects/${r}/token?source=vercel-oidc-refresh${t?`&teamId=${t}`:""}`,o=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!o.ok)throw new l.VercelOidcTokenError(`Failed to refresh OIDC token: ${o.statusText}`);let a=await o.json();return A(a),a}function A(e){if(!e||typeof e!="object")throw new TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!("token"in e)||typeof e.token!="string")throw new TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function nr(){let e=(0,y.findRootDir)();if(!e)throw new l.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let r=d.join(e,".vercel","project.json");if(!i.existsSync(r))throw new l.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let t=JSON.parse(i.readFileSync(r,"utf8"));if(typeof t.projectId!="string"&&typeof t.orgId!="string")throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:t.projectId,teamId:t.orgId}}function sr(e,r){let t=(0,y.getUserDataDir)();if(!t)throw new l.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let n=d.join(t,"com.vercel.token",`${r}.json`),o=JSON.stringify(e);i.mkdirSync(d.dirname(n),{mode:504,recursive:!0}),i.writeFileSync(n,o),i.chmodSync(n,432)}function ir(e){let r=(0,y.getUserDataDir)();if(!r)throw new l.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let t=d.join(r,"com.vercel.token",`${e}.json`);if(!i.existsSync(t))return null;let n=JSON.parse(i.readFileSync(t,"utf8"));return A(n),n}function ar(e){let r=e.split(".");if(r.length!==3)throw new l.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let t=r[1].replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(t.length+(4-t.length%4)%4,"=");return JSON.parse(Buffer.from(n,"base64").toString("utf8"))}function cr(e,r=0){return e.exp*1e3<Date.now()+r}});export{O as a,B as b};