Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elevenlabs/cli",
"version": "0.1.1",
"version": "0.1.2",
"description": "CLI tool to manage ElevenLabs agents",
"type": "module",
"keywords": [
Expand Down
19 changes: 13 additions & 6 deletions src/agents/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ interface AgentDefinition {

interface AddOptions {
configPath?: string;
template: string;
template?: string;
env: string;
}

export function createAddCommand(): Command {
return new Command('add')
.description('Add a new agent - creates config, uploads to ElevenLabs, and saves ID')
.argument('<name>', 'Name of the agent to create')
.argument('[name]', 'Name of the agent to create')
.option('--config-path <path>', 'Custom config path (optional)')
.option('--template <template>', 'Template type to use', 'default')
.option('--template <template>', 'Template type to use')
.option('--env <environment>', 'Environment to create agent in', 'prod')
.option('--no-ui', 'Disable interactive UI')
.action(async (name: string, options: AddOptions & { ui: boolean }) => {
.action(async (name: string | undefined, options: AddOptions & { ui: boolean }) => {
try {
if (options.ui !== false && !options.configPath) {
// Use Ink UI for agent creation
Expand All @@ -52,6 +52,13 @@ export function createAddCommand(): Command {
await waitUntilExit();
return;
}

// Non-UI path requires name to be provided
if (!name) {
console.error('Error: Agent name is required when using --no-ui or --config-path');
process.exit(1);
}

// Check if agents.json exists
const agentsConfigPath = path.resolve(AGENTS_CONFIG_FILE);
if (!(await fs.pathExists(agentsConfigPath))) {
Expand All @@ -65,7 +72,7 @@ export function createAddCommand(): Command {
// Create agent config using template (in memory first)
let agentConfig: AgentConfig;
try {
agentConfig = getTemplateByName(name, options.template);
agentConfig = getTemplateByName(name, options.template || 'default');
} catch (error) {
console.error(`${error}`);
process.exit(1);
Expand Down Expand Up @@ -104,7 +111,7 @@ export function createAddCommand(): Command {
await fs.ensureDir(path.dirname(configFilePath));

await writeConfig(configFilePath, agentConfig);
console.log(`Created config file: ${configPath} (template: ${options.template})`);
console.log(`Created config file: ${configPath} (template: ${options.template || 'default'})`);

// Store agent ID in index file
const newAgent: AgentDefinition = {
Expand Down
12 changes: 7 additions & 5 deletions src/agents/ui/AddAgentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ interface AddAgentViewProps {

type Step = 'name' | 'template' | 'confirm' | 'creating';

export const AddAgentView: React.FC<AddAgentViewProps> = ({
export const AddAgentView: React.FC<AddAgentViewProps> = ({
initialName,
template = 'default',
template,
environment = 'prod',
onComplete
onComplete
}) => {
const { exit } = useApp();
const [currentStep, setCurrentStep] = useState<Step>(initialName ? 'template' : 'name');
const [currentStep, setCurrentStep] = useState<Step>(
initialName && template ? 'confirm' : initialName ? 'template' : 'name'
);
const [agentName, setAgentName] = useState(initialName || '');
const [selectedTemplate, setSelectedTemplate] = useState(template);
const [selectedTemplate, setSelectedTemplate] = useState(template || 'default');
const [isCreating, setIsCreating] = useState(false);
const [error, setError] = useState<string | null>(null);
const [success, setSuccess] = useState(false);
Expand Down
Loading