/** * GoalsCheckinService — per-goal check-in engine on the scheduling spine. * * Goal check-ins are plain `ScheduledTask` records (`kind: "checkin"`) on * `@elizaos/plugin-scheduling`'s runner, created idempotently per goal + * cadence slot and fired by the production tick/dispatcher like every other * scheduled task. This service owns three seams: * * - `syncGoalCheckins(goal)` — reconcile the goal's check-in tasks with its * current status + cadence (create missing slots, edit changed triggers, * dismiss slots the cadence no longer declares). Called by `GoalsService` * after every goal write via the `checkinSync` hook, and once per goal at * boot. * - `removeGoalCheckins(goalId)` — dismiss all live check-in tasks for a * deleted goal. * - `recordCheckinResponse(args)` — route an owner check-in response into * goal progress: complete the fired task, append a bounded * `metadata.checkinLog` entry, set `reviewState` from the reported * progress, and write a `goal_updated` audit event. * * Cron slots use the `owner_local` tz sentinel so check-ins fire at the * owner's local hour wherever they are (resolved by the spine against * owner facts). * * Deliberate non-features: a slot the owner dismissed is never resurrected * for the same trigger shape (spine seed semantics); a goal with no cadence * (or an unusable one) schedules no check-ins — that is logged, not padded * with invented defaults. */ import type { LifeOpsGoalDefinition } from "@elizaos/contracts"; import { type IAgentRuntime, Service } from "@elizaos/core"; import { type ScheduledTask, type ScheduledTaskInput, type ScheduledTaskTrigger } from "@elizaos/plugin-scheduling"; import type { GoalsCheckinSync } from "../goals-service.js"; /** `createdBy` stamp identifying check-in tasks this engine owns. */ export declare const GOAL_CHECKIN_CREATED_BY = "@elizaos/plugin-goals"; /** Dismissal reason recorded when a cadence change retires a slot. */ export declare const GOAL_CHECKIN_SYNC_DISMISS_REASON = "goal_checkin_sync"; /** Reason recorded when sync reopens a once check-in it had dismissed. */ export declare const GOAL_CHECKIN_SYNC_REOPEN_REASON = "goal_checkin_sync_reopen"; /** Bounded length of the per-goal `metadata.checkinLog` history. */ export declare const GOAL_CHECKIN_LOG_LIMIT = 50; /** Progress states an owner check-in response may assign to a goal. */ export declare const GOAL_CHECKIN_PROGRESS_STATES: readonly ["on_track", "at_risk", "needs_attention"]; export type GoalCheckinProgress = (typeof GOAL_CHECKIN_PROGRESS_STATES)[number]; export interface GoalCheckinPlan { /** Stable slot identity within the goal (part of the idempotency key). */ slotKey: string; trigger: ScheduledTaskTrigger; } export declare function checkinIdempotencyKey(goalId: string, slotKey: string): string; /** * Map a goal's cadence (`LifeOpsCadence`-shaped `Record`) to concrete * check-in trigger slots. Pure; validated field-by-field because * `LifeOpsGoalDefinition.cadence` is persisted as an untyped record. * Unusable cadences yield `[]` and a warning — never an invented default. */ export declare function checkinTriggersForGoal(goal: LifeOpsGoalDefinition): GoalCheckinPlan[]; /** * Build the spine task input for one goal check-in slot. `nowIso` becomes * `metadata.createdAtIso` — the cron due-scan base — so a fresh check-in * never "catches up" an occurrence from before the slot existed. */ export declare function buildCheckinTaskInput(goal: LifeOpsGoalDefinition, plan: GoalCheckinPlan, nowIso: string): ScheduledTaskInput; export interface GoalCheckinSyncResult { scheduled: ScheduledTask[]; edited: ScheduledTask[]; dismissedTaskIds: string[]; } export interface RecordGoalCheckinArgs { goalId: string; /** Specific fired task to complete; defaults to the latest fired one. */ taskId?: string; note?: string; progress?: GoalCheckinProgress; } export interface GoalCheckinLogEntry { atIso: string; taskId: string | null; note: string | null; progress: GoalCheckinProgress | null; } export declare class GoalsCheckinService extends Service implements GoalsCheckinSync { static readonly serviceType: "goals_checkin"; capabilityDescription: string; private repositoryInstance; private warnedSpineMissing; private stopping; private releaseStop; private readonly stopRequested; private reconciliation?; private readonly now; constructor(runtime?: IAgentRuntime, now?: () => Date); static start(runtime: IAgentRuntime): Promise; stop(): Promise; private rt; private repository; private runner; /** * The spine is a declared plugin dependency, so in production this is * always true. Test/minimal runtimes without `@elizaos/plugin-scheduling` * get goal CRUD without scheduled check-ins — warned once, not silent. */ private spineAvailable; private listGoalTasks; /** * Reconcile one goal's check-in tasks with its current status + cadence. * Idempotent: unchanged slots are left untouched (spine idempotency-key * dedupe), changed triggers are edited in place, retired slots are * dismissed, and a slot the owner already dismissed stays dismissed. */ syncGoalCheckins(goal: LifeOpsGoalDefinition): Promise; /** Dismiss all live check-in tasks for a deleted goal. */ removeGoalCheckins(goalId: string): Promise<{ dismissedTaskIds: string[]; }>; /** * Route an owner check-in response into goal progress: complete the fired * check-in task (when one is live), append a bounded `checkinLog` entry to * the goal's metadata, set `reviewState` from the reported progress, and * write a `goal_updated` audit event. */ recordCheckinResponse(args: RecordGoalCheckinArgs): Promise<{ goal: LifeOpsGoalDefinition; completedTaskId: string | null; }>; /** * Boot reconcile: once the runtime finished initializing, sync every goal * so pre-existing goals (created before this engine, or while the spine * was unavailable) get their check-in tasks. Failures are logged, not * fatal — every subsequent goal write re-syncs its own goal. */ private reconcileWhenReady; } export declare function getGoalsCheckinService(runtime: IAgentRuntime): GoalsCheckinService | null; //# sourceMappingURL=checkin.d.ts.map