@devries-cameron20 / t3code-1 / commits / 73bc60ef8a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

simp

Julius Marminge committed Feb 12, 2026 at 15:46 UTC 73bc60ef8a3c43126c40f317ec65ca38c0a045ba
1 file changed +24 -40
packages/contracts/src/provider.ts
+24 -40
@@ -59,17 +59,7 @@ export const PROVIDER_SEND_TURN_MAX_ATTACHMENTS = 8;
59 export const PROVIDER_SEND_TURN_MAX_IMAGE_BYTES = 10 * 1024 * 1024;
60 export const PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS = 14_000_000;
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({
63 type: z.literal("image"),
64 name: z.string().trim().min(1).max(255),
65 mimeType: z
@@ -82,35 +72,30 @@ const providerSendTurnImageAttachmentBaseSchema = z.object({
72 dataUrl: z.string().trim().min(1).max(PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS),
73 });
74
85 -export const providerSendTurnImageAttachmentInputSchema =
86 - providerSendTurnImageAttachmentBaseSchema.superRefine(validateImageDataUrl);
87 -
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 +]);
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 + });
99
100 export const providerTurnStartResultSchema = z.object({
101 threadId: z.string().min(1),
@@ -159,8 +144,7 @@ export type ProviderApprovalDecision = z.infer<typeof providerApprovalDecisionSc
144 export type ProviderSessionStatus = z.infer<typeof providerSessionStatusSchema>;
145 export type ProviderSession = z.infer<typeof providerSessionSchema>;
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>;
148 export type ProviderSendTurnAttachment = z.infer<typeof providerSendTurnAttachmentInputSchema>;
149 export type ProviderSendTurnAttachmentInput = z.input<typeof providerSendTurnAttachmentInputSchema>;
150 export type ProviderSendTurnInput = z.input<typeof providerSendTurnInputSchema>;