openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
34 lines (33 loc) • 1.38 kB
JavaScript
import { t as ExitError } from "./runtime-B-SLYP-m.mjs";
import { o as registerSecretValueForRedaction } from "./secret-redaction-registry-Cy0acctn.mjs";
import { n as normalizeSecretInput } from "./normalize-secret-input-Cxkx67Fv.mjs";
import { n as WizardCancelledError } from "./prompts-CCXo2K24.mjs";
import { t as createClackPrompter } from "./clack-prompter-oqVcatgQ.mjs";
import { r as readPipedStdin } from "./auth-manual-input-DeJ4s3kg.mjs";
import { addAbortSignal } from "node:stream";
//#region src/commands/models/auth-gateway.ts
/** Collect input without loading local config or opening a credential store. */
async function readGatewayApiKeyParams(e, t) {
let n;
try {
n = process.stdin.isTTY ? await createClackPrompter(process.stderr, t).text({
message: "Paste API key",
sensitive: true
}) : await readPipedStdin(addAbortSignal(t, process.stdin));
} catch (e) {
if (e instanceof WizardCancelledError) throw new ExitError(0);
throw e;
}
t.throwIfAborted();
const r = normalizeSecretInput(n);
if (!r) throw new Error("No API key was supplied. Rerun this command and paste a non-empty API key, or pipe one to stdin.");
registerSecretValueForRedaction(r);
if (!e.provider) throw new Error("Missing --provider.");
return {
provider: e.provider,
apiKey: r,
agentId: e.agent
};
}
//#endregion
export { readGatewayApiKeyParams as t };