@entrydesk/cli 2.1.0-beta.1 → 2.1.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 (66) hide show
  1. package/README.md +32 -16
  2. package/dist/{add-Lh_kLR85.js → add-DXYghmJz.js} +1 -1
  3. package/dist/agents-Drg2ZD85.js +2 -0
  4. package/dist/{billing-DHrYi0SU.js → billing-Bkk1BhAw.js} +1 -1
  5. package/dist/{budget-D_DDPBBb.js → budget-dazpYOON.js} +1 -1
  6. package/dist/build-task-request-config-BDlX-M_P.js +2 -0
  7. package/dist/{commands-3Yqb38G_.js → commands-DUKXJUfr.js} +1 -1
  8. package/dist/commands-FVFeS1MV.js +2 -0
  9. package/dist/{config-hGzOCx4u.js → config-CSJx1Xlt.js} +1 -1
  10. package/dist/{connectors-CxzG22No.js → connectors-CHcopt49.js} +2 -2
  11. package/dist/index.js +15 -14
  12. package/dist/{instruction-CRCyBKQf.js → instruction-BXKEUplM.js} +1 -1
  13. package/dist/{login-CwXjzUnO.js → login-ACaFCfsh.js} +1 -1
  14. package/dist/{logout-BYCFpaxh.js → logout-BX4YsOqw.js} +1 -1
  15. package/dist/{marketplace-NSEUjhXf.js → marketplace-S_4fkbWt.js} +1 -1
  16. package/dist/{mcp-B7wo_sRO.js → mcp-DOUHU2_Z.js} +1 -1
  17. package/dist/{mcp-client-DMOEcmul.js → mcp-client-LcmqajIh.js} +1 -1
  18. package/dist/{meeting-yS83In45.js → meeting-BG76tnT9.js} +1 -1
  19. package/dist/{models-AN9cWKSj.js → models-CkepW_-c.js} +1 -1
  20. package/dist/{notifications-QF11-X32.js → notifications-BAMcYXhl.js} +1 -1
  21. package/dist/options-CgmngSTC.js +2 -0
  22. package/dist/{paginate-CfIrho1f.js → paginate-DUu8qbek.js} +1 -1
  23. package/dist/{paths-C9BPsZVF.js → paths-DQh1PdjS.js} +1 -1
  24. package/dist/{profile-WtKtO0yp.js → profile-BzXbLYDw.js} +1 -1
  25. package/dist/profile-storage-DlaupNlV.js +60 -0
  26. package/dist/project-B9uLW5nn.js +2 -0
  27. package/dist/{project-context-Cc_Js6n4.js → project-context-VlX5GZxr.js} +1 -1
  28. package/dist/{project-governance-C7rl6gDW.js → project-governance-CwVlxGE2.js} +1 -1
  29. package/dist/{project-sources-CzylP6oS.js → project-sources-BzMkopCj.js} +1 -1
  30. package/dist/project-sources-write-D3WzWqet.js +2 -0
  31. package/dist/{project-tasks-DaGBt4Cp.js → project-tasks-CnXLm061.js} +1 -1
  32. package/dist/{push-Ce79oiu0.js → push-DWIgzvqe.js} +1 -1
  33. package/dist/{recordings-DoExjM1F.js → recordings-_HnTtukO.js} +1 -1
  34. package/dist/{remove-bHAmCTdf.js → remove-Cpen9pWn.js} +1 -1
  35. package/dist/resolve-7OXPmNrX.js +6 -0
  36. package/dist/resource-grants-D-ImlByb.js +2 -0
  37. package/dist/{schedules-tDaIGaad.js → schedules-DACWrdY_.js} +2 -2
  38. package/dist/skills-BenhDHKq.js +2 -0
  39. package/dist/{status-CDMSNVD8.js → status-BKd81bGK.js} +1 -1
  40. package/dist/{status-gK3MA1oe.js → status-ErhWpQxW.js} +1 -1
  41. package/dist/task-CvQD8Y4d.js +104 -0
  42. package/dist/tasks-C4dAgHmR.js +2 -0
  43. package/dist/tasks-CnncSIan.js +14 -0
  44. package/dist/terminal-text-D04u1hg1.js +2 -0
  45. package/dist/{tool-BEivzspP.js → tool-CpSoLUlR.js} +1 -1
  46. package/dist/{update-CJlVgq8V.js → update-D09UponU.js} +1 -1
  47. package/dist/{usage-DOI9sowA.js → usage-Dibnsgtg.js} +1 -1
  48. package/dist/{usage-audit-1GZx4VBG.js → usage-audit-Be431Kj1.js} +1 -1
  49. package/dist/version-BTqAbDeB.js +2 -0
  50. package/dist/workflow-Dx41WM43.js +6 -0
  51. package/dist/{workspaces-D0VOrP2A.js → workspaces-rVOwf5zp.js} +1 -1
  52. package/package.json +1 -1
  53. package/dist/agents-CLcXSbBp.js +0 -2
  54. package/dist/build-task-request-config-Y9X2h9Ia.js +0 -2
  55. package/dist/commands-CdnyYMrx.js +0 -2
  56. package/dist/options-D6fCp3Q_.js +0 -2
  57. package/dist/profile-storage-Dv0xRb8J.js +0 -58
  58. package/dist/project-BhPYRsaZ.js +0 -2
  59. package/dist/project-sources-write-6cBfdUfV.js +0 -2
  60. package/dist/resolve-f238uD6C.js +0 -6
  61. package/dist/skills-CDd-emMc.js +0 -2
  62. package/dist/task-CHnFR-Zp.js +0 -103
  63. package/dist/tasks-D4RIFT8Y.js +0 -14
  64. package/dist/tasks-acCatE6n.js +0 -2
  65. package/dist/version-C37EX5li.js +0 -2
  66. package/dist/workflow-DhomAltH.js +0 -6
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{O as e,St as t,T as n}from"./profile-storage-Dv0xRb8J.js";import{t as r}from"./paginate-CfIrho1f.js";import{T as i,a,d as o,n as s,o as c,r as l,v as u,x as d,y as f}from"./resolve-f238uD6C.js";import{t as p}from"./stdin-DzzLUF6W.js";import{n as m,t as h}from"./instruction-CRCyBKQf.js";async function g(e){let t={};if(e.name!==void 0&&(t.name=e.name),e.description!==void 0&&(t.description=e.description),e.clearInstruction)t.instruction=null;else{let n=await m(e);n!==void 0&&(t.instruction=n)}if(Object.keys(t).length===0)throw new c(`no_fields_to_update`,`No fields provided to update. Pass --name, --description, --instruction, --instruction-file, or --clear-instruction.`);return t}function _(e){return!e.all&&e.nextKey===void 0&&(e.filter??`all`)===`all`&&(e.limit??20)<=20}const v=`You are not a member of any project yet. Create one in the Hub, or ask a project owner to add you.`;async function y(e){await o(e,async t=>{if(e.all){let n=await r(async n=>{let r=await s(t,{limit:e.limit??100,filter:e.filter,nextKey:n});return{items:r.projects,nextKey:r.nextKey}});if(e.json){f({projects:n});return}if(n.length===0){console.log(v);return}d(n,{numbered:!1});return}let{projects:n,nextKey:i}=await s(t,{limit:e.limit,nextKey:e.nextKey,filter:e.filter});if(e.json){f({projects:n,nextKey:i});return}if(n.length===0){console.log(v);return}d(n,{numbered:_(e)}),i&&console.log(`Next page: --next-key ${i}`)})}async function b(e,t){await o(t,async n=>{let r=await l(n,e);if(t.json){f(r);return}u(r)})}async function x(e,t){await o(t,async n=>{let r=await l(n,e);if(t.json){f({id:r.id,instruction:r.instruction});return}r.instruction&&process.stdout.write(i(r.instruction))})}async function S(e,t){await o(t,async r=>{let i=await g(t),o=await a(r,e),s=await r.client.updateProject(r.accessToken,r.workspaceId,o,i);if(t.json){f(s);return}console.log(`Updated project: ${n(s.name)}`),console.log(` ID: ${s.id}`)})}const C=`A work note needs content. Pass -m <text>, -f <file>, or pipe the text in.`;async function w(e){if(e.message!==void 0)return e.message;if(e.file!==void 0)return h(e.file,`note`);if(process.stdin.isTTY)throw new c(`note_content_missing`,C);return p()}async function T(e){let n=await w(e),r=n.trim();if(r.length===0)throw new c(`note_content_missing`,C);if(r.length>1e5)throw new c(`note_content_too_long`,`The note is too long: the maximum is ${t} characters.`);return{content:n,...e.title!==void 0&&{title:e.title}}}async function E(t,n){await o(n,async r=>{let i=await T(n),o=await a(r,t),s=await r.client.createProjectNote(r.accessToken,r.workspaceId,o,i),c=e(`/${r.workspaceId}/task/${s.taskId}`);if(n.json){f({...s,url:c});return}console.log(`Reported a work note. It is a private task under your name, and no AI reply was triggered.`),console.log(` Task ID: ${s.taskId}`),console.log(` Hub: ${c}`)})}export{S as editProject,y as listProjects,E as reportProjectNote,b as showProject,x as showProjectInstruction};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{Mt as e,T as t,a as n,wt as r}from"./profile-storage-Dv0xRb8J.js";import{C as i,a,d as o,h as s,m as c,o as l,s as u,u as d,y as f}from"./resolve-f238uD6C.js";import{n as p,t as m}from"./file-upload-BmP4AJY0.js";const h=[`file`,`link`],g=h.join(`, `),_=/^https?:\/\//iu;function v(e){return h.some(t=>t===e)}function y(e){return e===`asset`||e===`assets`?new l(`asset_not_a_source`,`Assets are managed in the Hub, not through \`sources-*\`. Pass one of: ${g}.`):new l(`invalid_source_type`,`"${t(e)}" is not a source type. Pass one of: ${g}.`)}async function b(e,t){return v(e)?e:d(t,y(e))}async function x(e){if(e.description===void 0)return;let t=r.safeParse({description:e.description});return t.success?t.data.description:d(e,new l(`description_too_long`,`--description ${t.error.issues[0]?.message??`is invalid`}.`))}async function S(n,r){let i=e.safeParse(n);return i.success?i.data:d(r,new l(`invalid_link_url`,`${t(n)} is not a link the project can fetch: ${i.error.issues[0]?.message??`invalid URL`}. Pass a public http(s) URL.`))}function C(e){let n=t(e.filePath);switch(e.problem){case`missing`:return new l(`local_file_not_found`,`No file at ${n}. Pass the path of a local file, or an http(s):// URL to add a link.`);case`not_a_file`:return new l(`local_path_not_a_file`,`${n} is not a regular file. Pass the path of one file at a time.`);default:return new l(`local_file_unreadable`,`Cannot read ${n}. Check its permissions and try again.`)}}async function w(e,t){try{return await p(e)}catch(e){if(!(e instanceof m))throw e;return d(t,C(e))}}async function T(e,t,n,r){let{client:i,accessToken:a,workspaceId:o}=e;return n.type===`file`?c(await i.updateProjectFileDescription(a,o,t,n.id,{description:r})):s(await i.updateProjectLinkDescription(a,o,t,n.id,{description:r}))}async function E(e,t,n){return s(await e.client.addProjectLink(e.accessToken,e.workspaceId,t,{url:n}))}async function D(e,r,i){let a=await u(i,{client:e.client}),o=`${t(r.name)} was uploaded as file ${r.id} before the project refused it; that upload is attached to nothing, and running the command again uploads the file afresh.`;return new l(a?.code??`file_not_attached`,`${a?.message??n(i).message} ${o}`)}async function O(e,t,n){let{client:r,accessToken:i,workspaceId:a}=e,o=await r.uploadFile(i,a,n,`openai`);try{return c(await r.attachProjectFile(i,a,t,{fileId:o.id}))}catch(t){throw await D(e,o,t)}}function k(e,t,n){if(n.json){f(t);return}i(e,t,t.status===`pending`?"Its snapshot is being fetched; `entrydesk project sources <project>` shows when it is ready.":void 0)}async function A(e,t){return _.test(e)?{kind:`link`,url:await S(e,t)}:{kind:`file`,file:await w(e,t)}}async function j(e,t,r){let i=(await u(r,{client:e.client}))?.message??n(r).message;return new l(`description_not_saved`,`The ${t.type} was added, but its description was not saved: ${i} Set it with \`entrydesk project sources-edit <project> ${t.type} ${t.id} --description <text>\`.`)}async function M(e,t,n,r,i){try{return await T(e,t,n,r)}catch(t){throw k(`Added`,n,i),await j(e,n,t)}}async function N(e,t,n){let r=await x(n),i=await A(t,n);await o(n,async t=>{let o=await a(t,e),s=i.kind===`link`?await E(t,o,i.url):await O(t,o,i.file);r!==void 0&&(s=await M(t,o,s,r,n)),k(`Added`,s,n)})}async function P(e,t,n,r){let i=await b(t,r),s=await x(r);if(s===void 0)return d(r,new l(`description_missing`,`Pass --description <text>. An empty string clears the description.`));await o(r,async t=>{k(`Updated`,await T(t,await a(t,e),{type:i,id:n},s),r)})}async function F(e,t,n){await o(n,async r=>{let i=await a(r,e);k(`Refetching`,s(await r.client.refetchProjectLink(r.accessToken,r.workspaceId,i,t)),n)})}async function I(e,n,r,i){let s=await b(n,i);await o(i,async n=>{let{client:o,accessToken:c,workspaceId:l}=n,u=await a(n,e);if(s===`file`?await o.removeProjectFile(c,l,u,r):await o.removeProjectLink(c,l,u,r),i.json){f({type:s,id:r,removed:!0});return}console.log(`Removed ${s}: ${t(r)}`)})}export{N as addProjectSource,P as editProjectSource,F as refetchProjectSource,I as removeProjectSource};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{T as e,a as t,b as n,g as r,o as i,u as a,w as o,x as s}from"./profile-storage-Dv0xRb8J.js";import{i as c,n as l}from"./format-C3tQC6LL.js";import{HTTPError as u}from"ky";import{validate as d}from"uuid";function f(t){return e(t)}function p(e){return e.split(`
3
- `).map(f)}function m(e,{numbered:t}){console.log(`Projects (${e.length}):\n`);for(let[n,r]of e.entries()){let e=t?`${String(n+1).padStart(2,` `)} `:``;console.log(` ${e}${f(r.name)}`),console.log(` ${r.role} · updated ${l(r.updatedAt)}`),console.log(` ID: ${r.id}`),console.log(``)}t||console.log("This listing is filtered or paged, so its positions are not the numbers `<project>` takes — pass an ID above.")}function h(e){return`${f(e.name)} <${f(e.email)}> · ${e.role}`}function g(e){console.log(`${f(e.name)}\n`),console.log(` ID: ${e.id}`),console.log(` Role: ${e.role}`),e.description&&console.log(` Description: ${f(e.description)}`),console.log(` Updated: ${l(e.updatedAt)}`),console.log(` Sources: ${e.sourceCount} · Tasks: ${e.taskCount} · Assets: ${e.assetCount}`),console.log(`\n Members (${e.members.length}):`);for(let t of e.members)console.log(` - ${h(t)}`);if(console.log(`
4
- Instruction:`),!e.instruction){console.log(` (none)`);return}for(let t of p(e.instruction))console.log(` ${t}`)}function _(e){console.log(`Members of ${f(e.name)} (${e.members.length}):\n`);for(let t of e.members)console.log(` - ${h(t)}`),console.log(` ID: ${t.userId}`)}function v(e){console.log(`Deleting project: ${f(e.name)}`),console.log(` ID: ${e.id}\n`),console.log(`This will:`),console.log(` - Detach its ${c(e.taskCount,`task`)}; each returns to its owner's main list`),console.log(` - Delete its ${c(e.sourceCount,`source`)} — the files and links in it`),console.log(` - Delete its ${c(e.assetCount,`asset`)}, with every version in their history`),console.log(`
5
- This can't be undone.`)}function y(e){return process.stdout.isTTY?p(e).join(`
6
- `):e}function b(e){let t=JSON.stringify(e);console.log(process.stdout.isTTY?f(t):t)}function x(e){let t=JSON.stringify(e);process.stderr.write(`${process.stderr.isTTY?f(t):t}\n`)}function S(e){return{type:`file`,id:e.id,title:e.name,description:e.description,status:`ready`}}function C(e){return{type:`link`,id:e.id,title:e.title??e.url,description:e.description,status:e.status,url:e.url,fetchError:e.fetchError}}function w(e){return e.status===`failed`&&e.fetchError?`${e.status} — ${f(e.fetchError)}`:e.status}function T(e){console.log(`Sources (${e.length}):\n`);for(let t of e)console.log(` [${t.type}] ${f(t.title)}`),console.log(` ID: ${t.id}`),console.log(` Status: ${w(t)}`),t.url&&console.log(` URL: ${f(t.url)}`),console.log(` Description: ${t.description?f(t.description):`(none)`}`),console.log(``)}function E(e,t,n){console.log(`${e} ${t.type}: ${f(t.title)}`),console.log(` ID: ${t.id}`),console.log(` Status: ${w(t)}`),n&&console.log(n)}function D(e){for(let t of p(e))console.log(` ${t}`)}function O(e){console.log(`Results (${e.length}):\n`);for(let t of e)console.log(` [${t.type}] ${f(t.title)}`),t.type===`task`?(console.log(` ID: ${t.taskId}`),console.log(` Updated: ${l(t.updatedAt)}`)):(console.log(` ID: ${t.sourceId}`),t.description&&console.log(` Description: ${f(t.description)}`)),t.snippet&&D(t.snippet),console.log(``)}var k=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`ProjectCommandError`}};const A=`Project not found`,j="Source not found. Check the type and id against `entrydesk project sources <project>`.";function M(){return new k(`project_not_found`,A)}function N(){return new k(`project_feature_disabled`,"Projects are not enabled on this server. Ask an operator to set ENABLE_PROJECT, or point `entrydesk config set apiUrl <url>` at a server that has them.")}const P={context_source_not_found:`Context source not found. Check the id, and note that assets are not part of the CLI context surface — view them in the Hub.`,project_owner_required:`Only a project owner can do this. Ask an owner, or have one make you an owner first.`,project_last_owner_required:`This is the last owner of the project. Promote another member to owner before removing or demoting them.`,project_invitee_not_in_workspace:`That user is not a member of this workspace, so they cannot be added to a project in it.`,project_member_already_exists:`That user is already a member of this project.`,project_member_not_found:`That user is not a member of this project.`,task_not_found:`Task not found. Only a task you own can be moved or shared, and only by its id.`,asset_sharing_confirmation_required:`This task produced assets the project does not hold yet. Moving it in shares them with every member of the project — re-run with --confirm-asset-sharing to confirm.`,task_not_in_project:`This task is not in a project, so there are no project members to share it with.`,not_project_member:"This person is not a member of the project. `entrydesk project get <project> --json` lists the members with their ids.",sharing_disabled:`Sharing is turned off for this workspace by an admin.`,share_visibility_not_allowed:`This share level is not allowed by the workspace share policy set by an admin.`,project_not_found:A,project_file_not_found:j,project_link_not_found:j,file_not_found:`The uploaded file is no longer there to attach. Run the command again.`,project_file_already_attached:`This file is already a source of the project.`,project_link_fetch_in_progress:"This link is already being fetched. Wait for `entrydesk project sources <project>` to show it as ready or failed, then refetch."};function F(){return new k(`project_owner_required`,P.project_owner_required)}function I(e){let{status:t}=e.response;if(t<400||t>=500)return null;let n=o(e.data);if(n===void 0)return null;let r=P[n];return r===void 0?null:new k(n,r)}async function L(e){try{let{features:t}=await e.getRuntimeConfig();if(!t.enableProject)return N()}catch{}return M()}const R=[/\/projects\/[^/]+\/notes$/u,/\/projects\/[^/]+\/tasks$/u,/\/tasks\/[^/]+$/u,/\/tasks\/[^/]+\/project$/u,/\/tasks\/[^/]+\/shares(?:\/members\/[^/]+)?$/u,/\/workspaces\/[^/]+\/files$/u];function z(e){let{pathname:t}=new URL(e.request.url),n=R.some(e=>e.test(t));return e.request.method.toUpperCase()===`GET`?n?`tasks:read`:`projects:read`:n?`tasks:write`:`projects:write`}function B(e){let t=null;try{t=r()}catch{}return t?.authSource===`pat-env`?`This token is missing the \`${e}\` scope. Issue a personal access token that grants it, then set ENTRYDESK_TOKEN to it.`:`Your session is missing the \`${e}\` scope — it predates project support. Run \`entrydesk login\` again to grant it.`}function V(e){return new k(`insufficient_scope`,B(e))}function H(e){if(!(e instanceof s))return null;switch(e.code){case`project_not_found`:return M();case`project_not_enabled`:return N();case`insufficient_scope`:return V(`tasks:write`);default:return null}}async function U(e,t,n){if(t instanceof k)return t;if(!(t instanceof u))return null;let r=t.response.status;return r===403&&o(t.data)===`insufficient_scope`?V(n??z(t)):r===404&&e?I(t)??L(e):I(t)}async function W(e,t={}){return U(t.client,e,t.requiredScope)}async function G(n,r,a,o){let s=await U(n,r,o);a.json||(s||i(r),console.error(`Error: ${e(s.message)}`),process.exit(1)),x({error:s?{code:s.code,message:s.message}:{code:`request_failed`,message:t(r).message}}),process.exit(1)}function K(e,t){return G(void 0,t,e)}async function q(e,t,r){let i=new n;try{let{accessToken:e,workspaceId:n}=await a();return await t({client:i,accessToken:e,workspaceId:n})}catch(t){return G(i,t,e,r)}}async function J(e,t){await q(e,t)}async function Y({client:e,accessToken:t,workspaceId:n},r){return e.listProjects(t,n,{limit:r.limit??20,nextKey:r.nextKey,filter:r.filter})}async function X(e,t){if(d(t))return t;if(!/^\d+$/u.test(t))throw M();let n=Number.parseInt(t,10),{projects:r}=await Y(e,{filter:`all`});if(n<1||n>r.length)throw new k(`project_index_out_of_range`,`No project numbered ${n}. \`entrydesk project list\` shows ${r.length}.`);return r[n-1].id}async function Z(e,t){let n=await X(e,t);return e.client.getProject(e.accessToken,e.workspaceId,n)}async function Q(e,t){await e.client.getTasks(e.accessToken,e.workspaceId,{limit:1,projectId:t})}async function $(e,t){return q({json:t},t=>X(t,e),`projects:read`)}export{E as C,_ as S,y as T,v as _,X as a,x as b,H as c,J as d,q as f,O as g,C as h,$ as i,F as l,S as m,Y as n,k as o,h as p,Z as r,W as s,Q as t,K as u,g as v,T as w,m as x,b as y};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{F as e,b as t,u as n}from"./profile-storage-Dv0xRb8J.js";import{i as r,m as i}from"./paths-C9BPsZVF.js";import{n as a,t as o}from"./commands-3Yqb38G_.js";import{t as s}from"./remote-nEFOyIM2.js";import c from"node:fs";import l from"node:os";import u from"node:path";import{isHTTPError as d}from"ky";import f from"node:crypto";import p from"node:fs/promises";import{Readable as m}from"node:stream";import{pipeline as h}from"node:stream/promises";import g from"adm-zip";import _ from"archiver";function v(e){return e.all?`all`:e.remote&&!e.local?`remote`:e.local&&!e.remote?`local`:`all`}function y(e,t,n){let r=new Map(t.map(e=>[e.name,e])),i=new Map(Object.entries(e)),a=new Set;if(n!==`remote`)for(let e of i.keys())a.add(e);if(n!==`local`)for(let e of r.keys())a.add(e);let o=[];for(let e of a){let t=i.get(e),n=r.get(e);o.push({name:e,local:!!t,remote:!!n,sourceType:t?.sourceType,skillId:t?.skillId??n?.id})}return o.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),o}function b(e){return e.local&&e.remote?`local+remote`:e.local?`local-only`:`remote-only`}async function x(e,t){let n=v(e),{rootDir:a,workspaceId:o}=r(!!e.global,t.workspaceId),c=y(n===`remote`?{}:i(a).skills,n===`local`?[]:await s(t.client,t.accessToken,o),n);if(e.json){console.info(JSON.stringify(c,null,2));return}if(c.length===0){console.info(n===`local`?`No skills tracked locally.`:`No skills available in the workspace.`);return}let l=(e,t)=>e.padEnd(t);console.info(`${l(`NAME`,28)}${l(`WHERE`,14)}SOURCE`);for(let e of c)console.info(`${l(e.name,28)}${l(b(e),14)}${e.sourceType??`—`}`)}async function S(){let{accessToken:e,workspaceId:r}=await n();return{accessToken:e,workspaceId:r,client:new t}}function C(e,t){let n=u.relative(e,t);return n===``||!n.startsWith(`..`)&&!u.isAbsolute(n)}async function w(e){let t=await p.realpath(e),n=[process.cwd(),l.homedir()];if(!(await Promise.all(n.map(async e=>{try{return await p.realpath(e)}catch{return u.resolve(e)}}))).some(e=>C(e,t)))throw Error(`Invalid upload path: must be within the current directory or your home directory.`)}async function T(e){let t=await p.mkdtemp(u.join(l.tmpdir(),`entrydesk-skill-`)),n=u.join(t,`${u.basename(e)}.zip`);return await new Promise((t,r)=>{let i=c.createWriteStream(n),a=_(`zip`,{zlib:{level:9}});i.on(`close`,()=>t()),i.on(`error`,r),a.on(`error`,r),a.pipe(i),a.directory(e,!1),a.finalize()}),{zipPath:n,cleanupDir:t}}function E(e){console.log(`Versions (${e.length}):\n`);for(let t of e){let e=new Date(t.createdAt).toLocaleString();if(console.log(` v${t.versionNumber} · ${e}`),t.description){let e=t.description.length>100?`${t.description.slice(0,100)}…`:t.description;console.log(` ${e}`)}console.log(` Version ID: ${t.id}`),console.log(``)}}function D(t){let n=e(t);if(console.log(`User grants (${n.length}):`),n.length===0){console.log(` (none)`);return}for(let e of n)console.log(` - ${e.user.name} <${e.user.email}> · ${e.role}`),console.log(` ID: ${e.userId}`)}async function O(e){let t=await S();if(e.local||e.remote||e.all){await x(e,t);return}let n=[],r;do{let i=await t.client.listAvailableSkills(t.accessToken,t.workspaceId,{createdBy:e.mine?`me`:void 0,nextKey:r,limit:100});n.push(...i.skills),r=i.nextKey}while(r);if(e.json){console.log(JSON.stringify(n));return}if(n.length===0){console.log("No skills in this workspace yet. Upload one with `entrydesk skills upload <path>`, or browse `entrydesk marketplace`.");return}console.log(`Available skills (${n.length}):\n`);for(let e of n)console.log(` ${e.name} (${e.provider})`),console.log(` ${e.description.slice(0,120)}`),console.log(` ID: ${e.id}`),console.log(` Author: ${e.author.name}`),console.log(``)}async function k(e,r){let{accessToken:i,workspaceId:a}=await n(),o=new t,s=u.resolve(e),c;try{c=await p.stat(s)}catch{console.error(`File not found: ${s}`),process.exit(1)}let l=s,f=null;try{try{await w(s)}catch(e){let t=e instanceof Error?e.message:`Invalid upload path.`;console.error(t),process.exit(1)}if(c.isDirectory()){let e=await T(s);l=e.zipPath,f=e.cleanupDir}else c.isFile()||(console.error(`Not a file or directory: ${s}`),process.exit(1));u.extname(l).toLowerCase()!==`.zip`&&(console.error(`Only .zip files are supported for upload.`),process.exit(1));let e=await p.readFile(l),t=new FormData;t.append(`file`,new Blob([e],{type:`application/zip`}),u.basename(l)),r.force&&t.append(`force`,`true`);let n;try{n=await o.uploadSkill(i,a,t)}catch(e){throw d(e)&&e.response.status===409&&(console.error(`Upload failed: A skill with this name already exists.`),console.error(`Use --force to overwrite the existing skill.`),process.exit(1)),e}if(r.json){console.log(JSON.stringify(n));return}console.log(`Uploaded skill: ${n.name}`),console.log(` ID: ${n.id}`),console.log(` Version ID: ${n.versionId}`),console.log(` Description: ${n.description}`)}finally{f&&await p.rm(f,{recursive:!0,force:!0})}}async function A(e,r){!r.enable&&!r.disable&&(console.error(`Pass exactly one of --enable or --disable.`),process.exit(1));let i=!!r.enable,{accessToken:a,workspaceId:o}=await n(),s=await new t().updateSkillPreference(a,o,e,i);if(r.json){console.log(JSON.stringify(s));return}console.log(`${s.isEnabled?`Enabled`:`Disabled`} skill for you: ${e}`)}async function j(e,r){let{accessToken:i,workspaceId:a}=await n(),o=await new t().getSkillVersions(i,a,e);if(r.json){console.log(JSON.stringify(o));return}if(o.versions.length===0){console.log(`No versions for this skill.`);return}E(o.versions)}async function M(e,r){let{accessToken:i,workspaceId:a}=await n(),o=new t;if(r.addUser){let t=await o.upsertSkillGrant(i,a,e,r.addUser,r.role);if(r.json){console.log(JSON.stringify(t));return}console.log(`Granted ${r.role} to user ${r.addUser}`);return}if(r.removeUser){if(await o.removeSkillGrant(i,a,e,r.removeUser),r.json){console.log(JSON.stringify({userId:r.removeUser,removed:!0}));return}console.log(`Revoked access for user ${r.removeUser}`);return}let s=await o.getSkillGrants(i,a,e);if(r.json){console.log(JSON.stringify(s));return}D(s)}async function N(e){let{accessToken:r,workspaceId:i}=await n();await new t().deleteSkill(r,i,e),console.log(`Deleted skill: ${e}`)}async function P(e,r){let{accessToken:i,workspaceId:a}=await n(),{url:o,name:s}=await new t().downloadSkillCurrent(i,a,e);(s.includes(`/`)||s.includes(u.sep)||s===`.`||s===`..`||!s)&&(console.error(`Invalid skill name for output directory: ${s}`),process.exit(1));let d=u.resolve(s),_=await p.mkdtemp(u.join(l.tmpdir(),`entrydesk-skill-download-`)),v=u.join(_,`${s}.zip`);try{let t=await fetch(o);if(!t.ok)throw Error(`Failed to download skill zip: ${t.status} ${t.statusText}`);if(!t.body)throw Error(`Response body is empty`);let n=c.createWriteStream(v);await h(m.fromWeb(t.body),n);let i=await p.mkdtemp(u.join(u.dirname(d),`.entrydesk-skill-extract-`)),a=null;try{r.json||console.log(`Extracting…`);let e=new g(v),t=u.resolve(i)+u.sep;for(let n of e.getEntries()){if(n.isDirectory)continue;let e=u.resolve(i,n.entryName);if(!e.startsWith(t))throw Error(`Zip entry contains path traversal: ${n.entryName}`);await p.mkdir(u.dirname(e),{recursive:!0}),await p.writeFile(e,n.getData())}c.existsSync(d)&&(a=u.join(u.dirname(d),`.entrydesk-backup-${f.randomUUID()}`),r.json||console.log(`Replacing existing directory: ${d}`),await p.rename(d,a));try{await p.rename(i,d),a&&c.existsSync(a)&&(await p.rm(a,{recursive:!0,force:!0}),a=null)}catch(e){throw a&&c.existsSync(a)&&(await p.rename(a,d),a=null),e}}catch(e){if(await p.rm(i,{recursive:!0,force:!0}),a&&c.existsSync(a))try{await p.rename(a,d)}catch{console.error(`Warning: Could not restore backup. Your original files are at: ${a}`)}throw e}if(r.json){console.log(JSON.stringify({skillId:e,skillName:s,outputDir:d}));return}console.log(`Downloaded skill "${s}" to ${d}`)}finally{await p.rm(_,{recursive:!0,force:!0})}}async function F(e,t){let{runSkillsAdd:n}=await import(`./add-Lh_kLR85.js`);await n(e,t,await S())}async function I(e,t){await a(e,t,await S())}async function L(e,t){let{runSkillsPush:n}=await import(`./push-Ce79oiu0.js`);await n(e,t,await S())}async function R(e){let{runSkillsStatus:t}=await import(`./status-CDMSNVD8.js`);await t(e,await S())}async function z(e,t){let{runSkillsRemove:n}=await import(`./remove-bHAmCTdf.js`);await n(e,t,await S())}async function B(e,t){o(e,t,await S())}export{F as addSkill,N as deleteSkill,P as downloadSkill,B as linkSkillsDirectory,j as listSkillVersions,O as listSkills,I as pullSkill,L as pushSkill,z as removeSkill,M as shareSkill,R as showSkillsStatus,A as toggleSkill,k as uploadSkill};