Documentation
¶
Overview ¶
Package installer provides automated installation of Ollama and related local-LLM infrastructure for nSelf Block A (Zero-Config AI).
Index ¶
Constants ¶
const ( ErrOllamaInstallFailed = "OLLAMA_INSTALL_FAILED" ErrIptablesNoPermission = "IPTABLES_NO_PERMISSION" ErrPortBindConflict = "PORT_BIND_CONFLICT" ErrRAMInsufficient = "RAM_INSUFFICIENT" ErrUnsupportedOS = "UNSUPPORTED_OS" )
Error codes (per spec §3.2.1).
const DefaultChecksumVersion = "1.0.3"
DefaultChecksumVersion is the CLI version whose pinned checksum we use.
const LocalStateFile = ".nself/ai/local-state.json"
LocalStateFile is where the installer records its run.
Variables ¶
var PinnedOllamaInstallSHA256 = map[string]string{
"1.0.3": "",
}
PinnedOllamaInstallSHA256 is the SHA256 checksum of the official https://ollama.com/install.sh script, pinned to the version validated for nSelf CLI v1.0.3 LTS. When Ollama ships a new installer, update this table and the DefaultChecksumVersion constant.
The checksum is verified after download in OllamaInstaller.Install() before the script is executed. If it does not match, installation aborts with OLLAMA_INSTALL_FAILED.
var RecommendationMatrix = map[string]map[TierKey][]ModelRec{ "1.0.3": { TierNone: {}, TierTiny: { {Name: "gemma2:2b", Tasks: []string{"chat", "classify"}}, {Name: "nomic-embed-text", Tasks: []string{"embed"}}, }, TierSmall: { {Name: "phi3:mini", Tasks: []string{"chat", "classify"}}, {Name: "nomic-embed-text", Tasks: []string{"embed"}}, }, TierBalanced: { {Name: "qwen2.5:3b", Tasks: []string{"chat"}}, {Name: "nomic-embed-text", Tasks: []string{"embed"}}, {Name: "gemma2:2b", Tasks: []string{"classify"}}, }, TierMedium: { {Name: "llama3.2:3b", Tasks: []string{"chat"}}, {Name: "nomic-embed-text", Tasks: []string{"embed"}}, {Name: "gemma2:2b", Tasks: []string{"classify"}}, }, TierLarge: { {Name: "qwen2.5:7b", Tasks: []string{"chat"}}, {Name: "nomic-embed-text", Tasks: []string{"embed"}}, {Name: "gemma2:2b", Tasks: []string{"classify"}}, }, TierXL: { {Name: "llama3.1:8b", Tasks: []string{"chat"}}, {Name: "bge-large", Tasks: []string{"embed"}}, {Name: "gemma2:2b", Tasks: []string{"classify"}}, }, TierXXL: { {Name: "qwen2.5:14b", Tasks: []string{"chat"}}, {Name: "bge-large", Tasks: []string{"embed"}}, {Name: "gemma2:2b", Tasks: []string{"classify"}}, }, }, }
RecommendationMatrix is keyed by nSelf CLI version. Only the current version entry is authoritative at runtime; older entries are kept for historical reproducibility.
Functions ¶
func ExpectedOllamaInstallChecksum ¶
func ExpectedOllamaInstallChecksum() string
ExpectedOllamaInstallChecksum returns the pinned SHA256 for the current CLI version, or empty string if not pinned (non-enforcing).
func MemAvailableMB ¶
MemAvailableMB reads /proc/meminfo on Linux and returns the MemAvailable value in MB. Returns 0 and an error on non-Linux or read failure.
func RecommendForHost ¶
RecommendForHost returns the recommended model list for the current host. If MemAvailable cannot be read, returns TierNone recommendations.
Types ¶
type InstallOptions ¶
type InstallOptions struct {
SkipModels bool
Model string // optional single model to pull (overrides matrix)
Bind string // host:port, default 0.0.0.0:11434
Yes bool // non-interactive
JSON bool
LogFn func(level, msg string, kv map[string]any)
}
InstallOptions controls the installer flow.
type InstallResult ¶
type InstallResult struct {
AlreadyInstalled bool `json:"already_installed"`
OllamaVersion string `json:"ollama_version,omitempty"`
Bind string `json:"bind"`
Tier TierKey `json:"ram_tier"`
ModelsPulled []string `json:"models_pulled"`
CompletedAt time.Time `json:"completed_at"`
}
InstallResult summarises an install run.
func Install ¶
func Install(ctx context.Context, opts InstallOptions) (*InstallResult, error)
Install performs the full install flow. Returns an *InstallerError on failure.
func ReadLocalState ¶
func ReadLocalState() (*InstallResult, error)
ReadLocalState returns the persisted install state if present.
type InstallerError ¶
InstallerError wraps a coded installer error.
func (*InstallerError) Error ¶
func (e *InstallerError) Error() string
type ModelRec ¶
type ModelRec struct {
Name string // ollama model tag, e.g. "gemma2:2b"
Tasks []string // chat, embed, classify
}
ModelRec is a single recommendation entry.
type TierKey ¶
type TierKey string
TierKey identifies a RAM tier.
const ( TierNone TierKey = "none" // <4 GB TierTiny TierKey = "tiny" // 4-6 GB TierSmall TierKey = "small" // 6-8 GB TierBalanced TierKey = "balanced" // 8-12 GB TierMedium TierKey = "medium" // 12-16 GB TierLarge TierKey = "large" // 16-24 GB TierXL TierKey = "xl" // 24-32 GB TierXXL TierKey = "xxl" // >32 GB )