UNPKG

@agentled/cli

Version:

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

80 lines 3.66 kB
/** * `agentled do` — Semantic Intent Router * * Describe what you want in natural language. Agentled finds the best matching * workflow, extracts inputs from your intent, and optionally executes it. * * Examples: * agentled do "find the CEO's email for stripe.com" * agentled do "research acme corp and score them" --execute * agentled do "scrape https://example.com" --execute --no-confirm */ import { AgentledClient } from '../client.js'; import { printOutput, printError } from '../utils/output.js'; export function registerDoCommand(program) { program .command('do <intent>') .description('Describe what you want — Agentled routes to the best matching workflow') .option('--execute', 'Auto-execute the matched workflow', false) .option('--no-confirm', 'Skip confirmation when executing with missing inputs') .option('--format <fmt>', 'Output format: json, table, minimal', 'json') .action(async (intent, opts) => { try { const client = new AgentledClient(); if (!client.isAuthenticated) { printError('Not authenticated. Run "agentled auth login" or set AGENTLED_API_KEY.'); return; } const result = await client.resolveIntent(intent, { execute: opts.execute, confirm: opts.confirm, }); // Pretty-print based on action if (opts.format === 'json') { printOutput(result, 'json'); return; } // Human-friendly output for table/minimal if (!result.match) { console.log(result.message || 'No matching workflow found.'); return; } const m = result.match; console.log(`\nMatch: ${m.name} (${m.confidence}% confidence)`); console.log(` Goal: ${m.goal}`); console.log(` Reasoning: ${m.reasoning}`); if (m.extractedInputs && Object.keys(m.extractedInputs).length > 0) { console.log(` Extracted inputs:`); for (const [k, v] of Object.entries(m.extractedInputs)) { console.log(` ${k}: ${v}`); } } if (m.missingInputs && m.missingInputs.length > 0) { console.log(` Missing required inputs: ${m.missingInputs.map((f) => f.name).join(', ')}`); } if (result.alternatives?.length > 0) { console.log(`\nAlternatives:`); for (const alt of result.alternatives) { console.log(` - ${alt.name} (${alt.confidence}% confidence): ${alt.reasoning}`); } } if (result.action === 'executed') { console.log(`\nExecution started:`); console.log(` Execution input ID: ${result.execution?.executionInputId}`); console.log(` Workflow ID: ${result.execution?.pipelineId}`); } if (result.action === 'confirmation_needed') { console.log(`\nTo execute, provide the missing inputs:`); console.log(` agentled workflows start ${m.workflowId} --input '${JSON.stringify(m.extractedInputs || {})}'`); } if (result.action === 'low_confidence') { console.log(`\nLow confidence match. To execute anyway:\n agentled workflows start ${m.workflowId} --input '...'`); } console.log(''); } catch (e) { printError(e.message); } }); } //# sourceMappingURL=do.js.map