MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / promptForInput

Method promptForInput

apps/cli/src/agent/prompt-manager.ts:101–130  ·  view source on GitHub ↗

* Prompt for text input using readline. * * @param prompt - The prompt text to display * @returns The user's input * @throws If input is cancelled or an error occurs

(prompt: string)

Source from the content-addressed store, hash-verified

99 * @throws If input is cancelled or an error occurs
100 */
101 async promptForInput(prompt: string): Promise<string> {
102 return new Promise((resolve, reject) => {
103 this.beforePrompt()
104 this.isPrompting = true
105
106 const rl = readline.createInterface({
107 input: this.stdin,
108 output: this.stdout,
109 })
110
111 rl.question(prompt, (answer) => {
112 rl.close()
113 this.isPrompting = false
114 this.afterPrompt()
115 resolve(answer)
116 })
117
118 rl.on("close", () => {
119 this.isPrompting = false
120 this.afterPrompt()
121 })
122
123 rl.on("error", (err) => {
124 rl.close()
125 this.isPrompting = false
126 this.afterPrompt()
127 reject(err)
128 })
129 })
130 }
131
132 /**
133 * Prompt for yes/no input.

Callers 2

promptForYesNoMethod · 0.95

Calls 4

beforePromptMethod · 0.95
afterPromptMethod · 0.95
closeMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected