@entrydesk/cli 2.2.0-beta.1 → 2.2.0-beta.2

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 (64) hide show
  1. package/README.md +2 -2
  2. package/dist/{add-BJv6tPO-.js → add-BYupRwo_.js} +1 -1
  3. package/dist/{agents-fP3hIH7X.js → agents-CeXkI4US.js} +1 -1
  4. package/dist/billing-BeaQvLSK.js +10 -0
  5. package/dist/{budget-MVbF8WbS.js → budget-B4SKcu-1.js} +1 -1
  6. package/dist/build-task-request-config-eOeyGAfk.js +10 -0
  7. package/dist/{commands-CfDSEDKI.js → commands-Bisc9IY0.js} +1 -1
  8. package/dist/{commands-DU48SG8W.js → commands-Drf0_Uu8.js} +1 -1
  9. package/dist/{config-Cl-c7scx.js → config-ROg2C1qz.js} +1 -1
  10. package/dist/{connectors-DVzXDbUU.js → connectors-jktsuWlk.js} +2 -2
  11. package/dist/{file-upload-Dq6B0x4m.js → file-upload-ClVCUJp1.js} +1 -1
  12. package/dist/{format-CIj0qQba.js → format-B6a10P86.js} +1 -1
  13. package/dist/index.js +19 -19
  14. package/dist/{instruction-6ZWRQh4G.js → instruction-D0Sy5WJu.js} +1 -1
  15. package/dist/{login-CO1aBG6c.js → login-7nuzjqqL.js} +1 -1
  16. package/dist/{logout-WKIZVWJ7.js → logout-O7uVmxmK.js} +1 -1
  17. package/dist/{marketplace-C0C2JpYf.js → marketplace-8V1DNOld.js} +1 -1
  18. package/dist/{mcp-CqMrd5AI.js → mcp-DwMCTWU-.js} +1 -1
  19. package/dist/{mcp-client-CEH9X7Vs.js → mcp-client-DpDabxv9.js} +1 -1
  20. package/dist/{meeting-C5vHfcTw.js → meeting-DCMyPA59.js} +1 -1
  21. package/dist/{message-utils-D48Yqd9T.js → message-utils-C6JS91tT.js} +5 -5
  22. package/dist/{models-BENTHton.js → models-BdxCIBZD.js} +1 -1
  23. package/dist/{notifications-DdadH0Wc.js → notifications-BZxmGqEM.js} +1 -1
  24. package/dist/{paginate-Cbe4RaEq.js → paginate-B-nHzQ0j.js} +1 -1
  25. package/dist/{paths-BiowKnkz.js → paths-ZPsPG0IC.js} +1 -1
  26. package/dist/{profile-hhU_G-Ea.js → profile-D4jP-vQE.js} +1 -1
  27. package/dist/profile-storage--QCh_u_Q.js +73 -0
  28. package/dist/{project-xiz3Jopl.js → project-Ba5LBPMF.js} +1 -1
  29. package/dist/project-context-8lb14kaU.js +10 -0
  30. package/dist/{project-governance-R__UPIhr.js → project-governance-B66BEQxO.js} +1 -1
  31. package/dist/{project-sources-C-MXx6j-.js → project-sources-D4m1oEvu.js} +1 -1
  32. package/dist/{project-sources-write-ygvHaDUu.js → project-sources-write-CCICd6f8.js} +1 -1
  33. package/dist/{project-tasks-B0STK_8Q.js → project-tasks-ylwpld2n.js} +1 -1
  34. package/dist/push-CNZNGP6D.js +10 -0
  35. package/dist/{recordings-68Oe1Kvd.js → recordings-DpDUq0iw.js} +1 -1
  36. package/dist/{remove-C7BCBdoq.js → remove-CbGljmXk.js} +1 -1
  37. package/dist/{resolve-IOW00hfy.js → resolve-Di6ohyyF.js} +2 -2
  38. package/dist/{resource-grants-Bb4evqsH.js → resource-grants-DojPWFs8.js} +1 -1
  39. package/dist/{schedules-wopieg4D.js → schedules-CTFIi2SL.js} +2 -2
  40. package/dist/{skills-Drr0gw-l.js → skills-DbFd9oBS.js} +1 -1
  41. package/dist/{status-Bw2E5bfa.js → status-Br8KI96N.js} +1 -1
  42. package/dist/{status-DX6A6ugk.js → status-DLI2OgMv.js} +1 -1
  43. package/dist/task-CRwWxEOf.js +116 -0
  44. package/dist/{tasks-lK8PTMnE.js → tasks-CNUJbs7w.js} +1 -1
  45. package/dist/tasks-VEfTbXVT.js +22 -0
  46. package/dist/{team-8-enl9cj.js → team-BfBb-uk2.js} +1 -1
  47. package/dist/{teams-ByeuT2Ks.js → teams-47YS8wYw.js} +1 -1
  48. package/dist/{token-DrAF7BWj.js → token-CvjOXFDB.js} +1 -1
  49. package/dist/{tool-82NKBr29.js → tool-D_n28XK0.js} +7 -7
  50. package/dist/{update-DfOBWme1.js → update-B8gxXkSO.js} +1 -1
  51. package/dist/{usage-BS_didkP.js → usage-BPyHU-GL.js} +1 -1
  52. package/dist/{usage-audit-DOuyWGaq.js → usage-audit-STxCfVta.js} +1 -1
  53. package/dist/{version-D7DOD1ug.js → version-Ca4arzgb.js} +1 -1
  54. package/dist/{webhook-Da2l-gv6.js → webhook-B0E0M2EK.js} +1 -1
  55. package/dist/{workflow-oudE3gsp.js → workflow-B-iN8d5R.js} +1 -1
  56. package/dist/{workspaces-9SRfDSh3.js → workspaces-DmqtYNX1.js} +1 -1
  57. package/package.json +5 -5
  58. package/dist/billing-Cy0BYngu.js +0 -10
  59. package/dist/build-task-request-config-BzI-dDZP.js +0 -10
  60. package/dist/profile-storage-CKrZ-xsd.js +0 -73
  61. package/dist/project-context-DeYepfN2.js +0 -10
  62. package/dist/push-BxQQWCZ2.js +0 -10
  63. package/dist/task-bZNZ_yxV.js +0 -116
  64. package/dist/tasks-ZC9uSdkB.js +0 -22
