setup

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const CurrentVersion = 3
View Source
const DaemonUnitName = "matrixclawd.service"

Variables

View Source
var ErrConfigNotFound = errors.New("setup config not found")
View Source
var ErrDraftNotFound = errors.New("setup draft not found")
View Source
var ErrUnsupportedConfigVersion = errors.New("unsupported setup config version")

Functions

func BoolString

func BoolString(v bool) string

func ClientBootstrapsFromConfig

func ClientBootstrapsFromConfig(cfg Config) (map[string]ClientBootstrap, error)

func DaemonEnvironmentFilePath

func DaemonEnvironmentFilePath(setupPath string) string

func DefaultAssistantSystemPrompt

func DefaultAssistantSystemPrompt() string

func DefaultConfigPath

func DefaultConfigPath() (string, error)

func DefaultDBPath

func DefaultDBPath() string

func ImportDaemonEnvironmentFile

func ImportDaemonEnvironmentFile(setupPath string, cfg Config) error

func InitializeAssistantSystemPrompt

func InitializeAssistantSystemPrompt(current string) string

func InitializeAssistantSystemPromptForConfig

func InitializeAssistantSystemPromptForConfig(current string, cfg Config) string

func InitializeAssistantSystemPromptForDraft

func InitializeAssistantSystemPromptForDraft(current string, draft Draft) string

func InitializeAssistantSystemPromptWithContext

func InitializeAssistantSystemPromptWithContext(current string, promptContext AssistantPromptContext) string

func MaskSecret

func MaskSecret(value string) string

func ParseBool

func ParseBool(v string) bool

func ProviderAPIKeyPreview

func ProviderAPIKeyPreview(provider ProviderConfig) string

func ProviderCompactStatus

func ProviderCompactStatus(item ProviderSetupItem) string

func ProviderDisplayName

func ProviderDisplayName(item ProviderSetupItem) string

func ProviderDisplayStatus

func ProviderDisplayStatus(item ProviderSetupItem) string

func ProviderDraftConfigured

func ProviderDraftConfigured(provider ProviderDraft) bool

func ReasoningEfforts

func ReasoningEfforts() []string

func ResolvedProviderAPIKey

func ResolvedProviderAPIKey(provider ProviderConfig) (string, bool)

Types

type ApplyResult

type ApplyResult struct {
	Config   Config
	Path     string
	Summary  Summary
	Warnings []string
}

type AssistantConfig

type AssistantConfig struct {
	Name               string `json:"name,omitempty"`
	SystemPrompt       string `json:"system_prompt,omitempty"`
	CustomInstructions string `json:"custom_instructions,omitempty"`
}

type AssistantPromptContext

type AssistantPromptContext struct {
	HTTPAddr              string
	DBPath                string
	Timezone              string
	AutostartOnBoot       bool
	TelegramEnabled       bool
	TelegramProviderSetup bool
	ActiveProviderID      string
	ConfiguredProviders   int
}

type AssistantSummary

type AssistantSummary struct {
	Name   string
	Status string
}

type ClientBootstrap

type ClientBootstrap struct {
	Enabled     bool
	Values      map[string]string
	Int64Values map[string]int64
}

type ClientsConfig

type ClientsConfig struct {
	Terminal TerminalConfig `json:"terminal"`
	Telegram TelegramConfig `json:"telegram"`
}

type Config

type Config struct {
	Version          int              `json:"version"`
	CompletedAt      time.Time        `json:"completed_at"`
	ActiveProviderID string           `json:"active_provider_id,omitempty"`
	Assistant        AssistantConfig  `json:"assistant,omitempty"`
	Providers        []ProviderConfig `json:"providers,omitempty"`
	Daemon           DaemonConfig     `json:"daemon"`
	Clients          ClientsConfig    `json:"clients"`
}

type DaemonConfig

type DaemonConfig struct {
	HTTPAddr        string `json:"http_addr"`
	DBPath          string `json:"db_path"`
	Timezone        string `json:"timezone,omitempty"`
	APIToken        string `json:"api_token,omitempty"`
	AutostartOnBoot bool   `json:"autostart_on_boot"`
}

type DaemonSummary

type DaemonSummary struct {
	Status        string
	HTTPAddr      string
	DBPath        string
	Timezone      string
	Autostart     bool
	RuntimeStatus string
	Installed     bool
	Running       bool
	Enabled       bool
	Warning       string
}

type Draft

