

























@@ -156,7 +156,17 @@ const CRON_DELIVERY_PAD = 64;
156156const CRON_AGENT_PAD = 10;
157157const CRON_MODEL_PAD = 20;
158158159-const pad = (value: string, width: number) => value.padEnd(width);
159+const stringifyCell = (value: unknown, fallback = "-") => {
160+if (typeof value === "string") {
161+return value;
162+}
163+if (typeof value === "number" || typeof value === "boolean") {
164+return String(value);
165+}
166+return fallback;
167+};
168+169+const pad = (value: unknown, width: number) => stringifyCell(value).padEnd(width);
160170161171const truncate = (value: string, width: number) => {
162172if (value.length <= width) {
@@ -200,13 +210,16 @@ const formatRelative = (ms: number | null | undefined, nowMs: number) => {
200210return delta >= 0 ? `in ${label}` : `${label} ago`;
201211};
202212203-const formatSchedule = (schedule: CronSchedule) => {
204-if (schedule.kind === "at") {
213+const formatSchedule = (schedule: CronSchedule | undefined) => {
214+if (schedule?.kind === "at") {
205215return `at ${formatIsoMinute(schedule.at)}`;
206216}
207-if (schedule.kind === "every") {
217+if (schedule?.kind === "every") {
208218return `every ${formatDurationHuman(schedule.everyMs)}`;
209219}
220+if (schedule?.kind !== "cron") {
221+return "-";
222+}
210223const base = schedule.tz ? `cron ${schedule.expr} @ ${schedule.tz}` : `cron ${schedule.expr}`;
211224const staggerMs = resolveCronStaggerMs(schedule);
212225if (staggerMs <= 0) {
@@ -219,10 +232,11 @@ const formatStatus = (job: CronJob) => {
219232if (!job.enabled) {
220233return "disabled";
221234}
222-if (job.state.runningAtMs) {
235+const state = job.state ?? {};
236+if (state.runningAtMs) {
223237return "running";
224238}
225-return job.state.lastStatus ?? "idle";
239+return state.lastStatus ?? "idle";
226240};
227241228242export function coerceCronDeliveryPreviews(value: unknown): Map<string, CronDeliveryPreview> {
@@ -275,17 +289,18 @@ export function printCronList(
275289const now = Date.now();
276290277291for (const job of jobs) {
292+const state = job.state ?? {};
278293const idLabel = pad(job.id, CRON_ID_PAD);
279-const nameLabel = pad(truncate(job.name, CRON_NAME_PAD), CRON_NAME_PAD);
294+const nameLabel = pad(truncate(stringifyCell(job.name), CRON_NAME_PAD), CRON_NAME_PAD);
280295const scheduleLabel = pad(
281296truncate(formatSchedule(job.schedule), CRON_SCHEDULE_PAD),
282297CRON_SCHEDULE_PAD,
283298);
284299const nextLabel = pad(
285-job.enabled ? formatRelative(job.state.nextRunAtMs, now) : "-",
300+job.enabled ? formatRelative(state.nextRunAtMs, now) : "-",
286301CRON_NEXT_PAD,
287302);
288-const lastLabel = pad(formatRelative(job.state.lastRunAtMs, now), CRON_LAST_PAD);
303+const lastLabel = pad(formatRelative(state.lastRunAtMs, now), CRON_LAST_PAD);
289304const statusRaw = formatStatus(job);
290305const statusLabel = pad(statusRaw, CRON_STATUS_PAD);
291306const targetLabel = pad(job.sessionTarget ?? "-", CRON_TARGET_PAD);
@@ -297,7 +312,7 @@ export function printCronList(
297312const agentLabel = pad(truncate(job.agentId ?? "-", CRON_AGENT_PAD), CRON_AGENT_PAD);
298313const modelLabel = pad(
299314truncate(
300-(job.payload.kind === "agentTurn" ? job.payload.model : undefined) ?? "-",
315+(job.payload?.kind === "agentTurn" ? job.payload.model : undefined) ?? "-",
301316CRON_MODEL_PAD,
302317),
303318CRON_MODEL_PAD,
@@ -339,7 +354,7 @@ export function printCronList(
339354 ? colorize(rich, theme.info, deliveryLabel)
340355 : colorize(rich, theme.muted, deliveryLabel),
341356coloredAgent,
342-job.payload.kind === "agentTurn" && job.payload.model
357+job.payload?.kind === "agentTurn" && job.payload.model
343358 ? colorize(rich, theme.info, modelLabel)
344359 : colorize(rich, theme.muted, modelLabel),
345360].join(" ");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。