openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
37 lines (36 loc) • 1.72 kB
JavaScript
import { h as readNonEmptyStringPreservingWhitespace } from "./string-coerce-CCIiB4H7.mjs";
import { i as stripAnsi } from "./ansi-CZa2t0Hf.mjs";
import { u as truncateRelayText } from "./native-hook-relay-utils-vHMzjiyc.mjs";
//#region src/agents/harness/native-hook-relay-approval-presentation.ts
function formatNativeHookRelayApprovalPresentation(e) {
return formatHarnessApprovalPresentation({
title: "Codex permission request",
description: formatPermissionApprovalDescription(e)
});
}
function formatPermissionApprovalDescription(e) {
return [
`Tool: ${sanitizeApprovalText(e.toolName)}`,
e.cwd ? `Cwd: ${sanitizeApprovalText(e.cwd)}` : void 0,
e.model ? `Model: ${sanitizeApprovalText(e.model)}` : void 0,
formatToolInputPreview(e.toolInput)
].filter((e) => Boolean(e)).join("\n");
}
function formatToolInputPreview(e) {
const t = readNonEmptyStringPreservingWhitespace(e.command);
if (t) return `Command: ${truncateRelayText(sanitizeApprovalText(t), 240)}`;
const n = Object.keys(e).map(sanitizeApprovalText).filter(Boolean).toSorted();
if (!n.length) return;
return `Input keys: ${n.slice(0, 12).join(", ")}${n.length > 12 ? ` (${n.length - 12} omitted)` : ""}`;
}
function sanitizeApprovalText(e) {
return stripAnsi(e).replace(/[\p{Cc}\u202a-\u202e\u2066-\u2069]/gu, " ").replace(/\s+/g, " ").trim();
}
function formatHarnessApprovalPresentation(e) {
return {
title: truncateRelayText(sanitizeApprovalText(e.title), 80),
description: truncateRelayText(e.description.split("\n").map(sanitizeApprovalText).join("\n"), 512)
};
}
//#endregion
export { formatNativeHookRelayApprovalPresentation as n, formatPermissionApprovalDescription as r, formatHarnessApprovalPresentation as t };