UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

78 lines (77 loc) • 3.82 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { d as pathExists } from "./fs-safe-BbWvmdVn.mjs"; import { n as resolvePreferredOpenClawTmpDir } from "./tmp-openclaw-dir-Bf0oU1Cn.mjs"; import "./string-coerce-runtime-BwAZZDf5.mjs"; import "./security-runtime-C-zE_Zy_.mjs"; import { t as createPluginSecretRefSetupCli } from "./secret-ref-runtime-yIA1xrYi.mjs"; import "./temp-path-CW7QMeae.mjs"; import { t as parseVaultSecretId } from "./vault-secret-id-YXRkYh0r.mjs"; import { fileURLToPath } from "node:url"; import path from "node:path"; //#region 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); } //#endregion export { registerVaultCommands };