settings

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 11 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

Overview

Package settings keeps SSHYard's preferences in a JSON file.

Index

Constants

View Source
const (
	BackupWebDAV = "webdav"
	BackupS3     = "s3"
	BackupGist   = "gist"
)

The kinds of BackupTarget.

View Source
const (
	BackupKeepDefault = 20
	BackupKeepMax     = 1000
)

BackupKeepDefault is how many of this device's backups a new target keeps; BackupKeepMax bounds it.

View Source
const (
	AIFormatChat      = "chat"
	AIFormatResponses = "responses"
	AIFormatAnthropic = "anthropic"
	// AIFormatTypeSafe decides and does not chat: it only reviews.
	AIFormatTypeSafe = "typesafe"
)

The wire formats of an AIProvider, as internal/ai/llm names them.

View Source
const (
	AIReviewChat      = "chat"
	AIReviewDecisions = "decisions"
	AIReviewJev       = "jev"
)

The ways a review model is asked. AIReviewChat asks a chat model for a JSON verdict; AIReviewDecisions asks OpenAI Decisions and AIReviewJev asks TypeSafe's Jev how likely the action is safe.

View Source
const (
	AIDecisionsModel = "gpt-6-luna"
	AIJevModel       = "jev-latest"
)

The default models of the decision reviews.

View Source
const (
	AIReviewLoose    = "loose"
	AIReviewStandard = "standard"
	AIReviewStrict   = "strict"
)

The strictness of a decision review.

View Source
const (
	AIMaxTokensMax = 1_000_000
	AIModelsMax    = 1000
)

AIMaxTokensMax bounds AIProvider.MaxTokens; AIModelsMax bounds Models.

View Source
const (
	// OSC52Allow lets a remote program copy to the clipboard.
	OSC52Allow = "allow"
	// OSC52Ask asks before each copy.
	OSC52Ask = "ask"
	// OSC52Deny ignores remote copies.
	OSC52Deny = "deny"
	// OSC52MaxDefault is 1 MiB. OSC52MaxMin and OSC52MaxMax bound the setting.
	OSC52MaxDefault = 1 << 20
	OSC52MaxMin     = 64 << 10
	OSC52MaxMax     = 8 << 20
)
View Source
const (
	MaterialTranslucent = "translucent"
	MaterialOpaque      = "opaque"
)

The materials of a part of the window: the system's translucent material behind it, or its own solid fill.

View Source
const MCPPortDefault = 47320

MCPPortDefault is the MCP endpoint's port unless the user picks one.

Variables

View Source
var BackupAutoHours = []int{6, 24, 168}

BackupAutoHours are the times between automatic backups a target may have, in hours.

View Source
var ErrBaseURL = errors.New("settings: base URL must be http or https with a host")

ErrBaseURL reports a base URL that is not http(s) with a host, or that carries user info (a secret does not belong in the settings).

View Source
var ErrHeader = errors.New("settings: invalid header")

ErrHeader reports a header name or value SSHYard will not send, including Authorization (the API key lives in the keychain).

View Source
var ErrPlainHTTP = errors.New("settings: plain http to a non-loopback host")

ErrPlainHTTP warns that a base URL is plain HTTP to a host that is not this computer. CheckBaseURL still returns a nil error for it.

View Source
var Languages = []string{"en", "zh-Hans", "zh-Hant", "ko", "ja"}

Languages are the languages SSHYard ships, besides following the system.

View Source
var UpdateIntervals = []int{1, 2, 6, 12, 24}

UpdateIntervals are the hours between automatic checks for updates the user can choose.

Functions

func CheckBaseURL

func CheckBaseURL(raw string) (warn, err error)

CheckBaseURL checks a provider base URL. warn is ErrPlainHTTP for plain http to a host outside this computer; err rejects anything that is not an http(s) URL with a host and no user info.

func CheckHeaders

func CheckHeaders(h map[string]string) error

CheckHeaders rejects a CR, LF or NUL in a name or value, an empty name, and Authorization (any case). The API key is not a header.

func ResolveOSC52Write

func ResolveOSC52Write(global, host string) string

ResolveOSC52Write is the write policy in effect. A host value of allow, ask or deny wins; otherwise the global policy is used. Anything else is ask.

func ReviewKinds

func ReviewKinds(format string) []string

ReviewKinds are the kinds of review a provider of format can give.

func ReviewThreshold

func ReviewThreshold(s string) float64

ReviewThreshold is the least probability that an action is safe for a decision review of strictness s to allow it.

func Save

func Save(path string, s Settings) error

Save writes the settings to path atomically.

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to a temporary file beside path and renames it over path.

Types

type ACPConfig

type ACPConfig struct {
	Command string   `json:"command,omitempty"`
	Args    []string `json:"args,omitempty"`
}

