Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions bin/lib/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,22 @@ function prompt(question, opts = {}) {
});
}

const SUPPORTED_API_KEYS = [
"NVIDIA_API_KEY",
"OPENAI_API_KEY",
"ANTHROPIC_API_KEY",
"GEMINI_API_KEY",
"COMPATIBLE_API_KEY",
"COMPATIBLE_ANTHROPIC_API_KEY",
];

async function ensureApiKey() {
let key = getCredential("NVIDIA_API_KEY");
if (key) {
process.env.NVIDIA_API_KEY = key;
return;
for (const envKey of SUPPORTED_API_KEYS) {
const val = getCredential(envKey);
if (val) {
process.env[envKey] = val;
return;
}
}

console.log("");
Expand All @@ -232,6 +243,7 @@ async function ensureApiKey() {
console.log(" └─────────────────────────────────────────────────────────────────┘");
console.log("");

let key;
while (true) {
key = normalizeCredentialValue(await prompt(" NVIDIA API Key: ", { secret: true }));

Expand Down Expand Up @@ -311,6 +323,7 @@ async function ensureGithubToken() {
}

const exports_ = {
SUPPORTED_API_KEYS,
loadCredentials,
normalizeCredentialValue,
saveCredential,
Expand Down
5 changes: 5 additions & 0 deletions bin/lib/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2162,6 +2162,7 @@ async function createSandbox(
// See: crates/openshell-sandbox/src/proxy.rs (header stripping),
// crates/openshell-router/src/backend.rs (server-side auth injection).
const envArgs = [formatEnvAssignment("CHAT_UI_URL", chatUiUrl)];

const sandboxEnv = { ...process.env };
delete sandboxEnv.NVIDIA_API_KEY;
const discordToken = getCredential("DISCORD_BOT_TOKEN") || process.env.DISCORD_BOT_TOKEN;
Expand All @@ -2172,6 +2173,10 @@ async function createSandbox(
if (slackToken) {
sandboxEnv.SLACK_BOT_TOKEN = slackToken;
}
const slackAppToken = getCredential("SLACK_APP_TOKEN") || process.env.SLACK_APP_TOKEN;
if (slackAppToken) {
sandboxEnv.SLACK_APP_TOKEN = slackAppToken;
}
// Run without piping through awk — the pipe masked non-zero exit codes
// from openshell because bash returns the status of the last pipeline
// command (awk, always 0) unless pipefail is set. Removing the pipe
Expand Down
27 changes: 26 additions & 1 deletion bin/nemoclaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const {
ensureGithubToken,
getCredential,
isRepoPrivate,
SUPPORTED_API_KEYS,
} = require("./lib/credentials");
const registry = require("./lib/registry");
const nim = require("./lib/nim");
Expand Down Expand Up @@ -729,7 +730,17 @@ async function deploy(instanceName) {
`rsync -az --delete --exclude node_modules --exclude .git --exclude src -e "ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR" "${ROOT}/scripts" "${ROOT}/Dockerfile" "${ROOT}/nemoclaw" "${ROOT}/nemoclaw-blueprint" "${ROOT}/bin" "${ROOT}/package.json" ${qname}:/home/ubuntu/nemoclaw/`,
);

const envLines = [`NVIDIA_API_KEY=${shellQuote(process.env.NVIDIA_API_KEY || "")}`];
const envLines = [];
let hasKey = false;
for (const k of SUPPORTED_API_KEYS) {
const val = process.env[k] || getCredential(k);
if (val) {
envLines.push(`${k}=${shellQuote(val)}`);
hasKey = true;
}
}
if (hasKey) envLines.push("NEMOCLAW_HAS_API_KEY=1");

const ghToken = process.env.GITHUB_TOKEN;
if (ghToken) envLines.push(`GITHUB_TOKEN=${shellQuote(ghToken)}`);
const tgToken = getCredential("TELEGRAM_BOT_TOKEN");
Expand Down Expand Up @@ -782,6 +793,11 @@ async function deploy(instanceName) {
}

async function start() {
const creds = require("./lib/credentials").loadCredentials();
for (const [k, v] of Object.entries(creds)) {
if (!process.env[k]) process.env[k] = v;
}

const { startAll } = require("./lib/services");
const { defaultSandbox } = registry.listSandboxes();
const safeName =
Expand Down Expand Up @@ -885,6 +901,10 @@ function uninstall(args) {
}

function showStatus() {
if (SUPPORTED_API_KEYS.some((k) => process.env[k] || getCredential(k))) {
process.env.NEMOCLAW_HAS_API_KEY = "1";
}

// Show sandbox registry
const { sandboxes, defaultSandbox } = registry.listSandboxes();
if (sandboxes.length > 0) {
Expand All @@ -902,6 +922,11 @@ function showStatus() {
}

// Show service status
const creds = require("./lib/credentials").loadCredentials();
for (const [k, v] of Object.entries(creds)) {
if (!process.env[k]) process.env[k] = v;
}

const { showStatus: showServiceStatus } = require("./lib/services");
showServiceStatus({ sandboxName: defaultSandbox || undefined });
}
Expand Down
Loading