type Draft struct {
	ActiveProviderID      string
	AssistantName         string
	AssistantSystemPrompt string
	AssistantCustomPrompt string
	Providers             []ProviderDraft
	HTTPAddr              string
	DBPath                string
	Timezone              string
	AutostartOnBoot       string
	TelegramEnabled       string
	TelegramBotToken      string
	TelegramAllowedUID    string
	TelegramProviderSetup string
}

func DeleteProviderDraft

func DeleteProviderDraft(draft Draft, providerID string) Draft

func UpsertProviderDraft

func UpsertProviderDraft(draft Draft, provider ProviderDraft) Draft

type FileStore

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

func NewFileStore

func NewFileStore(path string) *FileStore

func (*FileStore) ClearDraft

func (s *FileStore) ClearDraft() error

func (*FileStore) Load

func (s *FileStore) Load() (Config, error)

func (*FileStore) LoadDraft

func (s *FileStore) LoadDraft() (Draft, error)

func (*FileStore) Path

func (s *FileStore) Path() string

func (*FileStore) Save

func (s *FileStore) Save(cfg Config) error

func (*FileStore) SaveDraft

func (s *FileStore) SaveDraft(draft Draft) error

type ProviderConfig

type ProviderConfig struct {
	ID              string                `json:"id"`
	CatalogID       string                `json:"catalog_id,omitempty"`
	Name            string                `json:"name"`
	Type            string                `json:"type"`
	APIKey          string                `json:"api_key"`
	APIKeyEnv       string                `json:"api_key_env,omitempty"`
	BaseURL         string                `json:"base_url,omitempty"`
	Model           string                `json:"model"`
	MaxOutputTokens int64                 `json:"max_output_tokens,omitempty"`
	ReasoningEffort string                `json:"reasoning_effort,omitempty"`
	ToolUseMode     providers.ToolUseMode `json:"tool_use_mode,omitempty"`
}

func ActiveProviderConfig

func ActiveProviderConfig(cfg Config) (ProviderConfig, bool)

func ProviderConfigWithResolvedAPIKey

func ProviderConfigWithResolvedAPIKey(provider ProviderConfig) (ProviderConfig, bool)

type ProviderDraft

type ProviderDraft struct {
	ID                  string
	CatalogID           string
	Name                string
	Type                string
	APIKey              string
	APIKeyEnv           string
	BaseURL             string
	Model               string
	ToolUseMode         providers.ToolUseMode
	MaxOutputTokens     string
	ReasoningEffort     string
	HasStoredAPIKey     bool
	StoredAPIKeyPreview string
}

func ConfiguredProviders

func ConfiguredProviders(draft Draft) []ProviderDraft

func FindProviderDraft

func FindProviderDraft(draft Draft, providerID string) (ProviderDraft, bool)

type ProviderOption

type ProviderOption struct {
	ID              string
	Name            string
	Type            string
	Implemented     bool
	RequiresBaseURL bool
	DefaultBaseURL  string
	DefaultModel    string
	APIKeyEnv       string
	Notes           string
}

type ProviderSetupItem

type ProviderSetupItem struct {
	ID              string                `json:"id"`
	CatalogID       string                `json:"catalog_id,omitempty"`
	Name            string                `json:"name"`
	Type            string                `json:"type"`
	Status          string                `json:"status"`
	Configured      bool                  `json:"configured"`
	Active          bool                  `json:"active"`
	Implemented     bool                  `json:"implemented"`
	RequiresBaseURL bool                  `json:"requires_base_url,omitempty"`
	BaseURL         string                `json:"base_url,omitempty"`
	Model           string                `json:"model,omitempty"`
	ToolUseMode     providers.ToolUseMode `json:"tool_use_mode,omitempty"`
	DefaultModel    string                `json:"default_model,omitempty"`
	APIKeyPreview   string                `json:"api_key_preview,omitempty"`
	Notes           string                `json:"notes,omitempty"`
}

func ProviderSetupItemsFromConfig

func ProviderSetupItemsFromConfig(cfg Config, options []ProviderOption) []ProviderSetupItem

func ProviderSetupItemsFromDraft

func ProviderSetupItemsFromDraft(draft Draft, options []ProviderOption) []ProviderSetupItem

type ProviderSetupListResponse

type ProviderSetupListResponse struct {
	Providers []ProviderSetupItem `json:"providers"`
}

type ProviderSetupOKResponse

type ProviderSetupOKResponse struct {
	OK bool `json:"ok"`
}

type ProviderSetupResponse

type ProviderSetupResponse struct {
	Provider ProviderSetupItem `json:"provider"`
}

