chore: import clean Agent Desk snapshot (2/7)

This commit is contained in:
2026-10-16 11:57:21 +00:00
parent 79176541c7
commit 89c5231c4c
461 changed files with 60092 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package tooling
import (
"regexp"
"strings"
)
const maxPreviewChars = 4000
var secretAssignmentPattern = regexp.MustCompile(`(?i)(?:"|')?(api[_-]?key|authorization|password|secret|token|cookie)(?:"|')?\s*([:=])\s*(?:"[^"]*"|'[^']*'|[^\s,;}]+)`)
// SanitizePreview keeps audit/model previews bounded and masks common secrets.
// It intentionally operates on plain text so it also covers malformed JSON.
func SanitizePreview(value string) string {
value = strings.TrimSpace(value)
if value == "" {
return ""
}
value = secretAssignmentPattern.ReplaceAllString(value, "$1$2***")
runes := []rune(value)
if len(runes) <= maxPreviewChars {
return value
}
return strings.TrimSpace(string(runes[:maxPreviewChars])) + "\n[preview truncated]"
}