@@ -186,7 +186,11 @@ export function registerCronEditCommand(cron: Command) {
186186 patch . sessionTarget = sessionTarget ;
187187 }
188188 if ( typeof opts . wake === "string" ) {
189- patch . wakeMode = opts . wake ;
189+ const wakeMode = opts . wake . trim ( ) ;
190+ if ( wakeMode !== "now" && wakeMode !== "next-heartbeat" ) {
191+ throw new Error ( "--wake must be now or next-heartbeat" ) ;
192+ }
193+ patch . wakeMode = wakeMode ;
190194 }
191195 if ( opts . agent && opts . clearAgent ) {
192196 throw new Error ( "Use --agent or --clear-agent, not both" ) ;
@@ -229,10 +233,20 @@ export function registerCronEditCommand(cron: Command) {
229233 const model = normalizeOptionalString ( opts . model ) ;
230234 const thinking = normalizeOptionalString ( opts . thinking ) ;
231235 const toolsAllow = parseCronToolsAllow ( opts . tools ) ;
232- const timeoutSeconds = opts . timeoutSeconds
233- ? Number . parseInt ( String ( opts . timeoutSeconds ) , 10 )
234- : undefined ;
235- const hasTimeoutSeconds = Boolean ( timeoutSeconds && Number . isFinite ( timeoutSeconds ) ) ;
236+ const rawTimeoutSeconds =
237+ opts . timeoutSeconds === undefined ? undefined : String ( opts . timeoutSeconds ) . trim ( ) ;
238+ if ( rawTimeoutSeconds !== undefined && ! / ^ \d + $ / u. test ( rawTimeoutSeconds ) ) {
239+ throw new Error ( "Invalid --timeout-seconds (must be a positive integer)." ) ;
240+ }
241+ const timeoutSeconds =
242+ rawTimeoutSeconds === undefined ? undefined : Number ( rawTimeoutSeconds ) ;
243+ const hasTimeoutSeconds =
244+ typeof timeoutSeconds === "number" &&
245+ Number . isSafeInteger ( timeoutSeconds ) &&
246+ timeoutSeconds > 0 ;
247+ if ( rawTimeoutSeconds !== undefined && ! hasTimeoutSeconds ) {
248+ throw new Error ( "Invalid --timeout-seconds (must be a positive integer)." ) ;
249+ }
236250 const hasDeliveryModeFlag = opts . announce || typeof opts . deliver === "boolean" ;
237251 const threadId = parseCronThreadIdOption ( opts . threadId ) ;
238252 const hasDeliveryThreadId = typeof threadId === "number" ;
0 commit comments