lindoai-cli 1.4.6 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</script>`;});var At="LINDO_API_KEY",Et="LINDO_BASE_URL",Lt=".lindo",jt="config.json",Rt="https://api.lindo.ai";function Ze(){return A__namespace.join(je__namespace.homedir(),Lt)}function K(){return A__namespace.join(Ze(),jt)}function xe(){let o=K();try{if(O__namespace.existsSync(o)){let t=O__namespace.readFileSync(o,"utf-8");return JSON.parse(t)}}catch{}return {}}function et(o){let t=Ze(),i=K();O__namespace.existsSync(t)||O__namespace.mkdirSync(t,{recursive:true}),O__namespace.writeFileSync(i,JSON.stringify(o,null,2),"utf-8");}function F(){let o=xe(),t=process.env[At]||o.apiKey,i=process.env[Et]||o.baseUrl||Rt;return {apiKey:t,baseUrl:i}}function tt(o){let t=xe();t.apiKey=o,et(t);}function ot(o,t){let i=xe();switch(o){case "apiKey":i.apiKey=t;break;case "baseUrl":i.baseUrl=t;break;default:throw new Error(`Unknown configuration key: ${o}`)}et(i);}function it(o){let t=F();switch(o){case "apiKey":return t.apiKey;case "baseUrl":return t.baseUrl;default:return}}function T(){return !!F().apiKey}var G={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Dt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function J(o,t){return Dt()?`${t}${o}${G.reset}`:o}function h(o){console.log(J(`\u2713 ${o}`,G.green));}function c(o){console.error(J(`\u2717 ${o}`,G.red));}function s(o){console.log(J(`\u2139 ${o}`,G.blue));}function Nt(o){return JSON.stringify(o,null,2)}function Ut(o){if(o==null)return "";if(Array.isArray(o)){if(o.length===0)return "No data";let t=new Set;for(let e of o)typeof e=="object"&&e!==null&&Object.keys(e).forEach(n=>t.add(n));if(t.size===0)return o.map(e=>String(e)).join(`
|
|
33
33
|
`);let i=Array.from(t);return Mt(i,o)}if(typeof o=="object"){let i=Object.entries(o);if(i.length===0)return "No data";let e=Math.max(...i.map(([n])=>n.length));return i.map(([n,r])=>{let l=n.padEnd(e),a=ve(r);return `${J(l,G.cyan)} ${a}`}).join(`
|
|
34
34
|
`)}return String(o)}function Mt(o,t){let i={};for(let l of o)i[l]=l.length;for(let l of t)if(typeof l=="object"&&l!==null){let a=l;for(let d of o){let p=ve(a[d]);i[d]=Math.max(i[d],p.length);}}let e=o.map(l=>J(l.padEnd(i[l]),G.bold)).join(" "),n=o.map(l=>"-".repeat(i[l])).join(" "),r=t.map(l=>{if(typeof l=="object"&&l!==null){let a=l;return o.map(d=>ve(a[d]).padEnd(i[d])).join(" ")}return String(l)});return [e,n,...r].join(`
|
|
35
|
-
`)}function ve(o){return o==null?J("-",G.gray):typeof o=="boolean"?o?J("true",G.green):J("false",G.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function g(o,t){console.log(t==="json"?Nt(o):Ut(o));}var nt=["apiKey","baseUrl"];function Ce(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,i)=>{nt.includes(t)||(c(`Invalid configuration key: ${t}`),s(`Valid keys: ${nt.join(", ")}`),process.exit(1));try{ot(t,i),h(`Configuration saved: ${t}`),s(`Config file: ${K()}`);}catch(e){c(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,i)=>{let e=it(t);if(e===void 0){i.format==="json"?g({key:t,value:null},i.format):s(`Configuration key '${t}' is not set`);return}if(i.format==="json")g({key:t,value:e},i.format);else {let n=t==="apiKey"?ke(e):e;console.log(`${t}: ${n}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let i=F(),e={apiKey:i.apiKey?ke(i.apiKey):"(not set)",baseUrl:i.baseUrl,configFile:K()};t.format==="json"?g({apiKey:i.apiKey?ke(i.apiKey):null,baseUrl:i.baseUrl,configFile:K()},t.format):g(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(K());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new commander.Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,i)=>{T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=F(),n=new lindoai.LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(i.input);}catch{c("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let l=await n.agents.run({agent_id:t,input:r,stream:i.stream});l.success?(h("Agent run completed"),g(l,i.format)):(c(`Agent run failed: ${l.error||"Unknown error"}`),g(l,i.format),process.exit(1));}catch(l){Kt(l);}}),o}function Kt(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Se(){let o=new commander.Command("workflows").description("Manage workflows");o.command("list").description("List workflow logs").option("-n, --name <name>","Filter by workflow name").option("-s, --status <status>","Filter by status").option("-w, --website <id>","Filter by website ID").option("-c, --client <id>","Filter by client ID").option("-l, --limit <number>","Maximum number of results","50").option("-f, --format <format>","Output format (json, table)","table").action(async i=>{let e=P();try{let n=await e.workflows.list({workflow_name:i.name,status:i.status,website_id:i.website,client_id:i.client,limit:parseInt(i.limit)});n.success?g(n.data,i.format):(c("Failed to list workflows"),process.exit(1));}catch(n){I(n);}}),o.command("start <workflow-name>").description("Start a workflow").option("-p, --params <json>","Workflow parameters as JSON string","{}").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=JSON.parse(e.params);}catch{c("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${i}`);let l=await n.workflows.start({workflow_name:i,params:r});l.success?(h(`Workflow started: ${l.instance_id}`),g(l,e.format)):(c("Failed to start workflow"),g(l,e.format),process.exit(1));}catch(l){I(l);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getStatus(i);g(r,e.format);}catch(r){I(r);}}),o.command("status-website <record-id>").description("Check the status of a website-creation workflow (started via create-website)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getWebsiteStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-page <record-id>").description("Check the status of a page-creation workflow (started via create-page)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getPageStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-blog <record-id>").description("Check the status of a blog-creation workflow (started via create-blog)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getBlogStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Pausing workflow: ${i}`);let r=await n.workflows.pause(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Resuming workflow: ${i}`);let r=await n.workflows.resume(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Terminating workflow: ${i}`);let r=await n.workflows.terminate(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}});function t(i){let e;try{let r=Tt("fs");r.existsSync(i)?e=r.readFileSync(i,"utf8"):e=i;}catch{e=i;}let n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Items must be a JSON array");return n}return o.command("batch-create-websites <items>").description("Create up to 25 websites at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=t(i);}catch(l){c(`Invalid items JSON: ${l.message}`),s(`Example: --items '[{"prompt":"..."},{"prompt":"..."}]'`),process.exit(1);}try{s(`Starting batch of ${r.length} websites\u2026`);let l=await n.workflows.batchCreateWebsites(r);h(`Batch accepted: ${l.succeeded} succeeded, ${l.failed} failed of ${l.total}.`),g(l,e.format);}catch(l){I(l);}}),o.command("batch-create-pages <website-id> <items>").description("Create up to 25 pages on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} pages on ${i}\u2026`);let a=await r.workflows.batchCreatePages(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-create-blogs <website-id> <items>").description("Create up to 25 blog posts on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} blog posts on ${i}\u2026`);let a=await r.workflows.batchCreateBlogs(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-status-websites <record-ids...>").description("Check the status of up to 25 website workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckWebsiteStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-pages <record-ids...>").description("Check the status of up to 25 page workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckPageStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-blogs <record-ids...>").description("Check the status of up to 25 blog workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckBlogStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o}function P(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new commander.Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.get();g(e,t.format);}catch(e){M(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getCredits();g(e,t.format);}catch(e){M(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getClientCredits(t.client);g(e,t.format);}catch(e){M(e);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&h("Workspace updated"),g(e,t.format);}catch(e){M(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.addTeamMember(t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){M(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeTeamMember(t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){M(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.workspace.addIntegration({integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){M(n);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeIntegration(t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){M(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&h("Whitelabel settings updated"),g(e,t.format);}catch(e){M(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&h("Appearance settings updated"),g(e,t.format);}catch(e){M(e);}}),o}function U(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function M(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function $e(){let o=new commander.Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWorkspace({from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o}function rt(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new commander.Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
|
|
35
|
+
`)}function ve(o){return o==null?J("-",G.gray):typeof o=="boolean"?o?J("true",G.green):J("false",G.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function g(o,t){console.log(t==="json"?Nt(o):Ut(o));}var nt=["apiKey","baseUrl"];function Ce(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,i)=>{nt.includes(t)||(c(`Invalid configuration key: ${t}`),s(`Valid keys: ${nt.join(", ")}`),process.exit(1));try{ot(t,i),h(`Configuration saved: ${t}`),s(`Config file: ${K()}`);}catch(e){c(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,i)=>{let e=it(t);if(e===void 0){i.format==="json"?g({key:t,value:null},i.format):s(`Configuration key '${t}' is not set`);return}if(i.format==="json")g({key:t,value:e},i.format);else {let n=t==="apiKey"?ke(e):e;console.log(`${t}: ${n}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let i=F(),e={apiKey:i.apiKey?ke(i.apiKey):"(not set)",baseUrl:i.baseUrl,configFile:K()};t.format==="json"?g({apiKey:i.apiKey?ke(i.apiKey):null,baseUrl:i.baseUrl,configFile:K()},t.format):g(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(K());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new commander.Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,i)=>{T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=F(),n=new lindoai.LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(i.input);}catch{c("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let l=await n.agents.run({agent_id:t,input:r,stream:i.stream});l.success?(h("Agent run completed"),g(l,i.format)):(c(`Agent run failed: ${l.error||"Unknown error"}`),g(l,i.format),process.exit(1));}catch(l){Kt(l);}}),o}function Kt(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Se(){let o=new commander.Command("workflows").description("Manage workflows");o.command("list").description("List workflow logs").option("-n, --name <name>","Filter by workflow name").option("-s, --status <status>","Filter by status").option("-w, --website <id>","Filter by website ID").option("-c, --client <id>","Filter by client ID").option("-l, --limit <number>","Maximum number of results","50").option("-f, --format <format>","Output format (json, table)","table").action(async i=>{let e=P();try{let n=await e.workflows.list({workflow_name:i.name,status:i.status,website_id:i.website,client_id:i.client,limit:parseInt(i.limit)});n.success?g(n.data,i.format):(c("Failed to list workflows"),process.exit(1));}catch(n){I(n);}}),o.command("start <workflow-name>").description("Start a workflow").option("-p, --params <json>","Workflow parameters as JSON string","{}").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=JSON.parse(e.params);}catch{c("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${i}`);let l=await n.workflows.start({workflow_name:i,params:r});l.success?(h(`Workflow started: ${l.instance_id}`),g(l,e.format)):(c("Failed to start workflow"),g(l,e.format),process.exit(1));}catch(l){I(l);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getStatus(i);g(r,e.format);}catch(r){I(r);}}),o.command("status-website <workflow-id>").description("Check the status of a website-creation workflow (started via create-website)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getWebsiteStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-page <workflow-id>").description("Check the status of a page-creation workflow (started via create-page)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getPageStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-blog <workflow-id>").description("Check the status of a blog-creation workflow (started via create-blog)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getBlogStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Pausing workflow: ${i}`);let r=await n.workflows.pause(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Resuming workflow: ${i}`);let r=await n.workflows.resume(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Terminating workflow: ${i}`);let r=await n.workflows.terminate(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}});function t(i){let e;try{let r=Tt("fs");r.existsSync(i)?e=r.readFileSync(i,"utf8"):e=i;}catch{e=i;}let n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Items must be a JSON array");return n}return o.command("batch-create-websites <items>").description("Create up to 25 websites at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=t(i);}catch(l){c(`Invalid items JSON: ${l.message}`),s(`Example: --items '[{"prompt":"..."},{"prompt":"..."}]'`),process.exit(1);}try{s(`Starting batch of ${r.length} websites\u2026`);let l=await n.workflows.batchCreateWebsites(r);h(`Batch accepted: ${l.succeeded} succeeded, ${l.failed} failed of ${l.total}.`),g(l,e.format);}catch(l){I(l);}}),o.command("batch-create-pages <website-id> <items>").description("Create up to 25 pages on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} pages on ${i}\u2026`);let a=await r.workflows.batchCreatePages(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-create-blogs <website-id> <items>").description("Create up to 25 blog posts on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} blog posts on ${i}\u2026`);let a=await r.workflows.batchCreateBlogs(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-status-websites <workflow-ids...>").description("Check the status of up to 25 website workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckWebsiteStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-pages <workflow-ids...>").description("Check the status of up to 25 page workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckPageStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-blogs <workflow-ids...>").description("Check the status of up to 25 blog workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckBlogStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o}function P(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new commander.Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.get();g(e,t.format);}catch(e){M(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getCredits();g(e,t.format);}catch(e){M(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getClientCredits(t.client);g(e,t.format);}catch(e){M(e);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&h("Workspace updated"),g(e,t.format);}catch(e){M(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.addTeamMember(t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){M(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeTeamMember(t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){M(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.workspace.addIntegration({integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){M(n);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeIntegration(t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){M(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&h("Whitelabel settings updated"),g(e,t.format);}catch(e){M(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&h("Appearance settings updated"),g(e,t.format);}catch(e){M(e);}}),o}function U(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function M(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function $e(){let o=new commander.Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWorkspace({from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o}function rt(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new commander.Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
|
|
36
36
|
Clients:`),console.log("--------");for(let n of e.clients)console.log(` ID: ${n.record_id}`),console.log(` Email: ${n.email}`),console.log(` Website Limit: ${n.website_limit??"N/A"}`),console.log(` Suspended: ${n.suspended??!1}`),console.log("");console.log(`Total: ${e.total??e.clients.length}`);}else s("No clients found");}catch(e){ce(e);}}),o.command("create").description("Create a new workspace client").requiredOption("-e, --email <email>","Client email address").option("-l, --limit <limit>","Website limit","5").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.create({email:t.email,website_limit:parseInt(t.limit,10)});if(e.success&&e.client)h(`Client created: ${e.client.record_id}`),g(e.client,t.format);else if(c("Failed to create client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("update").description("Update a workspace client").requiredOption("-i, --id <id>","Client ID").option("-l, --limit <limit>","Website limit").option("--suspend","Suspend the client").option("--unsuspend","Unsuspend the client").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.update({client_id:t.id,website_limit:t.limit?parseInt(t.limit,10):void 0,suspended:t.suspend?!0:t.unsuspend?!1:void 0});if(e.success)h("Client updated"),e.client&&g(e.client,t.format);else if(c("Failed to update client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async t=>{let i=le();try{let e=await i.clients.delete(t.id);if(e.success)h("Client deleted");else if(c("Failed to delete client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("magic-link").description("Create a magic link for client authentication").requiredOption("-e, --email <email>","Client email address").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.createMagicLink(t.email);if(e.success)h("Magic link created"),g(e,t.format);else if(c("Failed to create magic link"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o}function le(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function ce(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Te(){let o=new commander.Command("websites").description("Website management operations");return o.command("list").description("List all workspace websites").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else {let n=e.result?.list??[];if(n.length>0){console.log(`
|
|
37
37
|
Websites:`),console.log("---------");for(let r of n)console.log(` ID: ${r.website_id}`),console.log(` Name: ${r.website_name??"N/A"}`),console.log(` Domain: ${r.domain??"N/A"}`),console.log(` Activated: ${r.activated??!1}`),console.log("");console.log(`Total: ${e.result?.total??n.length}`);}else s("No websites found");}}catch(e){L(e);}}),o.command("get").description("Get website details").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.getDetails(t.id);g(e,t.format);}catch(e){L(e);}}),o.command("update").description("Update a website").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("--activate","Activate the website").option("--deactivate","Deactivate the website").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.update({website_id:t.id,business_name:t.name,activated:t.activate?!0:t.deactivate?!1:void 0});if(e.success)h("Website updated"),e.website&&g(e.website,t.format);else if(c("Failed to update website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("settings").description("Update website settings").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("-l, --language <lang>","Language").option("-d, --description <desc>","Business description").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.updateSettings(t.id,{business_name:t.name,language:t.language,business_description:t.description});e.success&&h("Website settings updated"),g(e,t.format);}catch(e){L(e);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async t=>{let i=E();try{let e=await i.websites.delete(t.id);if(e.success)h("Website deleted");else if(c("Failed to delete website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("assign").description("Assign a website to a client").requiredOption("-w, --website <id>","Website ID").requiredOption("-c, --client <id>","Client ID").action(async t=>{let i=E();try{let e=await i.websites.assign({website_id:t.website,client_id:t.client});if(e.success)h("Website assigned to client");else if(c("Failed to assign website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("domain-add").description("Add a custom domain to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-d, --domain <domain>","Custom domain").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.addDomain(t.id,t.domain);if(e.success&&(h("Domain added"),e.result?.dns_records)){console.log(`
|
|
38
38
|
DNS Records to configure:`);for(let n of e.result.dns_records)console.log(` ${n.record_type} ${n.host} -> ${n.value}`);}g(e,t.format);}catch(e){L(e);}}),o.command("domain-remove").description("Remove a custom domain from a website").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeDomain(t.id);e.success&&h("Domain removed"),g(e,t.format);}catch(e){L(e);}}),o.command("integration-add").description("Add an integration to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.websites.addIntegration(t.id,{integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){L(n);}}),o.command("integration-remove").description("Remove an integration from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeIntegration(t.id,t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){L(e);}}),o.command("team-add").description("Add a team member to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-e, --email <email>","Team member email").requiredOption("-r, --role <role>","Role (Editor or Commenter)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.addTeamMember(t.id,t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){L(e);}}),o.command("team-remove").description("Remove a team member from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-m, --member <memberId>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeTeamMember(t.id,t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){L(e);}}),o}function E(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function L(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Y(o){return new Promise(t=>{let i=je.platform(),e;switch(i){case "darwin":e=`open "${o}"`;break;case "win32":e=`start "" "${o}"`;break;default:e=`xdg-open "${o}"`;break}child_process.exec(e,n=>{t(!n);});})}function co(o){let t=o.filter(e=>!!(e&&e.trim()));return t.length===0?"":`https://fonts.googleapis.com/css2?family=${t.map(e=>`${e.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function de(o){let t=[o.font,o.title_font].filter(Boolean);if(t.length===0)return "";let i=co(t);if(!i)return "";let e=o.font||o.title_font,n=o.title_font||o.font,r=`
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import*as lt from'http';import*as O from'fs';import*as A from'path';import*as je
|
|
|
32
32
|
</script>`;});var At="LINDO_API_KEY",Et="LINDO_BASE_URL",Lt=".lindo",jt="config.json",Rt="https://api.lindo.ai";function Ze(){return A.join(je.homedir(),Lt)}function K(){return A.join(Ze(),jt)}function xe(){let o=K();try{if(O.existsSync(o)){let t=O.readFileSync(o,"utf-8");return JSON.parse(t)}}catch{}return {}}function et(o){let t=Ze(),i=K();O.existsSync(t)||O.mkdirSync(t,{recursive:true}),O.writeFileSync(i,JSON.stringify(o,null,2),"utf-8");}function F(){let o=xe(),t=process.env[At]||o.apiKey,i=process.env[Et]||o.baseUrl||Rt;return {apiKey:t,baseUrl:i}}function tt(o){let t=xe();t.apiKey=o,et(t);}function ot(o,t){let i=xe();switch(o){case "apiKey":i.apiKey=t;break;case "baseUrl":i.baseUrl=t;break;default:throw new Error(`Unknown configuration key: ${o}`)}et(i);}function it(o){let t=F();switch(o){case "apiKey":return t.apiKey;case "baseUrl":return t.baseUrl;default:return}}function T(){return !!F().apiKey}var G={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Dt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function J(o,t){return Dt()?`${t}${o}${G.reset}`:o}function h(o){console.log(J(`\u2713 ${o}`,G.green));}function c(o){console.error(J(`\u2717 ${o}`,G.red));}function s(o){console.log(J(`\u2139 ${o}`,G.blue));}function Nt(o){return JSON.stringify(o,null,2)}function Ut(o){if(o==null)return "";if(Array.isArray(o)){if(o.length===0)return "No data";let t=new Set;for(let e of o)typeof e=="object"&&e!==null&&Object.keys(e).forEach(n=>t.add(n));if(t.size===0)return o.map(e=>String(e)).join(`
|
|
33
33
|
`);let i=Array.from(t);return Mt(i,o)}if(typeof o=="object"){let i=Object.entries(o);if(i.length===0)return "No data";let e=Math.max(...i.map(([n])=>n.length));return i.map(([n,r])=>{let l=n.padEnd(e),a=ve(r);return `${J(l,G.cyan)} ${a}`}).join(`
|
|
34
34
|
`)}return String(o)}function Mt(o,t){let i={};for(let l of o)i[l]=l.length;for(let l of t)if(typeof l=="object"&&l!==null){let a=l;for(let d of o){let p=ve(a[d]);i[d]=Math.max(i[d],p.length);}}let e=o.map(l=>J(l.padEnd(i[l]),G.bold)).join(" "),n=o.map(l=>"-".repeat(i[l])).join(" "),r=t.map(l=>{if(typeof l=="object"&&l!==null){let a=l;return o.map(d=>ve(a[d]).padEnd(i[d])).join(" ")}return String(l)});return [e,n,...r].join(`
|
|
35
|
-
`)}function ve(o){return o==null?J("-",G.gray):typeof o=="boolean"?o?J("true",G.green):J("false",G.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function g(o,t){console.log(t==="json"?Nt(o):Ut(o));}var nt=["apiKey","baseUrl"];function Ce(){let o=new Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,i)=>{nt.includes(t)||(c(`Invalid configuration key: ${t}`),s(`Valid keys: ${nt.join(", ")}`),process.exit(1));try{ot(t,i),h(`Configuration saved: ${t}`),s(`Config file: ${K()}`);}catch(e){c(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,i)=>{let e=it(t);if(e===void 0){i.format==="json"?g({key:t,value:null},i.format):s(`Configuration key '${t}' is not set`);return}if(i.format==="json")g({key:t,value:e},i.format);else {let n=t==="apiKey"?ke(e):e;console.log(`${t}: ${n}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let i=F(),e={apiKey:i.apiKey?ke(i.apiKey):"(not set)",baseUrl:i.baseUrl,configFile:K()};t.format==="json"?g({apiKey:i.apiKey?ke(i.apiKey):null,baseUrl:i.baseUrl,configFile:K()},t.format):g(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(K());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,i)=>{T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=F(),n=new LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(i.input);}catch{c("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let l=await n.agents.run({agent_id:t,input:r,stream:i.stream});l.success?(h("Agent run completed"),g(l,i.format)):(c(`Agent run failed: ${l.error||"Unknown error"}`),g(l,i.format),process.exit(1));}catch(l){Kt(l);}}),o}function Kt(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Se(){let o=new Command("workflows").description("Manage workflows");o.command("list").description("List workflow logs").option("-n, --name <name>","Filter by workflow name").option("-s, --status <status>","Filter by status").option("-w, --website <id>","Filter by website ID").option("-c, --client <id>","Filter by client ID").option("-l, --limit <number>","Maximum number of results","50").option("-f, --format <format>","Output format (json, table)","table").action(async i=>{let e=P();try{let n=await e.workflows.list({workflow_name:i.name,status:i.status,website_id:i.website,client_id:i.client,limit:parseInt(i.limit)});n.success?g(n.data,i.format):(c("Failed to list workflows"),process.exit(1));}catch(n){I(n);}}),o.command("start <workflow-name>").description("Start a workflow").option("-p, --params <json>","Workflow parameters as JSON string","{}").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=JSON.parse(e.params);}catch{c("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${i}`);let l=await n.workflows.start({workflow_name:i,params:r});l.success?(h(`Workflow started: ${l.instance_id}`),g(l,e.format)):(c("Failed to start workflow"),g(l,e.format),process.exit(1));}catch(l){I(l);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getStatus(i);g(r,e.format);}catch(r){I(r);}}),o.command("status-website <record-id>").description("Check the status of a website-creation workflow (started via create-website)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getWebsiteStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-page <record-id>").description("Check the status of a page-creation workflow (started via create-page)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getPageStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-blog <record-id>").description("Check the status of a blog-creation workflow (started via create-blog)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getBlogStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Pausing workflow: ${i}`);let r=await n.workflows.pause(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Resuming workflow: ${i}`);let r=await n.workflows.resume(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Terminating workflow: ${i}`);let r=await n.workflows.terminate(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}});function t(i){let e;try{let r=Tt("fs");r.existsSync(i)?e=r.readFileSync(i,"utf8"):e=i;}catch{e=i;}let n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Items must be a JSON array");return n}return o.command("batch-create-websites <items>").description("Create up to 25 websites at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=t(i);}catch(l){c(`Invalid items JSON: ${l.message}`),s(`Example: --items '[{"prompt":"..."},{"prompt":"..."}]'`),process.exit(1);}try{s(`Starting batch of ${r.length} websites\u2026`);let l=await n.workflows.batchCreateWebsites(r);h(`Batch accepted: ${l.succeeded} succeeded, ${l.failed} failed of ${l.total}.`),g(l,e.format);}catch(l){I(l);}}),o.command("batch-create-pages <website-id> <items>").description("Create up to 25 pages on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} pages on ${i}\u2026`);let a=await r.workflows.batchCreatePages(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-create-blogs <website-id> <items>").description("Create up to 25 blog posts on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} blog posts on ${i}\u2026`);let a=await r.workflows.batchCreateBlogs(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-status-websites <record-ids...>").description("Check the status of up to 25 website workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckWebsiteStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-pages <record-ids...>").description("Check the status of up to 25 page workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckPageStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-blogs <record-ids...>").description("Check the status of up to 25 blog workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckBlogStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o}function P(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.get();g(e,t.format);}catch(e){M(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getCredits();g(e,t.format);}catch(e){M(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getClientCredits(t.client);g(e,t.format);}catch(e){M(e);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&h("Workspace updated"),g(e,t.format);}catch(e){M(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.addTeamMember(t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){M(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeTeamMember(t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){M(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.workspace.addIntegration({integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){M(n);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeIntegration(t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){M(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&h("Whitelabel settings updated"),g(e,t.format);}catch(e){M(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&h("Appearance settings updated"),g(e,t.format);}catch(e){M(e);}}),o}function U(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function M(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function $e(){let o=new Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWorkspace({from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o}function rt(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
|
|
35
|
+
`)}function ve(o){return o==null?J("-",G.gray):typeof o=="boolean"?o?J("true",G.green):J("false",G.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function g(o,t){console.log(t==="json"?Nt(o):Ut(o));}var nt=["apiKey","baseUrl"];function Ce(){let o=new Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,i)=>{nt.includes(t)||(c(`Invalid configuration key: ${t}`),s(`Valid keys: ${nt.join(", ")}`),process.exit(1));try{ot(t,i),h(`Configuration saved: ${t}`),s(`Config file: ${K()}`);}catch(e){c(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,i)=>{let e=it(t);if(e===void 0){i.format==="json"?g({key:t,value:null},i.format):s(`Configuration key '${t}' is not set`);return}if(i.format==="json")g({key:t,value:e},i.format);else {let n=t==="apiKey"?ke(e):e;console.log(`${t}: ${n}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let i=F(),e={apiKey:i.apiKey?ke(i.apiKey):"(not set)",baseUrl:i.baseUrl,configFile:K()};t.format==="json"?g({apiKey:i.apiKey?ke(i.apiKey):null,baseUrl:i.baseUrl,configFile:K()},t.format):g(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(K());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,i)=>{T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=F(),n=new LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(i.input);}catch{c("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let l=await n.agents.run({agent_id:t,input:r,stream:i.stream});l.success?(h("Agent run completed"),g(l,i.format)):(c(`Agent run failed: ${l.error||"Unknown error"}`),g(l,i.format),process.exit(1));}catch(l){Kt(l);}}),o}function Kt(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Se(){let o=new Command("workflows").description("Manage workflows");o.command("list").description("List workflow logs").option("-n, --name <name>","Filter by workflow name").option("-s, --status <status>","Filter by status").option("-w, --website <id>","Filter by website ID").option("-c, --client <id>","Filter by client ID").option("-l, --limit <number>","Maximum number of results","50").option("-f, --format <format>","Output format (json, table)","table").action(async i=>{let e=P();try{let n=await e.workflows.list({workflow_name:i.name,status:i.status,website_id:i.website,client_id:i.client,limit:parseInt(i.limit)});n.success?g(n.data,i.format):(c("Failed to list workflows"),process.exit(1));}catch(n){I(n);}}),o.command("start <workflow-name>").description("Start a workflow").option("-p, --params <json>","Workflow parameters as JSON string","{}").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=JSON.parse(e.params);}catch{c("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${i}`);let l=await n.workflows.start({workflow_name:i,params:r});l.success?(h(`Workflow started: ${l.instance_id}`),g(l,e.format)):(c("Failed to start workflow"),g(l,e.format),process.exit(1));}catch(l){I(l);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getStatus(i);g(r,e.format);}catch(r){I(r);}}),o.command("status-website <workflow-id>").description("Check the status of a website-creation workflow (started via create-website)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getWebsiteStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-page <workflow-id>").description("Check the status of a page-creation workflow (started via create-page)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getPageStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-blog <workflow-id>").description("Check the status of a blog-creation workflow (started via create-blog)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getBlogStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Pausing workflow: ${i}`);let r=await n.workflows.pause(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Resuming workflow: ${i}`);let r=await n.workflows.resume(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Terminating workflow: ${i}`);let r=await n.workflows.terminate(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}});function t(i){let e;try{let r=Tt("fs");r.existsSync(i)?e=r.readFileSync(i,"utf8"):e=i;}catch{e=i;}let n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Items must be a JSON array");return n}return o.command("batch-create-websites <items>").description("Create up to 25 websites at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=t(i);}catch(l){c(`Invalid items JSON: ${l.message}`),s(`Example: --items '[{"prompt":"..."},{"prompt":"..."}]'`),process.exit(1);}try{s(`Starting batch of ${r.length} websites\u2026`);let l=await n.workflows.batchCreateWebsites(r);h(`Batch accepted: ${l.succeeded} succeeded, ${l.failed} failed of ${l.total}.`),g(l,e.format);}catch(l){I(l);}}),o.command("batch-create-pages <website-id> <items>").description("Create up to 25 pages on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} pages on ${i}\u2026`);let a=await r.workflows.batchCreatePages(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-create-blogs <website-id> <items>").description("Create up to 25 blog posts on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} blog posts on ${i}\u2026`);let a=await r.workflows.batchCreateBlogs(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-status-websites <workflow-ids...>").description("Check the status of up to 25 website workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckWebsiteStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-pages <workflow-ids...>").description("Check the status of up to 25 page workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckPageStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-blogs <workflow-ids...>").description("Check the status of up to 25 blog workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckBlogStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o}function P(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.get();g(e,t.format);}catch(e){M(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getCredits();g(e,t.format);}catch(e){M(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getClientCredits(t.client);g(e,t.format);}catch(e){M(e);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&h("Workspace updated"),g(e,t.format);}catch(e){M(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.addTeamMember(t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){M(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeTeamMember(t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){M(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.workspace.addIntegration({integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){M(n);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeIntegration(t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){M(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&h("Whitelabel settings updated"),g(e,t.format);}catch(e){M(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&h("Appearance settings updated"),g(e,t.format);}catch(e){M(e);}}),o}function U(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function M(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function $e(){let o=new Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWorkspace({from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o}function rt(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
|
|
36
36
|
Clients:`),console.log("--------");for(let n of e.clients)console.log(` ID: ${n.record_id}`),console.log(` Email: ${n.email}`),console.log(` Website Limit: ${n.website_limit??"N/A"}`),console.log(` Suspended: ${n.suspended??!1}`),console.log("");console.log(`Total: ${e.total??e.clients.length}`);}else s("No clients found");}catch(e){ce(e);}}),o.command("create").description("Create a new workspace client").requiredOption("-e, --email <email>","Client email address").option("-l, --limit <limit>","Website limit","5").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.create({email:t.email,website_limit:parseInt(t.limit,10)});if(e.success&&e.client)h(`Client created: ${e.client.record_id}`),g(e.client,t.format);else if(c("Failed to create client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("update").description("Update a workspace client").requiredOption("-i, --id <id>","Client ID").option("-l, --limit <limit>","Website limit").option("--suspend","Suspend the client").option("--unsuspend","Unsuspend the client").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.update({client_id:t.id,website_limit:t.limit?parseInt(t.limit,10):void 0,suspended:t.suspend?!0:t.unsuspend?!1:void 0});if(e.success)h("Client updated"),e.client&&g(e.client,t.format);else if(c("Failed to update client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async t=>{let i=le();try{let e=await i.clients.delete(t.id);if(e.success)h("Client deleted");else if(c("Failed to delete client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("magic-link").description("Create a magic link for client authentication").requiredOption("-e, --email <email>","Client email address").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.createMagicLink(t.email);if(e.success)h("Magic link created"),g(e,t.format);else if(c("Failed to create magic link"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o}function le(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function ce(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Te(){let o=new Command("websites").description("Website management operations");return o.command("list").description("List all workspace websites").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else {let n=e.result?.list??[];if(n.length>0){console.log(`
|
|
37
37
|
Websites:`),console.log("---------");for(let r of n)console.log(` ID: ${r.website_id}`),console.log(` Name: ${r.website_name??"N/A"}`),console.log(` Domain: ${r.domain??"N/A"}`),console.log(` Activated: ${r.activated??!1}`),console.log("");console.log(`Total: ${e.result?.total??n.length}`);}else s("No websites found");}}catch(e){L(e);}}),o.command("get").description("Get website details").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.getDetails(t.id);g(e,t.format);}catch(e){L(e);}}),o.command("update").description("Update a website").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("--activate","Activate the website").option("--deactivate","Deactivate the website").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.update({website_id:t.id,business_name:t.name,activated:t.activate?!0:t.deactivate?!1:void 0});if(e.success)h("Website updated"),e.website&&g(e.website,t.format);else if(c("Failed to update website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("settings").description("Update website settings").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("-l, --language <lang>","Language").option("-d, --description <desc>","Business description").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.updateSettings(t.id,{business_name:t.name,language:t.language,business_description:t.description});e.success&&h("Website settings updated"),g(e,t.format);}catch(e){L(e);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async t=>{let i=E();try{let e=await i.websites.delete(t.id);if(e.success)h("Website deleted");else if(c("Failed to delete website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("assign").description("Assign a website to a client").requiredOption("-w, --website <id>","Website ID").requiredOption("-c, --client <id>","Client ID").action(async t=>{let i=E();try{let e=await i.websites.assign({website_id:t.website,client_id:t.client});if(e.success)h("Website assigned to client");else if(c("Failed to assign website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("domain-add").description("Add a custom domain to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-d, --domain <domain>","Custom domain").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.addDomain(t.id,t.domain);if(e.success&&(h("Domain added"),e.result?.dns_records)){console.log(`
|
|
38
38
|
DNS Records to configure:`);for(let n of e.result.dns_records)console.log(` ${n.record_type} ${n.host} -> ${n.value}`);}g(e,t.format);}catch(e){L(e);}}),o.command("domain-remove").description("Remove a custom domain from a website").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeDomain(t.id);e.success&&h("Domain removed"),g(e,t.format);}catch(e){L(e);}}),o.command("integration-add").description("Add an integration to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.websites.addIntegration(t.id,{integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){L(n);}}),o.command("integration-remove").description("Remove an integration from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeIntegration(t.id,t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){L(e);}}),o.command("team-add").description("Add a team member to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-e, --email <email>","Team member email").requiredOption("-r, --role <role>","Role (Editor or Commenter)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.addTeamMember(t.id,t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){L(e);}}),o.command("team-remove").description("Remove a team member from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-m, --member <memberId>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeTeamMember(t.id,t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){L(e);}}),o}function E(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function L(o){o instanceof AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Y(o){return new Promise(t=>{let i=platform(),e;switch(i){case "darwin":e=`open "${o}"`;break;case "win32":e=`start "" "${o}"`;break;default:e=`xdg-open "${o}"`;break}exec(e,n=>{t(!n);});})}function co(o){let t=o.filter(e=>!!(e&&e.trim()));return t.length===0?"":`https://fonts.googleapis.com/css2?family=${t.map(e=>`${e.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function de(o){let t=[o.font,o.title_font].filter(Boolean);if(t.length===0)return "";let i=co(t);if(!i)return "";let e=o.font||o.title_font,n=o.title_font||o.font,r=`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lindoai-cli",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"description": "Command-line interface for the Lindo API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"cheerio": "^1.0.0",
|
|
54
54
|
"commander": "^12.0.0",
|
|
55
|
-
"lindoai": "^1.1.
|
|
55
|
+
"lindoai": "^1.1.5",
|
|
56
56
|
"marked": "^17.0.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|