























@@ -5,7 +5,12 @@ enum GatewayLaunchAgentManager {
55private static let disableLaunchAgentMarker = ".openclaw/disable-launchagent"
6677private static var disableLaunchAgentMarkerURL: URL {
8-FileManager().homeDirectoryForCurrentUser
8+#if DEBUG
9+if let testingDisableLaunchAgentMarkerURL {
10+return testingDisableLaunchAgentMarkerURL
11+}
12+#endif
13+return FileManager().homeDirectoryForCurrentUser
914.appendingPathComponent(self.disableLaunchAgentMarker)
1015}
1116@@ -19,6 +24,10 @@ enum GatewayLaunchAgentManager {
1924return false
2025}
212627+static func applyAttachOnlyRuntimeOverride() -> String? {
28+self.setLaunchAgentWriteDisabled(true)
29+}
30+2231static func setLaunchAgentWriteDisabled(_ disabled: Bool) -> String? {
2332let marker = self.disableLaunchAgentMarkerURL
2433if disabled {
@@ -144,6 +153,15 @@ extension GatewayLaunchAgentManager {
144153 timeout: Double,
145154 quiet: Bool) async -> CommandResult
146155{
156+#if DEBUG
157+if self.testingInterceptDaemonCommands {
158+self.testingDaemonCommandCalls.append(args)
159+return CommandResult(
160+ success: true,
161+ payload: Data("{\"ok\":true}".utf8),
162+ message: nil)
163+}
164+#endif
147165let command = CommandResolver.openclawCommand(
148166 subcommand: "gateway",
149167 extraArgs: self.withJsonFlag(args),
@@ -187,4 +205,26 @@ extension GatewayLaunchAgentManager {
187205private static func summarize(_ text: String) -> String? {
188206TextSummarySupport.summarizeLastLine(text)
189207}
208+209+#if DEBUG
210+nonisolated(unsafe) private static var testingDisableLaunchAgentMarkerURL: URL?
211+nonisolated(unsafe) private static var testingInterceptDaemonCommands = false
212+nonisolated(unsafe) private static var testingDaemonCommandCalls: [[String]] = []
213+214+static func setTestingDisableLaunchAgentMarkerURL(_ url: URL?) {
215+self.testingDisableLaunchAgentMarkerURL = url
216+}
217+218+static func setTestingInterceptDaemonCommands(_ intercept: Bool) {
219+self.testingInterceptDaemonCommands = intercept
220+}
221+222+static func clearTestingDaemonCommandCalls() {
223+self.testingDaemonCommandCalls.removeAll(keepingCapacity: false)
224+}
225+226+static func testingDaemonCommandCallsSnapshot() -> [[String]] {
227+self.testingDaemonCommandCalls
228+}
229+#endif
190230}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。