clientdetect

package
v0.0.0-...-4f7fa88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const IsolatedOpenCodeProbeTimeout = 30 * time.Second

IsolatedOpenCodeProbeTimeout allows cold native startup without permitting callers to extend the isolated probe's finite budget.

View Source
const OpenCodeProbeTimeout = 10 * time.Second

Variables

View Source
var (
	ErrInvalidProbeTarget    = errors.New("host_target_invalid")
	ErrUnverifiedProbeTarget = errors.New("host_target_unverified")
	ErrProbeTargetChanged    = errors.New("host_target_changed")
)

Functions

func CopyOpenCodeProbeEnvironment

func CopyOpenCodeProbeEnvironment(env []string) ([]string, error)

CopyOpenCodeProbeEnvironment validates and canonicalizes an independent copy. Case-equivalent duplicates are rejected on all platforms to keep snapshots portable. An empty PATH is valid and never replaced with ambient PATH.

func IsNotFound

func IsNotFound(err error) bool

func OpenCodeProbeEnvironment

func OpenCodeProbeEnvironment() []string

OpenCodeProbeEnvironment captures only process-launch variables. It does not inspect HOME, provider, config, or credential variables. New pins this copy.

func OpenCodeRootIdentity

func OpenCodeRootIdentity(root string) string

OpenCodeRootIdentity resolves existing ancestors even when the selected config root has not been created yet. Ordinary directory creation preserves it.

Types

type Detector

type Detector struct {
	HomeDir                     string
	WorkingDir                  string
	GOOS                        string
	Environment                 map[string]string
	SystemApplicationsDir       string
	WindowsProgramFiles         []string
	LinuxApplicationDirs        []string
	LookPath                    func(string) (string, error)
	Lstat                       func(string) (fs.FileInfo, error)
	ReadDir                     func(string) ([]os.DirEntry, error)
	EvalSymlinks                func(string) (string, error)
	ProbeVersionWithEnvironment func(context.Context, string, []string) (string, error)
	// An explicitly injected legacy probe overrides the OS probe. It cannot
	// carry a profile environment, so clients requiring one remain unprobed.
	// Use ProbeVersionWithEnvironment and leave ProbeVersion nil for those clients.
	ProbeVersion           func(context.Context, string) (string, error)
	VersionTimeout         time.Duration
	TargetedVersionTimeout time.Duration
	// Registry supplies the client adapters that know where each client keeps
	// its surfaces. It is injected by the composition root and never defaulted
	// to "every client": that would link every adapter into any binary that
	// merely detects clients.
	Registry *clients.Registry
}

func NewOS

func NewOS(homeDir string) Detector

NewOS builds the detector for the machine it runs on. The registry stays unset on purpose - only the composition root decides which clients a binary knows about, so it assigns Registry before the detector is used.

func (Detector) Detect

func (detector Detector) Detect(ctx context.Context) ([]domain.DetectedClient, error)

func (Detector) DetectTargetsWithVersionProbe

func (detector Detector) DetectTargetsWithVersionProbe(ctx context.Context, targets []domain.ClientID) ([]domain.DetectedClient, error)

func (Detector) DetectWithVersionProbe

func (detector Detector) DetectWithVersionProbe(ctx context.Context) ([]domain.DetectedClient, error)

DetectWithVersionProbe is reserved for explicit lifecycle resolution that needs the installed client version to bind signed Directory evidence. Detect itself is strictly observational and never executes a discovered binary.

type ProbeEvidence

type ProbeEvidence struct {
	opencodehost.VersionEvidence
	Reason string
}

func ProbeIsolatedOpenCodeTarget

func ProbeIsolatedOpenCodeTarget(ctx context.Context, target ProbeTarget) (ProbeEvidence, error)

ProbeIsolatedOpenCodeTarget uses private HOME, XDG and temporary roots and an empty OpenCode configuration. It accepts the same strict launch environment and native executable authority as ProbeOpenCodeTarget. No caller-provided config or credential overrides are accepted, and cleanup follows process Wait.

func ProbeOpenCodeTarget

func ProbeOpenCodeTarget(ctx context.Context, target ProbeTarget) (ProbeEvidence, error)

ProbeOpenCodeTarget supports native executable bytes and bounded symlinks to native bytes only. Scripts/npm shims are deliberately unverified and are not executed. Runtime authority is checked both sides of the version invocation.

type ProbeTarget

type ProbeTarget struct {
	Executable  string        `json:"-"`
	Environment []string      `json:"-"`
	Timeout     time.Duration `json:"-"`
}

ProbeTarget never selects an executable from PATH. Timeout may shorten the selected probe's fixed maximum. Environment contains one PATH and no config.

func (ProbeTarget) Clone

func (t ProbeTarget) Clone() ProbeTarget

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL