An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
feat(mac): set every browser's theme and guardrails from the Settings tab, hear a change made in a browser or config.json as it happens, and say so when the running daemon predates the app
Shahriar8cd7629823ea
diff --git a/src/mac/Sources/Browsentic/App/AppModel.swift b/src/mac/Sources/Browsentic/App/AppModel.swiftindex 92f7b24..f2699e9 100644--- a/src/mac/Sources/Browsentic/App/AppModel.swift+++ b/src/mac/Sources/Browsentic/App/AppModel.swift@@ -54,6 +54,9 @@ final class AppModel: ObservableObject {@Published var sessions: [BrowserSession] = []@Published var pairing: PairingCode?@Published var agents: AgentState?+ @Published var preferences: Preferences?+ /// The running daemon never answered for its settings: it predates this app and needs a restart.+ @Published var preferencesUnsupported = false@Published var skills: SkillListing?@Published var grants: [Grant] = []@Published var downloads: DownloadListing?@@ -71,6 +74,7 @@ final class AppModel: ObservableObject {private(set) var node: NodeInstall?private let control = ControlClient()private var poller: Task<Void, Never>?+ private var eventWatcher: Task<Void, Never>?private var updateWatcher: Task<Void, Never>?var cli: CLI? { node.map(CLI.init) }@@ -220,6 +224,13 @@ final class AppModel: ObservableObject {// MARK: Daemonfunc startPolling() {+ eventWatcher?.cancel()+ eventWatcher = Task { [weak self, control] in+ for await event in control.events where event == "settings-changed" {+ await self?.loadPreferences()+ await self?.loadAgents()+ }+ }poller?.cancel()poller = Task { [weak self] inwhile !Task.isCancelled {@@ -231,7 +242,9 @@ final class AppModel: ObservableObject {func refresh() async {guard let lock = Self.readLock() else { return markOff() }- await control.connect(lock)+ if await control.connect(lock) {+ Task { await self.loadPreferences(watch: true) }+ }do {let status = try await control.status()let sessions = try await control.sessions()@@ -255,6 +268,7 @@ final class AppModel: ObservableObject {status = nilsessions = []pairing = nil+ preferences = nil}private static func readLock() -> Lockfile? {@@ -306,6 +320,23 @@ final class AppModel: ObservableObject {if let state = try? await cli.agents() { agents = state }}+ func loadPreferences(watch: Bool = false) async {+ do {+ preferences = try await control.preferences(watch: watch)+ preferencesUnsupported = false+ } catch ControlError.timeout {+ preferencesUnsupported = true+ } catch {}+ }++ func setBrowserTheme(_ theme: BrowserTheme) async {+ await perform("theme") { _, control in self.preferences = try await control.setTheme(theme) }+ }++ func setGuardrail(_ setting: String, to value: Any?) async {+ await perform("guardrail:\(setting)") { _, control in self.preferences = try await control.setGuardrail(setting, to: value) }+ }+func selectAgent(_ kind: String) async {await perform("agent:\(kind)") { _, control inlet state = try await control.agent(set: kind)diff --git a/src/mac/Sources/Browsentic/Core/ControlClient.swift b/src/mac/Sources/Browsentic/Core/ControlClient.swiftindex 5c4ee07..6f16295 100644--- a/src/mac/Sources/Browsentic/Core/ControlClient.swift+++ b/src/mac/Sources/Browsentic/Core/ControlClient.swift@@ -19,12 +19,18 @@ enum ControlError: LocalizedError {actor ControlClient {private var task: URLSessionWebSocketTask?private var pending: [String: CheckedContinuation<Data, Error>] = [:]+ private let (eventStream, eventSink) = AsyncStream.makeStream(of: String.self)private(set) var lock: Lockfile?var isOpen: Bool { task?.state == .running }- func connect(_ lock: Lockfile) {- if self.lock == lock, isOpen { return }+ /// What the daemon says without being asked, from whichever socket is open at the time.+ nonisolated var events: AsyncStream<String> { eventStream }++ /// True when this opened a new socket, which has subscribed to nothing yet.+ @discardableResult+ func connect(_ lock: Lockfile) -> Bool {+ if self.lock == lock, isOpen { return false }close()var request = URLRequest(url: URL(string: "ws://127.0.0.1:\(lock.port)/control")!)request.setValue("Bearer \(lock.token)", forHTTPHeaderField: "Authorization")@@ -34,6 +40,7 @@ actor ControlClient {self.lock = locktask.resume()listen(on: task)+ return true}func close() {@@ -72,6 +79,24 @@ actor ControlClient {return try await request(frame, as: Reply<AgentState>.self, key: "state", timeout: 60)}+ /// The settings the extension's settings page edits too. `watch` subscribes this socket to `settings-changed`.+ func preferences(watch: Bool = false) async throws -> Preferences {+ try await request(["op": "preferences", "watch": watch], as: Reply<Outcome<Preferences>>.self, key: "result").value()+ }++ func setTheme(_ theme: BrowserTheme) async throws -> Preferences {+ try await setPreference(["kind": "theme", "theme": theme.rawValue])+ }++ /// `value` is an effect, a switch's Bool, or nil to go back to the default Browsentic ships.+ func setGuardrail(_ setting: String, to value: Any?) async throws -> Preferences {+ try await setPreference(["kind": "guardrail", "setting": setting, "value": value ?? NSNull()])+ }++ private func setPreference(_ change: [String: Any]) async throws -> Preferences {+ try await request(["op": "setPreference", "change": change], as: Reply<Outcome<Preferences>>.self, key: "result").value()+ }+private struct Reply<Value: Decodable>: Decodable {let value: Value@@ -146,9 +171,9 @@ actor ControlClient {failAll(ControlError.offline)case .success(let message):if case .string(let text) = message, let data = text.data(using: .utf8),- let frame = try? JSONSerialization.jsonObject(with: data) as? [String: Any],- let id = frame["id"] as? String {- settle(id, .success(data))+ let frame = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {+ if let id = frame["id"] as? String { settle(id, .success(data)) }+ if let event = frame["event"] as? String { eventSink.yield(event) }}listen(on: task)}diff --git a/src/mac/Sources/Browsentic/Core/Models.swift b/src/mac/Sources/Browsentic/Core/Models.swiftindex 0eee429..f0412a3 100644--- a/src/mac/Sources/Browsentic/Core/Models.swift+++ b/src/mac/Sources/Browsentic/Core/Models.swift@@ -82,6 +82,82 @@ struct AgentState: Decodable, Equatable {var catalog: [AgentDescriptor]?}+/// What config.json holds for every surface. The extension's settings page reads and writes the same values.+struct Preferences: Decodable, Equatable {+ /// Nil until someone picks one; every paired browser shows Ember until then.+ let theme: String?+ let guardrails: GuardrailSettings+}++struct GuardrailSettings: Decodable, Equatable {+ struct Switch: Decodable, Equatable {+ let enabled: Bool+ let overridden: Bool+ }++ struct Unattended: Decodable, Equatable {+ let effect: String+ let overridden: Bool+ }++ let rules: [GuardrailRule]+ let fence: Switch+ let unattended: Unattended+ let hosts: [String]+ let configPath: String+}++struct GuardrailRule: Decodable, Identifiable, Equatable {+ let id: String+ let title: String+ let reason: String+ /// The effect with nothing overridden.+ let fallback: String+ /// Present only when someone chose one.+ let choice: String?+ let locked: Bool?++ var isLocked: Bool { locked == true }++ enum CodingKeys: String, CodingKey {+ case choice = "override"+ case id, title, reason, fallback, locked+ }+}++enum RuleEffect: String, CaseIterable, Identifiable {+ case allow, confirm, deny++ var id: String { rawValue }+ var label: String {+ switch self {+ case .allow: "Allow"+ case .confirm: "Ask"+ case .deny: "Block"+ }+ }++ static func label(_ raw: String) -> String { RuleEffect(rawValue: raw)?.label ?? raw.capitalized }+}++/// A daemon answer shaped `{ ok, data }` or `{ ok, error }`, as the whole socket protocol is.+struct Outcome<Value: Decodable>: Decodable {+ struct Failure: Decodable, LocalizedError {+ let code: String+ let message: String+ var errorDescription: String? { message }+ }++ let ok: Bool+ let data: Value?+ let error: Failure?++ func value() throws -> Value {+ if ok, let data { return data }+ throw error ?? Failure(code: "MALFORMED", message: ControlError.malformed.localizedDescription)+ }+}+struct Skill: Decodable, Identifiable, Equatable {let name: Stringlet description: Stringdiff --git a/src/mac/Sources/Browsentic/Theme/Theme.swift b/src/mac/Sources/Browsentic/Theme/Theme.swiftindex af4fa18..08046a4 100644--- a/src/mac/Sources/Browsentic/Theme/Theme.swift+++ b/src/mac/Sources/Browsentic/Theme/Theme.swift@@ -59,3 +59,47 @@ extension Font {.system(size: size, weight: weight, design: .monospaced)}}++/// The extension's four looks, which this app can pick for every paired browser. The swatches are+/// globals.css' oklch tokens converted once, the same way `Palette` was; a change there is re-derived here.+enum BrowserTheme: String, CaseIterable, Identifiable {+ case ember, midnight, phosphor, daylight++ struct Swatches {+ let ground: Color+ let surface: Color+ let ink: Color+ let inkFaint: Color+ let brand: Color+ let accents: [Color]+ }++ var id: String { rawValue }+ var name: String { rawValue.capitalized }++ var note: String {+ switch self {+ case .ember: "Warm near-black, cyan brand."+ case .midnight: "Cool blue-black, violet brand."+ case .phosphor: "A green CRT, grain turned up."+ case .daylight: "Ink on paper, for a bright room."+ }+ }++ var swatches: Swatches {+ switch self {+ case .ember: Self.swatches(0x110A06, 0x201611, 0xF7F0E9, 0x83766E, 0x3BE1E1, [0xFE804C, 0x63EA89, 0xF7C243])+ case .midnight: Self.swatches(0x080D17, 0x151C2C, 0xEEF1FA, 0x747C8C, 0xB6AAFF, [0xFF807F, 0x2FF0B2, 0xFFC75A])+ case .phosphor: Self.swatches(0x040C06, 0x0D1C10, 0xD1F9D8, 0x668B6D, 0x4BF58C, [0xFF9757, 0xC8F23C, 0xFAD03E])+ case .daylight: Self.swatches(0xFCFBF8, 0xF0ECE7, 0x2C231D, 0x7D7068, 0x007791, [0xC04307, 0x187E36, 0xA66300])+ }+ }++ private static func swatches(_ ground: UInt32, _ surface: UInt32, _ ink: UInt32, _ inkFaint: UInt32, _ brand: UInt32, _ accents: [UInt32]) -> Swatches {+ Swatches(ground: color(ground), surface: color(surface), ink: color(ink), inkFaint: color(inkFaint), brand: color(brand), accents: accents.map(color))+ }++ private static func color(_ hex: UInt32) -> Color {+ Color(.sRGB, red: Double((hex >> 16) & 0xFF) / 255, green: Double((hex >> 8) & 0xFF) / 255, blue: Double(hex & 0xFF) / 255)+ }+}diff --git a/src/mac/Sources/Browsentic/Views/BrowserSettings.swift b/src/mac/Sources/Browsentic/Views/BrowserSettings.swiftnew file mode 100644index 0000000..e47c773--- /dev/null+++ b/src/mac/Sources/Browsentic/Views/BrowserSettings.swift@@ -0,0 +1,295 @@+import SwiftUI++/// The settings every paired browser shares, kept by the daemon in config.json. The extension's own+/// settings page edits the same values, and a change on either side shows up on the other at once.+struct BrowserSettings: View {+ @EnvironmentObject private var model: AppModel++ var body: some View {+ if model.daemon != .on {+ OfflineHint(what: "The browser theme and the guardrails")+ } else if model.preferencesUnsupported {+ StaleDaemonHint()+ } else if let preferences = model.preferences {+ BrowserThemeCard(selected: BrowserTheme(rawValue: preferences.theme ?? "") ?? .ember)+ GuardrailsCard(settings: preferences.guardrails)+ } else {+ Card { ProgressView().controlSize(.small).frame(maxWidth: .infinity) }+ }+ }+}++private struct StaleDaemonHint: View {+ @EnvironmentObject private var model: AppModel++ var body: some View {+ Card {+ HStack(spacing: 14) {+ Image(systemName: "arrow.clockwise.circle").font(.system(size: 18, weight: .semibold)).foregroundStyle(Palette.amber)+ SectionTitle(+ title: "The daemon predates this app",+ subtitle: "It is still running from before the last update, so it cannot share the browser theme or the guardrails yet."+ )+ Spacer()+ Button("Restart it") { Task { await model.restartDaemon() } }.buttonStyle(PrimaryButtonStyle())+ }+ }+ }+}++private struct BrowserThemeCard: View {+ @EnvironmentObject private var model: AppModel+ let selected: BrowserTheme++ var body: some View {+ Card {+ VStack(alignment: .leading, spacing: 14) {+ SectionTitle(+ title: "Browser theme",+ subtitle: "How the side panel, the popup and the extension’s settings page look in every paired browser. This window keeps its own appearance."+ )+ HStack(spacing: 10) {+ ForEach(BrowserTheme.allCases) { theme in+ ThemeTile(theme: theme, selected: theme == selected) {+ Task { await model.setBrowserTheme(theme) }+ }+ }+ }+ .disabled(model.busy.contains("theme"))+ }+ }+ }+}++private struct ThemeTile: View {+ let theme: BrowserTheme+ let selected: Bool+ let pick: () -> Void++ var body: some View {+ let swatch = theme.swatches+ Button(action: pick) {+ VStack(alignment: .leading, spacing: 8) {+ VStack(alignment: .leading, spacing: 4) {+ Capsule().fill(swatch.ink.opacity(0.75)).frame(width: 52, height: 4)+ Capsule().fill(swatch.ink.opacity(0.3)).frame(width: 34, height: 4)+ HStack(spacing: 4) {+ ForEach(Array(([swatch.brand] + swatch.accents).enumerated()), id: \.offset) { _, color in+ Circle().fill(color).frame(width: 7, height: 7)+ }+ }+ .padding(.top, 4)+ }+ .padding(9)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(swatch.surface, in: RoundedRectangle(cornerRadius: 8, style: .continuous))++ HStack(spacing: 6) {+ Text(theme.name).font(.system(size: 12, weight: .semibold)).foregroundStyle(swatch.ink)+ Spacer(minLength: 0)+ Image(systemName: selected ? "checkmark.circle.fill" : "circle")+ .font(.system(size: 12, weight: .semibold))+ .foregroundStyle(selected ? swatch.brand : swatch.inkFaint)+ }+ Text(theme.note)+ .font(.system(size: 10.5))+ .foregroundStyle(swatch.inkFaint)+ .lineLimit(2, reservesSpace: true)+ }+ .padding(10)+ .background(swatch.ground, in: RoundedRectangle(cornerRadius: 12, style: .continuous))+ .overlay(+ RoundedRectangle(cornerRadius: 12, style: .continuous)+ .strokeBorder(selected ? swatch.brand.opacity(0.7) : Palette.line, lineWidth: selected ? 1.5 : 1)+ )+ .contentShape(RoundedRectangle(cornerRadius: 12, style: .continuous))+ }+ .buttonStyle(.plain)+ .accessibilityLabel("\(theme.name) browser theme")+ .accessibilityAddTraits(selected ? .isSelected : [])+ }+}++private struct GuardrailsCard: View {+ @EnvironmentObject private var model: AppModel+ let settings: GuardrailSettings++ var body: some View {+ Card {+ VStack(alignment: .leading, spacing: 16) {+ SectionTitle(+ title: "Guardrails",+ subtitle: "What the agent may do without asking you first. Each row starts on the default Browsentic ships; switch one on to choose Allow, Ask or Block. A run takes its policy when it starts."+ )++ RowGroup(rows: settings.rules.filter { !$0.isLocked }.map { rule in+ AnyView(RuleRow(rule: rule))+ })++ RowGroup(title: "Everything else", rows: [+ AnyView(SwitchRow(+ id: "fence",+ title: "Fence page text",+ note: "Wraps every page result in a marker telling the model it is reading data, never instructions.",+ state: settings.fence.overridden ? (settings.fence.enabled ? "On" : "Off") : "On (default)",+ overridden: settings.fence.overridden,+ whenOn: settings.fence.enabled+ ) {+ Picker("Fence page text", selection: Binding(+ get: { settings.fence.enabled },+ set: { value in Task { await model.setGuardrail("fence", to: value) } }+ )) {+ Text("Fence").tag(true)+ Text("Do not fence").tag(false)+ }+ }),+ AnyView(SwitchRow(+ id: "unattended",+ title: "Callers with nobody to ask",+ note: "An MCP client outside the side panel cannot answer a prompt. This is what its “Ask” decisions become.",+ state: settings.unattended.overridden ? RuleEffect.label(settings.unattended.effect) : "Block (default)",+ overridden: settings.unattended.overridden,+ whenOn: settings.unattended.effect+ ) {+ Picker("Callers with nobody to ask", selection: Binding(+ get: { settings.unattended.effect },+ set: { value in Task { await model.setGuardrail("unattended", to: value) } }+ )) {+ Text("Block").tag("deny")+ Text("Allow").tag("allow")+ }+ }),+ ])++ RowGroup(title: "Not switches", rows: [AnyView(FactRow(+ icon: "checkmark.shield.fill",+ title: "Credential sealing",+ badge: "Always on",+ note: "Passwords, keys, tokens and cookies are replaced by a placeholder before a result leaves the browser."+ ))] + settings.rules.filter(\.isLocked).map { rule in+ AnyView(FactRow(icon: "lock.fill", title: rule.title, badge: RuleEffect.label(rule.fallback), note: rule.reason))+ })++ if !settings.hosts.isEmpty {+ VStack(alignment: .leading, spacing: 4) {+ Text("Standing host allowlist").font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.inkDim)+ Text(settings.hosts.joined(separator: " · ")).font(.code(11)).foregroundStyle(Palette.inkFaint).textSelection(.enabled)+ }+ }++ PathRow(url: URL(fileURLWithPath: settings.configPath))+ }+ }+ }+}++private struct RowGroup: View {+ var title: String?+ let rows: [AnyView]++ var body: some View {+ VStack(alignment: .leading, spacing: 8) {+ if let title {+ Text(title.uppercased()).font(.code(10)).tracking(1.2).foregroundStyle(Palette.inkFaint)+ }+ VStack(spacing: 0) {+ ForEach(rows.indices, id: \.self) { index in+ if index > 0 { Divider().overlay(Palette.line) }+ rows[index]+ }+ }+ .background(Palette.ground2.opacity(0.6), in: RoundedRectangle(cornerRadius: 12, style: .continuous))+ .overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).strokeBorder(Palette.line))+ }+ }+}++private struct RuleRow: View {+ @EnvironmentObject private var model: AppModel+ let rule: GuardrailRule++ var body: some View {+ SwitchRow(+ id: rule.id,+ title: rule.title,+ note: rule.reason,+ state: rule.choice.map(RuleEffect.label) ?? "\(RuleEffect.label(rule.fallback)) (default)",+ overridden: rule.choice != nil,+ whenOn: rule.choice ?? rule.fallback+ ) {+ Picker(rule.title, selection: Binding(+ get: { rule.choice ?? rule.fallback },+ set: { value in Task { await model.setGuardrail(rule.id, to: value) } }+ )) {+ ForEach(RuleEffect.allCases) { Text($0.label).tag($0.rawValue) }+ }+ }+ }+}++/// A row that uses the shipped default until switched on, and then offers its choices underneath.+private struct SwitchRow<Value: Sendable, Choices: View>: View {+ @EnvironmentObject private var model: AppModel+ let id: String+ let title: String+ let note: String+ let state: String+ let overridden: Bool+ /// What switching the row on writes: the value it already resolves to, so nothing changes until a choice is made.+ let whenOn: Value+ @ViewBuilder let choices: Choices++ var body: some View {+ HStack(alignment: .top, spacing: 16) {+ VStack(alignment: .leading, spacing: 3) {+ Text(title).font(.system(size: 12.5, weight: .medium)).foregroundStyle(Palette.ink)+ Text(note).font(.system(size: 11.5)).foregroundStyle(Palette.inkFaint).fixedSize(horizontal: false, vertical: true)+ if overridden {+ choices.pickerStyle(.segmented).labelsHidden().fixedSize().padding(.top, 6)+ }+ }+ Spacer(minLength: 0)+ Text(state.uppercased())+ .font(.code(10))+ .tracking(0.8)+ .foregroundStyle(overridden ? Palette.brand : Palette.inkFaint)+ .padding(.top, 2)+ if model.busy.contains("guardrail:\(id)") {+ ProgressView().controlSize(.small).frame(width: 34)+ } else {+ Toggle(title, isOn: Binding(+ get: { overridden },+ set: { on in Task { await model.setGuardrail(id, to: on ? whenOn as Any : nil) } }+ ))+ .toggleStyle(.switch)+ .labelsHidden()+ .controlSize(.small)+ .tint(Palette.brand)+ }+ }+ .padding(.horizontal, 14)+ .padding(.vertical, 11)+ .background(overridden ? Palette.brand.opacity(0.06) : .clear)+ }+}++private struct FactRow: View {+ let icon: String+ let title: String+ let badge: String+ let note: String++ var body: some View {+ VStack(alignment: .leading, spacing: 3) {+ HStack(spacing: 7) {+ Image(systemName: icon).font(.system(size: 10, weight: .semibold)).foregroundStyle(Palette.inkFaint)+ Text(title).font(.system(size: 12.5, weight: .medium)).foregroundStyle(Palette.inkDim)+ Spacer(minLength: 0)+ Text(badge.uppercased()).font(.code(10)).tracking(0.8).foregroundStyle(Palette.inkFaint)+ }+ Text(note).font(.system(size: 11.5)).foregroundStyle(Palette.inkFaint).fixedSize(horizontal: false, vertical: true)+ }+ .padding(.horizontal, 14)+ .padding(.vertical, 11)+ }+}diff --git a/src/mac/Sources/Browsentic/Views/SettingsView.swift b/src/mac/Sources/Browsentic/Views/SettingsView.swiftindex badda7e..b9e9c8d 100644--- a/src/mac/Sources/Browsentic/Views/SettingsView.swift+++ b/src/mac/Sources/Browsentic/Views/SettingsView.swift@@ -31,6 +31,8 @@ struct SettingsView: View {}}+ BrowserSettings()+Card {VStack(alignment: .leading, spacing: 12) {SwitchRow(diff --git a/src/mac/Tests/BrowsenticTests/ModelTests.swift b/src/mac/Tests/BrowsenticTests/ModelTests.swiftindex cad18ab..6cdb658 100644--- a/src/mac/Tests/BrowsenticTests/ModelTests.swift+++ b/src/mac/Tests/BrowsenticTests/ModelTests.swift@@ -52,6 +52,33 @@ import Testing#expect(session.extensionId == "abcdef")}+ @Test func preferencesCarryALockedRuleAndOneLeftOnItsDefault() throws {+ let result = #"""+ {"ok":true,"data":{"theme":null,"guardrails":{"rules":[+ {"id":"secret-in-url","title":"Secret in a URL","reason":"A credential never travels in a query string.","fallback":"deny","locked":true},+ {"id":"form-submission","title":"Submits a form","reason":"Submitting a form is a consequential action.","fallback":"confirm","override":"allow"},+ {"id":"file-upload","title":"Uploads one of the user's files","reason":"It hands the file to the site.","fallback":"confirm"}],+ "fence":{"enabled":true,"overridden":false},"unattended":{"effect":"deny","overridden":false},"hosts":[],"configPath":"/Users/x/.browsentic/config.json"}}}+ """#+ let preferences = try JSONDecoder().decode(Outcome<Preferences>.self, from: Data(result.utf8)).value()+ #expect(preferences.theme == nil)+ #expect(preferences.guardrails.rules.map(\.isLocked) == [true, false, false])+ #expect(preferences.guardrails.rules.map(\.choice) == [nil, "allow", nil])+ #expect(RuleEffect.label(preferences.guardrails.rules[1].fallback) == "Ask")+ }++ @Test func aRefusedChangeThrowsTheDaemonsOwnMessage() throws {+ let result = #"{"ok":false,"error":{"code":"BLOCKED","message":"An agent run cannot change the settings it runs under."}}"#+ let outcome = try JSONDecoder().decode(Outcome<Preferences>.self, from: Data(result.utf8))+ #expect(throws: Outcome<Preferences>.Failure.self) { try outcome.value() }+ #expect((try? outcome.value()) == nil)+ #expect(outcome.error?.localizedDescription == "An agent run cannot change the settings it runs under.")+ }++ @Test func everyBrowserThemeIsOneTheExtensionKnows() {+ #expect(BrowserTheme.allCases.map(\.rawValue) == ["ember", "midnight", "phosphor", "daylight"])+ }+@Test func timestampsReadTheDaemonsIsoStrings() {#expect(Timestamp.date("2026-09-17T14:21:45.381Z") != nil)#expect(Timestamp.ago("not a date") == "not a date")