@@ -17,50 +17,22 @@ internal enum ManagedPolicy: String, CaseIterable, Sendable {
1717 /// raised to this; a stronger choice is left alone, so the policy is a floor and never a ceiling.
1818 case minimumSafeModeLevel = " com.TablePro.policy.minimumSafeModeLevel "
1919
20- /// Stops the MCP server from listening, so an AI client cannot reach the databases at all.
21- case mcpServerDisabled = " com.TablePro.policy.mcpServerDisabled "
22-
23- /// Stops the in-app AI assistant, including inline suggestions.
24- case aiAssistantDisabled = " com.TablePro.policy.aiAssistantDisabled "
25-
26- /// Stops plugins being installed, from the registry or from a file.
27- case pluginInstallDisabled = " com.TablePro.policy.pluginInstallDisabled "
28-
2920 internal var key : String { rawValue }
3021}
3122
3223internal protocol ManagedPolicyReading : Sendable {
33- /// True when a configuration profile supplies this key, so the UI for it must be disabled.
34- func isManaged( _ policy: ManagedPolicy ) -> Bool
35- func bool( _ policy: ManagedPolicy ) -> Bool
3624 func string( _ policy: ManagedPolicy ) -> String ?
3725}
3826
39- /// Reads policy out of the standard preferences chain.
40- ///
41- /// macOS already merges a configuration profile's values into `UserDefaults` at the highest
42- /// priority, so reading a managed key needs no special path: the forced value simply wins. The one
43- /// thing the normal API cannot tell you is *whether* a key was forced, which is what
44- /// `CFPreferencesAppValueIsForced` is for. Its own header says callers "should use this function to
45- /// determine whether or not to disable UI elements corresponding to those preference keys".
27+ /// Reads policy out of the standard preferences chain. macOS merges a configuration profile's
28+ /// values into `UserDefaults` at the highest priority, so the forced value simply wins.
4629internal struct ManagedPolicyReader : ManagedPolicyReading , @unchecked Sendable {
4730 internal static let shared = ManagedPolicyReader ( )
4831
4932 private let defaults : UserDefaults
50- private let applicationID : String
5133
52- internal init ( defaults: UserDefaults = . standard, applicationID : String = Bundle . main . bundleIdentifier ?? " " ) {
34+ internal init ( defaults: UserDefaults = . standard) {
5335 self . defaults = defaults
54- self . applicationID = applicationID
55- }
56-
57- internal func isManaged( _ policy: ManagedPolicy ) -> Bool {
58- guard !applicationID. isEmpty else { return false }
59- return CFPreferencesAppValueIsForced ( policy. key as CFString , applicationID as CFString )
60- }
61-
62- internal func bool( _ policy: ManagedPolicy ) -> Bool {
63- defaults. bool ( forKey: policy. key)
6436 }
6537
6638 internal func string( _ policy: ManagedPolicy ) -> String ? {
0 commit comments