Unified · Split
| @@ -59,17 +59,7 @@ export const PROVIDER_SEND_TURN_MAX_ATTACHMENTS = 8; · 58 unmodified lines | ||
| 59 | 59 | export const PROVIDER_SEND_TURN_MAX_IMAGE_BYTES = 10 * 1024 * 1024; |
| 60 | 60 | export const PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS = 14_000_000; |
| 61 | 61 | |
| 62 | −function validateImageDataUrl(value: { dataUrl: string }, ctx: z.RefinementCtx): void { | |
| 63 | − if (!value.dataUrl.startsWith("data:image/")) { | |
| 64 | − ctx.addIssue({ | |
| 65 | − code: z.ZodIssueCode.custom, | |
| 66 | − message: "Image dataUrl must start with data:image/", | |
| 67 | − path: ["dataUrl"], | |
| 68 | − }); | |
| 69 | − } | |
| 70 | −} | |
| 71 | − | |
| 72 | −const providerSendTurnImageAttachmentBaseSchema = z.object({ | |
| 62 | +export const providerSendTurnImageAttachmentSchema = z.object({ | |
| 73 | 63 | type: z.literal("image"), |
| 74 | 64 | name: z.string().trim().min(1).max(255), |
| 75 | 65 | mimeType: z |
| @@ -82,35 +72,30 @@ const providerSendTurnImageAttachmentBaseSchema = z.object({ · 6 unmodified lines | ||
| 82 | 72 | dataUrl: z.string().trim().min(1).max(PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS), |
| 83 | 73 | }); |
| 84 | 74 | |
| 85 | −export const providerSendTurnImageAttachmentInputSchema = | |
| 86 | − providerSendTurnImageAttachmentBaseSchema.superRefine(validateImageDataUrl); | |
| 87 | − | |
| 88 | 75 | export const providerSendTurnAttachmentInputSchema = z.discriminatedUnion("type", [ |
| 89 | − providerSendTurnImageAttachmentBaseSchema, | |
| 90 | −]).superRefine((value, ctx) => { | |
| 91 | − if (value.type === "image") { | |
| 92 | − validateImageDataUrl(value, ctx); | |
| 93 | − } | |
| 94 | −}); | |
| 76 | + providerSendTurnImageAttachmentSchema, | |
| 77 | +]); | |
| 95 | 78 | |
| 96 | −export const providerSendTurnInputSchema = z.object({ | |
| 97 | − sessionId: z.string().min(1), | |
| 98 | − input: z.string().trim().min(1).max(PROVIDER_SEND_TURN_MAX_INPUT_CHARS).optional(), | |
| 99 | − attachments: z | |
| 100 | − .array(providerSendTurnAttachmentInputSchema) | |
| 101 | − .max(PROVIDER_SEND_TURN_MAX_ATTACHMENTS) | |
| 102 | − .default([]), | |
| 103 | − model: z.string().trim().min(1).optional(), | |
| 104 | − effort: z.string().trim().min(1).optional(), | |
| 105 | −}).superRefine((value, ctx) => { | |
| 106 | − if (!value.input && value.attachments.length === 0) { | |
| 107 | − ctx.addIssue({ | |
| 108 | − code: z.ZodIssueCode.custom, | |
| 109 | − message: "Either input text or at least one attachment is required", | |
| 110 | − path: ["input"], | |
| 111 | − }); | |
| 112 | − } | |
| 113 | −}); | |
| 79 | +export const providerSendTurnInputSchema = z | |
| 80 | + .object({ | |
| 81 | + sessionId: z.string().min(1), | |
| 82 | + input: z.string().trim().min(1).max(PROVIDER_SEND_TURN_MAX_INPUT_CHARS).optional(), | |
| 83 | + attachments: z | |
| 84 | + .array(providerSendTurnAttachmentInputSchema) | |
| 85 | + .max(PROVIDER_SEND_TURN_MAX_ATTACHMENTS) | |
| 86 | + .default([]), | |
| 87 | + model: z.string().trim().min(1).optional(), | |
| 88 | + effort: z.string().trim().min(1).optional(), | |
| 89 | + }) | |
| 90 | + .superRefine((value, ctx) => { | |
| 91 | + if (!value.input && value.attachments.length === 0) { | |
| 92 | + ctx.addIssue({ | |
| 93 | + code: z.ZodIssueCode.custom, | |
| 94 | + message: "Either input text or at least one attachment is required", | |
| 95 | + path: ["input"], | |
| 96 | + }); | |
| 97 | + } | |
| 98 | + }); | |
| 114 | 99 | |
| 115 | 100 | export const providerTurnStartResultSchema = z.object({ |
| 116 | 101 | threadId: z.string().min(1), |
| @@ -159,8 +144,7 @@ export type ProviderApprovalDecision = z.infer<typeof providerApprovalDecisionSc · 42 unmodified lines | ||
| 159 | 144 | export type ProviderSessionStatus = z.infer<typeof providerSessionStatusSchema>; |
| 160 | 145 | export type ProviderSession = z.infer<typeof providerSessionSchema>; |
| 161 | 146 | export type ProviderSessionStartInput = z.input<typeof providerSessionStartInputSchema>; |
| 162 | −export type ProviderSendTurnImageAttachment = z.infer<typeof providerSendTurnImageAttachmentInputSchema>; | |
| 163 | −export type ProviderSendTurnImageAttachmentInput = z.input<typeof providerSendTurnImageAttachmentInputSchema>; | |
| 147 | +export type ProviderSendTurnImageAttachment = z.infer<typeof providerSendTurnImageAttachmentSchema>; | |
| 164 | 148 | export type ProviderSendTurnAttachment = z.infer<typeof providerSendTurnAttachmentInputSchema>; |
| 165 | 149 | export type ProviderSendTurnAttachmentInput = z.input<typeof providerSendTurnAttachmentInputSchema>; |
| 166 | 150 | export type ProviderSendTurnInput = z.input<typeof providerSendTurnInputSchema>; |