跳到主要内容

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

浏览文件

macos_editor_file.swift

23 行 · 1.0 KB历史下载
1// Locate the exact temporary file in the real guest editor's Explorer image.
2// No desktop capture or external service is involved.
3import AppKit
4import Vision
5
6guard CommandLine.arguments.count == 3,
7 let image = NSImage(contentsOfFile: CommandLine.arguments[1]),
8 let cg = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else { exit(2) }
9let name = CommandLine.arguments[2]
10let request = VNRecognizeTextRequest()
11request.recognitionLevel = .accurate
12request.usesLanguageCorrection = false
13try VNImageRequestHandler(cgImage: cg).perform([request])
14for result in request.results ?? [] {
15 guard result.topCandidates(3).contains(where: { $0.string.hasSuffix(name) }) else { continue }
16 let b = result.boundingBox
17 // A matching name in the tab bar or a Quick Open field does not identify
18 // the Explorer item. Require the left pane below the workbench toolbar.
19 guard b.midX < 0.32, b.midY < 0.85 else { continue }
20 print(Int(b.midX * CGFloat(cg.width)), Int((1 - b.midY) * CGFloat(cg.height)))
21 exit(0)
22}
23exit(1)