Download apps/desktop/src/lib/preview-annotate/flush.ts from SaylorTwift/hermes-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/apps/desktop/src/lib/preview-annotate/flush.ts
- Command line
-
hf download hf://SaylorTwift/hermes-agent/apps/desktop/src/lib/preview-annotate/flush.ts
-
curl -L -o flush.ts https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/apps/desktop/src/lib/preview-annotate/flush.ts
1.09 kB
| import { annotateFlushPrompt, dataUrlToFile, packageAnnotateStack } from './pack' | |
| import type { AnnotatePin } from './stack' | |
| export interface AnnotateFlushPorts { | |
| attachImage: (blob: Blob) => void | Promise<void> | |
| insertText: (text: string) => void | |
| send?: () => void | |
| } | |
| export interface AnnotateFlushResult { | |
| count: number | |
| prompt: string | |
| sent: false | |
| } | |
| /** | |
| * Attach every pin to the composer as a numbered crop plus the packed prompt. | |
| * Saving / flushing never submits a turn — `send` is accepted so tests can | |
| * prove it stays untouched. | |
| */ | |
| export async function flushAnnotateStack( | |
| pins: readonly AnnotatePin[], | |
| ports: AnnotateFlushPorts, | |
| pageUrl?: string | |
| ): Promise<AnnotateFlushResult> { | |
| const items = packageAnnotateStack(pins) | |
| for (const item of items) { | |
| if (item.imageDataUrl) { | |
| await ports.attachImage(dataUrlToFile(item.imageDataUrl, `Comment_${item.number}.png`)) | |
| } | |
| } | |
| const prompt = annotateFlushPrompt(items, pageUrl) | |
| if (prompt.trim()) { | |
| ports.insertText(prompt) | |
| } | |
| return { count: items.length, prompt, sent: false } | |
| } | |