refactor: update macOS config paths
This commit is contained in:
@@ -61,22 +61,22 @@ enum ClawdisConfigFile {
|
||||
self.saveDict(root)
|
||||
}
|
||||
|
||||
static func inboundWorkspace() -> String? {
|
||||
static func agentWorkspace() -> String? {
|
||||
let root = self.loadDict()
|
||||
let inbound = root["inbound"] as? [String: Any]
|
||||
return inbound?["workspace"] as? String
|
||||
let agent = root["agent"] as? [String: Any]
|
||||
return agent?["workspace"] as? String
|
||||
}
|
||||
|
||||
static func setInboundWorkspace(_ workspace: String?) {
|
||||
static func setAgentWorkspace(_ workspace: String?) {
|
||||
var root = self.loadDict()
|
||||
var inbound = root["inbound"] as? [String: Any] ?? [:]
|
||||
var agent = root["agent"] as? [String: Any] ?? [:]
|
||||
let trimmed = workspace?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
if trimmed.isEmpty {
|
||||
inbound.removeValue(forKey: "workspace")
|
||||
agent.removeValue(forKey: "workspace")
|
||||
} else {
|
||||
inbound["workspace"] = trimmed
|
||||
agent["workspace"] = trimmed
|
||||
}
|
||||
root["inbound"] = inbound
|
||||
root["agent"] = agent
|
||||
self.saveDict(root)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ struct ConfigSettings: View {
|
||||
private var header: some View {
|
||||
Text("Clawdis CLI config")
|
||||
.font(.title3.weight(.semibold))
|
||||
Text("Edit ~/.clawdis/clawdis.json (inbound.agent / inbound.session).")
|
||||
Text("Edit ~/.clawdis/clawdis.json (agent / inbound.session).")
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
@@ -274,11 +274,9 @@ struct ConfigSettings: View {
|
||||
|
||||
private func loadConfig() {
|
||||
let parsed = self.loadConfigDict()
|
||||
let inbound = parsed["inbound"] as? [String: Any]
|
||||
let reply = inbound?["reply"] as? [String: Any]
|
||||
let agent = reply?["agent"] as? [String: Any]
|
||||
let heartbeatMinutes = reply?["heartbeatMinutes"] as? Int
|
||||
let heartbeatBody = reply?["heartbeatBody"] as? String
|
||||
let agent = parsed["agent"] as? [String: Any]
|
||||
let heartbeatMinutes = agent?["heartbeatMinutes"] as? Int
|
||||
let heartbeatBody = agent?["heartbeatBody"] as? String
|
||||
let browser = parsed["browser"] as? [String: Any]
|
||||
|
||||
let loadedModel = (agent?["model"] as? String) ?? ""
|
||||
@@ -312,9 +310,7 @@ struct ConfigSettings: View {
|
||||
defer { self.configSaving = false }
|
||||
|
||||
var root = self.loadConfigDict()
|
||||
var inbound = root["inbound"] as? [String: Any] ?? [:]
|
||||
var reply = inbound["reply"] as? [String: Any] ?? [:]
|
||||
var agent = reply["agent"] as? [String: Any] ?? [:]
|
||||
var agent = root["agent"] as? [String: Any] ?? [:]
|
||||
var browser = root["browser"] as? [String: Any] ?? [:]
|
||||
|
||||
let chosenModel = (self.configModel == "__custom__" ? self.customModel : self.configModel)
|
||||
@@ -322,19 +318,16 @@ struct ConfigSettings: View {
|
||||
let trimmedModel = chosenModel
|
||||
if !trimmedModel.isEmpty { agent["model"] = trimmedModel }
|
||||
|
||||
reply["agent"] = agent
|
||||
|
||||
if let heartbeatMinutes {
|
||||
reply["heartbeatMinutes"] = heartbeatMinutes
|
||||
agent["heartbeatMinutes"] = heartbeatMinutes
|
||||
}
|
||||
|
||||
let trimmedBody = self.heartbeatBody.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if !trimmedBody.isEmpty {
|
||||
reply["heartbeatBody"] = trimmedBody
|
||||
agent["heartbeatBody"] = trimmedBody
|
||||
}
|
||||
|
||||
inbound["reply"] = reply
|
||||
root["inbound"] = inbound
|
||||
root["agent"] = agent
|
||||
|
||||
browser["enabled"] = self.browserEnabled
|
||||
let trimmedUrl = self.browserControlUrl.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
@@ -164,8 +164,7 @@ enum DebugActions {
|
||||
let data = try? Data(contentsOf: configURL),
|
||||
let parsed = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
||||
let inbound = parsed["inbound"] as? [String: Any],
|
||||
let reply = inbound["reply"] as? [String: Any],
|
||||
let session = reply["session"] as? [String: Any],
|
||||
let session = inbound["session"] as? [String: Any],
|
||||
let path = session["store"] as? String,
|
||||
!path.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||
else {
|
||||
|
||||
@@ -682,8 +682,7 @@ struct DebugSettings: View {
|
||||
let data = try? Data(contentsOf: url),
|
||||
let parsed = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
||||
let inbound = parsed["inbound"] as? [String: Any],
|
||||
let reply = inbound["reply"] as? [String: Any],
|
||||
let session = reply["session"] as? [String: Any],
|
||||
let session = inbound["session"] as? [String: Any],
|
||||
let path = session["store"] as? String
|
||||
else {
|
||||
self.sessionStorePath = SessionLoader.defaultStorePath
|
||||
@@ -703,11 +702,9 @@ struct DebugSettings: View {
|
||||
}
|
||||
|
||||
var inbound = root["inbound"] as? [String: Any] ?? [:]
|
||||
var reply = inbound["reply"] as? [String: Any] ?? [:]
|
||||
var session = reply["session"] as? [String: Any] ?? [:]
|
||||
var session = inbound["session"] as? [String: Any] ?? [:]
|
||||
session["store"] = trimmed.isEmpty ? SessionLoader.defaultStorePath : trimmed
|
||||
reply["session"] = session
|
||||
inbound["reply"] = reply
|
||||
inbound["session"] = session
|
||||
root["inbound"] = inbound
|
||||
|
||||
do {
|
||||
|
||||
@@ -881,8 +881,8 @@ struct OnboardingView: View {
|
||||
|
||||
Button("Save in config") {
|
||||
let url = AgentWorkspace.resolveWorkspaceURL(from: self.workspacePath)
|
||||
ClawdisConfigFile.setInboundWorkspace(AgentWorkspace.displayPath(for: url))
|
||||
self.workspaceStatus = "Saved to ~/.clawdis/clawdis.json (inbound.workspace)"
|
||||
ClawdisConfigFile.setAgentWorkspace(AgentWorkspace.displayPath(for: url))
|
||||
self.workspaceStatus = "Saved to ~/.clawdis/clawdis.json (agent.workspace)"
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.disabled(self.workspaceApplying)
|
||||
@@ -1268,7 +1268,7 @@ struct OnboardingView: View {
|
||||
|
||||
private func loadWorkspaceDefaults() {
|
||||
guard self.workspacePath.isEmpty else { return }
|
||||
let configured = ClawdisConfigFile.inboundWorkspace()
|
||||
let configured = ClawdisConfigFile.agentWorkspace()
|
||||
let url = AgentWorkspace.resolveWorkspaceURL(from: configured)
|
||||
self.workspacePath = AgentWorkspace.displayPath(for: url)
|
||||
self.refreshBootstrapStatus()
|
||||
@@ -1276,14 +1276,14 @@ struct OnboardingView: View {
|
||||
|
||||
private func ensureDefaultWorkspace() {
|
||||
guard self.state.connectionMode == .local else { return }
|
||||
let configured = ClawdisConfigFile.inboundWorkspace()
|
||||
let configured = ClawdisConfigFile.agentWorkspace()
|
||||
let url = AgentWorkspace.resolveWorkspaceURL(from: configured)
|
||||
switch AgentWorkspace.bootstrapSafety(for: url) {
|
||||
case .safe:
|
||||
do {
|
||||
_ = try AgentWorkspace.bootstrap(workspaceURL: url)
|
||||
if (configured ?? "").trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
ClawdisConfigFile.setInboundWorkspace(AgentWorkspace.displayPath(for: url))
|
||||
ClawdisConfigFile.setAgentWorkspace(AgentWorkspace.displayPath(for: url))
|
||||
}
|
||||
} catch {
|
||||
self.workspaceStatus = "Failed to create workspace: \(error.localizedDescription)"
|
||||
|
||||
Reference in New Issue
Block a user