hostconfig

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hostconfig turns a SpeechKit TOML configuration file into the public SDK types an embedding host drives the framework with: a speechkit.ModeSettings (which modes are on, their hotkeys and selected provider profiles) and a permissive speechkit.RuntimePolicy (which modes the host exposes and whether fallbacks are allowed).

Without this package a library host has to build ModeSettings by hand from a parsed config, the way the reference Windows app does internally. Load does that wiring once so a host can go from a config.toml on disk to a ready-to-validate ModeSettings/RuntimePolicy pair in a single call:

settings, policy, err := hostconfig.Load("config.toml")

The conversion is intentionally kernel-clean. It maps the embedder-relevant fields only; the reference desktop app additionally introspects the host secret store to report whether a server bearer token env var is set, which is a device-UI concern and is deliberately left out here.

Example

Example shows the one-call path from a config.toml on disk to the public ModeSettings and RuntimePolicy an embedding host drives the framework with.

package main

import (
	"fmt"
	"log"

	"github.com/kombifyio/SpeechKit/pkg/speechkit/hostconfig"
)

func main() {
	settings, policy, err := hostconfig.Load("config.toml")
	if err != nil {
		log.Fatal(err)
	}

	// settings tells the host which modes are on and which provider profiles
	// they use; policy is a starting point the host can tighten before
	// validating selections with speechkit.ValidateModeSettingsForPolicy.
	fmt.Println("dictation enabled:", settings.Dictation.Enabled)
	fmt.Println("enabled modes:", policy.EnabledModes)
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

Load reads and decodes the SpeechKit TOML config at path — applying the same defaults the reference app applies — and returns the host-facing ModeSettings together with a RuntimePolicy derived from it.

The returned policy enables exactly the modes turned on in config and allows fallback profiles only when the config actually pins one. It leaves AllowedProfiles and FixedProfiles empty (meaning "all") so the host can tighten the policy further before calling speechkit.ValidateModeSettingsForPolicy.

func ModeSettingsFrom

func ModeSettingsFrom(cfg *config.Config) speechkit.ModeSettings

ModeSettingsFrom converts an already-parsed *config.Config into the public ModeSettings shape. Hosts that load config themselves can call this directly. A nil cfg yields the zero ModeSettings.

Example

ExampleModeSettingsFrom converts an already-parsed *config.Config — useful for hosts that load or synthesise config themselves. An empty primary selection is filled with the built-in default profile.

package main

import (
	"fmt"

	"github.com/kombifyio/SpeechKit/internal/config"
	"github.com/kombifyio/SpeechKit/pkg/speechkit/hostconfig"
)

func main() {
	cfg := &config.Config{}
	cfg.General.AssistEnabled = true
	cfg.General.AssistHotkey = "ctrl+alt+a"

	settings := hostconfig.ModeSettingsFrom(cfg)
	fmt.Println(settings.Assist.Enabled, settings.Assist.Hotkey, settings.Assist.PrimaryProfileID)
}
Output:
true ctrl+alt+a assist.builtin.gemma4-e4b

func PolicyFrom

func PolicyFrom(cfg *config.Config) speechkit.RuntimePolicy

PolicyFrom derives a permissive RuntimePolicy from config: it enables the modes turned on in [general] and allows fallbacks only if any mode pins a fallback profile. AllowedProfiles and FixedProfiles are left empty (meaning "all"), so a host can lock the policy down further. A nil cfg yields the zero RuntimePolicy.

Note: if config enables no modes at all, EnabledModes is empty, which SpeechKit treats as "all modes enabled". Set an explicit policy if you need a hard mode lockout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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