Documentation
¶
Overview ¶
Package localconfig owns Sol's single-user configuration and credentials. It has no provider transport or project-directory discovery.
Index ¶
- Constants
- func DefaultPath() (string, error)
- func ParseEntry(entry string) (string, string, error)
- func SessionPath() (string, error)
- func ValidID(id string) bool
- type CommitStore
- type Config
- type EntryLocker
- type FileStore
- func (s *FileStore) Load(ctx context.Context) (Config, error)
- func (s *FileStore) LockEntry(ctx context.Context, entry string) (func(), error)
- func (s *FileStore) Update(ctx context.Context, change func(*Config) error) (Config, error)
- func (s *FileStore) UpdateWithCommit(ctx context.Context, change func(*Config) (context.Context, error)) (Config, error)
- type LocalSession
- type ModelRef
- type OAuthCredential
- type ProviderConfig
- type SessionFile
- func (s *SessionFile) Append(ctx context.Context, messages []session.Message) error
- func (s *SessionFile) Close()
- func (s *SessionFile) Compact(ctx context.Context, messages []session.Message, _ int) error
- func (s *SessionFile) Load(ctx context.Context) ([]session.Message, error)
- func (s *SessionFile) Save(ctx context.Context) error
- type Store
Constants ¶
const APIKeyMode = "api-key"
const Version = 3
Version is the current on-disk configuration schema version.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath resolves only the OS user config directory, never the project.
func SessionPath ¶ added in v0.1.16
SessionPath uses private per-user state, independent of terminal selection.
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.
type EntryLocker ¶ added in v0.1.16
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 ¶
NewFileStore requires an explicit absolute path in a Sol-owned directory. The containing directory is made private. Construction does not access files.
func (*FileStore) LockEntry ¶ added in v0.1.16
LockEntry serializes credential operations independently of other accounts. Acquire this lock before Update; never acquire it inside an Update callback.
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
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 (*SessionFile) Close ¶ added in v0.1.16
func (s *SessionFile) Close()