background agent 2

This commit is contained in:
Arjun 2026-02-04 15:55:42 +05:30
parent eef7e1d508
commit 7791541f30
8 changed files with 431 additions and 47 deletions

View file

@ -5,8 +5,9 @@ export const AgentScheduleStatus = z.enum(["scheduled", "running", "finished", "
export const AgentScheduleStateEntry = z.object({
status: AgentScheduleStatus,
lastRunAt: z.string().datetime().nullable(),
nextRunAt: z.string().datetime().nullable(),
startedAt: z.string().nullable(), // When current run started (for timeout detection)
lastRunAt: z.string().nullable(), // ISO 8601 local datetime
nextRunAt: z.string().nullable(), // ISO 8601 local datetime
lastError: z.string().nullable(),
runCount: z.number().default(0),
});

View file

@ -24,10 +24,10 @@ export const WindowSchedule = z.object({
// Once schedule - runs exactly once at a specific time, then never again.
// Examples:
// - Run once at specific datetime: runAt="2024-02-05T10:30:00Z"
// - Run once at specific datetime: runAt="2024-02-05T10:30:00"
export const OnceSchedule = z.object({
type: z.literal("once"),
runAt: z.string().datetime(), // ISO 8601 datetime
runAt: z.string(), // ISO 8601 datetime (local time, e.g., "2024-02-05T10:30:00")
});
export const ScheduleDefinition = z.union([CronSchedule, WindowSchedule, OnceSchedule]);
@ -35,6 +35,7 @@ export const ScheduleDefinition = z.union([CronSchedule, WindowSchedule, OnceSch
export const AgentScheduleEntry = z.object({
schedule: ScheduleDefinition,
enabled: z.boolean().optional().default(true),
startingMessage: z.string().optional(), // Message sent to agent when run starts (defaults to "go")
});
export const AgentScheduleConfig = z.object({