Compare commits

..

1 Commits

Author SHA1 Message Date
Alan Wizemann 57a6340985 feat(providers): catalog refresh + image_gen.model + OpenRouter caching (WS-6)
Surfaces the v0.13 provider catalog work in Scarf v2.8.0. Five new model IDs
(deepseek/deepseek-v4-pro, x-ai/grok-4.3, openrouter/owl-alpha,
tencent/hy3-preview, arcee/trinity-large-thinking) flow through
models_dev_cache.json on next refresh — no manual catalog entries
needed; the picker reaches them automatically. The grok-4.20-beta →
grok-4.20 rename is handled via a new ModelCatalogService.modelAliases
map plus resolveModelAlias() helper, called from validateModel(),
model(_:_:), and provider(for:) at read time. Lossless: stored configs
are never rewritten.

Vercel AI Gateway is demoted to the bottom of the picker via a new
demotedProviders set + sort-comparator axis (between subscription-gated
and alphabetical). Always-on, no capability gate — sort-order
consistency across Hermes versions.

image_gen.model (top-level v0.13 YAML key) and
openrouter.response_cache.enabled (provisional key shape per
TODO(WS-6-Q1)) are surfaced as new SettingsSection rows in
AuxiliaryTab, capability-gated on hasImageGenModel +
hasOpenRouterResponseCache so pre-v0.13 hosts hide them. Image-gen
picker has a curated 7-entry allowlist (HermesImageGenModel) plus
free-form Custom model ID entry.

CLAUDE.md gains two schema-drift bullets next to the existing
overlayOnlyProviders requirement (modelAliases + demotedProviders
mirror with hermes_cli/providers.py).

Tests: 4 new M0cServicesTests (sort axis, alias resolution + cross-
provider isolation, image-gen allowlist, demoted-set sentinel) and 2
new M6ConfigCronTests (YAML round-trip + empty-default).

