openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.46 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{l as pathExists}from"./fs-safe-Bxzu1j4h.mjs";import{r as resolvePreferredOpenClawTmpDir}from"./tmp-openclaw-dir-DapBruir.mjs";import"./string-coerce-runtime-BYDH9Quw.mjs";import"./security-runtime-Y28JTB1K.mjs";import{t as createPluginSecretRefSetupCli}from"./secret-ref-runtime-Bcs6tgPC.mjs";import"./temp-path-B-Bci5oK.mjs";import{t as parseVaultSecretId}from"./vault-secret-id-Bye2cz-2.mjs";import{fileURLToPath}from"node:url";import path from"node:path";
//!extensions/vault/src/cli.ts
const vaultSecretRefSetupCli=createPluginSecretRefSetupCli({productName:`Vault`,secretIdLabel:`Vault secret id`,secretIdPlaceholder:`vault-secret-id`,defaultProviderAlias:`vault`,pluginIntegration:{pluginId:`vault`,integrationId:`vault`},normalizeSecretId:(e,t)=>{parseVaultSecretId(t);return t},defaultPlanPath:()=>path.join(resolvePreferredOpenClawTmpDir(),`openclaw-vault-secrets-${process.pid}.json`)});function writeLine(e=``){process.stdout.write(`${e}\n`)}async function resolveResolverScriptPath(){const e=[fileURLToPath(new URL(`../vault-secret-ref-resolver.js`,import.meta.url)),fileURLToPath(new URL(`./extensions/vault/vault-secret-ref-resolver.js`,import.meta.url))];for(const t of e)if(await pathExists(t))return t;return e[0]}function registerVaultCommands(e){const t=e.program.command(`vault`).description(`Manage Vault SecretRefs`);t.command(`status`).description(`Show Vault SecretRef provider status`).option(`--json`,`Print JSON status`).option(`--provider-alias <alias>`,`Secret provider alias to inspect`).action(async t=>{const n=e.config;const{providerAlias:r,provider:i}=vaultSecretRefSetupCli.inspectProvider(n,t.providerAlias);const a=normalizeOptionalString(process.env.OPENCLAW_VAULT_AUTH_METHOD)??`token`;const o={providerAlias:r,provider:i,resolverScript:await resolveResolverScriptPath(),vaultAddr:normalizeOptionalString(process.env.VAULT_ADDR),authMethod:a,authMount:normalizeOptionalString(process.env.OPENCLAW_VAULT_AUTH_MOUNT)??(a===`kubernetes`?`kubernetes`:`jwt`),authRole:normalizeOptionalString(process.env.OPENCLAW_VAULT_AUTH_ROLE),hasJwtFile:Boolean(normalizeOptionalString(process.env.OPENCLAW_VAULT_JWT_FILE)),hasVaultTokenFile:Boolean(normalizeOptionalString(process.env.VAULT_TOKEN_FILE)),kvMount:normalizeOptionalString(process.env.OPENCLAW_VAULT_KV_MOUNT)??`secret`,kvVersion:normalizeOptionalString(process.env.OPENCLAW_VAULT_KV_VERSION)??`2`,hasVaultToken:Boolean(normalizeOptionalString(process.env.VAULT_TOKEN))};if(t.json){writeLine(JSON.stringify(o,null,2));return}writeLine(`Vault provider: ${i.configured?`configured`:`not configured`}`);if(i.source)writeLine(`Source: ${i.source}`);if(i.command)writeLine(`Command: ${i.command}`);if(i.pluginIntegration)writeLine(`Plugin integration: ${i.pluginIntegration.pluginId}:${i.pluginIntegration.integrationId}`);writeLine(`Resolver: ${o.resolverScript}`);writeLine(`VAULT_ADDR: ${o.vaultAddr??`not set`}`);writeLine(`Auth method: ${o.authMethod}`);writeLine(`VAULT_TOKEN: ${o.hasVaultToken?`set`:`not set`}`);writeLine(`VAULT_TOKEN_FILE: ${o.hasVaultTokenFile?`set`:`not set`}`);writeLine(`Auth mount: ${o.authMount}`);writeLine(`Auth role: ${o.authRole??`not set`}`);writeLine(`OPENCLAW_VAULT_JWT_FILE: ${o.hasJwtFile?`set`:`not set`}`);writeLine(`KV mount: ${o.kvMount}`);writeLine(`KV version: ${o.kvVersion}`)});vaultSecretRefSetupCli.registerSetupCommand(t)}export{registerVaultCommands};