UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

34 lines (33 loc) 2.65 kB
import { l as normalizeOptionalString } from "./string-coerce-CIXf7egm.js"; import { c as buildPluginApprovalExpiredMessage, u as buildPluginApprovalResolvedMessage } from "./plugin-approvals-BUrr4V_c.js"; import { s as normalizeApprovalRequest } from "./approval-request-account-binding-Sc-eGYO-.js"; import "./approval-gateway-runtime-Dq_qSpK7.js"; import { n as buildApprovalResolvedReplyPayload } from "./approval-renderers-DKlGmVsG.js"; import "./approval-handler-runtime-BZs1zst-.js"; //#region src/plugin-sdk/approval-handler-runtime.ts /** * Runtime SDK subpath for approval handler adapters and approval view text helpers. */ /** Builds channel-visible resolved approval text for exec and plugin approvals. */ function buildChannelApprovalResolvedText(params) { if (params.view.approvalKind === "system-agent") return params.view.terminalStatus === "cancelled" ? "⚠️ OpenClaw change was cancelled because its run ended. No change was made. Retry." : params.resolved.decision === "deny" ? "❌ OpenClaw change denied. No change was made." : params.view.applicationStatus === "applied" ? `✅ OpenClaw change approved and applied: ${params.view.operationSummary}` : params.view.applicationStatus === "not-applied" ? "⚠️ OpenClaw change approved, but it was not applied. Check the Gateway and retry." : `✅ OpenClaw change approved. Applying: ${params.view.operationSummary}`; if (params.view.approvalKind === "plugin") return buildPluginApprovalResolvedMessage(params.resolved); const resolvedByText = params.resolved.resolvedBy ? ` Resolved by ${params.resolved.resolvedBy}.` : ""; return buildApprovalResolvedReplyPayload({ approvalId: params.request.id, approvalSlug: params.request.id.slice(0, 8), text: `✅ Exec approval ${params.resolved.decision}.${resolvedByText} ID: ${params.request.id}` }).text ?? ""; } /** Builds channel-visible expiration text for exec and plugin approvals. */ function buildChannelApprovalExpiredText(params) { const request = normalizeApprovalRequest(params.request); if (request.approvalKind === "system-agent") return "⏱️ OpenClaw change expired. No change was made."; if (request.approvalKind === "plugin") return buildPluginApprovalExpiredMessage(request); return `⏱️ Exec approval expired. ID: ${request.id}`; } function resolvePreparedApprovalAccountId(params) { return normalizeOptionalString(params.plannedAccountId) ?? normalizeOptionalString(params.contextAccountId) ?? normalizeOptionalString(params.fallbackAccountId); } //#endregion export { buildChannelApprovalResolvedText as n, resolvePreparedApprovalAccountId as r, buildChannelApprovalExpiredText as t };