diff --git a/.changeset/current-document-and-video-schemas.md b/.changeset/current-document-and-video-schemas.md new file mode 100644 index 00000000..65739ec9 --- /dev/null +++ b/.changeset/current-document-and-video-schemas.md @@ -0,0 +1,25 @@ +--- +'@transloadit/node': minor +'transloadit': minor +'@transloadit/types': minor +'@transloadit/zod': minor +'@transloadit/mcp-server': patch +--- + +Contract: sync API2’s `/ai/chat` file compatibility, PDF layout extraction, video normalization, +and DAM folder-listing schemas ([#11612](https://github.com/transloadit/api2/pull/11612), +[#11630](https://github.com/transloadit/api2/pull/11630), +[#11657](https://github.com/transloadit/api2/pull/11657), +[#11682](https://github.com/transloadit/api2/pull/11682), +[#11373](https://github.com/transloadit/api2/pull/11373), and +[#11639](https://github.com/transloadit/api2/pull/11639)). + +- `/document/extract` accepts the `docling` text method and `json_layout` format. The layout + output schema describes pages, blocks, and table cells. +- Type-breaking: the parsed `/document/extract` method and format unions include `docling` and + `json_layout`, respectively. Update exhaustive handlers for either union to cover the new value. +- Type-breaking: parsed `RobotDocumentExtractInstructions` now require `keep_page_headers` and + `keep_page_footers`. Both fields are optional on input and default to `false` during parsing. +- Type-breaking: parsed `/video/encode` and `/video/ondemand` Instructions with hidden fields now + include `normalize_hdr`, defaulting to `false`. If you construct either parsed type directly, + set the field. The field remains optional in the corresponding input types. diff --git a/packages/node/src/alphalib/types/robots/_ai-models.ts b/packages/node/src/alphalib/types/robots/_ai-models.ts index 26e26c92..b137bcde 100644 --- a/packages/node/src/alphalib/types/robots/_ai-models.ts +++ b/packages/node/src/alphalib/types/robots/_ai-models.ts @@ -1,26 +1,28 @@ +type AiChatModelInputCapabilities = { pdf: boolean; image: boolean; gif?: true } + /** * Transloadit's supported /ai/chat models and their input capabilities. * This is intentionally not a complete vendor catalog: add models only after runtime behavior, * pricing, and file handling have been reviewed. */ -export const MODEL_CAPABILITIES: Readonly> = +export const MODEL_CAPABILITIES: Readonly> = Object.freeze({ - 'anthropic/claude-sonnet-4-6': { pdf: true, image: true }, - 'anthropic/claude-4-sonnet-20250514': { pdf: true, image: true }, - 'anthropic/claude-sonnet-4-20250514': { pdf: true, image: true }, - 'anthropic/claude-opus-4-8': { pdf: true, image: true }, - 'anthropic/claude-opus-5': { pdf: true, image: true }, - 'anthropic/claude-opus-5-5': { pdf: true, image: true }, - 'anthropic/claude-4-opus-20250514': { pdf: true, image: true }, - 'anthropic/claude-opus-4-20250514': { pdf: true, image: true }, - 'anthropic/claude-sonnet-4-5': { pdf: true, image: true }, - 'anthropic/claude-opus-4-5': { pdf: true, image: true }, - 'anthropic/claude-opus-4-6': { pdf: true, image: true }, - 'anthropic/claude-opus-4-7': { pdf: true, image: true }, - 'anthropic/claude-fable-5': { pdf: true, image: true }, - 'anthropic/claude-fable-5-1': { pdf: true, image: true }, - 'anthropic/claude-sonnet-5': { pdf: true, image: true }, - 'anthropic/claude-sonnet-5-5': { pdf: true, image: true }, + 'anthropic/claude-sonnet-4-6': { pdf: true, image: true, gif: true }, + 'anthropic/claude-4-sonnet-20250514': { pdf: true, image: true, gif: true }, + 'anthropic/claude-sonnet-4-20250514': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-4-8': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-5': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-5-5': { pdf: true, image: true, gif: true }, + 'anthropic/claude-4-opus-20250514': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-4-20250514': { pdf: true, image: true, gif: true }, + 'anthropic/claude-sonnet-4-5': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-4-5': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-4-6': { pdf: true, image: true, gif: true }, + 'anthropic/claude-opus-4-7': { pdf: true, image: true, gif: true }, + 'anthropic/claude-fable-5': { pdf: true, image: true, gif: true }, + 'anthropic/claude-fable-5-1': { pdf: true, image: true, gif: true }, + 'anthropic/claude-sonnet-5': { pdf: true, image: true, gif: true }, + 'anthropic/claude-sonnet-5-5': { pdf: true, image: true, gif: true }, 'openai/gpt-4.1-2025-04-14': { pdf: false, image: true }, 'openai/chatgpt-4o-latest': { pdf: false, image: true }, 'openai/o3-2025-04-16': { pdf: false, image: true }, @@ -44,9 +46,22 @@ export const MODEL_CAPABILITIES: Readonly { + if ( + block.kind === 'list' && + block.markers !== undefined && + block.markers.length !== block.items.length + ) { + context.addIssue({ + code: z.ZodIssueCode.custom, + path: ['markers'], + message: 'Each list item must have a corresponding source marker.', + }) + } + }) + +/** Versioned document extraction output, grouped by original one-based page number. */ +export const documentLayoutOutputSchema = z.object({ + schema_version: z.literal(1), + generator: z.object({ name: z.literal('docling'), document_version: z.string() }).optional(), + pages: z.array( + z.object({ + page: z.number().int().positive(), + width: z.number().positive().optional(), + height: z.number().positive().optional(), + blocks: z.array(documentLayoutBlockSchema), + }), + ), +}) + +/** A serializable content block; text is literal and image names identify retained results. */ +export type DocumentLayoutBlock = z.infer + +/** The contents of a `json_layout` extraction result. */ +export type DocumentLayoutOutput = z.infer diff --git a/packages/node/src/alphalib/types/robots/ai-chat.ts b/packages/node/src/alphalib/types/robots/ai-chat.ts index 87767b4d..7c445111 100644 --- a/packages/node/src/alphalib/types/robots/ai-chat.ts +++ b/packages/node/src/alphalib/types/robots/ai-chat.ts @@ -481,14 +481,13 @@ export const robotAiChatInstructionsSchema = robotBase robot: z .literal('/ai/chat') .describe( - '## Analyze files with an LLM\n\nConnect an input Step explicitly with `use`. Text files are read into the conversation automatically. PDFs require a PDF-capable model; PNG and JPEG inputs require an image-capable model. Convert other document formats to PDF first, and transcribe audio or video to text before using the recording workflows. Provider capabilities alone do not establish support through this Robot.\n\nFor OCR or transcription pipelines, choose `format: "text"` on the upstream Step, then reference that Step with `use` on `/ai/chat`. You do not need to interpolate the file contents into `messages`.\n\nThe `schema` parameter must be a **string containing JSON Schema**, not an inline object. Use `format: "json"` with a serialized schema for structured fields, or `format: "text"` for an answer file. Set `result: true` to expose that file in Assembly Status and download its `ssl_url` to read the answer. Result URLs are temporary; add an export Step for durable storage.\n\nFor production, we recommend using your own Anthropic, OpenAI, or Google account. Store the matching key as `anthropic_api_key`, `openai_api_key`, or `google_generative_ai_api_key` in a Template Credential of the AI Providers type and reference it with `credentials`. With your own account, you have your own provider limits and credits. The provider bills you directly, and Transloadit charges only its fee: 30% of the provider cost, with a minimum fee of $0.0005 per chat request.\n\nTransloadit’s shared provider accounts are a quick way to try things out with `test_credentials: true`. Their credits and capacity are shared by all customers, so your Step can be delayed or refused for reasons outside your control. With these accounts, Transloadit bills the provider cost plus a 30% fee, with a minimum fee of $0.0005 per chat request.\n\nWith either key source, Transloadit retries HTTP 429 limit responses and HTTP 5xx server errors up to twice per model request, waiting between attempts. If the provider keeps rejecting the request, the Step fails. Rejections returned as HTTP 400, 401, or 403 fail without retrying. The minimum fee applies once across the chat request’s model calls. When the Step’s regular data volume charge is higher than the pricing above, that applies instead.\n\nProvider credentials are separate from Transloadit request authentication. The example below uses a Template Credential named `my_anthropic_credentials` and exposes its JSON file with `result: true`. `model: "auto"` resolves to a configured default; select an explicitly supported PDF-capable model when passing a PDF.\n\nStart with the [complete file-processing examples](/guides/ai-file-processing-workflows/) for invoice JSON, PDF questions, recording summaries, and image descriptions. For a longer invoice application walkthrough, see the [document intelligence pipeline](/blog/2026/01/ai-document-intelligence-pipeline/).', + '## Analyze files with an LLM\n\nConnect an input Step explicitly with `use`. Text files are read into the conversation automatically. Use PDF, PNG, JPEG, GIF, or WebP. GIFs require a compatible Claude model, which sees the first frame. Convert other documents to PDF and transcribe recordings to text.\n\nFor OCR or transcription pipelines, choose `format: "text"` on the upstream Step, then reference that Step with `use` on `/ai/chat`. You do not need to interpolate the file contents into `messages`.\n\nThe `schema` parameter must be a **string containing JSON Schema**, not an inline object. Use `format: "json"` with a serialized schema for structured fields, or `format: "text"` for an answer file. Set `result: true` to expose that file in Assembly Status and download its `ssl_url` to read the answer. Result URLs are temporary; add an export Step for durable storage.\n\nFor production, we recommend using your own Anthropic, OpenAI, or Google account. Store the matching key as `anthropic_api_key`, `openai_api_key`, or `google_generative_ai_api_key` in a Template Credential of the AI Providers type and reference it with `credentials`. With your own account, you have your own provider limits and credits. The provider bills you directly, and Transloadit charges only its fee: 30% of the provider cost, with a minimum fee of $0.0005 per chat request.\n\nTransloadit’s shared provider accounts are a quick way to try things out with `test_credentials: true`. Their credits and capacity are shared by all customers, so your Step can be delayed or refused for reasons outside your control. With these accounts, Transloadit bills the provider cost plus a 30% fee, with a minimum fee of $0.0005 per chat request.\n\nWith either key source, Transloadit retries HTTP 429 limit responses and HTTP 5xx server errors up to twice per model request, waiting between attempts. If the provider keeps rejecting the request, the Step fails. Rejections returned as HTTP 400, 401, or 403 fail without retrying. The minimum fee applies once across the chat request’s model calls. When the Step’s regular data volume charge is higher than the pricing above, that applies instead.\n\nThe example uses the Template Credential `my_anthropic_credentials`. Fileless and text-only requests keep the configured default with `model: "auto"`. For PDFs from `use`, it selects Anthropic or Gemini. PDFs and images prefer compatible customer keys, then shared keys enabled by `test_credentials: true` at the shared rate.\n\nStart with the [complete file-processing examples](/guides/ai-file-processing-workflows/) for invoice JSON, PDF questions, recording summaries, and image descriptions. For a longer invoice application walkthrough, see the [document intelligence pipeline](/blog/2026/01/ai-document-intelligence-pipeline/).', ), - // NOTE: model:"auto" is resolved server-side to AI_CHAT_DEFAULT_MODEL for now. model: z .union([vendorModelSchema, z.literal('auto')]) .default('auto') .describe( - 'The model to use. The default, "auto", uses Transloadit\'s configured default model; it does not select a model based on the attached file. Choose a model that supports your input files.', + '`auto` keeps the default model for fileless or text-only requests. For PDFs and images from `use`, it prefers compatible customer keys over enabled shared keys. Unsupported-only bundles are skipped. An admitted bundle with an unsupported file fails with `AI_CHAT_VALIDATION`.', ), format: z.enum(['json', 'text', 'meta']).default('json'), return_messages: z.enum(['all', 'last']).default('last'), diff --git a/packages/node/src/alphalib/types/robots/document-extract.ts b/packages/node/src/alphalib/types/robots/document-extract.ts index 7f46bd60..e628f499 100644 --- a/packages/node/src/alphalib/types/robots/document-extract.ts +++ b/packages/node/src/alphalib/types/robots/document-extract.ts @@ -19,9 +19,11 @@ import { const extractTargets = z.enum(['text', 'images']) const imageFormats = z.enum(['auto', 'original', 'png', 'jpg']) const ocrProviders = z.enum(['aws', 'gcp']) -const textFormats = z.enum(['txt', 'json', 'md', 'html']) +const textFormats = z.enum(['txt', 'json', 'md', 'html', 'json_layout']) +/** OCR supports the legacy text formats, without native-layout JSON. */ +export const documentExtractOcrTextFormats = textFormats.exclude(['json_layout']) const textGranularities = z.enum(['document', 'page']) -const textMethods = z.enum(['native', 'ocr', 'auto']) +const textMethods = z.enum(['native', 'ocr', 'auto', 'docling']) /** Validate OCR dependencies after interpolation-aware parsing at the Assembly Step boundary. */ export function refineDocumentExtractOcr( @@ -29,15 +31,49 @@ export function refineDocumentExtractOcr( robot: string extract?: unknown text_method?: unknown + text_format?: unknown ocr_provider?: unknown password?: unknown page_range?: unknown text_granularity?: unknown + image_format?: unknown + include_image_masks?: unknown }, context: z.RefinementCtx, options: { allowInterpolation?: boolean } = {}, ): void { if (step.robot !== '/document/extract') return + if (step.text_method === 'docling') { + for (const key of ['password', 'ocr_provider'] as const) { + if ( + step[key] !== undefined && + step[key] !== '' && + !( + options.allowInterpolation !== false && + interpolationSchemaFull.safeParse(step[key]).success + ) + ) { + context.addIssue({ + code: z.ZodIssueCode.custom, + path: [key], + message: `The ${key} parameter is not supported with text_method docling.`, + }) + } + } + if (step.image_format === 'original' || step.image_format === 'jpg') + context.addIssue({ + code: z.ZodIssueCode.custom, + path: ['image_format'], + message: 'The docling text_method renders figures as PNG.', + }) + if (step.include_image_masks === true) + context.addIssue({ + code: z.ZodIssueCode.custom, + path: ['include_image_masks'], + message: 'The docling text_method does not retain image masks.', + }) + return + } if (step.text_method !== 'ocr' && step.text_method !== 'auto') return // Image-only extraction never invokes OCR; unresolved targets are checked at runtime. @@ -47,6 +83,14 @@ export function refineDocumentExtractOcr( (Array.isArray(step.extract) && step.extract.includes('text')) if (!extractsText) return + if (step.text_format === 'json_layout') { + context.addIssue({ + code: z.ZodIssueCode.custom, + path: ['text_format'], + message: 'The json_layout text_format requires text_method native.', + }) + } + if (step.ocr_provider === undefined) { context.addIssue({ code: z.ZodIssueCode.custom, @@ -146,18 +190,19 @@ Optional comma-separated page selection, such as \`"1"\`, \`"1-3"\`, or \`"1,3-5 At most 1,000 selected pages are allowed per job. -This is supported for native text extraction and embedded image extraction. OCR extraction currently works on the full document. +This is supported for native extraction and the self-hosted Docling method. The AWS and GCP OCR methods currently work on the full document. `), password: z .string() .optional() .describe(` -Password used to unlock encrypted PDFs for native text extraction and embedded image extraction. OCR extraction currently does not support encrypted PDFs, so do not combine this with \`text_method: "ocr"\` or \`text_method: "auto"\`. +Password used to unlock encrypted PDFs for native text extraction and embedded image extraction. The other text methods do not support encrypted PDFs. `), text_method: textMethods.default('native').describe(` Controls how text is extracted. - \`"native"\` extracts selectable PDF text locally with Poppler. This is fast, but returns little or no text for scanned PDFs. +- \`"docling"\` uses Transloadit’s self-hosted parser for layout, tables, figures, and OCR on scanned regions, including mixed native/scanned documents. No external document-processing service is used. This opt-in method requires an enabled deployment, supports page selection and page granularity, and does not accept \`password\` or \`ocr_provider\`. Figures are rendered as PNG; original embedded-image encodings and masks are not retained. Recognition and inferred structure can be incorrect. - \`"ocr"\` delegates to \`/document/ocr\` and requires \`ocr_provider\`. - \`"auto"\` tries native extraction first, then falls back to OCR when no native text is found, or when the native text is unusable because most of its words are spelled as separate letters (\`s p a c e c r a f t\`), as in the text layer of some old scans. This also requires \`ocr_provider\`. @@ -169,11 +214,15 @@ OCR provider to use when \`text_method\` is \`"ocr"\` or \`"auto"\`. Valid value text_format: textFormats.default('txt').describe(` Output format for extracted text. Plain text and JSON retain the existing extraction behavior. Markdown and HTML output are in beta and infer basic structure from native text positions and font sizes. -Native Markdown and HTML extraction limits layout data to 8 MiB per input document, summed across its selected page ranges. For larger documents, use separate extraction Steps with fewer pages in each Step’s \`page_range\`. +With \`text_method: "docling"\`, all text formats use the self-hosted parser’s reading order and OCR. Its \`json_layout\` also includes page dimensions, block IDs, source labels, top-left-origin bounding boxes in PDF points, and table cells with zero-based offsets and merged-cell spans. HTML preserves spans and Markdown flattens them. Figures are PNG crops referenced by result name. This method accepts up to 64 MiB of input and PDFs containing at most 1,000 pages, including when selecting a page range and fails incomplete conversions. Recognition and inferred structure can be incorrect; confidence scores and field-level citations are not reported. + +\`"json_layout"\` returns a JSON file containing \`schema_version: 1\` and a \`pages\` array. Each page has its original one-based \`page\` number and a \`blocks\` array. Block \`kind\` is \`"paragraph"\` (\`text\`), \`"heading"\` (\`text\`, \`level\`), \`"list"\` (\`ordered\`, \`start\`, \`items\`), \`"table"\` (\`rows\`, \`header\`) or \`"image"\` (\`name\`). Text is literal, without Markdown or HTML escaping. Image names match retained extraction results and must be saved alongside the JSON file. Images omitted from rich-text references are also omitted from these blocks. With native extraction, this format uses the same beta layout inference as Markdown and HTML and requires \`text_method: "native"\`. Native output does not report bounding boxes, confidence scores or field-level citations. The existing \`"json"\` format remains text and page text only. + +Native Markdown, HTML and \`json_layout\` extraction limits layout data to 8 MiB per input document, summed across its selected page ranges. For larger documents, use separate extraction Steps with fewer pages in each Step’s \`page_range\`. If native extraction cannot confirm the reading order of bidirectional text, it returns a validation error. Try fewer pages or use \`text_method: "ocr"\` with an OCR provider. -When \`extract\` includes images, Markdown and HTML reference retained image results inline using relative, URL-encoded filenames matching each image result’s \`name\`. Save the text and image results together to resolve the references. Filtered images have no references; repeated images can reference the same deduplicated result. Images covering the whole page, including page scans, are omitted from references when their visible coverage can be confirmed, while remaining available as image results. This also applies to pages without extracted text; use \`text_method: "ocr"\` with an OCR provider to read scanned text. Images with unavailable or inconsistent positions, including retained image masks, are appended after their page’s text. Embedded base64 images are not produced. +For native extraction, when \`extract\` includes images, Markdown and HTML reference retained image results inline using relative, URL-encoded filenames matching each image result’s \`name\`. Save the text and image results together to resolve the references. Filtered images have no references; repeated images can reference the same deduplicated result. Images covering the whole page, including page scans, are omitted from references when their visible coverage can be confirmed, while remaining available as image results. This also applies to pages without extracted text; use \`text_method: "ocr"\` with an OCR provider to read scanned text. Images with unavailable or inconsistent positions, including retained image masks, are appended after their page’s text. Embedded base64 images are not produced. When exporting, preserve result names in a shared directory per input document. For example, set \`/s3/store\`’s \`path\` to \`"\${assembly.id}/\${file.original_id}/\${file.name}"\`. Default storage paths using \`\${unique_prefix}/\${file.url_name}\` separate and rename files, so they do not preserve these relative image links. @@ -182,15 +231,35 @@ Some native image encodings cannot be displayed by browsers or Markdown viewers. OCR Markdown and HTML with \`ocr_provider: "aws"\` infer paragraphs, lists and headings from the positions of the recognized lines and words. With \`ocr_provider: "gcp"\`, which does not report those positions, they preserve readable text with minimal structure detection. In both cases, extracted images are appended in source order, since OCR does not position them. `), text_granularity: textGranularities.default('document').describe(` -Controls text output grouping for native extraction. +Controls text output grouping for native extraction and the self-hosted Docling method. - \`"document"\` creates one text result for the selected pages. - \`"page"\` creates one text result per selected page. -Page granularity is currently only supported with \`text_method: "native"\`. +Page granularity is supported with \`text_method: "native"\` or \`text_method: "docling"\`. +`), + keep_page_footers: z + .boolean() + .default(false) + .describe(` +Retain recurring footer text, including page numbers, in native Markdown, HTML and \`json_layout\` output, and AWS OCR Markdown and HTML output. By default, recurring text in the bottom 8% of selected pages is omitted when it appears on at least half of the selected pages, with a minimum of two pages. One-off margin text is retained regardless of this setting. + +With \`text_method: "docling"\`, this setting instead retains blocks classified as page headers or footers by the parser, in every text format. This classification can be incorrect and does not require repetition across pages. + +For native and cloud OCR extraction, this setting does not change plain text, legacy \`json\` or extracted image results. GCP OCR and OCR results without usable geometry already retain all recognized text. +`), + keep_page_headers: z + .boolean() + .default(false) + .describe(` +Retain recurring header text in native Markdown, HTML and \`json_layout\` output, and AWS OCR Markdown and HTML output. By default, recurring text in the top 8% of selected pages is omitted when it appears on at least half of the selected pages, with a minimum of two pages. Enable this when recurring headers contain document IDs or other context you need to retain. + +With \`text_method: "docling"\`, this setting instead retains blocks classified as page headers or footers by the parser, in every text format. This classification can be incorrect and does not require repetition across pages. + +For native and cloud OCR extraction, this setting does not change plain text, legacy \`json\` or extracted image results. GCP OCR and OCR results without usable geometry already retain all recognized text. `), image_format: imageFormats.default('auto').describe(` -Output format for extracted embedded raster images. +Output format for extracted embedded raster images. With \`text_method: "docling"\`, \`auto\` and \`png\` both return rendered PNG figure crops; \`original\` and \`jpg\` are unsupported. - \`"auto"\` and \`"original"\` preserve the embedded image format where possible. - \`"png"\` asks Poppler to decode images as PNG. diff --git a/packages/node/src/alphalib/types/robots/video-encode.ts b/packages/node/src/alphalib/types/robots/video-encode.ts index c7693ead..1ec7361d 100644 --- a/packages/node/src/alphalib/types/robots/video-encode.ts +++ b/packages/node/src/alphalib/types/robots/video-encode.ts @@ -104,6 +104,7 @@ See the [live text overlay demo](/demos/video-encoding/add-text-overlay/). const hiddenFields = { chunked_transcoding: z.boolean().optional(), freeze_detect: z.boolean().optional(), + normalize_hdr: z.boolean().default(false), realtime: z.boolean().optional(), } diff --git a/packages/node/src/alphalib/types/robots/video-ondemand.ts b/packages/node/src/alphalib/types/robots/video-ondemand.ts index d2d0ae96..4e740473 100644 --- a/packages/node/src/alphalib/types/robots/video-ondemand.ts +++ b/packages/node/src/alphalib/types/robots/video-ondemand.ts @@ -115,6 +115,7 @@ const hiddenFields = { .describe( 'Internal parameter that indicates whether `cdn=required` should be added to the URLs in playlists. Useful for testing with URL Transform directly and not through Smart CDN.', ), + normalize_hdr: z.boolean().default(false), url_transform_format: z .boolean() .optional() diff --git a/packages/node/src/alphalib/types/storageAsset.ts b/packages/node/src/alphalib/types/storageAsset.ts index 53964d13..bf81334c 100644 --- a/packages/node/src/alphalib/types/storageAsset.ts +++ b/packages/node/src/alphalib/types/storageAsset.ts @@ -104,6 +104,28 @@ export const damAssetsListOptionsSchema = z.object( ), ) +/** Recursive folder discovery uses bounded prefix, name and path-cursor options. */ +export const damFoldersListOptionsSchema = z.object({ + prefix: boundedPathSchema.default(''), + cursor: boundedPathSchema.min(1).optional(), + limit: z.number().int().min(1).max(500).default(100), + search: damAssetsListOptionsSchema.shape.search, +}) + +/** A live folder, with a Workspace-relative path without a trailing slash. */ +export const storedFolderSchema = z.object({ path: z.string().min(1) }) + +/** A bounded page of live folders, including empty folders, in case-sensitive path order. */ +export const damFoldersListedResponseSchema = z + .object({ + ok: z.literal('DAM_FOLDERS_LISTED'), + message: z.string().min(1), + workspace: z.string().min(1), + folders: z.array(storedFolderSchema), + next_cursor: z.string().min(1).nullable(), + }) + .strict() + /** An omitted version selects the current version; an explicit version never falls back. */ export const damAssetGetOptionsSchema = z.object({ version_id: describeApiParameter( diff --git a/packages/node/src/cli/stepsInput.ts b/packages/node/src/cli/stepsInput.ts index b242beeb..b2153780 100644 --- a/packages/node/src/cli/stepsInput.ts +++ b/packages/node/src/cli/stepsInput.ts @@ -29,6 +29,7 @@ interface PreviousContract { * current contract. */ const previousContract: ReadonlyMap = new Map([ + ['/document/extract', { added: ['keep_page_footers', 'keep_page_headers'] }], ['/document/thumbs', { apply: { imagemagick_stack: 'v2.0.10' } }], ['/file/serve', { added: ['download'] }], ['/image/enhance', { apply: { imagemagick_stack: 'v2.0.10' } }], diff --git a/packages/node/test/unit/ai-chat.test.ts b/packages/node/test/unit/ai-chat.test.ts index 0772422f..00f1131c 100644 --- a/packages/node/test/unit/ai-chat.test.ts +++ b/packages/node/test/unit/ai-chat.test.ts @@ -12,8 +12,8 @@ describe('/ai/chat message schema', () => { 'anthropic/claude-opus-5-5', 'anthropic/claude-opus-5', 'anthropic/claude-fable-5-1', - ])('accepts %s with image and PDF capabilities', (model) => { - expect(MODEL_CAPABILITIES[model]).toEqual({ image: true, pdf: true }) + ])('accepts %s with image, GIF and PDF capabilities', (model) => { + expect(MODEL_CAPABILITIES[model]).toEqual({ image: true, gif: true, pdf: true }) expect( robotAiChatInstructionsSchema.parse({ robot: '/ai/chat', diff --git a/packages/node/test/unit/cli/previous-step-defaults.test.ts b/packages/node/test/unit/cli/previous-step-defaults.test.ts index df092689..06765cce 100644 --- a/packages/node/test/unit/cli/previous-step-defaults.test.ts +++ b/packages/node/test/unit/cli/previous-step-defaults.test.ts @@ -59,6 +59,22 @@ describe('contract defaults within this major', () => { expect(await syncNewTemplate(previous.input.steps)).toEqual(previous.templatesSync) }) + it('omits new page margin flags when signing and syncing unchanged PDF Steps', async () => { + const steps = { extracted: { robot: '/document/extract', use: ':original' } } + const signed = await signParams({ auth: { expires: '2030-01-01T00:00:00.000Z' }, steps }) + const synced = await syncNewTemplate(steps) + const signedStep = JSON.parse(signed.params).steps.extracted + const writtenStep = JSON.parse(synced.writtenFile).steps.extracted + + expect(signedStep).not.toHaveProperty('keep_page_headers') + expect(signedStep).not.toHaveProperty('keep_page_footers') + expect(writtenStep).toEqual(signedStep) + expect(synced.createTemplate).toEqual({ + name: 'golden', + template: { steps: { extracted: signedStep } }, + }) + }) + it('passes explicit values for the changed defaults through unchanged', async () => { const steps = { generated: { robot: '/image/generate', prompt: 'a cat', inpainting: 'strict' }, @@ -68,6 +84,12 @@ describe('contract defaults within this major', () => { resized: { robot: '/image/resize', use: 'generated', imagemagick_stack: 'v2.0.11' }, enhanced: { robot: '/image/enhance', use: 'generated', imagemagick_stack: 'v3' }, thumbnailed: { robot: '/document/thumbs', use: ':original', imagemagick_stack: 'v3.0.2' }, + extracted: { + robot: '/document/extract', + use: ':original', + keep_page_headers: true, + keep_page_footers: false, + }, } const expected = { steps: Object.fromEntries(