Files
OSGKeyboard/OSGKeyboardShared/Core/Configuration/ConfigurationStore.swift
T
Rocky 10bc457c72
CI / Validate manifests (push) Has been cancelled
CI / SwiftLint (push) Has been cancelled
CI / iOS / Extension (push) Has been cancelled
CI / macOS (push) Has been cancelled
feat(app): add resilient Flow recovery and privacy-safe analytics
Unify PiP recovery across startup and foreground transitions, surface actionable status, and add privacy-safe analytics plus the refreshed onboarding and account experience. Update documentation assets and advance the release build to 84.
2026-08-20 20:22:20 +08:00

61 lines
2.2 KiB
Swift

// ConfigurationStore.swift
// OSGKeyboard · Shared
//
// Cross-platform read facade for the dictation pipeline (ASR → polish).
// iOS implements this via `AppGroupStore` (App Group UserDefaults + Keychain).
// macOS will gain a separate implementation (standard UserDefaults + Keychain)
// without pulling in keyboard-extension-only APIs.
import Foundation
/// Read-only configuration surface consumed by ASR, cloud ASR, and polish services.
///
/// Keep this protocol narrow: only what the shared pipeline needs today.
/// Platform-specific settings UI and iCloud sync stay on concrete stores.
public protocol ConfigurationStore: Sendable {
/// Polish / LLM provider id.
var providerId: String { get }
var baseURL: String { get }
var apiKey: String { get }
var model: String { get }
/// Cloud ASR provider id — independent from polish when `engineMode == "cloud"`.
var asrProviderId: String { get }
var asrBaseURL: String { get }
var asrApiKey: String { get }
var asrModel: String { get }
var engineMode: String { get }
var credentialSource: CredentialSource { get }
var polishIntensity: PolishIntensity { get }
var aiResponseLength: AIResponseLength { get }
var llmThinkingEnabled: Bool { get }
var personalDictionary: PersonalDictionary { get }
var polishStyleCatalog: PolishStyleCatalog { get }
var activePolishStyleId: String { get }
/// Foreground-app context for polish prompts (keyboard extension publishes this).
var detectedAppContext: (context: AppContext, observedAt: Date)? { get }
/// Provider-specific ASR caches (e.g. Alibaba Fun-ASR vocabulary IDs).
var cloudASRPersistence: UserDefaults { get }
func makeClient(
taskKind: ManagedGatewayTaskKind?,
requestPurpose: ManagedGatewayRequestPurpose?
) -> LLMClient
}
public extension ConfigurationStore {
/// Existing stores and test doubles remain BYOK unless they opt in.
var credentialSource: CredentialSource { .byok }
func makeClient() -> LLMClient {
makeClient(taskKind: nil, requestPurpose: nil)
}
func makeClient(taskKind: ManagedGatewayTaskKind?) -> LLMClient {
makeClient(taskKind: taskKind, requestPurpose: nil)
}
}