@tronsfey/ucli 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/lib/config-encryption.ts","../src/lib/server-client.ts","../src/lib/exit-codes.ts","../src/lib/output.ts","../src/commands/configure.ts","../src/lib/cache.ts","../src/lib/oas-runner.ts","../src/lib/yaml.ts","../src/commands/services.ts","../src/commands/run.ts","../src/commands/refresh.ts","../src/commands/help-cmd.ts","../src/lib/mcp-runner.ts","../src/commands/mcp.ts","../src/lib/errors.ts","../src/commands/doctor.ts","../src/commands/completions.ts","../src/commands/introspect.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { createRequire } from 'node:module'\nimport { registerConfigure } from './commands/configure.js'\nimport { registerServices } from './commands/services.js'\nimport { registerRun } from './commands/run.js'\nimport { registerRefresh } from './commands/refresh.js'\nimport { registerHelp } from './commands/help-cmd.js'\nimport { registerMcp } from './commands/mcp.js'\nimport { registerDoctor } from './commands/doctor.js'\nimport { registerCompletions } from './commands/completions.js'\nimport { registerIntrospect } from './commands/introspect.js'\nimport { setDebugMode } from './lib/errors.js'\nimport { setOutputMode, type OutputMode } from './lib/output.js'\n\nconst require = createRequire(import.meta.url)\nconst pkg = require('../package.json') as { version: string; description: string }\n\nconst program = new Command()\n\nprogram\n .name('ucli')\n .description(pkg.description)\n .version(pkg.version, '-v, --version')\n .option('--debug', 'Enable verbose debug logging')\n .option('--output <mode>', 'Output mode: text | json (json wraps every result in a structured envelope for agent consumption)', 'text')\n .addHelpCommand(false) // we provide our own help command\n .hook('preAction', (_thisCommand, actionCommand) => {\n // Walk up to root to find the --debug and --output flags\n let cmd = actionCommand\n while (cmd) {\n const opts = cmd.opts() as Record<string, unknown>\n if (opts.debug) {\n setDebugMode(true)\n }\n if (opts.output && typeof opts.output === 'string') {\n const mode = opts.output.toLowerCase() as OutputMode\n if (mode === 'json' || mode === 'text') {\n setOutputMode(mode)\n }\n }\n cmd = cmd.parent as Command\n }\n })\n\nregisterConfigure(program)\nregisterServices(program)\nregisterRun(program)\nregisterRefresh(program)\nregisterMcp(program)\nregisterDoctor(program)\nregisterCompletions(program)\nregisterIntrospect(program)\nregisterHelp(program)\n\nprogram.parse(process.argv)\n","import Conf from 'conf'\nimport { homedir } from 'node:os'\nimport { join, dirname } from 'node:path'\nimport { chmodSync, mkdirSync } from 'node:fs'\nimport { encryptValue, decryptValue, isEncrypted } from './lib/config-encryption.js'\n\nexport interface CLIConfig {\n serverUrl: string\n token: string\n}\n\nconst conf = new Conf<CLIConfig>({\n projectName: 'ucli',\n schema: {\n serverUrl: { type: 'string' },\n token: { type: 'string' },\n },\n})\n\nexport const cacheDir = join(homedir(), '.cache', 'ucli')\n\n/** Ensure the config file and its directory have restrictive permissions. */\nfunction hardenConfigPermissions(): void {\n try {\n const configPath = conf.path\n const configDir = dirname(configPath)\n mkdirSync(configDir, { recursive: true, mode: 0o700 })\n chmodSync(configDir, 0o700)\n chmodSync(configPath, 0o600)\n } catch {\n // Permission enforcement may fail on some platforms (e.g., Windows)\n console.warn('Warning: Could not enforce restrictive file permissions on config. Token is encrypted but file permissions may be permissive.')\n }\n}\n\nexport function getConfig(): CLIConfig {\n const serverUrl = conf.get('serverUrl')\n const rawToken = conf.get('token')\n\n if (!serverUrl || !rawToken) {\n console.error('ucli is not configured. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n const token = decryptValue(rawToken)\n\n // Auto-migrate: re-encrypt legacy plaintext tokens on read\n if (!isEncrypted(rawToken)) {\n conf.set('token', encryptValue(token))\n hardenConfigPermissions()\n }\n\n return { serverUrl, token }\n}\n\nexport function saveConfig(cfg: CLIConfig): void {\n conf.set('serverUrl', cfg.serverUrl)\n conf.set('token', encryptValue(cfg.token))\n hardenConfigPermissions()\n}\n\nexport function isConfigured(): boolean {\n return Boolean(conf.get('serverUrl') && conf.get('token'))\n}\n","/**\n * Config value encryption utilities.\n *\n * Encrypts sensitive config values (e.g., JWT tokens) at rest using AES-256-GCM\n * with a machine-specific derived key. This ensures credentials are never stored\n * in plaintext on disk.\n *\n * Key derivation: PBKDF2(username + hostname, random-salt, 100k iterations, SHA-512)\n * Format: \"enc:v1:<base64(salt + iv + authTag + ciphertext)>\"\n */\nimport {\n createCipheriv,\n createDecipheriv,\n randomBytes,\n pbkdf2Sync,\n} from 'node:crypto'\nimport { hostname, userInfo } from 'node:os'\n\nconst ENC_PREFIX = 'enc:v1:'\nconst ALGORITHM = 'aes-256-gcm'\nconst SALT_LEN = 32\nconst IV_LEN = 12\nconst TAG_LEN = 16\nconst PBKDF2_ITERATIONS = 100_000\n\n/** Derive a 256-bit key from machine-specific identity + per-value random salt. */\nfunction deriveKey(salt: Buffer): Buffer {\n let user = 'default'\n try {\n user = userInfo().username\n } catch {\n // userInfo() may throw on some platforms (e.g., certain containers)\n }\n const material = `ucli:${user}@${hostname()}`\n return pbkdf2Sync(material, salt, PBKDF2_ITERATIONS, 32, 'sha512')\n}\n\n/** Encrypt a plaintext string. Returns prefixed ciphertext string. */\nexport function encryptValue(plaintext: string): string {\n const salt = randomBytes(SALT_LEN)\n const key = deriveKey(salt)\n const iv = randomBytes(IV_LEN)\n const cipher = createCipheriv(ALGORITHM, key, iv)\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()])\n const tag = cipher.getAuthTag()\n const packed = Buffer.concat([salt, iv, tag, encrypted])\n return ENC_PREFIX + packed.toString('base64')\n}\n\n/**\n * Decrypt a stored value. If the value has the encryption prefix, it is\n * decrypted; otherwise it is returned as-is for backward compatibility\n * with legacy plaintext configs.\n */\nexport function decryptValue(stored: string): string {\n if (!stored.startsWith(ENC_PREFIX)) {\n return stored\n }\n const packed = Buffer.from(stored.slice(ENC_PREFIX.length), 'base64')\n const salt = packed.subarray(0, SALT_LEN)\n const iv = packed.subarray(SALT_LEN, SALT_LEN + IV_LEN)\n const tag = packed.subarray(SALT_LEN + IV_LEN, SALT_LEN + IV_LEN + TAG_LEN)\n const encrypted = packed.subarray(SALT_LEN + IV_LEN + TAG_LEN)\n const key = deriveKey(salt)\n const decipher = createDecipheriv(ALGORITHM, key, iv)\n decipher.setAuthTag(tag)\n return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8')\n}\n\n/** Check whether a stored value is encrypted (has the encryption prefix). */\nexport function isEncrypted(value: string): boolean {\n return value.startsWith(ENC_PREFIX)\n}\n","/**\n * HTTP client for the ucli-server API.\n * Attaches group JWT and handles common error cases.\n */\nimport axios, { type AxiosInstance } from 'axios'\nimport type { CLIConfig } from '../config.js'\n\nexport interface OASEntryPublic {\n id: string\n name: string\n description: string\n remoteUrl: string\n baseEndpoint: string | null\n authType: 'bearer' | 'api_key' | 'basic' | 'oauth2_cc' | 'none'\n authConfig: Record<string, unknown>\n cacheTtl: number\n}\n\nexport type McpAuthConfig =\n | { type: 'none' }\n | { type: 'http_headers'; headers: Record<string, string> }\n | { type: 'env'; env: Record<string, string> }\n\nexport interface McpEntryPublic {\n id: string\n groupId: string\n name: string\n description: string\n transport: 'http' | 'stdio'\n serverUrl: string | null\n command: string | null\n authConfig: McpAuthConfig\n enabled: boolean\n}\n\nexport class ServerClient {\n private http: AxiosInstance\n\n constructor(cfg: CLIConfig) {\n this.http = axios.create({\n baseURL: cfg.serverUrl.replace(/\\/$/, ''),\n headers: {\n Authorization: `Bearer ${cfg.token}`,\n 'Content-Type': 'application/json',\n },\n timeout: 15_000,\n })\n\n this.http.interceptors.response.use(\n (r) => r,\n (err: unknown) => {\n if (axios.isAxiosError(err)) {\n const status = err.response?.status\n const message = (err.response?.data as { message?: string })?.message ?? err.message\n\n if (status === 401) {\n console.error('Authentication failed. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n throw new Error(`Server error ${status ?? 'unknown'}: ${message}`)\n }\n throw err\n },\n )\n }\n\n async listOAS(): Promise<OASEntryPublic[]> {\n const { data } = await this.http.get<OASEntryPublic[]>('/api/v1/oas')\n return data\n }\n\n async getOAS(name: string): Promise<OASEntryPublic> {\n const { data } = await this.http.get<OASEntryPublic>(`/api/v1/oas/${encodeURIComponent(name)}`)\n return data\n }\n\n async listMCP(): Promise<McpEntryPublic[]> {\n const { data } = await this.http.get<McpEntryPublic[]>('/api/v1/mcp')\n return data\n }\n\n async getMCP(name: string): Promise<McpEntryPublic> {\n const { data } = await this.http.get<McpEntryPublic>(`/api/v1/mcp/${encodeURIComponent(name)}`)\n return data\n }\n}\n","/**\n * Structured exit codes for automation and scripting.\n *\n * Convention:\n * 0 — success\n * 1 — general / unknown error\n * 2 — usage / argument error\n * 3 — configuration error (missing or invalid config)\n * 4 — authentication error (invalid / expired token)\n * 5 — connectivity error (server unreachable)\n * 6 — not-found error (service / resource doesn't exist)\n * 7 — server error (5xx from upstream)\n */\n\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n USAGE_ERROR: 2,\n CONFIG_ERROR: 3,\n AUTH_ERROR: 4,\n CONNECTIVITY_ERROR: 5,\n NOT_FOUND: 6,\n SERVER_ERROR: 7,\n} as const\n\nexport type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode]\n","/**\n * Structured output module for AI agent consumption.\n *\n * When `--output json` is active globally, every command emits a single\n * JSON envelope to stdout so that agents can reliably parse both success\n * and error results without scraping human-readable text.\n *\n * Envelope shapes:\n * Success → { \"success\": true, \"data\": <any> }\n * Error → { \"success\": false, \"error\": { \"code\": <number>, \"message\": <string>, \"hint\"?: <string> } }\n */\n\nexport type OutputMode = 'text' | 'json'\n\nlet currentMode: OutputMode = 'text'\n\n/** Set the global output mode. Called once from index.ts preAction hook. */\nexport function setOutputMode(mode: OutputMode): void {\n currentMode = mode\n}\n\n/** Get the current output mode. */\nexport function getOutputMode(): OutputMode {\n return currentMode\n}\n\n/** Returns true when structured JSON output is active. */\nexport function isJsonOutput(): boolean {\n return currentMode === 'json'\n}\n\n/**\n * Emit a successful result.\n *\n * In JSON mode the data is wrapped in `{ success: true, data }`.\n * In text mode this is a no-op — the caller is responsible for\n * printing human-readable output itself.\n */\nexport function outputSuccess(data: unknown): void {\n if (currentMode === 'json') {\n console.log(JSON.stringify({ success: true, data }, null, 2))\n }\n}\n\n/**\n * Emit a structured error and exit.\n *\n * In JSON mode the error is wrapped in `{ success: false, error: { code, message, hint? } }`.\n * In text mode falls through to the existing `formatError` path.\n */\nexport function outputError(\n code: number,\n message: string,\n hint?: string,\n): never {\n if (currentMode === 'json') {\n const envelope: Record<string, unknown> = {\n success: false,\n error: { code, message, ...(hint ? { hint } : {}) },\n }\n console.log(JSON.stringify(envelope, null, 2))\n process.exit(code)\n }\n\n // Text mode — re-use existing stderr formatting\n console.error(`\\n✖ Error: ${message}`)\n if (hint) console.error(` Hint: ${hint}`)\n process.exit(code)\n}\n","import type { Command } from 'commander'\nimport { saveConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\nexport function registerConfigure(program: Command): void {\n program\n .command('configure')\n .description('Configure the OAS Gateway server URL and authentication token')\n .requiredOption('--server <url>', 'OAS Gateway server URL (e.g. https://oas.example.com)')\n .requiredOption('--token <jwt>', 'Group JWT token issued by the server admin')\n .action(async (opts: { server: string; token: string }) => {\n const serverUrl = opts.server.replace(/\\/$/, '')\n const token = opts.token\n\n // Validate connectivity before saving\n if (!isJsonOutput()) {\n console.log(`Connecting to ${serverUrl}...`)\n }\n const client = new ServerClient({ serverUrl, token })\n\n try {\n await client.listOAS()\n saveConfig({ serverUrl, token })\n\n if (isJsonOutput()) {\n outputSuccess({ serverUrl, configured: true })\n return\n }\n\n console.log('✓ Configuration saved successfully.')\n console.log(` Server: ${serverUrl}`)\n console.log(` Token: ${token.slice(0, 20)}...`)\n } catch (err) {\n outputError(ExitCode.CONNECTIVITY_ERROR,\n `Connection failed: ${(err as Error).message}`,\n 'Check the server URL and token')\n }\n })\n}\n","/**\n * Local file cache for OAS entries.\n * Stored at ~/.cache/oas-cli/<name>.json with TTL metadata.\n *\n * Security: authConfig credential values are stripped before writing.\n * Only { type } is persisted — full secrets are never written to disk.\n */\nimport { readFile, writeFile, mkdir, unlink, chmod } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { cacheDir } from '../config.js'\nimport type { OASEntryPublic } from './server-client.js'\n\ninterface CacheFile {\n entries: OASEntryPublic[]\n fetchedAt: number // ms timestamp\n ttlSec: number // cache duration\n}\n\nconst LIST_CACHE_FILE = join(cacheDir, 'oas-list.json')\n\nasync function ensureCacheDir(): Promise<void> {\n await mkdir(cacheDir, { recursive: true, mode: 0o700 })\n}\n\n/** Strip credential secrets from authConfig — only persist { type }. */\nfunction redactEntries(entries: OASEntryPublic[]): OASEntryPublic[] {\n return entries.map((e) => ({\n ...e,\n authConfig: { type: (e.authConfig as Record<string, unknown>)['type'] ?? e.authType },\n }))\n}\n\nexport async function readOASListCache(): Promise<OASEntryPublic[] | null> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const age = (Date.now() - cached.fetchedAt) / 1000\n if (cached.ttlSec === 0 || age > cached.ttlSec) return null // expired\n return cached.entries\n } catch {\n return null // not found or parse error\n }\n}\n\nexport async function writeOASListCache(entries: OASEntryPublic[], ttlSec: number): Promise<void> {\n await ensureCacheDir()\n const cached: CacheFile = { entries: redactEntries(entries), fetchedAt: Date.now(), ttlSec }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(cached, null, 2), { encoding: 'utf8', mode: 0o600 })\n await chmod(LIST_CACHE_FILE, 0o600)\n}\n\nexport async function clearOASListCache(): Promise<void> {\n try {\n await unlink(LIST_CACHE_FILE)\n } catch {\n // ignore if not found\n }\n}\n\nexport async function clearOASCache(name: string): Promise<void> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const entries = Array.isArray(cached.entries) ? cached.entries.filter((e) => e.name !== name) : []\n if (entries.length === 0) {\n await clearOASListCache()\n return\n }\n const next: CacheFile = {\n entries,\n fetchedAt: cached.fetchedAt ?? Date.now(),\n ttlSec: cached.ttlSec ?? 0,\n }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(next, null, 2), { encoding: 'utf8', mode: 0o600 })\n } catch {\n await clearOASListCache()\n }\n}\n","/**\n * Bridge between oas-cli and @tronsfey/openapi2cli run mode.\n *\n * Spawns openapi2cli as a child process, injecting auth config\n * as environment variables (never exposed to the agent's shell).\n */\nimport { spawn } from 'node:child_process'\nimport { createRequire } from 'node:module'\nimport { join, dirname } from 'node:path'\nimport type { OASEntryPublic } from './server-client.js'\n\nconst require = createRequire(import.meta.url)\n\nfunction resolveOpenapi2CliBin(): string {\n try {\n const pkgPath = require.resolve('@tronsfey/openapi2cli/package.json')\n const pkgDir = dirname(pkgPath)\n // @tronsfey/openapi2cli exposes its binary; find it\n const pkg = require('@tronsfey/openapi2cli/package.json') as { bin?: Record<string, string> }\n const binEntry = pkg.bin?.['openapi2cli'] ?? 'bin/openapi2cli.js'\n return join(pkgDir, binEntry)\n } catch {\n throw new Error(\n '@tronsfey/openapi2cli is not installed. Run: pnpm add @tronsfey/openapi2cli in packages/cli',\n )\n }\n}\n\nexport interface RunOptions {\n entry: OASEntryPublic\n /** Operation command args (e.g. ['listPets', '--limit', '10']) */\n operationArgs: string[]\n format?: 'json' | 'table' | 'yaml'\n query?: string\n}\n\n/**\n * Build auth environment variables for injection into child process.\n * The calling shell (and thus the AI agent) never sees these values.\n */\nfunction buildAuthEnv(entry: OASEntryPublic): Record<string, string> {\n const cfg = entry.authConfig\n const prefix = entry.name.toUpperCase().replace(/[^A-Z0-9]/g, '_')\n\n switch (cfg['type']) {\n case 'bearer':\n return { [`${prefix}_TOKEN`]: cfg['token'] as string }\n\n case 'api_key':\n return { [`${prefix}_API_KEY`]: cfg['key'] as string }\n\n case 'basic':\n return { [`${prefix}_CREDENTIALS`]: `${cfg['username']}:${cfg['password']}` }\n\n case 'oauth2_cc':\n return {\n [`${prefix}_CLIENT_ID`]: cfg['clientId'] as string,\n [`${prefix}_CLIENT_SECRET`]: cfg['clientSecret'] as string,\n [`${prefix}_SCOPES`]: (cfg['scopes'] as string[]).join(' '),\n }\n\n default:\n return {}\n }\n}\n\n/**\n * Environment variable allowlist for subprocess execution.\n * Only these variables (when present in the parent) are forwarded to the\n * child process. This prevents leakage of secrets such as cloud credentials,\n * encryption keys, or database passwords that may be in the parent env.\n */\nconst SAFE_ENV_KEYS: readonly string[] = [\n // System essentials\n 'PATH', 'HOME', 'USER', 'LOGNAME', 'SHELL', 'TMPDIR', 'TMP', 'TEMP',\n // Terminal / display\n 'TERM', 'COLORTERM', 'NO_COLOR', 'FORCE_COLOR', 'LANG', 'LC_ALL',\n 'LC_CTYPE', 'LC_MESSAGES', 'LC_COLLATE',\n // Node.js\n 'NODE_ENV', 'NODE_PATH', 'NODE_OPTIONS', 'NODE_EXTRA_CA_CERTS',\n // Network proxy (required for tools behind corporate proxies)\n 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY',\n 'http_proxy', 'https_proxy', 'no_proxy',\n // OS-specific\n 'SYSTEMROOT', 'COMSPEC', 'APPDATA', 'LOCALAPPDATA', 'PROGRAMFILES',\n 'XDG_RUNTIME_DIR', 'XDG_CONFIG_HOME', 'XDG_CACHE_HOME', 'XDG_DATA_HOME',\n]\n\nfunction buildSafeEnv(authEnv: Record<string, string>): Record<string, string> {\n const safe: Record<string, string> = {}\n for (const key of SAFE_ENV_KEYS) {\n if (process.env[key] !== undefined) {\n safe[key] = process.env[key]!\n }\n }\n return { ...safe, ...authEnv }\n}\n\nexport async function runOperation(opts: RunOptions): Promise<void> {\n const bin = resolveOpenapi2CliBin()\n const { entry, operationArgs, format, query } = opts\n\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n ...(entry.baseEndpoint ? ['--endpoint', entry.baseEndpoint] : []),\n ...(format ? ['--format', format] : []),\n ...(query ? ['--query', query] : []),\n ...operationArgs,\n ]\n\n const authEnv = buildAuthEnv(entry)\n\n await new Promise<void>((resolve, reject) => {\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: 'inherit',\n env: buildSafeEnv(authEnv),\n })\n\n child.on('close', (code) => {\n if (code === 0) resolve()\n else reject(new Error(`openapi2cli exited with code ${code}`))\n })\n child.on('error', reject)\n })\n}\n\n/**\n * Get list of available operations for a service by running `--help`.\n * Returns the raw help text from openapi2cli.\n */\nexport async function getServiceHelp(entry: OASEntryPublic): Promise<string> {\n const bin = resolveOpenapi2CliBin()\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n '--help',\n ]\n\n return new Promise<string>((resolve, reject) => {\n let output = ''\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n child.stdout?.on('data', (d: Buffer) => { output += d.toString() })\n child.stderr?.on('data', (d: Buffer) => { output += d.toString() })\n child.on('close', () => resolve(output))\n child.on('error', reject)\n })\n}\n","/**\n * YAML output format support.\n *\n * A lightweight YAML serialiser that covers the data shapes produced by\n * ucli commands (plain objects, arrays, strings, numbers, booleans, null).\n * No external dependencies — we don't need a full YAML parser, only output.\n */\n\n/** Convert a JSON-serialisable value to a YAML string. */\nexport function toYaml(value: unknown, indent = 0): string {\n if (value === null || value === undefined) {\n return 'null'\n }\n\n if (typeof value === 'boolean') {\n return value ? 'true' : 'false'\n }\n\n if (typeof value === 'number') {\n return String(value)\n }\n\n if (typeof value === 'string') {\n // Use quotes if the string contains special YAML characters\n if (needsQuoting(value)) {\n return JSON.stringify(value)\n }\n return value\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]'\n const prefix = ' '.repeat(indent)\n return value\n .map((item) => {\n const serialised = toYaml(item, indent + 2)\n if (typeof item === 'object' && item !== null && !Array.isArray(item)) {\n // Object items: put the first key on the same line as the dash\n const firstNewline = serialised.indexOf('\\n')\n if (firstNewline === -1) {\n return `${prefix}- ${serialised.trimStart()}`\n }\n const firstLine = serialised.slice(0, firstNewline)\n const rest = serialised.slice(firstNewline + 1)\n return `${prefix}- ${firstLine.trimStart()}\\n${rest}`\n }\n return `${prefix}- ${serialised}`\n })\n .join('\\n')\n }\n\n if (typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n if (entries.length === 0) return '{}'\n const prefix = ' '.repeat(indent)\n return entries\n .map(([key, val]) => {\n if (val === null || val === undefined) {\n return `${prefix}${key}: null`\n }\n if (typeof val === 'object') {\n const nested = toYaml(val, indent + 2)\n return `${prefix}${key}:\\n${nested}`\n }\n return `${prefix}${key}: ${toYaml(val, indent)}`\n })\n .join('\\n')\n }\n\n return String(value)\n}\n\nfunction needsQuoting(s: string): boolean {\n if (s === '') return true\n if (s === 'true' || s === 'false' || s === 'null') return true\n if (/^\\d/.test(s)) return true\n if (/[:{}\\[\\],&*#?|<>=!%@`'\"\\\\\\n\\r\\t]/.test(s)) return true\n if (s.startsWith(' ') || s.endsWith(' ')) return true\n return false\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\nimport { toYaml } from '../lib/yaml.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\nexport function registerServices(program: Command): void {\n const services = program\n .command('services')\n .description('Manage and inspect available OAS services')\n\n // services list\n services\n .command('list')\n .description('List all OAS services available in the current group')\n .option('--refresh', 'Bypass local cache and fetch fresh from server')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .option('--no-cache', 'Bypass local cache and fetch fresh from server')\n .action(async (opts: { cache: boolean; refresh?: boolean; format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n if (!opts.cache) {\n process.emitWarning('The --no-cache flag is deprecated. Please use --refresh instead.')\n }\n\n const useCache = opts.cache && !opts.refresh\n let entries = useCache ? await readOASListCache() : null\n\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n\n // Strip authConfig secrets — only expose { type }\n const safe = entries.map(({ authConfig, ...rest }) => ({\n ...rest,\n authConfig: { type: (authConfig as Record<string, unknown>)['type'] ?? rest.authType },\n }))\n\n // Structured JSON envelope mode\n if (isJsonOutput()) {\n outputSuccess(safe)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n\n if (entries.length === 0) {\n console.log('No services registered in this group.')\n return\n }\n\n if (format === 'json') {\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(safe))\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map((e) => e.name.length))\n console.log(`\\n${'SERVICE'.padEnd(nameWidth)} AUTH DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} -------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const auth = e.authType.padEnd(8)\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${auth} ${desc}`)\n }\n console.log()\n })\n\n // services info <name>\n services\n .command('info <name>')\n .description('Show detailed information and available operations for a service')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (name: string, opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(name)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Service not found: ${name}`,\n 'Run: ucli services list to see available services')\n }\n\n const help = await getServiceHelp(entry)\n const { authConfig, ...rest } = entry\n const safe = {\n ...rest,\n authConfig: { type: (authConfig as Record<string, unknown>)['type'] ?? rest.authType },\n operationsHelp: help,\n }\n\n if (isJsonOutput()) {\n outputSuccess(safe)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(safe))\n return\n }\n\n console.log(`\\nService: ${entry.name}`)\n console.log(`Description: ${entry.description || '(none)'}`)\n console.log(`OAS URL: ${entry.remoteUrl}`)\n if (entry.baseEndpoint) console.log(`Base endpoint: ${entry.baseEndpoint}`)\n console.log(`Auth type: ${entry.authType}`)\n console.log(`Cache TTL: ${entry.cacheTtl}s`)\n console.log('\\nAvailable operations:')\n console.log('─'.repeat(60))\n console.log(help)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { runOperation } from '../lib/oas-runner.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { outputError } from '../lib/output.js'\n\nexport function registerRun(program: Command): void {\n program\n .command('run [service] [args...]')\n .description('Execute an operation on a service')\n .option('--service <name>', 'Service name (from `services list`)')\n .option('--operation <id>', 'OperationId to execute')\n .option('--params <json>', 'JSON string of operation parameters')\n .option('--format <fmt>', 'Output format: json | table | yaml', 'json')\n .option('--query <jmespath>', 'Filter response with JMESPath expression')\n .option('--data <json>', 'Request body (JSON string or @filename)')\n .allowUnknownOption(true)\n .action(async (\n serviceArg: string | undefined,\n args: string[],\n opts: { service?: string; operation?: string; params?: string; format?: string; query?: string; data?: string; args?: string[] },\n ) => {\n if (serviceArg && opts.service && serviceArg !== opts.service) {\n outputError(ExitCode.USAGE_ERROR,\n `Conflicting service values: positional \"${serviceArg}\" and --service \"${opts.service}\". Use either the positional argument or --service flag, not both.`)\n }\n\n const service = opts.service ?? serviceArg\n if (!service) {\n outputError(ExitCode.USAGE_ERROR,\n 'Missing service name. Use positional <service> or --service <name>.',\n 'Run: ucli services list to see available services')\n }\n\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n outputError(ExitCode.NOT_FOUND,\n `Unknown service: ${service}`,\n 'Run: ucli services list to see available services')\n }\n\n // Collect extra args (pass-through to openapi2cli)\n const extraArgs = opts.args ?? []\n const operationArgs = [...args, ...extraArgs]\n\n if (opts.operation) {\n operationArgs.unshift(opts.operation)\n }\n\n if (opts.params) {\n let parsed: unknown\n try {\n parsed = JSON.parse(opts.params)\n } catch {\n outputError(ExitCode.USAGE_ERROR,\n 'Invalid --params JSON.',\n 'Example: --params \\'{\"petId\": 1}\\'')\n }\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n for (const [k, v] of Object.entries(parsed as Record<string, unknown>)) {\n if (v === undefined || v === null) continue\n const strVal = typeof v === 'object' ? JSON.stringify(v) : String(v)\n operationArgs.push(`--${k}`, strVal)\n }\n }\n }\n\n if (opts.data) {\n operationArgs.push('--data', opts.data)\n }\n\n const format = opts.format as 'json' | 'table' | 'yaml' | undefined\n const query = opts.query as string | undefined\n\n try {\n await runOperation({\n entry,\n operationArgs,\n ...(format !== undefined ? { format } : {}),\n ...(query !== undefined ? { query } : {}),\n })\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR,\n `Operation failed: ${(err as Error).message}`)\n }\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { writeOASListCache, clearOASListCache, clearOASCache } from '../lib/cache.js'\nimport { isJsonOutput, outputSuccess } from '../lib/output.js'\n\nexport function registerRefresh(program: Command): void {\n program\n .command('refresh')\n .description('Force-refresh the local OAS cache from the server')\n .option('--service <name>', 'Refresh only a specific service')\n .action(async (opts: { service?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n if (!isJsonOutput()) {\n console.log('Refreshing OAS list from server...')\n }\n\n if (opts.service) {\n await clearOASCache(opts.service)\n } else {\n await clearOASListCache()\n }\n\n const entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n\n if (isJsonOutput()) {\n outputSuccess({ refreshed: entries.length })\n return\n }\n\n console.log(`✓ Refreshed ${entries.length} service(s).`)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig, isConfigured } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\nimport { ExitCode } from '../lib/exit-codes.js'\n\nexport function registerHelp(program: Command): void {\n program\n .command('help [service]')\n .description('Show usage guide. Pass a service name for service-specific operations.')\n .action(async (service?: string) => {\n if (!service) {\n printGeneralHelp()\n if (isConfigured()) {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n let entries = await readOASListCache()\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n if (entries.length > 0) {\n console.log('\\nAvailable services:')\n for (const e of entries) {\n console.log(` ${e.name.padEnd(20)} ${e.description}`)\n }\n console.log('\\nTip: Run `ucli help <service>` for service-specific operations.')\n }\n } else {\n console.log('\\nRun `ucli configure --server <url> --token <jwt>` to get started.')\n }\n return\n }\n\n // Service-specific help\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n console.error(`Unknown service: ${service}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(ExitCode.NOT_FOUND)\n }\n\n console.log(`\\n=== ${entry.name} ===`)\n console.log(`${entry.description}`)\n console.log(`\\nOAS spec: ${entry.remoteUrl}`)\n console.log('\\nOperations:')\n console.log('─'.repeat(60))\n\n const help = await getServiceHelp(entry)\n console.log(help)\n\n console.log('\\nExamples:')\n console.log(` ucli run ${entry.name} <operation>`)\n console.log(` ucli run ${entry.name} <operation> --format table`)\n console.log(` ucli run ${entry.name} <operation> --query \"results[*].id\"`)\n console.log(` ucli run ${entry.name} <operation> --data '{\"key\":\"value\"}'`)\n })\n}\n\nfunction printGeneralHelp(): void {\n console.log(`\nucli — OpenAPI & MCP Gateway for AI Agents\n════════════════════════════════════════\n\nSETUP\n ucli configure --server <url> --token <jwt>\n Configure server connection and authentication.\n\nDISCOVERY\n ucli services list\n List all OAS services available in your group.\n\n ucli services info <service>\n Show detailed service info and all available operations.\n\n ucli introspect\n Return complete capability manifest in a single call (JSON).\n Ideal for AI agents: includes services, MCP servers, and command reference.\n\n ucli help [service]\n Show this guide, or service-specific operations.\n\nEXECUTION\n ucli run <service> <operation> [options]\n Execute a service operation.\n\n Options:\n --format json|table|yaml Output format (default: json)\n --query <jmespath> Filter response with JMESPath\n --data <json|@file> Request body for POST/PUT/PATCH\n\nMCP SERVERS\n ucli mcp list\n List all MCP servers in your group.\n\n ucli mcp tools <server>\n List tools available on a MCP server.\n\n ucli mcp run <server> <tool> [key=value ...]\n Call a tool on a MCP server.\n\nMAINTENANCE\n ucli refresh\n Force-refresh the local OAS cache from the server.\n\n ucli doctor\n Check configuration, server connectivity, and token validity.\n\nSHELL COMPLETIONS\n eval \"$(ucli completions bash)\"\n eval \"$(ucli completions zsh)\"\n ucli completions fish | source\n\nGLOBAL FLAGS\n --debug Enable verbose debug logging\n --output json Wrap ALL output in structured JSON envelopes\n (for agent/automation consumption)\n -v, --version Show version number\n\nERRORS\n 401 Unauthorized → Run: ucli configure --server <url> --token <jwt>\n 404 Not Found → Check service name: ucli services list\n 4xx Client Error → Check operation args: ucli services info <service>\n 5xx Server Error → Retry or run: ucli refresh\n\nAI AGENT QUICK START\n 1. ucli introspect # discover everything in one call\n 2. ucli run <svc> <op> [args] # execute operations\n 3. Use --output json globally # get structured { success, data/error } envelopes\n`)\n}\n","/**\n * MCP tool runner using @tronsfey/mcp2cli programmatic API.\n *\n * Auth credentials are injected via McpServerConfig (headers or env) —\n * never passed as CLI arguments (which would be visible in `ps`).\n */\nimport type { McpEntryPublic } from './server-client.js'\n\n/**\n * Resolve a named export from a module that may be CJS-wrapped (exports live\n * under `module.default`) or a plain ESM module (named exports at top level).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction resolve(mod: any, name: string): unknown {\n if (typeof mod[name] === 'function') return mod[name]\n if (mod.default && typeof mod.default[name] === 'function') return mod.default[name]\n throw new Error(`Cannot resolve export \"${name}\" from module`)\n}\n\nasync function getMcp2cli() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const clientMod = await import('@tronsfey/mcp2cli/dist/client/index.js') as any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const runnerMod = await import('@tronsfey/mcp2cli/dist/runner/index.js') as any\n return {\n createMcpClient: resolve(clientMod, 'createMcpClient') as (...args: unknown[]) => Promise<unknown>,\n getTools: resolve(runnerMod, 'getTools') as (...args: unknown[]) => Promise<{ name: string; description?: string }[]>,\n runTool: resolve(runnerMod, 'runTool') as (...args: unknown[]) => Promise<void>,\n }\n}\n\nasync function closeClient(client: unknown): Promise<void> {\n if (typeof (client as { close?: unknown }).close === 'function') {\n await (client as { close: () => Promise<void> }).close()\n }\n}\n\nfunction buildMcpConfig(entry: McpEntryPublic): Record<string, unknown> {\n const base: Record<string, unknown> = { type: entry.transport }\n if (entry.transport === 'http') {\n base.url = entry.serverUrl\n } else {\n base.command = entry.command\n }\n const auth = entry.authConfig\n if (auth.type === 'http_headers') {\n base.headers = auth.headers\n } else if (auth.type === 'env') {\n base.env = auth.env\n }\n return base\n}\n\nexport async function listMcpTools(entry: McpEntryPublic): Promise<{ name: string; description?: string }[]> {\n const { createMcpClient, getTools } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: true })\n return tools\n } finally {\n await closeClient(client)\n }\n}\n\nexport async function runMcpTool(entry: McpEntryPublic, toolName: string, rawArgs: string[]): Promise<void> {\n const { createMcpClient, getTools, runTool } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tool = tools.find((t: any) => t.name === toolName)\n if (!tool) throw new Error(`Tool \"${toolName}\" not found on MCP server \"${entry.name}\"`)\n const normalizedArgs: string[] = []\n for (const arg of rawArgs) {\n if (arg.includes('=') && !arg.startsWith('--')) {\n const idx = arg.indexOf('=')\n const key = arg.slice(0, idx)\n const value = arg.slice(idx + 1)\n normalizedArgs.push(`--${key}`, value)\n } else {\n normalizedArgs.push(arg)\n }\n }\n await runTool(client, tool, normalizedArgs, {})\n } finally {\n await closeClient(client)\n }\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { listMcpTools, runMcpTool } from '../lib/mcp-runner.js'\nimport { toYaml } from '../lib/yaml.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\nexport function registerMcp(program: Command): void {\n const mcp = program\n .command('mcp')\n .description('Interact with MCP servers registered in your group')\n\n // mcp list\n mcp\n .command('list')\n .description('List all MCP servers available in the current group')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n const entries = await client.listMCP()\n\n // Strip authConfig secrets — only expose { type }\n const safe = entries.map(({ authConfig, ...rest }) => ({\n ...rest,\n authConfig: { type: authConfig.type },\n }))\n\n if (isJsonOutput()) {\n outputSuccess(safe)\n return\n }\n\n if (entries.length === 0) {\n console.log('No MCP servers registered in this group.')\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(safe))\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map(e => e.name.length))\n console.log(`\\n${'SERVER'.padEnd(nameWidth)} TRANSPORT DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} --------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${e.transport.padEnd(9)} ${desc}`)\n }\n console.log()\n })\n\n // mcp tools <server>\n mcp\n .command('tools <server>')\n .description('List tools available on a MCP server')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (serverName: string, opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Unknown MCP server: ${serverName}`,\n 'Run: ucli mcp list to see available servers')\n }\n\n let tools\n try {\n tools = await listMcpTools(entry)\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR, `Failed to fetch tools: ${(err as Error).message}`)\n }\n\n if (isJsonOutput()) {\n outputSuccess(tools)\n return\n }\n\n if (tools.length === 0) {\n console.log(`No tools found on MCP server \"${serverName}\".`)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(tools, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(tools))\n return\n }\n\n console.log(`\\nTools on \"${serverName}\":`)\n console.log('─'.repeat(60))\n for (const t of tools) {\n console.log(` ${t.name}`)\n if (t.description) console.log(` ${t.description}`)\n }\n console.log()\n })\n\n // mcp run <server> <tool> [args...]\n mcp\n .command('run <server> <tool> [args...]')\n .description('Call a tool on a MCP server')\n .action(async (serverName: string, toolName: string, args: string[]) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Unknown MCP server: ${serverName}`,\n 'Run: ucli mcp list to see available servers')\n }\n\n try {\n await runMcpTool(entry, toolName, args)\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR, `Tool execution failed: ${(err as Error).message}`)\n }\n })\n}\n","/**\n * Consistent error formatting utility.\n *\n * Provides a unified error output with actionable hints so that both\n * humans and AI agents can quickly understand what went wrong and how\n * to fix it.\n *\n * When `--output json` is active, errors are emitted as structured JSON\n * to stdout (via outputError) so that agents can parse them reliably.\n */\nimport { ExitCode, type ExitCodeValue } from './exit-codes.js'\nimport { isJsonOutput, outputError } from './output.js'\n\nlet debugEnabled = false\n\nexport function setDebugMode(enabled: boolean): void {\n debugEnabled = enabled\n}\n\nexport function isDebugMode(): boolean {\n return debugEnabled\n}\n\n/** Log a debug message (only when --debug is active). */\nexport function debug(message: string): void {\n if (debugEnabled) {\n console.error(`[DEBUG] ${message}`)\n }\n}\n\nexport interface FormattedError {\n code: ExitCodeValue\n message: string\n hint?: string\n}\n\nexport const HINT_MAP: Record<number, string> = {\n [ExitCode.CONFIG_ERROR]:\n 'Run: ucli configure --server <url> --token <jwt>',\n [ExitCode.AUTH_ERROR]:\n 'Your token may be expired or revoked. Run: ucli configure --server <url> --token <jwt>',\n [ExitCode.CONNECTIVITY_ERROR]:\n 'Check that the server URL is correct and the server is running. Run: ucli doctor',\n [ExitCode.NOT_FOUND]:\n 'Check the resource name. Run: ucli services list or ucli mcp list',\n [ExitCode.SERVER_ERROR]:\n 'The server returned an unexpected error. Try again or run: ucli doctor',\n}\n\n/**\n * Print a formatted error to stderr and exit with the given code.\n *\n * When `--output json` is active, emits structured JSON to stdout\n * instead of human-readable text to stderr.\n * When --debug is active, the full stack trace is also printed (text mode only).\n */\nexport function formatError(err: unknown, code?: ExitCodeValue): never {\n const exitCode = code ?? classifyError(err)\n const message = err instanceof Error ? err.message : String(err)\n const hint = HINT_MAP[exitCode]\n\n // In JSON output mode, delegate to the structured envelope emitter\n if (isJsonOutput()) {\n outputError(exitCode, message, hint)\n }\n\n console.error(`\\n✖ Error: ${message}`)\n if (hint) {\n console.error(` Hint: ${hint}`)\n }\n\n if (debugEnabled && err instanceof Error && err.stack) {\n console.error(`\\n${err.stack}`)\n }\n\n process.exit(exitCode)\n}\n\n/** Classify an error into an exit code based on common patterns. */\nexport function classifyError(err: unknown): ExitCodeValue {\n if (!(err instanceof Error)) return ExitCode.GENERAL_ERROR\n\n const msg = err.message.toLowerCase()\n\n if (msg.includes('not configured') || msg.includes('missing')) {\n return ExitCode.CONFIG_ERROR\n }\n if (msg.includes('401') || msg.includes('unauthorized') || msg.includes('authentication')) {\n return ExitCode.AUTH_ERROR\n }\n if (msg.includes('econnrefused') || msg.includes('enotfound') || msg.includes('timeout') || msg.includes('network')) {\n return ExitCode.CONNECTIVITY_ERROR\n }\n if (msg.includes('404') || msg.includes('not found')) {\n return ExitCode.NOT_FOUND\n }\n if (msg.includes('5') && msg.includes('server error')) {\n return ExitCode.SERVER_ERROR\n }\n\n return ExitCode.GENERAL_ERROR\n}\n","/**\n * `ucli doctor` — diagnostic tool for configuration, connectivity, and token validation.\n *\n * Checks:\n * 1. Configuration file exists and is readable\n * 2. Server URL is reachable (GET /api/v1/health)\n * 3. JWT token is accepted (GET /api/v1/oas — expects 200 or empty list)\n */\nimport type { Command } from 'commander'\nimport { isConfigured, getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { debug } from '../lib/errors.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\nimport axios from 'axios'\n\ninterface CheckResult {\n name: string\n ok: boolean\n detail: string\n}\n\nexport function registerDoctor(program: Command): void {\n program\n .command('doctor')\n .description('Check configuration, server connectivity, and token validity')\n .action(async () => {\n const results: CheckResult[] = []\n\n // ── Check 1: Configuration ──────────────────────────────────────\n debug('Checking configuration...')\n if (!isConfigured()) {\n results.push({\n name: 'Configuration',\n ok: false,\n detail: 'Not configured. Run: ucli configure --server <url> --token <jwt>',\n })\n outputError(ExitCode.CONFIG_ERROR,\n 'Not configured',\n 'Run: ucli configure --server <url> --token <jwt>')\n }\n\n let cfg: { serverUrl: string; token: string }\n try {\n cfg = getConfig()\n results.push({\n name: 'Configuration',\n ok: true,\n detail: `Server: ${cfg.serverUrl}`,\n })\n } catch (err) {\n results.push({\n name: 'Configuration',\n ok: false,\n detail: `Failed to read config: ${(err as Error).message}`,\n })\n outputError(ExitCode.CONFIG_ERROR,\n `Failed to read config: ${(err as Error).message}`,\n 'Run: ucli configure --server <url> --token <jwt>')\n }\n\n // ── Check 2: Connectivity (health endpoint, no auth required) ──\n debug(`Checking connectivity to ${cfg.serverUrl}...`)\n try {\n const healthUrl = `${cfg.serverUrl}/api/v1/health`\n const resp = await axios.get(healthUrl, { timeout: 10_000 })\n results.push({\n name: 'Server connectivity',\n ok: resp.status === 200,\n detail: resp.status === 200\n ? `Health endpoint OK (${cfg.serverUrl})`\n : `Unexpected status: ${resp.status}`,\n })\n } catch (err) {\n const msg = axios.isAxiosError(err)\n ? err.code ?? err.message\n : (err as Error).message\n results.push({\n name: 'Server connectivity',\n ok: false,\n detail: `Cannot reach server: ${msg}`,\n })\n }\n\n // ── Check 3: Token validity (authenticated request) ────────────\n debug('Validating JWT token...')\n try {\n const client = new ServerClient(cfg)\n await client.listOAS()\n results.push({\n name: 'Authentication',\n ok: true,\n detail: 'Token accepted by server',\n })\n } catch (err) {\n const msg = (err as Error).message\n results.push({\n name: 'Authentication',\n ok: false,\n detail: `Token rejected: ${msg}`,\n })\n }\n\n const allOk = results.every((r) => r.ok)\n\n if (isJsonOutput()) {\n outputSuccess({\n healthy: allOk,\n checks: results,\n })\n process.exit(allOk ? ExitCode.SUCCESS : ExitCode.GENERAL_ERROR)\n }\n\n printResults(results)\n process.exit(allOk ? ExitCode.SUCCESS : ExitCode.GENERAL_ERROR)\n })\n}\n\nfunction printResults(results: CheckResult[]): void {\n console.log('\\nucli doctor\\n' + '═'.repeat(40))\n for (const r of results) {\n const icon = r.ok ? '✓' : '✖'\n console.log(` ${icon} ${r.name}: ${r.detail}`)\n }\n console.log()\n}\n","/**\n * `ucli completions` — generate shell completion scripts for bash/zsh/fish.\n *\n * Usage:\n * eval \"$(ucli completions bash)\"\n * eval \"$(ucli completions zsh)\"\n * ucli completions fish | source\n */\nimport type { Command } from 'commander'\nimport { ExitCode } from '../lib/exit-codes.js'\n\nexport function registerCompletions(program: Command): void {\n program\n .command('completions <shell>')\n .description('Generate shell completion script (bash | zsh | fish)')\n .action((shell: string) => {\n const normalized = shell.toLowerCase().trim()\n\n switch (normalized) {\n case 'bash':\n console.log(bashCompletions())\n break\n case 'zsh':\n console.log(zshCompletions())\n break\n case 'fish':\n console.log(fishCompletions())\n break\n default:\n console.error(`Unsupported shell: ${shell}. Supported: bash, zsh, fish`)\n process.exit(ExitCode.USAGE_ERROR)\n }\n })\n}\n\nfunction bashCompletions(): string {\n return `# ucli bash completions — eval \"$(ucli completions bash)\"\n_ucli_completions() {\n local cur prev commands\n COMPREPLY=()\n cur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n prev=\"\\${COMP_WORDS[COMP_CWORD-1]}\"\n commands=\"configure services run refresh help mcp doctor completions introspect\"\n\n case \"\\${COMP_WORDS[1]}\" in\n services)\n COMPREPLY=( $(compgen -W \"list info\" -- \"$cur\") )\n return 0\n ;;\n mcp)\n COMPREPLY=( $(compgen -W \"list tools run\" -- \"$cur\") )\n return 0\n ;;\n completions)\n COMPREPLY=( $(compgen -W \"bash zsh fish\" -- \"$cur\") )\n return 0\n ;;\n run|help)\n # dynamic completions would require server calls; skip for now\n return 0\n ;;\n esac\n\n if [ \"$COMP_CWORD\" -eq 1 ]; then\n COMPREPLY=( $(compgen -W \"$commands\" -- \"$cur\") )\n fi\n\n return 0\n}\ncomplete -F _ucli_completions ucli`\n}\n\nfunction zshCompletions(): string {\n return `# ucli zsh completions — eval \"$(ucli completions zsh)\"\n#compdef ucli\n\n_ucli() {\n local -a commands\n commands=(\n 'configure:Configure server URL and authentication token'\n 'services:Manage and inspect available OAS services'\n 'run:Execute an operation on a service'\n 'refresh:Force-refresh the local OAS cache'\n 'help:Show usage guide'\n 'mcp:Interact with MCP servers'\n 'doctor:Check configuration and connectivity'\n 'completions:Generate shell completion script'\n 'introspect:Return complete capability manifest for AI agents'\n )\n\n _arguments -C \\\\\n '1: :->command' \\\\\n '*::arg:->args'\n\n case $state in\n command)\n _describe -t commands 'ucli commands' commands\n ;;\n args)\n case $words[1] in\n services)\n _values 'subcommand' 'list[List all OAS services]' 'info[Show service details]'\n ;;\n mcp)\n _values 'subcommand' 'list[List MCP servers]' 'tools[List tools]' 'run[Call a tool]'\n ;;\n completions)\n _values 'shell' bash zsh fish\n ;;\n esac\n ;;\n esac\n}\n\n_ucli \"$@\"`\n}\n\nfunction fishCompletions(): string {\n return `# ucli fish completions — ucli completions fish | source\ncomplete -c ucli -e\n\n# Top-level commands\ncomplete -c ucli -n __fish_use_subcommand -a configure -d 'Configure server URL and token'\ncomplete -c ucli -n __fish_use_subcommand -a services -d 'Manage OAS services'\ncomplete -c ucli -n __fish_use_subcommand -a run -d 'Execute a service operation'\ncomplete -c ucli -n __fish_use_subcommand -a refresh -d 'Refresh local cache'\ncomplete -c ucli -n __fish_use_subcommand -a help -d 'Show usage guide'\ncomplete -c ucli -n __fish_use_subcommand -a mcp -d 'Interact with MCP servers'\ncomplete -c ucli -n __fish_use_subcommand -a doctor -d 'Check config and connectivity'\ncomplete -c ucli -n __fish_use_subcommand -a completions -d 'Generate shell completions'\n\ncomplete -c ucli -n __fish_use_subcommand -a introspect -d 'Return capability manifest for AI agents'\n\n# services subcommands\ncomplete -c ucli -n '__fish_seen_subcommand_from services' -a list -d 'List services'\ncomplete -c ucli -n '__fish_seen_subcommand_from services' -a info -d 'Show service details'\n\n# mcp subcommands\ncomplete -c ucli -n '__fish_seen_subcommand_from mcp' -a list -d 'List MCP servers'\ncomplete -c ucli -n '__fish_seen_subcommand_from mcp' -a tools -d 'List tools'\ncomplete -c ucli -n '__fish_seen_subcommand_from mcp' -a run -d 'Call a tool'\n\n# completions subcommands\ncomplete -c ucli -n '__fish_seen_subcommand_from completions' -a 'bash zsh fish' -d 'Shell type'`\n}\n","/**\n * `ucli introspect` — unified capability discovery for AI agents.\n *\n * Returns a complete machine-readable manifest of everything the agent\n * can do in a single call: OAS services, MCP servers, and the CLI\n * command reference. This eliminates multiple round-trips that agents\n * would otherwise need (`services list` → `services info` × N →\n * `mcp list` → `mcp tools` × N).\n *\n * Methodology: This follows the \"Observe → Orient → Decide → Act\" (OODA)\n * loop and the ReAct pattern — agents should call `introspect` once at\n * the start of a task to build a mental model before acting.\n */\nimport type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient, type OASEntryPublic, type McpEntryPublic } from '../lib/server-client.js'\nimport { toYaml } from '../lib/yaml.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\n/**\n * Shape of the introspection manifest returned by `ucli introspect`.\n */\nexport interface IntrospectManifest {\n version: string\n services: IntrospectService[]\n mcpServers: IntrospectMcpServer[]\n commands: IntrospectCommand[]\n}\n\nexport interface IntrospectService {\n name: string\n description: string\n authType: string\n remoteUrl: string\n baseEndpoint: string | null\n cacheTtl: number\n}\n\nexport interface IntrospectMcpServer {\n name: string\n description: string\n transport: string\n enabled: boolean\n}\n\nexport interface IntrospectCommand {\n name: string\n description: string\n usage: string\n examples: string[]\n}\n\nexport function registerIntrospect(program: Command): void {\n program\n .command('introspect')\n .description('Return a complete capability manifest for AI agent discovery (services, MCP servers, commands)')\n .option('--format <fmt>', 'Output format: json | yaml', 'json')\n .action(async (opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n // Fetch OAS services and MCP servers in parallel\n let oasEntries: OASEntryPublic[] = []\n let mcpEntries: McpEntryPublic[] = []\n\n try {\n ;[oasEntries, mcpEntries] = await Promise.all([\n client.listOAS(),\n client.listMCP(),\n ])\n } catch (err) {\n const message = (err as Error).message\n outputError(ExitCode.CONNECTIVITY_ERROR, `Failed to fetch capabilities: ${message}`,\n 'Check server connectivity with: ucli doctor')\n }\n\n const manifest: IntrospectManifest = {\n version: '1',\n services: oasEntries.map(toIntrospectService),\n mcpServers: mcpEntries.map(toIntrospectMcpServer),\n commands: getCommandReference(),\n }\n\n const format = (opts.format ?? 'json').toLowerCase()\n\n if (isJsonOutput()) {\n outputSuccess(manifest)\n return\n }\n\n if (format === 'json') {\n console.log(JSON.stringify(manifest, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(manifest))\n return\n }\n\n // Fallback to json\n console.log(JSON.stringify(manifest, null, 2))\n })\n}\n\nfunction toIntrospectService(e: OASEntryPublic): IntrospectService {\n return {\n name: e.name,\n description: e.description,\n authType: e.authType,\n remoteUrl: e.remoteUrl,\n baseEndpoint: e.baseEndpoint,\n cacheTtl: e.cacheTtl,\n }\n}\n\nfunction toIntrospectMcpServer(e: McpEntryPublic): IntrospectMcpServer {\n return {\n name: e.name,\n description: e.description,\n transport: e.transport,\n enabled: e.enabled,\n }\n}\n\n/**\n * Static command reference that agents can use to understand\n * what CLI commands are available and how to use them.\n */\nfunction getCommandReference(): IntrospectCommand[] {\n return [\n {\n name: 'services list',\n description: 'List all OAS services available in the current group',\n usage: 'ucli services list [--format json|table|yaml] [--refresh]',\n examples: [\n 'ucli services list',\n 'ucli services list --format json',\n 'ucli services list --refresh',\n ],\n },\n {\n name: 'services info',\n description: 'Show detailed information and available operations for a service',\n usage: 'ucli services info <name> [--format json|table|yaml]',\n examples: [\n 'ucli services info payments',\n 'ucli services info payments --format json',\n ],\n },\n {\n name: 'run',\n description: 'Execute an operation on an OAS service',\n usage: 'ucli run <service> <operation> [--format json|table|yaml] [--query <jmespath>] [--data <json|@file>] [--params <json>]',\n examples: [\n 'ucli run payments listTransactions',\n 'ucli run payments getTransaction --transactionId txn_123',\n 'ucli run payments createCharge --data \\'{\"amount\": 5000, \"currency\": \"USD\"}\\'',\n 'ucli run inventory listProducts --query \"items[?stock > `0`].name\"',\n ],\n },\n {\n name: 'mcp list',\n description: 'List all MCP servers available in the current group',\n usage: 'ucli mcp list [--format json|table|yaml]',\n examples: [\n 'ucli mcp list',\n 'ucli mcp list --format json',\n ],\n },\n {\n name: 'mcp tools',\n description: 'List tools available on a MCP server',\n usage: 'ucli mcp tools <server> [--format json|table|yaml]',\n examples: [\n 'ucli mcp tools weather',\n 'ucli mcp tools weather --format json',\n ],\n },\n {\n name: 'mcp run',\n description: 'Call a tool on a MCP server',\n usage: 'ucli mcp run <server> <tool> [key=value ...]',\n examples: [\n 'ucli mcp run weather get_forecast location=\"New York\"',\n 'ucli mcp run search web_search query=\"ucli docs\" limit=5',\n ],\n },\n {\n name: 'introspect',\n description: 'Return complete capability manifest (this command)',\n usage: 'ucli introspect [--format json|yaml]',\n examples: [\n 'ucli introspect',\n 'ucli introspect --format yaml',\n ],\n },\n {\n name: 'refresh',\n description: 'Force-refresh the local OAS cache from the server',\n usage: 'ucli refresh [--service <name>]',\n examples: [\n 'ucli refresh',\n 'ucli refresh --service payments',\n ],\n },\n {\n name: 'doctor',\n description: 'Check configuration, server connectivity, and token validity',\n usage: 'ucli doctor',\n examples: ['ucli doctor'],\n },\n {\n name: 'configure',\n description: 'Configure the server URL and authentication token',\n usage: 'ucli configure --server <url> --token <jwt>',\n examples: ['ucli configure --server https://oas.example.com --token eyJ...'],\n },\n ]\n}\n"],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,iBAAAA,sBAAqB;;;ACD9B,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AAC9B,SAAS,WAAW,iBAAiB;;;ACOrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,gBAAgB;AAEnC,IAAM,aAAa;AACnB,IAAM,YAAY;AAClB,IAAM,WAAW;AACjB,IAAM,SAAS;AACf,IAAM,UAAU;AAChB,IAAM,oBAAoB;AAG1B,SAAS,UAAU,MAAsB;AACvC,MAAI,OAAO;AACX,MAAI;AACF,WAAO,SAAS,EAAE;AAAA,EACpB,QAAQ;AAAA,EAER;AACA,QAAM,WAAW,QAAQ,IAA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IAAMC,WAAUC,eAAc,YAAY,GAAG;AAC7C,IAAM,MAAMD,SAAQ,iBAAiB;AAErC,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,MAAM,EACX,YAAY,IAAI,WAAW,EAC3B,QAAQ,IAAI,SAAS,eAAe,EACpC,OAAO,WAAW,8BAA8B,EAChD,OAAO,mBAAmB,qGAAqG,MAAM,EACrI,eAAe,KAAK,EACpB,KAAK,aAAa,CAAC,cAAc,kBAAkB;AAElD,MAAI,MAAM;AACV,SAAO,KAAK;AACV,UAAM,OAAO,IAAI,KAAK;AACtB,QAAI,KAAK,OAAO;AACd,mBAAa,IAAI;AAAA,IACnB;AACA,QAAI,KAAK,UAAU,OAAO,KAAK,WAAW,UAAU;AAClD,YAAM,OAAO,KAAK,OAAO,YAAY;AACrC,UAAI,SAAS,UAAU,SAAS,QAAQ;AACtC,sBAAc,IAAI;AAAA,MACpB;AAAA,IACF;AACA,UAAM,IAAI;AAAA,EACZ;AACF,CAAC;AAEH,kBAAkB,OAAO;AACzB,iBAAiB,OAAO;AACxB,YAAY,OAAO;AACnB,gBAAgB,OAAO;AACvB,YAAY,OAAO;AACnB,eAAe,OAAO;AACtB,oBAAoB,OAAO;AAC3B,mBAAmB,OAAO;AAC1B,aAAa,OAAO;AAEpB,QAAQ,MAAM,QAAQ,IAAI;","names":["createRequire","program","join","join","join","dirname","require","pkg","resolve","program","program","program","program","cfg","client","program","axios","program","program","program","require","createRequire"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/lib/config-encryption.ts","../src/lib/server-client.ts","../src/lib/exit-codes.ts","../src/lib/output.ts","../src/commands/configure.ts","../src/lib/cache.ts","../src/lib/oas-runner.ts","../src/lib/yaml.ts","../src/commands/services.ts","../src/commands/run.ts","../src/commands/refresh.ts","../src/commands/help-cmd.ts","../src/lib/mcp-runner.ts","../src/commands/mcp.ts","../src/lib/errors.ts","../src/commands/doctor.ts","../src/commands/completions.ts","../src/commands/introspect.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { createRequire } from 'node:module'\nimport { registerConfigure } from './commands/configure.js'\nimport { registerServices } from './commands/services.js'\nimport { registerRun } from './commands/run.js'\nimport { registerRefresh } from './commands/refresh.js'\nimport { registerHelp } from './commands/help-cmd.js'\nimport { registerMcp } from './commands/mcp.js'\nimport { registerDoctor } from './commands/doctor.js'\nimport { registerCompletions } from './commands/completions.js'\nimport { registerIntrospect } from './commands/introspect.js'\nimport { setDebugMode } from './lib/errors.js'\nimport { setOutputMode, type OutputMode } from './lib/output.js'\n\nconst require = createRequire(import.meta.url)\nconst pkg = require('../package.json') as { version: string; description: string }\n\nconst program = new Command()\n\nprogram\n .name('ucli')\n .description(pkg.description)\n .version(pkg.version, '-v, --version')\n .option('--debug', 'Enable verbose debug logging')\n .option('--output <mode>', 'Output mode: text | json (json wraps every result in a structured envelope for agent consumption)', 'text')\n .addHelpCommand(false) // we provide our own help command\n .hook('preAction', (_thisCommand, actionCommand) => {\n // Walk up to root to find the --debug and --output flags\n let cmd = actionCommand\n while (cmd) {\n const opts = cmd.opts() as Record<string, unknown>\n if (opts.debug) {\n setDebugMode(true)\n }\n if (opts.output && typeof opts.output === 'string') {\n const mode = opts.output.toLowerCase() as OutputMode\n if (mode === 'json' || mode === 'text') {\n setOutputMode(mode)\n }\n }\n cmd = cmd.parent as Command\n }\n })\n\nregisterConfigure(program)\nregisterServices(program)\nregisterRun(program)\nregisterRefresh(program)\nregisterMcp(program)\nregisterDoctor(program)\nregisterCompletions(program)\nregisterIntrospect(program)\nregisterHelp(program)\n\nprogram.parse(process.argv)\n","import Conf from 'conf'\nimport { homedir } from 'node:os'\nimport { join, dirname } from 'node:path'\nimport { chmodSync, mkdirSync } from 'node:fs'\nimport { encryptValue, decryptValue, isEncrypted } from './lib/config-encryption.js'\n\nexport interface CLIConfig {\n serverUrl: string\n token: string\n}\n\nconst conf = new Conf<CLIConfig>({\n projectName: 'ucli',\n schema: {\n serverUrl: { type: 'string' },\n token: { type: 'string' },\n },\n})\n\nexport const cacheDir = join(homedir(), '.cache', 'ucli')\n\n/** Ensure the config file and its directory have restrictive permissions. */\nfunction hardenConfigPermissions(): void {\n try {\n const configPath = conf.path\n const configDir = dirname(configPath)\n mkdirSync(configDir, { recursive: true, mode: 0o700 })\n chmodSync(configDir, 0o700)\n chmodSync(configPath, 0o600)\n } catch {\n // Permission enforcement may fail on some platforms (e.g., Windows)\n console.warn('Warning: Could not enforce restrictive file permissions on config. Token is encrypted but file permissions may be permissive.')\n }\n}\n\nexport function getConfig(): CLIConfig {\n const serverUrl = conf.get('serverUrl')\n const rawToken = conf.get('token')\n\n if (!serverUrl || !rawToken) {\n console.error('ucli is not configured. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n const token = decryptValue(rawToken)\n\n // Auto-migrate: re-encrypt legacy plaintext tokens on read\n if (!isEncrypted(rawToken)) {\n conf.set('token', encryptValue(token))\n hardenConfigPermissions()\n }\n\n return { serverUrl, token }\n}\n\nexport function saveConfig(cfg: CLIConfig): void {\n conf.set('serverUrl', cfg.serverUrl)\n conf.set('token', encryptValue(cfg.token))\n hardenConfigPermissions()\n}\n\nexport function isConfigured(): boolean {\n return Boolean(conf.get('serverUrl') && conf.get('token'))\n}\n","/**\n * Config value encryption utilities.\n *\n * Encrypts sensitive config values (e.g., JWT tokens) at rest using AES-256-GCM\n * with a machine-specific derived key. This ensures credentials are never stored\n * in plaintext on disk.\n *\n * Key derivation: PBKDF2(username + hostname, random-salt, 100k iterations, SHA-512)\n * Format: \"enc:v1:<base64(salt + iv + authTag + ciphertext)>\"\n */\nimport {\n createCipheriv,\n createDecipheriv,\n randomBytes,\n pbkdf2Sync,\n} from 'node:crypto'\nimport { hostname, userInfo } from 'node:os'\n\nconst ENC_PREFIX = 'enc:v1:'\nconst ALGORITHM = 'aes-256-gcm'\nconst SALT_LEN = 32\nconst IV_LEN = 12\nconst TAG_LEN = 16\nconst PBKDF2_ITERATIONS = 100_000\n\n/** Derive a 256-bit key from machine-specific identity + per-value random salt. */\nfunction deriveKey(salt: Buffer): Buffer {\n let user = 'default'\n try {\n user = userInfo().username\n } catch {\n // userInfo() may throw on some platforms (e.g., certain containers)\n }\n const material = `ucli:${user}@${hostname()}`\n return pbkdf2Sync(material, salt, PBKDF2_ITERATIONS, 32, 'sha512')\n}\n\n/** Encrypt a plaintext string. Returns prefixed ciphertext string. */\nexport function encryptValue(plaintext: string): string {\n const salt = randomBytes(SALT_LEN)\n const key = deriveKey(salt)\n const iv = randomBytes(IV_LEN)\n const cipher = createCipheriv(ALGORITHM, key, iv)\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()])\n const tag = cipher.getAuthTag()\n const packed = Buffer.concat([salt, iv, tag, encrypted])\n return ENC_PREFIX + packed.toString('base64')\n}\n\n/**\n * Decrypt a stored value. If the value has the encryption prefix, it is\n * decrypted; otherwise it is returned as-is for backward compatibility\n * with legacy plaintext configs.\n */\nexport function decryptValue(stored: string): string {\n if (!stored.startsWith(ENC_PREFIX)) {\n return stored\n }\n const packed = Buffer.from(stored.slice(ENC_PREFIX.length), 'base64')\n const salt = packed.subarray(0, SALT_LEN)\n const iv = packed.subarray(SALT_LEN, SALT_LEN + IV_LEN)\n const tag = packed.subarray(SALT_LEN + IV_LEN, SALT_LEN + IV_LEN + TAG_LEN)\n const encrypted = packed.subarray(SALT_LEN + IV_LEN + TAG_LEN)\n const key = deriveKey(salt)\n const decipher = createDecipheriv(ALGORITHM, key, iv)\n decipher.setAuthTag(tag)\n return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8')\n}\n\n/** Check whether a stored value is encrypted (has the encryption prefix). */\nexport function isEncrypted(value: string): boolean {\n return value.startsWith(ENC_PREFIX)\n}\n","/**\n * HTTP client for the ucli-server API.\n * Attaches group JWT and handles common error cases.\n */\nimport axios, { type AxiosInstance } from 'axios'\nimport type { CLIConfig } from '../config.js'\n\nexport interface OASEntryPublic {\n id: string\n name: string\n description: string\n remoteUrl: string\n baseEndpoint: string | null\n authType: 'bearer' | 'api_key' | 'basic' | 'oauth2_cc' | 'none'\n authConfig: Record<string, unknown>\n cacheTtl: number\n}\n\nexport type McpAuthConfig =\n | { type: 'none' }\n | { type: 'http_headers'; headers: Record<string, string> }\n | { type: 'env'; env: Record<string, string> }\n\nexport interface McpEntryPublic {\n id: string\n groupId: string\n name: string\n description: string\n transport: 'http' | 'stdio'\n serverUrl: string | null\n command: string | null\n authConfig: McpAuthConfig\n enabled: boolean\n}\n\nexport class ServerClient {\n private http: AxiosInstance\n\n constructor(cfg: CLIConfig) {\n this.http = axios.create({\n baseURL: cfg.serverUrl.replace(/\\/$/, ''),\n headers: {\n Authorization: `Bearer ${cfg.token}`,\n 'Content-Type': 'application/json',\n },\n timeout: 15_000,\n })\n\n this.http.interceptors.response.use(\n (r) => r,\n (err: unknown) => {\n if (axios.isAxiosError(err)) {\n const status = err.response?.status\n const message = (err.response?.data as { message?: string })?.message ?? err.message\n\n if (status === 401) {\n console.error('Authentication failed. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n throw new Error(`Server error ${status ?? 'unknown'}: ${message}`)\n }\n throw err\n },\n )\n }\n\n async listOAS(): Promise<OASEntryPublic[]> {\n const { data } = await this.http.get<OASEntryPublic[]>('/api/v1/oas')\n return data\n }\n\n async getOAS(name: string): Promise<OASEntryPublic> {\n const { data } = await this.http.get<OASEntryPublic>(`/api/v1/oas/${encodeURIComponent(name)}`)\n return data\n }\n\n async listMCP(): Promise<McpEntryPublic[]> {\n const { data } = await this.http.get<McpEntryPublic[]>('/api/v1/mcp')\n return data\n }\n\n async getMCP(name: string): Promise<McpEntryPublic> {\n const { data } = await this.http.get<McpEntryPublic>(`/api/v1/mcp/${encodeURIComponent(name)}`)\n return data\n }\n}\n","/**\n * Structured exit codes for automation and scripting.\n *\n * Convention:\n * 0 — success\n * 1 — general / unknown error\n * 2 — usage / argument error\n * 3 — configuration error (missing or invalid config)\n * 4 — authentication error (invalid / expired token)\n * 5 — connectivity error (server unreachable)\n * 6 — not-found error (service / resource doesn't exist)\n * 7 — server error (5xx from upstream)\n */\n\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n USAGE_ERROR: 2,\n CONFIG_ERROR: 3,\n AUTH_ERROR: 4,\n CONNECTIVITY_ERROR: 5,\n NOT_FOUND: 6,\n SERVER_ERROR: 7,\n} as const\n\nexport type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode]\n","/**\n * Structured output module for AI agent consumption.\n *\n * When `--output json` is active globally, every command emits a single\n * JSON envelope to stdout so that agents can reliably parse both success\n * and error results without scraping human-readable text.\n *\n * Envelope shapes:\n * Success → { \"success\": true, \"data\": <any> }\n * Error → { \"success\": false, \"error\": { \"code\": <number>, \"message\": <string>, \"hint\"?: <string> } }\n */\n\nexport type OutputMode = 'text' | 'json'\n\nlet currentMode: OutputMode = 'text'\n\n/** Set the global output mode. Called once from index.ts preAction hook. */\nexport function setOutputMode(mode: OutputMode): void {\n currentMode = mode\n}\n\n/** Get the current output mode. */\nexport function getOutputMode(): OutputMode {\n return currentMode\n}\n\n/** Returns true when structured JSON output is active. */\nexport function isJsonOutput(): boolean {\n return currentMode === 'json'\n}\n\n/**\n * Emit a successful result.\n *\n * In JSON mode the data is wrapped in `{ success: true, data }`.\n * In text mode this is a no-op — the caller is responsible for\n * printing human-readable output itself.\n */\nexport function outputSuccess(data: unknown): void {\n if (currentMode === 'json') {\n console.log(JSON.stringify({ success: true, data }, null, 2))\n }\n}\n\n/**\n * Emit a structured error and exit.\n *\n * In JSON mode the error is wrapped in `{ success: false, error: { code, message, hint? } }`.\n * In text mode falls through to the existing `formatError` path.\n */\nexport function outputError(\n code: number,\n message: string,\n hint?: string,\n): never {\n if (currentMode === 'json') {\n const envelope: Record<string, unknown> = {\n success: false,\n error: { code, message, ...(hint ? { hint } : {}) },\n }\n console.log(JSON.stringify(envelope, null, 2))\n process.exit(code)\n }\n\n // Text mode — re-use existing stderr formatting\n console.error(`\\n✖ Error: ${message}`)\n if (hint) console.error(` Hint: ${hint}`)\n process.exit(code)\n}\n","import type { Command } from 'commander'\nimport { saveConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\nexport function registerConfigure(program: Command): void {\n program\n .command('configure')\n .description('Configure the OAS Gateway server URL and authentication token')\n .requiredOption('--server <url>', 'OAS Gateway server URL (e.g. https://oas.example.com)')\n .requiredOption('--token <jwt>', 'Group JWT token issued by the server admin')\n .action(async (opts: { server: string; token: string }) => {\n const serverUrl = opts.server.replace(/\\/$/, '')\n const token = opts.token\n\n // Validate connectivity before saving\n if (!isJsonOutput()) {\n console.log(`Connecting to ${serverUrl}...`)\n }\n const client = new ServerClient({ serverUrl, token })\n\n try {\n await client.listOAS()\n saveConfig({ serverUrl, token })\n\n if (isJsonOutput()) {\n outputSuccess({ serverUrl, configured: true })\n return\n }\n\n console.log('✓ Configuration saved successfully.')\n console.log(` Server: ${serverUrl}`)\n console.log(` Token: ${token.slice(0, 20)}...`)\n } catch (err) {\n outputError(ExitCode.CONNECTIVITY_ERROR,\n `Connection failed: ${(err as Error).message}`,\n 'Check the server URL and token')\n }\n })\n}\n","/**\n * Local file cache for OAS entries.\n * Stored at ~/.cache/oas-cli/<name>.json with TTL metadata.\n *\n * Security: authConfig credential values are stripped before writing.\n * Only { type } is persisted — full secrets are never written to disk.\n */\nimport { readFile, writeFile, mkdir, unlink, chmod } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { cacheDir } from '../config.js'\nimport type { OASEntryPublic } from './server-client.js'\n\ninterface CacheFile {\n entries: OASEntryPublic[]\n fetchedAt: number // ms timestamp\n ttlSec: number // cache duration\n}\n\nconst LIST_CACHE_FILE = join(cacheDir, 'oas-list.json')\n\nasync function ensureCacheDir(): Promise<void> {\n await mkdir(cacheDir, { recursive: true, mode: 0o700 })\n}\n\n/** Strip credential secrets from authConfig — only persist { type }. */\nfunction redactEntries(entries: OASEntryPublic[]): OASEntryPublic[] {\n return entries.map((e) => ({\n ...e,\n authConfig: { type: (e.authConfig as Record<string, unknown>)['type'] ?? e.authType },\n }))\n}\n\nexport async function readOASListCache(): Promise<OASEntryPublic[] | null> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const age = (Date.now() - cached.fetchedAt) / 1000\n if (cached.ttlSec === 0 || age > cached.ttlSec) return null // expired\n return cached.entries\n } catch {\n return null // not found or parse error\n }\n}\n\nexport async function writeOASListCache(entries: OASEntryPublic[], ttlSec: number): Promise<void> {\n await ensureCacheDir()\n const cached: CacheFile = { entries: redactEntries(entries), fetchedAt: Date.now(), ttlSec }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(cached, null, 2), { encoding: 'utf8', mode: 0o600 })\n await chmod(LIST_CACHE_FILE, 0o600)\n}\n\nexport async function clearOASListCache(): Promise<void> {\n try {\n await unlink(LIST_CACHE_FILE)\n } catch {\n // ignore if not found\n }\n}\n\nexport async function clearOASCache(name: string): Promise<void> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const entries = Array.isArray(cached.entries) ? cached.entries.filter((e) => e.name !== name) : []\n if (entries.length === 0) {\n await clearOASListCache()\n return\n }\n const next: CacheFile = {\n entries,\n fetchedAt: cached.fetchedAt ?? Date.now(),\n ttlSec: cached.ttlSec ?? 0,\n }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(next, null, 2), { encoding: 'utf8', mode: 0o600 })\n } catch {\n await clearOASListCache()\n }\n}\n","/**\n * Bridge between oas-cli and @tronsfey/openapi2cli run mode.\n *\n * Spawns openapi2cli as a child process, injecting auth config\n * as environment variables (never exposed to the agent's shell).\n */\nimport { spawn } from 'node:child_process'\nimport { createRequire } from 'node:module'\nimport { join, dirname } from 'node:path'\nimport type { OASEntryPublic } from './server-client.js'\n\nconst require = createRequire(import.meta.url)\n\nfunction resolveOpenapi2CliBin(): string {\n try {\n const pkgPath = require.resolve('@tronsfey/openapi2cli/package.json')\n const pkgDir = dirname(pkgPath)\n // @tronsfey/openapi2cli exposes its binary; find it\n const pkg = require('@tronsfey/openapi2cli/package.json') as { bin?: Record<string, string> }\n const binEntry = pkg.bin?.['openapi2cli'] ?? 'bin/openapi2cli.js'\n return join(pkgDir, binEntry)\n } catch {\n throw new Error(\n '@tronsfey/openapi2cli is not installed. Run: pnpm add @tronsfey/openapi2cli in packages/cli',\n )\n }\n}\n\nexport interface RunOptions {\n entry: OASEntryPublic\n /** Operation command args (e.g. ['listPets', '--limit', '10']) */\n operationArgs: string[]\n format?: 'json' | 'table' | 'yaml'\n query?: string\n /** Agent-friendly mode: wrap all output in structured JSON envelopes */\n machine?: boolean\n /** Preview the HTTP request without executing it (implies --machine) */\n dryRun?: boolean\n}\n\n/**\n * Build auth environment variables for injection into child process.\n * The calling shell (and thus the AI agent) never sees these values.\n */\nfunction buildAuthEnv(entry: OASEntryPublic): Record<string, string> {\n const cfg = entry.authConfig\n const prefix = entry.name.toUpperCase().replace(/[^A-Z0-9]/g, '_')\n\n switch (cfg['type']) {\n case 'bearer':\n return { [`${prefix}_TOKEN`]: cfg['token'] as string }\n\n case 'api_key':\n return { [`${prefix}_API_KEY`]: cfg['key'] as string }\n\n case 'basic':\n return { [`${prefix}_CREDENTIALS`]: `${cfg['username']}:${cfg['password']}` }\n\n case 'oauth2_cc':\n return {\n [`${prefix}_CLIENT_ID`]: cfg['clientId'] as string,\n [`${prefix}_CLIENT_SECRET`]: cfg['clientSecret'] as string,\n [`${prefix}_SCOPES`]: (cfg['scopes'] as string[]).join(' '),\n }\n\n default:\n return {}\n }\n}\n\n/**\n * Environment variable allowlist for subprocess execution.\n * Only these variables (when present in the parent) are forwarded to the\n * child process. This prevents leakage of secrets such as cloud credentials,\n * encryption keys, or database passwords that may be in the parent env.\n */\nconst SAFE_ENV_KEYS: readonly string[] = [\n // System essentials\n 'PATH', 'HOME', 'USER', 'LOGNAME', 'SHELL', 'TMPDIR', 'TMP', 'TEMP',\n // Terminal / display\n 'TERM', 'COLORTERM', 'NO_COLOR', 'FORCE_COLOR', 'LANG', 'LC_ALL',\n 'LC_CTYPE', 'LC_MESSAGES', 'LC_COLLATE',\n // Node.js\n 'NODE_ENV', 'NODE_PATH', 'NODE_OPTIONS', 'NODE_EXTRA_CA_CERTS',\n // Network proxy (required for tools behind corporate proxies)\n 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY',\n 'http_proxy', 'https_proxy', 'no_proxy',\n // OS-specific\n 'SYSTEMROOT', 'COMSPEC', 'APPDATA', 'LOCALAPPDATA', 'PROGRAMFILES',\n 'XDG_RUNTIME_DIR', 'XDG_CONFIG_HOME', 'XDG_CACHE_HOME', 'XDG_DATA_HOME',\n]\n\nfunction buildSafeEnv(authEnv: Record<string, string>): Record<string, string> {\n const safe: Record<string, string> = {}\n for (const key of SAFE_ENV_KEYS) {\n if (process.env[key] !== undefined) {\n safe[key] = process.env[key]!\n }\n }\n return { ...safe, ...authEnv }\n}\n\nexport async function runOperation(opts: RunOptions): Promise<void> {\n const bin = resolveOpenapi2CliBin()\n const { entry, operationArgs, format, query, machine, dryRun } = opts\n\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n ...(entry.baseEndpoint ? ['--endpoint', entry.baseEndpoint] : []),\n ...(machine ? ['--machine'] : []),\n ...(dryRun ? ['--dry-run'] : []),\n ...(format ? ['--format', format] : []),\n ...(query ? ['--query', query] : []),\n ...operationArgs,\n ]\n\n const authEnv = buildAuthEnv(entry)\n\n await new Promise<void>((resolve, reject) => {\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: 'inherit',\n env: buildSafeEnv(authEnv),\n })\n\n child.on('close', (code) => {\n if (code === 0) resolve()\n else reject(new Error(`openapi2cli exited with code ${code}`))\n })\n child.on('error', reject)\n })\n}\n\n/**\n * Get list of available operations for a service by running `--help`.\n * Returns the raw help text from openapi2cli.\n */\nexport async function getServiceHelp(entry: OASEntryPublic): Promise<string> {\n const bin = resolveOpenapi2CliBin()\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n '--help',\n ]\n\n return new Promise<string>((resolve, reject) => {\n let output = ''\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n child.stdout?.on('data', (d: Buffer) => { output += d.toString() })\n child.stderr?.on('data', (d: Buffer) => { output += d.toString() })\n child.on('close', () => resolve(output))\n child.on('error', reject)\n })\n}\n","/**\n * YAML output format support.\n *\n * A lightweight YAML serialiser that covers the data shapes produced by\n * ucli commands (plain objects, arrays, strings, numbers, booleans, null).\n * No external dependencies — we don't need a full YAML parser, only output.\n */\n\n/** Convert a JSON-serialisable value to a YAML string. */\nexport function toYaml(value: unknown, indent = 0): string {\n if (value === null || value === undefined) {\n return 'null'\n }\n\n if (typeof value === 'boolean') {\n return value ? 'true' : 'false'\n }\n\n if (typeof value === 'number') {\n return String(value)\n }\n\n if (typeof value === 'string') {\n // Use quotes if the string contains special YAML characters\n if (needsQuoting(value)) {\n return JSON.stringify(value)\n }\n return value\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]'\n const prefix = ' '.repeat(indent)\n return value\n .map((item) => {\n const serialised = toYaml(item, indent + 2)\n if (typeof item === 'object' && item !== null && !Array.isArray(item)) {\n // Object items: put the first key on the same line as the dash\n const firstNewline = serialised.indexOf('\\n')\n if (firstNewline === -1) {\n return `${prefix}- ${serialised.trimStart()}`\n }\n const firstLine = serialised.slice(0, firstNewline)\n const rest = serialised.slice(firstNewline + 1)\n return `${prefix}- ${firstLine.trimStart()}\\n${rest}`\n }\n return `${prefix}- ${serialised}`\n })\n .join('\\n')\n }\n\n if (typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n if (entries.length === 0) return '{}'\n const prefix = ' '.repeat(indent)\n return entries\n .map(([key, val]) => {\n if (val === null || val === undefined) {\n return `${prefix}${key}: null`\n }\n if (typeof val === 'object') {\n const nested = toYaml(val, indent + 2)\n return `${prefix}${key}:\\n${nested}`\n }\n return `${prefix}${key}: ${toYaml(val, indent)}`\n })\n .join('\\n')\n }\n\n return String(value)\n}\n\nfunction needsQuoting(s: string): boolean {\n if (s === '') return true\n if (s === 'true' || s === 'false' || s === 'null') return true\n if (/^\\d/.test(s)) return true\n if (/[:{}\\[\\],&*#?|<>=!%@`'\"\\\\\\n\\r\\t]/.test(s)) return true\n if (s.startsWith(' ') || s.endsWith(' ')) return true\n return false\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\nimport { toYaml } from '../lib/yaml.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\nexport function registerServices(program: Command): void {\n const services = program\n .command('services')\n .description('Manage and inspect available OAS services')\n\n // services list\n services\n .command('list')\n .description('List all OAS services available in the current group')\n .option('--refresh', 'Bypass local cache and fetch fresh from server')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .option('--no-cache', 'Bypass local cache and fetch fresh from server')\n .action(async (opts: { cache: boolean; refresh?: boolean; format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n if (!opts.cache) {\n process.emitWarning('The --no-cache flag is deprecated. Please use --refresh instead.')\n }\n\n const useCache = opts.cache && !opts.refresh\n let entries = useCache ? await readOASListCache() : null\n\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n\n // Strip authConfig secrets — only expose { type }\n const safe = entries.map(({ authConfig, ...rest }) => ({\n ...rest,\n authConfig: { type: (authConfig as Record<string, unknown>)['type'] ?? rest.authType },\n }))\n\n // Structured JSON envelope mode\n if (isJsonOutput()) {\n outputSuccess(safe)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n\n if (entries.length === 0) {\n console.log('No services registered in this group.')\n return\n }\n\n if (format === 'json') {\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(safe))\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map((e) => e.name.length))\n console.log(`\\n${'SERVICE'.padEnd(nameWidth)} AUTH DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} -------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const auth = e.authType.padEnd(8)\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${auth} ${desc}`)\n }\n console.log()\n })\n\n // services info <name>\n services\n .command('info <name>')\n .description('Show detailed information and available operations for a service')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (name: string, opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(name)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Service not found: ${name}`,\n 'Run: ucli services list to see available services')\n }\n\n const help = await getServiceHelp(entry)\n const { authConfig, ...rest } = entry\n const safe = {\n ...rest,\n authConfig: { type: (authConfig as Record<string, unknown>)['type'] ?? rest.authType },\n operationsHelp: help,\n }\n\n if (isJsonOutput()) {\n outputSuccess(safe)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(safe))\n return\n }\n\n console.log(`\\nService: ${entry.name}`)\n console.log(`Description: ${entry.description || '(none)'}`)\n console.log(`OAS URL: ${entry.remoteUrl}`)\n if (entry.baseEndpoint) console.log(`Base endpoint: ${entry.baseEndpoint}`)\n console.log(`Auth type: ${entry.authType}`)\n console.log(`Cache TTL: ${entry.cacheTtl}s`)\n console.log('\\nAvailable operations:')\n console.log('─'.repeat(60))\n console.log(help)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { runOperation } from '../lib/oas-runner.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { outputError } from '../lib/output.js'\n\nexport function registerRun(program: Command): void {\n program\n .command('run [service] [args...]')\n .description('Execute an operation on a service')\n .option('--service <name>', 'Service name (from `services list`)')\n .option('--operation <id>', 'OperationId to execute')\n .option('--params <json>', 'JSON string of operation parameters')\n .option('--format <fmt>', 'Output format: json | table | yaml', 'json')\n .option('--query <jmespath>', 'Filter response with JMESPath expression')\n .option('--data <json>', 'Request body (JSON string or @filename)')\n .option('--machine', 'Agent-friendly mode: structured JSON envelope output')\n .option('--dry-run', 'Preview the HTTP request without executing (implies --machine)')\n .allowUnknownOption(true)\n .action(async (\n serviceArg: string | undefined,\n args: string[],\n opts: { service?: string; operation?: string; params?: string; format?: string; query?: string; data?: string; machine?: boolean; dryRun?: boolean; args?: string[] },\n ) => {\n if (serviceArg && opts.service && serviceArg !== opts.service) {\n outputError(ExitCode.USAGE_ERROR,\n `Conflicting service values: positional \"${serviceArg}\" and --service \"${opts.service}\". Use either the positional argument or --service flag, not both.`)\n }\n\n const service = opts.service ?? serviceArg\n if (!service) {\n outputError(ExitCode.USAGE_ERROR,\n 'Missing service name. Use positional <service> or --service <name>.',\n 'Run: ucli services list to see available services')\n }\n\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n outputError(ExitCode.NOT_FOUND,\n `Unknown service: ${service}`,\n 'Run: ucli services list to see available services')\n }\n\n // Collect extra args (pass-through to openapi2cli)\n const extraArgs = opts.args ?? []\n const operationArgs = [...args, ...extraArgs]\n\n if (opts.operation) {\n operationArgs.unshift(opts.operation)\n }\n\n if (opts.params) {\n let parsed: unknown\n try {\n parsed = JSON.parse(opts.params)\n } catch {\n outputError(ExitCode.USAGE_ERROR,\n 'Invalid --params JSON.',\n 'Example: --params \\'{\"petId\": 1}\\'')\n }\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n for (const [k, v] of Object.entries(parsed as Record<string, unknown>)) {\n if (v === undefined || v === null) continue\n const strVal = typeof v === 'object' ? JSON.stringify(v) : String(v)\n operationArgs.push(`--${k}`, strVal)\n }\n }\n }\n\n if (opts.data) {\n operationArgs.push('--data', opts.data)\n }\n\n const format = opts.format as 'json' | 'table' | 'yaml' | undefined\n const query = opts.query as string | undefined\n const machine = opts.machine ?? false\n const dryRun = opts.dryRun ?? false\n\n try {\n await runOperation({\n entry,\n operationArgs,\n ...(format !== undefined ? { format } : {}),\n ...(query !== undefined ? { query } : {}),\n ...(machine ? { machine } : {}),\n ...(dryRun ? { dryRun } : {}),\n })\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR,\n `Operation failed: ${(err as Error).message}`)\n }\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { writeOASListCache, clearOASListCache, clearOASCache } from '../lib/cache.js'\nimport { isJsonOutput, outputSuccess } from '../lib/output.js'\n\nexport function registerRefresh(program: Command): void {\n program\n .command('refresh')\n .description('Force-refresh the local OAS cache from the server')\n .option('--service <name>', 'Refresh only a specific service')\n .action(async (opts: { service?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n if (!isJsonOutput()) {\n console.log('Refreshing OAS list from server...')\n }\n\n if (opts.service) {\n await clearOASCache(opts.service)\n } else {\n await clearOASListCache()\n }\n\n const entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n\n if (isJsonOutput()) {\n outputSuccess({ refreshed: entries.length })\n return\n }\n\n console.log(`✓ Refreshed ${entries.length} service(s).`)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig, isConfigured } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\nimport { ExitCode } from '../lib/exit-codes.js'\n\nexport function registerHelp(program: Command): void {\n program\n .command('help [service]')\n .description('Show usage guide. Pass a service name for service-specific operations.')\n .action(async (service?: string) => {\n if (!service) {\n printGeneralHelp()\n if (isConfigured()) {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n let entries = await readOASListCache()\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n if (entries.length > 0) {\n console.log('\\nAvailable services:')\n for (const e of entries) {\n console.log(` ${e.name.padEnd(20)} ${e.description}`)\n }\n console.log('\\nTip: Run `ucli help <service>` for service-specific operations.')\n }\n } else {\n console.log('\\nRun `ucli configure --server <url> --token <jwt>` to get started.')\n }\n return\n }\n\n // Service-specific help\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n console.error(`Unknown service: ${service}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(ExitCode.NOT_FOUND)\n }\n\n console.log(`\\n=== ${entry.name} ===`)\n console.log(`${entry.description}`)\n console.log(`\\nOAS spec: ${entry.remoteUrl}`)\n console.log('\\nOperations:')\n console.log('─'.repeat(60))\n\n const help = await getServiceHelp(entry)\n console.log(help)\n\n console.log('\\nExamples:')\n console.log(` ucli run ${entry.name} <operation>`)\n console.log(` ucli run ${entry.name} <operation> --format table`)\n console.log(` ucli run ${entry.name} <operation> --query \"results[*].id\"`)\n console.log(` ucli run ${entry.name} <operation> --data '{\"key\":\"value\"}'`)\n })\n}\n\nfunction printGeneralHelp(): void {\n console.log(`\nucli — OpenAPI & MCP Gateway for AI Agents\n════════════════════════════════════════\n\nSETUP\n ucli configure --server <url> --token <jwt>\n Configure server connection and authentication.\n\nDISCOVERY\n ucli services list\n List all OAS services available in your group.\n\n ucli services info <service>\n Show detailed service info and all available operations.\n\n ucli introspect\n Return complete capability manifest in a single call (JSON).\n Ideal for AI agents: includes services, MCP servers, and command reference.\n\n ucli help [service]\n Show this guide, or service-specific operations.\n\nEXECUTION\n ucli run <service> <operation> [options]\n Execute a service operation.\n\n Options:\n --format json|table|yaml Output format (default: json)\n --query <jmespath> Filter response with JMESPath\n --data <json|@file> Request body for POST/PUT/PATCH\n\nMCP SERVERS\n ucli mcp list\n List all MCP servers in your group.\n\n ucli mcp tools <server>\n List tools available on a MCP server.\n\n ucli mcp run <server> <tool> [key=value ...]\n Call a tool on a MCP server.\n\nMAINTENANCE\n ucli refresh\n Force-refresh the local OAS cache from the server.\n\n ucli doctor\n Check configuration, server connectivity, and token validity.\n\nSHELL COMPLETIONS\n eval \"$(ucli completions bash)\"\n eval \"$(ucli completions zsh)\"\n ucli completions fish | source\n\nGLOBAL FLAGS\n --debug Enable verbose debug logging\n --output json Wrap ALL output in structured JSON envelopes\n (for agent/automation consumption)\n -v, --version Show version number\n\nERRORS\n 401 Unauthorized → Run: ucli configure --server <url> --token <jwt>\n 404 Not Found → Check service name: ucli services list\n 4xx Client Error → Check operation args: ucli services info <service>\n 5xx Server Error → Retry or run: ucli refresh\n\nAI AGENT QUICK START\n 1. ucli introspect # discover everything in one call\n 2. ucli run <svc> <op> [args] # execute operations\n 3. Use --output json globally # get structured { success, data/error } envelopes\n`)\n}\n","/**\n * MCP tool runner using @tronsfey/mcp2cli programmatic API.\n *\n * Auth credentials are injected via McpServerConfig (headers or env) —\n * never passed as CLI arguments (which would be visible in `ps`).\n */\nimport type { McpEntryPublic } from './server-client.js'\n\n/**\n * Resolve a named export from a module that may be CJS-wrapped (exports live\n * under `module.default`) or a plain ESM module (named exports at top level).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction resolve(mod: any, name: string): unknown {\n if (typeof mod[name] === 'function') return mod[name]\n if (mod.default && typeof mod.default[name] === 'function') return mod.default[name]\n throw new Error(`Cannot resolve export \"${name}\" from module`)\n}\n\nasync function getMcp2cli() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const clientMod = await import('@tronsfey/mcp2cli/dist/client/index.js') as any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const runnerMod = await import('@tronsfey/mcp2cli/dist/runner/index.js') as any\n return {\n createMcpClient: resolve(clientMod, 'createMcpClient') as (...args: unknown[]) => Promise<unknown>,\n getTools: resolve(runnerMod, 'getTools') as (...args: unknown[]) => Promise<{ name: string; description?: string; inputSchema?: unknown }[]>,\n runTool: resolve(runnerMod, 'runTool') as (...args: unknown[]) => Promise<void>,\n describeTool: resolve(runnerMod, 'describeTool') as (...args: unknown[]) => void,\n describeToolJson: resolve(runnerMod, 'describeToolJson') as (...args: unknown[]) => void,\n }\n}\n\nasync function closeClient(client: unknown): Promise<void> {\n if (typeof (client as { close?: unknown }).close === 'function') {\n await (client as { close: () => Promise<void> }).close()\n }\n}\n\nfunction buildMcpConfig(entry: McpEntryPublic): Record<string, unknown> {\n const base: Record<string, unknown> = { type: entry.transport }\n if (entry.transport === 'http') {\n base.url = entry.serverUrl\n } else {\n base.command = entry.command\n }\n const auth = entry.authConfig\n if (auth.type === 'http_headers') {\n base.headers = auth.headers\n } else if (auth.type === 'env') {\n base.env = auth.env\n }\n return base\n}\n\nexport async function listMcpTools(entry: McpEntryPublic): Promise<{ name: string; description?: string; inputSchema?: unknown }[]> {\n const { createMcpClient, getTools } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: true })\n return tools\n } finally {\n await closeClient(client)\n }\n}\n\nexport async function describeMcpTool(\n entry: McpEntryPublic,\n toolName: string,\n opts?: { json?: boolean },\n): Promise<void> {\n const { createMcpClient, getTools, describeTool, describeToolJson } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tool = tools.find((t: any) => t.name === toolName)\n if (!tool) throw new Error(`Tool \"${toolName}\" not found on MCP server \"${entry.name}\"`)\n if (opts?.json) {\n describeToolJson(tool)\n } else {\n describeTool(tool)\n }\n } finally {\n await closeClient(client)\n }\n}\n\nexport async function runMcpTool(\n entry: McpEntryPublic,\n toolName: string,\n rawArgs: string[],\n opts?: { json?: boolean; inputJson?: string },\n): Promise<void> {\n const { createMcpClient, getTools, runTool } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tool = tools.find((t: any) => t.name === toolName)\n if (!tool) throw new Error(`Tool \"${toolName}\" not found on MCP server \"${entry.name}\"`)\n const normalizedArgs: string[] = []\n for (const arg of rawArgs) {\n if (arg.includes('=') && !arg.startsWith('--')) {\n const idx = arg.indexOf('=')\n const key = arg.slice(0, idx)\n const value = arg.slice(idx + 1)\n normalizedArgs.push(`--${key}`, value)\n } else {\n normalizedArgs.push(arg)\n }\n }\n await runTool(client, tool, normalizedArgs, {\n ...(opts?.json ? { json: true } : {}),\n ...(opts?.inputJson ? { inputJson: opts.inputJson } : {}),\n })\n } finally {\n await closeClient(client)\n }\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { listMcpTools, describeMcpTool, runMcpTool } from '../lib/mcp-runner.js'\nimport { toYaml } from '../lib/yaml.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\nexport function registerMcp(program: Command): void {\n const mcp = program\n .command('mcp')\n .description('Interact with MCP servers registered in your group')\n\n // mcp list\n mcp\n .command('list')\n .description('List all MCP servers available in the current group')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n const entries = await client.listMCP()\n\n // Strip authConfig secrets — only expose { type }\n const safe = entries.map(({ authConfig, ...rest }) => ({\n ...rest,\n authConfig: { type: authConfig.type },\n }))\n\n if (isJsonOutput()) {\n outputSuccess(safe)\n return\n }\n\n if (entries.length === 0) {\n console.log('No MCP servers registered in this group.')\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(safe))\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map(e => e.name.length))\n console.log(`\\n${'SERVER'.padEnd(nameWidth)} TRANSPORT DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} --------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${e.transport.padEnd(9)} ${desc}`)\n }\n console.log()\n })\n\n // mcp tools <server>\n mcp\n .command('tools <server>')\n .description('List tools available on a MCP server')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (serverName: string, opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Unknown MCP server: ${serverName}`,\n 'Run: ucli mcp list to see available servers')\n }\n\n let tools\n try {\n tools = await listMcpTools(entry)\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR, `Failed to fetch tools: ${(err as Error).message}`)\n }\n\n if (isJsonOutput()) {\n outputSuccess(tools)\n return\n }\n\n if (tools.length === 0) {\n console.log(`No tools found on MCP server \"${serverName}\".`)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(tools, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(tools))\n return\n }\n\n console.log(`\\nTools on \"${serverName}\":`)\n console.log('─'.repeat(60))\n for (const t of tools) {\n console.log(` ${t.name}`)\n if (t.description) console.log(` ${t.description}`)\n }\n console.log()\n })\n\n // mcp describe <server> <tool>\n mcp\n .command('describe <server> <tool>')\n .description('Show detailed schema for a tool on a MCP server')\n .option('--json', 'Output full schema as JSON (for agent consumption)')\n .action(async (serverName: string, toolName: string, opts: { json?: boolean }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Unknown MCP server: ${serverName}`,\n 'Run: ucli mcp list to see available servers')\n }\n\n try {\n await describeMcpTool(entry, toolName, { json: opts.json })\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR, `Failed to describe tool: ${(err as Error).message}`)\n }\n })\n\n // mcp run <server> <tool> [args...]\n mcp\n .command('run <server> <tool> [args...]')\n .description('Call a tool on a MCP server')\n .option('--json', 'Machine-readable JSON output')\n .option('--input-json <json>', 'Pass tool arguments as a JSON object')\n .action(async (serverName: string, toolName: string, args: string[], opts: { json?: boolean; inputJson?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n outputError(ExitCode.NOT_FOUND, `Unknown MCP server: ${serverName}`,\n 'Run: ucli mcp list to see available servers')\n }\n\n try {\n await runMcpTool(entry, toolName, args, {\n json: opts.json,\n inputJson: opts.inputJson,\n })\n } catch (err) {\n outputError(ExitCode.GENERAL_ERROR, `Tool execution failed: ${(err as Error).message}`)\n }\n })\n}\n","/**\n * Consistent error formatting utility.\n *\n * Provides a unified error output with actionable hints so that both\n * humans and AI agents can quickly understand what went wrong and how\n * to fix it.\n *\n * When `--output json` is active, errors are emitted as structured JSON\n * to stdout (via outputError) so that agents can parse them reliably.\n */\nimport { ExitCode, type ExitCodeValue } from './exit-codes.js'\nimport { isJsonOutput, outputError } from './output.js'\n\nlet debugEnabled = false\n\nexport function setDebugMode(enabled: boolean): void {\n debugEnabled = enabled\n}\n\nexport function isDebugMode(): boolean {\n return debugEnabled\n}\n\n/** Log a debug message (only when --debug is active). */\nexport function debug(message: string): void {\n if (debugEnabled) {\n console.error(`[DEBUG] ${message}`)\n }\n}\n\nexport interface FormattedError {\n code: ExitCodeValue\n message: string\n hint?: string\n}\n\nexport const HINT_MAP: Record<number, string> = {\n [ExitCode.CONFIG_ERROR]:\n 'Run: ucli configure --server <url> --token <jwt>',\n [ExitCode.AUTH_ERROR]:\n 'Your token may be expired or revoked. Run: ucli configure --server <url> --token <jwt>',\n [ExitCode.CONNECTIVITY_ERROR]:\n 'Check that the server URL is correct and the server is running. Run: ucli doctor',\n [ExitCode.NOT_FOUND]:\n 'Check the resource name. Run: ucli services list or ucli mcp list',\n [ExitCode.SERVER_ERROR]:\n 'The server returned an unexpected error. Try again or run: ucli doctor',\n}\n\n/**\n * Print a formatted error to stderr and exit with the given code.\n *\n * When `--output json` is active, emits structured JSON to stdout\n * instead of human-readable text to stderr.\n * When --debug is active, the full stack trace is also printed (text mode only).\n */\nexport function formatError(err: unknown, code?: ExitCodeValue): never {\n const exitCode = code ?? classifyError(err)\n const message = err instanceof Error ? err.message : String(err)\n const hint = HINT_MAP[exitCode]\n\n // In JSON output mode, delegate to the structured envelope emitter\n if (isJsonOutput()) {\n outputError(exitCode, message, hint)\n }\n\n console.error(`\\n✖ Error: ${message}`)\n if (hint) {\n console.error(` Hint: ${hint}`)\n }\n\n if (debugEnabled && err instanceof Error && err.stack) {\n console.error(`\\n${err.stack}`)\n }\n\n process.exit(exitCode)\n}\n\n/** Classify an error into an exit code based on common patterns. */\nexport function classifyError(err: unknown): ExitCodeValue {\n if (!(err instanceof Error)) return ExitCode.GENERAL_ERROR\n\n const msg = err.message.toLowerCase()\n\n if (msg.includes('not configured') || msg.includes('missing')) {\n return ExitCode.CONFIG_ERROR\n }\n if (msg.includes('401') || msg.includes('unauthorized') || msg.includes('authentication')) {\n return ExitCode.AUTH_ERROR\n }\n if (msg.includes('econnrefused') || msg.includes('enotfound') || msg.includes('timeout') || msg.includes('network')) {\n return ExitCode.CONNECTIVITY_ERROR\n }\n if (msg.includes('404') || msg.includes('not found')) {\n return ExitCode.NOT_FOUND\n }\n if (msg.includes('5') && msg.includes('server error')) {\n return ExitCode.SERVER_ERROR\n }\n\n return ExitCode.GENERAL_ERROR\n}\n","/**\n * `ucli doctor` — diagnostic tool for configuration, connectivity, and token validation.\n *\n * Checks:\n * 1. Configuration file exists and is readable\n * 2. Server URL is reachable (GET /api/v1/health)\n * 3. JWT token is accepted (GET /api/v1/oas — expects 200 or empty list)\n */\nimport type { Command } from 'commander'\nimport { isConfigured, getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { debug } from '../lib/errors.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\nimport axios from 'axios'\n\ninterface CheckResult {\n name: string\n ok: boolean\n detail: string\n}\n\nexport function registerDoctor(program: Command): void {\n program\n .command('doctor')\n .description('Check configuration, server connectivity, and token validity')\n .action(async () => {\n const results: CheckResult[] = []\n\n // ── Check 1: Configuration ──────────────────────────────────────\n debug('Checking configuration...')\n if (!isConfigured()) {\n results.push({\n name: 'Configuration',\n ok: false,\n detail: 'Not configured. Run: ucli configure --server <url> --token <jwt>',\n })\n outputError(ExitCode.CONFIG_ERROR,\n 'Not configured',\n 'Run: ucli configure --server <url> --token <jwt>')\n }\n\n let cfg: { serverUrl: string; token: string }\n try {\n cfg = getConfig()\n results.push({\n name: 'Configuration',\n ok: true,\n detail: `Server: ${cfg.serverUrl}`,\n })\n } catch (err) {\n results.push({\n name: 'Configuration',\n ok: false,\n detail: `Failed to read config: ${(err as Error).message}`,\n })\n outputError(ExitCode.CONFIG_ERROR,\n `Failed to read config: ${(err as Error).message}`,\n 'Run: ucli configure --server <url> --token <jwt>')\n }\n\n // ── Check 2: Connectivity (health endpoint, no auth required) ──\n debug(`Checking connectivity to ${cfg.serverUrl}...`)\n try {\n const healthUrl = `${cfg.serverUrl}/api/v1/health`\n const resp = await axios.get(healthUrl, { timeout: 10_000 })\n results.push({\n name: 'Server connectivity',\n ok: resp.status === 200,\n detail: resp.status === 200\n ? `Health endpoint OK (${cfg.serverUrl})`\n : `Unexpected status: ${resp.status}`,\n })\n } catch (err) {\n const msg = axios.isAxiosError(err)\n ? err.code ?? err.message\n : (err as Error).message\n results.push({\n name: 'Server connectivity',\n ok: false,\n detail: `Cannot reach server: ${msg}`,\n })\n }\n\n // ── Check 3: Token validity (authenticated request) ────────────\n debug('Validating JWT token...')\n try {\n const client = new ServerClient(cfg)\n await client.listOAS()\n results.push({\n name: 'Authentication',\n ok: true,\n detail: 'Token accepted by server',\n })\n } catch (err) {\n const msg = (err as Error).message\n results.push({\n name: 'Authentication',\n ok: false,\n detail: `Token rejected: ${msg}`,\n })\n }\n\n const allOk = results.every((r) => r.ok)\n\n if (isJsonOutput()) {\n outputSuccess({\n healthy: allOk,\n checks: results,\n })\n process.exit(allOk ? ExitCode.SUCCESS : ExitCode.GENERAL_ERROR)\n }\n\n printResults(results)\n process.exit(allOk ? ExitCode.SUCCESS : ExitCode.GENERAL_ERROR)\n })\n}\n\nfunction printResults(results: CheckResult[]): void {\n console.log('\\nucli doctor\\n' + '═'.repeat(40))\n for (const r of results) {\n const icon = r.ok ? '✓' : '✖'\n console.log(` ${icon} ${r.name}: ${r.detail}`)\n }\n console.log()\n}\n","/**\n * `ucli completions` — generate shell completion scripts for bash/zsh/fish.\n *\n * Usage:\n * eval \"$(ucli completions bash)\"\n * eval \"$(ucli completions zsh)\"\n * ucli completions fish | source\n */\nimport type { Command } from 'commander'\nimport { ExitCode } from '../lib/exit-codes.js'\n\nexport function registerCompletions(program: Command): void {\n program\n .command('completions <shell>')\n .description('Generate shell completion script (bash | zsh | fish)')\n .action((shell: string) => {\n const normalized = shell.toLowerCase().trim()\n\n switch (normalized) {\n case 'bash':\n console.log(bashCompletions())\n break\n case 'zsh':\n console.log(zshCompletions())\n break\n case 'fish':\n console.log(fishCompletions())\n break\n default:\n console.error(`Unsupported shell: ${shell}. Supported: bash, zsh, fish`)\n process.exit(ExitCode.USAGE_ERROR)\n }\n })\n}\n\nfunction bashCompletions(): string {\n return `# ucli bash completions — eval \"$(ucli completions bash)\"\n_ucli_completions() {\n local cur prev commands\n COMPREPLY=()\n cur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n prev=\"\\${COMP_WORDS[COMP_CWORD-1]}\"\n commands=\"configure services run refresh help mcp doctor completions introspect\"\n\n case \"\\${COMP_WORDS[1]}\" in\n services)\n COMPREPLY=( $(compgen -W \"list info\" -- \"$cur\") )\n return 0\n ;;\n mcp)\n COMPREPLY=( $(compgen -W \"list tools run\" -- \"$cur\") )\n return 0\n ;;\n completions)\n COMPREPLY=( $(compgen -W \"bash zsh fish\" -- \"$cur\") )\n return 0\n ;;\n run|help)\n # dynamic completions would require server calls; skip for now\n return 0\n ;;\n esac\n\n if [ \"$COMP_CWORD\" -eq 1 ]; then\n COMPREPLY=( $(compgen -W \"$commands\" -- \"$cur\") )\n fi\n\n return 0\n}\ncomplete -F _ucli_completions ucli`\n}\n\nfunction zshCompletions(): string {\n return `# ucli zsh completions — eval \"$(ucli completions zsh)\"\n#compdef ucli\n\n_ucli() {\n local -a commands\n commands=(\n 'configure:Configure server URL and authentication token'\n 'services:Manage and inspect available OAS services'\n 'run:Execute an operation on a service'\n 'refresh:Force-refresh the local OAS cache'\n 'help:Show usage guide'\n 'mcp:Interact with MCP servers'\n 'doctor:Check configuration and connectivity'\n 'completions:Generate shell completion script'\n 'introspect:Return complete capability manifest for AI agents'\n )\n\n _arguments -C \\\\\n '1: :->command' \\\\\n '*::arg:->args'\n\n case $state in\n command)\n _describe -t commands 'ucli commands' commands\n ;;\n args)\n case $words[1] in\n services)\n _values 'subcommand' 'list[List all OAS services]' 'info[Show service details]'\n ;;\n mcp)\n _values 'subcommand' 'list[List MCP servers]' 'tools[List tools]' 'run[Call a tool]'\n ;;\n completions)\n _values 'shell' bash zsh fish\n ;;\n esac\n ;;\n esac\n}\n\n_ucli \"$@\"`\n}\n\nfunction fishCompletions(): string {\n return `# ucli fish completions — ucli completions fish | source\ncomplete -c ucli -e\n\n# Top-level commands\ncomplete -c ucli -n __fish_use_subcommand -a configure -d 'Configure server URL and token'\ncomplete -c ucli -n __fish_use_subcommand -a services -d 'Manage OAS services'\ncomplete -c ucli -n __fish_use_subcommand -a run -d 'Execute a service operation'\ncomplete -c ucli -n __fish_use_subcommand -a refresh -d 'Refresh local cache'\ncomplete -c ucli -n __fish_use_subcommand -a help -d 'Show usage guide'\ncomplete -c ucli -n __fish_use_subcommand -a mcp -d 'Interact with MCP servers'\ncomplete -c ucli -n __fish_use_subcommand -a doctor -d 'Check config and connectivity'\ncomplete -c ucli -n __fish_use_subcommand -a completions -d 'Generate shell completions'\n\ncomplete -c ucli -n __fish_use_subcommand -a introspect -d 'Return capability manifest for AI agents'\n\n# services subcommands\ncomplete -c ucli -n '__fish_seen_subcommand_from services' -a list -d 'List services'\ncomplete -c ucli -n '__fish_seen_subcommand_from services' -a info -d 'Show service details'\n\n# mcp subcommands\ncomplete -c ucli -n '__fish_seen_subcommand_from mcp' -a list -d 'List MCP servers'\ncomplete -c ucli -n '__fish_seen_subcommand_from mcp' -a tools -d 'List tools'\ncomplete -c ucli -n '__fish_seen_subcommand_from mcp' -a run -d 'Call a tool'\n\n# completions subcommands\ncomplete -c ucli -n '__fish_seen_subcommand_from completions' -a 'bash zsh fish' -d 'Shell type'`\n}\n","/**\n * `ucli introspect` — unified capability discovery for AI agents.\n *\n * Returns a complete machine-readable manifest of everything the agent\n * can do in a single call: OAS services, MCP servers, and the CLI\n * command reference. This eliminates multiple round-trips that agents\n * would otherwise need (`services list` → `services info` × N →\n * `mcp list` → `mcp tools` × N).\n *\n * Methodology: This follows the \"Observe → Orient → Decide → Act\" (OODA)\n * loop and the ReAct pattern — agents should call `introspect` once at\n * the start of a task to build a mental model before acting.\n */\nimport type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient, type OASEntryPublic, type McpEntryPublic } from '../lib/server-client.js'\nimport { toYaml } from '../lib/yaml.js'\nimport { ExitCode } from '../lib/exit-codes.js'\nimport { isJsonOutput, outputSuccess, outputError } from '../lib/output.js'\n\n/**\n * Shape of the introspection manifest returned by `ucli introspect`.\n */\nexport interface IntrospectManifest {\n version: string\n services: IntrospectService[]\n mcpServers: IntrospectMcpServer[]\n commands: IntrospectCommand[]\n}\n\nexport interface IntrospectService {\n name: string\n description: string\n authType: string\n remoteUrl: string\n baseEndpoint: string | null\n cacheTtl: number\n}\n\nexport interface IntrospectMcpServer {\n name: string\n description: string\n transport: string\n enabled: boolean\n}\n\nexport interface IntrospectCommand {\n name: string\n description: string\n usage: string\n examples: string[]\n}\n\nexport function registerIntrospect(program: Command): void {\n program\n .command('introspect')\n .description('Return a complete capability manifest for AI agent discovery (services, MCP servers, commands)')\n .option('--format <fmt>', 'Output format: json | yaml', 'json')\n .action(async (opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n // Fetch OAS services and MCP servers in parallel\n let oasEntries: OASEntryPublic[] = []\n let mcpEntries: McpEntryPublic[] = []\n\n try {\n ;[oasEntries, mcpEntries] = await Promise.all([\n client.listOAS(),\n client.listMCP(),\n ])\n } catch (err) {\n const message = (err as Error).message\n outputError(ExitCode.CONNECTIVITY_ERROR, `Failed to fetch capabilities: ${message}`,\n 'Check server connectivity with: ucli doctor')\n }\n\n const manifest: IntrospectManifest = {\n version: '1',\n services: oasEntries.map(toIntrospectService),\n mcpServers: mcpEntries.map(toIntrospectMcpServer),\n commands: getCommandReference(),\n }\n\n const format = (opts.format ?? 'json').toLowerCase()\n\n if (isJsonOutput()) {\n outputSuccess(manifest)\n return\n }\n\n if (format === 'json') {\n console.log(JSON.stringify(manifest, null, 2))\n return\n }\n\n if (format === 'yaml') {\n console.log(toYaml(manifest))\n return\n }\n\n // Fallback to json\n console.log(JSON.stringify(manifest, null, 2))\n })\n}\n\nfunction toIntrospectService(e: OASEntryPublic): IntrospectService {\n return {\n name: e.name,\n description: e.description,\n authType: e.authType,\n remoteUrl: e.remoteUrl,\n baseEndpoint: e.baseEndpoint,\n cacheTtl: e.cacheTtl,\n }\n}\n\nfunction toIntrospectMcpServer(e: McpEntryPublic): IntrospectMcpServer {\n return {\n name: e.name,\n description: e.description,\n transport: e.transport,\n enabled: e.enabled,\n }\n}\n\n/**\n * Static command reference that agents can use to understand\n * what CLI commands are available and how to use them.\n */\nfunction getCommandReference(): IntrospectCommand[] {\n return [\n {\n name: 'services list',\n description: 'List all OAS services available in the current group',\n usage: 'ucli services list [--format json|table|yaml] [--refresh]',\n examples: [\n 'ucli services list',\n 'ucli services list --format json',\n 'ucli services list --refresh',\n ],\n },\n {\n name: 'services info',\n description: 'Show detailed information and available operations for a service',\n usage: 'ucli services info <name> [--format json|table|yaml]',\n examples: [\n 'ucli services info payments',\n 'ucli services info payments --format json',\n ],\n },\n {\n name: 'run',\n description: 'Execute an operation on an OAS service',\n usage: 'ucli run <service> <operation> [--format json|table|yaml] [--query <jmespath>] [--data <json|@file>] [--params <json>] [--machine] [--dry-run]',\n examples: [\n 'ucli run payments listTransactions',\n 'ucli run payments getTransaction --transactionId txn_123',\n 'ucli run payments createCharge --data \\'{\"amount\": 5000, \"currency\": \"USD\"}\\'',\n 'ucli run inventory listProducts --query \"items[?stock > `0`].name\"',\n 'ucli run payments listTransactions --machine',\n 'ucli run payments createCharge --dry-run --data \\'{\"amount\": 5000}\\'',\n ],\n },\n {\n name: 'mcp list',\n description: 'List all MCP servers available in the current group',\n usage: 'ucli mcp list [--format json|table|yaml]',\n examples: [\n 'ucli mcp list',\n 'ucli mcp list --format json',\n ],\n },\n {\n name: 'mcp tools',\n description: 'List tools available on a MCP server',\n usage: 'ucli mcp tools <server> [--format json|table|yaml]',\n examples: [\n 'ucli mcp tools weather',\n 'ucli mcp tools weather --format json',\n ],\n },\n {\n name: 'mcp describe',\n description: 'Show detailed schema for a tool on a MCP server',\n usage: 'ucli mcp describe <server> <tool> [--json]',\n examples: [\n 'ucli mcp describe weather get_forecast',\n 'ucli mcp describe weather get_forecast --json',\n ],\n },\n {\n name: 'mcp run',\n description: 'Call a tool on a MCP server',\n usage: 'ucli mcp run <server> <tool> [key=value ...] [--json] [--input-json <json>]',\n examples: [\n 'ucli mcp run weather get_forecast location=\"New York\"',\n 'ucli mcp run search web_search query=\"ucli docs\" limit=5',\n 'ucli mcp run weather get_forecast --input-json \\'{\"location\": \"New York\"}\\'',\n 'ucli mcp run weather get_forecast --json location=\"New York\"',\n ],\n },\n {\n name: 'introspect',\n description: 'Return complete capability manifest (this command)',\n usage: 'ucli introspect [--format json|yaml]',\n examples: [\n 'ucli introspect',\n 'ucli introspect --format yaml',\n ],\n },\n {\n name: 'refresh',\n description: 'Force-refresh the local OAS cache from the server',\n usage: 'ucli refresh [--service <name>]',\n examples: [\n 'ucli refresh',\n 'ucli refresh --service payments',\n ],\n },\n {\n name: 'doctor',\n description: 'Check configuration, server connectivity, and token validity',\n usage: 'ucli doctor',\n examples: ['ucli doctor'],\n },\n {\n name: 'configure',\n description: 'Configure the server URL and authentication token',\n usage: 'ucli configure --server <url> --token <jwt>',\n examples: ['ucli configure --server https://oas.example.com --token eyJ...'],\n },\n ]\n}\n"],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,iBAAAA,sBAAqB;;;ACD9B,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AAC9B,SAAS,WAAW,iBAAiB;;;ACOrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,gBAAgB;AAEnC,IAAM,aAAa;AACnB,IAAM,YAAY;AAClB,IAAM,WAAW;AACjB,IAAM,SAAS;AACf,IAAM,UAAU;AAChB,IAAM,oBAAoB;AAG1B,SAAS,U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AO,KAAK,WAAW,UAAU;AAClD,YAAM,OAAO,KAAK,OAAO,YAAY;AACrC,UAAI,SAAS,UAAU,SAAS,QAAQ;AACtC,sBAAc,IAAI;AAAA,MACpB;AAAA,IACF;AACA,UAAM,IAAI;AAAA,EACZ;AACF,CAAC;AAEH,kBAAkB,OAAO;AACzB,iBAAiB,OAAO;AACxB,YAAY,OAAO;AACnB,gBAAgB,OAAO;AACvB,YAAY,OAAO;AACnB,eAAe,OAAO;AACtB,oBAAoB,OAAO;AAC3B,mBAAmB,OAAO;AAC1B,aAAa,OAAO;AAEpB,QAAQ,MAAM,QAAQ,IAAI;","names":["createRequire","program","join","join","join","dirname","require","pkg","resolve","program","program","program","program","cfg","client","program","axios","program","program","program","require","createRequire"]}