mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Squash merge of 1,462 upstream commits with openclaw→hanzo-bot naming transforms applied. Conflicts resolved favoring our main branch to preserve existing customizations. Key upstream additions: - iOS Security Stack (concurrency locks, runtime guards, TTS fallback) - Discord CDN hostname allowlisting for SSRF protection - Discord mention handling improvements - Various bug fixes and stability improvements
31 lines
1.0 KiB
Swift
31 lines
1.0 KiB
Swift
import Foundation
|
|
|
|
enum AgentWorkspaceConfig {
|
|
static func workspace(from root: [String: Any]) -> String? {
|
|
let agents = root["agents"] as? [String: Any]
|
|
let defaults = agents?["defaults"] as? [String: Any]
|
|
return defaults?["workspace"] as? String
|
|
}
|
|
|
|
static func setWorkspace(in root: inout [String: Any], workspace: String?) {
|
|
var agents = root["agents"] as? [String: Any] ?? [:]
|
|
var defaults = agents["defaults"] as? [String: Any] ?? [:]
|
|
let trimmed = workspace?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
if trimmed.isEmpty {
|
|
defaults.removeValue(forKey: "workspace")
|
|
} else {
|
|
defaults["workspace"] = trimmed
|
|
}
|
|
if defaults.isEmpty {
|
|
agents.removeValue(forKey: "defaults")
|
|
} else {
|
|
agents["defaults"] = defaults
|
|
}
|
|
if agents.isEmpty {
|
|
root.removeValue(forKey: "agents")
|
|
} else {
|
|
root["agents"] = agents
|
|
}
|
|
}
|
|
}
|