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
36 changes: 24 additions & 12 deletions src/commands/agent/commands/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,33 @@ export function registerDeleteCommand(agentCmd: Command): void {
console.log(chalk.red('⚠️ This action cannot be undone!'));
console.log(chalk.dim('─'.repeat(50)));

// Check if confirmation should be skipped
const isNonInteractive = process.env.XPANDER_NON_INTERACTIVE === 'true';
const skipConfirmation = updatedOptions.confirm || isNonInteractive;

// Confirm deletion
const confirmation = await inquirer.prompt([
{
type: 'confirm',
name: 'confirmed',
message: `Are you sure you want to permanently delete this agent?`,
default: false,
},
]);

if (!confirmation.confirmed) {
if (!skipConfirmation) {
const confirmation = await inquirer.prompt([
{
type: 'confirm',
name: 'confirmed',
message: `Are you sure you want to permanently delete this agent?`,
default: false,
},
]);

if (!confirmation.confirmed) {
console.log(
chalk.blue('\n✓ Operation cancelled. Agent was not deleted.'),
);
return;
}
} else {
console.log(
chalk.blue('\n✓ Operation cancelled. Agent was not deleted.'),
chalk.yellow(
'→ Skipping confirmation (non-interactive mode or --confirm flag set)',
),
);
return;
}

// Create a spinner for deletion
Expand Down
43 changes: 29 additions & 14 deletions src/commands/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,72 @@ export function agent(program: Command): void {
.alias('d')
.description('Deploy agent')
.option('--profile <n>', 'Profile to use')
.option(
'--path <path>',
'Path to agent directory (defaults to current directory)',
)
.option('--confirm', 'Skip confirmation prompts')
.option('--skip-local-tests', 'Skip local Docker container tests')
.action(async (agentId, options) => {
.action(async (agentId, options, command) => {
const { createClient } = await import('../../utils/client');
const { getAgentIdFromEnvOrSelection } = await import(
'../../utils/agent-resolver'
);
const { deployAgent } = await import('./interactive/deploy');

// Check if --profile was explicitly provided in command line
const profileExplicitlySet =
command.parent?.rawArgs.includes('--profile');

const client = createClient(options.profile);
const resolvedAgentId = await getAgentIdFromEnvOrSelection(
client,
agentId,
);
if (!resolvedAgentId) return;
await deployAgent(
client,
resolvedAgentId,
agentId,
options.confirm,
options.skipLocalTests,
options.path,
profileExplicitlySet || false, // Use profile credentials if --profile was explicitly set
);
});

agentCmd
.command('dev [agent]')
.description('Run agent locally')
.option('--profile <n>', 'Profile to use')
.action(async (agentId) => {
.option(
'--path <path>',
'Path to agent directory (defaults to current directory)',
)
.action(async (agentId, options) => {
const { startAgent } = await import('./interactive/dev');
await startAgent(agentId);
await startAgent(agentId, options.path);
});

agentCmd
.command('restart [agent]')
.description('Restart agent')
.option('--profile <n>', 'Profile to use')
.option(
'--path <path>',
'Path to agent directory (defaults to current directory)',
)
.action(async (agentId, options) => {
const { restartAgent } = await import('../restart');
const { createClient } = await import('../../utils/client');
const client = createClient(options.profile);
await restartAgent(client, agentId);
await restartAgent(client, agentId, options.path);
});

agentCmd
.command('stop [agent]')
.description('Stop agent')
.option('--profile <n>', 'Profile to use')
.option(
'--path <path>',
'Path to agent directory (defaults to current directory)',
)
.action(async (agentId, options) => {
const { stopAgent } = await import('../stop');
const { createClient } = await import('../../utils/client');
const client = createClient(options.profile);
await stopAgent(client, agentId);
await stopAgent(client, agentId, options.path);
});

// Register graph and tools commands
Expand Down
Loading