mirror of
https://github.com/awizemann/scarf.git
synced 2026-05-10 18:44:45 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f78856e6e | |||
| 5877bf6519 | |||
| f19f19cd56 |
@@ -311,6 +311,14 @@ public actor ACPClient {
|
|||||||
let result = try await sendRequest(method: "session/prompt", params: params)
|
let result = try await sendRequest(method: "session/prompt", params: params)
|
||||||
let dict = result?.dictValue ?? [:]
|
let dict = result?.dictValue ?? [:]
|
||||||
let usage = dict["usage"] as? [String: Any] ?? [:]
|
let usage = dict["usage"] as? [String: Any] ?? [:]
|
||||||
|
// TODO(WS-8-Q1): Confirm wire field name once v0.13 Hermes is
|
||||||
|
// available. We tolerate camelCase + snake_case to match the rest
|
||||||
|
// of the ACP payload's mixed conventions; if Hermes routes the
|
||||||
|
// count through a `session/update` notification instead, this
|
||||||
|
// decode is a no-op and the ACPEvent path takes over.
|
||||||
|
let compression = (usage["compressionCount"] as? Int)
|
||||||
|
?? (usage["compression_count"] as? Int)
|
||||||
|
?? 0
|
||||||
|
|
||||||
statusMessage = "Ready"
|
statusMessage = "Ready"
|
||||||
return ACPPromptResult(
|
return ACPPromptResult(
|
||||||
@@ -318,7 +326,8 @@ public actor ACPClient {
|
|||||||
inputTokens: usage["inputTokens"] as? Int ?? 0,
|
inputTokens: usage["inputTokens"] as? Int ?? 0,
|
||||||
outputTokens: usage["outputTokens"] as? Int ?? 0,
|
outputTokens: usage["outputTokens"] as? Int ?? 0,
|
||||||
thoughtTokens: usage["thoughtTokens"] as? Int ?? 0,
|
thoughtTokens: usage["thoughtTokens"] as? Int ?? 0,
|
||||||
cachedReadTokens: usage["cachedReadTokens"] as? Int ?? 0
|
cachedReadTokens: usage["cachedReadTokens"] as? Int ?? 0,
|
||||||
|
compressionCount: compression
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,19 +243,32 @@ public struct ACPPromptResult: Sendable {
|
|||||||
public let outputTokens: Int
|
public let outputTokens: Int
|
||||||
public let thoughtTokens: Int
|
public let thoughtTokens: Int
|
||||||
public let cachedReadTokens: Int
|
public let cachedReadTokens: Int
|
||||||
|
/// Number of automatic context compactions Hermes has performed on this
|
||||||
|
/// session so far. v0.13+ — older Hermes hosts always return 0, which
|
||||||
|
/// the chat status bar treats as "hide chip". Optional in the wire
|
||||||
|
/// payload; folded into a non-optional `Int` here with a 0 default so
|
||||||
|
/// the rest of the pipeline doesn't need to nil-check.
|
||||||
|
// TODO(WS-8-Q1): Verify that v0.13 Hermes emits the count on
|
||||||
|
// `session/prompt`'s `usage` blob (assumed here). If it lands on a
|
||||||
|
// separate `session/update` notification instead, this becomes a new
|
||||||
|
// ACPEvent case + a branch in RichChatViewModel.handleACPEvent — wire
|
||||||
|
// shape is documented in the WS-8 plan as the bigger fix path.
|
||||||
|
public let compressionCount: Int
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
stopReason: String,
|
stopReason: String,
|
||||||
inputTokens: Int,
|
inputTokens: Int,
|
||||||
outputTokens: Int,
|
outputTokens: Int,
|
||||||
thoughtTokens: Int,
|
thoughtTokens: Int,
|
||||||
cachedReadTokens: Int
|
cachedReadTokens: Int,
|
||||||
|
compressionCount: Int = 0
|
||||||
) {
|
) {
|
||||||
self.stopReason = stopReason
|
self.stopReason = stopReason
|
||||||
self.inputTokens = inputTokens
|
self.inputTokens = inputTokens
|
||||||
self.outputTokens = outputTokens
|
self.outputTokens = outputTokens
|
||||||
self.thoughtTokens = thoughtTokens
|
self.thoughtTokens = thoughtTokens
|
||||||
self.cachedReadTokens = cachedReadTokens
|
self.cachedReadTokens = cachedReadTokens
|
||||||
|
self.compressionCount = compressionCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ public struct DisplaySettings: Sendable, Equatable {
|
|||||||
public var toolProgressCommand: Bool
|
public var toolProgressCommand: Bool
|
||||||
public var toolPreviewLength: Int
|
public var toolPreviewLength: Int
|
||||||
public var busyInputMode: String // e.g. "interrupt"
|
public var busyInputMode: String // e.g. "interrupt"
|
||||||
|
/// Static-message translation language. v0.13+. Empty string means
|
||||||
|
/// "follow Hermes default" — the picker collapses both empty-string
|
||||||
|
/// and `"en"` to "English" in display, but only writes a value when
|
||||||
|
/// the user explicitly picks one. Persisted via
|
||||||
|
/// `hermes config set display.language <code>`. Supported values per
|
||||||
|
/// v0.13 release notes: `en`, `zh`, `ja`, `de`, `es`, `fr`, `uk`, `tr`.
|
||||||
|
public var language: String
|
||||||
|
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
@@ -46,7 +53,8 @@ public struct DisplaySettings: Sendable, Equatable {
|
|||||||
inlineDiffs: Bool,
|
inlineDiffs: Bool,
|
||||||
toolProgressCommand: Bool,
|
toolProgressCommand: Bool,
|
||||||
toolPreviewLength: Int,
|
toolPreviewLength: Int,
|
||||||
busyInputMode: String
|
busyInputMode: String,
|
||||||
|
language: String = ""
|
||||||
) {
|
) {
|
||||||
self.skin = skin
|
self.skin = skin
|
||||||
self.compact = compact
|
self.compact = compact
|
||||||
@@ -56,6 +64,7 @@ public struct DisplaySettings: Sendable, Equatable {
|
|||||||
self.toolProgressCommand = toolProgressCommand
|
self.toolProgressCommand = toolProgressCommand
|
||||||
self.toolPreviewLength = toolPreviewLength
|
self.toolPreviewLength = toolPreviewLength
|
||||||
self.busyInputMode = busyInputMode
|
self.busyInputMode = busyInputMode
|
||||||
|
self.language = language
|
||||||
}
|
}
|
||||||
public nonisolated static let empty = DisplaySettings(
|
public nonisolated static let empty = DisplaySettings(
|
||||||
skin: "default",
|
skin: "default",
|
||||||
@@ -65,7 +74,8 @@ public struct DisplaySettings: Sendable, Equatable {
|
|||||||
inlineDiffs: true,
|
inlineDiffs: true,
|
||||||
toolProgressCommand: false,
|
toolProgressCommand: false,
|
||||||
toolPreviewLength: 0,
|
toolPreviewLength: 0,
|
||||||
busyInputMode: "interrupt"
|
busyInputMode: "interrupt",
|
||||||
|
language: ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +200,15 @@ public struct VoiceSettings: Sendable, Equatable {
|
|||||||
public var ttsOpenAIVoice: String
|
public var ttsOpenAIVoice: String
|
||||||
public var ttsNeuTTSModel: String
|
public var ttsNeuTTSModel: String
|
||||||
public var ttsNeuTTSDevice: String
|
public var ttsNeuTTSDevice: String
|
||||||
|
/// xAI TTS voice identifier. v0.13+ — xAI shipped TTS earlier but the
|
||||||
|
/// custom-voice / cloning surface is the v0.13 add-on.
|
||||||
|
// TODO(WS-8-Q2): Confirm key name vs `tts.xai.voice` /
|
||||||
|
// `tts.xai.voice_id` / a top-level `tts.xai_voice` once a v0.13
|
||||||
|
// host is on hand. The setter / YAML reader follow whatever this
|
||||||
|
// field name implies.
|
||||||
|
public var ttsXAIVoiceID: String
|
||||||
|
/// xAI TTS model identifier. v0.13+. Mirrors the elevenlabs shape.
|
||||||
|
public var ttsXAIModel: String
|
||||||
|
|
||||||
// STT
|
// STT
|
||||||
public var sttEnabled: Bool
|
public var sttEnabled: Bool
|
||||||
@@ -217,7 +236,9 @@ public struct VoiceSettings: Sendable, Equatable {
|
|||||||
sttLocalModel: String,
|
sttLocalModel: String,
|
||||||
sttLocalLanguage: String,
|
sttLocalLanguage: String,
|
||||||
sttOpenAIModel: String,
|
sttOpenAIModel: String,
|
||||||
sttMistralModel: String
|
sttMistralModel: String,
|
||||||
|
ttsXAIVoiceID: String = "",
|
||||||
|
ttsXAIModel: String = ""
|
||||||
) {
|
) {
|
||||||
self.recordKey = recordKey
|
self.recordKey = recordKey
|
||||||
self.maxRecordingSeconds = maxRecordingSeconds
|
self.maxRecordingSeconds = maxRecordingSeconds
|
||||||
@@ -230,6 +251,8 @@ public struct VoiceSettings: Sendable, Equatable {
|
|||||||
self.ttsOpenAIVoice = ttsOpenAIVoice
|
self.ttsOpenAIVoice = ttsOpenAIVoice
|
||||||
self.ttsNeuTTSModel = ttsNeuTTSModel
|
self.ttsNeuTTSModel = ttsNeuTTSModel
|
||||||
self.ttsNeuTTSDevice = ttsNeuTTSDevice
|
self.ttsNeuTTSDevice = ttsNeuTTSDevice
|
||||||
|
self.ttsXAIVoiceID = ttsXAIVoiceID
|
||||||
|
self.ttsXAIModel = ttsXAIModel
|
||||||
self.sttEnabled = sttEnabled
|
self.sttEnabled = sttEnabled
|
||||||
self.sttProvider = sttProvider
|
self.sttProvider = sttProvider
|
||||||
self.sttLocalModel = sttLocalModel
|
self.sttLocalModel = sttLocalModel
|
||||||
@@ -254,7 +277,9 @@ public struct VoiceSettings: Sendable, Equatable {
|
|||||||
sttLocalModel: "base",
|
sttLocalModel: "base",
|
||||||
sttLocalLanguage: "",
|
sttLocalLanguage: "",
|
||||||
sttOpenAIModel: "whisper-1",
|
sttOpenAIModel: "whisper-1",
|
||||||
sttMistralModel: "voxtral-mini-latest"
|
sttMistralModel: "voxtral-mini-latest",
|
||||||
|
ttsXAIVoiceID: "",
|
||||||
|
ttsXAIModel: ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,18 +691,6 @@ public struct HermesConfig: Sendable {
|
|||||||
/// final reply (provider/model/cost/turn count). Off by default;
|
/// final reply (provider/model/cost/turn count). Off by default;
|
||||||
/// useful for cost auditing and screen-recording demos.
|
/// useful for cost auditing and screen-recording demos.
|
||||||
public var runtimeMetadataFooter: Bool
|
public var runtimeMetadataFooter: Bool
|
||||||
/// Pre-v0.13: single combined Web Tools backend at `web_tools.backend`.
|
|
||||||
/// v0.13 split this into per-capability keys (see below). Kept readable
|
|
||||||
/// for round-trip compatibility on hosts that never migrated; v0.13+
|
|
||||||
/// hosts ignore this scalar and read the split keys instead.
|
|
||||||
public var webToolsBackend: String
|
|
||||||
/// v0.13+: `web_tools.search.backend`. SearXNG is search-only and
|
|
||||||
/// can land here. Pre-v0.13 hosts default to the same value as the
|
|
||||||
/// combined backend.
|
|
||||||
public var webToolsSearchBackend: String
|
|
||||||
/// v0.13+: `web_tools.extract.backend`. Pre-v0.13 hosts default to
|
|
||||||
/// the same value as the combined backend.
|
|
||||||
public var webToolsExtractBackend: String
|
|
||||||
|
|
||||||
// Grouped blocks
|
// Grouped blocks
|
||||||
public var display: DisplaySettings
|
public var display: DisplaySettings
|
||||||
@@ -759,17 +772,11 @@ public struct HermesConfig: Sendable {
|
|||||||
homeAssistant: HomeAssistantSettings,
|
homeAssistant: HomeAssistantSettings,
|
||||||
cacheTTL: String = "5m",
|
cacheTTL: String = "5m",
|
||||||
redactionEnabled: Bool = false,
|
redactionEnabled: Bool = false,
|
||||||
runtimeMetadataFooter: Bool = false,
|
runtimeMetadataFooter: Bool = false
|
||||||
webToolsBackend: String = "duckduckgo",
|
|
||||||
webToolsSearchBackend: String = "duckduckgo",
|
|
||||||
webToolsExtractBackend: String = "reader"
|
|
||||||
) {
|
) {
|
||||||
self.cacheTTL = cacheTTL
|
self.cacheTTL = cacheTTL
|
||||||
self.redactionEnabled = redactionEnabled
|
self.redactionEnabled = redactionEnabled
|
||||||
self.runtimeMetadataFooter = runtimeMetadataFooter
|
self.runtimeMetadataFooter = runtimeMetadataFooter
|
||||||
self.webToolsBackend = webToolsBackend
|
|
||||||
self.webToolsSearchBackend = webToolsSearchBackend
|
|
||||||
self.webToolsExtractBackend = webToolsExtractBackend
|
|
||||||
self.model = model
|
self.model = model
|
||||||
self.provider = provider
|
self.provider = provider
|
||||||
self.maxTurns = maxTurns
|
self.maxTurns = maxTurns
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
/// job's prompt. YAML-only field today (no `--context-from` CLI
|
/// job's prompt. YAML-only field today (no `--context-from` CLI
|
||||||
/// flag yet) — Scarf displays it but doesn't write it.
|
/// flag yet) — Scarf displays it but doesn't write it.
|
||||||
public nonisolated let contextFrom: [String]?
|
public nonisolated let contextFrom: [String]?
|
||||||
/// Hermes v0.13+ — script-only watchdog mode. When `true` the
|
|
||||||
/// pre-run script runs but the AI turn is skipped. `nil` means the
|
|
||||||
/// jobs.json file is pre-v0.13 (treat as `false`); `false` is the
|
|
||||||
/// explicit v0.13+ default. Capability-gated on `hasCronNoAgent`
|
|
||||||
/// at all write call sites.
|
|
||||||
public nonisolated let noAgent: Bool?
|
|
||||||
|
|
||||||
public enum CodingKeys: String, CodingKey {
|
public enum CodingKeys: String, CodingKey {
|
||||||
case id, name, prompt, skills, model, schedule, enabled, state, deliver, silent
|
case id, name, prompt, skills, model, schedule, enabled, state, deliver, silent
|
||||||
@@ -47,7 +41,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
case timeoutSeconds = "timeout_seconds"
|
case timeoutSeconds = "timeout_seconds"
|
||||||
case workdir
|
case workdir
|
||||||
case contextFrom = "context_from"
|
case contextFrom = "context_from"
|
||||||
case noAgent = "no_agent"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Memberwise init. Swift doesn't synthesize one for us because
|
/// Memberwise init. Swift doesn't synthesize one for us because
|
||||||
@@ -73,8 +66,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
timeoutSeconds: Int? = nil,
|
timeoutSeconds: Int? = nil,
|
||||||
silent: Bool? = nil,
|
silent: Bool? = nil,
|
||||||
workdir: String? = nil,
|
workdir: String? = nil,
|
||||||
contextFrom: [String]? = nil,
|
contextFrom: [String]? = nil
|
||||||
noAgent: Bool? = nil
|
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -96,7 +88,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
self.silent = silent
|
self.silent = silent
|
||||||
self.workdir = workdir
|
self.workdir = workdir
|
||||||
self.contextFrom = contextFrom
|
self.contextFrom = contextFrom
|
||||||
self.noAgent = noAgent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public nonisolated init(from decoder: any Decoder) throws {
|
public nonisolated init(from decoder: any Decoder) throws {
|
||||||
@@ -121,7 +112,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
self.silent = try c.decodeIfPresent(Bool.self, forKey: .silent)
|
self.silent = try c.decodeIfPresent(Bool.self, forKey: .silent)
|
||||||
self.workdir = try c.decodeIfPresent(String.self, forKey: .workdir)
|
self.workdir = try c.decodeIfPresent(String.self, forKey: .workdir)
|
||||||
self.contextFrom = try c.decodeIfPresent([String].self, forKey: .contextFrom)
|
self.contextFrom = try c.decodeIfPresent([String].self, forKey: .contextFrom)
|
||||||
self.noAgent = try c.decodeIfPresent(Bool.self, forKey: .noAgent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public nonisolated func encode(to encoder: any Encoder) throws {
|
public nonisolated func encode(to encoder: any Encoder) throws {
|
||||||
@@ -146,7 +136,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
try c.encodeIfPresent(silent, forKey: .silent)
|
try c.encodeIfPresent(silent, forKey: .silent)
|
||||||
try c.encodeIfPresent(workdir, forKey: .workdir)
|
try c.encodeIfPresent(workdir, forKey: .workdir)
|
||||||
try c.encodeIfPresent(contextFrom, forKey: .contextFrom)
|
try c.encodeIfPresent(contextFrom, forKey: .contextFrom)
|
||||||
try c.encodeIfPresent(noAgent, forKey: .noAgent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public nonisolated var stateIcon: String {
|
public nonisolated var stateIcon: String {
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import Foundation
|
|||||||
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
|
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
|
||||||
case stdio
|
case stdio
|
||||||
case http
|
case http
|
||||||
/// Server-Sent Events transport. Hermes v0.13+ only.
|
|
||||||
// TODO(WS-7-Q1): Verify Hermes uses the literal `sse` transport name
|
|
||||||
// (vs. `streamable-http`/`http-sse`/etc.) once a v0.13 host is on hand.
|
|
||||||
case sse
|
|
||||||
|
|
||||||
public var id: String { rawValue }
|
public var id: String { rawValue }
|
||||||
|
|
||||||
@@ -15,7 +11,6 @@ public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiabl
|
|||||||
switch self {
|
switch self {
|
||||||
case .stdio: return "Local (stdio)"
|
case .stdio: return "Local (stdio)"
|
||||||
case .http: return "Remote (HTTP)"
|
case .http: return "Remote (HTTP)"
|
||||||
case .sse: return "Remote (SSE)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -38,12 +33,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
public let resourcesEnabled: Bool
|
public let resourcesEnabled: Bool
|
||||||
public let promptsEnabled: Bool
|
public let promptsEnabled: Bool
|
||||||
public let hasOAuthToken: Bool
|
public let hasOAuthToken: Bool
|
||||||
/// Hermes-side keepalive interval (seconds) for SSE transport. `nil`
|
|
||||||
/// when the YAML doesn't specify `sse_read_timeout` (Hermes default
|
|
||||||
/// applies). Pre-v0.13 hosts always have this as `nil`.
|
|
||||||
// TODO(WS-7-Q2): Default is assumed to be 300s per WS-7 plan; placeholder
|
|
||||||
// copy uses that. Verify against `~/.hermes/hermes-agent/hermes_cli/mcp.py`.
|
|
||||||
public let sseReadTimeout: Int?
|
|
||||||
|
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
@@ -62,8 +51,7 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
toolsExclude: [String],
|
toolsExclude: [String],
|
||||||
resourcesEnabled: Bool,
|
resourcesEnabled: Bool,
|
||||||
promptsEnabled: Bool,
|
promptsEnabled: Bool,
|
||||||
hasOAuthToken: Bool,
|
hasOAuthToken: Bool
|
||||||
sseReadTimeout: Int? = nil
|
|
||||||
) {
|
) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.transport = transport
|
self.transport = transport
|
||||||
@@ -81,7 +69,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
self.resourcesEnabled = resourcesEnabled
|
self.resourcesEnabled = resourcesEnabled
|
||||||
self.promptsEnabled = promptsEnabled
|
self.promptsEnabled = promptsEnabled
|
||||||
self.hasOAuthToken = hasOAuthToken
|
self.hasOAuthToken = hasOAuthToken
|
||||||
self.sseReadTimeout = sseReadTimeout
|
|
||||||
}
|
}
|
||||||
public var id: String { name }
|
public var id: String { name }
|
||||||
|
|
||||||
@@ -92,8 +79,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
return (command ?? "") + argString
|
return (command ?? "") + argString
|
||||||
case .http:
|
case .http:
|
||||||
return url ?? ""
|
return url ?? ""
|
||||||
case .sse:
|
|
||||||
return url ?? ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,14 +284,7 @@ public extension HermesConfig {
|
|||||||
homeAssistant: homeAssistant,
|
homeAssistant: homeAssistant,
|
||||||
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
|
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
|
||||||
redactionEnabled: bool("redaction.enabled", default: false),
|
redactionEnabled: bool("redaction.enabled", default: false),
|
||||||
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false),
|
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false)
|
||||||
// Pre-v0.13 hosts wrote a single `web_tools.backend`. v0.13 split
|
|
||||||
// it into per-capability keys. Read all three so the round-trip
|
|
||||||
// never loses a value the user already set; the WebTools tab
|
|
||||||
// chooses which to render based on `hasWebToolsBackendSplit`.
|
|
||||||
webToolsBackend: str("web_tools.backend", default: "duckduckgo"),
|
|
||||||
webToolsSearchBackend: str("web_tools.search.backend", default: "duckduckgo"),
|
|
||||||
webToolsExtractBackend: str("web_tools.extract.backend", default: "reader")
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// Pure helpers that build argv arrays for `hermes update` invocations.
|
||||||
|
///
|
||||||
|
/// Lives in ScarfCore so the eventual UI surface (Mac / iOS / remote)
|
||||||
|
/// shares flag selection. There is no in-app "Update Hermes" affordance
|
||||||
|
/// in v2.7.5 — Sparkle handles Scarf-self-update and `hermes update` is
|
||||||
|
/// invoked by users in their terminal — but capability-gated flag logic
|
||||||
|
/// is forward-compat plumbing that the future affordance will call. Each
|
||||||
|
/// helper is a `nonisolated static` pure function: no transport, no
|
||||||
|
/// MainActor, no mocking surface required.
|
||||||
|
public enum HermesUpdaterCommandBuilder {
|
||||||
|
/// Argv for an `hermes update` invocation, capability-gated.
|
||||||
|
///
|
||||||
|
/// Pre-v0.12 hosts only had `update` (no flags). v0.12+ accepts
|
||||||
|
/// `--check` for preflight. v0.13+ accepts `--yes` / `-y` for
|
||||||
|
/// unattended runs (skips the interactive confirmation prompt).
|
||||||
|
/// Flags are silently dropped when the connected host can't honor
|
||||||
|
/// them so callers don't need to branch on capabilities themselves.
|
||||||
|
public static func updateArgv(
|
||||||
|
capabilities: HermesCapabilities,
|
||||||
|
unattended: Bool,
|
||||||
|
checkOnly: Bool
|
||||||
|
) -> [String] {
|
||||||
|
var args: [String] = ["update"]
|
||||||
|
if checkOnly && capabilities.hasUpdateCheck {
|
||||||
|
args.append("--check")
|
||||||
|
}
|
||||||
|
if unattended && capabilities.hasUpdateNonInteractive {
|
||||||
|
args.append("--yes")
|
||||||
|
}
|
||||||
|
return args
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -229,6 +229,12 @@ public final class RichChatViewModel {
|
|||||||
public private(set) var acpOutputTokens = 0
|
public private(set) var acpOutputTokens = 0
|
||||||
public private(set) var acpThoughtTokens = 0
|
public private(set) var acpThoughtTokens = 0
|
||||||
public private(set) var acpCachedReadTokens = 0
|
public private(set) var acpCachedReadTokens = 0
|
||||||
|
/// Running count of context compactions Hermes has performed on this
|
||||||
|
/// session. Surfaced as the `🗜 ×N` chip in `SessionInfoBar` when > 0
|
||||||
|
/// and `HermesCapabilities.hasContextCompressionCount` is true. Each
|
||||||
|
/// `session/prompt` response carries the latest server-side total, so
|
||||||
|
/// we replace (with a `max` guard) rather than accumulate.
|
||||||
|
public private(set) var acpCompressionCount = 0
|
||||||
|
|
||||||
/// Slash commands advertised by the ACP server via `available_commands_update`.
|
/// Slash commands advertised by the ACP server via `available_commands_update`.
|
||||||
public private(set) var acpCommands: [HermesSlashCommand] = []
|
public private(set) var acpCommands: [HermesSlashCommand] = []
|
||||||
@@ -468,6 +474,7 @@ public final class RichChatViewModel {
|
|||||||
acpErrorHint = nil
|
acpErrorHint = nil
|
||||||
acpErrorDetails = nil
|
acpErrorDetails = nil
|
||||||
acpCachedReadTokens = 0
|
acpCachedReadTokens = 0
|
||||||
|
acpCompressionCount = 0
|
||||||
acpCommands = []
|
acpCommands = []
|
||||||
projectScopedCommands = []
|
projectScopedCommands = []
|
||||||
currentTurnStart = nil
|
currentTurnStart = nil
|
||||||
@@ -811,6 +818,13 @@ public final class RichChatViewModel {
|
|||||||
acpOutputTokens += response.outputTokens
|
acpOutputTokens += response.outputTokens
|
||||||
acpThoughtTokens += response.thoughtTokens
|
acpThoughtTokens += response.thoughtTokens
|
||||||
acpCachedReadTokens += response.cachedReadTokens
|
acpCachedReadTokens += response.cachedReadTokens
|
||||||
|
// Compression count is a session-wide running total emitted by
|
||||||
|
// Hermes; each prompt response carries the latest value, so we
|
||||||
|
// replace rather than accumulate. The `max` guard tolerates
|
||||||
|
// pre-v0.13 hosts (which emit 0) being upgraded server-side
|
||||||
|
// mid-session — once a real number lands the count resumes from
|
||||||
|
// there rather than snapping back to 0.
|
||||||
|
acpCompressionCount = max(acpCompressionCount, response.compressionCount)
|
||||||
isAgentWorking = false
|
isAgentWorking = false
|
||||||
buildMessageGroups()
|
buildMessageGroups()
|
||||||
// Final position after the prompt settles. Catches fast responses
|
// Final position after the prompt settles. Catches fast responses
|
||||||
|
|||||||
@@ -162,6 +162,47 @@ import Foundation
|
|||||||
// start → false.
|
// start → false.
|
||||||
#expect(vm.supportsCompress == false)
|
#expect(vm.supportsCompress == false)
|
||||||
#expect(vm.hasBroaderCommandMenu == false)
|
#expect(vm.hasBroaderCommandMenu == false)
|
||||||
|
// v0.13: compression count starts at 0 so the SessionInfoBar chip
|
||||||
|
// stays hidden on fresh sessions.
|
||||||
|
#expect(vm.acpCompressionCount == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @MainActor func richChatTracksCompressionCountFromPromptResults() {
|
||||||
|
let vm = RichChatViewModel(context: .local)
|
||||||
|
let response = ACPPromptResult(
|
||||||
|
stopReason: "end_turn",
|
||||||
|
inputTokens: 100, outputTokens: 50,
|
||||||
|
thoughtTokens: 20, cachedReadTokens: 10,
|
||||||
|
compressionCount: 3
|
||||||
|
)
|
||||||
|
vm.handleACPEvent(.promptComplete(sessionId: "s", response: response))
|
||||||
|
#expect(vm.acpCompressionCount == 3)
|
||||||
|
|
||||||
|
// Subsequent prompts overwrite (with a max guard) — the server
|
||||||
|
// emits a session-wide running total, not a per-prompt delta.
|
||||||
|
let next = ACPPromptResult(
|
||||||
|
stopReason: "end_turn",
|
||||||
|
inputTokens: 0, outputTokens: 0,
|
||||||
|
thoughtTokens: 0, cachedReadTokens: 0,
|
||||||
|
compressionCount: 5
|
||||||
|
)
|
||||||
|
vm.handleACPEvent(.promptComplete(sessionId: "s", response: next))
|
||||||
|
#expect(vm.acpCompressionCount == 5)
|
||||||
|
|
||||||
|
// A pre-v0.13 host mid-session emits 0; the max-guard keeps the
|
||||||
|
// last real value rather than snapping back.
|
||||||
|
let stale = ACPPromptResult(
|
||||||
|
stopReason: "end_turn",
|
||||||
|
inputTokens: 0, outputTokens: 0,
|
||||||
|
thoughtTokens: 0, cachedReadTokens: 0,
|
||||||
|
compressionCount: 0
|
||||||
|
)
|
||||||
|
vm.handleACPEvent(.promptComplete(sessionId: "s", response: stale))
|
||||||
|
#expect(vm.acpCompressionCount == 5)
|
||||||
|
|
||||||
|
// reset() clears the counter so a fresh session starts clean.
|
||||||
|
vm.reset()
|
||||||
|
#expect(vm.acpCompressionCount == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @MainActor func messageGroupDerivedProperties() {
|
@Test @MainActor func messageGroupDerivedProperties() {
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
@testable import ScarfCore
|
||||||
|
|
||||||
|
/// Pure-function matrix for `HermesUpdaterCommandBuilder.updateArgv`. The
|
||||||
|
/// builder degrades flags silently when the connected host can't honor
|
||||||
|
/// them, so the "is the right flag emitted on the right version?" matrix
|
||||||
|
/// is the meaningful test surface.
|
||||||
|
@Suite struct M0eUpdaterTests {
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
|
||||||
|
private func caps(_ versionLine: String?) -> HermesCapabilities {
|
||||||
|
guard let line = versionLine else { return .empty }
|
||||||
|
return HermesCapabilities.parseLine(line)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Pre-v0.12 (no flags supported)
|
||||||
|
|
||||||
|
@Test func preV012_returnsBareUpdateRegardlessOfFlags() {
|
||||||
|
let pre = caps("Hermes Agent v0.11.0 (2026.4.23)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: pre, unattended: false, checkOnly: false
|
||||||
|
) == ["update"])
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: pre, unattended: true, checkOnly: false
|
||||||
|
) == ["update"])
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: pre, unattended: true, checkOnly: true
|
||||||
|
) == ["update"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func unknownVersion_returnsBareUpdate() {
|
||||||
|
// No detected version means we can't guarantee any flag is
|
||||||
|
// honored; defensively emit the bare verb.
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: .empty, unattended: true, checkOnly: true
|
||||||
|
) == ["update"])
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - v0.12 (--check supported, --yes is not)
|
||||||
|
|
||||||
|
@Test func v012_checkOnly_emitsCheckFlag() {
|
||||||
|
let v012 = caps("Hermes Agent v0.12.0 (2026.4.30)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: v012, unattended: false, checkOnly: true
|
||||||
|
) == ["update", "--check"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func v012_unattended_dropsYesFlag() {
|
||||||
|
// v0.12 doesn't honor --yes; the helper degrades silently.
|
||||||
|
let v012 = caps("Hermes Agent v0.12.0 (2026.4.30)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: v012, unattended: true, checkOnly: false
|
||||||
|
) == ["update"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func v012_checkOnlyAndUnattended_emitsOnlyCheck() {
|
||||||
|
let v012 = caps("Hermes Agent v0.12.0 (2026.4.30)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: v012, unattended: true, checkOnly: true
|
||||||
|
) == ["update", "--check"])
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - v0.13 (full flag support)
|
||||||
|
|
||||||
|
@Test func v013_unattended_emitsYesFlag() {
|
||||||
|
let v013 = caps("Hermes Agent v0.13.0 (2026.5.7)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: v013, unattended: true, checkOnly: false
|
||||||
|
) == ["update", "--yes"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func v013_checkOnlyAndUnattended_emitsBothFlags() {
|
||||||
|
let v013 = caps("Hermes Agent v0.13.0 (2026.5.7)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: v013, unattended: true, checkOnly: true
|
||||||
|
) == ["update", "--check", "--yes"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func v013_neither_emitsBareUpdate() {
|
||||||
|
let v013 = caps("Hermes Agent v0.13.0 (2026.5.7)")
|
||||||
|
#expect(HermesUpdaterCommandBuilder.updateArgv(
|
||||||
|
capabilities: v013, unattended: false, checkOnly: false
|
||||||
|
) == ["update"])
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -242,6 +242,15 @@ import Foundation
|
|||||||
thoughtTokens: 20, cachedReadTokens: 10
|
thoughtTokens: 20, cachedReadTokens: 10
|
||||||
)
|
)
|
||||||
#expect(prompt.stopReason == "end_turn")
|
#expect(prompt.stopReason == "end_turn")
|
||||||
|
// v0.13: compressionCount has a 0 default for legacy callers.
|
||||||
|
#expect(prompt.compressionCount == 0)
|
||||||
|
|
||||||
|
let v013Prompt = ACPPromptResult(
|
||||||
|
stopReason: "end_turn", inputTokens: 0, outputTokens: 0,
|
||||||
|
thoughtTokens: 0, cachedReadTokens: 0,
|
||||||
|
compressionCount: 7
|
||||||
|
)
|
||||||
|
#expect(v013Prompt.compressionCount == 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func projectDashboardInitChain() {
|
@Test func projectDashboardInitChain() {
|
||||||
|
|||||||
@@ -84,7 +84,11 @@ struct HermesFileService: Sendable {
|
|||||||
inlineDiffs: bool("display.inline_diffs", default: true),
|
inlineDiffs: bool("display.inline_diffs", default: true),
|
||||||
toolProgressCommand: bool("display.tool_progress_command", default: false),
|
toolProgressCommand: bool("display.tool_progress_command", default: false),
|
||||||
toolPreviewLength: int("display.tool_preview_length", default: 0),
|
toolPreviewLength: int("display.tool_preview_length", default: 0),
|
||||||
busyInputMode: str("display.busy_input_mode", default: "interrupt")
|
busyInputMode: str("display.busy_input_mode", default: "interrupt"),
|
||||||
|
// v0.13: empty default means "key absent — agent uses its own
|
||||||
|
// default" (English). The picker writes a real value when the
|
||||||
|
// user explicitly chooses one.
|
||||||
|
language: str("display.language", default: "")
|
||||||
)
|
)
|
||||||
|
|
||||||
let terminal = TerminalSettings(
|
let terminal = TerminalSettings(
|
||||||
@@ -131,7 +135,12 @@ struct HermesFileService: Sendable {
|
|||||||
sttLocalModel: str("stt.local.model", default: "base"),
|
sttLocalModel: str("stt.local.model", default: "base"),
|
||||||
sttLocalLanguage: str("stt.local.language"),
|
sttLocalLanguage: str("stt.local.language"),
|
||||||
sttOpenAIModel: str("stt.openai.model", default: "whisper-1"),
|
sttOpenAIModel: str("stt.openai.model", default: "whisper-1"),
|
||||||
sttMistralModel: str("stt.mistral.model", default: "voxtral-mini-latest")
|
sttMistralModel: str("stt.mistral.model", default: "voxtral-mini-latest"),
|
||||||
|
// TODO(WS-8-Q2): Verify key names. Mirroring the elevenlabs
|
||||||
|
// shape (`<provider>.voice_id` + `<provider>.model`); v0.13
|
||||||
|
// source might use `tts.xai.voice` or `tts.xai.model_id`.
|
||||||
|
ttsXAIVoiceID: str("tts.xai.voice_id"),
|
||||||
|
ttsXAIModel: str("tts.xai.model")
|
||||||
)
|
)
|
||||||
|
|
||||||
func aux(_ name: String) -> AuxiliaryModel {
|
func aux(_ name: String) -> AuxiliaryModel {
|
||||||
@@ -599,8 +608,7 @@ struct HermesFileService: Sendable {
|
|||||||
toolsExclude: server.toolsExclude,
|
toolsExclude: server.toolsExclude,
|
||||||
resourcesEnabled: server.resourcesEnabled,
|
resourcesEnabled: server.resourcesEnabled,
|
||||||
promptsEnabled: server.promptsEnabled,
|
promptsEnabled: server.promptsEnabled,
|
||||||
hasOAuthToken: hasToken,
|
hasOAuthToken: hasToken
|
||||||
sseReadTimeout: server.sseReadTimeout
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -631,37 +639,6 @@ struct HermesFileService: Sendable {
|
|||||||
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
|
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an SSE-transport MCP server. v0.13+ only — caller is responsible
|
|
||||||
/// for capability-gating; pre-v0.13 hosts will reject the `--transport`
|
|
||||||
/// flag at argparse time. The optional `sseReadTimeout` is passed via
|
|
||||||
/// `--sse-read-timeout <int>` and persisted as `sse_read_timeout: <int>`
|
|
||||||
/// in the YAML entry.
|
|
||||||
// TODO(WS-7-Q3): Verify exact CLI flag spelling against `hermes mcp add --help`
|
|
||||||
// on a v0.13 install. Plan assumes `--transport sse` + `--sse-read-timeout`;
|
|
||||||
// alternatives could be `--sse` (boolean) + `--read-timeout`.
|
|
||||||
@discardableResult
|
|
||||||
nonisolated func addMCPServerSSE(name: String, url: String, sseReadTimeout: Int?) -> (exitCode: Int32, output: String) {
|
|
||||||
var cliArgs: [String] = ["mcp", "add", name, "--url", url, "--transport", "sse"]
|
|
||||||
if let timeout = sseReadTimeout {
|
|
||||||
cliArgs.append(contentsOf: ["--sse-read-timeout", String(timeout)])
|
|
||||||
}
|
|
||||||
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Updates the `sse_read_timeout` scalar in-place via the same surgical
|
|
||||||
/// patcher used by `setMCPServerTimeouts`. Pass `nil` to remove the
|
|
||||||
/// scalar entirely (Hermes default applies).
|
|
||||||
@discardableResult
|
|
||||||
nonisolated func setMCPServerSSETimeout(name: String, sseReadTimeout: Int?) -> Bool {
|
|
||||||
patchMCPServerField(name: name) { entryLines in
|
|
||||||
if let timeout = sseReadTimeout {
|
|
||||||
Self.replaceOrInsertScalar(key: "sse_read_timeout", value: String(timeout), in: &entryLines)
|
|
||||||
} else {
|
|
||||||
Self.removeScalar(key: "sse_read_timeout", in: &entryLines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool {
|
nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool {
|
||||||
patchMCPServerField(name: name) { entryLines in
|
patchMCPServerField(name: name) { entryLines in
|
||||||
@@ -844,23 +821,11 @@ struct HermesFileService: Sendable {
|
|||||||
|
|
||||||
func flush() {
|
func flush() {
|
||||||
guard let name = currentName else { return }
|
guard let name = currentName else { return }
|
||||||
// 3-way transport discriminator: an explicit `transport: sse` scalar
|
let transport: MCPTransport = fields["url"] != nil ? .http : .stdio
|
||||||
// wins (Hermes v0.13+ emits it for SSE servers); otherwise URL-bearing
|
|
||||||
// entries fall back to .http (v0.12 shape) and command-bearing entries
|
|
||||||
// to .stdio. This preserves byte-for-byte round-trip on existing files
|
|
||||||
// — pre-v0.13 entries have no `transport:` key so they parse identically.
|
|
||||||
// TODO(WS-7-Q1): Verify Hermes v0.13 actually emits `transport: sse`
|
|
||||||
// (vs. inferring from the schema/url shape) once a v0.13 host is on hand.
|
|
||||||
let transport: MCPTransport = {
|
|
||||||
if fields["transport"]?.lowercased() == "sse" { return .sse }
|
|
||||||
if fields["url"] != nil { return .http }
|
|
||||||
return .stdio
|
|
||||||
}()
|
|
||||||
let enabledStr = fields["enabled"]?.lowercased()
|
let enabledStr = fields["enabled"]?.lowercased()
|
||||||
let enabled = enabledStr != "false"
|
let enabled = enabledStr != "false"
|
||||||
let timeout = fields["timeout"].flatMap(Int.init)
|
let timeout = fields["timeout"].flatMap(Int.init)
|
||||||
let connectTimeout = fields["connect_timeout"].flatMap(Int.init)
|
let connectTimeout = fields["connect_timeout"].flatMap(Int.init)
|
||||||
let sseReadTimeout = fields["sse_read_timeout"].flatMap(Int.init)
|
|
||||||
let server = HermesMCPServer(
|
let server = HermesMCPServer(
|
||||||
name: name,
|
name: name,
|
||||||
transport: transport,
|
transport: transport,
|
||||||
@@ -877,8 +842,7 @@ struct HermesFileService: Sendable {
|
|||||||
toolsExclude: excludeList,
|
toolsExclude: excludeList,
|
||||||
resourcesEnabled: resources,
|
resourcesEnabled: resources,
|
||||||
promptsEnabled: prompts,
|
promptsEnabled: prompts,
|
||||||
hasOAuthToken: false,
|
hasOAuthToken: false
|
||||||
sseReadTimeout: sseReadTimeout
|
|
||||||
)
|
)
|
||||||
servers.append(server)
|
servers.append(server)
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ struct ChatTranscriptPane: View {
|
|||||||
@Bindable var chatViewModel: ChatViewModel
|
@Bindable var chatViewModel: ChatViewModel
|
||||||
var onSend: (String, [ChatImageAttachment]) -> Void
|
var onSend: (String, [ChatImageAttachment]) -> Void
|
||||||
var isEnabled: Bool
|
var isEnabled: Bool
|
||||||
|
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
@@ -20,8 +21,10 @@ struct ChatTranscriptPane: View {
|
|||||||
acpInputTokens: richChat.acpInputTokens,
|
acpInputTokens: richChat.acpInputTokens,
|
||||||
acpOutputTokens: richChat.acpOutputTokens,
|
acpOutputTokens: richChat.acpOutputTokens,
|
||||||
acpThoughtTokens: richChat.acpThoughtTokens,
|
acpThoughtTokens: richChat.acpThoughtTokens,
|
||||||
|
acpCompressionCount: richChat.acpCompressionCount,
|
||||||
projectName: chatViewModel.currentProjectName,
|
projectName: chatViewModel.currentProjectName,
|
||||||
gitBranch: chatViewModel.currentGitBranch
|
gitBranch: chatViewModel.currentGitBranch,
|
||||||
|
capabilities: capabilitiesStore?.capabilities ?? .empty
|
||||||
)
|
)
|
||||||
Divider()
|
Divider()
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ struct SessionInfoBar: View {
|
|||||||
var acpInputTokens: Int = 0
|
var acpInputTokens: Int = 0
|
||||||
var acpOutputTokens: Int = 0
|
var acpOutputTokens: Int = 0
|
||||||
var acpThoughtTokens: Int = 0
|
var acpThoughtTokens: Int = 0
|
||||||
|
/// Number of context compactions Hermes has run on this session. v0.13+
|
||||||
|
/// surface — capability-gated by the bar so pre-v0.13 hosts never see
|
||||||
|
/// the chip even if a stale value somehow trickles through. Defaults
|
||||||
|
/// to 0 so existing callers and previews don't need to be updated.
|
||||||
|
var acpCompressionCount: Int = 0
|
||||||
/// Name of the Scarf project this session is attributed to, when
|
/// Name of the Scarf project this session is attributed to, when
|
||||||
/// applicable. Nil for plain global chats. Drives the folder-chip
|
/// applicable. Nil for plain global chats. Drives the folder-chip
|
||||||
/// indicator rendered before the session title. Resolved by
|
/// indicator rendered before the session title. Resolved by
|
||||||
@@ -20,6 +25,11 @@ struct SessionInfoBar: View {
|
|||||||
/// name. Nil for non-project chats and for projects that aren't
|
/// name. Nil for non-project chats and for projects that aren't
|
||||||
/// git repos.
|
/// git repos.
|
||||||
var gitBranch: String? = nil
|
var gitBranch: String? = nil
|
||||||
|
/// Capability snapshot for v0.13+ surfaces. Defaulted so previews and
|
||||||
|
/// pre-v0.13 hosts render the v2.7.5 layout unchanged. Coordinated
|
||||||
|
/// with WS-2 — both WSes add `capabilities` to this view; whichever
|
||||||
|
/// lands first establishes the prop.
|
||||||
|
var capabilities: HermesCapabilities = .empty
|
||||||
|
|
||||||
/// Active Hermes profile name (issue #50). Resolved on each body
|
/// Active Hermes profile name (issue #50). Resolved on each body
|
||||||
/// re-evaluation; the resolver caches for 5s so this is cheap.
|
/// re-evaluation; the resolver caches for 5s so this is cheap.
|
||||||
@@ -96,6 +106,21 @@ struct SessionInfoBar: View {
|
|||||||
Label("\(formatTokens(reasonToks)) reasoning", systemImage: "brain")
|
Label("\(formatTokens(reasonToks)) reasoning", systemImage: "brain")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v0.13: Hermes surfaces a running count of automatic
|
||||||
|
// context compactions. Render only when the host is on
|
||||||
|
// v0.13+ AND the count is non-zero, so a pre-v0.13 host
|
||||||
|
// (which always reports 0) sees no chip, and a v0.13 host
|
||||||
|
// sees the chip the first time the agent compacts.
|
||||||
|
if capabilities.hasContextCompressionCount && acpCompressionCount > 0 {
|
||||||
|
Label(
|
||||||
|
"×\(acpCompressionCount)",
|
||||||
|
systemImage: "arrow.down.right.and.arrow.up.left"
|
||||||
|
)
|
||||||
|
.scarfStyle(.caption)
|
||||||
|
.foregroundStyle(ScarfColor.foregroundMuted)
|
||||||
|
.help("Hermes auto-compacted this session's context \(acpCompressionCount) time\(acpCompressionCount == 1 ? "" : "s")")
|
||||||
|
}
|
||||||
|
|
||||||
if let cost = session.displayCostUSD {
|
if let cost = session.displayCostUSD {
|
||||||
let formattedCost = cost.formatted(.currency(code: "USD").precision(.fractionLength(4)))
|
let formattedCost = cost.formatted(.currency(code: "USD").precision(.fractionLength(4)))
|
||||||
Label(session.costIsActual ? formattedCost : "\(formattedCost) est.", systemImage: "dollarsign.circle")
|
Label(session.costIsActual ? formattedCost : "\(formattedCost) est.", systemImage: "dollarsign.circle")
|
||||||
|
|||||||
@@ -87,7 +87,16 @@ private struct SlashCommandRow: View {
|
|||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.foregroundStyle(isSelected ? ScarfColor.accentActive : ScarfColor.foregroundPrimary)
|
.foregroundStyle(isSelected ? ScarfColor.accentActive : ScarfColor.foregroundPrimary)
|
||||||
if let hint = command.argumentHint {
|
if let hint = command.argumentHint {
|
||||||
Text("<\(hint)>")
|
// v0.13: Hermes may emit hints already wrapped in
|
||||||
|
// brackets (e.g. `[name]` for the optional `/new
|
||||||
|
// <name>` argument exposed by `hasNewWithSessionName`).
|
||||||
|
// Avoid double-wrapping — bracketed hints pass through
|
||||||
|
// verbatim while older `guidance`-style hints (no
|
||||||
|
// brackets) still render as `<guidance>`.
|
||||||
|
let display = hint.hasPrefix("<") || hint.hasPrefix("[")
|
||||||
|
? hint
|
||||||
|
: "<\(hint)>"
|
||||||
|
Text(display)
|
||||||
.font(ScarfFont.monoSmall)
|
.font(ScarfFont.monoSmall)
|
||||||
.foregroundStyle(ScarfColor.foregroundFaint)
|
.foregroundStyle(ScarfColor.foregroundFaint)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ final class CronViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "", noAgent: Bool = false) {
|
func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "") {
|
||||||
var args = ["cron", "create"]
|
var args = ["cron", "create"]
|
||||||
if !name.isEmpty { args += ["--name", name] }
|
if !name.isEmpty { args += ["--name", name] }
|
||||||
if !deliver.isEmpty { args += ["--deliver", deliver] }
|
if !deliver.isEmpty { args += ["--deliver", deliver] }
|
||||||
@@ -158,25 +158,12 @@ final class CronViewModel {
|
|||||||
// know the flag — argparse rejects unknown args, so the form
|
// know the flag — argparse rejects unknown args, so the form
|
||||||
// omits the flag when the field is empty.
|
// omits the flag when the field is empty.
|
||||||
if !workdir.isEmpty { args += ["--workdir", workdir] }
|
if !workdir.isEmpty { args += ["--workdir", workdir] }
|
||||||
// v0.13+: --no-agent runs the pre-run script and skips the AI turn.
|
|
||||||
// Caller (CronView) strips this on pre-v0.13 hosts so the flag is
|
|
||||||
// never emitted to a Hermes that can't parse it.
|
|
||||||
if noAgent { args.append("--no-agent") }
|
|
||||||
args.append(schedule)
|
args.append(schedule)
|
||||||
// TODO(WS-7-Q5): When --no-agent is set Hermes ignores the prompt arg,
|
if !prompt.isEmpty { args.append(prompt) }
|
||||||
// but argparse still wants positional args to line up with the
|
|
||||||
// schedule. The plan recommends passing an empty string explicitly so
|
|
||||||
// the positional parser doesn't treat the prompt as missing — verify
|
|
||||||
// this behaviour against `hermes cron create --help` on a v0.13 host.
|
|
||||||
if noAgent {
|
|
||||||
args.append("")
|
|
||||||
} else if !prompt.isEmpty {
|
|
||||||
args.append(prompt)
|
|
||||||
}
|
|
||||||
runAndReload(args, success: "Job created")
|
runAndReload(args, success: "Job created")
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateJob(id: String, schedule: String?, prompt: String?, name: String?, deliver: String?, repeatCount: String?, newSkills: [String]?, clearSkills: Bool, script: String?, workdir: String? = nil, noAgent: Bool? = nil) {
|
func updateJob(id: String, schedule: String?, prompt: String?, name: String?, deliver: String?, repeatCount: String?, newSkills: [String]?, clearSkills: Bool, script: String?, workdir: String? = nil) {
|
||||||
var args = ["cron", "edit", id]
|
var args = ["cron", "edit", id]
|
||||||
if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] }
|
if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] }
|
||||||
if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] }
|
if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] }
|
||||||
@@ -193,16 +180,6 @@ final class CronViewModel {
|
|||||||
// = user cleared an existing workdir; Hermes documents `--workdir ""`
|
// = user cleared an existing workdir; Hermes documents `--workdir ""`
|
||||||
// on edit as the explicit clear gesture, mirroring the `--script` shape.
|
// on edit as the explicit clear gesture, mirroring the `--script` shape.
|
||||||
if let workdir { args += ["--workdir", workdir] }
|
if let workdir { args += ["--workdir", workdir] }
|
||||||
// TODO(WS-7-Q4): The toggle-off shape of `--no-agent` on edit is
|
|
||||||
// unverified. Plan assumes Hermes accepts `--agent` to flip the flag
|
|
||||||
// back; if the CLI is one-way (`--no-agent` only), the edit-mode
|
|
||||||
// toggle should disable itself with a tooltip explaining the
|
|
||||||
// limitation. Send the flag in the assumed shape for now and adjust
|
|
||||||
// post-integration.
|
|
||||||
if let noAgent {
|
|
||||||
if noAgent { args.append("--no-agent") }
|
|
||||||
else { args.append("--agent") }
|
|
||||||
}
|
|
||||||
runAndReload(args, success: "Updated")
|
runAndReload(args, success: "Updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ struct CronView: View {
|
|||||||
capabilitiesStore?.capabilities.hasCronWorkdir ?? false
|
capabilitiesStore?.capabilities.hasCronWorkdir ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
private var hasCronNoAgent: Bool {
|
|
||||||
capabilitiesStore?.capabilities.hasCronNoAgent ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
pageHeader
|
pageHeader
|
||||||
@@ -51,7 +47,7 @@ struct CronView: View {
|
|||||||
// polling timer. Same wiring ActivityView uses.
|
// polling timer. Same wiring ActivityView uses.
|
||||||
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
|
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
|
||||||
.sheet(isPresented: $viewModel.showCreateSheet) {
|
.sheet(isPresented: $viewModel.showCreateSheet) {
|
||||||
CronJobEditor(mode: .create, availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir, supportsNoAgent: hasCronNoAgent) { form in
|
CronJobEditor(mode: .create, availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir) { form in
|
||||||
viewModel.createJob(
|
viewModel.createJob(
|
||||||
schedule: form.schedule,
|
schedule: form.schedule,
|
||||||
prompt: form.prompt,
|
prompt: form.prompt,
|
||||||
@@ -60,12 +56,7 @@ struct CronView: View {
|
|||||||
skills: form.skills,
|
skills: form.skills,
|
||||||
script: form.script,
|
script: form.script,
|
||||||
repeatCount: form.repeatCount,
|
repeatCount: form.repeatCount,
|
||||||
workdir: hasCronWorkdir ? form.workdir : "",
|
workdir: hasCronWorkdir ? form.workdir : ""
|
||||||
// Mirrors the workdir strip-on-pre-version pattern: pre-v0.13
|
|
||||||
// hosts get a hard `false`, so a stale form value (or a
|
|
||||||
// hand-edited jobs.json round-tripped through edit-mode)
|
|
||||||
// can't sneak `--no-agent` into a CLI that doesn't grok it.
|
|
||||||
noAgent: hasCronNoAgent ? form.noAgent : false
|
|
||||||
)
|
)
|
||||||
viewModel.showCreateSheet = false
|
viewModel.showCreateSheet = false
|
||||||
} onCancel: {
|
} onCancel: {
|
||||||
@@ -73,7 +64,7 @@ struct CronView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(item: $viewModel.editingJob) { job in
|
.sheet(item: $viewModel.editingJob) { job in
|
||||||
CronJobEditor(mode: .edit(job), availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir, supportsNoAgent: hasCronNoAgent) { form in
|
CronJobEditor(mode: .edit(job), availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir) { form in
|
||||||
viewModel.updateJob(
|
viewModel.updateJob(
|
||||||
id: job.id,
|
id: job.id,
|
||||||
schedule: form.schedule,
|
schedule: form.schedule,
|
||||||
@@ -84,8 +75,7 @@ struct CronView: View {
|
|||||||
newSkills: form.skills,
|
newSkills: form.skills,
|
||||||
clearSkills: form.clearSkills,
|
clearSkills: form.clearSkills,
|
||||||
script: form.script,
|
script: form.script,
|
||||||
workdir: hasCronWorkdir ? form.workdir : nil,
|
workdir: hasCronWorkdir ? form.workdir : nil
|
||||||
noAgent: hasCronNoAgent ? form.noAgent : nil
|
|
||||||
)
|
)
|
||||||
viewModel.editingJob = nil
|
viewModel.editingJob = nil
|
||||||
} onCancel: {
|
} onCancel: {
|
||||||
@@ -653,9 +643,6 @@ struct CronJobEditor: View {
|
|||||||
/// v0.12+ workdir flag — fills `--workdir <path>`. Empty string
|
/// v0.12+ workdir flag — fills `--workdir <path>`. Empty string
|
||||||
/// preserves the v0.11 behaviour of running with no cwd hint.
|
/// preserves the v0.11 behaviour of running with no cwd hint.
|
||||||
var workdir: String = ""
|
var workdir: String = ""
|
||||||
/// v0.13+ `--no-agent` flag — script-only watchdog mode. Hermes
|
|
||||||
/// runs the pre-run script and skips the AI turn.
|
|
||||||
var noAgent: Bool = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mode: Mode
|
let mode: Mode
|
||||||
@@ -663,10 +650,6 @@ struct CronJobEditor: View {
|
|||||||
/// Pass `false` on pre-v0.12 hosts; the `--workdir` field is hidden and
|
/// Pass `false` on pre-v0.12 hosts; the `--workdir` field is hidden and
|
||||||
/// the form's value is dropped when the parent calls `createJob`/`updateJob`.
|
/// the form's value is dropped when the parent calls `createJob`/`updateJob`.
|
||||||
let supportsWorkdir: Bool
|
let supportsWorkdir: Bool
|
||||||
/// Pass `false` on pre-v0.13 hosts; the `--no-agent` toggle is hidden
|
|
||||||
/// and the parent strips the form's value before calling
|
|
||||||
/// `createJob`/`updateJob`. Mirrors the `supportsWorkdir` pattern.
|
|
||||||
let supportsNoAgent: Bool
|
|
||||||
let onSave: (FormState) -> Void
|
let onSave: (FormState) -> Void
|
||||||
let onCancel: () -> Void
|
let onCancel: () -> Void
|
||||||
|
|
||||||
@@ -698,25 +681,12 @@ struct CronJobEditor: View {
|
|||||||
)
|
)
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
}
|
}
|
||||||
.opacity(form.noAgent ? 0.4 : 1.0)
|
|
||||||
.disabled(form.noAgent)
|
|
||||||
formField("Deliver", text: $form.deliver, placeholder: "origin | local | discord:CHANNEL | telegram:CHAT", mono: true)
|
formField("Deliver", text: $form.deliver, placeholder: "origin | local | discord:CHANNEL | telegram:CHAT", mono: true)
|
||||||
formField("Repeat", text: $form.repeatCount, placeholder: "Optional count")
|
formField("Repeat", text: $form.repeatCount, placeholder: "Optional count")
|
||||||
formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true)
|
formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true)
|
||||||
if supportsWorkdir {
|
if supportsWorkdir {
|
||||||
formField("Workdir", text: $form.workdir, placeholder: "Absolute path; pulls AGENTS.md/CLAUDE.md context", mono: true)
|
formField("Workdir", text: $form.workdir, placeholder: "Absolute path; pulls AGENTS.md/CLAUDE.md context", mono: true)
|
||||||
}
|
}
|
||||||
if supportsNoAgent {
|
|
||||||
Toggle("Run script only (no agent call)", isOn: $form.noAgent)
|
|
||||||
.scarfStyle(.body)
|
|
||||||
.tint(ScarfColor.accent)
|
|
||||||
if form.noAgent {
|
|
||||||
Text("Watchdog mode — Hermes runs the pre-run script and skips the AI turn. Prompt + skills are ignored.")
|
|
||||||
.scarfStyle(.caption)
|
|
||||||
.foregroundStyle(ScarfColor.foregroundMuted)
|
|
||||||
.padding(.leading, ScarfSpace.s3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !availableSkills.isEmpty {
|
if !availableSkills.isEmpty {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
Text("Skills")
|
Text("Skills")
|
||||||
@@ -753,8 +723,6 @@ struct CronJobEditor: View {
|
|||||||
.tint(ScarfColor.accent)
|
.tint(ScarfColor.accent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.opacity(form.noAgent ? 0.4 : 1.0)
|
|
||||||
.disabled(form.noAgent)
|
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
@@ -778,7 +746,6 @@ struct CronJobEditor: View {
|
|||||||
form.skills = job.skills ?? []
|
form.skills = job.skills ?? []
|
||||||
form.script = job.preRunScript ?? ""
|
form.script = job.preRunScript ?? ""
|
||||||
form.workdir = job.workdir ?? ""
|
form.workdir = job.workdir ?? ""
|
||||||
form.noAgent = job.noAgent ?? false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ final class MCPServerEditorViewModel {
|
|||||||
var promptsEnabled: Bool
|
var promptsEnabled: Bool
|
||||||
var timeoutDraft: String
|
var timeoutDraft: String
|
||||||
var connectTimeoutDraft: String
|
var connectTimeoutDraft: String
|
||||||
/// SSE-only — renders as a third numeric on `.sse` servers. Empty string
|
|
||||||
/// means "use Hermes default" (writer drops the scalar).
|
|
||||||
var sseReadTimeoutDraft: String
|
|
||||||
var showSecrets: Bool = false
|
var showSecrets: Bool = false
|
||||||
var isSaving: Bool = false
|
var isSaving: Bool = false
|
||||||
var saveError: String?
|
var saveError: String?
|
||||||
@@ -40,7 +37,6 @@ final class MCPServerEditorViewModel {
|
|||||||
self.promptsEnabled = server.promptsEnabled
|
self.promptsEnabled = server.promptsEnabled
|
||||||
self.timeoutDraft = server.timeout.map { String($0) } ?? ""
|
self.timeoutDraft = server.timeout.map { String($0) } ?? ""
|
||||||
self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? ""
|
self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? ""
|
||||||
self.sseReadTimeoutDraft = server.sseReadTimeout.map { String($0) } ?? ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendEnvRow() {
|
func appendEnvRow() {
|
||||||
@@ -73,8 +69,6 @@ final class MCPServerEditorViewModel {
|
|||||||
let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
|
let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
|
||||||
let timeoutValue = Int(timeoutDraft.trimmingCharacters(in: .whitespaces))
|
let timeoutValue = Int(timeoutDraft.trimmingCharacters(in: .whitespaces))
|
||||||
let connectValue = Int(connectTimeoutDraft.trimmingCharacters(in: .whitespaces))
|
let connectValue = Int(connectTimeoutDraft.trimmingCharacters(in: .whitespaces))
|
||||||
let trimmedSSE = sseReadTimeoutDraft.trimmingCharacters(in: .whitespaces)
|
|
||||||
let sseTimeoutValue: Int? = trimmedSSE.isEmpty ? nil : Int(trimmedSSE)
|
|
||||||
|
|
||||||
let service = fileService
|
let service = fileService
|
||||||
let transport = server.transport
|
let transport = server.transport
|
||||||
@@ -93,11 +87,6 @@ final class MCPServerEditorViewModel {
|
|||||||
if !service.setMCPServerEnv(name: name, env: envMap) { ok = false }
|
if !service.setMCPServerEnv(name: name, env: envMap) { ok = false }
|
||||||
case .http:
|
case .http:
|
||||||
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
|
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
|
||||||
case .sse:
|
|
||||||
// SSE servers carry headers like .http does, plus an
|
|
||||||
// optional sse_read_timeout written below.
|
|
||||||
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
|
|
||||||
if !service.setMCPServerSSETimeout(name: name, sseReadTimeout: sseTimeoutValue) { ok = false }
|
|
||||||
}
|
}
|
||||||
if !service.updateMCPToolFilters(
|
if !service.updateMCPToolFilters(
|
||||||
name: name,
|
name: name,
|
||||||
|
|||||||
@@ -42,10 +42,6 @@ final class MCPServersViewModel {
|
|||||||
filteredServers.filter { $0.transport == .http }
|
filteredServers.filter { $0.transport == .http }
|
||||||
}
|
}
|
||||||
|
|
||||||
var sseServers: [HermesMCPServer] {
|
|
||||||
filteredServers.filter { $0.transport == .sse }
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectedServer: HermesMCPServer? {
|
var selectedServer: HermesMCPServer? {
|
||||||
guard let name = selectedServerName else { return nil }
|
guard let name = selectedServerName else { return nil }
|
||||||
return servers.first(where: { $0.name == name })
|
return servers.first(where: { $0.name == name })
|
||||||
@@ -171,11 +167,6 @@ final class MCPServersViewModel {
|
|||||||
url: preset.url ?? "",
|
url: preset.url ?? "",
|
||||||
auth: preset.auth
|
auth: preset.auth
|
||||||
)
|
)
|
||||||
case .sse:
|
|
||||||
// No SSE-transport presets ship today; the preset picker
|
|
||||||
// only surfaces stdio/http servers. Treat as a no-op
|
|
||||||
// failure if a preset somehow declares .sse.
|
|
||||||
addResult = (exitCode: 1, output: "SSE-transport presets are not supported.")
|
|
||||||
}
|
}
|
||||||
guard addResult.exitCode == 0 else {
|
guard addResult.exitCode == 0 else {
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
@@ -205,11 +196,6 @@ final class MCPServersViewModel {
|
|||||||
result = fileService.addMCPServerStdio(name: name, command: command, args: args)
|
result = fileService.addMCPServerStdio(name: name, command: command, args: args)
|
||||||
case .http:
|
case .http:
|
||||||
result = fileService.addMCPServerHTTP(name: name, url: url, auth: auth)
|
result = fileService.addMCPServerHTTP(name: name, url: url, auth: auth)
|
||||||
case .sse:
|
|
||||||
// Routed through addCustomSSE; this branch is unreachable from
|
|
||||||
// the add-server form (which dispatches per-transport in submit())
|
|
||||||
// but kept so the switch is exhaustive without `@unknown default`.
|
|
||||||
result = (exitCode: 1, output: "SSE servers must be added via addCustomSSE.")
|
|
||||||
}
|
}
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
if result.exitCode == 0 {
|
if result.exitCode == 0 {
|
||||||
@@ -225,28 +211,6 @@ final class MCPServersViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// v0.13+ SSE-transport server creation. Caller is responsible for
|
|
||||||
/// capability-gating; the form filters `.sse` out of `availableTransports`
|
|
||||||
/// when `hasMCPSSETransport` is false, so this method is unreachable
|
|
||||||
/// from the UI on pre-v0.13 hosts.
|
|
||||||
func addCustomSSE(name: String, url: String, sseReadTimeout: Int?) {
|
|
||||||
let fileService = self.fileService
|
|
||||||
Task.detached {
|
|
||||||
let result = fileService.addMCPServerSSE(name: name, url: url, sseReadTimeout: sseReadTimeout)
|
|
||||||
await MainActor.run {
|
|
||||||
if result.exitCode == 0 {
|
|
||||||
self.flashStatus("Added \(name)")
|
|
||||||
self.load()
|
|
||||||
self.selectedServerName = name
|
|
||||||
self.showRestartBanner = true
|
|
||||||
self.showAddCustom = false
|
|
||||||
} else {
|
|
||||||
self.activeError = "Add failed: \(result.output)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func restartGateway() {
|
func restartGateway() {
|
||||||
let fileService = self.fileService
|
let fileService = self.fileService
|
||||||
Task.detached {
|
Task.detached {
|
||||||
|
|||||||
@@ -6,26 +6,12 @@ struct MCPServerAddCustomView: View {
|
|||||||
let viewModel: MCPServersViewModel
|
let viewModel: MCPServersViewModel
|
||||||
|
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
|
||||||
@State private var name: String = ""
|
@State private var name: String = ""
|
||||||
@State private var transport: MCPTransport = .stdio
|
@State private var transport: MCPTransport = .stdio
|
||||||
@State private var command: String = "npx"
|
@State private var command: String = "npx"
|
||||||
@State private var argsText: String = ""
|
@State private var argsText: String = ""
|
||||||
@State private var url: String = ""
|
@State private var url: String = ""
|
||||||
@State private var auth: String = "none"
|
@State private var auth: String = "none"
|
||||||
@State private var sseReadTimeout: String = ""
|
|
||||||
|
|
||||||
/// `.sse` is a v0.13+ surface; pre-v0.13 hosts only see stdio + http.
|
|
||||||
/// Iterating `MCPTransport.allCases` directly would render the SSE
|
|
||||||
/// segment unconditionally and Hermes would reject the resulting CLI
|
|
||||||
/// invocation at argparse time.
|
|
||||||
private var availableTransports: [MCPTransport] {
|
|
||||||
var t: [MCPTransport] = [.stdio, .http]
|
|
||||||
if capabilitiesStore?.capabilities.hasMCPSSETransport ?? false {
|
|
||||||
t.append(.sse)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
@@ -58,20 +44,17 @@ struct MCPServerAddCustomView: View {
|
|||||||
}
|
}
|
||||||
sectionBox(title: "Transport") {
|
sectionBox(title: "Transport") {
|
||||||
Picker("", selection: $transport) {
|
Picker("", selection: $transport) {
|
||||||
ForEach(availableTransports) { t in
|
ForEach(MCPTransport.allCases) { t in
|
||||||
Text(t.displayName).tag(t)
|
Text(t.displayName).tag(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.segmented)
|
.pickerStyle(.segmented)
|
||||||
.labelsHidden()
|
.labelsHidden()
|
||||||
}
|
}
|
||||||
switch transport {
|
if transport == .stdio {
|
||||||
case .stdio:
|
|
||||||
stdioSection
|
stdioSection
|
||||||
case .http:
|
} else {
|
||||||
httpSection
|
httpSection
|
||||||
case .sse:
|
|
||||||
sseSection
|
|
||||||
}
|
}
|
||||||
Text("Env vars, headers, and tool filters can be edited after the server is added.")
|
Text("Env vars, headers, and tool filters can be edited after the server is added.")
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
@@ -129,28 +112,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var sseSection: some View {
|
|
||||||
sectionBox(title: "Endpoint (SSE)") {
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text("URL").font(.caption.bold())
|
|
||||||
TextField("https://.../sse", text: $url)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.font(.system(.body, design: .monospaced))
|
|
||||||
}
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text("SSE Read Timeout (seconds)").font(.caption.bold())
|
|
||||||
TextField("default 300", text: $sseReadTimeout)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.frame(maxWidth: 140)
|
|
||||||
Text("Hermes-side keepalive interval. Leave blank to use the default.")
|
|
||||||
.font(.caption2)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var canSubmit: Bool {
|
private var canSubmit: Bool {
|
||||||
let trimmedName = name.trimmingCharacters(in: .whitespaces)
|
let trimmedName = name.trimmingCharacters(in: .whitespaces)
|
||||||
guard !trimmedName.isEmpty else { return false }
|
guard !trimmedName.isEmpty else { return false }
|
||||||
@@ -159,8 +120,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
return !command.trimmingCharacters(in: .whitespaces).isEmpty
|
return !command.trimmingCharacters(in: .whitespaces).isEmpty
|
||||||
case .http:
|
case .http:
|
||||||
return !url.trimmingCharacters(in: .whitespaces).isEmpty
|
return !url.trimmingCharacters(in: .whitespaces).isEmpty
|
||||||
case .sse:
|
|
||||||
return !url.trimmingCharacters(in: .whitespaces).isEmpty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,8 +130,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
.map { $0.trimmingCharacters(in: .whitespaces) }
|
.map { $0.trimmingCharacters(in: .whitespaces) }
|
||||||
.filter { !$0.isEmpty }
|
.filter { !$0.isEmpty }
|
||||||
let resolvedAuth: String? = (auth == "none") ? nil : auth
|
let resolvedAuth: String? = (auth == "none") ? nil : auth
|
||||||
switch transport {
|
|
||||||
case .stdio, .http:
|
|
||||||
viewModel.addCustom(
|
viewModel.addCustom(
|
||||||
name: trimmedName,
|
name: trimmedName,
|
||||||
transport: transport,
|
transport: transport,
|
||||||
@@ -181,15 +138,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
url: url.trimmingCharacters(in: .whitespaces),
|
url: url.trimmingCharacters(in: .whitespaces),
|
||||||
auth: resolvedAuth
|
auth: resolvedAuth
|
||||||
)
|
)
|
||||||
case .sse:
|
|
||||||
let trimmedTimeout = sseReadTimeout.trimmingCharacters(in: .whitespaces)
|
|
||||||
let parsedTimeout: Int? = trimmedTimeout.isEmpty ? nil : Int(trimmedTimeout)
|
|
||||||
viewModel.addCustomSSE(
|
|
||||||
name: trimmedName,
|
|
||||||
url: url.trimmingCharacters(in: .whitespaces),
|
|
||||||
sseReadTimeout: parsedTimeout
|
|
||||||
)
|
|
||||||
}
|
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,11 +127,6 @@ struct MCPServerDetailView: View {
|
|||||||
if let auth = server.auth, !auth.isEmpty {
|
if let auth = server.auth, !auth.isEmpty {
|
||||||
summaryRow(label: "Auth", value: auth)
|
summaryRow(label: "Auth", value: auth)
|
||||||
}
|
}
|
||||||
case .sse:
|
|
||||||
summaryRow(label: "URL", value: server.url ?? "—")
|
|
||||||
if let timeout = server.sseReadTimeout {
|
|
||||||
summaryRow(label: "Read TO", value: "\(timeout)s")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(ScarfSpace.s3)
|
.padding(ScarfSpace.s3)
|
||||||
|
|||||||
@@ -186,16 +186,6 @@ struct MCPServerEditorView: View {
|
|||||||
.textFieldStyle(.roundedBorder)
|
.textFieldStyle(.roundedBorder)
|
||||||
.frame(maxWidth: 140)
|
.frame(maxWidth: 140)
|
||||||
}
|
}
|
||||||
if viewModel.server.transport == .sse {
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text("SSE read timeout")
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
TextField("default 300", text: $viewModel.sseReadTimeoutDraft)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.frame(maxWidth: 140)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,14 +132,6 @@ struct MCPServersView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !viewModel.sseServers.isEmpty {
|
|
||||||
Section("Remote (SSE)") {
|
|
||||||
ForEach(viewModel.sseServers) { server in
|
|
||||||
serverRow(server)
|
|
||||||
.tag(server.name as String?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if viewModel.servers.isEmpty && !viewModel.isLoading {
|
if viewModel.servers.isEmpty && !viewModel.isLoading {
|
||||||
Section {
|
Section {
|
||||||
Text("No servers configured yet")
|
Text("No servers configured yet")
|
||||||
|
|||||||
@@ -112,17 +112,10 @@ final class ProfilesViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func create(name: String, cloneConfig: Bool, cloneAll: Bool, noSkills: Bool = false) {
|
func create(name: String, cloneConfig: Bool, cloneAll: Bool) {
|
||||||
var args = ["profile", "create", name]
|
var args = ["profile", "create", name]
|
||||||
if cloneAll { args.append("--clone-all") }
|
if cloneAll { args.append("--clone-all") }
|
||||||
else if cloneConfig { args.append("--clone") }
|
else if cloneConfig { args.append("--clone") }
|
||||||
// v0.13+: Empty-profile creation. The wire is independent of
|
|
||||||
// --clone / --clone-all per the v0.13 release notes — the user
|
|
||||||
// can stack `--clone --no-skills` to clone config but skip
|
|
||||||
// skills, which is a plausible workflow. The UI still disables
|
|
||||||
// the toggle under --clone-all (Decision H, see ProfilesView)
|
|
||||||
// but the wire is permissive.
|
|
||||||
if noSkills { args.append("--no-skills") }
|
|
||||||
runAndReload(args, success: "Profile '\(name)' created")
|
runAndReload(args, success: "Profile '\(name)' created")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,7 @@ struct ProfilesView: View {
|
|||||||
@State private var createName = ""
|
@State private var createName = ""
|
||||||
@State private var createCloneConfig = true
|
@State private var createCloneConfig = true
|
||||||
@State private var createCloneAll = false
|
@State private var createCloneAll = false
|
||||||
/// v0.13+ `--no-skills` toggle. Mutually exclusive with `--clone-all`
|
|
||||||
/// at the UX layer (Decision H from the WS-7 plan): a full clone
|
|
||||||
/// copies skills wholesale — `--no-skills` would be a contradiction.
|
|
||||||
@State private var createNoSkills = false
|
|
||||||
@State private var showRename = false
|
@State private var showRename = false
|
||||||
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
|
||||||
|
|
||||||
init(context: ServerContext) {
|
init(context: ServerContext) {
|
||||||
_viewModel = State(initialValue: ProfilesViewModel(context: context))
|
_viewModel = State(initialValue: ProfilesViewModel(context: context))
|
||||||
@@ -128,7 +123,7 @@ struct ProfilesView: View {
|
|||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
Button {
|
Button {
|
||||||
createName = ""; createCloneConfig = true; createCloneAll = false; createNoSkills = false
|
createName = ""; createCloneConfig = true; createCloneAll = false
|
||||||
showCreate = true
|
showCreate = true
|
||||||
} label: {
|
} label: {
|
||||||
Label("Create", systemImage: "plus")
|
Label("Create", systemImage: "plus")
|
||||||
@@ -305,31 +300,11 @@ struct ProfilesView: View {
|
|||||||
Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig)
|
Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig)
|
||||||
.disabled(createCloneAll)
|
.disabled(createCloneAll)
|
||||||
Toggle("Full copy of active profile (all state)", isOn: $createCloneAll)
|
Toggle("Full copy of active profile (all state)", isOn: $createCloneAll)
|
||||||
// TODO(WS-7-Q8): Decision H — disable --no-skills when --clone-all
|
|
||||||
// is on. A full clone copies skills wholesale; --no-skills would
|
|
||||||
// be a contradiction. Verify Hermes's behaviour with both flags
|
|
||||||
// (argparse mutual exclusion vs. last-flag-wins vs. clone-but-
|
|
||||||
// skip-skills) and relax the disabled state if Hermes does
|
|
||||||
// something useful with the combination.
|
|
||||||
if capabilitiesStore?.capabilities.hasProfileNoSkills ?? false {
|
|
||||||
Toggle("Empty profile (no skills)", isOn: $createNoSkills)
|
|
||||||
.disabled(createCloneAll)
|
|
||||||
}
|
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("Cancel") { showCreate = false }
|
Button("Cancel") { showCreate = false }
|
||||||
Button("Create") {
|
Button("Create") {
|
||||||
viewModel.create(
|
viewModel.create(name: createName, cloneConfig: createCloneConfig, cloneAll: createCloneAll)
|
||||||
name: createName,
|
|
||||||
cloneConfig: createCloneConfig,
|
|
||||||
cloneAll: createCloneAll,
|
|
||||||
// Defensive: if the toggle isn't visible (pre-v0.13)
|
|
||||||
// the state is always `false`, but read it through
|
|
||||||
// the capability gate anyway so a stale state value
|
|
||||||
// can't sneak `--no-skills` to a CLI that doesn't
|
|
||||||
// know it.
|
|
||||||
noSkills: (capabilitiesStore?.capabilities.hasProfileNoSkills ?? false) ? createNoSkills : false
|
|
||||||
)
|
|
||||||
showCreate = false
|
showCreate = false
|
||||||
}
|
}
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
|
|||||||
@@ -29,8 +29,31 @@ final class SettingsViewModel {
|
|||||||
// that no-ops on older hosts is low compared to gating overhead.
|
// that no-ops on older hosts is low compared to gating overhead.
|
||||||
var terminalBackends = ["local", "docker", "singularity", "modal", "daytona", "ssh", "vercel"]
|
var terminalBackends = ["local", "docker", "singularity", "modal", "daytona", "ssh", "vercel"]
|
||||||
var browserBackends = ["browseruse", "firecrawl", "local"]
|
var browserBackends = ["browseruse", "firecrawl", "local"]
|
||||||
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts", "piper"]
|
// v0.13: `xai` joins the TTS provider list. xAI shipped TTS earlier
|
||||||
|
// (v0.12) but the v0.13 add-on is custom voice cloning — see
|
||||||
|
// `HermesCapabilities.hasXAIVoiceCloning` and the badge in VoiceTab.
|
||||||
|
// The provider option itself is ungated so pre-v0.13 hosts with xAI
|
||||||
|
// keys can still pick it.
|
||||||
|
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts", "piper", "xai"]
|
||||||
var sttProviders = ["local", "groq", "openai", "mistral"]
|
var sttProviders = ["local", "groq", "openai", "mistral"]
|
||||||
|
/// Static-message translation languages honored by Hermes v0.13's
|
||||||
|
/// `display.language` key. The first row's empty value writes no
|
||||||
|
/// key — equivalent to "Hermes default" — while explicit `en` writes
|
||||||
|
/// the code so users who care about determinism can pin it. Keep the
|
||||||
|
/// label list in sync with the Hermes v0.13 release notes; new
|
||||||
|
/// languages should be appended in alphabetical order by display
|
||||||
|
/// label so the picker stays scannable.
|
||||||
|
var displayLanguages: [(code: String, label: String)] = [
|
||||||
|
("", "English (default)"),
|
||||||
|
("en", "English"),
|
||||||
|
("zh", "中文 (Chinese)"),
|
||||||
|
("ja", "日本語 (Japanese)"),
|
||||||
|
("de", "Deutsch (German)"),
|
||||||
|
("es", "Español (Spanish)"),
|
||||||
|
("fr", "Français (French)"),
|
||||||
|
("uk", "Українська (Ukrainian)"),
|
||||||
|
("tr", "Türkçe (Turkish)"),
|
||||||
|
]
|
||||||
var memoryProviders = ["", "honcho", "openviking", "mem0", "hindsight", "holographic", "retaindb", "byterover", "supermemory"]
|
var memoryProviders = ["", "honcho", "openviking", "mem0", "hindsight", "holographic", "retaindb", "byterover", "supermemory"]
|
||||||
var saveMessage: String?
|
var saveMessage: String?
|
||||||
var isLoading = false
|
var isLoading = false
|
||||||
@@ -104,6 +127,10 @@ final class SettingsViewModel {
|
|||||||
func setToolProgressCommand(_ value: Bool) { setSetting("display.tool_progress_command", value: value ? "true" : "false") }
|
func setToolProgressCommand(_ value: Bool) { setSetting("display.tool_progress_command", value: value ? "true" : "false") }
|
||||||
func setToolPreviewLength(_ value: Int) { setSetting("display.tool_preview_length", value: String(value)) }
|
func setToolPreviewLength(_ value: Int) { setSetting("display.tool_preview_length", value: String(value)) }
|
||||||
func setBusyInputMode(_ value: String) { setSetting("display.busy_input_mode", value: value) }
|
func setBusyInputMode(_ value: String) { setSetting("display.busy_input_mode", value: value) }
|
||||||
|
/// v0.13: `display.language` for static-message translations. Empty
|
||||||
|
/// string writes "" via `hermes config set` which Hermes treats as
|
||||||
|
/// "use default"; explicit codes pin the language.
|
||||||
|
func setDisplayLanguage(_ value: String) { setSetting("display.language", value: value) }
|
||||||
|
|
||||||
// MARK: - Agent
|
// MARK: - Agent
|
||||||
|
|
||||||
@@ -143,16 +170,6 @@ final class SettingsViewModel {
|
|||||||
func setBrowserAllowPrivateURLs(_ value: Bool) { setSetting("browser.allow_private_urls", value: value ? "true" : "false") }
|
func setBrowserAllowPrivateURLs(_ value: Bool) { setSetting("browser.allow_private_urls", value: value ? "true" : "false") }
|
||||||
func setCamofoxManagedPersistence(_ value: Bool) { setSetting("browser.camofox.managed_persistence", value: value ? "true" : "false") }
|
func setCamofoxManagedPersistence(_ value: Bool) { setSetting("browser.camofox.managed_persistence", value: value ? "true" : "false") }
|
||||||
|
|
||||||
// MARK: - Web Tools
|
|
||||||
|
|
||||||
/// Pre-v0.13 combined backend. Pre-v0.13 hosts read this; v0.13+
|
|
||||||
/// hosts read it for back-compat but the WebToolsTab gates writes
|
|
||||||
/// on `hasWebToolsBackendSplit` so the tab only writes the split
|
|
||||||
/// keys on v0.13.
|
|
||||||
func setWebToolsBackend(_ value: String) { setSetting("web_tools.backend", value: value) }
|
|
||||||
func setWebToolsSearchBackend(_ value: String) { setSetting("web_tools.search.backend", value: value) }
|
|
||||||
func setWebToolsExtractBackend(_ value: String) { setSetting("web_tools.extract.backend", value: value) }
|
|
||||||
|
|
||||||
// MARK: - Voice / TTS / STT
|
// MARK: - Voice / TTS / STT
|
||||||
|
|
||||||
func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") }
|
func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") }
|
||||||
@@ -168,6 +185,10 @@ final class SettingsViewModel {
|
|||||||
func setTTSOpenAIVoice(_ value: String) { setSetting("tts.openai.voice", value: value) }
|
func setTTSOpenAIVoice(_ value: String) { setSetting("tts.openai.voice", value: value) }
|
||||||
func setTTSNeuTTSModel(_ value: String) { setSetting("tts.neutts.model", value: value) }
|
func setTTSNeuTTSModel(_ value: String) { setSetting("tts.neutts.model", value: value) }
|
||||||
func setTTSNeuTTSDevice(_ value: String) { setSetting("tts.neutts.device", value: value) }
|
func setTTSNeuTTSDevice(_ value: String) { setSetting("tts.neutts.device", value: value) }
|
||||||
|
// v0.13: xAI TTS / Custom Voices. TODO(WS-8-Q2): grep-verify key
|
||||||
|
// names against `~/.hermes/hermes-agent/hermes_cli/voice/tts.py`.
|
||||||
|
func setTTSXAIVoiceID(_ value: String) { setSetting("tts.xai.voice_id", value: value) }
|
||||||
|
func setTTSXAIModel(_ value: String) { setSetting("tts.xai.model", value: value) }
|
||||||
func setSTTEnabled(_ value: Bool) { setSetting("stt.enabled", value: value ? "true" : "false") }
|
func setSTTEnabled(_ value: Bool) { setSetting("stt.enabled", value: value ? "true" : "false") }
|
||||||
func setSTTProvider(_ value: String) { setSetting("stt.provider", value: value) }
|
func setSTTProvider(_ value: String) { setSetting("stt.provider", value: value) }
|
||||||
func setSTTLocalModel(_ value: String) { setSetting("stt.local.model", value: value) }
|
func setSTTLocalModel(_ value: String) { setSetting("stt.local.model", value: value) }
|
||||||
|
|||||||
@@ -152,8 +152,23 @@ struct PickerRow: View {
|
|||||||
let label: String
|
let label: String
|
||||||
let selection: String
|
let selection: String
|
||||||
let options: [String]
|
let options: [String]
|
||||||
|
let optionLabel: ((String) -> String)?
|
||||||
let onChange: (String) -> Void
|
let onChange: (String) -> Void
|
||||||
|
|
||||||
|
init(
|
||||||
|
label: String,
|
||||||
|
selection: String,
|
||||||
|
options: [String],
|
||||||
|
optionLabel: ((String) -> String)? = nil,
|
||||||
|
onChange: @escaping (String) -> Void
|
||||||
|
) {
|
||||||
|
self.label = label
|
||||||
|
self.selection = selection
|
||||||
|
self.options = options
|
||||||
|
self.optionLabel = optionLabel
|
||||||
|
self.onChange = onChange
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
SettingsRowLabel(label: label)
|
SettingsRowLabel(label: label)
|
||||||
@@ -162,7 +177,7 @@ struct PickerRow: View {
|
|||||||
set: { onChange($0) }
|
set: { onChange($0) }
|
||||||
)) {
|
)) {
|
||||||
ForEach(options, id: \.self) { option in
|
ForEach(options, id: \.self) { option in
|
||||||
Text(option.isEmpty ? "(none)" : option).tag(option)
|
Text(displayLabel(for: option)).tag(option)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(maxWidth: 250)
|
.frame(maxWidth: 250)
|
||||||
@@ -170,6 +185,13 @@ struct PickerRow: View {
|
|||||||
}
|
}
|
||||||
.settingsRowChrome()
|
.settingsRowChrome()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func displayLabel(for option: String) -> String {
|
||||||
|
if let mapper = optionLabel {
|
||||||
|
return mapper(option)
|
||||||
|
}
|
||||||
|
return option.isEmpty ? "(none)" : option
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ToggleRow: View {
|
struct ToggleRow: View {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ struct SettingsView: View {
|
|||||||
case agent = "Agent"
|
case agent = "Agent"
|
||||||
case terminal = "Terminal"
|
case terminal = "Terminal"
|
||||||
case browser = "Browser"
|
case browser = "Browser"
|
||||||
case webTools = "Web Tools"
|
|
||||||
case voice = "Voice"
|
case voice = "Voice"
|
||||||
case memory = "Memory"
|
case memory = "Memory"
|
||||||
case auxiliary = "Aux Models"
|
case auxiliary = "Aux Models"
|
||||||
@@ -42,7 +41,6 @@ struct SettingsView: View {
|
|||||||
case .agent: return "Agent"
|
case .agent: return "Agent"
|
||||||
case .terminal: return "Terminal"
|
case .terminal: return "Terminal"
|
||||||
case .browser: return "Browser"
|
case .browser: return "Browser"
|
||||||
case .webTools: return "Web Tools"
|
|
||||||
case .voice: return "Voice"
|
case .voice: return "Voice"
|
||||||
case .memory: return "Memory"
|
case .memory: return "Memory"
|
||||||
case .auxiliary: return "Aux Models"
|
case .auxiliary: return "Aux Models"
|
||||||
@@ -58,7 +56,6 @@ struct SettingsView: View {
|
|||||||
case .agent: return "brain.head.profile"
|
case .agent: return "brain.head.profile"
|
||||||
case .terminal: return "terminal"
|
case .terminal: return "terminal"
|
||||||
case .browser: return "globe"
|
case .browser: return "globe"
|
||||||
case .webTools: return "globe.americas"
|
|
||||||
case .voice: return "mic"
|
case .voice: return "mic"
|
||||||
case .memory: return "memorychip"
|
case .memory: return "memorychip"
|
||||||
case .auxiliary: return "sparkles.rectangle.stack"
|
case .auxiliary: return "sparkles.rectangle.stack"
|
||||||
@@ -174,7 +171,6 @@ struct SettingsView: View {
|
|||||||
case .agent: AgentTab(viewModel: viewModel)
|
case .agent: AgentTab(viewModel: viewModel)
|
||||||
case .terminal: TerminalTab(viewModel: viewModel)
|
case .terminal: TerminalTab(viewModel: viewModel)
|
||||||
case .browser: BrowserTab(viewModel: viewModel)
|
case .browser: BrowserTab(viewModel: viewModel)
|
||||||
case .webTools: WebToolsTab(viewModel: viewModel)
|
|
||||||
case .voice: VoiceTab(viewModel: viewModel)
|
case .voice: VoiceTab(viewModel: viewModel)
|
||||||
case .memory: MemoryTab(viewModel: viewModel)
|
case .memory: MemoryTab(viewModel: viewModel)
|
||||||
case .auxiliary: AuxiliaryTab(viewModel: viewModel)
|
case .auxiliary: AuxiliaryTab(viewModel: viewModel)
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ struct AdvancedTab: View {
|
|||||||
isOn: viewModel.config.redactionEnabled
|
isOn: viewModel.config.redactionEnabled
|
||||||
) { viewModel.setSetting("redaction.enabled", value: $0 ? "true" : "false") }
|
) { viewModel.setSetting("redaction.enabled", value: $0 ? "true" : "false") }
|
||||||
|
|
||||||
|
redactionDefaultsHint
|
||||||
|
|
||||||
ToggleRow(
|
ToggleRow(
|
||||||
label: "Runtime metadata footer",
|
label: "Runtime metadata footer",
|
||||||
isOn: viewModel.config.runtimeMetadataFooter
|
isOn: viewModel.config.runtimeMetadataFooter
|
||||||
@@ -138,6 +140,30 @@ struct AdvancedTab: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Inline hint below the redaction toggle. The server-side default
|
||||||
|
/// flipped from OFF (v0.12) to ON (v0.13), but Scarf's parser still
|
||||||
|
/// reads "absent key" as `false` — meaning a v0.13 host with no
|
||||||
|
/// explicit key in `config.yaml` shows the toggle OFF while the
|
||||||
|
/// agent treats redaction as ON. Hint copy disambiguates so users
|
||||||
|
/// can tell what's actually happening server-side.
|
||||||
|
@ViewBuilder
|
||||||
|
private var redactionDefaultsHint: some View {
|
||||||
|
let isV013 = capabilitiesStore?.capabilities.isV013OrLater ?? false
|
||||||
|
HStack {
|
||||||
|
Text("")
|
||||||
|
.font(.caption)
|
||||||
|
.frame(width: 160, alignment: .trailing)
|
||||||
|
Text(isV013
|
||||||
|
? "Recommended: ON. Hermes v0.13+ defaults to redacting secrets unless you opt out."
|
||||||
|
: "Default OFF in Hermes v0.12. Toggle ON to redact secrets in logs and shares.")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
}
|
||||||
|
|
||||||
private var backupSection: some View {
|
private var backupSection: some View {
|
||||||
SettingsSection(title: "Backup & Restore", icon: "externaldrive") {
|
SettingsSection(title: "Backup & Restore", icon: "externaldrive") {
|
||||||
HStack {
|
HStack {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import ScarfCore
|
|||||||
struct GeneralTab: View {
|
struct GeneralTab: View {
|
||||||
@Bindable var viewModel: SettingsViewModel
|
@Bindable var viewModel: SettingsViewModel
|
||||||
@Environment(AppCoordinator.self) private var coordinator
|
@Environment(AppCoordinator.self) private var coordinator
|
||||||
|
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SettingsSection(title: "Model", icon: "cpu") {
|
SettingsSection(title: "Model", icon: "cpu") {
|
||||||
@@ -39,6 +40,20 @@ struct GeneralTab: View {
|
|||||||
|
|
||||||
SettingsSection(title: "Locale", icon: "globe.americas") {
|
SettingsSection(title: "Locale", icon: "globe.americas") {
|
||||||
EditableTextField(label: "Timezone (IANA)", value: viewModel.config.timezone) { viewModel.setTimezone($0) }
|
EditableTextField(label: "Timezone (IANA)", value: viewModel.config.timezone) { viewModel.setTimezone($0) }
|
||||||
|
// v0.13: `display.language` picker. Hidden on pre-v0.13 hosts
|
||||||
|
// because writing the key would no-op silently. Two "English"
|
||||||
|
// entries by design — empty string preserves "no key" semantics
|
||||||
|
// (Hermes-default), explicit `en` pins it.
|
||||||
|
if capabilitiesStore?.capabilities.hasDisplayLanguage == true {
|
||||||
|
PickerRow(
|
||||||
|
label: "Display language",
|
||||||
|
selection: viewModel.config.display.language,
|
||||||
|
options: viewModel.displayLanguages.map(\.code),
|
||||||
|
optionLabel: { code in
|
||||||
|
viewModel.displayLanguages.first { $0.code == code }?.label ?? code
|
||||||
|
}
|
||||||
|
) { viewModel.setDisplayLanguage($0) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatesSection()
|
UpdatesSection()
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import ScarfCore
|
import ScarfCore
|
||||||
|
import ScarfDesign
|
||||||
|
|
||||||
/// Voice tab — push-to-talk + TTS + STT provider settings.
|
/// Voice tab — push-to-talk + TTS + STT provider settings.
|
||||||
struct VoiceTab: View {
|
struct VoiceTab: View {
|
||||||
@Bindable var viewModel: SettingsViewModel
|
@Bindable var viewModel: SettingsViewModel
|
||||||
|
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SettingsSection(title: "Push-to-Talk", icon: "mic") {
|
SettingsSection(title: "Push-to-Talk", icon: "mic") {
|
||||||
@@ -28,6 +30,16 @@ struct VoiceTab: View {
|
|||||||
case "neutts":
|
case "neutts":
|
||||||
EditableTextField(label: "Model", value: viewModel.config.voice.ttsNeuTTSModel) { viewModel.setTTSNeuTTSModel($0) }
|
EditableTextField(label: "Model", value: viewModel.config.voice.ttsNeuTTSModel) { viewModel.setTTSNeuTTSModel($0) }
|
||||||
PickerRow(label: "Device", selection: viewModel.config.voice.ttsNeuTTSDevice, options: ["cpu", "cuda"]) { viewModel.setTTSNeuTTSDevice($0) }
|
PickerRow(label: "Device", selection: viewModel.config.voice.ttsNeuTTSDevice, options: ["cpu", "cuda"]) { viewModel.setTTSNeuTTSDevice($0) }
|
||||||
|
case "xai":
|
||||||
|
// v0.13: xAI TTS surface. Voice ID + Model are always
|
||||||
|
// visible (xAI TTS shipped earlier); the cloning-supported
|
||||||
|
// badge is gated on `hasXAIVoiceCloning` so pre-v0.13 hosts
|
||||||
|
// see the input rows but no cloning advertisement.
|
||||||
|
EditableTextField(label: "Voice ID", value: viewModel.config.voice.ttsXAIVoiceID) { viewModel.setTTSXAIVoiceID($0) }
|
||||||
|
EditableTextField(label: "Model", value: viewModel.config.voice.ttsXAIModel) { viewModel.setTTSXAIModel($0) }
|
||||||
|
if capabilitiesStore?.capabilities.hasXAIVoiceCloning == true {
|
||||||
|
xaiCloningBadge
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}
|
}
|
||||||
@@ -49,4 +61,24 @@ struct VoiceTab: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Inline hint chip+caption shown below xAI's Voice ID + Model fields
|
||||||
|
/// on v0.13+. References `hermes voice` because Scarf doesn't manage
|
||||||
|
/// cloned voices in-app yet — the badge is discovery-only. Out-of-scope
|
||||||
|
/// for v2.8: an in-app cloned-voice manager (would be its own feature).
|
||||||
|
@ViewBuilder
|
||||||
|
private var xaiCloningBadge: some View {
|
||||||
|
HStack(alignment: .center, spacing: 8) {
|
||||||
|
Text("")
|
||||||
|
.font(.caption)
|
||||||
|
.frame(width: 160, alignment: .trailing)
|
||||||
|
ScarfBadge("Cloning supported", kind: .info)
|
||||||
|
Text("Manage cloned voices in your terminal: `hermes voice` (xAI subcommands).")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
import SwiftUI
|
|
||||||
import ScarfCore
|
|
||||||
import ScarfDesign
|
|
||||||
|
|
||||||
/// Web Tools tab — search + extract backend pickers. Pre-v0.13 hosts
|
|
||||||
/// see a single "Combined backend" row writing to the legacy
|
|
||||||
/// `web_tools.backend` key. v0.13+ hosts see two rows writing to the
|
|
||||||
/// per-capability split keys (`web_tools.search.backend` +
|
|
||||||
/// `web_tools.extract.backend`); SearXNG appears in the search picker
|
|
||||||
/// only because Hermes registers it as a search-only backend.
|
|
||||||
struct WebToolsTab: View {
|
|
||||||
@Bindable var viewModel: SettingsViewModel
|
|
||||||
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
|
||||||
|
|
||||||
private var split: Bool {
|
|
||||||
capabilitiesStore?.capabilities.hasWebToolsBackendSplit ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(WS-7-Q6): Backend lists are curated inline based on the v0.13
|
|
||||||
// release notes ("SearXNG joined search-only"). The exact dispatch
|
|
||||||
// table lives in `~/.hermes/hermes-agent/hermes_cli/web_tools.py` —
|
|
||||||
// verify during integration. A wrong entry just produces a
|
|
||||||
// `hermes config set` failure on save (recoverable, not silent).
|
|
||||||
private static let searchBackends: [String] = [
|
|
||||||
"duckduckgo", "tavily", "brave", "exa", "you", "searxng"
|
|
||||||
]
|
|
||||||
private static let extractBackends: [String] = [
|
|
||||||
"reader", "browserless", "trafilatura", "firecrawl"
|
|
||||||
]
|
|
||||||
/// v0.12 combined-backend list — superset of the v0.13 search list
|
|
||||||
/// minus SearXNG (which only dispatches as search) plus the v0.13
|
|
||||||
/// extract-only entries that pre-v0.13 hosts handled under the
|
|
||||||
/// combined key.
|
|
||||||
private static let combinedBackends: [String] = [
|
|
||||||
"duckduckgo", "tavily", "brave", "exa", "you",
|
|
||||||
"reader", "browserless", "trafilatura", "firecrawl"
|
|
||||||
]
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
if split {
|
|
||||||
SettingsSection(title: "Web Tools", icon: "globe.americas") {
|
|
||||||
PickerRow(
|
|
||||||
label: "Search backend",
|
|
||||||
selection: viewModel.config.webToolsSearchBackend,
|
|
||||||
options: Self.searchBackends
|
|
||||||
) { viewModel.setWebToolsSearchBackend($0) }
|
|
||||||
PickerRow(
|
|
||||||
label: "Extract backend",
|
|
||||||
selection: viewModel.config.webToolsExtractBackend,
|
|
||||||
options: Self.extractBackends
|
|
||||||
) { viewModel.setWebToolsExtractBackend($0) }
|
|
||||||
}
|
|
||||||
Text("SearXNG joined v0.13 as a search-only backend. Backend-specific tuning (host URLs, API keys) lives in the raw YAML editor for now.")
|
|
||||||
.scarfStyle(.caption)
|
|
||||||
.foregroundStyle(ScarfColor.foregroundMuted)
|
|
||||||
.padding(.horizontal, ScarfSpace.s4)
|
|
||||||
} else {
|
|
||||||
// TODO(WS-7-Q7): Pre-v0.13 hosts fall back to the legacy single
|
|
||||||
// backend. v0.13 may or may not honour `web_tools.backend` as a
|
|
||||||
// fallback when the split keys are absent — verify with Hermes
|
|
||||||
// and consider a one-time migration prompt in a follow-up if
|
|
||||||
// upgrading from v0.12 silently resets the user's backend.
|
|
||||||
SettingsSection(title: "Web Tools", icon: "globe.americas") {
|
|
||||||
PickerRow(
|
|
||||||
label: "Backend",
|
|
||||||
selection: viewModel.config.webToolsBackend,
|
|
||||||
options: Self.combinedBackends
|
|
||||||
) { viewModel.setWebToolsBackend($0) }
|
|
||||||
}
|
|
||||||
Text("Hermes v0.13 splits search and extract into separate backends. Update Hermes to access the per-capability picker.")
|
|
||||||
.scarfStyle(.caption)
|
|
||||||
.foregroundStyle(ScarfColor.foregroundFaint)
|
|
||||||
.padding(.horizontal, ScarfSpace.s4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user