UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

50 lines • 1.5 kB
import { createInterface } from 'node:readline/promises'; /** Line prompts on the terminal, including hidden input for secret fields (4.7). */ export class Prompter { rl; get interface() { this.rl ??= createInterface({ input: process.stdin, output: process.stdout, terminal: process.stdin.isTTY, }); return this.rl; } get interactive() { return Boolean(process.stdin.isTTY); } ask(question, signal) { return signal ? this.interface.question(question, { signal }) : this.interface.question(question); } /** Reads without echoing: the value is never shown back, logged, or stored by the CLI. */ async askSecret(question) { const rl = this.interface; const original = rl._writeToOutput; let shown = false; rl._writeToOutput = (s) => { if (!shown) { shown = true; original?.call(rl, s); } }; try { return await this.interface.question(question); } finally { rl._writeToOutput = original; process.stdout.write('\n'); } } async confirm(question) { if (!this.interactive) return false; return /^y(es)?$/i.test((await this.ask(`${question} [y/N] `)).trim()); } close() { this.rl?.close(); this.rl = undefined; } } //# sourceMappingURL=prompt.js.map