Skip to content

Commit f815fed

Browse files
committed
fix(computer-use): reject blank titles and malformed times in the app-command contract
1 parent 48b77a0 commit f815fed

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/desktop-bridge/src/computer-use.generated.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,16 @@ export const ComputerUseSchema = z.union([
230230
export type ComputerUseInput = z.infer<typeof ComputerUseSchema>;
231231

232232
/** Typed app commands: one allowlisted create or list read through the OS's own data frameworks, never a script. */
233-
const CommandTitle = z.string().min(1).max(1024);
233+
const CommandTitle = z
234+
.string()
235+
.max(1024)
236+
.refine((title) => title.trim().length > 0, "A title must not be blank");
237+
/** `YYYY-MM-DD`, or a date-time with optional seconds, fraction and offset; the helper checks it is a real date. */
238+
const ISO_DATE_OR_TIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:\d{2})?)?$/;
234239
const CommandNotes = z.string().max(8000).optional();
235240
const EventBoundary = z
236241
.string()
237-
.min(10)
238-
.max(64)
242+
.regex(ISO_DATE_OR_TIME, "Use YYYY-MM-DD or an ISO 8601 date-time")
239243
.describe(
240244
"ISO 8601 date-time, or YYYY-MM-DD when allDay is true. Without an offset it is this Mac's local time, as typing it into Calendar would be.",
241245
);
@@ -249,8 +253,7 @@ export const AppCommandSchema = z.discriminatedUnion("name", [
249253
notes: CommandNotes,
250254
due: z
251255
.string()
252-
.min(10)
253-
.max(64)
256+
.regex(ISO_DATE_OR_TIME, "Use YYYY-MM-DD or an ISO 8601 date-time")
254257
.optional()
255258
.describe(
256259
"YYYY-MM-DD for a date-only reminder, or an ISO 8601 date-time (this Mac's local time without an offset).",

0 commit comments

Comments
 (0)