From cca513e2abea5f5def2f20f35a5afbdd66b9c239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Dr=C4=83gan=20R=C4=83dule=C8=9B?= Date: Thu, 16 Jul 2026 20:59:42 +0200 Subject: [PATCH] feat(contracts): add ChatFileAttachment variant to attachment unions Additive union member: existing image rows/drafts decode unchanged. Limits shared with images (10 MB, 8 per message). Co-Authored-By: Claude Fable 5 --- packages/contracts/src/orchestration.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts index c0c9c62d08..5d35e2c59f 100644 --- a/packages/contracts/src/orchestration.ts +++ b/packages/contracts/src/orchestration.ts @@ -173,9 +173,29 @@ const UploadChatImageAttachment = Schema.Struct({ }); export type UploadChatImageAttachment = typeof UploadChatImageAttachment.Type; -export const ChatAttachment = Schema.Union([ChatImageAttachment]); +export const ChatFileAttachment = Schema.Struct({ + type: Schema.Literal("file"), + id: ChatAttachmentId, + name: TrimmedNonEmptyString.check(Schema.isMaxLength(255)), + mimeType: TrimmedNonEmptyString.check(Schema.isMaxLength(100)), + sizeBytes: NonNegativeInt.check(Schema.isLessThanOrEqualTo(PROVIDER_SEND_TURN_MAX_IMAGE_BYTES)), +}); +export type ChatFileAttachment = typeof ChatFileAttachment.Type; + +const UploadChatFileAttachment = Schema.Struct({ + type: Schema.Literal("file"), + name: TrimmedNonEmptyString.check(Schema.isMaxLength(255)), + mimeType: TrimmedNonEmptyString.check(Schema.isMaxLength(100)), + sizeBytes: NonNegativeInt.check(Schema.isLessThanOrEqualTo(PROVIDER_SEND_TURN_MAX_IMAGE_BYTES)), + dataUrl: TrimmedNonEmptyString.check( + Schema.isMaxLength(PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS), + ), +}); +export type UploadChatFileAttachment = typeof UploadChatFileAttachment.Type; + +export const ChatAttachment = Schema.Union([ChatImageAttachment, ChatFileAttachment]); export type ChatAttachment = typeof ChatAttachment.Type; -const UploadChatAttachment = Schema.Union([UploadChatImageAttachment]); +const UploadChatAttachment = Schema.Union([UploadChatImageAttachment, UploadChatFileAttachment]); export type UploadChatAttachment = typeof UploadChatAttachment.Type; export const ProjectScriptIcon = Schema.Literals([