adapters

package
v0.0.0-...-10bf2d1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryDoctor

func BinaryDoctor(ctx context.Context, adapter Adapter, configured, prefix string) (Binary, []Check)

func CredentialPath

func CredentialPath(relative string) bool

CredentialPath reports paths whose basename or extension conventionally carries authentication material. It deliberately checks the basename rather than only the top-level entry so credentials nested in otherwise durable directories (for example plugins/.credentials.json) cannot be imported.

func MakeHome

func MakeHome(path string) error

func SortedUnique

func SortedUnique(values []string) []string

func TopLevel

func TopLevel(relative string) string

func VersionAtLeast

func VersionAtLeast(v Version, major, minor, patch int) bool

Types

type ActivationRequest

type ActivationRequest struct {
	Home              string
	AuthMode          string
	Variables         map[string]string
	ProviderVariables []string
}

ActivationRequest contains only vendor-specific activation inputs.

type Adapter

type Adapter interface {
	Tool() Tool
	DetectBinary(context.Context, string) (Binary, error)
	DefaultSourceHome() (string, error)
	CreateHome(string) error
	Inventory(string, bool) (Inventory, error)
	ClassifyEntry(string, fs.FileInfo) (Category, bool, string)
	ResolveEnvironment(ActivationRequest) (EnvironmentPlan, error)
	ValidateConfig(string) []Check
	CredentialStatusCommand(AuthRequest) (Command, error)
	CredentialLoginCommand(AuthRequest) (Command, error)
	CredentialLogoutCommand(AuthRequest) (Command, error)
	ParseCredentialStatus([]byte) CredentialStatus
	Capabilities(Version) []Capability
	Doctor(context.Context, DoctorOptions) []Check
}

Adapter is the stable compiled-in boundary used by activation, import, authentication, and doctor commands.

type AuthRequest

type AuthRequest struct {
	Binary     string
	Home       string
	Mode       string
	Method     string
	Secret     []byte
	ProviderID string
}

AuthRequest contains enough information to construct a native auth command. Secret is carried separately so callers can pipe it through stdin.

type Binary

type Binary struct {
	Configured string  `json:"configured"`
	Path       string  `json:"path"`
	Version    Version `json:"version"`
}

Binary describes a resolved native executable.

func ResolveBinary

func ResolveBinary(ctx context.Context, runner CommandRunner, configured string, versionArgs ...string) (Binary, error)

type Capability

type Capability struct {
	Name        string   `json:"name"`
	Supported   bool     `json:"supported"`
	Severity    Severity `json:"severity"`
	Evidence    string   `json:"evidence,omitempty"`
	Remediation string   `json:"remediation,omitempty"`
}

Capability records whether an installed client can satisfy a required adapter behavior.

type Category

type Category string

Category controls the default import disposition of a native entry.

const (
	CategoryConfig     Category = "config"
	CategoryAsset      Category = "asset"
	CategoryCredential Category = "credential"
	CategorySession    Category = "session"
	CategoryGenerated  Category = "generated"
	CategoryUnknown    Category = "unknown"
)

type Check

type Check struct {
	Code        string   `json:"code"`
	Severity    Severity `json:"severity"`
	Message     string   `json:"message"`
	Remediation string   `json:"remediation,omitempty"`
	Paths       []string `json:"paths,omitempty"`
	Evidence    string   `json:"evidence,omitempty"`
}

Check is a structured diagnostic result. Evidence must never contain secrets.

func FileCheck

func FileCheck(path, code string) []Check

func InheritedConflictChecks

func InheritedConflictChecks(prefix string, inherited map[string]string, scrubbed []string) []Check

type Classifier

type Classifier func(string, fs.FileInfo) (Category, bool, string)

type Clock

type Clock interface {
	Now() time.Time
}

Clock is reserved for import receipts and deterministic diagnostic evidence.

type Command

type Command struct {
	Path  string
	Args  []string
	Env   map[string]string
	Stdin []byte
}

Command is an argv-safe native command plan. If Stdin is non-empty, callers must pipe it to the process rather than place it in argv or logs.

type CommandRunner

type CommandRunner interface {
	Output(ctx context.Context, path string, args ...string) ([]byte, error)
}

CommandRunner exists so binary detection and diagnostics can be tested without invoking a real vendor client.

type CredentialState

type CredentialState string

CredentialState is a parsed, vendor-neutral credential status.

const (
	CredentialUnknown         CredentialState = "unknown"
	CredentialAuthenticated   CredentialState = "authenticated"
	CredentialUnauthenticated CredentialState = "unauthenticated"
)

type CredentialStatus

type CredentialStatus struct {
	State    CredentialState `json:"state"`
	Identity string          `json:"identity,omitempty"`
	Message  string          `json:"message,omitempty"`
}

type DoctorOptions

type DoctorOptions struct {
	Binary            string
	Home              string
	AuthMode          string
	Inherited         map[string]string
	ProviderVariables []string
	GOOS              string
	Deep              bool
}

type Entry

type Entry struct {
	Path          string      `json:"path"`
	Category      Category    `json:"category"`
	Include       bool        `json:"include"`
	Reason        string      `json:"reason"`
	Mode          fs.FileMode `json:"mode"`
	Size          int64       `json:"size,omitempty"`
	SymlinkTarget string      `json:"symlink_target,omitempty"`
}

Entry is one path discovered while inventorying a native home.

type EnvironmentPlan

type EnvironmentPlan struct {
	Unset []string          `json:"unset"`
	Set   map[string]string `json:"set"`
}

EnvironmentPlan describes which inherited values to remove and which non-secret values to apply. Secret values belong in the later process-only credential layer and must not be placed here.

type ExecRunner

type ExecRunner struct{}

func (ExecRunner) Output

func (ExecRunner) Output(ctx context.Context, path string, args ...string) ([]byte, error)

type Inventory

type Inventory struct {
	Home    string  `json:"home"`
	Entries []Entry `json:"entries"`
}

Inventory is a deterministic native-home inventory.

func WalkInventory

func WalkInventory(home string, includeSessions bool, classify Classifier) (Inventory, error)

type Severity

type Severity string

Severity is the stable machine-readable importance of a check.

const (
	SeverityInfo    Severity = "info"
	SeverityWarning Severity = "warning"
	SeverityError   Severity = "error"
)

type Tool

type Tool string

Tool identifies a compiled-in native client.

const (
	ToolClaude Tool = "claude"
	ToolCodex  Tool = "codex"
)

type Version

type Version struct {
	Raw    string `json:"raw"`
	Parsed bool   `json:"parsed"`
	Major  int    `json:"major,omitempty"`
	Minor  int    `json:"minor,omitempty"`
	Patch  int    `json:"patch,omitempty"`
}

Version describes version output from a native binary.

func ParseVersion

func ParseVersion(raw string) Version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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