feat(mcp): Vorschau von Ausgangsbelegen mit Seitenbildern und Umbruchprüfung
- accounting.outgoing_documents.preview rendert den Beleg wie der Editor und liefert Seiten als PNG-Bilder im MCP-Ergebnis - Layout je Seite in mm mit Warnungen zu übervollen Seiten, allein stehenden Überschriften, leeren Seiten und vom Überweisungs-QR-Code überdeckten Beträgen samt Vorschlag für den Seitenumbruch - rows testet geänderte Positionen samt Seitenumbrüchen, ohne zu speichern - Belegdaten für das PDF als Backend-Port von getDocumentData (Titelsummen, Überträge, Abschläge, Optional-/Alternativpositionen) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,12 @@ import { McpToolResult } from "./types"
|
||||
|
||||
const OMIT_ARCHIVED = Symbol("omit-archived")
|
||||
|
||||
/** Attach images to a tool payload; they become MCP image content next to the JSON text. */
|
||||
export const MCP_IMAGES = Symbol("mcp-images")
|
||||
export type McpImage = { data: string, mimeType: string }
|
||||
export const withImages = <T extends Record<string, unknown>>(payload: T, images: McpImage[]) =>
|
||||
Object.assign(payload, { [MCP_IMAGES]: images })
|
||||
|
||||
function omitArchivedRecords(value: unknown): unknown | typeof OMIT_ARCHIVED {
|
||||
if (Array.isArray(value)) {
|
||||
return value
|
||||
@@ -32,12 +38,15 @@ export function asToolResult(payload: unknown): McpToolResult {
|
||||
? resultPayload as Record<string, unknown>
|
||||
: { result: resultPayload }
|
||||
|
||||
const images: McpImage[] = (payload as any)?.[MCP_IMAGES] || []
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(resultPayload, null, 2),
|
||||
},
|
||||
...images.map((image) => ({ type: "image" as const, data: image.data, mimeType: image.mimeType })),
|
||||
],
|
||||
structuredContent,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user