UNPKG

@agentled/cli

Version:

CLI for Agentled — manage workflows, apps, and knowledge from the command line. Zero context-window cost for AI agents.

154 lines 6.39 kB
import { AgentledClient } from '../client.js'; import { printError, printOutput } from '../utils/output.js'; const INTERVAL_CHOICES = [ 'weekday-morning', 'weekday-evening', 'weekly-monday', 'weekly-friday-evening', 'daily', '2h', '6h', '48h', ]; const TRIGGER_SOURCE_CHOICES = ['codex', 'claude', 'ui', 'api', 'mcp']; export function registerRoutineCommands(program) { const routines = program.command('routines').description('Manage agent routines'); routines .command('list <agent-slug>') .description('List all routines for an agent') .option('--format <fmt>', 'Output format', 'json') .action(async (agentSlug, opts) => { try { printOutput(await new AgentledClient().listRoutines(agentSlug), opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('create <agent-slug>') .description('Create a new paid autonomous routine for an agent') .requiredOption('--name <name>', 'Routine name') .requiredOption('--prompt <prompt>', 'Instructions the agent follows each run') .requiredOption('--interval <interval>', `Schedule interval (${INTERVAL_CHOICES.join(', ')})`) .option('--model <model>', 'Model to use (e.g. anthropic:claude-4-6-sonnet)') .option('--max-steps <n>', 'Max tool-use steps per run', parseInt) .option('--max-credits <n>', 'Daily credit cap', parseInt) .option('--format <fmt>', 'Output format', 'json') .action(async (agentSlug, opts) => { try { const result = await new AgentledClient().createRoutine(agentSlug, { name: opts.name, prompt: opts.prompt, interval: opts.interval, model: opts.model, maxStepsPerRun: opts.maxSteps, maxCreditsPerDay: opts.maxCredits, }); printOutput(result, opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('update <routine-id>') .description('Update routine fields') .option('--name <name>', 'New name') .option('--prompt <prompt>', 'New prompt / instructions') .option('--interval <interval>', `New schedule interval (${INTERVAL_CHOICES.join(', ')})`) .option('--model <model>', 'New model') .option('--max-steps <n>', 'Max steps per run', parseInt) .option('--max-credits <n>', 'Daily credit cap', parseInt) .option('--format <fmt>', 'Output format', 'json') .action(async (routineId, opts) => { try { const result = await new AgentledClient().updateRoutine(routineId, { name: opts.name, prompt: opts.prompt, interval: opts.interval, model: opts.model, maxStepsPerRun: opts.maxSteps, maxCreditsPerDay: opts.maxCredits, }); printOutput(result, opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('pause <routine-id>') .description('Pause a routine') .option('--format <fmt>', 'Output format', 'json') .action(async (routineId, opts) => { try { printOutput(await new AgentledClient().pauseRoutine(routineId), opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('resume <routine-id>') .description('Resume a paused paid autonomous routine') .option('--format <fmt>', 'Output format', 'json') .action(async (routineId, opts) => { try { printOutput(await new AgentledClient().resumeRoutine(routineId), opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('trigger <routine-id>') .description('Run a paid autonomous routine immediately without changing its scheduled cadence') .requiredOption('--source <source>', `Trigger source (${TRIGGER_SOURCE_CHOICES.join(', ')})`) .requiredOption('--reason <reason>', 'Short reason for this manual run') .option('--format <fmt>', 'Output format', 'json') .action(async (routineId, opts) => { try { if (!TRIGGER_SOURCE_CHOICES.includes(opts.source)) { throw new Error(`--source must be one of: ${TRIGGER_SOURCE_CHOICES.join(', ')}`); } printOutput(await new AgentledClient().triggerRoutine(routineId, { source: opts.source, reason: opts.reason, }), opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('get-run <routine-id> <run-id>') .description('Read one exact durable routine run and a bounded page of its events') .option('--limit <n>', 'Maximum events to return (maximum 200)', parseInt) .option('--next-token <token>', 'Opaque event pagination token') .option('--format <fmt>', 'Output format', 'json') .action(async (routineId, runId, opts) => { try { printOutput(await new AgentledClient().getRoutineRun(routineId, runId, { limit: opts.limit, nextToken: opts.nextToken, }), opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); routines .command('delete <routine-id>') .description('Permanently delete a routine') .option('--format <fmt>', 'Output format', 'json') .action(async (routineId, opts) => { try { printOutput(await new AgentledClient().deleteRoutine(routineId), opts.format); } catch (error) { printError(error instanceof Error ? error.message : String(error)); } }); } //# sourceMappingURL=routines.js.map