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 BackupTarget
- type Settings
Constants ¶
const ( BackupWebDAV = "webdav" BackupS3 = "s3" BackupGist = "gist" )
The kinds of BackupTarget.
const ( BackupKeepDefault = 20 BackupKeepMax = 1000 )
BackupKeepDefault is how many of this device's backups a new target keeps; BackupKeepMax bounds it.
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 BackupAutoHours = []int{6, 24, 168}
BackupAutoHours are the times between automatic backups a target may have, in hours.
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", "zh-Hant", "ko", "ja"}
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 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"`
// FilesDual shows this computer's files beside the server's in a
// files pane; off, the default, shows the server's alone. A new pane
// follows the last choice.
FilesDual bool `json:"filesDual,omitempty"`
// FilesSplit is the share, in percent, of the first side of a files
// pane showing both, 10 to 90.
FilesSplit float32 `json:"filesSplit,omitempty"`
// EditorTreeWidth is the width, in DIPs, of the folders beside the
// text in an editor window, 140 to 600; EditorTreeHidden hides them.
EditorTreeWidth float32 `json:"editorTreeWidth,omitempty"`
EditorTreeHidden bool `json:"editorTreeHidden,omitempty"`
// 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 (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.