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