Files
tutti/packages/agent/runtimeprep/codex_provider_state_home.go
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

38 lines
1.3 KiB
Go

package runtimeprep
import (
"fmt"
"os"
"path/filepath"
"strings"
)
func resolveCodexProviderStateHome(input PrepareInput) (string, error) {
configured := strings.TrimSpace(input.ProviderStateHome)
if configured == "" {
userHome, err := os.UserHomeDir()
if err != nil || strings.TrimSpace(userHome) == "" {
// Preserve the existing Host behavior: an unavailable native user
// home omits optional Codex state projection without preventing the
// run-scoped runtime from being prepared.
return "", nil
}
// The implicit Host path keeps native filesystem semantics, including
// an existing ~/.codex symlink. Strict shape checks below apply only to
// an embedder-provided provider state root.
return filepath.Join(userHome, ".codex"), nil
}
configured = filepath.Clean(configured)
if !filepath.IsAbs(configured) || configured == string(filepath.Separator) {
return "", fmt.Errorf("codex provider state home must be an absolute non-root path: %q", input.ProviderStateHome)
}
info, err := os.Lstat(configured)
if err != nil {
return "", fmt.Errorf("inspect Codex provider state home: %w", err)
}
if info.Mode()&os.ModeSymlink != 0 || !info.IsDir() {
return "", fmt.Errorf("codex provider state home must be a real directory: %s", configured)
}
return configured, nil
}