Implements WS-6 of Scarf v2.8.0 (Hermes v0.13.0 catch-up).
Plan: scarf/docs/v2.8/WS-6-providers-v0.13-plan.md
(on coordination/v2.8.0-plans).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 19:02:45 +02:00
23 changed files with 364 additions and 428 deletions
+4
View File
@@ -173,6 +173,10 @@ v0.10.0 introduced the **Tool Gateway** — paid Nous Portal subscribers route w
**Keep `ModelCatalogService.overlayOnlyProviders` in sync** with `HERMES_OVERLAYS` in `~/.hermes/hermes-agent/hermes_cli/providers.py`. When Hermes adds a new overlay-only provider, mirror the entry (display name, base URL, auth type, subscription-gated flag, doc URL) or the picker won't reach it.
**Keep `ModelCatalogService.modelAliases` in sync** with Hermes's deprecated-model-ID map (currently release-notes-only upstream; the canonical successor lives in `hermes_cli/providers.py` if/when upstream tracks it in code). Drift here means a user's old model ID stops resolving in the picker even though Hermes still accepts it at runtime.
**Keep `ModelCatalogService.demotedProviders` in sync** with the deprioritized-provider list in `hermes-agent/hermes_cli/providers.py`. Drift means Vercel AI Gateway (or any future demoted provider) sorts in the wrong position in Scarf's picker.
## Kanban v3: drag-and-drop board + per-project tenants (v2.7.5)
Scarf v2.7.5 promotes Kanban from a read-only list to a full board with drag-and-drop, every Hermes write verb wired up, and per-project boards bound to a Scarf-minted tenant slug. The list view is preserved as a `Board | List` toggle for accessibility / narrow-window fallback.
@@ -666,18 +666,27 @@ public struct HermesConfig: Sendable {
/// final reply (provider/model/cost/turn count). Off by default;
/// useful for cost auditing and screen-recording demos.
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
// -- Hermes v0.13 additions ----------------------------------------
/// `image_gen.model` (v0.13+) overrides the per-provider default
/// image-gen model. Empty string means "let Hermes pick the
/// provider default". Hermes v0.12 advertised this key but ignored
/// it; Scarf's `AuxiliaryTab` only renders the picker when
/// `HermesCapabilities.hasImageGenModel` is `true`.
public var imageGenModel: String
/// `openrouter.response_cache.enabled` (v0.13+) when true, Hermes
/// asks OpenRouter to cache responses for repeat prompts within a
/// session. Off by default in Scarf's parser per WS-6 plan
/// recommendation. UI gated on
/// `HermesCapabilities.hasOpenRouterResponseCache`.
// TODO(WS-6-Q1): the exact YAML key shape is provisional. Verify
// against a v0.13 host's `hermes config check` output before
// shipping (see WS-6-plan §Open Questions #1). Candidate alternative
// shapes: `providers.openrouter.response_cache_enabled` or
// `prompt_caching.openrouter.enabled`.
public var openrouterResponseCacheEnabled: Bool
// Grouped blocks
public var display: DisplaySettings
@@ -760,16 +769,14 @@ public struct HermesConfig: Sendable {
cacheTTL: String = "5m",
redactionEnabled: Bool = false,
runtimeMetadataFooter: Bool = false,
webToolsBackend: String = "duckduckgo",
webToolsSearchBackend: String = "duckduckgo",
webToolsExtractBackend: String = "reader"
imageGenModel: String = "",
openrouterResponseCacheEnabled: Bool = false
) {
self.cacheTTL = cacheTTL
self.redactionEnabled = redactionEnabled
self.runtimeMetadataFooter = runtimeMetadataFooter
self.webToolsBackend = webToolsBackend
self.webToolsSearchBackend = webToolsSearchBackend
self.webToolsExtractBackend = webToolsExtractBackend
self.imageGenModel = imageGenModel
self.openrouterResponseCacheEnabled = openrouterResponseCacheEnabled
self.model = model
self.provider = provider
self.maxTurns = maxTurns
@@ -28,12 +28,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
/// job's prompt. YAML-only field today (no `--context-from` CLI
/// flag yet) Scarf displays it but doesn't write it.
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 {
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 workdir
case contextFrom = "context_from"
case noAgent = "no_agent"
}
/// Memberwise init. Swift doesn't synthesize one for us because
@@ -73,8 +66,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
timeoutSeconds: Int? = nil,
silent: Bool? = nil,
workdir: String? = nil,
contextFrom: [String]? = nil,
noAgent: Bool? = nil
contextFrom: [String]? = nil
) {
self.id = id
self.name = name
@@ -96,7 +88,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
self.silent = silent
self.workdir = workdir
self.contextFrom = contextFrom
self.noAgent = noAgent
}
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.workdir = try c.decodeIfPresent(String.self, forKey: .workdir)
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 {
@@ -146,7 +136,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
try c.encodeIfPresent(silent, forKey: .silent)
try c.encodeIfPresent(workdir, forKey: .workdir)
try c.encodeIfPresent(contextFrom, forKey: .contextFrom)
try c.encodeIfPresent(noAgent, forKey: .noAgent)
}
public nonisolated var stateIcon: String {
@@ -3,10 +3,6 @@ import Foundation
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
case stdio
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 }
@@ -15,7 +11,6 @@ public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiabl
switch self {
case .stdio: return "Local (stdio)"
case .http: return "Remote (HTTP)"
case .sse: return "Remote (SSE)"
}
}
#endif
@@ -38,12 +33,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
public let resourcesEnabled: Bool
public let promptsEnabled: 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(
@@ -62,8 +51,7 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
toolsExclude: [String],
resourcesEnabled: Bool,
promptsEnabled: Bool,
hasOAuthToken: Bool,
sseReadTimeout: Int? = nil
hasOAuthToken: Bool
) {
self.name = name
self.transport = transport
@@ -81,7 +69,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
self.resourcesEnabled = resourcesEnabled
self.promptsEnabled = promptsEnabled
self.hasOAuthToken = hasOAuthToken
self.sseReadTimeout = sseReadTimeout
}
public var id: String { name }
@@ -92,8 +79,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
return (command ?? "") + argString
case .http:
return url ?? ""
case .sse:
return url ?? ""
}
}
}
@@ -285,13 +285,17 @@ public extension HermesConfig {
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
redactionEnabled: bool("redaction.enabled", 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")
// -- v0.13 additions -------------------------------------
// TODO(WS-6-Q1): the `openrouter.response_cache.enabled`
// key shape is provisional pending verification against a
// v0.13 `hermes config check`. If upstream uses a different
// path (e.g. `providers.openrouter.response_cache_enabled`
// or nested under `prompt_caching`), update this single
// line + the matching `setSetting` key in
// `SettingsViewModel.setOpenRouterResponseCache`. Default
// is `false` per WS-6-plan §Open Questions #2.
imageGenModel: str("image_gen.model", default: ""),
openrouterResponseCacheEnabled: bool("openrouter.response_cache.enabled", default: false)
)
}
}
@@ -155,9 +155,20 @@ public struct ModelCatalogService: Sendable {
)
}
return byID.values.sorted { lhs, rhs in
// Subscription-gated first (Nous Portal).
if lhs.subscriptionGated != rhs.subscriptionGated {
return lhs.subscriptionGated
}
// Demoted last (Vercel AI Gateway, per Hermes v0.13). The
// axis is unconditional we don't gate on the Hermes
// version because "Vercel mid-alphabet on v0.12, bottom on
// v0.13" would be more confusing than the consistent
// "Vercel last" treatment for everyone.
let lDemoted = Self.demotedProviders.contains(lhs.providerID)
let rDemoted = Self.demotedProviders.contains(rhs.providerID)
if lDemoted != rDemoted {
return !lDemoted
}
return lhs.providerName.localizedCaseInsensitiveCompare(rhs.providerName) == .orderedAscending
}
}
@@ -235,7 +246,10 @@ public struct ModelCatalogService: Sendable {
public func provider(for modelID: String) -> HermesProviderInfo? {
guard let catalog = loadCatalog() else { return nil }
for (providerID, p) in catalog {
if p.models?[modelID] != nil {
// Resolve any model-rename alias for this provider before
// checking the catalog see `modelAliases` for rationale.
let resolved = resolveModelAlias(providerID: providerID, modelID: modelID)
if p.models?[resolved] != nil {
return HermesProviderInfo(
providerID: providerID,
providerName: p.name ?? providerID,
@@ -299,14 +313,17 @@ public struct ModelCatalogService: Sendable {
/// Look up a specific model by provider + ID. Returns nil if not in the
/// catalog (e.g., free-typed custom model).
public func model(providerID: String, modelID: String) -> HermesModelInfo? {
// Resolve any model-rename alias for this provider before
// checking the catalog see `modelAliases` for rationale.
let resolved = resolveModelAlias(providerID: providerID, modelID: modelID)
guard let catalog = loadCatalog(),
let provider = catalog[providerID],
let raw = provider.models?[modelID] else { return nil }
let raw = provider.models?[resolved] else { return nil }
return HermesModelInfo(
providerID: providerID,
providerName: provider.name ?? providerID,
modelID: modelID,
modelName: raw.name ?? modelID,
modelID: resolved,
modelName: raw.name ?? resolved,
contextWindow: raw.limit?.context,
maxOutput: raw.limit?.output,
costInput: raw.cost?.input,
@@ -344,10 +361,14 @@ public struct ModelCatalogService: Sendable {
/// HTTP 404 at runtime. Catch that at save time, not 6 hours later.
public func validateModel(_ modelID: String, for providerID: String) -> ModelValidation {
ScarfMon.measure(.diskIO, "modelCatalog.validateModel") {
let trimmed = modelID.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else {
let raw = modelID.trimmingCharacters(in: .whitespacesAndNewlines)
guard !raw.isEmpty else {
return .invalid(providerName: providerID, suggestions: [])
}
// Resolve any model-rename alias before lookup so configs
// referencing a deprecated ID (e.g. `x-ai/grok-4.20-beta`)
// validate against the canonical successor.
let trimmed = resolveModelAlias(providerID: providerID, modelID: raw)
// Overlay-only providers (Nous Portal, OpenAI Codex, Qwen
// OAuth, ) serve their own catalogs that aren't mirrored to
@@ -433,6 +454,78 @@ public struct ModelCatalogService: Sendable {
let output: Int?
}
// MARK: - Model aliases (model rename resolution)
/// Hermes deprecates model IDs across releases. When a stored config
/// `model.default` references a deprecated ID, resolve to its
/// canonical successor. Lossless we never rewrite the user's
/// `config.yaml`; the alias just lets `validateModel` /
/// `model(providerID:modelID:)` / `provider(for:)` succeed against
/// the new ID.
///
/// Keys are slash-joined `providerID/modelID` to disambiguate
/// across providers even if `vercel` later adds a `grok-4.20-beta`
/// alias on its own, the openrouter resolution shouldn't fire.
/// Values are the bare resolved model ID (no provider prefix).
///
/// **Schema is Swift-primary.** Mirror new entries into Hermes's
/// upstream deprecation map in `hermes_cli/providers.py` if/when
/// upstream tracks renames in code (today they're release-notes
/// only).
public static let modelAliases: [String: String] = [
// v0.13: x-ai dropped the `-beta` suffix once Grok 4.20 GA'd.
// The model is the same one served at the same OpenRouter slot;
// only the marketing identifier changed.
// TODO(WS-6-Q4): verify whether OpenRouter retired the
// `x-ai/grok-4.20-beta` slot entirely. Either way the alias is
// correct (cosmetic if old slot stays live, load-bearing if it
// 404s).
"openrouter/x-ai/grok-4.20-beta": "x-ai/grok-4.20",
"xai/grok-4.20-beta": "grok-4.20",
"vercel/xai/grok-4.20-beta": "xai/grok-4.20",
]
/// Resolve a stored model identifier through the alias map. Returns
/// the input unchanged when no alias exists. Pure function used at
/// read time everywhere a config'd model ID is rendered, validated,
/// or sent to Hermes.
public func resolveModelAlias(providerID: String, modelID: String) -> String {
let composite = "\(providerID)/\(modelID)"
return Self.modelAliases[composite] ?? modelID
}
// MARK: - Demoted providers (sort tail)
/// Provider IDs that Hermes v0.13 explicitly deprioritizes in the
/// picker. `loadProviders()` sorts these to the tail of the list,
/// after the alphabetical group, so users who haven't manually
/// chosen Vercel as their gateway don't end up there by default.
/// Mirrors Hermes's deprioritized-provider list in
/// `hermes-agent/hermes_cli/providers.py`.
public static let demotedProviders: Set<String> = [
"vercel",
]
// MARK: - Image-generation model allowlist (curated)
/// Known image-generation models, used to pre-populate the
/// `image_gen.model` picker on the Auxiliary tab. The list is
/// curated `models_dev_cache.json` doesn't tag image-capable
/// models, so we maintain this by hand on Hermes version bumps.
/// Always free-form-typeable on the picker too, so missing entries
/// don't block users with non-listed image providers.
///
/// Order: most-likely-to-be-chosen first.
public static let imageGenModels: [HermesImageGenModel] = [
.init(modelID: "openai/gpt-image-1", display: "OpenAI · gpt-image-1", providerHint: "openai"),
.init(modelID: "google/imagen-4", display: "Google · Imagen 4", providerHint: "google-vertex"),
.init(modelID: "google/imagen-3", display: "Google · Imagen 3", providerHint: "google-vertex"),
.init(modelID: "stability/stable-image-ultra", display: "Stability · Stable Image Ultra", providerHint: "stability"),
.init(modelID: "fal-ai/flux-pro-1.1", display: "fal · FLUX 1.1 Pro", providerHint: "fal"),
.init(modelID: "black-forest-labs/flux-1.1-pro", display: "Black Forest Labs · FLUX 1.1 Pro", providerHint: "openrouter"),
.init(modelID: "openai/dall-e-3", display: "OpenAI · DALL·E 3", providerHint: "openai"),
]
// MARK: - Hermes overlay providers
/// The 11 providers Hermes surfaces via `hermes model` that have no
@@ -538,6 +631,27 @@ public struct ModelCatalogService: Sendable {
]
}
/// Curated entry for the `image_gen.model` picker on the Auxiliary
/// tab. Hermes v0.13 honors a top-level `image_gen.model` key but the
/// models.dev catalog has no `image: true` tag, so we maintain a
/// short hand-curated allowlist keyed by display order. The picker
/// always allows free-form-typing too, so any provider's model ID
/// works regardless of whether it appears here.
public struct HermesImageGenModel: Sendable, Identifiable, Hashable {
public let modelID: String
public let display: String
/// Hint at which provider serves this model surfaced as a
/// "Configure provider X first" advisory but never enforced.
public let providerHint: String?
public var id: String { modelID }
public init(modelID: String, display: String, providerHint: String?) {
self.modelID = modelID
self.display = display
self.providerHint = providerHint
}
}
/// Scarf-side mirror of `HermesOverlay` from hermes-agent's
/// `hermes_cli/providers.py`. Describes a provider that isn't in the
/// models.dev catalog.
@@ -310,6 +310,74 @@ import Foundation
}
}
// MARK: - ModelCatalogService — WS-6 (v0.13)
@Test func vercelAIGatewayDemotedToBottom() throws {
// Build a minimal catalog with vercel + alphabetically-later
// providers, then assert vercel sorts after them. Locks the
// demoted-axis sort comparator added in WS-6.
let json = """
{
"anthropic": { "name": "Anthropic", "models": {} },
"vercel": { "name": "Vercel AI Gateway", "models": {} },
"zonk": { "name": "Zonk Provider", "models": {} }
}
"""
let tmp = FileManager.default.temporaryDirectory
.appendingPathComponent("scarf-models-\(UUID().uuidString).json")
try json.write(to: tmp, atomically: true, encoding: .utf8)
defer { try? FileManager.default.removeItem(at: tmp) }
let svc = ModelCatalogService(path: tmp.path)
let providers = svc.loadProviders().filter { !$0.isOverlay }
let names = providers.map(\.providerName)
// anthropic first (alpha), zonk next (alpha), vercel last
// (demoted) — even though `vercel` < `zonk` alphabetically.
#expect(names.last == "Vercel AI Gateway")
let vercelIdx = names.firstIndex(of: "Vercel AI Gateway") ?? -1
let zonkIdx = names.firstIndex(of: "Zonk Provider") ?? -1
#expect(vercelIdx > zonkIdx)
}
@Test func grok420BetaAliasResolvesToGrok420() {
let svc = ModelCatalogService(path: "/tmp/scarf-nonexistent-\(UUID().uuidString).json")
// OpenRouter's old `-beta` ID resolves to the GA name.
#expect(svc.resolveModelAlias(providerID: "openrouter", modelID: "x-ai/grok-4.20-beta")
== "x-ai/grok-4.20")
// xAI direct provider keeps the same shape minus prefix.
#expect(svc.resolveModelAlias(providerID: "xai", modelID: "grok-4.20-beta")
== "grok-4.20")
// Non-aliased ID passes through unchanged.
#expect(svc.resolveModelAlias(providerID: "anthropic", modelID: "claude-4.7-opus")
== "claude-4.7-opus")
// Cross-provider isolation: same modelID on a different
// provider isn't aliased — composite key in `modelAliases`
// disambiguates by providerID.
#expect(svc.resolveModelAlias(providerID: "fictional", modelID: "x-ai/grok-4.20-beta")
== "x-ai/grok-4.20-beta")
}
@Test func imageGenModelAllowlistShape() {
// Lock the curated list size + a few sentinel entries so
// unintentional edits get caught in review. Free-form-typing
// bypasses the allowlist, so additions/removals here are
// purely UX (which models surface as picker rows).
let models = ModelCatalogService.imageGenModels
#expect(models.count >= 5)
#expect(models.contains(where: { $0.modelID == "openai/gpt-image-1" }))
#expect(models.contains(where: { $0.modelID == "google/imagen-4" }))
// Every entry has a non-empty display + a non-empty modelID.
for m in models {
#expect(!m.modelID.isEmpty)
#expect(!m.display.isEmpty)
}
}
@Test func demotedProvidersContainsVercel() {
// Minimal lock-in for the demoted-providers static set. Mirrors
// Hermes's deprioritized-provider list in providers.py.
#expect(ModelCatalogService.demotedProviders.contains("vercel"))
}
// MARK: - ProjectDashboardService
@Test func projectDashboardServiceRegistryRoundTrip() throws {
@@ -92,6 +92,27 @@ import Foundation
#expect(c.security.redactSecrets == true)
#expect(c.compression.enabled == true)
#expect(c.voice.ttsProvider == "edge")
// v0.13 additions default to empty / off when the YAML omits
// them pre-v0.13 hosts produce this exact shape.
#expect(c.imageGenModel == "")
#expect(c.openrouterResponseCacheEnabled == false)
}
@Test func parsesImageGenAndOpenRouterCache() {
// WS-6: round-trip the two new top-level v0.13 keys. If the
// OpenRouter key shape changes upstream (see TODO(WS-6-Q1)),
// this test is the single touchpoint that pins the parser
// line + setter key + UI binding to a single shape.
let yaml = """
image_gen:
model: openai/gpt-image-1
openrouter:
response_cache:
enabled: true
"""
let c = HermesConfig(yaml: yaml)
#expect(c.imageGenModel == "openai/gpt-image-1")
#expect(c.openrouterResponseCacheEnabled == true)
}
@Test func parsesTopLevelModel() {
@@ -599,8 +599,7 @@ struct HermesFileService: Sendable {
toolsExclude: server.toolsExclude,
resourcesEnabled: server.resourcesEnabled,
promptsEnabled: server.promptsEnabled,
hasOAuthToken: hasToken,
sseReadTimeout: server.sseReadTimeout
hasOAuthToken: hasToken
)
}
}
@@ -631,37 +630,6 @@ struct HermesFileService: Sendable {
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
nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool {
patchMCPServerField(name: name) { entryLines in
@@ -844,23 +812,11 @@ struct HermesFileService: Sendable {
func flush() {
guard let name = currentName else { return }
// 3-way transport discriminator: an explicit `transport: sse` scalar
// 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 transport: MCPTransport = fields["url"] != nil ? .http : .stdio
let enabledStr = fields["enabled"]?.lowercased()
let enabled = enabledStr != "false"
let timeout = fields["timeout"].flatMap(Int.init)
let connectTimeout = fields["connect_timeout"].flatMap(Int.init)
let sseReadTimeout = fields["sse_read_timeout"].flatMap(Int.init)
let server = HermesMCPServer(
name: name,
transport: transport,
@@ -877,8 +833,7 @@ struct HermesFileService: Sendable {
toolsExclude: excludeList,
resourcesEnabled: resources,
promptsEnabled: prompts,
hasOAuthToken: false,
sseReadTimeout: sseReadTimeout
hasOAuthToken: false
)
servers.append(server)
@@ -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"]
if !name.isEmpty { args += ["--name", name] }
if !deliver.isEmpty { args += ["--deliver", deliver] }
@@ -158,25 +158,12 @@ final class CronViewModel {
// know the flag argparse rejects unknown args, so the form
// omits the flag when the field is empty.
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)
// TODO(WS-7-Q5): When --no-agent is set Hermes ignores the prompt arg,
// 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)
}
if !prompt.isEmpty { args.append(prompt) }
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]
if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] }
if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] }
@@ -193,16 +180,6 @@ final class CronViewModel {
// = user cleared an existing workdir; Hermes documents `--workdir ""`
// on edit as the explicit clear gesture, mirroring the `--script` shape.
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")
}
+4 -37
View File
@@ -25,10 +25,6 @@ struct CronView: View {
capabilitiesStore?.capabilities.hasCronWorkdir ?? false
}
private var hasCronNoAgent: Bool {
capabilitiesStore?.capabilities.hasCronNoAgent ?? false
}
var body: some View {
VStack(spacing: 0) {
pageHeader
@@ -51,7 +47,7 @@ struct CronView: View {
// polling timer. Same wiring ActivityView uses.
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
.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(
schedule: form.schedule,
prompt: form.prompt,
@@ -60,12 +56,7 @@ struct CronView: View {
skills: form.skills,
script: form.script,
repeatCount: form.repeatCount,
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
workdir: hasCronWorkdir ? form.workdir : ""
)
viewModel.showCreateSheet = false
} onCancel: {
@@ -73,7 +64,7 @@ struct CronView: View {
}
}
.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(
id: job.id,
schedule: form.schedule,
@@ -84,8 +75,7 @@ struct CronView: View {
newSkills: form.skills,
clearSkills: form.clearSkills,
script: form.script,
workdir: hasCronWorkdir ? form.workdir : nil,
noAgent: hasCronNoAgent ? form.noAgent : nil
workdir: hasCronWorkdir ? form.workdir : nil
)
viewModel.editingJob = nil
} onCancel: {
@@ -653,9 +643,6 @@ struct CronJobEditor: View {
/// v0.12+ workdir flag fills `--workdir <path>`. Empty string
/// preserves the v0.11 behaviour of running with no cwd hint.
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
@@ -663,10 +650,6 @@ struct CronJobEditor: View {
/// 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`.
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 onCancel: () -> Void
@@ -698,25 +681,12 @@ struct CronJobEditor: View {
)
.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("Repeat", text: $form.repeatCount, placeholder: "Optional count")
formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true)
if supportsWorkdir {
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 {
VStack(alignment: .leading, spacing: 4) {
Text("Skills")
@@ -753,8 +723,6 @@ struct CronJobEditor: View {
.tint(ScarfColor.accent)
}
}
.opacity(form.noAgent ? 0.4 : 1.0)
.disabled(form.noAgent)
}
HStack {
Spacer()
@@ -778,7 +746,6 @@ struct CronJobEditor: View {
form.skills = job.skills ?? []
form.script = job.preRunScript ?? ""
form.workdir = job.workdir ?? ""
form.noAgent = job.noAgent ?? false
}
}
}
@@ -21,9 +21,6 @@ final class MCPServerEditorViewModel {
var promptsEnabled: Bool
var timeoutDraft: 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 isSaving: Bool = false
var saveError: String?
@@ -40,7 +37,6 @@ final class MCPServerEditorViewModel {
self.promptsEnabled = server.promptsEnabled
self.timeoutDraft = server.timeout.map { String($0) } ?? ""
self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? ""
self.sseReadTimeoutDraft = server.sseReadTimeout.map { String($0) } ?? ""
}
func appendEnvRow() {
@@ -73,8 +69,6 @@ final class MCPServerEditorViewModel {
let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
let timeoutValue = Int(timeoutDraft.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 transport = server.transport
@@ -93,11 +87,6 @@ final class MCPServerEditorViewModel {
if !service.setMCPServerEnv(name: name, env: envMap) { ok = false }
case .http:
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(
name: name,
@@ -42,10 +42,6 @@ final class MCPServersViewModel {
filteredServers.filter { $0.transport == .http }
}
var sseServers: [HermesMCPServer] {
filteredServers.filter { $0.transport == .sse }
}
var selectedServer: HermesMCPServer? {
guard let name = selectedServerName else { return nil }
return servers.first(where: { $0.name == name })
@@ -171,11 +167,6 @@ final class MCPServersViewModel {
url: preset.url ?? "",
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 {
await MainActor.run {
@@ -205,11 +196,6 @@ final class MCPServersViewModel {
result = fileService.addMCPServerStdio(name: name, command: command, args: args)
case .http:
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 {
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() {
let fileService = self.fileService
Task.detached {
@@ -6,26 +6,12 @@ struct MCPServerAddCustomView: View {
let viewModel: MCPServersViewModel
@Environment(\.dismiss) private var dismiss
@Environment(\.hermesCapabilities) private var capabilitiesStore
@State private var name: String = ""
@State private var transport: MCPTransport = .stdio
@State private var command: String = "npx"
@State private var argsText: String = ""
@State private var url: String = ""
@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 {
VStack(spacing: 0) {
@@ -58,20 +44,17 @@ struct MCPServerAddCustomView: View {
}
sectionBox(title: "Transport") {
Picker("", selection: $transport) {
ForEach(availableTransports) { t in
ForEach(MCPTransport.allCases) { t in
Text(t.displayName).tag(t)
}
}
.pickerStyle(.segmented)
.labelsHidden()
}
switch transport {
case .stdio:
if transport == .stdio {
stdioSection
case .http:
} else {
httpSection
case .sse:
sseSection
}
Text("Env vars, headers, and tool filters can be edited after the server is added.")
.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 {
let trimmedName = name.trimmingCharacters(in: .whitespaces)
guard !trimmedName.isEmpty else { return false }
@@ -159,8 +120,6 @@ struct MCPServerAddCustomView: View {
return !command.trimmingCharacters(in: .whitespaces).isEmpty
case .http:
return !url.trimmingCharacters(in: .whitespaces).isEmpty
case .sse:
return !url.trimmingCharacters(in: .whitespaces).isEmpty
}
}
@@ -171,25 +130,14 @@ struct MCPServerAddCustomView: View {
.map { $0.trimmingCharacters(in: .whitespaces) }
.filter { !$0.isEmpty }
let resolvedAuth: String? = (auth == "none") ? nil : auth
switch transport {
case .stdio, .http:
viewModel.addCustom(
name: trimmedName,
transport: transport,
command: command.trimmingCharacters(in: .whitespaces),
args: args,
url: url.trimmingCharacters(in: .whitespaces),
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
)
}
viewModel.addCustom(
name: trimmedName,
transport: transport,
command: command.trimmingCharacters(in: .whitespaces),
args: args,
url: url.trimmingCharacters(in: .whitespaces),
auth: resolvedAuth
)
dismiss()
}
@@ -127,11 +127,6 @@ struct MCPServerDetailView: View {
if let auth = server.auth, !auth.isEmpty {
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)
@@ -186,16 +186,6 @@ struct MCPServerEditorView: View {
.textFieldStyle(.roundedBorder)
.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()
}
}
@@ -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 {
Section {
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]
if cloneAll { args.append("--clone-all") }
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")
}
@@ -11,12 +11,7 @@ struct ProfilesView: View {
@State private var createName = ""
@State private var createCloneConfig = true
@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
@Environment(\.hermesCapabilities) private var capabilitiesStore
init(context: ServerContext) {
_viewModel = State(initialValue: ProfilesViewModel(context: context))
@@ -128,7 +123,7 @@ struct ProfilesView: View {
}
Spacer()
Button {
createName = ""; createCloneConfig = true; createCloneAll = false; createNoSkills = false
createName = ""; createCloneConfig = true; createCloneAll = false
showCreate = true
} label: {
Label("Create", systemImage: "plus")
@@ -305,31 +300,11 @@ struct ProfilesView: View {
Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig)
.disabled(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 {
Spacer()
Button("Cancel") { showCreate = false }
Button("Create") {
viewModel.create(
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
)
viewModel.create(name: createName, cloneConfig: createCloneConfig, cloneAll: createCloneAll)
showCreate = false
}
.buttonStyle(.borderedProminent)
@@ -143,16 +143,6 @@ final class SettingsViewModel {
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") }
// 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
func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") }
@@ -205,6 +195,24 @@ final class SettingsViewModel {
setSetting("auxiliary.\(task).timeout", value: String(value))
}
// MARK: - Image generation (v0.13+)
/// `image_gen.model` overrides the per-provider default image
/// model (Hermes v0.13+). Empty string clears the override.
/// Capability-gated in `AuxiliaryTab` so pre-v0.13 hosts never
/// invoke this setter.
func setImageGenModel(_ value: String) { setSetting("image_gen.model", value: value) }
/// `openrouter.response_cache.enabled` toggles OpenRouter
/// response caching for repeat prompts (Hermes v0.13+).
/// Capability-gated in `AuxiliaryTab` so pre-v0.13 hosts never
/// invoke this setter.
// TODO(WS-6-Q1): the YAML key path is provisional keep in lockstep
// with `HermesConfig+YAML.swift`'s parser line.
func setOpenRouterResponseCache(_ value: Bool) {
setSetting("openrouter.response_cache.enabled", value: value ? "true" : "false")
}
// MARK: - Security / Privacy
func setRedactSecrets(_ value: Bool) { setSetting("security.redact_secrets", value: value ? "true" : "false") }
@@ -26,7 +26,6 @@ struct SettingsView: View {
case agent = "Agent"
case terminal = "Terminal"
case browser = "Browser"
case webTools = "Web Tools"
case voice = "Voice"
case memory = "Memory"
case auxiliary = "Aux Models"
@@ -42,7 +41,6 @@ struct SettingsView: View {
case .agent: return "Agent"
case .terminal: return "Terminal"
case .browser: return "Browser"
case .webTools: return "Web Tools"
case .voice: return "Voice"
case .memory: return "Memory"
case .auxiliary: return "Aux Models"
@@ -58,7 +56,6 @@ struct SettingsView: View {
case .agent: return "brain.head.profile"
case .terminal: return "terminal"
case .browser: return "globe"
case .webTools: return "globe.americas"
case .voice: return "mic"
case .memory: return "memorychip"
case .auxiliary: return "sparkles.rectangle.stack"
@@ -174,7 +171,6 @@ struct SettingsView: View {
case .agent: AgentTab(viewModel: viewModel)
case .terminal: TerminalTab(viewModel: viewModel)
case .browser: BrowserTab(viewModel: viewModel)
case .webTools: WebToolsTab(viewModel: viewModel)
case .voice: VoiceTab(viewModel: viewModel)
case .memory: MemoryTab(viewModel: viewModel)
case .auxiliary: AuxiliaryTab(viewModel: viewModel)
@@ -139,6 +139,23 @@ struct AuxiliaryTab: View {
auxRows(for: task.key)
}
}
// -- Hermes v0.13 additions ---------------------------------
// Image-gen model picker. Hermes v0.13 honors `image_gen.model`
// as a top-level YAML key; pre-v0.13 hosts ignore it silently.
// Hide the section on pre-v0.13 hosts to spare users a
// "I set this and nothing happened" trap.
if capabilitiesStore?.capabilities.hasImageGenModel ?? false {
SettingsSection(title: "Image Generation", icon: "photo") {
imageGenRow
}
}
// OpenRouter response caching toggle (v0.13+). Same hide-on-
// pre-v0.13 rationale: the toggle no-ops on older Hermes hosts.
if capabilitiesStore?.capabilities.hasOpenRouterResponseCache ?? false {
SettingsSection(title: "OpenRouter", icon: "shippingbox") {
openRouterResponseCacheRow
}
}
// Unknown / unrecognised aux tasks present in config.yaml.
// Shown only when at least one such key is present so the
// typical user with a clean config never sees this section.
@@ -225,6 +242,60 @@ struct AuxiliaryTab: View {
}
}
// MARK: - v0.13 surfaces
/// Image-gen model picker curated allowlist + free-form custom
/// entry. Capability-gated by the caller; this view assumes the
/// host honors `image_gen.model` (Hermes v0.13+).
@ViewBuilder
private var imageGenRow: some View {
let value = viewModel.config.imageGenModel
Picker("Model", selection: Binding(
get: { value },
set: { viewModel.setImageGenModel($0) }
)) {
Text("Provider default").tag("")
Divider()
ForEach(ModelCatalogService.imageGenModels) { model in
Text(model.display).tag(model.modelID)
}
// User has set a custom value not in the curated list;
// preserve it as a tagged option so the picker renders the
// actual selection rather than collapsing to "Provider
// default".
if !value.isEmpty
&& !ModelCatalogService.imageGenModels.contains(where: { $0.modelID == value }) {
Divider()
Text(value + " (custom)").tag(value)
}
}
.pickerStyle(.menu)
EditableTextField(label: "Custom model ID", value: value) { newValue in
viewModel.setImageGenModel(newValue.trimmingCharacters(in: .whitespaces))
}
Text("Used for image generation calls. Leave as Provider default unless your provider documents a specific model ID for image-gen.")
.font(.caption2)
.foregroundStyle(.tertiary)
.padding(.horizontal, 12)
.padding(.bottom, 4)
}
/// OpenRouter response-caching toggle (Hermes v0.13+). Off by
/// default; surfaced for users with highly repeated prompts who
/// want OpenRouter to cache identical-prompt responses.
@ViewBuilder
private var openRouterResponseCacheRow: some View {
let isOn = viewModel.config.openrouterResponseCacheEnabled
ToggleRow(label: "Response caching", isOn: isOn) { newValue in
viewModel.setOpenRouterResponseCache(newValue)
}
Text("OpenRouter caches identical prompts within a session to reduce token costs. Off by default — enable when your workload has highly repeated prompts.")
.font(.caption2)
.foregroundStyle(.tertiary)
.padding(.horizontal, 12)
.padding(.bottom, 4)
}
private func auxModel(for key: String) -> AuxiliaryModel {
switch key {
case "vision": return viewModel.config.auxiliary.vision
@@ -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)
}
}
}