mirror of
https://github.com/awizemann/scarf.git
synced 2026-05-10 18:44:45 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57a6340985 | |||
| 3e470c7155 | |||
| 963d0e1a5c | |||
| 52c802676f |
@@ -113,9 +113,29 @@ Public documentation lives in the GitHub wiki at https://github.com/awizemann/sc
|
||||
|
||||
## Hermes Version
|
||||
|
||||
Targets Hermes v2026.4.30 (v0.12.0). Log lines may carry an optional `[session_id]` tag between the level and logger name — `HermesLogService.parseLine` treats the session tag as an optional capture group, so older untagged lines still parse.
|
||||
Targets Hermes v2026.5.7 (v0.13.0). Log lines may carry an optional `[session_id]` tag between the level and logger name — `HermesLogService.parseLine` treats the session tag as an optional capture group, so older untagged lines still parse.
|
||||
|
||||
**Capability gating.** Scarf detects the target's Hermes version once per server connection via [HermesCapabilities](scarf/Packages/ScarfCore/Sources/ScarfCore/Services/HermesCapabilities.swift) (`hermes --version` → semver + `YYYY.M.D` parse). The resulting `HermesCapabilitiesStore` is injected on `ContextBoundRoot` (Mac) and `ScarfGoTabRoot` (iOS) via `.environment(_:)` and `.hermesCapabilities(_:)`; UI that depends on a v0.12+ surface (Curator, Kanban, ACP image input, `auxiliary.curator`, `prompt_caching.cache_ttl`, Piper TTS, Vercel terminal) reads it through the typed environment key. Pre-v0.12 hosts gracefully hide the new affordances rather than throwing on unknown CLI subcommands. Add a new flag at the top of `HermesCapabilities` whenever Scarf gains a release-gated UI surface.
|
||||
**Capability gating.** Scarf detects the target's Hermes version once per server connection via [HermesCapabilities](scarf/Packages/ScarfCore/Sources/ScarfCore/Services/HermesCapabilities.swift) (`hermes --version` → semver + `YYYY.M.D` parse). The resulting `HermesCapabilitiesStore` is injected on `ContextBoundRoot` (Mac) and `ScarfGoTabRoot` (iOS) via `.environment(_:)` and `.hermesCapabilities(_:)`; UI that depends on a release-gated surface reads it through the typed environment key. Pre-target hosts gracefully hide the new affordances rather than throwing on unknown CLI subcommands. Add a new flag at the top of `HermesCapabilities` whenever Scarf gains a release-gated UI surface — group flags by the Hermes release that introduced them (`MARK: v0.13 (v2026.5.7) flags`, etc.).
|
||||
|
||||
**v2026.5.7 (v0.13.0)** added (Scarf-relevant subset; full v2.8.0 implementation lands across WS-2 through WS-9):
|
||||
|
||||
- **Persistent Goals** — `/goal <text>` slash command locks the agent onto a target across turns. Checkpoints v2 single-store rewrite + auto-resume after gateway restart. Surfaced in Scarf chat as a non-interruptive command + a "🎯 Goal locked: <text>" pill in the chat header. Gated on `HermesCapabilities.hasGoals`.
|
||||
- **ACP `/queue` slash command** — queues a prompt to run after the current turn completes. Joins `/steer` in `RichChatViewModel.nonInterruptiveCommands` with a transient "Queued" toast. Gated on `hasACPQueue`. `/steer` now also runs as a regular prompt on idle sessions (`hasACPSteerOnIdle`).
|
||||
- **Kanban v0.13 reliability + recovery UX** — hallucination gate on worker-created cards, generic diagnostics engine (per-task distress signals), per-task `max_retries` override, multiline title/body create, `auto_blocked_reason` rendered in the inspector banner, darwin zombie detection, unify failure counter across spawn/timeout/crash. New fields decode through tolerant `HermesKanbanRun` / `HermesKanbanTaskDetail` extensions; pre-v0.13 hosts ignore unknown keys. Gated on `hasKanbanDiagnostics`.
|
||||
- **Curator archive + prune** — `hermes curator archive <skill>` + `prune` + `list-archived` subcommands. The synchronous manual `hermes curator run` blocks until done (pre-v0.13 returned immediately). Surfaced as an "Archived" tab in CuratorView with per-row Restore + Prune actions and a destructive prune-confirm sheet. Gated on `hasCuratorArchive`.
|
||||
- **Messaging Gateway expansion** — Google Chat (20th platform; `hasGoogleChatPlatform`), cross-platform allowlists (`allowed_channels` / `allowed_chats` / `allowed_rooms` per platform; `hasGatewayAllowlists`), per-platform `gateway_restart_notification` (`hasGatewayRestartNotification`), `busy_ack_enabled` toggle (`hasGatewayBusyAckToggle`), slash-command auto-delete TTL, `[[as_document]]` skill media routing directive, `hermes gateway list` cross-profile status verb (`hasGatewayList`).
|
||||
- **Provider catalog refresh** — new models on Nous Portal + OpenRouter: `deepseek/deepseek-v4-pro`, `x-ai/grok-4.3`, `openrouter/owl-alpha` (free), `tencent/hy3-preview`, `arcee/trinity-large-thinking` (with temperature + compression overrides). `x-ai/grok-4.20-beta` renamed to `x-ai/grok-4.20` — keep alias map. Vercel AI Gateway demoted to bottom of the picker. `image_gen.model` from `config.yaml` now honored by Hermes (was advertised but ignored pre-v0.13); surfaced in `Settings → Auxiliary` (`hasImageGenModel`). OpenRouter response caching toggle (`hasOpenRouterResponseCache`).
|
||||
- **MCP SSE transport** — MCP servers can be configured with SSE transport + `sse_read_timeout`. Surfaced in MCPServersView add-server flow alongside stdio/pipe. Gated on `hasMCPSSETransport`.
|
||||
- **Cron `--no-agent` mode** — script-only watchdog jobs that skip the AI call. Surfaced in CronView edit sheet. Gated on `hasCronNoAgent`.
|
||||
- **Web Tools per-capability backends** — `web_search` and `web_extract` can use distinct backends; SearXNG joined as a search-only backend. Surfaced in the Web Tools settings tab. Gated on `hasWebToolsBackendSplit`.
|
||||
- **Profiles `--no-skills`** — `hermes profile create --no-skills` for empty-profile creation. Surfaced as a toggle in the create-profile flow. Gated on `hasProfileNoSkills`.
|
||||
- **CLI / UX additions** — context compression count in the status feed (rendered next to the token count in chat status bar; `hasContextCompressionCount`), `/new <name>` slash-command argument (`hasNewWithSessionName`), `hermes update --yes` non-interactive (`hasUpdateNonInteractive`), `display.language` static-message translation (zh / ja / de / es / fr / uk / tr; `hasDisplayLanguage`), xAI Custom Voices (voice-cloning badge next to xAI TTS provider; `hasXAIVoiceCloning`).
|
||||
- **Server-side defaults flipped** — secret redaction defaults back to ON in v0.13 (was off by default in v0.12). The Settings redaction toggle remains for opt-out; the default-state hint reflects the v0.13 semantics when the host advertises v0.13+.
|
||||
- **`video_analyze` tool** — native video understanding on Gemini-class models. Hermes handles transparently inside the agent loop; Scarf has no UI surface yet but `hasVideoAnalyze` is reserved for future widget gating.
|
||||
- **`transform_llm_output` plugin hook** — plugin-author concern; surfaced indirectly through PluginsView when a plugin advertises the hook. `hasTransformLLMOutputHook` gates the metadata badge.
|
||||
- **Schema is unchanged from v0.11/v0.12** — same state.db columns. No migration needed.
|
||||
|
||||
**v2026.4.30 (v0.12.0)** added (Scarf-relevant subset):
|
||||
|
||||
**v2026.4.30 (v0.12.0)** added (Scarf-relevant subset):
|
||||
|
||||
@@ -153,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.
|
||||
|
||||
@@ -667,6 +667,27 @@ public struct HermesConfig: Sendable {
|
||||
/// useful for cost auditing and screen-recording demos.
|
||||
public var runtimeMetadataFooter: Bool
|
||||
|
||||
// -- 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
|
||||
public var terminal: TerminalSettings
|
||||
@@ -747,11 +768,15 @@ public struct HermesConfig: Sendable {
|
||||
homeAssistant: HomeAssistantSettings,
|
||||
cacheTTL: String = "5m",
|
||||
redactionEnabled: Bool = false,
|
||||
runtimeMetadataFooter: Bool = false
|
||||
runtimeMetadataFooter: Bool = false,
|
||||
imageGenModel: String = "",
|
||||
openrouterResponseCacheEnabled: Bool = false
|
||||
) {
|
||||
self.cacheTTL = cacheTTL
|
||||
self.redactionEnabled = redactionEnabled
|
||||
self.runtimeMetadataFooter = runtimeMetadataFooter
|
||||
self.imageGenModel = imageGenModel
|
||||
self.openrouterResponseCacheEnabled = openrouterResponseCacheEnabled
|
||||
self.model = model
|
||||
self.provider = provider
|
||||
self.maxTurns = maxTurns
|
||||
|
||||
@@ -284,7 +284,18 @@ public extension HermesConfig {
|
||||
homeAssistant: homeAssistant,
|
||||
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
|
||||
redactionEnabled: bool("redaction.enabled", default: false),
|
||||
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false)
|
||||
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false),
|
||||
// -- 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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,13 @@ import os
|
||||
///
|
||||
/// Scarf tracks Hermes feature releases by date-version + semver. v0.12 added
|
||||
/// a dozen surfaces (Curator, Kanban, multimodal ACP, ...) and removed a few
|
||||
/// (`flush_memories` aux task). UI that branches on these surfaces calls
|
||||
/// the boolean accessors here so older Hermes installs degrade silently
|
||||
/// instead of throwing on an unknown CLI subcommand.
|
||||
/// (`flush_memories` aux task); v0.13 added Persistent Goals, ACP `/queue`,
|
||||
/// Kanban diagnostics + recovery UX, Curator archive/prune, Google Chat (20th
|
||||
/// platform), cross-platform allowlists, MCP SSE transport, Cron `no_agent`
|
||||
/// mode, Web Tools per-capability backends, Profiles `--no-skills`, and a
|
||||
/// handful of UX additions. UI that branches on these surfaces calls the
|
||||
/// boolean accessors here so older Hermes installs degrade silently instead
|
||||
/// of throwing on an unknown CLI subcommand.
|
||||
///
|
||||
/// Pure value type — no side effects. The async detection lives in
|
||||
/// `HermesCapabilitiesStore`.
|
||||
@@ -45,8 +49,11 @@ public struct HermesCapabilities: Sendable, Equatable {
|
||||
// MARK: - Capability flags
|
||||
//
|
||||
// Add a new flag here when Scarf gains UI that conditionally branches on
|
||||
// a Hermes capability. Keep the comparison conservative: `>= 0.12.0`
|
||||
// covers users still on the 0.12 line who haven't upgraded to 0.13 yet.
|
||||
// a Hermes capability. Keep the comparison conservative: a flag introduced
|
||||
// in v0.13.0 should gate on `>= 0.13.0`, not `>= 0.13.5`, so users on
|
||||
// an early 0.13 patch still see the surface.
|
||||
|
||||
// MARK: v0.12 (v2026.4.30) flags
|
||||
|
||||
/// `hermes curator` autonomous skill maintenance (v0.12+).
|
||||
public var hasCurator: Bool { atLeastSemver(0, 12, 0) }
|
||||
@@ -96,9 +103,123 @@ public struct HermesCapabilities: Sendable, Equatable {
|
||||
public var hasPromptCacheTTL: Bool { atLeastSemver(0, 12, 0) }
|
||||
|
||||
/// `redaction.enabled` is now off by default in v0.12 — Scarf surfaces
|
||||
/// the toggle so users can flip it back on.
|
||||
/// the toggle so users can flip it back on. v0.13 flips the server-side
|
||||
/// default back to ON; the toggle remains so users on v0.13 can opt out.
|
||||
public var hasRedactionToggle: Bool { atLeastSemver(0, 12, 0) }
|
||||
|
||||
// MARK: v0.13 (v2026.5.7) flags
|
||||
|
||||
/// `/goal` slash command + Persistent Goals + Checkpoints v2 single-store
|
||||
/// (v0.13+). Used by RichChatViewModel to add `/goal` to the
|
||||
/// non-interruptive command list and to render the "Goal locked" pill in
|
||||
/// the chat header.
|
||||
public var hasGoals: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `/queue` slash command in the ACP adapter (v0.13+). Queues a prompt
|
||||
/// to run after the current turn completes without interrupting.
|
||||
public var hasACPQueue: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `/steer` runs as a regular prompt on idle ACP sessions (v0.13+). Pre-
|
||||
/// v0.13 hosts silently no-op `/steer` when no turn is in flight; with
|
||||
/// this flag on, Scarf can surface `/steer` even when the agent isn't
|
||||
/// mid-turn without confusing UX.
|
||||
public var hasACPSteerOnIdle: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Kanban v0.13 reliability surface: hallucination gate on worker-created
|
||||
/// cards, generic diagnostics engine, per-task `max_retries`, multiline
|
||||
/// title/body create, `auto_blocked_reason` on blocked tasks, darwin
|
||||
/// zombie detection. All read through the `kanban show` JSON surface.
|
||||
public var hasKanbanDiagnostics: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `hermes curator archive`, `prune`, and `list-archived` subcommands
|
||||
/// (v0.13+). The synchronous manual `hermes curator run` lives behind
|
||||
/// this flag too — pre-v0.13 `run` returns immediately and the work
|
||||
/// happens in the background.
|
||||
public var hasCuratorArchive: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Google Chat — 20th messaging-gateway platform (v0.13+).
|
||||
public var hasGoogleChatPlatform: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Cross-platform allowlist keys: `allowed_channels` (Slack / Mattermost
|
||||
/// / Google Chat), `allowed_chats` (Telegram / WhatsApp), `allowed_rooms`
|
||||
/// (Matrix / DingTalk). Settable per platform in `config.yaml` (v0.13+).
|
||||
public var hasGatewayAllowlists: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `busy_ack_enabled` config to suppress per-message "agent is working…"
|
||||
/// acks across platforms (v0.13+).
|
||||
public var hasGatewayBusyAckToggle: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Per-platform `gateway_restart_notification` flag controls whether the
|
||||
/// platform posts a "Gateway restarted" notice on boot (v0.13+).
|
||||
public var hasGatewayRestartNotification: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `hermes gateway list` cross-profile status verb (v0.13+). Lets Scarf
|
||||
/// show which profile is currently running which platform.
|
||||
public var hasGatewayList: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// MCP servers can use SSE transport (v0.13+). Adds an `sse_read_timeout`
|
||||
/// knob alongside the existing stdio/pipe transports.
|
||||
public var hasMCPSSETransport: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Cron `--no-agent` mode for script-only watchdog jobs (v0.13+). Skips
|
||||
/// the AI call entirely — useful for keep-alive / periodic-check jobs.
|
||||
public var hasCronNoAgent: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Web Tools split into per-capability backend selection: `web_search`
|
||||
/// and `web_extract` can now use distinct backends (v0.13+). SearXNG
|
||||
/// joined as a search-only backend.
|
||||
public var hasWebToolsBackendSplit: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `hermes profile create --no-skills` flag for empty profiles (v0.13+).
|
||||
public var hasProfileNoSkills: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// Context compression count surfaced in the status feed (v0.13+). Scarf
|
||||
/// renders it next to the token count in the chat status bar.
|
||||
public var hasContextCompressionCount: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `/new` slash command accepts an optional session-name argument (v0.13+).
|
||||
public var hasNewWithSessionName: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `hermes update --yes` / `-y` skips interactive prompts (v0.13+). Used
|
||||
/// by Scarf's "Update Hermes" affordance to run unattended.
|
||||
public var hasUpdateNonInteractive: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// OpenRouter response caching toggle in `config.yaml` (v0.13+).
|
||||
public var hasOpenRouterResponseCache: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `image_gen.model` honored from `config.yaml` (v0.13+). Pre-v0.13 the
|
||||
/// value was advertised but ignored at runtime.
|
||||
public var hasImageGenModel: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `display.language` config key for static-message translation: zh / ja /
|
||||
/// de / es / fr / uk / tr (v0.13+).
|
||||
public var hasDisplayLanguage: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// xAI Custom Voices — voice cloning support (v0.13+). Exposed in Scarf
|
||||
/// as a "Cloning supported" badge next to the xAI TTS provider entry.
|
||||
public var hasXAIVoiceCloning: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `video_analyze` tool — native video understanding on Gemini and
|
||||
/// compatible models (v0.13+). Hermes handles this transparently inside
|
||||
/// the agent loop; Scarf has no UI surface yet, but the flag lets future
|
||||
/// dashboards / activity views light up video-tool annotations.
|
||||
public var hasVideoAnalyze: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
/// `transform_llm_output` plugin hook for shaping LLM output before the
|
||||
/// conversation receives it (v0.13+). Plugin-author concern; Scarf's
|
||||
/// PluginsView surfaces it as a documented hook in plugin metadata.
|
||||
public var hasTransformLLMOutputHook: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
// MARK: Convenience predicates
|
||||
|
||||
/// Whether the connected host is on the v0.13 line or newer. Convenience
|
||||
/// for UI copy that needs to switch on the v0.12 → v0.13 boundary without
|
||||
/// proxying through a feature-specific flag (e.g. "v0.13 features active"
|
||||
/// badges, redaction default-state hints). Equivalent to any individual
|
||||
/// v0.13 flag; prefer this when the call site isn't actually about a
|
||||
/// specific feature.
|
||||
public var isV013OrLater: Bool { atLeastSemver(0, 13, 0) }
|
||||
|
||||
private func atLeastSemver(_ major: Int, _ minor: Int, _ patch: Int) -> Bool {
|
||||
guard let s = semver else { return false }
|
||||
return s >= SemVer(major: major, minor: minor, patch: patch)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -9,6 +9,13 @@ import Foundation
|
||||
|
||||
// MARK: - Version line parsing
|
||||
|
||||
@Test func parseV013ReleaseLine() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.13.0 (2026.5.7)")
|
||||
#expect(caps.semver == HermesCapabilities.SemVer(major: 0, minor: 13, patch: 0))
|
||||
#expect(caps.dateVersion == HermesCapabilities.DateVersion(year: 2026, month: 5, day: 7))
|
||||
#expect(caps.detected)
|
||||
}
|
||||
|
||||
@Test func parseV012ReleaseLine() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.12.0 (2026.4.30)")
|
||||
#expect(caps.semver == HermesCapabilities.SemVer(major: 0, minor: 12, patch: 0))
|
||||
@@ -75,8 +82,42 @@ import Foundation
|
||||
|
||||
// MARK: - Capability flags
|
||||
|
||||
@Test func v013FlagsAllOn() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.13.0 (2026.5.7)")
|
||||
// v0.12 surfaces remain on.
|
||||
#expect(caps.hasCurator)
|
||||
#expect(caps.hasKanban)
|
||||
#expect(caps.hasACPImagePrompts)
|
||||
#expect(!caps.hasFlushMemoriesAux)
|
||||
// v0.13 surfaces light up.
|
||||
#expect(caps.hasGoals)
|
||||
#expect(caps.hasACPQueue)
|
||||
#expect(caps.hasACPSteerOnIdle)
|
||||
#expect(caps.hasKanbanDiagnostics)
|
||||
#expect(caps.hasCuratorArchive)
|
||||
#expect(caps.hasGoogleChatPlatform)
|
||||
#expect(caps.hasGatewayAllowlists)
|
||||
#expect(caps.hasGatewayBusyAckToggle)
|
||||
#expect(caps.hasGatewayRestartNotification)
|
||||
#expect(caps.hasGatewayList)
|
||||
#expect(caps.hasMCPSSETransport)
|
||||
#expect(caps.hasCronNoAgent)
|
||||
#expect(caps.hasWebToolsBackendSplit)
|
||||
#expect(caps.hasProfileNoSkills)
|
||||
#expect(caps.hasContextCompressionCount)
|
||||
#expect(caps.hasNewWithSessionName)
|
||||
#expect(caps.hasUpdateNonInteractive)
|
||||
#expect(caps.hasOpenRouterResponseCache)
|
||||
#expect(caps.hasImageGenModel)
|
||||
#expect(caps.hasDisplayLanguage)
|
||||
#expect(caps.hasXAIVoiceCloning)
|
||||
#expect(caps.hasVideoAnalyze)
|
||||
#expect(caps.hasTransformLLMOutputHook)
|
||||
}
|
||||
|
||||
@Test func v012FlagsAllOn() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.12.0 (2026.4.30)")
|
||||
// v0.12 surfaces on.
|
||||
#expect(caps.hasCurator)
|
||||
#expect(caps.hasFallbackCommand)
|
||||
#expect(caps.hasKanban)
|
||||
@@ -94,6 +135,22 @@ import Foundation
|
||||
#expect(caps.hasRedactionToggle)
|
||||
// flush_memories was REMOVED in v0.12 — flag inverts.
|
||||
#expect(!caps.hasFlushMemoriesAux)
|
||||
// v0.13 surfaces stay off on a v0.12 host.
|
||||
#expect(!caps.hasGoals)
|
||||
#expect(!caps.hasACPQueue)
|
||||
#expect(!caps.hasKanbanDiagnostics)
|
||||
#expect(!caps.hasCuratorArchive)
|
||||
#expect(!caps.hasGoogleChatPlatform)
|
||||
#expect(!caps.hasGatewayAllowlists)
|
||||
#expect(!caps.hasMCPSSETransport)
|
||||
#expect(!caps.hasCronNoAgent)
|
||||
#expect(!caps.hasWebToolsBackendSplit)
|
||||
#expect(!caps.hasProfileNoSkills)
|
||||
#expect(!caps.hasContextCompressionCount)
|
||||
#expect(!caps.hasOpenRouterResponseCache)
|
||||
#expect(!caps.hasImageGenModel)
|
||||
#expect(!caps.hasDisplayLanguage)
|
||||
#expect(!caps.hasXAIVoiceCloning)
|
||||
}
|
||||
|
||||
@Test func v011FlagsAllOff() {
|
||||
@@ -126,11 +183,45 @@ import Foundation
|
||||
}
|
||||
|
||||
@Test func futureVersionRetainsCapabilities() {
|
||||
// A v0.13 (hypothetical) should still see all v0.12 capabilities on.
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.13.0 (2026.6.1)")
|
||||
// A v0.14 (hypothetical) should still see all v0.12 + v0.13 capabilities on.
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.14.0 (2026.7.1)")
|
||||
#expect(caps.hasCurator)
|
||||
#expect(caps.hasACPImagePrompts)
|
||||
#expect(caps.hasGoals)
|
||||
#expect(caps.hasKanbanDiagnostics)
|
||||
#expect(caps.hasCuratorArchive)
|
||||
// And flush_memories stays gone.
|
||||
#expect(!caps.hasFlushMemoriesAux)
|
||||
}
|
||||
|
||||
@Test func v0_13_patchReleaseStillEnablesAllFlags() {
|
||||
// A v0.13.4 patch release should still enable every v0.13 flag.
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.13.4 (2026.5.20)")
|
||||
#expect(caps.hasGoals)
|
||||
#expect(caps.hasACPQueue)
|
||||
#expect(caps.hasKanbanDiagnostics)
|
||||
#expect(caps.hasGoogleChatPlatform)
|
||||
}
|
||||
|
||||
// MARK: - isV013OrLater convenience predicate
|
||||
|
||||
@Test func isV013OrLater_v013HostTrue() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.13.0 (2026.5.7)")
|
||||
#expect(caps.isV013OrLater)
|
||||
}
|
||||
|
||||
@Test func isV013OrLater_v012HostFalse() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.12.0 (2026.4.30)")
|
||||
#expect(!caps.isV013OrLater)
|
||||
}
|
||||
|
||||
@Test func isV013OrLater_emptyFalse() {
|
||||
let caps = HermesCapabilities.empty
|
||||
#expect(!caps.isV013OrLater)
|
||||
}
|
||||
|
||||
@Test func isV013OrLater_v014HostTrue() {
|
||||
let caps = HermesCapabilities.parseLine("Hermes Agent v0.14.0 (2026.7.1)")
|
||||
#expect(caps.isV013OrLater)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -195,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") }
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user