Chrome screenshots can be saved for the human

This commit is contained in:
Ian Gulliver
2026-10-18 11:57:14 -07:00
parent e170da1c3a
commit aac99c48f9
4 changed files with 13 additions and 5 deletions
+6 -2
View File
@@ -139,10 +139,14 @@ func captureTool(_ args: [String: Any]) async throws -> [Content] {
guard args.bool("save") else {
return [.text(shot.note), .png(shot.png)]
}
return [.text("\(shot.note); saved to \(try save(shot.png))"), .png(shot.png)]
}
func save(_ png: Data) throws -> String {
guard let dir = mediaDir else {
throw ToolError("save needs byre's media folder, and this byre-hands has none")
}
let url = URL(filePath: dir).appending(path: "capture-\(UUID().uuidString.prefix(8).lowercased()).png")
try shot.png.write(to: url)
return [.text("\(shot.note); saved to \(url.path)"), .png(shot.png)]
try png.write(to: url)
return url.path
}