Console widgets get an appendImage / respond.image API on the agent. read_widget_state surfaces image entries as attachments scaled to at most max_dimension pixels (default 1568) on the longest edge. Anthropic nests image blocks inside tool_result; OpenAI gets a synthetic follow-up user message. The host scales via CoreImage on macOS and GdkPixbuf on GTK.
24 lines
765 B
Swift
24 lines
765 B
Swift
import Foundation
|
|
|
|
public struct ProcessedImage: Sendable, Equatable {
|
|
public var mediaType: String
|
|
public var data: Data
|
|
public var width: Int
|
|
public var height: Int
|
|
|
|
public init(mediaType: String, data: Data, width: Int, height: Int) {
|
|
self.mediaType = mediaType
|
|
self.data = data
|
|
self.width = width
|
|
self.height = height
|
|
}
|
|
}
|
|
|
|
public protocol ImageProcessor: Sendable {
|
|
/// Decode `data` (PNG, JPEG, etc.) and return a re-encoded PNG whose
|
|
/// longest edge is at most `maxDimension`. If the image already fits,
|
|
/// the original may be returned unchanged. Returns nil if the input
|
|
/// cannot be decoded.
|
|
func scaleDown(data: Data, mediaType: String, maxDimension: Int) -> ProcessedImage?
|
|
}
|