UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

719 lines (718 loc) • 25.4 kB
import { c as normalizeOptionalLowercaseString, l as normalizeOptionalString, p as normalizeStringifiedOptionalString, t as hasNonEmptyString } from "./string-coerce-CCIiB4H7.mjs"; import { D as parseStrictPositiveInteger } from "./number-coercion-D6u-4YD8.mjs"; import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import { o as normalizeCsvOrLooseStringList } from "./string-normalization-DLmfYZXI.mjs"; import { t as parseConfigPathArrayIndex } from "./path-array-index-qP-D1DoI.mjs"; import { f as isValidSecretProviderAlias, h as resolveDefaultSecretProviderAlias, l as isValidEnvSecretRefId, o as formatExecSecretRefIdValidationMessage, u as isValidExecSecretRefId } from "./ref-contract-b8L-9DrQ.mjs"; import { _ as resolveSecretInputRef, a as coerceSecretRef } from "./types.secrets-BmNLLnHp.mjs"; import { r as terminalText } from "./safe-text-C80HAQ2e.mjs"; import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs"; import "./session-key-CqAyZeVk.mjs"; import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs"; import { _ as resolveDefaultAgentId, a as resolveAgentDir } from "./agent-scope-config-DmXgFGKP.mjs"; import { t as loadPluginManifestRegistryCore } from "./manifest-registry-CuWv8ibc.mjs"; import "./user-model-account-authority-CRj924IP.mjs"; import { t as getProviderEnvVarsCore } from "./provider-env-vars-DPvuIf4v.mjs"; import "./agent-scope-BwB8YH6y.mjs"; import { t as isSafeExecutableValue } from "./exec-safety-DkenKsFz.mjs"; import "./shared-DyBTHA2R.mjs"; import { p as assertExpectedResolvedSecretValue } from "./runtime-shared-BVJ4BbUu.mjs"; import { n as discoverConfigSecretTargets, t as discoverAuthProfileSecretTargets } from "./target-registry-query-le6rMGHo.mjs"; import "./target-registry-C0PdHjLu.mjs"; import { n as listSecretProviderIntegrationPresets } from "./provider-integrations-YWHLMzFF.mjs"; import { n as resolveSecretRefValue } from "./resolve-BYfGhigB.mjs"; import { n as loadPersistedAuthProfileStore } from "./persisted-Dv3zNYHi.mjs"; import { g as readPersistedSharedAuthProfileStoreRaw } from "./sqlite-B2CoJ4Om.mjs"; import { t as getSkippedExecRefStaticError } from "./exec-resolution-policy-DTeP4tsd.mjs"; import { i as iterateAuthProfileCredentials, t as createSecretsConfigIO } from "./config-io-C2NM6IWl.mjs"; import { t as runSecretsApply } from "./apply-D0DIQRbL.mjs"; import path from "node:path"; import { isDeepStrictEqual } from "node:util"; import { confirm, log, select, text } from "@clack/prompts"; //#region src/secrets/configure-plan.ts /** Builds the interactive `openclaw secrets configure` target list and apply plan. */ function configureCandidateSortKey(e) { if (e.configFile === "auth-profile-store") return `auth-profiles:${e.agentId ?? ""}:${e.path}`; return `openclaw:${e.path}`; } function resolveAuthProfileProvider(e, t) { const n = t[1]; if (!n) return; return e.profiles[n]?.provider.trim() || void 0; } /** Builds configure candidates for OpenClaw config plus an optional auth-profile scope. */ function buildConfigureCandidatesForScope(e) { const t = e.authoredOpenClawConfig ?? e.config; const n = []; for (const r of ["openclaw.json", "auth-profile-store"]) { const i = r === "auth-profile-store" ? e.authProfiles : void 0; if (r === "auth-profile-store" && i === void 0) continue; const a = i === void 0 ? discoverConfigSecretTargets(e.config) : discoverAuthProfileSecretTargets(i.store); for (const o of a.filter((e) => e.entry.includeInConfigure)) { const a = i === void 0 ? void 0 : resolveAuthProfileProvider(i.store, o.pathSegments); const s = resolveSecretInputRef({ value: o.value, refValue: o.refValue, defaults: e.config.secrets?.defaults }); const c = { type: o.entry.targetType, path: o.path, pathSegments: [...o.pathSegments], label: i === void 0 ? o.path : `${o.path} (auth profile, agent ${i.agentId})`, configFile: r, expectedResolvedValue: o.entry.expectedResolvedValue, ...s.ref ? { existingRef: s.ref } : {} }; if (i === void 0) { const e = hasPath(t, o.pathSegments); const n = o.refPathSegments ? hasPath(t, o.refPathSegments) : false; Object.assign(c, e || n ? {} : { isDerived: true }, o.providerId ? { providerId: o.providerId } : {}, o.accountId ? { accountId: o.accountId } : {}); } else Object.assign(c, { agentId: i.agentId }, a ? { authProfileProvider: a } : {}); n.push(c); } } return n.toSorted((e, t) => configureCandidateSortKey(e).localeCompare(configureCandidateSortKey(t))); } function hasPath(e, t) { if (t.length === 0) return false; let n = e; for (let e = 0; e < t.length; e += 1) { const r = t[e] ?? ""; if (Array.isArray(n)) { const i = parseConfigPathArrayIndex(r); if (i === void 0 || i >= n.length) return false; if (e < t.length - 1) n = n[i]; } else { if (!isRecord(n) || !Object.hasOwn(n, r)) return false; if (e < t.length - 1) n = n[r]; } } return true; } /** Computes provider upserts/deletes between original and edited config. */ function collectConfigureProviderChanges(e) { const t = e.original.secrets?.providers ?? {}; const n = e.next.secrets?.providers ?? {}; const r = {}; const i = []; for (const [e, i] of Object.entries(n)) { const n = t[e]; if (isDeepStrictEqual(n, i)) continue; r[e] = i; } for (const e of Object.keys(t)) if (!Object.hasOwn(n, e)) i.push(e); return { upserts: r, deletes: i.toSorted() }; } /** Returns true when selected targets or provider mutations would produce a plan. */ function hasConfigurePlanChanges(e) { return e.selectedTargets.size > 0 || Object.keys(e.providerChanges.upserts).length > 0 || e.providerChanges.deletes.length > 0; } /** Builds the serializable secrets apply plan from configure selections. */ function buildSecretsConfigurePlan(e) { return { version: 1, protocolVersion: 1, generatedAt: (/* @__PURE__ */ new Date()).toISOString(), generatedBy: "openclaw secrets configure", targets: [...e.selectedTargets.values()].map((e) => Object.assign({ type: e.type, path: e.path, pathSegments: [...e.pathSegments], ref: e.ref }, e.agentId ? { agentId: e.agentId } : {}, e.providerId ? { providerId: e.providerId } : {}, e.accountId ? { accountId: e.accountId } : {}, e.authProfileProvider ? { authProfileProvider: e.authProfileProvider } : {})), ...Object.keys(e.providerChanges.upserts).length > 0 ? { providerUpserts: e.providerChanges.upserts } : {}, ...e.providerChanges.deletes.length > 0 ? { providerDeletes: e.providerChanges.deletes } : {}, options: { scrubEnv: true, scrubAuthProfilesForProviderTargets: true, scrubLegacyAuthJson: false } }; } //#endregion //#region src/secrets/configure.ts /** Interactive and noninteractive secrets configure workflow. */ const WINDOWS_ABS_PATH_PATTERN = /^[A-Za-z]:[\\/]/; const WINDOWS_UNC_PATH_PATTERN = /^\\\\[^\\]+\\[^\\]+/; function isAbsolutePathValue(e) { return path.isAbsolute(e) || WINDOWS_ABS_PATH_PATTERN.test(e) || WINDOWS_UNC_PATH_PATTERN.test(e); } function parseOptionalPositiveInt(e, t) { const n = e.trim(); if (!n) return; if (!/^\d+$/.test(n)) return; const r = parseStrictPositiveInteger(n); if (r === void 0 || r > t) return; return r; } function setSecretProvider(e, t, n) { e.secrets ??= {}; e.secrets.providers ??= {}; e.secrets.providers[t] = n; } function removeSecretProvider(e, t) { if (!e.secrets?.providers) return false; const n = e.secrets.providers; if (!Object.hasOwn(n, t)) return false; delete n[t]; if (Object.keys(n).length === 0) delete e.secrets.providers; if (e.secrets.defaults) { const n = e.secrets.defaults; const r = [ "env", "file", "exec", "store" ]; for (const e of r) if (n[e] === t) delete n[e]; if (r.every((e) => n[e] === void 0)) delete e.secrets.defaults; } return true; } function providerHint(e) { if (e.source === "env") return e.allowlist?.length ? `env (${e.allowlist.length} allowlisted)` : "env"; if (e.source === "file") return `file (${e.mode ?? "json"})`; if (e.source === "store") return "store"; if ("pluginIntegration" in e) { const { pluginId: t, integrationId: n } = e.pluginIntegration; return `exec plugin (${t}:${n})`; } return `exec (${e.jsonOnly === false ? "json+text" : "json"})`; } function toSourceChoices(e) { return [ "env", "store", "file", "exec" ].filter((t) => t === "env" || t === "store" || Object.values(e.secrets?.providers ?? {}).some((e) => e.source === t)).map((e) => ({ value: e, label: e })); } function assertNoCancel(e) { if (typeof e === "symbol") throw new Error("Secrets configure cancelled."); return e; } async function promptRequiredText(e) { return assertNoCancel(await text({ ...e, validate: (t) => { const n = t?.trim() ?? ""; return n ? e.validate?.(n) : "Required"; } })).trim(); } const AUTH_PROFILE_ID_PATTERN = /^[A-Za-z0-9:_-]{1,128}$/; function validateEnvNameCsv(e) { const t = normalizeCsvOrLooseStringList(e).find((e) => !isValidEnvSecretRefId(e)); return t === void 0 ? void 0 : terminalText`Invalid env name: ${t}`; } async function promptEnvNameCsv(e) { const t = assertNoCancel(await text({ message: e.message, initialValue: e.initialValue, validate: (e) => validateEnvNameCsv(e ?? "") })); return normalizeCsvOrLooseStringList(t); } const PROVIDER_LIMITS = { timeoutMs: { label: "Timeout ms", max: 12e4 }, noOutputTimeoutMs: { label: "No-output timeout ms", max: 12e4 }, maxBytes: { label: "Max bytes", max: 20971520 }, maxOutputBytes: { label: "Max output bytes", max: 20971520 } }; async function promptOptionalPositiveInt(e, t) { const { label: n, max: r } = PROVIDER_LIMITS[e]; const i = t?.[e]; return parseOptionalPositiveInt(assertNoCancel(await text({ message: `${n} (blank for default)`, initialValue: i === void 0 ? "" : String(i), validate: (e) => { const t = normalizeStringifiedOptionalString(e) ?? ""; if (!t) return; if (parseOptionalPositiveInt(t, r) === void 0) return `Must be an integer between 1 and ${r}`; } })), r); } function configureCandidateKey(e) { if (e.configFile === "auth-profile-store") return `auth-profiles:${normalizeOptionalString(e.agentId) ?? ""}:${e.path}`; return `openclaw:${e.path}`; } function resolveSuggestedEnvSecretId(e) { const t = normalizeOptionalLowercaseString(e.authProfileProvider) ?? normalizeOptionalLowercaseString(e.providerId); if (!t) return; return getProviderEnvVarsCore(t)[0]; } function resolveConfigureAgentId(e, t) { const n = new Set(listAgentIds(e)); if (!t) return resolveDefaultAgentId(e); const r = normalizeAgentId(t); if (n.has(r)) return r; const i = [...n].toSorted().join(", "); throw new Error(`Unknown agent id "${t}". Known agents: ${i || "none configured"}.`); } /** * Counts plaintext (non-SecretRef) credentials in the canonical shared * auth-profile store. `secrets configure` only edits the selected agent's * local store; shared profiles are not writable here. Surfacing the count * lets an operator know a shared plaintext migration is pending so they do * not mistake "no shared candidate" for "shared store is clean". * * Classification mirrors `secrets audit` (audit.ts): the raw shared row is * read without normalization so a stored `key` survives even when a sibling * `keyRef` is present (the normalized loader drops `key` in that case), and * an authored value that is itself a supported SecretRef shorthand * (`$ENV` / `${ENV}`) is treated as a reference, not plaintext. */ function countSharedAuthProfilePlaintext(e) { const t = readPersistedSharedAuthProfileStoreRaw(e); if (!isRecord(t) || !isRecord(t.profiles)) return 0; let n = 0; for (const e of iterateAuthProfileCredentials(t.profiles)) { if (e.kind !== "api_key" && e.kind !== "token") continue; if (coerceSecretRef(e.value)) continue; if (hasNonEmptyString(e.value)) n += 1; } return n; } async function promptNewAuthProfileCandidate(e) { const t = await promptRequiredText({ message: "Auth profile id", validate: (e) => AUTH_PROFILE_ID_PATTERN.test(e) ? void 0 : "Use letters/numbers/\":\"/\"_\"/\"-\" only." }); const n = assertNoCancel(await select({ message: "Auth profile credential type", options: [{ value: "api_key", label: "api_key (key/keyRef)" }, { value: "token", label: "token (token/tokenRef)" }] })); const r = await promptRequiredText({ message: "Provider id" }); const i = n === "token" ? "token" : "key"; return { type: n === "token" ? "auth-profiles.token.token" : "auth-profiles.api_key.key", path: `profiles.${t}.${i}`, pathSegments: [ "profiles", t, i ], label: `profiles.${t}.${i} (auth profile, agent ${e})`, configFile: "auth-profile-store", agentId: e, authProfileProvider: r, expectedResolvedValue: "string" }; } async function promptProviderAlias(e) { return await promptRequiredText({ message: "Provider alias", initialValue: "default", validate: (t) => { if (!isValidSecretProviderAlias(t)) return "Must match /^[a-z][a-z0-9_-]{0,63}$/"; return e.existingAliases.has(t) ? "Alias already exists" : void 0; } }); } async function promptProviderSource(e) { return assertNoCancel(await select({ message: "Provider source", options: [ { value: "env", label: "env" }, { value: "file", label: "file" }, { value: "exec", label: "exec" }, { value: "store", label: "store" } ], initialValue: e })); } async function promptEnvProvider(e) { const t = await promptEnvNameCsv({ message: "Env allowlist (comma-separated, blank for unrestricted)", initialValue: e?.allowlist?.join(",") ?? "" }); return { source: "env", ...t.length > 0 ? { allowlist: t } : {} }; } async function promptFileProvider(e) { const t = await promptRequiredText({ message: "File path (absolute)", initialValue: e?.path ?? "", validate: (e) => isAbsolutePathValue(e) ? void 0 : "Must be an absolute path" }); const n = assertNoCancel(await select({ message: "File mode", options: [{ value: "json", label: "json" }, { value: "singleValue", label: "singleValue" }], initialValue: e?.mode ?? "json" })); const r = await promptOptionalPositiveInt("timeoutMs", e); const i = await promptOptionalPositiveInt("maxBytes", e); return { source: "file", path: t, mode: n, ...r ? { timeoutMs: r } : {}, ...i ? { maxBytes: i } : {} }; } async function parseArgsInput(e) { const t = e.trim(); if (!t) return; const n = JSON.parse(t); if (!Array.isArray(n) || !n.every((e) => typeof e === "string")) throw new Error("args must be a JSON array of strings"); return n; } async function promptExecProvider(e) { const t = await promptRequiredText({ message: "Command path (absolute)", initialValue: e?.command ?? "", validate: (e) => { if (!isAbsolutePathValue(e)) return "Must be an absolute path"; return isSafeExecutableValue(e) ? void 0 : "Command value is not allowed"; } }); const n = assertNoCancel(await text({ message: "Args JSON array (blank for none)", initialValue: JSON.stringify(e?.args ?? []), validate: (e) => { const t = normalizeStringifiedOptionalString(e) ?? ""; if (!t) return; try { const e = JSON.parse(t); if (!Array.isArray(e) || !e.every((e) => typeof e === "string")) return "Must be a JSON array of strings"; return; } catch { return "Must be valid JSON"; } } })); const r = await promptOptionalPositiveInt("timeoutMs", e); const i = await promptOptionalPositiveInt("noOutputTimeoutMs", e); const a = await promptOptionalPositiveInt("maxOutputBytes", e); const o = assertNoCancel(await confirm({ message: "Require JSON-only response?", initialValue: e?.jsonOnly ?? true })); const s = await promptEnvNameCsv({ message: "Pass-through env vars (comma-separated, blank for none)", initialValue: e?.passEnv?.join(",") ?? "" }); const c = assertNoCancel(await text({ message: "Trusted dirs (comma-separated absolute paths, blank for none)", initialValue: e?.trustedDirs?.join(",") ?? "", validate: (e) => { const t = normalizeCsvOrLooseStringList(e ?? ""); for (const e of t) if (!isAbsolutePathValue(e)) return terminalText`Trusted dir must be absolute: ${e}`; } })); const l = await parseArgsInput(n); const u = normalizeCsvOrLooseStringList(c); return { source: "exec", command: t, ...l && l.length > 0 ? { args: l } : {}, ...r ? { timeoutMs: r } : {}, ...i ? { noOutputTimeoutMs: i } : {}, ...a ? { maxOutputBytes: a } : {}, jsonOnly: o, ...s.length > 0 ? { passEnv: s } : {}, ...u.length > 0 ? { trustedDirs: u } : {}, ...e?.env ? { env: e.env } : {} }; } async function promptProviderConfig(e, t) { if (e === "env") return await promptEnvProvider(t?.source === "env" ? t : void 0); if (e === "file") return await promptFileProvider(t?.source === "file" ? t : void 0); if (e === "store") return { source: "store" }; return await promptExecProvider(t?.source === "exec" && "command" in t ? t : void 0); } async function configureProvidersInteractive(e, t) { const n = loadPluginManifestRegistryCore({ config: e, env: t }); const r = listSecretProviderIntegrationPresets({ manifestRegistry: n, config: e, env: t }); while (true) { const t = e.secrets?.providers ?? {}; const n = Object.entries(t).toSorted(([e], [t]) => e.localeCompare(t)); const i = r.filter((e) => { const n = t[e.providerAlias]; return !n || !isDeepStrictEqual(n, e.providerConfig); }); const a = [{ value: "add", label: "Add provider", hint: "Define a new env/file/exec/store provider" }]; if (i.length > 0) a.push({ value: "preset", label: "Use plugin preset", hint: "Configure a provider declared by an installed plugin" }); if (n.length > 0) { a.push({ value: "edit", label: "Edit provider", hint: "Update an existing provider" }); a.push({ value: "remove", label: "Remove provider", hint: "Delete a provider alias" }); } a.push({ value: "continue", label: "Continue", hint: "Move to credential mapping" }); const o = assertNoCancel(await select({ message: n.length > 0 ? "Configure secret providers" : "Configure secret providers (env/store refs are built in; add file/exec providers as needed)", options: a })); if (o === "continue") return; if (o === "add") { const t = await promptProviderSource(); setSecretProvider(e, await promptProviderAlias({ existingAliases: new Set(n.map(([e]) => e)) }), await promptProviderConfig(t)); continue; } if (o === "preset") { const n = assertNoCancel(await select({ message: "Select plugin preset", options: i.map((e) => ({ value: e, label: terminalText`${e.displayName}`, hint: terminalText`${e.providerAlias} | ${e.pluginId}:${e.id} | exec plugin` })) })); if (t[n.providerAlias]) { if (!assertNoCancel(await confirm({ message: terminalText`Replace provider "${n.providerAlias}" with the ${n.displayName} preset?`, initialValue: false }))) continue; } setSecretProvider(e, n.providerAlias, n.providerConfig); continue; } if (o === "edit" || o === "remove") { const { alias: t, provider: r } = assertNoCancel(await select({ message: o === "edit" ? "Select provider to edit" : "Select provider to remove", options: n.map(([e, t]) => ({ value: { alias: e, provider: t }, label: terminalText`${e}`, hint: terminalText`${providerHint(t)}` })) })); if (o === "edit") { const n = await promptProviderConfig(await promptProviderSource(r.source), r); if (!isDeepStrictEqual(r, n)) setSecretProvider(e, t, n); continue; } if (assertNoCancel(await confirm({ message: terminalText`Remove provider "${t}"?`, initialValue: false }))) removeSecretProvider(e, t); } } } /** Runs interactive secrets configuration and returns changed config/auth-store state. */ async function runSecretsConfigureInteractive(e = {}) { if (!process.stdin.isTTY) throw new Error("secrets configure requires an interactive TTY."); if (e.providersOnly && e.skipProviderSetup) throw new Error("Cannot combine --providers-only with --skip-provider-setup."); const t = process.env; const n = Boolean(e.allowExecInPreflight); const { snapshot: r } = await createSecretsConfigIO({ env: t }).readConfigFileSnapshotForWrite(); if (!r.valid) throw new Error("Cannot run interactive secrets configure because config is invalid."); const i = structuredClone(r.config); if (!e.skipProviderSetup) await configureProvidersInteractive(i, t); const a = collectConfigureProviderChanges({ original: r.config, next: i }); const o = /* @__PURE__ */ new Map(); if (!e.providersOnly) { const a = resolveConfigureAgentId(r.config, e.agentId); const s = resolveAgentDir(r.config, a); const c = loadPersistedAuthProfileStore(s) ?? { version: 1, profiles: {} }; const l = buildConfigureCandidatesForScope({ config: i, authoredOpenClawConfig: r.resolved, authProfiles: { agentId: a, store: c } }); const u = countSharedAuthProfilePlaintext(t); if (u > 0) log.warn(`Shared auth-profile store has ${u} plaintext credential(s). \`secrets configure\` edits the selected agent's local store only and cannot migrate shared credentials. Run \`openclaw secrets audit\` to review them; a shared-store SecretRef migration path is tracked separately.`, { output: process.stderr }); if (l.length === 0) throw new Error("No configurable secret-bearing fields found for this agent scope."); const d = toSourceChoices(i); const f = l.some((e) => e.isDerived === true); let p = false; while (true) { const e = (p ? l : l.filter((e) => e.isDerived !== true)).map((e) => ({ value: e, label: terminalText`${e.label}`, hint: [e.configFile === "auth-profile-store" ? "auth profile store" : "openclaw.json", e.isDerived === true ? "derived" : void 0].filter(Boolean).join(" | ") })); e.push({ value: "__create_auth_profile__", label: "Create auth profile mapping", hint: terminalText`Add a new auth-profiles target for agent ${a}` }); if (f) e.push({ value: "__toggle_derived__", label: p ? "Hide derived targets" : "Show derived targets", hint: p ? "Show only fields authored directly in config" : "Include normalized/derived aliases" }); if (o.size > 0) e.unshift({ value: "__done__", label: "Done", hint: "Finish and run preflight" }); const r = assertNoCancel(await select({ message: "Select credential field", options: e })); if (r === "__done__") break; if (r === "__create_auth_profile__") { const e = await promptNewAuthProfileCandidate(a); const t = configureCandidateKey(e); const n = l.findIndex((e) => configureCandidateKey(e) === t); if (n >= 0) l[n] = e; else l.push(e); continue; } if (r === "__toggle_derived__") { p = !p; continue; } const s = configureCandidateKey(r); const c = o.get(s)?.ref ?? r.existingRef; const u = c && d.some((e) => e.value === c.source) ? c.source : void 0; const m = assertNoCancel(await select({ message: "Secret source", options: d, initialValue: u })); const h = resolveDefaultSecretProviderAlias(i, m, { preferFirstProviderForSource: true }); const g = await promptRequiredText({ message: "Provider alias", initialValue: c?.source === m ? c.provider : h, validate: (e) => isValidSecretProviderAlias(e) ? void 0 : "Must match /^[a-z][a-z0-9_-]{0,63}$/" }); let _ = c?.source === m ? c.id : void 0; if (!_ && (m === "env" || m === "store")) _ = resolveSuggestedEnvSecretId(r); if (!_ && m === "file") { const e = i.secrets?.providers?.[g]; if (e?.source === "file" && e.mode === "singleValue") _ = "value"; } const v = { source: m, provider: g, id: await promptRequiredText({ message: "Secret id", initialValue: _, validate: (e) => { if ((m === "env" || m === "store") && !isValidEnvSecretRefId(e)) return `${m} ids must match /^[A-Z][A-Z0-9_]{0,127}$/`; return m === "exec" && !isValidExecSecretRefId(e) ? formatExecSecretRefIdValidationMessage() : void 0; } }) }; if (v.source === "exec" && !n) { const e = getSkippedExecRefStaticError({ ref: v, config: i }); if (e) throw new Error(e); } else { const e = await resolveSecretRefValue(v, { config: i, env: t }); assertExpectedResolvedSecretValue({ value: e, expected: r.expectedResolvedValue, errorMessage: r.expectedResolvedValue === "string" ? `Ref ${v.source}:${v.provider}:${v.id} did not resolve to a non-empty string.` : `Ref ${v.source}:${v.provider}:${v.id} did not resolve to a supported value type.` }); } const y = { ...r, ref: v }; o.set(s, y); if (!assertNoCancel(await confirm({ message: "Configure another credential?", initialValue: true }))) break; } } if (!hasConfigurePlanChanges({ selectedTargets: o, providerChanges: a })) throw new Error("No secrets changes were selected."); const s = buildSecretsConfigurePlan({ selectedTargets: o, providerChanges: a }); return { plan: s, preflight: await runSecretsApply({ plan: s, env: t, write: false, allowExec: n }) }; } //#endregion export { runSecretsConfigureInteractive };