mirror of
https://github.com/awizemann/scarf.git
synced 2026-05-10 18:44:45 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cedee04f2a |
@@ -666,18 +666,6 @@ public struct HermesConfig: Sendable {
|
|||||||
/// final reply (provider/model/cost/turn count). Off by default;
|
/// final reply (provider/model/cost/turn count). Off by default;
|
||||||
/// useful for cost auditing and screen-recording demos.
|
/// useful for cost auditing and screen-recording demos.
|
||||||
public var runtimeMetadataFooter: Bool
|
public var runtimeMetadataFooter: Bool
|
||||||
/// Pre-v0.13: single combined Web Tools backend at `web_tools.backend`.
|
|
||||||
/// v0.13 split this into per-capability keys (see below). Kept readable
|
|
||||||
/// for round-trip compatibility on hosts that never migrated; v0.13+
|
|
||||||
/// hosts ignore this scalar and read the split keys instead.
|
|
||||||
public var webToolsBackend: String
|
|
||||||
/// v0.13+: `web_tools.search.backend`. SearXNG is search-only and
|
|
||||||
/// can land here. Pre-v0.13 hosts default to the same value as the
|
|
||||||
/// combined backend.
|
|
||||||
public var webToolsSearchBackend: String
|
|
||||||
/// v0.13+: `web_tools.extract.backend`. Pre-v0.13 hosts default to
|
|
||||||
/// the same value as the combined backend.
|
|
||||||
public var webToolsExtractBackend: String
|
|
||||||
|
|
||||||
// Grouped blocks
|
// Grouped blocks
|
||||||
public var display: DisplaySettings
|
public var display: DisplaySettings
|
||||||
@@ -759,17 +747,11 @@ public struct HermesConfig: Sendable {
|
|||||||
homeAssistant: HomeAssistantSettings,
|
homeAssistant: HomeAssistantSettings,
|
||||||
cacheTTL: String = "5m",
|
cacheTTL: String = "5m",
|
||||||
redactionEnabled: Bool = false,
|
redactionEnabled: Bool = false,
|
||||||
runtimeMetadataFooter: Bool = false,
|
runtimeMetadataFooter: Bool = false
|
||||||
webToolsBackend: String = "duckduckgo",
|
|
||||||
webToolsSearchBackend: String = "duckduckgo",
|
|
||||||
webToolsExtractBackend: String = "reader"
|
|
||||||
) {
|
) {
|
||||||
self.cacheTTL = cacheTTL
|
self.cacheTTL = cacheTTL
|
||||||
self.redactionEnabled = redactionEnabled
|
self.redactionEnabled = redactionEnabled
|
||||||
self.runtimeMetadataFooter = runtimeMetadataFooter
|
self.runtimeMetadataFooter = runtimeMetadataFooter
|
||||||
self.webToolsBackend = webToolsBackend
|
|
||||||
self.webToolsSearchBackend = webToolsSearchBackend
|
|
||||||
self.webToolsExtractBackend = webToolsExtractBackend
|
|
||||||
self.model = model
|
self.model = model
|
||||||
self.provider = provider
|
self.provider = provider
|
||||||
self.maxTurns = maxTurns
|
self.maxTurns = maxTurns
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
/// job's prompt. YAML-only field today (no `--context-from` CLI
|
/// job's prompt. YAML-only field today (no `--context-from` CLI
|
||||||
/// flag yet) — Scarf displays it but doesn't write it.
|
/// flag yet) — Scarf displays it but doesn't write it.
|
||||||
public nonisolated let contextFrom: [String]?
|
public nonisolated let contextFrom: [String]?
|
||||||
/// Hermes v0.13+ — script-only watchdog mode. When `true` the
|
|
||||||
/// pre-run script runs but the AI turn is skipped. `nil` means the
|
|
||||||
/// jobs.json file is pre-v0.13 (treat as `false`); `false` is the
|
|
||||||
/// explicit v0.13+ default. Capability-gated on `hasCronNoAgent`
|
|
||||||
/// at all write call sites.
|
|
||||||
public nonisolated let noAgent: Bool?
|
|
||||||
|
|
||||||
public enum CodingKeys: String, CodingKey {
|
public enum CodingKeys: String, CodingKey {
|
||||||
case id, name, prompt, skills, model, schedule, enabled, state, deliver, silent
|
case id, name, prompt, skills, model, schedule, enabled, state, deliver, silent
|
||||||
@@ -47,7 +41,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
case timeoutSeconds = "timeout_seconds"
|
case timeoutSeconds = "timeout_seconds"
|
||||||
case workdir
|
case workdir
|
||||||
case contextFrom = "context_from"
|
case contextFrom = "context_from"
|
||||||
case noAgent = "no_agent"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Memberwise init. Swift doesn't synthesize one for us because
|
/// Memberwise init. Swift doesn't synthesize one for us because
|
||||||
@@ -73,8 +66,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
timeoutSeconds: Int? = nil,
|
timeoutSeconds: Int? = nil,
|
||||||
silent: Bool? = nil,
|
silent: Bool? = nil,
|
||||||
workdir: String? = nil,
|
workdir: String? = nil,
|
||||||
contextFrom: [String]? = nil,
|
contextFrom: [String]? = nil
|
||||||
noAgent: Bool? = nil
|
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -96,7 +88,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
self.silent = silent
|
self.silent = silent
|
||||||
self.workdir = workdir
|
self.workdir = workdir
|
||||||
self.contextFrom = contextFrom
|
self.contextFrom = contextFrom
|
||||||
self.noAgent = noAgent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public nonisolated init(from decoder: any Decoder) throws {
|
public nonisolated init(from decoder: any Decoder) throws {
|
||||||
@@ -121,7 +112,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
self.silent = try c.decodeIfPresent(Bool.self, forKey: .silent)
|
self.silent = try c.decodeIfPresent(Bool.self, forKey: .silent)
|
||||||
self.workdir = try c.decodeIfPresent(String.self, forKey: .workdir)
|
self.workdir = try c.decodeIfPresent(String.self, forKey: .workdir)
|
||||||
self.contextFrom = try c.decodeIfPresent([String].self, forKey: .contextFrom)
|
self.contextFrom = try c.decodeIfPresent([String].self, forKey: .contextFrom)
|
||||||
self.noAgent = try c.decodeIfPresent(Bool.self, forKey: .noAgent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public nonisolated func encode(to encoder: any Encoder) throws {
|
public nonisolated func encode(to encoder: any Encoder) throws {
|
||||||
@@ -146,7 +136,6 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
|
|||||||
try c.encodeIfPresent(silent, forKey: .silent)
|
try c.encodeIfPresent(silent, forKey: .silent)
|
||||||
try c.encodeIfPresent(workdir, forKey: .workdir)
|
try c.encodeIfPresent(workdir, forKey: .workdir)
|
||||||
try c.encodeIfPresent(contextFrom, forKey: .contextFrom)
|
try c.encodeIfPresent(contextFrom, forKey: .contextFrom)
|
||||||
try c.encodeIfPresent(noAgent, forKey: .noAgent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public nonisolated var stateIcon: String {
|
public nonisolated var stateIcon: String {
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// A structured signal Hermes emits when it observes worker / task
|
||||||
|
/// distress. Hermes v0.13 introduced a generic diagnostics engine that
|
||||||
|
/// attaches these to a task (cross-run signals) and/or a run (per-attempt
|
||||||
|
/// signals). Pre-v0.13 hosts never emit diagnostics so the array decodes
|
||||||
|
/// empty and downstream UI no-ops.
|
||||||
|
///
|
||||||
|
/// **Wire shape (best inference from release notes — verify against live
|
||||||
|
/// JSON during integration):** an array of objects with `kind`, optional
|
||||||
|
/// `message`, optional `detected_at` (ISO-8601 string OR Unix integer,
|
||||||
|
/// matching the rest of `HermesKanbanTask`'s timestamp tolerance).
|
||||||
|
///
|
||||||
|
/// **Forward compat:** `kind` stays a `String` so a future Hermes can
|
||||||
|
/// add new diagnostic kinds without a Scarf release. `KanbanDiagnosticKind`
|
||||||
|
/// is the typed mirror — it falls back to `.unknown` for unrecognized
|
||||||
|
/// kinds and renders the raw string verbatim.
|
||||||
|
public struct HermesKanbanDiagnostic: Sendable, Equatable, Identifiable, Codable {
|
||||||
|
/// Synthetic id — not on the wire. Lets SwiftUI `ForEach` over a
|
||||||
|
/// diagnostic array without forcing a deterministic id from the
|
||||||
|
/// server (Hermes doesn't currently mint one).
|
||||||
|
public let id: UUID
|
||||||
|
/// Wire-side `kind` string. Compared case-insensitively via
|
||||||
|
/// `KanbanDiagnosticKind.from(_:)`.
|
||||||
|
public let kind: String
|
||||||
|
/// Human-friendly elaboration ("no heartbeat for 4m20s", "exit code
|
||||||
|
/// 0 with no complete call", etc.). May be nil; render the raw
|
||||||
|
/// `kind` then.
|
||||||
|
public let message: String?
|
||||||
|
/// ISO-8601 string. Decoder accepts Unix integer seconds (Hermes's
|
||||||
|
/// SQLite-backed shape) and converts to ISO-8601 so consumers see
|
||||||
|
/// one type — same pattern as `HermesKanbanTask.decodeFlexibleTimestamp`.
|
||||||
|
public let detectedAt: String?
|
||||||
|
|
||||||
|
public init(
|
||||||
|
kind: String,
|
||||||
|
message: String? = nil,
|
||||||
|
detectedAt: String? = nil
|
||||||
|
) {
|
||||||
|
self.id = UUID()
|
||||||
|
self.kind = kind
|
||||||
|
self.message = message
|
||||||
|
self.detectedAt = detectedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case kind
|
||||||
|
case message
|
||||||
|
case detectedAt = "detected_at"
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(from decoder: any Decoder) throws {
|
||||||
|
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.id = UUID()
|
||||||
|
self.kind = try c.decodeIfPresent(String.self, forKey: .kind) ?? "unknown"
|
||||||
|
self.message = try c.decodeIfPresent(String.self, forKey: .message)
|
||||||
|
// Flexible timestamp decode mirrors HermesKanbanTask's pattern.
|
||||||
|
if !c.contains(.detectedAt) {
|
||||||
|
self.detectedAt = nil
|
||||||
|
} else if let unix = try? c.decodeIfPresent(Double.self, forKey: .detectedAt) {
|
||||||
|
let date = Date(timeIntervalSince1970: unix)
|
||||||
|
self.detectedAt = Self.isoFormatter.string(from: date)
|
||||||
|
} else {
|
||||||
|
self.detectedAt = try c.decodeIfPresent(String.self, forKey: .detectedAt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: any Encoder) throws {
|
||||||
|
var c = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try c.encode(kind, forKey: .kind)
|
||||||
|
try c.encodeIfPresent(message, forKey: .message)
|
||||||
|
try c.encodeIfPresent(detectedAt, forKey: .detectedAt)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func == (lhs: HermesKanbanDiagnostic, rhs: HermesKanbanDiagnostic) -> Bool {
|
||||||
|
// Compare on wire fields, not synthetic id — round-trip decoding
|
||||||
|
// mints fresh ids.
|
||||||
|
lhs.kind == rhs.kind
|
||||||
|
&& lhs.message == rhs.message
|
||||||
|
&& lhs.detectedAt == rhs.detectedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let isoFormatter: ISO8601DateFormatter = {
|
||||||
|
let f = ISO8601DateFormatter()
|
||||||
|
f.formatOptions = [.withInternetDateTime]
|
||||||
|
return f
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Typed mirror
|
||||||
|
|
||||||
|
/// Typed view of `HermesKanbanDiagnostic.kind`. Models keep the raw
|
||||||
|
/// string for forward compatibility; UI helpers read this enum to pick
|
||||||
|
/// the right glyph + tint without string-matching at every callsite.
|
||||||
|
///
|
||||||
|
/// `unknown` is the fallback for any kind a future Hermes adds that
|
||||||
|
/// Scarf doesn't recognize. Views render the raw string verbatim in
|
||||||
|
/// that case so the user still sees what Hermes flagged.
|
||||||
|
// TODO(WS-3-Q5): The exact `kind` string for darwin-zombie detection is
|
||||||
|
// inferred from the v0.13 release notes ("Detect darwin zombie workers");
|
||||||
|
// confirm against live `hermes kanban show --json` output during
|
||||||
|
// integration. Same for `worker_exit_no_complete` and the heartbeat-stalled
|
||||||
|
// kinds — typed mirror falls through to `.unknown` if the wire string
|
||||||
|
// drifts, and the raw string is still rendered.
|
||||||
|
public enum KanbanDiagnosticKind: String, Sendable, CaseIterable {
|
||||||
|
case heartbeatStalled = "heartbeat_stalled"
|
||||||
|
case toolErrorLoop = "tool_error_loop"
|
||||||
|
case retryCapHit = "retry_cap_hit"
|
||||||
|
case unboundedRetry = "unbounded_retry"
|
||||||
|
case darwinZombieDetected = "darwin_zombie_detected"
|
||||||
|
case spawnFailure = "spawn_failure"
|
||||||
|
case workerExitNoComplete = "worker_exit_no_complete"
|
||||||
|
case unknown
|
||||||
|
|
||||||
|
/// Map a wire string (case-insensitive) to a typed kind. Unknown
|
||||||
|
/// values fall through to `.unknown` so callers can still surface
|
||||||
|
/// the raw string.
|
||||||
|
public static func from(_ raw: String) -> KanbanDiagnosticKind {
|
||||||
|
KanbanDiagnosticKind(rawValue: raw.lowercased()) ?? .unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
/// SF Symbol name to render alongside the diagnostic. View code
|
||||||
|
/// reaches through the typed enum so glyph choices live in one
|
||||||
|
/// place.
|
||||||
|
public var glyphName: String {
|
||||||
|
switch self {
|
||||||
|
case .heartbeatStalled: return "waveform.path.badge.minus"
|
||||||
|
case .toolErrorLoop: return "arrow.triangle.2.circlepath.exclamationmark"
|
||||||
|
case .retryCapHit: return "nosign"
|
||||||
|
case .unboundedRetry: return "arrow.clockwise.circle.fill"
|
||||||
|
case .darwinZombieDetected: return "apple.logo"
|
||||||
|
case .spawnFailure: return "bolt.slash"
|
||||||
|
case .workerExitNoComplete: return "figure.walk.departure"
|
||||||
|
case .unknown: return "stethoscope"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Severity tier for this kind — drives badge tint. `.danger` for
|
||||||
|
/// terminal-class signals (retry cap hit, zombie, spawn failure);
|
||||||
|
/// `.warning` for recoverable signals (heartbeat stalled, tool
|
||||||
|
/// error loop); `.neutral` only for unknown / forward-compat kinds.
|
||||||
|
public var severity: DiagnosticSeverity {
|
||||||
|
switch self {
|
||||||
|
case .retryCapHit, .darwinZombieDetected, .spawnFailure:
|
||||||
|
return .danger
|
||||||
|
case .heartbeatStalled, .toolErrorLoop, .unboundedRetry, .workerExitNoComplete:
|
||||||
|
return .warning
|
||||||
|
case .unknown:
|
||||||
|
return .neutral
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DiagnosticSeverity: Sendable {
|
||||||
|
case warning
|
||||||
|
case danger
|
||||||
|
case neutral
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,19 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
|
|||||||
/// raw string so we don't lock the typed shape.
|
/// raw string so we don't lock the typed shape.
|
||||||
public let metadataJSON: String?
|
public let metadataJSON: String?
|
||||||
|
|
||||||
|
// v0.13 (v2026.5.7) fields. Both Optional / empty-default so a v0.12
|
||||||
|
// host's run row decodes without error.
|
||||||
|
/// Per-attempt distress signals. Cross-run signals (retry cap hit,
|
||||||
|
/// etc.) hang off `HermesKanbanTask.diagnostics`; in-flight signals
|
||||||
|
/// (heartbeat stalled, darwin zombie detected) attach here.
|
||||||
|
public let diagnostics: [HermesKanbanDiagnostic]
|
||||||
|
/// Server-side unified failure counter (renamed from three separate
|
||||||
|
/// spawn / timeout / crash counters in v0.13). Optional — when nil,
|
||||||
|
/// callers fall back to counting failed runs in the runs array.
|
||||||
|
// TODO(WS-3-Q4): Verify whether v0.13 exposes this field on the per-run
|
||||||
|
// shape OR only at the task level. Tolerant decode handles either.
|
||||||
|
public let failureCount: Int?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
id: Int,
|
id: Int,
|
||||||
taskId: String,
|
taskId: String,
|
||||||
@@ -40,7 +53,9 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
|
|||||||
outcome: String? = nil,
|
outcome: String? = nil,
|
||||||
summary: String? = nil,
|
summary: String? = nil,
|
||||||
error: String? = nil,
|
error: String? = nil,
|
||||||
metadataJSON: String? = nil
|
metadataJSON: String? = nil,
|
||||||
|
diagnostics: [HermesKanbanDiagnostic] = [],
|
||||||
|
failureCount: Int? = nil
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.taskId = taskId
|
self.taskId = taskId
|
||||||
@@ -58,6 +73,8 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
|
|||||||
self.summary = summary
|
self.summary = summary
|
||||||
self.error = error
|
self.error = error
|
||||||
self.metadataJSON = metadataJSON
|
self.metadataJSON = metadataJSON
|
||||||
|
self.diagnostics = diagnostics
|
||||||
|
self.failureCount = failureCount
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
@@ -77,6 +94,8 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
|
|||||||
case summary
|
case summary
|
||||||
case error
|
case error
|
||||||
case metadata
|
case metadata
|
||||||
|
case diagnostics
|
||||||
|
case failureCount = "failure_count"
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(from decoder: any Decoder) throws {
|
public init(from decoder: any Decoder) throws {
|
||||||
@@ -120,6 +139,11 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
|
|||||||
} else {
|
} else {
|
||||||
self.metadataJSON = nil
|
self.metadataJSON = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v0.13 diagnostics array — `try?` so a malformed entry doesn't
|
||||||
|
// poison the whole run row. Empty default for pre-v0.13 hosts.
|
||||||
|
self.diagnostics = (try? c.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .diagnostics)) ?? []
|
||||||
|
self.failureCount = try c.decodeIfPresent(Int.self, forKey: .failureCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: any Encoder) throws {
|
public func encode(to encoder: any Encoder) throws {
|
||||||
@@ -140,5 +164,7 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
|
|||||||
try c.encodeIfPresent(summary, forKey: .summary)
|
try c.encodeIfPresent(summary, forKey: .summary)
|
||||||
try c.encodeIfPresent(error, forKey: .error)
|
try c.encodeIfPresent(error, forKey: .error)
|
||||||
try c.encodeIfPresent(metadataJSON, forKey: .metadata)
|
try c.encodeIfPresent(metadataJSON, forKey: .metadata)
|
||||||
|
try c.encode(diagnostics, forKey: .diagnostics)
|
||||||
|
try c.encodeIfPresent(failureCount, forKey: .failureCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ import Foundation
|
|||||||
/// `link`/`unlink`, `comment`, `dispatch`).
|
/// `link`/`unlink`, `comment`, `dispatch`).
|
||||||
///
|
///
|
||||||
/// Hermes has no `update` verb — `priority` / `title` / `body` /
|
/// Hermes has no `update` verb — `priority` / `title` / `body` /
|
||||||
/// `tenant` are write-once at create time. Mutations after that are
|
/// `tenant` / `max_retries` are write-once at create time. Mutations
|
||||||
/// expressed as state transitions (status, assignee) or new comments.
|
/// after that are expressed as state transitions (status, assignee) or
|
||||||
|
/// new comments.
|
||||||
public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
||||||
public let id: String
|
public let id: String
|
||||||
public let title: String
|
public let title: String
|
||||||
@@ -34,6 +35,29 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
|||||||
public let maxRuntimeSeconds: Int?
|
public let maxRuntimeSeconds: Int?
|
||||||
public let currentRunId: Int?
|
public let currentRunId: Int?
|
||||||
|
|
||||||
|
// v0.13 (v2026.5.7) reliability + recovery fields. All Optional with
|
||||||
|
// `nil` decoded for pre-v0.13 hosts so the v2.7.5 surface keeps
|
||||||
|
// rendering unchanged when the connected Hermes hasn't shipped them.
|
||||||
|
/// Per-task retry budget set at create time via `--max-retries N`.
|
||||||
|
/// Hermes pattern is write-once — no `set_max_retries` verb. Scarf
|
||||||
|
/// surfaces this read-only on the inspector header.
|
||||||
|
public let maxRetries: Int?
|
||||||
|
/// Server-supplied reason a task was auto-blocked (e.g. "worker
|
||||||
|
/// exited (code 0) without calling `kanban complete`"). Surfaced
|
||||||
|
/// verbatim in the inspector banner.
|
||||||
|
public let autoBlockedReason: String?
|
||||||
|
/// `pending` / `verified` / `rejected` / nil. Pending means a worker
|
||||||
|
/// claimed it created this card but Hermes hasn't confirmed the
|
||||||
|
/// underlying work exists. Read through `KanbanHallucinationGate.from`
|
||||||
|
/// to map to a typed mirror — kept as a String at the wire level so
|
||||||
|
/// Hermes can add new gate states (e.g. `quarantined`) without a
|
||||||
|
/// Scarf release.
|
||||||
|
public let hallucinationGateStatus: String?
|
||||||
|
/// Cross-run distress signals (retry cap hit, etc.). Per-run signals
|
||||||
|
/// hang off `HermesKanbanRun.diagnostics`. Empty array for pre-v0.13
|
||||||
|
/// hosts AND for tasks the diagnostics engine hasn't flagged.
|
||||||
|
public let diagnostics: [HermesKanbanDiagnostic]
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
id: String,
|
id: String,
|
||||||
title: String,
|
title: String,
|
||||||
@@ -53,7 +77,11 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
|||||||
idempotencyKey: String? = nil,
|
idempotencyKey: String? = nil,
|
||||||
lastHeartbeatAt: String? = nil,
|
lastHeartbeatAt: String? = nil,
|
||||||
maxRuntimeSeconds: Int? = nil,
|
maxRuntimeSeconds: Int? = nil,
|
||||||
currentRunId: Int? = nil
|
currentRunId: Int? = nil,
|
||||||
|
maxRetries: Int? = nil,
|
||||||
|
autoBlockedReason: String? = nil,
|
||||||
|
hallucinationGateStatus: String? = nil,
|
||||||
|
diagnostics: [HermesKanbanDiagnostic] = []
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.title = title
|
self.title = title
|
||||||
@@ -74,6 +102,10 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
|||||||
self.lastHeartbeatAt = lastHeartbeatAt
|
self.lastHeartbeatAt = lastHeartbeatAt
|
||||||
self.maxRuntimeSeconds = maxRuntimeSeconds
|
self.maxRuntimeSeconds = maxRuntimeSeconds
|
||||||
self.currentRunId = currentRunId
|
self.currentRunId = currentRunId
|
||||||
|
self.maxRetries = maxRetries
|
||||||
|
self.autoBlockedReason = autoBlockedReason
|
||||||
|
self.hallucinationGateStatus = hallucinationGateStatus
|
||||||
|
self.diagnostics = diagnostics
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
@@ -89,6 +121,10 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
|||||||
case lastHeartbeatAt = "last_heartbeat_at"
|
case lastHeartbeatAt = "last_heartbeat_at"
|
||||||
case maxRuntimeSeconds = "max_runtime_seconds"
|
case maxRuntimeSeconds = "max_runtime_seconds"
|
||||||
case currentRunId = "current_run_id"
|
case currentRunId = "current_run_id"
|
||||||
|
case maxRetries = "max_retries"
|
||||||
|
case autoBlockedReason = "auto_blocked_reason"
|
||||||
|
case hallucinationGateStatus = "hallucination_gate_status"
|
||||||
|
case diagnostics
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(from decoder: any Decoder) throws {
|
public init(from decoder: any Decoder) throws {
|
||||||
@@ -117,6 +153,17 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
|
|||||||
self.lastHeartbeatAt = try Self.decodeFlexibleTimestamp(c, forKey: .lastHeartbeatAt)
|
self.lastHeartbeatAt = try Self.decodeFlexibleTimestamp(c, forKey: .lastHeartbeatAt)
|
||||||
self.maxRuntimeSeconds = try c.decodeIfPresent(Int.self, forKey: .maxRuntimeSeconds)
|
self.maxRuntimeSeconds = try c.decodeIfPresent(Int.self, forKey: .maxRuntimeSeconds)
|
||||||
self.currentRunId = try c.decodeIfPresent(Int.self, forKey: .currentRunId)
|
self.currentRunId = try c.decodeIfPresent(Int.self, forKey: .currentRunId)
|
||||||
|
// v0.13 fields — every one is `decodeIfPresent` so a v0.12 host's
|
||||||
|
// task row decodes successfully with these all nil/empty. The
|
||||||
|
// tolerant-decode contract is pinned by KanbanModelsTests.
|
||||||
|
self.maxRetries = try c.decodeIfPresent(Int.self, forKey: .maxRetries)
|
||||||
|
self.autoBlockedReason = try c.decodeIfPresent(String.self, forKey: .autoBlockedReason)
|
||||||
|
self.hallucinationGateStatus = try c.decodeIfPresent(String.self, forKey: .hallucinationGateStatus)
|
||||||
|
// Wrap diagnostics decode in `try?` so a single malformed entry
|
||||||
|
// (or the whole array being the wrong shape) doesn't poison the
|
||||||
|
// task row — the rest of the decoder still produces a usable
|
||||||
|
// task. Empty default matches the `skills` pattern.
|
||||||
|
self.diagnostics = (try? c.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .diagnostics)) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a timestamp that may arrive as a Unix integer or an
|
/// Decode a timestamp that may arrive as a Unix integer or an
|
||||||
@@ -209,3 +256,27 @@ public enum KanbanBoardColumn: String, Sendable, CaseIterable, Identifiable {
|
|||||||
.triage, .upNext, .running, .blocked, .done
|
.triage, .upNext, .running, .blocked, .done
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Hallucination gate (v0.13)
|
||||||
|
|
||||||
|
/// Typed mirror of Hermes v0.13's hallucination-gate state. Worker-created
|
||||||
|
/// cards land in `pending` until something verifies the underlying work
|
||||||
|
/// exists; Scarf surfaces a Verify / Reject UX above the task body so the
|
||||||
|
/// user can act as the verification gate.
|
||||||
|
///
|
||||||
|
/// Kept separate from `KanbanStatus` because hallucination state is
|
||||||
|
/// orthogonal to the lifecycle — a card can be `ready` *and* `pending`,
|
||||||
|
/// for example.
|
||||||
|
public enum KanbanHallucinationGate: String, Sendable, CaseIterable {
|
||||||
|
case pending
|
||||||
|
case verified
|
||||||
|
case rejected
|
||||||
|
|
||||||
|
/// Map a raw `hallucination_gate_status` string (case-insensitive) to
|
||||||
|
/// a typed gate. Returns nil for empty/nil/unknown values so callers
|
||||||
|
/// can short-circuit "no gate" branches with `if let gate = …`.
|
||||||
|
public static func from(_ raw: String?) -> KanbanHallucinationGate? {
|
||||||
|
guard let raw, !raw.isEmpty else { return nil }
|
||||||
|
return KanbanHallucinationGate(rawValue: raw.lowercased())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,17 +12,27 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
|
|||||||
/// to the worker as upstream context; surfacing them in the
|
/// to the worker as upstream context; surfacing them in the
|
||||||
/// inspector is useful for understanding why a task started.
|
/// inspector is useful for understanding why a task started.
|
||||||
public let parentResults: [String: String]
|
public let parentResults: [String: String]
|
||||||
|
/// Envelope-level diagnostics array (sibling to `task`, not nested
|
||||||
|
/// inside it). Defensive — Hermes v0.13's wire shape may attach
|
||||||
|
/// diagnostics to the task itself OR to the envelope.
|
||||||
|
/// `allDiagnostics` dedupes both sources by `(kind, detected_at)`.
|
||||||
|
// TODO(WS-3-Q2): Confirm against live `hermes kanban show --json`
|
||||||
|
// whether diagnostics live on the task envelope, the inner task, or
|
||||||
|
// both. Current decode is tolerant of either.
|
||||||
|
public let envelopeDiagnostics: [HermesKanbanDiagnostic]?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
task: HermesKanbanTask,
|
task: HermesKanbanTask,
|
||||||
comments: [HermesKanbanComment] = [],
|
comments: [HermesKanbanComment] = [],
|
||||||
events: [HermesKanbanEvent] = [],
|
events: [HermesKanbanEvent] = [],
|
||||||
parentResults: [String: String] = [:]
|
parentResults: [String: String] = [:],
|
||||||
|
envelopeDiagnostics: [HermesKanbanDiagnostic]? = nil
|
||||||
) {
|
) {
|
||||||
self.task = task
|
self.task = task
|
||||||
self.comments = comments
|
self.comments = comments
|
||||||
self.events = events
|
self.events = events
|
||||||
self.parentResults = parentResults
|
self.parentResults = parentResults
|
||||||
|
self.envelopeDiagnostics = envelopeDiagnostics
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
@@ -30,6 +40,7 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
|
|||||||
case comments
|
case comments
|
||||||
case events
|
case events
|
||||||
case parentResults = "parent_results"
|
case parentResults = "parent_results"
|
||||||
|
case envelopeDiagnostics = "diagnostics"
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(from decoder: any Decoder) throws {
|
public init(from decoder: any Decoder) throws {
|
||||||
@@ -48,6 +59,9 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
|
|||||||
self.comments = (try? container.decodeIfPresent([HermesKanbanComment].self, forKey: .comments)) ?? []
|
self.comments = (try? container.decodeIfPresent([HermesKanbanComment].self, forKey: .comments)) ?? []
|
||||||
self.events = (try? container.decodeIfPresent([HermesKanbanEvent].self, forKey: .events)) ?? []
|
self.events = (try? container.decodeIfPresent([HermesKanbanEvent].self, forKey: .events)) ?? []
|
||||||
self.parentResults = (try? container.decodeIfPresent([String: String].self, forKey: .parentResults)) ?? [:]
|
self.parentResults = (try? container.decodeIfPresent([String: String].self, forKey: .parentResults)) ?? [:]
|
||||||
|
// Same `try?` shield as the rest — a malformed envelope
|
||||||
|
// diagnostics array shouldn't reject the whole show response.
|
||||||
|
self.envelopeDiagnostics = try? container.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .envelopeDiagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: any Encoder) throws {
|
public func encode(to encoder: any Encoder) throws {
|
||||||
@@ -56,5 +70,20 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
|
|||||||
try c.encode(comments, forKey: .comments)
|
try c.encode(comments, forKey: .comments)
|
||||||
try c.encode(events, forKey: .events)
|
try c.encode(events, forKey: .events)
|
||||||
try c.encode(parentResults, forKey: .parentResults)
|
try c.encode(parentResults, forKey: .parentResults)
|
||||||
|
try c.encodeIfPresent(envelopeDiagnostics, forKey: .envelopeDiagnostics)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Unified diagnostics view for the inspector. Combines `task.diagnostics`
|
||||||
|
/// with envelope-level diagnostics (when present) and dedupes on the
|
||||||
|
/// `(kind, detectedAt)` tuple. Wire-side dupes are unlikely but cheap to
|
||||||
|
/// filter. Empty for pre-v0.13 hosts.
|
||||||
|
public var allDiagnostics: [HermesKanbanDiagnostic] {
|
||||||
|
let onTask = task.diagnostics
|
||||||
|
let onEnvelope = envelopeDiagnostics ?? []
|
||||||
|
var seen = Set<String>()
|
||||||
|
return (onTask + onEnvelope).filter { diag in
|
||||||
|
let key = "\(diag.kind)|\(diag.detectedAt ?? "")"
|
||||||
|
return seen.insert(key).inserted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import Foundation
|
|||||||
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
|
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
|
||||||
case stdio
|
case stdio
|
||||||
case http
|
case http
|
||||||
/// Server-Sent Events transport. Hermes v0.13+ only.
|
|
||||||
// TODO(WS-7-Q1): Verify Hermes uses the literal `sse` transport name
|
|
||||||
// (vs. `streamable-http`/`http-sse`/etc.) once a v0.13 host is on hand.
|
|
||||||
case sse
|
|
||||||
|
|
||||||
public var id: String { rawValue }
|
public var id: String { rawValue }
|
||||||
|
|
||||||
@@ -15,7 +11,6 @@ public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiabl
|
|||||||
switch self {
|
switch self {
|
||||||
case .stdio: return "Local (stdio)"
|
case .stdio: return "Local (stdio)"
|
||||||
case .http: return "Remote (HTTP)"
|
case .http: return "Remote (HTTP)"
|
||||||
case .sse: return "Remote (SSE)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -38,12 +33,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
public let resourcesEnabled: Bool
|
public let resourcesEnabled: Bool
|
||||||
public let promptsEnabled: Bool
|
public let promptsEnabled: Bool
|
||||||
public let hasOAuthToken: Bool
|
public let hasOAuthToken: Bool
|
||||||
/// Hermes-side keepalive interval (seconds) for SSE transport. `nil`
|
|
||||||
/// when the YAML doesn't specify `sse_read_timeout` (Hermes default
|
|
||||||
/// applies). Pre-v0.13 hosts always have this as `nil`.
|
|
||||||
// TODO(WS-7-Q2): Default is assumed to be 300s per WS-7 plan; placeholder
|
|
||||||
// copy uses that. Verify against `~/.hermes/hermes-agent/hermes_cli/mcp.py`.
|
|
||||||
public let sseReadTimeout: Int?
|
|
||||||
|
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
@@ -62,8 +51,7 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
toolsExclude: [String],
|
toolsExclude: [String],
|
||||||
resourcesEnabled: Bool,
|
resourcesEnabled: Bool,
|
||||||
promptsEnabled: Bool,
|
promptsEnabled: Bool,
|
||||||
hasOAuthToken: Bool,
|
hasOAuthToken: Bool
|
||||||
sseReadTimeout: Int? = nil
|
|
||||||
) {
|
) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.transport = transport
|
self.transport = transport
|
||||||
@@ -81,7 +69,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
self.resourcesEnabled = resourcesEnabled
|
self.resourcesEnabled = resourcesEnabled
|
||||||
self.promptsEnabled = promptsEnabled
|
self.promptsEnabled = promptsEnabled
|
||||||
self.hasOAuthToken = hasOAuthToken
|
self.hasOAuthToken = hasOAuthToken
|
||||||
self.sseReadTimeout = sseReadTimeout
|
|
||||||
}
|
}
|
||||||
public var id: String { name }
|
public var id: String { name }
|
||||||
|
|
||||||
@@ -92,8 +79,6 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
|
|||||||
return (command ?? "") + argString
|
return (command ?? "") + argString
|
||||||
case .http:
|
case .http:
|
||||||
return url ?? ""
|
return url ?? ""
|
||||||
case .sse:
|
|
||||||
return url ?? ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ public struct KanbanCreateRequest: Sendable, Equatable {
|
|||||||
public var maxRuntimeSeconds: Int?
|
public var maxRuntimeSeconds: Int?
|
||||||
public var createdBy: String?
|
public var createdBy: String?
|
||||||
public var skills: [String]
|
public var skills: [String]
|
||||||
|
/// v0.13: per-task retry budget. `--max-retries N` is write-once at
|
||||||
|
/// create time — no `set_max_retries` verb. Pass `nil` to let Hermes
|
||||||
|
/// pick its built-in default (3 as of v0.13.0). Capability-gated in
|
||||||
|
/// the create sheet on `hasKanbanDiagnostics`.
|
||||||
|
// TODO(WS-3-Q6): Confirm Hermes's global default for `max_retries`
|
||||||
|
// (v0.13 release notes don't enumerate it). The create sheet defaults
|
||||||
|
// the field to 3; if Hermes config exposes a different default, mirror
|
||||||
|
// it.
|
||||||
|
public var maxRetries: Int?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
title: String,
|
title: String,
|
||||||
@@ -30,7 +39,8 @@ public struct KanbanCreateRequest: Sendable, Equatable {
|
|||||||
idempotencyKey: String? = nil,
|
idempotencyKey: String? = nil,
|
||||||
maxRuntimeSeconds: Int? = nil,
|
maxRuntimeSeconds: Int? = nil,
|
||||||
createdBy: String? = nil,
|
createdBy: String? = nil,
|
||||||
skills: [String] = []
|
skills: [String] = [],
|
||||||
|
maxRetries: Int? = nil
|
||||||
) {
|
) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.body = body
|
self.body = body
|
||||||
@@ -44,6 +54,7 @@ public struct KanbanCreateRequest: Sendable, Equatable {
|
|||||||
self.maxRuntimeSeconds = maxRuntimeSeconds
|
self.maxRuntimeSeconds = maxRuntimeSeconds
|
||||||
self.createdBy = createdBy
|
self.createdBy = createdBy
|
||||||
self.skills = skills
|
self.skills = skills
|
||||||
|
self.maxRetries = maxRetries
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the argv suffix this request maps to (everything after
|
/// Build the argv suffix this request maps to (everything after
|
||||||
@@ -78,6 +89,9 @@ public struct KanbanCreateRequest: Sendable, Equatable {
|
|||||||
if let maxRuntimeSeconds {
|
if let maxRuntimeSeconds {
|
||||||
args.append(contentsOf: ["--max-runtime", "\(maxRuntimeSeconds)s"])
|
args.append(contentsOf: ["--max-runtime", "\(maxRuntimeSeconds)s"])
|
||||||
}
|
}
|
||||||
|
if let maxRetries {
|
||||||
|
args.append(contentsOf: ["--max-retries", String(maxRetries)])
|
||||||
|
}
|
||||||
if let createdBy, !createdBy.isEmpty {
|
if let createdBy, !createdBy.isEmpty {
|
||||||
args.append(contentsOf: ["--created-by", createdBy])
|
args.append(contentsOf: ["--created-by", createdBy])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,14 +284,7 @@ public extension HermesConfig {
|
|||||||
homeAssistant: homeAssistant,
|
homeAssistant: homeAssistant,
|
||||||
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
|
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
|
||||||
redactionEnabled: bool("redaction.enabled", default: false),
|
redactionEnabled: bool("redaction.enabled", default: false),
|
||||||
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false),
|
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false)
|
||||||
// Pre-v0.13 hosts wrote a single `web_tools.backend`. v0.13 split
|
|
||||||
// it into per-capability keys. Read all three so the round-trip
|
|
||||||
// never loses a value the user already set; the WebTools tab
|
|
||||||
// chooses which to render based on `hasWebToolsBackendSplit`.
|
|
||||||
webToolsBackend: str("web_tools.backend", default: "duckduckgo"),
|
|
||||||
webToolsSearchBackend: str("web_tools.search.backend", default: "duckduckgo"),
|
|
||||||
webToolsExtractBackend: str("web_tools.extract.backend", default: "reader")
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,6 +321,61 @@ public actor KanbanService {
|
|||||||
try ensureSuccess(code: code, stdout: "", stderr: stderr, verb: "unlink")
|
try ensureSuccess(code: code, stdout: "", stderr: stderr, verb: "unlink")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Hallucination gate (v0.13)
|
||||||
|
|
||||||
|
/// Mark a worker-created card as user-verified — flips
|
||||||
|
/// `hallucination_gate_status` from `pending` to `verified` so the
|
||||||
|
/// dispatcher can pick it up. The polling loop picks up the new
|
||||||
|
/// state on the next tick (and the VM optimistically clears the
|
||||||
|
/// pending banner immediately on the click).
|
||||||
|
///
|
||||||
|
/// **Pre-v0.13 hosts:** the verb doesn't exist; callers MUST gate
|
||||||
|
/// on `HermesCapabilities.hasKanbanDiagnostics` before invoking this.
|
||||||
|
/// A pre-v0.13 binary will surface the failure as
|
||||||
|
/// `KanbanError.nonZeroExit` with stderr containing "unknown command".
|
||||||
|
// TODO(WS-3-Q1): Confirm the exact CLI verb name for the
|
||||||
|
// hallucination-gate verify path against a v0.13 binary (`hermes
|
||||||
|
// kanban --help`). The v0.13 release notes describe "hallucination
|
||||||
|
// gate + recovery UX" but don't enumerate the verb name. This
|
||||||
|
// implementation assumes `hermes kanban verify <id>`. If Hermes ships
|
||||||
|
// it as `hermes kanban gate verify <id>`, `hermes kanban hallucination
|
||||||
|
// verify <id>`, or another name, update the args here. The Reject
|
||||||
|
// path does NOT depend on this verb (it routes through
|
||||||
|
// `archive` + a comment), so the recovery UX stays functional even
|
||||||
|
// if Verify is a stub for an early v0.13.x.
|
||||||
|
public func verify(taskId: String) async throws {
|
||||||
|
let args = ["kanban", "verify", taskId]
|
||||||
|
let (code, _, stderr) = await runHermes(args: args, timeout: 15)
|
||||||
|
try ensureSuccess(code: code, stdout: "", stderr: stderr, verb: "verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reject a worker-created card as a hallucinated reference. There
|
||||||
|
/// is no dedicated `kanban reject` verb in v0.13; the right action
|
||||||
|
/// per the v0.13 release notes is to archive the card (the work
|
||||||
|
/// doesn't exist) with a comment recording the rejection reason for
|
||||||
|
/// the audit trail. Routing this through the existing `comment` +
|
||||||
|
/// `archive` verbs keeps the wire shape stable across versions.
|
||||||
|
///
|
||||||
|
/// If a future Hermes adds a dedicated `kanban reject` verb, swap
|
||||||
|
/// the body here — the public surface stays "reject" returning Void.
|
||||||
|
public func rejectHallucinated(taskId: String) async throws {
|
||||||
|
// Best-effort comment first so the audit trail records the
|
||||||
|
// rejection. A failure here shouldn't block the archive — log
|
||||||
|
// and continue.
|
||||||
|
do {
|
||||||
|
try await comment(
|
||||||
|
taskId: taskId,
|
||||||
|
text: "Rejected as hallucinated (no underlying work).",
|
||||||
|
author: nil
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
#if canImport(os)
|
||||||
|
Self.logger.warning("kanban reject: comment failed, proceeding to archive (\(error.localizedDescription, privacy: .public))")
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
try await archive(taskIds: [taskId])
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Drag-drop transition mapper
|
// MARK: - Drag-drop transition mapper
|
||||||
|
|
||||||
/// Map a board-level column transition to the right Hermes verb call.
|
/// Map a board-level column transition to the right Hermes verb call.
|
||||||
|
|||||||
@@ -327,4 +327,196 @@ import Foundation
|
|||||||
#expect(stats.glanceString.isEmpty)
|
#expect(stats.glanceString.isEmpty)
|
||||||
#expect(stats.activeCount == 0)
|
#expect(stats.activeCount == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - v0.13 (Hermes 2026.5.7) tolerant decode
|
||||||
|
//
|
||||||
|
// The contract these tests pin: a v0.13 host's task / run / detail
|
||||||
|
// JSON decodes successfully WITH the new fields populated, AND a
|
||||||
|
// pre-v0.13 (v0.12) host's task / run / detail JSON decodes
|
||||||
|
// successfully WITHOUT the new fields (everything resolves to nil
|
||||||
|
// or empty). Drift from this pair = a regression that bites every
|
||||||
|
// user not yet on Hermes v0.13.
|
||||||
|
|
||||||
|
@Test func decodeV013TaskFields() throws {
|
||||||
|
let json = """
|
||||||
|
{
|
||||||
|
"id": "t_v013",
|
||||||
|
"title": "v0.13 task",
|
||||||
|
"status": "blocked",
|
||||||
|
"max_retries": 5,
|
||||||
|
"auto_blocked_reason": "worker exited without `kanban complete`",
|
||||||
|
"hallucination_gate_status": "pending",
|
||||||
|
"diagnostics": [
|
||||||
|
{"kind": "worker_exit_no_complete", "message": "exit code 0 with no complete call", "detected_at": 1778160614},
|
||||||
|
{"kind": "darwin_zombie_detected", "detected_at": "2026-05-09T12:00:00Z"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
|
||||||
|
#expect(task.maxRetries == 5)
|
||||||
|
#expect(task.autoBlockedReason?.contains("kanban complete") == true)
|
||||||
|
#expect(task.hallucinationGateStatus == "pending")
|
||||||
|
#expect(task.diagnostics.count == 2)
|
||||||
|
#expect(task.diagnostics.first?.kind == "worker_exit_no_complete")
|
||||||
|
#expect(task.diagnostics.last?.detectedAt?.contains("2026") == true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func decodeV012TaskHasNoNewFields() throws {
|
||||||
|
// The most damaging failure mode is a v0.12 user upgrading Scarf
|
||||||
|
// and having the board stop loading because a v0.13-only field
|
||||||
|
// is required. Pin the contract.
|
||||||
|
let json = """
|
||||||
|
{"id": "t_legacy", "title": "v0.12 task", "status": "ready"}
|
||||||
|
"""
|
||||||
|
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
|
||||||
|
#expect(task.maxRetries == nil)
|
||||||
|
#expect(task.autoBlockedReason == nil)
|
||||||
|
#expect(task.hallucinationGateStatus == nil)
|
||||||
|
#expect(task.diagnostics.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func decodeMalformedDiagnosticTolerated() throws {
|
||||||
|
// If Hermes emits a malformed diagnostics value, the rest of the
|
||||||
|
// task should still decode. We use try? on the diagnostics decode
|
||||||
|
// so a single bad entry doesn't reject the whole row.
|
||||||
|
let json = """
|
||||||
|
{
|
||||||
|
"id": "t_x",
|
||||||
|
"title": "x",
|
||||||
|
"status": "ready",
|
||||||
|
"diagnostics": "not-an-array"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
|
||||||
|
#expect(task.id == "t_x")
|
||||||
|
// Diagnostics field couldn't decode — treat as empty.
|
||||||
|
#expect(task.diagnostics.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func hallucinationGateMirrorMapsKnownValues() {
|
||||||
|
#expect(KanbanHallucinationGate.from("pending") == .pending)
|
||||||
|
#expect(KanbanHallucinationGate.from("verified") == .verified)
|
||||||
|
#expect(KanbanHallucinationGate.from("REJECTED") == .rejected) // case-insensitive
|
||||||
|
#expect(KanbanHallucinationGate.from(nil) == nil)
|
||||||
|
#expect(KanbanHallucinationGate.from("") == nil)
|
||||||
|
// Unknown wire values fall through to nil so the banner stays
|
||||||
|
// hidden; future Hermes versions can add `quarantined` etc.
|
||||||
|
// without a Scarf release.
|
||||||
|
#expect(KanbanHallucinationGate.from("quarantined") == nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func diagnosticKindMirrorMapsKnownValues() {
|
||||||
|
#expect(KanbanDiagnosticKind.from("heartbeat_stalled") == .heartbeatStalled)
|
||||||
|
#expect(KanbanDiagnosticKind.from("DARWIN_ZOMBIE_DETECTED") == .darwinZombieDetected)
|
||||||
|
// Unknown kinds fall through to .unknown so views can render
|
||||||
|
// the raw string verbatim.
|
||||||
|
#expect(KanbanDiagnosticKind.from("future_kind_v014") == .unknown)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func diagnosticSeverityMapping() {
|
||||||
|
#expect(KanbanDiagnosticKind.retryCapHit.severity == .danger)
|
||||||
|
#expect(KanbanDiagnosticKind.darwinZombieDetected.severity == .danger)
|
||||||
|
#expect(KanbanDiagnosticKind.heartbeatStalled.severity == .warning)
|
||||||
|
#expect(KanbanDiagnosticKind.workerExitNoComplete.severity == .warning)
|
||||||
|
#expect(KanbanDiagnosticKind.unknown.severity == .neutral)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func createRequestArgvIncludesMaxRetries() {
|
||||||
|
let req = KanbanCreateRequest(title: "t", maxRetries: 5)
|
||||||
|
let argv = req.argv()
|
||||||
|
#expect(argv.contains("--max-retries"))
|
||||||
|
#expect(argv.contains("5"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func createRequestArgvOmitsMaxRetriesWhenAbsent() {
|
||||||
|
let req = KanbanCreateRequest(title: "t")
|
||||||
|
let argv = req.argv()
|
||||||
|
#expect(!argv.contains("--max-retries"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func decodeRunWithDiagnostics() throws {
|
||||||
|
let json = """
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"task_id": "t_x",
|
||||||
|
"status": "failed",
|
||||||
|
"started_at": 1778160000,
|
||||||
|
"ended_at": 1778160300,
|
||||||
|
"outcome": "crashed",
|
||||||
|
"error": "OOM",
|
||||||
|
"diagnostics": [
|
||||||
|
{"kind": "retry_cap_hit", "message": "3/3 retries exhausted"}
|
||||||
|
],
|
||||||
|
"failure_count": 3
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
let run = try JSONDecoder().decode(HermesKanbanRun.self, from: Data(json.utf8))
|
||||||
|
#expect(run.diagnostics.count == 1)
|
||||||
|
#expect(run.diagnostics.first?.kind == "retry_cap_hit")
|
||||||
|
#expect(run.failureCount == 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func decodeRunWithoutDiagnostics() throws {
|
||||||
|
// v0.12 run row — no diagnostics, no failure_count, must still
|
||||||
|
// decode cleanly.
|
||||||
|
let json = """
|
||||||
|
{"id": 1, "task_id": "t_x", "status": "running", "started_at": 1778160000}
|
||||||
|
"""
|
||||||
|
let run = try JSONDecoder().decode(HermesKanbanRun.self, from: Data(json.utf8))
|
||||||
|
#expect(run.diagnostics.isEmpty)
|
||||||
|
#expect(run.failureCount == nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func taskDetailMergesEnvelopeAndTaskDiagnostics() throws {
|
||||||
|
// Hermes's wire shape may put diagnostics on the task envelope OR
|
||||||
|
// on the inner task. `allDiagnostics` dedupes by (kind, detected_at)
|
||||||
|
// so a server emitting both sides doesn't surface dupes.
|
||||||
|
let json = """
|
||||||
|
{
|
||||||
|
"task": {
|
||||||
|
"id": "t_y",
|
||||||
|
"title": "y",
|
||||||
|
"status": "blocked",
|
||||||
|
"diagnostics": [
|
||||||
|
{"kind": "heartbeat_stalled", "detected_at": "2026-05-09T12:00:00Z"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"comments": [],
|
||||||
|
"events": [],
|
||||||
|
"diagnostics": [
|
||||||
|
{"kind": "heartbeat_stalled", "detected_at": "2026-05-09T12:00:00Z"},
|
||||||
|
{"kind": "retry_cap_hit"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
let detail = try JSONDecoder().decode(HermesKanbanTaskDetail.self, from: Data(json.utf8))
|
||||||
|
let merged = detail.allDiagnostics
|
||||||
|
#expect(merged.count == 2)
|
||||||
|
#expect(merged.contains(where: { $0.kind == "heartbeat_stalled" }))
|
||||||
|
#expect(merged.contains(where: { $0.kind == "retry_cap_hit" }))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func taskDetailWithoutEnvelopeDiagnosticsDecodes() throws {
|
||||||
|
// Pre-v0.13 task detail — no envelope diagnostics. Must decode.
|
||||||
|
let json = """
|
||||||
|
{
|
||||||
|
"task": {"id": "t_z", "title": "z", "status": "ready"},
|
||||||
|
"comments": [],
|
||||||
|
"events": []
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
let detail = try JSONDecoder().decode(HermesKanbanTaskDetail.self, from: Data(json.utf8))
|
||||||
|
#expect(detail.envelopeDiagnostics == nil)
|
||||||
|
#expect(detail.allDiagnostics.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func diagnosticDecodesUnixTimestamp() throws {
|
||||||
|
let json = """
|
||||||
|
{"kind": "spawn_failure", "detected_at": 1778160614}
|
||||||
|
"""
|
||||||
|
let diag = try JSONDecoder().decode(HermesKanbanDiagnostic.self, from: Data(json.utf8))
|
||||||
|
#expect(diag.kind == "spawn_failure")
|
||||||
|
// Decoder normalizes Unix int → ISO-8601 string.
|
||||||
|
#expect(diag.detectedAt?.contains("2026") == true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -599,8 +599,7 @@ struct HermesFileService: Sendable {
|
|||||||
toolsExclude: server.toolsExclude,
|
toolsExclude: server.toolsExclude,
|
||||||
resourcesEnabled: server.resourcesEnabled,
|
resourcesEnabled: server.resourcesEnabled,
|
||||||
promptsEnabled: server.promptsEnabled,
|
promptsEnabled: server.promptsEnabled,
|
||||||
hasOAuthToken: hasToken,
|
hasOAuthToken: hasToken
|
||||||
sseReadTimeout: server.sseReadTimeout
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -631,37 +630,6 @@ struct HermesFileService: Sendable {
|
|||||||
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
|
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an SSE-transport MCP server. v0.13+ only — caller is responsible
|
|
||||||
/// for capability-gating; pre-v0.13 hosts will reject the `--transport`
|
|
||||||
/// flag at argparse time. The optional `sseReadTimeout` is passed via
|
|
||||||
/// `--sse-read-timeout <int>` and persisted as `sse_read_timeout: <int>`
|
|
||||||
/// in the YAML entry.
|
|
||||||
// TODO(WS-7-Q3): Verify exact CLI flag spelling against `hermes mcp add --help`
|
|
||||||
// on a v0.13 install. Plan assumes `--transport sse` + `--sse-read-timeout`;
|
|
||||||
// alternatives could be `--sse` (boolean) + `--read-timeout`.
|
|
||||||
@discardableResult
|
|
||||||
nonisolated func addMCPServerSSE(name: String, url: String, sseReadTimeout: Int?) -> (exitCode: Int32, output: String) {
|
|
||||||
var cliArgs: [String] = ["mcp", "add", name, "--url", url, "--transport", "sse"]
|
|
||||||
if let timeout = sseReadTimeout {
|
|
||||||
cliArgs.append(contentsOf: ["--sse-read-timeout", String(timeout)])
|
|
||||||
}
|
|
||||||
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Updates the `sse_read_timeout` scalar in-place via the same surgical
|
|
||||||
/// patcher used by `setMCPServerTimeouts`. Pass `nil` to remove the
|
|
||||||
/// scalar entirely (Hermes default applies).
|
|
||||||
@discardableResult
|
|
||||||
nonisolated func setMCPServerSSETimeout(name: String, sseReadTimeout: Int?) -> Bool {
|
|
||||||
patchMCPServerField(name: name) { entryLines in
|
|
||||||
if let timeout = sseReadTimeout {
|
|
||||||
Self.replaceOrInsertScalar(key: "sse_read_timeout", value: String(timeout), in: &entryLines)
|
|
||||||
} else {
|
|
||||||
Self.removeScalar(key: "sse_read_timeout", in: &entryLines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool {
|
nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool {
|
||||||
patchMCPServerField(name: name) { entryLines in
|
patchMCPServerField(name: name) { entryLines in
|
||||||
@@ -844,23 +812,11 @@ struct HermesFileService: Sendable {
|
|||||||
|
|
||||||
func flush() {
|
func flush() {
|
||||||
guard let name = currentName else { return }
|
guard let name = currentName else { return }
|
||||||
// 3-way transport discriminator: an explicit `transport: sse` scalar
|
let transport: MCPTransport = fields["url"] != nil ? .http : .stdio
|
||||||
// wins (Hermes v0.13+ emits it for SSE servers); otherwise URL-bearing
|
|
||||||
// entries fall back to .http (v0.12 shape) and command-bearing entries
|
|
||||||
// to .stdio. This preserves byte-for-byte round-trip on existing files
|
|
||||||
// — pre-v0.13 entries have no `transport:` key so they parse identically.
|
|
||||||
// TODO(WS-7-Q1): Verify Hermes v0.13 actually emits `transport: sse`
|
|
||||||
// (vs. inferring from the schema/url shape) once a v0.13 host is on hand.
|
|
||||||
let transport: MCPTransport = {
|
|
||||||
if fields["transport"]?.lowercased() == "sse" { return .sse }
|
|
||||||
if fields["url"] != nil { return .http }
|
|
||||||
return .stdio
|
|
||||||
}()
|
|
||||||
let enabledStr = fields["enabled"]?.lowercased()
|
let enabledStr = fields["enabled"]?.lowercased()
|
||||||
let enabled = enabledStr != "false"
|
let enabled = enabledStr != "false"
|
||||||
let timeout = fields["timeout"].flatMap(Int.init)
|
let timeout = fields["timeout"].flatMap(Int.init)
|
||||||
let connectTimeout = fields["connect_timeout"].flatMap(Int.init)
|
let connectTimeout = fields["connect_timeout"].flatMap(Int.init)
|
||||||
let sseReadTimeout = fields["sse_read_timeout"].flatMap(Int.init)
|
|
||||||
let server = HermesMCPServer(
|
let server = HermesMCPServer(
|
||||||
name: name,
|
name: name,
|
||||||
transport: transport,
|
transport: transport,
|
||||||
@@ -877,8 +833,7 @@ struct HermesFileService: Sendable {
|
|||||||
toolsExclude: excludeList,
|
toolsExclude: excludeList,
|
||||||
resourcesEnabled: resources,
|
resourcesEnabled: resources,
|
||||||
promptsEnabled: prompts,
|
promptsEnabled: prompts,
|
||||||
hasOAuthToken: false,
|
hasOAuthToken: false
|
||||||
sseReadTimeout: sseReadTimeout
|
|
||||||
)
|
)
|
||||||
servers.append(server)
|
servers.append(server)
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ final class CronViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "", noAgent: Bool = false) {
|
func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "") {
|
||||||
var args = ["cron", "create"]
|
var args = ["cron", "create"]
|
||||||
if !name.isEmpty { args += ["--name", name] }
|
if !name.isEmpty { args += ["--name", name] }
|
||||||
if !deliver.isEmpty { args += ["--deliver", deliver] }
|
if !deliver.isEmpty { args += ["--deliver", deliver] }
|
||||||
@@ -158,25 +158,12 @@ final class CronViewModel {
|
|||||||
// know the flag — argparse rejects unknown args, so the form
|
// know the flag — argparse rejects unknown args, so the form
|
||||||
// omits the flag when the field is empty.
|
// omits the flag when the field is empty.
|
||||||
if !workdir.isEmpty { args += ["--workdir", workdir] }
|
if !workdir.isEmpty { args += ["--workdir", workdir] }
|
||||||
// v0.13+: --no-agent runs the pre-run script and skips the AI turn.
|
|
||||||
// Caller (CronView) strips this on pre-v0.13 hosts so the flag is
|
|
||||||
// never emitted to a Hermes that can't parse it.
|
|
||||||
if noAgent { args.append("--no-agent") }
|
|
||||||
args.append(schedule)
|
args.append(schedule)
|
||||||
// TODO(WS-7-Q5): When --no-agent is set Hermes ignores the prompt arg,
|
if !prompt.isEmpty { args.append(prompt) }
|
||||||
// but argparse still wants positional args to line up with the
|
|
||||||
// schedule. The plan recommends passing an empty string explicitly so
|
|
||||||
// the positional parser doesn't treat the prompt as missing — verify
|
|
||||||
// this behaviour against `hermes cron create --help` on a v0.13 host.
|
|
||||||
if noAgent {
|
|
||||||
args.append("")
|
|
||||||
} else if !prompt.isEmpty {
|
|
||||||
args.append(prompt)
|
|
||||||
}
|
|
||||||
runAndReload(args, success: "Job created")
|
runAndReload(args, success: "Job created")
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateJob(id: String, schedule: String?, prompt: String?, name: String?, deliver: String?, repeatCount: String?, newSkills: [String]?, clearSkills: Bool, script: String?, workdir: String? = nil, noAgent: Bool? = nil) {
|
func updateJob(id: String, schedule: String?, prompt: String?, name: String?, deliver: String?, repeatCount: String?, newSkills: [String]?, clearSkills: Bool, script: String?, workdir: String? = nil) {
|
||||||
var args = ["cron", "edit", id]
|
var args = ["cron", "edit", id]
|
||||||
if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] }
|
if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] }
|
||||||
if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] }
|
if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] }
|
||||||
@@ -193,16 +180,6 @@ final class CronViewModel {
|
|||||||
// = user cleared an existing workdir; Hermes documents `--workdir ""`
|
// = user cleared an existing workdir; Hermes documents `--workdir ""`
|
||||||
// on edit as the explicit clear gesture, mirroring the `--script` shape.
|
// on edit as the explicit clear gesture, mirroring the `--script` shape.
|
||||||
if let workdir { args += ["--workdir", workdir] }
|
if let workdir { args += ["--workdir", workdir] }
|
||||||
// TODO(WS-7-Q4): The toggle-off shape of `--no-agent` on edit is
|
|
||||||
// unverified. Plan assumes Hermes accepts `--agent` to flip the flag
|
|
||||||
// back; if the CLI is one-way (`--no-agent` only), the edit-mode
|
|
||||||
// toggle should disable itself with a tooltip explaining the
|
|
||||||
// limitation. Send the flag in the assumed shape for now and adjust
|
|
||||||
// post-integration.
|
|
||||||
if let noAgent {
|
|
||||||
if noAgent { args.append("--no-agent") }
|
|
||||||
else { args.append("--agent") }
|
|
||||||
}
|
|
||||||
runAndReload(args, success: "Updated")
|
runAndReload(args, success: "Updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ struct CronView: View {
|
|||||||
capabilitiesStore?.capabilities.hasCronWorkdir ?? false
|
capabilitiesStore?.capabilities.hasCronWorkdir ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
private var hasCronNoAgent: Bool {
|
|
||||||
capabilitiesStore?.capabilities.hasCronNoAgent ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
pageHeader
|
pageHeader
|
||||||
@@ -51,7 +47,7 @@ struct CronView: View {
|
|||||||
// polling timer. Same wiring ActivityView uses.
|
// polling timer. Same wiring ActivityView uses.
|
||||||
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
|
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
|
||||||
.sheet(isPresented: $viewModel.showCreateSheet) {
|
.sheet(isPresented: $viewModel.showCreateSheet) {
|
||||||
CronJobEditor(mode: .create, availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir, supportsNoAgent: hasCronNoAgent) { form in
|
CronJobEditor(mode: .create, availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir) { form in
|
||||||
viewModel.createJob(
|
viewModel.createJob(
|
||||||
schedule: form.schedule,
|
schedule: form.schedule,
|
||||||
prompt: form.prompt,
|
prompt: form.prompt,
|
||||||
@@ -60,12 +56,7 @@ struct CronView: View {
|
|||||||
skills: form.skills,
|
skills: form.skills,
|
||||||
script: form.script,
|
script: form.script,
|
||||||
repeatCount: form.repeatCount,
|
repeatCount: form.repeatCount,
|
||||||
workdir: hasCronWorkdir ? form.workdir : "",
|
workdir: hasCronWorkdir ? form.workdir : ""
|
||||||
// Mirrors the workdir strip-on-pre-version pattern: pre-v0.13
|
|
||||||
// hosts get a hard `false`, so a stale form value (or a
|
|
||||||
// hand-edited jobs.json round-tripped through edit-mode)
|
|
||||||
// can't sneak `--no-agent` into a CLI that doesn't grok it.
|
|
||||||
noAgent: hasCronNoAgent ? form.noAgent : false
|
|
||||||
)
|
)
|
||||||
viewModel.showCreateSheet = false
|
viewModel.showCreateSheet = false
|
||||||
} onCancel: {
|
} onCancel: {
|
||||||
@@ -73,7 +64,7 @@ struct CronView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(item: $viewModel.editingJob) { job in
|
.sheet(item: $viewModel.editingJob) { job in
|
||||||
CronJobEditor(mode: .edit(job), availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir, supportsNoAgent: hasCronNoAgent) { form in
|
CronJobEditor(mode: .edit(job), availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir) { form in
|
||||||
viewModel.updateJob(
|
viewModel.updateJob(
|
||||||
id: job.id,
|
id: job.id,
|
||||||
schedule: form.schedule,
|
schedule: form.schedule,
|
||||||
@@ -84,8 +75,7 @@ struct CronView: View {
|
|||||||
newSkills: form.skills,
|
newSkills: form.skills,
|
||||||
clearSkills: form.clearSkills,
|
clearSkills: form.clearSkills,
|
||||||
script: form.script,
|
script: form.script,
|
||||||
workdir: hasCronWorkdir ? form.workdir : nil,
|
workdir: hasCronWorkdir ? form.workdir : nil
|
||||||
noAgent: hasCronNoAgent ? form.noAgent : nil
|
|
||||||
)
|
)
|
||||||
viewModel.editingJob = nil
|
viewModel.editingJob = nil
|
||||||
} onCancel: {
|
} onCancel: {
|
||||||
@@ -653,9 +643,6 @@ struct CronJobEditor: View {
|
|||||||
/// v0.12+ workdir flag — fills `--workdir <path>`. Empty string
|
/// v0.12+ workdir flag — fills `--workdir <path>`. Empty string
|
||||||
/// preserves the v0.11 behaviour of running with no cwd hint.
|
/// preserves the v0.11 behaviour of running with no cwd hint.
|
||||||
var workdir: String = ""
|
var workdir: String = ""
|
||||||
/// v0.13+ `--no-agent` flag — script-only watchdog mode. Hermes
|
|
||||||
/// runs the pre-run script and skips the AI turn.
|
|
||||||
var noAgent: Bool = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mode: Mode
|
let mode: Mode
|
||||||
@@ -663,10 +650,6 @@ struct CronJobEditor: View {
|
|||||||
/// Pass `false` on pre-v0.12 hosts; the `--workdir` field is hidden and
|
/// Pass `false` on pre-v0.12 hosts; the `--workdir` field is hidden and
|
||||||
/// the form's value is dropped when the parent calls `createJob`/`updateJob`.
|
/// the form's value is dropped when the parent calls `createJob`/`updateJob`.
|
||||||
let supportsWorkdir: Bool
|
let supportsWorkdir: Bool
|
||||||
/// Pass `false` on pre-v0.13 hosts; the `--no-agent` toggle is hidden
|
|
||||||
/// and the parent strips the form's value before calling
|
|
||||||
/// `createJob`/`updateJob`. Mirrors the `supportsWorkdir` pattern.
|
|
||||||
let supportsNoAgent: Bool
|
|
||||||
let onSave: (FormState) -> Void
|
let onSave: (FormState) -> Void
|
||||||
let onCancel: () -> Void
|
let onCancel: () -> Void
|
||||||
|
|
||||||
@@ -698,25 +681,12 @@ struct CronJobEditor: View {
|
|||||||
)
|
)
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
}
|
}
|
||||||
.opacity(form.noAgent ? 0.4 : 1.0)
|
|
||||||
.disabled(form.noAgent)
|
|
||||||
formField("Deliver", text: $form.deliver, placeholder: "origin | local | discord:CHANNEL | telegram:CHAT", mono: true)
|
formField("Deliver", text: $form.deliver, placeholder: "origin | local | discord:CHANNEL | telegram:CHAT", mono: true)
|
||||||
formField("Repeat", text: $form.repeatCount, placeholder: "Optional count")
|
formField("Repeat", text: $form.repeatCount, placeholder: "Optional count")
|
||||||
formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true)
|
formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true)
|
||||||
if supportsWorkdir {
|
if supportsWorkdir {
|
||||||
formField("Workdir", text: $form.workdir, placeholder: "Absolute path; pulls AGENTS.md/CLAUDE.md context", mono: true)
|
formField("Workdir", text: $form.workdir, placeholder: "Absolute path; pulls AGENTS.md/CLAUDE.md context", mono: true)
|
||||||
}
|
}
|
||||||
if supportsNoAgent {
|
|
||||||
Toggle("Run script only (no agent call)", isOn: $form.noAgent)
|
|
||||||
.scarfStyle(.body)
|
|
||||||
.tint(ScarfColor.accent)
|
|
||||||
if form.noAgent {
|
|
||||||
Text("Watchdog mode — Hermes runs the pre-run script and skips the AI turn. Prompt + skills are ignored.")
|
|
||||||
.scarfStyle(.caption)
|
|
||||||
.foregroundStyle(ScarfColor.foregroundMuted)
|
|
||||||
.padding(.leading, ScarfSpace.s3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !availableSkills.isEmpty {
|
if !availableSkills.isEmpty {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
Text("Skills")
|
Text("Skills")
|
||||||
@@ -753,8 +723,6 @@ struct CronJobEditor: View {
|
|||||||
.tint(ScarfColor.accent)
|
.tint(ScarfColor.accent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.opacity(form.noAgent ? 0.4 : 1.0)
|
|
||||||
.disabled(form.noAgent)
|
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
@@ -778,7 +746,6 @@ struct CronJobEditor: View {
|
|||||||
form.skills = job.skills ?? []
|
form.skills = job.skills ?? []
|
||||||
form.script = job.preRunScript ?? ""
|
form.script = job.preRunScript ?? ""
|
||||||
form.workdir = job.workdir ?? ""
|
form.workdir = job.workdir ?? ""
|
||||||
form.noAgent = job.noAgent ?? false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,9 +55,22 @@ final class KanbanBoardViewModel {
|
|||||||
var assigneeFilter: String? // nil = all assignees
|
var assigneeFilter: String? // nil = all assignees
|
||||||
var showArchived: Bool = false
|
var showArchived: Bool = false
|
||||||
|
|
||||||
/// Optimistic moves keyed by task id; cleared when the polled
|
/// Optimistic in-flight overrides keyed by task id; cleared when the
|
||||||
/// response includes the same status the optimistic move set.
|
/// polled response confirms the new state.
|
||||||
private var optimisticOverrides: [String: String] = [:]
|
/// - Status side: drag-drop column moves.
|
||||||
|
/// - Hallucination-gate side (v0.13): Verify clicks flip `pending` →
|
||||||
|
/// `verified` locally so the banner disappears immediately.
|
||||||
|
/// The override entry is dropped from the dictionary entirely once
|
||||||
|
/// both sides are nil (no override needed).
|
||||||
|
private struct OptimisticOverride {
|
||||||
|
var status: String?
|
||||||
|
var hallucinationGate: KanbanHallucinationGate?
|
||||||
|
|
||||||
|
var isEmpty: Bool {
|
||||||
|
status == nil && hallucinationGate == nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private var optimisticOverrides: [String: OptimisticOverride] = [:]
|
||||||
/// Tasks dropped into invalid columns produce a transient "denied"
|
/// Tasks dropped into invalid columns produce a transient "denied"
|
||||||
/// banner. Stored as an explicit error to support the Cmd-Z style
|
/// banner. Stored as an explicit error to support the Cmd-Z style
|
||||||
/// undo we don't ship in v2.7.5 but want to leave room for.
|
/// undo we don't ship in v2.7.5 but want to leave room for.
|
||||||
@@ -177,8 +190,10 @@ final class KanbanBoardViewModel {
|
|||||||
// Optimistic mutation — flip the local row's status to a
|
// Optimistic mutation — flip the local row's status to a
|
||||||
// value within the destination column's range. We pick a
|
// value within the destination column's range. We pick a
|
||||||
// representative status per column.
|
// representative status per column.
|
||||||
let optimisticStatus = optimisticStatus(for: destination)
|
let optimisticStatusValue = optimisticStatus(for: destination)
|
||||||
optimisticOverrides[taskId] = optimisticStatus
|
var override = optimisticOverrides[taskId] ?? OptimisticOverride()
|
||||||
|
override.status = optimisticStatusValue
|
||||||
|
optimisticOverrides[taskId] = override
|
||||||
|
|
||||||
let svc = service
|
let svc = service
|
||||||
Task {
|
Task {
|
||||||
@@ -190,11 +205,11 @@ final class KanbanBoardViewModel {
|
|||||||
// without waiting for the 5s tick.
|
// without waiting for the 5s tick.
|
||||||
await refresh()
|
await refresh()
|
||||||
} catch let err as KanbanError {
|
} catch let err as KanbanError {
|
||||||
optimisticOverrides.removeValue(forKey: taskId)
|
clearStatusOverride(for: taskId)
|
||||||
lastError = err.errorDescription
|
lastError = err.errorDescription
|
||||||
logger.warning("kanban move failed: \(err.errorDescription ?? "", privacy: .public)")
|
logger.warning("kanban move failed: \(err.errorDescription ?? "", privacy: .public)")
|
||||||
} catch {
|
} catch {
|
||||||
optimisticOverrides.removeValue(forKey: taskId)
|
clearStatusOverride(for: taskId)
|
||||||
lastError = error.localizedDescription
|
lastError = error.localizedDescription
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,6 +284,48 @@ final class KanbanBoardViewModel {
|
|||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Hallucination gate (v0.13)
|
||||||
|
|
||||||
|
/// User confirmed the worker-created card is real. Optimistically
|
||||||
|
/// flip the gate to `verified` so the banner disappears immediately;
|
||||||
|
/// the polling loop confirms the new state on the next tick. On
|
||||||
|
/// failure (e.g. the verb name is wrong on this v0.13.x build), the
|
||||||
|
/// override is cleared and the error surfaces in `lastError`.
|
||||||
|
func verifyHallucination(taskId: String) {
|
||||||
|
var override = optimisticOverrides[taskId] ?? OptimisticOverride()
|
||||||
|
override.hallucinationGate = .verified
|
||||||
|
optimisticOverrides[taskId] = override
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
try await service.verify(taskId: taskId)
|
||||||
|
await refresh()
|
||||||
|
} catch let err as KanbanError {
|
||||||
|
clearHallucinationOverride(for: taskId)
|
||||||
|
lastError = err.errorDescription
|
||||||
|
logger.warning("kanban verify failed: \(err.errorDescription ?? "", privacy: .public)")
|
||||||
|
} catch {
|
||||||
|
clearHallucinationOverride(for: taskId)
|
||||||
|
lastError = error.localizedDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// User rejected the worker-created card as a hallucinated reference.
|
||||||
|
/// Routes through `comment` + `archive` per `KanbanService.rejectHallucinated`
|
||||||
|
/// so there's an audit trail for why the card disappeared.
|
||||||
|
func rejectHallucination(taskId: String) {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
try await service.rejectHallucinated(taskId: taskId)
|
||||||
|
await refresh()
|
||||||
|
} catch let err as KanbanError {
|
||||||
|
lastError = err.errorDescription
|
||||||
|
} catch {
|
||||||
|
lastError = error.localizedDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private helpers
|
// MARK: - Private helpers
|
||||||
|
|
||||||
private func mergePolledTasks(_ polled: [HermesKanbanTask]) {
|
private func mergePolledTasks(_ polled: [HermesKanbanTask]) {
|
||||||
@@ -282,25 +339,75 @@ final class KanbanBoardViewModel {
|
|||||||
filtered = polled
|
filtered = polled
|
||||||
}
|
}
|
||||||
let presentIds = Set(filtered.map(\.id))
|
let presentIds = Set(filtered.map(\.id))
|
||||||
// Drop optimistic overrides for tasks Hermes confirmed.
|
// Drop optimistic overrides for tasks Hermes confirmed. Two
|
||||||
for (id, optimistic) in optimisticOverrides {
|
// independent sides — clear them separately so a Verify click
|
||||||
if let row = filtered.first(where: { $0.id == id }) {
|
// still in-flight survives a status-side poll confirmation, and
|
||||||
if columnFromStatus(optimistic) == columnFromStatus(row.status) {
|
// vice versa.
|
||||||
|
for (id, override) in optimisticOverrides {
|
||||||
|
guard let row = filtered.first(where: { $0.id == id }) else {
|
||||||
|
if !presentIds.contains(id) {
|
||||||
|
// Task no longer in the polled set (archived, deleted,
|
||||||
|
// or filtered out). Drop the override entirely.
|
||||||
optimisticOverrides.removeValue(forKey: id)
|
optimisticOverrides.removeValue(forKey: id)
|
||||||
}
|
}
|
||||||
} else if !presentIds.contains(id) {
|
continue
|
||||||
// Task no longer in the polled set (archived, deleted,
|
}
|
||||||
// or filtered out). Drop the optimistic entry.
|
// Status side — optimistic move confirmed.
|
||||||
|
if let optStatus = override.status,
|
||||||
|
columnFromStatus(optStatus) == columnFromStatus(row.status) {
|
||||||
|
optimisticOverrides[id]?.status = nil
|
||||||
|
}
|
||||||
|
// Hallucination-gate side — optimistic verify/reject confirmed.
|
||||||
|
if let optGate = override.hallucinationGate,
|
||||||
|
KanbanHallucinationGate.from(row.hallucinationGateStatus) == optGate {
|
||||||
|
optimisticOverrides[id]?.hallucinationGate = nil
|
||||||
|
}
|
||||||
|
if optimisticOverrides[id]?.isEmpty ?? true {
|
||||||
optimisticOverrides.removeValue(forKey: id)
|
optimisticOverrides.removeValue(forKey: id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks = filtered
|
tasks = filtered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Drop the status side of a task's override (preserving any
|
||||||
|
/// in-flight hallucination-gate optimistic state).
|
||||||
|
private func clearStatusOverride(for taskId: String) {
|
||||||
|
guard var override = optimisticOverrides[taskId] else { return }
|
||||||
|
override.status = nil
|
||||||
|
if override.isEmpty {
|
||||||
|
optimisticOverrides.removeValue(forKey: taskId)
|
||||||
|
} else {
|
||||||
|
optimisticOverrides[taskId] = override
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Drop the hallucination-gate side of a task's override (preserving
|
||||||
|
/// any in-flight status-side drag-drop).
|
||||||
|
private func clearHallucinationOverride(for taskId: String) {
|
||||||
|
guard var override = optimisticOverrides[taskId] else { return }
|
||||||
|
override.hallucinationGate = nil
|
||||||
|
if override.isEmpty {
|
||||||
|
optimisticOverrides.removeValue(forKey: taskId)
|
||||||
|
} else {
|
||||||
|
optimisticOverrides[taskId] = override
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Effective hallucination gate for a task — the optimistic override
|
||||||
|
/// wins if one is in flight; otherwise the polled value. View code
|
||||||
|
/// reads through this so the banner / dim state matches the moment-
|
||||||
|
/// after-click experience.
|
||||||
|
func effectiveHallucinationGate(_ task: HermesKanbanTask) -> KanbanHallucinationGate? {
|
||||||
|
if let override = optimisticOverrides[task.id]?.hallucinationGate {
|
||||||
|
return override
|
||||||
|
}
|
||||||
|
return KanbanHallucinationGate.from(task.hallucinationGateStatus)
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the effective board column for a task — the optimistic
|
/// Return the effective board column for a task — the optimistic
|
||||||
/// override wins if one is in flight; otherwise the polled status.
|
/// override wins if one is in flight; otherwise the polled status.
|
||||||
private func effectiveColumn(_ task: HermesKanbanTask) -> KanbanBoardColumn {
|
private func effectiveColumn(_ task: HermesKanbanTask) -> KanbanBoardColumn {
|
||||||
if let overrideStatus = optimisticOverrides[task.id] {
|
if let overrideStatus = optimisticOverrides[task.id]?.status {
|
||||||
return columnFromStatus(overrideStatus)
|
return columnFromStatus(overrideStatus)
|
||||||
}
|
}
|
||||||
return columnFromStatus(task.status)
|
return columnFromStatus(task.status)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import ScarfDesign
|
|||||||
/// tenant.
|
/// tenant.
|
||||||
struct KanbanBoardView: View {
|
struct KanbanBoardView: View {
|
||||||
@State private var viewModel: KanbanBoardViewModel
|
@State private var viewModel: KanbanBoardViewModel
|
||||||
|
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
||||||
|
|
||||||
/// When non-nil, a project board hosts this view. Drives header
|
/// When non-nil, a project board hosts this view. Drives header
|
||||||
/// chrome (subtitle, hidden tenant filter) and create-sheet
|
/// chrome (subtitle, hidden tenant filter) and create-sheet
|
||||||
@@ -33,6 +34,15 @@ struct KanbanBoardView: View {
|
|||||||
self.projectName = projectName
|
self.projectName = projectName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convenience read for the v0.13 diagnostics flag — gates the
|
||||||
|
/// max_retries field, hallucination banner, diagnostics rendering,
|
||||||
|
/// and the auto-blocked reason banner. Pre-v0.13 hosts get the
|
||||||
|
/// v2.7.5 surface unchanged. Treats a missing store as "off" so
|
||||||
|
/// harness contexts (Previews) don't accidentally surface gated UI.
|
||||||
|
private var supportsKanbanDiagnostics: Bool {
|
||||||
|
capabilitiesStore?.capabilities.hasKanbanDiagnostics ?? false
|
||||||
|
}
|
||||||
|
|
||||||
@State private var inspectorTaskId: String?
|
@State private var inspectorTaskId: String?
|
||||||
@State private var showingCreateSheet = false
|
@State private var showingCreateSheet = false
|
||||||
@State private var blockSheetTaskId: String?
|
@State private var blockSheetTaskId: String?
|
||||||
@@ -71,7 +81,8 @@ struct KanbanBoardView: View {
|
|||||||
KanbanCreateSheet(
|
KanbanCreateSheet(
|
||||||
assignees: viewModel.assignees,
|
assignees: viewModel.assignees,
|
||||||
tenantPrefill: viewModel.tenantFilter,
|
tenantPrefill: viewModel.tenantFilter,
|
||||||
projectWorkspacePath: viewModel.projectPath
|
projectWorkspacePath: viewModel.projectPath,
|
||||||
|
supportsKanbanDiagnostics: supportsKanbanDiagnostics
|
||||||
) { request in
|
) { request in
|
||||||
_ = try await viewModel.createTask(request)
|
_ = try await viewModel.createTask(request)
|
||||||
}
|
}
|
||||||
@@ -188,7 +199,9 @@ struct KanbanBoardView: View {
|
|||||||
onDrop: { ref in
|
onDrop: { ref in
|
||||||
handleDrop(ref.id, on: column)
|
handleDrop(ref.id, on: column)
|
||||||
},
|
},
|
||||||
canCreate: column == .upNext || column == .triage
|
canCreate: column == .upNext || column == .triage,
|
||||||
|
supportsKanbanDiagnostics: supportsKanbanDiagnostics,
|
||||||
|
effectiveHallucinationGate: { viewModel.effectiveHallucinationGate($0) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(minLength: ScarfSpace.s4)
|
Spacer(minLength: ScarfSpace.s4)
|
||||||
@@ -208,6 +221,8 @@ struct KanbanBoardView: View {
|
|||||||
service: viewModel.service,
|
service: viewModel.service,
|
||||||
taskId: taskId,
|
taskId: taskId,
|
||||||
availableAssignees: viewModel.assignees,
|
availableAssignees: viewModel.assignees,
|
||||||
|
supportsKanbanDiagnostics: supportsKanbanDiagnostics,
|
||||||
|
effectiveHallucinationGate: { viewModel.effectiveHallucinationGate($0) },
|
||||||
onClose: { inspectorTaskId = nil },
|
onClose: { inspectorTaskId = nil },
|
||||||
onClaim: {
|
onClaim: {
|
||||||
viewModel.attemptMove(taskId: taskId, to: .running)
|
viewModel.attemptMove(taskId: taskId, to: .running)
|
||||||
@@ -232,6 +247,15 @@ struct KanbanBoardView: View {
|
|||||||
},
|
},
|
||||||
onReassign: { profile in
|
onReassign: { profile in
|
||||||
viewModel.reassignTask(taskId: taskId, to: profile)
|
viewModel.reassignTask(taskId: taskId, to: profile)
|
||||||
|
},
|
||||||
|
onVerifyHallucination: {
|
||||||
|
viewModel.verifyHallucination(taskId: taskId)
|
||||||
|
},
|
||||||
|
onRejectHallucination: {
|
||||||
|
viewModel.rejectHallucination(taskId: taskId)
|
||||||
|
// Card vanishes from active board after archive — close
|
||||||
|
// the inspector so it doesn't dangle on a deleted task.
|
||||||
|
inspectorTaskId = nil
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,40 @@ struct KanbanTaskRef: Transferable {
|
|||||||
/// - **Running** gets a blue left-edge accent + live shimmer
|
/// - **Running** gets a blue left-edge accent + live shimmer
|
||||||
/// - **Blocked** gets a warning left-edge accent + ⚠ glyph
|
/// - **Blocked** gets a warning left-edge accent + ⚠ glyph
|
||||||
/// - **Done** dims to 0.7 opacity (0.55 in dark mode)
|
/// - **Done** dims to 0.7 opacity (0.55 in dark mode)
|
||||||
|
/// - **Hallucination-gate pending** (v0.13+) dims to 0.6 + ⚠ glyph and
|
||||||
|
/// shows a one-line auto-blocked reason in the footer when present.
|
||||||
struct KanbanCardView: View {
|
struct KanbanCardView: View {
|
||||||
let task: HermesKanbanTask
|
let task: HermesKanbanTask
|
||||||
let onTap: () -> Void
|
let onTap: () -> Void
|
||||||
|
/// True when the connected Hermes is on v0.13+ — gates the
|
||||||
|
/// hallucination dim/glyph, auto-block sub-line, and diagnostics
|
||||||
|
/// dot on the card. Pre-v0.13 hosts see the v2.7.5 chrome unchanged.
|
||||||
|
let supportsKanbanDiagnostics: Bool
|
||||||
|
/// Optimistic-aware accessor. Pre-v0.13 always nil. Otherwise delegates
|
||||||
|
/// to the board VM so a Verify click un-dims the card immediately.
|
||||||
|
let effectiveHallucinationGate: (HermesKanbanTask) -> KanbanHallucinationGate?
|
||||||
|
|
||||||
|
init(
|
||||||
|
task: HermesKanbanTask,
|
||||||
|
supportsKanbanDiagnostics: Bool = false,
|
||||||
|
effectiveHallucinationGate: @escaping (HermesKanbanTask) -> KanbanHallucinationGate? = { _ in nil },
|
||||||
|
onTap: @escaping () -> Void
|
||||||
|
) {
|
||||||
|
self.task = task
|
||||||
|
self.supportsKanbanDiagnostics = supportsKanbanDiagnostics
|
||||||
|
self.effectiveHallucinationGate = effectiveHallucinationGate
|
||||||
|
self.onTap = onTap
|
||||||
|
}
|
||||||
|
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
|
|
||||||
|
/// Cached gate read — derived once per body eval rather than recomputed
|
||||||
|
/// in each subview helper.
|
||||||
|
private var hallucinationGate: KanbanHallucinationGate? {
|
||||||
|
guard supportsKanbanDiagnostics else { return nil }
|
||||||
|
return effectiveHallucinationGate(task)
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: onTap) {
|
Button(action: onTap) {
|
||||||
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
|
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
|
||||||
@@ -66,13 +94,22 @@ struct KanbanCardView: View {
|
|||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.scarfShadow(.sm)
|
.scarfShadow(.sm)
|
||||||
.opacity(task.isDone ? doneOpacity : 1.0)
|
// v0.13: hallucination-pending cards dim to 0.6 to signal "needs
|
||||||
|
// verification before running" without making them unreadable.
|
||||||
|
// Done cards stay at the established doneOpacity (0.7 / 0.55).
|
||||||
|
.opacity(cardOpacity)
|
||||||
.draggable(KanbanTaskRef(id: task.id)) {
|
.draggable(KanbanTaskRef(id: task.id)) {
|
||||||
// Drag preview — the live card with a heavier shadow.
|
// Drag preview — the live card with a heavier shadow.
|
||||||
self.dragPreview
|
self.dragPreview
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var cardOpacity: Double {
|
||||||
|
if task.isDone { return doneOpacity }
|
||||||
|
if hallucinationGate == .pending { return 0.6 }
|
||||||
|
return 1.0
|
||||||
|
}
|
||||||
|
|
||||||
private var titleRow: some View {
|
private var titleRow: some View {
|
||||||
HStack(alignment: .top, spacing: ScarfSpace.s2) {
|
HStack(alignment: .top, spacing: ScarfSpace.s2) {
|
||||||
statusGlyph
|
statusGlyph
|
||||||
@@ -82,7 +119,15 @@ struct KanbanCardView: View {
|
|||||||
.lineLimit(2)
|
.lineLimit(2)
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
if needsAssignmentWarning {
|
// v0.13 hallucination glyph takes precedence over the
|
||||||
|
// unassigned glyph — the hallucination state is the more
|
||||||
|
// specific signal (a worker created this card; verify it).
|
||||||
|
if hallucinationGate == .pending {
|
||||||
|
Image(systemName: "questionmark.diamond.fill")
|
||||||
|
.foregroundStyle(ScarfColor.warning)
|
||||||
|
.font(.system(size: 11, weight: .semibold))
|
||||||
|
.help("Worker-created — verify before running")
|
||||||
|
} else if needsAssignmentWarning {
|
||||||
Image(systemName: "exclamationmark.triangle.fill")
|
Image(systemName: "exclamationmark.triangle.fill")
|
||||||
.foregroundStyle(ScarfColor.warning)
|
.foregroundStyle(ScarfColor.warning)
|
||||||
.font(.system(size: 11, weight: .semibold))
|
.font(.system(size: 11, weight: .semibold))
|
||||||
@@ -186,16 +231,40 @@ struct KanbanCardView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var footerRow: some View {
|
private var footerRow: some View {
|
||||||
|
VStack(alignment: .leading, spacing: 2) {
|
||||||
|
// v0.13: server-supplied auto-blocked reason. Renders verbatim
|
||||||
|
// (truncated to one line; full reason in the inspector).
|
||||||
|
// Pre-v0.13 hosts always have task.autoBlockedReason == nil.
|
||||||
|
if supportsKanbanDiagnostics,
|
||||||
|
KanbanStatus.from(task.status) == .blocked,
|
||||||
|
let reason = task.autoBlockedReason, !reason.isEmpty {
|
||||||
|
Text(reason)
|
||||||
|
.scarfStyle(.caption)
|
||||||
|
.foregroundStyle(ScarfColor.danger)
|
||||||
|
.lineLimit(1)
|
||||||
|
.truncationMode(.tail)
|
||||||
|
.help(reason)
|
||||||
|
}
|
||||||
HStack(spacing: ScarfSpace.s2) {
|
HStack(spacing: ScarfSpace.s2) {
|
||||||
Text(relativeTimeLabel)
|
Text(relativeTimeLabel)
|
||||||
.scarfStyle(.caption)
|
.scarfStyle(.caption)
|
||||||
.foregroundStyle(ScarfColor.foregroundFaint)
|
.foregroundStyle(ScarfColor.foregroundFaint)
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
|
// v0.13: diagnostics dot — small stethoscope glyph when
|
||||||
|
// any cross-run distress signal is attached. Matches the
|
||||||
|
// chip count in the inspector.
|
||||||
|
if supportsKanbanDiagnostics, !task.diagnostics.isEmpty {
|
||||||
|
Image(systemName: "stethoscope")
|
||||||
|
.font(.system(size: 9))
|
||||||
|
.foregroundStyle(ScarfColor.warning)
|
||||||
|
.help("\(task.diagnostics.count) diagnostic signal\(task.diagnostics.count == 1 ? "" : "s")")
|
||||||
|
}
|
||||||
if let priority = task.priority, priority >= 70 {
|
if let priority = task.priority, priority >= 70 {
|
||||||
priorityIndicator(priority)
|
priorityIndicator(priority)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func priorityIndicator(_ priority: Int) -> some View {
|
private func priorityIndicator(_ priority: Int) -> some View {
|
||||||
let color: Color = priority >= 90 ? ScarfColor.danger : ScarfColor.warning
|
let color: Color = priority >= 90 ? ScarfColor.danger : ScarfColor.warning
|
||||||
|
|||||||
@@ -17,6 +17,38 @@ struct KanbanColumnView: View {
|
|||||||
let onCreate: () -> Void
|
let onCreate: () -> Void
|
||||||
let onDrop: (KanbanTaskRef) -> Void
|
let onDrop: (KanbanTaskRef) -> Void
|
||||||
let canCreate: Bool
|
let canCreate: Bool
|
||||||
|
/// True when the connected Hermes is on v0.13+. Forwarded to each
|
||||||
|
/// `KanbanCardView` so the hallucination dim/glyph + diagnostics dot
|
||||||
|
/// + auto-block sub-line gate uniformly.
|
||||||
|
let supportsKanbanDiagnostics: Bool
|
||||||
|
/// Optimistic-aware accessor forwarded to cards. Default is
|
||||||
|
/// "no override" so Previews and harness contexts still render
|
||||||
|
/// without wiring up a board VM.
|
||||||
|
let effectiveHallucinationGate: (HermesKanbanTask) -> KanbanHallucinationGate?
|
||||||
|
|
||||||
|
init(
|
||||||
|
column: KanbanBoardColumn,
|
||||||
|
tasks: [HermesKanbanTask],
|
||||||
|
isLive: Bool,
|
||||||
|
readyPillCount: Int,
|
||||||
|
onTaskTap: @escaping (HermesKanbanTask) -> Void,
|
||||||
|
onCreate: @escaping () -> Void,
|
||||||
|
onDrop: @escaping (KanbanTaskRef) -> Void,
|
||||||
|
canCreate: Bool,
|
||||||
|
supportsKanbanDiagnostics: Bool = false,
|
||||||
|
effectiveHallucinationGate: @escaping (HermesKanbanTask) -> KanbanHallucinationGate? = { _ in nil }
|
||||||
|
) {
|
||||||
|
self.column = column
|
||||||
|
self.tasks = tasks
|
||||||
|
self.isLive = isLive
|
||||||
|
self.readyPillCount = readyPillCount
|
||||||
|
self.onTaskTap = onTaskTap
|
||||||
|
self.onCreate = onCreate
|
||||||
|
self.onDrop = onDrop
|
||||||
|
self.canCreate = canCreate
|
||||||
|
self.supportsKanbanDiagnostics = supportsKanbanDiagnostics
|
||||||
|
self.effectiveHallucinationGate = effectiveHallucinationGate
|
||||||
|
}
|
||||||
|
|
||||||
@State private var isTargeted = false
|
@State private var isTargeted = false
|
||||||
|
|
||||||
@@ -36,7 +68,11 @@ struct KanbanColumnView: View {
|
|||||||
.padding(.top, ScarfSpace.s4)
|
.padding(.top, ScarfSpace.s4)
|
||||||
} else {
|
} else {
|
||||||
ForEach(tasks) { task in
|
ForEach(tasks) { task in
|
||||||
KanbanCardView(task: task) {
|
KanbanCardView(
|
||||||
|
task: task,
|
||||||
|
supportsKanbanDiagnostics: supportsKanbanDiagnostics,
|
||||||
|
effectiveHallucinationGate: effectiveHallucinationGate
|
||||||
|
) {
|
||||||
onTaskTap(task)
|
onTaskTap(task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ struct KanbanCreateSheet: View {
|
|||||||
/// Pre-filled project workspace path on per-project boards. When
|
/// Pre-filled project workspace path on per-project boards. When
|
||||||
/// non-nil, the workspace picker is locked to "Project Dir".
|
/// non-nil, the workspace picker is locked to "Project Dir".
|
||||||
let projectWorkspacePath: String?
|
let projectWorkspacePath: String?
|
||||||
|
/// True when the connected Hermes is on v0.13+ — gates the
|
||||||
|
/// `--max-retries` field and decides whether to strip newlines from
|
||||||
|
/// the title at submit time. Pre-v0.13 hosts may truncate at the
|
||||||
|
/// first `\n`; we keep the multi-line input rendering on either way
|
||||||
|
/// since a taller `TextField` is harmless on v0.12.
|
||||||
|
let supportsKanbanDiagnostics: Bool
|
||||||
/// Closure invoked when the user submits — VM owner constructs the
|
/// Closure invoked when the user submits — VM owner constructs the
|
||||||
/// `KanbanService.create` call.
|
/// `KanbanService.create` call.
|
||||||
let onSubmit: (KanbanCreateRequest) async throws -> Void
|
let onSubmit: (KanbanCreateRequest) async throws -> Void
|
||||||
@@ -33,6 +39,11 @@ struct KanbanCreateSheet: View {
|
|||||||
@State private var skillsInput: String = ""
|
@State private var skillsInput: String = ""
|
||||||
@State private var tenant: String = ""
|
@State private var tenant: String = ""
|
||||||
@State private var sendToTriage: Bool = false
|
@State private var sendToTriage: Bool = false
|
||||||
|
/// v0.13: per-task retry budget. Toggle-gated so the user can opt
|
||||||
|
/// into "send the flag" vs. "let Hermes pick its default" (the
|
||||||
|
/// release notes default to 3 — see TODO in KanbanCreateRequest).
|
||||||
|
@State private var maxRetriesEnabled: Bool = false
|
||||||
|
@State private var maxRetries: Int = 3
|
||||||
@State private var isSubmitting: Bool = false
|
@State private var isSubmitting: Bool = false
|
||||||
@State private var submitError: String?
|
@State private var submitError: String?
|
||||||
@FocusState private var titleFocused: Bool
|
@FocusState private var titleFocused: Bool
|
||||||
@@ -62,6 +73,9 @@ struct KanbanCreateSheet: View {
|
|||||||
assigneePicker
|
assigneePicker
|
||||||
workspaceField
|
workspaceField
|
||||||
priorityField
|
priorityField
|
||||||
|
if supportsKanbanDiagnostics {
|
||||||
|
maxRetriesField
|
||||||
|
}
|
||||||
skillsField
|
skillsField
|
||||||
if projectWorkspacePath == nil {
|
if projectWorkspacePath == nil {
|
||||||
tenantField
|
tenantField
|
||||||
@@ -114,13 +128,63 @@ struct KanbanCreateSheet: View {
|
|||||||
// MARK: - Fields
|
// MARK: - Fields
|
||||||
|
|
||||||
private var titleField: some View {
|
private var titleField: some View {
|
||||||
|
// v0.13 server tolerates multi-line titles. We keep the
|
||||||
|
// multi-line input rendering on for ALL versions of Hermes —
|
||||||
|
// visually a taller TextField is harmless on v0.12 — and decide
|
||||||
|
// at submit time whether to strip newlines (see `makeRequest`).
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
ScarfSectionHeader("Title")
|
ScarfSectionHeader("Title")
|
||||||
ScarfTextField("What needs doing?", text: $title)
|
TextField(
|
||||||
|
"What needs doing?",
|
||||||
|
text: $title,
|
||||||
|
axis: .vertical
|
||||||
|
)
|
||||||
|
.lineLimit(1...4)
|
||||||
|
.textFieldStyle(.plain)
|
||||||
|
.scarfStyle(.body)
|
||||||
|
.padding(.horizontal, ScarfSpace.s3)
|
||||||
|
.padding(.vertical, ScarfSpace.s2)
|
||||||
|
.background(
|
||||||
|
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
|
||||||
|
.fill(ScarfColor.backgroundSecondary)
|
||||||
|
)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
|
||||||
|
.strokeBorder(ScarfColor.borderStrong, lineWidth: 1)
|
||||||
|
)
|
||||||
.focused($titleFocused)
|
.focused($titleFocused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// v0.13: per-task retry budget. Toggle gates whether `--max-retries`
|
||||||
|
/// is sent at all so the user can preserve "let Hermes pick the
|
||||||
|
/// default" semantics by leaving the toggle off.
|
||||||
|
private var maxRetriesField: some View {
|
||||||
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
ScarfSectionHeader(
|
||||||
|
"Max retries",
|
||||||
|
subtitle: "0 = no retries. Defaults to 3."
|
||||||
|
)
|
||||||
|
HStack(spacing: ScarfSpace.s3) {
|
||||||
|
Toggle("Override default", isOn: $maxRetriesEnabled)
|
||||||
|
.toggleStyle(.switch)
|
||||||
|
.labelsHidden()
|
||||||
|
Stepper(value: $maxRetries, in: 0...20) {
|
||||||
|
Text("\(maxRetries)")
|
||||||
|
.scarfStyle(.bodyEmph)
|
||||||
|
.frame(minWidth: 24, alignment: .trailing)
|
||||||
|
.foregroundStyle(
|
||||||
|
maxRetriesEnabled
|
||||||
|
? ScarfColor.foregroundPrimary
|
||||||
|
: ScarfColor.foregroundFaint
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.disabled(!maxRetriesEnabled)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var descriptionField: some View {
|
private var descriptionField: some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
ScarfSectionHeader("Description", subtitle: "Markdown supported")
|
ScarfSectionHeader("Description", subtitle: "Markdown supported")
|
||||||
@@ -307,7 +371,14 @@ struct KanbanCreateSheet: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func makeRequest() -> KanbanCreateRequest {
|
private func makeRequest() -> KanbanCreateRequest {
|
||||||
let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines)
|
var trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
// Pre-v0.13 hosts may truncate titles at the first `\n`. Strip
|
||||||
|
// newlines client-side when we know the connected Hermes hasn't
|
||||||
|
// shipped multi-line title support — replace with a space to
|
||||||
|
// keep the user's intent visible. v0.13+ keeps newlines verbatim.
|
||||||
|
if !supportsKanbanDiagnostics {
|
||||||
|
trimmedTitle = trimmedTitle.replacingOccurrences(of: "\n", with: " ")
|
||||||
|
}
|
||||||
let trimmedBody = bodyText.trimmingCharacters(in: .whitespacesAndNewlines)
|
let trimmedBody = bodyText.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
let trimmedAssignee = assignee.trimmingCharacters(in: .whitespacesAndNewlines)
|
let trimmedAssignee = assignee.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
let trimmedTenant = tenant.trimmingCharacters(in: .whitespacesAndNewlines)
|
let trimmedTenant = tenant.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
@@ -330,6 +401,14 @@ struct KanbanCreateSheet: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Belt-and-suspenders: the `maxRetriesField` is only rendered
|
||||||
|
// when `supportsKanbanDiagnostics` is true, but gate again here
|
||||||
|
// so a programmatic state change can't smuggle the flag onto a
|
||||||
|
// pre-v0.13 host (where the verb would error).
|
||||||
|
let resolvedMaxRetries: Int? = (supportsKanbanDiagnostics && maxRetriesEnabled)
|
||||||
|
? maxRetries
|
||||||
|
: nil
|
||||||
|
|
||||||
return KanbanCreateRequest(
|
return KanbanCreateRequest(
|
||||||
title: trimmedTitle,
|
title: trimmedTitle,
|
||||||
body: trimmedBody.isEmpty ? nil : trimmedBody,
|
body: trimmedBody.isEmpty ? nil : trimmedBody,
|
||||||
@@ -342,7 +421,8 @@ struct KanbanCreateSheet: View {
|
|||||||
idempotencyKey: nil,
|
idempotencyKey: nil,
|
||||||
maxRuntimeSeconds: nil,
|
maxRuntimeSeconds: nil,
|
||||||
createdBy: nil,
|
createdBy: nil,
|
||||||
skills: parsedSkills
|
skills: parsedSkills,
|
||||||
|
maxRetries: resolvedMaxRetries
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ import ScarfDesign
|
|||||||
struct KanbanInspectorPane: View {
|
struct KanbanInspectorPane: View {
|
||||||
@State private var viewModel: KanbanTaskDetailViewModel
|
@State private var viewModel: KanbanTaskDetailViewModel
|
||||||
let availableAssignees: [HermesKanbanAssignee]
|
let availableAssignees: [HermesKanbanAssignee]
|
||||||
|
/// True when the connected Hermes is on v0.13+ — gates the
|
||||||
|
/// hallucination banner, max_retries chip, diagnostics block,
|
||||||
|
/// and auto-blocked reason banner. Pre-v0.13 hosts see the v2.7.5
|
||||||
|
/// inspector unchanged.
|
||||||
|
let supportsKanbanDiagnostics: Bool
|
||||||
|
/// Resolves an effective hallucination gate — the board VM owns the
|
||||||
|
/// optimistic-override merge so the banner disappears immediately on
|
||||||
|
/// Verify before the polled state confirms the new gate. Falls back
|
||||||
|
/// to the wire-level value when no override is in flight.
|
||||||
|
let effectiveHallucinationGate: (HermesKanbanTask) -> KanbanHallucinationGate?
|
||||||
let onClose: () -> Void
|
let onClose: () -> Void
|
||||||
let onClaim: () -> Void
|
let onClaim: () -> Void
|
||||||
let onComplete: () -> Void
|
let onComplete: () -> Void
|
||||||
@@ -15,6 +25,8 @@ struct KanbanInspectorPane: View {
|
|||||||
let onUnblock: () -> Void
|
let onUnblock: () -> Void
|
||||||
let onArchive: () -> Void
|
let onArchive: () -> Void
|
||||||
let onReassign: (String?) -> Void
|
let onReassign: (String?) -> Void
|
||||||
|
let onVerifyHallucination: () -> Void
|
||||||
|
let onRejectHallucination: () -> Void
|
||||||
|
|
||||||
@State private var selectedTab: DetailTab = .comments
|
@State private var selectedTab: DetailTab = .comments
|
||||||
|
|
||||||
@@ -30,16 +42,22 @@ struct KanbanInspectorPane: View {
|
|||||||
service: KanbanService,
|
service: KanbanService,
|
||||||
taskId: String,
|
taskId: String,
|
||||||
availableAssignees: [HermesKanbanAssignee] = [],
|
availableAssignees: [HermesKanbanAssignee] = [],
|
||||||
|
supportsKanbanDiagnostics: Bool = false,
|
||||||
|
effectiveHallucinationGate: @escaping (HermesKanbanTask) -> KanbanHallucinationGate? = { _ in nil },
|
||||||
onClose: @escaping () -> Void,
|
onClose: @escaping () -> Void,
|
||||||
onClaim: @escaping () -> Void,
|
onClaim: @escaping () -> Void,
|
||||||
onComplete: @escaping () -> Void,
|
onComplete: @escaping () -> Void,
|
||||||
onBlock: @escaping () -> Void,
|
onBlock: @escaping () -> Void,
|
||||||
onUnblock: @escaping () -> Void,
|
onUnblock: @escaping () -> Void,
|
||||||
onArchive: @escaping () -> Void,
|
onArchive: @escaping () -> Void,
|
||||||
onReassign: @escaping (String?) -> Void = { _ in }
|
onReassign: @escaping (String?) -> Void = { _ in },
|
||||||
|
onVerifyHallucination: @escaping () -> Void = {},
|
||||||
|
onRejectHallucination: @escaping () -> Void = {}
|
||||||
) {
|
) {
|
||||||
_viewModel = State(initialValue: KanbanTaskDetailViewModel(service: service, taskId: taskId))
|
_viewModel = State(initialValue: KanbanTaskDetailViewModel(service: service, taskId: taskId))
|
||||||
self.availableAssignees = availableAssignees
|
self.availableAssignees = availableAssignees
|
||||||
|
self.supportsKanbanDiagnostics = supportsKanbanDiagnostics
|
||||||
|
self.effectiveHallucinationGate = effectiveHallucinationGate
|
||||||
self.onClose = onClose
|
self.onClose = onClose
|
||||||
self.onClaim = onClaim
|
self.onClaim = onClaim
|
||||||
self.onComplete = onComplete
|
self.onComplete = onComplete
|
||||||
@@ -47,6 +65,8 @@ struct KanbanInspectorPane: View {
|
|||||||
self.onUnblock = onUnblock
|
self.onUnblock = onUnblock
|
||||||
self.onArchive = onArchive
|
self.onArchive = onArchive
|
||||||
self.onReassign = onReassign
|
self.onReassign = onReassign
|
||||||
|
self.onVerifyHallucination = onVerifyHallucination
|
||||||
|
self.onRejectHallucination = onRejectHallucination
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -159,6 +179,16 @@ struct KanbanInspectorPane: View {
|
|||||||
ScarfBadge(workspace, kind: .neutral)
|
ScarfBadge(workspace, kind: .neutral)
|
||||||
.fixedSize()
|
.fixedSize()
|
||||||
}
|
}
|
||||||
|
// v0.13: max_retries chip. Read-only — Hermes
|
||||||
|
// has no `update --max-retries` verb. The
|
||||||
|
// `if let` guards pre-v0.13 hosts (always nil)
|
||||||
|
// and the explicit capability gate adds
|
||||||
|
// belt-and-suspenders.
|
||||||
|
if supportsKanbanDiagnostics, let maxRetries = task.maxRetries {
|
||||||
|
ScarfBadge("retries: \(maxRetries)", kind: .neutral)
|
||||||
|
.fixedSize()
|
||||||
|
.help("Max retries set at create time. Hermes has no update verb — re-create the task to change this.")
|
||||||
|
}
|
||||||
if let tenant = task.tenant, !tenant.isEmpty {
|
if let tenant = task.tenant, !tenant.isEmpty {
|
||||||
ScarfBadge(tenant, kind: .brand)
|
ScarfBadge(tenant, kind: .brand)
|
||||||
.fixedSize()
|
.fixedSize()
|
||||||
@@ -251,13 +281,18 @@ struct KanbanInspectorPane: View {
|
|||||||
// MARK: - Body
|
// MARK: - Body
|
||||||
|
|
||||||
/// Inline health banner shown above the task body when something
|
/// Inline health banner shown above the task body when something
|
||||||
/// requires user attention. Two conditions trigger today:
|
/// requires user attention. Stack vertically (multiple can apply at
|
||||||
/// 1. Task is in `ready`/`todo` with no assignee — explains that
|
/// once on a v0.13 task — e.g. unassigned + hallucination pending +
|
||||||
/// the dispatcher silently skips unassigned tasks.
|
/// last-run-blocked).
|
||||||
/// 2. The most recent run ended in a non-success outcome
|
/// Order top-to-bottom:
|
||||||
/// (`stale_lock`/`crashed`/`gave_up`/`timed_out`/`spawn_failed`/
|
/// 1. **Hallucination gate (v0.13+)** — pending worker-created card.
|
||||||
/// `reclaimed`/`failed`) — surfaces the error so the user
|
/// User must verify or reject before any other action makes sense.
|
||||||
/// doesn't have to dig into the Runs tab to discover it.
|
/// 2. **Auto-blocked reason (v0.13+)** — server-supplied reason
|
||||||
|
/// overrides the generic "Last run: blocked" banner.
|
||||||
|
/// 3. Task is in `ready`/`todo` with no assignee — explains that the
|
||||||
|
/// dispatcher silently skips unassigned tasks.
|
||||||
|
/// 4. The most recent run ended in a non-success outcome — surfaces
|
||||||
|
/// the error so the user doesn't have to dig into the Runs tab.
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func healthBanner(for task: HermesKanbanTask) -> some View {
|
private func healthBanner(for task: HermesKanbanTask) -> some View {
|
||||||
let status = KanbanStatus.from(task.status)
|
let status = KanbanStatus.from(task.status)
|
||||||
@@ -292,6 +327,38 @@ struct KanbanInspectorPane: View {
|
|||||||
// Also suppress for `done` (terminal success).
|
// Also suppress for `done` (terminal success).
|
||||||
let suppressFailureBanner = (status == .running) || (status == .done)
|
let suppressFailureBanner = (status == .running) || (status == .done)
|
||||||
|
|
||||||
|
// v0.13: hallucination-gate state. Read through the VM's
|
||||||
|
// optimistic-aware accessor so a Verify click takes effect
|
||||||
|
// before the polled state confirms. Belt-and-suspenders gate
|
||||||
|
// on capability flag.
|
||||||
|
let hallucination: KanbanHallucinationGate? = supportsKanbanDiagnostics
|
||||||
|
? effectiveHallucinationGate(task)
|
||||||
|
: nil
|
||||||
|
// v0.13: structured auto-blocked reason. Renders the server's
|
||||||
|
// string verbatim; takes precedence over the generic "Last run:
|
||||||
|
// blocked" banner.
|
||||||
|
let autoBlockedReason: String? = (supportsKanbanDiagnostics
|
||||||
|
&& status == .blocked
|
||||||
|
&& (task.autoBlockedReason?.isEmpty == false))
|
||||||
|
? task.autoBlockedReason
|
||||||
|
: nil
|
||||||
|
// Suppress the generic last-run banner when the more specific
|
||||||
|
// server-side reason supersedes it.
|
||||||
|
let suppressGenericFailure = autoBlockedReason != nil
|
||||||
|
|
||||||
|
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
|
||||||
|
if hallucination == .pending {
|
||||||
|
hallucinationBanner
|
||||||
|
}
|
||||||
|
if let reason = autoBlockedReason {
|
||||||
|
bannerRow(
|
||||||
|
icon: "exclamationmark.octagon.fill",
|
||||||
|
tint: ScarfColor.danger,
|
||||||
|
title: "Auto-blocked",
|
||||||
|
// Verbatim — Hermes-side message is the source of truth.
|
||||||
|
message: reason
|
||||||
|
)
|
||||||
|
}
|
||||||
if needsAssignee {
|
if needsAssignee {
|
||||||
bannerRow(
|
bannerRow(
|
||||||
icon: "exclamationmark.triangle.fill",
|
icon: "exclamationmark.triangle.fill",
|
||||||
@@ -299,7 +366,9 @@ struct KanbanInspectorPane: View {
|
|||||||
title: "Won't run automatically",
|
title: "Won't run automatically",
|
||||||
message: "Unassigned tasks are silently skipped by Hermes's dispatcher. Add an assignee to get this scheduled."
|
message: "Unassigned tasks are silently skipped by Hermes's dispatcher. Add an assignee to get this scheduled."
|
||||||
)
|
)
|
||||||
} else if hadFailedEndedRun, let lastEndedRun, !suppressFailureBanner {
|
}
|
||||||
|
if hadFailedEndedRun, let lastEndedRun,
|
||||||
|
!suppressFailureBanner, !suppressGenericFailure {
|
||||||
let label = (lastEndedRun.outcome ?? lastEndedRun.status).lowercased()
|
let label = (lastEndedRun.outcome ?? lastEndedRun.status).lowercased()
|
||||||
let detail = lastEndedRun.error ?? lastEndedRun.summary ?? "no details"
|
let detail = lastEndedRun.error ?? lastEndedRun.summary ?? "no details"
|
||||||
bannerRow(
|
bannerRow(
|
||||||
@@ -309,6 +378,84 @@ struct KanbanInspectorPane: View {
|
|||||||
message: detail
|
message: detail
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// v0.13: cross-run diagnostics on the task header.
|
||||||
|
if supportsKanbanDiagnostics, !task.diagnostics.isEmpty {
|
||||||
|
diagnosticsBlock(task.diagnostics)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// v0.13 hallucination-gate banner — Verify / Reject affordances for
|
||||||
|
/// worker-created cards waiting on user verification.
|
||||||
|
private var hallucinationBanner: some View {
|
||||||
|
HStack(alignment: .top, spacing: ScarfSpace.s2) {
|
||||||
|
Image(systemName: "questionmark.diamond.fill")
|
||||||
|
.foregroundStyle(ScarfColor.warning)
|
||||||
|
.font(.system(size: 13, weight: .semibold))
|
||||||
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
Text("Created by a worker — verify before running")
|
||||||
|
.scarfStyle(.captionStrong)
|
||||||
|
.foregroundStyle(ScarfColor.foregroundPrimary)
|
||||||
|
Text("A worker claimed it created this card; Hermes hasn't confirmed the underlying work exists. Verify the card matches a real follow-up, or reject if it's a hallucinated reference.")
|
||||||
|
.scarfStyle(.caption)
|
||||||
|
.foregroundStyle(ScarfColor.foregroundMuted)
|
||||||
|
HStack(spacing: ScarfSpace.s2) {
|
||||||
|
Button("Verify", action: onVerifyHallucination)
|
||||||
|
.buttonStyle(ScarfPrimaryButton())
|
||||||
|
Button("Reject", action: onRejectHallucination)
|
||||||
|
.buttonStyle(ScarfDestructiveButton())
|
||||||
|
}
|
||||||
|
.padding(.top, 2)
|
||||||
|
}
|
||||||
|
Spacer(minLength: 0)
|
||||||
|
}
|
||||||
|
.padding(ScarfSpace.s2)
|
||||||
|
.background(
|
||||||
|
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
|
||||||
|
.fill(ScarfColor.warning.opacity(0.10))
|
||||||
|
)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
|
||||||
|
.strokeBorder(ScarfColor.warning.opacity(0.4), lineWidth: 1)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// v0.13 diagnostics block — renders a list of distress signals.
|
||||||
|
/// Used both at the task-header level (cross-run signals) and per
|
||||||
|
/// run on the Runs tab (in-flight signals). Wraps in a horizontal
|
||||||
|
/// scroll so a long diag list doesn't blow out inspector width.
|
||||||
|
private func diagnosticsBlock(_ diags: [HermesKanbanDiagnostic]) -> some View {
|
||||||
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
Text("Diagnostics")
|
||||||
|
.scarfStyle(.captionUppercase)
|
||||||
|
.foregroundStyle(ScarfColor.foregroundFaint)
|
||||||
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
ForEach(diags) { diag in
|
||||||
|
diagnosticBadge(diag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.top, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func diagnosticBadge(_ diag: HermesKanbanDiagnostic) -> some View {
|
||||||
|
let kind = KanbanDiagnosticKind.from(diag.kind)
|
||||||
|
let badgeKind: ScarfBadgeKind = {
|
||||||
|
switch kind.severity {
|
||||||
|
case .danger: return .danger
|
||||||
|
case .warning: return .warning
|
||||||
|
case .neutral: return .neutral
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// Render the raw kind string — view code stays in sync with
|
||||||
|
// whatever future kinds Hermes ships. The typed mirror picks
|
||||||
|
// the badge tint and tooltip glyph; the verbatim wire string
|
||||||
|
// is the user-facing label.
|
||||||
|
ScarfBadge(diag.kind, kind: badgeKind)
|
||||||
|
.help(diag.message ?? diag.kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func bannerRow(
|
private func bannerRow(
|
||||||
@@ -562,6 +709,9 @@ struct KanbanInspectorPane: View {
|
|||||||
private func runRow(_ run: HermesKanbanRun) -> some View {
|
private func runRow(_ run: HermesKanbanRun) -> some View {
|
||||||
VStack(alignment: .leading, spacing: 2) {
|
VStack(alignment: .leading, spacing: 2) {
|
||||||
HStack(spacing: ScarfSpace.s2) {
|
HStack(spacing: ScarfSpace.s2) {
|
||||||
|
// Render the wire-side outcome / status string verbatim so
|
||||||
|
// v0.13's richer outcome strings ("zombied — reclaimed by
|
||||||
|
// reaper", etc.) surface unchanged.
|
||||||
ScarfBadge(run.outcome ?? run.status, kind: outcomeKind(run.outcome ?? run.status))
|
ScarfBadge(run.outcome ?? run.status, kind: outcomeKind(run.outcome ?? run.status))
|
||||||
if let profile = run.profile {
|
if let profile = run.profile {
|
||||||
Text(profile)
|
Text(profile)
|
||||||
@@ -585,6 +735,12 @@ struct KanbanInspectorPane: View {
|
|||||||
.foregroundStyle(ScarfColor.danger)
|
.foregroundStyle(ScarfColor.danger)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
}
|
}
|
||||||
|
// v0.13: per-run diagnostics. Gated on capability so a future
|
||||||
|
// server-side change can't accidentally surface partial UX
|
||||||
|
// on a pre-v0.13 host.
|
||||||
|
if supportsKanbanDiagnostics, !run.diagnostics.isEmpty {
|
||||||
|
diagnosticsBlock(run.diagnostics)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(ScarfSpace.s2)
|
.padding(ScarfSpace.s2)
|
||||||
.background(
|
.background(
|
||||||
@@ -619,6 +775,14 @@ struct KanbanInspectorPane: View {
|
|||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var primaryAction: some View {
|
private var primaryAction: some View {
|
||||||
if let task = viewModel.detail?.task {
|
if let task = viewModel.detail?.task {
|
||||||
|
// v0.13: when the hallucination gate is pending, suppress the
|
||||||
|
// primary action — the banner provides Verify / Reject as the
|
||||||
|
// gate. Showing "Start" alongside the banner would let the
|
||||||
|
// user dispatch a card Hermes hasn't confirmed exists.
|
||||||
|
if supportsKanbanDiagnostics,
|
||||||
|
effectiveHallucinationGate(task) == .pending {
|
||||||
|
EmptyView()
|
||||||
|
} else {
|
||||||
switch KanbanStatus.from(task.status) {
|
switch KanbanStatus.from(task.status) {
|
||||||
case .ready, .todo:
|
case .ready, .todo:
|
||||||
Button("Start", action: onClaim)
|
Button("Start", action: onClaim)
|
||||||
@@ -639,6 +803,7 @@ struct KanbanInspectorPane: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var secondaryActions: some View {
|
private var secondaryActions: some View {
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ final class MCPServerEditorViewModel {
|
|||||||
var promptsEnabled: Bool
|
var promptsEnabled: Bool
|
||||||
var timeoutDraft: String
|
var timeoutDraft: String
|
||||||
var connectTimeoutDraft: String
|
var connectTimeoutDraft: String
|
||||||
/// SSE-only — renders as a third numeric on `.sse` servers. Empty string
|
|
||||||
/// means "use Hermes default" (writer drops the scalar).
|
|
||||||
var sseReadTimeoutDraft: String
|
|
||||||
var showSecrets: Bool = false
|
var showSecrets: Bool = false
|
||||||
var isSaving: Bool = false
|
var isSaving: Bool = false
|
||||||
var saveError: String?
|
var saveError: String?
|
||||||
@@ -40,7 +37,6 @@ final class MCPServerEditorViewModel {
|
|||||||
self.promptsEnabled = server.promptsEnabled
|
self.promptsEnabled = server.promptsEnabled
|
||||||
self.timeoutDraft = server.timeout.map { String($0) } ?? ""
|
self.timeoutDraft = server.timeout.map { String($0) } ?? ""
|
||||||
self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? ""
|
self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? ""
|
||||||
self.sseReadTimeoutDraft = server.sseReadTimeout.map { String($0) } ?? ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendEnvRow() {
|
func appendEnvRow() {
|
||||||
@@ -73,8 +69,6 @@ final class MCPServerEditorViewModel {
|
|||||||
let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
|
let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
|
||||||
let timeoutValue = Int(timeoutDraft.trimmingCharacters(in: .whitespaces))
|
let timeoutValue = Int(timeoutDraft.trimmingCharacters(in: .whitespaces))
|
||||||
let connectValue = Int(connectTimeoutDraft.trimmingCharacters(in: .whitespaces))
|
let connectValue = Int(connectTimeoutDraft.trimmingCharacters(in: .whitespaces))
|
||||||
let trimmedSSE = sseReadTimeoutDraft.trimmingCharacters(in: .whitespaces)
|
|
||||||
let sseTimeoutValue: Int? = trimmedSSE.isEmpty ? nil : Int(trimmedSSE)
|
|
||||||
|
|
||||||
let service = fileService
|
let service = fileService
|
||||||
let transport = server.transport
|
let transport = server.transport
|
||||||
@@ -93,11 +87,6 @@ final class MCPServerEditorViewModel {
|
|||||||
if !service.setMCPServerEnv(name: name, env: envMap) { ok = false }
|
if !service.setMCPServerEnv(name: name, env: envMap) { ok = false }
|
||||||
case .http:
|
case .http:
|
||||||
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
|
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
|
||||||
case .sse:
|
|
||||||
// SSE servers carry headers like .http does, plus an
|
|
||||||
// optional sse_read_timeout written below.
|
|
||||||
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
|
|
||||||
if !service.setMCPServerSSETimeout(name: name, sseReadTimeout: sseTimeoutValue) { ok = false }
|
|
||||||
}
|
}
|
||||||
if !service.updateMCPToolFilters(
|
if !service.updateMCPToolFilters(
|
||||||
name: name,
|
name: name,
|
||||||
|
|||||||
@@ -42,10 +42,6 @@ final class MCPServersViewModel {
|
|||||||
filteredServers.filter { $0.transport == .http }
|
filteredServers.filter { $0.transport == .http }
|
||||||
}
|
}
|
||||||
|
|
||||||
var sseServers: [HermesMCPServer] {
|
|
||||||
filteredServers.filter { $0.transport == .sse }
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectedServer: HermesMCPServer? {
|
var selectedServer: HermesMCPServer? {
|
||||||
guard let name = selectedServerName else { return nil }
|
guard let name = selectedServerName else { return nil }
|
||||||
return servers.first(where: { $0.name == name })
|
return servers.first(where: { $0.name == name })
|
||||||
@@ -171,11 +167,6 @@ final class MCPServersViewModel {
|
|||||||
url: preset.url ?? "",
|
url: preset.url ?? "",
|
||||||
auth: preset.auth
|
auth: preset.auth
|
||||||
)
|
)
|
||||||
case .sse:
|
|
||||||
// No SSE-transport presets ship today; the preset picker
|
|
||||||
// only surfaces stdio/http servers. Treat as a no-op
|
|
||||||
// failure if a preset somehow declares .sse.
|
|
||||||
addResult = (exitCode: 1, output: "SSE-transport presets are not supported.")
|
|
||||||
}
|
}
|
||||||
guard addResult.exitCode == 0 else {
|
guard addResult.exitCode == 0 else {
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
@@ -205,11 +196,6 @@ final class MCPServersViewModel {
|
|||||||
result = fileService.addMCPServerStdio(name: name, command: command, args: args)
|
result = fileService.addMCPServerStdio(name: name, command: command, args: args)
|
||||||
case .http:
|
case .http:
|
||||||
result = fileService.addMCPServerHTTP(name: name, url: url, auth: auth)
|
result = fileService.addMCPServerHTTP(name: name, url: url, auth: auth)
|
||||||
case .sse:
|
|
||||||
// Routed through addCustomSSE; this branch is unreachable from
|
|
||||||
// the add-server form (which dispatches per-transport in submit())
|
|
||||||
// but kept so the switch is exhaustive without `@unknown default`.
|
|
||||||
result = (exitCode: 1, output: "SSE servers must be added via addCustomSSE.")
|
|
||||||
}
|
}
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
if result.exitCode == 0 {
|
if result.exitCode == 0 {
|
||||||
@@ -225,28 +211,6 @@ final class MCPServersViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// v0.13+ SSE-transport server creation. Caller is responsible for
|
|
||||||
/// capability-gating; the form filters `.sse` out of `availableTransports`
|
|
||||||
/// when `hasMCPSSETransport` is false, so this method is unreachable
|
|
||||||
/// from the UI on pre-v0.13 hosts.
|
|
||||||
func addCustomSSE(name: String, url: String, sseReadTimeout: Int?) {
|
|
||||||
let fileService = self.fileService
|
|
||||||
Task.detached {
|
|
||||||
let result = fileService.addMCPServerSSE(name: name, url: url, sseReadTimeout: sseReadTimeout)
|
|
||||||
await MainActor.run {
|
|
||||||
if result.exitCode == 0 {
|
|
||||||
self.flashStatus("Added \(name)")
|
|
||||||
self.load()
|
|
||||||
self.selectedServerName = name
|
|
||||||
self.showRestartBanner = true
|
|
||||||
self.showAddCustom = false
|
|
||||||
} else {
|
|
||||||
self.activeError = "Add failed: \(result.output)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func restartGateway() {
|
func restartGateway() {
|
||||||
let fileService = self.fileService
|
let fileService = self.fileService
|
||||||
Task.detached {
|
Task.detached {
|
||||||
|
|||||||
@@ -6,26 +6,12 @@ struct MCPServerAddCustomView: View {
|
|||||||
let viewModel: MCPServersViewModel
|
let viewModel: MCPServersViewModel
|
||||||
|
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
|
||||||
@State private var name: String = ""
|
@State private var name: String = ""
|
||||||
@State private var transport: MCPTransport = .stdio
|
@State private var transport: MCPTransport = .stdio
|
||||||
@State private var command: String = "npx"
|
@State private var command: String = "npx"
|
||||||
@State private var argsText: String = ""
|
@State private var argsText: String = ""
|
||||||
@State private var url: String = ""
|
@State private var url: String = ""
|
||||||
@State private var auth: String = "none"
|
@State private var auth: String = "none"
|
||||||
@State private var sseReadTimeout: String = ""
|
|
||||||
|
|
||||||
/// `.sse` is a v0.13+ surface; pre-v0.13 hosts only see stdio + http.
|
|
||||||
/// Iterating `MCPTransport.allCases` directly would render the SSE
|
|
||||||
/// segment unconditionally and Hermes would reject the resulting CLI
|
|
||||||
/// invocation at argparse time.
|
|
||||||
private var availableTransports: [MCPTransport] {
|
|
||||||
var t: [MCPTransport] = [.stdio, .http]
|
|
||||||
if capabilitiesStore?.capabilities.hasMCPSSETransport ?? false {
|
|
||||||
t.append(.sse)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
@@ -58,20 +44,17 @@ struct MCPServerAddCustomView: View {
|
|||||||
}
|
}
|
||||||
sectionBox(title: "Transport") {
|
sectionBox(title: "Transport") {
|
||||||
Picker("", selection: $transport) {
|
Picker("", selection: $transport) {
|
||||||
ForEach(availableTransports) { t in
|
ForEach(MCPTransport.allCases) { t in
|
||||||
Text(t.displayName).tag(t)
|
Text(t.displayName).tag(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.segmented)
|
.pickerStyle(.segmented)
|
||||||
.labelsHidden()
|
.labelsHidden()
|
||||||
}
|
}
|
||||||
switch transport {
|
if transport == .stdio {
|
||||||
case .stdio:
|
|
||||||
stdioSection
|
stdioSection
|
||||||
case .http:
|
} else {
|
||||||
httpSection
|
httpSection
|
||||||
case .sse:
|
|
||||||
sseSection
|
|
||||||
}
|
}
|
||||||
Text("Env vars, headers, and tool filters can be edited after the server is added.")
|
Text("Env vars, headers, and tool filters can be edited after the server is added.")
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
@@ -129,28 +112,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var sseSection: some View {
|
|
||||||
sectionBox(title: "Endpoint (SSE)") {
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text("URL").font(.caption.bold())
|
|
||||||
TextField("https://.../sse", text: $url)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.font(.system(.body, design: .monospaced))
|
|
||||||
}
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text("SSE Read Timeout (seconds)").font(.caption.bold())
|
|
||||||
TextField("default 300", text: $sseReadTimeout)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.frame(maxWidth: 140)
|
|
||||||
Text("Hermes-side keepalive interval. Leave blank to use the default.")
|
|
||||||
.font(.caption2)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var canSubmit: Bool {
|
private var canSubmit: Bool {
|
||||||
let trimmedName = name.trimmingCharacters(in: .whitespaces)
|
let trimmedName = name.trimmingCharacters(in: .whitespaces)
|
||||||
guard !trimmedName.isEmpty else { return false }
|
guard !trimmedName.isEmpty else { return false }
|
||||||
@@ -159,8 +120,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
return !command.trimmingCharacters(in: .whitespaces).isEmpty
|
return !command.trimmingCharacters(in: .whitespaces).isEmpty
|
||||||
case .http:
|
case .http:
|
||||||
return !url.trimmingCharacters(in: .whitespaces).isEmpty
|
return !url.trimmingCharacters(in: .whitespaces).isEmpty
|
||||||
case .sse:
|
|
||||||
return !url.trimmingCharacters(in: .whitespaces).isEmpty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,8 +130,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
.map { $0.trimmingCharacters(in: .whitespaces) }
|
.map { $0.trimmingCharacters(in: .whitespaces) }
|
||||||
.filter { !$0.isEmpty }
|
.filter { !$0.isEmpty }
|
||||||
let resolvedAuth: String? = (auth == "none") ? nil : auth
|
let resolvedAuth: String? = (auth == "none") ? nil : auth
|
||||||
switch transport {
|
|
||||||
case .stdio, .http:
|
|
||||||
viewModel.addCustom(
|
viewModel.addCustom(
|
||||||
name: trimmedName,
|
name: trimmedName,
|
||||||
transport: transport,
|
transport: transport,
|
||||||
@@ -181,15 +138,6 @@ struct MCPServerAddCustomView: View {
|
|||||||
url: url.trimmingCharacters(in: .whitespaces),
|
url: url.trimmingCharacters(in: .whitespaces),
|
||||||
auth: resolvedAuth
|
auth: resolvedAuth
|
||||||
)
|
)
|
||||||
case .sse:
|
|
||||||
let trimmedTimeout = sseReadTimeout.trimmingCharacters(in: .whitespaces)
|
|
||||||
let parsedTimeout: Int? = trimmedTimeout.isEmpty ? nil : Int(trimmedTimeout)
|
|
||||||
viewModel.addCustomSSE(
|
|
||||||
name: trimmedName,
|
|
||||||
url: url.trimmingCharacters(in: .whitespaces),
|
|
||||||
sseReadTimeout: parsedTimeout
|
|
||||||
)
|
|
||||||
}
|
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,11 +127,6 @@ struct MCPServerDetailView: View {
|
|||||||
if let auth = server.auth, !auth.isEmpty {
|
if let auth = server.auth, !auth.isEmpty {
|
||||||
summaryRow(label: "Auth", value: auth)
|
summaryRow(label: "Auth", value: auth)
|
||||||
}
|
}
|
||||||
case .sse:
|
|
||||||
summaryRow(label: "URL", value: server.url ?? "—")
|
|
||||||
if let timeout = server.sseReadTimeout {
|
|
||||||
summaryRow(label: "Read TO", value: "\(timeout)s")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(ScarfSpace.s3)
|
.padding(ScarfSpace.s3)
|
||||||
|
|||||||
@@ -186,16 +186,6 @@ struct MCPServerEditorView: View {
|
|||||||
.textFieldStyle(.roundedBorder)
|
.textFieldStyle(.roundedBorder)
|
||||||
.frame(maxWidth: 140)
|
.frame(maxWidth: 140)
|
||||||
}
|
}
|
||||||
if viewModel.server.transport == .sse {
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text("SSE read timeout")
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
TextField("default 300", text: $viewModel.sseReadTimeoutDraft)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.frame(maxWidth: 140)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,14 +132,6 @@ struct MCPServersView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !viewModel.sseServers.isEmpty {
|
|
||||||
Section("Remote (SSE)") {
|
|
||||||
ForEach(viewModel.sseServers) { server in
|
|
||||||
serverRow(server)
|
|
||||||
.tag(server.name as String?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if viewModel.servers.isEmpty && !viewModel.isLoading {
|
if viewModel.servers.isEmpty && !viewModel.isLoading {
|
||||||
Section {
|
Section {
|
||||||
Text("No servers configured yet")
|
Text("No servers configured yet")
|
||||||
|
|||||||
@@ -112,17 +112,10 @@ final class ProfilesViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func create(name: String, cloneConfig: Bool, cloneAll: Bool, noSkills: Bool = false) {
|
func create(name: String, cloneConfig: Bool, cloneAll: Bool) {
|
||||||
var args = ["profile", "create", name]
|
var args = ["profile", "create", name]
|
||||||
if cloneAll { args.append("--clone-all") }
|
if cloneAll { args.append("--clone-all") }
|
||||||
else if cloneConfig { args.append("--clone") }
|
else if cloneConfig { args.append("--clone") }
|
||||||
// v0.13+: Empty-profile creation. The wire is independent of
|
|
||||||
// --clone / --clone-all per the v0.13 release notes — the user
|
|
||||||
// can stack `--clone --no-skills` to clone config but skip
|
|
||||||
// skills, which is a plausible workflow. The UI still disables
|
|
||||||
// the toggle under --clone-all (Decision H, see ProfilesView)
|
|
||||||
// but the wire is permissive.
|
|
||||||
if noSkills { args.append("--no-skills") }
|
|
||||||
runAndReload(args, success: "Profile '\(name)' created")
|
runAndReload(args, success: "Profile '\(name)' created")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,7 @@ struct ProfilesView: View {
|
|||||||
@State private var createName = ""
|
@State private var createName = ""
|
||||||
@State private var createCloneConfig = true
|
@State private var createCloneConfig = true
|
||||||
@State private var createCloneAll = false
|
@State private var createCloneAll = false
|
||||||
/// v0.13+ `--no-skills` toggle. Mutually exclusive with `--clone-all`
|
|
||||||
/// at the UX layer (Decision H from the WS-7 plan): a full clone
|
|
||||||
/// copies skills wholesale — `--no-skills` would be a contradiction.
|
|
||||||
@State private var createNoSkills = false
|
|
||||||
@State private var showRename = false
|
@State private var showRename = false
|
||||||
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
|
||||||
|
|
||||||
init(context: ServerContext) {
|
init(context: ServerContext) {
|
||||||
_viewModel = State(initialValue: ProfilesViewModel(context: context))
|
_viewModel = State(initialValue: ProfilesViewModel(context: context))
|
||||||
@@ -128,7 +123,7 @@ struct ProfilesView: View {
|
|||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
Button {
|
Button {
|
||||||
createName = ""; createCloneConfig = true; createCloneAll = false; createNoSkills = false
|
createName = ""; createCloneConfig = true; createCloneAll = false
|
||||||
showCreate = true
|
showCreate = true
|
||||||
} label: {
|
} label: {
|
||||||
Label("Create", systemImage: "plus")
|
Label("Create", systemImage: "plus")
|
||||||
@@ -305,31 +300,11 @@ struct ProfilesView: View {
|
|||||||
Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig)
|
Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig)
|
||||||
.disabled(createCloneAll)
|
.disabled(createCloneAll)
|
||||||
Toggle("Full copy of active profile (all state)", isOn: $createCloneAll)
|
Toggle("Full copy of active profile (all state)", isOn: $createCloneAll)
|
||||||
// TODO(WS-7-Q8): Decision H — disable --no-skills when --clone-all
|
|
||||||
// is on. A full clone copies skills wholesale; --no-skills would
|
|
||||||
// be a contradiction. Verify Hermes's behaviour with both flags
|
|
||||||
// (argparse mutual exclusion vs. last-flag-wins vs. clone-but-
|
|
||||||
// skip-skills) and relax the disabled state if Hermes does
|
|
||||||
// something useful with the combination.
|
|
||||||
if capabilitiesStore?.capabilities.hasProfileNoSkills ?? false {
|
|
||||||
Toggle("Empty profile (no skills)", isOn: $createNoSkills)
|
|
||||||
.disabled(createCloneAll)
|
|
||||||
}
|
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("Cancel") { showCreate = false }
|
Button("Cancel") { showCreate = false }
|
||||||
Button("Create") {
|
Button("Create") {
|
||||||
viewModel.create(
|
viewModel.create(name: createName, cloneConfig: createCloneConfig, cloneAll: createCloneAll)
|
||||||
name: createName,
|
|
||||||
cloneConfig: createCloneConfig,
|
|
||||||
cloneAll: createCloneAll,
|
|
||||||
// Defensive: if the toggle isn't visible (pre-v0.13)
|
|
||||||
// the state is always `false`, but read it through
|
|
||||||
// the capability gate anyway so a stale state value
|
|
||||||
// can't sneak `--no-skills` to a CLI that doesn't
|
|
||||||
// know it.
|
|
||||||
noSkills: (capabilitiesStore?.capabilities.hasProfileNoSkills ?? false) ? createNoSkills : false
|
|
||||||
)
|
|
||||||
showCreate = false
|
showCreate = false
|
||||||
}
|
}
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
|
|||||||
@@ -143,16 +143,6 @@ final class SettingsViewModel {
|
|||||||
func setBrowserAllowPrivateURLs(_ value: Bool) { setSetting("browser.allow_private_urls", value: value ? "true" : "false") }
|
func setBrowserAllowPrivateURLs(_ value: Bool) { setSetting("browser.allow_private_urls", value: value ? "true" : "false") }
|
||||||
func setCamofoxManagedPersistence(_ value: Bool) { setSetting("browser.camofox.managed_persistence", value: value ? "true" : "false") }
|
func setCamofoxManagedPersistence(_ value: Bool) { setSetting("browser.camofox.managed_persistence", value: value ? "true" : "false") }
|
||||||
|
|
||||||
// MARK: - Web Tools
|
|
||||||
|
|
||||||
/// Pre-v0.13 combined backend. Pre-v0.13 hosts read this; v0.13+
|
|
||||||
/// hosts read it for back-compat but the WebToolsTab gates writes
|
|
||||||
/// on `hasWebToolsBackendSplit` so the tab only writes the split
|
|
||||||
/// keys on v0.13.
|
|
||||||
func setWebToolsBackend(_ value: String) { setSetting("web_tools.backend", value: value) }
|
|
||||||
func setWebToolsSearchBackend(_ value: String) { setSetting("web_tools.search.backend", value: value) }
|
|
||||||
func setWebToolsExtractBackend(_ value: String) { setSetting("web_tools.extract.backend", value: value) }
|
|
||||||
|
|
||||||
// MARK: - Voice / TTS / STT
|
// MARK: - Voice / TTS / STT
|
||||||
|
|
||||||
func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") }
|
func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") }
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ struct SettingsView: View {
|
|||||||
case agent = "Agent"
|
case agent = "Agent"
|
||||||
case terminal = "Terminal"
|
case terminal = "Terminal"
|
||||||
case browser = "Browser"
|
case browser = "Browser"
|
||||||
case webTools = "Web Tools"
|
|
||||||
case voice = "Voice"
|
case voice = "Voice"
|
||||||
case memory = "Memory"
|
case memory = "Memory"
|
||||||
case auxiliary = "Aux Models"
|
case auxiliary = "Aux Models"
|
||||||
@@ -42,7 +41,6 @@ struct SettingsView: View {
|
|||||||
case .agent: return "Agent"
|
case .agent: return "Agent"
|
||||||
case .terminal: return "Terminal"
|
case .terminal: return "Terminal"
|
||||||
case .browser: return "Browser"
|
case .browser: return "Browser"
|
||||||
case .webTools: return "Web Tools"
|
|
||||||
case .voice: return "Voice"
|
case .voice: return "Voice"
|
||||||
case .memory: return "Memory"
|
case .memory: return "Memory"
|
||||||
case .auxiliary: return "Aux Models"
|
case .auxiliary: return "Aux Models"
|
||||||
@@ -58,7 +56,6 @@ struct SettingsView: View {
|
|||||||
case .agent: return "brain.head.profile"
|
case .agent: return "brain.head.profile"
|
||||||
case .terminal: return "terminal"
|
case .terminal: return "terminal"
|
||||||
case .browser: return "globe"
|
case .browser: return "globe"
|
||||||
case .webTools: return "globe.americas"
|
|
||||||
case .voice: return "mic"
|
case .voice: return "mic"
|
||||||
case .memory: return "memorychip"
|
case .memory: return "memorychip"
|
||||||
case .auxiliary: return "sparkles.rectangle.stack"
|
case .auxiliary: return "sparkles.rectangle.stack"
|
||||||
@@ -174,7 +171,6 @@ struct SettingsView: View {
|
|||||||
case .agent: AgentTab(viewModel: viewModel)
|
case .agent: AgentTab(viewModel: viewModel)
|
||||||
case .terminal: TerminalTab(viewModel: viewModel)
|
case .terminal: TerminalTab(viewModel: viewModel)
|
||||||
case .browser: BrowserTab(viewModel: viewModel)
|
case .browser: BrowserTab(viewModel: viewModel)
|
||||||
case .webTools: WebToolsTab(viewModel: viewModel)
|
|
||||||
case .voice: VoiceTab(viewModel: viewModel)
|
case .voice: VoiceTab(viewModel: viewModel)
|
||||||
case .memory: MemoryTab(viewModel: viewModel)
|
case .memory: MemoryTab(viewModel: viewModel)
|
||||||
case .auxiliary: AuxiliaryTab(viewModel: viewModel)
|
case .auxiliary: AuxiliaryTab(viewModel: viewModel)
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
import SwiftUI
|
|
||||||
import ScarfCore
|
|
||||||
import ScarfDesign
|
|
||||||
|
|
||||||
/// Web Tools tab — search + extract backend pickers. Pre-v0.13 hosts
|
|
||||||
/// see a single "Combined backend" row writing to the legacy
|
|
||||||
/// `web_tools.backend` key. v0.13+ hosts see two rows writing to the
|
|
||||||
/// per-capability split keys (`web_tools.search.backend` +
|
|
||||||
/// `web_tools.extract.backend`); SearXNG appears in the search picker
|
|
||||||
/// only because Hermes registers it as a search-only backend.
|
|
||||||
struct WebToolsTab: View {
|
|
||||||
@Bindable var viewModel: SettingsViewModel
|
|
||||||
@Environment(\.hermesCapabilities) private var capabilitiesStore
|
|
||||||
|
|
||||||
private var split: Bool {
|
|
||||||
capabilitiesStore?.capabilities.hasWebToolsBackendSplit ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(WS-7-Q6): Backend lists are curated inline based on the v0.13
|
|
||||||
// release notes ("SearXNG joined search-only"). The exact dispatch
|
|
||||||
// table lives in `~/.hermes/hermes-agent/hermes_cli/web_tools.py` —
|
|
||||||
// verify during integration. A wrong entry just produces a
|
|
||||||
// `hermes config set` failure on save (recoverable, not silent).
|
|
||||||
private static let searchBackends: [String] = [
|
|
||||||
"duckduckgo", "tavily", "brave", "exa", "you", "searxng"
|
|
||||||
]
|
|
||||||
private static let extractBackends: [String] = [
|
|
||||||
"reader", "browserless", "trafilatura", "firecrawl"
|
|
||||||
]
|
|
||||||
/// v0.12 combined-backend list — superset of the v0.13 search list
|
|
||||||
/// minus SearXNG (which only dispatches as search) plus the v0.13
|
|
||||||
/// extract-only entries that pre-v0.13 hosts handled under the
|
|
||||||
/// combined key.
|
|
||||||
private static let combinedBackends: [String] = [
|
|
||||||
"duckduckgo", "tavily", "brave", "exa", "you",
|
|
||||||
"reader", "browserless", "trafilatura", "firecrawl"
|
|
||||||
]
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
if split {
|
|
||||||
SettingsSection(title: "Web Tools", icon: "globe.americas") {
|
|
||||||
PickerRow(
|
|
||||||
label: "Search backend",
|
|
||||||
selection: viewModel.config.webToolsSearchBackend,
|
|
||||||
options: Self.searchBackends
|
|
||||||
) { viewModel.setWebToolsSearchBackend($0) }
|
|
||||||
PickerRow(
|
|
||||||
label: "Extract backend",
|
|
||||||
selection: viewModel.config.webToolsExtractBackend,
|
|
||||||
options: Self.extractBackends
|
|
||||||
) { viewModel.setWebToolsExtractBackend($0) }
|
|
||||||
}
|
|
||||||
Text("SearXNG joined v0.13 as a search-only backend. Backend-specific tuning (host URLs, API keys) lives in the raw YAML editor for now.")
|
|
||||||
.scarfStyle(.caption)
|
|
||||||
.foregroundStyle(ScarfColor.foregroundMuted)
|
|
||||||
.padding(.horizontal, ScarfSpace.s4)
|
|
||||||
} else {
|
|
||||||
// TODO(WS-7-Q7): Pre-v0.13 hosts fall back to the legacy single
|
|
||||||
// backend. v0.13 may or may not honour `web_tools.backend` as a
|
|
||||||
// fallback when the split keys are absent — verify with Hermes
|
|
||||||
// and consider a one-time migration prompt in a follow-up if
|
|
||||||
// upgrading from v0.12 silently resets the user's backend.
|
|
||||||
SettingsSection(title: "Web Tools", icon: "globe.americas") {
|
|
||||||
PickerRow(
|
|
||||||
label: "Backend",
|
|
||||||
selection: viewModel.config.webToolsBackend,
|
|
||||||
options: Self.combinedBackends
|
|
||||||
) { viewModel.setWebToolsBackend($0) }
|
|
||||||
}
|
|
||||||
Text("Hermes v0.13 splits search and extract into separate backends. Update Hermes to access the per-capability picker.")
|
|
||||||
.scarfStyle(.caption)
|
|
||||||
.foregroundStyle(ScarfColor.foregroundFaint)
|
|
||||||
.padding(.horizontal, ScarfSpace.s4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user