@entrydesk/cli 1.29.0 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/agents-PRK5LQNG.js +43 -0
- package/dist/{billing-LXGGM4BO.js → billing-L6QQXRZW.js} +1 -1
- package/dist/{budget-3KJ75AIF.js → budget-NSNB4TFT.js} +1 -1
- package/dist/chunk-FKRIIPBA.js +2 -0
- package/dist/chunk-JMYSCKCF.js +2 -0
- package/dist/chunk-UVF7TGFB.js +120 -0
- package/dist/config-2JH7KXGU.js +4 -0
- package/dist/{config-help-2YHNIPHU.js → config-help-ND4I4Y4D.js} +1 -1
- package/dist/{connectors-YUVHSMJD.js → connectors-26E6RK7B.js} +8 -8
- package/dist/help-KDHCFJNF.js +4 -0
- package/dist/index.js +1 -1
- package/dist/login-WXXDXOHI.js +2 -0
- package/dist/logout-6S6KRPMB.js +2 -0
- package/dist/{marketplace-4NZ4R2RK.js → marketplace-WV4PKSWS.js} +8 -8
- package/dist/mcp-2Q5DRF4P.js +4 -0
- package/dist/{meeting-NAS2QHFI.js → meeting-ZI2UOSO6.js} +5 -5
- package/dist/models-TXYNHCLD.js +3 -0
- package/dist/{notifications-CSXLCFK2.js → notifications-5CD6KFTP.js} +3 -3
- package/dist/{profile-4GVYKBJP.js → profile-OMP7YDYA.js} +1 -1
- package/dist/{recordings-GJIO55FV.js → recordings-MLYXHDWH.js} +3 -3
- package/dist/{schedules-7CGTNN5S.js → schedules-GIAYSDUE.js} +9 -9
- package/dist/{skills-OOY3DP3O.js → skills-IK7KZZ45.js} +3 -3
- package/dist/status-OKGY6H3C.js +2 -0
- package/dist/task-XXJ5PAJF.js +179 -0
- package/dist/{tasks-SJWOHL6F.js → tasks-2TMKPOTB.js} +9 -9
- package/dist/tool-HMD5ROEP.js +35 -0
- package/dist/{update-B3LT5ALF.js → update-DM47OUD3.js} +2 -2
- package/dist/{usage-IQW77ZHI.js → usage-TLLEU4K7.js} +5 -5
- package/dist/version-USTE3KNX.js +2 -0
- package/dist/workflow-PRS2UCQT.js +62 -0
- package/dist/{workspaces-KDZIJPII.js → workspaces-HML7DEAL.js} +3 -3
- package/package.json +9 -7
- package/dist/agents-HRFKKSCB.js +0 -43
- package/dist/chunk-GN6HSCLY.js +0 -4
- package/dist/chunk-LHRI5YM6.js +0 -2
- package/dist/chunk-NOSHH4TO.js +0 -8
- package/dist/chunk-YAWZE3PA.js +0 -91
- package/dist/chunk-ZIAOI7B2.js +0 -2
- package/dist/config-53QOLH2T.js +0 -4
- package/dist/help-FBKSAMA7.js +0 -4
- package/dist/login-BKSNJT4R.js +0 -2
- package/dist/logout-U64RQTQO.js +0 -2
- package/dist/mcp-EON5KZPT.js +0 -4
- package/dist/models-E3O6GOH5.js +0 -3
- package/dist/status-KK6P75DT.js +0 -2
- package/dist/task-ET6X7N52.js +0 -211
- package/dist/token-5JSZTSX7.js +0 -2
- package/dist/token-util-U6DGFQDY.js +0 -2
- package/dist/tool-TW7BI2LH.js +0 -35
- package/dist/version-TG5WFL3B.js +0 -2
- package/dist/workflow-J6RX65V7.js +0 -62
package/dist/token-5JSZTSX7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as _,b as k}from"./chunk-LHRI5YM6.js";import{b as s}from"./chunk-ZIAOI7B2.js";var T=s((w,f)=>{var i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,O=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},j=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of u(e))!d.call(t,r)&&r!==o&&i(t,r,{get:()=>e[r],enumerable:!(n=l(e,r))||n.enumerable});return t},v=t=>j(i({},"__esModule",{value:!0}),t),p={};O(p,{refreshToken:()=>y});f.exports=v(p);var c=_(),a=k();async function y(t){let e=t?.project,o=t?.team;if(!e&&!o){let r=(0,a.findProjectInfo)();e=r.projectId,o=r.teamId}else if(!e||!o){let r=(0,a.findProjectInfo)();e=e??r.projectId,o=o??r.teamId}if(!e)throw new c.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let n=(0,a.loadToken)(e);if(!n||(0,a.isExpired)((0,a.getTokenPayload)(n.token),t?.expirationBufferMs)){let r=await(0,a.getVercelToken)({expirationBufferMs:t?.expirationBufferMs});if(n=await(0,a.getVercelOidcToken)(r,e,o),!n)throw new c.VercelOidcTokenError("Failed to refresh OIDC token");(0,a.saveToken)(n,e)}process.env.VERCEL_OIDC_TOKEN=n.token}});export default T();
|
package/dist/tool-TW7BI2LH.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{c as S,t as _}from"./chunk-GN6HSCLY.js";import"./chunk-ZIAOI7B2.js";import R from"fs";import{Client as x}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as v}from"@modelcontextprotocol/sdk/client/streamableHttp.js";async function A(t={}){let e=t.apiUrl,n=t.accessToken,o=t.workspaceId;if(!n||!o){let l=await _();n=n||l.accessToken,o=o||l.workspaceId}e||(e=S().apiUrl);let i=new x({name:"entrydesk-cli",version:"1.0.0"}),s=new URL(`${e}/v1/workspaces/${o}/mcp`),r=new v(s,{requestInit:{headers:{Authorization:`Bearer ${n}`}}});return await i.connect(r),i}async function T(){return A()}import h from"fs/promises";import D from"os";import d from"path";var y=!process.env.NO_COLOR&&!!process.stdout.isTTY,p={green:y?"\x1B[32m":"",yellow:y?"\x1B[33m":"",reset:y?"\x1B[0m":""},P=10*1024,O=8*1024,I=2*1024,b=100,M=100;function U(){return d.join(D.homedir(),".entrydesk","tool-results")}function B(t){let e=t.trim().replace(/[/\\:*?"<>|\s]/g,"_").replace(/_+/g,"_").replace(/^[._]+|[._]+$/g,"").slice(0,b);return!e||e==="."||e===".."?"unnamed_tool":e}function F(t){try{return JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}n`:typeof n=="function"?"[Function]":typeof n=="symbol"?n.toString():n,2)}catch{return String(t)}}function J(t){let e=new Date,n=[e.getFullYear(),String(e.getMonth()+1).padStart(2,"0"),String(e.getDate()).padStart(2,"0")].join("-")+"_"+[String(e.getHours()).padStart(2,"0"),String(e.getMinutes()).padStart(2,"0"),String(e.getSeconds()).padStart(2,"0")].join("-"),o=B(t);return`${n}_${o}.json`}async function N(t,e){try{return await h.writeFile(t,e,{encoding:"utf8",flag:"wx"}),!0}catch(n){if(n instanceof Error&&"code"in n&&n.code==="EEXIST")return!1;throw n}}async function C(t,e){try{let n=U();await h.mkdir(n,{recursive:!0});let o=J(t),i=d.extname(o),s=o.slice(0,-i.length),r=F(e),l=d.join(n,o);if(await N(l,r))return l;for(let c=1;c<=M;c++){let w=d.join(n,`${s}-${c}${i}`);if(await N(w,r))return w}let u=Math.random().toString(36).slice(2,10),a=d.join(n,`${s}-${u}${i}`);return await h.writeFile(a,r,{encoding:"utf8",flag:"wx"}),a}catch(n){let o=n instanceof Error?n.message:"unknown error";return console.error(`${p.yellow}Warning: Could not save result to file: ${o}${p.reset}`),null}}function k(t,e){let n=Buffer.byteLength(t,"utf8");if(n<=P)return t;let o=t.slice(0,O),i=t.slice(-I),r=((n-O-I)/1024).toFixed(1),l=(n/1024).toFixed(1),u=` ... (skipped ${r}KB of ${l}KB) ...`;return e&&(u+=`
|
|
3
|
-
Tip: jq -r '.structuredContent.field' <file> | grep/head/tail`),`${o}
|
|
4
|
-
|
|
5
|
-
${u}
|
|
6
|
-
|
|
7
|
-
${i}`}function $(t){console.log(`${p.green}Tool execution result saved to: ${t}${p.reset}`),console.log()}function E(){console.log(`${p.green}Tool execution result:${p.reset}`)}function H(t){return t.split("__")[0]??t}function f(t,e,n){console.error(n?JSON.stringify({error:{code:t,message:e}}):`Error [${t}]: ${e}`),process.exit(1)}function g(t,e,n="CONNECTION_FAILED"){let o=t instanceof Error?t.message:"Unknown error";o.includes("Not logged in")||o.includes("not-logged-in")?f("AUTH_MISSING",o,e):f(n,o,e)}async function Y(){return process.stdin.isTTY?null:new Promise(t=>{let e=[],n=!1,o=!1,i,s,r,l,u=()=>{clearTimeout(i),process.stdin.removeListener("data",s),process.stdin.removeListener("end",r),process.stdin.removeListener("error",l)},a=c=>{o||(o=!0,u(),t(c))};s=c=>{n=!0,clearTimeout(i),e.push(c)},r=()=>{e.length===0?a(null):a(Buffer.concat(e).toString("utf-8").trim())},l=()=>{a(null)},i=setTimeout(()=>{n||a(null)},100),process.stdin.on("data",s),process.stdin.on("end",r),process.stdin.on("error",l),process.stdin.resume()})}var m=class extends Error{constructor(e){super(e),this.name="InputError"}};async function V(t,e){if(t)return t;if(e)try{return R.readFileSync(e,"utf-8").trim()}catch(o){let i=o instanceof Error?o.message:"Failed to read input file";throw new m(`Failed to read input file: ${i}`)}let n=await Y();if(n)return n;throw new m("Input JSON is required. Use --input, --input-file, or pipe via stdin")}function q(t){let e=[`Tool: ${t.name}`];return t.description&&e.push(` Description: ${t.description}`),e.join(`
|
|
8
|
-
`)}function X(t){let e=[`Tool: ${t.name}`];return t.description&&(e.push("Description:"),e.push(` ${t.description}`)),e.push("Input Schema:"),e.push(JSON.stringify(t.inputSchema,null,2)),e.join(`
|
|
9
|
-
`)}async function z(t,e){let n=await T().catch(o=>{g(o,t)});try{let i=(await n.listTools()).tools;if(e){let s=e.toLowerCase();i=i.filter(r=>H(r.name).toLowerCase().startsWith(s))}if(t)console.log(JSON.stringify(i,null,2));else{let s=e?` (prefix: ${e})`:"";console.log(`Available Tools (${i.length})${s}:
|
|
10
|
-
`);for(let r of i)console.log(q(r)),console.log()}}catch(o){g(o,t)}finally{await n.close().catch(()=>{})}}async function G(t,e){let n=await T().catch(o=>{g(o,e)});try{let i=(await n.listTools()).tools.find(s=>s.name===t);i||f("TOOL_NOT_FOUND",`Tool not found: ${t}`,e),console.log(e?JSON.stringify(i,null,2):X(i))}catch(o){g(o,e)}finally{await n.close().catch(()=>{})}}async function K(t,e,n){let o;try{o=JSON.parse(e)}catch(r){let l=r instanceof Error?`Invalid JSON input: ${r.message}`:"Invalid JSON input";f("INVALID_INPUT",l,n)}let i=await T().catch(r=>{g(r,n,"TOOL_CALL_FAILED")}),s=!1;try{let r=await i.callTool({name:t,arguments:o});if(n)console.log(JSON.stringify(r,null,2));else{let l=await C(t,r);l&&$(l),E();let u=r.content;for(let a of u)a.type==="text"?console.log(a.text):a.type==="image"?console.log(`[Image: ${a.mimeType}]`):a.type==="resource"?console.log(`[Resource: ${a.resource?.uri??"unknown"}]`):console.log(JSON.stringify(a,null,2));if(r.structuredContent){let a=JSON.stringify(r.structuredContent,null,2),c=k(a,l);console.log(c)}}r.isError&&(s=!0)}catch(r){g(r,n,"TOOL_CALL_FAILED")}finally{await i.close().catch(()=>{})}s&&process.exit(1)}function L(){console.log(`Usage: entrydesk tool <action> [options]
|
|
11
|
-
|
|
12
|
-
Actions:
|
|
13
|
-
list List all available tools
|
|
14
|
-
get <name> Get details of a specific tool
|
|
15
|
-
call <name> Call a tool with JSON input
|
|
16
|
-
|
|
17
|
-
Options:
|
|
18
|
-
--json Output in JSON format
|
|
19
|
-
-p, --prefix <name> Filter tools by prefix (for 'list' action)
|
|
20
|
-
-i, --input <json> JSON input for tool call
|
|
21
|
-
-f, --input-file <path> Read JSON input from file
|
|
22
|
-
|
|
23
|
-
Input Priority (for 'call' action):
|
|
24
|
-
1. --input flag (direct JSON string)
|
|
25
|
-
2. --input-file flag (read from file)
|
|
26
|
-
3. stdin (piped input)
|
|
27
|
-
|
|
28
|
-
Examples:
|
|
29
|
-
entrydesk tool list
|
|
30
|
-
entrydesk tool list --prefix agent
|
|
31
|
-
entrydesk tool get agent__search_agents
|
|
32
|
-
entrydesk tool call agent__search_agents --input '{"limit": 5}'
|
|
33
|
-
entrydesk tool call agent__search_agents --input-file input.json
|
|
34
|
-
echo '{"limit": 5}' | entrydesk tool call agent__search_agents
|
|
35
|
-
`)}async function at(t){let e=t.json??!1;if(t.help){L();return}switch(t.action){case"list":await z(e,t.prefix);break;case"get":t.name||f("INVALID_INPUT","Tool name is required",e),await G(t.name,e);break;case"call":{t.name||f("INVALID_INPUT","Tool name is required",e);let n;try{n=await V(t.input,t.inputFile)}catch(o){throw o instanceof m&&f("INVALID_INPUT",o.message,e),o}await K(t.name,n,e);break}default:L();break}}export{m as InputError,V as getInputJson,L as printToolUsage,Y as readStdin,at as runTool};
|
package/dist/version-TG5WFL3B.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{c as u}from"./chunk-YAWZE3PA.js";import"./chunk-NOSHH4TO.js";import{g as p,t as g,v as k}from"./chunk-GN6HSCLY.js";import"./chunk-ZIAOI7B2.js";import{readFileSync as I}from"fs";var m=262144,R=new Set(["completed","failed","cancelled"]);function f(){console.log(`
|
|
3
|
-
Usage: entrydesk workflow [list|get|create|update|run|runs|run-get|share] [options]
|
|
4
|
-
|
|
5
|
-
Commands:
|
|
6
|
-
list List workflows (default)
|
|
7
|
-
get <workflowId> Show workflow details (--show-source for the script)
|
|
8
|
-
create Create a workflow from a local script file
|
|
9
|
-
update <workflowId> Update name/description/script or enable/disable
|
|
10
|
-
run <workflowId> Trigger a run; prints the runId (--wait to follow)
|
|
11
|
-
runs <workflowId> List runs of a workflow
|
|
12
|
-
run-get <workflowId> <runId> Show a run's status, nodes, and logs
|
|
13
|
-
share <workflowId> Show or manage sharing (user grants)
|
|
14
|
-
|
|
15
|
-
List Options:
|
|
16
|
-
--search <text> Search by name
|
|
17
|
-
--limit <number> Max workflows per page (default: 20)
|
|
18
|
-
--next-key <cursor> Fetch next page using cursor
|
|
19
|
-
--all Fetch all workflows (auto-paginate)
|
|
20
|
-
|
|
21
|
-
Create/Update Options:
|
|
22
|
-
--name <text> (required for create)
|
|
23
|
-
--description <text>
|
|
24
|
-
--file <path.js> Script source file (required for create)
|
|
25
|
-
--activate Enable the workflow (update only)
|
|
26
|
-
--deactivate Disable the workflow (update only)
|
|
27
|
-
|
|
28
|
-
Get Options:
|
|
29
|
-
--show-source Print the full script source
|
|
30
|
-
|
|
31
|
-
Run Options:
|
|
32
|
-
--args '<json>' Inline JSON passed to the workflow's args global
|
|
33
|
-
--args-file <path> Read the JSON args from a file
|
|
34
|
-
--wait Poll the run until it finishes, then print the result
|
|
35
|
-
|
|
36
|
-
Share Options:
|
|
37
|
-
--add-user <userId> Grant a user access (use with --role)
|
|
38
|
-
--remove-user <userId> Revoke a user's access
|
|
39
|
-
--role owner|editor|viewer Role for --add-user (default: viewer)
|
|
40
|
-
|
|
41
|
-
Flags:
|
|
42
|
-
--json Output JSON
|
|
43
|
-
|
|
44
|
-
Examples:
|
|
45
|
-
entrydesk workflow list --search report
|
|
46
|
-
entrydesk workflow create --name "Nightly report" --file ./report.js
|
|
47
|
-
entrydesk workflow run <workflowId> --args '{"date":"2026-06-20"}' --wait
|
|
48
|
-
entrydesk workflow runs <workflowId>
|
|
49
|
-
entrydesk workflow run-get <workflowId> <runId>
|
|
50
|
-
entrydesk workflow share <workflowId> --add-user <userId> --role editor
|
|
51
|
-
`)}function a(o){if(!o)return"";let e=new Date(o);return Number.isNaN(e.getTime())?o:e.toLocaleString()}function h(o){let e;try{e=I(o,"utf8")}catch{console.error(`Cannot read script file: ${o}`),process.exit(1)}return e.trim().length===0&&(console.error(`Script file is empty: ${o}`),process.exit(1)),Buffer.byteLength(e,"utf8")>m&&(console.error(`Script file exceeds ${m} bytes.`),process.exit(1)),e}function A(o){o.args!==void 0&&o.argsFile!==void 0&&(console.error("Use only one of --args or --args-file."),process.exit(1));let e;if(o.argsFile===void 0)e=o.args;else try{e=I(o.argsFile,"utf8")}catch{console.error(`Cannot read args file: ${o.argsFile}`),process.exit(1)}if(e!==void 0)try{return JSON.parse(e)}catch{console.error("--args/--args-file must be valid JSON."),process.exit(1)}}function y(o){console.log(`Workflows (${o.length}):
|
|
52
|
-
`);for(let e of o){let n=e.isActive?"active":"inactive";if(console.log(` ${e.name} (${n})`),e.description){let t=e.description.length>80?`${e.description.slice(0,80)}...`:e.description;console.log(` ${t}`)}console.log(` ${e.myRole??"no-role"} \xB7 ID: ${e.id}`),console.log("")}}function v(o,e){console.log(`${o.name}
|
|
53
|
-
`),console.log(` ID: ${o.id}`),console.log(` Active: ${o.isActive}`),console.log(` My role: ${o.myRole??"no-role"}`),o.description&&console.log(` Description: ${o.description}`),console.log(` Updated: ${a(o.updatedAt)}`);let n=o.scriptSource.split(`
|
|
54
|
-
`).length;e?(console.log(`
|
|
55
|
-
Script (${n} lines):
|
|
56
|
-
`),console.log(o.scriptSource)):console.log(` Script: ${n} lines (use --show-source to print)`)}function S(o){console.log(`Runs (${o.length}):
|
|
57
|
-
`);for(let e of o){let n=a(e.startedAt??e.createdAt);console.log(` ${e.status}${n?` \xB7 ${n}`:""}`),console.log(` ID: ${e.id}`)}}function $(o){console.log(`Run ${o.id}`),console.log(` Workflow: ${o.workflowId}`),console.log(` Status: ${o.status}`),o.startedAt&&console.log(` Started: ${a(o.startedAt)}`),o.completedAt&&console.log(` Completed: ${a(o.completedAt)}`),o.error!=null&&console.log(` Error: ${JSON.stringify(o.error)}`);let e=Object.entries(o.context?.nodes??{});if(e.length>0){console.log(`
|
|
58
|
-
Nodes (${e.length}):`);for(let[t,i]of e){let r=[i.kind??"node",i.status];i.durationMs!=null&&r.push(`${i.durationMs}ms`),console.log(` - ${i.label??t} [${r.join(" \xB7 ")}]`)}}let n=o.context?.logs??[];if(n.length>0){console.log(`
|
|
59
|
-
Logs:`);for(let t of n)console.log(` ${t}`)}o.context?.spent!=null&&console.log(`
|
|
60
|
-
Tokens spent: ${o.context.spent}`)}function W(o){let e=u(o);if(console.log(`User grants (${e.length}):`),e.length===0){console.log(" (none)");return}for(let n of e)console.log(` - ${n.user.name} <${n.user.email}> \xB7 ${n.role}`),console.log(` ID: ${n.userId}`)}async function N(o,e,n,t,i){for(let s=0;s<600;s++){let l=await o.getWorkflowRun(e,n,t,i);if(R.has(l.status))return s>0&&process.stderr.write(`
|
|
61
|
-
`),l;let c=s*2;process.stderr.write(`\rWaiting\u2026 ${l.status} (${c}s)`),await new Promise(d=>setTimeout(d,2e3))}throw process.stderr.write(`
|
|
62
|
-
`),new Error(`Run ${i} did not finish within the wait window.`)}async function x(o){let n=[],t;for(let i=0;;i++){i>=100&&(console.error("Reached maximum page limit (100). Use --limit and --next-key for manual pagination."),process.exit(1));let r=await o(t);if(n.push(...r.items),t=r.nextKey,!t)break}return n}async function O(o,e,n,t){if(t.all&&t.nextKey&&(console.error("Cannot use --all and --next-key together."),process.exit(1)),t.all){let s=await x(async l=>{let c=await o.getWorkflows(e,n,{limit:t.limit??20,nextKey:l,search:t.search});return{items:c.workflows,nextKey:c.nextKey}});if(t.json){console.log(JSON.stringify({workflows:s}));return}if(s.length===0){console.log("No workflows found in this workspace.");return}y(s);return}let{workflows:i,nextKey:r}=await o.getWorkflows(e,n,{limit:t.limit,nextKey:t.nextKey,search:t.search});if(t.json){console.log(JSON.stringify({workflows:i,nextKey:r}));return}if(i.length===0){console.log("No workflows found in this workspace.");return}y(i),r&&console.log(`Next page: --next-key ${r}`)}async function j(o,e,n,t){if(!t.workflowId)throw new Error("Missing workflowId for share command");let i=t.workflowId,r=t.role??"viewer";if(t.addUser){let l=await o.upsertWorkflowGrant(e,n,i,t.addUser,r);if(t.json){console.log(JSON.stringify(l));return}console.log(`Granted ${r} to user ${t.addUser}`);return}if(t.removeUser){if(await o.removeWorkflowGrant(e,n,i,t.removeUser),t.json){console.log(JSON.stringify({userId:t.removeUser,removed:!0}));return}console.log(`Revoked access for user ${t.removeUser}`);return}let s=await o.getWorkflowGrants(e,n,i);if(t.json){console.log(JSON.stringify(s));return}W(s)}async function C(o){try{if(o.help){f();return}let{accessToken:e,workspaceId:n}=await g(),t=o.action||"list",i=new p;if(t==="list"){await O(i,e,n,o);return}if(t==="get"){if(!o.workflowId)throw new Error("Missing workflowId for get command");let r=await i.getWorkflow(e,n,o.workflowId);if(o.json){console.log(JSON.stringify(r));return}v(r,!!o.showSource);return}if(t==="create"){(!o.name||!o.file)&&(console.error("create requires --name and --file <path.js>."),f(),process.exit(1));let r=h(o.file),s=await i.createWorkflow(e,n,{name:o.name,description:o.description,scriptSource:r});if(o.json){console.log(JSON.stringify(s));return}console.log(`Created workflow: ${s.name}`),console.log(` ID: ${s.id}`);return}if(t==="update"){if(!o.workflowId)throw new Error("Missing workflowId for update command");o.activate&&o.deactivate&&(console.error("Cannot use --activate and --deactivate together."),process.exit(1));let r={};if(o.name!==void 0&&(r.name=o.name),o.description!==void 0&&(r.description=o.description),o.file!==void 0&&(r.scriptSource=h(o.file)),o.activate&&(r.isActive=!0),o.deactivate&&(r.isActive=!1),Object.keys(r).length===0&&(console.error("No fields provided to update."),f(),process.exit(1)),await i.updateWorkflow(e,n,o.workflowId,r),o.json){console.log(JSON.stringify({id:o.workflowId,updated:!0}));return}console.log(`Updated workflow: ${o.workflowId}`);return}if(t==="run"){if(!o.workflowId)throw new Error("Missing workflowId for run command");let r=A(o),{runId:s}=await i.triggerWorkflowRun(e,n,o.workflowId,r);if(!o.wait){if(o.json){console.log(JSON.stringify({runId:s}));return}console.log(`Started run: ${s}`),console.log(` Check: entrydesk workflow run-get ${o.workflowId} ${s}`);return}let l=await N(i,e,n,o.workflowId,s);o.json?console.log(JSON.stringify(l)):$(l),l.status!=="completed"&&process.exit(1);return}if(t==="runs"){if(!o.workflowId)throw new Error("Missing workflowId for runs command");if(o.all&&o.nextKey&&(console.error("Cannot use --all and --next-key together."),process.exit(1)),o.all){let l=o.workflowId,c=await x(async d=>{let w=await i.getWorkflowRuns(e,n,l,{limit:o.limit??20,nextKey:d});return{items:w.runs,nextKey:w.nextKey}});if(o.json){console.log(JSON.stringify({runs:c}));return}if(c.length===0){console.log("No runs for this workflow.");return}S(c);return}let{runs:r,nextKey:s}=await i.getWorkflowRuns(e,n,o.workflowId,{limit:o.limit,nextKey:o.nextKey});if(o.json){console.log(JSON.stringify({runs:r,nextKey:s}));return}if(r.length===0){console.log("No runs for this workflow.");return}S(r),s&&console.log(`Next page: --next-key ${s}`);return}if(t==="run-get"){if(!o.workflowId||!o.runId)throw new Error("Missing workflowId or runId for run-get command");let r=await i.getWorkflowRun(e,n,o.workflowId,o.runId);if(o.json){console.log(JSON.stringify(r));return}$(r);return}if(t==="share"){await j(i,e,n,o);return}console.error(`Unknown workflow command: ${t}`),f(),process.exit(1)}catch(e){k(e)}}export{C as runWorkflow};
|