@agentled/cli
Version:
CLI for Agentled — manage workflows, apps, and knowledge from the command line. Zero context-window cost for AI agents.
103 lines • 4.22 kB
JavaScript
import { readFileSync } from 'node:fs';
import { AgentledClient } from '../client.js';
import { printError, printOutput } from '../utils/output.js';
function parseJson(opts, label) {
if (!opts.input && !opts.file)
throw new Error(`Provide ${label} via --input '<json>' or --file <path>`);
if (opts.input && opts.file)
throw new Error(`Provide ${label} with either --input or --file, not both`);
return JSON.parse(opts.file ? readFileSync(opts.file, 'utf8') : opts.input);
}
export function registerProactiveAgentCommands(program) {
const pa = program.command('proactive-agents').description('Manage proactive agents');
pa.command('list')
.description('List proactive agents')
.option('--status <status>', 'Filter by status')
.option('--format <fmt>', 'Output format', 'json')
.action(async (opts) => {
try {
printOutput(await new AgentledClient().listProactiveAgents({ status: opts.status }), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
pa.command('get <id>')
.description('Get proactive agent')
.option('--format <fmt>', 'Output format', 'json')
.action(async (id, opts) => {
try {
printOutput(await new AgentledClient().getProactiveAgent(id), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
pa.command('create')
.description('Create proactive agent')
.option('--input <json>', 'JSON payload (name, description, config)')
.option('--file <path>', 'Path to JSON payload file')
.option('--format <fmt>', 'Output format', 'json')
.action(async (opts) => {
try {
printOutput(await new AgentledClient().createProactiveAgent(parseJson(opts, 'proactive agent payload')), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
pa.command('update <id>')
.description('Update proactive agent')
.option('--input <json>', 'JSON updates object')
.option('--file <path>', 'Path to JSON updates file')
.option('--format <fmt>', 'Output format', 'json')
.action(async (id, opts) => {
try {
printOutput(await new AgentledClient().updateProactiveAgent(id, parseJson(opts, 'proactive agent updates')), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
pa.command('delete <id>')
.description('Delete proactive agent')
.option('--format <fmt>', 'Output format', 'json')
.action(async (id, opts) => {
try {
printOutput(await new AgentledClient().deleteProactiveAgent(id), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
pa.command('pause <id>')
.description('Pause proactive agent')
.option('--format <fmt>', 'Output format', 'json')
.action(async (id, opts) => {
try {
printOutput(await new AgentledClient().pauseProactiveAgent(id), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
pa.command('resume <id>')
.description('Resume proactive agent')
.option('--format <fmt>', 'Output format', 'json')
.action(async (id, opts) => {
try {
printOutput(await new AgentledClient().resumeProactiveAgent(id), opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
}
//# sourceMappingURL=proactive-agents.js.map