repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import readline from "readline"; |
| #2 | import chalk from "chalk"; |
| #3 | let rl = null; |
| #4 | function getRL() { |
| #5 | if (!rl) { |
| #6 | rl = readline.createInterface({ |
| #7 | input: process.stdin, |
| #8 | output: process.stdout, |
| #9 | }); |
| #10 | } |
| #11 | return rl; |
| #12 | } |
| #13 | function ask(question) { |
| #14 | return new Promise((resolve) => { |
| #15 | getRL().question(question, (answer) => resolve(answer.trim())); |
| #16 | }); |
| #17 | } |
| #18 | export async function promptRequired(label) { |
| #19 | while (true) { |
| #20 | const value = await ask(chalk.white(` → ${label}: `)); |
| #21 | if (value) |
| #22 | return value; |
| #23 | console.log(chalk.yellow(" This field is required.")); |
| #24 | } |
| #25 | } |
| #26 | export async function promptMultiline(label) { |
| #27 | console.log(""); |
| #28 | console.log(chalk.white(` ${label}`)); |
| #29 | console.log(chalk.dim(" Type your prompt, then press Enter twice to finish:")); |
| #30 | console.log(""); |
| #31 | const lines = []; |
| #32 | let lastWasEmpty = false; |
| #33 | while (true) { |
| #34 | const line = await ask(" "); |
| #35 | if (line === "" && lastWasEmpty && lines.length > 0) { |
| #36 | // Remove the trailing empty line we added |
| #37 | lines.pop(); |
| #38 | break; |
| #39 | } |
| #40 | if (line === "" && lines.length > 0) { |
| #41 | lastWasEmpty = true; |
| #42 | lines.push(""); |
| #43 | } |
| #44 | else { |
| #45 | lastWasEmpty = false; |
| #46 | lines.push(line); |
| #47 | } |
| #48 | } |
| #49 | const result = lines.join("\n").trim(); |
| #50 | if (!result) { |
| #51 | console.log(chalk.yellow(" Genesis prompt is required. Try again.")); |
| #52 | return promptMultiline(label); |
| #53 | } |
| #54 | return result; |
| #55 | } |
| #56 | export async function promptAddress(label) { |
| #57 | while (true) { |
| #58 | const value = await ask(chalk.white(` → ${label}: `)); |
| #59 | if (/^0x[0-9a-fA-F]{40}$/.test(value)) |
| #60 | return value; |
| #61 | console.log(chalk.yellow(" Invalid Ethereum address. Must be 0x followed by 40 hex characters.")); |
| #62 | } |
| #63 | } |
| #64 | export function closePrompts() { |
| #65 | if (rl) { |
| #66 | rl.close(); |
| #67 | rl = null; |
| #68 | } |
| #69 | } |
| #70 | //# sourceMappingURL=prompts.js.map |