ACPConfig describes the one external ACP backend

type AIProvider

type AIProvider struct {
	ID              string            `json:"id"`
	Name            string            `json:"name"`
	Format          string            `json:"format,omitempty"`
	BaseURL         string            `json:"baseUrl"`
	Model           string            `json:"model"`
	Models          []string          `json:"models,omitempty"`
	Headers         map[string]string `json:"headers,omitempty"`
	Temperature     *float64          `json:"temperature,omitempty"`
	TopP            *float64          `json:"topP,omitempty"`
	MaxTokens       *int              `json:"maxTokens,omitempty"`
	LegacyMaxTokens bool              `json:"legacyMaxTokens,omitempty"`
}

AIProvider is one built-in agent profile. Headers are non-secret; the API key is keychain.AIKey(ID). Model is the default model a pane asks; Models are the endpoint's chat models, as last fetched.

A nil Temperature, TopP or MaxTokens is not sent, so the provider's default applies. LegacyMaxTokens sends a Chat Completions limit as max_tokens instead of max_completion_tokens.

func (AIProvider) CanChat

func (p AIProvider) CanChat() bool

CanChat reports whether a pane can ask the provider questions.

type BackupTarget added in v0.0.7

type BackupTarget struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Kind string `json:"kind"`
	// URL is the WebDAV server, or the S3 endpoint ("" for AWS).
	URL string `json:"url,omitempty"`
	// User is the WebDAV user, or the S3 access key ID.
	User   string `json:"user,omitempty"`
	Bucket string `json:"bucket,omitempty"`
	Region string `json:"region,omitempty"`
	// Dir is the folder on the WebDAV server, or the key prefix in the
	// bucket.
	Dir string `json:"dir,omitempty"`
	// PathStyle names the bucket in the path rather than the host name.
	PathStyle bool `json:"pathStyle,omitempty"`
	// GistID is the gist the backups are in, "" until one is found or made.
	GistID string `json:"gistId,omitempty"`
	// ProxyID is the proxy the place is reached through, "" for none.
	ProxyID string `json:"proxyId,omitempty"`
	// Keep is how many of this device's backups stay; older ones are
	// deleted after a backup. 0 keeps them all.
	Keep int `json:"keep"`
	// DefaultPassword seals its backups with the default backup password
	// (keychain.DefaultBackupKey) rather than its own.
	DefaultPassword bool `json:"defaultPassword,omitempty"`
	// OmitSecrets leaves the secrets out of its backups.
	OmitSecrets bool `json:"omitSecrets,omitempty"`
	// AutoHours is the time between automatic backups, one of
	// BackupAutoHours; 0 is off.
	AutoHours int `json:"autoHours,omitempty"`
}

BackupTarget is a place backups go: a folder on a WebDAV server, an S3 bucket or a GitHub gist. Its password, secret key or token is in the keychain (keychain.BackupSecret), and so is the key its backups are sealed with, by hand or automatically (keychain.BackupKey).

type Settings

