UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

33 lines (32 loc) • 2.02 kB
//#region src/plugin-sdk/approval-terminal.ts const TERMINAL_LABELS = { "allow-once": "Allowed once", "allow-always": "Allowed always", deny: "Denied", cancelled: "Cancelled", applied: "Applied", "not-applied": "Completion unconfirmed" }; /** Label a recorded decision without implying that a system change was applied. */ function formatApprovalDecisionLabel(e) { return TERMINAL_LABELS[e]; } function interpretApprovalTerminalOutcome(e, t) { if (e.approvalKind !== "system-agent") return e.decision; if (e.terminalStatus === "cancelled") return "cancelled"; return e.decision === "deny" && (t === "denial" || e.applicationStatus === "not-applied") ? "deny" : e.applicationStatus ?? e.decision; } /** Format a rich terminal label, retaining transport-specific decision spelling. */ function formatChannelApprovalResolvedLabel(e, t) { const n = interpretApprovalTerminalOutcome(e, "application"); return t && n === e.decision ? t(e.decision) : TERMINAL_LABELS[n]; } /** Describe a system change using denial-first prose and a prepared operation summary. */ function buildSystemAgentApprovalResolvedText(e) { const t = interpretApprovalTerminalOutcome(e, "denial"); return t === "cancelled" ? "⚠️ OpenClaw change was cancelled because its run ended. No change was made. Retry." : t === "deny" ? "❌ OpenClaw change denied. No change was made." : t === "applied" ? `✅ OpenClaw change approved and applied: ${e.operationSummary}` : t === "not-applied" ? "⚠️ OpenClaw change approved, but completion could not be confirmed. Check the current settings before retrying." : `✅ OpenClaw change approved. Applying: ${e.operationSummary}`; } /** Terminal copy for a system change approval that expired before a decision. */ const SYSTEM_AGENT_APPROVAL_EXPIRED_TEXT = "⏱️ OpenClaw change expired. No change was made."; //#endregion export { formatChannelApprovalResolvedLabel as i, buildSystemAgentApprovalResolvedText as n, formatApprovalDecisionLabel as r, SYSTEM_AGENT_APPROVAL_EXPIRED_TEXT as t };