-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: expand provider onboarding and validation #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4979df8
31f5cc7
6967b1b
e2d4481
c6cfccc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,8 +31,97 @@ function getCredential(key) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return creds[key] || null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function prompt(question) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function promptSecret(question) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new Promise((resolve, reject) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const input = process.stdin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const output = process.stderr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let answer = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let rawModeEnabled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let finished = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function cleanup() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.removeListener("data", onData); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (rawModeEnabled && typeof input.setRawMode === "function") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.setRawMode(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof input.pause === "function") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.pause(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function finish(fn, value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (finished) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finished = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cleanup(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output.write("\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn(value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function onData(chunk) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const text = chunk.toString("utf8"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (let i = 0; i < text.length; i += 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ch = text[i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ch === "\u0003") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finish(reject, Object.assign(new Error("Prompt interrupted"), { code: "SIGINT" })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ch === "\r" || ch === "\n") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finish(resolve, answer.trim()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ch === "\u0008" || ch === "\u007f") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| answer = answer.slice(0, -1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ch === "\u001b") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ignore terminal escape/control sequences such as Delete, arrows, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Home/End, etc. while leaving the buffered secret untouched. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const rest = text.slice(i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const match = rest.match(/^\u001b(?:\[[0-9;?]*[~A-Za-z]|\][^\u0007]*\u0007|.)/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (match) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| i += match[0].length - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ch >= " ") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| answer += ch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output.write(question); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.setEncoding("utf8"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof input.resume === "function") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.resume(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof input.setRawMode === "function") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.setRawMode(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rawModeEnabled = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.on("data", onData); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function prompt(question, opts = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new Promise((resolve) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const silent = opts.secret === true && process.stdin.isTTY && process.stderr.isTTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (silent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| promptSecret(question) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then(resolve) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .catch((err) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (err && err.code === "SIGINT") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.kill(process.pid, "SIGINT"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+110
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify unresolved Promise paths in prompt() silent branch (read-only).
awk 'NR>=110 && NR<=124 {printf "%4d %s\n", NR, $0}' bin/lib/credentials.js
rg -nP 'new Promise\(\(resolve\)\s*=>\s*\{' bin/lib/credentials.js -n -A12 -B2Repository: NVIDIA/NemoClaw Length of output: 1081 🏁 Script executed: sed -n '110,200p' bin/lib/credentials.js | cat -nRepository: NVIDIA/NemoClaw Length of output: 3624 Settle the outer The Promise at line 111 only accepts Add Suggested fix-function prompt(question, opts = {}) {
- return new Promise((resolve) => {
+function prompt(question, opts = {}) {
+ return new Promise((resolve, reject) => {
const silent = opts.secret === true && process.stdin.isTTY && process.stderr.isTTY;
if (silent) {
promptSecret(question)
.then(resolve)
.catch((err) => {
if (err && err.code === "SIGINT") {
process.kill(process.pid, "SIGINT");
- return;
+ reject(err);
+ return;
}
- throw err;
+ reject(err);
});
return;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const rl = readline.createInterface({ input: process.stdin, output: process.stderr }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rl.question(question, (answer) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rl.close(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -67,7 +156,7 @@ async function ensureApiKey() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(" └─────────────────────────────────────────────────────────────────┘"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key = await prompt(" NVIDIA API Key: "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key = await prompt(" NVIDIA API Key: ", { secret: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!key || !key.startsWith("nvapi-")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(" Invalid key. Must start with nvapi-"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -114,7 +203,7 @@ async function ensureGithubToken() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(" └──────────────────────────────────────────────────┘"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token = await prompt(" GitHub Token: "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token = await prompt(" GitHub Token: ", { secret: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(" Token required for deploy (repo is private)."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.