type Settings struct {
	Theme theme.Mode `json:"theme"`
	// Language is "" to follow the system, else one of Languages.
	Language     string `json:"language"`
	CheckUpdates bool   `json:"checkUpdates"`
	// UpdateIntervalHours is the time between automatic checks for
	// updates, one of UpdateIntervals. The updater reads it at launch.
	UpdateIntervalHours int     `json:"updateIntervalHours"`
	TerminalFontSize    int     `json:"terminalFontSize"`
	KeepAliveSeconds    int     `json:"keepAliveSeconds"`
	AutoReconnect       bool    `json:"autoReconnect"`
	SidebarWidth        float32 `json:"sidebarWidth"`
	// Privacy masks the IP addresses the app shows, for a screen share
	// or a recording. What is typed in a form is shown as it is.
	Privacy bool `json:"privacy,omitempty"`
	// ChromeMaterial is how the sidebar and the title bar show the
	// window's material (macOS): MaterialTranslucent, the default, or
	// MaterialOpaque. ContentMaterial is that of the content beside them,
	// opaque by default.
	ChromeMaterial  string `json:"chromeMaterial,omitempty"`
	ContentMaterial string `json:"contentMaterial,omitempty"`
	// UIFont is the interface's font family, "" for the system's.
	UIFont string `json:"uiFont,omitempty"`
	// TerminalFont is the terminal's font family, "" for the system's
	// monospaced font.
	TerminalFont string `json:"terminalFont,omitempty"`
	// MonospacedOnly limits the terminal font choice to monospaced
	// families.
	MonospacedOnly bool `json:"monospacedOnly"`
	// TransferConcurrency is how many SFTP transfers of a files pane run
	// at once, 1 to 10.
	TransferConcurrency int `json:"transferConcurrency"`
	// OpenConfirmMB is the size, in MB, from which opening a remote file
	// (in the editor or a local program) asks first, 1 to 1024.
	OpenConfirmMB int `json:"openConfirmMB"`
	// OSC52Write is whether a remote program may copy to the local
	// clipboard: allow (the default), ask or deny.
	OSC52Write string `json:"osc52Write"`
	// OSC52MaxBytes is the largest decoded OSC 52 paste to keep,
	// from 64 KiB to 8 MiB.
	OSC52MaxBytes int `json:"osc52MaxBytes"`
	// MetricsEnabled shows the terminal metrics bar. Off hides it on every
	// host. A host can still hide its own bar while this is on.
	MetricsEnabled bool `json:"metricsEnabled"`
	// MetricsInterval is how often a host is sampled, in seconds: 1, 2, 5 or 10.
	MetricsInterval int `json:"metricsInterval"`
	// MetricsMount is an extra filesystem shown beside the root. Empty is the root only.
	MetricsMount string `json:"metricsMount,omitempty"`
	// AIDefaultAgent is the agent a new AI pane starts with. "builtin"
	// is the in-process agent, which speaks to the configured providers.
	AIDefaultAgent string `json:"aiDefaultAgent,omitempty"`
	// AIACP is a user-supplied ACP executable; arguments are passed directly, without a shell
	AIACP ACPConfig `json:"aiACP,omitempty"`
	// AIDefaultMode is the global permission mode: ask, review or full.
	// "full" is kept when a file already says so; the UI asks before
	// writing it.
	AIDefaultMode string `json:"aiDefaultMode,omitempty"`
	// AIReviewProvider is an AIProviders ID, or empty for no review model.
	AIReviewProvider string `json:"aiReviewProvider,omitempty"`
	// AIReviewKind is how the review model is asked: AIReviewChat,
	// AIReviewDecisions or AIReviewJev, as the provider's format allows.
	AIReviewKind string `json:"aiReviewKind,omitempty"`
	// AIReviewModel is the model reviewing. Empty is the provider's
	// default for AIReviewChat, and the kind's default model otherwise.
	AIReviewModel string `json:"aiReviewModel,omitempty"`
	// AIReviewStrictness is how sure a decision model must be that an
	// action is safe to allow it: loose, standard or strict.
	AIReviewStrictness string `json:"aiReviewStrictness,omitempty"`
	// AIDefaultProvider is the AIProviders ID a new AI pane asks, or empty
	// for the first of them.
	AIDefaultProvider string `json:"aiDefaultProvider,omitempty"`
	// AIContextLines is how many lines of the linked terminal are sent
	// with a question, 50 to 2000.
	AIContextLines int `json:"aiContextLines,omitempty"`
	// AIAuditRetentionDays is how long audit files are kept.
	AIAuditRetentionDays int `json:"aiAuditRetentionDays,omitempty"`
	// AIRedact masks suspected private keys and tokens before they are
	// sent to a model. The default is on; false is stored so it survives.
	AIRedact bool `json:"aiRedact"`
	// AIProviders are built-in agent profiles. API keys are not here;
	// they live in the keychain.
	AIProviders []AIProvider `json:"aiProviders,omitempty"`
	// AIConsentHosts are host IDs whose first-use AI notice the user
	// already confirmed. Nothing is sent for a host that is not listed.
	AIConsentHosts []string `json:"aiConsentHosts,omitempty"`
	// MCPEnabled serves the MCP endpoint on 127.0.0.1:MCPPort, for AI
	// agents on this computer. Off by default; the UI shows the risks
	// before turning it on. Its bearer token lives in the keychain.
	MCPEnabled bool `json:"mcpEnabled,omitempty"`
	// MCPPort is the endpoint's port, 1024 to 65535.
	MCPPort int `json:"mcpPort,omitempty"`
	// BackupTargets are the places this device backs up to. They belong
	// to this device: a backup neither holds nor replaces them.
	BackupTargets []BackupTarget `json:"backupTargets,omitempty"`
	// DefaultBackupPassword says a default backup password is set: the key
	// derived from it is in the keychain (keychain.DefaultBackupKey). It
	// belongs to this device too.
	DefaultBackupPassword bool `json:"defaultBackupPassword,omitempty"`
}

Settings are the user's preferences.

func Default

func Default() Settings

Default returns the defaults.

func Load

func Load(path string) (Settings, error)

Load reads the settings at path; a missing file gives the defaults.

func (Settings) BackupTarget added in v0.0.7

func (s Settings) BackupTarget(id string) (BackupTarget, bool)

BackupTarget is the target of id, and whether there is one.

func (*Settings) Normalize

func (s *Settings) Normalize()

Normalize replaces invalid values with defaults.

Jump to

Keyboard shortcuts

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