Documentation
¶
Overview ¶
Resolves the icebath home directory, its named profiles and the files inside them
Index ¶
- Constants
- Variables
- func AccountDefault(ctx context.Context) string
- func AdoptRecordKey(record *jsonutil.Object)
- func ApplyIPv4Preference(force bool)
- func ApplyScratchTmpEnv(ctx context.Context, env map[string]string) bool
- func ApplySecureDirPolicy(ctx context.Context, path, h string)
- func ApplySubprocessHomeEnv(ctx context.Context, env map[string]string)
- func AssertProfileLive(path string) error
- func AuthPath(h string) string
- func BundlesDir(h string) string
- func CacheDir(h string) string
- func CandidateNodeCommandNames(command string) []string
- func CaptureProfileFallbackWarning(w io.Writer) func()
- func CaptureScratchPruneSpawns() (*[]string, func())
- func ClearProfileDeleted(profileHome string) error
- func ConfigPath(h string) string
- func ContainerOrChmodSkipped() bool
- func CronDir(h string) string
- func DetachAttr(breakaway bool) *syscall.SysProcAttr
- func Dir(ctx context.Context) string
- func DispatchScratchPruneEntry(ctx context.Context)
- func Display(path string) string
- func EnsureScratchDir(ctx context.Context, h string) string
- func EnvPath(h string) string
- func ExportScratchTmpEnv(ctx context.Context) bool
- func GrantUserAccess(ctx context.Context, path string, elevated, repairChildren bool) bool
- func IcebathDir(h, newSubpath, oldName string) string
- func InstallRoot() string
- func IsReparsePoint(path string) bool
- func IterTreeWithoutReparsePoints(root string, skipped *[]string) iter.Seq2[string, bool]
- func Key(path string) string
- func LineageWithStartTimes() ([]lineageEntry, bool)
- func ListProfiles(root string) []string
- func LoadStuckSkips(root string, persist bool) (map[string]bool, error)
- func LocalesDir(h string) string
- func LogsDir(h string) string
- func MakeUserDir(ctx context.Context, path string, mode os.FileMode, parents, existOK bool) (string, error)
- func ManagedNodeTreePresent(ctx context.Context, h string) bool
- func ManagedSystem(ctx context.Context, h string) string
- func MarkHomeErased(h string)
- func MarkProfileDeleted(profileHome string) error
- func MemoriesDir(h string) string
- func Mkdir(ctx context.Context, path string) (string, error)
- func NamedProfileHome(path string) string
- func NodeDirs(ctx context.Context, h string) []string
- func NormHomePath(path string) string
- func NormalizeScope(scope string) string
- func OpenRouterVariantBase(modelID string) string
- func OptionalSkillsDir(ctx context.Context, def string) string
- func Override(ctx context.Context) string
- func PackagedDir(ctx context.Context, envVar, def, subdir string) string
- func PatchPlatformDefault(dir string) (restore func())
- func PatchUserHome(dir string) (restore func())
- func PathMkdir(p string, mode os.FileMode, parents, existOK bool) error
- func PendingDir(h string) string
- func PinProcess(path string, unpin bool)
- func PlatformDefault() string
- func PluginDataDir(h string) string
- func PluginsDir(h string) string
- func Process() string
- func ProcessIsElevated() bool
- func ProcessPinned() bool
- func ProfileCLISelector(h string) string
- func ProfileDeleted(profileHome string) bool
- func ProfileHasIdentity(profileHome string) bool
- func ProfileHome(root, name string) string
- func ProfileIdentityMarkers() []string
- func ProfileLive(profileHome string) bool
- func ProfileNameFor(path string) string
- func PruneIdleEntries(root string, maxIdleHours float64, skipNames map[string]bool, logFile string) (int, error)
- func PruneScratchDir(ctx context.Context, scratch string, maxIdleHours float64) (int, error)
- func RealHome(ctx context.Context, env map[string]string) string
- func RecordValue(lookup func(string) (any, bool), key string) (any, bool)
- func ReleaseGitWorktrees(repos map[string]bool)
- func RemovalHint(entry string) string
- func RepairWindowsHomeACL(ctx context.Context, elevated *bool) error
- func ResetKeyCache()
- func ResetScratchPruneLatch()
- func RetiredRecordKey(key string) string
- func Root() string
- func RootForEnvironment(environ map[string]string) string
- func RootOf(home string) string
- func RoutingProcess() string
- func RunScratchPrune(ctx context.Context, args []string) int
- func ScratchDir(h string) string
- func ScratchDirUsageBytes(ctx context.Context, scratch string) int64
- func ScratchDirWithoutPrune(ctx context.Context, h string) string
- func SecureParentDir(path string)
- func SessionsDir(h string) string
- func SetWSLProbe(probe func() bool) (previous func() bool)
- func SkillsDir(h string) string
- func SocketSafeTmpdir() (string, error)
- func SoulPath(h string) string
- func StatePath(h string) string
- func StuckEntries(root string) ([]string, error)
- func SubprocessHome(ctx context.Context, env map[string]string) string
- func SubtreeTouchState(path string, cutoff float64) string
- func SudoInvokerDefaultHome() string
- func TombstonePath(profileHome string) string
- func TranslateCwdForWSLBackend(cwd string) string
- func UnusableDirRemedy(path string) string
- func UserHome() (string, error)
- func WSLUNCPathToPosix(path string) (string, bool)
- func WindowsPathToWSL(path string) (string, bool)
- func WithOverride(ctx context.Context, path string) context.Context
- type ErrHomeErased
- type ErrProfileMissing
- type GrantFailure
- type ReparsePointRefused
Constants ¶
const ( OpenRouterBaseURL = "https://openrouter.ai/api/v1" OpenRouterModelsURL = OpenRouterBaseURL + "/models" AIGatewayBaseURL = "https://ai-gateway.vercel.sh/v1" )
const ( FileAttributeDirectory = 0x10 FileAttributeReparsePoint = 0x400 )
const ( // Env var holding the scratch dir icebath itself exported into the temp vars ScratchDirMarkerEnv = "ICEBATH_SCRATCH_DIR" // Hours without a write anywhere in a scratch entry before the prune removes it ScratchMaxIdleHours = 24 )
const ( // Scratch file remembering entries this user cannot delete StuckStateName = ".prune_stuck.json" // Lock file serializing read merge write of the stuck state StuckLockName = StuckStateName + ".lock" )
const AttachmentMaxBytes = 16 * 1024 * 1024
Size ceiling for an attachment staged on the host before the base64 read back
const DefaultIndicatorStyle = "unicode"
const DirName = dirName
DirName is the dot directory name of a default home
const EnvHome = "ICEBATH_HOME"
Environment variable naming the home directory of the running process
const EnvSuffix = "ICEBATH_DATA_DIR_SUFFIX"
Environment variable appending a suffix to the platform default directory name
const FinishReasonLength = "length"
Provider finish reason for an output length stop
const PartialStreamStubID = "partial-stream-stub"
Request id of the synthetic response a stream cut short by the length limit leaves behind
const ProfilesDir = "profiles"
Directory holding named profiles under the root home
const RecordKey = "icebath_home"
Key of the home directory in pid, lock, identity and runtime records
const ScratchPruneEntry = "__icebath_scratch_prune__"
Hidden first argument a main or TestMain routes to RunScratchPrune through DispatchScratchPruneEntry before any other parsing
const SocketTmpdirMaxLen = 50
Longest temp root that leaves room for Chrome and code kernel AF_UNIX socket names
Variables ¶
var ConnectorDownloadsSubdir = filepath.Join("downloads", "connectors")
Where connector tool results save the files they return, under each profile home
var IndicatorStyles = []string{"ascii", "emoji", "unicode"}
Busy indicator styles the TUI accepts and the one it starts with
var LocalRuntimeRootDirs = map[string]bool{"models": true, "runtimes": true, "node": true}
Root directories of the default home that hold local models and runtimes
var OpenRouterVariantSuffixes = map[string]bool{"nitro": true, "floor": true, "exacto": true, "online": true}
OpenRouter request time routing suffixes valid on any model id and never separate catalog entries
var ProfileIDRe = regexp.MustCompile(`^[a-z0-9][a-z0-9_-]{0,63}$`)
Profile id grammar every profile directory gate shares
var ScratchTmpEnvVars = []string{"TMPDIR", "TMP", "TEMP"}
Temp vars pointed at the scratch dir for every icebath process and child
Functions ¶
func AccountDefault ¶
Default home of the OS account, the process platform default when the user home resolves to the account home
func AdoptRecordKey ¶
Moves the home of a record an older icebath wrote to the current key in place, so the next write carries it
func ApplyIPv4Preference ¶
func ApplyIPv4Preference(force bool)
Makes the process resolve unspecified address families as IPv4 first, the network.force_ipv4 setting
func ApplyScratchTmpEnv ¶
Points TMPDIR, TMP and TEMP in env at the scratch dir of its ICEBATH_HOME unless the user set them
func ApplySecureDirPolicy ¶
Owner only directory unless the home is managed, a container keeps its modes, or ICEBATH_HOME_MODE names one
func ApplySubprocessHomeEnv ¶
Sets HOME and ICEBATH_REAL_HOME per the home mode and points the temp variables at the scratch dir
func AssertProfileLive ¶
Fails when path lies under a home this process erased or under a deleted or missing named profile
func CandidateNodeCommandNames ¶
File names a Node tool command may carry on this platform, the cmd shim first on Windows
func CaptureProfileFallbackWarning ¶
Routes the profile fallback warning to w with its once latch rearmed, returning the function that restores both
func CaptureScratchPruneSpawns ¶
func CaptureScratchPruneSpawns() (*[]string, func())
Records detached prune launches instead of starting them with the once latch rearmed, returning the record and its restore
func ClearProfileDeleted ¶
Unlinks the tombstone file of a profile, a missing one ignored and a directory in its place refused and kept
func ContainerOrChmodSkipped ¶
func ContainerOrChmodSkipped() bool
Operator chmod skip or container signal that leaves directory modes to the deployment
func DetachAttr ¶
func DetachAttr(breakaway bool) *syscall.SysProcAttr
DetachAttr is the detached child attribute set, a new session outside Windows
func DispatchScratchPruneEntry ¶
Runs the prune and exits when argv carries the entry, otherwise records that this binary handles it
func Display ¶
Path relative to the user home as a tilde posix path, the path itself when outside the user home or when no user home is known
func EnsureScratchDir ¶
Creates and secures the scratch dir of h or the active home and starts its hourly detached prune
func ExportScratchTmpEnv ¶
Boot hook pointing this process temp vars at its scratch dir, rerun after anything re-homes the process
func GrantUserAccess ¶
Gives the user an inheriting full control ACE on path when elevated, true when the grant took
func IcebathDir ¶
Home subdirectory, a populated legacy directory winning over the new subpath
func InstallRoot ¶
func InstallRoot() string
Directory of the resolved running binary, the install tree secure parent hardening never chmods
func IsReparsePoint ¶
True when path itself is a symlink, junction or other reparse point, or cannot be lstat-ed
func IterTreeWithoutReparsePoints ¶
Yields root and everything under it, never entering or yielding a link, which lands in skipped
func Key ¶
Stable key of a home directory, the resolved path, cached once the directory exists; a leading ~ whose home is unknown is kept as written, and a path that cannot be resolved is keyed as it is spelled
func LineageWithStartTimes ¶
func LineageWithStartTimes() ([]lineageEntry, bool)
This process and its ancestors with start stamps, false when any link cannot be read
func ListProfiles ¶
Names of every live named profile under root, sorted
func LoadStuckSkips ¶
Names to skip this pass, dropping records that no longer hold and persisting that unless persist is false
func MakeUserDir ¶
func MakeUserDir(ctx context.Context, path string, mode os.FileMode, parents, existOK bool) (string, error)
pathlib mkdir that keeps a directory an elevated Windows process creates usable by the same user unelevated
func ManagedNodeTreePresent ¶
Reports whether a legacy managed Node tree with node, npm or npx sits in the home
func ManagedSystem ¶
Package manager owning the install from ICEBATH_MANAGED or the home marker, empty when unmanaged
func MarkHomeErased ¶
func MarkHomeErased(h string)
Records that this process erased the home h, refusing every later directory it would create under h
func MarkProfileDeleted ¶
Writes the tombstone of a profile, its directory and missing parents created first
func Mkdir ¶
Creates path and its parents through MakeUserDir, refusing to materialize a dead profile
func NamedProfileHome ¶
Profile home that path is or passes through on its way down, dot-dot elements kept as steps through the directory before them, empty when path is not a named profile
func NodeDirs ¶
Historical managed Node directories of a home, bin first on POSIX and the node dir first on Windows
func NormHomePath ¶
Comparable absolute and case normalized form of a home path, empty for blank input
func NormalizeScope ¶
Registry write scope key, empty staying empty for the process global layer and anything else keyed like Key
func OpenRouterVariantBase ¶
Base model id when the id carries a routing variant suffix, empty otherwise
func OptionalSkillsDir ¶
Optional skills directory honoring package manager wrappers
func PackagedDir ¶
Package manager relocatable directory from envVar, then def, then the subdir of the active home
func PatchPlatformDefault ¶
func PatchPlatformDefault(dir string) (restore func())
Serves the platform default home under dir keeping its name, as test isolation does, returning the restore
func PatchUserHome ¶
func PatchUserHome(dir string) (restore func())
Serves dir as the user home until the returned restore runs
func PinProcess ¶
Pins the home this process serves as its own profile for routed profile decisions, unpin clears it
func PlatformDefault ¶
func PlatformDefault() string
Platform default home of the running process; without a user home there is no folder for the data, and it panics with the noDataHome error
func Process ¶
func Process() string
Home directory of the process from the environment variable or the platform default
func ProcessIsElevated ¶
func ProcessIsElevated() bool
True for an elevated Windows process, false on every other host or on any probe error
func ProfileCLISelector ¶
Returns the -p name selector with a trailing space for a named profile home, empty for default or custom homes
func ProfileDeleted ¶
Reports whether the profile was deleted
func ProfileHasIdentity ¶
Reports whether a profile directory carries a file that identifies it as a profile
func ProfileHome ¶
Home directory of the named profile under the root, the root for default
func ProfileIdentityMarkers ¶
func ProfileIdentityMarkers() []string
Files whose presence marks a directory as a real profile home, the identity markers
func ProfileLive ¶
Reports whether the profile exists, has identity and is not deleted
func ProfileNameFor ¶
Profile id owning path, default for the root home, empty when path is no home or starts with a ~ whose home is unknown
func PruneIdleEntries ¶
func PruneIdleEntries(root string, maxIdleHours float64, skipNames map[string]bool, logFile string) (int, error)
Deletes entries of root idle for maxIdleHours after reaping processes and worktrees rooted in them, returns the count
func PruneScratchDir ¶
Removes scratch entries idle for maxIdleHours after reaping what runs in them, logging to logs/scratch-prune.log
func RealHome ¶
The OS user's real home, never the profile home, the temp root when no candidate fits
func RecordValue ¶
Value of a home record key, the older spelling read from a record written before the rename
func ReleaseGitWorktrees ¶
Runs git worktree prune in each repo so registrations of deleted trees are dropped
func RemovalHint ¶
Command that clears entry, with a sudo free docker variant when docker is installed
func RepairWindowsHomeACL ¶
Grants the user back the home tree an elevated update left Administrators only, an error when nothing took
func ResetScratchPruneLatch ¶
func ResetScratchPruneLatch()
Rearms the once per process prune latch the way a fresh process starts
func RetiredRecordKey ¶
Same record key in the spelling records of an older icebath carry
func Root ¶
func Root() string
Root home that owns the profile tree, derived from the process home; panics with the noDataHome error when no user home is known
func RootForEnvironment ¶
Root another process started with environ resolves, empty when the answer depends on anything outside environ
func RoutingProcess ¶
func RoutingProcess() string
Launch home for routed profile decisions, the expanded pinned home else the process home
func RunScratchPrune ¶
Detached child entry running one prune of the scratch dir while sparing the launcher ancestry
func ScratchDir ¶
Scratch directory a home hands to child processes as their temp dir
func ScratchDirUsageBytes ¶
Total lstat bytes of every non directory os.walk lists under the scratch dir, zero when unreadable
func ScratchDirWithoutPrune ¶
Scratch dir of h, created and permissioned with no prune handed to a child
func SecureParentDir ¶
func SecureParentDir(path string)
Restricts the resolved parent of path to 0700, never the root, a top level dir or the install tree; a parent that cannot be resolved is left as it is with a warning
func SetWSLProbe ¶
Replaces the WSL probe of the cwd translation and returns the probe it replaced
func SocketSafeTmpdir ¶
Temp root short enough for AF_UNIX sockets, the system root when the default one is too long
func StuckEntries ¶
Entries the prune currently skips as not removable, for the doctor report
func SubprocessHome ¶
HOME a subprocess gets under TERMINAL_HOME_MODE, empty when it keeps its own
func SubtreeTouchState ¶
Touched, scan-failed or idle for the subtree at path against cutoff, hardlinked files never counting as writes
func SudoInvokerDefaultHome ¶
func SudoInvokerDefaultHome() string
Invoking user's native home when this process is root under sudo, empty otherwise
func TombstonePath ¶
Tombstone file marking a profile as deleted
func TranslateCwdForWSLBackend ¶
A Windows host cwd mapped to POSIX when icebath runs inside WSL, unchanged elsewhere or when already POSIX
func UnusableDirRemedy ¶
One line repair for a directory this process may not use
func UserHome ¶
Home directory of the current user, an error wrapping pathutil.ErrNoHome when none is known; the replacement lookup when a test installed one
func WSLUNCPathToPosix ¶
The POSIX path inside a wsl.localhost or wsl$ UNC path, false when path is not one
func WindowsPathToWSL ¶
The /mnt drive form of a Windows drive path, false when path is not one
Types ¶
type ErrHomeErased ¶
type ErrHomeErased struct {
Home string
}
Error of a path under a home this process erased
func (*ErrHomeErased) Error ¶
func (e *ErrHomeErased) Error() string
func (*ErrHomeErased) Is ¶
func (e *ErrHomeErased) Is(target error) bool
Matches fs.ErrNotExist, the home data no longer exists
type ErrProfileMissing ¶
type ErrProfileMissing struct {
Home string
}
Error of a path under a named profile that was deleted or never created
func (*ErrProfileMissing) Error ¶
func (e *ErrProfileMissing) Error() string
func (*ErrProfileMissing) Is ¶
func (e *ErrProfileMissing) Is(target error) bool
Matches fs.ErrNotExist, the profile home does not exist
type GrantFailure ¶
Outcome of one failed grant in a tree walk, the path and the error text
func GrantTreeUserAccess ¶
func GrantTreeUserAccess(root string, pinRoot, elevated bool) (int, []string, []GrantFailure, error)
Elevated recursive grant over root and everything under it, never through a link
type ReparsePointRefused ¶
type ReparsePointRefused struct{ Msg string }
Refusal to grant through a junction, symlink, other reparse point or hard link
func (*ReparsePointRefused) Error ¶
func (e *ReparsePointRefused) Error() string
Source Files
¶
- constants_extra.go
- constants_values.go
- detach_unix.go
- dir_acl.go
- dir_acl_unix.go
- home.go
- icebath_dir.go
- identity_markers.go
- ipv4_preference.go
- layout.go
- log.go
- profile_cli_selector.go
- record_key.go
- scratch.go
- scratch_detach.go
- scratch_env.go
- scratch_prune.go
- scratch_stuck.go
- scratch_stuck_unix.go
- secure_dir.go
- secure_parent.go
- subprocess_home.go
- update_acl.go
- wsl_paths.go
- wsl_probe.go