Documentation
¶
Overview ¶
Package settings keeps SSHYard's preferences in a JSON file.
Index ¶
- Constants
- Variables
- func CheckBaseURL(raw string) (warn, err error)
- func CheckHeaders(h map[string]string) error
- func ResolveOSC52Write(global, host string) string
- func ReviewKinds(format string) []string
- func ReviewThreshold(s string) float64
- func Save(path string, s Settings) error
- func WriteFileAtomic(path string, data []byte, perm os.FileMode) error
- type ACPConfig
- type AIProvider
- type Settings
Constants ¶
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.
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.
const ( AIDecisionsModel = "gpt-6-luna" AIJevModel = "jev-latest" )
The default models of the decision reviews.
const ( AIReviewLoose = "loose" AIReviewStandard = "standard" AIReviewStrict = "strict" )
The strictness of a decision review.
const ( AIMaxTokensMax = 1_000_000 AIModelsMax = 1000 )
AIMaxTokensMax bounds AIProvider.MaxTokens; AIModelsMax bounds Models.
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 )
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.
const MCPPortDefault = 47320
MCPPortDefault is the MCP endpoint's port unless the user picks one.
Variables ¶
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).
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).
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.
var Languages = []string{"en", "zh-Hans"}
Languages are the languages SSHYard ships, besides following the system.
var UpdateIntervals = []int{1, 2, 6, 12, 24}
UpdateIntervals are the hours between automatic checks for updates the user can choose.
Functions ¶
func CheckBaseURL ¶
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 ¶
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 ¶
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 ¶
ReviewKinds are the kinds of review a provider of format can give.
func ReviewThreshold ¶
ReviewThreshold is the least probability that an action is safe for a decision review of strictness s to allow it.
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 Settings ¶
type Settings struct {
Theme theme.Mode `json:"theme"`
// Language is "" to follow the system, else "en" or "zh-Hans".
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"`
}
Settings are the user's preferences.