From dbdc022fb305ecb311133d5e2b218f476fef09df Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 8 Mar 2026 14:23:49 +0800 Subject: [PATCH] update openclaw secret --- single-scripts/openclaw-secret.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/single-scripts/openclaw-secret.ts b/single-scripts/openclaw-secret.ts index 1d50c95..f3a56f2 100755 --- a/single-scripts/openclaw-secret.ts +++ b/single-scripts/openclaw-secret.ts @@ -9,7 +9,7 @@ import { log, stdinToArrayBuffer, } from "https://script.hatter.ink/@50/deno-commons-mod.ts"; -import {parseArgs} from "jsr:@std/cli/parse-args"; +import { parseArgs } from "jsr:@std/cli/parse-args"; // specification: https://docs.openclaw.ai/gateway/secrets @@ -110,14 +110,20 @@ async function getSecretValue( } const flags = parseArgs(args(), { - boolean: ["help"], + boolean: ["help", "direct-output"], collect: ["id"], + alias: { + d: "direct-output", + }, }); if (flags.help) { console.log( "export RUN_ENV=ALIBABA_CLOUD or `echo ALIBABA_CLOUD > ~/.config/envs/RUN_ENV` runs on Alibaba Cloud", ); + console.log( + "openclaw-secret.ts --id ID1 [--id ID2] [--direct-output|-d]", + ); console.log( 'echo \'{"protocolVersion": 1, "provider": "vault", "ids": ["providers/openai/apiKey"]}\' | openclaw-secret.ts', ); @@ -152,6 +158,18 @@ if (openClawInput.protocolVersion !== 1) { exit(1); } +if (flags["direct-output"]) { + if (openClawInput.ids.length != 1) { + console.error( + `--direct-output requires only one id`, + openClawInput.ids, + ); + exit(1); + } + console.log(await getSecretValue(isOnAlibabaCloud, openClawInput.ids[0])); + exit(0); +} + for (const id of openClawInput.ids) { try { values[id] = await getSecretValue(isOnAlibabaCloud, id);