Status: ratified — shipped 2026-04-27 (Sources/OpenQuackKit/Output/PasteService.swift)
Owner: OpenQuackKit/Output/
Last updated: 2026-04-26
After the active agent returns .text(String), deposit the text at the cursor position in whatever app is currently focused — the same UX as a system paste.
AXUIElementSetAttributeValue). We use the simpler “pasteboard + simulated ⌘V” idiom, which works in 99 % of apps without Accessibility-tree manipulation.public enum PasteService {
/// Set the text on the general pasteboard, then post a synthetic ⌘V event.
/// Restores the previous pasteboard contents after a short delay.
public static func paste(_ text: String) async throws
/// Just put text on the pasteboard — for the "clipboard-only" Settings option.
public static func copyToClipboard(_ text: String)
}
paste(_:):
NSPasteboard.general contents (string variant; we accept that we can’t perfectly preserve rich types).text to the pasteboard.kCGEventKeyDown for V with .maskCommand, then the matching kCGEventKeyUp.The 600 ms delay covers normal apps; some sluggish ones may miss the restore. Document this and provide a “clipboard-only” mode as an escape hatch.
CGEvents requires Accessibility permission (com.apple.security.accessibility).paste(_:), prompt via AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt: true]).CGEvent.post(tap:) docs.