cx-vcc
Version:
Cloudonix Agentic Voice Connector Tool
112 lines (96 loc) • 4.58 kB
JavaScript
const { program } = require('commander');
const pkg = require('../package.json');
const chalk = require('chalk');
require('dotenv').config();
// Import commands
const configureCommand = require('./commands/configure');
const deleteCommand = require('./commands/delete');
const serviceCommand = require('./commands/service');
const addNumberCommand = require('./commands/addnumber');
const displayCommand = require('./commands/display');
const syncCommand = require('./commands/sync');
// Import utilities
const { setDebugMode } = require('./utils/debug');
// ASCII Art Banner
const banner = `
.d8888b. 888 888 d8b
d88P Y88b 888 888 Y8P
888 888 888 888
888 888 .d88b. 888 888 .d88888 .d88b. 88888b. 888 888 888
888 888 d88""88b 888 888 d88" 888 d88""88b 888 "88b 888 \`Y8bd8P'
888 888 888 888 888 888 888 888 888 888 888 888 888 888 X88K
Y88b d88P 888 Y88..88P Y88b 888 Y88b 888 Y88..88P 888 888 888 .d8""8b.
"Y8888P" 888 "Y88P" "Y88888 "Y88888 "Y88P" 888 888 888 888 888
v${pkg.version} - Cloudonix Voice AI Connector
Home: https://cloudonix.com
Documentation: https://developers.cloudonix.com
Discord: https://discord.gg/etCGgNh9VV
GitHub: https://github.com/cloudonix
`;
program
.name('cx-vcc')
.description('Cloudonix Voice AI Connector - Setup SIP trunks between Cloudonix and Voice AI providers')
.version(pkg.version, '-v, --version', 'Output the current version')
.hook('preAction', (thisCommand, actionCommand) => {
// Set debug mode based on the global flag
const options = thisCommand.opts();
setDebugMode(options.debug || false);
});
// Display the banner on each execution
console.log(chalk.cyan(banner));
// Configure command
program
.command('configure')
.description('Configure a new Cloudonix domain')
.requiredOption('-d, --domain <domain>', 'Cloudonix domain name')
.requiredOption('-a, --apikey <apikey>', 'Cloudonix API key')
.option('--debug', 'Enable debug mode for detailed logging')
.action(configureCommand);
// Delete command
program
.command('delete')
.description('Delete a Cloudonix domain configuration')
.requiredOption('-d, --domain <domain>', 'Cloudonix domain name to delete')
.option('--debug', 'Enable debug mode for detailed logging')
.action(deleteCommand);
// Service command
program
.command('service')
.description('Configure a Voice AI service provider')
.requiredOption('-p, --provider <provider>', 'Service provider name (currently supports: vapi, retell, 11labs)')
.requiredOption('-a, --apikey <apikey>', 'API key for the service provider')
.option('-n, --name <n>', 'Name for the SIP trunk (if creating a trunk)')
.option('-d, --domain <domain>', 'Cloudonix domain to use for SIP trunk (only required when creating a trunk)')
.option('--debug', 'Enable debug mode for detailed logging')
.action(serviceCommand);
// Add Number command
program
.command('addnumber')
.description('Add a phone number to a Voice AI provider')
.requiredOption('-d, --domain <domain>', 'Cloudonix domain to use')
.requiredOption('-p, --provider <provider>', 'Service provider name (currently supports: vapi, retell, 11labs)')
.requiredOption('-n, --number <number>', 'Phone number to add (E.164 format mandatory)')
.option('--debug', 'Enable debug mode for detailed logging')
.action(addNumberCommand);
// Display command
program
.command('display')
.description('Display configuration information')
.option('-d, --domain <domain>', 'Specific domain to display')
.option('-r, --remote', 'Display remote configuration from service providers')
.option('--debug', 'Enable debug mode for detailed logging')
.action(displayCommand);
// Sync command
program
.command('sync')
.description('Synchronize local configuration with remote service providers')
.option('-d, --domain <domain>', 'Limit sync to a specific Cloudonix domain')
.option('-p, --provider <provider>', 'Limit sync to a specific service provider (vapi, retell, 11labs)')
.option('--debug', 'Enable debug mode for detailed logging')
.action(syncCommand);
program.parse(process.argv);
// Display help if no arguments provided
if (!process.argv.slice(2).length) {
program.help();
}