mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-31 06:25:59 +00:00
Pure cut-and-paste of functions/methods into separate files within the same package — no logic changes. Reduces file sizes for readability. - loop.go (1312→856) → loop_types.go, loop_compact.go, loop_media.go, loop_utils.go - delegate.go (687→171) → delegate_sync.go, delegate_async.go, delegate_prep.go - browser.go (605→154) → browser_tabs.go, browser_page.go, browser_remote.go - teams.go (602→170) → teams_crud.go, teams_members.go - web_fetch_convert.go (572→176) → web_fetch_convert_handlers.go, web_fetch_convert_utils.go - resolver.go (543→373) → resolver_helpers.go - sessions.go (536→157) → sessions_tokens.go, sessions_ops.go, sessions_list.go Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
870 B
Go
32 lines
870 B
Go
package agent
|
|
|
|
import "strings"
|
|
|
|
// sanitizePathSegment makes a userID safe for use as a directory name.
|
|
// Replaces colons, spaces, and other unsafe chars with underscores.
|
|
func sanitizePathSegment(s string) string {
|
|
var b strings.Builder
|
|
for _, r := range s {
|
|
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') || r == '-' || r == '_' {
|
|
b.WriteRune(r)
|
|
} else {
|
|
b.WriteByte('_')
|
|
}
|
|
}
|
|
return b.String()
|
|
}
|
|
|
|
// InvalidateUserWorkspace clears the cached workspace for a user,
|
|
// forcing the next request to re-read from user_agent_profiles.
|
|
func (l *Loop) InvalidateUserWorkspace(userID string) {
|
|
l.userWorkspaces.Delete(userID)
|
|
}
|
|
|
|
// ProviderName returns the name of this agent's LLM provider (e.g. "anthropic", "openai").
|
|
func (l *Loop) ProviderName() string {
|
|
if l.provider == nil {
|
|
return ""
|
|
}
|
|
return l.provider.Name()
|
|
}
|