localconfig

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package localconfig owns Sol's single-user configuration and credentials. It has no provider transport or project-directory discovery.

Index

Constants

View Source
const APIKeyMode = "api-key"
View Source
const Version = 3

Version is the current on-disk configuration schema version.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath resolves only the OS user config directory, never the project.

func ParseEntry added in v0.1.16

func ParseEntry(entry string) (string, string, error)

func SessionPath added in v0.1.16

func SessionPath() (string, error)

SessionPath uses private per-user state, independent of terminal selection.

func ValidID

func ValidID(id string) bool

ValidID is case-sensitive and accepts [A-Za-z0-9][A-Za-z0-9._-]*.

Types

type CommitStore

type CommitStore interface {
	Store
	UpdateWithCommit(context.Context, func(*Config) (context.Context, error)) (Config, error)
}

CommitStore supports transactions which accept an irreversible remote effect. Lock acquisition and the callback use the caller's context. The callback may supply a fresh bounded context for committing an accepted effect independently of caller cancellation. Ordinary configuration changes use Store.Update.

type Config

type Config struct {
	Providers    map[string]ProviderConfig `json:"providers"`
	DefaultModel string                    `json:"defaultModel,omitempty"`
	DefaultAgent string                    `json:"defaultAgent,omitempty"`
}

Config is the complete local configuration snapshot. Providers is initialized even when the file is absent. Credentials are not safe for display.

func (Config) Resolve added in v0.1.16

func (c Config) Resolve(value string) (ModelRef, ProviderConfig, error)

func (Config) Validate

func (c Config) Validate() error

type EntryLocker added in v0.1.16

type EntryLocker interface {
	LockEntry(context.Context, string) (func(), error)
}

EntryLocker is required for account-scoped credential mutations.

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

FileStore persists the complete record using private atomic writes and a stable advisory lock. Load and Update coordinate across independent processes.

func NewFileStore

func NewFileStore(path string) (*FileStore, error)

NewFileStore requires an explicit absolute path in a Sol-owned directory. The containing directory is made private. Construction does not access files.

func (*FileStore) Load

func (s *FileStore) Load(ctx context.Context) (Config, error)

func (*FileStore) LockEntry added in v0.1.16

func (s *FileStore) LockEntry(ctx context.Context, entry string) (func(), error)

LockEntry serializes credential operations independently of other accounts. Acquire this lock before Update; never acquire it inside an Update callback.

func (*FileStore) Update

func (s *FileStore) Update(ctx context.Context, change func(*Config) error) (Config, error)

func (*FileStore) UpdateWithCommit

func (s *FileStore) UpdateWithCommit(ctx context.Context, change func(*Config) (context.Context, error)) (Config, error)

UpdateWithCommit requires a bounded commit context from a successful callback. Returning an error leaves the file unchanged. The caller owns context cleanup.

type LocalSession added in v0.1.16

type LocalSession struct {
	Version int               `json:"version"`
	ID      string            `json:"id"`
	Title   string            `json:"title"`
	WorkDir string            `json:"workDir"`
	Model   string            `json:"model"`
	Agent   string            `json:"agent"`
	Updated time.Time         `json:"updated"`
	Active  bool              `json:"active"`
	History []session.Message `json:"history"`
	Context []session.Message `json:"context"`
}

LocalSession records both the complete transcript and the compacted model context.

func ListSessions added in v0.1.16

func ListSessions(root string) ([]LocalSession, error)

type ModelRef added in v0.1.16

type ModelRef struct{ Entry, Provider, Model string }

ModelRef retains the entire provider-specific model suffix, including slashes.

func ParseModelRef added in v0.1.16

func ParseModelRef(value string) (ModelRef, error)

type OAuthCredential

type OAuthCredential struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
	AccountID    string    `json:"account_id,omitempty"`
}

OAuthCredential holds refreshable tokens and optional account-routing metadata.

type ProviderConfig added in v0.1.16

type ProviderConfig struct {
	Auth        string           `json:"auth"`
	Key         string           `json:"key,omitempty"`
	KeyEnv      string           `json:"keyEnv,omitempty"`
	Credentials *OAuthCredential `json:"credentials,omitempty"`
	BaseURL     string           `json:"baseURL,omitempty"`
}

ProviderConfig binds one named account to exactly one authentication method. Empty credentials represent a disconnected account, never an environment fallback.

type SessionFile added in v0.1.16

type SessionFile struct {
	Record LocalSession
	// contains filtered or unexported fields
}

SessionFile holds the cross-process lease for one conversation until Close.

func OpenSession added in v0.1.16

func OpenSession(ctx context.Context, root, id string, create bool) (*SessionFile, error)

func (*SessionFile) Append added in v0.1.16

func (s *SessionFile) Append(ctx context.Context, messages []session.Message) error

func (*SessionFile) Clear added in v0.1.17

func (s *SessionFile) Clear(ctx context.Context) error

Clear resets model context and interruption state under the session lease. The complete transcript and session identity are retained.

func (*SessionFile) Close added in v0.1.16

func (s *SessionFile) Close()

func (*SessionFile) Compact added in v0.1.16

func (s *SessionFile) Compact(ctx context.Context, messages []session.Message, _ int) error

func (*SessionFile) Load added in v0.1.16

func (s *SessionFile) Load(ctx context.Context) ([]session.Message, error)

func (*SessionFile) Save added in v0.1.16

func (s *SessionFile) Save(ctx context.Context) error

type Store

type Store interface {
	Load(context.Context) (Config, error)
	Update(context.Context, func(*Config) error) (Config, error)
}

Store serializes read-modify-write across its users, including token refresh. Update callbacks must not reenter the store. A failed callback is not persisted.

Jump to

Keyboard shortcuts

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