win 21325afb33
Some checks failed
CI / test (push) Failing after 10s
CI / frontend (push) Failing after 8s
CI / golangci-lint (push) Failing after 5s
Security Scan / backend-security (push) Failing after 5s
Security Scan / frontend-security (push) Failing after 4s
feat(windsurf): 补全ops日志记录与endpoint派生,对齐其他平台
- windsurf_gateway_service: 添加上游延迟/TTFT/错误上下文记录
- endpoint: DeriveUpstreamEndpoint 添加 PlatformWindsurf 分支
- ops_error_logger: guessPlatformFromPath 添加 /windsurf/ 识别
2026-04-23 20:46:27 +08:00

41 lines
1.0 KiB
Go

package windsurf
import "strings"
// SanitizePath scrubs server-internal filesystem paths from model output.
// /tmp/windsurf-workspace/foo → [unmounted-workspace]/foo, /opt/windsurf/… → [internal].
func SanitizePath(s string) string {
if s == "" {
return s
}
s = replacePathPrefix(s, "/tmp/windsurf-workspace", "[unmounted-workspace]")
s = replacePathPrefix(s, "/opt/windsurf", "[internal]")
s = replacePathPrefix(s, "/root/WindsurfAPI", "[internal]")
return s
}
func replacePathPrefix(s, prefix, replacement string) string {
for {
idx := strings.Index(s, prefix)
if idx < 0 {
return s
}
end := idx + len(prefix)
if end < len(s) && s[end] == '/' {
s = s[:idx] + replacement + s[end:]
} else if end == len(s) || isPathTerminator(s[end]) {
s = s[:idx] + replacement + s[end:]
} else {
s = s[:idx] + replacement + s[end:]
}
}
}
func isPathTerminator(b byte) bool {
switch b {
case ' ', '"', '\'', '`', '<', '>', ')', '}', ']', ',', '*', ';', '\n', '\r', '\t':
return true
}
return false
}