@@ -7,4 +7,4 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{n as e}from"./tasks-ZC9uSdkB.js";export{e as runTasks};
10
+ import{n as e}from"./tasks-VEfTbXVT.js";export{e as runTasks};
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ var __entrydeskNodeFloor = 24;
3
+ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
4
+ process.stderr.write(
5
+ 'entrydesk: Node.js ' + __entrydeskNodeFloor + ' or newer is required, but this is Node ' + process.versions.node + '.\n' +
6
+ 'Upgrade Node (https://nodejs.org/en/download), then reinstall @entrydesk/cli.\n'
7
+ );
8
+ process.exit(1);
9
+ }
10
+ import{C as e,Tn as t,d as n,p as r,s as i}from"./profile-storage--QCh_u_Q.js";import{n as a,r as o,t as s}from"./terminal-text-cBPBiP3x.js";import{d as c,i as l,o as u,p as d,t as f}from"./resolve-Di6ohyyF.js";import{a as p,i as m,n as h,r as g,s as _}from"./message-utils-C6JS91tT.js";const v=`\x1B[2m`,y=`\x1B[0m`,b=`\x1B[36m`,x=`\x1B[33m`,S=`\x1B[32m`;function C(e,t){let n=t===void 0?{event:e}:{event:e,data:t};process.stdout.write(`${s(n)}\n`)}function w(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/(1e3*60*60*24));return r===0?t.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):r===1?`Yesterday`:r<7?`${r} days ago`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function T(e){return e.replace(/<mark>/g,`\x1B[1m`).replace(/<\/mark>/g,y).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&amp;/g,`&`)}function E(e,t){if(t)return e;let n=e.split(`
11
+ `);if(n.length<=15)return e;let r=n.slice(0,6),i=n.slice(-4),a=n.length-10;return[...r,`… (${a} lines omitted, use --full-output to see all) …`,...i].join(`
12
+ `)}function D(e){if(Array.isArray(e))return e.map(D);if(!t(e))return e;let n={};for(let[t,r]of Object.entries(e))typeof r==`string`&&r.length>200?n[t]=r.slice(0,150)+`… (truncated)`:typeof r==`object`&&r?n[t]=D(r):n[t]=r;return n}function O(e){if(!e||typeof e!=`object`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function k(e){return o(O(e))}function A(e,n){if(!e)return`(no result)`;if(typeof e!=`object`)return E(o(String(e)),n);let r=n?e:D(e),i=t(r)?r:{},a=i.structuredContent;if(a){let e=t(a)?a:{},r=[];if(e.stdout&&typeof e.stdout==`string`&&e.stdout.trim()&&r.push(o(e.stdout.trim())),e.stderr&&typeof e.stderr==`string`&&e.stderr.trim()&&r.push(`${x}[stderr]${y} ${o(e.stderr.trim())}`),e.urls&&Array.isArray(e.urls)){let t=e.urls;for(let e of t)e.path&&e.url&&r.push(o(`${e.path}: ${e.url}`))}return r.length===0&&r.push(o(JSON.stringify(a,null,2))),E(r.join(`
13
+ `),n)}return`content`in i&&Array.isArray(i.content)?E(o(i.content.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
14
+ `)||JSON.stringify(e,null,2)),n):i.type===`text`&&typeof i.content==`string`?E(o(i.content),n):E(o(JSON.stringify(e,null,2)),n)}function j(e){if(typeof e.title==`string`)return e.title;if(typeof e.toolName==`string`)return e.toolName;let t=e.type;return t.startsWith(`tool-`)?t.slice(5).replaceAll(`__`,` `).replace(/_/g,` `):t}function M(e,t){let n=[];for(let r of e)if(r.type===`reasoning`&&r.text)n.push(`${v}${o(r.text)}${y}`);else if(r.type===`text`&&r.text)n.push(o(r.text));else if(r.type===`data-background-run-receipt`){let e=h(r.data);e&&n.push(e)}else if(r.type===`tool-call`&&r.toolName){let e=[`${b}┌─ Tool: ${a(String(r.toolName))}${y}`];if(r.args){e.push(`${x}│ Input:${y}`);let t=k(r.args);for(let n of t.split(`
15
+ `))e.push(`${v}│ ${n}${y}`)}if(r.result!==void 0){e.push(`${S}│ Output:${y}`);let n=A(r.result,t);for(let t of n.split(`
16
+ `))e.push(`${v}│ ${t}${y}`);e.push(`${b}└─ ${r.toolName} completed${y}`)}else r.state===`call`?e.push(`${b}└─ (awaiting result)${y}`):e.push(`${b}└─${y}`);n.push(e.join(`
17
+ `))}else if(r.type.startsWith(`tool-`)&&r.type!==`tool-call`){if(p(r))continue;let e=g(r);if(e){n.push(e);continue}let i=a(j(r)),s=[`${b}┌─ Tool: ${i}${y}`];if(r.input){s.push(`${x}│ Input:${y}`);let e=k(r.input);for(let t of e.split(`
18
+ `))s.push(`${v}│ ${t}${y}`)}let c=_({state:r.state,output:r.output,errorText:r.errorText});if(r.output!==void 0&&r.state===`output-available`){s.push(`${S}│ Output:${y}`);let e=A(r.output,t);for(let t of e.split(`
19
+ `))s.push(`${v}│ ${t}${y}`);let n=m(r.approval);n&&s.push(`${v}│ ${n}${y}`),s.push(`${b}└─ completed${y}`)}else c===void 0?r.state===`call`||r.state===`partial-call`?s.push(`${b}└─ (in progress)${y}`):s.push(`${b}└─${y}`):(c&&s.push(`${v}│ ${o(c)}${y}`),s.push(`${b}└─ failed${y}`));n.push(s.join(`
20
+ `))}return n.join(`
21
+
22
+ `).trim()}function N(){return{empty:'No tasks yet. Start one with `entrydesk task -m "..."`.',heading:e=>`Recent tasks (${e}):`,label:(e,t)=>`${(t+1).toString().padStart(2,` `)}.`,footer:e=>["Use `entrydesk tasks 1` to view the most recent task",'Use `entrydesk task -c 1 -m "message"` to continue it',...e?[`Next page: --next-key ${e}`]:[]]}}function P(e){return{empty:`No tasks you can see in this project yet. Start one with \`entrydesk task --project ${e} -m "..."\`.`,heading:e=>`Tasks in this project (${e}):`,label:e=>`${v}${e.id}${y}`,footer:e=>["Use `entrydesk tasks <taskId>` to view one of them",...e?[`Next page: --next-key ${e}`]:[]]}}async function F(t,a){let o=a.output!==void 0,p=new e;if(t&&a.project&&await c(a,new u(`project_not_applicable`,"`--project` narrows the listing and the search; drop it to view a task.")),a.share){let e;try{e=await n()}catch{}try{let t=await p.getSharedTask(a.share,e),{messages:n}=await p.getSharedMessages(a.share,50,e);if(a.json){console.log(s({task:t,messages:n}));return}if(o){if(C(`task`,t),n.length===0)C(`info`,`No messages in this shared task.`);else for(let e of n.toReversed())C(`message`,e);C(`done`);return}if(console.log(`Shared task: ${t.title||`Untitled`}`),console.log(`Visibility: ${t.visibility}`),t.agent&&console.log(`Agent: ${t.agent.name}`),console.log(`${n.length} messages\n`),n.length===0){console.log(`No messages in this shared task.`);return}let r=n.toReversed(),i=a.fullOutput??!1;for(let e of r){let t=M(e.parts,i);if(!t)continue;let n=e.role===`user`?`You`:`Assistant`;console.log(`[${n}] ${w(e.createdAt)}`),console.log(t),console.log(``)}return}catch(e){if(e instanceof Error){let t=e.message.toLowerCase();t.includes(`401`)||t.includes(`unauthorized`)?console.error(`Access denied. This shared task requires authentication or is not accessible to you.`):t.includes(`404`)||t.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: ${e.message}`)}else console.error(`Failed to fetch shared task`);process.exit(1)}}let m=a.project?await l(a.project,a.json??!1):void 0,h=e=>m?d({json:a.json??!1},e,`tasks:read`):e(),g,_;try{let e=await r();g=e.accessToken,_=e.workspaceId}catch(e){i(e)}if(t){let e=t,n=!1,r=null,i=Number.parseInt(t,10);if(!Number.isNaN(i)&&i>=0&&/^\d+$/.test(t)){let t=i===0?1:i,{tasks:a}=await p.getTasks(g,_),s=a[t-1];s===void 0&&(console.error(`Task number ${t} not found. You have ${a.length} recent tasks.`),process.exit(1)),e=s.id,n=!0,r=s,o||console.log(`Task: ${s.title||`Untitled`}\n`)}let{messages:c}=await p.getMessages(g,_,e,50);if(a.json){console.log(s(c));return}if(o){if(r&&C(`task`,r),c.length===0)C(`info`,`No messages in this task.`);else for(let e of c.toReversed())C(`message`,e);C(`done`);return}if(c.length===0){console.log(`No messages in this task.`);return}let l=c.toReversed(),u=a.fullOutput??!1;n||console.log(`Task: ${t.slice(0,8)}…`),console.log(`${c.length} messages\n`);for(let e of l){let t=M(e.parts,u);if(!t)continue;let n=e.role===`user`?`You`:`Assistant`;console.log(`[${n}] ${w(e.createdAt)}`),console.log(t),console.log(``)}return}let b=a.search;if(b){m&&await h(()=>f({client:p,accessToken:g,workspaceId:_},m));let{results:e,nextKey:t}=await h(()=>p.searchTasks(g,_,b,{limit:a.limit,nextKey:a.nextKey,projectId:m}));if(o){for(let t of e)C(`task`,t);C(`done`);return}if(a.json){console.log(s({results:e,nextKey:t}));return}if(e.length===0){console.log(`No tasks match "${a.search}".`);return}console.log(`Search results for "${a.search}" (${e.length}):\n`);for(let[t,n]of e.entries()){let e=(t+1).toString().padStart(2,` `),r=n.titleHighlight?T(n.titleHighlight):n.title||`Untitled`;console.log(` ${e}. ${v}${w(n.createdAt)}${y} ${r}`),n.contentSnippet&&console.log(` ${T(n.contentSnippet)}`),console.log(` ${v}ID: ${n.id}${y}`)}t&&console.log(`\nNext page: --next-key ${t}`);return}let S=m&&a.project?P(a.project):N(),{tasks:E,nextKey:D}=await h(()=>p.getTasks(g,_,{limit:a.limit,nextKey:a.nextKey,projectId:m}));if(o){for(let e of E)C(`task`,e);C(`done`);return}if(a.json){console.log(s(E));return}if(E.length===0){console.log(S.empty);return}console.log(`${S.heading(E.length)}\n`);for(let[e,t]of E.entries()){let n=t.waitingReason===`approval`?` ${x}[waiting approval]${y}`:t.waitingReason===`client`?` ${x}[waiting device]${y}`:t.waitingReason===`background`?` [waiting background]${y}`:``;console.log(` ${S.label(t,e)} ${w(t.createdAt).padEnd(12)} ${t.title||`Untitled`}${n}`)}console.log(``);for(let e of S.footer(D))console.log(e)}export{F as n,T as t};
@@ -7,5 +7,5 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{O as e}from"./profile-storage-CKrZ-xsd.js";import{o as t}from"./resolve-IOW00hfy.js";import{validate as n}from"uuid";function r(t){return t.map(t=>` - ${e(t.name)} (${t.teamId})`).join(`
10
+ import{O as e}from"./profile-storage--QCh_u_Q.js";import{o as t}from"./resolve-Di6ohyyF.js";import{validate as n}from"uuid";function r(t){return t.map(t=>` - ${e(t.name)} (${t.teamId})`).join(`
11
11
  `)}function i(e){return e.toLocaleLowerCase(`en`)}function a(e,i,a){return new t(`project_team_not_found`,`${n(e)?`No team with id ${e}.`:`No team named "${e}".`} ${i}${a.length>0?`\nA name has to match exactly, including case. Teams with a similar name:\n${r(a)}`:``}`)}function o(e,t){return e.teamId.toLowerCase()===t.toLowerCase()}function s(e,t){return n(t)?e.filter(e=>o(e,t)):e.filter(e=>e.name===t)}function c(e,o,c){let l=s(e,o),[u]=l;if(l.length===1&&u!==void 0)return u;if(l.length>1)throw new t(`team_ambiguous`,`More than one team is named "${o}". Pass one of these ids with --team:\n${r(l)}`);if(n(o))throw a(o,c,[]);let d=i(o);throw a(o,c,e.filter(e=>i(e.name).includes(d)))}export{c as n,s as t};
@@ -7,4 +7,4 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{C as e,O as t,p as n}from"./profile-storage-CKrZ-xsd.js";import{t as r}from"./terminal-text-cBPBiP3x.js";async function i(i){let{accessToken:a,workspaceId:o}=await n(),s=new e,c=[],l;do{let e=await s.listTeams(a,o,{nextKey:l,search:i.search});c.push(...e.teams),l=e.nextKey}while(l);if(i.json){console.log(r(c));return}if(c.length===0){console.log(`No teams found.`);return}console.log(`Teams (${c.length}):\n`);for(let e of c){let n=e.currentUserRole?` · you are ${e.currentUserRole}`:``;console.log(` ${t(e.name)} (${e.memberCount} members, ${e.visibility}${n})`),console.log(` ID: ${e.id}`),console.log(``)}}export{i as listTeams};
10
+ import{C as e,O as t,p as n}from"./profile-storage--QCh_u_Q.js";import{t as r}from"./terminal-text-cBPBiP3x.js";async function i(i){let{accessToken:a,workspaceId:o}=await n(),s=new e,c=[],l;do{let e=await s.listTeams(a,o,{nextKey:l,search:i.search});c.push(...e.teams),l=e.nextKey}while(l);if(i.json){console.log(r(c));return}if(c.length===0){console.log(`No teams found.`);return}console.log(`Teams (${c.length}):\n`);for(let e of c){let n=e.currentUserRole?` · you are ${e.currentUserRole}`:``;console.log(` ${t(e.name)} (${e.memberCount} members, ${e.visibility}${n})`),console.log(` ID: ${e.id}`),console.log(``)}}export{i as listTeams};
@@ -7,4 +7,4 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{f as e,u as t}from"./profile-storage-CKrZ-xsd.js";async function n(n){let{accessToken:r,workspaceId:i}=await e();if(!n.json){process.stdout.write(`${r}\n`);return}let a=t(r)?.exp;process.stdout.write(`${JSON.stringify({token:r,expiresAt:typeof a==`number`?new Date(a*1e3).toISOString():void 0,workspaceId:i})}\n`)}export{n as printAccessToken};
10
+ import{f as e,u as t}from"./profile-storage--QCh_u_Q.js";async function n(n){let{accessToken:r,workspaceId:i}=await e();if(!n.json){process.stdout.write(`${r}\n`);return}let a=t(r)?.exp;process.stdout.write(`${JSON.stringify({token:r,expiresAt:typeof a==`number`?new Date(a*1e3).toISOString():void 0,workspaceId:i})}\n`)}export{n as printAccessToken};
@@ -7,11 +7,11 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{Tn as e,Yt as t,c as n,i as r,l as i}from"./profile-storage-CKrZ-xsd.js";import{t as a}from"./terminal-text-cBPBiP3x.js";import{n as o,r as s}from"./mcp-client-CEH9X7Vs.js";import{t as c}from"./stdin-B18x8pUF.js";import l from"node:fs";import u from"node:os";import d from"node:path";import f from"node:fs/promises";const p=!process.env.NO_COLOR&&process.stdout.isTTY,m={green:p?`\x1B[32m`:``,yellow:p?`\x1B[33m`:``,reset:p?`\x1B[0m`:``},h=8*1024;function g(){return d.join(u.homedir(),`.entrydesk`,`tool-results`)}function _(e){let t=e.trim().replace(/[/\\:*?"<>|\s]/g,`_`).replace(/_+/g,`_`).replace(/^[._]+|[._]+$/g,``).slice(0,100);return!t||t===`.`||t===`..`?`unnamed_tool`:t}function v(e){try{return JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}n`:typeof t==`function`?`[Function]`:typeof t==`symbol`?t.toString():t,2)}catch{return String(e)}}function y(e){let t=new Date;return`${[t.getFullYear(),String(t.getMonth()+1).padStart(2,`0`),String(t.getDate()).padStart(2,`0`)].join(`-`)+`_`+[String(t.getHours()).padStart(2,`0`),String(t.getMinutes()).padStart(2,`0`),String(t.getSeconds()).padStart(2,`0`)].join(`-`)}_${_(e)}.json`}async function b(e,t){try{return await f.writeFile(e,t,{encoding:`utf8`,flag:`wx`}),!0}catch(e){if(e instanceof Error&&`code`in e&&e.code===`EEXIST`)return!1;throw e}}async function x(e,t){try{let n=g();await f.mkdir(n,{recursive:!0});let r=y(e),i=d.extname(r),a=r.slice(0,-i.length),o=v(t),s=d.join(n,r);if(await b(s,o))return s;for(let e=1;e<=100;e++){let t=d.join(n,`${a}-${e}${i}`);if(await b(t,o))return t}let c=Math.random().toString(36).slice(2,10),l=d.join(n,`${a}-${c}${i}`);return await f.writeFile(l,o,{encoding:`utf8`,flag:`wx`}),l}catch(e){let t=e instanceof Error?e.message:`unknown error`;return console.error(`${m.yellow}Warning: Could not save result to file: ${t}${m.reset}`),null}}function S(e,t){let n=Buffer.byteLength(e,`utf8`);if(n<=10240)return e;let r=e.slice(0,h),i=e.slice(-2048),a=` … (skipped ${((n-h-2048)/1024).toFixed(1)}KB of ${(n/1024).toFixed(1)}KB) …`;return t&&(a+=`
11
- Tip: jq -r '.structuredContent.field' <file> | grep/head/tail`),`${r}\n\n${a}\n\n${i}`}function C(e){console.log(`${m.green}Tool execution result saved to: ${e}${m.reset}`),console.log()}function w(){console.log(`${m.green}Tool execution result:${m.reset}`)}function T(t){return e(t)&&typeof t.name==`string`&&(t.description===void 0||typeof t.description==`string`)}function E(t){return Array.isArray(t.primaryTools)&&t.primaryTools.every(T)&&(t.relatedTools===void 0||Array.isArray(t.relatedTools)&&t.relatedTools.every(T))&&(t.toolSchemas===void 0||e(t.toolSchemas))&&(t.authStatuses===void 0||Array.isArray(t.authStatuses)&&t.authStatuses.every(t=>e(t)&&typeof t.toolNamespace==`string`&&typeof t.connected==`boolean`&&(t.authStatusMessage===void 0||typeof t.authStatusMessage==`string`)))&&[t.recommendedPlanSteps,t.knownPitfalls].every(e=>e===void 0||Array.isArray(e)&&e.every(e=>typeof e==`string`))&&(t.error===null||typeof t.error==`string`)}function D(e){return e.split(`__`)[0]??e}function O(e,t,n){console.error(n?a({error:{code:e,message:t}}):`Error [${e}]: ${t}`),process.exitCode=1}function k(e,t,n){O(e,t,n),process.exit(1)}function A(e,t,a=`CONNECTION_FAILED`){if(n(e)){O(a,r(),t);return}let o=e instanceof Error?e.message:`Unknown error`;e instanceof i&&e.code===`not-logged-in`?O(`AUTH_MISSING`,o,t):O(a,o,t)}function j(e,t,n=`CONNECTION_FAILED`){A(e,t,n),process.exit(1)}var M=class extends Error{constructor(e){super(e),this.name=`InputError`}};async function N(e,t){if(e)return e;if(t)try{return l.readFileSync(t,`utf-8`).trim()}catch(e){throw new M(`Failed to read input file: ${e instanceof Error?e.message:`Failed to read input file`}`)}if(!process.stdin.isTTY){let e;try{e=await c()}catch(e){throw new M(`Failed to read stdin: ${e instanceof Error?e.message:`Failed to read stdin`}`)}let t=e.trim();if(t)return t}throw new M(`Input JSON is required. Use --input, --input-file, or pipe it via stdin.`)}function P(e){let t=[`Tool: ${e.name}`];return e.description&&t.push(` Description: ${e.description}`),t.join(`
12
- `)}async function F(e){let t=[],n=new Set,r;do{let i=await e.listTools(r?{cursor:r}:{},s());if(t.push(...i.tools),r=i.nextCursor,r){if(n.has(r))throw Error(`Tool listing returned a repeated pagination cursor`);n.add(r)}}while(r);return t}async function I(t,n,r){let i=await t.callTool({name:n,arguments:r},s());if(i.isError){let e=i.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
13
- `);throw Error(e||`Tool discovery failed: ${n}`)}if(!e(i.structuredContent))throw Error(`Tool discovery returned no structured content: ${n}`);return i.structuredContent}async function L(e,n){let r=await I(e,t.GET_TOOL_SCHEMAS,{toolNames:[n]}),i=r.errors;if(i?.length)throw Error(i.join(`
14
- `));let a=r.toolSchemas?.[n];if(a?.inputSchema)return{name:n,...a};throw Error(`Could not retrieve an input schema for ${n}. The name may be incorrect, or its connector may need authorization or be unavailable. Use entrydesk tool search "<English query>" to discover tool names, or entrydesk connectors --all to check connections.`)}async function R(e,n){let r=n.json??!1,i=await o().catch(e=>{j(e,r)}),s;try{let r=await I(i,t.SEARCH_TOOLS,{query:e,...n.namespace&&{toolNamespaces:n.namespace}});if(!E(r))throw Error(`Tool discovery returned invalid search results`);s=r}catch(e){A(e,r,`TOOL_DISCOVERY_FAILED`);return}finally{await i.close().catch(()=>{})}if(r)console.log(a(s,2));else{console.log(`Matched tools (${s.primaryTools.length}):\n`);for(let e of s.primaryTools)console.log(P(e));if(s.relatedTools?.length){console.log(`
10
+ import{Tn as e,c as t,i as n,l as r,zt as i}from"./profile-storage--QCh_u_Q.js";import{t as a}from"./terminal-text-cBPBiP3x.js";import{n as o,r as s}from"./mcp-client-DpDabxv9.js";import{t as c}from"./stdin-B18x8pUF.js";import l from"node:fs";import u from"node:os";import d from"node:path";import f from"node:fs/promises";const p=!process.env.NO_COLOR&&process.stdout.isTTY,m={green:p?`\x1B[32m`:``,yellow:p?`\x1B[33m`:``,reset:p?`\x1B[0m`:``},h=8*1024;function g(){return d.join(u.homedir(),`.entrydesk`,`tool-results`)}function _(e){let t=e.trim().replace(/[/\\:*?"<>|\s]/g,`_`).replace(/_+/g,`_`).replace(/^[._]+|[._]+$/g,``).slice(0,100);return!t||t===`.`||t===`..`?`unnamed_tool`:t}function v(e){try{return JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}n`:typeof t==`function`?`[Function]`:typeof t==`symbol`?t.toString():t,2)}catch{return String(e)}}function y(e){let t=new Date;return`${[t.getFullYear(),String(t.getMonth()+1).padStart(2,`0`),String(t.getDate()).padStart(2,`0`)].join(`-`)+`_`+[String(t.getHours()).padStart(2,`0`),String(t.getMinutes()).padStart(2,`0`),String(t.getSeconds()).padStart(2,`0`)].join(`-`)}_${_(e)}.json`}async function b(e,t){try{return await f.writeFile(e,t,{encoding:`utf8`,flag:`wx`}),!0}catch(e){if(e instanceof Error&&`code`in e&&e.code===`EEXIST`)return!1;throw e}}async function x(e,t){try{let n=g();await f.mkdir(n,{recursive:!0});let r=y(e),i=d.extname(r),a=r.slice(0,-i.length),o=v(t),s=d.join(n,r);if(await b(s,o))return s;for(let e=1;e<=100;e++){let t=d.join(n,`${a}-${e}${i}`);if(await b(t,o))return t}let c=Math.random().toString(36).slice(2,10),l=d.join(n,`${a}-${c}${i}`);return await f.writeFile(l,o,{encoding:`utf8`,flag:`wx`}),l}catch(e){let t=e instanceof Error?e.message:`unknown error`;return console.error(`${m.yellow}Warning: Could not save result to file: ${t}${m.reset}`),null}}function S(e,t){let n=Buffer.byteLength(e,`utf8`);if(n<=10240)return e;let r=e.slice(0,h),i=e.slice(-2048),a=` … (skipped ${((n-h-2048)/1024).toFixed(1)}KB of ${(n/1024).toFixed(1)}KB) …`;return t&&(a+=`
11
+ Tip: jq -r '.structuredContent.field' <file> | grep/head/tail`),`${r}\n\n${a}\n\n${i}`}function C(e){console.log(`${m.green}Tool execution result saved to: ${e}${m.reset}`),console.log()}function w(){console.log(`${m.green}Tool execution result:${m.reset}`)}function T(t){return e(t)&&typeof t.name==`string`&&(t.description===void 0||typeof t.description==`string`)}function E(t){return Array.isArray(t.primaryTools)&&t.primaryTools.every(T)&&(t.relatedTools===void 0||Array.isArray(t.relatedTools)&&t.relatedTools.every(T))&&(t.toolSchemas===void 0||e(t.toolSchemas))&&(t.authStatuses===void 0||Array.isArray(t.authStatuses)&&t.authStatuses.every(t=>e(t)&&typeof t.toolNamespace==`string`&&typeof t.connected==`boolean`&&(t.authStatusMessage===void 0||typeof t.authStatusMessage==`string`)))&&[t.recommendedPlanSteps,t.knownPitfalls].every(e=>e===void 0||Array.isArray(e)&&e.every(e=>typeof e==`string`))&&(t.error===null||typeof t.error==`string`)}function D(e){return e.split(`__`)[0]??e}function O(e,t,n){console.error(n?a({error:{code:e,message:t}}):`Error [${e}]: ${t}`),process.exitCode=1}function k(e,t,n){O(e,t,n),process.exit(1)}function A(e,i,a=`CONNECTION_FAILED`){if(t(e)){O(a,n(),i);return}let o=e instanceof Error?e.message:`Unknown error`;e instanceof r&&e.code===`not-logged-in`?O(`AUTH_MISSING`,o,i):O(a,o,i)}function j(e,t,n=`CONNECTION_FAILED`){A(e,t,n),process.exit(1)}var M=class extends Error{constructor(e){super(e),this.name=`InputError`}};async function N(e,t){if(e)return e;if(t)try{return l.readFileSync(t,`utf-8`).trim()}catch(e){throw new M(`Failed to read input file: ${e instanceof Error?e.message:`Failed to read input file`}`)}if(!process.stdin.isTTY){let e;try{e=await c()}catch(e){throw new M(`Failed to read stdin: ${e instanceof Error?e.message:`Failed to read stdin`}`)}let t=e.trim();if(t)return t}throw new M(`Input JSON is required. Use --input, --input-file, or pipe it via stdin.`)}function P(e){let t=[`Tool: ${e.name}`];return e.description&&t.push(` Description: ${e.description}`),t.join(`
12
+ `)}async function F(t,n,r){let i=await t.callTool({name:n,arguments:r},s());if(i.isError){let e=i.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
13
+ `);throw Error(e||`Tool discovery failed: ${n}`)}if(!e(i.structuredContent))throw Error(`Tool discovery returned no structured content: ${n}`);return i.structuredContent}async function I(e,t){let n=await F(e,i.GET_TOOL_SCHEMAS,{toolNames:[t]}),r=n.errors;if(r?.length)throw Error(r.join(`
14
+ `));let a=n.toolSchemas?.[t];if(a?.inputSchema)return{name:t,...a};throw Error(`Could not retrieve an input schema for ${t}. The name may be incorrect, or its connector may need authorization or be unavailable. Use entrydesk tool search "<English query>" to discover tool names, or entrydesk connectors --all to check connections.`)}async function L(e,t){let n=t.json??!1,r=await o().catch(e=>{j(e,n)}),s;try{let n=await F(r,i.SEARCH_TOOLS,{query:e,...t.namespace&&{toolNamespaces:t.namespace}});if(!E(n))throw Error(`Tool discovery returned invalid search results`);s=n}catch(e){A(e,n,`TOOL_DISCOVERY_FAILED`);return}finally{await r.close().catch(()=>{})}if(n)console.log(a(s,2));else{console.log(`Matched tools (${s.primaryTools.length}):\n`);for(let e of s.primaryTools)console.log(P(e));if(s.relatedTools?.length){console.log(`
15
15
  Related tools:`);for(let e of s.relatedTools)console.log(P(e))}for(let e of s.authStatuses??[])e.connected||console.log(`\n${e.toolNamespace}: ${e.authStatusMessage??`Not connected. Run entrydesk connectors --all to check authorization.`}`);for(let e of s.recommendedPlanSteps??[])console.log(e);for(let e of s.knownPitfalls??[])console.log(e);console.log(`
16
- Next: entrydesk tool get <name> --json`),console.log(`Then: entrydesk tool call <name> --input-file input.json --json`)}s.error&&O(`TOOL_DISCOVERY_FAILED`,s.error,r)}function z(e){let t=[`Tool: ${e.name}`];return e.description&&(t.push(`Description:`),t.push(` ${e.description}`)),t.push(`Input Schema:`),t.push(a(e.inputSchema,2)),t.join(`
17
- `)}async function B(e){let t=e.json??!1,n=await o().catch(e=>{j(e,t)});try{let r=await F(n);if(e.prefix){let t=e.prefix.toLowerCase();r=r.filter(e=>D(e.name).toLowerCase().startsWith(t))}if(t)console.log(a(r,2));else{let t=e.prefix?` (prefix: ${e.prefix})`:``;console.log(`Directly listed tools (${r.length})${t}:\n`);for(let e of r)console.log(P(e)),console.log();console.log(`Connector tools may be available without appearing here. Use entrydesk tool search "<English query>" or entrydesk tool get <name>.`)}}catch(e){j(e,t)}finally{await n.close().catch(()=>{})}}async function V(e,t){let n=t.json??!1,r=await o().catch(e=>{j(e,n)}),i;try{i=(await F(r)).find(t=>t.name===e)??await L(r,e)}catch(e){A(e,n,`TOOL_DISCOVERY_FAILED`);return}finally{await r.close().catch(()=>{})}console.log(n?a(i,2):z(i))}async function H(e,t,n){let r;try{r=JSON.parse(t)}catch(e){k(`INVALID_INPUT`,e instanceof Error?`Invalid JSON input: ${e.message}`:`Invalid JSON input`,n)}let i=await o().catch(e=>{j(e,n,`TOOL_CALL_FAILED`)}),c=!1;try{let t=await i.callTool({name:e,arguments:r},s());if(n)console.log(a(t,2));else{let n=await x(e,t);n&&C(n),w();for(let e of t.content)e.type===`text`?console.log(e.text):e.type===`image`?console.log(`[Image: ${e.mimeType}]`):e.type===`resource`?console.log(`[Resource: ${e.resource.uri}]`):console.log(a(e,2));if(t.structuredContent){let e=S(a(t.structuredContent,2),n);console.log(e)}}t.isError&&(c=!0)}catch(e){j(e,n,`TOOL_CALL_FAILED`)}finally{await i.close().catch(()=>{})}c&&process.exit(1)}async function U(e,t){let n=t.json??!1,r;try{r=await N(t.input,t.inputFile)}catch(e){throw e instanceof M&&k(`INVALID_INPUT`,e.message,n),e}await H(e,r,n)}export{V as getTool,B as listTools,U as runToolCall,R as searchTools};
16
+ Next: entrydesk tool get <name> --json`),console.log(`Then: entrydesk tool call <name> --input-file input.json --json`)}s.error&&O(`TOOL_DISCOVERY_FAILED`,s.error,n)}function R(e){let t=[`Tool: ${e.name}`];return e.description&&(t.push(`Description:`),t.push(` ${e.description}`)),t.push(`Input Schema:`),t.push(a(e.inputSchema,2)),t.join(`
17
+ `)}async function z(e){let t=e.json??!1,n=await o().catch(e=>{j(e,t)});try{let{tools:r}=await n.listTools({},s());if(e.prefix){let t=e.prefix.toLowerCase();r=r.filter(e=>D(e.name).toLowerCase().startsWith(t))}if(t)console.log(a(r,2));else{let t=e.prefix?` (prefix: ${e.prefix})`:``;console.log(`Directly listed tools (${r.length})${t}:\n`);for(let e of r)console.log(P(e)),console.log();console.log(`Connector tools may be available without appearing here. Use entrydesk tool search "<English query>" or entrydesk tool get <name>.`)}}catch(e){j(e,t)}finally{await n.close().catch(()=>{})}}async function B(e,t){let n=t.json??!1,r=await o().catch(e=>{j(e,n)}),i;try{let{tools:t}=await r.listTools({},s());i=t.find(t=>t.name===e)??await I(r,e)}catch(e){A(e,n,`TOOL_DISCOVERY_FAILED`);return}finally{await r.close().catch(()=>{})}console.log(n?a(i,2):R(i))}async function V(t,n,r){let i;try{i=JSON.parse(n)}catch(e){k(`INVALID_INPUT`,e instanceof Error?`Invalid JSON input: ${e.message}`:`Invalid JSON input`,r)}e(i)||k(`INVALID_INPUT`,`Input must be a JSON object`,r);let c=await o().catch(e=>{j(e,r,`TOOL_CALL_FAILED`)}),l=!1;try{let e=await c.callTool({name:t,arguments:i},s());if(r)console.log(a(e,2));else{let n=await x(t,e);n&&C(n),w();for(let t of e.content)t.type===`text`?console.log(t.text):t.type===`image`?console.log(`[Image: ${t.mimeType}]`):t.type===`resource`?console.log(`[Resource: ${t.resource.uri}]`):console.log(a(t,2));if(e.structuredContent){let t=S(a(e.structuredContent,2),n);console.log(t)}}e.isError&&(l=!0)}catch(e){j(e,r,`TOOL_CALL_FAILED`)}finally{await c.close().catch(()=>{})}l&&process.exit(1)}async function H(e,t){let n=t.json??!1,r;try{r=await N(t.input,t.inputFile)}catch(e){throw e instanceof M&&k(`INVALID_INPUT`,e.message,n),e}await V(e,r,n)}export{B as getTool,z as listTools,H as runToolCall,L as searchTools};
@@ -7,4 +7,4 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{r as e}from"./profile-storage-CKrZ-xsd.js";import{t}from"./version-D7DOD1ug.js";import{t as n}from"./terminal-text-cBPBiP3x.js";import r from"cross-spawn";const i=`@entrydesk/cli`;function a(e){let t=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u.exec(e.trim());return t?{nums:[Number(t[1]),Number(t[2]),Number(t[3])],prerelease:t[4]??null}:null}function o(e,t){if(e===t)return 0;if(e===null)return 1;if(t===null)return-1;let n=e.split(`.`),r=t.split(`.`);for(let[e,t]of n.entries()){let n=r[e];if(n===void 0)break;if(t!==n){let e=/^\d+$/u.test(t),r=/^\d+$/u.test(n);return e&&r?Number(t)<Number(n)?-1:1:e?-1:r?1:t<n?-1:1}}return n.length===r.length?0:n.length<r.length?-1:1}function s(e,t){let n=a(e),r=a(t);if(!n||!r)return n?1:r?-1:0;for(let[e,t]of n.nums.entries()){let n=r.nums[e];if(n!==void 0&&t!==n)return t<n?-1:1}return o(n.prerelease,r.prerelease)}function c(e,{inheritOutput:t}){return new Promise((n,i)=>{let a=r(`npm`,e,{stdio:t?[`ignore`,`inherit`,`inherit`]:[`ignore`,`pipe`,`pipe`]}),o=``,s=``;a.stdout?.on(`data`,e=>{o+=String(e)}),a.stderr?.on(`data`,e=>{s+=String(e)}),a.once(`error`,i),a.once(`close`,e=>{n({exitCode:e??1,stdout:o,stderr:s})})})}async function l(){let t;try{t=await c([`view`,i,`version`],{inheritOutput:!1})}catch(t){throw new e(`Failed to run npm — is npm installed and on your PATH?`,1,t instanceof Error?t:void 0)}let n=t.stdout.trim();if(t.exitCode!==0||!n)throw new e(`Failed to look up the latest ${i} version from the npm registry.${t.stderr?`\n${t.stderr.trim()}`:``}`);if(!a(n))throw new e(`Unexpected version from the npm registry: ${JSON.stringify(n)}`);return n}async function u(r){let a=t(),o=await l(),u=s(a,o),d=u>=0;if(r.check||d){r.json?console.log(n({current:a,latest:o,upToDate:d,updated:!1})):console.log(u>0?`entrydesk ${a} is newer than the latest published version (${o}). Nothing to do.`:d?`entrydesk ${a} is already the latest version.`:`Update available: ${a} → ${o}. Run \`entrydesk update\` to install.`);return}r.json||console.log(`Updating entrydesk ${a} → ${o}…`);let f=await c([`install`,`-g`,`${i}@${o}`],{inheritOutput:!r.json});if(f.exitCode!==0){let t=f.stderr?`\n${f.stderr.trim()}`:``;throw new e(`npm install failed (exit code ${f.exitCode}). You can update manually with \`npm install -g ${i}@latest\`.`+t,f.exitCode)}r.json?console.log(n({current:a,latest:o,upToDate:d,updated:!0})):console.log(`entrydesk updated to ${o}.`)}export{u as runUpdate};
10
+ import{r as e}from"./profile-storage--QCh_u_Q.js";import{t}from"./version-Ca4arzgb.js";import{t as n}from"./terminal-text-cBPBiP3x.js";import r from"cross-spawn";const i=`@entrydesk/cli`;function a(e){let t=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u.exec(e.trim());return t?{nums:[Number(t[1]),Number(t[2]),Number(t[3])],prerelease:t[4]??null}:null}function o(e,t){if(e===t)return 0;if(e===null)return 1;if(t===null)return-1;let n=e.split(`.`),r=t.split(`.`);for(let[e,t]of n.entries()){let n=r[e];if(n===void 0)break;if(t!==n){let e=/^\d+$/u.test(t),r=/^\d+$/u.test(n);return e&&r?Number(t)<Number(n)?-1:1:e?-1:r?1:t<n?-1:1}}return n.length===r.length?0:n.length<r.length?-1:1}function s(e,t){let n=a(e),r=a(t);if(!n||!r)return n?1:r?-1:0;for(let[e,t]of n.nums.entries()){let n=r.nums[e];if(n!==void 0&&t!==n)return t<n?-1:1}return o(n.prerelease,r.prerelease)}function c(e,{inheritOutput:t}){return new Promise((n,i)=>{let a=r(`npm`,e,{stdio:t?[`ignore`,`inherit`,`inherit`]:[`ignore`,`pipe`,`pipe`]}),o=``,s=``;a.stdout?.on(`data`,e=>{o+=String(e)}),a.stderr?.on(`data`,e=>{s+=String(e)}),a.once(`error`,i),a.once(`close`,e=>{n({exitCode:e??1,stdout:o,stderr:s})})})}async function l(){let t;try{t=await c([`view`,i,`version`],{inheritOutput:!1})}catch(t){throw new e(`Failed to run npm — is npm installed and on your PATH?`,1,t instanceof Error?t:void 0)}let n=t.stdout.trim();if(t.exitCode!==0||!n)throw new e(`Failed to look up the latest ${i} version from the npm registry.${t.stderr?`\n${t.stderr.trim()}`:``}`);if(!a(n))throw new e(`Unexpected version from the npm registry: ${JSON.stringify(n)}`);return n}async function u(r){let a=t(),o=await l(),u=s(a,o),d=u>=0;if(r.check||d){r.json?console.log(n({current:a,latest:o,upToDate:d,updated:!1})):console.log(u>0?`entrydesk ${a} is newer than the latest published version (${o}). Nothing to do.`:d?`entrydesk ${a} is already the latest version.`:`Update available: ${a} → ${o}. Run \`entrydesk update\` to install.`);return}r.json||console.log(`Updating entrydesk ${a} → ${o}…`);let f=await c([`install`,`-g`,`${i}@${o}`],{inheritOutput:!r.json});if(f.exitCode!==0){let t=f.stderr?`\n${f.stderr.trim()}`:``;throw new e(`npm install failed (exit code ${f.exitCode}). You can update manually with \`npm install -g ${i}@latest\`.`+t,f.exitCode)}r.json?console.log(n({current:a,latest:o,upToDate:d,updated:!0})):console.log(`entrydesk updated to ${o}.`)}export{u as runUpdate};
@@ -7,5 +7,5 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{C as e,p as t}from"./profile-storage-CKrZ-xsd.js";import{t as n}from"./terminal-text-cBPBiP3x.js";import{i as r,n as i}from"./format-CIj0qQba.js";import{writeFileSync as a}from"node:fs";function o(e){console.log(`Extra-usage balance: ${r(e.balanceUsd)}`);let t=e.currentSpentUsedPercent==null?``:` (${e.currentSpentUsedPercent}% of limit)`;console.log(`Spent this period: ${i(e.currentSpentUsd)}${t}`),e.monthlyExtraUsageLimitUsd!=null&&console.log(`Workspace limit: ${r(e.monthlyExtraUsageLimitUsd)} / month`),e.memberMonthlyExtraUsageLimitUsd!=null&&console.log(`Per-member limit: ${r(e.memberMonthlyExtraUsageLimitUsd)} / month`),e.nextExpiry&&console.log(`Next expiry: ${r(e.nextExpiry.amountUsd)} at ${new Date(e.nextExpiry.expiresAt).toLocaleString()}`),console.log(`Period: ${new Date(e.period.startAt).toLocaleDateString()} – ${new Date(e.period.endAt).toLocaleDateString()}`)}function s(e){console.log(`Seat type: ${e.seatType}`),e.hourly&&console.log(`Hourly used: ${e.hourly.usedPercent}%`),console.log(`Weekly used: ${e.weekly.usedPercent}%`),console.log(`Extra spent: ${i(e.extraUsage.spentUsd)}`),console.log(`Available: ${e.availability.allowed?`yes`:`no (${e.availability.reason??`unknown`})`}`),e.trial&&console.log(`Trial: ${e.trial.remainingDays} days remaining`)}function c(e){console.log(`Consumptions (${e.items.length} of ${e.total}):\n`);for(let t of e.items)console.log(` ${t.user.name} (${t.user.email})`),console.log(` Seat: ${t.seatType} · Extra usage: ${i(t.extraUsage)}`),console.log(` User ID: ${t.user.id}`),console.log(``)}async function l(r){let{accessToken:i,workspaceId:a}=await t(),s=await new e().getUsageOverview(i,a);if(r.json){console.log(n(s));return}o(s)}async function u(r){let{accessToken:i,workspaceId:a}=await t(),o=await new e().getUsageMe(i,a);if(r.json){console.log(n(o));return}s(o)}async function d(r){let{accessToken:i,workspaceId:a}=await t(),o=await new e().getUsageConsumptions(i,a,{limit:r.limit,offset:r.offset,periodStart:r.periodStart});if(r.json){console.log(n(o));return}if(o.items.length===0){console.log(`No consumptions for this period.`);return}c(o)}async function f(n){let{accessToken:r,workspaceId:i}=await t(),o=await new e().exportUsageCsv(r,i,n.periodStart);if(n.output){a(n.output,o),console.log(`Wrote usage CSV to ${n.output}`);return}process.stdout.write(o)}async function p(r){let{accessToken:a,workspaceId:o}=await t(),s=new e,c=[],l,u=0;do{let e=await s.getMonthlyUsages(a,o,{nextKey:l,limit:100});if(c.push(...e.monthlyUsages),l=e.nextKey,u++,u>=100){console.error(`Warning: Showing first ${c.length} entries (pagination limit reached)`);break}}while(l);if(r.json){console.log(n(c));return}if(c.length===0){console.log(`No usage data found for this workspace.`);return}console.log(`Current month usage:
10
+ import{C as e,p as t}from"./profile-storage--QCh_u_Q.js";import{t as n}from"./terminal-text-cBPBiP3x.js";import{i as r,n as i}from"./format-B6a10P86.js";import{writeFileSync as a}from"node:fs";function o(e){console.log(`Extra-usage balance: ${r(e.balanceUsd)}`);let t=e.currentSpentUsedPercent==null?``:` (${e.currentSpentUsedPercent}% of limit)`;console.log(`Spent this period: ${i(e.currentSpentUsd)}${t}`),e.monthlyExtraUsageLimitUsd!=null&&console.log(`Workspace limit: ${r(e.monthlyExtraUsageLimitUsd)} / month`),e.memberMonthlyExtraUsageLimitUsd!=null&&console.log(`Per-member limit: ${r(e.memberMonthlyExtraUsageLimitUsd)} / month`),e.nextExpiry&&console.log(`Next expiry: ${r(e.nextExpiry.amountUsd)} at ${new Date(e.nextExpiry.expiresAt).toLocaleString()}`),console.log(`Period: ${new Date(e.period.startAt).toLocaleDateString()} – ${new Date(e.period.endAt).toLocaleDateString()}`)}function s(e){console.log(`Seat type: ${e.seatType}`),e.hourly&&console.log(`Hourly used: ${e.hourly.usedPercent}%`),console.log(`Weekly used: ${e.weekly.usedPercent}%`),console.log(`Extra spent: ${i(e.extraUsage.spentUsd)}`),console.log(`Available: ${e.availability.allowed?`yes`:`no (${e.availability.reason??`unknown`})`}`),e.trial&&console.log(`Trial: ${e.trial.remainingDays} days remaining`)}function c(e){console.log(`Consumptions (${e.items.length} of ${e.total}):\n`);for(let t of e.items)console.log(` ${t.user.name} (${t.user.email})`),console.log(` Seat: ${t.seatType} · Extra usage: ${i(t.extraUsage)}`),console.log(` User ID: ${t.user.id}`),console.log(``)}async function l(r){let{accessToken:i,workspaceId:a}=await t(),s=await new e().getUsageOverview(i,a);if(r.json){console.log(n(s));return}o(s)}async function u(r){let{accessToken:i,workspaceId:a}=await t(),o=await new e().getUsageMe(i,a);if(r.json){console.log(n(o));return}s(o)}async function d(r){let{accessToken:i,workspaceId:a}=await t(),o=await new e().getUsageConsumptions(i,a,{limit:r.limit,offset:r.offset,periodStart:r.periodStart});if(r.json){console.log(n(o));return}if(o.items.length===0){console.log(`No consumptions for this period.`);return}c(o)}async function f(n){let{accessToken:r,workspaceId:i}=await t(),o=await new e().exportUsageCsv(r,i,n.periodStart);if(n.output){a(n.output,o),console.log(`Wrote usage CSV to ${n.output}`);return}process.stdout.write(o)}async function p(r){let{accessToken:a,workspaceId:o}=await t(),s=new e,c=[],l,u=0;do{let e=await s.getMonthlyUsages(a,o,{nextKey:l,limit:100});if(c.push(...e.monthlyUsages),l=e.nextKey,u++,u>=100){console.error(`Warning: Showing first ${c.length} entries (pagination limit reached)`);break}}while(l);if(r.json){console.log(n(c));return}if(c.length===0){console.log(`No usage data found for this workspace.`);return}console.log(`Current month usage:
11
11
  `);let d=0,f=0;for(let e of c)d+=Number.parseFloat(e.totalCost),f+=e.operationCount;console.log(`Total cost: ${i(d)}`),console.log(`Total operations: ${f.toLocaleString()}`),console.log(`Users: ${c.length}\n`);let p=[...c].toSorted((e,t)=>r.sortBy===`cost`?Number.parseFloat(t.totalCost)-Number.parseFloat(e.totalCost):t.operationCount-e.operationCount),m=r.limit??p.length,h=p.slice(0,m);console.log(`Usage by user (sorted by ${r.sortBy}, showing ${h.length} of ${c.length}):\n`);for(let e of h)console.log(` ${e.user.name} (${e.user.email})`),console.log(` Cost: ${i(e.totalCost)}`),console.log(` Operations: ${e.operationCount.toLocaleString()}`),console.log(``);h.length<c.length&&console.log(`… and ${c.length-h.length} more users`)}export{f as exportUsage,d as listUsageConsumptions,u as showOwnUsage,l as showUsageBalance,p as showUsageSummary};
@@ -7,6 +7,6 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{O as e,Zt as t,r as n}from"./profile-storage-CKrZ-xsd.js";import{t as r}from"./terminal-text-cBPBiP3x.js";import{i}from"./format-CIj0qQba.js";import{n as a,r as o}from"./mcp-client-CEH9X7Vs.js";function s(t){return Array.isArray(t)&&e(t.map(e=>typeof e==`object`&&e&&`text`in e?String(e.text):``).filter(Boolean).join(`
10
+ import{O as e,Vt as t,r as n}from"./profile-storage--QCh_u_Q.js";import{t as r}from"./terminal-text-cBPBiP3x.js";import{i}from"./format-B6a10P86.js";import{n as a,r as o}from"./mcp-client-DpDabxv9.js";function s(t){return Array.isArray(t)&&e(t.map(e=>typeof e==`object`&&e&&`text`in e?String(e.text):``).filter(Boolean).join(`
11
11
  `))||`usage-audit tool call failed`}async function c(e,t,r){let i=await e.callTool({name:t,arguments:r},o());if(i.isError){let e=s(i.content);throw/not found/i.test(e)?new n(`This deployment does not expose the usage-audit tools (${t}). Credit-billed workspaces record spend in a separate ledger — use \`entrydesk usage consumptions\` and \`entrydesk usage balance\` instead.`):new n(e)}if(i.structuredContent==null)throw new n(`${t} returned no structured content; the workspace may not expose the usage-audit tools.`);return i.structuredContent}async function l(e){let t=await a();try{return await e(t)}finally{await t.close().catch(()=>{})}}function u(e){return e.toLocaleString()}function d(e){return e==null?`—`:`${e>0?`+`:``}${e}%`}function f(e){return e?e.slice(0,10):`never`}async function p(e){let n=await l(n=>c(n,t.GET_COST_RANKING,{groupBy:e.by,...e.days!=null&&{windowDays:e.days},...e.model&&{model:e.model},...e.limit!=null&&{limit:e.limit}}));if(e.json){console.log(r(n,2));return}let a=n.windowDays==null?`all time`:`last ${n.windowDays} days`,o=e.model?` · model ~ "${e.model}"`:``;if(console.log(`Cost ranking by ${e.by} · ${a}${o}\n`),n.rows.length===0){console.log(` No spend in this window.`);return}let s=Math.max(...n.rows.map(e=>i(e.cost).length));for(let e of n.rows){let t=e.ownerEmail?` · ${e.ownerEmail}`:``;console.log(` ${i(e.cost).padStart(s)} ${d(e.costChangePct).padEnd(7)} ${u(e.calls).padStart(8)} calls ${e.key}${t}`)}console.log(`\n ${n.rows.length} rows.`)}async function m(e,n){let[a,o]=await l(r=>Promise.all([c(r,t.GET_USER_BREAKDOWN,{email:e,sinceDays:n.days,minCost:n.minCost??0}),c(r,t.GET_USER_DAILY_TREND,{emails:[e],days:n.days})]));if(n.json){console.log(r({breakdown:a,trend:o},2));return}if(console.log(`${e} · last ${n.days} days\n`),console.log(`By agent / operation:`),a.breakdown.length===0)console.log(` (no spend)`);else{let e=Math.max(...a.breakdown.map(e=>i(e.cost).length));for(let t of a.breakdown)console.log(` ${i(t.cost).padStart(e)} ${u(t.calls).padStart(8)} calls ${t.agentOrOperation}`)}let s=o.trends[0]?.days??[];if(s.length>0){console.log(`
12
12
  Daily:`);for(let e of s)console.log(` ${e.date} ${i(e.cost).padStart(10)} ${u(e.calls).padStart(8)} calls`)}if(a.activeSchedules.length>0){console.log(`\nActive schedules (${a.activeSchedules.length}):`);for(let e of a.activeSchedules){let t=e.agentName?` · ${e.agentName}`:``;console.log(` ${e.name}${t} (${e.scheduleType}, last run ${f(e.lastTaskAt)})`)}}}async function h(e){let{stale:n,toolCalls:a}=await l(async n=>{let r=await c(n,t.FIND_STALE_SCHEDULES,{sinceDays:e.days,...e.minCost!=null&&{minCost:e.minCost},...e.limit!=null&&{limit:e.limit}}),i=r.schedules.map(e=>e.scheduleId),a=[];for(let e=0;e<i.length;e+=20)a.push(i.slice(e,e+20));return{stale:r,toolCalls:{schedules:(await Promise.all(a.map(r=>c(n,t.GET_SCHEDULE_TOOL_CALLS,{scheduleIds:r,sinceDays:e.days,recentRuns:5})))).flatMap(e=>e.schedules)}}});if(e.json){console.log(r({stale:n,toolCalls:a},2));return}if(console.log(`Schedules spending with unread output · last ${e.days} days\n`),n.schedules.length===0){console.log(` Nothing flagged.`);return}let o=new Map(a.schedules.map(e=>[e.scheduleId,e.toolCalls]));for(let e of n.schedules){console.log(` ${i(e.cost)} ${u(e.runs)} runs ${e.unreadPct}% unread last read ${f(e.lastReadAt)}`),console.log(` ${e.scheduleName} · ${e.ownerEmail}`);let t=o.get(e.scheduleId)??[];if(t.length===0){console.log(` no tool calls in the last 5 runs — deactivation candidate`);continue}console.log(` tools (last 5 runs): ${t.map(e=>`${e.tool} ${e.calls}`).join(`, `)}`);let n=t.filter(e=>e.failedCalls>0);n.length>0&&console.log(` failing: ${n.map(e=>`${e.tool} ${e.failedCalls}`).join(`, `)} — may be spinning on retries`)}console.log(`\n ${n.schedules.length} schedules.`)}export{m as drillUsage,h as findUsageWaste,p as rankUsage};
@@ -7,4 +7,4 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- function e(){return`2.2.0-beta.1`}export{e as t};
10
+ function e(){return`2.2.0-beta.2`}export{e as t};
@@ -7,5 +7,5 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{C as e,D as t,O as n,a as r,o as i,p as a}from"./profile-storage-CKrZ-xsd.js";import{t as o}from"./terminal-text-cBPBiP3x.js";import{t as s}from"./paginate-Cbe4RaEq.js";import{t as c}from"./confirm-Ct432t3K.js";import{HTTPError as l}from"ky";var u=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WebhookCommandError`}};const d={webhook_destination_not_found:"Webhook destination not found. `entrydesk webhook list` shows the destinations in this workspace.",webhook_delivery_not_found:"Delivery not found. `entrydesk webhook deliveries <id>` lists the deliveries to a destination.",webhook_destination_disabled:"This destination is disabled. Run `entrydesk webhook enable <id>` first.",webhook_destination_limit_reached:`This workspace already has the maximum number of webhook destinations. Delete one first.`,insufficient_permissions:`Managing webhooks needs the Manage workspace permission in this workspace.`};async function f(e){try{let{features:t}=await e.getRuntimeConfig();if(!t.enableOutgoingWebhooks)return new u(`webhooks_not_enabled`,`Outgoing webhooks are not enabled on this EntryDesk environment.`)}catch(e){return new u(`not_found`,`Not found, and this EntryDesk environment's feature flags could not be read to tell whether webhooks are enabled (${r(e).message.replace(/^Error: /u,``)}).`)}return new u(`not_found`,`Not found.`)}async function p(e,n){if(n instanceof u)return n;if(!(n instanceof l))return null;let r=t(n.data);if(r===`insufficient_scope`)return new u(r,"Your token lacks the workspaces:read / workspaces:write scope webhooks need. Run `entrydesk login` again, or issue a token with those scopes and set ENTRYDESK_TOKEN.");let i=r&&Object.hasOwn(d,r)?d[r]:void 0;return r&&i?new u(r,i):n.response.status===404?f(e):null}async function m(t,r){let s=new e;try{let{accessToken:e,workspaceId:t}=await a();await r({client:s,accessToken:e,workspaceId:t})}catch(e){let{code:r,message:a}=await p(s,e)??i(e),c={code:r,message:a.replace(/^Error: /u,``)};t.json?console.error(o({error:c})):console.error(`Error: ${n(c.message)}`),process.exit(1)}}function h(e){return e?n(e):``}function g(e){return e===null?`—`:`${(e*100).toFixed(1)}%`}function _(e){return e===null?`—`:`${e} ms`}function v(e){return e.httpStatus===null?e.error===null?`In progress`:`${h(e.error)}, ${_(e.responseTimeMs)}`:`HTTP ${e.httpStatus}, ${_(e.responseTimeMs)}`}function y(e){let t=[e.status];return e.disabledReason===`consecutive_failures`&&t.push(`after repeated failures`),e.verifiedAt||t.push(`unverified`),t.join(`, `)}function b(e){return e===null?`All events`:e.join(`, `)}function x(e){let{metrics:t}=e;console.log(`${h(e.name)} (${e.id})`),console.log(` URL: ${h(e.url)}`),e.description&&console.log(` Description: ${h(e.description)}`),console.log(` Status: ${y(e)}`),console.log(` Listening to: ${b(e.eventTypes)}`),console.log(` API version: ${e.apiVersion}`),console.log(` Last 7 days: ${t.deliveryCount} deliveries, ${g(t.errorRate)} errors, p50 ${_(t.p50ResponseTimeMs)}`),e.previousSecretExpiresAt&&console.log(` Previous secret signs until ${e.previousSecretExpiresAt}`)}function S(e){console.log(``),console.log(`Signing secret: ${e}`),console.log(`Store it now; it is not shown again. Verify X-ED-Signature as v1=HMAC-SHA256(secret, "{X-ED-Timestamp}.{raw body}").`)}function C(e){let t=e.lastHttpStatus?`HTTP ${e.lastHttpStatus}`:h(e.lastError)||`—`,n=e.nextAttemptAt?`, next attempt ${e.nextAttemptAt}`:``;console.log(`${e.id} ${e.status.padEnd(9)} ${e.eventType} attempts ${e.attempts} ${t}${n} ${e.createdAt}`)}function w(e){return e.allEvents?{eventTypes:null}:e.events?{eventTypes:e.events}:{}}async function T(e){await m(e,async({client:t,accessToken:n,workspaceId:r})=>{let i=await t.listWebhookDestinations(n,r);if(e.json){console.log(o(i));return}if(i.items.length===0){console.log("No webhook destinations. Create one with `entrydesk webhook create`.");return}for(let e of i.items)console.log(`${e.id} ${h(e.name)} ${h(e.url)} [${y(e)}] ${b(e.eventTypes)} errors ${g(e.metrics.errorRate)}`)})}async function E(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=await n.getWebhookDestination(r,i,e);if(t.json){console.log(o(a));return}x(a)})}async function D(e){await m(e,async({client:t,accessToken:n,workspaceId:r})=>{if(!e.events&&!e.allEvents)throw new u(`events_required`,`Pass --events <types> or --all-events.`);let i=await t.createWebhookDestination(n,r,{url:e.url,name:e.name,description:e.description?.trim()||null,eventTypes:e.allEvents?null:e.events??null,...e.apiVersion?{apiVersion:e.apiVersion}:{}});if(e.json){console.log(o(i));return}console.log(`Created webhook destination.`),x(i.destination),S(i.signingSecret)})}async function O(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a={...t.url===void 0?{}:{url:t.url},...t.name===void 0?{}:{name:t.name},...t.description===void 0?{}:{description:t.description.trim()||null},...t.apiVersion===void 0?{}:{apiVersion:t.apiVersion},...w(t)};if(Object.keys(a).length===0)throw new u(`nothing_to_update`,`Pass at least one of --url, --name, --description, --events, --all-events or --api-version.`);let s=await n.updateWebhookDestination(r,i,e,a);if(t.json){console.log(o(s));return}console.log(`Updated webhook destination.`),x(s)})}async function k(e,t,n){await m(n,async({client:r,accessToken:i,workspaceId:a})=>{let s=await r.updateWebhookDestination(i,a,e,{status:t?`active`:`disabled`});if(n.json){console.log(o(s));return}console.log(t?`Enabled ${h(s.name)}. Events from while it was disabled are not resent.`:`Disabled ${h(s.name)}. No events are delivered until you enable it again.`)})}async function A(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{if(!t.yes){if(!process.stdin.isTTY||t.json)throw new u(`confirmation_required`,`Deleting webhook destination ${e} needs confirmation. Re-run with --yes.`);if(!await c(`Delete webhook destination ${e}? Its signing secret is destroyed and deliveries stop.`)){console.log(`Aborted.`);return}}if(await n.deleteWebhookDestination(r,i,e),t.json){console.log(o({id:e,deleted:!0}));return}console.log(`Deleted webhook destination ${e}.`)})}async function j(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=await n.rotateWebhookSecret(r,i,e,t.expirePrevious===void 0?{}:{expirePreviousInSeconds:t.expirePrevious});if(t.json){console.log(o(a));return}console.log(a.previousSecretExpiresAt?`Rotated. The previous secret keeps signing until ${a.previousSecretExpiresAt}.`:`Rotated. The previous secret no longer signs.`),S(a.signingSecret)})}async function M(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=a=>n.listWebhookDeliveries(r,i,e,{status:t.status,eventType:t.eventType,limit:t.all?100:t.limit,nextKey:a}),c=t.all?{items:await s(async e=>{let t=await a(e);return{items:t.items,nextKey:t.nextKey??void 0}}),nextKey:null}:await a(t.nextKey);if(t.json){console.log(o(c));return}if(c.items.length===0){console.log(`No deliveries.`);return}for(let e of c.items)C(e);c.nextKey&&console.log(`\nMore deliveries: --next-key ${h(c.nextKey)}`)})}async function N(e,t,n){await m(n,async({client:r,accessToken:i,workspaceId:a})=>{let s=await r.getWebhookDelivery(i,a,e,t);if(n.json){console.log(o(s));return}C(s),console.log(`\nEvent ${s.eventId}, occurred ${s.occurredAt}`),console.log(`
10
+ import{C as e,D as t,O as n,a as r,o as i,p as a}from"./profile-storage--QCh_u_Q.js";import{t as o}from"./terminal-text-cBPBiP3x.js";import{t as s}from"./paginate-B-nHzQ0j.js";import{t as c}from"./confirm-Ct432t3K.js";import{HTTPError as l}from"ky";var u=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WebhookCommandError`}};const d={webhook_destination_not_found:"Webhook destination not found. `entrydesk webhook list` shows the destinations in this workspace.",webhook_delivery_not_found:"Delivery not found. `entrydesk webhook deliveries <id>` lists the deliveries to a destination.",webhook_destination_disabled:"This destination is disabled. Run `entrydesk webhook enable <id>` first.",webhook_destination_limit_reached:`This workspace already has the maximum number of webhook destinations. Delete one first.`,insufficient_permissions:`Managing webhooks needs the Manage workspace permission in this workspace.`};async function f(e){try{let{features:t}=await e.getRuntimeConfig();if(!t.enableOutgoingWebhooks)return new u(`webhooks_not_enabled`,`Outgoing webhooks are not enabled on this EntryDesk environment.`)}catch(e){return new u(`not_found`,`Not found, and this EntryDesk environment's feature flags could not be read to tell whether webhooks are enabled (${r(e).message.replace(/^Error: /u,``)}).`)}return new u(`not_found`,`Not found.`)}async function p(e,n){if(n instanceof u)return n;if(!(n instanceof l))return null;let r=t(n.data);if(r===`insufficient_scope`)return new u(r,"Your token lacks the workspaces:read / workspaces:write scope webhooks need. Run `entrydesk login` again, or issue a token with those scopes and set ENTRYDESK_TOKEN.");let i=r&&Object.hasOwn(d,r)?d[r]:void 0;return r&&i?new u(r,i):n.response.status===404?f(e):null}async function m(t,r){let s=new e;try{let{accessToken:e,workspaceId:t}=await a();await r({client:s,accessToken:e,workspaceId:t})}catch(e){let{code:r,message:a}=await p(s,e)??i(e),c={code:r,message:a.replace(/^Error: /u,``)};t.json?console.error(o({error:c})):console.error(`Error: ${n(c.message)}`),process.exit(1)}}function h(e){return e?n(e):``}function g(e){return e===null?`—`:`${(e*100).toFixed(1)}%`}function _(e){return e===null?`—`:`${e} ms`}function v(e){return e.httpStatus===null?e.error===null?`In progress`:`${h(e.error)}, ${_(e.responseTimeMs)}`:`HTTP ${e.httpStatus}, ${_(e.responseTimeMs)}`}function y(e){let t=[e.status];return e.disabledReason===`consecutive_failures`&&t.push(`after repeated failures`),e.verifiedAt||t.push(`unverified`),t.join(`, `)}function b(e){return e===null?`All events`:e.join(`, `)}function x(e){let{metrics:t}=e;console.log(`${h(e.name)} (${e.id})`),console.log(` URL: ${h(e.url)}`),e.description&&console.log(` Description: ${h(e.description)}`),console.log(` Status: ${y(e)}`),console.log(` Listening to: ${b(e.eventTypes)}`),console.log(` API version: ${e.apiVersion}`),console.log(` Last 7 days: ${t.deliveryCount} deliveries, ${g(t.errorRate)} errors, p50 ${_(t.p50ResponseTimeMs)}`),e.previousSecretExpiresAt&&console.log(` Previous secret signs until ${e.previousSecretExpiresAt}`)}function S(e){console.log(``),console.log(`Signing secret: ${e}`),console.log(`Store it now; it is not shown again. Verify X-ED-Signature as v1=HMAC-SHA256(secret, "{X-ED-Timestamp}.{raw body}").`)}function C(e){let t=e.lastHttpStatus?`HTTP ${e.lastHttpStatus}`:h(e.lastError)||`—`,n=e.nextAttemptAt?`, next attempt ${e.nextAttemptAt}`:``;console.log(`${e.id} ${e.status.padEnd(9)} ${e.eventType} attempts ${e.attempts} ${t}${n} ${e.createdAt}`)}function w(e){return e.allEvents?{eventTypes:null}:e.events?{eventTypes:e.events}:{}}async function T(e){await m(e,async({client:t,accessToken:n,workspaceId:r})=>{let i=await t.listWebhookDestinations(n,r);if(e.json){console.log(o(i));return}if(i.items.length===0){console.log("No webhook destinations. Create one with `entrydesk webhook create`.");return}for(let e of i.items)console.log(`${e.id} ${h(e.name)} ${h(e.url)} [${y(e)}] ${b(e.eventTypes)} errors ${g(e.metrics.errorRate)}`)})}async function E(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=await n.getWebhookDestination(r,i,e);if(t.json){console.log(o(a));return}x(a)})}async function D(e){await m(e,async({client:t,accessToken:n,workspaceId:r})=>{if(!e.events&&!e.allEvents)throw new u(`events_required`,`Pass --events <types> or --all-events.`);let i=await t.createWebhookDestination(n,r,{url:e.url,name:e.name,description:e.description?.trim()||null,eventTypes:e.allEvents?null:e.events??null,...e.apiVersion?{apiVersion:e.apiVersion}:{}});if(e.json){console.log(o(i));return}console.log(`Created webhook destination.`),x(i.destination),S(i.signingSecret)})}async function O(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a={...t.url===void 0?{}:{url:t.url},...t.name===void 0?{}:{name:t.name},...t.description===void 0?{}:{description:t.description.trim()||null},...t.apiVersion===void 0?{}:{apiVersion:t.apiVersion},...w(t)};if(Object.keys(a).length===0)throw new u(`nothing_to_update`,`Pass at least one of --url, --name, --description, --events, --all-events or --api-version.`);let s=await n.updateWebhookDestination(r,i,e,a);if(t.json){console.log(o(s));return}console.log(`Updated webhook destination.`),x(s)})}async function k(e,t,n){await m(n,async({client:r,accessToken:i,workspaceId:a})=>{let s=await r.updateWebhookDestination(i,a,e,{status:t?`active`:`disabled`});if(n.json){console.log(o(s));return}console.log(t?`Enabled ${h(s.name)}. Events from while it was disabled are not resent.`:`Disabled ${h(s.name)}. No events are delivered until you enable it again.`)})}async function A(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{if(!t.yes){if(!process.stdin.isTTY||t.json)throw new u(`confirmation_required`,`Deleting webhook destination ${e} needs confirmation. Re-run with --yes.`);if(!await c(`Delete webhook destination ${e}? Its signing secret is destroyed and deliveries stop.`)){console.log(`Aborted.`);return}}if(await n.deleteWebhookDestination(r,i,e),t.json){console.log(o({id:e,deleted:!0}));return}console.log(`Deleted webhook destination ${e}.`)})}async function j(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=await n.rotateWebhookSecret(r,i,e,t.expirePrevious===void 0?{}:{expirePreviousInSeconds:t.expirePrevious});if(t.json){console.log(o(a));return}console.log(a.previousSecretExpiresAt?`Rotated. The previous secret keeps signing until ${a.previousSecretExpiresAt}.`:`Rotated. The previous secret no longer signs.`),S(a.signingSecret)})}async function M(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=a=>n.listWebhookDeliveries(r,i,e,{status:t.status,eventType:t.eventType,limit:t.all?100:t.limit,nextKey:a}),c=t.all?{items:await s(async e=>{let t=await a(e);return{items:t.items,nextKey:t.nextKey??void 0}}),nextKey:null}:await a(t.nextKey);if(t.json){console.log(o(c));return}if(c.items.length===0){console.log(`No deliveries.`);return}for(let e of c.items)C(e);c.nextKey&&console.log(`\nMore deliveries: --next-key ${h(c.nextKey)}`)})}async function N(e,t,n){await m(n,async({client:r,accessToken:i,workspaceId:a})=>{let s=await r.getWebhookDelivery(i,a,e,t);if(n.json){console.log(o(s));return}C(s),console.log(`\nEvent ${s.eventId}, occurred ${s.occurredAt}`),console.log(`
11
11
  Request body:`),console.log(h(s.requestBody));for(let e of s.attemptHistory)console.log(`\nAttempt ${e.attempt} at ${e.attemptedAt} (X-ED-Delivery-Id ${e.id})`),console.log(` Result: ${v(e)}`),e.responseBody&&console.log(` Response: ${h(e.responseBody)}`)})}async function P(e,t,n){await m(n,async({client:r,accessToken:i,workspaceId:a})=>{let s=await r.resendWebhookDelivery(i,a,e,t);if(n.json){console.log(o(s));return}console.log(`Queued delivery ${t} again (event ${s.delivery.eventId}). Check it with \`entrydesk webhook delivery ${e} ${t}\`.`)})}async function F(e,t){await m(t,async({client:n,accessToken:r,workspaceId:i})=>{let a=await n.sendWebhookTest(r,i,e,t.eventType?{eventType:t.eventType}:{});if(t.json){console.log(o(a));return}let{outcome:s,delivery:c}=a,l=s.httpStatus?`HTTP ${s.httpStatus}`:h(s.error);console.log(`${s.succeeded?`Delivered`:`Failed`}: ${l}${s.responseTimeMs===null?``:` in ${_(s.responseTimeMs)}`} (delivery ${c.id}).`),!s.succeeded&&c.nextAttemptAt&&console.log(`Retrying at ${c.nextAttemptAt}.`)})}async function I(e){await m(e,async({client:t,accessToken:n,workspaceId:r})=>{let i=await t.listWebhookEventTypes(n,r);if(e.json){console.log(o(i));return}for(let e of i.items.filter(e=>e.subscribable))console.log(`${e.type} (since ${e.addedIn})`),console.log(` ${e.description}`)})}export{D as createWebhook,A as deleteWebhook,M as listWebhookDeliveries,I as listWebhookEventTypes,T as listWebhooks,P as resendWebhookDelivery,j as rotateWebhookSecret,F as sendWebhookTest,k as setWebhookEnabled,E as showWebhook,N as showWebhookDelivery,O as updateWebhook};
@@ -7,7 +7,7 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{C as e,p as t}from"./profile-storage-CKrZ-xsd.js";import{t as n}from"./terminal-text-cBPBiP3x.js";import{t as r}from"./resource-grants-Bb4evqsH.js";import{r as i}from"./format-CIj0qQba.js";import{t as a}from"./paginate-Cbe4RaEq.js";import{readFileSync as o}from"node:fs";import{setTimeout as s}from"node:timers/promises";const c=262144,l=new Set([`completed`,`failed`,`cancelled`]);function u(e){let t;try{t=o(e,`utf8`)}catch{console.error(`Cannot read script file: ${e}`),process.exit(1)}return t.trim().length===0&&(console.error(`Script file is empty: ${e}`),process.exit(1)),Buffer.byteLength(t,`utf8`)>c&&(console.error(`Script file exceeds ${c} bytes.`),process.exit(1)),t}function d(e){console.log(`Workflows (${e.length}):\n`);for(let t of e){let e=t.isActive?`active`:`inactive`;if(console.log(` ${t.name} (${e})`),t.description){let e=t.description.length>80?`${t.description.slice(0,80)}…`:t.description;console.log(` ${e}`)}console.log(` ${t.myRole??`no-role`} · ID: ${t.id}`),console.log(``)}}function f(e,t){console.log(`${e.name}\n`),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: ${i(e.updatedAt)}`);let n=e.scriptSource.split(`
10
+ import{C as e,p as t}from"./profile-storage--QCh_u_Q.js";import{t as n}from"./terminal-text-cBPBiP3x.js";import{t as r}from"./resource-grants-DojPWFs8.js";import{r as i}from"./format-B6a10P86.js";import{t as a}from"./paginate-B-nHzQ0j.js";import{readFileSync as o}from"node:fs";import{setTimeout as s}from"node:timers/promises";const c=262144,l=new Set([`completed`,`failed`,`cancelled`]);function u(e){let t;try{t=o(e,`utf8`)}catch{console.error(`Cannot read script file: ${e}`),process.exit(1)}return t.trim().length===0&&(console.error(`Script file is empty: ${e}`),process.exit(1)),Buffer.byteLength(t,`utf8`)>c&&(console.error(`Script file exceeds ${c} bytes.`),process.exit(1)),t}function d(e){console.log(`Workflows (${e.length}):\n`);for(let t of e){let e=t.isActive?`active`:`inactive`;if(console.log(` ${t.name} (${e})`),t.description){let e=t.description.length>80?`${t.description.slice(0,80)}…`:t.description;console.log(` ${e}`)}console.log(` ${t.myRole??`no-role`} · ID: ${t.id}`),console.log(``)}}function f(e,t){console.log(`${e.name}\n`),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: ${i(e.updatedAt)}`);let n=e.scriptSource.split(`
11
11
  `).length;t?(console.log(`\n Script (${n} lines):\n`),console.log(e.scriptSource)):console.log(` Script: ${n} lines (use --show-source to print)`)}function p(e){console.log(`Runs (${e.length}):\n`);for(let t of e){let e=i(t.startedAt??t.createdAt);console.log(` ${t.status}${e?` · ${e}`:``}`),console.log(` ID: ${t.id}`)}}function m(e){console.log(`Run ${e.id}`),console.log(` Workflow: ${e.workflowId}`),console.log(` Status: ${e.status}`),e.startedAt&&console.log(` Started: ${i(e.startedAt)}`),e.completedAt&&console.log(` Completed: ${i(e.completedAt)}`),e.error!=null&&console.log(` Error: ${n(e.error)}`);let t=Object.entries(e.context?.nodes??{});if(t.length>0){console.log(`\n Nodes (${t.length}):`);for(let[e,n]of t){let t=[n.kind??`node`,n.status];n.durationMs!=null&&t.push(`${n.durationMs}ms`),console.log(` - ${n.label??e} [${t.join(` · `)}]`)}}let r=e.context?.logs??[];if(r.length>0){console.log(`
12
12
  Logs:`);for(let e of r)console.log(` ${e}`)}e.context?.spent!=null&&console.log(`\n Tokens spent: ${e.context.spent}`)}async function h(e,t,n,r,i){for(let a=0;a<600;a++){let o=await e.getWorkflowRun(t,n,r,i);if(l.has(o.status))return a>0&&process.stderr.write(`
13
13
  `),o;let c=a*2;process.stderr.write(`\rWaiting… ${o.status} (${c}s)`),await s(2e3)}throw process.stderr.write(`
@@ -7,5 +7,5 @@ if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
7
7
  );
8
8
  process.exit(1);
9
9
  }
10
- import{C as e,E as t,d as n}from"./profile-storage-CKrZ-xsd.js";import{t as r}from"./terminal-text-cBPBiP3x.js";async function i(i){let a=await t.getAll(),o=await n(),{workspaces:s}=await new e().getWorkspaces(o);if(i.json){console.log(r(s));return}if(s.length===0){console.log(`No workspaces found.`);return}console.log(`Workspaces (${s.length}):\n`);for(let e of s){let t=e.id===a?.workspaceId?` (current)`:``;console.log(` ${e.name}${t}`),console.log(` ID: ${e.id}`),console.log(``)}}async function a(i,a){let o=await n(),{workspaces:s}=await new e().getWorkspaces(o),c=s.find(e=>e.id===i);if(!c){console.error(`Workspace not found: ${i}`),console.error(`
10
+ import{C as e,E as t,d as n}from"./profile-storage--QCh_u_Q.js";import{t as r}from"./terminal-text-cBPBiP3x.js";async function i(i){let a=await t.getAll(),o=await n(),{workspaces:s}=await new e().getWorkspaces(o);if(i.json){console.log(r(s));return}if(s.length===0){console.log(`No workspaces found.`);return}console.log(`Workspaces (${s.length}):\n`);for(let e of s){let t=e.id===a?.workspaceId?` (current)`:``;console.log(` ${e.name}${t}`),console.log(` ID: ${e.id}`),console.log(``)}}async function a(i,a){let o=await n(),{workspaces:s}=await new e().getWorkspaces(o),c=s.find(e=>e.id===i);if(!c){console.error(`Workspace not found: ${i}`),console.error(`
11
11
  Available workspaces:`);for(let e of s)console.error(` ${e.name}: ${e.id}`);process.exit(1)}if(await t.saveWorkspaceId(i),a.json){console.log(r({workspaceId:i,workspaceName:c.name}));return}console.log(`Switched to workspace: ${c.name}`),console.log(` ID: ${i}`)}export{i as listWorkspaces,a as switchWorkspace};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entrydesk/cli",
3
- "version": "2.2.0-beta.1",
3
+ "version": "2.2.0-beta.2",
4
4
  "description": "EntryDesk CLI - Interact with EntryDesk from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,9 +13,9 @@
13
13
  "dependencies": {
14
14
  "@ai-sdk/react": "^4.0.126",
15
15
  "@commander-js/extra-typings": "^15.0.0",
16
- "@modelcontextprotocol/client": "^2.0.0",
17
- "@modelcontextprotocol/node": "^2.0.0",
18
- "@modelcontextprotocol/server": "^2.0.0",
16
+ "@modelcontextprotocol/client": "^2.3.1",
17
+ "@modelcontextprotocol/node": "^2.1.1",
18
+ "@modelcontextprotocol/server": "^2.3.1",
19
19
  "@vscode/ripgrep": "1.18.0",
20
20
  "adm-zip": "^0.6.1",
21
21
  "ai": "^7.0.123",
@@ -27,7 +27,7 @@
27
27
  "ink-spinner": "^5.0.0",
28
28
  "jose": "^6.2.3",
29
29
  "ky": "^2.0.2",
30
- "react": "^19.3.0",
30
+ "react": "^19.3.1",
31
31
  "undici": "^7.29.1",
32
32
  "uuid": "^14.0.0"
33
33
  },
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- var __entrydeskNodeFloor = 24;
3
- if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
4
- process.stderr.write(
5
- 'entrydesk: Node.js ' + __entrydeskNodeFloor + ' or newer is required, but this is Node ' + process.versions.node + '.\n' +
6
- 'Upgrade Node (https://nodejs.org/en/download), then reinstall @entrydesk/cli.\n'
7
- );
8
- process.exit(1);
9
- }
10
- import{C as e,p as t,x as n}from"./profile-storage-CKrZ-xsd.js";import{t as r}from"./terminal-text-cBPBiP3x.js";import{i,n as a}from"./format-CIj0qQba.js";import{t as o}from"./paginate-Cbe4RaEq.js";function s(e){if(console.log(`Billing status: ${e.lifecycle.kind}`),e.subscription){let t=e.subscription,n=t.nextInvoiceDueAt?` · next invoice ${new Date(t.nextInvoiceDueAt).toLocaleDateString()}`:``;console.log(` Plan: ${t.planName} · ~${i(t.estimatedMonthlyChargeUsd)}/month${n}`)}else console.log(` Plan: (no active subscription)`);let t=e.seats;console.log(` Seats: pro ${t.assigned.pro}/${t.purchased.pro}, premium ${t.assigned.premium}/${t.purchased.premium} (assigned/purchased)`);let n=e.extraUsage;console.log(` Balance: ${i(n.balanceUsd)} extra usage`),console.log(` Spent: ${a(n.currentSpentUsd)} this period`),n.monthlyExtraUsageLimitUsd!=null&&console.log(` Limit: ${i(n.monthlyExtraUsageLimitUsd)} / month`)}function c(e){console.log(`Invoices (${e.length}):\n`);for(let t of e){let e=new Date(t.billingDate).toLocaleDateString();console.log(` ${e} · ${t.type} · ${t.status} · ${i(t.totalUsd)}`),t.hostedInvoiceUrl&&console.log(` ${t.hostedInvoiceUrl}`),console.log(` ID: ${t.id}`),console.log(``)}}async function l(){return n()&&(console.error("Billing requires an interactive login. A workspace PAT (ENTRYDESK_TOKEN) cannot read billing — run `entrydesk login`."),process.exit(1)),t()}async function u(t){let{accessToken:n,workspaceId:i}=await l(),a=await new e().getBillingOverview(n,i);if(t.json){console.log(r(a));return}s(a)}async function d(t){let{accessToken:n,workspaceId:i}=await l(),a=new e;if(t.all){let e=await o(async e=>{let r=await a.getBillingInvoices(n,i,{limit:t.limit??20,nextKey:e});return{items:r.invoices,nextKey:r.nextKey}});if(t.json){console.log(r({invoices:e}));return}if(e.length===0){console.log(`No invoices.`);return}c(e);return}let{invoices:s,nextKey:u}=await a.getBillingInvoices(n,i,{limit:t.limit,nextKey:t.nextKey});if(t.json){console.log(r({invoices:s,nextKey:u}));return}if(s.length===0){console.log(`No invoices.`);return}c(s),u&&console.log(`Next page: --next-key ${u}`)}export{d as listInvoices,u as showBillingStatus};
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- var __entrydeskNodeFloor = 24;
3
- if (parseInt(process.versions.node, 10) < __entrydeskNodeFloor) {
4
- process.stderr.write(
5
- 'entrydesk: Node.js ' + __entrydeskNodeFloor + ' or newer is required, but this is Node ' + process.versions.node + '.\n' +
6
- 'Upgrade Node (https://nodejs.org/en/download), then reinstall @entrydesk/cli.\n'
7
- );
8
- process.exit(1);
9
- }
10
- import{$t as e,Ct as t,Qt as n,St as r}from"./profile-storage-CKrZ-xsd.js";function i({allowedTools:e,disallowedTools:n}){if(!(!e?.length&&!n?.length))return[...t(e?.map(e=>({toolName:e,policy:r.ALWAYS_ALLOW})),n?.map(e=>({toolName:e,policy:r.BLOCK})))].map(([e,t])=>({toolName:e,policy:t}))}function a(e,n){let i=[...n].map(e=>({toolName:e,policy:r.ALWAYS_ALLOW}));return i.length===0?e:[...t(e,i)].map(([e,t])=>({toolName:e,policy:t}))}function o({agentId:t,model:r,projectId:i,connectorIds:a,clientTools:o,clientToolSystemPrompt:s,toolApprovalMode:c,toolPolicies:l}){return{...i?{projectId:i}:{},...t?{agentId:t}:{...r?{model:r}:{},...a?.length?{connectorIds:a}:{}},...o?{clientTools:e(o,n.DIRECT)}:{},...s?{clientToolSystemPrompt:s}:{},...c?{toolApprovalMode:c}:{},...l?.length?{toolPolicies:l}:{}}}export{i as n,a as r,o as t};