fix: align routine system with actual RoutineStore/Routine APIs to prevent CLI crash
The RoutineRunner and RoutineScheduler were written against a different interface than what RoutineStore actually implements, causing TypeError crashes as soon as any routine became due. This adds the missing agentId/catchUpLimit fields to the Routine type and DB schema, adds startRoutineExecution/completeRoutineExecution/cancelRoutineExecution methods to RoutineStore, and fixes all property name mismatches (lastExecutedAt→lastRunAt, trigger.cron→trigger.cronExpression, policy value alignment) in the runner, scheduler, and tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,8 @@ export interface RoutineExecutionResult extends AutomationRunResult {
|
||||
export interface Routine {
|
||||
/** Unique identifier (UUID). */
|
||||
id: string;
|
||||
/** ID of the agent that executes this routine. */
|
||||
agentId: string;
|
||||
/** Human-readable name. */
|
||||
name: string;
|
||||
/** Optional description of what this routine does. */
|
||||
@@ -129,6 +131,8 @@ export interface Routine {
|
||||
runCount: number;
|
||||
/** History of recent run results (most recent first, capped at MAX_ROUTINE_RUN_HISTORY). */
|
||||
runHistory: RoutineExecutionResult[];
|
||||
/** Maximum number of catch-up executions when policy is "run". */
|
||||
catchUpLimit?: number;
|
||||
/** Optional cron expression stored directly for due-routine queries (derived from trigger). */
|
||||
cronExpression?: string;
|
||||
/** ISO-8601 timestamp of when this routine was created. */
|
||||
@@ -143,6 +147,8 @@ export interface Routine {
|
||||
export interface RoutineCreateInput {
|
||||
/** Human-readable name. Required. */
|
||||
name: string;
|
||||
/** ID of the agent that executes this routine. Required. */
|
||||
agentId: string;
|
||||
/** Optional description. */
|
||||
description?: string;
|
||||
/** Trigger configuration. Required. */
|
||||
|
||||
Reference in New Issue
Block a user