UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

6 lines • 1.56 kB
import{h as readNonEmptyStringPreservingWhitespace}from"./string-coerce-CpTFcSwY.mjs";import{i as stripAnsi}from"./ansi-54CEWBZf.mjs";import{u as truncateRelayText}from"./native-hook-relay-utils-BshMn1ot.mjs"; //!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(` `)}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(` `).map(sanitizeApprovalText).join(` `),512)}}export{formatNativeHookRelayApprovalPresentation as n,formatPermissionApprovalDescription as r,formatHarnessApprovalPresentation as t};