跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

macos-diagnostics-test.swift

33 行 · 2.0 KB历史下载
1import Foundation
2
3@main
4struct MacDiagnosticTest {
5 static func main() throws {
6 let temporary = FileManager.default.temporaryDirectory.appendingPathComponent("cage-native-diagnostics-" + UUID().uuidString)
7 try FileManager.default.createDirectory(at: temporary, withIntermediateDirectories: false)
8 defer { try? FileManager.default.removeItem(at: temporary) }
9 let logs = temporary.appendingPathComponent("Library/Logs/Cage")
10 try GuestDiagnostic.append("window", "window_changed", directory: logs)
11 try GuestDiagnostic.append("clipboard", "clipboard_write_failed", directory: logs)
12 let file = logs.appendingPathComponent("window.jsonl")
13 let original = try Data(contentsOf: file)
14 try GuestDiagnostic.append("window", "password=private-secret", directory: logs)
15 guard try Data(contentsOf: file) == original else { throw CocoaError(.fileWriteUnknown) }
16 for _ in 0..<7 {
17 try Data(repeating: 120, count: 1 << 20).write(to: file)
18 try GuestDiagnostic.append("window", "frame_unavailable", directory: logs)
19 }
20 let names = try FileManager.default.contentsOfDirectory(atPath: logs.path)
21 guard names.filter({ $0.hasPrefix("window") && $0.hasSuffix(".jsonl") }).count == 5 else { throw CocoaError(.fileWriteUnknown) }
22 let target = temporary.appendingPathComponent("preserved.txt")
23 try Data("preserved".utf8).write(to: target)
24 try FileManager.default.removeItem(at: file)
25 try FileManager.default.createSymbolicLink(at: file, withDestinationURL: target)
26 do {
27 try GuestDiagnostic.append("window", "window_changed", directory: logs)
28 throw CocoaError(.fileWriteUnknown)
29 } catch CocoaError.fileReadNoPermission { }
30 guard try Data(contentsOf: target) == Data("preserved".utf8) else { throw CocoaError(.fileWriteUnknown) }
31 print("Native macOS diagnostic schema, rotation and link rejection passed.")
32 }
33}