mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:00:42 +00:00
refactor(approvals): unify structured path display
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type AgentApprovalEventData,
|
||||
formatApprovalDisplayPath,
|
||||
type EmbeddedRunAttemptParams,
|
||||
} from "openclaw/plugin-sdk/agent-harness-runtime";
|
||||
import {
|
||||
@@ -431,15 +432,10 @@ function sanitizePermissionHostValue(value: string): string {
|
||||
}
|
||||
|
||||
function sanitizePermissionPathValue(value: string): string {
|
||||
const normalized = sanitizePermissionScalar(value);
|
||||
const homeCompacted = normalized
|
||||
.replace(/^\/home\/(?!\.{1,2}(?=\/|$))[^/]+(?=\/|$)/, "~")
|
||||
.replace(/^\/Users\/(?!\.{1,2}(?=\/|$))[^/]+(?=\/|$)/, "~")
|
||||
.replace(/^[A-Za-z]:[\\/]Users[\\/](?!\.{1,2}(?=[\\/]|$))[^\\/]+(?=[\\/]|$)/i, "~");
|
||||
const displayPath = homeCompacted.startsWith("~")
|
||||
? homeCompacted.replace(/\\/g, "/")
|
||||
: homeCompacted;
|
||||
return truncate(displayPath, PERMISSION_VALUE_MAX_LENGTH);
|
||||
return truncate(
|
||||
formatApprovalDisplayPath(sanitizePermissionScalar(value)),
|
||||
PERMISSION_VALUE_MAX_LENGTH,
|
||||
);
|
||||
}
|
||||
|
||||
function sanitizePermissionScalar(value: string): string {
|
||||
|
||||
Reference in New Issue
Block a user