UNPKG

@commit451/salamander

Version:

Never be AFK

73 lines • 2.97 kB
import { input } from '@inquirer/prompts'; import { resolve } from 'path'; import { access } from 'fs/promises'; import chalk from 'chalk'; import { RunnerService } from '../services/runner.js'; import { UserService } from '../services/user.js'; import { RunnerType } from '../types/runner.js'; export async function createRunnerFlow() { console.log(chalk.blue('\nšŸš€ Create New Runner')); console.log('Set up a new runner to execute commands in a specific directory.\n'); try { // Check user's remaining runners const user = await UserService.getCurrentUser(); if (!user) { console.error(chalk.red('āŒ Unable to fetch user information')); console.log(''); return; } console.log(chalk.gray(`Runners remaining: ${user.runnersRemaining}`)); if (user.runnersRemaining <= 0) { console.error(chalk.red('āŒ You have reached your runner limit and cannot create more runners. Please delete a runner, or you can purchase a Pro plan in the app to get 25 total runners, or contact us')); console.error(chalk.yellow('https://salamander.space')); console.log(''); return; } console.log(''); // Get runner name const name = await input({ message: 'Runner name:', validate: (value) => { if (!value.trim()) { return 'Please enter a runner name'; } return true; } }); // Get directory path const directoryInput = await input({ message: 'Directory path:', default: process.cwd(), validate: async (value) => { try { const fullPath = resolve(value); await access(fullPath); return true; } catch { return 'Directory does not exist or is not accessible'; } } }); const directory = resolve(directoryInput); // Default to claude runner type const runnerType = RunnerType.CLAUDE; console.log(chalk.yellow('ā³ Creating runner...')); const runner = await RunnerService.createRunner({ name: name.trim(), directory, runnerType }); console.log(chalk.green('āœ… Runner created successfully!')); console.log(chalk.gray(` ID: ${runner.id}`)); console.log(chalk.gray(` Name: ${runner.name}`)); console.log(chalk.gray(` Directory: ${runner.directory}`)); console.log(chalk.gray(` Type: ${runner.runnerType}`)); console.log('You can now start this runner to listen for commands.'); } catch (error) { console.error(chalk.red('āŒ Error creating runner:'), error.message); process.exit(1); } } //# sourceMappingURL=create-runner.js.map