type ProviderSetupUpdate

type ProviderSetupUpdate struct {
	Name        string                `json:"name,omitempty"`
	Type        string                `json:"type,omitempty"`
	APIKey      string                `json:"api_key,omitempty"`
	BaseURL     string                `json:"base_url,omitempty"`
	Model       string                `json:"model,omitempty"`
	ToolUseMode providers.ToolUseMode `json:"tool_use_mode,omitempty"`
	Active      bool                  `json:"active,omitempty"`
}

type ProviderSummary

type ProviderSummary struct {
	ID            string
	Name          string
	Model         string
	Status        string
	APIKeyPreview string
}

type Service

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

func NewDefaultService

func NewDefaultService() (*Service, error)

func NewService

func NewService(store Store) *Service

func (*Service) AllowProviderSetupForClient

func (s *Service) AllowProviderSetupForClient(client string) (bool, error)

func (*Service) Apply

func (s *Service) Apply(draft Draft) (ApplyResult, error)

func (*Service) ApplyContext

func (s *Service) ApplyContext(ctx context.Context, draft Draft) (ApplyResult, error)

func (*Service) BuiltInProviderDraft

func (s *Service) BuiltInProviderDraft(draft Draft, providerID string) (ProviderDraft, error)

func (*Service) ConfigureProviderContext

func (s *Service) ConfigureProviderContext(ctx context.Context, providerID string, update ProviderSetupUpdate) (ProviderSetupItem, error)

func (*Service) DeleteProviderContext

func (s *Service) DeleteProviderContext(ctx context.Context, providerID string) error

func (*Service) Draft

func (s *Service) Draft() (Draft, error)

func (*Service) EnsureDaemonAPIToken

func (s *Service) EnsureDaemonAPIToken() (Config, error)

func (*Service) EnsureDaemonContext

func (s *Service) EnsureDaemonContext(ctx context.Context) (DaemonSummary, error)

func (*Service) IsConfigured

func (s *Service) IsConfigured() (bool, error)

func (*Service) Load

func (s *Service) Load() (Config, error)

func (*Service) NewCustomProviderDraft

func (s *Service) NewCustomProviderDraft(draft Draft, providerType string) (ProviderDraft, error)

func (*Service) Path

func (s *Service) Path() string

func (*Service) ProviderModels

func (s *Service) ProviderModels(ctx context.Context, provider ProviderDraft) ([]string, error)

func (*Service) ProviderOptions

func (s *Service) ProviderOptions() []ProviderOption

func (*Service) ProviderSetupItems

func (s *Service) ProviderSetupItems() ([]ProviderSetupItem, error)

func (*Service) RestartDaemonContext

func (s *Service) RestartDaemonContext(ctx context.Context) (DaemonSummary, error)

func (*Service) SaveDraft

func (s *Service) SaveDraft(draft Draft) error

func (*Service) SaveRuntimeConfigContext

func (s *Service) SaveRuntimeConfigContext(ctx context.Context, draft Draft) (ApplyResult, error)

func (*Service) Summary

func (s *Service) Summary() (Summary, error)

func (*Service) SummaryContext

func (s *Service) SummaryContext(ctx context.Context) (Summary, error)

type Store

type Store interface {
	Load() (Config, error)
	Save(cfg Config) error
	LoadDraft() (Draft, error)
	SaveDraft(draft Draft) error
	ClearDraft() error
	Path() string
}

type Summary

type Summary struct {
	Assistant AssistantSummary
	Provider  ProviderSummary
	Daemon    DaemonSummary
	Telegram  TelegramSummary
}

func SummaryFromConfig

func SummaryFromConfig(cfg Config) Summary

func SummaryFromDraft

func SummaryFromDraft(d Draft) Summary

type TelegramConfig

type TelegramConfig struct {
	Enabled            bool   `json:"enabled"`
	BotToken           string `json:"bot_token,omitempty"`
	AllowedUserID      string `json:"allowed_user_id,omitempty"`
	AllowProviderSetup bool   `json:"allow_provider_setup,omitempty"`
}

type TelegramSummary

type TelegramSummary struct {
	Status   string
	Username string
	Warning  string
}

type TerminalConfig

type TerminalConfig struct {
	Enabled bool `json:"enabled"`
}

type TimezoneOption

type TimezoneOption struct {
	ID     string
	Name   string
	Offset string
	Label  string
}

func TimezoneOptions

func TimezoneOptions(now time.Time) []TimezoneOption

Jump to

Keyboard shortcuts

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